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 #ifdef 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 all (rxq|txq|rxd|txd) (value)\n"
810 " Set number for rxq/txq/rxd/txd.\n\n"
812 "port config all max-pkt-len (value)\n"
813 " Set the max packet length.\n\n"
815 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
816 "hw-vlan-strip|hw-vlan-extend|drop-en)"
818 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
821 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
822 "geneve|nvgre|none|<flowtype_id>)\n"
823 " Set the RSS mode.\n\n"
825 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
826 " Set the RSS redirection table.\n\n"
828 "port config (port_id) dcb vt (on|off) (traffic_class)"
830 " Set the DCB mode.\n\n"
832 "port config all burst (value)\n"
833 " Set the number of packets per burst.\n\n"
835 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
837 " Set the ring prefetch/host/writeback threshold"
838 " for tx/rx queue.\n\n"
840 "port config all (txfreet|txrst|rxfreet) (value)\n"
841 " Set free threshold for rx/tx, or set"
842 " tx rs bit threshold.\n\n"
843 "port config mtu X value\n"
844 " Set the MTU of port X to a given value\n\n"
846 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
847 " Start/stop a rx/tx queue of port X. Only take effect"
848 " when port X is started\n\n"
850 "port config (port_id|all) l2-tunnel E-tag ether-type"
852 " Set the value of E-tag ether-type.\n\n"
854 "port config (port_id|all) l2-tunnel E-tag"
855 " (enable|disable)\n"
856 " Enable/disable the E-tag support.\n\n"
858 "port config (port_id) pctype mapping reset\n"
859 " Reset flow type to pctype mapping on a port\n\n"
861 "port config (port_id) pctype mapping update"
862 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
863 " Update a flow type to pctype mapping item on a port\n\n"
865 "port config (port_id) pctype (pctype_id) hash_inset|"
866 "fdir_inset|fdir_flx_inset get|set|clear field\n"
868 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
870 "port config (port_id) pctype (pctype_id) hash_inset|"
871 "fdir_inset|fdir_flx_inset clear all"
872 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
876 if (show_all || !strcmp(res->section, "registers")) {
884 "read reg (port_id) (address)\n"
885 " Display value of a port register.\n\n"
887 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
888 " Display a port register bit field.\n\n"
890 "read regbit (port_id) (address) (bit_x)\n"
891 " Display a single port register bit.\n\n"
893 "write reg (port_id) (address) (value)\n"
894 " Set value of a port register.\n\n"
896 "write regfield (port_id) (address) (bit_x) (bit_y)"
898 " Set bit field of a port register.\n\n"
900 "write regbit (port_id) (address) (bit_x) (value)\n"
901 " Set single bit value of a port register.\n\n"
904 if (show_all || !strcmp(res->section, "filters")) {
912 "ethertype_filter (port_id) (add|del)"
913 " (mac_addr|mac_ignr) (mac_address) ethertype"
914 " (ether_type) (drop|fwd) queue (queue_id)\n"
915 " Add/Del an ethertype filter.\n\n"
917 "2tuple_filter (port_id) (add|del)"
918 " dst_port (dst_port_value) protocol (protocol_value)"
919 " mask (mask_value) tcp_flags (tcp_flags_value)"
920 " priority (prio_value) queue (queue_id)\n"
921 " Add/Del a 2tuple filter.\n\n"
923 "5tuple_filter (port_id) (add|del)"
924 " dst_ip (dst_address) src_ip (src_address)"
925 " dst_port (dst_port_value) src_port (src_port_value)"
926 " protocol (protocol_value)"
927 " mask (mask_value) tcp_flags (tcp_flags_value)"
928 " priority (prio_value) queue (queue_id)\n"
929 " Add/Del a 5tuple filter.\n\n"
931 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
932 " Add/Del syn filter.\n\n"
934 "flex_filter (port_id) (add|del) len (len_value)"
935 " bytes (bytes_value) mask (mask_value)"
936 " priority (prio_value) queue (queue_id)\n"
937 " Add/Del a flex filter.\n\n"
939 "flow_director_filter (port_id) mode IP (add|del|update)"
940 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
941 " src (src_ip_address) dst (dst_ip_address)"
942 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
943 " vlan (vlan_value) flexbytes (flexbytes_value)"
944 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
945 " fd_id (fd_id_value)\n"
946 " Add/Del an IP type flow director filter.\n\n"
948 "flow_director_filter (port_id) mode IP (add|del|update)"
949 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
950 " src (src_ip_address) (src_port)"
951 " dst (dst_ip_address) (dst_port)"
952 " tos (tos_value) ttl (ttl_value)"
953 " vlan (vlan_value) flexbytes (flexbytes_value)"
954 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
955 " fd_id (fd_id_value)\n"
956 " Add/Del an UDP/TCP type flow director filter.\n\n"
958 "flow_director_filter (port_id) mode IP (add|del|update)"
959 " flow (ipv4-sctp|ipv6-sctp)"
960 " src (src_ip_address) (src_port)"
961 " dst (dst_ip_address) (dst_port)"
962 " tag (verification_tag) "
963 " tos (tos_value) ttl (ttl_value)"
965 " flexbytes (flexbytes_value) (drop|fwd)"
966 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
967 " Add/Del a SCTP type flow director filter.\n\n"
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow l2_payload ether (ethertype)"
971 " flexbytes (flexbytes_value) (drop|fwd)"
972 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
973 " Add/Del a l2 payload type flow director filter.\n\n"
975 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
976 " mac (mac_address) vlan (vlan_value)"
977 " flexbytes (flexbytes_value) (drop|fwd)"
978 " queue (queue_id) fd_id (fd_id_value)\n"
979 " Add/Del a MAC-VLAN flow director filter.\n\n"
981 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
982 " mac (mac_address) vlan (vlan_value)"
983 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
984 " flexbytes (flexbytes_value) (drop|fwd)"
985 " queue (queue_id) fd_id (fd_id_value)\n"
986 " Add/Del a Tunnel flow director filter.\n\n"
988 "flow_director_filter (port_id) mode raw (add|del|update)"
989 " flow (flow_id) (drop|fwd) queue (queue_id)"
990 " fd_id (fd_id_value) packet (packet file name)\n"
991 " Add/Del a raw type flow director filter.\n\n"
993 "flush_flow_director (port_id)\n"
994 " Flush all flow director entries of a device.\n\n"
996 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
997 " src_mask (ipv4_src) (ipv6_src) (src_port)"
998 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
999 " Set flow director IP mask.\n\n"
1001 "flow_director_mask (port_id) mode MAC-VLAN"
1002 " vlan (vlan_value)\n"
1003 " Set flow director MAC-VLAN mask.\n\n"
1005 "flow_director_mask (port_id) mode Tunnel"
1006 " vlan (vlan_value) mac (mac_value)"
1007 " tunnel-type (tunnel_type_value)"
1008 " tunnel-id (tunnel_id_value)\n"
1009 " Set flow director Tunnel mask.\n\n"
1011 "flow_director_flex_mask (port_id)"
1012 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1013 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1015 " Configure mask of flex payload.\n\n"
1017 "flow_director_flex_payload (port_id)"
1018 " (raw|l2|l3|l4) (config)\n"
1019 " Configure flex payload selection.\n\n"
1021 "get_sym_hash_ena_per_port (port_id)\n"
1022 " get symmetric hash enable configuration per port.\n\n"
1024 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1025 " set symmetric hash enable configuration per port"
1026 " to enable or disable.\n\n"
1028 "get_hash_global_config (port_id)\n"
1029 " Get the global configurations of hash filters.\n\n"
1031 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1032 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1033 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1034 " (enable|disable)\n"
1035 " Set the global configurations of hash filters.\n\n"
1037 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1038 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1039 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1040 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1041 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1042 "ipv6-next-header|udp-src-port|udp-dst-port|"
1043 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1044 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1045 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1046 "fld-8th|none) (select|add)\n"
1047 " Set the input set for hash.\n\n"
1049 "set_fdir_input_set (port_id) "
1050 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1051 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1052 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1053 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1054 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1055 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1056 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1058 " Set the input set for FDir.\n\n"
1060 "flow validate {port_id}"
1061 " [group {group_id}] [priority {level}]"
1062 " [ingress] [egress]"
1063 " pattern {item} [/ {item} [...]] / end"
1064 " actions {action} [/ {action} [...]] / end\n"
1065 " Check whether a flow rule can be created.\n\n"
1067 "flow create {port_id}"
1068 " [group {group_id}] [priority {level}]"
1069 " [ingress] [egress]"
1070 " pattern {item} [/ {item} [...]] / end"
1071 " actions {action} [/ {action} [...]] / end\n"
1072 " Create a flow rule.\n\n"
1074 "flow destroy {port_id} rule {rule_id} [...]\n"
1075 " Destroy specific flow rules.\n\n"
1077 "flow flush {port_id}\n"
1078 " Destroy all flow rules.\n\n"
1080 "flow query {port_id} {rule_id} {action}\n"
1081 " Query an existing flow rule.\n\n"
1083 "flow list {port_id} [group {group_id}] [...]\n"
1084 " List existing flow rules sorted by priority,"
1085 " filtered by group identifiers.\n\n"
1087 "flow isolate {port_id} {boolean}\n"
1088 " Restrict ingress traffic to the defined"
1094 cmdline_parse_token_string_t cmd_help_long_help =
1095 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1097 cmdline_parse_token_string_t cmd_help_long_section =
1098 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1099 "all#control#display#config#"
1100 "ports#registers#filters");
1102 cmdline_parse_inst_t cmd_help_long = {
1103 .f = cmd_help_long_parsed,
1105 .help_str = "help all|control|display|config|ports|register|filters: "
1108 (void *)&cmd_help_long_help,
1109 (void *)&cmd_help_long_section,
1115 /* *** start/stop/close all ports *** */
1116 struct cmd_operate_port_result {
1117 cmdline_fixed_string_t keyword;
1118 cmdline_fixed_string_t name;
1119 cmdline_fixed_string_t value;
1122 static void cmd_operate_port_parsed(void *parsed_result,
1123 __attribute__((unused)) struct cmdline *cl,
1124 __attribute__((unused)) void *data)
1126 struct cmd_operate_port_result *res = parsed_result;
1128 if (!strcmp(res->name, "start"))
1129 start_port(RTE_PORT_ALL);
1130 else if (!strcmp(res->name, "stop"))
1131 stop_port(RTE_PORT_ALL);
1132 else if (!strcmp(res->name, "close"))
1133 close_port(RTE_PORT_ALL);
1134 else if (!strcmp(res->name, "reset"))
1135 reset_port(RTE_PORT_ALL);
1137 printf("Unknown parameter\n");
1140 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1141 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1143 cmdline_parse_token_string_t cmd_operate_port_all_port =
1144 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1145 "start#stop#close#reset");
1146 cmdline_parse_token_string_t cmd_operate_port_all_all =
1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1149 cmdline_parse_inst_t cmd_operate_port = {
1150 .f = cmd_operate_port_parsed,
1152 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1154 (void *)&cmd_operate_port_all_cmd,
1155 (void *)&cmd_operate_port_all_port,
1156 (void *)&cmd_operate_port_all_all,
1161 /* *** start/stop/close specific port *** */
1162 struct cmd_operate_specific_port_result {
1163 cmdline_fixed_string_t keyword;
1164 cmdline_fixed_string_t name;
1168 static void cmd_operate_specific_port_parsed(void *parsed_result,
1169 __attribute__((unused)) struct cmdline *cl,
1170 __attribute__((unused)) void *data)
1172 struct cmd_operate_specific_port_result *res = parsed_result;
1174 if (!strcmp(res->name, "start"))
1175 start_port(res->value);
1176 else if (!strcmp(res->name, "stop"))
1177 stop_port(res->value);
1178 else if (!strcmp(res->name, "close"))
1179 close_port(res->value);
1180 else if (!strcmp(res->name, "reset"))
1181 reset_port(res->value);
1183 printf("Unknown parameter\n");
1186 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1187 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1189 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1190 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1191 name, "start#stop#close#reset");
1192 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1193 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1196 cmdline_parse_inst_t cmd_operate_specific_port = {
1197 .f = cmd_operate_specific_port_parsed,
1199 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1201 (void *)&cmd_operate_specific_port_cmd,
1202 (void *)&cmd_operate_specific_port_port,
1203 (void *)&cmd_operate_specific_port_id,
1208 /* *** attach a specified port *** */
1209 struct cmd_operate_attach_port_result {
1210 cmdline_fixed_string_t port;
1211 cmdline_fixed_string_t keyword;
1212 cmdline_fixed_string_t identifier;
1215 static void cmd_operate_attach_port_parsed(void *parsed_result,
1216 __attribute__((unused)) struct cmdline *cl,
1217 __attribute__((unused)) void *data)
1219 struct cmd_operate_attach_port_result *res = parsed_result;
1221 if (!strcmp(res->keyword, "attach"))
1222 attach_port(res->identifier);
1224 printf("Unknown parameter\n");
1227 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1228 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1230 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1231 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1233 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1237 cmdline_parse_inst_t cmd_operate_attach_port = {
1238 .f = cmd_operate_attach_port_parsed,
1240 .help_str = "port attach <identifier>: "
1241 "(identifier: pci address or virtual dev name)",
1243 (void *)&cmd_operate_attach_port_port,
1244 (void *)&cmd_operate_attach_port_keyword,
1245 (void *)&cmd_operate_attach_port_identifier,
1250 /* *** detach a specified port *** */
1251 struct cmd_operate_detach_port_result {
1252 cmdline_fixed_string_t port;
1253 cmdline_fixed_string_t keyword;
1257 static void cmd_operate_detach_port_parsed(void *parsed_result,
1258 __attribute__((unused)) struct cmdline *cl,
1259 __attribute__((unused)) void *data)
1261 struct cmd_operate_detach_port_result *res = parsed_result;
1263 if (!strcmp(res->keyword, "detach"))
1264 detach_port(res->port_id);
1266 printf("Unknown parameter\n");
1269 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1270 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1272 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1273 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1275 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1276 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1279 cmdline_parse_inst_t cmd_operate_detach_port = {
1280 .f = cmd_operate_detach_port_parsed,
1282 .help_str = "port detach <port_id>",
1284 (void *)&cmd_operate_detach_port_port,
1285 (void *)&cmd_operate_detach_port_keyword,
1286 (void *)&cmd_operate_detach_port_port_id,
1291 /* *** configure speed for all ports *** */
1292 struct cmd_config_speed_all {
1293 cmdline_fixed_string_t port;
1294 cmdline_fixed_string_t keyword;
1295 cmdline_fixed_string_t all;
1296 cmdline_fixed_string_t item1;
1297 cmdline_fixed_string_t item2;
1298 cmdline_fixed_string_t value1;
1299 cmdline_fixed_string_t value2;
1303 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1308 if (!strcmp(duplexstr, "half")) {
1309 duplex = ETH_LINK_HALF_DUPLEX;
1310 } else if (!strcmp(duplexstr, "full")) {
1311 duplex = ETH_LINK_FULL_DUPLEX;
1312 } else if (!strcmp(duplexstr, "auto")) {
1313 duplex = ETH_LINK_FULL_DUPLEX;
1315 printf("Unknown duplex parameter\n");
1319 if (!strcmp(speedstr, "10")) {
1320 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1321 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1322 } else if (!strcmp(speedstr, "100")) {
1323 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1324 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1326 if (duplex != ETH_LINK_FULL_DUPLEX) {
1327 printf("Invalid speed/duplex parameters\n");
1330 if (!strcmp(speedstr, "1000")) {
1331 *speed = ETH_LINK_SPEED_1G;
1332 } else if (!strcmp(speedstr, "10000")) {
1333 *speed = ETH_LINK_SPEED_10G;
1334 } else if (!strcmp(speedstr, "25000")) {
1335 *speed = ETH_LINK_SPEED_25G;
1336 } else if (!strcmp(speedstr, "40000")) {
1337 *speed = ETH_LINK_SPEED_40G;
1338 } else if (!strcmp(speedstr, "50000")) {
1339 *speed = ETH_LINK_SPEED_50G;
1340 } else if (!strcmp(speedstr, "100000")) {
1341 *speed = ETH_LINK_SPEED_100G;
1342 } else if (!strcmp(speedstr, "auto")) {
1343 *speed = ETH_LINK_SPEED_AUTONEG;
1345 printf("Unknown speed parameter\n");
1354 cmd_config_speed_all_parsed(void *parsed_result,
1355 __attribute__((unused)) struct cmdline *cl,
1356 __attribute__((unused)) void *data)
1358 struct cmd_config_speed_all *res = parsed_result;
1359 uint32_t link_speed;
1362 if (!all_ports_stopped()) {
1363 printf("Please stop all ports first\n");
1367 if (parse_and_check_speed_duplex(res->value1, res->value2,
1371 RTE_ETH_FOREACH_DEV(pid) {
1372 ports[pid].dev_conf.link_speeds = link_speed;
1375 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1378 cmdline_parse_token_string_t cmd_config_speed_all_port =
1379 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1380 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1381 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1383 cmdline_parse_token_string_t cmd_config_speed_all_all =
1384 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1385 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1386 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1387 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1388 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1389 "10#100#1000#10000#25000#40000#50000#100000#auto");
1390 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1391 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1392 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1393 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1396 cmdline_parse_inst_t cmd_config_speed_all = {
1397 .f = cmd_config_speed_all_parsed,
1399 .help_str = "port config all speed "
1400 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1403 (void *)&cmd_config_speed_all_port,
1404 (void *)&cmd_config_speed_all_keyword,
1405 (void *)&cmd_config_speed_all_all,
1406 (void *)&cmd_config_speed_all_item1,
1407 (void *)&cmd_config_speed_all_value1,
1408 (void *)&cmd_config_speed_all_item2,
1409 (void *)&cmd_config_speed_all_value2,
1414 /* *** configure speed for specific port *** */
1415 struct cmd_config_speed_specific {
1416 cmdline_fixed_string_t port;
1417 cmdline_fixed_string_t keyword;
1419 cmdline_fixed_string_t item1;
1420 cmdline_fixed_string_t item2;
1421 cmdline_fixed_string_t value1;
1422 cmdline_fixed_string_t value2;
1426 cmd_config_speed_specific_parsed(void *parsed_result,
1427 __attribute__((unused)) struct cmdline *cl,
1428 __attribute__((unused)) void *data)
1430 struct cmd_config_speed_specific *res = parsed_result;
1431 uint32_t link_speed;
1433 if (!all_ports_stopped()) {
1434 printf("Please stop all ports first\n");
1438 if (port_id_is_invalid(res->id, ENABLED_WARN))
1441 if (parse_and_check_speed_duplex(res->value1, res->value2,
1445 ports[res->id].dev_conf.link_speeds = link_speed;
1447 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1451 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1452 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1454 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1455 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1457 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1458 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1459 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1460 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1462 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1463 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1464 "10#100#1000#10000#25000#40000#50000#100000#auto");
1465 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1468 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1472 cmdline_parse_inst_t cmd_config_speed_specific = {
1473 .f = cmd_config_speed_specific_parsed,
1475 .help_str = "port config <port_id> speed "
1476 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1479 (void *)&cmd_config_speed_specific_port,
1480 (void *)&cmd_config_speed_specific_keyword,
1481 (void *)&cmd_config_speed_specific_id,
1482 (void *)&cmd_config_speed_specific_item1,
1483 (void *)&cmd_config_speed_specific_value1,
1484 (void *)&cmd_config_speed_specific_item2,
1485 (void *)&cmd_config_speed_specific_value2,
1490 /* *** configure txq/rxq, txd/rxd *** */
1491 struct cmd_config_rx_tx {
1492 cmdline_fixed_string_t port;
1493 cmdline_fixed_string_t keyword;
1494 cmdline_fixed_string_t all;
1495 cmdline_fixed_string_t name;
1500 cmd_config_rx_tx_parsed(void *parsed_result,
1501 __attribute__((unused)) struct cmdline *cl,
1502 __attribute__((unused)) void *data)
1504 struct cmd_config_rx_tx *res = parsed_result;
1506 if (!all_ports_stopped()) {
1507 printf("Please stop all ports first\n");
1510 if (!strcmp(res->name, "rxq")) {
1511 if (!res->value && !nb_txq) {
1512 printf("Warning: Either rx or tx queues should be non zero\n");
1515 if (check_nb_rxq(res->value) != 0)
1517 nb_rxq = res->value;
1519 else if (!strcmp(res->name, "txq")) {
1520 if (!res->value && !nb_rxq) {
1521 printf("Warning: Either rx or tx queues should be non zero\n");
1524 if (check_nb_txq(res->value) != 0)
1526 nb_txq = res->value;
1528 else if (!strcmp(res->name, "rxd")) {
1529 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1530 printf("rxd %d invalid - must be > 0 && <= %d\n",
1531 res->value, RTE_TEST_RX_DESC_MAX);
1534 nb_rxd = res->value;
1535 } else if (!strcmp(res->name, "txd")) {
1536 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1537 printf("txd %d invalid - must be > 0 && <= %d\n",
1538 res->value, RTE_TEST_TX_DESC_MAX);
1541 nb_txd = res->value;
1543 printf("Unknown parameter\n");
1551 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1554 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1555 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1556 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1557 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1558 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1559 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1560 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1563 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1564 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1566 cmdline_parse_inst_t cmd_config_rx_tx = {
1567 .f = cmd_config_rx_tx_parsed,
1569 .help_str = "port config all rxq|txq|rxd|txd <value>",
1571 (void *)&cmd_config_rx_tx_port,
1572 (void *)&cmd_config_rx_tx_keyword,
1573 (void *)&cmd_config_rx_tx_all,
1574 (void *)&cmd_config_rx_tx_name,
1575 (void *)&cmd_config_rx_tx_value,
1580 /* *** config max packet length *** */
1581 struct cmd_config_max_pkt_len_result {
1582 cmdline_fixed_string_t port;
1583 cmdline_fixed_string_t keyword;
1584 cmdline_fixed_string_t all;
1585 cmdline_fixed_string_t name;
1590 cmd_config_max_pkt_len_parsed(void *parsed_result,
1591 __attribute__((unused)) struct cmdline *cl,
1592 __attribute__((unused)) void *data)
1594 struct cmd_config_max_pkt_len_result *res = parsed_result;
1597 if (!all_ports_stopped()) {
1598 printf("Please stop all ports first\n");
1602 RTE_ETH_FOREACH_DEV(pid) {
1603 struct rte_port *port = &ports[pid];
1604 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1606 if (!strcmp(res->name, "max-pkt-len")) {
1607 if (res->value < ETHER_MIN_LEN) {
1608 printf("max-pkt-len can not be less than %d\n",
1612 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1615 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1616 if (res->value > ETHER_MAX_LEN)
1617 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1619 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1620 port->dev_conf.rxmode.offloads = rx_offloads;
1622 printf("Unknown parameter\n");
1629 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1632 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1633 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1635 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1636 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1638 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1639 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1641 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1644 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1645 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1648 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1649 .f = cmd_config_max_pkt_len_parsed,
1651 .help_str = "port config all max-pkt-len <value>",
1653 (void *)&cmd_config_max_pkt_len_port,
1654 (void *)&cmd_config_max_pkt_len_keyword,
1655 (void *)&cmd_config_max_pkt_len_all,
1656 (void *)&cmd_config_max_pkt_len_name,
1657 (void *)&cmd_config_max_pkt_len_value,
1662 /* *** configure port MTU *** */
1663 struct cmd_config_mtu_result {
1664 cmdline_fixed_string_t port;
1665 cmdline_fixed_string_t keyword;
1666 cmdline_fixed_string_t mtu;
1672 cmd_config_mtu_parsed(void *parsed_result,
1673 __attribute__((unused)) struct cmdline *cl,
1674 __attribute__((unused)) void *data)
1676 struct cmd_config_mtu_result *res = parsed_result;
1678 if (res->value < ETHER_MIN_LEN) {
1679 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1682 port_mtu_set(res->port_id, res->value);
1685 cmdline_parse_token_string_t cmd_config_mtu_port =
1686 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1688 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1689 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1691 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1692 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1694 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1695 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1696 cmdline_parse_token_num_t cmd_config_mtu_value =
1697 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1699 cmdline_parse_inst_t cmd_config_mtu = {
1700 .f = cmd_config_mtu_parsed,
1702 .help_str = "port config mtu <port_id> <value>",
1704 (void *)&cmd_config_mtu_port,
1705 (void *)&cmd_config_mtu_keyword,
1706 (void *)&cmd_config_mtu_mtu,
1707 (void *)&cmd_config_mtu_port_id,
1708 (void *)&cmd_config_mtu_value,
1713 /* *** configure rx mode *** */
1714 struct cmd_config_rx_mode_flag {
1715 cmdline_fixed_string_t port;
1716 cmdline_fixed_string_t keyword;
1717 cmdline_fixed_string_t all;
1718 cmdline_fixed_string_t name;
1719 cmdline_fixed_string_t value;
1723 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1724 __attribute__((unused)) struct cmdline *cl,
1725 __attribute__((unused)) void *data)
1727 struct cmd_config_rx_mode_flag *res = parsed_result;
1730 if (!all_ports_stopped()) {
1731 printf("Please stop all ports first\n");
1735 RTE_ETH_FOREACH_DEV(pid) {
1736 struct rte_port *port;
1737 uint64_t rx_offloads;
1740 rx_offloads = port->dev_conf.rxmode.offloads;
1741 if (!strcmp(res->name, "crc-strip")) {
1742 if (!strcmp(res->value, "on"))
1743 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1744 else if (!strcmp(res->value, "off"))
1745 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1747 printf("Unknown parameter\n");
1750 } else if (!strcmp(res->name, "scatter")) {
1751 if (!strcmp(res->value, "on")) {
1752 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1753 } else if (!strcmp(res->value, "off")) {
1754 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1756 printf("Unknown parameter\n");
1759 } else if (!strcmp(res->name, "rx-cksum")) {
1760 if (!strcmp(res->value, "on"))
1761 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1762 else if (!strcmp(res->value, "off"))
1763 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1765 printf("Unknown parameter\n");
1768 } else if (!strcmp(res->name, "rx-timestamp")) {
1769 if (!strcmp(res->value, "on"))
1770 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1771 else if (!strcmp(res->value, "off"))
1772 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1774 printf("Unknown parameter\n");
1777 } else if (!strcmp(res->name, "hw-vlan")) {
1778 if (!strcmp(res->value, "on")) {
1779 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1780 DEV_RX_OFFLOAD_VLAN_STRIP);
1781 } else if (!strcmp(res->value, "off")) {
1782 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1783 DEV_RX_OFFLOAD_VLAN_STRIP);
1785 printf("Unknown parameter\n");
1788 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1789 if (!strcmp(res->value, "on"))
1790 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1791 else if (!strcmp(res->value, "off"))
1792 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1794 printf("Unknown parameter\n");
1797 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1798 if (!strcmp(res->value, "on"))
1799 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1800 else if (!strcmp(res->value, "off"))
1801 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1803 printf("Unknown parameter\n");
1806 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1807 if (!strcmp(res->value, "on"))
1808 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1809 else if (!strcmp(res->value, "off"))
1810 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1812 printf("Unknown parameter\n");
1815 } else if (!strcmp(res->name, "drop-en")) {
1816 if (!strcmp(res->value, "on"))
1818 else if (!strcmp(res->value, "off"))
1821 printf("Unknown parameter\n");
1825 printf("Unknown parameter\n");
1828 port->dev_conf.rxmode.offloads = rx_offloads;
1833 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1836 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1838 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1839 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1841 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1842 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1843 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1845 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1846 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1847 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1848 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1851 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1852 .f = cmd_config_rx_mode_flag_parsed,
1854 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1855 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1857 (void *)&cmd_config_rx_mode_flag_port,
1858 (void *)&cmd_config_rx_mode_flag_keyword,
1859 (void *)&cmd_config_rx_mode_flag_all,
1860 (void *)&cmd_config_rx_mode_flag_name,
1861 (void *)&cmd_config_rx_mode_flag_value,
1866 /* *** configure rss *** */
1867 struct cmd_config_rss {
1868 cmdline_fixed_string_t port;
1869 cmdline_fixed_string_t keyword;
1870 cmdline_fixed_string_t all;
1871 cmdline_fixed_string_t name;
1872 cmdline_fixed_string_t value;
1876 cmd_config_rss_parsed(void *parsed_result,
1877 __attribute__((unused)) struct cmdline *cl,
1878 __attribute__((unused)) void *data)
1880 struct cmd_config_rss *res = parsed_result;
1881 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1885 if (!strcmp(res->value, "all"))
1886 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1887 ETH_RSS_UDP | ETH_RSS_SCTP |
1889 else if (!strcmp(res->value, "ip"))
1890 rss_conf.rss_hf = ETH_RSS_IP;
1891 else if (!strcmp(res->value, "udp"))
1892 rss_conf.rss_hf = ETH_RSS_UDP;
1893 else if (!strcmp(res->value, "tcp"))
1894 rss_conf.rss_hf = ETH_RSS_TCP;
1895 else if (!strcmp(res->value, "sctp"))
1896 rss_conf.rss_hf = ETH_RSS_SCTP;
1897 else if (!strcmp(res->value, "ether"))
1898 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1899 else if (!strcmp(res->value, "port"))
1900 rss_conf.rss_hf = ETH_RSS_PORT;
1901 else if (!strcmp(res->value, "vxlan"))
1902 rss_conf.rss_hf = ETH_RSS_VXLAN;
1903 else if (!strcmp(res->value, "geneve"))
1904 rss_conf.rss_hf = ETH_RSS_GENEVE;
1905 else if (!strcmp(res->value, "nvgre"))
1906 rss_conf.rss_hf = ETH_RSS_NVGRE;
1907 else if (!strcmp(res->value, "none"))
1908 rss_conf.rss_hf = 0;
1909 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1910 atoi(res->value) < 64)
1911 rss_conf.rss_hf = 1ULL << atoi(res->value);
1913 printf("Unknown parameter\n");
1916 rss_conf.rss_key = NULL;
1917 for (i = 0; i < rte_eth_dev_count(); i++) {
1918 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1920 printf("Configuration of RSS hash at ethernet port %d "
1921 "failed with error (%d): %s.\n",
1922 i, -diag, strerror(-diag));
1926 cmdline_parse_token_string_t cmd_config_rss_port =
1927 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1928 cmdline_parse_token_string_t cmd_config_rss_keyword =
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1930 cmdline_parse_token_string_t cmd_config_rss_all =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1932 cmdline_parse_token_string_t cmd_config_rss_name =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1934 cmdline_parse_token_string_t cmd_config_rss_value =
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1937 cmdline_parse_inst_t cmd_config_rss = {
1938 .f = cmd_config_rss_parsed,
1940 .help_str = "port config all rss "
1941 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1943 (void *)&cmd_config_rss_port,
1944 (void *)&cmd_config_rss_keyword,
1945 (void *)&cmd_config_rss_all,
1946 (void *)&cmd_config_rss_name,
1947 (void *)&cmd_config_rss_value,
1952 /* *** configure rss hash key *** */
1953 struct cmd_config_rss_hash_key {
1954 cmdline_fixed_string_t port;
1955 cmdline_fixed_string_t config;
1957 cmdline_fixed_string_t rss_hash_key;
1958 cmdline_fixed_string_t rss_type;
1959 cmdline_fixed_string_t key;
1963 hexa_digit_to_value(char hexa_digit)
1965 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1966 return (uint8_t) (hexa_digit - '0');
1967 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1968 return (uint8_t) ((hexa_digit - 'a') + 10);
1969 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1970 return (uint8_t) ((hexa_digit - 'A') + 10);
1971 /* Invalid hexa digit */
1976 parse_and_check_key_hexa_digit(char *key, int idx)
1980 hexa_v = hexa_digit_to_value(key[idx]);
1982 printf("invalid key: character %c at position %d is not a "
1983 "valid hexa digit\n", key[idx], idx);
1988 cmd_config_rss_hash_key_parsed(void *parsed_result,
1989 __attribute__((unused)) struct cmdline *cl,
1990 __attribute__((unused)) void *data)
1992 struct cmd_config_rss_hash_key *res = parsed_result;
1993 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1997 struct rte_eth_dev_info dev_info;
1998 uint8_t hash_key_size;
2001 memset(&dev_info, 0, sizeof(dev_info));
2002 rte_eth_dev_info_get(res->port_id, &dev_info);
2003 if (dev_info.hash_key_size > 0 &&
2004 dev_info.hash_key_size <= sizeof(hash_key))
2005 hash_key_size = dev_info.hash_key_size;
2007 printf("dev_info did not provide a valid hash key size\n");
2010 /* Check the length of the RSS hash key */
2011 key_len = strlen(res->key);
2012 if (key_len != (hash_key_size * 2)) {
2013 printf("key length: %d invalid - key must be a string of %d"
2014 " hexa-decimal numbers\n",
2015 (int) key_len, hash_key_size * 2);
2018 /* Translate RSS hash key into binary representation */
2019 for (i = 0; i < hash_key_size; i++) {
2020 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2023 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2026 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2028 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2032 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2034 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2037 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2038 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2039 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2040 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2041 rss_hash_key, "rss-hash-key");
2042 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2043 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2044 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2045 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2046 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2047 "ipv6-tcp-ex#ipv6-udp-ex");
2048 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2049 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2051 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2052 .f = cmd_config_rss_hash_key_parsed,
2054 .help_str = "port config <port_id> rss-hash-key "
2055 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2056 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2057 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2058 "<string of hex digits (variable length, NIC dependent)>",
2060 (void *)&cmd_config_rss_hash_key_port,
2061 (void *)&cmd_config_rss_hash_key_config,
2062 (void *)&cmd_config_rss_hash_key_port_id,
2063 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2064 (void *)&cmd_config_rss_hash_key_rss_type,
2065 (void *)&cmd_config_rss_hash_key_value,
2070 /* *** configure port rxq/txq start/stop *** */
2071 struct cmd_config_rxtx_queue {
2072 cmdline_fixed_string_t port;
2074 cmdline_fixed_string_t rxtxq;
2076 cmdline_fixed_string_t opname;
2080 cmd_config_rxtx_queue_parsed(void *parsed_result,
2081 __attribute__((unused)) struct cmdline *cl,
2082 __attribute__((unused)) void *data)
2084 struct cmd_config_rxtx_queue *res = parsed_result;
2089 if (test_done == 0) {
2090 printf("Please stop forwarding first\n");
2094 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2097 if (port_is_started(res->portid) != 1) {
2098 printf("Please start port %u first\n", res->portid);
2102 if (!strcmp(res->rxtxq, "rxq"))
2104 else if (!strcmp(res->rxtxq, "txq"))
2107 printf("Unknown parameter\n");
2111 if (isrx && rx_queue_id_is_invalid(res->qid))
2113 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2116 if (!strcmp(res->opname, "start"))
2118 else if (!strcmp(res->opname, "stop"))
2121 printf("Unknown parameter\n");
2125 if (isstart && isrx)
2126 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2127 else if (!isstart && isrx)
2128 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2129 else if (isstart && !isrx)
2130 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2132 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2134 if (ret == -ENOTSUP)
2135 printf("Function not supported in PMD driver\n");
2138 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2139 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2140 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2141 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2142 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2143 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2144 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2145 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2146 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2147 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2150 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2151 .f = cmd_config_rxtx_queue_parsed,
2153 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2155 (void *)&cmd_config_speed_all_port,
2156 (void *)&cmd_config_rxtx_queue_portid,
2157 (void *)&cmd_config_rxtx_queue_rxtxq,
2158 (void *)&cmd_config_rxtx_queue_qid,
2159 (void *)&cmd_config_rxtx_queue_opname,
2164 /* *** Configure RSS RETA *** */
2165 struct cmd_config_rss_reta {
2166 cmdline_fixed_string_t port;
2167 cmdline_fixed_string_t keyword;
2169 cmdline_fixed_string_t name;
2170 cmdline_fixed_string_t list_name;
2171 cmdline_fixed_string_t list_of_items;
2175 parse_reta_config(const char *str,
2176 struct rte_eth_rss_reta_entry64 *reta_conf,
2177 uint16_t nb_entries)
2181 uint16_t hash_index, idx, shift;
2184 const char *p, *p0 = str;
2191 unsigned long int_fld[_NUM_FLD];
2192 char *str_fld[_NUM_FLD];
2194 while ((p = strchr(p0,'(')) != NULL) {
2196 if((p0 = strchr(p,')')) == NULL)
2200 if(size >= sizeof(s))
2203 snprintf(s, sizeof(s), "%.*s", size, p);
2204 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2206 for (i = 0; i < _NUM_FLD; i++) {
2208 int_fld[i] = strtoul(str_fld[i], &end, 0);
2209 if (errno != 0 || end == str_fld[i] ||
2214 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2215 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2217 if (hash_index >= nb_entries) {
2218 printf("Invalid RETA hash index=%d\n", hash_index);
2222 idx = hash_index / RTE_RETA_GROUP_SIZE;
2223 shift = hash_index % RTE_RETA_GROUP_SIZE;
2224 reta_conf[idx].mask |= (1ULL << shift);
2225 reta_conf[idx].reta[shift] = nb_queue;
2232 cmd_set_rss_reta_parsed(void *parsed_result,
2233 __attribute__((unused)) struct cmdline *cl,
2234 __attribute__((unused)) void *data)
2237 struct rte_eth_dev_info dev_info;
2238 struct rte_eth_rss_reta_entry64 reta_conf[8];
2239 struct cmd_config_rss_reta *res = parsed_result;
2241 memset(&dev_info, 0, sizeof(dev_info));
2242 rte_eth_dev_info_get(res->port_id, &dev_info);
2243 if (dev_info.reta_size == 0) {
2244 printf("Redirection table size is 0 which is "
2245 "invalid for RSS\n");
2248 printf("The reta size of port %d is %u\n",
2249 res->port_id, dev_info.reta_size);
2250 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2251 printf("Currently do not support more than %u entries of "
2252 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2256 memset(reta_conf, 0, sizeof(reta_conf));
2257 if (!strcmp(res->list_name, "reta")) {
2258 if (parse_reta_config(res->list_of_items, reta_conf,
2259 dev_info.reta_size)) {
2260 printf("Invalid RSS Redirection Table "
2261 "config entered\n");
2264 ret = rte_eth_dev_rss_reta_update(res->port_id,
2265 reta_conf, dev_info.reta_size);
2267 printf("Bad redirection table parameter, "
2268 "return code = %d \n", ret);
2272 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2273 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2274 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2275 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2276 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2277 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2278 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2279 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2280 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2281 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2282 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2285 cmdline_parse_inst_t cmd_config_rss_reta = {
2286 .f = cmd_set_rss_reta_parsed,
2288 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2290 (void *)&cmd_config_rss_reta_port,
2291 (void *)&cmd_config_rss_reta_keyword,
2292 (void *)&cmd_config_rss_reta_port_id,
2293 (void *)&cmd_config_rss_reta_name,
2294 (void *)&cmd_config_rss_reta_list_name,
2295 (void *)&cmd_config_rss_reta_list_of_items,
2300 /* *** SHOW PORT RETA INFO *** */
2301 struct cmd_showport_reta {
2302 cmdline_fixed_string_t show;
2303 cmdline_fixed_string_t port;
2305 cmdline_fixed_string_t rss;
2306 cmdline_fixed_string_t reta;
2308 cmdline_fixed_string_t list_of_items;
2312 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2313 uint16_t nb_entries,
2317 const char *p, *p0 = str;
2322 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2323 RTE_RETA_GROUP_SIZE;
2326 p = strchr(p0, '(');
2330 p0 = strchr(p, ')');
2334 if (size >= sizeof(s)) {
2335 printf("The string size exceeds the internal buffer size\n");
2338 snprintf(s, sizeof(s), "%.*s", size, p);
2339 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2340 if (ret <= 0 || ret != num) {
2341 printf("The bits of masks do not match the number of "
2342 "reta entries: %u\n", num);
2345 for (i = 0; i < ret; i++)
2346 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2352 cmd_showport_reta_parsed(void *parsed_result,
2353 __attribute__((unused)) struct cmdline *cl,
2354 __attribute__((unused)) void *data)
2356 struct cmd_showport_reta *res = parsed_result;
2357 struct rte_eth_rss_reta_entry64 reta_conf[8];
2358 struct rte_eth_dev_info dev_info;
2359 uint16_t max_reta_size;
2361 memset(&dev_info, 0, sizeof(dev_info));
2362 rte_eth_dev_info_get(res->port_id, &dev_info);
2363 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2364 if (res->size == 0 || res->size > max_reta_size) {
2365 printf("Invalid redirection table size: %u (1-%u)\n",
2366 res->size, max_reta_size);
2370 memset(reta_conf, 0, sizeof(reta_conf));
2371 if (showport_parse_reta_config(reta_conf, res->size,
2372 res->list_of_items) < 0) {
2373 printf("Invalid string: %s for reta masks\n",
2374 res->list_of_items);
2377 port_rss_reta_info(res->port_id, reta_conf, res->size);
2380 cmdline_parse_token_string_t cmd_showport_reta_show =
2381 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2382 cmdline_parse_token_string_t cmd_showport_reta_port =
2383 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2384 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2385 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2386 cmdline_parse_token_string_t cmd_showport_reta_rss =
2387 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2388 cmdline_parse_token_string_t cmd_showport_reta_reta =
2389 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2390 cmdline_parse_token_num_t cmd_showport_reta_size =
2391 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2392 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2393 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2394 list_of_items, NULL);
2396 cmdline_parse_inst_t cmd_showport_reta = {
2397 .f = cmd_showport_reta_parsed,
2399 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2401 (void *)&cmd_showport_reta_show,
2402 (void *)&cmd_showport_reta_port,
2403 (void *)&cmd_showport_reta_port_id,
2404 (void *)&cmd_showport_reta_rss,
2405 (void *)&cmd_showport_reta_reta,
2406 (void *)&cmd_showport_reta_size,
2407 (void *)&cmd_showport_reta_list_of_items,
2412 /* *** Show RSS hash configuration *** */
2413 struct cmd_showport_rss_hash {
2414 cmdline_fixed_string_t show;
2415 cmdline_fixed_string_t port;
2417 cmdline_fixed_string_t rss_hash;
2418 cmdline_fixed_string_t rss_type;
2419 cmdline_fixed_string_t key; /* optional argument */
2422 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2423 __attribute__((unused)) struct cmdline *cl,
2426 struct cmd_showport_rss_hash *res = parsed_result;
2428 port_rss_hash_conf_show(res->port_id, res->rss_type,
2429 show_rss_key != NULL);
2432 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2433 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2434 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2435 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2436 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2437 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2438 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2439 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2441 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2442 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2443 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2444 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2445 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2446 "ipv6-tcp-ex#ipv6-udp-ex");
2447 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2448 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2450 cmdline_parse_inst_t cmd_showport_rss_hash = {
2451 .f = cmd_showport_rss_hash_parsed,
2453 .help_str = "show port <port_id> rss-hash "
2454 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2455 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2456 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2458 (void *)&cmd_showport_rss_hash_show,
2459 (void *)&cmd_showport_rss_hash_port,
2460 (void *)&cmd_showport_rss_hash_port_id,
2461 (void *)&cmd_showport_rss_hash_rss_hash,
2462 (void *)&cmd_showport_rss_hash_rss_hash_info,
2467 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2468 .f = cmd_showport_rss_hash_parsed,
2470 .help_str = "show port <port_id> rss-hash "
2471 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2472 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2473 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2475 (void *)&cmd_showport_rss_hash_show,
2476 (void *)&cmd_showport_rss_hash_port,
2477 (void *)&cmd_showport_rss_hash_port_id,
2478 (void *)&cmd_showport_rss_hash_rss_hash,
2479 (void *)&cmd_showport_rss_hash_rss_hash_info,
2480 (void *)&cmd_showport_rss_hash_rss_key,
2485 /* *** Configure DCB *** */
2486 struct cmd_config_dcb {
2487 cmdline_fixed_string_t port;
2488 cmdline_fixed_string_t config;
2490 cmdline_fixed_string_t dcb;
2491 cmdline_fixed_string_t vt;
2492 cmdline_fixed_string_t vt_en;
2494 cmdline_fixed_string_t pfc;
2495 cmdline_fixed_string_t pfc_en;
2499 cmd_config_dcb_parsed(void *parsed_result,
2500 __attribute__((unused)) struct cmdline *cl,
2501 __attribute__((unused)) void *data)
2503 struct cmd_config_dcb *res = parsed_result;
2504 portid_t port_id = res->port_id;
2505 struct rte_port *port;
2509 port = &ports[port_id];
2510 /** Check if the port is not started **/
2511 if (port->port_status != RTE_PORT_STOPPED) {
2512 printf("Please stop port %d first\n", port_id);
2516 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2517 printf("The invalid number of traffic class,"
2518 " only 4 or 8 allowed.\n");
2522 if (nb_fwd_lcores < res->num_tcs) {
2523 printf("nb_cores shouldn't be less than number of TCs.\n");
2526 if (!strncmp(res->pfc_en, "on", 2))
2531 /* DCB in VT mode */
2532 if (!strncmp(res->vt_en, "on", 2))
2533 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2534 (enum rte_eth_nb_tcs)res->num_tcs,
2537 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2538 (enum rte_eth_nb_tcs)res->num_tcs,
2543 printf("Cannot initialize network ports.\n");
2547 cmd_reconfig_device_queue(port_id, 1, 1);
2550 cmdline_parse_token_string_t cmd_config_dcb_port =
2551 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2552 cmdline_parse_token_string_t cmd_config_dcb_config =
2553 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2554 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2555 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2556 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2557 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2558 cmdline_parse_token_string_t cmd_config_dcb_vt =
2559 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2560 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2561 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2562 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2563 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2564 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2565 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2566 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2567 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2569 cmdline_parse_inst_t cmd_config_dcb = {
2570 .f = cmd_config_dcb_parsed,
2572 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2574 (void *)&cmd_config_dcb_port,
2575 (void *)&cmd_config_dcb_config,
2576 (void *)&cmd_config_dcb_port_id,
2577 (void *)&cmd_config_dcb_dcb,
2578 (void *)&cmd_config_dcb_vt,
2579 (void *)&cmd_config_dcb_vt_en,
2580 (void *)&cmd_config_dcb_num_tcs,
2581 (void *)&cmd_config_dcb_pfc,
2582 (void *)&cmd_config_dcb_pfc_en,
2587 /* *** configure number of packets per burst *** */
2588 struct cmd_config_burst {
2589 cmdline_fixed_string_t port;
2590 cmdline_fixed_string_t keyword;
2591 cmdline_fixed_string_t all;
2592 cmdline_fixed_string_t name;
2597 cmd_config_burst_parsed(void *parsed_result,
2598 __attribute__((unused)) struct cmdline *cl,
2599 __attribute__((unused)) void *data)
2601 struct cmd_config_burst *res = parsed_result;
2603 if (!all_ports_stopped()) {
2604 printf("Please stop all ports first\n");
2608 if (!strcmp(res->name, "burst")) {
2609 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2610 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2613 nb_pkt_per_burst = res->value;
2615 printf("Unknown parameter\n");
2621 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2624 cmdline_parse_token_string_t cmd_config_burst_port =
2625 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2626 cmdline_parse_token_string_t cmd_config_burst_keyword =
2627 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2628 cmdline_parse_token_string_t cmd_config_burst_all =
2629 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2630 cmdline_parse_token_string_t cmd_config_burst_name =
2631 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2632 cmdline_parse_token_num_t cmd_config_burst_value =
2633 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2635 cmdline_parse_inst_t cmd_config_burst = {
2636 .f = cmd_config_burst_parsed,
2638 .help_str = "port config all burst <value>",
2640 (void *)&cmd_config_burst_port,
2641 (void *)&cmd_config_burst_keyword,
2642 (void *)&cmd_config_burst_all,
2643 (void *)&cmd_config_burst_name,
2644 (void *)&cmd_config_burst_value,
2649 /* *** configure rx/tx queues *** */
2650 struct cmd_config_thresh {
2651 cmdline_fixed_string_t port;
2652 cmdline_fixed_string_t keyword;
2653 cmdline_fixed_string_t all;
2654 cmdline_fixed_string_t name;
2659 cmd_config_thresh_parsed(void *parsed_result,
2660 __attribute__((unused)) struct cmdline *cl,
2661 __attribute__((unused)) void *data)
2663 struct cmd_config_thresh *res = parsed_result;
2665 if (!all_ports_stopped()) {
2666 printf("Please stop all ports first\n");
2670 if (!strcmp(res->name, "txpt"))
2671 tx_pthresh = res->value;
2672 else if(!strcmp(res->name, "txht"))
2673 tx_hthresh = res->value;
2674 else if(!strcmp(res->name, "txwt"))
2675 tx_wthresh = res->value;
2676 else if(!strcmp(res->name, "rxpt"))
2677 rx_pthresh = res->value;
2678 else if(!strcmp(res->name, "rxht"))
2679 rx_hthresh = res->value;
2680 else if(!strcmp(res->name, "rxwt"))
2681 rx_wthresh = res->value;
2683 printf("Unknown parameter\n");
2689 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2692 cmdline_parse_token_string_t cmd_config_thresh_port =
2693 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2694 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2695 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2696 cmdline_parse_token_string_t cmd_config_thresh_all =
2697 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2698 cmdline_parse_token_string_t cmd_config_thresh_name =
2699 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2700 "txpt#txht#txwt#rxpt#rxht#rxwt");
2701 cmdline_parse_token_num_t cmd_config_thresh_value =
2702 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2704 cmdline_parse_inst_t cmd_config_thresh = {
2705 .f = cmd_config_thresh_parsed,
2707 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2709 (void *)&cmd_config_thresh_port,
2710 (void *)&cmd_config_thresh_keyword,
2711 (void *)&cmd_config_thresh_all,
2712 (void *)&cmd_config_thresh_name,
2713 (void *)&cmd_config_thresh_value,
2718 /* *** configure free/rs threshold *** */
2719 struct cmd_config_threshold {
2720 cmdline_fixed_string_t port;
2721 cmdline_fixed_string_t keyword;
2722 cmdline_fixed_string_t all;
2723 cmdline_fixed_string_t name;
2728 cmd_config_threshold_parsed(void *parsed_result,
2729 __attribute__((unused)) struct cmdline *cl,
2730 __attribute__((unused)) void *data)
2732 struct cmd_config_threshold *res = parsed_result;
2734 if (!all_ports_stopped()) {
2735 printf("Please stop all ports first\n");
2739 if (!strcmp(res->name, "txfreet"))
2740 tx_free_thresh = res->value;
2741 else if (!strcmp(res->name, "txrst"))
2742 tx_rs_thresh = res->value;
2743 else if (!strcmp(res->name, "rxfreet"))
2744 rx_free_thresh = res->value;
2746 printf("Unknown parameter\n");
2752 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2755 cmdline_parse_token_string_t cmd_config_threshold_port =
2756 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2757 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2758 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2760 cmdline_parse_token_string_t cmd_config_threshold_all =
2761 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2762 cmdline_parse_token_string_t cmd_config_threshold_name =
2763 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2764 "txfreet#txrst#rxfreet");
2765 cmdline_parse_token_num_t cmd_config_threshold_value =
2766 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2768 cmdline_parse_inst_t cmd_config_threshold = {
2769 .f = cmd_config_threshold_parsed,
2771 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2773 (void *)&cmd_config_threshold_port,
2774 (void *)&cmd_config_threshold_keyword,
2775 (void *)&cmd_config_threshold_all,
2776 (void *)&cmd_config_threshold_name,
2777 (void *)&cmd_config_threshold_value,
2783 struct cmd_stop_result {
2784 cmdline_fixed_string_t stop;
2787 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2788 __attribute__((unused)) struct cmdline *cl,
2789 __attribute__((unused)) void *data)
2791 stop_packet_forwarding();
2794 cmdline_parse_token_string_t cmd_stop_stop =
2795 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2797 cmdline_parse_inst_t cmd_stop = {
2798 .f = cmd_stop_parsed,
2800 .help_str = "stop: Stop packet forwarding",
2802 (void *)&cmd_stop_stop,
2807 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2810 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2811 unsigned int *parsed_items, int check_unique_values)
2813 unsigned int nb_item;
2821 * First parse all items in the list and store their value.
2826 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2828 if ((c >= '0') && (c <= '9')) {
2829 value = (unsigned int) (value * 10 + (c - '0'));
2834 printf("character %c is not a decimal digit\n", c);
2838 printf("No valid value before comma\n");
2841 if (nb_item < max_items) {
2842 parsed_items[nb_item] = value;
2848 if (nb_item >= max_items) {
2849 printf("Number of %s = %u > %u (maximum items)\n",
2850 item_name, nb_item + 1, max_items);
2853 parsed_items[nb_item++] = value;
2854 if (! check_unique_values)
2858 * Then, check that all values in the list are differents.
2859 * No optimization here...
2861 for (i = 0; i < nb_item; i++) {
2862 for (j = i + 1; j < nb_item; j++) {
2863 if (parsed_items[j] == parsed_items[i]) {
2864 printf("duplicated %s %u at index %u and %u\n",
2865 item_name, parsed_items[i], i, j);
2873 struct cmd_set_list_result {
2874 cmdline_fixed_string_t cmd_keyword;
2875 cmdline_fixed_string_t list_name;
2876 cmdline_fixed_string_t list_of_items;
2879 static void cmd_set_list_parsed(void *parsed_result,
2880 __attribute__((unused)) struct cmdline *cl,
2881 __attribute__((unused)) void *data)
2883 struct cmd_set_list_result *res;
2885 unsigned int lcorelist[RTE_MAX_LCORE];
2886 unsigned int portlist[RTE_MAX_ETHPORTS];
2888 unsigned int nb_item;
2890 if (test_done == 0) {
2891 printf("Please stop forwarding first\n");
2895 res = parsed_result;
2896 if (!strcmp(res->list_name, "corelist")) {
2897 nb_item = parse_item_list(res->list_of_items, "core",
2899 parsed_items.lcorelist, 1);
2901 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2906 if (!strcmp(res->list_name, "portlist")) {
2907 nb_item = parse_item_list(res->list_of_items, "port",
2909 parsed_items.portlist, 1);
2911 set_fwd_ports_list(parsed_items.portlist, nb_item);
2917 cmdline_parse_token_string_t cmd_set_list_keyword =
2918 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2920 cmdline_parse_token_string_t cmd_set_list_name =
2921 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2922 "corelist#portlist");
2923 cmdline_parse_token_string_t cmd_set_list_of_items =
2924 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2927 cmdline_parse_inst_t cmd_set_fwd_list = {
2928 .f = cmd_set_list_parsed,
2930 .help_str = "set corelist|portlist <list0[,list1]*>",
2932 (void *)&cmd_set_list_keyword,
2933 (void *)&cmd_set_list_name,
2934 (void *)&cmd_set_list_of_items,
2939 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2941 struct cmd_setmask_result {
2942 cmdline_fixed_string_t set;
2943 cmdline_fixed_string_t mask;
2947 static void cmd_set_mask_parsed(void *parsed_result,
2948 __attribute__((unused)) struct cmdline *cl,
2949 __attribute__((unused)) void *data)
2951 struct cmd_setmask_result *res = parsed_result;
2953 if (test_done == 0) {
2954 printf("Please stop forwarding first\n");
2957 if (!strcmp(res->mask, "coremask")) {
2958 set_fwd_lcores_mask(res->hexavalue);
2960 } else if (!strcmp(res->mask, "portmask")) {
2961 set_fwd_ports_mask(res->hexavalue);
2966 cmdline_parse_token_string_t cmd_setmask_set =
2967 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2968 cmdline_parse_token_string_t cmd_setmask_mask =
2969 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2970 "coremask#portmask");
2971 cmdline_parse_token_num_t cmd_setmask_value =
2972 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2974 cmdline_parse_inst_t cmd_set_fwd_mask = {
2975 .f = cmd_set_mask_parsed,
2977 .help_str = "set coremask|portmask <hexadecimal value>",
2979 (void *)&cmd_setmask_set,
2980 (void *)&cmd_setmask_mask,
2981 (void *)&cmd_setmask_value,
2987 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2989 struct cmd_set_result {
2990 cmdline_fixed_string_t set;
2991 cmdline_fixed_string_t what;
2995 static void cmd_set_parsed(void *parsed_result,
2996 __attribute__((unused)) struct cmdline *cl,
2997 __attribute__((unused)) void *data)
2999 struct cmd_set_result *res = parsed_result;
3000 if (!strcmp(res->what, "nbport")) {
3001 set_fwd_ports_number(res->value);
3003 } else if (!strcmp(res->what, "nbcore")) {
3004 set_fwd_lcores_number(res->value);
3006 } else if (!strcmp(res->what, "burst"))
3007 set_nb_pkt_per_burst(res->value);
3008 else if (!strcmp(res->what, "verbose"))
3009 set_verbose_level(res->value);
3012 cmdline_parse_token_string_t cmd_set_set =
3013 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3014 cmdline_parse_token_string_t cmd_set_what =
3015 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3016 "nbport#nbcore#burst#verbose");
3017 cmdline_parse_token_num_t cmd_set_value =
3018 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3020 cmdline_parse_inst_t cmd_set_numbers = {
3021 .f = cmd_set_parsed,
3023 .help_str = "set nbport|nbcore|burst|verbose <value>",
3025 (void *)&cmd_set_set,
3026 (void *)&cmd_set_what,
3027 (void *)&cmd_set_value,
3032 /* *** SET LOG LEVEL CONFIGURATION *** */
3034 struct cmd_set_log_result {
3035 cmdline_fixed_string_t set;
3036 cmdline_fixed_string_t log;
3037 cmdline_fixed_string_t type;
3042 cmd_set_log_parsed(void *parsed_result,
3043 __attribute__((unused)) struct cmdline *cl,
3044 __attribute__((unused)) void *data)
3046 struct cmd_set_log_result *res;
3049 res = parsed_result;
3050 if (!strcmp(res->type, "global"))
3051 rte_log_set_global_level(res->level);
3053 ret = rte_log_set_level_regexp(res->type, res->level);
3055 printf("Unable to set log level\n");
3059 cmdline_parse_token_string_t cmd_set_log_set =
3060 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3061 cmdline_parse_token_string_t cmd_set_log_log =
3062 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3063 cmdline_parse_token_string_t cmd_set_log_type =
3064 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3065 cmdline_parse_token_num_t cmd_set_log_level =
3066 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3068 cmdline_parse_inst_t cmd_set_log = {
3069 .f = cmd_set_log_parsed,
3071 .help_str = "set log global|<type> <level>",
3073 (void *)&cmd_set_log_set,
3074 (void *)&cmd_set_log_log,
3075 (void *)&cmd_set_log_type,
3076 (void *)&cmd_set_log_level,
3081 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3083 struct cmd_set_txpkts_result {
3084 cmdline_fixed_string_t cmd_keyword;
3085 cmdline_fixed_string_t txpkts;
3086 cmdline_fixed_string_t seg_lengths;
3090 cmd_set_txpkts_parsed(void *parsed_result,
3091 __attribute__((unused)) struct cmdline *cl,
3092 __attribute__((unused)) void *data)
3094 struct cmd_set_txpkts_result *res;
3095 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3096 unsigned int nb_segs;
3098 res = parsed_result;
3099 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3100 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3102 set_tx_pkt_segments(seg_lengths, nb_segs);
3105 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3106 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3107 cmd_keyword, "set");
3108 cmdline_parse_token_string_t cmd_set_txpkts_name =
3109 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3111 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3112 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3115 cmdline_parse_inst_t cmd_set_txpkts = {
3116 .f = cmd_set_txpkts_parsed,
3118 .help_str = "set txpkts <len0[,len1]*>",
3120 (void *)&cmd_set_txpkts_keyword,
3121 (void *)&cmd_set_txpkts_name,
3122 (void *)&cmd_set_txpkts_lengths,
3127 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3129 struct cmd_set_txsplit_result {
3130 cmdline_fixed_string_t cmd_keyword;
3131 cmdline_fixed_string_t txsplit;
3132 cmdline_fixed_string_t mode;
3136 cmd_set_txsplit_parsed(void *parsed_result,
3137 __attribute__((unused)) struct cmdline *cl,
3138 __attribute__((unused)) void *data)
3140 struct cmd_set_txsplit_result *res;
3142 res = parsed_result;
3143 set_tx_pkt_split(res->mode);
3146 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3147 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3148 cmd_keyword, "set");
3149 cmdline_parse_token_string_t cmd_set_txsplit_name =
3150 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3151 txsplit, "txsplit");
3152 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3153 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3156 cmdline_parse_inst_t cmd_set_txsplit = {
3157 .f = cmd_set_txsplit_parsed,
3159 .help_str = "set txsplit on|off|rand",
3161 (void *)&cmd_set_txsplit_keyword,
3162 (void *)&cmd_set_txsplit_name,
3163 (void *)&cmd_set_txsplit_mode,
3168 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3169 struct cmd_rx_vlan_filter_all_result {
3170 cmdline_fixed_string_t rx_vlan;
3171 cmdline_fixed_string_t what;
3172 cmdline_fixed_string_t all;
3177 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3178 __attribute__((unused)) struct cmdline *cl,
3179 __attribute__((unused)) void *data)
3181 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3183 if (!strcmp(res->what, "add"))
3184 rx_vlan_all_filter_set(res->port_id, 1);
3186 rx_vlan_all_filter_set(res->port_id, 0);
3189 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3190 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3191 rx_vlan, "rx_vlan");
3192 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3193 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3195 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3196 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3198 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3199 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3202 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3203 .f = cmd_rx_vlan_filter_all_parsed,
3205 .help_str = "rx_vlan add|rm all <port_id>: "
3206 "Add/Remove all identifiers to/from the set of VLAN "
3207 "identifiers filtered by a port",
3209 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3210 (void *)&cmd_rx_vlan_filter_all_what,
3211 (void *)&cmd_rx_vlan_filter_all_all,
3212 (void *)&cmd_rx_vlan_filter_all_portid,
3217 /* *** VLAN OFFLOAD SET ON A PORT *** */
3218 struct cmd_vlan_offload_result {
3219 cmdline_fixed_string_t vlan;
3220 cmdline_fixed_string_t set;
3221 cmdline_fixed_string_t vlan_type;
3222 cmdline_fixed_string_t what;
3223 cmdline_fixed_string_t on;
3224 cmdline_fixed_string_t port_id;
3228 cmd_vlan_offload_parsed(void *parsed_result,
3229 __attribute__((unused)) struct cmdline *cl,
3230 __attribute__((unused)) void *data)
3233 struct cmd_vlan_offload_result *res = parsed_result;
3236 portid_t port_id = 0;
3240 len = strnlen(str, STR_TOKEN_SIZE);
3242 /* Get port_id first */
3250 tmp = strtoul(str, NULL, 0);
3251 /* If port_id greater that what portid_t can represent, return */
3252 if(tmp >= RTE_MAX_ETHPORTS)
3254 port_id = (portid_t)tmp;
3256 if (!strcmp(res->on, "on"))
3261 if (!strcmp(res->what, "strip"))
3262 rx_vlan_strip_set(port_id, on);
3263 else if(!strcmp(res->what, "stripq")){
3264 uint16_t queue_id = 0;
3266 /* No queue_id, return */
3268 printf("must specify (port,queue_id)\n");
3271 tmp = strtoul(str + i + 1, NULL, 0);
3272 /* If queue_id greater that what 16-bits can represent, return */
3276 queue_id = (uint16_t)tmp;
3277 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3279 else if (!strcmp(res->what, "filter"))
3280 rx_vlan_filter_set(port_id, on);
3282 vlan_extend_set(port_id, on);
3287 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3288 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3290 cmdline_parse_token_string_t cmd_vlan_offload_set =
3291 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3293 cmdline_parse_token_string_t cmd_vlan_offload_what =
3294 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3295 what, "strip#filter#qinq#stripq");
3296 cmdline_parse_token_string_t cmd_vlan_offload_on =
3297 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3299 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3300 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3303 cmdline_parse_inst_t cmd_vlan_offload = {
3304 .f = cmd_vlan_offload_parsed,
3306 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3307 "<port_id[,queue_id]>: "
3308 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3310 (void *)&cmd_vlan_offload_vlan,
3311 (void *)&cmd_vlan_offload_set,
3312 (void *)&cmd_vlan_offload_what,
3313 (void *)&cmd_vlan_offload_on,
3314 (void *)&cmd_vlan_offload_portid,
3319 /* *** VLAN TPID SET ON A PORT *** */
3320 struct cmd_vlan_tpid_result {
3321 cmdline_fixed_string_t vlan;
3322 cmdline_fixed_string_t set;
3323 cmdline_fixed_string_t vlan_type;
3324 cmdline_fixed_string_t what;
3330 cmd_vlan_tpid_parsed(void *parsed_result,
3331 __attribute__((unused)) struct cmdline *cl,
3332 __attribute__((unused)) void *data)
3334 struct cmd_vlan_tpid_result *res = parsed_result;
3335 enum rte_vlan_type vlan_type;
3337 if (!strcmp(res->vlan_type, "inner"))
3338 vlan_type = ETH_VLAN_TYPE_INNER;
3339 else if (!strcmp(res->vlan_type, "outer"))
3340 vlan_type = ETH_VLAN_TYPE_OUTER;
3342 printf("Unknown vlan type\n");
3345 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3348 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3349 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3351 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3352 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3354 cmdline_parse_token_string_t cmd_vlan_type =
3355 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3356 vlan_type, "inner#outer");
3357 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3358 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3360 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3361 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3363 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3364 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3367 cmdline_parse_inst_t cmd_vlan_tpid = {
3368 .f = cmd_vlan_tpid_parsed,
3370 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3371 "Set the VLAN Ether type",
3373 (void *)&cmd_vlan_tpid_vlan,
3374 (void *)&cmd_vlan_tpid_set,
3375 (void *)&cmd_vlan_type,
3376 (void *)&cmd_vlan_tpid_what,
3377 (void *)&cmd_vlan_tpid_tpid,
3378 (void *)&cmd_vlan_tpid_portid,
3383 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3384 struct cmd_rx_vlan_filter_result {
3385 cmdline_fixed_string_t rx_vlan;
3386 cmdline_fixed_string_t what;
3392 cmd_rx_vlan_filter_parsed(void *parsed_result,
3393 __attribute__((unused)) struct cmdline *cl,
3394 __attribute__((unused)) void *data)
3396 struct cmd_rx_vlan_filter_result *res = parsed_result;
3398 if (!strcmp(res->what, "add"))
3399 rx_vft_set(res->port_id, res->vlan_id, 1);
3401 rx_vft_set(res->port_id, res->vlan_id, 0);
3404 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3405 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3406 rx_vlan, "rx_vlan");
3407 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3408 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3410 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3411 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3413 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3414 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3417 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3418 .f = cmd_rx_vlan_filter_parsed,
3420 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3421 "Add/Remove a VLAN identifier to/from the set of VLAN "
3422 "identifiers filtered by a port",
3424 (void *)&cmd_rx_vlan_filter_rx_vlan,
3425 (void *)&cmd_rx_vlan_filter_what,
3426 (void *)&cmd_rx_vlan_filter_vlanid,
3427 (void *)&cmd_rx_vlan_filter_portid,
3432 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3433 struct cmd_tx_vlan_set_result {
3434 cmdline_fixed_string_t tx_vlan;
3435 cmdline_fixed_string_t set;
3441 cmd_tx_vlan_set_parsed(void *parsed_result,
3442 __attribute__((unused)) struct cmdline *cl,
3443 __attribute__((unused)) void *data)
3445 struct cmd_tx_vlan_set_result *res = parsed_result;
3447 if (!port_is_stopped(res->port_id)) {
3448 printf("Please stop port %d first\n", res->port_id);
3452 tx_vlan_set(res->port_id, res->vlan_id);
3454 cmd_reconfig_device_queue(res->port_id, 1, 1);
3457 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3458 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3459 tx_vlan, "tx_vlan");
3460 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3461 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3463 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3464 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3466 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3467 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3470 cmdline_parse_inst_t cmd_tx_vlan_set = {
3471 .f = cmd_tx_vlan_set_parsed,
3473 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3474 "Enable hardware insertion of a single VLAN header "
3475 "with a given TAG Identifier in packets sent on a port",
3477 (void *)&cmd_tx_vlan_set_tx_vlan,
3478 (void *)&cmd_tx_vlan_set_set,
3479 (void *)&cmd_tx_vlan_set_portid,
3480 (void *)&cmd_tx_vlan_set_vlanid,
3485 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3486 struct cmd_tx_vlan_set_qinq_result {
3487 cmdline_fixed_string_t tx_vlan;
3488 cmdline_fixed_string_t set;
3491 uint16_t vlan_id_outer;
3495 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3496 __attribute__((unused)) struct cmdline *cl,
3497 __attribute__((unused)) void *data)
3499 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3501 if (!port_is_stopped(res->port_id)) {
3502 printf("Please stop port %d first\n", res->port_id);
3506 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3508 cmd_reconfig_device_queue(res->port_id, 1, 1);
3511 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3512 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3513 tx_vlan, "tx_vlan");
3514 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3515 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3517 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3518 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3520 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3521 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3523 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3524 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3525 vlan_id_outer, UINT16);
3527 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3528 .f = cmd_tx_vlan_set_qinq_parsed,
3530 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3531 "Enable hardware insertion of double VLAN header "
3532 "with given TAG Identifiers in packets sent on a port",
3534 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3535 (void *)&cmd_tx_vlan_set_qinq_set,
3536 (void *)&cmd_tx_vlan_set_qinq_portid,
3537 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3538 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3543 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3544 struct cmd_tx_vlan_set_pvid_result {
3545 cmdline_fixed_string_t tx_vlan;
3546 cmdline_fixed_string_t set;
3547 cmdline_fixed_string_t pvid;
3550 cmdline_fixed_string_t mode;
3554 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3555 __attribute__((unused)) struct cmdline *cl,
3556 __attribute__((unused)) void *data)
3558 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3560 if (strcmp(res->mode, "on") == 0)
3561 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3563 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3566 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3567 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3568 tx_vlan, "tx_vlan");
3569 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3570 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3572 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3573 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3575 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3576 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3578 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3579 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3581 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3582 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3585 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3586 .f = cmd_tx_vlan_set_pvid_parsed,
3588 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3590 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3591 (void *)&cmd_tx_vlan_set_pvid_set,
3592 (void *)&cmd_tx_vlan_set_pvid_pvid,
3593 (void *)&cmd_tx_vlan_set_pvid_port_id,
3594 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3595 (void *)&cmd_tx_vlan_set_pvid_mode,
3600 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3601 struct cmd_tx_vlan_reset_result {
3602 cmdline_fixed_string_t tx_vlan;
3603 cmdline_fixed_string_t reset;
3608 cmd_tx_vlan_reset_parsed(void *parsed_result,
3609 __attribute__((unused)) struct cmdline *cl,
3610 __attribute__((unused)) void *data)
3612 struct cmd_tx_vlan_reset_result *res = parsed_result;
3614 if (!port_is_stopped(res->port_id)) {
3615 printf("Please stop port %d first\n", res->port_id);
3619 tx_vlan_reset(res->port_id);
3621 cmd_reconfig_device_queue(res->port_id, 1, 1);
3624 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3625 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3626 tx_vlan, "tx_vlan");
3627 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3628 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3630 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3631 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3634 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3635 .f = cmd_tx_vlan_reset_parsed,
3637 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3638 "VLAN header in packets sent on a port",
3640 (void *)&cmd_tx_vlan_reset_tx_vlan,
3641 (void *)&cmd_tx_vlan_reset_reset,
3642 (void *)&cmd_tx_vlan_reset_portid,
3648 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3649 struct cmd_csum_result {
3650 cmdline_fixed_string_t csum;
3651 cmdline_fixed_string_t mode;
3652 cmdline_fixed_string_t proto;
3653 cmdline_fixed_string_t hwsw;
3658 csum_show(int port_id)
3660 struct rte_eth_dev_info dev_info;
3661 uint64_t tx_offloads;
3663 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3664 printf("Parse tunnel is %s\n",
3665 (ports[port_id].parse_tunnel) ? "on" : "off");
3666 printf("IP checksum offload is %s\n",
3667 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3668 printf("UDP checksum offload is %s\n",
3669 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3670 printf("TCP checksum offload is %s\n",
3671 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3672 printf("SCTP checksum offload is %s\n",
3673 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3674 printf("Outer-Ip checksum offload is %s\n",
3675 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3677 /* display warnings if configuration is not supported by the NIC */
3678 rte_eth_dev_info_get(port_id, &dev_info);
3679 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3680 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3681 printf("Warning: hardware IP checksum enabled but not "
3682 "supported by port %d\n", port_id);
3684 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3685 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3686 printf("Warning: hardware UDP checksum enabled but not "
3687 "supported by port %d\n", port_id);
3689 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3690 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3691 printf("Warning: hardware TCP checksum enabled but not "
3692 "supported by port %d\n", port_id);
3694 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3695 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3696 printf("Warning: hardware SCTP checksum enabled but not "
3697 "supported by port %d\n", port_id);
3699 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3700 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3701 printf("Warning: hardware outer IP checksum enabled but not "
3702 "supported by port %d\n", port_id);
3707 cmd_csum_parsed(void *parsed_result,
3708 __attribute__((unused)) struct cmdline *cl,
3709 __attribute__((unused)) void *data)
3711 struct cmd_csum_result *res = parsed_result;
3713 uint64_t csum_offloads = 0;
3714 struct rte_eth_dev_info dev_info;
3716 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3717 printf("invalid port %d\n", res->port_id);
3720 if (!port_is_stopped(res->port_id)) {
3721 printf("Please stop port %d first\n", res->port_id);
3725 rte_eth_dev_info_get(res->port_id, &dev_info);
3726 if (!strcmp(res->mode, "set")) {
3728 if (!strcmp(res->hwsw, "hw"))
3731 if (!strcmp(res->proto, "ip")) {
3732 if (hw == 0 || (dev_info.tx_offload_capa &
3733 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
3734 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3736 printf("IP checksum offload is not supported "
3737 "by port %u\n", res->port_id);
3739 } else if (!strcmp(res->proto, "udp")) {
3740 if (hw == 0 || (dev_info.tx_offload_capa &
3741 DEV_TX_OFFLOAD_UDP_CKSUM)) {
3742 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3744 printf("UDP checksum offload is not supported "
3745 "by port %u\n", res->port_id);
3747 } else if (!strcmp(res->proto, "tcp")) {
3748 if (hw == 0 || (dev_info.tx_offload_capa &
3749 DEV_TX_OFFLOAD_TCP_CKSUM)) {
3750 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3752 printf("TCP checksum offload is not supported "
3753 "by port %u\n", res->port_id);
3755 } else if (!strcmp(res->proto, "sctp")) {
3756 if (hw == 0 || (dev_info.tx_offload_capa &
3757 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
3758 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3760 printf("SCTP checksum offload is not supported "
3761 "by port %u\n", res->port_id);
3763 } else if (!strcmp(res->proto, "outer-ip")) {
3764 if (hw == 0 || (dev_info.tx_offload_capa &
3765 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
3767 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3769 printf("Outer IP checksum offload is not "
3770 "supported by port %u\n", res->port_id);
3775 ports[res->port_id].dev_conf.txmode.offloads |=
3778 ports[res->port_id].dev_conf.txmode.offloads &=
3782 csum_show(res->port_id);
3784 cmd_reconfig_device_queue(res->port_id, 1, 1);
3787 cmdline_parse_token_string_t cmd_csum_csum =
3788 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3790 cmdline_parse_token_string_t cmd_csum_mode =
3791 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3793 cmdline_parse_token_string_t cmd_csum_proto =
3794 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3795 proto, "ip#tcp#udp#sctp#outer-ip");
3796 cmdline_parse_token_string_t cmd_csum_hwsw =
3797 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3799 cmdline_parse_token_num_t cmd_csum_portid =
3800 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3803 cmdline_parse_inst_t cmd_csum_set = {
3804 .f = cmd_csum_parsed,
3806 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3807 "Enable/Disable hardware calculation of L3/L4 checksum when "
3808 "using csum forward engine",
3810 (void *)&cmd_csum_csum,
3811 (void *)&cmd_csum_mode,
3812 (void *)&cmd_csum_proto,
3813 (void *)&cmd_csum_hwsw,
3814 (void *)&cmd_csum_portid,
3819 cmdline_parse_token_string_t cmd_csum_mode_show =
3820 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3823 cmdline_parse_inst_t cmd_csum_show = {
3824 .f = cmd_csum_parsed,
3826 .help_str = "csum show <port_id>: Show checksum offload configuration",
3828 (void *)&cmd_csum_csum,
3829 (void *)&cmd_csum_mode_show,
3830 (void *)&cmd_csum_portid,
3835 /* Enable/disable tunnel parsing */
3836 struct cmd_csum_tunnel_result {
3837 cmdline_fixed_string_t csum;
3838 cmdline_fixed_string_t parse;
3839 cmdline_fixed_string_t onoff;
3844 cmd_csum_tunnel_parsed(void *parsed_result,
3845 __attribute__((unused)) struct cmdline *cl,
3846 __attribute__((unused)) void *data)
3848 struct cmd_csum_tunnel_result *res = parsed_result;
3850 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3853 if (!strcmp(res->onoff, "on"))
3854 ports[res->port_id].parse_tunnel = 1;
3856 ports[res->port_id].parse_tunnel = 0;
3858 csum_show(res->port_id);
3861 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3862 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3864 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3865 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3866 parse, "parse_tunnel");
3867 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3868 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3870 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3871 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3874 cmdline_parse_inst_t cmd_csum_tunnel = {
3875 .f = cmd_csum_tunnel_parsed,
3877 .help_str = "csum parse_tunnel on|off <port_id>: "
3878 "Enable/Disable parsing of tunnels for csum engine",
3880 (void *)&cmd_csum_tunnel_csum,
3881 (void *)&cmd_csum_tunnel_parse,
3882 (void *)&cmd_csum_tunnel_onoff,
3883 (void *)&cmd_csum_tunnel_portid,
3888 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3889 struct cmd_tso_set_result {
3890 cmdline_fixed_string_t tso;
3891 cmdline_fixed_string_t mode;
3897 cmd_tso_set_parsed(void *parsed_result,
3898 __attribute__((unused)) struct cmdline *cl,
3899 __attribute__((unused)) void *data)
3901 struct cmd_tso_set_result *res = parsed_result;
3902 struct rte_eth_dev_info dev_info;
3904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3906 if (!port_is_stopped(res->port_id)) {
3907 printf("Please stop port %d first\n", res->port_id);
3911 if (!strcmp(res->mode, "set"))
3912 ports[res->port_id].tso_segsz = res->tso_segsz;
3914 rte_eth_dev_info_get(res->port_id, &dev_info);
3915 if ((ports[res->port_id].tso_segsz != 0) &&
3916 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3917 printf("Error: TSO is not supported by port %d\n",
3922 if (ports[res->port_id].tso_segsz == 0) {
3923 ports[res->port_id].dev_conf.txmode.offloads &=
3924 ~DEV_TX_OFFLOAD_TCP_TSO;
3925 printf("TSO for non-tunneled packets is disabled\n");
3927 ports[res->port_id].dev_conf.txmode.offloads |=
3928 DEV_TX_OFFLOAD_TCP_TSO;
3929 printf("TSO segment size for non-tunneled packets is %d\n",
3930 ports[res->port_id].tso_segsz);
3933 /* display warnings if configuration is not supported by the NIC */
3934 rte_eth_dev_info_get(res->port_id, &dev_info);
3935 if ((ports[res->port_id].tso_segsz != 0) &&
3936 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3937 printf("Warning: TSO enabled but not "
3938 "supported by port %d\n", res->port_id);
3941 cmd_reconfig_device_queue(res->port_id, 1, 1);
3944 cmdline_parse_token_string_t cmd_tso_set_tso =
3945 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3947 cmdline_parse_token_string_t cmd_tso_set_mode =
3948 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3950 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3951 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3953 cmdline_parse_token_num_t cmd_tso_set_portid =
3954 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3957 cmdline_parse_inst_t cmd_tso_set = {
3958 .f = cmd_tso_set_parsed,
3960 .help_str = "tso set <tso_segsz> <port_id>: "
3961 "Set TSO segment size of non-tunneled packets for csum engine "
3964 (void *)&cmd_tso_set_tso,
3965 (void *)&cmd_tso_set_mode,
3966 (void *)&cmd_tso_set_tso_segsz,
3967 (void *)&cmd_tso_set_portid,
3972 cmdline_parse_token_string_t cmd_tso_show_mode =
3973 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3977 cmdline_parse_inst_t cmd_tso_show = {
3978 .f = cmd_tso_set_parsed,
3980 .help_str = "tso show <port_id>: "
3981 "Show TSO segment size of non-tunneled packets for csum engine",
3983 (void *)&cmd_tso_set_tso,
3984 (void *)&cmd_tso_show_mode,
3985 (void *)&cmd_tso_set_portid,
3990 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3991 struct cmd_tunnel_tso_set_result {
3992 cmdline_fixed_string_t tso;
3993 cmdline_fixed_string_t mode;
3998 static struct rte_eth_dev_info
3999 check_tunnel_tso_nic_support(portid_t port_id)
4001 struct rte_eth_dev_info dev_info;
4003 rte_eth_dev_info_get(port_id, &dev_info);
4004 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4005 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4006 "not enabled for port %d\n", port_id);
4007 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4008 printf("Warning: GRE TUNNEL TSO not supported therefore "
4009 "not enabled for port %d\n", port_id);
4010 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4011 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4012 "not enabled for port %d\n", port_id);
4013 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4014 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4015 "not enabled for port %d\n", port_id);
4020 cmd_tunnel_tso_set_parsed(void *parsed_result,
4021 __attribute__((unused)) struct cmdline *cl,
4022 __attribute__((unused)) void *data)
4024 struct cmd_tunnel_tso_set_result *res = parsed_result;
4025 struct rte_eth_dev_info dev_info;
4027 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4029 if (!port_is_stopped(res->port_id)) {
4030 printf("Please stop port %d first\n", res->port_id);
4034 if (!strcmp(res->mode, "set"))
4035 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4037 dev_info = check_tunnel_tso_nic_support(res->port_id);
4038 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4039 ports[res->port_id].dev_conf.txmode.offloads &=
4040 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4041 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4042 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4043 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4044 printf("TSO for tunneled packets is disabled\n");
4046 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4047 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4048 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4049 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4051 ports[res->port_id].dev_conf.txmode.offloads |=
4052 (tso_offloads & dev_info.tx_offload_capa);
4053 printf("TSO segment size for tunneled packets is %d\n",
4054 ports[res->port_id].tunnel_tso_segsz);
4056 /* Below conditions are needed to make it work:
4057 * (1) tunnel TSO is supported by the NIC;
4058 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4060 * (3) for tunneled pkts with outer L3 of IPv4,
4061 * "csum set outer-ip" must be set to hw, because after tso,
4062 * total_len of outer IP header is changed, and the checksum
4063 * of outer IP header calculated by sw should be wrong; that
4064 * is not necessary for IPv6 tunneled pkts because there's no
4065 * checksum in IP header anymore.
4068 if (!ports[res->port_id].parse_tunnel)
4069 printf("Warning: csum parse_tunnel must be set "
4070 "so that tunneled packets are recognized\n");
4071 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4072 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4073 printf("Warning: csum set outer-ip must be set to hw "
4074 "if outer L3 is IPv4; not necessary for IPv6\n");
4077 cmd_reconfig_device_queue(res->port_id, 1, 1);
4080 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4081 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4083 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4084 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4086 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4087 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4089 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4090 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4093 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4094 .f = cmd_tunnel_tso_set_parsed,
4096 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4097 "Set TSO segment size of tunneled packets for csum engine "
4100 (void *)&cmd_tunnel_tso_set_tso,
4101 (void *)&cmd_tunnel_tso_set_mode,
4102 (void *)&cmd_tunnel_tso_set_tso_segsz,
4103 (void *)&cmd_tunnel_tso_set_portid,
4108 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4109 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4113 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4114 .f = cmd_tunnel_tso_set_parsed,
4116 .help_str = "tunnel_tso show <port_id> "
4117 "Show TSO segment size of tunneled packets for csum engine",
4119 (void *)&cmd_tunnel_tso_set_tso,
4120 (void *)&cmd_tunnel_tso_show_mode,
4121 (void *)&cmd_tunnel_tso_set_portid,
4126 /* *** SET GRO FOR A PORT *** */
4127 struct cmd_gro_enable_result {
4128 cmdline_fixed_string_t cmd_set;
4129 cmdline_fixed_string_t cmd_port;
4130 cmdline_fixed_string_t cmd_keyword;
4131 cmdline_fixed_string_t cmd_onoff;
4136 cmd_gro_enable_parsed(void *parsed_result,
4137 __attribute__((unused)) struct cmdline *cl,
4138 __attribute__((unused)) void *data)
4140 struct cmd_gro_enable_result *res;
4142 res = parsed_result;
4143 if (!strcmp(res->cmd_keyword, "gro"))
4144 setup_gro(res->cmd_onoff, res->cmd_pid);
4147 cmdline_parse_token_string_t cmd_gro_enable_set =
4148 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4150 cmdline_parse_token_string_t cmd_gro_enable_port =
4151 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4152 cmd_keyword, "port");
4153 cmdline_parse_token_num_t cmd_gro_enable_pid =
4154 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4156 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4157 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4158 cmd_keyword, "gro");
4159 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4160 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4161 cmd_onoff, "on#off");
4163 cmdline_parse_inst_t cmd_gro_enable = {
4164 .f = cmd_gro_enable_parsed,
4166 .help_str = "set port <port_id> gro on|off",
4168 (void *)&cmd_gro_enable_set,
4169 (void *)&cmd_gro_enable_port,
4170 (void *)&cmd_gro_enable_pid,
4171 (void *)&cmd_gro_enable_keyword,
4172 (void *)&cmd_gro_enable_onoff,
4177 /* *** DISPLAY GRO CONFIGURATION *** */
4178 struct cmd_gro_show_result {
4179 cmdline_fixed_string_t cmd_show;
4180 cmdline_fixed_string_t cmd_port;
4181 cmdline_fixed_string_t cmd_keyword;
4186 cmd_gro_show_parsed(void *parsed_result,
4187 __attribute__((unused)) struct cmdline *cl,
4188 __attribute__((unused)) void *data)
4190 struct cmd_gro_show_result *res;
4192 res = parsed_result;
4193 if (!strcmp(res->cmd_keyword, "gro"))
4194 show_gro(res->cmd_pid);
4197 cmdline_parse_token_string_t cmd_gro_show_show =
4198 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4200 cmdline_parse_token_string_t cmd_gro_show_port =
4201 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4203 cmdline_parse_token_num_t cmd_gro_show_pid =
4204 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4206 cmdline_parse_token_string_t cmd_gro_show_keyword =
4207 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4208 cmd_keyword, "gro");
4210 cmdline_parse_inst_t cmd_gro_show = {
4211 .f = cmd_gro_show_parsed,
4213 .help_str = "show port <port_id> gro",
4215 (void *)&cmd_gro_show_show,
4216 (void *)&cmd_gro_show_port,
4217 (void *)&cmd_gro_show_pid,
4218 (void *)&cmd_gro_show_keyword,
4223 /* *** SET FLUSH CYCLES FOR GRO *** */
4224 struct cmd_gro_flush_result {
4225 cmdline_fixed_string_t cmd_set;
4226 cmdline_fixed_string_t cmd_keyword;
4227 cmdline_fixed_string_t cmd_flush;
4232 cmd_gro_flush_parsed(void *parsed_result,
4233 __attribute__((unused)) struct cmdline *cl,
4234 __attribute__((unused)) void *data)
4236 struct cmd_gro_flush_result *res;
4238 res = parsed_result;
4239 if ((!strcmp(res->cmd_keyword, "gro")) &&
4240 (!strcmp(res->cmd_flush, "flush")))
4241 setup_gro_flush_cycles(res->cmd_cycles);
4244 cmdline_parse_token_string_t cmd_gro_flush_set =
4245 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4247 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4248 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4249 cmd_keyword, "gro");
4250 cmdline_parse_token_string_t cmd_gro_flush_flush =
4251 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4252 cmd_flush, "flush");
4253 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4254 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4257 cmdline_parse_inst_t cmd_gro_flush = {
4258 .f = cmd_gro_flush_parsed,
4260 .help_str = "set gro flush <cycles>",
4262 (void *)&cmd_gro_flush_set,
4263 (void *)&cmd_gro_flush_keyword,
4264 (void *)&cmd_gro_flush_flush,
4265 (void *)&cmd_gro_flush_cycles,
4270 /* *** ENABLE/DISABLE GSO *** */
4271 struct cmd_gso_enable_result {
4272 cmdline_fixed_string_t cmd_set;
4273 cmdline_fixed_string_t cmd_port;
4274 cmdline_fixed_string_t cmd_keyword;
4275 cmdline_fixed_string_t cmd_mode;
4280 cmd_gso_enable_parsed(void *parsed_result,
4281 __attribute__((unused)) struct cmdline *cl,
4282 __attribute__((unused)) void *data)
4284 struct cmd_gso_enable_result *res;
4286 res = parsed_result;
4287 if (!strcmp(res->cmd_keyword, "gso"))
4288 setup_gso(res->cmd_mode, res->cmd_pid);
4291 cmdline_parse_token_string_t cmd_gso_enable_set =
4292 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4294 cmdline_parse_token_string_t cmd_gso_enable_port =
4295 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4297 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4298 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4299 cmd_keyword, "gso");
4300 cmdline_parse_token_string_t cmd_gso_enable_mode =
4301 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4302 cmd_mode, "on#off");
4303 cmdline_parse_token_num_t cmd_gso_enable_pid =
4304 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4307 cmdline_parse_inst_t cmd_gso_enable = {
4308 .f = cmd_gso_enable_parsed,
4310 .help_str = "set port <port_id> gso on|off",
4312 (void *)&cmd_gso_enable_set,
4313 (void *)&cmd_gso_enable_port,
4314 (void *)&cmd_gso_enable_pid,
4315 (void *)&cmd_gso_enable_keyword,
4316 (void *)&cmd_gso_enable_mode,
4321 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4322 struct cmd_gso_size_result {
4323 cmdline_fixed_string_t cmd_set;
4324 cmdline_fixed_string_t cmd_keyword;
4325 cmdline_fixed_string_t cmd_segsz;
4330 cmd_gso_size_parsed(void *parsed_result,
4331 __attribute__((unused)) struct cmdline *cl,
4332 __attribute__((unused)) void *data)
4334 struct cmd_gso_size_result *res = parsed_result;
4336 if (test_done == 0) {
4337 printf("Before setting GSO segsz, please first"
4338 " stop fowarding\n");
4342 if (!strcmp(res->cmd_keyword, "gso") &&
4343 !strcmp(res->cmd_segsz, "segsz")) {
4344 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4345 printf("gso_size should be larger than %zu."
4346 " Please input a legal value\n",
4347 RTE_GSO_SEG_SIZE_MIN);
4349 gso_max_segment_size = res->cmd_size;
4353 cmdline_parse_token_string_t cmd_gso_size_set =
4354 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4356 cmdline_parse_token_string_t cmd_gso_size_keyword =
4357 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4358 cmd_keyword, "gso");
4359 cmdline_parse_token_string_t cmd_gso_size_segsz =
4360 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4361 cmd_segsz, "segsz");
4362 cmdline_parse_token_num_t cmd_gso_size_size =
4363 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4366 cmdline_parse_inst_t cmd_gso_size = {
4367 .f = cmd_gso_size_parsed,
4369 .help_str = "set gso segsz <length>",
4371 (void *)&cmd_gso_size_set,
4372 (void *)&cmd_gso_size_keyword,
4373 (void *)&cmd_gso_size_segsz,
4374 (void *)&cmd_gso_size_size,
4379 /* *** SHOW GSO CONFIGURATION *** */
4380 struct cmd_gso_show_result {
4381 cmdline_fixed_string_t cmd_show;
4382 cmdline_fixed_string_t cmd_port;
4383 cmdline_fixed_string_t cmd_keyword;
4388 cmd_gso_show_parsed(void *parsed_result,
4389 __attribute__((unused)) struct cmdline *cl,
4390 __attribute__((unused)) void *data)
4392 struct cmd_gso_show_result *res = parsed_result;
4394 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4395 printf("invalid port id %u\n", res->cmd_pid);
4398 if (!strcmp(res->cmd_keyword, "gso")) {
4399 if (gso_ports[res->cmd_pid].enable) {
4400 printf("Max GSO'd packet size: %uB\n"
4401 "Supported GSO types: TCP/IPv4, "
4402 "VxLAN with inner TCP/IPv4 packet, "
4403 "GRE with inner TCP/IPv4 packet\n",
4404 gso_max_segment_size);
4406 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4410 cmdline_parse_token_string_t cmd_gso_show_show =
4411 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4413 cmdline_parse_token_string_t cmd_gso_show_port =
4414 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4416 cmdline_parse_token_string_t cmd_gso_show_keyword =
4417 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4418 cmd_keyword, "gso");
4419 cmdline_parse_token_num_t cmd_gso_show_pid =
4420 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4423 cmdline_parse_inst_t cmd_gso_show = {
4424 .f = cmd_gso_show_parsed,
4426 .help_str = "show port <port_id> gso",
4428 (void *)&cmd_gso_show_show,
4429 (void *)&cmd_gso_show_port,
4430 (void *)&cmd_gso_show_pid,
4431 (void *)&cmd_gso_show_keyword,
4436 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4437 struct cmd_set_flush_rx {
4438 cmdline_fixed_string_t set;
4439 cmdline_fixed_string_t flush_rx;
4440 cmdline_fixed_string_t mode;
4444 cmd_set_flush_rx_parsed(void *parsed_result,
4445 __attribute__((unused)) struct cmdline *cl,
4446 __attribute__((unused)) void *data)
4448 struct cmd_set_flush_rx *res = parsed_result;
4449 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4452 cmdline_parse_token_string_t cmd_setflushrx_set =
4453 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4455 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4456 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4457 flush_rx, "flush_rx");
4458 cmdline_parse_token_string_t cmd_setflushrx_mode =
4459 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4463 cmdline_parse_inst_t cmd_set_flush_rx = {
4464 .f = cmd_set_flush_rx_parsed,
4465 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4468 (void *)&cmd_setflushrx_set,
4469 (void *)&cmd_setflushrx_flush_rx,
4470 (void *)&cmd_setflushrx_mode,
4475 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4476 struct cmd_set_link_check {
4477 cmdline_fixed_string_t set;
4478 cmdline_fixed_string_t link_check;
4479 cmdline_fixed_string_t mode;
4483 cmd_set_link_check_parsed(void *parsed_result,
4484 __attribute__((unused)) struct cmdline *cl,
4485 __attribute__((unused)) void *data)
4487 struct cmd_set_link_check *res = parsed_result;
4488 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4491 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4492 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4494 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4495 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4496 link_check, "link_check");
4497 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4498 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4502 cmdline_parse_inst_t cmd_set_link_check = {
4503 .f = cmd_set_link_check_parsed,
4504 .help_str = "set link_check on|off: Enable/Disable link status check "
4505 "when starting/stopping a port",
4508 (void *)&cmd_setlinkcheck_set,
4509 (void *)&cmd_setlinkcheck_link_check,
4510 (void *)&cmd_setlinkcheck_mode,
4515 /* *** SET NIC BYPASS MODE *** */
4516 struct cmd_set_bypass_mode_result {
4517 cmdline_fixed_string_t set;
4518 cmdline_fixed_string_t bypass;
4519 cmdline_fixed_string_t mode;
4520 cmdline_fixed_string_t value;
4525 cmd_set_bypass_mode_parsed(void *parsed_result,
4526 __attribute__((unused)) struct cmdline *cl,
4527 __attribute__((unused)) void *data)
4529 struct cmd_set_bypass_mode_result *res = parsed_result;
4530 portid_t port_id = res->port_id;
4531 int32_t rc = -EINVAL;
4533 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4534 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4536 if (!strcmp(res->value, "bypass"))
4537 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4538 else if (!strcmp(res->value, "isolate"))
4539 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4541 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4543 /* Set the bypass mode for the relevant port. */
4544 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4547 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4550 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4551 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4553 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4554 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4556 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4557 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4559 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4560 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4561 value, "normal#bypass#isolate");
4562 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4563 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4566 cmdline_parse_inst_t cmd_set_bypass_mode = {
4567 .f = cmd_set_bypass_mode_parsed,
4568 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4569 "Set the NIC bypass mode for port_id",
4572 (void *)&cmd_setbypass_mode_set,
4573 (void *)&cmd_setbypass_mode_bypass,
4574 (void *)&cmd_setbypass_mode_mode,
4575 (void *)&cmd_setbypass_mode_value,
4576 (void *)&cmd_setbypass_mode_port,
4581 /* *** SET NIC BYPASS EVENT *** */
4582 struct cmd_set_bypass_event_result {
4583 cmdline_fixed_string_t set;
4584 cmdline_fixed_string_t bypass;
4585 cmdline_fixed_string_t event;
4586 cmdline_fixed_string_t event_value;
4587 cmdline_fixed_string_t mode;
4588 cmdline_fixed_string_t mode_value;
4593 cmd_set_bypass_event_parsed(void *parsed_result,
4594 __attribute__((unused)) struct cmdline *cl,
4595 __attribute__((unused)) void *data)
4597 int32_t rc = -EINVAL;
4598 struct cmd_set_bypass_event_result *res = parsed_result;
4599 portid_t port_id = res->port_id;
4601 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4602 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4603 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4605 if (!strcmp(res->event_value, "timeout"))
4606 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4607 else if (!strcmp(res->event_value, "os_on"))
4608 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4609 else if (!strcmp(res->event_value, "os_off"))
4610 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4611 else if (!strcmp(res->event_value, "power_on"))
4612 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4613 else if (!strcmp(res->event_value, "power_off"))
4614 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4616 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4618 if (!strcmp(res->mode_value, "bypass"))
4619 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4620 else if (!strcmp(res->mode_value, "isolate"))
4621 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4623 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4625 /* Set the watchdog timeout. */
4626 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4629 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4630 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4634 printf("Failed to set timeout value %u "
4635 "for port %d, errto code: %d.\n",
4636 bypass_timeout, port_id, rc);
4640 /* Set the bypass event to transition to bypass mode. */
4641 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4646 printf("\t Failed to set bypass event for port = %d.\n",
4650 cmdline_parse_token_string_t cmd_setbypass_event_set =
4651 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4653 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4654 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4656 cmdline_parse_token_string_t cmd_setbypass_event_event =
4657 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4659 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4660 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4661 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4662 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4663 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4665 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4666 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4667 mode_value, "normal#bypass#isolate");
4668 cmdline_parse_token_num_t cmd_setbypass_event_port =
4669 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4672 cmdline_parse_inst_t cmd_set_bypass_event = {
4673 .f = cmd_set_bypass_event_parsed,
4674 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4675 "power_off mode normal|bypass|isolate <port_id>: "
4676 "Set the NIC bypass event mode for port_id",
4679 (void *)&cmd_setbypass_event_set,
4680 (void *)&cmd_setbypass_event_bypass,
4681 (void *)&cmd_setbypass_event_event,
4682 (void *)&cmd_setbypass_event_event_value,
4683 (void *)&cmd_setbypass_event_mode,
4684 (void *)&cmd_setbypass_event_mode_value,
4685 (void *)&cmd_setbypass_event_port,
4691 /* *** SET NIC BYPASS TIMEOUT *** */
4692 struct cmd_set_bypass_timeout_result {
4693 cmdline_fixed_string_t set;
4694 cmdline_fixed_string_t bypass;
4695 cmdline_fixed_string_t timeout;
4696 cmdline_fixed_string_t value;
4700 cmd_set_bypass_timeout_parsed(void *parsed_result,
4701 __attribute__((unused)) struct cmdline *cl,
4702 __attribute__((unused)) void *data)
4704 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4706 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4707 if (!strcmp(res->value, "1.5"))
4708 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4709 else if (!strcmp(res->value, "2"))
4710 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4711 else if (!strcmp(res->value, "3"))
4712 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4713 else if (!strcmp(res->value, "4"))
4714 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4715 else if (!strcmp(res->value, "8"))
4716 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4717 else if (!strcmp(res->value, "16"))
4718 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4719 else if (!strcmp(res->value, "32"))
4720 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4722 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4726 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4727 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4729 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4730 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4732 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4733 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4734 timeout, "timeout");
4735 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4736 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4737 value, "0#1.5#2#3#4#8#16#32");
4739 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4740 .f = cmd_set_bypass_timeout_parsed,
4741 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4742 "Set the NIC bypass watchdog timeout in seconds",
4745 (void *)&cmd_setbypass_timeout_set,
4746 (void *)&cmd_setbypass_timeout_bypass,
4747 (void *)&cmd_setbypass_timeout_timeout,
4748 (void *)&cmd_setbypass_timeout_value,
4753 /* *** SHOW NIC BYPASS MODE *** */
4754 struct cmd_show_bypass_config_result {
4755 cmdline_fixed_string_t show;
4756 cmdline_fixed_string_t bypass;
4757 cmdline_fixed_string_t config;
4762 cmd_show_bypass_config_parsed(void *parsed_result,
4763 __attribute__((unused)) struct cmdline *cl,
4764 __attribute__((unused)) void *data)
4766 struct cmd_show_bypass_config_result *res = parsed_result;
4767 portid_t port_id = res->port_id;
4769 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4770 uint32_t event_mode;
4771 uint32_t bypass_mode;
4772 uint32_t timeout = bypass_timeout;
4775 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4776 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4777 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4778 {"UNKNOWN", "normal", "bypass", "isolate"};
4779 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4786 int num_events = (sizeof events) / (sizeof events[0]);
4788 /* Display the bypass mode.*/
4789 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4790 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4794 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4795 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4797 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4800 /* Display the bypass timeout.*/
4801 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4802 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4804 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4806 /* Display the bypass events and associated modes. */
4807 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4809 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4810 printf("\tFailed to get bypass mode for event = %s\n",
4813 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4814 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4816 printf("\tbypass event: %-16s = %s\n", events[i],
4822 printf("\tFailed to get bypass configuration for port = %d\n",
4826 cmdline_parse_token_string_t cmd_showbypass_config_show =
4827 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4829 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4830 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4832 cmdline_parse_token_string_t cmd_showbypass_config_config =
4833 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4835 cmdline_parse_token_num_t cmd_showbypass_config_port =
4836 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4839 cmdline_parse_inst_t cmd_show_bypass_config = {
4840 .f = cmd_show_bypass_config_parsed,
4841 .help_str = "show bypass config <port_id>: "
4842 "Show the NIC bypass config for port_id",
4845 (void *)&cmd_showbypass_config_show,
4846 (void *)&cmd_showbypass_config_bypass,
4847 (void *)&cmd_showbypass_config_config,
4848 (void *)&cmd_showbypass_config_port,
4853 #ifdef RTE_LIBRTE_PMD_BOND
4854 /* *** SET BONDING MODE *** */
4855 struct cmd_set_bonding_mode_result {
4856 cmdline_fixed_string_t set;
4857 cmdline_fixed_string_t bonding;
4858 cmdline_fixed_string_t mode;
4863 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4864 __attribute__((unused)) struct cmdline *cl,
4865 __attribute__((unused)) void *data)
4867 struct cmd_set_bonding_mode_result *res = parsed_result;
4868 portid_t port_id = res->port_id;
4870 /* Set the bonding mode for the relevant port. */
4871 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4872 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4875 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4876 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4878 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4879 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4880 bonding, "bonding");
4881 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4882 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4884 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4885 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4887 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4888 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4891 cmdline_parse_inst_t cmd_set_bonding_mode = {
4892 .f = cmd_set_bonding_mode_parsed,
4893 .help_str = "set bonding mode <mode_value> <port_id>: "
4894 "Set the bonding mode for port_id",
4897 (void *) &cmd_setbonding_mode_set,
4898 (void *) &cmd_setbonding_mode_bonding,
4899 (void *) &cmd_setbonding_mode_mode,
4900 (void *) &cmd_setbonding_mode_value,
4901 (void *) &cmd_setbonding_mode_port,
4906 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4907 struct cmd_set_bonding_lacp_dedicated_queues_result {
4908 cmdline_fixed_string_t set;
4909 cmdline_fixed_string_t bonding;
4910 cmdline_fixed_string_t lacp;
4911 cmdline_fixed_string_t dedicated_queues;
4913 cmdline_fixed_string_t mode;
4916 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4917 __attribute__((unused)) struct cmdline *cl,
4918 __attribute__((unused)) void *data)
4920 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4921 portid_t port_id = res->port_id;
4922 struct rte_port *port;
4924 port = &ports[port_id];
4926 /** Check if the port is not started **/
4927 if (port->port_status != RTE_PORT_STOPPED) {
4928 printf("Please stop port %d first\n", port_id);
4932 if (!strcmp(res->mode, "enable")) {
4933 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4934 printf("Dedicate queues for LACP control packets"
4937 printf("Enabling dedicate queues for LACP control "
4938 "packets on port %d failed\n", port_id);
4939 } else if (!strcmp(res->mode, "disable")) {
4940 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4941 printf("Dedicated queues for LACP control packets "
4944 printf("Disabling dedicated queues for LACP control "
4945 "traffic on port %d failed\n", port_id);
4949 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4950 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4952 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4953 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4954 bonding, "bonding");
4955 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4956 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4958 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4959 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4960 dedicated_queues, "dedicated_queues");
4961 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4962 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4964 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4965 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4966 mode, "enable#disable");
4968 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4969 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4970 .help_str = "set bonding lacp dedicated_queues <port_id> "
4972 "Enable/disable dedicated queues for LACP control traffic for port_id",
4975 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4976 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4977 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4978 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4979 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4980 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4985 /* *** SET BALANCE XMIT POLICY *** */
4986 struct cmd_set_bonding_balance_xmit_policy_result {
4987 cmdline_fixed_string_t set;
4988 cmdline_fixed_string_t bonding;
4989 cmdline_fixed_string_t balance_xmit_policy;
4991 cmdline_fixed_string_t policy;
4994 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4995 __attribute__((unused)) struct cmdline *cl,
4996 __attribute__((unused)) void *data)
4998 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4999 portid_t port_id = res->port_id;
5002 if (!strcmp(res->policy, "l2")) {
5003 policy = BALANCE_XMIT_POLICY_LAYER2;
5004 } else if (!strcmp(res->policy, "l23")) {
5005 policy = BALANCE_XMIT_POLICY_LAYER23;
5006 } else if (!strcmp(res->policy, "l34")) {
5007 policy = BALANCE_XMIT_POLICY_LAYER34;
5009 printf("\t Invalid xmit policy selection");
5013 /* Set the bonding mode for the relevant port. */
5014 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5015 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5020 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5021 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5023 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5024 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5025 bonding, "bonding");
5026 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5027 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5028 balance_xmit_policy, "balance_xmit_policy");
5029 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5030 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5032 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5033 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5034 policy, "l2#l23#l34");
5036 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5037 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5038 .help_str = "set bonding balance_xmit_policy <port_id> "
5040 "Set the bonding balance_xmit_policy for port_id",
5043 (void *)&cmd_setbonding_balance_xmit_policy_set,
5044 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5045 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5046 (void *)&cmd_setbonding_balance_xmit_policy_port,
5047 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5052 /* *** SHOW NIC BONDING CONFIGURATION *** */
5053 struct cmd_show_bonding_config_result {
5054 cmdline_fixed_string_t show;
5055 cmdline_fixed_string_t bonding;
5056 cmdline_fixed_string_t config;
5060 static void cmd_show_bonding_config_parsed(void *parsed_result,
5061 __attribute__((unused)) struct cmdline *cl,
5062 __attribute__((unused)) void *data)
5064 struct cmd_show_bonding_config_result *res = parsed_result;
5065 int bonding_mode, agg_mode;
5066 portid_t slaves[RTE_MAX_ETHPORTS];
5067 int num_slaves, num_active_slaves;
5070 portid_t port_id = res->port_id;
5072 /* Display the bonding mode.*/
5073 bonding_mode = rte_eth_bond_mode_get(port_id);
5074 if (bonding_mode < 0) {
5075 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5078 printf("\tBonding mode: %d\n", bonding_mode);
5080 if (bonding_mode == BONDING_MODE_BALANCE) {
5081 int balance_xmit_policy;
5083 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5084 if (balance_xmit_policy < 0) {
5085 printf("\tFailed to get balance xmit policy for port = %d\n",
5089 printf("\tBalance Xmit Policy: ");
5091 switch (balance_xmit_policy) {
5092 case BALANCE_XMIT_POLICY_LAYER2:
5093 printf("BALANCE_XMIT_POLICY_LAYER2");
5095 case BALANCE_XMIT_POLICY_LAYER23:
5096 printf("BALANCE_XMIT_POLICY_LAYER23");
5098 case BALANCE_XMIT_POLICY_LAYER34:
5099 printf("BALANCE_XMIT_POLICY_LAYER34");
5106 if (bonding_mode == BONDING_MODE_8023AD) {
5107 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5108 printf("\tIEEE802.3AD Aggregator Mode: ");
5111 printf("bandwidth");
5123 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5125 if (num_slaves < 0) {
5126 printf("\tFailed to get slave list for port = %d\n", port_id);
5129 if (num_slaves > 0) {
5130 printf("\tSlaves (%d): [", num_slaves);
5131 for (i = 0; i < num_slaves - 1; i++)
5132 printf("%d ", slaves[i]);
5134 printf("%d]\n", slaves[num_slaves - 1]);
5136 printf("\tSlaves: []\n");
5140 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5143 if (num_active_slaves < 0) {
5144 printf("\tFailed to get active slave list for port = %d\n", port_id);
5147 if (num_active_slaves > 0) {
5148 printf("\tActive Slaves (%d): [", num_active_slaves);
5149 for (i = 0; i < num_active_slaves - 1; i++)
5150 printf("%d ", slaves[i]);
5152 printf("%d]\n", slaves[num_active_slaves - 1]);
5155 printf("\tActive Slaves: []\n");
5159 primary_id = rte_eth_bond_primary_get(port_id);
5160 if (primary_id < 0) {
5161 printf("\tFailed to get primary slave for port = %d\n", port_id);
5164 printf("\tPrimary: [%d]\n", primary_id);
5168 cmdline_parse_token_string_t cmd_showbonding_config_show =
5169 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5171 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5172 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5173 bonding, "bonding");
5174 cmdline_parse_token_string_t cmd_showbonding_config_config =
5175 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5177 cmdline_parse_token_num_t cmd_showbonding_config_port =
5178 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5181 cmdline_parse_inst_t cmd_show_bonding_config = {
5182 .f = cmd_show_bonding_config_parsed,
5183 .help_str = "show bonding config <port_id>: "
5184 "Show the bonding config for port_id",
5187 (void *)&cmd_showbonding_config_show,
5188 (void *)&cmd_showbonding_config_bonding,
5189 (void *)&cmd_showbonding_config_config,
5190 (void *)&cmd_showbonding_config_port,
5195 /* *** SET BONDING PRIMARY *** */
5196 struct cmd_set_bonding_primary_result {
5197 cmdline_fixed_string_t set;
5198 cmdline_fixed_string_t bonding;
5199 cmdline_fixed_string_t primary;
5204 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5205 __attribute__((unused)) struct cmdline *cl,
5206 __attribute__((unused)) void *data)
5208 struct cmd_set_bonding_primary_result *res = parsed_result;
5209 portid_t master_port_id = res->port_id;
5210 portid_t slave_port_id = res->slave_id;
5212 /* Set the primary slave for a bonded device. */
5213 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5214 printf("\t Failed to set primary slave for port = %d.\n",
5221 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5222 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5224 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5225 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5226 bonding, "bonding");
5227 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5228 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5229 primary, "primary");
5230 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5231 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5233 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5234 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5237 cmdline_parse_inst_t cmd_set_bonding_primary = {
5238 .f = cmd_set_bonding_primary_parsed,
5239 .help_str = "set bonding primary <slave_id> <port_id>: "
5240 "Set the primary slave for port_id",
5243 (void *)&cmd_setbonding_primary_set,
5244 (void *)&cmd_setbonding_primary_bonding,
5245 (void *)&cmd_setbonding_primary_primary,
5246 (void *)&cmd_setbonding_primary_slave,
5247 (void *)&cmd_setbonding_primary_port,
5252 /* *** ADD SLAVE *** */
5253 struct cmd_add_bonding_slave_result {
5254 cmdline_fixed_string_t add;
5255 cmdline_fixed_string_t bonding;
5256 cmdline_fixed_string_t slave;
5261 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5262 __attribute__((unused)) struct cmdline *cl,
5263 __attribute__((unused)) void *data)
5265 struct cmd_add_bonding_slave_result *res = parsed_result;
5266 portid_t master_port_id = res->port_id;
5267 portid_t slave_port_id = res->slave_id;
5269 /* add the slave for a bonded device. */
5270 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5271 printf("\t Failed to add slave %d to master port = %d.\n",
5272 slave_port_id, master_port_id);
5276 set_port_slave_flag(slave_port_id);
5279 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5280 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5282 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5283 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5284 bonding, "bonding");
5285 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5286 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5288 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5289 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5291 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5292 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5295 cmdline_parse_inst_t cmd_add_bonding_slave = {
5296 .f = cmd_add_bonding_slave_parsed,
5297 .help_str = "add bonding slave <slave_id> <port_id>: "
5298 "Add a slave device to a bonded device",
5301 (void *)&cmd_addbonding_slave_add,
5302 (void *)&cmd_addbonding_slave_bonding,
5303 (void *)&cmd_addbonding_slave_slave,
5304 (void *)&cmd_addbonding_slave_slaveid,
5305 (void *)&cmd_addbonding_slave_port,
5310 /* *** REMOVE SLAVE *** */
5311 struct cmd_remove_bonding_slave_result {
5312 cmdline_fixed_string_t remove;
5313 cmdline_fixed_string_t bonding;
5314 cmdline_fixed_string_t slave;
5319 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5320 __attribute__((unused)) struct cmdline *cl,
5321 __attribute__((unused)) void *data)
5323 struct cmd_remove_bonding_slave_result *res = parsed_result;
5324 portid_t master_port_id = res->port_id;
5325 portid_t slave_port_id = res->slave_id;
5327 /* remove the slave from a bonded device. */
5328 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5329 printf("\t Failed to remove slave %d from master port = %d.\n",
5330 slave_port_id, master_port_id);
5334 clear_port_slave_flag(slave_port_id);
5337 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5338 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5340 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5341 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5342 bonding, "bonding");
5343 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5344 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5346 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5347 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5349 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5350 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5353 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5354 .f = cmd_remove_bonding_slave_parsed,
5355 .help_str = "remove bonding slave <slave_id> <port_id>: "
5356 "Remove a slave device from a bonded device",
5359 (void *)&cmd_removebonding_slave_remove,
5360 (void *)&cmd_removebonding_slave_bonding,
5361 (void *)&cmd_removebonding_slave_slave,
5362 (void *)&cmd_removebonding_slave_slaveid,
5363 (void *)&cmd_removebonding_slave_port,
5368 /* *** CREATE BONDED DEVICE *** */
5369 struct cmd_create_bonded_device_result {
5370 cmdline_fixed_string_t create;
5371 cmdline_fixed_string_t bonded;
5372 cmdline_fixed_string_t device;
5377 static int bond_dev_num = 0;
5379 static void cmd_create_bonded_device_parsed(void *parsed_result,
5380 __attribute__((unused)) struct cmdline *cl,
5381 __attribute__((unused)) void *data)
5383 struct cmd_create_bonded_device_result *res = parsed_result;
5384 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5387 if (test_done == 0) {
5388 printf("Please stop forwarding first\n");
5392 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5395 /* Create a new bonded device. */
5396 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5398 printf("\t Failed to create bonded device.\n");
5401 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5404 /* Update number of ports */
5405 nb_ports = rte_eth_dev_count();
5406 reconfig(port_id, res->socket);
5407 rte_eth_promiscuous_enable(port_id);
5412 cmdline_parse_token_string_t cmd_createbonded_device_create =
5413 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5415 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5416 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5418 cmdline_parse_token_string_t cmd_createbonded_device_device =
5419 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5421 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5422 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5424 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5425 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5428 cmdline_parse_inst_t cmd_create_bonded_device = {
5429 .f = cmd_create_bonded_device_parsed,
5430 .help_str = "create bonded device <mode> <socket>: "
5431 "Create a new bonded device with specific bonding mode and socket",
5434 (void *)&cmd_createbonded_device_create,
5435 (void *)&cmd_createbonded_device_bonded,
5436 (void *)&cmd_createbonded_device_device,
5437 (void *)&cmd_createbonded_device_mode,
5438 (void *)&cmd_createbonded_device_socket,
5443 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5444 struct cmd_set_bond_mac_addr_result {
5445 cmdline_fixed_string_t set;
5446 cmdline_fixed_string_t bonding;
5447 cmdline_fixed_string_t mac_addr;
5449 struct ether_addr address;
5452 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5453 __attribute__((unused)) struct cmdline *cl,
5454 __attribute__((unused)) void *data)
5456 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5459 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5462 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5464 /* check the return value and print it if is < 0 */
5466 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5469 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5470 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5471 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5472 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5474 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5475 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5477 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5478 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5480 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5481 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5483 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5484 .f = cmd_set_bond_mac_addr_parsed,
5486 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5488 (void *)&cmd_set_bond_mac_addr_set,
5489 (void *)&cmd_set_bond_mac_addr_bonding,
5490 (void *)&cmd_set_bond_mac_addr_mac,
5491 (void *)&cmd_set_bond_mac_addr_portnum,
5492 (void *)&cmd_set_bond_mac_addr_addr,
5498 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5499 struct cmd_set_bond_mon_period_result {
5500 cmdline_fixed_string_t set;
5501 cmdline_fixed_string_t bonding;
5502 cmdline_fixed_string_t mon_period;
5507 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5508 __attribute__((unused)) struct cmdline *cl,
5509 __attribute__((unused)) void *data)
5511 struct cmd_set_bond_mon_period_result *res = parsed_result;
5514 if (res->port_num >= nb_ports) {
5515 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5519 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5521 /* check the return value and print it if is < 0 */
5523 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5526 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5527 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5529 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5530 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5531 bonding, "bonding");
5532 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5533 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5534 mon_period, "mon_period");
5535 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5536 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5538 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5539 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5542 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5543 .f = cmd_set_bond_mon_period_parsed,
5545 .help_str = "set bonding mon_period <port_id> <period_ms>",
5547 (void *)&cmd_set_bond_mon_period_set,
5548 (void *)&cmd_set_bond_mon_period_bonding,
5549 (void *)&cmd_set_bond_mon_period_mon_period,
5550 (void *)&cmd_set_bond_mon_period_portnum,
5551 (void *)&cmd_set_bond_mon_period_period_ms,
5558 struct cmd_set_bonding_agg_mode_policy_result {
5559 cmdline_fixed_string_t set;
5560 cmdline_fixed_string_t bonding;
5561 cmdline_fixed_string_t agg_mode;
5563 cmdline_fixed_string_t policy;
5568 cmd_set_bonding_agg_mode(void *parsed_result,
5569 __attribute__((unused)) struct cmdline *cl,
5570 __attribute__((unused)) void *data)
5572 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5573 uint8_t policy = AGG_BANDWIDTH;
5575 if (res->port_num >= nb_ports) {
5576 printf("Port id %d must be less than %d\n",
5577 res->port_num, nb_ports);
5581 if (!strcmp(res->policy, "bandwidth"))
5582 policy = AGG_BANDWIDTH;
5583 else if (!strcmp(res->policy, "stable"))
5584 policy = AGG_STABLE;
5585 else if (!strcmp(res->policy, "count"))
5588 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5592 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5593 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5595 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5596 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5597 bonding, "bonding");
5599 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5600 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5601 agg_mode, "agg_mode");
5603 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5604 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5607 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5608 TOKEN_STRING_INITIALIZER(
5609 struct cmd_set_bonding_balance_xmit_policy_result,
5610 policy, "stable#bandwidth#count");
5612 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5613 .f = cmd_set_bonding_agg_mode,
5615 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5617 (void *)&cmd_set_bonding_agg_mode_set,
5618 (void *)&cmd_set_bonding_agg_mode_bonding,
5619 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5620 (void *)&cmd_set_bonding_agg_mode_portnum,
5621 (void *)&cmd_set_bonding_agg_mode_policy_string,
5627 #endif /* RTE_LIBRTE_PMD_BOND */
5629 /* *** SET FORWARDING MODE *** */
5630 struct cmd_set_fwd_mode_result {
5631 cmdline_fixed_string_t set;
5632 cmdline_fixed_string_t fwd;
5633 cmdline_fixed_string_t mode;
5636 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5637 __attribute__((unused)) struct cmdline *cl,
5638 __attribute__((unused)) void *data)
5640 struct cmd_set_fwd_mode_result *res = parsed_result;
5643 set_pkt_forwarding_mode(res->mode);
5646 cmdline_parse_token_string_t cmd_setfwd_set =
5647 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5648 cmdline_parse_token_string_t cmd_setfwd_fwd =
5649 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5650 cmdline_parse_token_string_t cmd_setfwd_mode =
5651 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5652 "" /* defined at init */);
5654 cmdline_parse_inst_t cmd_set_fwd_mode = {
5655 .f = cmd_set_fwd_mode_parsed,
5657 .help_str = NULL, /* defined at init */
5659 (void *)&cmd_setfwd_set,
5660 (void *)&cmd_setfwd_fwd,
5661 (void *)&cmd_setfwd_mode,
5666 static void cmd_set_fwd_mode_init(void)
5669 static char token[128];
5670 static char help[256];
5671 cmdline_parse_token_string_t *token_struct;
5673 modes = list_pkt_forwarding_modes();
5674 snprintf(help, sizeof(help), "set fwd %s: "
5675 "Set packet forwarding mode", modes);
5676 cmd_set_fwd_mode.help_str = help;
5678 /* string token separator is # */
5679 for (c = token; *modes != '\0'; modes++)
5684 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5685 token_struct->string_data.str = token;
5688 /* *** SET RETRY FORWARDING MODE *** */
5689 struct cmd_set_fwd_retry_mode_result {
5690 cmdline_fixed_string_t set;
5691 cmdline_fixed_string_t fwd;
5692 cmdline_fixed_string_t mode;
5693 cmdline_fixed_string_t retry;
5696 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5697 __attribute__((unused)) struct cmdline *cl,
5698 __attribute__((unused)) void *data)
5700 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5703 set_pkt_forwarding_mode(res->mode);
5706 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5707 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5709 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5710 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5712 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5713 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5715 "" /* defined at init */);
5716 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5717 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5720 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5721 .f = cmd_set_fwd_retry_mode_parsed,
5723 .help_str = NULL, /* defined at init */
5725 (void *)&cmd_setfwd_retry_set,
5726 (void *)&cmd_setfwd_retry_fwd,
5727 (void *)&cmd_setfwd_retry_mode,
5728 (void *)&cmd_setfwd_retry_retry,
5733 static void cmd_set_fwd_retry_mode_init(void)
5736 static char token[128];
5737 static char help[256];
5738 cmdline_parse_token_string_t *token_struct;
5740 modes = list_pkt_forwarding_retry_modes();
5741 snprintf(help, sizeof(help), "set fwd %s retry: "
5742 "Set packet forwarding mode with retry", modes);
5743 cmd_set_fwd_retry_mode.help_str = help;
5745 /* string token separator is # */
5746 for (c = token; *modes != '\0'; modes++)
5751 token_struct = (cmdline_parse_token_string_t *)
5752 cmd_set_fwd_retry_mode.tokens[2];
5753 token_struct->string_data.str = token;
5756 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5757 struct cmd_set_burst_tx_retry_result {
5758 cmdline_fixed_string_t set;
5759 cmdline_fixed_string_t burst;
5760 cmdline_fixed_string_t tx;
5761 cmdline_fixed_string_t delay;
5763 cmdline_fixed_string_t retry;
5767 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5768 __attribute__((unused)) struct cmdline *cl,
5769 __attribute__((unused)) void *data)
5771 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5773 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5774 && !strcmp(res->tx, "tx")) {
5775 if (!strcmp(res->delay, "delay"))
5776 burst_tx_delay_time = res->time;
5777 if (!strcmp(res->retry, "retry"))
5778 burst_tx_retry_num = res->retry_num;
5783 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5784 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5785 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5786 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5788 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5789 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5790 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5791 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5792 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5793 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5794 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5795 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5796 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5797 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5799 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5800 .f = cmd_set_burst_tx_retry_parsed,
5801 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5803 (void *)&cmd_set_burst_tx_retry_set,
5804 (void *)&cmd_set_burst_tx_retry_burst,
5805 (void *)&cmd_set_burst_tx_retry_tx,
5806 (void *)&cmd_set_burst_tx_retry_delay,
5807 (void *)&cmd_set_burst_tx_retry_time,
5808 (void *)&cmd_set_burst_tx_retry_retry,
5809 (void *)&cmd_set_burst_tx_retry_retry_num,
5814 /* *** SET PROMISC MODE *** */
5815 struct cmd_set_promisc_mode_result {
5816 cmdline_fixed_string_t set;
5817 cmdline_fixed_string_t promisc;
5818 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5819 uint16_t port_num; /* valid if "allports" argument == 0 */
5820 cmdline_fixed_string_t mode;
5823 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5824 __attribute__((unused)) struct cmdline *cl,
5827 struct cmd_set_promisc_mode_result *res = parsed_result;
5831 if (!strcmp(res->mode, "on"))
5838 RTE_ETH_FOREACH_DEV(i) {
5840 rte_eth_promiscuous_enable(i);
5842 rte_eth_promiscuous_disable(i);
5847 rte_eth_promiscuous_enable(res->port_num);
5849 rte_eth_promiscuous_disable(res->port_num);
5853 cmdline_parse_token_string_t cmd_setpromisc_set =
5854 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5855 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5856 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5858 cmdline_parse_token_string_t cmd_setpromisc_portall =
5859 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5861 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5862 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5864 cmdline_parse_token_string_t cmd_setpromisc_mode =
5865 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5868 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5869 .f = cmd_set_promisc_mode_parsed,
5871 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5873 (void *)&cmd_setpromisc_set,
5874 (void *)&cmd_setpromisc_promisc,
5875 (void *)&cmd_setpromisc_portall,
5876 (void *)&cmd_setpromisc_mode,
5881 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5882 .f = cmd_set_promisc_mode_parsed,
5884 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5886 (void *)&cmd_setpromisc_set,
5887 (void *)&cmd_setpromisc_promisc,
5888 (void *)&cmd_setpromisc_portnum,
5889 (void *)&cmd_setpromisc_mode,
5894 /* *** SET ALLMULTI MODE *** */
5895 struct cmd_set_allmulti_mode_result {
5896 cmdline_fixed_string_t set;
5897 cmdline_fixed_string_t allmulti;
5898 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5899 uint16_t port_num; /* valid if "allports" argument == 0 */
5900 cmdline_fixed_string_t mode;
5903 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5904 __attribute__((unused)) struct cmdline *cl,
5907 struct cmd_set_allmulti_mode_result *res = parsed_result;
5911 if (!strcmp(res->mode, "on"))
5918 RTE_ETH_FOREACH_DEV(i) {
5920 rte_eth_allmulticast_enable(i);
5922 rte_eth_allmulticast_disable(i);
5927 rte_eth_allmulticast_enable(res->port_num);
5929 rte_eth_allmulticast_disable(res->port_num);
5933 cmdline_parse_token_string_t cmd_setallmulti_set =
5934 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5935 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5936 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5938 cmdline_parse_token_string_t cmd_setallmulti_portall =
5939 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5941 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5942 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5944 cmdline_parse_token_string_t cmd_setallmulti_mode =
5945 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5948 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5949 .f = cmd_set_allmulti_mode_parsed,
5951 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5953 (void *)&cmd_setallmulti_set,
5954 (void *)&cmd_setallmulti_allmulti,
5955 (void *)&cmd_setallmulti_portall,
5956 (void *)&cmd_setallmulti_mode,
5961 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5962 .f = cmd_set_allmulti_mode_parsed,
5964 .help_str = "set allmulti <port_id> on|off: "
5965 "Set allmulti mode on port_id",
5967 (void *)&cmd_setallmulti_set,
5968 (void *)&cmd_setallmulti_allmulti,
5969 (void *)&cmd_setallmulti_portnum,
5970 (void *)&cmd_setallmulti_mode,
5975 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5976 struct cmd_link_flow_ctrl_set_result {
5977 cmdline_fixed_string_t set;
5978 cmdline_fixed_string_t flow_ctrl;
5979 cmdline_fixed_string_t rx;
5980 cmdline_fixed_string_t rx_lfc_mode;
5981 cmdline_fixed_string_t tx;
5982 cmdline_fixed_string_t tx_lfc_mode;
5983 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5984 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5985 cmdline_fixed_string_t autoneg_str;
5986 cmdline_fixed_string_t autoneg;
5987 cmdline_fixed_string_t hw_str;
5988 uint32_t high_water;
5989 cmdline_fixed_string_t lw_str;
5991 cmdline_fixed_string_t pt_str;
5992 uint16_t pause_time;
5993 cmdline_fixed_string_t xon_str;
5998 cmdline_parse_token_string_t cmd_lfc_set_set =
5999 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6001 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6002 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6003 flow_ctrl, "flow_ctrl");
6004 cmdline_parse_token_string_t cmd_lfc_set_rx =
6005 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6007 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6008 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6009 rx_lfc_mode, "on#off");
6010 cmdline_parse_token_string_t cmd_lfc_set_tx =
6011 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6013 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6014 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6015 tx_lfc_mode, "on#off");
6016 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6017 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6018 hw_str, "high_water");
6019 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6020 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6021 high_water, UINT32);
6022 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6023 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6024 lw_str, "low_water");
6025 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6026 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6028 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6029 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6030 pt_str, "pause_time");
6031 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6032 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6033 pause_time, UINT16);
6034 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6035 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6036 xon_str, "send_xon");
6037 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6038 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6040 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6041 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6042 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6043 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6044 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6045 mac_ctrl_frame_fwd_mode, "on#off");
6046 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6047 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6048 autoneg_str, "autoneg");
6049 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6050 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6052 cmdline_parse_token_num_t cmd_lfc_set_portid =
6053 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6056 /* forward declaration */
6058 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6061 cmdline_parse_inst_t cmd_link_flow_control_set = {
6062 .f = cmd_link_flow_ctrl_set_parsed,
6064 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6065 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6066 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6068 (void *)&cmd_lfc_set_set,
6069 (void *)&cmd_lfc_set_flow_ctrl,
6070 (void *)&cmd_lfc_set_rx,
6071 (void *)&cmd_lfc_set_rx_mode,
6072 (void *)&cmd_lfc_set_tx,
6073 (void *)&cmd_lfc_set_tx_mode,
6074 (void *)&cmd_lfc_set_high_water,
6075 (void *)&cmd_lfc_set_low_water,
6076 (void *)&cmd_lfc_set_pause_time,
6077 (void *)&cmd_lfc_set_send_xon,
6078 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6079 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6080 (void *)&cmd_lfc_set_autoneg_str,
6081 (void *)&cmd_lfc_set_autoneg,
6082 (void *)&cmd_lfc_set_portid,
6087 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6088 .f = cmd_link_flow_ctrl_set_parsed,
6089 .data = (void *)&cmd_link_flow_control_set_rx,
6090 .help_str = "set flow_ctrl rx on|off <port_id>: "
6091 "Change rx flow control parameter",
6093 (void *)&cmd_lfc_set_set,
6094 (void *)&cmd_lfc_set_flow_ctrl,
6095 (void *)&cmd_lfc_set_rx,
6096 (void *)&cmd_lfc_set_rx_mode,
6097 (void *)&cmd_lfc_set_portid,
6102 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6103 .f = cmd_link_flow_ctrl_set_parsed,
6104 .data = (void *)&cmd_link_flow_control_set_tx,
6105 .help_str = "set flow_ctrl tx on|off <port_id>: "
6106 "Change tx flow control parameter",
6108 (void *)&cmd_lfc_set_set,
6109 (void *)&cmd_lfc_set_flow_ctrl,
6110 (void *)&cmd_lfc_set_tx,
6111 (void *)&cmd_lfc_set_tx_mode,
6112 (void *)&cmd_lfc_set_portid,
6117 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6118 .f = cmd_link_flow_ctrl_set_parsed,
6119 .data = (void *)&cmd_link_flow_control_set_hw,
6120 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6121 "Change high water flow control parameter",
6123 (void *)&cmd_lfc_set_set,
6124 (void *)&cmd_lfc_set_flow_ctrl,
6125 (void *)&cmd_lfc_set_high_water_str,
6126 (void *)&cmd_lfc_set_high_water,
6127 (void *)&cmd_lfc_set_portid,
6132 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6133 .f = cmd_link_flow_ctrl_set_parsed,
6134 .data = (void *)&cmd_link_flow_control_set_lw,
6135 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6136 "Change low water flow control parameter",
6138 (void *)&cmd_lfc_set_set,
6139 (void *)&cmd_lfc_set_flow_ctrl,
6140 (void *)&cmd_lfc_set_low_water_str,
6141 (void *)&cmd_lfc_set_low_water,
6142 (void *)&cmd_lfc_set_portid,
6147 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6148 .f = cmd_link_flow_ctrl_set_parsed,
6149 .data = (void *)&cmd_link_flow_control_set_pt,
6150 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6151 "Change pause time flow control parameter",
6153 (void *)&cmd_lfc_set_set,
6154 (void *)&cmd_lfc_set_flow_ctrl,
6155 (void *)&cmd_lfc_set_pause_time_str,
6156 (void *)&cmd_lfc_set_pause_time,
6157 (void *)&cmd_lfc_set_portid,
6162 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6163 .f = cmd_link_flow_ctrl_set_parsed,
6164 .data = (void *)&cmd_link_flow_control_set_xon,
6165 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6166 "Change send_xon flow control parameter",
6168 (void *)&cmd_lfc_set_set,
6169 (void *)&cmd_lfc_set_flow_ctrl,
6170 (void *)&cmd_lfc_set_send_xon_str,
6171 (void *)&cmd_lfc_set_send_xon,
6172 (void *)&cmd_lfc_set_portid,
6177 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6178 .f = cmd_link_flow_ctrl_set_parsed,
6179 .data = (void *)&cmd_link_flow_control_set_macfwd,
6180 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6181 "Change mac ctrl fwd flow control parameter",
6183 (void *)&cmd_lfc_set_set,
6184 (void *)&cmd_lfc_set_flow_ctrl,
6185 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6186 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6187 (void *)&cmd_lfc_set_portid,
6192 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6193 .f = cmd_link_flow_ctrl_set_parsed,
6194 .data = (void *)&cmd_link_flow_control_set_autoneg,
6195 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6196 "Change autoneg flow control parameter",
6198 (void *)&cmd_lfc_set_set,
6199 (void *)&cmd_lfc_set_flow_ctrl,
6200 (void *)&cmd_lfc_set_autoneg_str,
6201 (void *)&cmd_lfc_set_autoneg,
6202 (void *)&cmd_lfc_set_portid,
6208 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6209 __attribute__((unused)) struct cmdline *cl,
6212 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6213 cmdline_parse_inst_t *cmd = data;
6214 struct rte_eth_fc_conf fc_conf;
6220 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6221 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6222 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6223 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6225 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6226 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6229 /* Partial command line, retrieve current configuration */
6231 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6233 printf("cannot get current flow ctrl parameters, return"
6234 "code = %d\n", ret);
6238 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6239 (fc_conf.mode == RTE_FC_FULL))
6241 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6242 (fc_conf.mode == RTE_FC_FULL))
6246 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6247 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6249 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6250 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6252 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6254 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6255 fc_conf.high_water = res->high_water;
6257 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6258 fc_conf.low_water = res->low_water;
6260 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6261 fc_conf.pause_time = res->pause_time;
6263 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6264 fc_conf.send_xon = res->send_xon;
6266 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6267 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6268 fc_conf.mac_ctrl_frame_fwd = 1;
6270 fc_conf.mac_ctrl_frame_fwd = 0;
6273 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6274 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6276 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6278 printf("bad flow contrl parameter, return code = %d \n", ret);
6281 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6282 struct cmd_priority_flow_ctrl_set_result {
6283 cmdline_fixed_string_t set;
6284 cmdline_fixed_string_t pfc_ctrl;
6285 cmdline_fixed_string_t rx;
6286 cmdline_fixed_string_t rx_pfc_mode;
6287 cmdline_fixed_string_t tx;
6288 cmdline_fixed_string_t tx_pfc_mode;
6289 uint32_t high_water;
6291 uint16_t pause_time;
6297 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6298 __attribute__((unused)) struct cmdline *cl,
6299 __attribute__((unused)) void *data)
6301 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6302 struct rte_eth_pfc_conf pfc_conf;
6303 int rx_fc_enable, tx_fc_enable;
6307 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6308 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6309 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6310 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6312 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6313 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6316 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6317 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6318 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6319 pfc_conf.fc.high_water = res->high_water;
6320 pfc_conf.fc.low_water = res->low_water;
6321 pfc_conf.fc.pause_time = res->pause_time;
6322 pfc_conf.priority = res->priority;
6324 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6326 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6329 cmdline_parse_token_string_t cmd_pfc_set_set =
6330 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6332 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6333 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6334 pfc_ctrl, "pfc_ctrl");
6335 cmdline_parse_token_string_t cmd_pfc_set_rx =
6336 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6338 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6339 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6340 rx_pfc_mode, "on#off");
6341 cmdline_parse_token_string_t cmd_pfc_set_tx =
6342 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6344 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6345 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6346 tx_pfc_mode, "on#off");
6347 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6348 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6349 high_water, UINT32);
6350 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6351 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6353 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6354 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6355 pause_time, UINT16);
6356 cmdline_parse_token_num_t cmd_pfc_set_priority =
6357 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6359 cmdline_parse_token_num_t cmd_pfc_set_portid =
6360 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6363 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6364 .f = cmd_priority_flow_ctrl_set_parsed,
6366 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6367 "<pause_time> <priority> <port_id>: "
6368 "Configure the Ethernet priority flow control",
6370 (void *)&cmd_pfc_set_set,
6371 (void *)&cmd_pfc_set_flow_ctrl,
6372 (void *)&cmd_pfc_set_rx,
6373 (void *)&cmd_pfc_set_rx_mode,
6374 (void *)&cmd_pfc_set_tx,
6375 (void *)&cmd_pfc_set_tx_mode,
6376 (void *)&cmd_pfc_set_high_water,
6377 (void *)&cmd_pfc_set_low_water,
6378 (void *)&cmd_pfc_set_pause_time,
6379 (void *)&cmd_pfc_set_priority,
6380 (void *)&cmd_pfc_set_portid,
6385 /* *** RESET CONFIGURATION *** */
6386 struct cmd_reset_result {
6387 cmdline_fixed_string_t reset;
6388 cmdline_fixed_string_t def;
6391 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6393 __attribute__((unused)) void *data)
6395 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6396 set_def_fwd_config();
6399 cmdline_parse_token_string_t cmd_reset_set =
6400 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6401 cmdline_parse_token_string_t cmd_reset_def =
6402 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6405 cmdline_parse_inst_t cmd_reset = {
6406 .f = cmd_reset_parsed,
6408 .help_str = "set default: Reset default forwarding configuration",
6410 (void *)&cmd_reset_set,
6411 (void *)&cmd_reset_def,
6416 /* *** START FORWARDING *** */
6417 struct cmd_start_result {
6418 cmdline_fixed_string_t start;
6421 cmdline_parse_token_string_t cmd_start_start =
6422 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6424 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6425 __attribute__((unused)) struct cmdline *cl,
6426 __attribute__((unused)) void *data)
6428 start_packet_forwarding(0);
6431 cmdline_parse_inst_t cmd_start = {
6432 .f = cmd_start_parsed,
6434 .help_str = "start: Start packet forwarding",
6436 (void *)&cmd_start_start,
6441 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6442 struct cmd_start_tx_first_result {
6443 cmdline_fixed_string_t start;
6444 cmdline_fixed_string_t tx_first;
6448 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6449 __attribute__((unused)) struct cmdline *cl,
6450 __attribute__((unused)) void *data)
6452 start_packet_forwarding(1);
6455 cmdline_parse_token_string_t cmd_start_tx_first_start =
6456 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6458 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6459 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6460 tx_first, "tx_first");
6462 cmdline_parse_inst_t cmd_start_tx_first = {
6463 .f = cmd_start_tx_first_parsed,
6465 .help_str = "start tx_first: Start packet forwarding, "
6466 "after sending 1 burst of packets",
6468 (void *)&cmd_start_tx_first_start,
6469 (void *)&cmd_start_tx_first_tx_first,
6474 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6475 struct cmd_start_tx_first_n_result {
6476 cmdline_fixed_string_t start;
6477 cmdline_fixed_string_t tx_first;
6482 cmd_start_tx_first_n_parsed(void *parsed_result,
6483 __attribute__((unused)) struct cmdline *cl,
6484 __attribute__((unused)) void *data)
6486 struct cmd_start_tx_first_n_result *res = parsed_result;
6488 start_packet_forwarding(res->tx_num);
6491 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6492 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6494 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6495 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6496 tx_first, "tx_first");
6497 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6498 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6501 cmdline_parse_inst_t cmd_start_tx_first_n = {
6502 .f = cmd_start_tx_first_n_parsed,
6504 .help_str = "start tx_first <num>: "
6505 "packet forwarding, after sending <num> bursts of packets",
6507 (void *)&cmd_start_tx_first_n_start,
6508 (void *)&cmd_start_tx_first_n_tx_first,
6509 (void *)&cmd_start_tx_first_n_tx_num,
6514 /* *** SET LINK UP *** */
6515 struct cmd_set_link_up_result {
6516 cmdline_fixed_string_t set;
6517 cmdline_fixed_string_t link_up;
6518 cmdline_fixed_string_t port;
6522 cmdline_parse_token_string_t cmd_set_link_up_set =
6523 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6524 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6525 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6527 cmdline_parse_token_string_t cmd_set_link_up_port =
6528 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6529 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6530 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6532 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6533 __attribute__((unused)) struct cmdline *cl,
6534 __attribute__((unused)) void *data)
6536 struct cmd_set_link_up_result *res = parsed_result;
6537 dev_set_link_up(res->port_id);
6540 cmdline_parse_inst_t cmd_set_link_up = {
6541 .f = cmd_set_link_up_parsed,
6543 .help_str = "set link-up port <port id>",
6545 (void *)&cmd_set_link_up_set,
6546 (void *)&cmd_set_link_up_link_up,
6547 (void *)&cmd_set_link_up_port,
6548 (void *)&cmd_set_link_up_port_id,
6553 /* *** SET LINK DOWN *** */
6554 struct cmd_set_link_down_result {
6555 cmdline_fixed_string_t set;
6556 cmdline_fixed_string_t link_down;
6557 cmdline_fixed_string_t port;
6561 cmdline_parse_token_string_t cmd_set_link_down_set =
6562 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6563 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6564 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6566 cmdline_parse_token_string_t cmd_set_link_down_port =
6567 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6568 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6569 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6571 static void cmd_set_link_down_parsed(
6572 __attribute__((unused)) void *parsed_result,
6573 __attribute__((unused)) struct cmdline *cl,
6574 __attribute__((unused)) void *data)
6576 struct cmd_set_link_down_result *res = parsed_result;
6577 dev_set_link_down(res->port_id);
6580 cmdline_parse_inst_t cmd_set_link_down = {
6581 .f = cmd_set_link_down_parsed,
6583 .help_str = "set link-down port <port id>",
6585 (void *)&cmd_set_link_down_set,
6586 (void *)&cmd_set_link_down_link_down,
6587 (void *)&cmd_set_link_down_port,
6588 (void *)&cmd_set_link_down_port_id,
6593 /* *** SHOW CFG *** */
6594 struct cmd_showcfg_result {
6595 cmdline_fixed_string_t show;
6596 cmdline_fixed_string_t cfg;
6597 cmdline_fixed_string_t what;
6600 static void cmd_showcfg_parsed(void *parsed_result,
6601 __attribute__((unused)) struct cmdline *cl,
6602 __attribute__((unused)) void *data)
6604 struct cmd_showcfg_result *res = parsed_result;
6605 if (!strcmp(res->what, "rxtx"))
6606 rxtx_config_display();
6607 else if (!strcmp(res->what, "cores"))
6608 fwd_lcores_config_display();
6609 else if (!strcmp(res->what, "fwd"))
6610 pkt_fwd_config_display(&cur_fwd_config);
6611 else if (!strcmp(res->what, "txpkts"))
6612 show_tx_pkt_segments();
6615 cmdline_parse_token_string_t cmd_showcfg_show =
6616 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6617 cmdline_parse_token_string_t cmd_showcfg_port =
6618 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6619 cmdline_parse_token_string_t cmd_showcfg_what =
6620 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6621 "rxtx#cores#fwd#txpkts");
6623 cmdline_parse_inst_t cmd_showcfg = {
6624 .f = cmd_showcfg_parsed,
6626 .help_str = "show config rxtx|cores|fwd|txpkts",
6628 (void *)&cmd_showcfg_show,
6629 (void *)&cmd_showcfg_port,
6630 (void *)&cmd_showcfg_what,
6635 /* *** SHOW ALL PORT INFO *** */
6636 struct cmd_showportall_result {
6637 cmdline_fixed_string_t show;
6638 cmdline_fixed_string_t port;
6639 cmdline_fixed_string_t what;
6640 cmdline_fixed_string_t all;
6643 static void cmd_showportall_parsed(void *parsed_result,
6644 __attribute__((unused)) struct cmdline *cl,
6645 __attribute__((unused)) void *data)
6649 struct cmd_showportall_result *res = parsed_result;
6650 if (!strcmp(res->show, "clear")) {
6651 if (!strcmp(res->what, "stats"))
6652 RTE_ETH_FOREACH_DEV(i)
6654 else if (!strcmp(res->what, "xstats"))
6655 RTE_ETH_FOREACH_DEV(i)
6656 nic_xstats_clear(i);
6657 } else if (!strcmp(res->what, "info"))
6658 RTE_ETH_FOREACH_DEV(i)
6659 port_infos_display(i);
6660 else if (!strcmp(res->what, "stats"))
6661 RTE_ETH_FOREACH_DEV(i)
6662 nic_stats_display(i);
6663 else if (!strcmp(res->what, "xstats"))
6664 RTE_ETH_FOREACH_DEV(i)
6665 nic_xstats_display(i);
6666 else if (!strcmp(res->what, "fdir"))
6667 RTE_ETH_FOREACH_DEV(i)
6669 else if (!strcmp(res->what, "stat_qmap"))
6670 RTE_ETH_FOREACH_DEV(i)
6671 nic_stats_mapping_display(i);
6672 else if (!strcmp(res->what, "dcb_tc"))
6673 RTE_ETH_FOREACH_DEV(i)
6674 port_dcb_info_display(i);
6675 else if (!strcmp(res->what, "cap"))
6676 RTE_ETH_FOREACH_DEV(i)
6677 port_offload_cap_display(i);
6680 cmdline_parse_token_string_t cmd_showportall_show =
6681 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6683 cmdline_parse_token_string_t cmd_showportall_port =
6684 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6685 cmdline_parse_token_string_t cmd_showportall_what =
6686 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6687 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6688 cmdline_parse_token_string_t cmd_showportall_all =
6689 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6690 cmdline_parse_inst_t cmd_showportall = {
6691 .f = cmd_showportall_parsed,
6693 .help_str = "show|clear port "
6694 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6696 (void *)&cmd_showportall_show,
6697 (void *)&cmd_showportall_port,
6698 (void *)&cmd_showportall_what,
6699 (void *)&cmd_showportall_all,
6704 /* *** SHOW PORT INFO *** */
6705 struct cmd_showport_result {
6706 cmdline_fixed_string_t show;
6707 cmdline_fixed_string_t port;
6708 cmdline_fixed_string_t what;
6712 static void cmd_showport_parsed(void *parsed_result,
6713 __attribute__((unused)) struct cmdline *cl,
6714 __attribute__((unused)) void *data)
6716 struct cmd_showport_result *res = parsed_result;
6717 if (!strcmp(res->show, "clear")) {
6718 if (!strcmp(res->what, "stats"))
6719 nic_stats_clear(res->portnum);
6720 else if (!strcmp(res->what, "xstats"))
6721 nic_xstats_clear(res->portnum);
6722 } else if (!strcmp(res->what, "info"))
6723 port_infos_display(res->portnum);
6724 else if (!strcmp(res->what, "stats"))
6725 nic_stats_display(res->portnum);
6726 else if (!strcmp(res->what, "xstats"))
6727 nic_xstats_display(res->portnum);
6728 else if (!strcmp(res->what, "fdir"))
6729 fdir_get_infos(res->portnum);
6730 else if (!strcmp(res->what, "stat_qmap"))
6731 nic_stats_mapping_display(res->portnum);
6732 else if (!strcmp(res->what, "dcb_tc"))
6733 port_dcb_info_display(res->portnum);
6734 else if (!strcmp(res->what, "cap"))
6735 port_offload_cap_display(res->portnum);
6738 cmdline_parse_token_string_t cmd_showport_show =
6739 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6741 cmdline_parse_token_string_t cmd_showport_port =
6742 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6743 cmdline_parse_token_string_t cmd_showport_what =
6744 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6745 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6746 cmdline_parse_token_num_t cmd_showport_portnum =
6747 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6749 cmdline_parse_inst_t cmd_showport = {
6750 .f = cmd_showport_parsed,
6752 .help_str = "show|clear port "
6753 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6756 (void *)&cmd_showport_show,
6757 (void *)&cmd_showport_port,
6758 (void *)&cmd_showport_what,
6759 (void *)&cmd_showport_portnum,
6764 /* *** SHOW QUEUE INFO *** */
6765 struct cmd_showqueue_result {
6766 cmdline_fixed_string_t show;
6767 cmdline_fixed_string_t type;
6768 cmdline_fixed_string_t what;
6774 cmd_showqueue_parsed(void *parsed_result,
6775 __attribute__((unused)) struct cmdline *cl,
6776 __attribute__((unused)) void *data)
6778 struct cmd_showqueue_result *res = parsed_result;
6780 if (!strcmp(res->type, "rxq"))
6781 rx_queue_infos_display(res->portnum, res->queuenum);
6782 else if (!strcmp(res->type, "txq"))
6783 tx_queue_infos_display(res->portnum, res->queuenum);
6786 cmdline_parse_token_string_t cmd_showqueue_show =
6787 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6788 cmdline_parse_token_string_t cmd_showqueue_type =
6789 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6790 cmdline_parse_token_string_t cmd_showqueue_what =
6791 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6792 cmdline_parse_token_num_t cmd_showqueue_portnum =
6793 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6794 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6795 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6797 cmdline_parse_inst_t cmd_showqueue = {
6798 .f = cmd_showqueue_parsed,
6800 .help_str = "show rxq|txq info <port_id> <queue_id>",
6802 (void *)&cmd_showqueue_show,
6803 (void *)&cmd_showqueue_type,
6804 (void *)&cmd_showqueue_what,
6805 (void *)&cmd_showqueue_portnum,
6806 (void *)&cmd_showqueue_queuenum,
6811 /* *** READ PORT REGISTER *** */
6812 struct cmd_read_reg_result {
6813 cmdline_fixed_string_t read;
6814 cmdline_fixed_string_t reg;
6820 cmd_read_reg_parsed(void *parsed_result,
6821 __attribute__((unused)) struct cmdline *cl,
6822 __attribute__((unused)) void *data)
6824 struct cmd_read_reg_result *res = parsed_result;
6825 port_reg_display(res->port_id, res->reg_off);
6828 cmdline_parse_token_string_t cmd_read_reg_read =
6829 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6830 cmdline_parse_token_string_t cmd_read_reg_reg =
6831 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6832 cmdline_parse_token_num_t cmd_read_reg_port_id =
6833 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6834 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6835 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6837 cmdline_parse_inst_t cmd_read_reg = {
6838 .f = cmd_read_reg_parsed,
6840 .help_str = "read reg <port_id> <reg_off>",
6842 (void *)&cmd_read_reg_read,
6843 (void *)&cmd_read_reg_reg,
6844 (void *)&cmd_read_reg_port_id,
6845 (void *)&cmd_read_reg_reg_off,
6850 /* *** READ PORT REGISTER BIT FIELD *** */
6851 struct cmd_read_reg_bit_field_result {
6852 cmdline_fixed_string_t read;
6853 cmdline_fixed_string_t regfield;
6861 cmd_read_reg_bit_field_parsed(void *parsed_result,
6862 __attribute__((unused)) struct cmdline *cl,
6863 __attribute__((unused)) void *data)
6865 struct cmd_read_reg_bit_field_result *res = parsed_result;
6866 port_reg_bit_field_display(res->port_id, res->reg_off,
6867 res->bit1_pos, res->bit2_pos);
6870 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6871 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6873 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6874 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6875 regfield, "regfield");
6876 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6877 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6879 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6880 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6882 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6883 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6885 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6886 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6889 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6890 .f = cmd_read_reg_bit_field_parsed,
6892 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6893 "Read register bit field between bit_x and bit_y included",
6895 (void *)&cmd_read_reg_bit_field_read,
6896 (void *)&cmd_read_reg_bit_field_regfield,
6897 (void *)&cmd_read_reg_bit_field_port_id,
6898 (void *)&cmd_read_reg_bit_field_reg_off,
6899 (void *)&cmd_read_reg_bit_field_bit1_pos,
6900 (void *)&cmd_read_reg_bit_field_bit2_pos,
6905 /* *** READ PORT REGISTER BIT *** */
6906 struct cmd_read_reg_bit_result {
6907 cmdline_fixed_string_t read;
6908 cmdline_fixed_string_t regbit;
6915 cmd_read_reg_bit_parsed(void *parsed_result,
6916 __attribute__((unused)) struct cmdline *cl,
6917 __attribute__((unused)) void *data)
6919 struct cmd_read_reg_bit_result *res = parsed_result;
6920 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6923 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6924 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6925 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6926 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6928 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6929 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6930 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6931 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6932 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6933 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6935 cmdline_parse_inst_t cmd_read_reg_bit = {
6936 .f = cmd_read_reg_bit_parsed,
6938 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6940 (void *)&cmd_read_reg_bit_read,
6941 (void *)&cmd_read_reg_bit_regbit,
6942 (void *)&cmd_read_reg_bit_port_id,
6943 (void *)&cmd_read_reg_bit_reg_off,
6944 (void *)&cmd_read_reg_bit_bit_pos,
6949 /* *** WRITE PORT REGISTER *** */
6950 struct cmd_write_reg_result {
6951 cmdline_fixed_string_t write;
6952 cmdline_fixed_string_t reg;
6959 cmd_write_reg_parsed(void *parsed_result,
6960 __attribute__((unused)) struct cmdline *cl,
6961 __attribute__((unused)) void *data)
6963 struct cmd_write_reg_result *res = parsed_result;
6964 port_reg_set(res->port_id, res->reg_off, res->value);
6967 cmdline_parse_token_string_t cmd_write_reg_write =
6968 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6969 cmdline_parse_token_string_t cmd_write_reg_reg =
6970 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6971 cmdline_parse_token_num_t cmd_write_reg_port_id =
6972 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6973 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6974 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6975 cmdline_parse_token_num_t cmd_write_reg_value =
6976 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6978 cmdline_parse_inst_t cmd_write_reg = {
6979 .f = cmd_write_reg_parsed,
6981 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6983 (void *)&cmd_write_reg_write,
6984 (void *)&cmd_write_reg_reg,
6985 (void *)&cmd_write_reg_port_id,
6986 (void *)&cmd_write_reg_reg_off,
6987 (void *)&cmd_write_reg_value,
6992 /* *** WRITE PORT REGISTER BIT FIELD *** */
6993 struct cmd_write_reg_bit_field_result {
6994 cmdline_fixed_string_t write;
6995 cmdline_fixed_string_t regfield;
7004 cmd_write_reg_bit_field_parsed(void *parsed_result,
7005 __attribute__((unused)) struct cmdline *cl,
7006 __attribute__((unused)) void *data)
7008 struct cmd_write_reg_bit_field_result *res = parsed_result;
7009 port_reg_bit_field_set(res->port_id, res->reg_off,
7010 res->bit1_pos, res->bit2_pos, res->value);
7013 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7014 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7016 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7017 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7018 regfield, "regfield");
7019 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7020 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7022 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7023 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7025 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7026 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7028 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7029 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7031 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7032 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7035 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7036 .f = cmd_write_reg_bit_field_parsed,
7038 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7040 "Set register bit field between bit_x and bit_y included",
7042 (void *)&cmd_write_reg_bit_field_write,
7043 (void *)&cmd_write_reg_bit_field_regfield,
7044 (void *)&cmd_write_reg_bit_field_port_id,
7045 (void *)&cmd_write_reg_bit_field_reg_off,
7046 (void *)&cmd_write_reg_bit_field_bit1_pos,
7047 (void *)&cmd_write_reg_bit_field_bit2_pos,
7048 (void *)&cmd_write_reg_bit_field_value,
7053 /* *** WRITE PORT REGISTER BIT *** */
7054 struct cmd_write_reg_bit_result {
7055 cmdline_fixed_string_t write;
7056 cmdline_fixed_string_t regbit;
7064 cmd_write_reg_bit_parsed(void *parsed_result,
7065 __attribute__((unused)) struct cmdline *cl,
7066 __attribute__((unused)) void *data)
7068 struct cmd_write_reg_bit_result *res = parsed_result;
7069 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7072 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7073 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7075 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7076 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7078 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7079 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7080 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7081 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7082 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7083 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7084 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7085 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7087 cmdline_parse_inst_t cmd_write_reg_bit = {
7088 .f = cmd_write_reg_bit_parsed,
7090 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7093 (void *)&cmd_write_reg_bit_write,
7094 (void *)&cmd_write_reg_bit_regbit,
7095 (void *)&cmd_write_reg_bit_port_id,
7096 (void *)&cmd_write_reg_bit_reg_off,
7097 (void *)&cmd_write_reg_bit_bit_pos,
7098 (void *)&cmd_write_reg_bit_value,
7103 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7104 struct cmd_read_rxd_txd_result {
7105 cmdline_fixed_string_t read;
7106 cmdline_fixed_string_t rxd_txd;
7113 cmd_read_rxd_txd_parsed(void *parsed_result,
7114 __attribute__((unused)) struct cmdline *cl,
7115 __attribute__((unused)) void *data)
7117 struct cmd_read_rxd_txd_result *res = parsed_result;
7119 if (!strcmp(res->rxd_txd, "rxd"))
7120 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7121 else if (!strcmp(res->rxd_txd, "txd"))
7122 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7125 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7126 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7127 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7128 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7130 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7131 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7132 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7133 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7134 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7135 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7137 cmdline_parse_inst_t cmd_read_rxd_txd = {
7138 .f = cmd_read_rxd_txd_parsed,
7140 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7142 (void *)&cmd_read_rxd_txd_read,
7143 (void *)&cmd_read_rxd_txd_rxd_txd,
7144 (void *)&cmd_read_rxd_txd_port_id,
7145 (void *)&cmd_read_rxd_txd_queue_id,
7146 (void *)&cmd_read_rxd_txd_desc_id,
7152 struct cmd_quit_result {
7153 cmdline_fixed_string_t quit;
7156 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7158 __attribute__((unused)) void *data)
7164 cmdline_parse_token_string_t cmd_quit_quit =
7165 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7167 cmdline_parse_inst_t cmd_quit = {
7168 .f = cmd_quit_parsed,
7170 .help_str = "quit: Exit application",
7172 (void *)&cmd_quit_quit,
7177 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7178 struct cmd_mac_addr_result {
7179 cmdline_fixed_string_t mac_addr_cmd;
7180 cmdline_fixed_string_t what;
7182 struct ether_addr address;
7185 static void cmd_mac_addr_parsed(void *parsed_result,
7186 __attribute__((unused)) struct cmdline *cl,
7187 __attribute__((unused)) void *data)
7189 struct cmd_mac_addr_result *res = parsed_result;
7192 if (strcmp(res->what, "add") == 0)
7193 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7194 else if (strcmp(res->what, "set") == 0)
7195 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7198 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7200 /* check the return value and print it if is < 0 */
7202 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7206 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7207 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7209 cmdline_parse_token_string_t cmd_mac_addr_what =
7210 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7212 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7213 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7215 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7216 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7218 cmdline_parse_inst_t cmd_mac_addr = {
7219 .f = cmd_mac_addr_parsed,
7221 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7222 "Add/Remove/Set MAC address on port_id",
7224 (void *)&cmd_mac_addr_cmd,
7225 (void *)&cmd_mac_addr_what,
7226 (void *)&cmd_mac_addr_portnum,
7227 (void *)&cmd_mac_addr_addr,
7232 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7233 struct cmd_eth_peer_result {
7234 cmdline_fixed_string_t set;
7235 cmdline_fixed_string_t eth_peer;
7237 cmdline_fixed_string_t peer_addr;
7240 static void cmd_set_eth_peer_parsed(void *parsed_result,
7241 __attribute__((unused)) struct cmdline *cl,
7242 __attribute__((unused)) void *data)
7244 struct cmd_eth_peer_result *res = parsed_result;
7246 if (test_done == 0) {
7247 printf("Please stop forwarding first\n");
7250 if (!strcmp(res->eth_peer, "eth-peer")) {
7251 set_fwd_eth_peer(res->port_id, res->peer_addr);
7255 cmdline_parse_token_string_t cmd_eth_peer_set =
7256 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7257 cmdline_parse_token_string_t cmd_eth_peer =
7258 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7259 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7260 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7261 cmdline_parse_token_string_t cmd_eth_peer_addr =
7262 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7264 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7265 .f = cmd_set_eth_peer_parsed,
7267 .help_str = "set eth-peer <port_id> <peer_mac>",
7269 (void *)&cmd_eth_peer_set,
7270 (void *)&cmd_eth_peer,
7271 (void *)&cmd_eth_peer_port_id,
7272 (void *)&cmd_eth_peer_addr,
7277 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7278 struct cmd_set_qmap_result {
7279 cmdline_fixed_string_t set;
7280 cmdline_fixed_string_t qmap;
7281 cmdline_fixed_string_t what;
7288 cmd_set_qmap_parsed(void *parsed_result,
7289 __attribute__((unused)) struct cmdline *cl,
7290 __attribute__((unused)) void *data)
7292 struct cmd_set_qmap_result *res = parsed_result;
7293 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7295 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7298 cmdline_parse_token_string_t cmd_setqmap_set =
7299 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7301 cmdline_parse_token_string_t cmd_setqmap_qmap =
7302 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7304 cmdline_parse_token_string_t cmd_setqmap_what =
7305 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7307 cmdline_parse_token_num_t cmd_setqmap_portid =
7308 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7310 cmdline_parse_token_num_t cmd_setqmap_queueid =
7311 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7313 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7314 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7317 cmdline_parse_inst_t cmd_set_qmap = {
7318 .f = cmd_set_qmap_parsed,
7320 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7321 "Set statistics mapping value on tx|rx queue_id of port_id",
7323 (void *)&cmd_setqmap_set,
7324 (void *)&cmd_setqmap_qmap,
7325 (void *)&cmd_setqmap_what,
7326 (void *)&cmd_setqmap_portid,
7327 (void *)&cmd_setqmap_queueid,
7328 (void *)&cmd_setqmap_mapvalue,
7333 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7334 struct cmd_set_xstats_hide_zero_result {
7335 cmdline_fixed_string_t keyword;
7336 cmdline_fixed_string_t name;
7337 cmdline_fixed_string_t on_off;
7341 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7342 __attribute__((unused)) struct cmdline *cl,
7343 __attribute__((unused)) void *data)
7345 struct cmd_set_xstats_hide_zero_result *res;
7346 uint16_t on_off = 0;
7348 res = parsed_result;
7349 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7350 set_xstats_hide_zero(on_off);
7353 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7354 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7356 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7357 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7358 name, "xstats-hide-zero");
7359 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7360 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7363 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7364 .f = cmd_set_xstats_hide_zero_parsed,
7366 .help_str = "set xstats-hide-zero on|off",
7368 (void *)&cmd_set_xstats_hide_zero_keyword,
7369 (void *)&cmd_set_xstats_hide_zero_name,
7370 (void *)&cmd_set_xstats_hide_zero_on_off,
7375 /* *** CONFIGURE UNICAST HASH TABLE *** */
7376 struct cmd_set_uc_hash_table {
7377 cmdline_fixed_string_t set;
7378 cmdline_fixed_string_t port;
7380 cmdline_fixed_string_t what;
7381 struct ether_addr address;
7382 cmdline_fixed_string_t mode;
7386 cmd_set_uc_hash_parsed(void *parsed_result,
7387 __attribute__((unused)) struct cmdline *cl,
7388 __attribute__((unused)) void *data)
7391 struct cmd_set_uc_hash_table *res = parsed_result;
7393 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7395 if (strcmp(res->what, "uta") == 0)
7396 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7397 &res->address,(uint8_t)is_on);
7399 printf("bad unicast hash table parameter, return code = %d \n", ret);
7403 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7404 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7406 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7407 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7409 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7410 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7412 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7413 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7415 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7416 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7418 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7419 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7422 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7423 .f = cmd_set_uc_hash_parsed,
7425 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7427 (void *)&cmd_set_uc_hash_set,
7428 (void *)&cmd_set_uc_hash_port,
7429 (void *)&cmd_set_uc_hash_portid,
7430 (void *)&cmd_set_uc_hash_what,
7431 (void *)&cmd_set_uc_hash_mac,
7432 (void *)&cmd_set_uc_hash_mode,
7437 struct cmd_set_uc_all_hash_table {
7438 cmdline_fixed_string_t set;
7439 cmdline_fixed_string_t port;
7441 cmdline_fixed_string_t what;
7442 cmdline_fixed_string_t value;
7443 cmdline_fixed_string_t mode;
7447 cmd_set_uc_all_hash_parsed(void *parsed_result,
7448 __attribute__((unused)) struct cmdline *cl,
7449 __attribute__((unused)) void *data)
7452 struct cmd_set_uc_all_hash_table *res = parsed_result;
7454 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7456 if ((strcmp(res->what, "uta") == 0) &&
7457 (strcmp(res->value, "all") == 0))
7458 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7460 printf("bad unicast hash table parameter,"
7461 "return code = %d \n", ret);
7464 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7465 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7467 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7468 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7470 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7471 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7473 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7474 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7476 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7477 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7479 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7480 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7483 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7484 .f = cmd_set_uc_all_hash_parsed,
7486 .help_str = "set port <port_id> uta all on|off",
7488 (void *)&cmd_set_uc_all_hash_set,
7489 (void *)&cmd_set_uc_all_hash_port,
7490 (void *)&cmd_set_uc_all_hash_portid,
7491 (void *)&cmd_set_uc_all_hash_what,
7492 (void *)&cmd_set_uc_all_hash_value,
7493 (void *)&cmd_set_uc_all_hash_mode,
7498 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7499 struct cmd_set_vf_macvlan_filter {
7500 cmdline_fixed_string_t set;
7501 cmdline_fixed_string_t port;
7503 cmdline_fixed_string_t vf;
7505 struct ether_addr address;
7506 cmdline_fixed_string_t filter_type;
7507 cmdline_fixed_string_t mode;
7511 cmd_set_vf_macvlan_parsed(void *parsed_result,
7512 __attribute__((unused)) struct cmdline *cl,
7513 __attribute__((unused)) void *data)
7516 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7517 struct rte_eth_mac_filter filter;
7519 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7521 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7523 /* set VF MAC filter */
7527 filter.dst_id = res->vf_id;
7529 if (!strcmp(res->filter_type, "exact-mac"))
7530 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7531 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7532 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7533 else if (!strcmp(res->filter_type, "hashmac"))
7534 filter.filter_type = RTE_MAC_HASH_MATCH;
7535 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7536 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7538 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7541 ret = rte_eth_dev_filter_ctrl(res->port_id,
7542 RTE_ETH_FILTER_MACVLAN,
7546 ret = rte_eth_dev_filter_ctrl(res->port_id,
7547 RTE_ETH_FILTER_MACVLAN,
7548 RTE_ETH_FILTER_DELETE,
7552 printf("bad set MAC hash parameter, return code = %d\n", ret);
7556 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7557 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7559 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7560 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7562 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7563 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7565 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7566 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7568 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7569 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7571 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7572 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7574 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7575 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7576 filter_type, "exact-mac#exact-mac-vlan"
7577 "#hashmac#hashmac-vlan");
7578 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7579 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7582 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7583 .f = cmd_set_vf_macvlan_parsed,
7585 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7586 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7587 "Exact match rule: exact match of MAC or MAC and VLAN; "
7588 "hash match rule: hash match of MAC and exact match of VLAN",
7590 (void *)&cmd_set_vf_macvlan_set,
7591 (void *)&cmd_set_vf_macvlan_port,
7592 (void *)&cmd_set_vf_macvlan_portid,
7593 (void *)&cmd_set_vf_macvlan_vf,
7594 (void *)&cmd_set_vf_macvlan_vf_id,
7595 (void *)&cmd_set_vf_macvlan_mac,
7596 (void *)&cmd_set_vf_macvlan_filter_type,
7597 (void *)&cmd_set_vf_macvlan_mode,
7602 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7603 struct cmd_set_vf_traffic {
7604 cmdline_fixed_string_t set;
7605 cmdline_fixed_string_t port;
7607 cmdline_fixed_string_t vf;
7609 cmdline_fixed_string_t what;
7610 cmdline_fixed_string_t mode;
7614 cmd_set_vf_traffic_parsed(void *parsed_result,
7615 __attribute__((unused)) struct cmdline *cl,
7616 __attribute__((unused)) void *data)
7618 struct cmd_set_vf_traffic *res = parsed_result;
7619 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7620 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7622 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7625 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7626 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7628 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7629 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7631 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7632 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7634 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7635 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7637 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7638 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7640 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7641 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7643 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7644 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7647 cmdline_parse_inst_t cmd_set_vf_traffic = {
7648 .f = cmd_set_vf_traffic_parsed,
7650 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7652 (void *)&cmd_setvf_traffic_set,
7653 (void *)&cmd_setvf_traffic_port,
7654 (void *)&cmd_setvf_traffic_portid,
7655 (void *)&cmd_setvf_traffic_vf,
7656 (void *)&cmd_setvf_traffic_vfid,
7657 (void *)&cmd_setvf_traffic_what,
7658 (void *)&cmd_setvf_traffic_mode,
7663 /* *** CONFIGURE VF RECEIVE MODE *** */
7664 struct cmd_set_vf_rxmode {
7665 cmdline_fixed_string_t set;
7666 cmdline_fixed_string_t port;
7668 cmdline_fixed_string_t vf;
7670 cmdline_fixed_string_t what;
7671 cmdline_fixed_string_t mode;
7672 cmdline_fixed_string_t on;
7676 cmd_set_vf_rxmode_parsed(void *parsed_result,
7677 __attribute__((unused)) struct cmdline *cl,
7678 __attribute__((unused)) void *data)
7681 uint16_t rx_mode = 0;
7682 struct cmd_set_vf_rxmode *res = parsed_result;
7684 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7685 if (!strcmp(res->what,"rxmode")) {
7686 if (!strcmp(res->mode, "AUPE"))
7687 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7688 else if (!strcmp(res->mode, "ROPE"))
7689 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7690 else if (!strcmp(res->mode, "BAM"))
7691 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7692 else if (!strncmp(res->mode, "MPE",3))
7693 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7696 RTE_SET_USED(is_on);
7698 #ifdef RTE_LIBRTE_IXGBE_PMD
7699 if (ret == -ENOTSUP)
7700 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7701 rx_mode, (uint8_t)is_on);
7703 #ifdef RTE_LIBRTE_BNXT_PMD
7704 if (ret == -ENOTSUP)
7705 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7706 rx_mode, (uint8_t)is_on);
7709 printf("bad VF receive mode parameter, return code = %d \n",
7713 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7714 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7716 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7717 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7719 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7720 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7722 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7723 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7725 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7726 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7728 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7729 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7731 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7732 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7733 mode, "AUPE#ROPE#BAM#MPE");
7734 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7735 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7738 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7739 .f = cmd_set_vf_rxmode_parsed,
7741 .help_str = "set port <port_id> vf <vf_id> rxmode "
7742 "AUPE|ROPE|BAM|MPE on|off",
7744 (void *)&cmd_set_vf_rxmode_set,
7745 (void *)&cmd_set_vf_rxmode_port,
7746 (void *)&cmd_set_vf_rxmode_portid,
7747 (void *)&cmd_set_vf_rxmode_vf,
7748 (void *)&cmd_set_vf_rxmode_vfid,
7749 (void *)&cmd_set_vf_rxmode_what,
7750 (void *)&cmd_set_vf_rxmode_mode,
7751 (void *)&cmd_set_vf_rxmode_on,
7756 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7757 struct cmd_vf_mac_addr_result {
7758 cmdline_fixed_string_t mac_addr_cmd;
7759 cmdline_fixed_string_t what;
7760 cmdline_fixed_string_t port;
7762 cmdline_fixed_string_t vf;
7764 struct ether_addr address;
7767 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7768 __attribute__((unused)) struct cmdline *cl,
7769 __attribute__((unused)) void *data)
7771 struct cmd_vf_mac_addr_result *res = parsed_result;
7774 if (strcmp(res->what, "add") != 0)
7777 #ifdef RTE_LIBRTE_I40E_PMD
7778 if (ret == -ENOTSUP)
7779 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7782 #ifdef RTE_LIBRTE_BNXT_PMD
7783 if (ret == -ENOTSUP)
7784 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7789 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7793 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7794 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7795 mac_addr_cmd,"mac_addr");
7796 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7797 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7799 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7800 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7802 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7803 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7805 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7806 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7808 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7809 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7811 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7812 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7815 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7816 .f = cmd_vf_mac_addr_parsed,
7818 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7819 "Add MAC address filtering for a VF on port_id",
7821 (void *)&cmd_vf_mac_addr_cmd,
7822 (void *)&cmd_vf_mac_addr_what,
7823 (void *)&cmd_vf_mac_addr_port,
7824 (void *)&cmd_vf_mac_addr_portnum,
7825 (void *)&cmd_vf_mac_addr_vf,
7826 (void *)&cmd_vf_mac_addr_vfnum,
7827 (void *)&cmd_vf_mac_addr_addr,
7832 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7833 struct cmd_vf_rx_vlan_filter {
7834 cmdline_fixed_string_t rx_vlan;
7835 cmdline_fixed_string_t what;
7837 cmdline_fixed_string_t port;
7839 cmdline_fixed_string_t vf;
7844 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7845 __attribute__((unused)) struct cmdline *cl,
7846 __attribute__((unused)) void *data)
7848 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7851 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7853 #ifdef RTE_LIBRTE_IXGBE_PMD
7854 if (ret == -ENOTSUP)
7855 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7856 res->vlan_id, res->vf_mask, is_add);
7858 #ifdef RTE_LIBRTE_I40E_PMD
7859 if (ret == -ENOTSUP)
7860 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7861 res->vlan_id, res->vf_mask, is_add);
7863 #ifdef RTE_LIBRTE_BNXT_PMD
7864 if (ret == -ENOTSUP)
7865 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7866 res->vlan_id, res->vf_mask, is_add);
7873 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7874 res->vlan_id, res->vf_mask);
7877 printf("invalid port_id %d\n", res->port_id);
7880 printf("function not implemented or supported\n");
7883 printf("programming error: (%s)\n", strerror(-ret));
7887 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7888 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7889 rx_vlan, "rx_vlan");
7890 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7891 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7893 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7894 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7896 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7897 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7899 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7900 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7902 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7903 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7905 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7906 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7909 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7910 .f = cmd_vf_rx_vlan_filter_parsed,
7912 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7913 "(vf_mask = hexadecimal VF mask)",
7915 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7916 (void *)&cmd_vf_rx_vlan_filter_what,
7917 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7918 (void *)&cmd_vf_rx_vlan_filter_port,
7919 (void *)&cmd_vf_rx_vlan_filter_portid,
7920 (void *)&cmd_vf_rx_vlan_filter_vf,
7921 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7926 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7927 struct cmd_queue_rate_limit_result {
7928 cmdline_fixed_string_t set;
7929 cmdline_fixed_string_t port;
7931 cmdline_fixed_string_t queue;
7933 cmdline_fixed_string_t rate;
7937 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7938 __attribute__((unused)) struct cmdline *cl,
7939 __attribute__((unused)) void *data)
7941 struct cmd_queue_rate_limit_result *res = parsed_result;
7944 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7945 && (strcmp(res->queue, "queue") == 0)
7946 && (strcmp(res->rate, "rate") == 0))
7947 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7950 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7954 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7955 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7957 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7958 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7960 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7961 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7963 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7964 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7966 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7967 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7969 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7970 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7972 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7973 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7976 cmdline_parse_inst_t cmd_queue_rate_limit = {
7977 .f = cmd_queue_rate_limit_parsed,
7979 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7980 "Set rate limit for a queue on port_id",
7982 (void *)&cmd_queue_rate_limit_set,
7983 (void *)&cmd_queue_rate_limit_port,
7984 (void *)&cmd_queue_rate_limit_portnum,
7985 (void *)&cmd_queue_rate_limit_queue,
7986 (void *)&cmd_queue_rate_limit_queuenum,
7987 (void *)&cmd_queue_rate_limit_rate,
7988 (void *)&cmd_queue_rate_limit_ratenum,
7993 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7994 struct cmd_vf_rate_limit_result {
7995 cmdline_fixed_string_t set;
7996 cmdline_fixed_string_t port;
7998 cmdline_fixed_string_t vf;
8000 cmdline_fixed_string_t rate;
8002 cmdline_fixed_string_t q_msk;
8006 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8007 __attribute__((unused)) struct cmdline *cl,
8008 __attribute__((unused)) void *data)
8010 struct cmd_vf_rate_limit_result *res = parsed_result;
8013 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8014 && (strcmp(res->vf, "vf") == 0)
8015 && (strcmp(res->rate, "rate") == 0)
8016 && (strcmp(res->q_msk, "queue_mask") == 0))
8017 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8018 res->rate_num, res->q_msk_val);
8020 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8024 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8025 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8027 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8028 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8030 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8031 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8033 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8034 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8036 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8037 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8039 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8040 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8042 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8043 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8045 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8046 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8047 q_msk, "queue_mask");
8048 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8049 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8052 cmdline_parse_inst_t cmd_vf_rate_limit = {
8053 .f = cmd_vf_rate_limit_parsed,
8055 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8056 "queue_mask <queue_mask_value>: "
8057 "Set rate limit for queues of VF on port_id",
8059 (void *)&cmd_vf_rate_limit_set,
8060 (void *)&cmd_vf_rate_limit_port,
8061 (void *)&cmd_vf_rate_limit_portnum,
8062 (void *)&cmd_vf_rate_limit_vf,
8063 (void *)&cmd_vf_rate_limit_vfnum,
8064 (void *)&cmd_vf_rate_limit_rate,
8065 (void *)&cmd_vf_rate_limit_ratenum,
8066 (void *)&cmd_vf_rate_limit_q_msk,
8067 (void *)&cmd_vf_rate_limit_q_msk_val,
8072 /* *** ADD TUNNEL FILTER OF A PORT *** */
8073 struct cmd_tunnel_filter_result {
8074 cmdline_fixed_string_t cmd;
8075 cmdline_fixed_string_t what;
8077 struct ether_addr outer_mac;
8078 struct ether_addr inner_mac;
8079 cmdline_ipaddr_t ip_value;
8080 uint16_t inner_vlan;
8081 cmdline_fixed_string_t tunnel_type;
8082 cmdline_fixed_string_t filter_type;
8088 cmd_tunnel_filter_parsed(void *parsed_result,
8089 __attribute__((unused)) struct cmdline *cl,
8090 __attribute__((unused)) void *data)
8092 struct cmd_tunnel_filter_result *res = parsed_result;
8093 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8096 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8098 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8099 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8100 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8102 if (res->ip_value.family == AF_INET) {
8103 tunnel_filter_conf.ip_addr.ipv4_addr =
8104 res->ip_value.addr.ipv4.s_addr;
8105 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8107 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8108 &(res->ip_value.addr.ipv6),
8109 sizeof(struct in6_addr));
8110 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8113 if (!strcmp(res->filter_type, "imac-ivlan"))
8114 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8115 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8116 tunnel_filter_conf.filter_type =
8117 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8118 else if (!strcmp(res->filter_type, "imac-tenid"))
8119 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8120 else if (!strcmp(res->filter_type, "imac"))
8121 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8122 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8123 tunnel_filter_conf.filter_type =
8124 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8125 else if (!strcmp(res->filter_type, "oip"))
8126 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8127 else if (!strcmp(res->filter_type, "iip"))
8128 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8130 printf("The filter type is not supported");
8134 if (!strcmp(res->tunnel_type, "vxlan"))
8135 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8136 else if (!strcmp(res->tunnel_type, "nvgre"))
8137 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8138 else if (!strcmp(res->tunnel_type, "ipingre"))
8139 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8141 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8145 tunnel_filter_conf.tenant_id = res->tenant_id;
8146 tunnel_filter_conf.queue_id = res->queue_num;
8147 if (!strcmp(res->what, "add"))
8148 ret = rte_eth_dev_filter_ctrl(res->port_id,
8149 RTE_ETH_FILTER_TUNNEL,
8151 &tunnel_filter_conf);
8153 ret = rte_eth_dev_filter_ctrl(res->port_id,
8154 RTE_ETH_FILTER_TUNNEL,
8155 RTE_ETH_FILTER_DELETE,
8156 &tunnel_filter_conf);
8158 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8162 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8163 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8164 cmd, "tunnel_filter");
8165 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8166 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8168 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8169 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8171 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8172 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8174 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8175 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8177 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8178 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8179 inner_vlan, UINT16);
8180 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8181 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8183 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8184 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8185 tunnel_type, "vxlan#nvgre#ipingre");
8187 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8188 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8189 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8190 "imac#omac-imac-tenid");
8191 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8192 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8194 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8195 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8198 cmdline_parse_inst_t cmd_tunnel_filter = {
8199 .f = cmd_tunnel_filter_parsed,
8201 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8202 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8203 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8204 "<queue_id>: Add/Rm tunnel filter of a port",
8206 (void *)&cmd_tunnel_filter_cmd,
8207 (void *)&cmd_tunnel_filter_what,
8208 (void *)&cmd_tunnel_filter_port_id,
8209 (void *)&cmd_tunnel_filter_outer_mac,
8210 (void *)&cmd_tunnel_filter_inner_mac,
8211 (void *)&cmd_tunnel_filter_ip_value,
8212 (void *)&cmd_tunnel_filter_innner_vlan,
8213 (void *)&cmd_tunnel_filter_tunnel_type,
8214 (void *)&cmd_tunnel_filter_filter_type,
8215 (void *)&cmd_tunnel_filter_tenant_id,
8216 (void *)&cmd_tunnel_filter_queue_num,
8221 /* *** CONFIGURE TUNNEL UDP PORT *** */
8222 struct cmd_tunnel_udp_config {
8223 cmdline_fixed_string_t cmd;
8224 cmdline_fixed_string_t what;
8230 cmd_tunnel_udp_config_parsed(void *parsed_result,
8231 __attribute__((unused)) struct cmdline *cl,
8232 __attribute__((unused)) void *data)
8234 struct cmd_tunnel_udp_config *res = parsed_result;
8235 struct rte_eth_udp_tunnel tunnel_udp;
8238 tunnel_udp.udp_port = res->udp_port;
8240 if (!strcmp(res->cmd, "rx_vxlan_port"))
8241 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8243 if (!strcmp(res->what, "add"))
8244 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8247 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8251 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8254 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8255 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8256 cmd, "rx_vxlan_port");
8257 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8258 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8260 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8261 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8263 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8264 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8267 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8268 .f = cmd_tunnel_udp_config_parsed,
8270 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8271 "Add/Remove a tunneling UDP port filter",
8273 (void *)&cmd_tunnel_udp_config_cmd,
8274 (void *)&cmd_tunnel_udp_config_what,
8275 (void *)&cmd_tunnel_udp_config_udp_port,
8276 (void *)&cmd_tunnel_udp_config_port_id,
8281 /* *** GLOBAL CONFIG *** */
8282 struct cmd_global_config_result {
8283 cmdline_fixed_string_t cmd;
8285 cmdline_fixed_string_t cfg_type;
8290 cmd_global_config_parsed(void *parsed_result,
8291 __attribute__((unused)) struct cmdline *cl,
8292 __attribute__((unused)) void *data)
8294 struct cmd_global_config_result *res = parsed_result;
8295 struct rte_eth_global_cfg conf;
8298 memset(&conf, 0, sizeof(conf));
8299 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8300 conf.cfg.gre_key_len = res->len;
8301 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8302 RTE_ETH_FILTER_SET, &conf);
8304 printf("Global config error\n");
8307 cmdline_parse_token_string_t cmd_global_config_cmd =
8308 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8310 cmdline_parse_token_num_t cmd_global_config_port_id =
8311 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8313 cmdline_parse_token_string_t cmd_global_config_type =
8314 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8315 cfg_type, "gre-key-len");
8316 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8317 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8320 cmdline_parse_inst_t cmd_global_config = {
8321 .f = cmd_global_config_parsed,
8322 .data = (void *)NULL,
8323 .help_str = "global_config <port_id> gre-key-len <key_len>",
8325 (void *)&cmd_global_config_cmd,
8326 (void *)&cmd_global_config_port_id,
8327 (void *)&cmd_global_config_type,
8328 (void *)&cmd_global_config_gre_key_len,
8333 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8334 struct cmd_set_mirror_mask_result {
8335 cmdline_fixed_string_t set;
8336 cmdline_fixed_string_t port;
8338 cmdline_fixed_string_t mirror;
8340 cmdline_fixed_string_t what;
8341 cmdline_fixed_string_t value;
8342 cmdline_fixed_string_t dstpool;
8344 cmdline_fixed_string_t on;
8347 cmdline_parse_token_string_t cmd_mirror_mask_set =
8348 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8350 cmdline_parse_token_string_t cmd_mirror_mask_port =
8351 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8353 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8354 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8356 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8357 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8358 mirror, "mirror-rule");
8359 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8360 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8362 cmdline_parse_token_string_t cmd_mirror_mask_what =
8363 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8364 what, "pool-mirror-up#pool-mirror-down"
8366 cmdline_parse_token_string_t cmd_mirror_mask_value =
8367 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8369 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8370 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8371 dstpool, "dst-pool");
8372 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8373 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8375 cmdline_parse_token_string_t cmd_mirror_mask_on =
8376 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8380 cmd_set_mirror_mask_parsed(void *parsed_result,
8381 __attribute__((unused)) struct cmdline *cl,
8382 __attribute__((unused)) void *data)
8385 struct cmd_set_mirror_mask_result *res = parsed_result;
8386 struct rte_eth_mirror_conf mr_conf;
8388 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8390 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8392 mr_conf.dst_pool = res->dstpool_id;
8394 if (!strcmp(res->what, "pool-mirror-up")) {
8395 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8396 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8397 } else if (!strcmp(res->what, "pool-mirror-down")) {
8398 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8399 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8400 } else if (!strcmp(res->what, "vlan-mirror")) {
8401 mr_conf.rule_type = ETH_MIRROR_VLAN;
8402 nb_item = parse_item_list(res->value, "vlan",
8403 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8407 for (i = 0; i < nb_item; i++) {
8408 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8409 printf("Invalid vlan_id: must be < 4096\n");
8413 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8414 mr_conf.vlan.vlan_mask |= 1ULL << i;
8418 if (!strcmp(res->on, "on"))
8419 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8422 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8425 printf("mirror rule add error: (%s)\n", strerror(-ret));
8428 cmdline_parse_inst_t cmd_set_mirror_mask = {
8429 .f = cmd_set_mirror_mask_parsed,
8431 .help_str = "set port <port_id> mirror-rule <rule_id> "
8432 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8433 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8435 (void *)&cmd_mirror_mask_set,
8436 (void *)&cmd_mirror_mask_port,
8437 (void *)&cmd_mirror_mask_portid,
8438 (void *)&cmd_mirror_mask_mirror,
8439 (void *)&cmd_mirror_mask_ruleid,
8440 (void *)&cmd_mirror_mask_what,
8441 (void *)&cmd_mirror_mask_value,
8442 (void *)&cmd_mirror_mask_dstpool,
8443 (void *)&cmd_mirror_mask_poolid,
8444 (void *)&cmd_mirror_mask_on,
8449 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8450 struct cmd_set_mirror_link_result {
8451 cmdline_fixed_string_t set;
8452 cmdline_fixed_string_t port;
8454 cmdline_fixed_string_t mirror;
8456 cmdline_fixed_string_t what;
8457 cmdline_fixed_string_t dstpool;
8459 cmdline_fixed_string_t on;
8462 cmdline_parse_token_string_t cmd_mirror_link_set =
8463 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8465 cmdline_parse_token_string_t cmd_mirror_link_port =
8466 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8468 cmdline_parse_token_num_t cmd_mirror_link_portid =
8469 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8471 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8472 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8473 mirror, "mirror-rule");
8474 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8475 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8477 cmdline_parse_token_string_t cmd_mirror_link_what =
8478 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8479 what, "uplink-mirror#downlink-mirror");
8480 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8481 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8482 dstpool, "dst-pool");
8483 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8484 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8486 cmdline_parse_token_string_t cmd_mirror_link_on =
8487 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8491 cmd_set_mirror_link_parsed(void *parsed_result,
8492 __attribute__((unused)) struct cmdline *cl,
8493 __attribute__((unused)) void *data)
8496 struct cmd_set_mirror_link_result *res = parsed_result;
8497 struct rte_eth_mirror_conf mr_conf;
8499 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8500 if (!strcmp(res->what, "uplink-mirror"))
8501 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8503 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8505 mr_conf.dst_pool = res->dstpool_id;
8507 if (!strcmp(res->on, "on"))
8508 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8511 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8514 /* check the return value and print it if is < 0 */
8516 printf("mirror rule add error: (%s)\n", strerror(-ret));
8520 cmdline_parse_inst_t cmd_set_mirror_link = {
8521 .f = cmd_set_mirror_link_parsed,
8523 .help_str = "set port <port_id> mirror-rule <rule_id> "
8524 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8526 (void *)&cmd_mirror_link_set,
8527 (void *)&cmd_mirror_link_port,
8528 (void *)&cmd_mirror_link_portid,
8529 (void *)&cmd_mirror_link_mirror,
8530 (void *)&cmd_mirror_link_ruleid,
8531 (void *)&cmd_mirror_link_what,
8532 (void *)&cmd_mirror_link_dstpool,
8533 (void *)&cmd_mirror_link_poolid,
8534 (void *)&cmd_mirror_link_on,
8539 /* *** RESET VM MIRROR RULE *** */
8540 struct cmd_rm_mirror_rule_result {
8541 cmdline_fixed_string_t reset;
8542 cmdline_fixed_string_t port;
8544 cmdline_fixed_string_t mirror;
8548 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8549 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8551 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8552 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8554 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8555 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8557 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8558 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8559 mirror, "mirror-rule");
8560 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8561 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8565 cmd_reset_mirror_rule_parsed(void *parsed_result,
8566 __attribute__((unused)) struct cmdline *cl,
8567 __attribute__((unused)) void *data)
8570 struct cmd_set_mirror_link_result *res = parsed_result;
8572 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8574 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8577 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8578 .f = cmd_reset_mirror_rule_parsed,
8580 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8582 (void *)&cmd_rm_mirror_rule_reset,
8583 (void *)&cmd_rm_mirror_rule_port,
8584 (void *)&cmd_rm_mirror_rule_portid,
8585 (void *)&cmd_rm_mirror_rule_mirror,
8586 (void *)&cmd_rm_mirror_rule_ruleid,
8591 /* ******************************************************************************** */
8593 struct cmd_dump_result {
8594 cmdline_fixed_string_t dump;
8598 dump_struct_sizes(void)
8600 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8601 DUMP_SIZE(struct rte_mbuf);
8602 DUMP_SIZE(struct rte_mempool);
8603 DUMP_SIZE(struct rte_ring);
8607 static void cmd_dump_parsed(void *parsed_result,
8608 __attribute__((unused)) struct cmdline *cl,
8609 __attribute__((unused)) void *data)
8611 struct cmd_dump_result *res = parsed_result;
8613 if (!strcmp(res->dump, "dump_physmem"))
8614 rte_dump_physmem_layout(stdout);
8615 else if (!strcmp(res->dump, "dump_memzone"))
8616 rte_memzone_dump(stdout);
8617 else if (!strcmp(res->dump, "dump_struct_sizes"))
8618 dump_struct_sizes();
8619 else if (!strcmp(res->dump, "dump_ring"))
8620 rte_ring_list_dump(stdout);
8621 else if (!strcmp(res->dump, "dump_mempool"))
8622 rte_mempool_list_dump(stdout);
8623 else if (!strcmp(res->dump, "dump_devargs"))
8624 rte_eal_devargs_dump(stdout);
8625 else if (!strcmp(res->dump, "dump_log_types"))
8626 rte_log_dump(stdout);
8629 cmdline_parse_token_string_t cmd_dump_dump =
8630 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8633 "dump_struct_sizes#"
8639 cmdline_parse_inst_t cmd_dump = {
8640 .f = cmd_dump_parsed, /* function to call */
8641 .data = NULL, /* 2nd arg of func */
8642 .help_str = "Dump status",
8643 .tokens = { /* token list, NULL terminated */
8644 (void *)&cmd_dump_dump,
8649 /* ******************************************************************************** */
8651 struct cmd_dump_one_result {
8652 cmdline_fixed_string_t dump;
8653 cmdline_fixed_string_t name;
8656 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8657 __attribute__((unused)) void *data)
8659 struct cmd_dump_one_result *res = parsed_result;
8661 if (!strcmp(res->dump, "dump_ring")) {
8663 r = rte_ring_lookup(res->name);
8665 cmdline_printf(cl, "Cannot find ring\n");
8668 rte_ring_dump(stdout, r);
8669 } else if (!strcmp(res->dump, "dump_mempool")) {
8670 struct rte_mempool *mp;
8671 mp = rte_mempool_lookup(res->name);
8673 cmdline_printf(cl, "Cannot find mempool\n");
8676 rte_mempool_dump(stdout, mp);
8680 cmdline_parse_token_string_t cmd_dump_one_dump =
8681 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8682 "dump_ring#dump_mempool");
8684 cmdline_parse_token_string_t cmd_dump_one_name =
8685 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8687 cmdline_parse_inst_t cmd_dump_one = {
8688 .f = cmd_dump_one_parsed, /* function to call */
8689 .data = NULL, /* 2nd arg of func */
8690 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8691 .tokens = { /* token list, NULL terminated */
8692 (void *)&cmd_dump_one_dump,
8693 (void *)&cmd_dump_one_name,
8698 /* *** Add/Del syn filter *** */
8699 struct cmd_syn_filter_result {
8700 cmdline_fixed_string_t filter;
8702 cmdline_fixed_string_t ops;
8703 cmdline_fixed_string_t priority;
8704 cmdline_fixed_string_t high;
8705 cmdline_fixed_string_t queue;
8710 cmd_syn_filter_parsed(void *parsed_result,
8711 __attribute__((unused)) struct cmdline *cl,
8712 __attribute__((unused)) void *data)
8714 struct cmd_syn_filter_result *res = parsed_result;
8715 struct rte_eth_syn_filter syn_filter;
8718 ret = rte_eth_dev_filter_supported(res->port_id,
8719 RTE_ETH_FILTER_SYN);
8721 printf("syn filter is not supported on port %u.\n",
8726 memset(&syn_filter, 0, sizeof(syn_filter));
8728 if (!strcmp(res->ops, "add")) {
8729 if (!strcmp(res->high, "high"))
8730 syn_filter.hig_pri = 1;
8732 syn_filter.hig_pri = 0;
8734 syn_filter.queue = res->queue_id;
8735 ret = rte_eth_dev_filter_ctrl(res->port_id,
8740 ret = rte_eth_dev_filter_ctrl(res->port_id,
8742 RTE_ETH_FILTER_DELETE,
8746 printf("syn filter programming error: (%s)\n",
8750 cmdline_parse_token_string_t cmd_syn_filter_filter =
8751 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8752 filter, "syn_filter");
8753 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8754 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8756 cmdline_parse_token_string_t cmd_syn_filter_ops =
8757 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8759 cmdline_parse_token_string_t cmd_syn_filter_priority =
8760 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8761 priority, "priority");
8762 cmdline_parse_token_string_t cmd_syn_filter_high =
8763 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8765 cmdline_parse_token_string_t cmd_syn_filter_queue =
8766 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8768 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8769 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8772 cmdline_parse_inst_t cmd_syn_filter = {
8773 .f = cmd_syn_filter_parsed,
8775 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8776 "<queue_id>: Add/Delete syn filter",
8778 (void *)&cmd_syn_filter_filter,
8779 (void *)&cmd_syn_filter_port_id,
8780 (void *)&cmd_syn_filter_ops,
8781 (void *)&cmd_syn_filter_priority,
8782 (void *)&cmd_syn_filter_high,
8783 (void *)&cmd_syn_filter_queue,
8784 (void *)&cmd_syn_filter_queue_id,
8789 /* *** queue region set *** */
8790 struct cmd_queue_region_result {
8791 cmdline_fixed_string_t set;
8792 cmdline_fixed_string_t port;
8794 cmdline_fixed_string_t cmd;
8795 cmdline_fixed_string_t region;
8797 cmdline_fixed_string_t queue_start_index;
8799 cmdline_fixed_string_t queue_num;
8800 uint8_t queue_num_value;
8804 cmd_queue_region_parsed(void *parsed_result,
8805 __attribute__((unused)) struct cmdline *cl,
8806 __attribute__((unused)) void *data)
8808 struct cmd_queue_region_result *res = parsed_result;
8810 #ifdef RTE_LIBRTE_I40E_PMD
8811 struct rte_pmd_i40e_queue_region_conf region_conf;
8812 enum rte_pmd_i40e_queue_region_op op_type;
8815 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8818 #ifdef RTE_LIBRTE_I40E_PMD
8819 memset(®ion_conf, 0, sizeof(region_conf));
8820 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8821 region_conf.region_id = res->region_id;
8822 region_conf.queue_num = res->queue_num_value;
8823 region_conf.queue_start_index = res->queue_id;
8825 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8826 op_type, ®ion_conf);
8833 printf("function not implemented or supported\n");
8836 printf("queue region config error: (%s)\n", strerror(-ret));
8840 cmdline_parse_token_string_t cmd_queue_region_set =
8841 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8843 cmdline_parse_token_string_t cmd_queue_region_port =
8844 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8845 cmdline_parse_token_num_t cmd_queue_region_port_id =
8846 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8848 cmdline_parse_token_string_t cmd_queue_region_cmd =
8849 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8850 cmd, "queue-region");
8851 cmdline_parse_token_string_t cmd_queue_region_id =
8852 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8853 region, "region_id");
8854 cmdline_parse_token_num_t cmd_queue_region_index =
8855 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8857 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8858 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8859 queue_start_index, "queue_start_index");
8860 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8861 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8863 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8864 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8865 queue_num, "queue_num");
8866 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8867 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8868 queue_num_value, UINT8);
8870 cmdline_parse_inst_t cmd_queue_region = {
8871 .f = cmd_queue_region_parsed,
8873 .help_str = "set port <port_id> queue-region region_id <value> "
8874 "queue_start_index <value> queue_num <value>: Set a queue region",
8876 (void *)&cmd_queue_region_set,
8877 (void *)&cmd_queue_region_port,
8878 (void *)&cmd_queue_region_port_id,
8879 (void *)&cmd_queue_region_cmd,
8880 (void *)&cmd_queue_region_id,
8881 (void *)&cmd_queue_region_index,
8882 (void *)&cmd_queue_region_queue_start_index,
8883 (void *)&cmd_queue_region_queue_id,
8884 (void *)&cmd_queue_region_queue_num,
8885 (void *)&cmd_queue_region_queue_num_value,
8890 /* *** queue region and flowtype set *** */
8891 struct cmd_region_flowtype_result {
8892 cmdline_fixed_string_t set;
8893 cmdline_fixed_string_t port;
8895 cmdline_fixed_string_t cmd;
8896 cmdline_fixed_string_t region;
8898 cmdline_fixed_string_t flowtype;
8899 uint8_t flowtype_id;
8903 cmd_region_flowtype_parsed(void *parsed_result,
8904 __attribute__((unused)) struct cmdline *cl,
8905 __attribute__((unused)) void *data)
8907 struct cmd_region_flowtype_result *res = parsed_result;
8909 #ifdef RTE_LIBRTE_I40E_PMD
8910 struct rte_pmd_i40e_queue_region_conf region_conf;
8911 enum rte_pmd_i40e_queue_region_op op_type;
8914 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8917 #ifdef RTE_LIBRTE_I40E_PMD
8918 memset(®ion_conf, 0, sizeof(region_conf));
8920 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8921 region_conf.region_id = res->region_id;
8922 region_conf.hw_flowtype = res->flowtype_id;
8924 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8925 op_type, ®ion_conf);
8932 printf("function not implemented or supported\n");
8935 printf("region flowtype config error: (%s)\n", strerror(-ret));
8939 cmdline_parse_token_string_t cmd_region_flowtype_set =
8940 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8942 cmdline_parse_token_string_t cmd_region_flowtype_port =
8943 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8945 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8946 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8948 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8949 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8950 cmd, "queue-region");
8951 cmdline_parse_token_string_t cmd_region_flowtype_index =
8952 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8953 region, "region_id");
8954 cmdline_parse_token_num_t cmd_region_flowtype_id =
8955 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8957 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8958 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8959 flowtype, "flowtype");
8960 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8961 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8962 flowtype_id, UINT8);
8963 cmdline_parse_inst_t cmd_region_flowtype = {
8964 .f = cmd_region_flowtype_parsed,
8966 .help_str = "set port <port_id> queue-region region_id <value> "
8967 "flowtype <value>: Set a flowtype region index",
8969 (void *)&cmd_region_flowtype_set,
8970 (void *)&cmd_region_flowtype_port,
8971 (void *)&cmd_region_flowtype_port_index,
8972 (void *)&cmd_region_flowtype_cmd,
8973 (void *)&cmd_region_flowtype_index,
8974 (void *)&cmd_region_flowtype_id,
8975 (void *)&cmd_region_flowtype_flow_index,
8976 (void *)&cmd_region_flowtype_flow_id,
8981 /* *** User Priority (UP) to queue region (region_id) set *** */
8982 struct cmd_user_priority_region_result {
8983 cmdline_fixed_string_t set;
8984 cmdline_fixed_string_t port;
8986 cmdline_fixed_string_t cmd;
8987 cmdline_fixed_string_t user_priority;
8988 uint8_t user_priority_id;
8989 cmdline_fixed_string_t region;
8994 cmd_user_priority_region_parsed(void *parsed_result,
8995 __attribute__((unused)) struct cmdline *cl,
8996 __attribute__((unused)) void *data)
8998 struct cmd_user_priority_region_result *res = parsed_result;
9000 #ifdef RTE_LIBRTE_I40E_PMD
9001 struct rte_pmd_i40e_queue_region_conf region_conf;
9002 enum rte_pmd_i40e_queue_region_op op_type;
9005 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9008 #ifdef RTE_LIBRTE_I40E_PMD
9009 memset(®ion_conf, 0, sizeof(region_conf));
9010 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9011 region_conf.user_priority = res->user_priority_id;
9012 region_conf.region_id = res->region_id;
9014 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9015 op_type, ®ion_conf);
9022 printf("function not implemented or supported\n");
9025 printf("user_priority region config error: (%s)\n",
9030 cmdline_parse_token_string_t cmd_user_priority_region_set =
9031 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9033 cmdline_parse_token_string_t cmd_user_priority_region_port =
9034 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9036 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9037 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9039 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9040 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9041 cmd, "queue-region");
9042 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9043 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9044 user_priority, "UP");
9045 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9046 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9047 user_priority_id, UINT8);
9048 cmdline_parse_token_string_t cmd_user_priority_region_region =
9049 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9050 region, "region_id");
9051 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9052 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9055 cmdline_parse_inst_t cmd_user_priority_region = {
9056 .f = cmd_user_priority_region_parsed,
9058 .help_str = "set port <port_id> queue-region UP <value> "
9059 "region_id <value>: Set the mapping of User Priority (UP) "
9060 "to queue region (region_id) ",
9062 (void *)&cmd_user_priority_region_set,
9063 (void *)&cmd_user_priority_region_port,
9064 (void *)&cmd_user_priority_region_port_index,
9065 (void *)&cmd_user_priority_region_cmd,
9066 (void *)&cmd_user_priority_region_UP,
9067 (void *)&cmd_user_priority_region_UP_id,
9068 (void *)&cmd_user_priority_region_region,
9069 (void *)&cmd_user_priority_region_region_id,
9074 /* *** flush all queue region related configuration *** */
9075 struct cmd_flush_queue_region_result {
9076 cmdline_fixed_string_t set;
9077 cmdline_fixed_string_t port;
9079 cmdline_fixed_string_t cmd;
9080 cmdline_fixed_string_t flush;
9081 cmdline_fixed_string_t what;
9085 cmd_flush_queue_region_parsed(void *parsed_result,
9086 __attribute__((unused)) struct cmdline *cl,
9087 __attribute__((unused)) void *data)
9089 struct cmd_flush_queue_region_result *res = parsed_result;
9091 #ifdef RTE_LIBRTE_I40E_PMD
9092 struct rte_pmd_i40e_queue_region_conf region_conf;
9093 enum rte_pmd_i40e_queue_region_op op_type;
9096 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9099 #ifdef RTE_LIBRTE_I40E_PMD
9100 memset(®ion_conf, 0, sizeof(region_conf));
9102 if (strcmp(res->what, "on") == 0)
9103 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9105 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9107 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9108 op_type, ®ion_conf);
9115 printf("function not implemented or supported\n");
9118 printf("queue region config flush error: (%s)\n",
9123 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9124 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9126 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9127 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9129 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9130 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9132 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9133 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9134 cmd, "queue-region");
9135 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9136 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9138 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9139 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9142 cmdline_parse_inst_t cmd_flush_queue_region = {
9143 .f = cmd_flush_queue_region_parsed,
9145 .help_str = "set port <port_id> queue-region flush on|off"
9146 ": flush all queue region related configuration",
9148 (void *)&cmd_flush_queue_region_set,
9149 (void *)&cmd_flush_queue_region_port,
9150 (void *)&cmd_flush_queue_region_port_index,
9151 (void *)&cmd_flush_queue_region_cmd,
9152 (void *)&cmd_flush_queue_region_flush,
9153 (void *)&cmd_flush_queue_region_what,
9158 /* *** get all queue region related configuration info *** */
9159 struct cmd_show_queue_region_info {
9160 cmdline_fixed_string_t show;
9161 cmdline_fixed_string_t port;
9163 cmdline_fixed_string_t cmd;
9167 cmd_show_queue_region_info_parsed(void *parsed_result,
9168 __attribute__((unused)) struct cmdline *cl,
9169 __attribute__((unused)) void *data)
9171 struct cmd_show_queue_region_info *res = parsed_result;
9173 #ifdef RTE_LIBRTE_I40E_PMD
9174 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9175 enum rte_pmd_i40e_queue_region_op op_type;
9178 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9181 #ifdef RTE_LIBRTE_I40E_PMD
9182 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9184 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9186 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9187 op_type, &rte_pmd_regions);
9189 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9196 printf("function not implemented or supported\n");
9199 printf("queue region config info show error: (%s)\n",
9204 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9205 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9207 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9208 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9210 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9211 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9213 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9214 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9215 cmd, "queue-region");
9217 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9218 .f = cmd_show_queue_region_info_parsed,
9220 .help_str = "show port <port_id> queue-region"
9221 ": show all queue region related configuration info",
9223 (void *)&cmd_show_queue_region_info_get,
9224 (void *)&cmd_show_queue_region_info_port,
9225 (void *)&cmd_show_queue_region_info_port_index,
9226 (void *)&cmd_show_queue_region_info_cmd,
9231 /* *** ADD/REMOVE A 2tuple FILTER *** */
9232 struct cmd_2tuple_filter_result {
9233 cmdline_fixed_string_t filter;
9235 cmdline_fixed_string_t ops;
9236 cmdline_fixed_string_t dst_port;
9237 uint16_t dst_port_value;
9238 cmdline_fixed_string_t protocol;
9239 uint8_t protocol_value;
9240 cmdline_fixed_string_t mask;
9242 cmdline_fixed_string_t tcp_flags;
9243 uint8_t tcp_flags_value;
9244 cmdline_fixed_string_t priority;
9245 uint8_t priority_value;
9246 cmdline_fixed_string_t queue;
9251 cmd_2tuple_filter_parsed(void *parsed_result,
9252 __attribute__((unused)) struct cmdline *cl,
9253 __attribute__((unused)) void *data)
9255 struct rte_eth_ntuple_filter filter;
9256 struct cmd_2tuple_filter_result *res = parsed_result;
9259 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9261 printf("ntuple filter is not supported on port %u.\n",
9266 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9268 filter.flags = RTE_2TUPLE_FLAGS;
9269 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9270 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9271 filter.proto = res->protocol_value;
9272 filter.priority = res->priority_value;
9273 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9274 printf("nonzero tcp_flags is only meaningful"
9275 " when protocol is TCP.\n");
9278 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9279 printf("invalid TCP flags.\n");
9283 if (res->tcp_flags_value != 0) {
9284 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9285 filter.tcp_flags = res->tcp_flags_value;
9288 /* need convert to big endian. */
9289 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9290 filter.queue = res->queue_id;
9292 if (!strcmp(res->ops, "add"))
9293 ret = rte_eth_dev_filter_ctrl(res->port_id,
9294 RTE_ETH_FILTER_NTUPLE,
9298 ret = rte_eth_dev_filter_ctrl(res->port_id,
9299 RTE_ETH_FILTER_NTUPLE,
9300 RTE_ETH_FILTER_DELETE,
9303 printf("2tuple filter programming error: (%s)\n",
9308 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9309 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9310 filter, "2tuple_filter");
9311 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9312 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9314 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9315 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9317 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9318 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9319 dst_port, "dst_port");
9320 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9321 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9322 dst_port_value, UINT16);
9323 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9324 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9325 protocol, "protocol");
9326 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9327 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9328 protocol_value, UINT8);
9329 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9330 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9332 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9333 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9335 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9336 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9337 tcp_flags, "tcp_flags");
9338 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9339 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9340 tcp_flags_value, UINT8);
9341 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9342 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9343 priority, "priority");
9344 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9345 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9346 priority_value, UINT8);
9347 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9348 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9350 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9351 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9354 cmdline_parse_inst_t cmd_2tuple_filter = {
9355 .f = cmd_2tuple_filter_parsed,
9357 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9358 "<value> mask <value> tcp_flags <value> priority <value> queue "
9359 "<queue_id>: Add a 2tuple filter",
9361 (void *)&cmd_2tuple_filter_filter,
9362 (void *)&cmd_2tuple_filter_port_id,
9363 (void *)&cmd_2tuple_filter_ops,
9364 (void *)&cmd_2tuple_filter_dst_port,
9365 (void *)&cmd_2tuple_filter_dst_port_value,
9366 (void *)&cmd_2tuple_filter_protocol,
9367 (void *)&cmd_2tuple_filter_protocol_value,
9368 (void *)&cmd_2tuple_filter_mask,
9369 (void *)&cmd_2tuple_filter_mask_value,
9370 (void *)&cmd_2tuple_filter_tcp_flags,
9371 (void *)&cmd_2tuple_filter_tcp_flags_value,
9372 (void *)&cmd_2tuple_filter_priority,
9373 (void *)&cmd_2tuple_filter_priority_value,
9374 (void *)&cmd_2tuple_filter_queue,
9375 (void *)&cmd_2tuple_filter_queue_id,
9380 /* *** ADD/REMOVE A 5tuple FILTER *** */
9381 struct cmd_5tuple_filter_result {
9382 cmdline_fixed_string_t filter;
9384 cmdline_fixed_string_t ops;
9385 cmdline_fixed_string_t dst_ip;
9386 cmdline_ipaddr_t dst_ip_value;
9387 cmdline_fixed_string_t src_ip;
9388 cmdline_ipaddr_t src_ip_value;
9389 cmdline_fixed_string_t dst_port;
9390 uint16_t dst_port_value;
9391 cmdline_fixed_string_t src_port;
9392 uint16_t src_port_value;
9393 cmdline_fixed_string_t protocol;
9394 uint8_t protocol_value;
9395 cmdline_fixed_string_t mask;
9397 cmdline_fixed_string_t tcp_flags;
9398 uint8_t tcp_flags_value;
9399 cmdline_fixed_string_t priority;
9400 uint8_t priority_value;
9401 cmdline_fixed_string_t queue;
9406 cmd_5tuple_filter_parsed(void *parsed_result,
9407 __attribute__((unused)) struct cmdline *cl,
9408 __attribute__((unused)) void *data)
9410 struct rte_eth_ntuple_filter filter;
9411 struct cmd_5tuple_filter_result *res = parsed_result;
9414 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9416 printf("ntuple filter is not supported on port %u.\n",
9421 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9423 filter.flags = RTE_5TUPLE_FLAGS;
9424 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9425 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9426 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9427 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9428 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9429 filter.proto = res->protocol_value;
9430 filter.priority = res->priority_value;
9431 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9432 printf("nonzero tcp_flags is only meaningful"
9433 " when protocol is TCP.\n");
9436 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9437 printf("invalid TCP flags.\n");
9441 if (res->tcp_flags_value != 0) {
9442 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9443 filter.tcp_flags = res->tcp_flags_value;
9446 if (res->dst_ip_value.family == AF_INET)
9447 /* no need to convert, already big endian. */
9448 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9450 if (filter.dst_ip_mask == 0) {
9451 printf("can not support ipv6 involved compare.\n");
9457 if (res->src_ip_value.family == AF_INET)
9458 /* no need to convert, already big endian. */
9459 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9461 if (filter.src_ip_mask == 0) {
9462 printf("can not support ipv6 involved compare.\n");
9467 /* need convert to big endian. */
9468 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9469 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9470 filter.queue = res->queue_id;
9472 if (!strcmp(res->ops, "add"))
9473 ret = rte_eth_dev_filter_ctrl(res->port_id,
9474 RTE_ETH_FILTER_NTUPLE,
9478 ret = rte_eth_dev_filter_ctrl(res->port_id,
9479 RTE_ETH_FILTER_NTUPLE,
9480 RTE_ETH_FILTER_DELETE,
9483 printf("5tuple filter programming error: (%s)\n",
9487 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9488 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9489 filter, "5tuple_filter");
9490 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9491 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9493 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9494 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9496 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9497 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9499 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9500 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9502 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9503 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9505 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9506 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9508 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9509 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9510 dst_port, "dst_port");
9511 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9512 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9513 dst_port_value, UINT16);
9514 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9515 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9516 src_port, "src_port");
9517 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9518 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9519 src_port_value, UINT16);
9520 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9521 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9522 protocol, "protocol");
9523 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9524 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9525 protocol_value, UINT8);
9526 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9527 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9529 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9530 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9532 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9533 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9534 tcp_flags, "tcp_flags");
9535 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9536 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9537 tcp_flags_value, UINT8);
9538 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9539 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9540 priority, "priority");
9541 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9542 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9543 priority_value, UINT8);
9544 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9545 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9547 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9548 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9551 cmdline_parse_inst_t cmd_5tuple_filter = {
9552 .f = cmd_5tuple_filter_parsed,
9554 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9555 "src_ip <value> dst_port <value> src_port <value> "
9556 "protocol <value> mask <value> tcp_flags <value> "
9557 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9559 (void *)&cmd_5tuple_filter_filter,
9560 (void *)&cmd_5tuple_filter_port_id,
9561 (void *)&cmd_5tuple_filter_ops,
9562 (void *)&cmd_5tuple_filter_dst_ip,
9563 (void *)&cmd_5tuple_filter_dst_ip_value,
9564 (void *)&cmd_5tuple_filter_src_ip,
9565 (void *)&cmd_5tuple_filter_src_ip_value,
9566 (void *)&cmd_5tuple_filter_dst_port,
9567 (void *)&cmd_5tuple_filter_dst_port_value,
9568 (void *)&cmd_5tuple_filter_src_port,
9569 (void *)&cmd_5tuple_filter_src_port_value,
9570 (void *)&cmd_5tuple_filter_protocol,
9571 (void *)&cmd_5tuple_filter_protocol_value,
9572 (void *)&cmd_5tuple_filter_mask,
9573 (void *)&cmd_5tuple_filter_mask_value,
9574 (void *)&cmd_5tuple_filter_tcp_flags,
9575 (void *)&cmd_5tuple_filter_tcp_flags_value,
9576 (void *)&cmd_5tuple_filter_priority,
9577 (void *)&cmd_5tuple_filter_priority_value,
9578 (void *)&cmd_5tuple_filter_queue,
9579 (void *)&cmd_5tuple_filter_queue_id,
9584 /* *** ADD/REMOVE A flex FILTER *** */
9585 struct cmd_flex_filter_result {
9586 cmdline_fixed_string_t filter;
9587 cmdline_fixed_string_t ops;
9589 cmdline_fixed_string_t len;
9591 cmdline_fixed_string_t bytes;
9592 cmdline_fixed_string_t bytes_value;
9593 cmdline_fixed_string_t mask;
9594 cmdline_fixed_string_t mask_value;
9595 cmdline_fixed_string_t priority;
9596 uint8_t priority_value;
9597 cmdline_fixed_string_t queue;
9601 static int xdigit2val(unsigned char c)
9606 else if (isupper(c))
9614 cmd_flex_filter_parsed(void *parsed_result,
9615 __attribute__((unused)) struct cmdline *cl,
9616 __attribute__((unused)) void *data)
9619 struct rte_eth_flex_filter filter;
9620 struct cmd_flex_filter_result *res = parsed_result;
9621 char *bytes_ptr, *mask_ptr;
9622 uint16_t len, i, j = 0;
9627 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9628 printf("the len exceed the max length 128\n");
9631 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9632 filter.len = res->len_value;
9633 filter.priority = res->priority_value;
9634 filter.queue = res->queue_id;
9635 bytes_ptr = res->bytes_value;
9636 mask_ptr = res->mask_value;
9638 /* translate bytes string to array. */
9639 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9640 (bytes_ptr[1] == 'X')))
9642 len = strnlen(bytes_ptr, res->len_value * 2);
9643 if (len == 0 || (len % 8 != 0)) {
9644 printf("please check len and bytes input\n");
9647 for (i = 0; i < len; i++) {
9649 if (isxdigit(c) == 0) {
9650 /* invalid characters. */
9651 printf("invalid input\n");
9654 val = xdigit2val(c);
9657 filter.bytes[j] = byte;
9658 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9665 /* translate mask string to uint8_t array. */
9666 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9667 (mask_ptr[1] == 'X')))
9669 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9671 printf("invalid input\n");
9676 for (i = 0; i < len; i++) {
9678 if (isxdigit(c) == 0) {
9679 /* invalid characters. */
9680 printf("invalid input\n");
9683 val = xdigit2val(c);
9686 filter.mask[j] = byte;
9687 printf("mask[%d]:%02x ", j, filter.mask[j]);
9695 if (!strcmp(res->ops, "add"))
9696 ret = rte_eth_dev_filter_ctrl(res->port_id,
9697 RTE_ETH_FILTER_FLEXIBLE,
9701 ret = rte_eth_dev_filter_ctrl(res->port_id,
9702 RTE_ETH_FILTER_FLEXIBLE,
9703 RTE_ETH_FILTER_DELETE,
9707 printf("flex filter setting error: (%s)\n", strerror(-ret));
9710 cmdline_parse_token_string_t cmd_flex_filter_filter =
9711 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9712 filter, "flex_filter");
9713 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9714 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9716 cmdline_parse_token_string_t cmd_flex_filter_ops =
9717 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9719 cmdline_parse_token_string_t cmd_flex_filter_len =
9720 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9722 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9723 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9725 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9726 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9728 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9729 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9731 cmdline_parse_token_string_t cmd_flex_filter_mask =
9732 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9734 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9735 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9737 cmdline_parse_token_string_t cmd_flex_filter_priority =
9738 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9739 priority, "priority");
9740 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9741 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9742 priority_value, UINT8);
9743 cmdline_parse_token_string_t cmd_flex_filter_queue =
9744 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9746 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9747 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9749 cmdline_parse_inst_t cmd_flex_filter = {
9750 .f = cmd_flex_filter_parsed,
9752 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9753 "<value> mask <value> priority <value> queue <queue_id>: "
9754 "Add/Del a flex filter",
9756 (void *)&cmd_flex_filter_filter,
9757 (void *)&cmd_flex_filter_port_id,
9758 (void *)&cmd_flex_filter_ops,
9759 (void *)&cmd_flex_filter_len,
9760 (void *)&cmd_flex_filter_len_value,
9761 (void *)&cmd_flex_filter_bytes,
9762 (void *)&cmd_flex_filter_bytes_value,
9763 (void *)&cmd_flex_filter_mask,
9764 (void *)&cmd_flex_filter_mask_value,
9765 (void *)&cmd_flex_filter_priority,
9766 (void *)&cmd_flex_filter_priority_value,
9767 (void *)&cmd_flex_filter_queue,
9768 (void *)&cmd_flex_filter_queue_id,
9773 /* *** Filters Control *** */
9775 /* *** deal with ethertype filter *** */
9776 struct cmd_ethertype_filter_result {
9777 cmdline_fixed_string_t filter;
9779 cmdline_fixed_string_t ops;
9780 cmdline_fixed_string_t mac;
9781 struct ether_addr mac_addr;
9782 cmdline_fixed_string_t ethertype;
9783 uint16_t ethertype_value;
9784 cmdline_fixed_string_t drop;
9785 cmdline_fixed_string_t queue;
9789 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9790 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9791 filter, "ethertype_filter");
9792 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9793 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9795 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9796 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9798 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9799 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9800 mac, "mac_addr#mac_ignr");
9801 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9802 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9804 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9805 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9806 ethertype, "ethertype");
9807 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9808 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9809 ethertype_value, UINT16);
9810 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9811 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9813 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9814 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9816 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9817 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9821 cmd_ethertype_filter_parsed(void *parsed_result,
9822 __attribute__((unused)) struct cmdline *cl,
9823 __attribute__((unused)) void *data)
9825 struct cmd_ethertype_filter_result *res = parsed_result;
9826 struct rte_eth_ethertype_filter filter;
9829 ret = rte_eth_dev_filter_supported(res->port_id,
9830 RTE_ETH_FILTER_ETHERTYPE);
9832 printf("ethertype filter is not supported on port %u.\n",
9837 memset(&filter, 0, sizeof(filter));
9838 if (!strcmp(res->mac, "mac_addr")) {
9839 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9840 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9841 sizeof(struct ether_addr));
9843 if (!strcmp(res->drop, "drop"))
9844 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9845 filter.ether_type = res->ethertype_value;
9846 filter.queue = res->queue_id;
9848 if (!strcmp(res->ops, "add"))
9849 ret = rte_eth_dev_filter_ctrl(res->port_id,
9850 RTE_ETH_FILTER_ETHERTYPE,
9854 ret = rte_eth_dev_filter_ctrl(res->port_id,
9855 RTE_ETH_FILTER_ETHERTYPE,
9856 RTE_ETH_FILTER_DELETE,
9859 printf("ethertype filter programming error: (%s)\n",
9863 cmdline_parse_inst_t cmd_ethertype_filter = {
9864 .f = cmd_ethertype_filter_parsed,
9866 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9867 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9868 "Add or delete an ethertype filter entry",
9870 (void *)&cmd_ethertype_filter_filter,
9871 (void *)&cmd_ethertype_filter_port_id,
9872 (void *)&cmd_ethertype_filter_ops,
9873 (void *)&cmd_ethertype_filter_mac,
9874 (void *)&cmd_ethertype_filter_mac_addr,
9875 (void *)&cmd_ethertype_filter_ethertype,
9876 (void *)&cmd_ethertype_filter_ethertype_value,
9877 (void *)&cmd_ethertype_filter_drop,
9878 (void *)&cmd_ethertype_filter_queue,
9879 (void *)&cmd_ethertype_filter_queue_id,
9884 /* *** deal with flow director filter *** */
9885 struct cmd_flow_director_result {
9886 cmdline_fixed_string_t flow_director_filter;
9888 cmdline_fixed_string_t mode;
9889 cmdline_fixed_string_t mode_value;
9890 cmdline_fixed_string_t ops;
9891 cmdline_fixed_string_t flow;
9892 cmdline_fixed_string_t flow_type;
9893 cmdline_fixed_string_t ether;
9894 uint16_t ether_type;
9895 cmdline_fixed_string_t src;
9896 cmdline_ipaddr_t ip_src;
9898 cmdline_fixed_string_t dst;
9899 cmdline_ipaddr_t ip_dst;
9901 cmdline_fixed_string_t verify_tag;
9902 uint32_t verify_tag_value;
9903 cmdline_fixed_string_t tos;
9905 cmdline_fixed_string_t proto;
9906 uint8_t proto_value;
9907 cmdline_fixed_string_t ttl;
9909 cmdline_fixed_string_t vlan;
9910 uint16_t vlan_value;
9911 cmdline_fixed_string_t flexbytes;
9912 cmdline_fixed_string_t flexbytes_value;
9913 cmdline_fixed_string_t pf_vf;
9914 cmdline_fixed_string_t drop;
9915 cmdline_fixed_string_t queue;
9917 cmdline_fixed_string_t fd_id;
9918 uint32_t fd_id_value;
9919 cmdline_fixed_string_t mac;
9920 struct ether_addr mac_addr;
9921 cmdline_fixed_string_t tunnel;
9922 cmdline_fixed_string_t tunnel_type;
9923 cmdline_fixed_string_t tunnel_id;
9924 uint32_t tunnel_id_value;
9925 cmdline_fixed_string_t packet;
9930 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9933 const char *p, *p0 = q_arg;
9935 unsigned long int_fld;
9936 char *str_fld[max_num];
9941 p = strchr(p0, '(');
9945 p0 = strchr(p, ')');
9950 if (size >= sizeof(s))
9953 snprintf(s, sizeof(s), "%.*s", size, p);
9954 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9955 if (ret < 0 || ret > max_num)
9957 for (i = 0; i < ret; i++) {
9959 int_fld = strtoul(str_fld[i], &end, 0);
9960 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9962 flexbytes[i] = (uint8_t)int_fld;
9968 str2flowtype(char *string)
9971 static const struct {
9974 } flowtype_str[] = {
9975 {"raw", RTE_ETH_FLOW_RAW},
9976 {"ipv4", RTE_ETH_FLOW_IPV4},
9977 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9978 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9979 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9980 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9981 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9982 {"ipv6", RTE_ETH_FLOW_IPV6},
9983 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9984 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9985 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9986 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9987 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9988 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9991 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9992 if (!strcmp(flowtype_str[i].str, string))
9993 return flowtype_str[i].type;
9996 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9997 return (uint16_t)atoi(string);
9999 return RTE_ETH_FLOW_UNKNOWN;
10002 static enum rte_eth_fdir_tunnel_type
10003 str2fdir_tunneltype(char *string)
10007 static const struct {
10009 enum rte_eth_fdir_tunnel_type type;
10010 } tunneltype_str[] = {
10011 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10012 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10015 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10016 if (!strcmp(tunneltype_str[i].str, string))
10017 return tunneltype_str[i].type;
10019 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10022 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10024 if ((ip_addr).family == AF_INET) \
10025 (ip) = (ip_addr).addr.ipv4.s_addr; \
10027 printf("invalid parameter.\n"); \
10032 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10034 if ((ip_addr).family == AF_INET6) \
10035 rte_memcpy(&(ip), \
10036 &((ip_addr).addr.ipv6), \
10037 sizeof(struct in6_addr)); \
10039 printf("invalid parameter.\n"); \
10045 cmd_flow_director_filter_parsed(void *parsed_result,
10046 __attribute__((unused)) struct cmdline *cl,
10047 __attribute__((unused)) void *data)
10049 struct cmd_flow_director_result *res = parsed_result;
10050 struct rte_eth_fdir_filter entry;
10051 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10053 unsigned long vf_id;
10056 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10058 printf("flow director is not supported on port %u.\n",
10062 memset(flexbytes, 0, sizeof(flexbytes));
10063 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10065 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10066 if (strcmp(res->mode_value, "MAC-VLAN")) {
10067 printf("Please set mode to MAC-VLAN.\n");
10070 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10071 if (strcmp(res->mode_value, "Tunnel")) {
10072 printf("Please set mode to Tunnel.\n");
10076 if (!strcmp(res->mode_value, "raw")) {
10077 #ifdef RTE_LIBRTE_I40E_PMD
10078 struct rte_pmd_i40e_flow_type_mapping
10079 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10080 struct rte_pmd_i40e_pkt_template_conf conf;
10081 uint16_t flow_type = str2flowtype(res->flow_type);
10082 uint16_t i, port = res->port_id;
10085 memset(&conf, 0, sizeof(conf));
10087 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10088 printf("Invalid flow type specified.\n");
10091 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10095 if (mapping[flow_type].pctype == 0ULL) {
10096 printf("Invalid flow type specified.\n");
10099 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10100 if (mapping[flow_type].pctype & (1ULL << i)) {
10101 conf.input.pctype = i;
10106 conf.input.packet = open_file(res->filepath,
10107 &conf.input.length);
10108 if (!conf.input.packet)
10110 if (!strcmp(res->drop, "drop"))
10111 conf.action.behavior =
10112 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10114 conf.action.behavior =
10115 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10116 conf.action.report_status =
10117 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10118 conf.action.rx_queue = res->queue_id;
10119 conf.soft_id = res->fd_id_value;
10120 add = strcmp(res->ops, "del") ? 1 : 0;
10121 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10125 printf("flow director config error: (%s)\n",
10127 close_file(conf.input.packet);
10130 } else if (strcmp(res->mode_value, "IP")) {
10131 printf("Please set mode to IP or raw.\n");
10134 entry.input.flow_type = str2flowtype(res->flow_type);
10137 ret = parse_flexbytes(res->flexbytes_value,
10139 RTE_ETH_FDIR_MAX_FLEXLEN);
10141 printf("error: Cannot parse flexbytes input.\n");
10145 switch (entry.input.flow_type) {
10146 case RTE_ETH_FLOW_FRAG_IPV4:
10147 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10148 entry.input.flow.ip4_flow.proto = res->proto_value;
10150 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10151 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10152 IPV4_ADDR_TO_UINT(res->ip_dst,
10153 entry.input.flow.ip4_flow.dst_ip);
10154 IPV4_ADDR_TO_UINT(res->ip_src,
10155 entry.input.flow.ip4_flow.src_ip);
10156 entry.input.flow.ip4_flow.tos = res->tos_value;
10157 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10158 /* need convert to big endian. */
10159 entry.input.flow.udp4_flow.dst_port =
10160 rte_cpu_to_be_16(res->port_dst);
10161 entry.input.flow.udp4_flow.src_port =
10162 rte_cpu_to_be_16(res->port_src);
10164 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10165 IPV4_ADDR_TO_UINT(res->ip_dst,
10166 entry.input.flow.sctp4_flow.ip.dst_ip);
10167 IPV4_ADDR_TO_UINT(res->ip_src,
10168 entry.input.flow.sctp4_flow.ip.src_ip);
10169 entry.input.flow.ip4_flow.tos = res->tos_value;
10170 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10171 /* need convert to big endian. */
10172 entry.input.flow.sctp4_flow.dst_port =
10173 rte_cpu_to_be_16(res->port_dst);
10174 entry.input.flow.sctp4_flow.src_port =
10175 rte_cpu_to_be_16(res->port_src);
10176 entry.input.flow.sctp4_flow.verify_tag =
10177 rte_cpu_to_be_32(res->verify_tag_value);
10179 case RTE_ETH_FLOW_FRAG_IPV6:
10180 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10181 entry.input.flow.ipv6_flow.proto = res->proto_value;
10183 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10184 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10185 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10186 entry.input.flow.ipv6_flow.dst_ip);
10187 IPV6_ADDR_TO_ARRAY(res->ip_src,
10188 entry.input.flow.ipv6_flow.src_ip);
10189 entry.input.flow.ipv6_flow.tc = res->tos_value;
10190 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10191 /* need convert to big endian. */
10192 entry.input.flow.udp6_flow.dst_port =
10193 rte_cpu_to_be_16(res->port_dst);
10194 entry.input.flow.udp6_flow.src_port =
10195 rte_cpu_to_be_16(res->port_src);
10197 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10198 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10199 entry.input.flow.sctp6_flow.ip.dst_ip);
10200 IPV6_ADDR_TO_ARRAY(res->ip_src,
10201 entry.input.flow.sctp6_flow.ip.src_ip);
10202 entry.input.flow.ipv6_flow.tc = res->tos_value;
10203 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10204 /* need convert to big endian. */
10205 entry.input.flow.sctp6_flow.dst_port =
10206 rte_cpu_to_be_16(res->port_dst);
10207 entry.input.flow.sctp6_flow.src_port =
10208 rte_cpu_to_be_16(res->port_src);
10209 entry.input.flow.sctp6_flow.verify_tag =
10210 rte_cpu_to_be_32(res->verify_tag_value);
10212 case RTE_ETH_FLOW_L2_PAYLOAD:
10213 entry.input.flow.l2_flow.ether_type =
10214 rte_cpu_to_be_16(res->ether_type);
10220 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10221 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10223 sizeof(struct ether_addr));
10225 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10226 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10228 sizeof(struct ether_addr));
10229 entry.input.flow.tunnel_flow.tunnel_type =
10230 str2fdir_tunneltype(res->tunnel_type);
10231 entry.input.flow.tunnel_flow.tunnel_id =
10232 rte_cpu_to_be_32(res->tunnel_id_value);
10235 rte_memcpy(entry.input.flow_ext.flexbytes,
10237 RTE_ETH_FDIR_MAX_FLEXLEN);
10239 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10241 entry.action.flex_off = 0; /*use 0 by default */
10242 if (!strcmp(res->drop, "drop"))
10243 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10245 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10247 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10248 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10249 if (!strcmp(res->pf_vf, "pf"))
10250 entry.input.flow_ext.is_vf = 0;
10251 else if (!strncmp(res->pf_vf, "vf", 2)) {
10252 struct rte_eth_dev_info dev_info;
10254 memset(&dev_info, 0, sizeof(dev_info));
10255 rte_eth_dev_info_get(res->port_id, &dev_info);
10257 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10258 if (errno != 0 || *end != '\0' ||
10259 vf_id >= dev_info.max_vfs) {
10260 printf("invalid parameter %s.\n", res->pf_vf);
10263 entry.input.flow_ext.is_vf = 1;
10264 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10266 printf("invalid parameter %s.\n", res->pf_vf);
10271 /* set to report FD ID by default */
10272 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10273 entry.action.rx_queue = res->queue_id;
10274 entry.soft_id = res->fd_id_value;
10275 if (!strcmp(res->ops, "add"))
10276 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10277 RTE_ETH_FILTER_ADD, &entry);
10278 else if (!strcmp(res->ops, "del"))
10279 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10280 RTE_ETH_FILTER_DELETE, &entry);
10282 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10283 RTE_ETH_FILTER_UPDATE, &entry);
10285 printf("flow director programming error: (%s)\n",
10289 cmdline_parse_token_string_t cmd_flow_director_filter =
10290 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10291 flow_director_filter, "flow_director_filter");
10292 cmdline_parse_token_num_t cmd_flow_director_port_id =
10293 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10295 cmdline_parse_token_string_t cmd_flow_director_ops =
10296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10297 ops, "add#del#update");
10298 cmdline_parse_token_string_t cmd_flow_director_flow =
10299 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10301 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10304 cmdline_parse_token_string_t cmd_flow_director_ether =
10305 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10307 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10308 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10309 ether_type, UINT16);
10310 cmdline_parse_token_string_t cmd_flow_director_src =
10311 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10313 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10314 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10316 cmdline_parse_token_num_t cmd_flow_director_port_src =
10317 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10319 cmdline_parse_token_string_t cmd_flow_director_dst =
10320 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10322 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10323 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10325 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10326 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10328 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10330 verify_tag, "verify_tag");
10331 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10332 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10333 verify_tag_value, UINT32);
10334 cmdline_parse_token_string_t cmd_flow_director_tos =
10335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10337 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10338 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10340 cmdline_parse_token_string_t cmd_flow_director_proto =
10341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10343 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10344 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10345 proto_value, UINT8);
10346 cmdline_parse_token_string_t cmd_flow_director_ttl =
10347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10349 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10350 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10352 cmdline_parse_token_string_t cmd_flow_director_vlan =
10353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10355 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10356 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10357 vlan_value, UINT16);
10358 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10360 flexbytes, "flexbytes");
10361 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10363 flexbytes_value, NULL);
10364 cmdline_parse_token_string_t cmd_flow_director_drop =
10365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10367 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10370 cmdline_parse_token_string_t cmd_flow_director_queue =
10371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10373 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10374 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10376 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10377 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10379 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10380 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10381 fd_id_value, UINT32);
10383 cmdline_parse_token_string_t cmd_flow_director_mode =
10384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10386 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10387 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10389 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10390 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10391 mode_value, "MAC-VLAN");
10392 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10393 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10394 mode_value, "Tunnel");
10395 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10396 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10397 mode_value, "raw");
10398 cmdline_parse_token_string_t cmd_flow_director_mac =
10399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10401 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10402 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10404 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10407 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10408 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10409 tunnel_type, "NVGRE#VxLAN");
10410 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10411 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10412 tunnel_id, "tunnel-id");
10413 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10414 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10415 tunnel_id_value, UINT32);
10416 cmdline_parse_token_string_t cmd_flow_director_packet =
10417 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10419 cmdline_parse_token_string_t cmd_flow_director_filepath =
10420 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10423 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10424 .f = cmd_flow_director_filter_parsed,
10426 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10427 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10428 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10429 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10430 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10431 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10432 "fd_id <fd_id_value>: "
10433 "Add or delete an ip flow director entry on NIC",
10435 (void *)&cmd_flow_director_filter,
10436 (void *)&cmd_flow_director_port_id,
10437 (void *)&cmd_flow_director_mode,
10438 (void *)&cmd_flow_director_mode_ip,
10439 (void *)&cmd_flow_director_ops,
10440 (void *)&cmd_flow_director_flow,
10441 (void *)&cmd_flow_director_flow_type,
10442 (void *)&cmd_flow_director_src,
10443 (void *)&cmd_flow_director_ip_src,
10444 (void *)&cmd_flow_director_dst,
10445 (void *)&cmd_flow_director_ip_dst,
10446 (void *)&cmd_flow_director_tos,
10447 (void *)&cmd_flow_director_tos_value,
10448 (void *)&cmd_flow_director_proto,
10449 (void *)&cmd_flow_director_proto_value,
10450 (void *)&cmd_flow_director_ttl,
10451 (void *)&cmd_flow_director_ttl_value,
10452 (void *)&cmd_flow_director_vlan,
10453 (void *)&cmd_flow_director_vlan_value,
10454 (void *)&cmd_flow_director_flexbytes,
10455 (void *)&cmd_flow_director_flexbytes_value,
10456 (void *)&cmd_flow_director_drop,
10457 (void *)&cmd_flow_director_pf_vf,
10458 (void *)&cmd_flow_director_queue,
10459 (void *)&cmd_flow_director_queue_id,
10460 (void *)&cmd_flow_director_fd_id,
10461 (void *)&cmd_flow_director_fd_id_value,
10466 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10467 .f = cmd_flow_director_filter_parsed,
10469 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10470 "director entry on NIC",
10472 (void *)&cmd_flow_director_filter,
10473 (void *)&cmd_flow_director_port_id,
10474 (void *)&cmd_flow_director_mode,
10475 (void *)&cmd_flow_director_mode_ip,
10476 (void *)&cmd_flow_director_ops,
10477 (void *)&cmd_flow_director_flow,
10478 (void *)&cmd_flow_director_flow_type,
10479 (void *)&cmd_flow_director_src,
10480 (void *)&cmd_flow_director_ip_src,
10481 (void *)&cmd_flow_director_port_src,
10482 (void *)&cmd_flow_director_dst,
10483 (void *)&cmd_flow_director_ip_dst,
10484 (void *)&cmd_flow_director_port_dst,
10485 (void *)&cmd_flow_director_tos,
10486 (void *)&cmd_flow_director_tos_value,
10487 (void *)&cmd_flow_director_ttl,
10488 (void *)&cmd_flow_director_ttl_value,
10489 (void *)&cmd_flow_director_vlan,
10490 (void *)&cmd_flow_director_vlan_value,
10491 (void *)&cmd_flow_director_flexbytes,
10492 (void *)&cmd_flow_director_flexbytes_value,
10493 (void *)&cmd_flow_director_drop,
10494 (void *)&cmd_flow_director_pf_vf,
10495 (void *)&cmd_flow_director_queue,
10496 (void *)&cmd_flow_director_queue_id,
10497 (void *)&cmd_flow_director_fd_id,
10498 (void *)&cmd_flow_director_fd_id_value,
10503 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10504 .f = cmd_flow_director_filter_parsed,
10506 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10507 "director entry on NIC",
10509 (void *)&cmd_flow_director_filter,
10510 (void *)&cmd_flow_director_port_id,
10511 (void *)&cmd_flow_director_mode,
10512 (void *)&cmd_flow_director_mode_ip,
10513 (void *)&cmd_flow_director_ops,
10514 (void *)&cmd_flow_director_flow,
10515 (void *)&cmd_flow_director_flow_type,
10516 (void *)&cmd_flow_director_src,
10517 (void *)&cmd_flow_director_ip_src,
10518 (void *)&cmd_flow_director_port_src,
10519 (void *)&cmd_flow_director_dst,
10520 (void *)&cmd_flow_director_ip_dst,
10521 (void *)&cmd_flow_director_port_dst,
10522 (void *)&cmd_flow_director_verify_tag,
10523 (void *)&cmd_flow_director_verify_tag_value,
10524 (void *)&cmd_flow_director_tos,
10525 (void *)&cmd_flow_director_tos_value,
10526 (void *)&cmd_flow_director_ttl,
10527 (void *)&cmd_flow_director_ttl_value,
10528 (void *)&cmd_flow_director_vlan,
10529 (void *)&cmd_flow_director_vlan_value,
10530 (void *)&cmd_flow_director_flexbytes,
10531 (void *)&cmd_flow_director_flexbytes_value,
10532 (void *)&cmd_flow_director_drop,
10533 (void *)&cmd_flow_director_pf_vf,
10534 (void *)&cmd_flow_director_queue,
10535 (void *)&cmd_flow_director_queue_id,
10536 (void *)&cmd_flow_director_fd_id,
10537 (void *)&cmd_flow_director_fd_id_value,
10542 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10543 .f = cmd_flow_director_filter_parsed,
10545 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10546 "director entry on NIC",
10548 (void *)&cmd_flow_director_filter,
10549 (void *)&cmd_flow_director_port_id,
10550 (void *)&cmd_flow_director_mode,
10551 (void *)&cmd_flow_director_mode_ip,
10552 (void *)&cmd_flow_director_ops,
10553 (void *)&cmd_flow_director_flow,
10554 (void *)&cmd_flow_director_flow_type,
10555 (void *)&cmd_flow_director_ether,
10556 (void *)&cmd_flow_director_ether_type,
10557 (void *)&cmd_flow_director_flexbytes,
10558 (void *)&cmd_flow_director_flexbytes_value,
10559 (void *)&cmd_flow_director_drop,
10560 (void *)&cmd_flow_director_pf_vf,
10561 (void *)&cmd_flow_director_queue,
10562 (void *)&cmd_flow_director_queue_id,
10563 (void *)&cmd_flow_director_fd_id,
10564 (void *)&cmd_flow_director_fd_id_value,
10569 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10570 .f = cmd_flow_director_filter_parsed,
10572 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10573 "director entry on NIC",
10575 (void *)&cmd_flow_director_filter,
10576 (void *)&cmd_flow_director_port_id,
10577 (void *)&cmd_flow_director_mode,
10578 (void *)&cmd_flow_director_mode_mac_vlan,
10579 (void *)&cmd_flow_director_ops,
10580 (void *)&cmd_flow_director_mac,
10581 (void *)&cmd_flow_director_mac_addr,
10582 (void *)&cmd_flow_director_vlan,
10583 (void *)&cmd_flow_director_vlan_value,
10584 (void *)&cmd_flow_director_flexbytes,
10585 (void *)&cmd_flow_director_flexbytes_value,
10586 (void *)&cmd_flow_director_drop,
10587 (void *)&cmd_flow_director_queue,
10588 (void *)&cmd_flow_director_queue_id,
10589 (void *)&cmd_flow_director_fd_id,
10590 (void *)&cmd_flow_director_fd_id_value,
10595 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10596 .f = cmd_flow_director_filter_parsed,
10598 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10599 "director entry on NIC",
10601 (void *)&cmd_flow_director_filter,
10602 (void *)&cmd_flow_director_port_id,
10603 (void *)&cmd_flow_director_mode,
10604 (void *)&cmd_flow_director_mode_tunnel,
10605 (void *)&cmd_flow_director_ops,
10606 (void *)&cmd_flow_director_mac,
10607 (void *)&cmd_flow_director_mac_addr,
10608 (void *)&cmd_flow_director_vlan,
10609 (void *)&cmd_flow_director_vlan_value,
10610 (void *)&cmd_flow_director_tunnel,
10611 (void *)&cmd_flow_director_tunnel_type,
10612 (void *)&cmd_flow_director_tunnel_id,
10613 (void *)&cmd_flow_director_tunnel_id_value,
10614 (void *)&cmd_flow_director_flexbytes,
10615 (void *)&cmd_flow_director_flexbytes_value,
10616 (void *)&cmd_flow_director_drop,
10617 (void *)&cmd_flow_director_queue,
10618 (void *)&cmd_flow_director_queue_id,
10619 (void *)&cmd_flow_director_fd_id,
10620 (void *)&cmd_flow_director_fd_id_value,
10625 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10626 .f = cmd_flow_director_filter_parsed,
10628 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10629 "director entry on NIC",
10631 (void *)&cmd_flow_director_filter,
10632 (void *)&cmd_flow_director_port_id,
10633 (void *)&cmd_flow_director_mode,
10634 (void *)&cmd_flow_director_mode_raw,
10635 (void *)&cmd_flow_director_ops,
10636 (void *)&cmd_flow_director_flow,
10637 (void *)&cmd_flow_director_flow_type,
10638 (void *)&cmd_flow_director_drop,
10639 (void *)&cmd_flow_director_queue,
10640 (void *)&cmd_flow_director_queue_id,
10641 (void *)&cmd_flow_director_fd_id,
10642 (void *)&cmd_flow_director_fd_id_value,
10643 (void *)&cmd_flow_director_packet,
10644 (void *)&cmd_flow_director_filepath,
10649 struct cmd_flush_flow_director_result {
10650 cmdline_fixed_string_t flush_flow_director;
10654 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10655 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10656 flush_flow_director, "flush_flow_director");
10657 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10658 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10662 cmd_flush_flow_director_parsed(void *parsed_result,
10663 __attribute__((unused)) struct cmdline *cl,
10664 __attribute__((unused)) void *data)
10666 struct cmd_flow_director_result *res = parsed_result;
10669 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10671 printf("flow director is not supported on port %u.\n",
10676 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10677 RTE_ETH_FILTER_FLUSH, NULL);
10679 printf("flow director table flushing error: (%s)\n",
10683 cmdline_parse_inst_t cmd_flush_flow_director = {
10684 .f = cmd_flush_flow_director_parsed,
10686 .help_str = "flush_flow_director <port_id>: "
10687 "Flush all flow director entries of a device on NIC",
10689 (void *)&cmd_flush_flow_director_flush,
10690 (void *)&cmd_flush_flow_director_port_id,
10695 /* *** deal with flow director mask *** */
10696 struct cmd_flow_director_mask_result {
10697 cmdline_fixed_string_t flow_director_mask;
10699 cmdline_fixed_string_t mode;
10700 cmdline_fixed_string_t mode_value;
10701 cmdline_fixed_string_t vlan;
10702 uint16_t vlan_mask;
10703 cmdline_fixed_string_t src_mask;
10704 cmdline_ipaddr_t ipv4_src;
10705 cmdline_ipaddr_t ipv6_src;
10707 cmdline_fixed_string_t dst_mask;
10708 cmdline_ipaddr_t ipv4_dst;
10709 cmdline_ipaddr_t ipv6_dst;
10711 cmdline_fixed_string_t mac;
10712 uint8_t mac_addr_byte_mask;
10713 cmdline_fixed_string_t tunnel_id;
10714 uint32_t tunnel_id_mask;
10715 cmdline_fixed_string_t tunnel_type;
10716 uint8_t tunnel_type_mask;
10720 cmd_flow_director_mask_parsed(void *parsed_result,
10721 __attribute__((unused)) struct cmdline *cl,
10722 __attribute__((unused)) void *data)
10724 struct cmd_flow_director_mask_result *res = parsed_result;
10725 struct rte_eth_fdir_masks *mask;
10726 struct rte_port *port;
10728 if (res->port_id > nb_ports) {
10729 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10733 port = &ports[res->port_id];
10734 /** Check if the port is not started **/
10735 if (port->port_status != RTE_PORT_STOPPED) {
10736 printf("Please stop port %d first\n", res->port_id);
10740 mask = &port->dev_conf.fdir_conf.mask;
10742 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10743 if (strcmp(res->mode_value, "MAC-VLAN")) {
10744 printf("Please set mode to MAC-VLAN.\n");
10748 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10749 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10750 if (strcmp(res->mode_value, "Tunnel")) {
10751 printf("Please set mode to Tunnel.\n");
10755 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10756 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10757 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10758 mask->tunnel_type_mask = res->tunnel_type_mask;
10760 if (strcmp(res->mode_value, "IP")) {
10761 printf("Please set mode to IP.\n");
10765 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10766 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10767 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10768 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10769 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10770 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10771 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10774 cmd_reconfig_device_queue(res->port_id, 1, 1);
10777 cmdline_parse_token_string_t cmd_flow_director_mask =
10778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10779 flow_director_mask, "flow_director_mask");
10780 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10781 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10783 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10786 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10787 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10788 vlan_mask, UINT16);
10789 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10791 src_mask, "src_mask");
10792 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10793 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10795 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10796 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10798 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10799 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10801 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10802 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10803 dst_mask, "dst_mask");
10804 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10805 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10807 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10808 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10810 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10811 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10814 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10815 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10817 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10818 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10820 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10821 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10822 mode_value, "MAC-VLAN");
10823 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10824 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10825 mode_value, "Tunnel");
10826 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10827 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10829 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10830 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10831 mac_addr_byte_mask, UINT8);
10832 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10833 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10834 tunnel_type, "tunnel-type");
10835 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10836 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10837 tunnel_type_mask, UINT8);
10838 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10839 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10840 tunnel_id, "tunnel-id");
10841 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10842 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10843 tunnel_id_mask, UINT32);
10845 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10846 .f = cmd_flow_director_mask_parsed,
10848 .help_str = "flow_director_mask ... : "
10849 "Set IP mode flow director's mask on NIC",
10851 (void *)&cmd_flow_director_mask,
10852 (void *)&cmd_flow_director_mask_port_id,
10853 (void *)&cmd_flow_director_mask_mode,
10854 (void *)&cmd_flow_director_mask_mode_ip,
10855 (void *)&cmd_flow_director_mask_vlan,
10856 (void *)&cmd_flow_director_mask_vlan_value,
10857 (void *)&cmd_flow_director_mask_src,
10858 (void *)&cmd_flow_director_mask_ipv4_src,
10859 (void *)&cmd_flow_director_mask_ipv6_src,
10860 (void *)&cmd_flow_director_mask_port_src,
10861 (void *)&cmd_flow_director_mask_dst,
10862 (void *)&cmd_flow_director_mask_ipv4_dst,
10863 (void *)&cmd_flow_director_mask_ipv6_dst,
10864 (void *)&cmd_flow_director_mask_port_dst,
10869 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10870 .f = cmd_flow_director_mask_parsed,
10872 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10873 "flow director's mask on NIC",
10875 (void *)&cmd_flow_director_mask,
10876 (void *)&cmd_flow_director_mask_port_id,
10877 (void *)&cmd_flow_director_mask_mode,
10878 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10879 (void *)&cmd_flow_director_mask_vlan,
10880 (void *)&cmd_flow_director_mask_vlan_value,
10885 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10886 .f = cmd_flow_director_mask_parsed,
10888 .help_str = "flow_director_mask ... : Set tunnel mode "
10889 "flow director's mask on NIC",
10891 (void *)&cmd_flow_director_mask,
10892 (void *)&cmd_flow_director_mask_port_id,
10893 (void *)&cmd_flow_director_mask_mode,
10894 (void *)&cmd_flow_director_mask_mode_tunnel,
10895 (void *)&cmd_flow_director_mask_vlan,
10896 (void *)&cmd_flow_director_mask_vlan_value,
10897 (void *)&cmd_flow_director_mask_mac,
10898 (void *)&cmd_flow_director_mask_mac_value,
10899 (void *)&cmd_flow_director_mask_tunnel_type,
10900 (void *)&cmd_flow_director_mask_tunnel_type_value,
10901 (void *)&cmd_flow_director_mask_tunnel_id,
10902 (void *)&cmd_flow_director_mask_tunnel_id_value,
10907 /* *** deal with flow director mask on flexible payload *** */
10908 struct cmd_flow_director_flex_mask_result {
10909 cmdline_fixed_string_t flow_director_flexmask;
10911 cmdline_fixed_string_t flow;
10912 cmdline_fixed_string_t flow_type;
10913 cmdline_fixed_string_t mask;
10917 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10918 __attribute__((unused)) struct cmdline *cl,
10919 __attribute__((unused)) void *data)
10921 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10922 struct rte_eth_fdir_info fdir_info;
10923 struct rte_eth_fdir_flex_mask flex_mask;
10924 struct rte_port *port;
10925 uint64_t flow_type_mask;
10929 if (res->port_id > nb_ports) {
10930 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10934 port = &ports[res->port_id];
10935 /** Check if the port is not started **/
10936 if (port->port_status != RTE_PORT_STOPPED) {
10937 printf("Please stop port %d first\n", res->port_id);
10941 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10942 ret = parse_flexbytes(res->mask,
10944 RTE_ETH_FDIR_MAX_FLEXLEN);
10946 printf("error: Cannot parse mask input.\n");
10950 memset(&fdir_info, 0, sizeof(fdir_info));
10951 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10952 RTE_ETH_FILTER_INFO, &fdir_info);
10954 printf("Cannot get FDir filter info\n");
10958 if (!strcmp(res->flow_type, "none")) {
10959 /* means don't specify the flow type */
10960 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10961 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10962 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10963 0, sizeof(struct rte_eth_fdir_flex_mask));
10964 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10965 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10967 sizeof(struct rte_eth_fdir_flex_mask));
10968 cmd_reconfig_device_queue(res->port_id, 1, 1);
10971 flow_type_mask = fdir_info.flow_types_mask[0];
10972 if (!strcmp(res->flow_type, "all")) {
10973 if (!flow_type_mask) {
10974 printf("No flow type supported\n");
10977 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10978 if (flow_type_mask & (1ULL << i)) {
10979 flex_mask.flow_type = i;
10980 fdir_set_flex_mask(res->port_id, &flex_mask);
10983 cmd_reconfig_device_queue(res->port_id, 1, 1);
10986 flex_mask.flow_type = str2flowtype(res->flow_type);
10987 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
10988 printf("Flow type %s not supported on port %d\n",
10989 res->flow_type, res->port_id);
10992 fdir_set_flex_mask(res->port_id, &flex_mask);
10993 cmd_reconfig_device_queue(res->port_id, 1, 1);
10996 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10997 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10998 flow_director_flexmask,
10999 "flow_director_flex_mask");
11000 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11001 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11003 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11004 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11006 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11008 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11009 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11010 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11011 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11014 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11015 .f = cmd_flow_director_flex_mask_parsed,
11017 .help_str = "flow_director_flex_mask ... : "
11018 "Set flow director's flex mask on NIC",
11020 (void *)&cmd_flow_director_flexmask,
11021 (void *)&cmd_flow_director_flexmask_port_id,
11022 (void *)&cmd_flow_director_flexmask_flow,
11023 (void *)&cmd_flow_director_flexmask_flow_type,
11024 (void *)&cmd_flow_director_flexmask_mask,
11029 /* *** deal with flow director flexible payload configuration *** */
11030 struct cmd_flow_director_flexpayload_result {
11031 cmdline_fixed_string_t flow_director_flexpayload;
11033 cmdline_fixed_string_t payload_layer;
11034 cmdline_fixed_string_t payload_cfg;
11038 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11041 const char *p, *p0 = q_arg;
11043 unsigned long int_fld;
11044 char *str_fld[max_num];
11049 p = strchr(p0, '(');
11053 p0 = strchr(p, ')');
11058 if (size >= sizeof(s))
11061 snprintf(s, sizeof(s), "%.*s", size, p);
11062 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11063 if (ret < 0 || ret > max_num)
11065 for (i = 0; i < ret; i++) {
11067 int_fld = strtoul(str_fld[i], &end, 0);
11068 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11070 offsets[i] = (uint16_t)int_fld;
11076 cmd_flow_director_flxpld_parsed(void *parsed_result,
11077 __attribute__((unused)) struct cmdline *cl,
11078 __attribute__((unused)) void *data)
11080 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11081 struct rte_eth_flex_payload_cfg flex_cfg;
11082 struct rte_port *port;
11085 if (res->port_id > nb_ports) {
11086 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11090 port = &ports[res->port_id];
11091 /** Check if the port is not started **/
11092 if (port->port_status != RTE_PORT_STOPPED) {
11093 printf("Please stop port %d first\n", res->port_id);
11097 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11099 if (!strcmp(res->payload_layer, "raw"))
11100 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11101 else if (!strcmp(res->payload_layer, "l2"))
11102 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11103 else if (!strcmp(res->payload_layer, "l3"))
11104 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11105 else if (!strcmp(res->payload_layer, "l4"))
11106 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11108 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11109 RTE_ETH_FDIR_MAX_FLEXLEN);
11111 printf("error: Cannot parse flex payload input.\n");
11115 fdir_set_flex_payload(res->port_id, &flex_cfg);
11116 cmd_reconfig_device_queue(res->port_id, 1, 1);
11119 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11120 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11121 flow_director_flexpayload,
11122 "flow_director_flex_payload");
11123 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11124 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11126 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11127 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11128 payload_layer, "raw#l2#l3#l4");
11129 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11131 payload_cfg, NULL);
11133 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11134 .f = cmd_flow_director_flxpld_parsed,
11136 .help_str = "flow_director_flexpayload ... : "
11137 "Set flow director's flex payload on NIC",
11139 (void *)&cmd_flow_director_flexpayload,
11140 (void *)&cmd_flow_director_flexpayload_port_id,
11141 (void *)&cmd_flow_director_flexpayload_payload_layer,
11142 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11147 /* Generic flow interface command. */
11148 extern cmdline_parse_inst_t cmd_flow;
11150 /* *** Classification Filters Control *** */
11151 /* *** Get symmetric hash enable per port *** */
11152 struct cmd_get_sym_hash_ena_per_port_result {
11153 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11158 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11159 __rte_unused struct cmdline *cl,
11160 __rte_unused void *data)
11162 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11163 struct rte_eth_hash_filter_info info;
11166 if (rte_eth_dev_filter_supported(res->port_id,
11167 RTE_ETH_FILTER_HASH) < 0) {
11168 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11173 memset(&info, 0, sizeof(info));
11174 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11175 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11176 RTE_ETH_FILTER_GET, &info);
11179 printf("Cannot get symmetric hash enable per port "
11180 "on port %u\n", res->port_id);
11184 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11185 "enabled" : "disabled", res->port_id);
11188 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11189 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11190 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11191 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11192 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11195 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11196 .f = cmd_get_sym_hash_per_port_parsed,
11198 .help_str = "get_sym_hash_ena_per_port <port_id>",
11200 (void *)&cmd_get_sym_hash_ena_per_port_all,
11201 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11206 /* *** Set symmetric hash enable per port *** */
11207 struct cmd_set_sym_hash_ena_per_port_result {
11208 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11209 cmdline_fixed_string_t enable;
11214 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11215 __rte_unused struct cmdline *cl,
11216 __rte_unused void *data)
11218 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11219 struct rte_eth_hash_filter_info info;
11222 if (rte_eth_dev_filter_supported(res->port_id,
11223 RTE_ETH_FILTER_HASH) < 0) {
11224 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11229 memset(&info, 0, sizeof(info));
11230 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11231 if (!strcmp(res->enable, "enable"))
11232 info.info.enable = 1;
11233 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11234 RTE_ETH_FILTER_SET, &info);
11236 printf("Cannot set symmetric hash enable per port on "
11237 "port %u\n", res->port_id);
11240 printf("Symmetric hash has been set to %s on port %u\n",
11241 res->enable, res->port_id);
11244 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11245 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11246 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11247 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11248 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11250 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11251 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11252 enable, "enable#disable");
11254 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11255 .f = cmd_set_sym_hash_per_port_parsed,
11257 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11259 (void *)&cmd_set_sym_hash_ena_per_port_all,
11260 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11261 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11266 /* Get global config of hash function */
11267 struct cmd_get_hash_global_config_result {
11268 cmdline_fixed_string_t get_hash_global_config;
11273 flowtype_to_str(uint16_t ftype)
11279 } ftype_table[] = {
11280 {"ipv4", RTE_ETH_FLOW_IPV4},
11281 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11282 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11283 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11284 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11285 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11286 {"ipv6", RTE_ETH_FLOW_IPV6},
11287 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11288 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11289 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11290 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11291 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11292 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11293 {"port", RTE_ETH_FLOW_PORT},
11294 {"vxlan", RTE_ETH_FLOW_VXLAN},
11295 {"geneve", RTE_ETH_FLOW_GENEVE},
11296 {"nvgre", RTE_ETH_FLOW_NVGRE},
11299 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11300 if (ftype_table[i].ftype == ftype)
11301 return ftype_table[i].str;
11308 cmd_get_hash_global_config_parsed(void *parsed_result,
11309 __rte_unused struct cmdline *cl,
11310 __rte_unused void *data)
11312 struct cmd_get_hash_global_config_result *res = parsed_result;
11313 struct rte_eth_hash_filter_info info;
11314 uint32_t idx, offset;
11319 if (rte_eth_dev_filter_supported(res->port_id,
11320 RTE_ETH_FILTER_HASH) < 0) {
11321 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11326 memset(&info, 0, sizeof(info));
11327 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11328 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11329 RTE_ETH_FILTER_GET, &info);
11331 printf("Cannot get hash global configurations by port %d\n",
11336 switch (info.info.global_conf.hash_func) {
11337 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11338 printf("Hash function is Toeplitz\n");
11340 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11341 printf("Hash function is Simple XOR\n");
11344 printf("Unknown hash function\n");
11348 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11349 idx = i / UINT64_BIT;
11350 offset = i % UINT64_BIT;
11351 if (!(info.info.global_conf.valid_bit_mask[idx] &
11354 str = flowtype_to_str(i);
11357 printf("Symmetric hash is %s globally for flow type %s "
11359 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11360 (1ULL << offset)) ? "enabled" : "disabled"), str,
11365 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11366 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11367 get_hash_global_config, "get_hash_global_config");
11368 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11369 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11372 cmdline_parse_inst_t cmd_get_hash_global_config = {
11373 .f = cmd_get_hash_global_config_parsed,
11375 .help_str = "get_hash_global_config <port_id>",
11377 (void *)&cmd_get_hash_global_config_all,
11378 (void *)&cmd_get_hash_global_config_port_id,
11383 /* Set global config of hash function */
11384 struct cmd_set_hash_global_config_result {
11385 cmdline_fixed_string_t set_hash_global_config;
11387 cmdline_fixed_string_t hash_func;
11388 cmdline_fixed_string_t flow_type;
11389 cmdline_fixed_string_t enable;
11393 cmd_set_hash_global_config_parsed(void *parsed_result,
11394 __rte_unused struct cmdline *cl,
11395 __rte_unused void *data)
11397 struct cmd_set_hash_global_config_result *res = parsed_result;
11398 struct rte_eth_hash_filter_info info;
11399 uint32_t ftype, idx, offset;
11402 if (rte_eth_dev_filter_supported(res->port_id,
11403 RTE_ETH_FILTER_HASH) < 0) {
11404 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11408 memset(&info, 0, sizeof(info));
11409 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11410 if (!strcmp(res->hash_func, "toeplitz"))
11411 info.info.global_conf.hash_func =
11412 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11413 else if (!strcmp(res->hash_func, "simple_xor"))
11414 info.info.global_conf.hash_func =
11415 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11416 else if (!strcmp(res->hash_func, "default"))
11417 info.info.global_conf.hash_func =
11418 RTE_ETH_HASH_FUNCTION_DEFAULT;
11420 ftype = str2flowtype(res->flow_type);
11421 idx = ftype / UINT64_BIT;
11422 offset = ftype % UINT64_BIT;
11423 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11424 if (!strcmp(res->enable, "enable"))
11425 info.info.global_conf.sym_hash_enable_mask[idx] |=
11427 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11428 RTE_ETH_FILTER_SET, &info);
11430 printf("Cannot set global hash configurations by port %d\n",
11433 printf("Global hash configurations have been set "
11434 "succcessfully by port %d\n", res->port_id);
11437 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11438 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11439 set_hash_global_config, "set_hash_global_config");
11440 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11441 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11443 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11444 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11445 hash_func, "toeplitz#simple_xor#default");
11446 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11447 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11449 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11450 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11451 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11452 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11453 enable, "enable#disable");
11455 cmdline_parse_inst_t cmd_set_hash_global_config = {
11456 .f = cmd_set_hash_global_config_parsed,
11458 .help_str = "set_hash_global_config <port_id> "
11459 "toeplitz|simple_xor|default "
11460 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11461 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11462 "l2_payload enable|disable",
11464 (void *)&cmd_set_hash_global_config_all,
11465 (void *)&cmd_set_hash_global_config_port_id,
11466 (void *)&cmd_set_hash_global_config_hash_func,
11467 (void *)&cmd_set_hash_global_config_flow_type,
11468 (void *)&cmd_set_hash_global_config_enable,
11473 /* Set hash input set */
11474 struct cmd_set_hash_input_set_result {
11475 cmdline_fixed_string_t set_hash_input_set;
11477 cmdline_fixed_string_t flow_type;
11478 cmdline_fixed_string_t inset_field;
11479 cmdline_fixed_string_t select;
11482 static enum rte_eth_input_set_field
11483 str2inset(char *string)
11487 static const struct {
11489 enum rte_eth_input_set_field inset;
11490 } inset_table[] = {
11491 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11492 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11493 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11494 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11495 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11496 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11497 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11498 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11499 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11500 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11501 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11502 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11503 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11504 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11505 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11506 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11507 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11508 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11509 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11510 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11511 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11512 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11513 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11514 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11515 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11516 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11517 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11518 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11519 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11520 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11521 {"none", RTE_ETH_INPUT_SET_NONE},
11524 for (i = 0; i < RTE_DIM(inset_table); i++) {
11525 if (!strcmp(string, inset_table[i].str))
11526 return inset_table[i].inset;
11529 return RTE_ETH_INPUT_SET_UNKNOWN;
11533 cmd_set_hash_input_set_parsed(void *parsed_result,
11534 __rte_unused struct cmdline *cl,
11535 __rte_unused void *data)
11537 struct cmd_set_hash_input_set_result *res = parsed_result;
11538 struct rte_eth_hash_filter_info info;
11540 memset(&info, 0, sizeof(info));
11541 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11542 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11543 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11544 info.info.input_set_conf.inset_size = 1;
11545 if (!strcmp(res->select, "select"))
11546 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11547 else if (!strcmp(res->select, "add"))
11548 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11549 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11550 RTE_ETH_FILTER_SET, &info);
11553 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11554 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11555 set_hash_input_set, "set_hash_input_set");
11556 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11557 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11559 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11560 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11562 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11563 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11565 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11566 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11567 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11568 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11569 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11571 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11572 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11573 select, "select#add");
11575 cmdline_parse_inst_t cmd_set_hash_input_set = {
11576 .f = cmd_set_hash_input_set_parsed,
11578 .help_str = "set_hash_input_set <port_id> "
11579 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11580 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11581 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11582 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11583 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11584 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11585 "fld-7th|fld-8th|none select|add",
11587 (void *)&cmd_set_hash_input_set_cmd,
11588 (void *)&cmd_set_hash_input_set_port_id,
11589 (void *)&cmd_set_hash_input_set_flow_type,
11590 (void *)&cmd_set_hash_input_set_field,
11591 (void *)&cmd_set_hash_input_set_select,
11596 /* Set flow director input set */
11597 struct cmd_set_fdir_input_set_result {
11598 cmdline_fixed_string_t set_fdir_input_set;
11600 cmdline_fixed_string_t flow_type;
11601 cmdline_fixed_string_t inset_field;
11602 cmdline_fixed_string_t select;
11606 cmd_set_fdir_input_set_parsed(void *parsed_result,
11607 __rte_unused struct cmdline *cl,
11608 __rte_unused void *data)
11610 struct cmd_set_fdir_input_set_result *res = parsed_result;
11611 struct rte_eth_fdir_filter_info info;
11613 memset(&info, 0, sizeof(info));
11614 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11615 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11616 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11617 info.info.input_set_conf.inset_size = 1;
11618 if (!strcmp(res->select, "select"))
11619 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11620 else if (!strcmp(res->select, "add"))
11621 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11622 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11623 RTE_ETH_FILTER_SET, &info);
11626 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11627 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11628 set_fdir_input_set, "set_fdir_input_set");
11629 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11630 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11632 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11633 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11635 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11636 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11637 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11638 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11640 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11641 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11642 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11643 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11644 "sctp-veri-tag#none");
11645 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11646 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11647 select, "select#add");
11649 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11650 .f = cmd_set_fdir_input_set_parsed,
11652 .help_str = "set_fdir_input_set <port_id> "
11653 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11654 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11655 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11656 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11657 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11658 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11659 "sctp-veri-tag|none select|add",
11661 (void *)&cmd_set_fdir_input_set_cmd,
11662 (void *)&cmd_set_fdir_input_set_port_id,
11663 (void *)&cmd_set_fdir_input_set_flow_type,
11664 (void *)&cmd_set_fdir_input_set_field,
11665 (void *)&cmd_set_fdir_input_set_select,
11670 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11671 struct cmd_mcast_addr_result {
11672 cmdline_fixed_string_t mcast_addr_cmd;
11673 cmdline_fixed_string_t what;
11675 struct ether_addr mc_addr;
11678 static void cmd_mcast_addr_parsed(void *parsed_result,
11679 __attribute__((unused)) struct cmdline *cl,
11680 __attribute__((unused)) void *data)
11682 struct cmd_mcast_addr_result *res = parsed_result;
11684 if (!is_multicast_ether_addr(&res->mc_addr)) {
11685 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11686 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11687 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11688 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11691 if (strcmp(res->what, "add") == 0)
11692 mcast_addr_add(res->port_num, &res->mc_addr);
11694 mcast_addr_remove(res->port_num, &res->mc_addr);
11697 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11698 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11699 mcast_addr_cmd, "mcast_addr");
11700 cmdline_parse_token_string_t cmd_mcast_addr_what =
11701 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11703 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11704 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11705 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11706 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11708 cmdline_parse_inst_t cmd_mcast_addr = {
11709 .f = cmd_mcast_addr_parsed,
11711 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11712 "Add/Remove multicast MAC address on port_id",
11714 (void *)&cmd_mcast_addr_cmd,
11715 (void *)&cmd_mcast_addr_what,
11716 (void *)&cmd_mcast_addr_portnum,
11717 (void *)&cmd_mcast_addr_addr,
11722 /* l2 tunnel config
11723 * only support E-tag now.
11726 /* Ether type config */
11727 struct cmd_config_l2_tunnel_eth_type_result {
11728 cmdline_fixed_string_t port;
11729 cmdline_fixed_string_t config;
11730 cmdline_fixed_string_t all;
11732 cmdline_fixed_string_t l2_tunnel;
11733 cmdline_fixed_string_t l2_tunnel_type;
11734 cmdline_fixed_string_t eth_type;
11735 uint16_t eth_type_val;
11738 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11739 TOKEN_STRING_INITIALIZER
11740 (struct cmd_config_l2_tunnel_eth_type_result,
11742 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11743 TOKEN_STRING_INITIALIZER
11744 (struct cmd_config_l2_tunnel_eth_type_result,
11746 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11747 TOKEN_STRING_INITIALIZER
11748 (struct cmd_config_l2_tunnel_eth_type_result,
11750 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11751 TOKEN_NUM_INITIALIZER
11752 (struct cmd_config_l2_tunnel_eth_type_result,
11754 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11755 TOKEN_STRING_INITIALIZER
11756 (struct cmd_config_l2_tunnel_eth_type_result,
11757 l2_tunnel, "l2-tunnel");
11758 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11759 TOKEN_STRING_INITIALIZER
11760 (struct cmd_config_l2_tunnel_eth_type_result,
11761 l2_tunnel_type, "E-tag");
11762 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11763 TOKEN_STRING_INITIALIZER
11764 (struct cmd_config_l2_tunnel_eth_type_result,
11765 eth_type, "ether-type");
11766 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11767 TOKEN_NUM_INITIALIZER
11768 (struct cmd_config_l2_tunnel_eth_type_result,
11769 eth_type_val, UINT16);
11771 static enum rte_eth_tunnel_type
11772 str2fdir_l2_tunnel_type(char *string)
11776 static const struct {
11778 enum rte_eth_tunnel_type type;
11779 } l2_tunnel_type_str[] = {
11780 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11783 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11784 if (!strcmp(l2_tunnel_type_str[i].str, string))
11785 return l2_tunnel_type_str[i].type;
11787 return RTE_TUNNEL_TYPE_NONE;
11790 /* ether type config for all ports */
11792 cmd_config_l2_tunnel_eth_type_all_parsed
11793 (void *parsed_result,
11794 __attribute__((unused)) struct cmdline *cl,
11795 __attribute__((unused)) void *data)
11797 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11798 struct rte_eth_l2_tunnel_conf entry;
11801 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11802 entry.ether_type = res->eth_type_val;
11804 RTE_ETH_FOREACH_DEV(pid) {
11805 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11809 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11810 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11812 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11814 (void *)&cmd_config_l2_tunnel_eth_type_port,
11815 (void *)&cmd_config_l2_tunnel_eth_type_config,
11816 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11817 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11818 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11819 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11820 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11825 /* ether type config for a specific port */
11827 cmd_config_l2_tunnel_eth_type_specific_parsed(
11828 void *parsed_result,
11829 __attribute__((unused)) struct cmdline *cl,
11830 __attribute__((unused)) void *data)
11832 struct cmd_config_l2_tunnel_eth_type_result *res =
11834 struct rte_eth_l2_tunnel_conf entry;
11836 if (port_id_is_invalid(res->id, ENABLED_WARN))
11839 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11840 entry.ether_type = res->eth_type_val;
11842 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11845 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11846 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11848 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11850 (void *)&cmd_config_l2_tunnel_eth_type_port,
11851 (void *)&cmd_config_l2_tunnel_eth_type_config,
11852 (void *)&cmd_config_l2_tunnel_eth_type_id,
11853 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11854 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11855 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11856 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11861 /* Enable/disable l2 tunnel */
11862 struct cmd_config_l2_tunnel_en_dis_result {
11863 cmdline_fixed_string_t port;
11864 cmdline_fixed_string_t config;
11865 cmdline_fixed_string_t all;
11867 cmdline_fixed_string_t l2_tunnel;
11868 cmdline_fixed_string_t l2_tunnel_type;
11869 cmdline_fixed_string_t en_dis;
11872 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11873 TOKEN_STRING_INITIALIZER
11874 (struct cmd_config_l2_tunnel_en_dis_result,
11876 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11877 TOKEN_STRING_INITIALIZER
11878 (struct cmd_config_l2_tunnel_en_dis_result,
11880 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11881 TOKEN_STRING_INITIALIZER
11882 (struct cmd_config_l2_tunnel_en_dis_result,
11884 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11885 TOKEN_NUM_INITIALIZER
11886 (struct cmd_config_l2_tunnel_en_dis_result,
11888 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11889 TOKEN_STRING_INITIALIZER
11890 (struct cmd_config_l2_tunnel_en_dis_result,
11891 l2_tunnel, "l2-tunnel");
11892 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11893 TOKEN_STRING_INITIALIZER
11894 (struct cmd_config_l2_tunnel_en_dis_result,
11895 l2_tunnel_type, "E-tag");
11896 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11897 TOKEN_STRING_INITIALIZER
11898 (struct cmd_config_l2_tunnel_en_dis_result,
11899 en_dis, "enable#disable");
11901 /* enable/disable l2 tunnel for all ports */
11903 cmd_config_l2_tunnel_en_dis_all_parsed(
11904 void *parsed_result,
11905 __attribute__((unused)) struct cmdline *cl,
11906 __attribute__((unused)) void *data)
11908 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11909 struct rte_eth_l2_tunnel_conf entry;
11913 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11915 if (!strcmp("enable", res->en_dis))
11920 RTE_ETH_FOREACH_DEV(pid) {
11921 rte_eth_dev_l2_tunnel_offload_set(pid,
11923 ETH_L2_TUNNEL_ENABLE_MASK,
11928 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11929 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11931 .help_str = "port config all l2-tunnel E-tag enable|disable",
11933 (void *)&cmd_config_l2_tunnel_en_dis_port,
11934 (void *)&cmd_config_l2_tunnel_en_dis_config,
11935 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11936 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11937 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11938 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11943 /* enable/disable l2 tunnel for a port */
11945 cmd_config_l2_tunnel_en_dis_specific_parsed(
11946 void *parsed_result,
11947 __attribute__((unused)) struct cmdline *cl,
11948 __attribute__((unused)) void *data)
11950 struct cmd_config_l2_tunnel_en_dis_result *res =
11952 struct rte_eth_l2_tunnel_conf entry;
11954 if (port_id_is_invalid(res->id, ENABLED_WARN))
11957 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11959 if (!strcmp("enable", res->en_dis))
11960 rte_eth_dev_l2_tunnel_offload_set(res->id,
11962 ETH_L2_TUNNEL_ENABLE_MASK,
11965 rte_eth_dev_l2_tunnel_offload_set(res->id,
11967 ETH_L2_TUNNEL_ENABLE_MASK,
11971 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11972 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11974 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11976 (void *)&cmd_config_l2_tunnel_en_dis_port,
11977 (void *)&cmd_config_l2_tunnel_en_dis_config,
11978 (void *)&cmd_config_l2_tunnel_en_dis_id,
11979 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11980 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11981 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11986 /* E-tag configuration */
11988 /* Common result structure for all E-tag configuration */
11989 struct cmd_config_e_tag_result {
11990 cmdline_fixed_string_t e_tag;
11991 cmdline_fixed_string_t set;
11992 cmdline_fixed_string_t insertion;
11993 cmdline_fixed_string_t stripping;
11994 cmdline_fixed_string_t forwarding;
11995 cmdline_fixed_string_t filter;
11996 cmdline_fixed_string_t add;
11997 cmdline_fixed_string_t del;
11998 cmdline_fixed_string_t on;
11999 cmdline_fixed_string_t off;
12000 cmdline_fixed_string_t on_off;
12001 cmdline_fixed_string_t port_tag_id;
12002 uint32_t port_tag_id_val;
12003 cmdline_fixed_string_t e_tag_id;
12004 uint16_t e_tag_id_val;
12005 cmdline_fixed_string_t dst_pool;
12006 uint8_t dst_pool_val;
12007 cmdline_fixed_string_t port;
12009 cmdline_fixed_string_t vf;
12013 /* Common CLI fields for all E-tag configuration */
12014 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12015 TOKEN_STRING_INITIALIZER
12016 (struct cmd_config_e_tag_result,
12018 cmdline_parse_token_string_t cmd_config_e_tag_set =
12019 TOKEN_STRING_INITIALIZER
12020 (struct cmd_config_e_tag_result,
12022 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12023 TOKEN_STRING_INITIALIZER
12024 (struct cmd_config_e_tag_result,
12025 insertion, "insertion");
12026 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12027 TOKEN_STRING_INITIALIZER
12028 (struct cmd_config_e_tag_result,
12029 stripping, "stripping");
12030 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12031 TOKEN_STRING_INITIALIZER
12032 (struct cmd_config_e_tag_result,
12033 forwarding, "forwarding");
12034 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12035 TOKEN_STRING_INITIALIZER
12036 (struct cmd_config_e_tag_result,
12038 cmdline_parse_token_string_t cmd_config_e_tag_add =
12039 TOKEN_STRING_INITIALIZER
12040 (struct cmd_config_e_tag_result,
12042 cmdline_parse_token_string_t cmd_config_e_tag_del =
12043 TOKEN_STRING_INITIALIZER
12044 (struct cmd_config_e_tag_result,
12046 cmdline_parse_token_string_t cmd_config_e_tag_on =
12047 TOKEN_STRING_INITIALIZER
12048 (struct cmd_config_e_tag_result,
12050 cmdline_parse_token_string_t cmd_config_e_tag_off =
12051 TOKEN_STRING_INITIALIZER
12052 (struct cmd_config_e_tag_result,
12054 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12055 TOKEN_STRING_INITIALIZER
12056 (struct cmd_config_e_tag_result,
12058 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12059 TOKEN_STRING_INITIALIZER
12060 (struct cmd_config_e_tag_result,
12061 port_tag_id, "port-tag-id");
12062 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12063 TOKEN_NUM_INITIALIZER
12064 (struct cmd_config_e_tag_result,
12065 port_tag_id_val, UINT32);
12066 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12067 TOKEN_STRING_INITIALIZER
12068 (struct cmd_config_e_tag_result,
12069 e_tag_id, "e-tag-id");
12070 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12071 TOKEN_NUM_INITIALIZER
12072 (struct cmd_config_e_tag_result,
12073 e_tag_id_val, UINT16);
12074 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12075 TOKEN_STRING_INITIALIZER
12076 (struct cmd_config_e_tag_result,
12077 dst_pool, "dst-pool");
12078 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12079 TOKEN_NUM_INITIALIZER
12080 (struct cmd_config_e_tag_result,
12081 dst_pool_val, UINT8);
12082 cmdline_parse_token_string_t cmd_config_e_tag_port =
12083 TOKEN_STRING_INITIALIZER
12084 (struct cmd_config_e_tag_result,
12086 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12087 TOKEN_NUM_INITIALIZER
12088 (struct cmd_config_e_tag_result,
12090 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12091 TOKEN_STRING_INITIALIZER
12092 (struct cmd_config_e_tag_result,
12094 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12095 TOKEN_NUM_INITIALIZER
12096 (struct cmd_config_e_tag_result,
12099 /* E-tag insertion configuration */
12101 cmd_config_e_tag_insertion_en_parsed(
12102 void *parsed_result,
12103 __attribute__((unused)) struct cmdline *cl,
12104 __attribute__((unused)) void *data)
12106 struct cmd_config_e_tag_result *res =
12108 struct rte_eth_l2_tunnel_conf entry;
12110 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12113 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12114 entry.tunnel_id = res->port_tag_id_val;
12115 entry.vf_id = res->vf_id;
12116 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12118 ETH_L2_TUNNEL_INSERTION_MASK,
12123 cmd_config_e_tag_insertion_dis_parsed(
12124 void *parsed_result,
12125 __attribute__((unused)) struct cmdline *cl,
12126 __attribute__((unused)) void *data)
12128 struct cmd_config_e_tag_result *res =
12130 struct rte_eth_l2_tunnel_conf entry;
12132 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12135 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12136 entry.vf_id = res->vf_id;
12138 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12140 ETH_L2_TUNNEL_INSERTION_MASK,
12144 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12145 .f = cmd_config_e_tag_insertion_en_parsed,
12147 .help_str = "E-tag ... : E-tag insertion enable",
12149 (void *)&cmd_config_e_tag_e_tag,
12150 (void *)&cmd_config_e_tag_set,
12151 (void *)&cmd_config_e_tag_insertion,
12152 (void *)&cmd_config_e_tag_on,
12153 (void *)&cmd_config_e_tag_port_tag_id,
12154 (void *)&cmd_config_e_tag_port_tag_id_val,
12155 (void *)&cmd_config_e_tag_port,
12156 (void *)&cmd_config_e_tag_port_id,
12157 (void *)&cmd_config_e_tag_vf,
12158 (void *)&cmd_config_e_tag_vf_id,
12163 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12164 .f = cmd_config_e_tag_insertion_dis_parsed,
12166 .help_str = "E-tag ... : E-tag insertion disable",
12168 (void *)&cmd_config_e_tag_e_tag,
12169 (void *)&cmd_config_e_tag_set,
12170 (void *)&cmd_config_e_tag_insertion,
12171 (void *)&cmd_config_e_tag_off,
12172 (void *)&cmd_config_e_tag_port,
12173 (void *)&cmd_config_e_tag_port_id,
12174 (void *)&cmd_config_e_tag_vf,
12175 (void *)&cmd_config_e_tag_vf_id,
12180 /* E-tag stripping configuration */
12182 cmd_config_e_tag_stripping_parsed(
12183 void *parsed_result,
12184 __attribute__((unused)) struct cmdline *cl,
12185 __attribute__((unused)) void *data)
12187 struct cmd_config_e_tag_result *res =
12189 struct rte_eth_l2_tunnel_conf entry;
12191 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12194 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12196 if (!strcmp(res->on_off, "on"))
12197 rte_eth_dev_l2_tunnel_offload_set
12200 ETH_L2_TUNNEL_STRIPPING_MASK,
12203 rte_eth_dev_l2_tunnel_offload_set
12206 ETH_L2_TUNNEL_STRIPPING_MASK,
12210 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12211 .f = cmd_config_e_tag_stripping_parsed,
12213 .help_str = "E-tag ... : E-tag stripping enable/disable",
12215 (void *)&cmd_config_e_tag_e_tag,
12216 (void *)&cmd_config_e_tag_set,
12217 (void *)&cmd_config_e_tag_stripping,
12218 (void *)&cmd_config_e_tag_on_off,
12219 (void *)&cmd_config_e_tag_port,
12220 (void *)&cmd_config_e_tag_port_id,
12225 /* E-tag forwarding configuration */
12227 cmd_config_e_tag_forwarding_parsed(
12228 void *parsed_result,
12229 __attribute__((unused)) struct cmdline *cl,
12230 __attribute__((unused)) void *data)
12232 struct cmd_config_e_tag_result *res = parsed_result;
12233 struct rte_eth_l2_tunnel_conf entry;
12235 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12238 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12240 if (!strcmp(res->on_off, "on"))
12241 rte_eth_dev_l2_tunnel_offload_set
12244 ETH_L2_TUNNEL_FORWARDING_MASK,
12247 rte_eth_dev_l2_tunnel_offload_set
12250 ETH_L2_TUNNEL_FORWARDING_MASK,
12254 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12255 .f = cmd_config_e_tag_forwarding_parsed,
12257 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12259 (void *)&cmd_config_e_tag_e_tag,
12260 (void *)&cmd_config_e_tag_set,
12261 (void *)&cmd_config_e_tag_forwarding,
12262 (void *)&cmd_config_e_tag_on_off,
12263 (void *)&cmd_config_e_tag_port,
12264 (void *)&cmd_config_e_tag_port_id,
12269 /* E-tag filter configuration */
12271 cmd_config_e_tag_filter_add_parsed(
12272 void *parsed_result,
12273 __attribute__((unused)) struct cmdline *cl,
12274 __attribute__((unused)) void *data)
12276 struct cmd_config_e_tag_result *res = parsed_result;
12277 struct rte_eth_l2_tunnel_conf entry;
12280 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12283 if (res->e_tag_id_val > 0x3fff) {
12284 printf("e-tag-id must be equal or less than 0x3fff.\n");
12288 ret = rte_eth_dev_filter_supported(res->port_id,
12289 RTE_ETH_FILTER_L2_TUNNEL);
12291 printf("E-tag filter is not supported on port %u.\n",
12296 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12297 entry.tunnel_id = res->e_tag_id_val;
12298 entry.pool = res->dst_pool_val;
12300 ret = rte_eth_dev_filter_ctrl(res->port_id,
12301 RTE_ETH_FILTER_L2_TUNNEL,
12302 RTE_ETH_FILTER_ADD,
12305 printf("E-tag filter programming error: (%s)\n",
12309 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12310 .f = cmd_config_e_tag_filter_add_parsed,
12312 .help_str = "E-tag ... : E-tag filter add",
12314 (void *)&cmd_config_e_tag_e_tag,
12315 (void *)&cmd_config_e_tag_set,
12316 (void *)&cmd_config_e_tag_filter,
12317 (void *)&cmd_config_e_tag_add,
12318 (void *)&cmd_config_e_tag_e_tag_id,
12319 (void *)&cmd_config_e_tag_e_tag_id_val,
12320 (void *)&cmd_config_e_tag_dst_pool,
12321 (void *)&cmd_config_e_tag_dst_pool_val,
12322 (void *)&cmd_config_e_tag_port,
12323 (void *)&cmd_config_e_tag_port_id,
12329 cmd_config_e_tag_filter_del_parsed(
12330 void *parsed_result,
12331 __attribute__((unused)) struct cmdline *cl,
12332 __attribute__((unused)) void *data)
12334 struct cmd_config_e_tag_result *res = parsed_result;
12335 struct rte_eth_l2_tunnel_conf entry;
12338 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12341 if (res->e_tag_id_val > 0x3fff) {
12342 printf("e-tag-id must be less than 0x3fff.\n");
12346 ret = rte_eth_dev_filter_supported(res->port_id,
12347 RTE_ETH_FILTER_L2_TUNNEL);
12349 printf("E-tag filter is not supported on port %u.\n",
12354 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12355 entry.tunnel_id = res->e_tag_id_val;
12357 ret = rte_eth_dev_filter_ctrl(res->port_id,
12358 RTE_ETH_FILTER_L2_TUNNEL,
12359 RTE_ETH_FILTER_DELETE,
12362 printf("E-tag filter programming error: (%s)\n",
12366 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12367 .f = cmd_config_e_tag_filter_del_parsed,
12369 .help_str = "E-tag ... : E-tag filter delete",
12371 (void *)&cmd_config_e_tag_e_tag,
12372 (void *)&cmd_config_e_tag_set,
12373 (void *)&cmd_config_e_tag_filter,
12374 (void *)&cmd_config_e_tag_del,
12375 (void *)&cmd_config_e_tag_e_tag_id,
12376 (void *)&cmd_config_e_tag_e_tag_id_val,
12377 (void *)&cmd_config_e_tag_port,
12378 (void *)&cmd_config_e_tag_port_id,
12383 /* vf vlan anti spoof configuration */
12385 /* Common result structure for vf vlan anti spoof */
12386 struct cmd_vf_vlan_anti_spoof_result {
12387 cmdline_fixed_string_t set;
12388 cmdline_fixed_string_t vf;
12389 cmdline_fixed_string_t vlan;
12390 cmdline_fixed_string_t antispoof;
12393 cmdline_fixed_string_t on_off;
12396 /* Common CLI fields for vf vlan anti spoof enable disable */
12397 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12398 TOKEN_STRING_INITIALIZER
12399 (struct cmd_vf_vlan_anti_spoof_result,
12401 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12402 TOKEN_STRING_INITIALIZER
12403 (struct cmd_vf_vlan_anti_spoof_result,
12405 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12406 TOKEN_STRING_INITIALIZER
12407 (struct cmd_vf_vlan_anti_spoof_result,
12409 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12410 TOKEN_STRING_INITIALIZER
12411 (struct cmd_vf_vlan_anti_spoof_result,
12412 antispoof, "antispoof");
12413 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12414 TOKEN_NUM_INITIALIZER
12415 (struct cmd_vf_vlan_anti_spoof_result,
12417 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12418 TOKEN_NUM_INITIALIZER
12419 (struct cmd_vf_vlan_anti_spoof_result,
12421 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12422 TOKEN_STRING_INITIALIZER
12423 (struct cmd_vf_vlan_anti_spoof_result,
12427 cmd_set_vf_vlan_anti_spoof_parsed(
12428 void *parsed_result,
12429 __attribute__((unused)) struct cmdline *cl,
12430 __attribute__((unused)) void *data)
12432 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12433 int ret = -ENOTSUP;
12435 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12437 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12440 #ifdef RTE_LIBRTE_IXGBE_PMD
12441 if (ret == -ENOTSUP)
12442 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12443 res->vf_id, is_on);
12445 #ifdef RTE_LIBRTE_I40E_PMD
12446 if (ret == -ENOTSUP)
12447 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12448 res->vf_id, is_on);
12450 #ifdef RTE_LIBRTE_BNXT_PMD
12451 if (ret == -ENOTSUP)
12452 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12453 res->vf_id, is_on);
12460 printf("invalid vf_id %d\n", res->vf_id);
12463 printf("invalid port_id %d\n", res->port_id);
12466 printf("function not implemented\n");
12469 printf("programming error: (%s)\n", strerror(-ret));
12473 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12474 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12476 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12478 (void *)&cmd_vf_vlan_anti_spoof_set,
12479 (void *)&cmd_vf_vlan_anti_spoof_vf,
12480 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12481 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12482 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12483 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12484 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12489 /* vf mac anti spoof configuration */
12491 /* Common result structure for vf mac anti spoof */
12492 struct cmd_vf_mac_anti_spoof_result {
12493 cmdline_fixed_string_t set;
12494 cmdline_fixed_string_t vf;
12495 cmdline_fixed_string_t mac;
12496 cmdline_fixed_string_t antispoof;
12499 cmdline_fixed_string_t on_off;
12502 /* Common CLI fields for vf mac anti spoof enable disable */
12503 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12504 TOKEN_STRING_INITIALIZER
12505 (struct cmd_vf_mac_anti_spoof_result,
12507 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12508 TOKEN_STRING_INITIALIZER
12509 (struct cmd_vf_mac_anti_spoof_result,
12511 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12512 TOKEN_STRING_INITIALIZER
12513 (struct cmd_vf_mac_anti_spoof_result,
12515 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12516 TOKEN_STRING_INITIALIZER
12517 (struct cmd_vf_mac_anti_spoof_result,
12518 antispoof, "antispoof");
12519 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12520 TOKEN_NUM_INITIALIZER
12521 (struct cmd_vf_mac_anti_spoof_result,
12523 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12524 TOKEN_NUM_INITIALIZER
12525 (struct cmd_vf_mac_anti_spoof_result,
12527 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12528 TOKEN_STRING_INITIALIZER
12529 (struct cmd_vf_mac_anti_spoof_result,
12533 cmd_set_vf_mac_anti_spoof_parsed(
12534 void *parsed_result,
12535 __attribute__((unused)) struct cmdline *cl,
12536 __attribute__((unused)) void *data)
12538 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12539 int ret = -ENOTSUP;
12541 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12543 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12546 #ifdef RTE_LIBRTE_IXGBE_PMD
12547 if (ret == -ENOTSUP)
12548 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12549 res->vf_id, is_on);
12551 #ifdef RTE_LIBRTE_I40E_PMD
12552 if (ret == -ENOTSUP)
12553 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12554 res->vf_id, is_on);
12556 #ifdef RTE_LIBRTE_BNXT_PMD
12557 if (ret == -ENOTSUP)
12558 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12559 res->vf_id, is_on);
12566 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12569 printf("invalid port_id %d\n", res->port_id);
12572 printf("function not implemented\n");
12575 printf("programming error: (%s)\n", strerror(-ret));
12579 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12580 .f = cmd_set_vf_mac_anti_spoof_parsed,
12582 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12584 (void *)&cmd_vf_mac_anti_spoof_set,
12585 (void *)&cmd_vf_mac_anti_spoof_vf,
12586 (void *)&cmd_vf_mac_anti_spoof_mac,
12587 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12588 (void *)&cmd_vf_mac_anti_spoof_port_id,
12589 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12590 (void *)&cmd_vf_mac_anti_spoof_on_off,
12595 /* vf vlan strip queue configuration */
12597 /* Common result structure for vf mac anti spoof */
12598 struct cmd_vf_vlan_stripq_result {
12599 cmdline_fixed_string_t set;
12600 cmdline_fixed_string_t vf;
12601 cmdline_fixed_string_t vlan;
12602 cmdline_fixed_string_t stripq;
12605 cmdline_fixed_string_t on_off;
12608 /* Common CLI fields for vf vlan strip enable disable */
12609 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12610 TOKEN_STRING_INITIALIZER
12611 (struct cmd_vf_vlan_stripq_result,
12613 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12614 TOKEN_STRING_INITIALIZER
12615 (struct cmd_vf_vlan_stripq_result,
12617 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12618 TOKEN_STRING_INITIALIZER
12619 (struct cmd_vf_vlan_stripq_result,
12621 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12622 TOKEN_STRING_INITIALIZER
12623 (struct cmd_vf_vlan_stripq_result,
12625 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12626 TOKEN_NUM_INITIALIZER
12627 (struct cmd_vf_vlan_stripq_result,
12629 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12630 TOKEN_NUM_INITIALIZER
12631 (struct cmd_vf_vlan_stripq_result,
12633 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12634 TOKEN_STRING_INITIALIZER
12635 (struct cmd_vf_vlan_stripq_result,
12639 cmd_set_vf_vlan_stripq_parsed(
12640 void *parsed_result,
12641 __attribute__((unused)) struct cmdline *cl,
12642 __attribute__((unused)) void *data)
12644 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12645 int ret = -ENOTSUP;
12647 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12649 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12652 #ifdef RTE_LIBRTE_IXGBE_PMD
12653 if (ret == -ENOTSUP)
12654 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12655 res->vf_id, is_on);
12657 #ifdef RTE_LIBRTE_I40E_PMD
12658 if (ret == -ENOTSUP)
12659 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12660 res->vf_id, is_on);
12662 #ifdef RTE_LIBRTE_BNXT_PMD
12663 if (ret == -ENOTSUP)
12664 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12665 res->vf_id, is_on);
12672 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12675 printf("invalid port_id %d\n", res->port_id);
12678 printf("function not implemented\n");
12681 printf("programming error: (%s)\n", strerror(-ret));
12685 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12686 .f = cmd_set_vf_vlan_stripq_parsed,
12688 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12690 (void *)&cmd_vf_vlan_stripq_set,
12691 (void *)&cmd_vf_vlan_stripq_vf,
12692 (void *)&cmd_vf_vlan_stripq_vlan,
12693 (void *)&cmd_vf_vlan_stripq_stripq,
12694 (void *)&cmd_vf_vlan_stripq_port_id,
12695 (void *)&cmd_vf_vlan_stripq_vf_id,
12696 (void *)&cmd_vf_vlan_stripq_on_off,
12701 /* vf vlan insert configuration */
12703 /* Common result structure for vf vlan insert */
12704 struct cmd_vf_vlan_insert_result {
12705 cmdline_fixed_string_t set;
12706 cmdline_fixed_string_t vf;
12707 cmdline_fixed_string_t vlan;
12708 cmdline_fixed_string_t insert;
12714 /* Common CLI fields for vf vlan insert enable disable */
12715 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12716 TOKEN_STRING_INITIALIZER
12717 (struct cmd_vf_vlan_insert_result,
12719 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12720 TOKEN_STRING_INITIALIZER
12721 (struct cmd_vf_vlan_insert_result,
12723 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12724 TOKEN_STRING_INITIALIZER
12725 (struct cmd_vf_vlan_insert_result,
12727 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12728 TOKEN_STRING_INITIALIZER
12729 (struct cmd_vf_vlan_insert_result,
12731 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12732 TOKEN_NUM_INITIALIZER
12733 (struct cmd_vf_vlan_insert_result,
12735 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12736 TOKEN_NUM_INITIALIZER
12737 (struct cmd_vf_vlan_insert_result,
12739 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12740 TOKEN_NUM_INITIALIZER
12741 (struct cmd_vf_vlan_insert_result,
12745 cmd_set_vf_vlan_insert_parsed(
12746 void *parsed_result,
12747 __attribute__((unused)) struct cmdline *cl,
12748 __attribute__((unused)) void *data)
12750 struct cmd_vf_vlan_insert_result *res = parsed_result;
12751 int ret = -ENOTSUP;
12753 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12756 #ifdef RTE_LIBRTE_IXGBE_PMD
12757 if (ret == -ENOTSUP)
12758 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12761 #ifdef RTE_LIBRTE_I40E_PMD
12762 if (ret == -ENOTSUP)
12763 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12766 #ifdef RTE_LIBRTE_BNXT_PMD
12767 if (ret == -ENOTSUP)
12768 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12776 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12779 printf("invalid port_id %d\n", res->port_id);
12782 printf("function not implemented\n");
12785 printf("programming error: (%s)\n", strerror(-ret));
12789 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12790 .f = cmd_set_vf_vlan_insert_parsed,
12792 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12794 (void *)&cmd_vf_vlan_insert_set,
12795 (void *)&cmd_vf_vlan_insert_vf,
12796 (void *)&cmd_vf_vlan_insert_vlan,
12797 (void *)&cmd_vf_vlan_insert_insert,
12798 (void *)&cmd_vf_vlan_insert_port_id,
12799 (void *)&cmd_vf_vlan_insert_vf_id,
12800 (void *)&cmd_vf_vlan_insert_vlan_id,
12805 /* tx loopback configuration */
12807 /* Common result structure for tx loopback */
12808 struct cmd_tx_loopback_result {
12809 cmdline_fixed_string_t set;
12810 cmdline_fixed_string_t tx;
12811 cmdline_fixed_string_t loopback;
12813 cmdline_fixed_string_t on_off;
12816 /* Common CLI fields for tx loopback enable disable */
12817 cmdline_parse_token_string_t cmd_tx_loopback_set =
12818 TOKEN_STRING_INITIALIZER
12819 (struct cmd_tx_loopback_result,
12821 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12822 TOKEN_STRING_INITIALIZER
12823 (struct cmd_tx_loopback_result,
12825 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12826 TOKEN_STRING_INITIALIZER
12827 (struct cmd_tx_loopback_result,
12828 loopback, "loopback");
12829 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12830 TOKEN_NUM_INITIALIZER
12831 (struct cmd_tx_loopback_result,
12833 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12834 TOKEN_STRING_INITIALIZER
12835 (struct cmd_tx_loopback_result,
12839 cmd_set_tx_loopback_parsed(
12840 void *parsed_result,
12841 __attribute__((unused)) struct cmdline *cl,
12842 __attribute__((unused)) void *data)
12844 struct cmd_tx_loopback_result *res = parsed_result;
12845 int ret = -ENOTSUP;
12847 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12849 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12852 #ifdef RTE_LIBRTE_IXGBE_PMD
12853 if (ret == -ENOTSUP)
12854 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12856 #ifdef RTE_LIBRTE_I40E_PMD
12857 if (ret == -ENOTSUP)
12858 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12860 #ifdef RTE_LIBRTE_BNXT_PMD
12861 if (ret == -ENOTSUP)
12862 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12864 #ifdef RTE_LIBRTE_DPAA_PMD
12865 if (ret == -ENOTSUP)
12866 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12873 printf("invalid is_on %d\n", is_on);
12876 printf("invalid port_id %d\n", res->port_id);
12879 printf("function not implemented\n");
12882 printf("programming error: (%s)\n", strerror(-ret));
12886 cmdline_parse_inst_t cmd_set_tx_loopback = {
12887 .f = cmd_set_tx_loopback_parsed,
12889 .help_str = "set tx loopback <port_id> on|off",
12891 (void *)&cmd_tx_loopback_set,
12892 (void *)&cmd_tx_loopback_tx,
12893 (void *)&cmd_tx_loopback_loopback,
12894 (void *)&cmd_tx_loopback_port_id,
12895 (void *)&cmd_tx_loopback_on_off,
12900 /* all queues drop enable configuration */
12902 /* Common result structure for all queues drop enable */
12903 struct cmd_all_queues_drop_en_result {
12904 cmdline_fixed_string_t set;
12905 cmdline_fixed_string_t all;
12906 cmdline_fixed_string_t queues;
12907 cmdline_fixed_string_t drop;
12909 cmdline_fixed_string_t on_off;
12912 /* Common CLI fields for tx loopback enable disable */
12913 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12914 TOKEN_STRING_INITIALIZER
12915 (struct cmd_all_queues_drop_en_result,
12917 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12918 TOKEN_STRING_INITIALIZER
12919 (struct cmd_all_queues_drop_en_result,
12921 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12922 TOKEN_STRING_INITIALIZER
12923 (struct cmd_all_queues_drop_en_result,
12925 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12926 TOKEN_STRING_INITIALIZER
12927 (struct cmd_all_queues_drop_en_result,
12929 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12930 TOKEN_NUM_INITIALIZER
12931 (struct cmd_all_queues_drop_en_result,
12933 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12934 TOKEN_STRING_INITIALIZER
12935 (struct cmd_all_queues_drop_en_result,
12939 cmd_set_all_queues_drop_en_parsed(
12940 void *parsed_result,
12941 __attribute__((unused)) struct cmdline *cl,
12942 __attribute__((unused)) void *data)
12944 struct cmd_all_queues_drop_en_result *res = parsed_result;
12945 int ret = -ENOTSUP;
12946 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12948 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12951 #ifdef RTE_LIBRTE_IXGBE_PMD
12952 if (ret == -ENOTSUP)
12953 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12955 #ifdef RTE_LIBRTE_BNXT_PMD
12956 if (ret == -ENOTSUP)
12957 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12963 printf("invalid is_on %d\n", is_on);
12966 printf("invalid port_id %d\n", res->port_id);
12969 printf("function not implemented\n");
12972 printf("programming error: (%s)\n", strerror(-ret));
12976 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12977 .f = cmd_set_all_queues_drop_en_parsed,
12979 .help_str = "set all queues drop <port_id> on|off",
12981 (void *)&cmd_all_queues_drop_en_set,
12982 (void *)&cmd_all_queues_drop_en_all,
12983 (void *)&cmd_all_queues_drop_en_queues,
12984 (void *)&cmd_all_queues_drop_en_drop,
12985 (void *)&cmd_all_queues_drop_en_port_id,
12986 (void *)&cmd_all_queues_drop_en_on_off,
12991 /* vf split drop enable configuration */
12993 /* Common result structure for vf split drop enable */
12994 struct cmd_vf_split_drop_en_result {
12995 cmdline_fixed_string_t set;
12996 cmdline_fixed_string_t vf;
12997 cmdline_fixed_string_t split;
12998 cmdline_fixed_string_t drop;
13001 cmdline_fixed_string_t on_off;
13004 /* Common CLI fields for vf split drop enable disable */
13005 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13006 TOKEN_STRING_INITIALIZER
13007 (struct cmd_vf_split_drop_en_result,
13009 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13010 TOKEN_STRING_INITIALIZER
13011 (struct cmd_vf_split_drop_en_result,
13013 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13014 TOKEN_STRING_INITIALIZER
13015 (struct cmd_vf_split_drop_en_result,
13017 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13018 TOKEN_STRING_INITIALIZER
13019 (struct cmd_vf_split_drop_en_result,
13021 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13022 TOKEN_NUM_INITIALIZER
13023 (struct cmd_vf_split_drop_en_result,
13025 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13026 TOKEN_NUM_INITIALIZER
13027 (struct cmd_vf_split_drop_en_result,
13029 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13030 TOKEN_STRING_INITIALIZER
13031 (struct cmd_vf_split_drop_en_result,
13035 cmd_set_vf_split_drop_en_parsed(
13036 void *parsed_result,
13037 __attribute__((unused)) struct cmdline *cl,
13038 __attribute__((unused)) void *data)
13040 struct cmd_vf_split_drop_en_result *res = parsed_result;
13041 int ret = -ENOTSUP;
13042 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13044 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13047 #ifdef RTE_LIBRTE_IXGBE_PMD
13048 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13055 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13058 printf("invalid port_id %d\n", res->port_id);
13061 printf("not supported on port %d\n", res->port_id);
13064 printf("programming error: (%s)\n", strerror(-ret));
13068 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13069 .f = cmd_set_vf_split_drop_en_parsed,
13071 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13073 (void *)&cmd_vf_split_drop_en_set,
13074 (void *)&cmd_vf_split_drop_en_vf,
13075 (void *)&cmd_vf_split_drop_en_split,
13076 (void *)&cmd_vf_split_drop_en_drop,
13077 (void *)&cmd_vf_split_drop_en_port_id,
13078 (void *)&cmd_vf_split_drop_en_vf_id,
13079 (void *)&cmd_vf_split_drop_en_on_off,
13084 /* vf mac address configuration */
13086 /* Common result structure for vf mac address */
13087 struct cmd_set_vf_mac_addr_result {
13088 cmdline_fixed_string_t set;
13089 cmdline_fixed_string_t vf;
13090 cmdline_fixed_string_t mac;
13091 cmdline_fixed_string_t addr;
13094 struct ether_addr mac_addr;
13098 /* Common CLI fields for vf split drop enable disable */
13099 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13100 TOKEN_STRING_INITIALIZER
13101 (struct cmd_set_vf_mac_addr_result,
13103 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13104 TOKEN_STRING_INITIALIZER
13105 (struct cmd_set_vf_mac_addr_result,
13107 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13108 TOKEN_STRING_INITIALIZER
13109 (struct cmd_set_vf_mac_addr_result,
13111 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13112 TOKEN_STRING_INITIALIZER
13113 (struct cmd_set_vf_mac_addr_result,
13115 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13116 TOKEN_NUM_INITIALIZER
13117 (struct cmd_set_vf_mac_addr_result,
13119 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13120 TOKEN_NUM_INITIALIZER
13121 (struct cmd_set_vf_mac_addr_result,
13123 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13124 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13128 cmd_set_vf_mac_addr_parsed(
13129 void *parsed_result,
13130 __attribute__((unused)) struct cmdline *cl,
13131 __attribute__((unused)) void *data)
13133 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13134 int ret = -ENOTSUP;
13136 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13139 #ifdef RTE_LIBRTE_IXGBE_PMD
13140 if (ret == -ENOTSUP)
13141 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13144 #ifdef RTE_LIBRTE_I40E_PMD
13145 if (ret == -ENOTSUP)
13146 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13149 #ifdef RTE_LIBRTE_BNXT_PMD
13150 if (ret == -ENOTSUP)
13151 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13159 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13162 printf("invalid port_id %d\n", res->port_id);
13165 printf("function not implemented\n");
13168 printf("programming error: (%s)\n", strerror(-ret));
13172 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13173 .f = cmd_set_vf_mac_addr_parsed,
13175 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13177 (void *)&cmd_set_vf_mac_addr_set,
13178 (void *)&cmd_set_vf_mac_addr_vf,
13179 (void *)&cmd_set_vf_mac_addr_mac,
13180 (void *)&cmd_set_vf_mac_addr_addr,
13181 (void *)&cmd_set_vf_mac_addr_port_id,
13182 (void *)&cmd_set_vf_mac_addr_vf_id,
13183 (void *)&cmd_set_vf_mac_addr_mac_addr,
13188 /* MACsec configuration */
13190 /* Common result structure for MACsec offload enable */
13191 struct cmd_macsec_offload_on_result {
13192 cmdline_fixed_string_t set;
13193 cmdline_fixed_string_t macsec;
13194 cmdline_fixed_string_t offload;
13196 cmdline_fixed_string_t on;
13197 cmdline_fixed_string_t encrypt;
13198 cmdline_fixed_string_t en_on_off;
13199 cmdline_fixed_string_t replay_protect;
13200 cmdline_fixed_string_t rp_on_off;
13203 /* Common CLI fields for MACsec offload disable */
13204 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13205 TOKEN_STRING_INITIALIZER
13206 (struct cmd_macsec_offload_on_result,
13208 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13209 TOKEN_STRING_INITIALIZER
13210 (struct cmd_macsec_offload_on_result,
13212 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13213 TOKEN_STRING_INITIALIZER
13214 (struct cmd_macsec_offload_on_result,
13215 offload, "offload");
13216 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13217 TOKEN_NUM_INITIALIZER
13218 (struct cmd_macsec_offload_on_result,
13220 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13221 TOKEN_STRING_INITIALIZER
13222 (struct cmd_macsec_offload_on_result,
13224 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13225 TOKEN_STRING_INITIALIZER
13226 (struct cmd_macsec_offload_on_result,
13227 encrypt, "encrypt");
13228 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13229 TOKEN_STRING_INITIALIZER
13230 (struct cmd_macsec_offload_on_result,
13231 en_on_off, "on#off");
13232 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13233 TOKEN_STRING_INITIALIZER
13234 (struct cmd_macsec_offload_on_result,
13235 replay_protect, "replay-protect");
13236 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13237 TOKEN_STRING_INITIALIZER
13238 (struct cmd_macsec_offload_on_result,
13239 rp_on_off, "on#off");
13242 cmd_set_macsec_offload_on_parsed(
13243 void *parsed_result,
13244 __attribute__((unused)) struct cmdline *cl,
13245 __attribute__((unused)) void *data)
13247 struct cmd_macsec_offload_on_result *res = parsed_result;
13248 int ret = -ENOTSUP;
13249 portid_t port_id = res->port_id;
13250 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13251 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13252 struct rte_eth_dev_info dev_info;
13254 if (port_id_is_invalid(port_id, ENABLED_WARN))
13256 if (!port_is_stopped(port_id)) {
13257 printf("Please stop port %d first\n", port_id);
13261 rte_eth_dev_info_get(port_id, &dev_info);
13262 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13263 #ifdef RTE_LIBRTE_IXGBE_PMD
13264 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13272 ports[port_id].dev_conf.txmode.offloads |=
13273 DEV_TX_OFFLOAD_MACSEC_INSERT;
13274 cmd_reconfig_device_queue(port_id, 1, 1);
13277 printf("invalid port_id %d\n", port_id);
13280 printf("not supported on port %d\n", port_id);
13283 printf("programming error: (%s)\n", strerror(-ret));
13287 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13288 .f = cmd_set_macsec_offload_on_parsed,
13290 .help_str = "set macsec offload <port_id> on "
13291 "encrypt on|off replay-protect on|off",
13293 (void *)&cmd_macsec_offload_on_set,
13294 (void *)&cmd_macsec_offload_on_macsec,
13295 (void *)&cmd_macsec_offload_on_offload,
13296 (void *)&cmd_macsec_offload_on_port_id,
13297 (void *)&cmd_macsec_offload_on_on,
13298 (void *)&cmd_macsec_offload_on_encrypt,
13299 (void *)&cmd_macsec_offload_on_en_on_off,
13300 (void *)&cmd_macsec_offload_on_replay_protect,
13301 (void *)&cmd_macsec_offload_on_rp_on_off,
13306 /* Common result structure for MACsec offload disable */
13307 struct cmd_macsec_offload_off_result {
13308 cmdline_fixed_string_t set;
13309 cmdline_fixed_string_t macsec;
13310 cmdline_fixed_string_t offload;
13312 cmdline_fixed_string_t off;
13315 /* Common CLI fields for MACsec offload disable */
13316 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13317 TOKEN_STRING_INITIALIZER
13318 (struct cmd_macsec_offload_off_result,
13320 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13321 TOKEN_STRING_INITIALIZER
13322 (struct cmd_macsec_offload_off_result,
13324 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13325 TOKEN_STRING_INITIALIZER
13326 (struct cmd_macsec_offload_off_result,
13327 offload, "offload");
13328 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13329 TOKEN_NUM_INITIALIZER
13330 (struct cmd_macsec_offload_off_result,
13332 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13333 TOKEN_STRING_INITIALIZER
13334 (struct cmd_macsec_offload_off_result,
13338 cmd_set_macsec_offload_off_parsed(
13339 void *parsed_result,
13340 __attribute__((unused)) struct cmdline *cl,
13341 __attribute__((unused)) void *data)
13343 struct cmd_macsec_offload_off_result *res = parsed_result;
13344 int ret = -ENOTSUP;
13345 struct rte_eth_dev_info dev_info;
13346 portid_t port_id = res->port_id;
13348 if (port_id_is_invalid(port_id, ENABLED_WARN))
13350 if (!port_is_stopped(port_id)) {
13351 printf("Please stop port %d first\n", port_id);
13355 rte_eth_dev_info_get(port_id, &dev_info);
13356 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13357 #ifdef RTE_LIBRTE_IXGBE_PMD
13358 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13363 ports[port_id].dev_conf.txmode.offloads &=
13364 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13365 cmd_reconfig_device_queue(port_id, 1, 1);
13368 printf("invalid port_id %d\n", port_id);
13371 printf("not supported on port %d\n", port_id);
13374 printf("programming error: (%s)\n", strerror(-ret));
13378 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13379 .f = cmd_set_macsec_offload_off_parsed,
13381 .help_str = "set macsec offload <port_id> off",
13383 (void *)&cmd_macsec_offload_off_set,
13384 (void *)&cmd_macsec_offload_off_macsec,
13385 (void *)&cmd_macsec_offload_off_offload,
13386 (void *)&cmd_macsec_offload_off_port_id,
13387 (void *)&cmd_macsec_offload_off_off,
13392 /* Common result structure for MACsec secure connection configure */
13393 struct cmd_macsec_sc_result {
13394 cmdline_fixed_string_t set;
13395 cmdline_fixed_string_t macsec;
13396 cmdline_fixed_string_t sc;
13397 cmdline_fixed_string_t tx_rx;
13399 struct ether_addr mac;
13403 /* Common CLI fields for MACsec secure connection configure */
13404 cmdline_parse_token_string_t cmd_macsec_sc_set =
13405 TOKEN_STRING_INITIALIZER
13406 (struct cmd_macsec_sc_result,
13408 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13409 TOKEN_STRING_INITIALIZER
13410 (struct cmd_macsec_sc_result,
13412 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13413 TOKEN_STRING_INITIALIZER
13414 (struct cmd_macsec_sc_result,
13416 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13417 TOKEN_STRING_INITIALIZER
13418 (struct cmd_macsec_sc_result,
13420 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13421 TOKEN_NUM_INITIALIZER
13422 (struct cmd_macsec_sc_result,
13424 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13425 TOKEN_ETHERADDR_INITIALIZER
13426 (struct cmd_macsec_sc_result,
13428 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13429 TOKEN_NUM_INITIALIZER
13430 (struct cmd_macsec_sc_result,
13434 cmd_set_macsec_sc_parsed(
13435 void *parsed_result,
13436 __attribute__((unused)) struct cmdline *cl,
13437 __attribute__((unused)) void *data)
13439 struct cmd_macsec_sc_result *res = parsed_result;
13440 int ret = -ENOTSUP;
13441 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13443 #ifdef RTE_LIBRTE_IXGBE_PMD
13445 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13446 res->mac.addr_bytes) :
13447 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13448 res->mac.addr_bytes, res->pi);
13450 RTE_SET_USED(is_tx);
13456 printf("invalid port_id %d\n", res->port_id);
13459 printf("not supported on port %d\n", res->port_id);
13462 printf("programming error: (%s)\n", strerror(-ret));
13466 cmdline_parse_inst_t cmd_set_macsec_sc = {
13467 .f = cmd_set_macsec_sc_parsed,
13469 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13471 (void *)&cmd_macsec_sc_set,
13472 (void *)&cmd_macsec_sc_macsec,
13473 (void *)&cmd_macsec_sc_sc,
13474 (void *)&cmd_macsec_sc_tx_rx,
13475 (void *)&cmd_macsec_sc_port_id,
13476 (void *)&cmd_macsec_sc_mac,
13477 (void *)&cmd_macsec_sc_pi,
13482 /* Common result structure for MACsec secure connection configure */
13483 struct cmd_macsec_sa_result {
13484 cmdline_fixed_string_t set;
13485 cmdline_fixed_string_t macsec;
13486 cmdline_fixed_string_t sa;
13487 cmdline_fixed_string_t tx_rx;
13492 cmdline_fixed_string_t key;
13495 /* Common CLI fields for MACsec secure connection configure */
13496 cmdline_parse_token_string_t cmd_macsec_sa_set =
13497 TOKEN_STRING_INITIALIZER
13498 (struct cmd_macsec_sa_result,
13500 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13501 TOKEN_STRING_INITIALIZER
13502 (struct cmd_macsec_sa_result,
13504 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13505 TOKEN_STRING_INITIALIZER
13506 (struct cmd_macsec_sa_result,
13508 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13509 TOKEN_STRING_INITIALIZER
13510 (struct cmd_macsec_sa_result,
13512 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13513 TOKEN_NUM_INITIALIZER
13514 (struct cmd_macsec_sa_result,
13516 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13517 TOKEN_NUM_INITIALIZER
13518 (struct cmd_macsec_sa_result,
13520 cmdline_parse_token_num_t cmd_macsec_sa_an =
13521 TOKEN_NUM_INITIALIZER
13522 (struct cmd_macsec_sa_result,
13524 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13525 TOKEN_NUM_INITIALIZER
13526 (struct cmd_macsec_sa_result,
13528 cmdline_parse_token_string_t cmd_macsec_sa_key =
13529 TOKEN_STRING_INITIALIZER
13530 (struct cmd_macsec_sa_result,
13534 cmd_set_macsec_sa_parsed(
13535 void *parsed_result,
13536 __attribute__((unused)) struct cmdline *cl,
13537 __attribute__((unused)) void *data)
13539 struct cmd_macsec_sa_result *res = parsed_result;
13540 int ret = -ENOTSUP;
13541 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13542 uint8_t key[16] = { 0 };
13548 key_len = strlen(res->key) / 2;
13552 for (i = 0; i < key_len; i++) {
13553 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13556 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13559 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13562 #ifdef RTE_LIBRTE_IXGBE_PMD
13564 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13565 res->idx, res->an, res->pn, key) :
13566 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13567 res->idx, res->an, res->pn, key);
13569 RTE_SET_USED(is_tx);
13576 printf("invalid idx %d or an %d\n", res->idx, res->an);
13579 printf("invalid port_id %d\n", res->port_id);
13582 printf("not supported on port %d\n", res->port_id);
13585 printf("programming error: (%s)\n", strerror(-ret));
13589 cmdline_parse_inst_t cmd_set_macsec_sa = {
13590 .f = cmd_set_macsec_sa_parsed,
13592 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13594 (void *)&cmd_macsec_sa_set,
13595 (void *)&cmd_macsec_sa_macsec,
13596 (void *)&cmd_macsec_sa_sa,
13597 (void *)&cmd_macsec_sa_tx_rx,
13598 (void *)&cmd_macsec_sa_port_id,
13599 (void *)&cmd_macsec_sa_idx,
13600 (void *)&cmd_macsec_sa_an,
13601 (void *)&cmd_macsec_sa_pn,
13602 (void *)&cmd_macsec_sa_key,
13607 /* VF unicast promiscuous mode configuration */
13609 /* Common result structure for VF unicast promiscuous mode */
13610 struct cmd_vf_promisc_result {
13611 cmdline_fixed_string_t set;
13612 cmdline_fixed_string_t vf;
13613 cmdline_fixed_string_t promisc;
13616 cmdline_fixed_string_t on_off;
13619 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13620 cmdline_parse_token_string_t cmd_vf_promisc_set =
13621 TOKEN_STRING_INITIALIZER
13622 (struct cmd_vf_promisc_result,
13624 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13625 TOKEN_STRING_INITIALIZER
13626 (struct cmd_vf_promisc_result,
13628 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13629 TOKEN_STRING_INITIALIZER
13630 (struct cmd_vf_promisc_result,
13631 promisc, "promisc");
13632 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13633 TOKEN_NUM_INITIALIZER
13634 (struct cmd_vf_promisc_result,
13636 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13637 TOKEN_NUM_INITIALIZER
13638 (struct cmd_vf_promisc_result,
13640 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13641 TOKEN_STRING_INITIALIZER
13642 (struct cmd_vf_promisc_result,
13646 cmd_set_vf_promisc_parsed(
13647 void *parsed_result,
13648 __attribute__((unused)) struct cmdline *cl,
13649 __attribute__((unused)) void *data)
13651 struct cmd_vf_promisc_result *res = parsed_result;
13652 int ret = -ENOTSUP;
13654 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13656 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13659 #ifdef RTE_LIBRTE_I40E_PMD
13660 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13661 res->vf_id, is_on);
13668 printf("invalid vf_id %d\n", res->vf_id);
13671 printf("invalid port_id %d\n", res->port_id);
13674 printf("function not implemented\n");
13677 printf("programming error: (%s)\n", strerror(-ret));
13681 cmdline_parse_inst_t cmd_set_vf_promisc = {
13682 .f = cmd_set_vf_promisc_parsed,
13684 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13685 "Set unicast promiscuous mode for a VF from the PF",
13687 (void *)&cmd_vf_promisc_set,
13688 (void *)&cmd_vf_promisc_vf,
13689 (void *)&cmd_vf_promisc_promisc,
13690 (void *)&cmd_vf_promisc_port_id,
13691 (void *)&cmd_vf_promisc_vf_id,
13692 (void *)&cmd_vf_promisc_on_off,
13697 /* VF multicast promiscuous mode configuration */
13699 /* Common result structure for VF multicast promiscuous mode */
13700 struct cmd_vf_allmulti_result {
13701 cmdline_fixed_string_t set;
13702 cmdline_fixed_string_t vf;
13703 cmdline_fixed_string_t allmulti;
13706 cmdline_fixed_string_t on_off;
13709 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13710 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13711 TOKEN_STRING_INITIALIZER
13712 (struct cmd_vf_allmulti_result,
13714 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13715 TOKEN_STRING_INITIALIZER
13716 (struct cmd_vf_allmulti_result,
13718 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13719 TOKEN_STRING_INITIALIZER
13720 (struct cmd_vf_allmulti_result,
13721 allmulti, "allmulti");
13722 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13723 TOKEN_NUM_INITIALIZER
13724 (struct cmd_vf_allmulti_result,
13726 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13727 TOKEN_NUM_INITIALIZER
13728 (struct cmd_vf_allmulti_result,
13730 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13731 TOKEN_STRING_INITIALIZER
13732 (struct cmd_vf_allmulti_result,
13736 cmd_set_vf_allmulti_parsed(
13737 void *parsed_result,
13738 __attribute__((unused)) struct cmdline *cl,
13739 __attribute__((unused)) void *data)
13741 struct cmd_vf_allmulti_result *res = parsed_result;
13742 int ret = -ENOTSUP;
13744 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13746 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13749 #ifdef RTE_LIBRTE_I40E_PMD
13750 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13751 res->vf_id, is_on);
13758 printf("invalid vf_id %d\n", res->vf_id);
13761 printf("invalid port_id %d\n", res->port_id);
13764 printf("function not implemented\n");
13767 printf("programming error: (%s)\n", strerror(-ret));
13771 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13772 .f = cmd_set_vf_allmulti_parsed,
13774 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13775 "Set multicast promiscuous mode for a VF from the PF",
13777 (void *)&cmd_vf_allmulti_set,
13778 (void *)&cmd_vf_allmulti_vf,
13779 (void *)&cmd_vf_allmulti_allmulti,
13780 (void *)&cmd_vf_allmulti_port_id,
13781 (void *)&cmd_vf_allmulti_vf_id,
13782 (void *)&cmd_vf_allmulti_on_off,
13787 /* vf broadcast mode configuration */
13789 /* Common result structure for vf broadcast */
13790 struct cmd_set_vf_broadcast_result {
13791 cmdline_fixed_string_t set;
13792 cmdline_fixed_string_t vf;
13793 cmdline_fixed_string_t broadcast;
13796 cmdline_fixed_string_t on_off;
13799 /* Common CLI fields for vf broadcast enable disable */
13800 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13801 TOKEN_STRING_INITIALIZER
13802 (struct cmd_set_vf_broadcast_result,
13804 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13805 TOKEN_STRING_INITIALIZER
13806 (struct cmd_set_vf_broadcast_result,
13808 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13809 TOKEN_STRING_INITIALIZER
13810 (struct cmd_set_vf_broadcast_result,
13811 broadcast, "broadcast");
13812 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13813 TOKEN_NUM_INITIALIZER
13814 (struct cmd_set_vf_broadcast_result,
13816 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13817 TOKEN_NUM_INITIALIZER
13818 (struct cmd_set_vf_broadcast_result,
13820 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13821 TOKEN_STRING_INITIALIZER
13822 (struct cmd_set_vf_broadcast_result,
13826 cmd_set_vf_broadcast_parsed(
13827 void *parsed_result,
13828 __attribute__((unused)) struct cmdline *cl,
13829 __attribute__((unused)) void *data)
13831 struct cmd_set_vf_broadcast_result *res = parsed_result;
13832 int ret = -ENOTSUP;
13834 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13836 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13839 #ifdef RTE_LIBRTE_I40E_PMD
13840 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13841 res->vf_id, is_on);
13848 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13851 printf("invalid port_id %d\n", res->port_id);
13854 printf("function not implemented\n");
13857 printf("programming error: (%s)\n", strerror(-ret));
13861 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13862 .f = cmd_set_vf_broadcast_parsed,
13864 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13866 (void *)&cmd_set_vf_broadcast_set,
13867 (void *)&cmd_set_vf_broadcast_vf,
13868 (void *)&cmd_set_vf_broadcast_broadcast,
13869 (void *)&cmd_set_vf_broadcast_port_id,
13870 (void *)&cmd_set_vf_broadcast_vf_id,
13871 (void *)&cmd_set_vf_broadcast_on_off,
13876 /* vf vlan tag configuration */
13878 /* Common result structure for vf vlan tag */
13879 struct cmd_set_vf_vlan_tag_result {
13880 cmdline_fixed_string_t set;
13881 cmdline_fixed_string_t vf;
13882 cmdline_fixed_string_t vlan;
13883 cmdline_fixed_string_t tag;
13886 cmdline_fixed_string_t on_off;
13889 /* Common CLI fields for vf vlan tag enable disable */
13890 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13891 TOKEN_STRING_INITIALIZER
13892 (struct cmd_set_vf_vlan_tag_result,
13894 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13895 TOKEN_STRING_INITIALIZER
13896 (struct cmd_set_vf_vlan_tag_result,
13898 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13899 TOKEN_STRING_INITIALIZER
13900 (struct cmd_set_vf_vlan_tag_result,
13902 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13903 TOKEN_STRING_INITIALIZER
13904 (struct cmd_set_vf_vlan_tag_result,
13906 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13907 TOKEN_NUM_INITIALIZER
13908 (struct cmd_set_vf_vlan_tag_result,
13910 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13911 TOKEN_NUM_INITIALIZER
13912 (struct cmd_set_vf_vlan_tag_result,
13914 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13915 TOKEN_STRING_INITIALIZER
13916 (struct cmd_set_vf_vlan_tag_result,
13920 cmd_set_vf_vlan_tag_parsed(
13921 void *parsed_result,
13922 __attribute__((unused)) struct cmdline *cl,
13923 __attribute__((unused)) void *data)
13925 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13926 int ret = -ENOTSUP;
13928 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13930 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13933 #ifdef RTE_LIBRTE_I40E_PMD
13934 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13935 res->vf_id, is_on);
13942 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13945 printf("invalid port_id %d\n", res->port_id);
13948 printf("function not implemented\n");
13951 printf("programming error: (%s)\n", strerror(-ret));
13955 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13956 .f = cmd_set_vf_vlan_tag_parsed,
13958 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13960 (void *)&cmd_set_vf_vlan_tag_set,
13961 (void *)&cmd_set_vf_vlan_tag_vf,
13962 (void *)&cmd_set_vf_vlan_tag_vlan,
13963 (void *)&cmd_set_vf_vlan_tag_tag,
13964 (void *)&cmd_set_vf_vlan_tag_port_id,
13965 (void *)&cmd_set_vf_vlan_tag_vf_id,
13966 (void *)&cmd_set_vf_vlan_tag_on_off,
13971 /* Common definition of VF and TC TX bandwidth configuration */
13972 struct cmd_vf_tc_bw_result {
13973 cmdline_fixed_string_t set;
13974 cmdline_fixed_string_t vf;
13975 cmdline_fixed_string_t tc;
13976 cmdline_fixed_string_t tx;
13977 cmdline_fixed_string_t min_bw;
13978 cmdline_fixed_string_t max_bw;
13979 cmdline_fixed_string_t strict_link_prio;
13984 cmdline_fixed_string_t bw_list;
13988 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13989 TOKEN_STRING_INITIALIZER
13990 (struct cmd_vf_tc_bw_result,
13992 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13993 TOKEN_STRING_INITIALIZER
13994 (struct cmd_vf_tc_bw_result,
13996 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13997 TOKEN_STRING_INITIALIZER
13998 (struct cmd_vf_tc_bw_result,
14000 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14001 TOKEN_STRING_INITIALIZER
14002 (struct cmd_vf_tc_bw_result,
14004 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14005 TOKEN_STRING_INITIALIZER
14006 (struct cmd_vf_tc_bw_result,
14007 strict_link_prio, "strict-link-priority");
14008 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14009 TOKEN_STRING_INITIALIZER
14010 (struct cmd_vf_tc_bw_result,
14011 min_bw, "min-bandwidth");
14012 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14013 TOKEN_STRING_INITIALIZER
14014 (struct cmd_vf_tc_bw_result,
14015 max_bw, "max-bandwidth");
14016 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14017 TOKEN_NUM_INITIALIZER
14018 (struct cmd_vf_tc_bw_result,
14020 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14021 TOKEN_NUM_INITIALIZER
14022 (struct cmd_vf_tc_bw_result,
14024 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14025 TOKEN_NUM_INITIALIZER
14026 (struct cmd_vf_tc_bw_result,
14028 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14029 TOKEN_NUM_INITIALIZER
14030 (struct cmd_vf_tc_bw_result,
14032 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14033 TOKEN_STRING_INITIALIZER
14034 (struct cmd_vf_tc_bw_result,
14036 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14037 TOKEN_NUM_INITIALIZER
14038 (struct cmd_vf_tc_bw_result,
14041 /* VF max bandwidth setting */
14043 cmd_vf_max_bw_parsed(
14044 void *parsed_result,
14045 __attribute__((unused)) struct cmdline *cl,
14046 __attribute__((unused)) void *data)
14048 struct cmd_vf_tc_bw_result *res = parsed_result;
14049 int ret = -ENOTSUP;
14051 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14054 #ifdef RTE_LIBRTE_I40E_PMD
14055 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14056 res->vf_id, res->bw);
14063 printf("invalid vf_id %d or bandwidth %d\n",
14064 res->vf_id, res->bw);
14067 printf("invalid port_id %d\n", res->port_id);
14070 printf("function not implemented\n");
14073 printf("programming error: (%s)\n", strerror(-ret));
14077 cmdline_parse_inst_t cmd_vf_max_bw = {
14078 .f = cmd_vf_max_bw_parsed,
14080 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14082 (void *)&cmd_vf_tc_bw_set,
14083 (void *)&cmd_vf_tc_bw_vf,
14084 (void *)&cmd_vf_tc_bw_tx,
14085 (void *)&cmd_vf_tc_bw_max_bw,
14086 (void *)&cmd_vf_tc_bw_port_id,
14087 (void *)&cmd_vf_tc_bw_vf_id,
14088 (void *)&cmd_vf_tc_bw_bw,
14094 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14099 const char *p, *p0 = str;
14106 p = strchr(p0, '(');
14108 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14112 p0 = strchr(p, ')');
14114 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14118 if (size >= sizeof(s)) {
14119 printf("The string size exceeds the internal buffer size\n");
14122 snprintf(s, sizeof(s), "%.*s", size, p);
14123 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14125 printf("Failed to get the bandwidth list. ");
14129 for (i = 0; i < ret; i++)
14130 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14135 /* TC min bandwidth setting */
14137 cmd_vf_tc_min_bw_parsed(
14138 void *parsed_result,
14139 __attribute__((unused)) struct cmdline *cl,
14140 __attribute__((unused)) void *data)
14142 struct cmd_vf_tc_bw_result *res = parsed_result;
14145 int ret = -ENOTSUP;
14147 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14150 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14154 #ifdef RTE_LIBRTE_I40E_PMD
14155 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14163 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14166 printf("invalid port_id %d\n", res->port_id);
14169 printf("function not implemented\n");
14172 printf("programming error: (%s)\n", strerror(-ret));
14176 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14177 .f = cmd_vf_tc_min_bw_parsed,
14179 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14180 " <bw1, bw2, ...>",
14182 (void *)&cmd_vf_tc_bw_set,
14183 (void *)&cmd_vf_tc_bw_vf,
14184 (void *)&cmd_vf_tc_bw_tc,
14185 (void *)&cmd_vf_tc_bw_tx,
14186 (void *)&cmd_vf_tc_bw_min_bw,
14187 (void *)&cmd_vf_tc_bw_port_id,
14188 (void *)&cmd_vf_tc_bw_vf_id,
14189 (void *)&cmd_vf_tc_bw_bw_list,
14195 cmd_tc_min_bw_parsed(
14196 void *parsed_result,
14197 __attribute__((unused)) struct cmdline *cl,
14198 __attribute__((unused)) void *data)
14200 struct cmd_vf_tc_bw_result *res = parsed_result;
14201 struct rte_port *port;
14204 int ret = -ENOTSUP;
14206 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14209 port = &ports[res->port_id];
14210 /** Check if the port is not started **/
14211 if (port->port_status != RTE_PORT_STOPPED) {
14212 printf("Please stop port %d first\n", res->port_id);
14216 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14220 #ifdef RTE_LIBRTE_IXGBE_PMD
14221 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14228 printf("invalid bandwidth\n");
14231 printf("invalid port_id %d\n", res->port_id);
14234 printf("function not implemented\n");
14237 printf("programming error: (%s)\n", strerror(-ret));
14241 cmdline_parse_inst_t cmd_tc_min_bw = {
14242 .f = cmd_tc_min_bw_parsed,
14244 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14246 (void *)&cmd_vf_tc_bw_set,
14247 (void *)&cmd_vf_tc_bw_tc,
14248 (void *)&cmd_vf_tc_bw_tx,
14249 (void *)&cmd_vf_tc_bw_min_bw,
14250 (void *)&cmd_vf_tc_bw_port_id,
14251 (void *)&cmd_vf_tc_bw_bw_list,
14256 /* TC max bandwidth setting */
14258 cmd_vf_tc_max_bw_parsed(
14259 void *parsed_result,
14260 __attribute__((unused)) struct cmdline *cl,
14261 __attribute__((unused)) void *data)
14263 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 #ifdef RTE_LIBRTE_I40E_PMD
14270 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14271 res->tc_no, res->bw);
14278 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14279 res->vf_id, res->tc_no, res->bw);
14282 printf("invalid port_id %d\n", res->port_id);
14285 printf("function not implemented\n");
14288 printf("programming error: (%s)\n", strerror(-ret));
14292 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14293 .f = cmd_vf_tc_max_bw_parsed,
14295 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14298 (void *)&cmd_vf_tc_bw_set,
14299 (void *)&cmd_vf_tc_bw_vf,
14300 (void *)&cmd_vf_tc_bw_tc,
14301 (void *)&cmd_vf_tc_bw_tx,
14302 (void *)&cmd_vf_tc_bw_max_bw,
14303 (void *)&cmd_vf_tc_bw_port_id,
14304 (void *)&cmd_vf_tc_bw_vf_id,
14305 (void *)&cmd_vf_tc_bw_tc_no,
14306 (void *)&cmd_vf_tc_bw_bw,
14312 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14314 /* *** Set Port default Traffic Management Hierarchy *** */
14315 struct cmd_set_port_tm_hierarchy_default_result {
14316 cmdline_fixed_string_t set;
14317 cmdline_fixed_string_t port;
14318 cmdline_fixed_string_t tm;
14319 cmdline_fixed_string_t hierarchy;
14320 cmdline_fixed_string_t def;
14324 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14325 TOKEN_STRING_INITIALIZER(
14326 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14327 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14328 TOKEN_STRING_INITIALIZER(
14329 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14330 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14331 TOKEN_STRING_INITIALIZER(
14332 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14333 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14334 TOKEN_STRING_INITIALIZER(
14335 struct cmd_set_port_tm_hierarchy_default_result,
14336 hierarchy, "hierarchy");
14337 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14338 TOKEN_STRING_INITIALIZER(
14339 struct cmd_set_port_tm_hierarchy_default_result,
14341 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14342 TOKEN_NUM_INITIALIZER(
14343 struct cmd_set_port_tm_hierarchy_default_result,
14346 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14347 __attribute__((unused)) struct cmdline *cl,
14348 __attribute__((unused)) void *data)
14350 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14351 struct rte_port *p;
14352 portid_t port_id = res->port_id;
14354 if (port_id_is_invalid(port_id, ENABLED_WARN))
14357 p = &ports[port_id];
14360 if (p->softport.tm_flag == 0) {
14361 printf(" tm not enabled on port %u (error)\n", port_id);
14365 /* Forward mode: tm */
14366 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14367 printf(" tm mode not enabled(error)\n");
14371 /* Set the default tm hierarchy */
14372 p->softport.tm.default_hierarchy_enable = 1;
14375 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14376 .f = cmd_set_port_tm_hierarchy_default_parsed,
14378 .help_str = "set port tm hierarchy default <port_id>",
14380 (void *)&cmd_set_port_tm_hierarchy_default_set,
14381 (void *)&cmd_set_port_tm_hierarchy_default_port,
14382 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14383 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14384 (void *)&cmd_set_port_tm_hierarchy_default_default,
14385 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14391 /* Strict link priority scheduling mode setting */
14393 cmd_strict_link_prio_parsed(
14394 void *parsed_result,
14395 __attribute__((unused)) struct cmdline *cl,
14396 __attribute__((unused)) void *data)
14398 struct cmd_vf_tc_bw_result *res = parsed_result;
14399 int ret = -ENOTSUP;
14401 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14404 #ifdef RTE_LIBRTE_I40E_PMD
14405 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14412 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14415 printf("invalid port_id %d\n", res->port_id);
14418 printf("function not implemented\n");
14421 printf("programming error: (%s)\n", strerror(-ret));
14425 cmdline_parse_inst_t cmd_strict_link_prio = {
14426 .f = cmd_strict_link_prio_parsed,
14428 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14430 (void *)&cmd_vf_tc_bw_set,
14431 (void *)&cmd_vf_tc_bw_tx,
14432 (void *)&cmd_vf_tc_bw_strict_link_prio,
14433 (void *)&cmd_vf_tc_bw_port_id,
14434 (void *)&cmd_vf_tc_bw_tc_map,
14439 /* Load dynamic device personalization*/
14440 struct cmd_ddp_add_result {
14441 cmdline_fixed_string_t ddp;
14442 cmdline_fixed_string_t add;
14447 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14448 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14449 cmdline_parse_token_string_t cmd_ddp_add_add =
14450 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14451 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14452 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14453 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14454 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14457 cmd_ddp_add_parsed(
14458 void *parsed_result,
14459 __attribute__((unused)) struct cmdline *cl,
14460 __attribute__((unused)) void *data)
14462 struct cmd_ddp_add_result *res = parsed_result;
14468 int ret = -ENOTSUP;
14470 if (res->port_id > nb_ports) {
14471 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14475 if (!all_ports_stopped()) {
14476 printf("Please stop all ports first\n");
14480 filepath = strdup(res->filepath);
14481 if (filepath == NULL) {
14482 printf("Failed to allocate memory\n");
14485 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14487 buff = open_file(file_fld[0], &size);
14489 free((void *)filepath);
14493 #ifdef RTE_LIBRTE_I40E_PMD
14494 if (ret == -ENOTSUP)
14495 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14497 RTE_PMD_I40E_PKG_OP_WR_ADD);
14500 if (ret == -EEXIST)
14501 printf("Profile has already existed.\n");
14503 printf("Failed to load profile.\n");
14504 else if (file_num == 2)
14505 save_file(file_fld[1], buff, size);
14508 free((void *)filepath);
14511 cmdline_parse_inst_t cmd_ddp_add = {
14512 .f = cmd_ddp_add_parsed,
14514 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14516 (void *)&cmd_ddp_add_ddp,
14517 (void *)&cmd_ddp_add_add,
14518 (void *)&cmd_ddp_add_port_id,
14519 (void *)&cmd_ddp_add_filepath,
14524 /* Delete dynamic device personalization*/
14525 struct cmd_ddp_del_result {
14526 cmdline_fixed_string_t ddp;
14527 cmdline_fixed_string_t del;
14532 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14533 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14534 cmdline_parse_token_string_t cmd_ddp_del_del =
14535 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14536 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14537 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14538 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14539 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14542 cmd_ddp_del_parsed(
14543 void *parsed_result,
14544 __attribute__((unused)) struct cmdline *cl,
14545 __attribute__((unused)) void *data)
14547 struct cmd_ddp_del_result *res = parsed_result;
14550 int ret = -ENOTSUP;
14552 if (res->port_id > nb_ports) {
14553 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14557 if (!all_ports_stopped()) {
14558 printf("Please stop all ports first\n");
14562 buff = open_file(res->filepath, &size);
14566 #ifdef RTE_LIBRTE_I40E_PMD
14567 if (ret == -ENOTSUP)
14568 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14570 RTE_PMD_I40E_PKG_OP_WR_DEL);
14573 if (ret == -EACCES)
14574 printf("Profile does not exist.\n");
14576 printf("Failed to delete profile.\n");
14581 cmdline_parse_inst_t cmd_ddp_del = {
14582 .f = cmd_ddp_del_parsed,
14584 .help_str = "ddp del <port_id> <backup_profile_path>",
14586 (void *)&cmd_ddp_del_ddp,
14587 (void *)&cmd_ddp_del_del,
14588 (void *)&cmd_ddp_del_port_id,
14589 (void *)&cmd_ddp_del_filepath,
14594 /* Get dynamic device personalization profile info */
14595 struct cmd_ddp_info_result {
14596 cmdline_fixed_string_t ddp;
14597 cmdline_fixed_string_t get;
14598 cmdline_fixed_string_t info;
14602 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14603 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14604 cmdline_parse_token_string_t cmd_ddp_info_get =
14605 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14606 cmdline_parse_token_string_t cmd_ddp_info_info =
14607 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14608 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14609 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14612 cmd_ddp_info_parsed(
14613 void *parsed_result,
14614 __attribute__((unused)) struct cmdline *cl,
14615 __attribute__((unused)) void *data)
14617 struct cmd_ddp_info_result *res = parsed_result;
14620 int ret = -ENOTSUP;
14621 #ifdef RTE_LIBRTE_I40E_PMD
14624 uint32_t buff_size = 0;
14625 struct rte_pmd_i40e_profile_info info;
14626 uint32_t dev_num = 0;
14627 struct rte_pmd_i40e_ddp_device_id *devs;
14628 uint32_t proto_num = 0;
14629 struct rte_pmd_i40e_proto_info *proto = NULL;
14630 uint32_t pctype_num = 0;
14631 struct rte_pmd_i40e_ptype_info *pctype;
14632 uint32_t ptype_num = 0;
14633 struct rte_pmd_i40e_ptype_info *ptype;
14638 pkg = open_file(res->filepath, &pkg_size);
14642 #ifdef RTE_LIBRTE_I40E_PMD
14643 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14644 (uint8_t *)&info, sizeof(info),
14645 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14647 printf("Global Track id: 0x%x\n", info.track_id);
14648 printf("Global Version: %d.%d.%d.%d\n",
14649 info.version.major,
14650 info.version.minor,
14651 info.version.update,
14652 info.version.draft);
14653 printf("Global Package name: %s\n\n", info.name);
14656 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14657 (uint8_t *)&info, sizeof(info),
14658 RTE_PMD_I40E_PKG_INFO_HEADER);
14660 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14661 printf("i40e Profile Version: %d.%d.%d.%d\n",
14662 info.version.major,
14663 info.version.minor,
14664 info.version.update,
14665 info.version.draft);
14666 printf("i40e Profile name: %s\n\n", info.name);
14669 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14670 (uint8_t *)&buff_size, sizeof(buff_size),
14671 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14672 if (!ret && buff_size) {
14673 buff = (uint8_t *)malloc(buff_size);
14675 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14677 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14679 printf("Package Notes:\n%s\n\n", buff);
14684 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14685 (uint8_t *)&dev_num, sizeof(dev_num),
14686 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14687 if (!ret && dev_num) {
14688 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14689 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14691 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14692 (uint8_t *)devs, buff_size,
14693 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14695 printf("List of supported devices:\n");
14696 for (i = 0; i < dev_num; i++) {
14697 printf(" %04X:%04X %04X:%04X\n",
14698 devs[i].vendor_dev_id >> 16,
14699 devs[i].vendor_dev_id & 0xFFFF,
14700 devs[i].sub_vendor_dev_id >> 16,
14701 devs[i].sub_vendor_dev_id & 0xFFFF);
14709 /* get information about protocols and packet types */
14710 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14711 (uint8_t *)&proto_num, sizeof(proto_num),
14712 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14713 if (ret || !proto_num)
14714 goto no_print_return;
14716 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14717 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14719 goto no_print_return;
14721 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14723 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14725 printf("List of used protocols:\n");
14726 for (i = 0; i < proto_num; i++)
14727 printf(" %2u: %s\n", proto[i].proto_id,
14731 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14732 (uint8_t *)&pctype_num, sizeof(pctype_num),
14733 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14734 if (ret || !pctype_num)
14735 goto no_print_pctypes;
14737 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14738 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14740 goto no_print_pctypes;
14742 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14744 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14747 goto no_print_pctypes;
14750 printf("List of defined packet classification types:\n");
14751 for (i = 0; i < pctype_num; i++) {
14752 printf(" %2u:", pctype[i].ptype_id);
14753 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14754 proto_id = pctype[i].protocols[j];
14755 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14756 for (n = 0; n < proto_num; n++) {
14757 if (proto[n].proto_id == proto_id) {
14758 printf(" %s", proto[n].name);
14771 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14773 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14774 if (ret || !ptype_num)
14775 goto no_print_return;
14777 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14778 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14780 goto no_print_return;
14782 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14784 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14787 goto no_print_return;
14789 printf("List of defined packet types:\n");
14790 for (i = 0; i < ptype_num; i++) {
14791 printf(" %2u:", ptype[i].ptype_id);
14792 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14793 proto_id = ptype[i].protocols[j];
14794 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14795 for (n = 0; n < proto_num; n++) {
14796 if (proto[n].proto_id == proto_id) {
14797 printf(" %s", proto[n].name);
14813 if (ret == -ENOTSUP)
14814 printf("Function not supported in PMD driver\n");
14818 cmdline_parse_inst_t cmd_ddp_get_info = {
14819 .f = cmd_ddp_info_parsed,
14821 .help_str = "ddp get info <profile_path>",
14823 (void *)&cmd_ddp_info_ddp,
14824 (void *)&cmd_ddp_info_get,
14825 (void *)&cmd_ddp_info_info,
14826 (void *)&cmd_ddp_info_filepath,
14831 /* Get dynamic device personalization profile info list*/
14832 #define PROFILE_INFO_SIZE 48
14833 #define MAX_PROFILE_NUM 16
14835 struct cmd_ddp_get_list_result {
14836 cmdline_fixed_string_t ddp;
14837 cmdline_fixed_string_t get;
14838 cmdline_fixed_string_t list;
14842 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14843 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14844 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14845 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14846 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14847 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14848 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14849 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14852 cmd_ddp_get_list_parsed(
14853 void *parsed_result,
14854 __attribute__((unused)) struct cmdline *cl,
14855 __attribute__((unused)) void *data)
14857 struct cmd_ddp_get_list_result *res = parsed_result;
14858 #ifdef RTE_LIBRTE_I40E_PMD
14859 struct rte_pmd_i40e_profile_list *p_list;
14860 struct rte_pmd_i40e_profile_info *p_info;
14865 int ret = -ENOTSUP;
14867 if (res->port_id > nb_ports) {
14868 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14872 #ifdef RTE_LIBRTE_I40E_PMD
14873 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14874 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14876 printf("%s: Failed to malloc buffer\n", __func__);
14878 if (ret == -ENOTSUP)
14879 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14880 (uint8_t *)p_list, size);
14883 p_num = p_list->p_count;
14884 printf("Profile number is: %d\n\n", p_num);
14886 for (i = 0; i < p_num; i++) {
14887 p_info = &p_list->p_info[i];
14888 printf("Profile %d:\n", i);
14889 printf("Track id: 0x%x\n", p_info->track_id);
14890 printf("Version: %d.%d.%d.%d\n",
14891 p_info->version.major,
14892 p_info->version.minor,
14893 p_info->version.update,
14894 p_info->version.draft);
14895 printf("Profile name: %s\n\n", p_info->name);
14903 printf("Failed to get ddp list\n");
14906 cmdline_parse_inst_t cmd_ddp_get_list = {
14907 .f = cmd_ddp_get_list_parsed,
14909 .help_str = "ddp get list <port_id>",
14911 (void *)&cmd_ddp_get_list_ddp,
14912 (void *)&cmd_ddp_get_list_get,
14913 (void *)&cmd_ddp_get_list_list,
14914 (void *)&cmd_ddp_get_list_port_id,
14919 /* Configure input set */
14920 struct cmd_cfg_input_set_result {
14921 cmdline_fixed_string_t port;
14922 cmdline_fixed_string_t cfg;
14924 cmdline_fixed_string_t pctype;
14926 cmdline_fixed_string_t inset_type;
14927 cmdline_fixed_string_t opt;
14928 cmdline_fixed_string_t field;
14933 cmd_cfg_input_set_parsed(
14934 void *parsed_result,
14935 __attribute__((unused)) struct cmdline *cl,
14936 __attribute__((unused)) void *data)
14938 struct cmd_cfg_input_set_result *res = parsed_result;
14939 #ifdef RTE_LIBRTE_I40E_PMD
14940 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14941 struct rte_pmd_i40e_inset inset;
14943 int ret = -ENOTSUP;
14945 if (res->port_id > nb_ports) {
14946 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14950 if (!all_ports_stopped()) {
14951 printf("Please stop all ports first\n");
14955 #ifdef RTE_LIBRTE_I40E_PMD
14956 if (!strcmp(res->inset_type, "hash_inset"))
14957 inset_type = INSET_HASH;
14958 else if (!strcmp(res->inset_type, "fdir_inset"))
14959 inset_type = INSET_FDIR;
14960 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14961 inset_type = INSET_FDIR_FLX;
14962 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14963 &inset, inset_type);
14965 printf("Failed to get input set.\n");
14969 if (!strcmp(res->opt, "get")) {
14970 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14973 printf("Field index %d is enabled.\n", res->field_idx);
14975 printf("Field index %d is disabled.\n", res->field_idx);
14977 } else if (!strcmp(res->opt, "set"))
14978 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14980 else if (!strcmp(res->opt, "clear"))
14981 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14984 printf("Failed to configure input set field.\n");
14988 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14989 &inset, inset_type);
14991 printf("Failed to set input set.\n");
14996 if (ret == -ENOTSUP)
14997 printf("Function not supported\n");
15000 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15001 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15003 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15004 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15006 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15007 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15009 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15010 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15012 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15013 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15015 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15016 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15018 "hash_inset#fdir_inset#fdir_flx_inset");
15019 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15020 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15021 opt, "get#set#clear");
15022 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15023 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15025 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15026 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15029 cmdline_parse_inst_t cmd_cfg_input_set = {
15030 .f = cmd_cfg_input_set_parsed,
15032 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15033 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15035 (void *)&cmd_cfg_input_set_port,
15036 (void *)&cmd_cfg_input_set_cfg,
15037 (void *)&cmd_cfg_input_set_port_id,
15038 (void *)&cmd_cfg_input_set_pctype,
15039 (void *)&cmd_cfg_input_set_pctype_id,
15040 (void *)&cmd_cfg_input_set_inset_type,
15041 (void *)&cmd_cfg_input_set_opt,
15042 (void *)&cmd_cfg_input_set_field,
15043 (void *)&cmd_cfg_input_set_field_idx,
15048 /* Clear input set */
15049 struct cmd_clear_input_set_result {
15050 cmdline_fixed_string_t port;
15051 cmdline_fixed_string_t cfg;
15053 cmdline_fixed_string_t pctype;
15055 cmdline_fixed_string_t inset_type;
15056 cmdline_fixed_string_t clear;
15057 cmdline_fixed_string_t all;
15061 cmd_clear_input_set_parsed(
15062 void *parsed_result,
15063 __attribute__((unused)) struct cmdline *cl,
15064 __attribute__((unused)) void *data)
15066 struct cmd_clear_input_set_result *res = parsed_result;
15067 #ifdef RTE_LIBRTE_I40E_PMD
15068 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15069 struct rte_pmd_i40e_inset inset;
15071 int ret = -ENOTSUP;
15073 if (res->port_id > nb_ports) {
15074 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
15078 if (!all_ports_stopped()) {
15079 printf("Please stop all ports first\n");
15083 #ifdef RTE_LIBRTE_I40E_PMD
15084 if (!strcmp(res->inset_type, "hash_inset"))
15085 inset_type = INSET_HASH;
15086 else if (!strcmp(res->inset_type, "fdir_inset"))
15087 inset_type = INSET_FDIR;
15088 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15089 inset_type = INSET_FDIR_FLX;
15091 memset(&inset, 0, sizeof(inset));
15093 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15094 &inset, inset_type);
15096 printf("Failed to clear input set.\n");
15102 if (ret == -ENOTSUP)
15103 printf("Function not supported\n");
15106 cmdline_parse_token_string_t cmd_clear_input_set_port =
15107 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15109 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15110 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15112 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15113 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15115 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15116 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15118 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15119 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15121 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15122 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15124 "hash_inset#fdir_inset#fdir_flx_inset");
15125 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15126 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15128 cmdline_parse_token_string_t cmd_clear_input_set_all =
15129 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15132 cmdline_parse_inst_t cmd_clear_input_set = {
15133 .f = cmd_clear_input_set_parsed,
15135 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15136 "fdir_inset|fdir_flx_inset clear all",
15138 (void *)&cmd_clear_input_set_port,
15139 (void *)&cmd_clear_input_set_cfg,
15140 (void *)&cmd_clear_input_set_port_id,
15141 (void *)&cmd_clear_input_set_pctype,
15142 (void *)&cmd_clear_input_set_pctype_id,
15143 (void *)&cmd_clear_input_set_inset_type,
15144 (void *)&cmd_clear_input_set_clear,
15145 (void *)&cmd_clear_input_set_all,
15150 /* show vf stats */
15152 /* Common result structure for show vf stats */
15153 struct cmd_show_vf_stats_result {
15154 cmdline_fixed_string_t show;
15155 cmdline_fixed_string_t vf;
15156 cmdline_fixed_string_t stats;
15161 /* Common CLI fields show vf stats*/
15162 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15163 TOKEN_STRING_INITIALIZER
15164 (struct cmd_show_vf_stats_result,
15166 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15167 TOKEN_STRING_INITIALIZER
15168 (struct cmd_show_vf_stats_result,
15170 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15171 TOKEN_STRING_INITIALIZER
15172 (struct cmd_show_vf_stats_result,
15174 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15175 TOKEN_NUM_INITIALIZER
15176 (struct cmd_show_vf_stats_result,
15178 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15179 TOKEN_NUM_INITIALIZER
15180 (struct cmd_show_vf_stats_result,
15184 cmd_show_vf_stats_parsed(
15185 void *parsed_result,
15186 __attribute__((unused)) struct cmdline *cl,
15187 __attribute__((unused)) void *data)
15189 struct cmd_show_vf_stats_result *res = parsed_result;
15190 struct rte_eth_stats stats;
15191 int ret = -ENOTSUP;
15192 static const char *nic_stats_border = "########################";
15194 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15197 memset(&stats, 0, sizeof(stats));
15199 #ifdef RTE_LIBRTE_I40E_PMD
15200 if (ret == -ENOTSUP)
15201 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15205 #ifdef RTE_LIBRTE_BNXT_PMD
15206 if (ret == -ENOTSUP)
15207 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15216 printf("invalid vf_id %d\n", res->vf_id);
15219 printf("invalid port_id %d\n", res->port_id);
15222 printf("function not implemented\n");
15225 printf("programming error: (%s)\n", strerror(-ret));
15228 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15229 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15231 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15233 stats.ipackets, stats.imissed, stats.ibytes);
15234 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15235 printf(" RX-nombuf: %-10"PRIu64"\n",
15237 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15239 stats.opackets, stats.oerrors, stats.obytes);
15241 printf(" %s############################%s\n",
15242 nic_stats_border, nic_stats_border);
15245 cmdline_parse_inst_t cmd_show_vf_stats = {
15246 .f = cmd_show_vf_stats_parsed,
15248 .help_str = "show vf stats <port_id> <vf_id>",
15250 (void *)&cmd_show_vf_stats_show,
15251 (void *)&cmd_show_vf_stats_vf,
15252 (void *)&cmd_show_vf_stats_stats,
15253 (void *)&cmd_show_vf_stats_port_id,
15254 (void *)&cmd_show_vf_stats_vf_id,
15259 /* clear vf stats */
15261 /* Common result structure for clear vf stats */
15262 struct cmd_clear_vf_stats_result {
15263 cmdline_fixed_string_t clear;
15264 cmdline_fixed_string_t vf;
15265 cmdline_fixed_string_t stats;
15270 /* Common CLI fields clear vf stats*/
15271 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15272 TOKEN_STRING_INITIALIZER
15273 (struct cmd_clear_vf_stats_result,
15275 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15276 TOKEN_STRING_INITIALIZER
15277 (struct cmd_clear_vf_stats_result,
15279 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15280 TOKEN_STRING_INITIALIZER
15281 (struct cmd_clear_vf_stats_result,
15283 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15284 TOKEN_NUM_INITIALIZER
15285 (struct cmd_clear_vf_stats_result,
15287 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15288 TOKEN_NUM_INITIALIZER
15289 (struct cmd_clear_vf_stats_result,
15293 cmd_clear_vf_stats_parsed(
15294 void *parsed_result,
15295 __attribute__((unused)) struct cmdline *cl,
15296 __attribute__((unused)) void *data)
15298 struct cmd_clear_vf_stats_result *res = parsed_result;
15299 int ret = -ENOTSUP;
15301 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15304 #ifdef RTE_LIBRTE_I40E_PMD
15305 if (ret == -ENOTSUP)
15306 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15309 #ifdef RTE_LIBRTE_BNXT_PMD
15310 if (ret == -ENOTSUP)
15311 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15319 printf("invalid vf_id %d\n", res->vf_id);
15322 printf("invalid port_id %d\n", res->port_id);
15325 printf("function not implemented\n");
15328 printf("programming error: (%s)\n", strerror(-ret));
15332 cmdline_parse_inst_t cmd_clear_vf_stats = {
15333 .f = cmd_clear_vf_stats_parsed,
15335 .help_str = "clear vf stats <port_id> <vf_id>",
15337 (void *)&cmd_clear_vf_stats_clear,
15338 (void *)&cmd_clear_vf_stats_vf,
15339 (void *)&cmd_clear_vf_stats_stats,
15340 (void *)&cmd_clear_vf_stats_port_id,
15341 (void *)&cmd_clear_vf_stats_vf_id,
15346 /* port config pctype mapping reset */
15348 /* Common result structure for port config pctype mapping reset */
15349 struct cmd_pctype_mapping_reset_result {
15350 cmdline_fixed_string_t port;
15351 cmdline_fixed_string_t config;
15353 cmdline_fixed_string_t pctype;
15354 cmdline_fixed_string_t mapping;
15355 cmdline_fixed_string_t reset;
15358 /* Common CLI fields for port config pctype mapping reset*/
15359 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15360 TOKEN_STRING_INITIALIZER
15361 (struct cmd_pctype_mapping_reset_result,
15363 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15364 TOKEN_STRING_INITIALIZER
15365 (struct cmd_pctype_mapping_reset_result,
15367 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15368 TOKEN_NUM_INITIALIZER
15369 (struct cmd_pctype_mapping_reset_result,
15371 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15372 TOKEN_STRING_INITIALIZER
15373 (struct cmd_pctype_mapping_reset_result,
15375 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15376 TOKEN_STRING_INITIALIZER
15377 (struct cmd_pctype_mapping_reset_result,
15378 mapping, "mapping");
15379 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15380 TOKEN_STRING_INITIALIZER
15381 (struct cmd_pctype_mapping_reset_result,
15385 cmd_pctype_mapping_reset_parsed(
15386 void *parsed_result,
15387 __attribute__((unused)) struct cmdline *cl,
15388 __attribute__((unused)) void *data)
15390 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15391 int ret = -ENOTSUP;
15393 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15396 #ifdef RTE_LIBRTE_I40E_PMD
15397 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15404 printf("invalid port_id %d\n", res->port_id);
15407 printf("function not implemented\n");
15410 printf("programming error: (%s)\n", strerror(-ret));
15414 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15415 .f = cmd_pctype_mapping_reset_parsed,
15417 .help_str = "port config <port_id> pctype mapping reset",
15419 (void *)&cmd_pctype_mapping_reset_port,
15420 (void *)&cmd_pctype_mapping_reset_config,
15421 (void *)&cmd_pctype_mapping_reset_port_id,
15422 (void *)&cmd_pctype_mapping_reset_pctype,
15423 (void *)&cmd_pctype_mapping_reset_mapping,
15424 (void *)&cmd_pctype_mapping_reset_reset,
15429 /* show port pctype mapping */
15431 /* Common result structure for show port pctype mapping */
15432 struct cmd_pctype_mapping_get_result {
15433 cmdline_fixed_string_t show;
15434 cmdline_fixed_string_t port;
15436 cmdline_fixed_string_t pctype;
15437 cmdline_fixed_string_t mapping;
15440 /* Common CLI fields for pctype mapping get */
15441 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15442 TOKEN_STRING_INITIALIZER
15443 (struct cmd_pctype_mapping_get_result,
15445 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15446 TOKEN_STRING_INITIALIZER
15447 (struct cmd_pctype_mapping_get_result,
15449 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15450 TOKEN_NUM_INITIALIZER
15451 (struct cmd_pctype_mapping_get_result,
15453 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15454 TOKEN_STRING_INITIALIZER
15455 (struct cmd_pctype_mapping_get_result,
15457 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15458 TOKEN_STRING_INITIALIZER
15459 (struct cmd_pctype_mapping_get_result,
15460 mapping, "mapping");
15463 cmd_pctype_mapping_get_parsed(
15464 void *parsed_result,
15465 __attribute__((unused)) struct cmdline *cl,
15466 __attribute__((unused)) void *data)
15468 struct cmd_pctype_mapping_get_result *res = parsed_result;
15469 int ret = -ENOTSUP;
15470 #ifdef RTE_LIBRTE_I40E_PMD
15471 struct rte_pmd_i40e_flow_type_mapping
15472 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15473 int i, j, first_pctype;
15476 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15479 #ifdef RTE_LIBRTE_I40E_PMD
15480 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15487 printf("invalid port_id %d\n", res->port_id);
15490 printf("function not implemented\n");
15493 printf("programming error: (%s)\n", strerror(-ret));
15497 #ifdef RTE_LIBRTE_I40E_PMD
15498 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15499 if (mapping[i].pctype != 0ULL) {
15502 printf("pctype: ");
15503 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15504 if (mapping[i].pctype & (1ULL << j)) {
15505 printf(first_pctype ?
15506 "%02d" : ",%02d", j);
15510 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15516 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15517 .f = cmd_pctype_mapping_get_parsed,
15519 .help_str = "show port <port_id> pctype mapping",
15521 (void *)&cmd_pctype_mapping_get_show,
15522 (void *)&cmd_pctype_mapping_get_port,
15523 (void *)&cmd_pctype_mapping_get_port_id,
15524 (void *)&cmd_pctype_mapping_get_pctype,
15525 (void *)&cmd_pctype_mapping_get_mapping,
15530 /* port config pctype mapping update */
15532 /* Common result structure for port config pctype mapping update */
15533 struct cmd_pctype_mapping_update_result {
15534 cmdline_fixed_string_t port;
15535 cmdline_fixed_string_t config;
15537 cmdline_fixed_string_t pctype;
15538 cmdline_fixed_string_t mapping;
15539 cmdline_fixed_string_t update;
15540 cmdline_fixed_string_t pctype_list;
15541 uint16_t flow_type;
15544 /* Common CLI fields for pctype mapping update*/
15545 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15546 TOKEN_STRING_INITIALIZER
15547 (struct cmd_pctype_mapping_update_result,
15549 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15550 TOKEN_STRING_INITIALIZER
15551 (struct cmd_pctype_mapping_update_result,
15553 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15554 TOKEN_NUM_INITIALIZER
15555 (struct cmd_pctype_mapping_update_result,
15557 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15558 TOKEN_STRING_INITIALIZER
15559 (struct cmd_pctype_mapping_update_result,
15561 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15562 TOKEN_STRING_INITIALIZER
15563 (struct cmd_pctype_mapping_update_result,
15564 mapping, "mapping");
15565 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15566 TOKEN_STRING_INITIALIZER
15567 (struct cmd_pctype_mapping_update_result,
15569 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15570 TOKEN_STRING_INITIALIZER
15571 (struct cmd_pctype_mapping_update_result,
15572 pctype_list, NULL);
15573 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15574 TOKEN_NUM_INITIALIZER
15575 (struct cmd_pctype_mapping_update_result,
15576 flow_type, UINT16);
15579 cmd_pctype_mapping_update_parsed(
15580 void *parsed_result,
15581 __attribute__((unused)) struct cmdline *cl,
15582 __attribute__((unused)) void *data)
15584 struct cmd_pctype_mapping_update_result *res = parsed_result;
15585 int ret = -ENOTSUP;
15586 #ifdef RTE_LIBRTE_I40E_PMD
15587 struct rte_pmd_i40e_flow_type_mapping mapping;
15589 unsigned int nb_item;
15590 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15596 #ifdef RTE_LIBRTE_I40E_PMD
15597 nb_item = parse_item_list(res->pctype_list, "pctypes",
15598 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15599 mapping.flow_type = res->flow_type;
15600 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15601 mapping.pctype |= (1ULL << pctype_list[i]);
15602 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15612 printf("invalid pctype or flow type\n");
15615 printf("invalid port_id %d\n", res->port_id);
15618 printf("function not implemented\n");
15621 printf("programming error: (%s)\n", strerror(-ret));
15625 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15626 .f = cmd_pctype_mapping_update_parsed,
15628 .help_str = "port config <port_id> pctype mapping update"
15629 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15631 (void *)&cmd_pctype_mapping_update_port,
15632 (void *)&cmd_pctype_mapping_update_config,
15633 (void *)&cmd_pctype_mapping_update_port_id,
15634 (void *)&cmd_pctype_mapping_update_pctype,
15635 (void *)&cmd_pctype_mapping_update_mapping,
15636 (void *)&cmd_pctype_mapping_update_update,
15637 (void *)&cmd_pctype_mapping_update_pc_type,
15638 (void *)&cmd_pctype_mapping_update_flow_type,
15643 /* ptype mapping get */
15645 /* Common result structure for ptype mapping get */
15646 struct cmd_ptype_mapping_get_result {
15647 cmdline_fixed_string_t ptype;
15648 cmdline_fixed_string_t mapping;
15649 cmdline_fixed_string_t get;
15651 uint8_t valid_only;
15654 /* Common CLI fields for ptype mapping get */
15655 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15656 TOKEN_STRING_INITIALIZER
15657 (struct cmd_ptype_mapping_get_result,
15659 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15660 TOKEN_STRING_INITIALIZER
15661 (struct cmd_ptype_mapping_get_result,
15662 mapping, "mapping");
15663 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15664 TOKEN_STRING_INITIALIZER
15665 (struct cmd_ptype_mapping_get_result,
15667 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15668 TOKEN_NUM_INITIALIZER
15669 (struct cmd_ptype_mapping_get_result,
15671 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15672 TOKEN_NUM_INITIALIZER
15673 (struct cmd_ptype_mapping_get_result,
15674 valid_only, UINT8);
15677 cmd_ptype_mapping_get_parsed(
15678 void *parsed_result,
15679 __attribute__((unused)) struct cmdline *cl,
15680 __attribute__((unused)) void *data)
15682 struct cmd_ptype_mapping_get_result *res = parsed_result;
15683 int ret = -ENOTSUP;
15684 #ifdef RTE_LIBRTE_I40E_PMD
15685 int max_ptype_num = 256;
15686 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15691 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15694 #ifdef RTE_LIBRTE_I40E_PMD
15695 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15706 printf("invalid port_id %d\n", res->port_id);
15709 printf("function not implemented\n");
15712 printf("programming error: (%s)\n", strerror(-ret));
15715 #ifdef RTE_LIBRTE_I40E_PMD
15717 for (i = 0; i < count; i++)
15718 printf("%3d\t0x%08x\n",
15719 mapping[i].hw_ptype, mapping[i].sw_ptype);
15724 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15725 .f = cmd_ptype_mapping_get_parsed,
15727 .help_str = "ptype mapping get <port_id> <valid_only>",
15729 (void *)&cmd_ptype_mapping_get_ptype,
15730 (void *)&cmd_ptype_mapping_get_mapping,
15731 (void *)&cmd_ptype_mapping_get_get,
15732 (void *)&cmd_ptype_mapping_get_port_id,
15733 (void *)&cmd_ptype_mapping_get_valid_only,
15738 /* ptype mapping replace */
15740 /* Common result structure for ptype mapping replace */
15741 struct cmd_ptype_mapping_replace_result {
15742 cmdline_fixed_string_t ptype;
15743 cmdline_fixed_string_t mapping;
15744 cmdline_fixed_string_t replace;
15751 /* Common CLI fields for ptype mapping replace */
15752 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15753 TOKEN_STRING_INITIALIZER
15754 (struct cmd_ptype_mapping_replace_result,
15756 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15757 TOKEN_STRING_INITIALIZER
15758 (struct cmd_ptype_mapping_replace_result,
15759 mapping, "mapping");
15760 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15761 TOKEN_STRING_INITIALIZER
15762 (struct cmd_ptype_mapping_replace_result,
15763 replace, "replace");
15764 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15765 TOKEN_NUM_INITIALIZER
15766 (struct cmd_ptype_mapping_replace_result,
15768 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15769 TOKEN_NUM_INITIALIZER
15770 (struct cmd_ptype_mapping_replace_result,
15772 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15773 TOKEN_NUM_INITIALIZER
15774 (struct cmd_ptype_mapping_replace_result,
15776 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15777 TOKEN_NUM_INITIALIZER
15778 (struct cmd_ptype_mapping_replace_result,
15782 cmd_ptype_mapping_replace_parsed(
15783 void *parsed_result,
15784 __attribute__((unused)) struct cmdline *cl,
15785 __attribute__((unused)) void *data)
15787 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15788 int ret = -ENOTSUP;
15790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15793 #ifdef RTE_LIBRTE_I40E_PMD
15794 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15804 printf("invalid ptype 0x%8x or 0x%8x\n",
15805 res->target, res->pkt_type);
15808 printf("invalid port_id %d\n", res->port_id);
15811 printf("function not implemented\n");
15814 printf("programming error: (%s)\n", strerror(-ret));
15818 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15819 .f = cmd_ptype_mapping_replace_parsed,
15822 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15824 (void *)&cmd_ptype_mapping_replace_ptype,
15825 (void *)&cmd_ptype_mapping_replace_mapping,
15826 (void *)&cmd_ptype_mapping_replace_replace,
15827 (void *)&cmd_ptype_mapping_replace_port_id,
15828 (void *)&cmd_ptype_mapping_replace_target,
15829 (void *)&cmd_ptype_mapping_replace_mask,
15830 (void *)&cmd_ptype_mapping_replace_pkt_type,
15835 /* ptype mapping reset */
15837 /* Common result structure for ptype mapping reset */
15838 struct cmd_ptype_mapping_reset_result {
15839 cmdline_fixed_string_t ptype;
15840 cmdline_fixed_string_t mapping;
15841 cmdline_fixed_string_t reset;
15845 /* Common CLI fields for ptype mapping reset*/
15846 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15847 TOKEN_STRING_INITIALIZER
15848 (struct cmd_ptype_mapping_reset_result,
15850 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15851 TOKEN_STRING_INITIALIZER
15852 (struct cmd_ptype_mapping_reset_result,
15853 mapping, "mapping");
15854 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15855 TOKEN_STRING_INITIALIZER
15856 (struct cmd_ptype_mapping_reset_result,
15858 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15859 TOKEN_NUM_INITIALIZER
15860 (struct cmd_ptype_mapping_reset_result,
15864 cmd_ptype_mapping_reset_parsed(
15865 void *parsed_result,
15866 __attribute__((unused)) struct cmdline *cl,
15867 __attribute__((unused)) void *data)
15869 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15870 int ret = -ENOTSUP;
15872 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15875 #ifdef RTE_LIBRTE_I40E_PMD
15876 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15883 printf("invalid port_id %d\n", res->port_id);
15886 printf("function not implemented\n");
15889 printf("programming error: (%s)\n", strerror(-ret));
15893 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15894 .f = cmd_ptype_mapping_reset_parsed,
15896 .help_str = "ptype mapping reset <port_id>",
15898 (void *)&cmd_ptype_mapping_reset_ptype,
15899 (void *)&cmd_ptype_mapping_reset_mapping,
15900 (void *)&cmd_ptype_mapping_reset_reset,
15901 (void *)&cmd_ptype_mapping_reset_port_id,
15906 /* ptype mapping update */
15908 /* Common result structure for ptype mapping update */
15909 struct cmd_ptype_mapping_update_result {
15910 cmdline_fixed_string_t ptype;
15911 cmdline_fixed_string_t mapping;
15912 cmdline_fixed_string_t reset;
15918 /* Common CLI fields for ptype mapping update*/
15919 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15920 TOKEN_STRING_INITIALIZER
15921 (struct cmd_ptype_mapping_update_result,
15923 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15924 TOKEN_STRING_INITIALIZER
15925 (struct cmd_ptype_mapping_update_result,
15926 mapping, "mapping");
15927 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15928 TOKEN_STRING_INITIALIZER
15929 (struct cmd_ptype_mapping_update_result,
15931 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15932 TOKEN_NUM_INITIALIZER
15933 (struct cmd_ptype_mapping_update_result,
15935 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15936 TOKEN_NUM_INITIALIZER
15937 (struct cmd_ptype_mapping_update_result,
15939 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15940 TOKEN_NUM_INITIALIZER
15941 (struct cmd_ptype_mapping_update_result,
15945 cmd_ptype_mapping_update_parsed(
15946 void *parsed_result,
15947 __attribute__((unused)) struct cmdline *cl,
15948 __attribute__((unused)) void *data)
15950 struct cmd_ptype_mapping_update_result *res = parsed_result;
15951 int ret = -ENOTSUP;
15952 #ifdef RTE_LIBRTE_I40E_PMD
15953 struct rte_pmd_i40e_ptype_mapping mapping;
15955 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15958 #ifdef RTE_LIBRTE_I40E_PMD
15959 mapping.hw_ptype = res->hw_ptype;
15960 mapping.sw_ptype = res->sw_ptype;
15961 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15971 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15974 printf("invalid port_id %d\n", res->port_id);
15977 printf("function not implemented\n");
15980 printf("programming error: (%s)\n", strerror(-ret));
15984 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15985 .f = cmd_ptype_mapping_update_parsed,
15987 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15989 (void *)&cmd_ptype_mapping_update_ptype,
15990 (void *)&cmd_ptype_mapping_update_mapping,
15991 (void *)&cmd_ptype_mapping_update_update,
15992 (void *)&cmd_ptype_mapping_update_port_id,
15993 (void *)&cmd_ptype_mapping_update_hw_ptype,
15994 (void *)&cmd_ptype_mapping_update_sw_ptype,
15999 /* Common result structure for file commands */
16000 struct cmd_cmdfile_result {
16001 cmdline_fixed_string_t load;
16002 cmdline_fixed_string_t filename;
16005 /* Common CLI fields for file commands */
16006 cmdline_parse_token_string_t cmd_load_cmdfile =
16007 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16008 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16009 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16012 cmd_load_from_file_parsed(
16013 void *parsed_result,
16014 __attribute__((unused)) struct cmdline *cl,
16015 __attribute__((unused)) void *data)
16017 struct cmd_cmdfile_result *res = parsed_result;
16019 cmdline_read_from_file(res->filename);
16022 cmdline_parse_inst_t cmd_load_from_file = {
16023 .f = cmd_load_from_file_parsed,
16025 .help_str = "load <filename>",
16027 (void *)&cmd_load_cmdfile,
16028 (void *)&cmd_load_cmdfile_filename,
16033 /* ******************************************************************************** */
16035 /* list of instructions */
16036 cmdline_parse_ctx_t main_ctx[] = {
16037 (cmdline_parse_inst_t *)&cmd_help_brief,
16038 (cmdline_parse_inst_t *)&cmd_help_long,
16039 (cmdline_parse_inst_t *)&cmd_quit,
16040 (cmdline_parse_inst_t *)&cmd_load_from_file,
16041 (cmdline_parse_inst_t *)&cmd_showport,
16042 (cmdline_parse_inst_t *)&cmd_showqueue,
16043 (cmdline_parse_inst_t *)&cmd_showportall,
16044 (cmdline_parse_inst_t *)&cmd_showcfg,
16045 (cmdline_parse_inst_t *)&cmd_start,
16046 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16047 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16048 (cmdline_parse_inst_t *)&cmd_set_link_up,
16049 (cmdline_parse_inst_t *)&cmd_set_link_down,
16050 (cmdline_parse_inst_t *)&cmd_reset,
16051 (cmdline_parse_inst_t *)&cmd_set_numbers,
16052 (cmdline_parse_inst_t *)&cmd_set_log,
16053 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16054 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16055 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16056 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16057 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16058 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16059 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16060 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16061 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16062 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16063 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16064 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16065 (cmdline_parse_inst_t *)&cmd_set_link_check,
16066 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16067 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16068 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16069 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16070 #ifdef RTE_LIBRTE_PMD_BOND
16071 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16072 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16073 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16074 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16075 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16076 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16077 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16078 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16079 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16080 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16081 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16083 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16084 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16085 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16086 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16087 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16088 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16089 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16090 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16091 (cmdline_parse_inst_t *)&cmd_csum_set,
16092 (cmdline_parse_inst_t *)&cmd_csum_show,
16093 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16094 (cmdline_parse_inst_t *)&cmd_tso_set,
16095 (cmdline_parse_inst_t *)&cmd_tso_show,
16096 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16097 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16098 (cmdline_parse_inst_t *)&cmd_gro_enable,
16099 (cmdline_parse_inst_t *)&cmd_gro_flush,
16100 (cmdline_parse_inst_t *)&cmd_gro_show,
16101 (cmdline_parse_inst_t *)&cmd_gso_enable,
16102 (cmdline_parse_inst_t *)&cmd_gso_size,
16103 (cmdline_parse_inst_t *)&cmd_gso_show,
16104 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16105 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16106 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16107 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16108 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16109 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16110 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16111 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16112 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16113 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16114 (cmdline_parse_inst_t *)&cmd_config_dcb,
16115 (cmdline_parse_inst_t *)&cmd_read_reg,
16116 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16117 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16118 (cmdline_parse_inst_t *)&cmd_write_reg,
16119 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16120 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16121 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16122 (cmdline_parse_inst_t *)&cmd_stop,
16123 (cmdline_parse_inst_t *)&cmd_mac_addr,
16124 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16125 (cmdline_parse_inst_t *)&cmd_set_qmap,
16126 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16127 (cmdline_parse_inst_t *)&cmd_operate_port,
16128 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16129 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16130 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16131 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16132 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16133 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16134 (cmdline_parse_inst_t *)&cmd_config_mtu,
16135 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16136 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16137 (cmdline_parse_inst_t *)&cmd_config_rss,
16138 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16139 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16140 (cmdline_parse_inst_t *)&cmd_showport_reta,
16141 (cmdline_parse_inst_t *)&cmd_config_burst,
16142 (cmdline_parse_inst_t *)&cmd_config_thresh,
16143 (cmdline_parse_inst_t *)&cmd_config_threshold,
16144 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16145 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16146 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16147 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16148 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16149 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16150 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16151 (cmdline_parse_inst_t *)&cmd_global_config,
16152 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16153 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16154 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16155 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16156 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16157 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16158 (cmdline_parse_inst_t *)&cmd_dump,
16159 (cmdline_parse_inst_t *)&cmd_dump_one,
16160 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16161 (cmdline_parse_inst_t *)&cmd_syn_filter,
16162 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16163 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16164 (cmdline_parse_inst_t *)&cmd_flex_filter,
16165 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16166 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16167 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16168 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16169 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16170 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16171 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16172 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16173 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16174 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16175 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16176 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16177 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16178 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16179 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16180 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16181 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16182 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16183 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16184 (cmdline_parse_inst_t *)&cmd_flow,
16185 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16186 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16187 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16188 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16189 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16190 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16191 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16192 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16193 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16194 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16195 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16196 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16197 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16198 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16199 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16200 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16201 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16202 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16203 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16204 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16205 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16206 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16207 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16208 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16209 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16210 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16211 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16212 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16213 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16214 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16215 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16216 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16217 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16218 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16219 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16220 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16221 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16222 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16223 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16224 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16225 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16226 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16227 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16228 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16229 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16230 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16231 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16232 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16233 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16234 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16235 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16237 (cmdline_parse_inst_t *)&cmd_ddp_add,
16238 (cmdline_parse_inst_t *)&cmd_ddp_del,
16239 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16240 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16241 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16242 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16243 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16244 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16245 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16246 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16247 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16248 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16250 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16251 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16252 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16253 (cmdline_parse_inst_t *)&cmd_queue_region,
16254 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16255 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16256 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16257 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16258 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16259 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16260 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16261 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16262 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16263 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16264 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16265 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16266 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16267 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16268 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16269 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16270 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16271 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16272 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16273 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16274 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16278 /* read cmdline commands from file */
16280 cmdline_read_from_file(const char *filename)
16282 struct cmdline *cl;
16284 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16286 printf("Failed to create file based cmdline context: %s\n",
16291 cmdline_interact(cl);
16296 printf("Read CLI commands from %s\n", filename);
16299 /* prompt function, called from main on MASTER lcore */
16303 /* initialize non-constant commands */
16304 cmd_set_fwd_mode_init();
16305 cmd_set_fwd_retry_mode_init();
16307 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16308 if (testpmd_cl == NULL)
16310 cmdline_interact(testpmd_cl);
16311 cmdline_stdin_exit(testpmd_cl);
16317 if (testpmd_cl != NULL)
16318 cmdline_quit(testpmd_cl);
16322 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16324 if (id == (portid_t)RTE_PORT_ALL) {
16327 RTE_ETH_FOREACH_DEV(pid) {
16328 /* check if need_reconfig has been set to 1 */
16329 if (ports[pid].need_reconfig == 0)
16330 ports[pid].need_reconfig = dev;
16331 /* check if need_reconfig_queues has been set to 1 */
16332 if (ports[pid].need_reconfig_queues == 0)
16333 ports[pid].need_reconfig_queues = queue;
16335 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16336 /* check if need_reconfig has been set to 1 */
16337 if (ports[id].need_reconfig == 0)
16338 ports[id].need_reconfig = dev;
16339 /* check if need_reconfig_queues has been set to 1 */
16340 if (ports[id].need_reconfig_queues == 0)
16341 ports[id].need_reconfig_queues = queue;