1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
16 #include <net/socket.h>
18 #include <sys/socket.h>
21 #include <netinet/in.h>
23 #include <sys/queue.h>
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
47 #include <rte_eth_ctrl.h>
51 #include <cmdline_rdline.h>
52 #include <cmdline_parse.h>
53 #include <cmdline_parse_num.h>
54 #include <cmdline_parse_string.h>
55 #include <cmdline_parse_ipaddr.h>
56 #include <cmdline_parse_etheraddr.h>
57 #include <cmdline_socket.h>
59 #ifdef RTE_LIBRTE_PMD_BOND
60 #include <rte_eth_bond.h>
61 #include <rte_eth_bond_8023ad.h>
63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
64 #include <rte_pmd_dpaa.h>
66 #ifdef RTE_LIBRTE_IXGBE_PMD
67 #include <rte_pmd_ixgbe.h>
69 #ifdef RTE_LIBRTE_I40E_PMD
70 #include <rte_pmd_i40e.h>
72 #ifdef RTE_LIBRTE_BNXT_PMD
73 #include <rte_pmd_bnxt.h>
76 #include "cmdline_mtr.h"
77 #include "cmdline_tm.h"
79 static struct cmdline *testpmd_cl;
81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
83 /* *** Help command with introduction. *** */
84 struct cmd_help_brief_result {
85 cmdline_fixed_string_t help;
88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
90 __attribute__((unused)) void *data)
95 "Help is available for the following sections:\n\n"
96 " help control : Start and stop forwarding.\n"
97 " help display : Displaying port, stats and config "
99 " help config : Configuration information.\n"
100 " help ports : Configuring ports.\n"
101 " help registers : Reading and setting port registers.\n"
102 " help filters : Filters configuration help.\n"
103 " help all : All of the above sections.\n\n"
108 cmdline_parse_token_string_t cmd_help_brief_help =
109 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
111 cmdline_parse_inst_t cmd_help_brief = {
112 .f = cmd_help_brief_parsed,
114 .help_str = "help: Show help",
116 (void *)&cmd_help_brief_help,
121 /* *** Help command with help sections. *** */
122 struct cmd_help_long_result {
123 cmdline_fixed_string_t help;
124 cmdline_fixed_string_t section;
127 static void cmd_help_long_parsed(void *parsed_result,
129 __attribute__((unused)) void *data)
132 struct cmd_help_long_result *res = parsed_result;
134 if (!strcmp(res->section, "all"))
137 if (show_all || !strcmp(res->section, "control")) {
142 "Control forwarding:\n"
143 "-------------------\n\n"
146 " Start packet forwarding with current configuration.\n\n"
149 " Start packet forwarding with current config"
150 " after sending one burst of packets.\n\n"
153 " Stop packet forwarding, and display accumulated"
157 " Quit to prompt.\n\n"
161 if (show_all || !strcmp(res->section, "display")) {
169 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
170 " Display information for port_id, or all.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
178 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
179 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
180 " Display the RSS hash functions and RSS hash key"
183 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
184 " Clear information for port_id, or all.\n\n"
186 "show (rxq|txq) info (port_id) (queue_id)\n"
187 " Display information for configured RX/TX queue.\n\n"
189 "show config (rxtx|cores|fwd|txpkts)\n"
190 " Display the given configuration.\n\n"
192 "read rxd (port_id) (queue_id) (rxd_id)\n"
193 " Display an RX descriptor of a port RX queue.\n\n"
195 "read txd (port_id) (queue_id) (txd_id)\n"
196 " Display a TX descriptor of a port TX queue.\n\n"
198 "ddp get list (port_id)\n"
199 " Get ddp profile info list\n\n"
201 "ddp get info (profile_path)\n"
202 " Get ddp profile information.\n\n"
204 "show vf stats (port_id) (vf_id)\n"
205 " Display a VF's statistics.\n\n"
207 "clear vf stats (port_id) (vf_id)\n"
208 " Reset a VF's statistics.\n\n"
210 "show port (port_id) pctype mapping\n"
211 " Get flow ptype to pctype mapping on a port\n\n"
213 "show port meter stats (port_id) (meter_id) (clear)\n"
214 " Get meter stats on a port\n\n"
215 "show port tm cap (port_id)\n"
216 " Display the port TM capability.\n\n"
218 "show port tm level cap (port_id) (level_id)\n"
219 " Display the port TM hierarchical level capability.\n\n"
221 "show port tm node cap (port_id) (node_id)\n"
222 " Display the port TM node capability.\n\n"
224 "show port tm node type (port_id) (node_id)\n"
225 " Display the port TM node type.\n\n"
227 "show port tm node stats (port_id) (node_id) (clear)\n"
228 " Display the port TM node stats.\n\n"
233 if (show_all || !strcmp(res->section, "config")) {
239 "Configuration changes only become active when"
240 " forwarding is started/restarted.\n\n"
243 " Reset forwarding to the default configuration.\n\n"
245 "set verbose (level)\n"
246 " Set the debug verbosity level X.\n\n"
248 "set log global|(type) (level)\n"
249 " Set the log level.\n\n"
252 " Set number of ports.\n\n"
255 " Set number of cores.\n\n"
257 "set coremask (mask)\n"
258 " Set the forwarding cores hexadecimal mask.\n\n"
260 "set portmask (mask)\n"
261 " Set the forwarding ports hexadecimal mask.\n\n"
264 " Set number of packets per burst.\n\n"
266 "set burst tx delay (microseconds) retry (num)\n"
267 " Set the transmit delay time and number of retries,"
268 " effective when retry is enabled.\n\n"
270 "set txpkts (x[,y]*)\n"
271 " Set the length of each segment of TXONLY"
272 " and optionally CSUM packets.\n\n"
274 "set txsplit (off|on|rand)\n"
275 " Set the split policy for the TX packets."
276 " Right now only applicable for CSUM and TXONLY"
279 "set corelist (x[,y]*)\n"
280 " Set the list of forwarding cores.\n\n"
282 "set portlist (x[,y]*)\n"
283 " Set the list of forwarding ports.\n\n"
285 "set tx loopback (port_id) (on|off)\n"
286 " Enable or disable tx loopback.\n\n"
288 "set all queues drop (port_id) (on|off)\n"
289 " Set drop enable bit for all queues.\n\n"
291 "set vf split drop (port_id) (vf_id) (on|off)\n"
292 " Set split drop enable bit for a VF from the PF.\n\n"
294 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
295 " Set MAC antispoof for a VF from the PF.\n\n"
297 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
298 " Enable MACsec offload.\n\n"
300 "set macsec offload (port_id) off\n"
301 " Disable MACsec offload.\n\n"
303 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
304 " Configure MACsec secure connection (SC).\n\n"
306 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
307 " Configure MACsec secure association (SA).\n\n"
309 "set vf broadcast (port_id) (vf_id) (on|off)\n"
310 " Set VF broadcast for a VF from the PF.\n\n"
312 "vlan set strip (on|off) (port_id)\n"
313 " Set the VLAN strip on a port.\n\n"
315 "vlan set stripq (on|off) (port_id,queue_id)\n"
316 " Set the VLAN strip for a queue on a port.\n\n"
318 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
319 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
321 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
322 " Set VLAN insert for a VF from the PF.\n\n"
324 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
325 " Set VLAN antispoof for a VF from the PF.\n\n"
327 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
328 " Set VLAN tag for a VF from the PF.\n\n"
330 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
331 " Set a VF's max bandwidth(Mbps).\n\n"
333 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
334 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
336 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
337 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
339 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
340 " Set some TCs' strict link priority mode on a physical port.\n\n"
342 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
343 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
345 "vlan set filter (on|off) (port_id)\n"
346 " Set the VLAN filter on a port.\n\n"
348 "vlan set qinq (on|off) (port_id)\n"
349 " Set the VLAN QinQ (extended queue in queue)"
352 "vlan set (inner|outer) tpid (value) (port_id)\n"
353 " Set the VLAN TPID for Packet Filtering on"
356 "rx_vlan add (vlan_id|all) (port_id)\n"
357 " Add a vlan_id, or all identifiers, to the set"
358 " of VLAN identifiers filtered by port_id.\n\n"
360 "rx_vlan rm (vlan_id|all) (port_id)\n"
361 " Remove a vlan_id, or all identifiers, from the set"
362 " of VLAN identifiers filtered by port_id.\n\n"
364 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
365 " Add a vlan_id, to the set of VLAN identifiers"
366 "filtered for VF(s) from port_id.\n\n"
368 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
369 " Remove a vlan_id, to the set of VLAN identifiers"
370 "filtered for VF(s) from port_id.\n\n"
372 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
373 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
374 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
375 " add a tunnel filter of a port.\n\n"
377 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
378 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
379 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
380 " remove a tunnel filter of a port.\n\n"
382 "rx_vxlan_port add (udp_port) (port_id)\n"
383 " Add an UDP port for VXLAN packet filter on a port\n\n"
385 "rx_vxlan_port rm (udp_port) (port_id)\n"
386 " Remove an UDP port for VXLAN packet filter on a port\n\n"
388 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
389 " Set hardware insertion of VLAN IDs (single or double VLAN "
390 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
392 "tx_vlan set pvid port_id vlan_id (on|off)\n"
393 " Set port based TX VLAN insertion.\n\n"
395 "tx_vlan reset (port_id)\n"
396 " Disable hardware insertion of a VLAN header in"
397 " packets sent on a port.\n\n"
399 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
400 " Select hardware or software calculation of the"
401 " checksum when transmitting a packet using the"
402 " csum forward engine.\n"
403 " ip|udp|tcp|sctp always concern the inner layer.\n"
404 " outer-ip concerns the outer IP layer in"
405 " case the packet is recognized as a tunnel packet by"
406 " the forward engine (vxlan, gre and ipip are supported)\n"
407 " Please check the NIC datasheet for HW limits.\n\n"
409 "csum parse-tunnel (on|off) (tx_port_id)\n"
410 " If disabled, treat tunnel packets as non-tunneled"
411 " packets (treat inner headers as payload). The port\n"
412 " argument is the port used for TX in csum forward"
415 "csum show (port_id)\n"
416 " Display tx checksum offload configuration\n\n"
418 "tso set (segsize) (portid)\n"
419 " Enable TCP Segmentation Offload in csum forward"
421 " Please check the NIC datasheet for HW limits.\n\n"
424 " Display the status of TCP Segmentation Offload.\n\n"
426 "set port (port_id) gro on|off\n"
427 " Enable or disable Generic Receive Offload in"
428 " csum forwarding engine.\n\n"
430 "show port (port_id) gro\n"
431 " Display GRO configuration.\n\n"
433 "set gro flush (cycles)\n"
434 " Set the cycle to flush GROed packets from"
435 " reassembly tables.\n\n"
437 "set port (port_id) gso (on|off)"
438 " Enable or disable Generic Segmentation Offload in"
439 " csum forwarding engine.\n\n"
441 "set gso segsz (length)\n"
442 " Set max packet length for output GSO segments,"
443 " including packet header and payload.\n\n"
445 "show port (port_id) gso\n"
446 " Show GSO configuration.\n\n"
449 " Set packet forwarding mode.\n\n"
451 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
452 " Add a MAC address on port_id.\n\n"
454 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
455 " Remove a MAC address from port_id.\n\n"
457 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
458 " Set the default MAC address for port_id.\n\n"
460 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
461 " Add a MAC address for a VF on the port.\n\n"
463 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
464 " Set the MAC address for a VF from the PF.\n\n"
466 "set eth-peer (port_id) (peer_addr)\n"
467 " set the peer address for certain port.\n\n"
469 "set port (port_id) uta (mac_address|all) (on|off)\n"
470 " Add/Remove a or all unicast hash filter(s)"
473 "set promisc (port_id|all) (on|off)\n"
474 " Set the promiscuous mode on port_id, or all.\n\n"
476 "set allmulti (port_id|all) (on|off)\n"
477 " Set the allmulti mode on port_id, or all.\n\n"
479 "set vf promisc (port_id) (vf_id) (on|off)\n"
480 " Set unicast promiscuous mode for a VF from the PF.\n\n"
482 "set vf allmulti (port_id) (vf_id) (on|off)\n"
483 " Set multicast promiscuous mode for a VF from the PF.\n\n"
485 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
486 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
487 " (on|off) autoneg (on|off) (port_id)\n"
488 "set flow_ctrl rx (on|off) (portid)\n"
489 "set flow_ctrl tx (on|off) (portid)\n"
490 "set flow_ctrl high_water (high_water) (portid)\n"
491 "set flow_ctrl low_water (low_water) (portid)\n"
492 "set flow_ctrl pause_time (pause_time) (portid)\n"
493 "set flow_ctrl send_xon (send_xon) (portid)\n"
494 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
495 "set flow_ctrl autoneg (on|off) (port_id)\n"
496 " Set the link flow control parameter on a port.\n\n"
498 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
499 " (low_water) (pause_time) (priority) (port_id)\n"
500 " Set the priority flow control parameter on a"
503 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
504 " Set statistics mapping (qmapping 0..15) for RX/TX"
506 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
507 " on port 0 to mapping 5.\n\n"
509 "set xstats-hide-zero on|off\n"
510 " Set the option to hide the zero values"
511 " for xstats display.\n"
513 "set port (port_id) vf (vf_id) rx|tx on|off\n"
514 " Enable/Disable a VF receive/tranmit from a port\n\n"
516 "set port (port_id) vf (vf_id) (mac_addr)"
517 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
518 " Add/Remove unicast or multicast MAC addr filter"
521 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
523 " AUPE:accepts untagged VLAN;"
524 "ROPE:accept unicast hash\n\n"
525 " BAM:accepts broadcast packets;"
526 "MPE:accepts all multicast packets\n\n"
527 " Enable/Disable a VF receive mode of a port\n\n"
529 "set port (port_id) queue (queue_id) rate (rate_num)\n"
530 " Set rate limit for a queue of a port\n\n"
532 "set port (port_id) vf (vf_id) rate (rate_num) "
533 "queue_mask (queue_mask_value)\n"
534 " Set rate limit for queues in VF of a port\n\n"
536 "set port (port_id) mirror-rule (rule_id)"
537 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
538 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
539 " Set pool or vlan type mirror rule on a port.\n"
540 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
541 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
544 "set port (port_id) mirror-rule (rule_id)"
545 " (uplink-mirror|downlink-mirror) dst-pool"
546 " (pool_id) (on|off)\n"
547 " Set uplink or downlink type mirror rule on a port.\n"
548 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
549 " 0 on' enable mirror income traffic to pool 0.\n\n"
551 "reset port (port_id) mirror-rule (rule_id)\n"
552 " Reset a mirror rule.\n\n"
554 "set flush_rx (on|off)\n"
555 " Flush (default) or don't flush RX streams before"
556 " forwarding. Mainly used with PCAP drivers.\n\n"
558 "set bypass mode (normal|bypass|isolate) (port_id)\n"
559 " Set the bypass mode for the lowest port on bypass enabled"
562 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
563 "mode (normal|bypass|isolate) (port_id)\n"
564 " Set the event required to initiate specified bypass mode for"
565 " the lowest port on a bypass enabled NIC where:\n"
566 " timeout = enable bypass after watchdog timeout.\n"
567 " os_on = enable bypass when OS/board is powered on.\n"
568 " os_off = enable bypass when OS/board is powered off.\n"
569 " power_on = enable bypass when power supply is turned on.\n"
570 " power_off = enable bypass when power supply is turned off."
573 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
574 " Set the bypass watchdog timeout to 'n' seconds"
575 " where 0 = instant.\n\n"
577 "show bypass config (port_id)\n"
578 " Show the bypass configuration for a bypass enabled NIC"
579 " using the lowest port on the NIC.\n\n"
581 #ifdef RTE_LIBRTE_PMD_BOND
582 "create bonded device (mode) (socket)\n"
583 " Create a new bonded device with specific bonding mode and socket.\n\n"
585 "add bonding slave (slave_id) (port_id)\n"
586 " Add a slave device to a bonded device.\n\n"
588 "remove bonding slave (slave_id) (port_id)\n"
589 " Remove a slave device from a bonded device.\n\n"
591 "set bonding mode (value) (port_id)\n"
592 " Set the bonding mode on a bonded device.\n\n"
594 "set bonding primary (slave_id) (port_id)\n"
595 " Set the primary slave for a bonded device.\n\n"
597 "show bonding config (port_id)\n"
598 " Show the bonding config for port_id.\n\n"
600 "set bonding mac_addr (port_id) (address)\n"
601 " Set the MAC address of a bonded device.\n\n"
603 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
604 " Set Aggregation mode for IEEE802.3AD (mode 4)"
606 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
607 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
609 "set bonding mon_period (port_id) (value)\n"
610 " Set the bonding link status monitoring polling period in ms.\n\n"
612 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
613 " Enable/disable dedicated queues for LACP control traffic.\n\n"
616 "set link-up port (port_id)\n"
617 " Set link up for a port.\n\n"
619 "set link-down port (port_id)\n"
620 " Set link down for a port.\n\n"
622 "E-tag set insertion on port-tag-id (value)"
623 " port (port_id) vf (vf_id)\n"
624 " Enable E-tag insertion for a VF on a port\n\n"
626 "E-tag set insertion off port (port_id) vf (vf_id)\n"
627 " Disable E-tag insertion for a VF on a port\n\n"
629 "E-tag set stripping (on|off) port (port_id)\n"
630 " Enable/disable E-tag stripping on a port\n\n"
632 "E-tag set forwarding (on|off) port (port_id)\n"
633 " Enable/disable E-tag based forwarding"
636 "E-tag set filter add e-tag-id (value) dst-pool"
637 " (pool_id) port (port_id)\n"
638 " Add an E-tag forwarding filter on a port\n\n"
640 "E-tag set filter del e-tag-id (value) port (port_id)\n"
641 " Delete an E-tag forwarding filter on a port\n\n"
643 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
644 "set port tm hierarchy default (port_id)\n"
645 " Set default traffic Management hierarchy on a port\n\n"
648 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
649 " Load a profile package on a port\n\n"
651 "ddp del (port_id) (backup_profile_path)\n"
652 " Delete a profile package from a port\n\n"
654 "ptype mapping get (port_id) (valid_only)\n"
655 " Get ptype mapping on a port\n\n"
657 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
658 " Replace target with the pkt_type in ptype mapping\n\n"
660 "ptype mapping reset (port_id)\n"
661 " Reset ptype mapping on a port\n\n"
663 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
664 " Update a ptype mapping item on a port\n\n"
666 "set port (port_id) queue-region region_id (value) "
667 "queue_start_index (value) queue_num (value)\n"
668 " Set a queue region on a port\n\n"
670 "set port (port_id) queue-region region_id (value) "
672 " Set a flowtype region index on a port\n\n"
674 "set port (port_id) queue-region UP (value) region_id (value)\n"
675 " Set the mapping of User Priority to "
676 "queue region on a port\n\n"
678 "set port (port_id) queue-region flush (on|off)\n"
679 " flush all queue region related configuration\n\n"
681 "show port meter cap (port_id)\n"
682 " Show port meter capability information\n\n"
684 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
685 " meter profile add - srtcm rfc 2697\n\n"
687 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
688 " meter profile add - trtcm rfc 2698\n\n"
690 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
691 " meter profile add - trtcm rfc 4115\n\n"
693 "del port meter profile (port_id) (profile_id)\n"
694 " meter profile delete\n\n"
696 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
697 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
698 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
699 "(dscp_tbl_entry63)]\n"
702 "enable port meter (port_id) (mtr_id)\n"
705 "disable port meter (port_id) (mtr_id)\n"
708 "del port meter (port_id) (mtr_id)\n"
711 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
712 " meter update meter profile\n\n"
714 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
715 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
716 " update meter dscp table entries\n\n"
718 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
719 "(action0) [(action1) (action2)]\n"
720 " meter update policer action\n\n"
722 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
723 " meter update stats\n\n"
725 "show port (port_id) queue-region\n"
726 " show all queue region related configuration info\n\n"
728 "add port tm node shaper profile (port_id) (shaper_profile_id)"
729 " (tb_rate) (tb_size) (packet_length_adjust)\n"
730 " Add port tm node private shaper profile.\n\n"
732 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
733 " Delete port tm node private shaper profile.\n\n"
735 "add port tm node shared shaper (port_id) (shared_shaper_id)"
736 " (shaper_profile_id)\n"
737 " Add/update port tm node shared shaper.\n\n"
739 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
740 " Delete port tm node shared shaper.\n\n"
742 "set port tm node shaper profile (port_id) (node_id)"
743 " (shaper_profile_id)\n"
744 " Set port tm node shaper profile.\n\n"
746 "add port tm node wred profile (port_id) (wred_profile_id)"
747 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
748 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
749 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
750 " Add port tm node wred profile.\n\n"
752 "del port tm node wred profile (port_id) (wred_profile_id)\n"
753 " Delete port tm node wred profile.\n\n"
755 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
756 " (priority) (weight) (level_id) (shaper_profile_id)"
757 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
758 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
759 " Add port tm nonleaf node.\n\n"
761 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
762 " (priority) (weight) (level_id) (shaper_profile_id)"
763 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
764 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
765 " Add port tm leaf node.\n\n"
767 "del port tm node (port_id) (node_id)\n"
768 " Delete port tm node.\n\n"
770 "set port tm node parent (port_id) (node_id) (parent_node_id)"
771 " (priority) (weight)\n"
772 " Set port tm node parent.\n\n"
774 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
775 " Commit tm hierarchy.\n\n"
777 , list_pkt_forwarding_modes()
781 if (show_all || !strcmp(res->section, "ports")) {
787 "----------------\n\n"
789 "port start (port_id|all)\n"
790 " Start all ports or port_id.\n\n"
792 "port stop (port_id|all)\n"
793 " Stop all ports or port_id.\n\n"
795 "port close (port_id|all)\n"
796 " Close all ports or port_id.\n\n"
798 "port attach (ident)\n"
799 " Attach physical or virtual dev by pci address or virtual device name\n\n"
801 "port detach (port_id)\n"
802 " Detach physical or virtual dev by port_id\n\n"
804 "port config (port_id|all)"
805 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
806 " duplex (half|full|auto)\n"
807 " Set speed and duplex for all ports or port_id\n\n"
809 "port config (port_id|all) loopback (mode)\n"
810 " Set loopback mode for all ports or port_id\n\n"
812 "port config all (rxq|txq|rxd|txd) (value)\n"
813 " Set number for rxq/txq/rxd/txd.\n\n"
815 "port config all max-pkt-len (value)\n"
816 " Set the max packet length.\n\n"
818 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
819 "hw-vlan-strip|hw-vlan-extend|drop-en)"
821 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
824 "port config all rss (all|default|ip|tcp|udp|sctp|"
825 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
826 " Set the RSS mode.\n\n"
828 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
829 " Set the RSS redirection table.\n\n"
831 "port config (port_id) dcb vt (on|off) (traffic_class)"
833 " Set the DCB mode.\n\n"
835 "port config all burst (value)\n"
836 " Set the number of packets per burst.\n\n"
838 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
840 " Set the ring prefetch/host/writeback threshold"
841 " for tx/rx queue.\n\n"
843 "port config all (txfreet|txrst|rxfreet) (value)\n"
844 " Set free threshold for rx/tx, or set"
845 " tx rs bit threshold.\n\n"
846 "port config mtu X value\n"
847 " Set the MTU of port X to a given value\n\n"
849 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
850 " Start/stop a rx/tx queue of port X. Only take effect"
851 " when port X is started\n\n"
853 "port config (port_id|all) l2-tunnel E-tag ether-type"
855 " Set the value of E-tag ether-type.\n\n"
857 "port config (port_id|all) l2-tunnel E-tag"
858 " (enable|disable)\n"
859 " Enable/disable the E-tag support.\n\n"
861 "port config (port_id) pctype mapping reset\n"
862 " Reset flow type to pctype mapping on a port\n\n"
864 "port config (port_id) pctype mapping update"
865 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
866 " Update a flow type to pctype mapping item on a port\n\n"
868 "port config (port_id) pctype (pctype_id) hash_inset|"
869 "fdir_inset|fdir_flx_inset get|set|clear field\n"
871 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
873 "port config (port_id) pctype (pctype_id) hash_inset|"
874 "fdir_inset|fdir_flx_inset clear all"
875 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
879 if (show_all || !strcmp(res->section, "registers")) {
887 "read reg (port_id) (address)\n"
888 " Display value of a port register.\n\n"
890 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
891 " Display a port register bit field.\n\n"
893 "read regbit (port_id) (address) (bit_x)\n"
894 " Display a single port register bit.\n\n"
896 "write reg (port_id) (address) (value)\n"
897 " Set value of a port register.\n\n"
899 "write regfield (port_id) (address) (bit_x) (bit_y)"
901 " Set bit field of a port register.\n\n"
903 "write regbit (port_id) (address) (bit_x) (value)\n"
904 " Set single bit value of a port register.\n\n"
907 if (show_all || !strcmp(res->section, "filters")) {
915 "ethertype_filter (port_id) (add|del)"
916 " (mac_addr|mac_ignr) (mac_address) ethertype"
917 " (ether_type) (drop|fwd) queue (queue_id)\n"
918 " Add/Del an ethertype filter.\n\n"
920 "2tuple_filter (port_id) (add|del)"
921 " dst_port (dst_port_value) protocol (protocol_value)"
922 " mask (mask_value) tcp_flags (tcp_flags_value)"
923 " priority (prio_value) queue (queue_id)\n"
924 " Add/Del a 2tuple filter.\n\n"
926 "5tuple_filter (port_id) (add|del)"
927 " dst_ip (dst_address) src_ip (src_address)"
928 " dst_port (dst_port_value) src_port (src_port_value)"
929 " protocol (protocol_value)"
930 " mask (mask_value) tcp_flags (tcp_flags_value)"
931 " priority (prio_value) queue (queue_id)\n"
932 " Add/Del a 5tuple filter.\n\n"
934 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
935 " Add/Del syn filter.\n\n"
937 "flex_filter (port_id) (add|del) len (len_value)"
938 " bytes (bytes_value) mask (mask_value)"
939 " priority (prio_value) queue (queue_id)\n"
940 " Add/Del a flex filter.\n\n"
942 "flow_director_filter (port_id) mode IP (add|del|update)"
943 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
944 " src (src_ip_address) dst (dst_ip_address)"
945 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
946 " vlan (vlan_value) flexbytes (flexbytes_value)"
947 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
948 " fd_id (fd_id_value)\n"
949 " Add/Del an IP type flow director filter.\n\n"
951 "flow_director_filter (port_id) mode IP (add|del|update)"
952 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
953 " src (src_ip_address) (src_port)"
954 " dst (dst_ip_address) (dst_port)"
955 " tos (tos_value) ttl (ttl_value)"
956 " vlan (vlan_value) flexbytes (flexbytes_value)"
957 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
958 " fd_id (fd_id_value)\n"
959 " Add/Del an UDP/TCP type flow director filter.\n\n"
961 "flow_director_filter (port_id) mode IP (add|del|update)"
962 " flow (ipv4-sctp|ipv6-sctp)"
963 " src (src_ip_address) (src_port)"
964 " dst (dst_ip_address) (dst_port)"
965 " tag (verification_tag) "
966 " tos (tos_value) ttl (ttl_value)"
968 " flexbytes (flexbytes_value) (drop|fwd)"
969 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
970 " Add/Del a SCTP type flow director filter.\n\n"
972 "flow_director_filter (port_id) mode IP (add|del|update)"
973 " flow l2_payload ether (ethertype)"
974 " flexbytes (flexbytes_value) (drop|fwd)"
975 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
976 " Add/Del a l2 payload type flow director filter.\n\n"
978 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
979 " mac (mac_address) vlan (vlan_value)"
980 " flexbytes (flexbytes_value) (drop|fwd)"
981 " queue (queue_id) fd_id (fd_id_value)\n"
982 " Add/Del a MAC-VLAN flow director filter.\n\n"
984 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
985 " mac (mac_address) vlan (vlan_value)"
986 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
987 " flexbytes (flexbytes_value) (drop|fwd)"
988 " queue (queue_id) fd_id (fd_id_value)\n"
989 " Add/Del a Tunnel flow director filter.\n\n"
991 "flow_director_filter (port_id) mode raw (add|del|update)"
992 " flow (flow_id) (drop|fwd) queue (queue_id)"
993 " fd_id (fd_id_value) packet (packet file name)\n"
994 " Add/Del a raw type flow director filter.\n\n"
996 "flush_flow_director (port_id)\n"
997 " Flush all flow director entries of a device.\n\n"
999 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1000 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1001 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1002 " Set flow director IP mask.\n\n"
1004 "flow_director_mask (port_id) mode MAC-VLAN"
1005 " vlan (vlan_value)\n"
1006 " Set flow director MAC-VLAN mask.\n\n"
1008 "flow_director_mask (port_id) mode Tunnel"
1009 " vlan (vlan_value) mac (mac_value)"
1010 " tunnel-type (tunnel_type_value)"
1011 " tunnel-id (tunnel_id_value)\n"
1012 " Set flow director Tunnel mask.\n\n"
1014 "flow_director_flex_mask (port_id)"
1015 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1016 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1018 " Configure mask of flex payload.\n\n"
1020 "flow_director_flex_payload (port_id)"
1021 " (raw|l2|l3|l4) (config)\n"
1022 " Configure flex payload selection.\n\n"
1024 "get_sym_hash_ena_per_port (port_id)\n"
1025 " get symmetric hash enable configuration per port.\n\n"
1027 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1028 " set symmetric hash enable configuration per port"
1029 " to enable or disable.\n\n"
1031 "get_hash_global_config (port_id)\n"
1032 " Get the global configurations of hash filters.\n\n"
1034 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1035 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1036 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1037 " (enable|disable)\n"
1038 " Set the global configurations of hash filters.\n\n"
1040 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1041 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1042 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1043 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1044 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1045 "ipv6-next-header|udp-src-port|udp-dst-port|"
1046 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1047 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1048 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1049 "fld-8th|none) (select|add)\n"
1050 " Set the input set for hash.\n\n"
1052 "set_fdir_input_set (port_id) "
1053 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1054 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1055 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1056 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1057 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1058 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1059 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1061 " Set the input set for FDir.\n\n"
1063 "flow validate {port_id}"
1064 " [group {group_id}] [priority {level}]"
1065 " [ingress] [egress]"
1066 " pattern {item} [/ {item} [...]] / end"
1067 " actions {action} [/ {action} [...]] / end\n"
1068 " Check whether a flow rule can be created.\n\n"
1070 "flow create {port_id}"
1071 " [group {group_id}] [priority {level}]"
1072 " [ingress] [egress]"
1073 " pattern {item} [/ {item} [...]] / end"
1074 " actions {action} [/ {action} [...]] / end\n"
1075 " Create a flow rule.\n\n"
1077 "flow destroy {port_id} rule {rule_id} [...]\n"
1078 " Destroy specific flow rules.\n\n"
1080 "flow flush {port_id}\n"
1081 " Destroy all flow rules.\n\n"
1083 "flow query {port_id} {rule_id} {action}\n"
1084 " Query an existing flow rule.\n\n"
1086 "flow list {port_id} [group {group_id}] [...]\n"
1087 " List existing flow rules sorted by priority,"
1088 " filtered by group identifiers.\n\n"
1090 "flow isolate {port_id} {boolean}\n"
1091 " Restrict ingress traffic to the defined"
1097 cmdline_parse_token_string_t cmd_help_long_help =
1098 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1100 cmdline_parse_token_string_t cmd_help_long_section =
1101 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1102 "all#control#display#config#"
1103 "ports#registers#filters");
1105 cmdline_parse_inst_t cmd_help_long = {
1106 .f = cmd_help_long_parsed,
1108 .help_str = "help all|control|display|config|ports|register|filters: "
1111 (void *)&cmd_help_long_help,
1112 (void *)&cmd_help_long_section,
1118 /* *** start/stop/close all ports *** */
1119 struct cmd_operate_port_result {
1120 cmdline_fixed_string_t keyword;
1121 cmdline_fixed_string_t name;
1122 cmdline_fixed_string_t value;
1125 static void cmd_operate_port_parsed(void *parsed_result,
1126 __attribute__((unused)) struct cmdline *cl,
1127 __attribute__((unused)) void *data)
1129 struct cmd_operate_port_result *res = parsed_result;
1131 if (!strcmp(res->name, "start"))
1132 start_port(RTE_PORT_ALL);
1133 else if (!strcmp(res->name, "stop"))
1134 stop_port(RTE_PORT_ALL);
1135 else if (!strcmp(res->name, "close"))
1136 close_port(RTE_PORT_ALL);
1137 else if (!strcmp(res->name, "reset"))
1138 reset_port(RTE_PORT_ALL);
1140 printf("Unknown parameter\n");
1143 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1144 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1146 cmdline_parse_token_string_t cmd_operate_port_all_port =
1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1148 "start#stop#close#reset");
1149 cmdline_parse_token_string_t cmd_operate_port_all_all =
1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1152 cmdline_parse_inst_t cmd_operate_port = {
1153 .f = cmd_operate_port_parsed,
1155 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1157 (void *)&cmd_operate_port_all_cmd,
1158 (void *)&cmd_operate_port_all_port,
1159 (void *)&cmd_operate_port_all_all,
1164 /* *** start/stop/close specific port *** */
1165 struct cmd_operate_specific_port_result {
1166 cmdline_fixed_string_t keyword;
1167 cmdline_fixed_string_t name;
1171 static void cmd_operate_specific_port_parsed(void *parsed_result,
1172 __attribute__((unused)) struct cmdline *cl,
1173 __attribute__((unused)) void *data)
1175 struct cmd_operate_specific_port_result *res = parsed_result;
1177 if (!strcmp(res->name, "start"))
1178 start_port(res->value);
1179 else if (!strcmp(res->name, "stop"))
1180 stop_port(res->value);
1181 else if (!strcmp(res->name, "close"))
1182 close_port(res->value);
1183 else if (!strcmp(res->name, "reset"))
1184 reset_port(res->value);
1186 printf("Unknown parameter\n");
1189 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1190 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1192 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1194 name, "start#stop#close#reset");
1195 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1196 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1199 cmdline_parse_inst_t cmd_operate_specific_port = {
1200 .f = cmd_operate_specific_port_parsed,
1202 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1204 (void *)&cmd_operate_specific_port_cmd,
1205 (void *)&cmd_operate_specific_port_port,
1206 (void *)&cmd_operate_specific_port_id,
1211 /* *** attach a specified port *** */
1212 struct cmd_operate_attach_port_result {
1213 cmdline_fixed_string_t port;
1214 cmdline_fixed_string_t keyword;
1215 cmdline_fixed_string_t identifier;
1218 static void cmd_operate_attach_port_parsed(void *parsed_result,
1219 __attribute__((unused)) struct cmdline *cl,
1220 __attribute__((unused)) void *data)
1222 struct cmd_operate_attach_port_result *res = parsed_result;
1224 if (!strcmp(res->keyword, "attach"))
1225 attach_port(res->identifier);
1227 printf("Unknown parameter\n");
1230 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1231 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1233 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1236 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1240 cmdline_parse_inst_t cmd_operate_attach_port = {
1241 .f = cmd_operate_attach_port_parsed,
1243 .help_str = "port attach <identifier>: "
1244 "(identifier: pci address or virtual dev name)",
1246 (void *)&cmd_operate_attach_port_port,
1247 (void *)&cmd_operate_attach_port_keyword,
1248 (void *)&cmd_operate_attach_port_identifier,
1253 /* *** detach a specified port *** */
1254 struct cmd_operate_detach_port_result {
1255 cmdline_fixed_string_t port;
1256 cmdline_fixed_string_t keyword;
1260 static void cmd_operate_detach_port_parsed(void *parsed_result,
1261 __attribute__((unused)) struct cmdline *cl,
1262 __attribute__((unused)) void *data)
1264 struct cmd_operate_detach_port_result *res = parsed_result;
1266 if (!strcmp(res->keyword, "detach"))
1267 detach_port(res->port_id);
1269 printf("Unknown parameter\n");
1272 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1273 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1275 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1278 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1279 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1282 cmdline_parse_inst_t cmd_operate_detach_port = {
1283 .f = cmd_operate_detach_port_parsed,
1285 .help_str = "port detach <port_id>",
1287 (void *)&cmd_operate_detach_port_port,
1288 (void *)&cmd_operate_detach_port_keyword,
1289 (void *)&cmd_operate_detach_port_port_id,
1294 /* *** configure speed for all ports *** */
1295 struct cmd_config_speed_all {
1296 cmdline_fixed_string_t port;
1297 cmdline_fixed_string_t keyword;
1298 cmdline_fixed_string_t all;
1299 cmdline_fixed_string_t item1;
1300 cmdline_fixed_string_t item2;
1301 cmdline_fixed_string_t value1;
1302 cmdline_fixed_string_t value2;
1306 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1311 if (!strcmp(duplexstr, "half")) {
1312 duplex = ETH_LINK_HALF_DUPLEX;
1313 } else if (!strcmp(duplexstr, "full")) {
1314 duplex = ETH_LINK_FULL_DUPLEX;
1315 } else if (!strcmp(duplexstr, "auto")) {
1316 duplex = ETH_LINK_FULL_DUPLEX;
1318 printf("Unknown duplex parameter\n");
1322 if (!strcmp(speedstr, "10")) {
1323 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1324 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1325 } else if (!strcmp(speedstr, "100")) {
1326 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1327 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1329 if (duplex != ETH_LINK_FULL_DUPLEX) {
1330 printf("Invalid speed/duplex parameters\n");
1333 if (!strcmp(speedstr, "1000")) {
1334 *speed = ETH_LINK_SPEED_1G;
1335 } else if (!strcmp(speedstr, "10000")) {
1336 *speed = ETH_LINK_SPEED_10G;
1337 } else if (!strcmp(speedstr, "25000")) {
1338 *speed = ETH_LINK_SPEED_25G;
1339 } else if (!strcmp(speedstr, "40000")) {
1340 *speed = ETH_LINK_SPEED_40G;
1341 } else if (!strcmp(speedstr, "50000")) {
1342 *speed = ETH_LINK_SPEED_50G;
1343 } else if (!strcmp(speedstr, "100000")) {
1344 *speed = ETH_LINK_SPEED_100G;
1345 } else if (!strcmp(speedstr, "auto")) {
1346 *speed = ETH_LINK_SPEED_AUTONEG;
1348 printf("Unknown speed parameter\n");
1357 cmd_config_speed_all_parsed(void *parsed_result,
1358 __attribute__((unused)) struct cmdline *cl,
1359 __attribute__((unused)) void *data)
1361 struct cmd_config_speed_all *res = parsed_result;
1362 uint32_t link_speed;
1365 if (!all_ports_stopped()) {
1366 printf("Please stop all ports first\n");
1370 if (parse_and_check_speed_duplex(res->value1, res->value2,
1374 RTE_ETH_FOREACH_DEV(pid) {
1375 ports[pid].dev_conf.link_speeds = link_speed;
1378 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1381 cmdline_parse_token_string_t cmd_config_speed_all_port =
1382 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1383 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1384 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1386 cmdline_parse_token_string_t cmd_config_speed_all_all =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1388 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1389 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1390 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1391 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1392 "10#100#1000#10000#25000#40000#50000#100000#auto");
1393 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1395 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1399 cmdline_parse_inst_t cmd_config_speed_all = {
1400 .f = cmd_config_speed_all_parsed,
1402 .help_str = "port config all speed "
1403 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1406 (void *)&cmd_config_speed_all_port,
1407 (void *)&cmd_config_speed_all_keyword,
1408 (void *)&cmd_config_speed_all_all,
1409 (void *)&cmd_config_speed_all_item1,
1410 (void *)&cmd_config_speed_all_value1,
1411 (void *)&cmd_config_speed_all_item2,
1412 (void *)&cmd_config_speed_all_value2,
1417 /* *** configure speed for specific port *** */
1418 struct cmd_config_speed_specific {
1419 cmdline_fixed_string_t port;
1420 cmdline_fixed_string_t keyword;
1422 cmdline_fixed_string_t item1;
1423 cmdline_fixed_string_t item2;
1424 cmdline_fixed_string_t value1;
1425 cmdline_fixed_string_t value2;
1429 cmd_config_speed_specific_parsed(void *parsed_result,
1430 __attribute__((unused)) struct cmdline *cl,
1431 __attribute__((unused)) void *data)
1433 struct cmd_config_speed_specific *res = parsed_result;
1434 uint32_t link_speed;
1436 if (!all_ports_stopped()) {
1437 printf("Please stop all ports first\n");
1441 if (port_id_is_invalid(res->id, ENABLED_WARN))
1444 if (parse_and_check_speed_duplex(res->value1, res->value2,
1448 ports[res->id].dev_conf.link_speeds = link_speed;
1450 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1454 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1455 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1457 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1460 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1461 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1462 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1463 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1465 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1467 "10#100#1000#10000#25000#40000#50000#100000#auto");
1468 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1471 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1475 cmdline_parse_inst_t cmd_config_speed_specific = {
1476 .f = cmd_config_speed_specific_parsed,
1478 .help_str = "port config <port_id> speed "
1479 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1482 (void *)&cmd_config_speed_specific_port,
1483 (void *)&cmd_config_speed_specific_keyword,
1484 (void *)&cmd_config_speed_specific_id,
1485 (void *)&cmd_config_speed_specific_item1,
1486 (void *)&cmd_config_speed_specific_value1,
1487 (void *)&cmd_config_speed_specific_item2,
1488 (void *)&cmd_config_speed_specific_value2,
1493 /* *** configure loopback for all ports *** */
1494 struct cmd_config_loopback_all {
1495 cmdline_fixed_string_t port;
1496 cmdline_fixed_string_t keyword;
1497 cmdline_fixed_string_t all;
1498 cmdline_fixed_string_t item;
1503 cmd_config_loopback_all_parsed(void *parsed_result,
1504 __attribute__((unused)) struct cmdline *cl,
1505 __attribute__((unused)) void *data)
1507 struct cmd_config_loopback_all *res = parsed_result;
1510 if (!all_ports_stopped()) {
1511 printf("Please stop all ports first\n");
1515 RTE_ETH_FOREACH_DEV(pid) {
1516 ports[pid].dev_conf.lpbk_mode = res->mode;
1519 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1522 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1523 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1524 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1525 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1527 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1528 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1529 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1530 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1532 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1533 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1535 cmdline_parse_inst_t cmd_config_loopback_all = {
1536 .f = cmd_config_loopback_all_parsed,
1538 .help_str = "port config all loopback <mode>",
1540 (void *)&cmd_config_loopback_all_port,
1541 (void *)&cmd_config_loopback_all_keyword,
1542 (void *)&cmd_config_loopback_all_all,
1543 (void *)&cmd_config_loopback_all_item,
1544 (void *)&cmd_config_loopback_all_mode,
1549 /* *** configure loopback for specific port *** */
1550 struct cmd_config_loopback_specific {
1551 cmdline_fixed_string_t port;
1552 cmdline_fixed_string_t keyword;
1554 cmdline_fixed_string_t item;
1559 cmd_config_loopback_specific_parsed(void *parsed_result,
1560 __attribute__((unused)) struct cmdline *cl,
1561 __attribute__((unused)) void *data)
1563 struct cmd_config_loopback_specific *res = parsed_result;
1565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1568 if (!port_is_stopped(res->port_id)) {
1569 printf("Please stop port %u first\n", res->port_id);
1573 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1575 cmd_reconfig_device_queue(res->port_id, 1, 1);
1579 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1582 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1585 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1586 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1588 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1589 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1591 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1592 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1595 cmdline_parse_inst_t cmd_config_loopback_specific = {
1596 .f = cmd_config_loopback_specific_parsed,
1598 .help_str = "port config <port_id> loopback <mode>",
1600 (void *)&cmd_config_loopback_specific_port,
1601 (void *)&cmd_config_loopback_specific_keyword,
1602 (void *)&cmd_config_loopback_specific_id,
1603 (void *)&cmd_config_loopback_specific_item,
1604 (void *)&cmd_config_loopback_specific_mode,
1609 /* *** configure txq/rxq, txd/rxd *** */
1610 struct cmd_config_rx_tx {
1611 cmdline_fixed_string_t port;
1612 cmdline_fixed_string_t keyword;
1613 cmdline_fixed_string_t all;
1614 cmdline_fixed_string_t name;
1619 cmd_config_rx_tx_parsed(void *parsed_result,
1620 __attribute__((unused)) struct cmdline *cl,
1621 __attribute__((unused)) void *data)
1623 struct cmd_config_rx_tx *res = parsed_result;
1625 if (!all_ports_stopped()) {
1626 printf("Please stop all ports first\n");
1629 if (!strcmp(res->name, "rxq")) {
1630 if (!res->value && !nb_txq) {
1631 printf("Warning: Either rx or tx queues should be non zero\n");
1634 if (check_nb_rxq(res->value) != 0)
1636 nb_rxq = res->value;
1638 else if (!strcmp(res->name, "txq")) {
1639 if (!res->value && !nb_rxq) {
1640 printf("Warning: Either rx or tx queues should be non zero\n");
1643 if (check_nb_txq(res->value) != 0)
1645 nb_txq = res->value;
1647 else if (!strcmp(res->name, "rxd")) {
1648 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1649 printf("rxd %d invalid - must be > 0 && <= %d\n",
1650 res->value, RTE_TEST_RX_DESC_MAX);
1653 nb_rxd = res->value;
1654 } else if (!strcmp(res->name, "txd")) {
1655 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1656 printf("txd %d invalid - must be > 0 && <= %d\n",
1657 res->value, RTE_TEST_TX_DESC_MAX);
1660 nb_txd = res->value;
1662 printf("Unknown parameter\n");
1670 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1673 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1675 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1677 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1678 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1679 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1680 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1682 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1683 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1685 cmdline_parse_inst_t cmd_config_rx_tx = {
1686 .f = cmd_config_rx_tx_parsed,
1688 .help_str = "port config all rxq|txq|rxd|txd <value>",
1690 (void *)&cmd_config_rx_tx_port,
1691 (void *)&cmd_config_rx_tx_keyword,
1692 (void *)&cmd_config_rx_tx_all,
1693 (void *)&cmd_config_rx_tx_name,
1694 (void *)&cmd_config_rx_tx_value,
1699 /* *** config max packet length *** */
1700 struct cmd_config_max_pkt_len_result {
1701 cmdline_fixed_string_t port;
1702 cmdline_fixed_string_t keyword;
1703 cmdline_fixed_string_t all;
1704 cmdline_fixed_string_t name;
1709 cmd_config_max_pkt_len_parsed(void *parsed_result,
1710 __attribute__((unused)) struct cmdline *cl,
1711 __attribute__((unused)) void *data)
1713 struct cmd_config_max_pkt_len_result *res = parsed_result;
1716 if (!all_ports_stopped()) {
1717 printf("Please stop all ports first\n");
1721 RTE_ETH_FOREACH_DEV(pid) {
1722 struct rte_port *port = &ports[pid];
1723 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1725 if (!strcmp(res->name, "max-pkt-len")) {
1726 if (res->value < ETHER_MIN_LEN) {
1727 printf("max-pkt-len can not be less than %d\n",
1731 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1734 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1735 if (res->value > ETHER_MAX_LEN)
1736 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1738 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1739 port->dev_conf.rxmode.offloads = rx_offloads;
1741 printf("Unknown parameter\n");
1748 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1751 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1752 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1754 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1755 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1757 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1758 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1760 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1761 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1763 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1764 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1767 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1768 .f = cmd_config_max_pkt_len_parsed,
1770 .help_str = "port config all max-pkt-len <value>",
1772 (void *)&cmd_config_max_pkt_len_port,
1773 (void *)&cmd_config_max_pkt_len_keyword,
1774 (void *)&cmd_config_max_pkt_len_all,
1775 (void *)&cmd_config_max_pkt_len_name,
1776 (void *)&cmd_config_max_pkt_len_value,
1781 /* *** configure port MTU *** */
1782 struct cmd_config_mtu_result {
1783 cmdline_fixed_string_t port;
1784 cmdline_fixed_string_t keyword;
1785 cmdline_fixed_string_t mtu;
1791 cmd_config_mtu_parsed(void *parsed_result,
1792 __attribute__((unused)) struct cmdline *cl,
1793 __attribute__((unused)) void *data)
1795 struct cmd_config_mtu_result *res = parsed_result;
1797 if (res->value < ETHER_MIN_LEN) {
1798 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1801 port_mtu_set(res->port_id, res->value);
1804 cmdline_parse_token_string_t cmd_config_mtu_port =
1805 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1807 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1808 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1810 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1811 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1813 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1814 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1815 cmdline_parse_token_num_t cmd_config_mtu_value =
1816 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1818 cmdline_parse_inst_t cmd_config_mtu = {
1819 .f = cmd_config_mtu_parsed,
1821 .help_str = "port config mtu <port_id> <value>",
1823 (void *)&cmd_config_mtu_port,
1824 (void *)&cmd_config_mtu_keyword,
1825 (void *)&cmd_config_mtu_mtu,
1826 (void *)&cmd_config_mtu_port_id,
1827 (void *)&cmd_config_mtu_value,
1832 /* *** configure rx mode *** */
1833 struct cmd_config_rx_mode_flag {
1834 cmdline_fixed_string_t port;
1835 cmdline_fixed_string_t keyword;
1836 cmdline_fixed_string_t all;
1837 cmdline_fixed_string_t name;
1838 cmdline_fixed_string_t value;
1842 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1843 __attribute__((unused)) struct cmdline *cl,
1844 __attribute__((unused)) void *data)
1846 struct cmd_config_rx_mode_flag *res = parsed_result;
1849 if (!all_ports_stopped()) {
1850 printf("Please stop all ports first\n");
1854 RTE_ETH_FOREACH_DEV(pid) {
1855 struct rte_port *port;
1856 uint64_t rx_offloads;
1859 rx_offloads = port->dev_conf.rxmode.offloads;
1860 if (!strcmp(res->name, "crc-strip")) {
1861 if (!strcmp(res->value, "on"))
1862 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1863 else if (!strcmp(res->value, "off"))
1864 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1866 printf("Unknown parameter\n");
1869 } else if (!strcmp(res->name, "scatter")) {
1870 if (!strcmp(res->value, "on")) {
1871 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1872 } else if (!strcmp(res->value, "off")) {
1873 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1875 printf("Unknown parameter\n");
1878 } else if (!strcmp(res->name, "rx-cksum")) {
1879 if (!strcmp(res->value, "on"))
1880 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1881 else if (!strcmp(res->value, "off"))
1882 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1884 printf("Unknown parameter\n");
1887 } else if (!strcmp(res->name, "rx-timestamp")) {
1888 if (!strcmp(res->value, "on"))
1889 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1890 else if (!strcmp(res->value, "off"))
1891 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1893 printf("Unknown parameter\n");
1896 } else if (!strcmp(res->name, "hw-vlan")) {
1897 if (!strcmp(res->value, "on")) {
1898 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1899 DEV_RX_OFFLOAD_VLAN_STRIP);
1900 } else if (!strcmp(res->value, "off")) {
1901 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1902 DEV_RX_OFFLOAD_VLAN_STRIP);
1904 printf("Unknown parameter\n");
1907 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1908 if (!strcmp(res->value, "on"))
1909 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1910 else if (!strcmp(res->value, "off"))
1911 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1913 printf("Unknown parameter\n");
1916 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1917 if (!strcmp(res->value, "on"))
1918 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1919 else if (!strcmp(res->value, "off"))
1920 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1922 printf("Unknown parameter\n");
1925 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1926 if (!strcmp(res->value, "on"))
1927 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1928 else if (!strcmp(res->value, "off"))
1929 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1931 printf("Unknown parameter\n");
1934 } else if (!strcmp(res->name, "drop-en")) {
1935 if (!strcmp(res->value, "on"))
1937 else if (!strcmp(res->value, "off"))
1940 printf("Unknown parameter\n");
1944 printf("Unknown parameter\n");
1947 port->dev_conf.rxmode.offloads = rx_offloads;
1952 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1955 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1956 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1957 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1960 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1962 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1964 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1965 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1966 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1970 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1971 .f = cmd_config_rx_mode_flag_parsed,
1973 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1974 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1976 (void *)&cmd_config_rx_mode_flag_port,
1977 (void *)&cmd_config_rx_mode_flag_keyword,
1978 (void *)&cmd_config_rx_mode_flag_all,
1979 (void *)&cmd_config_rx_mode_flag_name,
1980 (void *)&cmd_config_rx_mode_flag_value,
1985 /* *** configure rss *** */
1986 struct cmd_config_rss {
1987 cmdline_fixed_string_t port;
1988 cmdline_fixed_string_t keyword;
1989 cmdline_fixed_string_t all;
1990 cmdline_fixed_string_t name;
1991 cmdline_fixed_string_t value;
1995 cmd_config_rss_parsed(void *parsed_result,
1996 __attribute__((unused)) struct cmdline *cl,
1997 __attribute__((unused)) void *data)
1999 struct cmd_config_rss *res = parsed_result;
2000 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2001 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2005 if (!strcmp(res->value, "all"))
2006 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2007 ETH_RSS_UDP | ETH_RSS_SCTP |
2009 else if (!strcmp(res->value, "ip"))
2010 rss_conf.rss_hf = ETH_RSS_IP;
2011 else if (!strcmp(res->value, "udp"))
2012 rss_conf.rss_hf = ETH_RSS_UDP;
2013 else if (!strcmp(res->value, "tcp"))
2014 rss_conf.rss_hf = ETH_RSS_TCP;
2015 else if (!strcmp(res->value, "sctp"))
2016 rss_conf.rss_hf = ETH_RSS_SCTP;
2017 else if (!strcmp(res->value, "ether"))
2018 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2019 else if (!strcmp(res->value, "port"))
2020 rss_conf.rss_hf = ETH_RSS_PORT;
2021 else if (!strcmp(res->value, "vxlan"))
2022 rss_conf.rss_hf = ETH_RSS_VXLAN;
2023 else if (!strcmp(res->value, "geneve"))
2024 rss_conf.rss_hf = ETH_RSS_GENEVE;
2025 else if (!strcmp(res->value, "nvgre"))
2026 rss_conf.rss_hf = ETH_RSS_NVGRE;
2027 else if (!strcmp(res->value, "none") || !strcmp(res->value, "default"))
2028 rss_conf.rss_hf = 0;
2029 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2030 atoi(res->value) < 64)
2031 rss_conf.rss_hf = 1ULL << atoi(res->value);
2033 printf("Unknown parameter\n");
2036 rss_conf.rss_key = NULL;
2037 /* Update global configuration for RSS types. */
2038 rss_hf = rss_conf.rss_hf;
2039 RTE_ETH_FOREACH_DEV(i) {
2040 if (!strcmp(res->value, "default")) {
2041 rte_eth_dev_info_get(i, &dev_info);
2042 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2044 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2046 printf("Configuration of RSS hash at ethernet port %d "
2047 "failed with error (%d): %s.\n",
2048 i, -diag, strerror(-diag));
2052 cmdline_parse_token_string_t cmd_config_rss_port =
2053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2054 cmdline_parse_token_string_t cmd_config_rss_keyword =
2055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2056 cmdline_parse_token_string_t cmd_config_rss_all =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2058 cmdline_parse_token_string_t cmd_config_rss_name =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2060 cmdline_parse_token_string_t cmd_config_rss_value =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2063 cmdline_parse_inst_t cmd_config_rss = {
2064 .f = cmd_config_rss_parsed,
2066 .help_str = "port config all rss "
2067 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2069 (void *)&cmd_config_rss_port,
2070 (void *)&cmd_config_rss_keyword,
2071 (void *)&cmd_config_rss_all,
2072 (void *)&cmd_config_rss_name,
2073 (void *)&cmd_config_rss_value,
2078 /* *** configure rss hash key *** */
2079 struct cmd_config_rss_hash_key {
2080 cmdline_fixed_string_t port;
2081 cmdline_fixed_string_t config;
2083 cmdline_fixed_string_t rss_hash_key;
2084 cmdline_fixed_string_t rss_type;
2085 cmdline_fixed_string_t key;
2089 hexa_digit_to_value(char hexa_digit)
2091 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2092 return (uint8_t) (hexa_digit - '0');
2093 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2094 return (uint8_t) ((hexa_digit - 'a') + 10);
2095 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2096 return (uint8_t) ((hexa_digit - 'A') + 10);
2097 /* Invalid hexa digit */
2102 parse_and_check_key_hexa_digit(char *key, int idx)
2106 hexa_v = hexa_digit_to_value(key[idx]);
2108 printf("invalid key: character %c at position %d is not a "
2109 "valid hexa digit\n", key[idx], idx);
2114 cmd_config_rss_hash_key_parsed(void *parsed_result,
2115 __attribute__((unused)) struct cmdline *cl,
2116 __attribute__((unused)) void *data)
2118 struct cmd_config_rss_hash_key *res = parsed_result;
2119 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2123 struct rte_eth_dev_info dev_info;
2124 uint8_t hash_key_size;
2127 memset(&dev_info, 0, sizeof(dev_info));
2128 rte_eth_dev_info_get(res->port_id, &dev_info);
2129 if (dev_info.hash_key_size > 0 &&
2130 dev_info.hash_key_size <= sizeof(hash_key))
2131 hash_key_size = dev_info.hash_key_size;
2133 printf("dev_info did not provide a valid hash key size\n");
2136 /* Check the length of the RSS hash key */
2137 key_len = strlen(res->key);
2138 if (key_len != (hash_key_size * 2)) {
2139 printf("key length: %d invalid - key must be a string of %d"
2140 " hexa-decimal numbers\n",
2141 (int) key_len, hash_key_size * 2);
2144 /* Translate RSS hash key into binary representation */
2145 for (i = 0; i < hash_key_size; i++) {
2146 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2149 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2152 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2154 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2158 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2159 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2160 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2161 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2163 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2164 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2165 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2166 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2167 rss_hash_key, "rss-hash-key");
2168 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2169 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2170 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2171 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2172 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2173 "ipv6-tcp-ex#ipv6-udp-ex");
2174 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2175 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2177 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2178 .f = cmd_config_rss_hash_key_parsed,
2180 .help_str = "port config <port_id> rss-hash-key "
2181 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2182 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2183 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2184 "<string of hex digits (variable length, NIC dependent)>",
2186 (void *)&cmd_config_rss_hash_key_port,
2187 (void *)&cmd_config_rss_hash_key_config,
2188 (void *)&cmd_config_rss_hash_key_port_id,
2189 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2190 (void *)&cmd_config_rss_hash_key_rss_type,
2191 (void *)&cmd_config_rss_hash_key_value,
2196 /* *** configure port rxq/txq start/stop *** */
2197 struct cmd_config_rxtx_queue {
2198 cmdline_fixed_string_t port;
2200 cmdline_fixed_string_t rxtxq;
2202 cmdline_fixed_string_t opname;
2206 cmd_config_rxtx_queue_parsed(void *parsed_result,
2207 __attribute__((unused)) struct cmdline *cl,
2208 __attribute__((unused)) void *data)
2210 struct cmd_config_rxtx_queue *res = parsed_result;
2215 if (test_done == 0) {
2216 printf("Please stop forwarding first\n");
2220 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2223 if (port_is_started(res->portid) != 1) {
2224 printf("Please start port %u first\n", res->portid);
2228 if (!strcmp(res->rxtxq, "rxq"))
2230 else if (!strcmp(res->rxtxq, "txq"))
2233 printf("Unknown parameter\n");
2237 if (isrx && rx_queue_id_is_invalid(res->qid))
2239 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2242 if (!strcmp(res->opname, "start"))
2244 else if (!strcmp(res->opname, "stop"))
2247 printf("Unknown parameter\n");
2251 if (isstart && isrx)
2252 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2253 else if (!isstart && isrx)
2254 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2255 else if (isstart && !isrx)
2256 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2258 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2260 if (ret == -ENOTSUP)
2261 printf("Function not supported in PMD driver\n");
2264 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2265 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2266 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2267 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2268 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2269 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2270 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2271 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2272 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2273 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2276 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2277 .f = cmd_config_rxtx_queue_parsed,
2279 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2281 (void *)&cmd_config_speed_all_port,
2282 (void *)&cmd_config_rxtx_queue_portid,
2283 (void *)&cmd_config_rxtx_queue_rxtxq,
2284 (void *)&cmd_config_rxtx_queue_qid,
2285 (void *)&cmd_config_rxtx_queue_opname,
2290 /* *** Configure RSS RETA *** */
2291 struct cmd_config_rss_reta {
2292 cmdline_fixed_string_t port;
2293 cmdline_fixed_string_t keyword;
2295 cmdline_fixed_string_t name;
2296 cmdline_fixed_string_t list_name;
2297 cmdline_fixed_string_t list_of_items;
2301 parse_reta_config(const char *str,
2302 struct rte_eth_rss_reta_entry64 *reta_conf,
2303 uint16_t nb_entries)
2307 uint16_t hash_index, idx, shift;
2310 const char *p, *p0 = str;
2317 unsigned long int_fld[_NUM_FLD];
2318 char *str_fld[_NUM_FLD];
2320 while ((p = strchr(p0,'(')) != NULL) {
2322 if((p0 = strchr(p,')')) == NULL)
2326 if(size >= sizeof(s))
2329 snprintf(s, sizeof(s), "%.*s", size, p);
2330 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2332 for (i = 0; i < _NUM_FLD; i++) {
2334 int_fld[i] = strtoul(str_fld[i], &end, 0);
2335 if (errno != 0 || end == str_fld[i] ||
2340 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2341 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2343 if (hash_index >= nb_entries) {
2344 printf("Invalid RETA hash index=%d\n", hash_index);
2348 idx = hash_index / RTE_RETA_GROUP_SIZE;
2349 shift = hash_index % RTE_RETA_GROUP_SIZE;
2350 reta_conf[idx].mask |= (1ULL << shift);
2351 reta_conf[idx].reta[shift] = nb_queue;
2358 cmd_set_rss_reta_parsed(void *parsed_result,
2359 __attribute__((unused)) struct cmdline *cl,
2360 __attribute__((unused)) void *data)
2363 struct rte_eth_dev_info dev_info;
2364 struct rte_eth_rss_reta_entry64 reta_conf[8];
2365 struct cmd_config_rss_reta *res = parsed_result;
2367 memset(&dev_info, 0, sizeof(dev_info));
2368 rte_eth_dev_info_get(res->port_id, &dev_info);
2369 if (dev_info.reta_size == 0) {
2370 printf("Redirection table size is 0 which is "
2371 "invalid for RSS\n");
2374 printf("The reta size of port %d is %u\n",
2375 res->port_id, dev_info.reta_size);
2376 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2377 printf("Currently do not support more than %u entries of "
2378 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2382 memset(reta_conf, 0, sizeof(reta_conf));
2383 if (!strcmp(res->list_name, "reta")) {
2384 if (parse_reta_config(res->list_of_items, reta_conf,
2385 dev_info.reta_size)) {
2386 printf("Invalid RSS Redirection Table "
2387 "config entered\n");
2390 ret = rte_eth_dev_rss_reta_update(res->port_id,
2391 reta_conf, dev_info.reta_size);
2393 printf("Bad redirection table parameter, "
2394 "return code = %d \n", ret);
2398 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2399 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2400 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2401 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2402 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2403 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2404 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2405 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2406 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2407 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2408 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2409 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2411 cmdline_parse_inst_t cmd_config_rss_reta = {
2412 .f = cmd_set_rss_reta_parsed,
2414 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2416 (void *)&cmd_config_rss_reta_port,
2417 (void *)&cmd_config_rss_reta_keyword,
2418 (void *)&cmd_config_rss_reta_port_id,
2419 (void *)&cmd_config_rss_reta_name,
2420 (void *)&cmd_config_rss_reta_list_name,
2421 (void *)&cmd_config_rss_reta_list_of_items,
2426 /* *** SHOW PORT RETA INFO *** */
2427 struct cmd_showport_reta {
2428 cmdline_fixed_string_t show;
2429 cmdline_fixed_string_t port;
2431 cmdline_fixed_string_t rss;
2432 cmdline_fixed_string_t reta;
2434 cmdline_fixed_string_t list_of_items;
2438 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2439 uint16_t nb_entries,
2443 const char *p, *p0 = str;
2448 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2449 RTE_RETA_GROUP_SIZE;
2452 p = strchr(p0, '(');
2456 p0 = strchr(p, ')');
2460 if (size >= sizeof(s)) {
2461 printf("The string size exceeds the internal buffer size\n");
2464 snprintf(s, sizeof(s), "%.*s", size, p);
2465 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2466 if (ret <= 0 || ret != num) {
2467 printf("The bits of masks do not match the number of "
2468 "reta entries: %u\n", num);
2471 for (i = 0; i < ret; i++)
2472 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2478 cmd_showport_reta_parsed(void *parsed_result,
2479 __attribute__((unused)) struct cmdline *cl,
2480 __attribute__((unused)) void *data)
2482 struct cmd_showport_reta *res = parsed_result;
2483 struct rte_eth_rss_reta_entry64 reta_conf[8];
2484 struct rte_eth_dev_info dev_info;
2485 uint16_t max_reta_size;
2487 memset(&dev_info, 0, sizeof(dev_info));
2488 rte_eth_dev_info_get(res->port_id, &dev_info);
2489 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2490 if (res->size == 0 || res->size > max_reta_size) {
2491 printf("Invalid redirection table size: %u (1-%u)\n",
2492 res->size, max_reta_size);
2496 memset(reta_conf, 0, sizeof(reta_conf));
2497 if (showport_parse_reta_config(reta_conf, res->size,
2498 res->list_of_items) < 0) {
2499 printf("Invalid string: %s for reta masks\n",
2500 res->list_of_items);
2503 port_rss_reta_info(res->port_id, reta_conf, res->size);
2506 cmdline_parse_token_string_t cmd_showport_reta_show =
2507 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2508 cmdline_parse_token_string_t cmd_showport_reta_port =
2509 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2510 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2511 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2512 cmdline_parse_token_string_t cmd_showport_reta_rss =
2513 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2514 cmdline_parse_token_string_t cmd_showport_reta_reta =
2515 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2516 cmdline_parse_token_num_t cmd_showport_reta_size =
2517 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2518 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2519 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2520 list_of_items, NULL);
2522 cmdline_parse_inst_t cmd_showport_reta = {
2523 .f = cmd_showport_reta_parsed,
2525 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2527 (void *)&cmd_showport_reta_show,
2528 (void *)&cmd_showport_reta_port,
2529 (void *)&cmd_showport_reta_port_id,
2530 (void *)&cmd_showport_reta_rss,
2531 (void *)&cmd_showport_reta_reta,
2532 (void *)&cmd_showport_reta_size,
2533 (void *)&cmd_showport_reta_list_of_items,
2538 /* *** Show RSS hash configuration *** */
2539 struct cmd_showport_rss_hash {
2540 cmdline_fixed_string_t show;
2541 cmdline_fixed_string_t port;
2543 cmdline_fixed_string_t rss_hash;
2544 cmdline_fixed_string_t rss_type;
2545 cmdline_fixed_string_t key; /* optional argument */
2548 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2549 __attribute__((unused)) struct cmdline *cl,
2552 struct cmd_showport_rss_hash *res = parsed_result;
2554 port_rss_hash_conf_show(res->port_id, res->rss_type,
2555 show_rss_key != NULL);
2558 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2559 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2560 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2561 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2562 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2563 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2564 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2565 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2567 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2568 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2569 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2570 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2571 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2572 "ipv6-tcp-ex#ipv6-udp-ex");
2573 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2574 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2576 cmdline_parse_inst_t cmd_showport_rss_hash = {
2577 .f = cmd_showport_rss_hash_parsed,
2579 .help_str = "show port <port_id> rss-hash "
2580 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2581 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2582 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2584 (void *)&cmd_showport_rss_hash_show,
2585 (void *)&cmd_showport_rss_hash_port,
2586 (void *)&cmd_showport_rss_hash_port_id,
2587 (void *)&cmd_showport_rss_hash_rss_hash,
2588 (void *)&cmd_showport_rss_hash_rss_hash_info,
2593 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2594 .f = cmd_showport_rss_hash_parsed,
2596 .help_str = "show port <port_id> rss-hash "
2597 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2598 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2599 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2601 (void *)&cmd_showport_rss_hash_show,
2602 (void *)&cmd_showport_rss_hash_port,
2603 (void *)&cmd_showport_rss_hash_port_id,
2604 (void *)&cmd_showport_rss_hash_rss_hash,
2605 (void *)&cmd_showport_rss_hash_rss_hash_info,
2606 (void *)&cmd_showport_rss_hash_rss_key,
2611 /* *** Configure DCB *** */
2612 struct cmd_config_dcb {
2613 cmdline_fixed_string_t port;
2614 cmdline_fixed_string_t config;
2616 cmdline_fixed_string_t dcb;
2617 cmdline_fixed_string_t vt;
2618 cmdline_fixed_string_t vt_en;
2620 cmdline_fixed_string_t pfc;
2621 cmdline_fixed_string_t pfc_en;
2625 cmd_config_dcb_parsed(void *parsed_result,
2626 __attribute__((unused)) struct cmdline *cl,
2627 __attribute__((unused)) void *data)
2629 struct cmd_config_dcb *res = parsed_result;
2630 portid_t port_id = res->port_id;
2631 struct rte_port *port;
2635 port = &ports[port_id];
2636 /** Check if the port is not started **/
2637 if (port->port_status != RTE_PORT_STOPPED) {
2638 printf("Please stop port %d first\n", port_id);
2642 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2643 printf("The invalid number of traffic class,"
2644 " only 4 or 8 allowed.\n");
2648 if (nb_fwd_lcores < res->num_tcs) {
2649 printf("nb_cores shouldn't be less than number of TCs.\n");
2652 if (!strncmp(res->pfc_en, "on", 2))
2657 /* DCB in VT mode */
2658 if (!strncmp(res->vt_en, "on", 2))
2659 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2660 (enum rte_eth_nb_tcs)res->num_tcs,
2663 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2664 (enum rte_eth_nb_tcs)res->num_tcs,
2669 printf("Cannot initialize network ports.\n");
2673 cmd_reconfig_device_queue(port_id, 1, 1);
2676 cmdline_parse_token_string_t cmd_config_dcb_port =
2677 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2678 cmdline_parse_token_string_t cmd_config_dcb_config =
2679 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2680 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2681 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2682 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2683 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2684 cmdline_parse_token_string_t cmd_config_dcb_vt =
2685 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2686 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2687 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2688 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2689 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2690 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2691 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2692 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2693 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2695 cmdline_parse_inst_t cmd_config_dcb = {
2696 .f = cmd_config_dcb_parsed,
2698 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2700 (void *)&cmd_config_dcb_port,
2701 (void *)&cmd_config_dcb_config,
2702 (void *)&cmd_config_dcb_port_id,
2703 (void *)&cmd_config_dcb_dcb,
2704 (void *)&cmd_config_dcb_vt,
2705 (void *)&cmd_config_dcb_vt_en,
2706 (void *)&cmd_config_dcb_num_tcs,
2707 (void *)&cmd_config_dcb_pfc,
2708 (void *)&cmd_config_dcb_pfc_en,
2713 /* *** configure number of packets per burst *** */
2714 struct cmd_config_burst {
2715 cmdline_fixed_string_t port;
2716 cmdline_fixed_string_t keyword;
2717 cmdline_fixed_string_t all;
2718 cmdline_fixed_string_t name;
2723 cmd_config_burst_parsed(void *parsed_result,
2724 __attribute__((unused)) struct cmdline *cl,
2725 __attribute__((unused)) void *data)
2727 struct cmd_config_burst *res = parsed_result;
2728 struct rte_eth_dev_info dev_info;
2729 uint16_t rec_nb_pkts;
2731 if (!all_ports_stopped()) {
2732 printf("Please stop all ports first\n");
2736 if (!strcmp(res->name, "burst")) {
2737 if (res->value == 0) {
2738 /* If user gives a value of zero, query the PMD for
2739 * its recommended Rx burst size. Testpmd uses a single
2740 * size for all ports, so assume all ports are the same
2741 * NIC model and use the values from Port 0.
2743 rte_eth_dev_info_get(0, &dev_info);
2744 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2746 if (rec_nb_pkts == 0) {
2747 printf("PMD does not recommend a burst size.\n"
2748 "User provided value must be between"
2749 " 1 and %d\n", MAX_PKT_BURST);
2751 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2752 printf("PMD recommended burst size of %d"
2753 " exceeds maximum value of %d\n",
2754 rec_nb_pkts, MAX_PKT_BURST);
2757 printf("Using PMD-provided burst value of %d\n",
2759 nb_pkt_per_burst = rec_nb_pkts;
2760 } else if (res->value > MAX_PKT_BURST) {
2761 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2764 nb_pkt_per_burst = res->value;
2766 printf("Unknown parameter\n");
2772 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2775 cmdline_parse_token_string_t cmd_config_burst_port =
2776 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2777 cmdline_parse_token_string_t cmd_config_burst_keyword =
2778 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2779 cmdline_parse_token_string_t cmd_config_burst_all =
2780 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2781 cmdline_parse_token_string_t cmd_config_burst_name =
2782 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2783 cmdline_parse_token_num_t cmd_config_burst_value =
2784 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2786 cmdline_parse_inst_t cmd_config_burst = {
2787 .f = cmd_config_burst_parsed,
2789 .help_str = "port config all burst <value>",
2791 (void *)&cmd_config_burst_port,
2792 (void *)&cmd_config_burst_keyword,
2793 (void *)&cmd_config_burst_all,
2794 (void *)&cmd_config_burst_name,
2795 (void *)&cmd_config_burst_value,
2800 /* *** configure rx/tx queues *** */
2801 struct cmd_config_thresh {
2802 cmdline_fixed_string_t port;
2803 cmdline_fixed_string_t keyword;
2804 cmdline_fixed_string_t all;
2805 cmdline_fixed_string_t name;
2810 cmd_config_thresh_parsed(void *parsed_result,
2811 __attribute__((unused)) struct cmdline *cl,
2812 __attribute__((unused)) void *data)
2814 struct cmd_config_thresh *res = parsed_result;
2816 if (!all_ports_stopped()) {
2817 printf("Please stop all ports first\n");
2821 if (!strcmp(res->name, "txpt"))
2822 tx_pthresh = res->value;
2823 else if(!strcmp(res->name, "txht"))
2824 tx_hthresh = res->value;
2825 else if(!strcmp(res->name, "txwt"))
2826 tx_wthresh = res->value;
2827 else if(!strcmp(res->name, "rxpt"))
2828 rx_pthresh = res->value;
2829 else if(!strcmp(res->name, "rxht"))
2830 rx_hthresh = res->value;
2831 else if(!strcmp(res->name, "rxwt"))
2832 rx_wthresh = res->value;
2834 printf("Unknown parameter\n");
2840 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2843 cmdline_parse_token_string_t cmd_config_thresh_port =
2844 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2845 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2846 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2847 cmdline_parse_token_string_t cmd_config_thresh_all =
2848 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2849 cmdline_parse_token_string_t cmd_config_thresh_name =
2850 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2851 "txpt#txht#txwt#rxpt#rxht#rxwt");
2852 cmdline_parse_token_num_t cmd_config_thresh_value =
2853 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2855 cmdline_parse_inst_t cmd_config_thresh = {
2856 .f = cmd_config_thresh_parsed,
2858 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2860 (void *)&cmd_config_thresh_port,
2861 (void *)&cmd_config_thresh_keyword,
2862 (void *)&cmd_config_thresh_all,
2863 (void *)&cmd_config_thresh_name,
2864 (void *)&cmd_config_thresh_value,
2869 /* *** configure free/rs threshold *** */
2870 struct cmd_config_threshold {
2871 cmdline_fixed_string_t port;
2872 cmdline_fixed_string_t keyword;
2873 cmdline_fixed_string_t all;
2874 cmdline_fixed_string_t name;
2879 cmd_config_threshold_parsed(void *parsed_result,
2880 __attribute__((unused)) struct cmdline *cl,
2881 __attribute__((unused)) void *data)
2883 struct cmd_config_threshold *res = parsed_result;
2885 if (!all_ports_stopped()) {
2886 printf("Please stop all ports first\n");
2890 if (!strcmp(res->name, "txfreet"))
2891 tx_free_thresh = res->value;
2892 else if (!strcmp(res->name, "txrst"))
2893 tx_rs_thresh = res->value;
2894 else if (!strcmp(res->name, "rxfreet"))
2895 rx_free_thresh = res->value;
2897 printf("Unknown parameter\n");
2903 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2906 cmdline_parse_token_string_t cmd_config_threshold_port =
2907 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2908 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2909 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2911 cmdline_parse_token_string_t cmd_config_threshold_all =
2912 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2913 cmdline_parse_token_string_t cmd_config_threshold_name =
2914 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2915 "txfreet#txrst#rxfreet");
2916 cmdline_parse_token_num_t cmd_config_threshold_value =
2917 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2919 cmdline_parse_inst_t cmd_config_threshold = {
2920 .f = cmd_config_threshold_parsed,
2922 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2924 (void *)&cmd_config_threshold_port,
2925 (void *)&cmd_config_threshold_keyword,
2926 (void *)&cmd_config_threshold_all,
2927 (void *)&cmd_config_threshold_name,
2928 (void *)&cmd_config_threshold_value,
2934 struct cmd_stop_result {
2935 cmdline_fixed_string_t stop;
2938 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2939 __attribute__((unused)) struct cmdline *cl,
2940 __attribute__((unused)) void *data)
2942 stop_packet_forwarding();
2945 cmdline_parse_token_string_t cmd_stop_stop =
2946 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2948 cmdline_parse_inst_t cmd_stop = {
2949 .f = cmd_stop_parsed,
2951 .help_str = "stop: Stop packet forwarding",
2953 (void *)&cmd_stop_stop,
2958 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2961 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2962 unsigned int *parsed_items, int check_unique_values)
2964 unsigned int nb_item;
2972 * First parse all items in the list and store their value.
2977 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2979 if ((c >= '0') && (c <= '9')) {
2980 value = (unsigned int) (value * 10 + (c - '0'));
2985 printf("character %c is not a decimal digit\n", c);
2989 printf("No valid value before comma\n");
2992 if (nb_item < max_items) {
2993 parsed_items[nb_item] = value;
2999 if (nb_item >= max_items) {
3000 printf("Number of %s = %u > %u (maximum items)\n",
3001 item_name, nb_item + 1, max_items);
3004 parsed_items[nb_item++] = value;
3005 if (! check_unique_values)
3009 * Then, check that all values in the list are differents.
3010 * No optimization here...
3012 for (i = 0; i < nb_item; i++) {
3013 for (j = i + 1; j < nb_item; j++) {
3014 if (parsed_items[j] == parsed_items[i]) {
3015 printf("duplicated %s %u at index %u and %u\n",
3016 item_name, parsed_items[i], i, j);
3024 struct cmd_set_list_result {
3025 cmdline_fixed_string_t cmd_keyword;
3026 cmdline_fixed_string_t list_name;
3027 cmdline_fixed_string_t list_of_items;
3030 static void cmd_set_list_parsed(void *parsed_result,
3031 __attribute__((unused)) struct cmdline *cl,
3032 __attribute__((unused)) void *data)
3034 struct cmd_set_list_result *res;
3036 unsigned int lcorelist[RTE_MAX_LCORE];
3037 unsigned int portlist[RTE_MAX_ETHPORTS];
3039 unsigned int nb_item;
3041 if (test_done == 0) {
3042 printf("Please stop forwarding first\n");
3046 res = parsed_result;
3047 if (!strcmp(res->list_name, "corelist")) {
3048 nb_item = parse_item_list(res->list_of_items, "core",
3050 parsed_items.lcorelist, 1);
3052 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3057 if (!strcmp(res->list_name, "portlist")) {
3058 nb_item = parse_item_list(res->list_of_items, "port",
3060 parsed_items.portlist, 1);
3062 set_fwd_ports_list(parsed_items.portlist, nb_item);
3068 cmdline_parse_token_string_t cmd_set_list_keyword =
3069 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3071 cmdline_parse_token_string_t cmd_set_list_name =
3072 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3073 "corelist#portlist");
3074 cmdline_parse_token_string_t cmd_set_list_of_items =
3075 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3078 cmdline_parse_inst_t cmd_set_fwd_list = {
3079 .f = cmd_set_list_parsed,
3081 .help_str = "set corelist|portlist <list0[,list1]*>",
3083 (void *)&cmd_set_list_keyword,
3084 (void *)&cmd_set_list_name,
3085 (void *)&cmd_set_list_of_items,
3090 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3092 struct cmd_setmask_result {
3093 cmdline_fixed_string_t set;
3094 cmdline_fixed_string_t mask;
3098 static void cmd_set_mask_parsed(void *parsed_result,
3099 __attribute__((unused)) struct cmdline *cl,
3100 __attribute__((unused)) void *data)
3102 struct cmd_setmask_result *res = parsed_result;
3104 if (test_done == 0) {
3105 printf("Please stop forwarding first\n");
3108 if (!strcmp(res->mask, "coremask")) {
3109 set_fwd_lcores_mask(res->hexavalue);
3111 } else if (!strcmp(res->mask, "portmask")) {
3112 set_fwd_ports_mask(res->hexavalue);
3117 cmdline_parse_token_string_t cmd_setmask_set =
3118 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3119 cmdline_parse_token_string_t cmd_setmask_mask =
3120 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3121 "coremask#portmask");
3122 cmdline_parse_token_num_t cmd_setmask_value =
3123 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3125 cmdline_parse_inst_t cmd_set_fwd_mask = {
3126 .f = cmd_set_mask_parsed,
3128 .help_str = "set coremask|portmask <hexadecimal value>",
3130 (void *)&cmd_setmask_set,
3131 (void *)&cmd_setmask_mask,
3132 (void *)&cmd_setmask_value,
3138 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3140 struct cmd_set_result {
3141 cmdline_fixed_string_t set;
3142 cmdline_fixed_string_t what;
3146 static void cmd_set_parsed(void *parsed_result,
3147 __attribute__((unused)) struct cmdline *cl,
3148 __attribute__((unused)) void *data)
3150 struct cmd_set_result *res = parsed_result;
3151 if (!strcmp(res->what, "nbport")) {
3152 set_fwd_ports_number(res->value);
3154 } else if (!strcmp(res->what, "nbcore")) {
3155 set_fwd_lcores_number(res->value);
3157 } else if (!strcmp(res->what, "burst"))
3158 set_nb_pkt_per_burst(res->value);
3159 else if (!strcmp(res->what, "verbose"))
3160 set_verbose_level(res->value);
3163 cmdline_parse_token_string_t cmd_set_set =
3164 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3165 cmdline_parse_token_string_t cmd_set_what =
3166 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3167 "nbport#nbcore#burst#verbose");
3168 cmdline_parse_token_num_t cmd_set_value =
3169 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3171 cmdline_parse_inst_t cmd_set_numbers = {
3172 .f = cmd_set_parsed,
3174 .help_str = "set nbport|nbcore|burst|verbose <value>",
3176 (void *)&cmd_set_set,
3177 (void *)&cmd_set_what,
3178 (void *)&cmd_set_value,
3183 /* *** SET LOG LEVEL CONFIGURATION *** */
3185 struct cmd_set_log_result {
3186 cmdline_fixed_string_t set;
3187 cmdline_fixed_string_t log;
3188 cmdline_fixed_string_t type;
3193 cmd_set_log_parsed(void *parsed_result,
3194 __attribute__((unused)) struct cmdline *cl,
3195 __attribute__((unused)) void *data)
3197 struct cmd_set_log_result *res;
3200 res = parsed_result;
3201 if (!strcmp(res->type, "global"))
3202 rte_log_set_global_level(res->level);
3204 ret = rte_log_set_level_regexp(res->type, res->level);
3206 printf("Unable to set log level\n");
3210 cmdline_parse_token_string_t cmd_set_log_set =
3211 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3212 cmdline_parse_token_string_t cmd_set_log_log =
3213 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3214 cmdline_parse_token_string_t cmd_set_log_type =
3215 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3216 cmdline_parse_token_num_t cmd_set_log_level =
3217 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3219 cmdline_parse_inst_t cmd_set_log = {
3220 .f = cmd_set_log_parsed,
3222 .help_str = "set log global|<type> <level>",
3224 (void *)&cmd_set_log_set,
3225 (void *)&cmd_set_log_log,
3226 (void *)&cmd_set_log_type,
3227 (void *)&cmd_set_log_level,
3232 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3234 struct cmd_set_txpkts_result {
3235 cmdline_fixed_string_t cmd_keyword;
3236 cmdline_fixed_string_t txpkts;
3237 cmdline_fixed_string_t seg_lengths;
3241 cmd_set_txpkts_parsed(void *parsed_result,
3242 __attribute__((unused)) struct cmdline *cl,
3243 __attribute__((unused)) void *data)
3245 struct cmd_set_txpkts_result *res;
3246 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3247 unsigned int nb_segs;
3249 res = parsed_result;
3250 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3251 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3253 set_tx_pkt_segments(seg_lengths, nb_segs);
3256 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3257 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3258 cmd_keyword, "set");
3259 cmdline_parse_token_string_t cmd_set_txpkts_name =
3260 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3262 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3263 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3266 cmdline_parse_inst_t cmd_set_txpkts = {
3267 .f = cmd_set_txpkts_parsed,
3269 .help_str = "set txpkts <len0[,len1]*>",
3271 (void *)&cmd_set_txpkts_keyword,
3272 (void *)&cmd_set_txpkts_name,
3273 (void *)&cmd_set_txpkts_lengths,
3278 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3280 struct cmd_set_txsplit_result {
3281 cmdline_fixed_string_t cmd_keyword;
3282 cmdline_fixed_string_t txsplit;
3283 cmdline_fixed_string_t mode;
3287 cmd_set_txsplit_parsed(void *parsed_result,
3288 __attribute__((unused)) struct cmdline *cl,
3289 __attribute__((unused)) void *data)
3291 struct cmd_set_txsplit_result *res;
3293 res = parsed_result;
3294 set_tx_pkt_split(res->mode);
3297 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3298 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3299 cmd_keyword, "set");
3300 cmdline_parse_token_string_t cmd_set_txsplit_name =
3301 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3302 txsplit, "txsplit");
3303 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3304 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3307 cmdline_parse_inst_t cmd_set_txsplit = {
3308 .f = cmd_set_txsplit_parsed,
3310 .help_str = "set txsplit on|off|rand",
3312 (void *)&cmd_set_txsplit_keyword,
3313 (void *)&cmd_set_txsplit_name,
3314 (void *)&cmd_set_txsplit_mode,
3319 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3320 struct cmd_rx_vlan_filter_all_result {
3321 cmdline_fixed_string_t rx_vlan;
3322 cmdline_fixed_string_t what;
3323 cmdline_fixed_string_t all;
3328 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3329 __attribute__((unused)) struct cmdline *cl,
3330 __attribute__((unused)) void *data)
3332 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3334 if (!strcmp(res->what, "add"))
3335 rx_vlan_all_filter_set(res->port_id, 1);
3337 rx_vlan_all_filter_set(res->port_id, 0);
3340 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3341 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3342 rx_vlan, "rx_vlan");
3343 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3344 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3346 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3347 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3349 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3350 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3353 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3354 .f = cmd_rx_vlan_filter_all_parsed,
3356 .help_str = "rx_vlan add|rm all <port_id>: "
3357 "Add/Remove all identifiers to/from the set of VLAN "
3358 "identifiers filtered by a port",
3360 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3361 (void *)&cmd_rx_vlan_filter_all_what,
3362 (void *)&cmd_rx_vlan_filter_all_all,
3363 (void *)&cmd_rx_vlan_filter_all_portid,
3368 /* *** VLAN OFFLOAD SET ON A PORT *** */
3369 struct cmd_vlan_offload_result {
3370 cmdline_fixed_string_t vlan;
3371 cmdline_fixed_string_t set;
3372 cmdline_fixed_string_t vlan_type;
3373 cmdline_fixed_string_t what;
3374 cmdline_fixed_string_t on;
3375 cmdline_fixed_string_t port_id;
3379 cmd_vlan_offload_parsed(void *parsed_result,
3380 __attribute__((unused)) struct cmdline *cl,
3381 __attribute__((unused)) void *data)
3384 struct cmd_vlan_offload_result *res = parsed_result;
3387 portid_t port_id = 0;
3391 len = strnlen(str, STR_TOKEN_SIZE);
3393 /* Get port_id first */
3401 tmp = strtoul(str, NULL, 0);
3402 /* If port_id greater that what portid_t can represent, return */
3403 if(tmp >= RTE_MAX_ETHPORTS)
3405 port_id = (portid_t)tmp;
3407 if (!strcmp(res->on, "on"))
3412 if (!strcmp(res->what, "strip"))
3413 rx_vlan_strip_set(port_id, on);
3414 else if(!strcmp(res->what, "stripq")){
3415 uint16_t queue_id = 0;
3417 /* No queue_id, return */
3419 printf("must specify (port,queue_id)\n");
3422 tmp = strtoul(str + i + 1, NULL, 0);
3423 /* If queue_id greater that what 16-bits can represent, return */
3427 queue_id = (uint16_t)tmp;
3428 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3430 else if (!strcmp(res->what, "filter"))
3431 rx_vlan_filter_set(port_id, on);
3433 vlan_extend_set(port_id, on);
3438 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3439 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3441 cmdline_parse_token_string_t cmd_vlan_offload_set =
3442 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3444 cmdline_parse_token_string_t cmd_vlan_offload_what =
3445 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3446 what, "strip#filter#qinq#stripq");
3447 cmdline_parse_token_string_t cmd_vlan_offload_on =
3448 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3450 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3451 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3454 cmdline_parse_inst_t cmd_vlan_offload = {
3455 .f = cmd_vlan_offload_parsed,
3457 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3458 "<port_id[,queue_id]>: "
3459 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3461 (void *)&cmd_vlan_offload_vlan,
3462 (void *)&cmd_vlan_offload_set,
3463 (void *)&cmd_vlan_offload_what,
3464 (void *)&cmd_vlan_offload_on,
3465 (void *)&cmd_vlan_offload_portid,
3470 /* *** VLAN TPID SET ON A PORT *** */
3471 struct cmd_vlan_tpid_result {
3472 cmdline_fixed_string_t vlan;
3473 cmdline_fixed_string_t set;
3474 cmdline_fixed_string_t vlan_type;
3475 cmdline_fixed_string_t what;
3481 cmd_vlan_tpid_parsed(void *parsed_result,
3482 __attribute__((unused)) struct cmdline *cl,
3483 __attribute__((unused)) void *data)
3485 struct cmd_vlan_tpid_result *res = parsed_result;
3486 enum rte_vlan_type vlan_type;
3488 if (!strcmp(res->vlan_type, "inner"))
3489 vlan_type = ETH_VLAN_TYPE_INNER;
3490 else if (!strcmp(res->vlan_type, "outer"))
3491 vlan_type = ETH_VLAN_TYPE_OUTER;
3493 printf("Unknown vlan type\n");
3496 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3499 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3500 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3502 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3503 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3505 cmdline_parse_token_string_t cmd_vlan_type =
3506 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3507 vlan_type, "inner#outer");
3508 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3509 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3511 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3512 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3514 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3515 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3518 cmdline_parse_inst_t cmd_vlan_tpid = {
3519 .f = cmd_vlan_tpid_parsed,
3521 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3522 "Set the VLAN Ether type",
3524 (void *)&cmd_vlan_tpid_vlan,
3525 (void *)&cmd_vlan_tpid_set,
3526 (void *)&cmd_vlan_type,
3527 (void *)&cmd_vlan_tpid_what,
3528 (void *)&cmd_vlan_tpid_tpid,
3529 (void *)&cmd_vlan_tpid_portid,
3534 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3535 struct cmd_rx_vlan_filter_result {
3536 cmdline_fixed_string_t rx_vlan;
3537 cmdline_fixed_string_t what;
3543 cmd_rx_vlan_filter_parsed(void *parsed_result,
3544 __attribute__((unused)) struct cmdline *cl,
3545 __attribute__((unused)) void *data)
3547 struct cmd_rx_vlan_filter_result *res = parsed_result;
3549 if (!strcmp(res->what, "add"))
3550 rx_vft_set(res->port_id, res->vlan_id, 1);
3552 rx_vft_set(res->port_id, res->vlan_id, 0);
3555 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3556 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3557 rx_vlan, "rx_vlan");
3558 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3559 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3561 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3562 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3564 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3565 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3568 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3569 .f = cmd_rx_vlan_filter_parsed,
3571 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3572 "Add/Remove a VLAN identifier to/from the set of VLAN "
3573 "identifiers filtered by a port",
3575 (void *)&cmd_rx_vlan_filter_rx_vlan,
3576 (void *)&cmd_rx_vlan_filter_what,
3577 (void *)&cmd_rx_vlan_filter_vlanid,
3578 (void *)&cmd_rx_vlan_filter_portid,
3583 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3584 struct cmd_tx_vlan_set_result {
3585 cmdline_fixed_string_t tx_vlan;
3586 cmdline_fixed_string_t set;
3592 cmd_tx_vlan_set_parsed(void *parsed_result,
3593 __attribute__((unused)) struct cmdline *cl,
3594 __attribute__((unused)) void *data)
3596 struct cmd_tx_vlan_set_result *res = parsed_result;
3598 if (!port_is_stopped(res->port_id)) {
3599 printf("Please stop port %d first\n", res->port_id);
3603 tx_vlan_set(res->port_id, res->vlan_id);
3605 cmd_reconfig_device_queue(res->port_id, 1, 1);
3608 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3609 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3610 tx_vlan, "tx_vlan");
3611 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3612 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3614 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3615 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3617 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3618 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3621 cmdline_parse_inst_t cmd_tx_vlan_set = {
3622 .f = cmd_tx_vlan_set_parsed,
3624 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3625 "Enable hardware insertion of a single VLAN header "
3626 "with a given TAG Identifier in packets sent on a port",
3628 (void *)&cmd_tx_vlan_set_tx_vlan,
3629 (void *)&cmd_tx_vlan_set_set,
3630 (void *)&cmd_tx_vlan_set_portid,
3631 (void *)&cmd_tx_vlan_set_vlanid,
3636 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3637 struct cmd_tx_vlan_set_qinq_result {
3638 cmdline_fixed_string_t tx_vlan;
3639 cmdline_fixed_string_t set;
3642 uint16_t vlan_id_outer;
3646 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3647 __attribute__((unused)) struct cmdline *cl,
3648 __attribute__((unused)) void *data)
3650 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3652 if (!port_is_stopped(res->port_id)) {
3653 printf("Please stop port %d first\n", res->port_id);
3657 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3659 cmd_reconfig_device_queue(res->port_id, 1, 1);
3662 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3663 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3664 tx_vlan, "tx_vlan");
3665 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3666 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3668 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3669 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3671 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3672 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3674 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3675 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3676 vlan_id_outer, UINT16);
3678 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3679 .f = cmd_tx_vlan_set_qinq_parsed,
3681 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3682 "Enable hardware insertion of double VLAN header "
3683 "with given TAG Identifiers in packets sent on a port",
3685 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3686 (void *)&cmd_tx_vlan_set_qinq_set,
3687 (void *)&cmd_tx_vlan_set_qinq_portid,
3688 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3689 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3694 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3695 struct cmd_tx_vlan_set_pvid_result {
3696 cmdline_fixed_string_t tx_vlan;
3697 cmdline_fixed_string_t set;
3698 cmdline_fixed_string_t pvid;
3701 cmdline_fixed_string_t mode;
3705 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3706 __attribute__((unused)) struct cmdline *cl,
3707 __attribute__((unused)) void *data)
3709 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3711 if (strcmp(res->mode, "on") == 0)
3712 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3714 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3717 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3718 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3719 tx_vlan, "tx_vlan");
3720 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3721 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3723 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3724 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3726 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3727 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3729 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3730 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3732 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3733 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3736 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3737 .f = cmd_tx_vlan_set_pvid_parsed,
3739 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3741 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3742 (void *)&cmd_tx_vlan_set_pvid_set,
3743 (void *)&cmd_tx_vlan_set_pvid_pvid,
3744 (void *)&cmd_tx_vlan_set_pvid_port_id,
3745 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3746 (void *)&cmd_tx_vlan_set_pvid_mode,
3751 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3752 struct cmd_tx_vlan_reset_result {
3753 cmdline_fixed_string_t tx_vlan;
3754 cmdline_fixed_string_t reset;
3759 cmd_tx_vlan_reset_parsed(void *parsed_result,
3760 __attribute__((unused)) struct cmdline *cl,
3761 __attribute__((unused)) void *data)
3763 struct cmd_tx_vlan_reset_result *res = parsed_result;
3765 if (!port_is_stopped(res->port_id)) {
3766 printf("Please stop port %d first\n", res->port_id);
3770 tx_vlan_reset(res->port_id);
3772 cmd_reconfig_device_queue(res->port_id, 1, 1);
3775 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3776 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3777 tx_vlan, "tx_vlan");
3778 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3779 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3781 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3782 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3785 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3786 .f = cmd_tx_vlan_reset_parsed,
3788 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3789 "VLAN header in packets sent on a port",
3791 (void *)&cmd_tx_vlan_reset_tx_vlan,
3792 (void *)&cmd_tx_vlan_reset_reset,
3793 (void *)&cmd_tx_vlan_reset_portid,
3799 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3800 struct cmd_csum_result {
3801 cmdline_fixed_string_t csum;
3802 cmdline_fixed_string_t mode;
3803 cmdline_fixed_string_t proto;
3804 cmdline_fixed_string_t hwsw;
3809 csum_show(int port_id)
3811 struct rte_eth_dev_info dev_info;
3812 uint64_t tx_offloads;
3814 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3815 printf("Parse tunnel is %s\n",
3816 (ports[port_id].parse_tunnel) ? "on" : "off");
3817 printf("IP checksum offload is %s\n",
3818 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3819 printf("UDP checksum offload is %s\n",
3820 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3821 printf("TCP checksum offload is %s\n",
3822 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3823 printf("SCTP checksum offload is %s\n",
3824 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3825 printf("Outer-Ip checksum offload is %s\n",
3826 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3828 /* display warnings if configuration is not supported by the NIC */
3829 rte_eth_dev_info_get(port_id, &dev_info);
3830 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3831 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3832 printf("Warning: hardware IP checksum enabled but not "
3833 "supported by port %d\n", port_id);
3835 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3836 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3837 printf("Warning: hardware UDP checksum enabled but not "
3838 "supported by port %d\n", port_id);
3840 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3841 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3842 printf("Warning: hardware TCP checksum enabled but not "
3843 "supported by port %d\n", port_id);
3845 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3846 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3847 printf("Warning: hardware SCTP checksum enabled but not "
3848 "supported by port %d\n", port_id);
3850 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3851 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3852 printf("Warning: hardware outer IP checksum enabled but not "
3853 "supported by port %d\n", port_id);
3858 cmd_csum_parsed(void *parsed_result,
3859 __attribute__((unused)) struct cmdline *cl,
3860 __attribute__((unused)) void *data)
3862 struct cmd_csum_result *res = parsed_result;
3864 uint64_t csum_offloads = 0;
3865 struct rte_eth_dev_info dev_info;
3867 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3868 printf("invalid port %d\n", res->port_id);
3871 if (!port_is_stopped(res->port_id)) {
3872 printf("Please stop port %d first\n", res->port_id);
3876 rte_eth_dev_info_get(res->port_id, &dev_info);
3877 if (!strcmp(res->mode, "set")) {
3879 if (!strcmp(res->hwsw, "hw"))
3882 if (!strcmp(res->proto, "ip")) {
3883 if (hw == 0 || (dev_info.tx_offload_capa &
3884 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
3885 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3887 printf("IP checksum offload is not supported "
3888 "by port %u\n", res->port_id);
3890 } else if (!strcmp(res->proto, "udp")) {
3891 if (hw == 0 || (dev_info.tx_offload_capa &
3892 DEV_TX_OFFLOAD_UDP_CKSUM)) {
3893 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3895 printf("UDP checksum offload is not supported "
3896 "by port %u\n", res->port_id);
3898 } else if (!strcmp(res->proto, "tcp")) {
3899 if (hw == 0 || (dev_info.tx_offload_capa &
3900 DEV_TX_OFFLOAD_TCP_CKSUM)) {
3901 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3903 printf("TCP checksum offload is not supported "
3904 "by port %u\n", res->port_id);
3906 } else if (!strcmp(res->proto, "sctp")) {
3907 if (hw == 0 || (dev_info.tx_offload_capa &
3908 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
3909 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3911 printf("SCTP checksum offload is not supported "
3912 "by port %u\n", res->port_id);
3914 } else if (!strcmp(res->proto, "outer-ip")) {
3915 if (hw == 0 || (dev_info.tx_offload_capa &
3916 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
3918 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3920 printf("Outer IP checksum offload is not "
3921 "supported by port %u\n", res->port_id);
3926 ports[res->port_id].dev_conf.txmode.offloads |=
3929 ports[res->port_id].dev_conf.txmode.offloads &=
3933 csum_show(res->port_id);
3935 cmd_reconfig_device_queue(res->port_id, 1, 1);
3938 cmdline_parse_token_string_t cmd_csum_csum =
3939 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3941 cmdline_parse_token_string_t cmd_csum_mode =
3942 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3944 cmdline_parse_token_string_t cmd_csum_proto =
3945 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3946 proto, "ip#tcp#udp#sctp#outer-ip");
3947 cmdline_parse_token_string_t cmd_csum_hwsw =
3948 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3950 cmdline_parse_token_num_t cmd_csum_portid =
3951 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3954 cmdline_parse_inst_t cmd_csum_set = {
3955 .f = cmd_csum_parsed,
3957 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3958 "Enable/Disable hardware calculation of L3/L4 checksum when "
3959 "using csum forward engine",
3961 (void *)&cmd_csum_csum,
3962 (void *)&cmd_csum_mode,
3963 (void *)&cmd_csum_proto,
3964 (void *)&cmd_csum_hwsw,
3965 (void *)&cmd_csum_portid,
3970 cmdline_parse_token_string_t cmd_csum_mode_show =
3971 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3974 cmdline_parse_inst_t cmd_csum_show = {
3975 .f = cmd_csum_parsed,
3977 .help_str = "csum show <port_id>: Show checksum offload configuration",
3979 (void *)&cmd_csum_csum,
3980 (void *)&cmd_csum_mode_show,
3981 (void *)&cmd_csum_portid,
3986 /* Enable/disable tunnel parsing */
3987 struct cmd_csum_tunnel_result {
3988 cmdline_fixed_string_t csum;
3989 cmdline_fixed_string_t parse;
3990 cmdline_fixed_string_t onoff;
3995 cmd_csum_tunnel_parsed(void *parsed_result,
3996 __attribute__((unused)) struct cmdline *cl,
3997 __attribute__((unused)) void *data)
3999 struct cmd_csum_tunnel_result *res = parsed_result;
4001 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4004 if (!strcmp(res->onoff, "on"))
4005 ports[res->port_id].parse_tunnel = 1;
4007 ports[res->port_id].parse_tunnel = 0;
4009 csum_show(res->port_id);
4012 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4013 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4015 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4016 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4017 parse, "parse_tunnel");
4018 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4019 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4021 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4022 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4025 cmdline_parse_inst_t cmd_csum_tunnel = {
4026 .f = cmd_csum_tunnel_parsed,
4028 .help_str = "csum parse_tunnel on|off <port_id>: "
4029 "Enable/Disable parsing of tunnels for csum engine",
4031 (void *)&cmd_csum_tunnel_csum,
4032 (void *)&cmd_csum_tunnel_parse,
4033 (void *)&cmd_csum_tunnel_onoff,
4034 (void *)&cmd_csum_tunnel_portid,
4039 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4040 struct cmd_tso_set_result {
4041 cmdline_fixed_string_t tso;
4042 cmdline_fixed_string_t mode;
4048 cmd_tso_set_parsed(void *parsed_result,
4049 __attribute__((unused)) struct cmdline *cl,
4050 __attribute__((unused)) void *data)
4052 struct cmd_tso_set_result *res = parsed_result;
4053 struct rte_eth_dev_info dev_info;
4055 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4057 if (!port_is_stopped(res->port_id)) {
4058 printf("Please stop port %d first\n", res->port_id);
4062 if (!strcmp(res->mode, "set"))
4063 ports[res->port_id].tso_segsz = res->tso_segsz;
4065 rte_eth_dev_info_get(res->port_id, &dev_info);
4066 if ((ports[res->port_id].tso_segsz != 0) &&
4067 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4068 printf("Error: TSO is not supported by port %d\n",
4073 if (ports[res->port_id].tso_segsz == 0) {
4074 ports[res->port_id].dev_conf.txmode.offloads &=
4075 ~DEV_TX_OFFLOAD_TCP_TSO;
4076 printf("TSO for non-tunneled packets is disabled\n");
4078 ports[res->port_id].dev_conf.txmode.offloads |=
4079 DEV_TX_OFFLOAD_TCP_TSO;
4080 printf("TSO segment size for non-tunneled packets is %d\n",
4081 ports[res->port_id].tso_segsz);
4084 /* display warnings if configuration is not supported by the NIC */
4085 rte_eth_dev_info_get(res->port_id, &dev_info);
4086 if ((ports[res->port_id].tso_segsz != 0) &&
4087 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4088 printf("Warning: TSO enabled but not "
4089 "supported by port %d\n", res->port_id);
4092 cmd_reconfig_device_queue(res->port_id, 1, 1);
4095 cmdline_parse_token_string_t cmd_tso_set_tso =
4096 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4098 cmdline_parse_token_string_t cmd_tso_set_mode =
4099 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4101 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4102 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4104 cmdline_parse_token_num_t cmd_tso_set_portid =
4105 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4108 cmdline_parse_inst_t cmd_tso_set = {
4109 .f = cmd_tso_set_parsed,
4111 .help_str = "tso set <tso_segsz> <port_id>: "
4112 "Set TSO segment size of non-tunneled packets for csum engine "
4115 (void *)&cmd_tso_set_tso,
4116 (void *)&cmd_tso_set_mode,
4117 (void *)&cmd_tso_set_tso_segsz,
4118 (void *)&cmd_tso_set_portid,
4123 cmdline_parse_token_string_t cmd_tso_show_mode =
4124 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4128 cmdline_parse_inst_t cmd_tso_show = {
4129 .f = cmd_tso_set_parsed,
4131 .help_str = "tso show <port_id>: "
4132 "Show TSO segment size of non-tunneled packets for csum engine",
4134 (void *)&cmd_tso_set_tso,
4135 (void *)&cmd_tso_show_mode,
4136 (void *)&cmd_tso_set_portid,
4141 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4142 struct cmd_tunnel_tso_set_result {
4143 cmdline_fixed_string_t tso;
4144 cmdline_fixed_string_t mode;
4149 static struct rte_eth_dev_info
4150 check_tunnel_tso_nic_support(portid_t port_id)
4152 struct rte_eth_dev_info dev_info;
4154 rte_eth_dev_info_get(port_id, &dev_info);
4155 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4156 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4157 "not enabled for port %d\n", port_id);
4158 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4159 printf("Warning: GRE TUNNEL TSO not supported therefore "
4160 "not enabled for port %d\n", port_id);
4161 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4162 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4163 "not enabled for port %d\n", port_id);
4164 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4165 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4166 "not enabled for port %d\n", port_id);
4167 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4168 printf("Warning: IP TUNNEL TSO not supported therefore "
4169 "not enabled for port %d\n", port_id);
4170 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4171 printf("Warning: UDP TUNNEL TSO not supported therefore "
4172 "not enabled for port %d\n", port_id);
4177 cmd_tunnel_tso_set_parsed(void *parsed_result,
4178 __attribute__((unused)) struct cmdline *cl,
4179 __attribute__((unused)) void *data)
4181 struct cmd_tunnel_tso_set_result *res = parsed_result;
4182 struct rte_eth_dev_info dev_info;
4184 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4186 if (!port_is_stopped(res->port_id)) {
4187 printf("Please stop port %d first\n", res->port_id);
4191 if (!strcmp(res->mode, "set"))
4192 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4194 dev_info = check_tunnel_tso_nic_support(res->port_id);
4195 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4196 ports[res->port_id].dev_conf.txmode.offloads &=
4197 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4198 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4199 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4200 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4201 DEV_TX_OFFLOAD_IP_TNL_TSO |
4202 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4203 printf("TSO for tunneled packets is disabled\n");
4205 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4206 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4207 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4208 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4209 DEV_TX_OFFLOAD_IP_TNL_TSO |
4210 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4212 ports[res->port_id].dev_conf.txmode.offloads |=
4213 (tso_offloads & dev_info.tx_offload_capa);
4214 printf("TSO segment size for tunneled packets is %d\n",
4215 ports[res->port_id].tunnel_tso_segsz);
4217 /* Below conditions are needed to make it work:
4218 * (1) tunnel TSO is supported by the NIC;
4219 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4221 * (3) for tunneled pkts with outer L3 of IPv4,
4222 * "csum set outer-ip" must be set to hw, because after tso,
4223 * total_len of outer IP header is changed, and the checksum
4224 * of outer IP header calculated by sw should be wrong; that
4225 * is not necessary for IPv6 tunneled pkts because there's no
4226 * checksum in IP header anymore.
4229 if (!ports[res->port_id].parse_tunnel)
4230 printf("Warning: csum parse_tunnel must be set "
4231 "so that tunneled packets are recognized\n");
4232 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4233 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4234 printf("Warning: csum set outer-ip must be set to hw "
4235 "if outer L3 is IPv4; not necessary for IPv6\n");
4238 cmd_reconfig_device_queue(res->port_id, 1, 1);
4241 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4242 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4244 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4245 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4247 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4248 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4250 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4251 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4254 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4255 .f = cmd_tunnel_tso_set_parsed,
4257 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4258 "Set TSO segment size of tunneled packets for csum engine "
4261 (void *)&cmd_tunnel_tso_set_tso,
4262 (void *)&cmd_tunnel_tso_set_mode,
4263 (void *)&cmd_tunnel_tso_set_tso_segsz,
4264 (void *)&cmd_tunnel_tso_set_portid,
4269 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4270 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4274 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4275 .f = cmd_tunnel_tso_set_parsed,
4277 .help_str = "tunnel_tso show <port_id> "
4278 "Show TSO segment size of tunneled packets for csum engine",
4280 (void *)&cmd_tunnel_tso_set_tso,
4281 (void *)&cmd_tunnel_tso_show_mode,
4282 (void *)&cmd_tunnel_tso_set_portid,
4287 /* *** SET GRO FOR A PORT *** */
4288 struct cmd_gro_enable_result {
4289 cmdline_fixed_string_t cmd_set;
4290 cmdline_fixed_string_t cmd_port;
4291 cmdline_fixed_string_t cmd_keyword;
4292 cmdline_fixed_string_t cmd_onoff;
4297 cmd_gro_enable_parsed(void *parsed_result,
4298 __attribute__((unused)) struct cmdline *cl,
4299 __attribute__((unused)) void *data)
4301 struct cmd_gro_enable_result *res;
4303 res = parsed_result;
4304 if (!strcmp(res->cmd_keyword, "gro"))
4305 setup_gro(res->cmd_onoff, res->cmd_pid);
4308 cmdline_parse_token_string_t cmd_gro_enable_set =
4309 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4311 cmdline_parse_token_string_t cmd_gro_enable_port =
4312 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4313 cmd_keyword, "port");
4314 cmdline_parse_token_num_t cmd_gro_enable_pid =
4315 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4317 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4318 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4319 cmd_keyword, "gro");
4320 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4321 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4322 cmd_onoff, "on#off");
4324 cmdline_parse_inst_t cmd_gro_enable = {
4325 .f = cmd_gro_enable_parsed,
4327 .help_str = "set port <port_id> gro on|off",
4329 (void *)&cmd_gro_enable_set,
4330 (void *)&cmd_gro_enable_port,
4331 (void *)&cmd_gro_enable_pid,
4332 (void *)&cmd_gro_enable_keyword,
4333 (void *)&cmd_gro_enable_onoff,
4338 /* *** DISPLAY GRO CONFIGURATION *** */
4339 struct cmd_gro_show_result {
4340 cmdline_fixed_string_t cmd_show;
4341 cmdline_fixed_string_t cmd_port;
4342 cmdline_fixed_string_t cmd_keyword;
4347 cmd_gro_show_parsed(void *parsed_result,
4348 __attribute__((unused)) struct cmdline *cl,
4349 __attribute__((unused)) void *data)
4351 struct cmd_gro_show_result *res;
4353 res = parsed_result;
4354 if (!strcmp(res->cmd_keyword, "gro"))
4355 show_gro(res->cmd_pid);
4358 cmdline_parse_token_string_t cmd_gro_show_show =
4359 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4361 cmdline_parse_token_string_t cmd_gro_show_port =
4362 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4364 cmdline_parse_token_num_t cmd_gro_show_pid =
4365 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4367 cmdline_parse_token_string_t cmd_gro_show_keyword =
4368 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4369 cmd_keyword, "gro");
4371 cmdline_parse_inst_t cmd_gro_show = {
4372 .f = cmd_gro_show_parsed,
4374 .help_str = "show port <port_id> gro",
4376 (void *)&cmd_gro_show_show,
4377 (void *)&cmd_gro_show_port,
4378 (void *)&cmd_gro_show_pid,
4379 (void *)&cmd_gro_show_keyword,
4384 /* *** SET FLUSH CYCLES FOR GRO *** */
4385 struct cmd_gro_flush_result {
4386 cmdline_fixed_string_t cmd_set;
4387 cmdline_fixed_string_t cmd_keyword;
4388 cmdline_fixed_string_t cmd_flush;
4393 cmd_gro_flush_parsed(void *parsed_result,
4394 __attribute__((unused)) struct cmdline *cl,
4395 __attribute__((unused)) void *data)
4397 struct cmd_gro_flush_result *res;
4399 res = parsed_result;
4400 if ((!strcmp(res->cmd_keyword, "gro")) &&
4401 (!strcmp(res->cmd_flush, "flush")))
4402 setup_gro_flush_cycles(res->cmd_cycles);
4405 cmdline_parse_token_string_t cmd_gro_flush_set =
4406 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4408 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4409 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4410 cmd_keyword, "gro");
4411 cmdline_parse_token_string_t cmd_gro_flush_flush =
4412 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4413 cmd_flush, "flush");
4414 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4415 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4418 cmdline_parse_inst_t cmd_gro_flush = {
4419 .f = cmd_gro_flush_parsed,
4421 .help_str = "set gro flush <cycles>",
4423 (void *)&cmd_gro_flush_set,
4424 (void *)&cmd_gro_flush_keyword,
4425 (void *)&cmd_gro_flush_flush,
4426 (void *)&cmd_gro_flush_cycles,
4431 /* *** ENABLE/DISABLE GSO *** */
4432 struct cmd_gso_enable_result {
4433 cmdline_fixed_string_t cmd_set;
4434 cmdline_fixed_string_t cmd_port;
4435 cmdline_fixed_string_t cmd_keyword;
4436 cmdline_fixed_string_t cmd_mode;
4441 cmd_gso_enable_parsed(void *parsed_result,
4442 __attribute__((unused)) struct cmdline *cl,
4443 __attribute__((unused)) void *data)
4445 struct cmd_gso_enable_result *res;
4447 res = parsed_result;
4448 if (!strcmp(res->cmd_keyword, "gso"))
4449 setup_gso(res->cmd_mode, res->cmd_pid);
4452 cmdline_parse_token_string_t cmd_gso_enable_set =
4453 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4455 cmdline_parse_token_string_t cmd_gso_enable_port =
4456 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4458 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4459 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4460 cmd_keyword, "gso");
4461 cmdline_parse_token_string_t cmd_gso_enable_mode =
4462 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4463 cmd_mode, "on#off");
4464 cmdline_parse_token_num_t cmd_gso_enable_pid =
4465 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4468 cmdline_parse_inst_t cmd_gso_enable = {
4469 .f = cmd_gso_enable_parsed,
4471 .help_str = "set port <port_id> gso on|off",
4473 (void *)&cmd_gso_enable_set,
4474 (void *)&cmd_gso_enable_port,
4475 (void *)&cmd_gso_enable_pid,
4476 (void *)&cmd_gso_enable_keyword,
4477 (void *)&cmd_gso_enable_mode,
4482 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4483 struct cmd_gso_size_result {
4484 cmdline_fixed_string_t cmd_set;
4485 cmdline_fixed_string_t cmd_keyword;
4486 cmdline_fixed_string_t cmd_segsz;
4491 cmd_gso_size_parsed(void *parsed_result,
4492 __attribute__((unused)) struct cmdline *cl,
4493 __attribute__((unused)) void *data)
4495 struct cmd_gso_size_result *res = parsed_result;
4497 if (test_done == 0) {
4498 printf("Before setting GSO segsz, please first"
4499 " stop fowarding\n");
4503 if (!strcmp(res->cmd_keyword, "gso") &&
4504 !strcmp(res->cmd_segsz, "segsz")) {
4505 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4506 printf("gso_size should be larger than %zu."
4507 " Please input a legal value\n",
4508 RTE_GSO_SEG_SIZE_MIN);
4510 gso_max_segment_size = res->cmd_size;
4514 cmdline_parse_token_string_t cmd_gso_size_set =
4515 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4517 cmdline_parse_token_string_t cmd_gso_size_keyword =
4518 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4519 cmd_keyword, "gso");
4520 cmdline_parse_token_string_t cmd_gso_size_segsz =
4521 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4522 cmd_segsz, "segsz");
4523 cmdline_parse_token_num_t cmd_gso_size_size =
4524 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4527 cmdline_parse_inst_t cmd_gso_size = {
4528 .f = cmd_gso_size_parsed,
4530 .help_str = "set gso segsz <length>",
4532 (void *)&cmd_gso_size_set,
4533 (void *)&cmd_gso_size_keyword,
4534 (void *)&cmd_gso_size_segsz,
4535 (void *)&cmd_gso_size_size,
4540 /* *** SHOW GSO CONFIGURATION *** */
4541 struct cmd_gso_show_result {
4542 cmdline_fixed_string_t cmd_show;
4543 cmdline_fixed_string_t cmd_port;
4544 cmdline_fixed_string_t cmd_keyword;
4549 cmd_gso_show_parsed(void *parsed_result,
4550 __attribute__((unused)) struct cmdline *cl,
4551 __attribute__((unused)) void *data)
4553 struct cmd_gso_show_result *res = parsed_result;
4555 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4556 printf("invalid port id %u\n", res->cmd_pid);
4559 if (!strcmp(res->cmd_keyword, "gso")) {
4560 if (gso_ports[res->cmd_pid].enable) {
4561 printf("Max GSO'd packet size: %uB\n"
4562 "Supported GSO types: TCP/IPv4, "
4563 "VxLAN with inner TCP/IPv4 packet, "
4564 "GRE with inner TCP/IPv4 packet\n",
4565 gso_max_segment_size);
4567 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4571 cmdline_parse_token_string_t cmd_gso_show_show =
4572 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4574 cmdline_parse_token_string_t cmd_gso_show_port =
4575 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4577 cmdline_parse_token_string_t cmd_gso_show_keyword =
4578 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4579 cmd_keyword, "gso");
4580 cmdline_parse_token_num_t cmd_gso_show_pid =
4581 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4584 cmdline_parse_inst_t cmd_gso_show = {
4585 .f = cmd_gso_show_parsed,
4587 .help_str = "show port <port_id> gso",
4589 (void *)&cmd_gso_show_show,
4590 (void *)&cmd_gso_show_port,
4591 (void *)&cmd_gso_show_pid,
4592 (void *)&cmd_gso_show_keyword,
4597 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4598 struct cmd_set_flush_rx {
4599 cmdline_fixed_string_t set;
4600 cmdline_fixed_string_t flush_rx;
4601 cmdline_fixed_string_t mode;
4605 cmd_set_flush_rx_parsed(void *parsed_result,
4606 __attribute__((unused)) struct cmdline *cl,
4607 __attribute__((unused)) void *data)
4609 struct cmd_set_flush_rx *res = parsed_result;
4610 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4613 cmdline_parse_token_string_t cmd_setflushrx_set =
4614 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4616 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4617 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4618 flush_rx, "flush_rx");
4619 cmdline_parse_token_string_t cmd_setflushrx_mode =
4620 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4624 cmdline_parse_inst_t cmd_set_flush_rx = {
4625 .f = cmd_set_flush_rx_parsed,
4626 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4629 (void *)&cmd_setflushrx_set,
4630 (void *)&cmd_setflushrx_flush_rx,
4631 (void *)&cmd_setflushrx_mode,
4636 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4637 struct cmd_set_link_check {
4638 cmdline_fixed_string_t set;
4639 cmdline_fixed_string_t link_check;
4640 cmdline_fixed_string_t mode;
4644 cmd_set_link_check_parsed(void *parsed_result,
4645 __attribute__((unused)) struct cmdline *cl,
4646 __attribute__((unused)) void *data)
4648 struct cmd_set_link_check *res = parsed_result;
4649 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4652 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4653 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4655 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4656 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4657 link_check, "link_check");
4658 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4659 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4663 cmdline_parse_inst_t cmd_set_link_check = {
4664 .f = cmd_set_link_check_parsed,
4665 .help_str = "set link_check on|off: Enable/Disable link status check "
4666 "when starting/stopping a port",
4669 (void *)&cmd_setlinkcheck_set,
4670 (void *)&cmd_setlinkcheck_link_check,
4671 (void *)&cmd_setlinkcheck_mode,
4676 /* *** SET NIC BYPASS MODE *** */
4677 struct cmd_set_bypass_mode_result {
4678 cmdline_fixed_string_t set;
4679 cmdline_fixed_string_t bypass;
4680 cmdline_fixed_string_t mode;
4681 cmdline_fixed_string_t value;
4686 cmd_set_bypass_mode_parsed(void *parsed_result,
4687 __attribute__((unused)) struct cmdline *cl,
4688 __attribute__((unused)) void *data)
4690 struct cmd_set_bypass_mode_result *res = parsed_result;
4691 portid_t port_id = res->port_id;
4692 int32_t rc = -EINVAL;
4694 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4695 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4697 if (!strcmp(res->value, "bypass"))
4698 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4699 else if (!strcmp(res->value, "isolate"))
4700 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4702 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4704 /* Set the bypass mode for the relevant port. */
4705 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4708 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4711 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4712 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4714 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4715 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4717 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4718 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4720 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4721 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4722 value, "normal#bypass#isolate");
4723 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4724 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4727 cmdline_parse_inst_t cmd_set_bypass_mode = {
4728 .f = cmd_set_bypass_mode_parsed,
4729 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4730 "Set the NIC bypass mode for port_id",
4733 (void *)&cmd_setbypass_mode_set,
4734 (void *)&cmd_setbypass_mode_bypass,
4735 (void *)&cmd_setbypass_mode_mode,
4736 (void *)&cmd_setbypass_mode_value,
4737 (void *)&cmd_setbypass_mode_port,
4742 /* *** SET NIC BYPASS EVENT *** */
4743 struct cmd_set_bypass_event_result {
4744 cmdline_fixed_string_t set;
4745 cmdline_fixed_string_t bypass;
4746 cmdline_fixed_string_t event;
4747 cmdline_fixed_string_t event_value;
4748 cmdline_fixed_string_t mode;
4749 cmdline_fixed_string_t mode_value;
4754 cmd_set_bypass_event_parsed(void *parsed_result,
4755 __attribute__((unused)) struct cmdline *cl,
4756 __attribute__((unused)) void *data)
4758 int32_t rc = -EINVAL;
4759 struct cmd_set_bypass_event_result *res = parsed_result;
4760 portid_t port_id = res->port_id;
4762 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4763 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4764 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4766 if (!strcmp(res->event_value, "timeout"))
4767 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4768 else if (!strcmp(res->event_value, "os_on"))
4769 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4770 else if (!strcmp(res->event_value, "os_off"))
4771 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4772 else if (!strcmp(res->event_value, "power_on"))
4773 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4774 else if (!strcmp(res->event_value, "power_off"))
4775 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4777 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4779 if (!strcmp(res->mode_value, "bypass"))
4780 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4781 else if (!strcmp(res->mode_value, "isolate"))
4782 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4784 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4786 /* Set the watchdog timeout. */
4787 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4790 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4791 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4795 printf("Failed to set timeout value %u "
4796 "for port %d, errto code: %d.\n",
4797 bypass_timeout, port_id, rc);
4801 /* Set the bypass event to transition to bypass mode. */
4802 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4807 printf("\t Failed to set bypass event for port = %d.\n",
4811 cmdline_parse_token_string_t cmd_setbypass_event_set =
4812 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4814 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4815 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4817 cmdline_parse_token_string_t cmd_setbypass_event_event =
4818 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4820 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4821 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4822 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4823 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4824 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4826 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4827 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4828 mode_value, "normal#bypass#isolate");
4829 cmdline_parse_token_num_t cmd_setbypass_event_port =
4830 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4833 cmdline_parse_inst_t cmd_set_bypass_event = {
4834 .f = cmd_set_bypass_event_parsed,
4835 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4836 "power_off mode normal|bypass|isolate <port_id>: "
4837 "Set the NIC bypass event mode for port_id",
4840 (void *)&cmd_setbypass_event_set,
4841 (void *)&cmd_setbypass_event_bypass,
4842 (void *)&cmd_setbypass_event_event,
4843 (void *)&cmd_setbypass_event_event_value,
4844 (void *)&cmd_setbypass_event_mode,
4845 (void *)&cmd_setbypass_event_mode_value,
4846 (void *)&cmd_setbypass_event_port,
4852 /* *** SET NIC BYPASS TIMEOUT *** */
4853 struct cmd_set_bypass_timeout_result {
4854 cmdline_fixed_string_t set;
4855 cmdline_fixed_string_t bypass;
4856 cmdline_fixed_string_t timeout;
4857 cmdline_fixed_string_t value;
4861 cmd_set_bypass_timeout_parsed(void *parsed_result,
4862 __attribute__((unused)) struct cmdline *cl,
4863 __attribute__((unused)) void *data)
4865 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4867 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4868 if (!strcmp(res->value, "1.5"))
4869 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4870 else if (!strcmp(res->value, "2"))
4871 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4872 else if (!strcmp(res->value, "3"))
4873 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4874 else if (!strcmp(res->value, "4"))
4875 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4876 else if (!strcmp(res->value, "8"))
4877 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4878 else if (!strcmp(res->value, "16"))
4879 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4880 else if (!strcmp(res->value, "32"))
4881 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4883 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4887 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4888 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4890 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4891 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4893 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4894 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4895 timeout, "timeout");
4896 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4897 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4898 value, "0#1.5#2#3#4#8#16#32");
4900 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4901 .f = cmd_set_bypass_timeout_parsed,
4902 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4903 "Set the NIC bypass watchdog timeout in seconds",
4906 (void *)&cmd_setbypass_timeout_set,
4907 (void *)&cmd_setbypass_timeout_bypass,
4908 (void *)&cmd_setbypass_timeout_timeout,
4909 (void *)&cmd_setbypass_timeout_value,
4914 /* *** SHOW NIC BYPASS MODE *** */
4915 struct cmd_show_bypass_config_result {
4916 cmdline_fixed_string_t show;
4917 cmdline_fixed_string_t bypass;
4918 cmdline_fixed_string_t config;
4923 cmd_show_bypass_config_parsed(void *parsed_result,
4924 __attribute__((unused)) struct cmdline *cl,
4925 __attribute__((unused)) void *data)
4927 struct cmd_show_bypass_config_result *res = parsed_result;
4928 portid_t port_id = res->port_id;
4930 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4931 uint32_t event_mode;
4932 uint32_t bypass_mode;
4933 uint32_t timeout = bypass_timeout;
4936 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4937 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4938 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4939 {"UNKNOWN", "normal", "bypass", "isolate"};
4940 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4947 int num_events = (sizeof events) / (sizeof events[0]);
4949 /* Display the bypass mode.*/
4950 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4951 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4955 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4956 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4958 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4961 /* Display the bypass timeout.*/
4962 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4963 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4965 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4967 /* Display the bypass events and associated modes. */
4968 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4970 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4971 printf("\tFailed to get bypass mode for event = %s\n",
4974 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4975 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4977 printf("\tbypass event: %-16s = %s\n", events[i],
4983 printf("\tFailed to get bypass configuration for port = %d\n",
4987 cmdline_parse_token_string_t cmd_showbypass_config_show =
4988 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4990 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4991 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4993 cmdline_parse_token_string_t cmd_showbypass_config_config =
4994 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4996 cmdline_parse_token_num_t cmd_showbypass_config_port =
4997 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5000 cmdline_parse_inst_t cmd_show_bypass_config = {
5001 .f = cmd_show_bypass_config_parsed,
5002 .help_str = "show bypass config <port_id>: "
5003 "Show the NIC bypass config for port_id",
5006 (void *)&cmd_showbypass_config_show,
5007 (void *)&cmd_showbypass_config_bypass,
5008 (void *)&cmd_showbypass_config_config,
5009 (void *)&cmd_showbypass_config_port,
5014 #ifdef RTE_LIBRTE_PMD_BOND
5015 /* *** SET BONDING MODE *** */
5016 struct cmd_set_bonding_mode_result {
5017 cmdline_fixed_string_t set;
5018 cmdline_fixed_string_t bonding;
5019 cmdline_fixed_string_t mode;
5024 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5025 __attribute__((unused)) struct cmdline *cl,
5026 __attribute__((unused)) void *data)
5028 struct cmd_set_bonding_mode_result *res = parsed_result;
5029 portid_t port_id = res->port_id;
5031 /* Set the bonding mode for the relevant port. */
5032 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5033 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5036 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5037 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5039 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5040 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5041 bonding, "bonding");
5042 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5043 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5045 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5046 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5048 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5049 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5052 cmdline_parse_inst_t cmd_set_bonding_mode = {
5053 .f = cmd_set_bonding_mode_parsed,
5054 .help_str = "set bonding mode <mode_value> <port_id>: "
5055 "Set the bonding mode for port_id",
5058 (void *) &cmd_setbonding_mode_set,
5059 (void *) &cmd_setbonding_mode_bonding,
5060 (void *) &cmd_setbonding_mode_mode,
5061 (void *) &cmd_setbonding_mode_value,
5062 (void *) &cmd_setbonding_mode_port,
5067 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5068 struct cmd_set_bonding_lacp_dedicated_queues_result {
5069 cmdline_fixed_string_t set;
5070 cmdline_fixed_string_t bonding;
5071 cmdline_fixed_string_t lacp;
5072 cmdline_fixed_string_t dedicated_queues;
5074 cmdline_fixed_string_t mode;
5077 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5078 __attribute__((unused)) struct cmdline *cl,
5079 __attribute__((unused)) void *data)
5081 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5082 portid_t port_id = res->port_id;
5083 struct rte_port *port;
5085 port = &ports[port_id];
5087 /** Check if the port is not started **/
5088 if (port->port_status != RTE_PORT_STOPPED) {
5089 printf("Please stop port %d first\n", port_id);
5093 if (!strcmp(res->mode, "enable")) {
5094 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5095 printf("Dedicate queues for LACP control packets"
5098 printf("Enabling dedicate queues for LACP control "
5099 "packets on port %d failed\n", port_id);
5100 } else if (!strcmp(res->mode, "disable")) {
5101 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5102 printf("Dedicated queues for LACP control packets "
5105 printf("Disabling dedicated queues for LACP control "
5106 "traffic on port %d failed\n", port_id);
5110 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5111 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5113 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5114 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5115 bonding, "bonding");
5116 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5117 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5119 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5120 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5121 dedicated_queues, "dedicated_queues");
5122 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5123 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5125 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5126 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5127 mode, "enable#disable");
5129 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5130 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5131 .help_str = "set bonding lacp dedicated_queues <port_id> "
5133 "Enable/disable dedicated queues for LACP control traffic for port_id",
5136 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5137 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5138 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5139 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5140 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5141 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5146 /* *** SET BALANCE XMIT POLICY *** */
5147 struct cmd_set_bonding_balance_xmit_policy_result {
5148 cmdline_fixed_string_t set;
5149 cmdline_fixed_string_t bonding;
5150 cmdline_fixed_string_t balance_xmit_policy;
5152 cmdline_fixed_string_t policy;
5155 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5156 __attribute__((unused)) struct cmdline *cl,
5157 __attribute__((unused)) void *data)
5159 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5160 portid_t port_id = res->port_id;
5163 if (!strcmp(res->policy, "l2")) {
5164 policy = BALANCE_XMIT_POLICY_LAYER2;
5165 } else if (!strcmp(res->policy, "l23")) {
5166 policy = BALANCE_XMIT_POLICY_LAYER23;
5167 } else if (!strcmp(res->policy, "l34")) {
5168 policy = BALANCE_XMIT_POLICY_LAYER34;
5170 printf("\t Invalid xmit policy selection");
5174 /* Set the bonding mode for the relevant port. */
5175 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5176 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5181 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5182 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5184 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5185 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5186 bonding, "bonding");
5187 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5188 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5189 balance_xmit_policy, "balance_xmit_policy");
5190 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5191 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5193 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5194 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5195 policy, "l2#l23#l34");
5197 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5198 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5199 .help_str = "set bonding balance_xmit_policy <port_id> "
5201 "Set the bonding balance_xmit_policy for port_id",
5204 (void *)&cmd_setbonding_balance_xmit_policy_set,
5205 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5206 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5207 (void *)&cmd_setbonding_balance_xmit_policy_port,
5208 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5213 /* *** SHOW NIC BONDING CONFIGURATION *** */
5214 struct cmd_show_bonding_config_result {
5215 cmdline_fixed_string_t show;
5216 cmdline_fixed_string_t bonding;
5217 cmdline_fixed_string_t config;
5221 static void cmd_show_bonding_config_parsed(void *parsed_result,
5222 __attribute__((unused)) struct cmdline *cl,
5223 __attribute__((unused)) void *data)
5225 struct cmd_show_bonding_config_result *res = parsed_result;
5226 int bonding_mode, agg_mode;
5227 portid_t slaves[RTE_MAX_ETHPORTS];
5228 int num_slaves, num_active_slaves;
5231 portid_t port_id = res->port_id;
5233 /* Display the bonding mode.*/
5234 bonding_mode = rte_eth_bond_mode_get(port_id);
5235 if (bonding_mode < 0) {
5236 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5239 printf("\tBonding mode: %d\n", bonding_mode);
5241 if (bonding_mode == BONDING_MODE_BALANCE) {
5242 int balance_xmit_policy;
5244 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5245 if (balance_xmit_policy < 0) {
5246 printf("\tFailed to get balance xmit policy for port = %d\n",
5250 printf("\tBalance Xmit Policy: ");
5252 switch (balance_xmit_policy) {
5253 case BALANCE_XMIT_POLICY_LAYER2:
5254 printf("BALANCE_XMIT_POLICY_LAYER2");
5256 case BALANCE_XMIT_POLICY_LAYER23:
5257 printf("BALANCE_XMIT_POLICY_LAYER23");
5259 case BALANCE_XMIT_POLICY_LAYER34:
5260 printf("BALANCE_XMIT_POLICY_LAYER34");
5267 if (bonding_mode == BONDING_MODE_8023AD) {
5268 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5269 printf("\tIEEE802.3AD Aggregator Mode: ");
5272 printf("bandwidth");
5284 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5286 if (num_slaves < 0) {
5287 printf("\tFailed to get slave list for port = %d\n", port_id);
5290 if (num_slaves > 0) {
5291 printf("\tSlaves (%d): [", num_slaves);
5292 for (i = 0; i < num_slaves - 1; i++)
5293 printf("%d ", slaves[i]);
5295 printf("%d]\n", slaves[num_slaves - 1]);
5297 printf("\tSlaves: []\n");
5301 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5304 if (num_active_slaves < 0) {
5305 printf("\tFailed to get active slave list for port = %d\n", port_id);
5308 if (num_active_slaves > 0) {
5309 printf("\tActive Slaves (%d): [", num_active_slaves);
5310 for (i = 0; i < num_active_slaves - 1; i++)
5311 printf("%d ", slaves[i]);
5313 printf("%d]\n", slaves[num_active_slaves - 1]);
5316 printf("\tActive Slaves: []\n");
5320 primary_id = rte_eth_bond_primary_get(port_id);
5321 if (primary_id < 0) {
5322 printf("\tFailed to get primary slave for port = %d\n", port_id);
5325 printf("\tPrimary: [%d]\n", primary_id);
5329 cmdline_parse_token_string_t cmd_showbonding_config_show =
5330 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5332 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5333 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5334 bonding, "bonding");
5335 cmdline_parse_token_string_t cmd_showbonding_config_config =
5336 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5338 cmdline_parse_token_num_t cmd_showbonding_config_port =
5339 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5342 cmdline_parse_inst_t cmd_show_bonding_config = {
5343 .f = cmd_show_bonding_config_parsed,
5344 .help_str = "show bonding config <port_id>: "
5345 "Show the bonding config for port_id",
5348 (void *)&cmd_showbonding_config_show,
5349 (void *)&cmd_showbonding_config_bonding,
5350 (void *)&cmd_showbonding_config_config,
5351 (void *)&cmd_showbonding_config_port,
5356 /* *** SET BONDING PRIMARY *** */
5357 struct cmd_set_bonding_primary_result {
5358 cmdline_fixed_string_t set;
5359 cmdline_fixed_string_t bonding;
5360 cmdline_fixed_string_t primary;
5365 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5366 __attribute__((unused)) struct cmdline *cl,
5367 __attribute__((unused)) void *data)
5369 struct cmd_set_bonding_primary_result *res = parsed_result;
5370 portid_t master_port_id = res->port_id;
5371 portid_t slave_port_id = res->slave_id;
5373 /* Set the primary slave for a bonded device. */
5374 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5375 printf("\t Failed to set primary slave for port = %d.\n",
5382 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5383 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5385 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5386 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5387 bonding, "bonding");
5388 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5389 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5390 primary, "primary");
5391 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5392 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5394 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5395 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5398 cmdline_parse_inst_t cmd_set_bonding_primary = {
5399 .f = cmd_set_bonding_primary_parsed,
5400 .help_str = "set bonding primary <slave_id> <port_id>: "
5401 "Set the primary slave for port_id",
5404 (void *)&cmd_setbonding_primary_set,
5405 (void *)&cmd_setbonding_primary_bonding,
5406 (void *)&cmd_setbonding_primary_primary,
5407 (void *)&cmd_setbonding_primary_slave,
5408 (void *)&cmd_setbonding_primary_port,
5413 /* *** ADD SLAVE *** */
5414 struct cmd_add_bonding_slave_result {
5415 cmdline_fixed_string_t add;
5416 cmdline_fixed_string_t bonding;
5417 cmdline_fixed_string_t slave;
5422 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5423 __attribute__((unused)) struct cmdline *cl,
5424 __attribute__((unused)) void *data)
5426 struct cmd_add_bonding_slave_result *res = parsed_result;
5427 portid_t master_port_id = res->port_id;
5428 portid_t slave_port_id = res->slave_id;
5430 /* add the slave for a bonded device. */
5431 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5432 printf("\t Failed to add slave %d to master port = %d.\n",
5433 slave_port_id, master_port_id);
5437 set_port_slave_flag(slave_port_id);
5440 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5441 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5443 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5444 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5445 bonding, "bonding");
5446 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5447 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5449 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5450 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5452 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5453 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5456 cmdline_parse_inst_t cmd_add_bonding_slave = {
5457 .f = cmd_add_bonding_slave_parsed,
5458 .help_str = "add bonding slave <slave_id> <port_id>: "
5459 "Add a slave device to a bonded device",
5462 (void *)&cmd_addbonding_slave_add,
5463 (void *)&cmd_addbonding_slave_bonding,
5464 (void *)&cmd_addbonding_slave_slave,
5465 (void *)&cmd_addbonding_slave_slaveid,
5466 (void *)&cmd_addbonding_slave_port,
5471 /* *** REMOVE SLAVE *** */
5472 struct cmd_remove_bonding_slave_result {
5473 cmdline_fixed_string_t remove;
5474 cmdline_fixed_string_t bonding;
5475 cmdline_fixed_string_t slave;
5480 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5481 __attribute__((unused)) struct cmdline *cl,
5482 __attribute__((unused)) void *data)
5484 struct cmd_remove_bonding_slave_result *res = parsed_result;
5485 portid_t master_port_id = res->port_id;
5486 portid_t slave_port_id = res->slave_id;
5488 /* remove the slave from a bonded device. */
5489 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5490 printf("\t Failed to remove slave %d from master port = %d.\n",
5491 slave_port_id, master_port_id);
5495 clear_port_slave_flag(slave_port_id);
5498 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5499 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5501 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5502 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5503 bonding, "bonding");
5504 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5505 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5507 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5508 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5510 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5511 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5514 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5515 .f = cmd_remove_bonding_slave_parsed,
5516 .help_str = "remove bonding slave <slave_id> <port_id>: "
5517 "Remove a slave device from a bonded device",
5520 (void *)&cmd_removebonding_slave_remove,
5521 (void *)&cmd_removebonding_slave_bonding,
5522 (void *)&cmd_removebonding_slave_slave,
5523 (void *)&cmd_removebonding_slave_slaveid,
5524 (void *)&cmd_removebonding_slave_port,
5529 /* *** CREATE BONDED DEVICE *** */
5530 struct cmd_create_bonded_device_result {
5531 cmdline_fixed_string_t create;
5532 cmdline_fixed_string_t bonded;
5533 cmdline_fixed_string_t device;
5538 static int bond_dev_num = 0;
5540 static void cmd_create_bonded_device_parsed(void *parsed_result,
5541 __attribute__((unused)) struct cmdline *cl,
5542 __attribute__((unused)) void *data)
5544 struct cmd_create_bonded_device_result *res = parsed_result;
5545 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5548 if (test_done == 0) {
5549 printf("Please stop forwarding first\n");
5553 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5556 /* Create a new bonded device. */
5557 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5559 printf("\t Failed to create bonded device.\n");
5562 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5565 /* Update number of ports */
5566 nb_ports = rte_eth_dev_count_avail();
5567 reconfig(port_id, res->socket);
5568 rte_eth_promiscuous_enable(port_id);
5573 cmdline_parse_token_string_t cmd_createbonded_device_create =
5574 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5576 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5577 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5579 cmdline_parse_token_string_t cmd_createbonded_device_device =
5580 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5582 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5583 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5585 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5586 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5589 cmdline_parse_inst_t cmd_create_bonded_device = {
5590 .f = cmd_create_bonded_device_parsed,
5591 .help_str = "create bonded device <mode> <socket>: "
5592 "Create a new bonded device with specific bonding mode and socket",
5595 (void *)&cmd_createbonded_device_create,
5596 (void *)&cmd_createbonded_device_bonded,
5597 (void *)&cmd_createbonded_device_device,
5598 (void *)&cmd_createbonded_device_mode,
5599 (void *)&cmd_createbonded_device_socket,
5604 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5605 struct cmd_set_bond_mac_addr_result {
5606 cmdline_fixed_string_t set;
5607 cmdline_fixed_string_t bonding;
5608 cmdline_fixed_string_t mac_addr;
5610 struct ether_addr address;
5613 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5614 __attribute__((unused)) struct cmdline *cl,
5615 __attribute__((unused)) void *data)
5617 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5620 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5623 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5625 /* check the return value and print it if is < 0 */
5627 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5630 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5631 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5632 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5633 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5635 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5636 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5638 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5639 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5641 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5642 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5644 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5645 .f = cmd_set_bond_mac_addr_parsed,
5647 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5649 (void *)&cmd_set_bond_mac_addr_set,
5650 (void *)&cmd_set_bond_mac_addr_bonding,
5651 (void *)&cmd_set_bond_mac_addr_mac,
5652 (void *)&cmd_set_bond_mac_addr_portnum,
5653 (void *)&cmd_set_bond_mac_addr_addr,
5659 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5660 struct cmd_set_bond_mon_period_result {
5661 cmdline_fixed_string_t set;
5662 cmdline_fixed_string_t bonding;
5663 cmdline_fixed_string_t mon_period;
5668 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5669 __attribute__((unused)) struct cmdline *cl,
5670 __attribute__((unused)) void *data)
5672 struct cmd_set_bond_mon_period_result *res = parsed_result;
5675 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5677 /* check the return value and print it if is < 0 */
5679 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5682 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5683 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5685 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5686 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5687 bonding, "bonding");
5688 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5689 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5690 mon_period, "mon_period");
5691 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5692 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5694 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5695 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5698 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5699 .f = cmd_set_bond_mon_period_parsed,
5701 .help_str = "set bonding mon_period <port_id> <period_ms>",
5703 (void *)&cmd_set_bond_mon_period_set,
5704 (void *)&cmd_set_bond_mon_period_bonding,
5705 (void *)&cmd_set_bond_mon_period_mon_period,
5706 (void *)&cmd_set_bond_mon_period_portnum,
5707 (void *)&cmd_set_bond_mon_period_period_ms,
5714 struct cmd_set_bonding_agg_mode_policy_result {
5715 cmdline_fixed_string_t set;
5716 cmdline_fixed_string_t bonding;
5717 cmdline_fixed_string_t agg_mode;
5719 cmdline_fixed_string_t policy;
5724 cmd_set_bonding_agg_mode(void *parsed_result,
5725 __attribute__((unused)) struct cmdline *cl,
5726 __attribute__((unused)) void *data)
5728 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5729 uint8_t policy = AGG_BANDWIDTH;
5731 if (!strcmp(res->policy, "bandwidth"))
5732 policy = AGG_BANDWIDTH;
5733 else if (!strcmp(res->policy, "stable"))
5734 policy = AGG_STABLE;
5735 else if (!strcmp(res->policy, "count"))
5738 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5742 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5743 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5745 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5746 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5747 bonding, "bonding");
5749 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5751 agg_mode, "agg_mode");
5753 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5754 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5757 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5758 TOKEN_STRING_INITIALIZER(
5759 struct cmd_set_bonding_balance_xmit_policy_result,
5760 policy, "stable#bandwidth#count");
5762 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5763 .f = cmd_set_bonding_agg_mode,
5765 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5767 (void *)&cmd_set_bonding_agg_mode_set,
5768 (void *)&cmd_set_bonding_agg_mode_bonding,
5769 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5770 (void *)&cmd_set_bonding_agg_mode_portnum,
5771 (void *)&cmd_set_bonding_agg_mode_policy_string,
5777 #endif /* RTE_LIBRTE_PMD_BOND */
5779 /* *** SET FORWARDING MODE *** */
5780 struct cmd_set_fwd_mode_result {
5781 cmdline_fixed_string_t set;
5782 cmdline_fixed_string_t fwd;
5783 cmdline_fixed_string_t mode;
5786 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5787 __attribute__((unused)) struct cmdline *cl,
5788 __attribute__((unused)) void *data)
5790 struct cmd_set_fwd_mode_result *res = parsed_result;
5793 set_pkt_forwarding_mode(res->mode);
5796 cmdline_parse_token_string_t cmd_setfwd_set =
5797 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5798 cmdline_parse_token_string_t cmd_setfwd_fwd =
5799 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5800 cmdline_parse_token_string_t cmd_setfwd_mode =
5801 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5802 "" /* defined at init */);
5804 cmdline_parse_inst_t cmd_set_fwd_mode = {
5805 .f = cmd_set_fwd_mode_parsed,
5807 .help_str = NULL, /* defined at init */
5809 (void *)&cmd_setfwd_set,
5810 (void *)&cmd_setfwd_fwd,
5811 (void *)&cmd_setfwd_mode,
5816 static void cmd_set_fwd_mode_init(void)
5819 static char token[128];
5820 static char help[256];
5821 cmdline_parse_token_string_t *token_struct;
5823 modes = list_pkt_forwarding_modes();
5824 snprintf(help, sizeof(help), "set fwd %s: "
5825 "Set packet forwarding mode", modes);
5826 cmd_set_fwd_mode.help_str = help;
5828 /* string token separator is # */
5829 for (c = token; *modes != '\0'; modes++)
5834 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5835 token_struct->string_data.str = token;
5838 /* *** SET RETRY FORWARDING MODE *** */
5839 struct cmd_set_fwd_retry_mode_result {
5840 cmdline_fixed_string_t set;
5841 cmdline_fixed_string_t fwd;
5842 cmdline_fixed_string_t mode;
5843 cmdline_fixed_string_t retry;
5846 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5847 __attribute__((unused)) struct cmdline *cl,
5848 __attribute__((unused)) void *data)
5850 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5853 set_pkt_forwarding_mode(res->mode);
5856 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5857 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5859 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5860 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5862 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5863 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5865 "" /* defined at init */);
5866 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5867 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5870 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5871 .f = cmd_set_fwd_retry_mode_parsed,
5873 .help_str = NULL, /* defined at init */
5875 (void *)&cmd_setfwd_retry_set,
5876 (void *)&cmd_setfwd_retry_fwd,
5877 (void *)&cmd_setfwd_retry_mode,
5878 (void *)&cmd_setfwd_retry_retry,
5883 static void cmd_set_fwd_retry_mode_init(void)
5886 static char token[128];
5887 static char help[256];
5888 cmdline_parse_token_string_t *token_struct;
5890 modes = list_pkt_forwarding_retry_modes();
5891 snprintf(help, sizeof(help), "set fwd %s retry: "
5892 "Set packet forwarding mode with retry", modes);
5893 cmd_set_fwd_retry_mode.help_str = help;
5895 /* string token separator is # */
5896 for (c = token; *modes != '\0'; modes++)
5901 token_struct = (cmdline_parse_token_string_t *)
5902 cmd_set_fwd_retry_mode.tokens[2];
5903 token_struct->string_data.str = token;
5906 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5907 struct cmd_set_burst_tx_retry_result {
5908 cmdline_fixed_string_t set;
5909 cmdline_fixed_string_t burst;
5910 cmdline_fixed_string_t tx;
5911 cmdline_fixed_string_t delay;
5913 cmdline_fixed_string_t retry;
5917 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5918 __attribute__((unused)) struct cmdline *cl,
5919 __attribute__((unused)) void *data)
5921 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5923 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5924 && !strcmp(res->tx, "tx")) {
5925 if (!strcmp(res->delay, "delay"))
5926 burst_tx_delay_time = res->time;
5927 if (!strcmp(res->retry, "retry"))
5928 burst_tx_retry_num = res->retry_num;
5933 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5934 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5935 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5936 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5938 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5939 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5940 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5941 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5942 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5943 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5944 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5945 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5946 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5947 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5949 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5950 .f = cmd_set_burst_tx_retry_parsed,
5951 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5953 (void *)&cmd_set_burst_tx_retry_set,
5954 (void *)&cmd_set_burst_tx_retry_burst,
5955 (void *)&cmd_set_burst_tx_retry_tx,
5956 (void *)&cmd_set_burst_tx_retry_delay,
5957 (void *)&cmd_set_burst_tx_retry_time,
5958 (void *)&cmd_set_burst_tx_retry_retry,
5959 (void *)&cmd_set_burst_tx_retry_retry_num,
5964 /* *** SET PROMISC MODE *** */
5965 struct cmd_set_promisc_mode_result {
5966 cmdline_fixed_string_t set;
5967 cmdline_fixed_string_t promisc;
5968 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5969 uint16_t port_num; /* valid if "allports" argument == 0 */
5970 cmdline_fixed_string_t mode;
5973 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5974 __attribute__((unused)) struct cmdline *cl,
5977 struct cmd_set_promisc_mode_result *res = parsed_result;
5981 if (!strcmp(res->mode, "on"))
5988 RTE_ETH_FOREACH_DEV(i) {
5990 rte_eth_promiscuous_enable(i);
5992 rte_eth_promiscuous_disable(i);
5997 rte_eth_promiscuous_enable(res->port_num);
5999 rte_eth_promiscuous_disable(res->port_num);
6003 cmdline_parse_token_string_t cmd_setpromisc_set =
6004 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6005 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6006 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6008 cmdline_parse_token_string_t cmd_setpromisc_portall =
6009 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6011 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6012 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6014 cmdline_parse_token_string_t cmd_setpromisc_mode =
6015 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6018 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6019 .f = cmd_set_promisc_mode_parsed,
6021 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6023 (void *)&cmd_setpromisc_set,
6024 (void *)&cmd_setpromisc_promisc,
6025 (void *)&cmd_setpromisc_portall,
6026 (void *)&cmd_setpromisc_mode,
6031 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6032 .f = cmd_set_promisc_mode_parsed,
6034 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6036 (void *)&cmd_setpromisc_set,
6037 (void *)&cmd_setpromisc_promisc,
6038 (void *)&cmd_setpromisc_portnum,
6039 (void *)&cmd_setpromisc_mode,
6044 /* *** SET ALLMULTI MODE *** */
6045 struct cmd_set_allmulti_mode_result {
6046 cmdline_fixed_string_t set;
6047 cmdline_fixed_string_t allmulti;
6048 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6049 uint16_t port_num; /* valid if "allports" argument == 0 */
6050 cmdline_fixed_string_t mode;
6053 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6054 __attribute__((unused)) struct cmdline *cl,
6057 struct cmd_set_allmulti_mode_result *res = parsed_result;
6061 if (!strcmp(res->mode, "on"))
6068 RTE_ETH_FOREACH_DEV(i) {
6070 rte_eth_allmulticast_enable(i);
6072 rte_eth_allmulticast_disable(i);
6077 rte_eth_allmulticast_enable(res->port_num);
6079 rte_eth_allmulticast_disable(res->port_num);
6083 cmdline_parse_token_string_t cmd_setallmulti_set =
6084 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6085 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6086 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6088 cmdline_parse_token_string_t cmd_setallmulti_portall =
6089 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6091 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6092 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6094 cmdline_parse_token_string_t cmd_setallmulti_mode =
6095 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6098 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6099 .f = cmd_set_allmulti_mode_parsed,
6101 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6103 (void *)&cmd_setallmulti_set,
6104 (void *)&cmd_setallmulti_allmulti,
6105 (void *)&cmd_setallmulti_portall,
6106 (void *)&cmd_setallmulti_mode,
6111 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6112 .f = cmd_set_allmulti_mode_parsed,
6114 .help_str = "set allmulti <port_id> on|off: "
6115 "Set allmulti mode on port_id",
6117 (void *)&cmd_setallmulti_set,
6118 (void *)&cmd_setallmulti_allmulti,
6119 (void *)&cmd_setallmulti_portnum,
6120 (void *)&cmd_setallmulti_mode,
6125 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6126 struct cmd_link_flow_ctrl_set_result {
6127 cmdline_fixed_string_t set;
6128 cmdline_fixed_string_t flow_ctrl;
6129 cmdline_fixed_string_t rx;
6130 cmdline_fixed_string_t rx_lfc_mode;
6131 cmdline_fixed_string_t tx;
6132 cmdline_fixed_string_t tx_lfc_mode;
6133 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6134 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6135 cmdline_fixed_string_t autoneg_str;
6136 cmdline_fixed_string_t autoneg;
6137 cmdline_fixed_string_t hw_str;
6138 uint32_t high_water;
6139 cmdline_fixed_string_t lw_str;
6141 cmdline_fixed_string_t pt_str;
6142 uint16_t pause_time;
6143 cmdline_fixed_string_t xon_str;
6148 cmdline_parse_token_string_t cmd_lfc_set_set =
6149 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6151 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6152 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6153 flow_ctrl, "flow_ctrl");
6154 cmdline_parse_token_string_t cmd_lfc_set_rx =
6155 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6157 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6158 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6159 rx_lfc_mode, "on#off");
6160 cmdline_parse_token_string_t cmd_lfc_set_tx =
6161 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6163 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6164 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6165 tx_lfc_mode, "on#off");
6166 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6168 hw_str, "high_water");
6169 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6170 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6171 high_water, UINT32);
6172 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6174 lw_str, "low_water");
6175 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6176 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6178 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6179 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6180 pt_str, "pause_time");
6181 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6182 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6183 pause_time, UINT16);
6184 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6185 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6186 xon_str, "send_xon");
6187 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6188 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6190 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6191 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6192 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6193 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6194 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6195 mac_ctrl_frame_fwd_mode, "on#off");
6196 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6197 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6198 autoneg_str, "autoneg");
6199 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6200 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6202 cmdline_parse_token_num_t cmd_lfc_set_portid =
6203 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6206 /* forward declaration */
6208 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6211 cmdline_parse_inst_t cmd_link_flow_control_set = {
6212 .f = cmd_link_flow_ctrl_set_parsed,
6214 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6215 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6216 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6218 (void *)&cmd_lfc_set_set,
6219 (void *)&cmd_lfc_set_flow_ctrl,
6220 (void *)&cmd_lfc_set_rx,
6221 (void *)&cmd_lfc_set_rx_mode,
6222 (void *)&cmd_lfc_set_tx,
6223 (void *)&cmd_lfc_set_tx_mode,
6224 (void *)&cmd_lfc_set_high_water,
6225 (void *)&cmd_lfc_set_low_water,
6226 (void *)&cmd_lfc_set_pause_time,
6227 (void *)&cmd_lfc_set_send_xon,
6228 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6229 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6230 (void *)&cmd_lfc_set_autoneg_str,
6231 (void *)&cmd_lfc_set_autoneg,
6232 (void *)&cmd_lfc_set_portid,
6237 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6238 .f = cmd_link_flow_ctrl_set_parsed,
6239 .data = (void *)&cmd_link_flow_control_set_rx,
6240 .help_str = "set flow_ctrl rx on|off <port_id>: "
6241 "Change rx flow control parameter",
6243 (void *)&cmd_lfc_set_set,
6244 (void *)&cmd_lfc_set_flow_ctrl,
6245 (void *)&cmd_lfc_set_rx,
6246 (void *)&cmd_lfc_set_rx_mode,
6247 (void *)&cmd_lfc_set_portid,
6252 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6253 .f = cmd_link_flow_ctrl_set_parsed,
6254 .data = (void *)&cmd_link_flow_control_set_tx,
6255 .help_str = "set flow_ctrl tx on|off <port_id>: "
6256 "Change tx flow control parameter",
6258 (void *)&cmd_lfc_set_set,
6259 (void *)&cmd_lfc_set_flow_ctrl,
6260 (void *)&cmd_lfc_set_tx,
6261 (void *)&cmd_lfc_set_tx_mode,
6262 (void *)&cmd_lfc_set_portid,
6267 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6268 .f = cmd_link_flow_ctrl_set_parsed,
6269 .data = (void *)&cmd_link_flow_control_set_hw,
6270 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6271 "Change high water flow control parameter",
6273 (void *)&cmd_lfc_set_set,
6274 (void *)&cmd_lfc_set_flow_ctrl,
6275 (void *)&cmd_lfc_set_high_water_str,
6276 (void *)&cmd_lfc_set_high_water,
6277 (void *)&cmd_lfc_set_portid,
6282 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6283 .f = cmd_link_flow_ctrl_set_parsed,
6284 .data = (void *)&cmd_link_flow_control_set_lw,
6285 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6286 "Change low water flow control parameter",
6288 (void *)&cmd_lfc_set_set,
6289 (void *)&cmd_lfc_set_flow_ctrl,
6290 (void *)&cmd_lfc_set_low_water_str,
6291 (void *)&cmd_lfc_set_low_water,
6292 (void *)&cmd_lfc_set_portid,
6297 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6298 .f = cmd_link_flow_ctrl_set_parsed,
6299 .data = (void *)&cmd_link_flow_control_set_pt,
6300 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6301 "Change pause time flow control parameter",
6303 (void *)&cmd_lfc_set_set,
6304 (void *)&cmd_lfc_set_flow_ctrl,
6305 (void *)&cmd_lfc_set_pause_time_str,
6306 (void *)&cmd_lfc_set_pause_time,
6307 (void *)&cmd_lfc_set_portid,
6312 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6313 .f = cmd_link_flow_ctrl_set_parsed,
6314 .data = (void *)&cmd_link_flow_control_set_xon,
6315 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6316 "Change send_xon flow control parameter",
6318 (void *)&cmd_lfc_set_set,
6319 (void *)&cmd_lfc_set_flow_ctrl,
6320 (void *)&cmd_lfc_set_send_xon_str,
6321 (void *)&cmd_lfc_set_send_xon,
6322 (void *)&cmd_lfc_set_portid,
6327 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6328 .f = cmd_link_flow_ctrl_set_parsed,
6329 .data = (void *)&cmd_link_flow_control_set_macfwd,
6330 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6331 "Change mac ctrl fwd flow control parameter",
6333 (void *)&cmd_lfc_set_set,
6334 (void *)&cmd_lfc_set_flow_ctrl,
6335 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6336 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6337 (void *)&cmd_lfc_set_portid,
6342 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6343 .f = cmd_link_flow_ctrl_set_parsed,
6344 .data = (void *)&cmd_link_flow_control_set_autoneg,
6345 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6346 "Change autoneg flow control parameter",
6348 (void *)&cmd_lfc_set_set,
6349 (void *)&cmd_lfc_set_flow_ctrl,
6350 (void *)&cmd_lfc_set_autoneg_str,
6351 (void *)&cmd_lfc_set_autoneg,
6352 (void *)&cmd_lfc_set_portid,
6358 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6359 __attribute__((unused)) struct cmdline *cl,
6362 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6363 cmdline_parse_inst_t *cmd = data;
6364 struct rte_eth_fc_conf fc_conf;
6370 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6371 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6372 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6373 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6375 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6376 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6379 /* Partial command line, retrieve current configuration */
6381 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6383 printf("cannot get current flow ctrl parameters, return"
6384 "code = %d\n", ret);
6388 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6389 (fc_conf.mode == RTE_FC_FULL))
6391 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6392 (fc_conf.mode == RTE_FC_FULL))
6396 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6397 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6399 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6400 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6402 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6404 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6405 fc_conf.high_water = res->high_water;
6407 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6408 fc_conf.low_water = res->low_water;
6410 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6411 fc_conf.pause_time = res->pause_time;
6413 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6414 fc_conf.send_xon = res->send_xon;
6416 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6417 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6418 fc_conf.mac_ctrl_frame_fwd = 1;
6420 fc_conf.mac_ctrl_frame_fwd = 0;
6423 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6424 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6426 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6428 printf("bad flow contrl parameter, return code = %d \n", ret);
6431 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6432 struct cmd_priority_flow_ctrl_set_result {
6433 cmdline_fixed_string_t set;
6434 cmdline_fixed_string_t pfc_ctrl;
6435 cmdline_fixed_string_t rx;
6436 cmdline_fixed_string_t rx_pfc_mode;
6437 cmdline_fixed_string_t tx;
6438 cmdline_fixed_string_t tx_pfc_mode;
6439 uint32_t high_water;
6441 uint16_t pause_time;
6447 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6448 __attribute__((unused)) struct cmdline *cl,
6449 __attribute__((unused)) void *data)
6451 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6452 struct rte_eth_pfc_conf pfc_conf;
6453 int rx_fc_enable, tx_fc_enable;
6457 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6458 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6459 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6460 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6462 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6463 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6466 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6467 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6468 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6469 pfc_conf.fc.high_water = res->high_water;
6470 pfc_conf.fc.low_water = res->low_water;
6471 pfc_conf.fc.pause_time = res->pause_time;
6472 pfc_conf.priority = res->priority;
6474 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6476 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6479 cmdline_parse_token_string_t cmd_pfc_set_set =
6480 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6482 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6483 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6484 pfc_ctrl, "pfc_ctrl");
6485 cmdline_parse_token_string_t cmd_pfc_set_rx =
6486 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6488 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6489 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6490 rx_pfc_mode, "on#off");
6491 cmdline_parse_token_string_t cmd_pfc_set_tx =
6492 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6494 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6495 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6496 tx_pfc_mode, "on#off");
6497 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6498 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6499 high_water, UINT32);
6500 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6501 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6503 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6504 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6505 pause_time, UINT16);
6506 cmdline_parse_token_num_t cmd_pfc_set_priority =
6507 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6509 cmdline_parse_token_num_t cmd_pfc_set_portid =
6510 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6513 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6514 .f = cmd_priority_flow_ctrl_set_parsed,
6516 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6517 "<pause_time> <priority> <port_id>: "
6518 "Configure the Ethernet priority flow control",
6520 (void *)&cmd_pfc_set_set,
6521 (void *)&cmd_pfc_set_flow_ctrl,
6522 (void *)&cmd_pfc_set_rx,
6523 (void *)&cmd_pfc_set_rx_mode,
6524 (void *)&cmd_pfc_set_tx,
6525 (void *)&cmd_pfc_set_tx_mode,
6526 (void *)&cmd_pfc_set_high_water,
6527 (void *)&cmd_pfc_set_low_water,
6528 (void *)&cmd_pfc_set_pause_time,
6529 (void *)&cmd_pfc_set_priority,
6530 (void *)&cmd_pfc_set_portid,
6535 /* *** RESET CONFIGURATION *** */
6536 struct cmd_reset_result {
6537 cmdline_fixed_string_t reset;
6538 cmdline_fixed_string_t def;
6541 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6543 __attribute__((unused)) void *data)
6545 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6546 set_def_fwd_config();
6549 cmdline_parse_token_string_t cmd_reset_set =
6550 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6551 cmdline_parse_token_string_t cmd_reset_def =
6552 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6555 cmdline_parse_inst_t cmd_reset = {
6556 .f = cmd_reset_parsed,
6558 .help_str = "set default: Reset default forwarding configuration",
6560 (void *)&cmd_reset_set,
6561 (void *)&cmd_reset_def,
6566 /* *** START FORWARDING *** */
6567 struct cmd_start_result {
6568 cmdline_fixed_string_t start;
6571 cmdline_parse_token_string_t cmd_start_start =
6572 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6574 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6575 __attribute__((unused)) struct cmdline *cl,
6576 __attribute__((unused)) void *data)
6578 start_packet_forwarding(0);
6581 cmdline_parse_inst_t cmd_start = {
6582 .f = cmd_start_parsed,
6584 .help_str = "start: Start packet forwarding",
6586 (void *)&cmd_start_start,
6591 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6592 struct cmd_start_tx_first_result {
6593 cmdline_fixed_string_t start;
6594 cmdline_fixed_string_t tx_first;
6598 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6599 __attribute__((unused)) struct cmdline *cl,
6600 __attribute__((unused)) void *data)
6602 start_packet_forwarding(1);
6605 cmdline_parse_token_string_t cmd_start_tx_first_start =
6606 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6608 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6609 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6610 tx_first, "tx_first");
6612 cmdline_parse_inst_t cmd_start_tx_first = {
6613 .f = cmd_start_tx_first_parsed,
6615 .help_str = "start tx_first: Start packet forwarding, "
6616 "after sending 1 burst of packets",
6618 (void *)&cmd_start_tx_first_start,
6619 (void *)&cmd_start_tx_first_tx_first,
6624 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6625 struct cmd_start_tx_first_n_result {
6626 cmdline_fixed_string_t start;
6627 cmdline_fixed_string_t tx_first;
6632 cmd_start_tx_first_n_parsed(void *parsed_result,
6633 __attribute__((unused)) struct cmdline *cl,
6634 __attribute__((unused)) void *data)
6636 struct cmd_start_tx_first_n_result *res = parsed_result;
6638 start_packet_forwarding(res->tx_num);
6641 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6642 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6644 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6645 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6646 tx_first, "tx_first");
6647 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6648 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6651 cmdline_parse_inst_t cmd_start_tx_first_n = {
6652 .f = cmd_start_tx_first_n_parsed,
6654 .help_str = "start tx_first <num>: "
6655 "packet forwarding, after sending <num> bursts of packets",
6657 (void *)&cmd_start_tx_first_n_start,
6658 (void *)&cmd_start_tx_first_n_tx_first,
6659 (void *)&cmd_start_tx_first_n_tx_num,
6664 /* *** SET LINK UP *** */
6665 struct cmd_set_link_up_result {
6666 cmdline_fixed_string_t set;
6667 cmdline_fixed_string_t link_up;
6668 cmdline_fixed_string_t port;
6672 cmdline_parse_token_string_t cmd_set_link_up_set =
6673 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6674 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6675 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6677 cmdline_parse_token_string_t cmd_set_link_up_port =
6678 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6679 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6680 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6682 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6683 __attribute__((unused)) struct cmdline *cl,
6684 __attribute__((unused)) void *data)
6686 struct cmd_set_link_up_result *res = parsed_result;
6687 dev_set_link_up(res->port_id);
6690 cmdline_parse_inst_t cmd_set_link_up = {
6691 .f = cmd_set_link_up_parsed,
6693 .help_str = "set link-up port <port id>",
6695 (void *)&cmd_set_link_up_set,
6696 (void *)&cmd_set_link_up_link_up,
6697 (void *)&cmd_set_link_up_port,
6698 (void *)&cmd_set_link_up_port_id,
6703 /* *** SET LINK DOWN *** */
6704 struct cmd_set_link_down_result {
6705 cmdline_fixed_string_t set;
6706 cmdline_fixed_string_t link_down;
6707 cmdline_fixed_string_t port;
6711 cmdline_parse_token_string_t cmd_set_link_down_set =
6712 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6713 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6714 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6716 cmdline_parse_token_string_t cmd_set_link_down_port =
6717 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6718 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6719 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6721 static void cmd_set_link_down_parsed(
6722 __attribute__((unused)) void *parsed_result,
6723 __attribute__((unused)) struct cmdline *cl,
6724 __attribute__((unused)) void *data)
6726 struct cmd_set_link_down_result *res = parsed_result;
6727 dev_set_link_down(res->port_id);
6730 cmdline_parse_inst_t cmd_set_link_down = {
6731 .f = cmd_set_link_down_parsed,
6733 .help_str = "set link-down port <port id>",
6735 (void *)&cmd_set_link_down_set,
6736 (void *)&cmd_set_link_down_link_down,
6737 (void *)&cmd_set_link_down_port,
6738 (void *)&cmd_set_link_down_port_id,
6743 /* *** SHOW CFG *** */
6744 struct cmd_showcfg_result {
6745 cmdline_fixed_string_t show;
6746 cmdline_fixed_string_t cfg;
6747 cmdline_fixed_string_t what;
6750 static void cmd_showcfg_parsed(void *parsed_result,
6751 __attribute__((unused)) struct cmdline *cl,
6752 __attribute__((unused)) void *data)
6754 struct cmd_showcfg_result *res = parsed_result;
6755 if (!strcmp(res->what, "rxtx"))
6756 rxtx_config_display();
6757 else if (!strcmp(res->what, "cores"))
6758 fwd_lcores_config_display();
6759 else if (!strcmp(res->what, "fwd"))
6760 pkt_fwd_config_display(&cur_fwd_config);
6761 else if (!strcmp(res->what, "txpkts"))
6762 show_tx_pkt_segments();
6765 cmdline_parse_token_string_t cmd_showcfg_show =
6766 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6767 cmdline_parse_token_string_t cmd_showcfg_port =
6768 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6769 cmdline_parse_token_string_t cmd_showcfg_what =
6770 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6771 "rxtx#cores#fwd#txpkts");
6773 cmdline_parse_inst_t cmd_showcfg = {
6774 .f = cmd_showcfg_parsed,
6776 .help_str = "show config rxtx|cores|fwd|txpkts",
6778 (void *)&cmd_showcfg_show,
6779 (void *)&cmd_showcfg_port,
6780 (void *)&cmd_showcfg_what,
6785 /* *** SHOW ALL PORT INFO *** */
6786 struct cmd_showportall_result {
6787 cmdline_fixed_string_t show;
6788 cmdline_fixed_string_t port;
6789 cmdline_fixed_string_t what;
6790 cmdline_fixed_string_t all;
6793 static void cmd_showportall_parsed(void *parsed_result,
6794 __attribute__((unused)) struct cmdline *cl,
6795 __attribute__((unused)) void *data)
6799 struct cmd_showportall_result *res = parsed_result;
6800 if (!strcmp(res->show, "clear")) {
6801 if (!strcmp(res->what, "stats"))
6802 RTE_ETH_FOREACH_DEV(i)
6804 else if (!strcmp(res->what, "xstats"))
6805 RTE_ETH_FOREACH_DEV(i)
6806 nic_xstats_clear(i);
6807 } else if (!strcmp(res->what, "info"))
6808 RTE_ETH_FOREACH_DEV(i)
6809 port_infos_display(i);
6810 else if (!strcmp(res->what, "stats"))
6811 RTE_ETH_FOREACH_DEV(i)
6812 nic_stats_display(i);
6813 else if (!strcmp(res->what, "xstats"))
6814 RTE_ETH_FOREACH_DEV(i)
6815 nic_xstats_display(i);
6816 else if (!strcmp(res->what, "fdir"))
6817 RTE_ETH_FOREACH_DEV(i)
6819 else if (!strcmp(res->what, "stat_qmap"))
6820 RTE_ETH_FOREACH_DEV(i)
6821 nic_stats_mapping_display(i);
6822 else if (!strcmp(res->what, "dcb_tc"))
6823 RTE_ETH_FOREACH_DEV(i)
6824 port_dcb_info_display(i);
6825 else if (!strcmp(res->what, "cap"))
6826 RTE_ETH_FOREACH_DEV(i)
6827 port_offload_cap_display(i);
6830 cmdline_parse_token_string_t cmd_showportall_show =
6831 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6833 cmdline_parse_token_string_t cmd_showportall_port =
6834 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6835 cmdline_parse_token_string_t cmd_showportall_what =
6836 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6837 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6838 cmdline_parse_token_string_t cmd_showportall_all =
6839 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6840 cmdline_parse_inst_t cmd_showportall = {
6841 .f = cmd_showportall_parsed,
6843 .help_str = "show|clear port "
6844 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6846 (void *)&cmd_showportall_show,
6847 (void *)&cmd_showportall_port,
6848 (void *)&cmd_showportall_what,
6849 (void *)&cmd_showportall_all,
6854 /* *** SHOW PORT INFO *** */
6855 struct cmd_showport_result {
6856 cmdline_fixed_string_t show;
6857 cmdline_fixed_string_t port;
6858 cmdline_fixed_string_t what;
6862 static void cmd_showport_parsed(void *parsed_result,
6863 __attribute__((unused)) struct cmdline *cl,
6864 __attribute__((unused)) void *data)
6866 struct cmd_showport_result *res = parsed_result;
6867 if (!strcmp(res->show, "clear")) {
6868 if (!strcmp(res->what, "stats"))
6869 nic_stats_clear(res->portnum);
6870 else if (!strcmp(res->what, "xstats"))
6871 nic_xstats_clear(res->portnum);
6872 } else if (!strcmp(res->what, "info"))
6873 port_infos_display(res->portnum);
6874 else if (!strcmp(res->what, "stats"))
6875 nic_stats_display(res->portnum);
6876 else if (!strcmp(res->what, "xstats"))
6877 nic_xstats_display(res->portnum);
6878 else if (!strcmp(res->what, "fdir"))
6879 fdir_get_infos(res->portnum);
6880 else if (!strcmp(res->what, "stat_qmap"))
6881 nic_stats_mapping_display(res->portnum);
6882 else if (!strcmp(res->what, "dcb_tc"))
6883 port_dcb_info_display(res->portnum);
6884 else if (!strcmp(res->what, "cap"))
6885 port_offload_cap_display(res->portnum);
6888 cmdline_parse_token_string_t cmd_showport_show =
6889 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6891 cmdline_parse_token_string_t cmd_showport_port =
6892 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6893 cmdline_parse_token_string_t cmd_showport_what =
6894 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6895 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6896 cmdline_parse_token_num_t cmd_showport_portnum =
6897 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6899 cmdline_parse_inst_t cmd_showport = {
6900 .f = cmd_showport_parsed,
6902 .help_str = "show|clear port "
6903 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6906 (void *)&cmd_showport_show,
6907 (void *)&cmd_showport_port,
6908 (void *)&cmd_showport_what,
6909 (void *)&cmd_showport_portnum,
6914 /* *** SHOW QUEUE INFO *** */
6915 struct cmd_showqueue_result {
6916 cmdline_fixed_string_t show;
6917 cmdline_fixed_string_t type;
6918 cmdline_fixed_string_t what;
6924 cmd_showqueue_parsed(void *parsed_result,
6925 __attribute__((unused)) struct cmdline *cl,
6926 __attribute__((unused)) void *data)
6928 struct cmd_showqueue_result *res = parsed_result;
6930 if (!strcmp(res->type, "rxq"))
6931 rx_queue_infos_display(res->portnum, res->queuenum);
6932 else if (!strcmp(res->type, "txq"))
6933 tx_queue_infos_display(res->portnum, res->queuenum);
6936 cmdline_parse_token_string_t cmd_showqueue_show =
6937 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6938 cmdline_parse_token_string_t cmd_showqueue_type =
6939 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6940 cmdline_parse_token_string_t cmd_showqueue_what =
6941 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6942 cmdline_parse_token_num_t cmd_showqueue_portnum =
6943 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6944 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6945 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6947 cmdline_parse_inst_t cmd_showqueue = {
6948 .f = cmd_showqueue_parsed,
6950 .help_str = "show rxq|txq info <port_id> <queue_id>",
6952 (void *)&cmd_showqueue_show,
6953 (void *)&cmd_showqueue_type,
6954 (void *)&cmd_showqueue_what,
6955 (void *)&cmd_showqueue_portnum,
6956 (void *)&cmd_showqueue_queuenum,
6961 /* *** READ PORT REGISTER *** */
6962 struct cmd_read_reg_result {
6963 cmdline_fixed_string_t read;
6964 cmdline_fixed_string_t reg;
6970 cmd_read_reg_parsed(void *parsed_result,
6971 __attribute__((unused)) struct cmdline *cl,
6972 __attribute__((unused)) void *data)
6974 struct cmd_read_reg_result *res = parsed_result;
6975 port_reg_display(res->port_id, res->reg_off);
6978 cmdline_parse_token_string_t cmd_read_reg_read =
6979 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6980 cmdline_parse_token_string_t cmd_read_reg_reg =
6981 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6982 cmdline_parse_token_num_t cmd_read_reg_port_id =
6983 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6984 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6985 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6987 cmdline_parse_inst_t cmd_read_reg = {
6988 .f = cmd_read_reg_parsed,
6990 .help_str = "read reg <port_id> <reg_off>",
6992 (void *)&cmd_read_reg_read,
6993 (void *)&cmd_read_reg_reg,
6994 (void *)&cmd_read_reg_port_id,
6995 (void *)&cmd_read_reg_reg_off,
7000 /* *** READ PORT REGISTER BIT FIELD *** */
7001 struct cmd_read_reg_bit_field_result {
7002 cmdline_fixed_string_t read;
7003 cmdline_fixed_string_t regfield;
7011 cmd_read_reg_bit_field_parsed(void *parsed_result,
7012 __attribute__((unused)) struct cmdline *cl,
7013 __attribute__((unused)) void *data)
7015 struct cmd_read_reg_bit_field_result *res = parsed_result;
7016 port_reg_bit_field_display(res->port_id, res->reg_off,
7017 res->bit1_pos, res->bit2_pos);
7020 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7021 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7023 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7024 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7025 regfield, "regfield");
7026 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7027 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7029 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7030 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7032 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7033 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7035 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7036 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7039 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7040 .f = cmd_read_reg_bit_field_parsed,
7042 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7043 "Read register bit field between bit_x and bit_y included",
7045 (void *)&cmd_read_reg_bit_field_read,
7046 (void *)&cmd_read_reg_bit_field_regfield,
7047 (void *)&cmd_read_reg_bit_field_port_id,
7048 (void *)&cmd_read_reg_bit_field_reg_off,
7049 (void *)&cmd_read_reg_bit_field_bit1_pos,
7050 (void *)&cmd_read_reg_bit_field_bit2_pos,
7055 /* *** READ PORT REGISTER BIT *** */
7056 struct cmd_read_reg_bit_result {
7057 cmdline_fixed_string_t read;
7058 cmdline_fixed_string_t regbit;
7065 cmd_read_reg_bit_parsed(void *parsed_result,
7066 __attribute__((unused)) struct cmdline *cl,
7067 __attribute__((unused)) void *data)
7069 struct cmd_read_reg_bit_result *res = parsed_result;
7070 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7073 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7074 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7075 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7076 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7078 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7079 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7080 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7081 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7082 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7083 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7085 cmdline_parse_inst_t cmd_read_reg_bit = {
7086 .f = cmd_read_reg_bit_parsed,
7088 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7090 (void *)&cmd_read_reg_bit_read,
7091 (void *)&cmd_read_reg_bit_regbit,
7092 (void *)&cmd_read_reg_bit_port_id,
7093 (void *)&cmd_read_reg_bit_reg_off,
7094 (void *)&cmd_read_reg_bit_bit_pos,
7099 /* *** WRITE PORT REGISTER *** */
7100 struct cmd_write_reg_result {
7101 cmdline_fixed_string_t write;
7102 cmdline_fixed_string_t reg;
7109 cmd_write_reg_parsed(void *parsed_result,
7110 __attribute__((unused)) struct cmdline *cl,
7111 __attribute__((unused)) void *data)
7113 struct cmd_write_reg_result *res = parsed_result;
7114 port_reg_set(res->port_id, res->reg_off, res->value);
7117 cmdline_parse_token_string_t cmd_write_reg_write =
7118 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7119 cmdline_parse_token_string_t cmd_write_reg_reg =
7120 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7121 cmdline_parse_token_num_t cmd_write_reg_port_id =
7122 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7123 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7124 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7125 cmdline_parse_token_num_t cmd_write_reg_value =
7126 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7128 cmdline_parse_inst_t cmd_write_reg = {
7129 .f = cmd_write_reg_parsed,
7131 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7133 (void *)&cmd_write_reg_write,
7134 (void *)&cmd_write_reg_reg,
7135 (void *)&cmd_write_reg_port_id,
7136 (void *)&cmd_write_reg_reg_off,
7137 (void *)&cmd_write_reg_value,
7142 /* *** WRITE PORT REGISTER BIT FIELD *** */
7143 struct cmd_write_reg_bit_field_result {
7144 cmdline_fixed_string_t write;
7145 cmdline_fixed_string_t regfield;
7154 cmd_write_reg_bit_field_parsed(void *parsed_result,
7155 __attribute__((unused)) struct cmdline *cl,
7156 __attribute__((unused)) void *data)
7158 struct cmd_write_reg_bit_field_result *res = parsed_result;
7159 port_reg_bit_field_set(res->port_id, res->reg_off,
7160 res->bit1_pos, res->bit2_pos, res->value);
7163 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7164 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7166 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7167 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7168 regfield, "regfield");
7169 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7170 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7172 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7173 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7175 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7176 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7178 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7179 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7181 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7182 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7185 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7186 .f = cmd_write_reg_bit_field_parsed,
7188 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7190 "Set register bit field between bit_x and bit_y included",
7192 (void *)&cmd_write_reg_bit_field_write,
7193 (void *)&cmd_write_reg_bit_field_regfield,
7194 (void *)&cmd_write_reg_bit_field_port_id,
7195 (void *)&cmd_write_reg_bit_field_reg_off,
7196 (void *)&cmd_write_reg_bit_field_bit1_pos,
7197 (void *)&cmd_write_reg_bit_field_bit2_pos,
7198 (void *)&cmd_write_reg_bit_field_value,
7203 /* *** WRITE PORT REGISTER BIT *** */
7204 struct cmd_write_reg_bit_result {
7205 cmdline_fixed_string_t write;
7206 cmdline_fixed_string_t regbit;
7214 cmd_write_reg_bit_parsed(void *parsed_result,
7215 __attribute__((unused)) struct cmdline *cl,
7216 __attribute__((unused)) void *data)
7218 struct cmd_write_reg_bit_result *res = parsed_result;
7219 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7222 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7223 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7225 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7226 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7228 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7229 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7230 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7231 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7232 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7233 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7234 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7235 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7237 cmdline_parse_inst_t cmd_write_reg_bit = {
7238 .f = cmd_write_reg_bit_parsed,
7240 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7243 (void *)&cmd_write_reg_bit_write,
7244 (void *)&cmd_write_reg_bit_regbit,
7245 (void *)&cmd_write_reg_bit_port_id,
7246 (void *)&cmd_write_reg_bit_reg_off,
7247 (void *)&cmd_write_reg_bit_bit_pos,
7248 (void *)&cmd_write_reg_bit_value,
7253 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7254 struct cmd_read_rxd_txd_result {
7255 cmdline_fixed_string_t read;
7256 cmdline_fixed_string_t rxd_txd;
7263 cmd_read_rxd_txd_parsed(void *parsed_result,
7264 __attribute__((unused)) struct cmdline *cl,
7265 __attribute__((unused)) void *data)
7267 struct cmd_read_rxd_txd_result *res = parsed_result;
7269 if (!strcmp(res->rxd_txd, "rxd"))
7270 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7271 else if (!strcmp(res->rxd_txd, "txd"))
7272 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7275 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7276 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7277 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7278 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7280 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7281 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7282 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7283 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7284 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7285 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7287 cmdline_parse_inst_t cmd_read_rxd_txd = {
7288 .f = cmd_read_rxd_txd_parsed,
7290 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7292 (void *)&cmd_read_rxd_txd_read,
7293 (void *)&cmd_read_rxd_txd_rxd_txd,
7294 (void *)&cmd_read_rxd_txd_port_id,
7295 (void *)&cmd_read_rxd_txd_queue_id,
7296 (void *)&cmd_read_rxd_txd_desc_id,
7302 struct cmd_quit_result {
7303 cmdline_fixed_string_t quit;
7306 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7308 __attribute__((unused)) void *data)
7314 cmdline_parse_token_string_t cmd_quit_quit =
7315 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7317 cmdline_parse_inst_t cmd_quit = {
7318 .f = cmd_quit_parsed,
7320 .help_str = "quit: Exit application",
7322 (void *)&cmd_quit_quit,
7327 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7328 struct cmd_mac_addr_result {
7329 cmdline_fixed_string_t mac_addr_cmd;
7330 cmdline_fixed_string_t what;
7332 struct ether_addr address;
7335 static void cmd_mac_addr_parsed(void *parsed_result,
7336 __attribute__((unused)) struct cmdline *cl,
7337 __attribute__((unused)) void *data)
7339 struct cmd_mac_addr_result *res = parsed_result;
7342 if (strcmp(res->what, "add") == 0)
7343 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7344 else if (strcmp(res->what, "set") == 0)
7345 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7348 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7350 /* check the return value and print it if is < 0 */
7352 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7356 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7357 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7359 cmdline_parse_token_string_t cmd_mac_addr_what =
7360 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7362 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7363 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7365 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7366 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7368 cmdline_parse_inst_t cmd_mac_addr = {
7369 .f = cmd_mac_addr_parsed,
7371 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7372 "Add/Remove/Set MAC address on port_id",
7374 (void *)&cmd_mac_addr_cmd,
7375 (void *)&cmd_mac_addr_what,
7376 (void *)&cmd_mac_addr_portnum,
7377 (void *)&cmd_mac_addr_addr,
7382 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7383 struct cmd_eth_peer_result {
7384 cmdline_fixed_string_t set;
7385 cmdline_fixed_string_t eth_peer;
7387 cmdline_fixed_string_t peer_addr;
7390 static void cmd_set_eth_peer_parsed(void *parsed_result,
7391 __attribute__((unused)) struct cmdline *cl,
7392 __attribute__((unused)) void *data)
7394 struct cmd_eth_peer_result *res = parsed_result;
7396 if (test_done == 0) {
7397 printf("Please stop forwarding first\n");
7400 if (!strcmp(res->eth_peer, "eth-peer")) {
7401 set_fwd_eth_peer(res->port_id, res->peer_addr);
7405 cmdline_parse_token_string_t cmd_eth_peer_set =
7406 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7407 cmdline_parse_token_string_t cmd_eth_peer =
7408 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7409 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7410 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7411 cmdline_parse_token_string_t cmd_eth_peer_addr =
7412 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7414 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7415 .f = cmd_set_eth_peer_parsed,
7417 .help_str = "set eth-peer <port_id> <peer_mac>",
7419 (void *)&cmd_eth_peer_set,
7420 (void *)&cmd_eth_peer,
7421 (void *)&cmd_eth_peer_port_id,
7422 (void *)&cmd_eth_peer_addr,
7427 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7428 struct cmd_set_qmap_result {
7429 cmdline_fixed_string_t set;
7430 cmdline_fixed_string_t qmap;
7431 cmdline_fixed_string_t what;
7438 cmd_set_qmap_parsed(void *parsed_result,
7439 __attribute__((unused)) struct cmdline *cl,
7440 __attribute__((unused)) void *data)
7442 struct cmd_set_qmap_result *res = parsed_result;
7443 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7445 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7448 cmdline_parse_token_string_t cmd_setqmap_set =
7449 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7451 cmdline_parse_token_string_t cmd_setqmap_qmap =
7452 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7454 cmdline_parse_token_string_t cmd_setqmap_what =
7455 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7457 cmdline_parse_token_num_t cmd_setqmap_portid =
7458 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7460 cmdline_parse_token_num_t cmd_setqmap_queueid =
7461 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7463 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7464 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7467 cmdline_parse_inst_t cmd_set_qmap = {
7468 .f = cmd_set_qmap_parsed,
7470 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7471 "Set statistics mapping value on tx|rx queue_id of port_id",
7473 (void *)&cmd_setqmap_set,
7474 (void *)&cmd_setqmap_qmap,
7475 (void *)&cmd_setqmap_what,
7476 (void *)&cmd_setqmap_portid,
7477 (void *)&cmd_setqmap_queueid,
7478 (void *)&cmd_setqmap_mapvalue,
7483 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7484 struct cmd_set_xstats_hide_zero_result {
7485 cmdline_fixed_string_t keyword;
7486 cmdline_fixed_string_t name;
7487 cmdline_fixed_string_t on_off;
7491 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7492 __attribute__((unused)) struct cmdline *cl,
7493 __attribute__((unused)) void *data)
7495 struct cmd_set_xstats_hide_zero_result *res;
7496 uint16_t on_off = 0;
7498 res = parsed_result;
7499 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7500 set_xstats_hide_zero(on_off);
7503 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7504 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7506 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7507 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7508 name, "xstats-hide-zero");
7509 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7510 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7513 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7514 .f = cmd_set_xstats_hide_zero_parsed,
7516 .help_str = "set xstats-hide-zero on|off",
7518 (void *)&cmd_set_xstats_hide_zero_keyword,
7519 (void *)&cmd_set_xstats_hide_zero_name,
7520 (void *)&cmd_set_xstats_hide_zero_on_off,
7525 /* *** CONFIGURE UNICAST HASH TABLE *** */
7526 struct cmd_set_uc_hash_table {
7527 cmdline_fixed_string_t set;
7528 cmdline_fixed_string_t port;
7530 cmdline_fixed_string_t what;
7531 struct ether_addr address;
7532 cmdline_fixed_string_t mode;
7536 cmd_set_uc_hash_parsed(void *parsed_result,
7537 __attribute__((unused)) struct cmdline *cl,
7538 __attribute__((unused)) void *data)
7541 struct cmd_set_uc_hash_table *res = parsed_result;
7543 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7545 if (strcmp(res->what, "uta") == 0)
7546 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7547 &res->address,(uint8_t)is_on);
7549 printf("bad unicast hash table parameter, return code = %d \n", ret);
7553 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7554 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7556 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7557 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7559 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7560 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7562 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7563 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7565 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7566 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7568 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7569 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7572 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7573 .f = cmd_set_uc_hash_parsed,
7575 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7577 (void *)&cmd_set_uc_hash_set,
7578 (void *)&cmd_set_uc_hash_port,
7579 (void *)&cmd_set_uc_hash_portid,
7580 (void *)&cmd_set_uc_hash_what,
7581 (void *)&cmd_set_uc_hash_mac,
7582 (void *)&cmd_set_uc_hash_mode,
7587 struct cmd_set_uc_all_hash_table {
7588 cmdline_fixed_string_t set;
7589 cmdline_fixed_string_t port;
7591 cmdline_fixed_string_t what;
7592 cmdline_fixed_string_t value;
7593 cmdline_fixed_string_t mode;
7597 cmd_set_uc_all_hash_parsed(void *parsed_result,
7598 __attribute__((unused)) struct cmdline *cl,
7599 __attribute__((unused)) void *data)
7602 struct cmd_set_uc_all_hash_table *res = parsed_result;
7604 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7606 if ((strcmp(res->what, "uta") == 0) &&
7607 (strcmp(res->value, "all") == 0))
7608 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7610 printf("bad unicast hash table parameter,"
7611 "return code = %d \n", ret);
7614 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7615 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7617 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7618 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7620 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7621 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7623 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7624 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7626 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7627 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7629 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7630 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7633 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7634 .f = cmd_set_uc_all_hash_parsed,
7636 .help_str = "set port <port_id> uta all on|off",
7638 (void *)&cmd_set_uc_all_hash_set,
7639 (void *)&cmd_set_uc_all_hash_port,
7640 (void *)&cmd_set_uc_all_hash_portid,
7641 (void *)&cmd_set_uc_all_hash_what,
7642 (void *)&cmd_set_uc_all_hash_value,
7643 (void *)&cmd_set_uc_all_hash_mode,
7648 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7649 struct cmd_set_vf_macvlan_filter {
7650 cmdline_fixed_string_t set;
7651 cmdline_fixed_string_t port;
7653 cmdline_fixed_string_t vf;
7655 struct ether_addr address;
7656 cmdline_fixed_string_t filter_type;
7657 cmdline_fixed_string_t mode;
7661 cmd_set_vf_macvlan_parsed(void *parsed_result,
7662 __attribute__((unused)) struct cmdline *cl,
7663 __attribute__((unused)) void *data)
7666 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7667 struct rte_eth_mac_filter filter;
7669 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7671 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7673 /* set VF MAC filter */
7677 filter.dst_id = res->vf_id;
7679 if (!strcmp(res->filter_type, "exact-mac"))
7680 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7681 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7682 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7683 else if (!strcmp(res->filter_type, "hashmac"))
7684 filter.filter_type = RTE_MAC_HASH_MATCH;
7685 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7686 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7688 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7691 ret = rte_eth_dev_filter_ctrl(res->port_id,
7692 RTE_ETH_FILTER_MACVLAN,
7696 ret = rte_eth_dev_filter_ctrl(res->port_id,
7697 RTE_ETH_FILTER_MACVLAN,
7698 RTE_ETH_FILTER_DELETE,
7702 printf("bad set MAC hash parameter, return code = %d\n", ret);
7706 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7707 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7709 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7710 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7712 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7713 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7715 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7716 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7718 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7719 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7721 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7722 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7724 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7725 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7726 filter_type, "exact-mac#exact-mac-vlan"
7727 "#hashmac#hashmac-vlan");
7728 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7729 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7732 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7733 .f = cmd_set_vf_macvlan_parsed,
7735 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7736 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7737 "Exact match rule: exact match of MAC or MAC and VLAN; "
7738 "hash match rule: hash match of MAC and exact match of VLAN",
7740 (void *)&cmd_set_vf_macvlan_set,
7741 (void *)&cmd_set_vf_macvlan_port,
7742 (void *)&cmd_set_vf_macvlan_portid,
7743 (void *)&cmd_set_vf_macvlan_vf,
7744 (void *)&cmd_set_vf_macvlan_vf_id,
7745 (void *)&cmd_set_vf_macvlan_mac,
7746 (void *)&cmd_set_vf_macvlan_filter_type,
7747 (void *)&cmd_set_vf_macvlan_mode,
7752 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7753 struct cmd_set_vf_traffic {
7754 cmdline_fixed_string_t set;
7755 cmdline_fixed_string_t port;
7757 cmdline_fixed_string_t vf;
7759 cmdline_fixed_string_t what;
7760 cmdline_fixed_string_t mode;
7764 cmd_set_vf_traffic_parsed(void *parsed_result,
7765 __attribute__((unused)) struct cmdline *cl,
7766 __attribute__((unused)) void *data)
7768 struct cmd_set_vf_traffic *res = parsed_result;
7769 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7770 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7772 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7775 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7776 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7778 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7779 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7781 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7782 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7784 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7785 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7787 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7788 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7790 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7791 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7793 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7794 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7797 cmdline_parse_inst_t cmd_set_vf_traffic = {
7798 .f = cmd_set_vf_traffic_parsed,
7800 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7802 (void *)&cmd_setvf_traffic_set,
7803 (void *)&cmd_setvf_traffic_port,
7804 (void *)&cmd_setvf_traffic_portid,
7805 (void *)&cmd_setvf_traffic_vf,
7806 (void *)&cmd_setvf_traffic_vfid,
7807 (void *)&cmd_setvf_traffic_what,
7808 (void *)&cmd_setvf_traffic_mode,
7813 /* *** CONFIGURE VF RECEIVE MODE *** */
7814 struct cmd_set_vf_rxmode {
7815 cmdline_fixed_string_t set;
7816 cmdline_fixed_string_t port;
7818 cmdline_fixed_string_t vf;
7820 cmdline_fixed_string_t what;
7821 cmdline_fixed_string_t mode;
7822 cmdline_fixed_string_t on;
7826 cmd_set_vf_rxmode_parsed(void *parsed_result,
7827 __attribute__((unused)) struct cmdline *cl,
7828 __attribute__((unused)) void *data)
7831 uint16_t rx_mode = 0;
7832 struct cmd_set_vf_rxmode *res = parsed_result;
7834 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7835 if (!strcmp(res->what,"rxmode")) {
7836 if (!strcmp(res->mode, "AUPE"))
7837 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7838 else if (!strcmp(res->mode, "ROPE"))
7839 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7840 else if (!strcmp(res->mode, "BAM"))
7841 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7842 else if (!strncmp(res->mode, "MPE",3))
7843 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7846 RTE_SET_USED(is_on);
7848 #ifdef RTE_LIBRTE_IXGBE_PMD
7849 if (ret == -ENOTSUP)
7850 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7851 rx_mode, (uint8_t)is_on);
7853 #ifdef RTE_LIBRTE_BNXT_PMD
7854 if (ret == -ENOTSUP)
7855 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7856 rx_mode, (uint8_t)is_on);
7859 printf("bad VF receive mode parameter, return code = %d \n",
7863 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7864 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7866 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7867 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7869 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7870 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7872 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7873 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7875 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7876 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7878 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7879 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7881 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7882 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7883 mode, "AUPE#ROPE#BAM#MPE");
7884 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7885 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7888 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7889 .f = cmd_set_vf_rxmode_parsed,
7891 .help_str = "set port <port_id> vf <vf_id> rxmode "
7892 "AUPE|ROPE|BAM|MPE on|off",
7894 (void *)&cmd_set_vf_rxmode_set,
7895 (void *)&cmd_set_vf_rxmode_port,
7896 (void *)&cmd_set_vf_rxmode_portid,
7897 (void *)&cmd_set_vf_rxmode_vf,
7898 (void *)&cmd_set_vf_rxmode_vfid,
7899 (void *)&cmd_set_vf_rxmode_what,
7900 (void *)&cmd_set_vf_rxmode_mode,
7901 (void *)&cmd_set_vf_rxmode_on,
7906 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7907 struct cmd_vf_mac_addr_result {
7908 cmdline_fixed_string_t mac_addr_cmd;
7909 cmdline_fixed_string_t what;
7910 cmdline_fixed_string_t port;
7912 cmdline_fixed_string_t vf;
7914 struct ether_addr address;
7917 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7918 __attribute__((unused)) struct cmdline *cl,
7919 __attribute__((unused)) void *data)
7921 struct cmd_vf_mac_addr_result *res = parsed_result;
7924 if (strcmp(res->what, "add") != 0)
7927 #ifdef RTE_LIBRTE_I40E_PMD
7928 if (ret == -ENOTSUP)
7929 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7932 #ifdef RTE_LIBRTE_BNXT_PMD
7933 if (ret == -ENOTSUP)
7934 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7939 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7943 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7944 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7945 mac_addr_cmd,"mac_addr");
7946 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7947 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7949 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7950 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7952 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7953 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7955 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7956 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7958 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7959 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7961 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7962 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7965 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7966 .f = cmd_vf_mac_addr_parsed,
7968 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7969 "Add MAC address filtering for a VF on port_id",
7971 (void *)&cmd_vf_mac_addr_cmd,
7972 (void *)&cmd_vf_mac_addr_what,
7973 (void *)&cmd_vf_mac_addr_port,
7974 (void *)&cmd_vf_mac_addr_portnum,
7975 (void *)&cmd_vf_mac_addr_vf,
7976 (void *)&cmd_vf_mac_addr_vfnum,
7977 (void *)&cmd_vf_mac_addr_addr,
7982 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7983 struct cmd_vf_rx_vlan_filter {
7984 cmdline_fixed_string_t rx_vlan;
7985 cmdline_fixed_string_t what;
7987 cmdline_fixed_string_t port;
7989 cmdline_fixed_string_t vf;
7994 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7995 __attribute__((unused)) struct cmdline *cl,
7996 __attribute__((unused)) void *data)
7998 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8001 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8003 #ifdef RTE_LIBRTE_IXGBE_PMD
8004 if (ret == -ENOTSUP)
8005 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8006 res->vlan_id, res->vf_mask, is_add);
8008 #ifdef RTE_LIBRTE_I40E_PMD
8009 if (ret == -ENOTSUP)
8010 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8011 res->vlan_id, res->vf_mask, is_add);
8013 #ifdef RTE_LIBRTE_BNXT_PMD
8014 if (ret == -ENOTSUP)
8015 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8016 res->vlan_id, res->vf_mask, is_add);
8023 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8024 res->vlan_id, res->vf_mask);
8027 printf("invalid port_id %d\n", res->port_id);
8030 printf("function not implemented or supported\n");
8033 printf("programming error: (%s)\n", strerror(-ret));
8037 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8038 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8039 rx_vlan, "rx_vlan");
8040 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8041 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8043 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8044 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8046 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8047 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8049 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8050 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8052 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8053 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8055 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8056 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8059 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8060 .f = cmd_vf_rx_vlan_filter_parsed,
8062 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8063 "(vf_mask = hexadecimal VF mask)",
8065 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8066 (void *)&cmd_vf_rx_vlan_filter_what,
8067 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8068 (void *)&cmd_vf_rx_vlan_filter_port,
8069 (void *)&cmd_vf_rx_vlan_filter_portid,
8070 (void *)&cmd_vf_rx_vlan_filter_vf,
8071 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8076 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8077 struct cmd_queue_rate_limit_result {
8078 cmdline_fixed_string_t set;
8079 cmdline_fixed_string_t port;
8081 cmdline_fixed_string_t queue;
8083 cmdline_fixed_string_t rate;
8087 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8088 __attribute__((unused)) struct cmdline *cl,
8089 __attribute__((unused)) void *data)
8091 struct cmd_queue_rate_limit_result *res = parsed_result;
8094 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8095 && (strcmp(res->queue, "queue") == 0)
8096 && (strcmp(res->rate, "rate") == 0))
8097 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8100 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8104 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8105 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8107 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8108 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8110 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8111 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8113 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8114 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8116 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8117 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8119 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8120 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8122 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8123 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8126 cmdline_parse_inst_t cmd_queue_rate_limit = {
8127 .f = cmd_queue_rate_limit_parsed,
8129 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8130 "Set rate limit for a queue on port_id",
8132 (void *)&cmd_queue_rate_limit_set,
8133 (void *)&cmd_queue_rate_limit_port,
8134 (void *)&cmd_queue_rate_limit_portnum,
8135 (void *)&cmd_queue_rate_limit_queue,
8136 (void *)&cmd_queue_rate_limit_queuenum,
8137 (void *)&cmd_queue_rate_limit_rate,
8138 (void *)&cmd_queue_rate_limit_ratenum,
8143 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8144 struct cmd_vf_rate_limit_result {
8145 cmdline_fixed_string_t set;
8146 cmdline_fixed_string_t port;
8148 cmdline_fixed_string_t vf;
8150 cmdline_fixed_string_t rate;
8152 cmdline_fixed_string_t q_msk;
8156 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8157 __attribute__((unused)) struct cmdline *cl,
8158 __attribute__((unused)) void *data)
8160 struct cmd_vf_rate_limit_result *res = parsed_result;
8163 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8164 && (strcmp(res->vf, "vf") == 0)
8165 && (strcmp(res->rate, "rate") == 0)
8166 && (strcmp(res->q_msk, "queue_mask") == 0))
8167 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8168 res->rate_num, res->q_msk_val);
8170 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8174 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8175 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8177 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8178 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8180 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8181 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8183 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8184 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8186 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8187 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8189 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8190 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8192 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8193 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8195 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8196 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8197 q_msk, "queue_mask");
8198 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8199 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8202 cmdline_parse_inst_t cmd_vf_rate_limit = {
8203 .f = cmd_vf_rate_limit_parsed,
8205 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8206 "queue_mask <queue_mask_value>: "
8207 "Set rate limit for queues of VF on port_id",
8209 (void *)&cmd_vf_rate_limit_set,
8210 (void *)&cmd_vf_rate_limit_port,
8211 (void *)&cmd_vf_rate_limit_portnum,
8212 (void *)&cmd_vf_rate_limit_vf,
8213 (void *)&cmd_vf_rate_limit_vfnum,
8214 (void *)&cmd_vf_rate_limit_rate,
8215 (void *)&cmd_vf_rate_limit_ratenum,
8216 (void *)&cmd_vf_rate_limit_q_msk,
8217 (void *)&cmd_vf_rate_limit_q_msk_val,
8222 /* *** ADD TUNNEL FILTER OF A PORT *** */
8223 struct cmd_tunnel_filter_result {
8224 cmdline_fixed_string_t cmd;
8225 cmdline_fixed_string_t what;
8227 struct ether_addr outer_mac;
8228 struct ether_addr inner_mac;
8229 cmdline_ipaddr_t ip_value;
8230 uint16_t inner_vlan;
8231 cmdline_fixed_string_t tunnel_type;
8232 cmdline_fixed_string_t filter_type;
8238 cmd_tunnel_filter_parsed(void *parsed_result,
8239 __attribute__((unused)) struct cmdline *cl,
8240 __attribute__((unused)) void *data)
8242 struct cmd_tunnel_filter_result *res = parsed_result;
8243 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8246 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8248 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8249 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8250 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8252 if (res->ip_value.family == AF_INET) {
8253 tunnel_filter_conf.ip_addr.ipv4_addr =
8254 res->ip_value.addr.ipv4.s_addr;
8255 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8257 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8258 &(res->ip_value.addr.ipv6),
8259 sizeof(struct in6_addr));
8260 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8263 if (!strcmp(res->filter_type, "imac-ivlan"))
8264 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8265 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8266 tunnel_filter_conf.filter_type =
8267 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8268 else if (!strcmp(res->filter_type, "imac-tenid"))
8269 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8270 else if (!strcmp(res->filter_type, "imac"))
8271 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8272 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8273 tunnel_filter_conf.filter_type =
8274 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8275 else if (!strcmp(res->filter_type, "oip"))
8276 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8277 else if (!strcmp(res->filter_type, "iip"))
8278 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8280 printf("The filter type is not supported");
8284 if (!strcmp(res->tunnel_type, "vxlan"))
8285 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8286 else if (!strcmp(res->tunnel_type, "nvgre"))
8287 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8288 else if (!strcmp(res->tunnel_type, "ipingre"))
8289 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8291 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8295 tunnel_filter_conf.tenant_id = res->tenant_id;
8296 tunnel_filter_conf.queue_id = res->queue_num;
8297 if (!strcmp(res->what, "add"))
8298 ret = rte_eth_dev_filter_ctrl(res->port_id,
8299 RTE_ETH_FILTER_TUNNEL,
8301 &tunnel_filter_conf);
8303 ret = rte_eth_dev_filter_ctrl(res->port_id,
8304 RTE_ETH_FILTER_TUNNEL,
8305 RTE_ETH_FILTER_DELETE,
8306 &tunnel_filter_conf);
8308 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8312 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8313 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8314 cmd, "tunnel_filter");
8315 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8316 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8318 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8319 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8321 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8322 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8324 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8325 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8327 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8328 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8329 inner_vlan, UINT16);
8330 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8331 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8333 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8334 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8335 tunnel_type, "vxlan#nvgre#ipingre");
8337 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8338 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8339 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8340 "imac#omac-imac-tenid");
8341 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8342 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8344 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8345 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8348 cmdline_parse_inst_t cmd_tunnel_filter = {
8349 .f = cmd_tunnel_filter_parsed,
8351 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8352 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8353 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8354 "<queue_id>: Add/Rm tunnel filter of a port",
8356 (void *)&cmd_tunnel_filter_cmd,
8357 (void *)&cmd_tunnel_filter_what,
8358 (void *)&cmd_tunnel_filter_port_id,
8359 (void *)&cmd_tunnel_filter_outer_mac,
8360 (void *)&cmd_tunnel_filter_inner_mac,
8361 (void *)&cmd_tunnel_filter_ip_value,
8362 (void *)&cmd_tunnel_filter_innner_vlan,
8363 (void *)&cmd_tunnel_filter_tunnel_type,
8364 (void *)&cmd_tunnel_filter_filter_type,
8365 (void *)&cmd_tunnel_filter_tenant_id,
8366 (void *)&cmd_tunnel_filter_queue_num,
8371 /* *** CONFIGURE TUNNEL UDP PORT *** */
8372 struct cmd_tunnel_udp_config {
8373 cmdline_fixed_string_t cmd;
8374 cmdline_fixed_string_t what;
8380 cmd_tunnel_udp_config_parsed(void *parsed_result,
8381 __attribute__((unused)) struct cmdline *cl,
8382 __attribute__((unused)) void *data)
8384 struct cmd_tunnel_udp_config *res = parsed_result;
8385 struct rte_eth_udp_tunnel tunnel_udp;
8388 tunnel_udp.udp_port = res->udp_port;
8390 if (!strcmp(res->cmd, "rx_vxlan_port"))
8391 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8393 if (!strcmp(res->what, "add"))
8394 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8397 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8401 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8404 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8405 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8406 cmd, "rx_vxlan_port");
8407 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8408 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8410 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8411 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8413 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8414 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8417 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8418 .f = cmd_tunnel_udp_config_parsed,
8420 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8421 "Add/Remove a tunneling UDP port filter",
8423 (void *)&cmd_tunnel_udp_config_cmd,
8424 (void *)&cmd_tunnel_udp_config_what,
8425 (void *)&cmd_tunnel_udp_config_udp_port,
8426 (void *)&cmd_tunnel_udp_config_port_id,
8431 /* *** GLOBAL CONFIG *** */
8432 struct cmd_global_config_result {
8433 cmdline_fixed_string_t cmd;
8435 cmdline_fixed_string_t cfg_type;
8440 cmd_global_config_parsed(void *parsed_result,
8441 __attribute__((unused)) struct cmdline *cl,
8442 __attribute__((unused)) void *data)
8444 struct cmd_global_config_result *res = parsed_result;
8445 struct rte_eth_global_cfg conf;
8448 memset(&conf, 0, sizeof(conf));
8449 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8450 conf.cfg.gre_key_len = res->len;
8451 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8452 RTE_ETH_FILTER_SET, &conf);
8454 printf("Global config error\n");
8457 cmdline_parse_token_string_t cmd_global_config_cmd =
8458 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8460 cmdline_parse_token_num_t cmd_global_config_port_id =
8461 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8463 cmdline_parse_token_string_t cmd_global_config_type =
8464 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8465 cfg_type, "gre-key-len");
8466 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8467 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8470 cmdline_parse_inst_t cmd_global_config = {
8471 .f = cmd_global_config_parsed,
8472 .data = (void *)NULL,
8473 .help_str = "global_config <port_id> gre-key-len <key_len>",
8475 (void *)&cmd_global_config_cmd,
8476 (void *)&cmd_global_config_port_id,
8477 (void *)&cmd_global_config_type,
8478 (void *)&cmd_global_config_gre_key_len,
8483 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8484 struct cmd_set_mirror_mask_result {
8485 cmdline_fixed_string_t set;
8486 cmdline_fixed_string_t port;
8488 cmdline_fixed_string_t mirror;
8490 cmdline_fixed_string_t what;
8491 cmdline_fixed_string_t value;
8492 cmdline_fixed_string_t dstpool;
8494 cmdline_fixed_string_t on;
8497 cmdline_parse_token_string_t cmd_mirror_mask_set =
8498 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8500 cmdline_parse_token_string_t cmd_mirror_mask_port =
8501 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8503 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8504 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8506 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8507 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8508 mirror, "mirror-rule");
8509 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8510 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8512 cmdline_parse_token_string_t cmd_mirror_mask_what =
8513 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8514 what, "pool-mirror-up#pool-mirror-down"
8516 cmdline_parse_token_string_t cmd_mirror_mask_value =
8517 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8519 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8520 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8521 dstpool, "dst-pool");
8522 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8523 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8525 cmdline_parse_token_string_t cmd_mirror_mask_on =
8526 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8530 cmd_set_mirror_mask_parsed(void *parsed_result,
8531 __attribute__((unused)) struct cmdline *cl,
8532 __attribute__((unused)) void *data)
8535 struct cmd_set_mirror_mask_result *res = parsed_result;
8536 struct rte_eth_mirror_conf mr_conf;
8538 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8540 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8542 mr_conf.dst_pool = res->dstpool_id;
8544 if (!strcmp(res->what, "pool-mirror-up")) {
8545 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8546 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8547 } else if (!strcmp(res->what, "pool-mirror-down")) {
8548 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8549 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8550 } else if (!strcmp(res->what, "vlan-mirror")) {
8551 mr_conf.rule_type = ETH_MIRROR_VLAN;
8552 nb_item = parse_item_list(res->value, "vlan",
8553 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8557 for (i = 0; i < nb_item; i++) {
8558 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8559 printf("Invalid vlan_id: must be < 4096\n");
8563 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8564 mr_conf.vlan.vlan_mask |= 1ULL << i;
8568 if (!strcmp(res->on, "on"))
8569 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8572 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8575 printf("mirror rule add error: (%s)\n", strerror(-ret));
8578 cmdline_parse_inst_t cmd_set_mirror_mask = {
8579 .f = cmd_set_mirror_mask_parsed,
8581 .help_str = "set port <port_id> mirror-rule <rule_id> "
8582 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8583 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8585 (void *)&cmd_mirror_mask_set,
8586 (void *)&cmd_mirror_mask_port,
8587 (void *)&cmd_mirror_mask_portid,
8588 (void *)&cmd_mirror_mask_mirror,
8589 (void *)&cmd_mirror_mask_ruleid,
8590 (void *)&cmd_mirror_mask_what,
8591 (void *)&cmd_mirror_mask_value,
8592 (void *)&cmd_mirror_mask_dstpool,
8593 (void *)&cmd_mirror_mask_poolid,
8594 (void *)&cmd_mirror_mask_on,
8599 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8600 struct cmd_set_mirror_link_result {
8601 cmdline_fixed_string_t set;
8602 cmdline_fixed_string_t port;
8604 cmdline_fixed_string_t mirror;
8606 cmdline_fixed_string_t what;
8607 cmdline_fixed_string_t dstpool;
8609 cmdline_fixed_string_t on;
8612 cmdline_parse_token_string_t cmd_mirror_link_set =
8613 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8615 cmdline_parse_token_string_t cmd_mirror_link_port =
8616 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8618 cmdline_parse_token_num_t cmd_mirror_link_portid =
8619 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8621 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8622 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8623 mirror, "mirror-rule");
8624 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8625 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8627 cmdline_parse_token_string_t cmd_mirror_link_what =
8628 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8629 what, "uplink-mirror#downlink-mirror");
8630 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8631 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8632 dstpool, "dst-pool");
8633 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8634 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8636 cmdline_parse_token_string_t cmd_mirror_link_on =
8637 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8641 cmd_set_mirror_link_parsed(void *parsed_result,
8642 __attribute__((unused)) struct cmdline *cl,
8643 __attribute__((unused)) void *data)
8646 struct cmd_set_mirror_link_result *res = parsed_result;
8647 struct rte_eth_mirror_conf mr_conf;
8649 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8650 if (!strcmp(res->what, "uplink-mirror"))
8651 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8653 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8655 mr_conf.dst_pool = res->dstpool_id;
8657 if (!strcmp(res->on, "on"))
8658 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8661 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8664 /* check the return value and print it if is < 0 */
8666 printf("mirror rule add error: (%s)\n", strerror(-ret));
8670 cmdline_parse_inst_t cmd_set_mirror_link = {
8671 .f = cmd_set_mirror_link_parsed,
8673 .help_str = "set port <port_id> mirror-rule <rule_id> "
8674 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8676 (void *)&cmd_mirror_link_set,
8677 (void *)&cmd_mirror_link_port,
8678 (void *)&cmd_mirror_link_portid,
8679 (void *)&cmd_mirror_link_mirror,
8680 (void *)&cmd_mirror_link_ruleid,
8681 (void *)&cmd_mirror_link_what,
8682 (void *)&cmd_mirror_link_dstpool,
8683 (void *)&cmd_mirror_link_poolid,
8684 (void *)&cmd_mirror_link_on,
8689 /* *** RESET VM MIRROR RULE *** */
8690 struct cmd_rm_mirror_rule_result {
8691 cmdline_fixed_string_t reset;
8692 cmdline_fixed_string_t port;
8694 cmdline_fixed_string_t mirror;
8698 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8699 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8701 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8702 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8704 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8705 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8707 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8708 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8709 mirror, "mirror-rule");
8710 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8711 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8715 cmd_reset_mirror_rule_parsed(void *parsed_result,
8716 __attribute__((unused)) struct cmdline *cl,
8717 __attribute__((unused)) void *data)
8720 struct cmd_set_mirror_link_result *res = parsed_result;
8722 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8724 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8727 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8728 .f = cmd_reset_mirror_rule_parsed,
8730 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8732 (void *)&cmd_rm_mirror_rule_reset,
8733 (void *)&cmd_rm_mirror_rule_port,
8734 (void *)&cmd_rm_mirror_rule_portid,
8735 (void *)&cmd_rm_mirror_rule_mirror,
8736 (void *)&cmd_rm_mirror_rule_ruleid,
8741 /* ******************************************************************************** */
8743 struct cmd_dump_result {
8744 cmdline_fixed_string_t dump;
8748 dump_struct_sizes(void)
8750 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8751 DUMP_SIZE(struct rte_mbuf);
8752 DUMP_SIZE(struct rte_mempool);
8753 DUMP_SIZE(struct rte_ring);
8757 static void cmd_dump_parsed(void *parsed_result,
8758 __attribute__((unused)) struct cmdline *cl,
8759 __attribute__((unused)) void *data)
8761 struct cmd_dump_result *res = parsed_result;
8763 if (!strcmp(res->dump, "dump_physmem"))
8764 rte_dump_physmem_layout(stdout);
8765 else if (!strcmp(res->dump, "dump_memzone"))
8766 rte_memzone_dump(stdout);
8767 else if (!strcmp(res->dump, "dump_struct_sizes"))
8768 dump_struct_sizes();
8769 else if (!strcmp(res->dump, "dump_ring"))
8770 rte_ring_list_dump(stdout);
8771 else if (!strcmp(res->dump, "dump_mempool"))
8772 rte_mempool_list_dump(stdout);
8773 else if (!strcmp(res->dump, "dump_devargs"))
8774 rte_devargs_dump(stdout);
8775 else if (!strcmp(res->dump, "dump_log_types"))
8776 rte_log_dump(stdout);
8779 cmdline_parse_token_string_t cmd_dump_dump =
8780 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8783 "dump_struct_sizes#"
8789 cmdline_parse_inst_t cmd_dump = {
8790 .f = cmd_dump_parsed, /* function to call */
8791 .data = NULL, /* 2nd arg of func */
8792 .help_str = "Dump status",
8793 .tokens = { /* token list, NULL terminated */
8794 (void *)&cmd_dump_dump,
8799 /* ******************************************************************************** */
8801 struct cmd_dump_one_result {
8802 cmdline_fixed_string_t dump;
8803 cmdline_fixed_string_t name;
8806 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8807 __attribute__((unused)) void *data)
8809 struct cmd_dump_one_result *res = parsed_result;
8811 if (!strcmp(res->dump, "dump_ring")) {
8813 r = rte_ring_lookup(res->name);
8815 cmdline_printf(cl, "Cannot find ring\n");
8818 rte_ring_dump(stdout, r);
8819 } else if (!strcmp(res->dump, "dump_mempool")) {
8820 struct rte_mempool *mp;
8821 mp = rte_mempool_lookup(res->name);
8823 cmdline_printf(cl, "Cannot find mempool\n");
8826 rte_mempool_dump(stdout, mp);
8830 cmdline_parse_token_string_t cmd_dump_one_dump =
8831 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8832 "dump_ring#dump_mempool");
8834 cmdline_parse_token_string_t cmd_dump_one_name =
8835 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8837 cmdline_parse_inst_t cmd_dump_one = {
8838 .f = cmd_dump_one_parsed, /* function to call */
8839 .data = NULL, /* 2nd arg of func */
8840 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8841 .tokens = { /* token list, NULL terminated */
8842 (void *)&cmd_dump_one_dump,
8843 (void *)&cmd_dump_one_name,
8848 /* *** Add/Del syn filter *** */
8849 struct cmd_syn_filter_result {
8850 cmdline_fixed_string_t filter;
8852 cmdline_fixed_string_t ops;
8853 cmdline_fixed_string_t priority;
8854 cmdline_fixed_string_t high;
8855 cmdline_fixed_string_t queue;
8860 cmd_syn_filter_parsed(void *parsed_result,
8861 __attribute__((unused)) struct cmdline *cl,
8862 __attribute__((unused)) void *data)
8864 struct cmd_syn_filter_result *res = parsed_result;
8865 struct rte_eth_syn_filter syn_filter;
8868 ret = rte_eth_dev_filter_supported(res->port_id,
8869 RTE_ETH_FILTER_SYN);
8871 printf("syn filter is not supported on port %u.\n",
8876 memset(&syn_filter, 0, sizeof(syn_filter));
8878 if (!strcmp(res->ops, "add")) {
8879 if (!strcmp(res->high, "high"))
8880 syn_filter.hig_pri = 1;
8882 syn_filter.hig_pri = 0;
8884 syn_filter.queue = res->queue_id;
8885 ret = rte_eth_dev_filter_ctrl(res->port_id,
8890 ret = rte_eth_dev_filter_ctrl(res->port_id,
8892 RTE_ETH_FILTER_DELETE,
8896 printf("syn filter programming error: (%s)\n",
8900 cmdline_parse_token_string_t cmd_syn_filter_filter =
8901 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8902 filter, "syn_filter");
8903 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8904 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8906 cmdline_parse_token_string_t cmd_syn_filter_ops =
8907 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8909 cmdline_parse_token_string_t cmd_syn_filter_priority =
8910 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8911 priority, "priority");
8912 cmdline_parse_token_string_t cmd_syn_filter_high =
8913 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8915 cmdline_parse_token_string_t cmd_syn_filter_queue =
8916 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8918 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8919 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8922 cmdline_parse_inst_t cmd_syn_filter = {
8923 .f = cmd_syn_filter_parsed,
8925 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8926 "<queue_id>: Add/Delete syn filter",
8928 (void *)&cmd_syn_filter_filter,
8929 (void *)&cmd_syn_filter_port_id,
8930 (void *)&cmd_syn_filter_ops,
8931 (void *)&cmd_syn_filter_priority,
8932 (void *)&cmd_syn_filter_high,
8933 (void *)&cmd_syn_filter_queue,
8934 (void *)&cmd_syn_filter_queue_id,
8939 /* *** queue region set *** */
8940 struct cmd_queue_region_result {
8941 cmdline_fixed_string_t set;
8942 cmdline_fixed_string_t port;
8944 cmdline_fixed_string_t cmd;
8945 cmdline_fixed_string_t region;
8947 cmdline_fixed_string_t queue_start_index;
8949 cmdline_fixed_string_t queue_num;
8950 uint8_t queue_num_value;
8954 cmd_queue_region_parsed(void *parsed_result,
8955 __attribute__((unused)) struct cmdline *cl,
8956 __attribute__((unused)) void *data)
8958 struct cmd_queue_region_result *res = parsed_result;
8960 #ifdef RTE_LIBRTE_I40E_PMD
8961 struct rte_pmd_i40e_queue_region_conf region_conf;
8962 enum rte_pmd_i40e_queue_region_op op_type;
8965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8968 #ifdef RTE_LIBRTE_I40E_PMD
8969 memset(®ion_conf, 0, sizeof(region_conf));
8970 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8971 region_conf.region_id = res->region_id;
8972 region_conf.queue_num = res->queue_num_value;
8973 region_conf.queue_start_index = res->queue_id;
8975 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8976 op_type, ®ion_conf);
8983 printf("function not implemented or supported\n");
8986 printf("queue region config error: (%s)\n", strerror(-ret));
8990 cmdline_parse_token_string_t cmd_queue_region_set =
8991 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8993 cmdline_parse_token_string_t cmd_queue_region_port =
8994 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8995 cmdline_parse_token_num_t cmd_queue_region_port_id =
8996 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8998 cmdline_parse_token_string_t cmd_queue_region_cmd =
8999 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9000 cmd, "queue-region");
9001 cmdline_parse_token_string_t cmd_queue_region_id =
9002 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9003 region, "region_id");
9004 cmdline_parse_token_num_t cmd_queue_region_index =
9005 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9007 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9008 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9009 queue_start_index, "queue_start_index");
9010 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9011 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9013 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9014 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9015 queue_num, "queue_num");
9016 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9017 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9018 queue_num_value, UINT8);
9020 cmdline_parse_inst_t cmd_queue_region = {
9021 .f = cmd_queue_region_parsed,
9023 .help_str = "set port <port_id> queue-region region_id <value> "
9024 "queue_start_index <value> queue_num <value>: Set a queue region",
9026 (void *)&cmd_queue_region_set,
9027 (void *)&cmd_queue_region_port,
9028 (void *)&cmd_queue_region_port_id,
9029 (void *)&cmd_queue_region_cmd,
9030 (void *)&cmd_queue_region_id,
9031 (void *)&cmd_queue_region_index,
9032 (void *)&cmd_queue_region_queue_start_index,
9033 (void *)&cmd_queue_region_queue_id,
9034 (void *)&cmd_queue_region_queue_num,
9035 (void *)&cmd_queue_region_queue_num_value,
9040 /* *** queue region and flowtype set *** */
9041 struct cmd_region_flowtype_result {
9042 cmdline_fixed_string_t set;
9043 cmdline_fixed_string_t port;
9045 cmdline_fixed_string_t cmd;
9046 cmdline_fixed_string_t region;
9048 cmdline_fixed_string_t flowtype;
9049 uint8_t flowtype_id;
9053 cmd_region_flowtype_parsed(void *parsed_result,
9054 __attribute__((unused)) struct cmdline *cl,
9055 __attribute__((unused)) void *data)
9057 struct cmd_region_flowtype_result *res = parsed_result;
9059 #ifdef RTE_LIBRTE_I40E_PMD
9060 struct rte_pmd_i40e_queue_region_conf region_conf;
9061 enum rte_pmd_i40e_queue_region_op op_type;
9064 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9067 #ifdef RTE_LIBRTE_I40E_PMD
9068 memset(®ion_conf, 0, sizeof(region_conf));
9070 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9071 region_conf.region_id = res->region_id;
9072 region_conf.hw_flowtype = res->flowtype_id;
9074 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9075 op_type, ®ion_conf);
9082 printf("function not implemented or supported\n");
9085 printf("region flowtype config error: (%s)\n", strerror(-ret));
9089 cmdline_parse_token_string_t cmd_region_flowtype_set =
9090 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9092 cmdline_parse_token_string_t cmd_region_flowtype_port =
9093 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9095 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9096 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9098 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9099 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9100 cmd, "queue-region");
9101 cmdline_parse_token_string_t cmd_region_flowtype_index =
9102 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9103 region, "region_id");
9104 cmdline_parse_token_num_t cmd_region_flowtype_id =
9105 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9107 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9108 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9109 flowtype, "flowtype");
9110 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9111 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9112 flowtype_id, UINT8);
9113 cmdline_parse_inst_t cmd_region_flowtype = {
9114 .f = cmd_region_flowtype_parsed,
9116 .help_str = "set port <port_id> queue-region region_id <value> "
9117 "flowtype <value>: Set a flowtype region index",
9119 (void *)&cmd_region_flowtype_set,
9120 (void *)&cmd_region_flowtype_port,
9121 (void *)&cmd_region_flowtype_port_index,
9122 (void *)&cmd_region_flowtype_cmd,
9123 (void *)&cmd_region_flowtype_index,
9124 (void *)&cmd_region_flowtype_id,
9125 (void *)&cmd_region_flowtype_flow_index,
9126 (void *)&cmd_region_flowtype_flow_id,
9131 /* *** User Priority (UP) to queue region (region_id) set *** */
9132 struct cmd_user_priority_region_result {
9133 cmdline_fixed_string_t set;
9134 cmdline_fixed_string_t port;
9136 cmdline_fixed_string_t cmd;
9137 cmdline_fixed_string_t user_priority;
9138 uint8_t user_priority_id;
9139 cmdline_fixed_string_t region;
9144 cmd_user_priority_region_parsed(void *parsed_result,
9145 __attribute__((unused)) struct cmdline *cl,
9146 __attribute__((unused)) void *data)
9148 struct cmd_user_priority_region_result *res = parsed_result;
9150 #ifdef RTE_LIBRTE_I40E_PMD
9151 struct rte_pmd_i40e_queue_region_conf region_conf;
9152 enum rte_pmd_i40e_queue_region_op op_type;
9155 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9158 #ifdef RTE_LIBRTE_I40E_PMD
9159 memset(®ion_conf, 0, sizeof(region_conf));
9160 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9161 region_conf.user_priority = res->user_priority_id;
9162 region_conf.region_id = res->region_id;
9164 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9165 op_type, ®ion_conf);
9172 printf("function not implemented or supported\n");
9175 printf("user_priority region config error: (%s)\n",
9180 cmdline_parse_token_string_t cmd_user_priority_region_set =
9181 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9183 cmdline_parse_token_string_t cmd_user_priority_region_port =
9184 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9186 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9187 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9189 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9190 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9191 cmd, "queue-region");
9192 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9193 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9194 user_priority, "UP");
9195 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9196 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9197 user_priority_id, UINT8);
9198 cmdline_parse_token_string_t cmd_user_priority_region_region =
9199 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9200 region, "region_id");
9201 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9202 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9205 cmdline_parse_inst_t cmd_user_priority_region = {
9206 .f = cmd_user_priority_region_parsed,
9208 .help_str = "set port <port_id> queue-region UP <value> "
9209 "region_id <value>: Set the mapping of User Priority (UP) "
9210 "to queue region (region_id) ",
9212 (void *)&cmd_user_priority_region_set,
9213 (void *)&cmd_user_priority_region_port,
9214 (void *)&cmd_user_priority_region_port_index,
9215 (void *)&cmd_user_priority_region_cmd,
9216 (void *)&cmd_user_priority_region_UP,
9217 (void *)&cmd_user_priority_region_UP_id,
9218 (void *)&cmd_user_priority_region_region,
9219 (void *)&cmd_user_priority_region_region_id,
9224 /* *** flush all queue region related configuration *** */
9225 struct cmd_flush_queue_region_result {
9226 cmdline_fixed_string_t set;
9227 cmdline_fixed_string_t port;
9229 cmdline_fixed_string_t cmd;
9230 cmdline_fixed_string_t flush;
9231 cmdline_fixed_string_t what;
9235 cmd_flush_queue_region_parsed(void *parsed_result,
9236 __attribute__((unused)) struct cmdline *cl,
9237 __attribute__((unused)) void *data)
9239 struct cmd_flush_queue_region_result *res = parsed_result;
9241 #ifdef RTE_LIBRTE_I40E_PMD
9242 struct rte_pmd_i40e_queue_region_conf region_conf;
9243 enum rte_pmd_i40e_queue_region_op op_type;
9246 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9249 #ifdef RTE_LIBRTE_I40E_PMD
9250 memset(®ion_conf, 0, sizeof(region_conf));
9252 if (strcmp(res->what, "on") == 0)
9253 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9255 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9257 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9258 op_type, ®ion_conf);
9265 printf("function not implemented or supported\n");
9268 printf("queue region config flush error: (%s)\n",
9273 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9274 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9276 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9277 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9279 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9280 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9282 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9283 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9284 cmd, "queue-region");
9285 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9286 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9288 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9289 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9292 cmdline_parse_inst_t cmd_flush_queue_region = {
9293 .f = cmd_flush_queue_region_parsed,
9295 .help_str = "set port <port_id> queue-region flush on|off"
9296 ": flush all queue region related configuration",
9298 (void *)&cmd_flush_queue_region_set,
9299 (void *)&cmd_flush_queue_region_port,
9300 (void *)&cmd_flush_queue_region_port_index,
9301 (void *)&cmd_flush_queue_region_cmd,
9302 (void *)&cmd_flush_queue_region_flush,
9303 (void *)&cmd_flush_queue_region_what,
9308 /* *** get all queue region related configuration info *** */
9309 struct cmd_show_queue_region_info {
9310 cmdline_fixed_string_t show;
9311 cmdline_fixed_string_t port;
9313 cmdline_fixed_string_t cmd;
9317 cmd_show_queue_region_info_parsed(void *parsed_result,
9318 __attribute__((unused)) struct cmdline *cl,
9319 __attribute__((unused)) void *data)
9321 struct cmd_show_queue_region_info *res = parsed_result;
9323 #ifdef RTE_LIBRTE_I40E_PMD
9324 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9325 enum rte_pmd_i40e_queue_region_op op_type;
9328 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9331 #ifdef RTE_LIBRTE_I40E_PMD
9332 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9334 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9336 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9337 op_type, &rte_pmd_regions);
9339 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9346 printf("function not implemented or supported\n");
9349 printf("queue region config info show error: (%s)\n",
9354 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9355 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9357 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9358 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9360 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9361 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9363 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9364 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9365 cmd, "queue-region");
9367 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9368 .f = cmd_show_queue_region_info_parsed,
9370 .help_str = "show port <port_id> queue-region"
9371 ": show all queue region related configuration info",
9373 (void *)&cmd_show_queue_region_info_get,
9374 (void *)&cmd_show_queue_region_info_port,
9375 (void *)&cmd_show_queue_region_info_port_index,
9376 (void *)&cmd_show_queue_region_info_cmd,
9381 /* *** ADD/REMOVE A 2tuple FILTER *** */
9382 struct cmd_2tuple_filter_result {
9383 cmdline_fixed_string_t filter;
9385 cmdline_fixed_string_t ops;
9386 cmdline_fixed_string_t dst_port;
9387 uint16_t dst_port_value;
9388 cmdline_fixed_string_t protocol;
9389 uint8_t protocol_value;
9390 cmdline_fixed_string_t mask;
9392 cmdline_fixed_string_t tcp_flags;
9393 uint8_t tcp_flags_value;
9394 cmdline_fixed_string_t priority;
9395 uint8_t priority_value;
9396 cmdline_fixed_string_t queue;
9401 cmd_2tuple_filter_parsed(void *parsed_result,
9402 __attribute__((unused)) struct cmdline *cl,
9403 __attribute__((unused)) void *data)
9405 struct rte_eth_ntuple_filter filter;
9406 struct cmd_2tuple_filter_result *res = parsed_result;
9409 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9411 printf("ntuple filter is not supported on port %u.\n",
9416 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9418 filter.flags = RTE_2TUPLE_FLAGS;
9419 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9420 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9421 filter.proto = res->protocol_value;
9422 filter.priority = res->priority_value;
9423 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9424 printf("nonzero tcp_flags is only meaningful"
9425 " when protocol is TCP.\n");
9428 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9429 printf("invalid TCP flags.\n");
9433 if (res->tcp_flags_value != 0) {
9434 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9435 filter.tcp_flags = res->tcp_flags_value;
9438 /* need convert to big endian. */
9439 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9440 filter.queue = res->queue_id;
9442 if (!strcmp(res->ops, "add"))
9443 ret = rte_eth_dev_filter_ctrl(res->port_id,
9444 RTE_ETH_FILTER_NTUPLE,
9448 ret = rte_eth_dev_filter_ctrl(res->port_id,
9449 RTE_ETH_FILTER_NTUPLE,
9450 RTE_ETH_FILTER_DELETE,
9453 printf("2tuple filter programming error: (%s)\n",
9458 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9459 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9460 filter, "2tuple_filter");
9461 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9462 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9464 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9465 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9467 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9468 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9469 dst_port, "dst_port");
9470 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9471 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9472 dst_port_value, UINT16);
9473 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9474 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9475 protocol, "protocol");
9476 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9477 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9478 protocol_value, UINT8);
9479 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9480 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9482 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9483 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9485 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9486 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9487 tcp_flags, "tcp_flags");
9488 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9489 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9490 tcp_flags_value, UINT8);
9491 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9492 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9493 priority, "priority");
9494 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9495 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9496 priority_value, UINT8);
9497 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9498 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9500 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9501 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9504 cmdline_parse_inst_t cmd_2tuple_filter = {
9505 .f = cmd_2tuple_filter_parsed,
9507 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9508 "<value> mask <value> tcp_flags <value> priority <value> queue "
9509 "<queue_id>: Add a 2tuple filter",
9511 (void *)&cmd_2tuple_filter_filter,
9512 (void *)&cmd_2tuple_filter_port_id,
9513 (void *)&cmd_2tuple_filter_ops,
9514 (void *)&cmd_2tuple_filter_dst_port,
9515 (void *)&cmd_2tuple_filter_dst_port_value,
9516 (void *)&cmd_2tuple_filter_protocol,
9517 (void *)&cmd_2tuple_filter_protocol_value,
9518 (void *)&cmd_2tuple_filter_mask,
9519 (void *)&cmd_2tuple_filter_mask_value,
9520 (void *)&cmd_2tuple_filter_tcp_flags,
9521 (void *)&cmd_2tuple_filter_tcp_flags_value,
9522 (void *)&cmd_2tuple_filter_priority,
9523 (void *)&cmd_2tuple_filter_priority_value,
9524 (void *)&cmd_2tuple_filter_queue,
9525 (void *)&cmd_2tuple_filter_queue_id,
9530 /* *** ADD/REMOVE A 5tuple FILTER *** */
9531 struct cmd_5tuple_filter_result {
9532 cmdline_fixed_string_t filter;
9534 cmdline_fixed_string_t ops;
9535 cmdline_fixed_string_t dst_ip;
9536 cmdline_ipaddr_t dst_ip_value;
9537 cmdline_fixed_string_t src_ip;
9538 cmdline_ipaddr_t src_ip_value;
9539 cmdline_fixed_string_t dst_port;
9540 uint16_t dst_port_value;
9541 cmdline_fixed_string_t src_port;
9542 uint16_t src_port_value;
9543 cmdline_fixed_string_t protocol;
9544 uint8_t protocol_value;
9545 cmdline_fixed_string_t mask;
9547 cmdline_fixed_string_t tcp_flags;
9548 uint8_t tcp_flags_value;
9549 cmdline_fixed_string_t priority;
9550 uint8_t priority_value;
9551 cmdline_fixed_string_t queue;
9556 cmd_5tuple_filter_parsed(void *parsed_result,
9557 __attribute__((unused)) struct cmdline *cl,
9558 __attribute__((unused)) void *data)
9560 struct rte_eth_ntuple_filter filter;
9561 struct cmd_5tuple_filter_result *res = parsed_result;
9564 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9566 printf("ntuple filter is not supported on port %u.\n",
9571 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9573 filter.flags = RTE_5TUPLE_FLAGS;
9574 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9575 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9576 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9577 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9578 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9579 filter.proto = res->protocol_value;
9580 filter.priority = res->priority_value;
9581 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9582 printf("nonzero tcp_flags is only meaningful"
9583 " when protocol is TCP.\n");
9586 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9587 printf("invalid TCP flags.\n");
9591 if (res->tcp_flags_value != 0) {
9592 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9593 filter.tcp_flags = res->tcp_flags_value;
9596 if (res->dst_ip_value.family == AF_INET)
9597 /* no need to convert, already big endian. */
9598 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9600 if (filter.dst_ip_mask == 0) {
9601 printf("can not support ipv6 involved compare.\n");
9607 if (res->src_ip_value.family == AF_INET)
9608 /* no need to convert, already big endian. */
9609 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9611 if (filter.src_ip_mask == 0) {
9612 printf("can not support ipv6 involved compare.\n");
9617 /* need convert to big endian. */
9618 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9619 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9620 filter.queue = res->queue_id;
9622 if (!strcmp(res->ops, "add"))
9623 ret = rte_eth_dev_filter_ctrl(res->port_id,
9624 RTE_ETH_FILTER_NTUPLE,
9628 ret = rte_eth_dev_filter_ctrl(res->port_id,
9629 RTE_ETH_FILTER_NTUPLE,
9630 RTE_ETH_FILTER_DELETE,
9633 printf("5tuple filter programming error: (%s)\n",
9637 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9638 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9639 filter, "5tuple_filter");
9640 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9641 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9643 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9644 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9646 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9647 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9649 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9650 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9652 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9653 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9655 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9656 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9658 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9659 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9660 dst_port, "dst_port");
9661 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9662 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9663 dst_port_value, UINT16);
9664 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9665 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9666 src_port, "src_port");
9667 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9668 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9669 src_port_value, UINT16);
9670 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9671 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9672 protocol, "protocol");
9673 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9674 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9675 protocol_value, UINT8);
9676 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9677 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9679 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9680 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9682 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9683 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9684 tcp_flags, "tcp_flags");
9685 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9686 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9687 tcp_flags_value, UINT8);
9688 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9689 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9690 priority, "priority");
9691 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9692 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9693 priority_value, UINT8);
9694 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9695 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9697 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9698 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9701 cmdline_parse_inst_t cmd_5tuple_filter = {
9702 .f = cmd_5tuple_filter_parsed,
9704 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9705 "src_ip <value> dst_port <value> src_port <value> "
9706 "protocol <value> mask <value> tcp_flags <value> "
9707 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9709 (void *)&cmd_5tuple_filter_filter,
9710 (void *)&cmd_5tuple_filter_port_id,
9711 (void *)&cmd_5tuple_filter_ops,
9712 (void *)&cmd_5tuple_filter_dst_ip,
9713 (void *)&cmd_5tuple_filter_dst_ip_value,
9714 (void *)&cmd_5tuple_filter_src_ip,
9715 (void *)&cmd_5tuple_filter_src_ip_value,
9716 (void *)&cmd_5tuple_filter_dst_port,
9717 (void *)&cmd_5tuple_filter_dst_port_value,
9718 (void *)&cmd_5tuple_filter_src_port,
9719 (void *)&cmd_5tuple_filter_src_port_value,
9720 (void *)&cmd_5tuple_filter_protocol,
9721 (void *)&cmd_5tuple_filter_protocol_value,
9722 (void *)&cmd_5tuple_filter_mask,
9723 (void *)&cmd_5tuple_filter_mask_value,
9724 (void *)&cmd_5tuple_filter_tcp_flags,
9725 (void *)&cmd_5tuple_filter_tcp_flags_value,
9726 (void *)&cmd_5tuple_filter_priority,
9727 (void *)&cmd_5tuple_filter_priority_value,
9728 (void *)&cmd_5tuple_filter_queue,
9729 (void *)&cmd_5tuple_filter_queue_id,
9734 /* *** ADD/REMOVE A flex FILTER *** */
9735 struct cmd_flex_filter_result {
9736 cmdline_fixed_string_t filter;
9737 cmdline_fixed_string_t ops;
9739 cmdline_fixed_string_t len;
9741 cmdline_fixed_string_t bytes;
9742 cmdline_fixed_string_t bytes_value;
9743 cmdline_fixed_string_t mask;
9744 cmdline_fixed_string_t mask_value;
9745 cmdline_fixed_string_t priority;
9746 uint8_t priority_value;
9747 cmdline_fixed_string_t queue;
9751 static int xdigit2val(unsigned char c)
9756 else if (isupper(c))
9764 cmd_flex_filter_parsed(void *parsed_result,
9765 __attribute__((unused)) struct cmdline *cl,
9766 __attribute__((unused)) void *data)
9769 struct rte_eth_flex_filter filter;
9770 struct cmd_flex_filter_result *res = parsed_result;
9771 char *bytes_ptr, *mask_ptr;
9772 uint16_t len, i, j = 0;
9777 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9778 printf("the len exceed the max length 128\n");
9781 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9782 filter.len = res->len_value;
9783 filter.priority = res->priority_value;
9784 filter.queue = res->queue_id;
9785 bytes_ptr = res->bytes_value;
9786 mask_ptr = res->mask_value;
9788 /* translate bytes string to array. */
9789 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9790 (bytes_ptr[1] == 'X')))
9792 len = strnlen(bytes_ptr, res->len_value * 2);
9793 if (len == 0 || (len % 8 != 0)) {
9794 printf("please check len and bytes input\n");
9797 for (i = 0; i < len; i++) {
9799 if (isxdigit(c) == 0) {
9800 /* invalid characters. */
9801 printf("invalid input\n");
9804 val = xdigit2val(c);
9807 filter.bytes[j] = byte;
9808 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9815 /* translate mask string to uint8_t array. */
9816 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9817 (mask_ptr[1] == 'X')))
9819 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9821 printf("invalid input\n");
9826 for (i = 0; i < len; i++) {
9828 if (isxdigit(c) == 0) {
9829 /* invalid characters. */
9830 printf("invalid input\n");
9833 val = xdigit2val(c);
9836 filter.mask[j] = byte;
9837 printf("mask[%d]:%02x ", j, filter.mask[j]);
9845 if (!strcmp(res->ops, "add"))
9846 ret = rte_eth_dev_filter_ctrl(res->port_id,
9847 RTE_ETH_FILTER_FLEXIBLE,
9851 ret = rte_eth_dev_filter_ctrl(res->port_id,
9852 RTE_ETH_FILTER_FLEXIBLE,
9853 RTE_ETH_FILTER_DELETE,
9857 printf("flex filter setting error: (%s)\n", strerror(-ret));
9860 cmdline_parse_token_string_t cmd_flex_filter_filter =
9861 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9862 filter, "flex_filter");
9863 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9864 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9866 cmdline_parse_token_string_t cmd_flex_filter_ops =
9867 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9869 cmdline_parse_token_string_t cmd_flex_filter_len =
9870 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9872 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9873 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9875 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9876 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9878 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9879 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9881 cmdline_parse_token_string_t cmd_flex_filter_mask =
9882 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9884 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9885 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9887 cmdline_parse_token_string_t cmd_flex_filter_priority =
9888 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9889 priority, "priority");
9890 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9891 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9892 priority_value, UINT8);
9893 cmdline_parse_token_string_t cmd_flex_filter_queue =
9894 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9896 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9897 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9899 cmdline_parse_inst_t cmd_flex_filter = {
9900 .f = cmd_flex_filter_parsed,
9902 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9903 "<value> mask <value> priority <value> queue <queue_id>: "
9904 "Add/Del a flex filter",
9906 (void *)&cmd_flex_filter_filter,
9907 (void *)&cmd_flex_filter_port_id,
9908 (void *)&cmd_flex_filter_ops,
9909 (void *)&cmd_flex_filter_len,
9910 (void *)&cmd_flex_filter_len_value,
9911 (void *)&cmd_flex_filter_bytes,
9912 (void *)&cmd_flex_filter_bytes_value,
9913 (void *)&cmd_flex_filter_mask,
9914 (void *)&cmd_flex_filter_mask_value,
9915 (void *)&cmd_flex_filter_priority,
9916 (void *)&cmd_flex_filter_priority_value,
9917 (void *)&cmd_flex_filter_queue,
9918 (void *)&cmd_flex_filter_queue_id,
9923 /* *** Filters Control *** */
9925 /* *** deal with ethertype filter *** */
9926 struct cmd_ethertype_filter_result {
9927 cmdline_fixed_string_t filter;
9929 cmdline_fixed_string_t ops;
9930 cmdline_fixed_string_t mac;
9931 struct ether_addr mac_addr;
9932 cmdline_fixed_string_t ethertype;
9933 uint16_t ethertype_value;
9934 cmdline_fixed_string_t drop;
9935 cmdline_fixed_string_t queue;
9939 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9940 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9941 filter, "ethertype_filter");
9942 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9943 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9945 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9946 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9948 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9949 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9950 mac, "mac_addr#mac_ignr");
9951 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9952 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9954 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9955 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9956 ethertype, "ethertype");
9957 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9958 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9959 ethertype_value, UINT16);
9960 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9961 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9963 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9964 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9966 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9967 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9971 cmd_ethertype_filter_parsed(void *parsed_result,
9972 __attribute__((unused)) struct cmdline *cl,
9973 __attribute__((unused)) void *data)
9975 struct cmd_ethertype_filter_result *res = parsed_result;
9976 struct rte_eth_ethertype_filter filter;
9979 ret = rte_eth_dev_filter_supported(res->port_id,
9980 RTE_ETH_FILTER_ETHERTYPE);
9982 printf("ethertype filter is not supported on port %u.\n",
9987 memset(&filter, 0, sizeof(filter));
9988 if (!strcmp(res->mac, "mac_addr")) {
9989 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9990 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9991 sizeof(struct ether_addr));
9993 if (!strcmp(res->drop, "drop"))
9994 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9995 filter.ether_type = res->ethertype_value;
9996 filter.queue = res->queue_id;
9998 if (!strcmp(res->ops, "add"))
9999 ret = rte_eth_dev_filter_ctrl(res->port_id,
10000 RTE_ETH_FILTER_ETHERTYPE,
10001 RTE_ETH_FILTER_ADD,
10004 ret = rte_eth_dev_filter_ctrl(res->port_id,
10005 RTE_ETH_FILTER_ETHERTYPE,
10006 RTE_ETH_FILTER_DELETE,
10009 printf("ethertype filter programming error: (%s)\n",
10013 cmdline_parse_inst_t cmd_ethertype_filter = {
10014 .f = cmd_ethertype_filter_parsed,
10016 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10017 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10018 "Add or delete an ethertype filter entry",
10020 (void *)&cmd_ethertype_filter_filter,
10021 (void *)&cmd_ethertype_filter_port_id,
10022 (void *)&cmd_ethertype_filter_ops,
10023 (void *)&cmd_ethertype_filter_mac,
10024 (void *)&cmd_ethertype_filter_mac_addr,
10025 (void *)&cmd_ethertype_filter_ethertype,
10026 (void *)&cmd_ethertype_filter_ethertype_value,
10027 (void *)&cmd_ethertype_filter_drop,
10028 (void *)&cmd_ethertype_filter_queue,
10029 (void *)&cmd_ethertype_filter_queue_id,
10034 /* *** deal with flow director filter *** */
10035 struct cmd_flow_director_result {
10036 cmdline_fixed_string_t flow_director_filter;
10038 cmdline_fixed_string_t mode;
10039 cmdline_fixed_string_t mode_value;
10040 cmdline_fixed_string_t ops;
10041 cmdline_fixed_string_t flow;
10042 cmdline_fixed_string_t flow_type;
10043 cmdline_fixed_string_t ether;
10044 uint16_t ether_type;
10045 cmdline_fixed_string_t src;
10046 cmdline_ipaddr_t ip_src;
10048 cmdline_fixed_string_t dst;
10049 cmdline_ipaddr_t ip_dst;
10051 cmdline_fixed_string_t verify_tag;
10052 uint32_t verify_tag_value;
10053 cmdline_fixed_string_t tos;
10055 cmdline_fixed_string_t proto;
10056 uint8_t proto_value;
10057 cmdline_fixed_string_t ttl;
10059 cmdline_fixed_string_t vlan;
10060 uint16_t vlan_value;
10061 cmdline_fixed_string_t flexbytes;
10062 cmdline_fixed_string_t flexbytes_value;
10063 cmdline_fixed_string_t pf_vf;
10064 cmdline_fixed_string_t drop;
10065 cmdline_fixed_string_t queue;
10067 cmdline_fixed_string_t fd_id;
10068 uint32_t fd_id_value;
10069 cmdline_fixed_string_t mac;
10070 struct ether_addr mac_addr;
10071 cmdline_fixed_string_t tunnel;
10072 cmdline_fixed_string_t tunnel_type;
10073 cmdline_fixed_string_t tunnel_id;
10074 uint32_t tunnel_id_value;
10075 cmdline_fixed_string_t packet;
10080 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10083 const char *p, *p0 = q_arg;
10085 unsigned long int_fld;
10086 char *str_fld[max_num];
10091 p = strchr(p0, '(');
10095 p0 = strchr(p, ')');
10100 if (size >= sizeof(s))
10103 snprintf(s, sizeof(s), "%.*s", size, p);
10104 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10105 if (ret < 0 || ret > max_num)
10107 for (i = 0; i < ret; i++) {
10109 int_fld = strtoul(str_fld[i], &end, 0);
10110 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10112 flexbytes[i] = (uint8_t)int_fld;
10118 str2flowtype(char *string)
10121 static const struct {
10124 } flowtype_str[] = {
10125 {"raw", RTE_ETH_FLOW_RAW},
10126 {"ipv4", RTE_ETH_FLOW_IPV4},
10127 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10128 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10129 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10130 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10131 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10132 {"ipv6", RTE_ETH_FLOW_IPV6},
10133 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10134 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10135 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10136 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10137 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10138 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10141 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10142 if (!strcmp(flowtype_str[i].str, string))
10143 return flowtype_str[i].type;
10146 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10147 return (uint16_t)atoi(string);
10149 return RTE_ETH_FLOW_UNKNOWN;
10152 static enum rte_eth_fdir_tunnel_type
10153 str2fdir_tunneltype(char *string)
10157 static const struct {
10159 enum rte_eth_fdir_tunnel_type type;
10160 } tunneltype_str[] = {
10161 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10162 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10165 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10166 if (!strcmp(tunneltype_str[i].str, string))
10167 return tunneltype_str[i].type;
10169 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10172 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10174 if ((ip_addr).family == AF_INET) \
10175 (ip) = (ip_addr).addr.ipv4.s_addr; \
10177 printf("invalid parameter.\n"); \
10182 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10184 if ((ip_addr).family == AF_INET6) \
10185 rte_memcpy(&(ip), \
10186 &((ip_addr).addr.ipv6), \
10187 sizeof(struct in6_addr)); \
10189 printf("invalid parameter.\n"); \
10195 cmd_flow_director_filter_parsed(void *parsed_result,
10196 __attribute__((unused)) struct cmdline *cl,
10197 __attribute__((unused)) void *data)
10199 struct cmd_flow_director_result *res = parsed_result;
10200 struct rte_eth_fdir_filter entry;
10201 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10203 unsigned long vf_id;
10206 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10208 printf("flow director is not supported on port %u.\n",
10212 memset(flexbytes, 0, sizeof(flexbytes));
10213 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10215 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10216 if (strcmp(res->mode_value, "MAC-VLAN")) {
10217 printf("Please set mode to MAC-VLAN.\n");
10220 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10221 if (strcmp(res->mode_value, "Tunnel")) {
10222 printf("Please set mode to Tunnel.\n");
10226 if (!strcmp(res->mode_value, "raw")) {
10227 #ifdef RTE_LIBRTE_I40E_PMD
10228 struct rte_pmd_i40e_flow_type_mapping
10229 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10230 struct rte_pmd_i40e_pkt_template_conf conf;
10231 uint16_t flow_type = str2flowtype(res->flow_type);
10232 uint16_t i, port = res->port_id;
10235 memset(&conf, 0, sizeof(conf));
10237 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10238 printf("Invalid flow type specified.\n");
10241 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10245 if (mapping[flow_type].pctype == 0ULL) {
10246 printf("Invalid flow type specified.\n");
10249 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10250 if (mapping[flow_type].pctype & (1ULL << i)) {
10251 conf.input.pctype = i;
10256 conf.input.packet = open_file(res->filepath,
10257 &conf.input.length);
10258 if (!conf.input.packet)
10260 if (!strcmp(res->drop, "drop"))
10261 conf.action.behavior =
10262 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10264 conf.action.behavior =
10265 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10266 conf.action.report_status =
10267 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10268 conf.action.rx_queue = res->queue_id;
10269 conf.soft_id = res->fd_id_value;
10270 add = strcmp(res->ops, "del") ? 1 : 0;
10271 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10275 printf("flow director config error: (%s)\n",
10277 close_file(conf.input.packet);
10280 } else if (strcmp(res->mode_value, "IP")) {
10281 printf("Please set mode to IP or raw.\n");
10284 entry.input.flow_type = str2flowtype(res->flow_type);
10287 ret = parse_flexbytes(res->flexbytes_value,
10289 RTE_ETH_FDIR_MAX_FLEXLEN);
10291 printf("error: Cannot parse flexbytes input.\n");
10295 switch (entry.input.flow_type) {
10296 case RTE_ETH_FLOW_FRAG_IPV4:
10297 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10298 entry.input.flow.ip4_flow.proto = res->proto_value;
10300 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10301 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10302 IPV4_ADDR_TO_UINT(res->ip_dst,
10303 entry.input.flow.ip4_flow.dst_ip);
10304 IPV4_ADDR_TO_UINT(res->ip_src,
10305 entry.input.flow.ip4_flow.src_ip);
10306 entry.input.flow.ip4_flow.tos = res->tos_value;
10307 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10308 /* need convert to big endian. */
10309 entry.input.flow.udp4_flow.dst_port =
10310 rte_cpu_to_be_16(res->port_dst);
10311 entry.input.flow.udp4_flow.src_port =
10312 rte_cpu_to_be_16(res->port_src);
10314 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10315 IPV4_ADDR_TO_UINT(res->ip_dst,
10316 entry.input.flow.sctp4_flow.ip.dst_ip);
10317 IPV4_ADDR_TO_UINT(res->ip_src,
10318 entry.input.flow.sctp4_flow.ip.src_ip);
10319 entry.input.flow.ip4_flow.tos = res->tos_value;
10320 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10321 /* need convert to big endian. */
10322 entry.input.flow.sctp4_flow.dst_port =
10323 rte_cpu_to_be_16(res->port_dst);
10324 entry.input.flow.sctp4_flow.src_port =
10325 rte_cpu_to_be_16(res->port_src);
10326 entry.input.flow.sctp4_flow.verify_tag =
10327 rte_cpu_to_be_32(res->verify_tag_value);
10329 case RTE_ETH_FLOW_FRAG_IPV6:
10330 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10331 entry.input.flow.ipv6_flow.proto = res->proto_value;
10333 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10334 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10335 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10336 entry.input.flow.ipv6_flow.dst_ip);
10337 IPV6_ADDR_TO_ARRAY(res->ip_src,
10338 entry.input.flow.ipv6_flow.src_ip);
10339 entry.input.flow.ipv6_flow.tc = res->tos_value;
10340 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10341 /* need convert to big endian. */
10342 entry.input.flow.udp6_flow.dst_port =
10343 rte_cpu_to_be_16(res->port_dst);
10344 entry.input.flow.udp6_flow.src_port =
10345 rte_cpu_to_be_16(res->port_src);
10347 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10348 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10349 entry.input.flow.sctp6_flow.ip.dst_ip);
10350 IPV6_ADDR_TO_ARRAY(res->ip_src,
10351 entry.input.flow.sctp6_flow.ip.src_ip);
10352 entry.input.flow.ipv6_flow.tc = res->tos_value;
10353 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10354 /* need convert to big endian. */
10355 entry.input.flow.sctp6_flow.dst_port =
10356 rte_cpu_to_be_16(res->port_dst);
10357 entry.input.flow.sctp6_flow.src_port =
10358 rte_cpu_to_be_16(res->port_src);
10359 entry.input.flow.sctp6_flow.verify_tag =
10360 rte_cpu_to_be_32(res->verify_tag_value);
10362 case RTE_ETH_FLOW_L2_PAYLOAD:
10363 entry.input.flow.l2_flow.ether_type =
10364 rte_cpu_to_be_16(res->ether_type);
10370 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10371 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10373 sizeof(struct ether_addr));
10375 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10376 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10378 sizeof(struct ether_addr));
10379 entry.input.flow.tunnel_flow.tunnel_type =
10380 str2fdir_tunneltype(res->tunnel_type);
10381 entry.input.flow.tunnel_flow.tunnel_id =
10382 rte_cpu_to_be_32(res->tunnel_id_value);
10385 rte_memcpy(entry.input.flow_ext.flexbytes,
10387 RTE_ETH_FDIR_MAX_FLEXLEN);
10389 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10391 entry.action.flex_off = 0; /*use 0 by default */
10392 if (!strcmp(res->drop, "drop"))
10393 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10395 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10397 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10398 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10399 if (!strcmp(res->pf_vf, "pf"))
10400 entry.input.flow_ext.is_vf = 0;
10401 else if (!strncmp(res->pf_vf, "vf", 2)) {
10402 struct rte_eth_dev_info dev_info;
10404 memset(&dev_info, 0, sizeof(dev_info));
10405 rte_eth_dev_info_get(res->port_id, &dev_info);
10407 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10408 if (errno != 0 || *end != '\0' ||
10409 vf_id >= dev_info.max_vfs) {
10410 printf("invalid parameter %s.\n", res->pf_vf);
10413 entry.input.flow_ext.is_vf = 1;
10414 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10416 printf("invalid parameter %s.\n", res->pf_vf);
10421 /* set to report FD ID by default */
10422 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10423 entry.action.rx_queue = res->queue_id;
10424 entry.soft_id = res->fd_id_value;
10425 if (!strcmp(res->ops, "add"))
10426 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10427 RTE_ETH_FILTER_ADD, &entry);
10428 else if (!strcmp(res->ops, "del"))
10429 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10430 RTE_ETH_FILTER_DELETE, &entry);
10432 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10433 RTE_ETH_FILTER_UPDATE, &entry);
10435 printf("flow director programming error: (%s)\n",
10439 cmdline_parse_token_string_t cmd_flow_director_filter =
10440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10441 flow_director_filter, "flow_director_filter");
10442 cmdline_parse_token_num_t cmd_flow_director_port_id =
10443 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10445 cmdline_parse_token_string_t cmd_flow_director_ops =
10446 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10447 ops, "add#del#update");
10448 cmdline_parse_token_string_t cmd_flow_director_flow =
10449 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10451 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10452 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10454 cmdline_parse_token_string_t cmd_flow_director_ether =
10455 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10457 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10458 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10459 ether_type, UINT16);
10460 cmdline_parse_token_string_t cmd_flow_director_src =
10461 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10463 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10464 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10466 cmdline_parse_token_num_t cmd_flow_director_port_src =
10467 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10469 cmdline_parse_token_string_t cmd_flow_director_dst =
10470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10472 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10473 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10475 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10476 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10478 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10479 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10480 verify_tag, "verify_tag");
10481 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10482 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10483 verify_tag_value, UINT32);
10484 cmdline_parse_token_string_t cmd_flow_director_tos =
10485 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10487 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10488 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10490 cmdline_parse_token_string_t cmd_flow_director_proto =
10491 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10493 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10494 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10495 proto_value, UINT8);
10496 cmdline_parse_token_string_t cmd_flow_director_ttl =
10497 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10499 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10500 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10502 cmdline_parse_token_string_t cmd_flow_director_vlan =
10503 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10505 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10506 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10507 vlan_value, UINT16);
10508 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10509 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10510 flexbytes, "flexbytes");
10511 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10512 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10513 flexbytes_value, NULL);
10514 cmdline_parse_token_string_t cmd_flow_director_drop =
10515 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10517 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10518 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10520 cmdline_parse_token_string_t cmd_flow_director_queue =
10521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10523 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10524 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10526 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10527 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10529 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10530 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10531 fd_id_value, UINT32);
10533 cmdline_parse_token_string_t cmd_flow_director_mode =
10534 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10536 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10537 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10539 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10540 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10541 mode_value, "MAC-VLAN");
10542 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10543 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10544 mode_value, "Tunnel");
10545 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10546 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10547 mode_value, "raw");
10548 cmdline_parse_token_string_t cmd_flow_director_mac =
10549 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10551 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10552 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10554 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10555 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10557 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10558 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10559 tunnel_type, "NVGRE#VxLAN");
10560 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10561 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10562 tunnel_id, "tunnel-id");
10563 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10564 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10565 tunnel_id_value, UINT32);
10566 cmdline_parse_token_string_t cmd_flow_director_packet =
10567 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10569 cmdline_parse_token_string_t cmd_flow_director_filepath =
10570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10573 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10574 .f = cmd_flow_director_filter_parsed,
10576 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10577 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10578 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10579 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10580 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10581 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10582 "fd_id <fd_id_value>: "
10583 "Add or delete an ip flow director entry on NIC",
10585 (void *)&cmd_flow_director_filter,
10586 (void *)&cmd_flow_director_port_id,
10587 (void *)&cmd_flow_director_mode,
10588 (void *)&cmd_flow_director_mode_ip,
10589 (void *)&cmd_flow_director_ops,
10590 (void *)&cmd_flow_director_flow,
10591 (void *)&cmd_flow_director_flow_type,
10592 (void *)&cmd_flow_director_src,
10593 (void *)&cmd_flow_director_ip_src,
10594 (void *)&cmd_flow_director_dst,
10595 (void *)&cmd_flow_director_ip_dst,
10596 (void *)&cmd_flow_director_tos,
10597 (void *)&cmd_flow_director_tos_value,
10598 (void *)&cmd_flow_director_proto,
10599 (void *)&cmd_flow_director_proto_value,
10600 (void *)&cmd_flow_director_ttl,
10601 (void *)&cmd_flow_director_ttl_value,
10602 (void *)&cmd_flow_director_vlan,
10603 (void *)&cmd_flow_director_vlan_value,
10604 (void *)&cmd_flow_director_flexbytes,
10605 (void *)&cmd_flow_director_flexbytes_value,
10606 (void *)&cmd_flow_director_drop,
10607 (void *)&cmd_flow_director_pf_vf,
10608 (void *)&cmd_flow_director_queue,
10609 (void *)&cmd_flow_director_queue_id,
10610 (void *)&cmd_flow_director_fd_id,
10611 (void *)&cmd_flow_director_fd_id_value,
10616 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10617 .f = cmd_flow_director_filter_parsed,
10619 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10620 "director entry on NIC",
10622 (void *)&cmd_flow_director_filter,
10623 (void *)&cmd_flow_director_port_id,
10624 (void *)&cmd_flow_director_mode,
10625 (void *)&cmd_flow_director_mode_ip,
10626 (void *)&cmd_flow_director_ops,
10627 (void *)&cmd_flow_director_flow,
10628 (void *)&cmd_flow_director_flow_type,
10629 (void *)&cmd_flow_director_src,
10630 (void *)&cmd_flow_director_ip_src,
10631 (void *)&cmd_flow_director_port_src,
10632 (void *)&cmd_flow_director_dst,
10633 (void *)&cmd_flow_director_ip_dst,
10634 (void *)&cmd_flow_director_port_dst,
10635 (void *)&cmd_flow_director_tos,
10636 (void *)&cmd_flow_director_tos_value,
10637 (void *)&cmd_flow_director_ttl,
10638 (void *)&cmd_flow_director_ttl_value,
10639 (void *)&cmd_flow_director_vlan,
10640 (void *)&cmd_flow_director_vlan_value,
10641 (void *)&cmd_flow_director_flexbytes,
10642 (void *)&cmd_flow_director_flexbytes_value,
10643 (void *)&cmd_flow_director_drop,
10644 (void *)&cmd_flow_director_pf_vf,
10645 (void *)&cmd_flow_director_queue,
10646 (void *)&cmd_flow_director_queue_id,
10647 (void *)&cmd_flow_director_fd_id,
10648 (void *)&cmd_flow_director_fd_id_value,
10653 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10654 .f = cmd_flow_director_filter_parsed,
10656 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10657 "director entry on NIC",
10659 (void *)&cmd_flow_director_filter,
10660 (void *)&cmd_flow_director_port_id,
10661 (void *)&cmd_flow_director_mode,
10662 (void *)&cmd_flow_director_mode_ip,
10663 (void *)&cmd_flow_director_ops,
10664 (void *)&cmd_flow_director_flow,
10665 (void *)&cmd_flow_director_flow_type,
10666 (void *)&cmd_flow_director_src,
10667 (void *)&cmd_flow_director_ip_src,
10668 (void *)&cmd_flow_director_port_src,
10669 (void *)&cmd_flow_director_dst,
10670 (void *)&cmd_flow_director_ip_dst,
10671 (void *)&cmd_flow_director_port_dst,
10672 (void *)&cmd_flow_director_verify_tag,
10673 (void *)&cmd_flow_director_verify_tag_value,
10674 (void *)&cmd_flow_director_tos,
10675 (void *)&cmd_flow_director_tos_value,
10676 (void *)&cmd_flow_director_ttl,
10677 (void *)&cmd_flow_director_ttl_value,
10678 (void *)&cmd_flow_director_vlan,
10679 (void *)&cmd_flow_director_vlan_value,
10680 (void *)&cmd_flow_director_flexbytes,
10681 (void *)&cmd_flow_director_flexbytes_value,
10682 (void *)&cmd_flow_director_drop,
10683 (void *)&cmd_flow_director_pf_vf,
10684 (void *)&cmd_flow_director_queue,
10685 (void *)&cmd_flow_director_queue_id,
10686 (void *)&cmd_flow_director_fd_id,
10687 (void *)&cmd_flow_director_fd_id_value,
10692 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10693 .f = cmd_flow_director_filter_parsed,
10695 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10696 "director entry on NIC",
10698 (void *)&cmd_flow_director_filter,
10699 (void *)&cmd_flow_director_port_id,
10700 (void *)&cmd_flow_director_mode,
10701 (void *)&cmd_flow_director_mode_ip,
10702 (void *)&cmd_flow_director_ops,
10703 (void *)&cmd_flow_director_flow,
10704 (void *)&cmd_flow_director_flow_type,
10705 (void *)&cmd_flow_director_ether,
10706 (void *)&cmd_flow_director_ether_type,
10707 (void *)&cmd_flow_director_flexbytes,
10708 (void *)&cmd_flow_director_flexbytes_value,
10709 (void *)&cmd_flow_director_drop,
10710 (void *)&cmd_flow_director_pf_vf,
10711 (void *)&cmd_flow_director_queue,
10712 (void *)&cmd_flow_director_queue_id,
10713 (void *)&cmd_flow_director_fd_id,
10714 (void *)&cmd_flow_director_fd_id_value,
10719 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10720 .f = cmd_flow_director_filter_parsed,
10722 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10723 "director entry on NIC",
10725 (void *)&cmd_flow_director_filter,
10726 (void *)&cmd_flow_director_port_id,
10727 (void *)&cmd_flow_director_mode,
10728 (void *)&cmd_flow_director_mode_mac_vlan,
10729 (void *)&cmd_flow_director_ops,
10730 (void *)&cmd_flow_director_mac,
10731 (void *)&cmd_flow_director_mac_addr,
10732 (void *)&cmd_flow_director_vlan,
10733 (void *)&cmd_flow_director_vlan_value,
10734 (void *)&cmd_flow_director_flexbytes,
10735 (void *)&cmd_flow_director_flexbytes_value,
10736 (void *)&cmd_flow_director_drop,
10737 (void *)&cmd_flow_director_queue,
10738 (void *)&cmd_flow_director_queue_id,
10739 (void *)&cmd_flow_director_fd_id,
10740 (void *)&cmd_flow_director_fd_id_value,
10745 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10746 .f = cmd_flow_director_filter_parsed,
10748 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10749 "director entry on NIC",
10751 (void *)&cmd_flow_director_filter,
10752 (void *)&cmd_flow_director_port_id,
10753 (void *)&cmd_flow_director_mode,
10754 (void *)&cmd_flow_director_mode_tunnel,
10755 (void *)&cmd_flow_director_ops,
10756 (void *)&cmd_flow_director_mac,
10757 (void *)&cmd_flow_director_mac_addr,
10758 (void *)&cmd_flow_director_vlan,
10759 (void *)&cmd_flow_director_vlan_value,
10760 (void *)&cmd_flow_director_tunnel,
10761 (void *)&cmd_flow_director_tunnel_type,
10762 (void *)&cmd_flow_director_tunnel_id,
10763 (void *)&cmd_flow_director_tunnel_id_value,
10764 (void *)&cmd_flow_director_flexbytes,
10765 (void *)&cmd_flow_director_flexbytes_value,
10766 (void *)&cmd_flow_director_drop,
10767 (void *)&cmd_flow_director_queue,
10768 (void *)&cmd_flow_director_queue_id,
10769 (void *)&cmd_flow_director_fd_id,
10770 (void *)&cmd_flow_director_fd_id_value,
10775 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10776 .f = cmd_flow_director_filter_parsed,
10778 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10779 "director entry on NIC",
10781 (void *)&cmd_flow_director_filter,
10782 (void *)&cmd_flow_director_port_id,
10783 (void *)&cmd_flow_director_mode,
10784 (void *)&cmd_flow_director_mode_raw,
10785 (void *)&cmd_flow_director_ops,
10786 (void *)&cmd_flow_director_flow,
10787 (void *)&cmd_flow_director_flow_type,
10788 (void *)&cmd_flow_director_drop,
10789 (void *)&cmd_flow_director_queue,
10790 (void *)&cmd_flow_director_queue_id,
10791 (void *)&cmd_flow_director_fd_id,
10792 (void *)&cmd_flow_director_fd_id_value,
10793 (void *)&cmd_flow_director_packet,
10794 (void *)&cmd_flow_director_filepath,
10799 struct cmd_flush_flow_director_result {
10800 cmdline_fixed_string_t flush_flow_director;
10804 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10805 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10806 flush_flow_director, "flush_flow_director");
10807 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10808 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10812 cmd_flush_flow_director_parsed(void *parsed_result,
10813 __attribute__((unused)) struct cmdline *cl,
10814 __attribute__((unused)) void *data)
10816 struct cmd_flow_director_result *res = parsed_result;
10819 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10821 printf("flow director is not supported on port %u.\n",
10826 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10827 RTE_ETH_FILTER_FLUSH, NULL);
10829 printf("flow director table flushing error: (%s)\n",
10833 cmdline_parse_inst_t cmd_flush_flow_director = {
10834 .f = cmd_flush_flow_director_parsed,
10836 .help_str = "flush_flow_director <port_id>: "
10837 "Flush all flow director entries of a device on NIC",
10839 (void *)&cmd_flush_flow_director_flush,
10840 (void *)&cmd_flush_flow_director_port_id,
10845 /* *** deal with flow director mask *** */
10846 struct cmd_flow_director_mask_result {
10847 cmdline_fixed_string_t flow_director_mask;
10849 cmdline_fixed_string_t mode;
10850 cmdline_fixed_string_t mode_value;
10851 cmdline_fixed_string_t vlan;
10852 uint16_t vlan_mask;
10853 cmdline_fixed_string_t src_mask;
10854 cmdline_ipaddr_t ipv4_src;
10855 cmdline_ipaddr_t ipv6_src;
10857 cmdline_fixed_string_t dst_mask;
10858 cmdline_ipaddr_t ipv4_dst;
10859 cmdline_ipaddr_t ipv6_dst;
10861 cmdline_fixed_string_t mac;
10862 uint8_t mac_addr_byte_mask;
10863 cmdline_fixed_string_t tunnel_id;
10864 uint32_t tunnel_id_mask;
10865 cmdline_fixed_string_t tunnel_type;
10866 uint8_t tunnel_type_mask;
10870 cmd_flow_director_mask_parsed(void *parsed_result,
10871 __attribute__((unused)) struct cmdline *cl,
10872 __attribute__((unused)) void *data)
10874 struct cmd_flow_director_mask_result *res = parsed_result;
10875 struct rte_eth_fdir_masks *mask;
10876 struct rte_port *port;
10878 port = &ports[res->port_id];
10879 /** Check if the port is not started **/
10880 if (port->port_status != RTE_PORT_STOPPED) {
10881 printf("Please stop port %d first\n", res->port_id);
10885 mask = &port->dev_conf.fdir_conf.mask;
10887 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10888 if (strcmp(res->mode_value, "MAC-VLAN")) {
10889 printf("Please set mode to MAC-VLAN.\n");
10893 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10894 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10895 if (strcmp(res->mode_value, "Tunnel")) {
10896 printf("Please set mode to Tunnel.\n");
10900 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10901 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10902 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10903 mask->tunnel_type_mask = res->tunnel_type_mask;
10905 if (strcmp(res->mode_value, "IP")) {
10906 printf("Please set mode to IP.\n");
10910 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10911 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10912 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10913 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10914 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10915 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10916 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10919 cmd_reconfig_device_queue(res->port_id, 1, 1);
10922 cmdline_parse_token_string_t cmd_flow_director_mask =
10923 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10924 flow_director_mask, "flow_director_mask");
10925 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10926 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10928 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10929 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10931 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10932 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10933 vlan_mask, UINT16);
10934 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10935 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10936 src_mask, "src_mask");
10937 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10938 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10940 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10941 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10943 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10944 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10946 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10947 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10948 dst_mask, "dst_mask");
10949 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10950 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10952 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10953 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10955 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10956 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10959 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10960 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10962 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10963 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10965 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10966 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10967 mode_value, "MAC-VLAN");
10968 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10969 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10970 mode_value, "Tunnel");
10971 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10972 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10974 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10975 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10976 mac_addr_byte_mask, UINT8);
10977 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10978 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10979 tunnel_type, "tunnel-type");
10980 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10981 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10982 tunnel_type_mask, UINT8);
10983 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10984 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10985 tunnel_id, "tunnel-id");
10986 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10987 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10988 tunnel_id_mask, UINT32);
10990 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10991 .f = cmd_flow_director_mask_parsed,
10993 .help_str = "flow_director_mask ... : "
10994 "Set IP mode flow director's mask on NIC",
10996 (void *)&cmd_flow_director_mask,
10997 (void *)&cmd_flow_director_mask_port_id,
10998 (void *)&cmd_flow_director_mask_mode,
10999 (void *)&cmd_flow_director_mask_mode_ip,
11000 (void *)&cmd_flow_director_mask_vlan,
11001 (void *)&cmd_flow_director_mask_vlan_value,
11002 (void *)&cmd_flow_director_mask_src,
11003 (void *)&cmd_flow_director_mask_ipv4_src,
11004 (void *)&cmd_flow_director_mask_ipv6_src,
11005 (void *)&cmd_flow_director_mask_port_src,
11006 (void *)&cmd_flow_director_mask_dst,
11007 (void *)&cmd_flow_director_mask_ipv4_dst,
11008 (void *)&cmd_flow_director_mask_ipv6_dst,
11009 (void *)&cmd_flow_director_mask_port_dst,
11014 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11015 .f = cmd_flow_director_mask_parsed,
11017 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11018 "flow director's mask on NIC",
11020 (void *)&cmd_flow_director_mask,
11021 (void *)&cmd_flow_director_mask_port_id,
11022 (void *)&cmd_flow_director_mask_mode,
11023 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11024 (void *)&cmd_flow_director_mask_vlan,
11025 (void *)&cmd_flow_director_mask_vlan_value,
11030 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11031 .f = cmd_flow_director_mask_parsed,
11033 .help_str = "flow_director_mask ... : Set tunnel mode "
11034 "flow director's mask on NIC",
11036 (void *)&cmd_flow_director_mask,
11037 (void *)&cmd_flow_director_mask_port_id,
11038 (void *)&cmd_flow_director_mask_mode,
11039 (void *)&cmd_flow_director_mask_mode_tunnel,
11040 (void *)&cmd_flow_director_mask_vlan,
11041 (void *)&cmd_flow_director_mask_vlan_value,
11042 (void *)&cmd_flow_director_mask_mac,
11043 (void *)&cmd_flow_director_mask_mac_value,
11044 (void *)&cmd_flow_director_mask_tunnel_type,
11045 (void *)&cmd_flow_director_mask_tunnel_type_value,
11046 (void *)&cmd_flow_director_mask_tunnel_id,
11047 (void *)&cmd_flow_director_mask_tunnel_id_value,
11052 /* *** deal with flow director mask on flexible payload *** */
11053 struct cmd_flow_director_flex_mask_result {
11054 cmdline_fixed_string_t flow_director_flexmask;
11056 cmdline_fixed_string_t flow;
11057 cmdline_fixed_string_t flow_type;
11058 cmdline_fixed_string_t mask;
11062 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11063 __attribute__((unused)) struct cmdline *cl,
11064 __attribute__((unused)) void *data)
11066 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11067 struct rte_eth_fdir_info fdir_info;
11068 struct rte_eth_fdir_flex_mask flex_mask;
11069 struct rte_port *port;
11070 uint64_t flow_type_mask;
11074 port = &ports[res->port_id];
11075 /** Check if the port is not started **/
11076 if (port->port_status != RTE_PORT_STOPPED) {
11077 printf("Please stop port %d first\n", res->port_id);
11081 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11082 ret = parse_flexbytes(res->mask,
11084 RTE_ETH_FDIR_MAX_FLEXLEN);
11086 printf("error: Cannot parse mask input.\n");
11090 memset(&fdir_info, 0, sizeof(fdir_info));
11091 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11092 RTE_ETH_FILTER_INFO, &fdir_info);
11094 printf("Cannot get FDir filter info\n");
11098 if (!strcmp(res->flow_type, "none")) {
11099 /* means don't specify the flow type */
11100 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11101 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11102 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11103 0, sizeof(struct rte_eth_fdir_flex_mask));
11104 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11105 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11107 sizeof(struct rte_eth_fdir_flex_mask));
11108 cmd_reconfig_device_queue(res->port_id, 1, 1);
11111 flow_type_mask = fdir_info.flow_types_mask[0];
11112 if (!strcmp(res->flow_type, "all")) {
11113 if (!flow_type_mask) {
11114 printf("No flow type supported\n");
11117 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11118 if (flow_type_mask & (1ULL << i)) {
11119 flex_mask.flow_type = i;
11120 fdir_set_flex_mask(res->port_id, &flex_mask);
11123 cmd_reconfig_device_queue(res->port_id, 1, 1);
11126 flex_mask.flow_type = str2flowtype(res->flow_type);
11127 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11128 printf("Flow type %s not supported on port %d\n",
11129 res->flow_type, res->port_id);
11132 fdir_set_flex_mask(res->port_id, &flex_mask);
11133 cmd_reconfig_device_queue(res->port_id, 1, 1);
11136 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11137 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11138 flow_director_flexmask,
11139 "flow_director_flex_mask");
11140 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11141 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11143 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11144 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11146 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11147 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11148 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11149 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11150 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11151 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11154 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11155 .f = cmd_flow_director_flex_mask_parsed,
11157 .help_str = "flow_director_flex_mask ... : "
11158 "Set flow director's flex mask on NIC",
11160 (void *)&cmd_flow_director_flexmask,
11161 (void *)&cmd_flow_director_flexmask_port_id,
11162 (void *)&cmd_flow_director_flexmask_flow,
11163 (void *)&cmd_flow_director_flexmask_flow_type,
11164 (void *)&cmd_flow_director_flexmask_mask,
11169 /* *** deal with flow director flexible payload configuration *** */
11170 struct cmd_flow_director_flexpayload_result {
11171 cmdline_fixed_string_t flow_director_flexpayload;
11173 cmdline_fixed_string_t payload_layer;
11174 cmdline_fixed_string_t payload_cfg;
11178 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11181 const char *p, *p0 = q_arg;
11183 unsigned long int_fld;
11184 char *str_fld[max_num];
11189 p = strchr(p0, '(');
11193 p0 = strchr(p, ')');
11198 if (size >= sizeof(s))
11201 snprintf(s, sizeof(s), "%.*s", size, p);
11202 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11203 if (ret < 0 || ret > max_num)
11205 for (i = 0; i < ret; i++) {
11207 int_fld = strtoul(str_fld[i], &end, 0);
11208 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11210 offsets[i] = (uint16_t)int_fld;
11216 cmd_flow_director_flxpld_parsed(void *parsed_result,
11217 __attribute__((unused)) struct cmdline *cl,
11218 __attribute__((unused)) void *data)
11220 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11221 struct rte_eth_flex_payload_cfg flex_cfg;
11222 struct rte_port *port;
11225 port = &ports[res->port_id];
11226 /** Check if the port is not started **/
11227 if (port->port_status != RTE_PORT_STOPPED) {
11228 printf("Please stop port %d first\n", res->port_id);
11232 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11234 if (!strcmp(res->payload_layer, "raw"))
11235 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11236 else if (!strcmp(res->payload_layer, "l2"))
11237 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11238 else if (!strcmp(res->payload_layer, "l3"))
11239 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11240 else if (!strcmp(res->payload_layer, "l4"))
11241 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11243 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11244 RTE_ETH_FDIR_MAX_FLEXLEN);
11246 printf("error: Cannot parse flex payload input.\n");
11250 fdir_set_flex_payload(res->port_id, &flex_cfg);
11251 cmd_reconfig_device_queue(res->port_id, 1, 1);
11254 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11256 flow_director_flexpayload,
11257 "flow_director_flex_payload");
11258 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11259 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11261 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11263 payload_layer, "raw#l2#l3#l4");
11264 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11266 payload_cfg, NULL);
11268 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11269 .f = cmd_flow_director_flxpld_parsed,
11271 .help_str = "flow_director_flexpayload ... : "
11272 "Set flow director's flex payload on NIC",
11274 (void *)&cmd_flow_director_flexpayload,
11275 (void *)&cmd_flow_director_flexpayload_port_id,
11276 (void *)&cmd_flow_director_flexpayload_payload_layer,
11277 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11282 /* Generic flow interface command. */
11283 extern cmdline_parse_inst_t cmd_flow;
11285 /* *** Classification Filters Control *** */
11286 /* *** Get symmetric hash enable per port *** */
11287 struct cmd_get_sym_hash_ena_per_port_result {
11288 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11293 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11294 __rte_unused struct cmdline *cl,
11295 __rte_unused void *data)
11297 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11298 struct rte_eth_hash_filter_info info;
11301 if (rte_eth_dev_filter_supported(res->port_id,
11302 RTE_ETH_FILTER_HASH) < 0) {
11303 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11308 memset(&info, 0, sizeof(info));
11309 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11310 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11311 RTE_ETH_FILTER_GET, &info);
11314 printf("Cannot get symmetric hash enable per port "
11315 "on port %u\n", res->port_id);
11319 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11320 "enabled" : "disabled", res->port_id);
11323 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11324 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11325 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11326 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11327 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11330 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11331 .f = cmd_get_sym_hash_per_port_parsed,
11333 .help_str = "get_sym_hash_ena_per_port <port_id>",
11335 (void *)&cmd_get_sym_hash_ena_per_port_all,
11336 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11341 /* *** Set symmetric hash enable per port *** */
11342 struct cmd_set_sym_hash_ena_per_port_result {
11343 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11344 cmdline_fixed_string_t enable;
11349 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11350 __rte_unused struct cmdline *cl,
11351 __rte_unused void *data)
11353 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11354 struct rte_eth_hash_filter_info info;
11357 if (rte_eth_dev_filter_supported(res->port_id,
11358 RTE_ETH_FILTER_HASH) < 0) {
11359 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11364 memset(&info, 0, sizeof(info));
11365 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11366 if (!strcmp(res->enable, "enable"))
11367 info.info.enable = 1;
11368 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11369 RTE_ETH_FILTER_SET, &info);
11371 printf("Cannot set symmetric hash enable per port on "
11372 "port %u\n", res->port_id);
11375 printf("Symmetric hash has been set to %s on port %u\n",
11376 res->enable, res->port_id);
11379 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11380 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11381 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11382 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11383 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11385 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11386 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11387 enable, "enable#disable");
11389 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11390 .f = cmd_set_sym_hash_per_port_parsed,
11392 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11394 (void *)&cmd_set_sym_hash_ena_per_port_all,
11395 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11396 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11401 /* Get global config of hash function */
11402 struct cmd_get_hash_global_config_result {
11403 cmdline_fixed_string_t get_hash_global_config;
11408 flowtype_to_str(uint16_t ftype)
11414 } ftype_table[] = {
11415 {"ipv4", RTE_ETH_FLOW_IPV4},
11416 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11417 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11418 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11419 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11420 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11421 {"ipv6", RTE_ETH_FLOW_IPV6},
11422 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11423 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11424 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11425 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11426 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11427 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11428 {"port", RTE_ETH_FLOW_PORT},
11429 {"vxlan", RTE_ETH_FLOW_VXLAN},
11430 {"geneve", RTE_ETH_FLOW_GENEVE},
11431 {"nvgre", RTE_ETH_FLOW_NVGRE},
11434 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11435 if (ftype_table[i].ftype == ftype)
11436 return ftype_table[i].str;
11443 cmd_get_hash_global_config_parsed(void *parsed_result,
11444 __rte_unused struct cmdline *cl,
11445 __rte_unused void *data)
11447 struct cmd_get_hash_global_config_result *res = parsed_result;
11448 struct rte_eth_hash_filter_info info;
11449 uint32_t idx, offset;
11454 if (rte_eth_dev_filter_supported(res->port_id,
11455 RTE_ETH_FILTER_HASH) < 0) {
11456 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11461 memset(&info, 0, sizeof(info));
11462 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11463 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11464 RTE_ETH_FILTER_GET, &info);
11466 printf("Cannot get hash global configurations by port %d\n",
11471 switch (info.info.global_conf.hash_func) {
11472 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11473 printf("Hash function is Toeplitz\n");
11475 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11476 printf("Hash function is Simple XOR\n");
11479 printf("Unknown hash function\n");
11483 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11484 idx = i / UINT64_BIT;
11485 offset = i % UINT64_BIT;
11486 if (!(info.info.global_conf.valid_bit_mask[idx] &
11489 str = flowtype_to_str(i);
11492 printf("Symmetric hash is %s globally for flow type %s "
11494 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11495 (1ULL << offset)) ? "enabled" : "disabled"), str,
11500 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11501 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11502 get_hash_global_config, "get_hash_global_config");
11503 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11504 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11507 cmdline_parse_inst_t cmd_get_hash_global_config = {
11508 .f = cmd_get_hash_global_config_parsed,
11510 .help_str = "get_hash_global_config <port_id>",
11512 (void *)&cmd_get_hash_global_config_all,
11513 (void *)&cmd_get_hash_global_config_port_id,
11518 /* Set global config of hash function */
11519 struct cmd_set_hash_global_config_result {
11520 cmdline_fixed_string_t set_hash_global_config;
11522 cmdline_fixed_string_t hash_func;
11523 cmdline_fixed_string_t flow_type;
11524 cmdline_fixed_string_t enable;
11528 cmd_set_hash_global_config_parsed(void *parsed_result,
11529 __rte_unused struct cmdline *cl,
11530 __rte_unused void *data)
11532 struct cmd_set_hash_global_config_result *res = parsed_result;
11533 struct rte_eth_hash_filter_info info;
11534 uint32_t ftype, idx, offset;
11537 if (rte_eth_dev_filter_supported(res->port_id,
11538 RTE_ETH_FILTER_HASH) < 0) {
11539 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11543 memset(&info, 0, sizeof(info));
11544 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11545 if (!strcmp(res->hash_func, "toeplitz"))
11546 info.info.global_conf.hash_func =
11547 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11548 else if (!strcmp(res->hash_func, "simple_xor"))
11549 info.info.global_conf.hash_func =
11550 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11551 else if (!strcmp(res->hash_func, "default"))
11552 info.info.global_conf.hash_func =
11553 RTE_ETH_HASH_FUNCTION_DEFAULT;
11555 ftype = str2flowtype(res->flow_type);
11556 idx = ftype / UINT64_BIT;
11557 offset = ftype % UINT64_BIT;
11558 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11559 if (!strcmp(res->enable, "enable"))
11560 info.info.global_conf.sym_hash_enable_mask[idx] |=
11562 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11563 RTE_ETH_FILTER_SET, &info);
11565 printf("Cannot set global hash configurations by port %d\n",
11568 printf("Global hash configurations have been set "
11569 "succcessfully by port %d\n", res->port_id);
11572 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11573 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11574 set_hash_global_config, "set_hash_global_config");
11575 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11576 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11578 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11579 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11580 hash_func, "toeplitz#simple_xor#default");
11581 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11582 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11584 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11585 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11586 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11587 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11588 enable, "enable#disable");
11590 cmdline_parse_inst_t cmd_set_hash_global_config = {
11591 .f = cmd_set_hash_global_config_parsed,
11593 .help_str = "set_hash_global_config <port_id> "
11594 "toeplitz|simple_xor|default "
11595 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11596 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11597 "l2_payload enable|disable",
11599 (void *)&cmd_set_hash_global_config_all,
11600 (void *)&cmd_set_hash_global_config_port_id,
11601 (void *)&cmd_set_hash_global_config_hash_func,
11602 (void *)&cmd_set_hash_global_config_flow_type,
11603 (void *)&cmd_set_hash_global_config_enable,
11608 /* Set hash input set */
11609 struct cmd_set_hash_input_set_result {
11610 cmdline_fixed_string_t set_hash_input_set;
11612 cmdline_fixed_string_t flow_type;
11613 cmdline_fixed_string_t inset_field;
11614 cmdline_fixed_string_t select;
11617 static enum rte_eth_input_set_field
11618 str2inset(char *string)
11622 static const struct {
11624 enum rte_eth_input_set_field inset;
11625 } inset_table[] = {
11626 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11627 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11628 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11629 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11630 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11631 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11632 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11633 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11634 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11635 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11636 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11637 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11638 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11639 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11640 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11641 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11642 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11643 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11644 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11645 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11646 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11647 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11648 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11649 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11650 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11651 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11652 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11653 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11654 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11655 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11656 {"none", RTE_ETH_INPUT_SET_NONE},
11659 for (i = 0; i < RTE_DIM(inset_table); i++) {
11660 if (!strcmp(string, inset_table[i].str))
11661 return inset_table[i].inset;
11664 return RTE_ETH_INPUT_SET_UNKNOWN;
11668 cmd_set_hash_input_set_parsed(void *parsed_result,
11669 __rte_unused struct cmdline *cl,
11670 __rte_unused void *data)
11672 struct cmd_set_hash_input_set_result *res = parsed_result;
11673 struct rte_eth_hash_filter_info info;
11675 memset(&info, 0, sizeof(info));
11676 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11677 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11678 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11679 info.info.input_set_conf.inset_size = 1;
11680 if (!strcmp(res->select, "select"))
11681 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11682 else if (!strcmp(res->select, "add"))
11683 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11684 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11685 RTE_ETH_FILTER_SET, &info);
11688 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11689 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11690 set_hash_input_set, "set_hash_input_set");
11691 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11692 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11694 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11695 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11697 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11698 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11700 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11701 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11702 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11703 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11704 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11706 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11707 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11708 select, "select#add");
11710 cmdline_parse_inst_t cmd_set_hash_input_set = {
11711 .f = cmd_set_hash_input_set_parsed,
11713 .help_str = "set_hash_input_set <port_id> "
11714 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11715 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11716 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11717 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11718 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11719 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11720 "fld-7th|fld-8th|none select|add",
11722 (void *)&cmd_set_hash_input_set_cmd,
11723 (void *)&cmd_set_hash_input_set_port_id,
11724 (void *)&cmd_set_hash_input_set_flow_type,
11725 (void *)&cmd_set_hash_input_set_field,
11726 (void *)&cmd_set_hash_input_set_select,
11731 /* Set flow director input set */
11732 struct cmd_set_fdir_input_set_result {
11733 cmdline_fixed_string_t set_fdir_input_set;
11735 cmdline_fixed_string_t flow_type;
11736 cmdline_fixed_string_t inset_field;
11737 cmdline_fixed_string_t select;
11741 cmd_set_fdir_input_set_parsed(void *parsed_result,
11742 __rte_unused struct cmdline *cl,
11743 __rte_unused void *data)
11745 struct cmd_set_fdir_input_set_result *res = parsed_result;
11746 struct rte_eth_fdir_filter_info info;
11748 memset(&info, 0, sizeof(info));
11749 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11750 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11751 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11752 info.info.input_set_conf.inset_size = 1;
11753 if (!strcmp(res->select, "select"))
11754 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11755 else if (!strcmp(res->select, "add"))
11756 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11757 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11758 RTE_ETH_FILTER_SET, &info);
11761 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11762 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11763 set_fdir_input_set, "set_fdir_input_set");
11764 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11765 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11767 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11768 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11770 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11771 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11772 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11773 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11775 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11776 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11777 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11778 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11779 "sctp-veri-tag#none");
11780 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11781 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11782 select, "select#add");
11784 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11785 .f = cmd_set_fdir_input_set_parsed,
11787 .help_str = "set_fdir_input_set <port_id> "
11788 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11789 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11790 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11791 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11792 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11793 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11794 "sctp-veri-tag|none select|add",
11796 (void *)&cmd_set_fdir_input_set_cmd,
11797 (void *)&cmd_set_fdir_input_set_port_id,
11798 (void *)&cmd_set_fdir_input_set_flow_type,
11799 (void *)&cmd_set_fdir_input_set_field,
11800 (void *)&cmd_set_fdir_input_set_select,
11805 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11806 struct cmd_mcast_addr_result {
11807 cmdline_fixed_string_t mcast_addr_cmd;
11808 cmdline_fixed_string_t what;
11810 struct ether_addr mc_addr;
11813 static void cmd_mcast_addr_parsed(void *parsed_result,
11814 __attribute__((unused)) struct cmdline *cl,
11815 __attribute__((unused)) void *data)
11817 struct cmd_mcast_addr_result *res = parsed_result;
11819 if (!is_multicast_ether_addr(&res->mc_addr)) {
11820 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11821 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11822 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11823 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11826 if (strcmp(res->what, "add") == 0)
11827 mcast_addr_add(res->port_num, &res->mc_addr);
11829 mcast_addr_remove(res->port_num, &res->mc_addr);
11832 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11833 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11834 mcast_addr_cmd, "mcast_addr");
11835 cmdline_parse_token_string_t cmd_mcast_addr_what =
11836 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11838 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11839 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11840 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11841 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11843 cmdline_parse_inst_t cmd_mcast_addr = {
11844 .f = cmd_mcast_addr_parsed,
11846 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11847 "Add/Remove multicast MAC address on port_id",
11849 (void *)&cmd_mcast_addr_cmd,
11850 (void *)&cmd_mcast_addr_what,
11851 (void *)&cmd_mcast_addr_portnum,
11852 (void *)&cmd_mcast_addr_addr,
11857 /* l2 tunnel config
11858 * only support E-tag now.
11861 /* Ether type config */
11862 struct cmd_config_l2_tunnel_eth_type_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 eth_type;
11870 uint16_t eth_type_val;
11873 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11874 TOKEN_STRING_INITIALIZER
11875 (struct cmd_config_l2_tunnel_eth_type_result,
11877 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11878 TOKEN_STRING_INITIALIZER
11879 (struct cmd_config_l2_tunnel_eth_type_result,
11881 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11882 TOKEN_STRING_INITIALIZER
11883 (struct cmd_config_l2_tunnel_eth_type_result,
11885 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11886 TOKEN_NUM_INITIALIZER
11887 (struct cmd_config_l2_tunnel_eth_type_result,
11889 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11890 TOKEN_STRING_INITIALIZER
11891 (struct cmd_config_l2_tunnel_eth_type_result,
11892 l2_tunnel, "l2-tunnel");
11893 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11894 TOKEN_STRING_INITIALIZER
11895 (struct cmd_config_l2_tunnel_eth_type_result,
11896 l2_tunnel_type, "E-tag");
11897 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11898 TOKEN_STRING_INITIALIZER
11899 (struct cmd_config_l2_tunnel_eth_type_result,
11900 eth_type, "ether-type");
11901 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11902 TOKEN_NUM_INITIALIZER
11903 (struct cmd_config_l2_tunnel_eth_type_result,
11904 eth_type_val, UINT16);
11906 static enum rte_eth_tunnel_type
11907 str2fdir_l2_tunnel_type(char *string)
11911 static const struct {
11913 enum rte_eth_tunnel_type type;
11914 } l2_tunnel_type_str[] = {
11915 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11918 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11919 if (!strcmp(l2_tunnel_type_str[i].str, string))
11920 return l2_tunnel_type_str[i].type;
11922 return RTE_TUNNEL_TYPE_NONE;
11925 /* ether type config for all ports */
11927 cmd_config_l2_tunnel_eth_type_all_parsed
11928 (void *parsed_result,
11929 __attribute__((unused)) struct cmdline *cl,
11930 __attribute__((unused)) void *data)
11932 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11933 struct rte_eth_l2_tunnel_conf entry;
11936 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11937 entry.ether_type = res->eth_type_val;
11939 RTE_ETH_FOREACH_DEV(pid) {
11940 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11944 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11945 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11947 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11949 (void *)&cmd_config_l2_tunnel_eth_type_port,
11950 (void *)&cmd_config_l2_tunnel_eth_type_config,
11951 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11952 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11953 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11954 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11955 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11960 /* ether type config for a specific port */
11962 cmd_config_l2_tunnel_eth_type_specific_parsed(
11963 void *parsed_result,
11964 __attribute__((unused)) struct cmdline *cl,
11965 __attribute__((unused)) void *data)
11967 struct cmd_config_l2_tunnel_eth_type_result *res =
11969 struct rte_eth_l2_tunnel_conf entry;
11971 if (port_id_is_invalid(res->id, ENABLED_WARN))
11974 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11975 entry.ether_type = res->eth_type_val;
11977 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11980 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11981 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11983 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11985 (void *)&cmd_config_l2_tunnel_eth_type_port,
11986 (void *)&cmd_config_l2_tunnel_eth_type_config,
11987 (void *)&cmd_config_l2_tunnel_eth_type_id,
11988 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11989 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11990 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11991 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11996 /* Enable/disable l2 tunnel */
11997 struct cmd_config_l2_tunnel_en_dis_result {
11998 cmdline_fixed_string_t port;
11999 cmdline_fixed_string_t config;
12000 cmdline_fixed_string_t all;
12002 cmdline_fixed_string_t l2_tunnel;
12003 cmdline_fixed_string_t l2_tunnel_type;
12004 cmdline_fixed_string_t en_dis;
12007 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_config_l2_tunnel_en_dis_result,
12011 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12012 TOKEN_STRING_INITIALIZER
12013 (struct cmd_config_l2_tunnel_en_dis_result,
12015 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12016 TOKEN_STRING_INITIALIZER
12017 (struct cmd_config_l2_tunnel_en_dis_result,
12019 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12020 TOKEN_NUM_INITIALIZER
12021 (struct cmd_config_l2_tunnel_en_dis_result,
12023 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12024 TOKEN_STRING_INITIALIZER
12025 (struct cmd_config_l2_tunnel_en_dis_result,
12026 l2_tunnel, "l2-tunnel");
12027 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12028 TOKEN_STRING_INITIALIZER
12029 (struct cmd_config_l2_tunnel_en_dis_result,
12030 l2_tunnel_type, "E-tag");
12031 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12032 TOKEN_STRING_INITIALIZER
12033 (struct cmd_config_l2_tunnel_en_dis_result,
12034 en_dis, "enable#disable");
12036 /* enable/disable l2 tunnel for all ports */
12038 cmd_config_l2_tunnel_en_dis_all_parsed(
12039 void *parsed_result,
12040 __attribute__((unused)) struct cmdline *cl,
12041 __attribute__((unused)) void *data)
12043 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12044 struct rte_eth_l2_tunnel_conf entry;
12048 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12050 if (!strcmp("enable", res->en_dis))
12055 RTE_ETH_FOREACH_DEV(pid) {
12056 rte_eth_dev_l2_tunnel_offload_set(pid,
12058 ETH_L2_TUNNEL_ENABLE_MASK,
12063 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12064 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12066 .help_str = "port config all l2-tunnel E-tag enable|disable",
12068 (void *)&cmd_config_l2_tunnel_en_dis_port,
12069 (void *)&cmd_config_l2_tunnel_en_dis_config,
12070 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12071 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12072 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12073 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12078 /* enable/disable l2 tunnel for a port */
12080 cmd_config_l2_tunnel_en_dis_specific_parsed(
12081 void *parsed_result,
12082 __attribute__((unused)) struct cmdline *cl,
12083 __attribute__((unused)) void *data)
12085 struct cmd_config_l2_tunnel_en_dis_result *res =
12087 struct rte_eth_l2_tunnel_conf entry;
12089 if (port_id_is_invalid(res->id, ENABLED_WARN))
12092 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12094 if (!strcmp("enable", res->en_dis))
12095 rte_eth_dev_l2_tunnel_offload_set(res->id,
12097 ETH_L2_TUNNEL_ENABLE_MASK,
12100 rte_eth_dev_l2_tunnel_offload_set(res->id,
12102 ETH_L2_TUNNEL_ENABLE_MASK,
12106 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12107 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12109 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12111 (void *)&cmd_config_l2_tunnel_en_dis_port,
12112 (void *)&cmd_config_l2_tunnel_en_dis_config,
12113 (void *)&cmd_config_l2_tunnel_en_dis_id,
12114 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12115 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12116 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12121 /* E-tag configuration */
12123 /* Common result structure for all E-tag configuration */
12124 struct cmd_config_e_tag_result {
12125 cmdline_fixed_string_t e_tag;
12126 cmdline_fixed_string_t set;
12127 cmdline_fixed_string_t insertion;
12128 cmdline_fixed_string_t stripping;
12129 cmdline_fixed_string_t forwarding;
12130 cmdline_fixed_string_t filter;
12131 cmdline_fixed_string_t add;
12132 cmdline_fixed_string_t del;
12133 cmdline_fixed_string_t on;
12134 cmdline_fixed_string_t off;
12135 cmdline_fixed_string_t on_off;
12136 cmdline_fixed_string_t port_tag_id;
12137 uint32_t port_tag_id_val;
12138 cmdline_fixed_string_t e_tag_id;
12139 uint16_t e_tag_id_val;
12140 cmdline_fixed_string_t dst_pool;
12141 uint8_t dst_pool_val;
12142 cmdline_fixed_string_t port;
12144 cmdline_fixed_string_t vf;
12148 /* Common CLI fields for all E-tag configuration */
12149 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12150 TOKEN_STRING_INITIALIZER
12151 (struct cmd_config_e_tag_result,
12153 cmdline_parse_token_string_t cmd_config_e_tag_set =
12154 TOKEN_STRING_INITIALIZER
12155 (struct cmd_config_e_tag_result,
12157 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12158 TOKEN_STRING_INITIALIZER
12159 (struct cmd_config_e_tag_result,
12160 insertion, "insertion");
12161 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12162 TOKEN_STRING_INITIALIZER
12163 (struct cmd_config_e_tag_result,
12164 stripping, "stripping");
12165 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12166 TOKEN_STRING_INITIALIZER
12167 (struct cmd_config_e_tag_result,
12168 forwarding, "forwarding");
12169 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12170 TOKEN_STRING_INITIALIZER
12171 (struct cmd_config_e_tag_result,
12173 cmdline_parse_token_string_t cmd_config_e_tag_add =
12174 TOKEN_STRING_INITIALIZER
12175 (struct cmd_config_e_tag_result,
12177 cmdline_parse_token_string_t cmd_config_e_tag_del =
12178 TOKEN_STRING_INITIALIZER
12179 (struct cmd_config_e_tag_result,
12181 cmdline_parse_token_string_t cmd_config_e_tag_on =
12182 TOKEN_STRING_INITIALIZER
12183 (struct cmd_config_e_tag_result,
12185 cmdline_parse_token_string_t cmd_config_e_tag_off =
12186 TOKEN_STRING_INITIALIZER
12187 (struct cmd_config_e_tag_result,
12189 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12190 TOKEN_STRING_INITIALIZER
12191 (struct cmd_config_e_tag_result,
12193 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12194 TOKEN_STRING_INITIALIZER
12195 (struct cmd_config_e_tag_result,
12196 port_tag_id, "port-tag-id");
12197 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12198 TOKEN_NUM_INITIALIZER
12199 (struct cmd_config_e_tag_result,
12200 port_tag_id_val, UINT32);
12201 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12202 TOKEN_STRING_INITIALIZER
12203 (struct cmd_config_e_tag_result,
12204 e_tag_id, "e-tag-id");
12205 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12206 TOKEN_NUM_INITIALIZER
12207 (struct cmd_config_e_tag_result,
12208 e_tag_id_val, UINT16);
12209 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12210 TOKEN_STRING_INITIALIZER
12211 (struct cmd_config_e_tag_result,
12212 dst_pool, "dst-pool");
12213 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12214 TOKEN_NUM_INITIALIZER
12215 (struct cmd_config_e_tag_result,
12216 dst_pool_val, UINT8);
12217 cmdline_parse_token_string_t cmd_config_e_tag_port =
12218 TOKEN_STRING_INITIALIZER
12219 (struct cmd_config_e_tag_result,
12221 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12222 TOKEN_NUM_INITIALIZER
12223 (struct cmd_config_e_tag_result,
12225 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12226 TOKEN_STRING_INITIALIZER
12227 (struct cmd_config_e_tag_result,
12229 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12230 TOKEN_NUM_INITIALIZER
12231 (struct cmd_config_e_tag_result,
12234 /* E-tag insertion configuration */
12236 cmd_config_e_tag_insertion_en_parsed(
12237 void *parsed_result,
12238 __attribute__((unused)) struct cmdline *cl,
12239 __attribute__((unused)) void *data)
12241 struct cmd_config_e_tag_result *res =
12243 struct rte_eth_l2_tunnel_conf entry;
12245 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12248 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12249 entry.tunnel_id = res->port_tag_id_val;
12250 entry.vf_id = res->vf_id;
12251 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12253 ETH_L2_TUNNEL_INSERTION_MASK,
12258 cmd_config_e_tag_insertion_dis_parsed(
12259 void *parsed_result,
12260 __attribute__((unused)) struct cmdline *cl,
12261 __attribute__((unused)) void *data)
12263 struct cmd_config_e_tag_result *res =
12265 struct rte_eth_l2_tunnel_conf entry;
12267 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12270 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12271 entry.vf_id = res->vf_id;
12273 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12275 ETH_L2_TUNNEL_INSERTION_MASK,
12279 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12280 .f = cmd_config_e_tag_insertion_en_parsed,
12282 .help_str = "E-tag ... : E-tag insertion enable",
12284 (void *)&cmd_config_e_tag_e_tag,
12285 (void *)&cmd_config_e_tag_set,
12286 (void *)&cmd_config_e_tag_insertion,
12287 (void *)&cmd_config_e_tag_on,
12288 (void *)&cmd_config_e_tag_port_tag_id,
12289 (void *)&cmd_config_e_tag_port_tag_id_val,
12290 (void *)&cmd_config_e_tag_port,
12291 (void *)&cmd_config_e_tag_port_id,
12292 (void *)&cmd_config_e_tag_vf,
12293 (void *)&cmd_config_e_tag_vf_id,
12298 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12299 .f = cmd_config_e_tag_insertion_dis_parsed,
12301 .help_str = "E-tag ... : E-tag insertion disable",
12303 (void *)&cmd_config_e_tag_e_tag,
12304 (void *)&cmd_config_e_tag_set,
12305 (void *)&cmd_config_e_tag_insertion,
12306 (void *)&cmd_config_e_tag_off,
12307 (void *)&cmd_config_e_tag_port,
12308 (void *)&cmd_config_e_tag_port_id,
12309 (void *)&cmd_config_e_tag_vf,
12310 (void *)&cmd_config_e_tag_vf_id,
12315 /* E-tag stripping configuration */
12317 cmd_config_e_tag_stripping_parsed(
12318 void *parsed_result,
12319 __attribute__((unused)) struct cmdline *cl,
12320 __attribute__((unused)) void *data)
12322 struct cmd_config_e_tag_result *res =
12324 struct rte_eth_l2_tunnel_conf entry;
12326 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12329 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12331 if (!strcmp(res->on_off, "on"))
12332 rte_eth_dev_l2_tunnel_offload_set
12335 ETH_L2_TUNNEL_STRIPPING_MASK,
12338 rte_eth_dev_l2_tunnel_offload_set
12341 ETH_L2_TUNNEL_STRIPPING_MASK,
12345 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12346 .f = cmd_config_e_tag_stripping_parsed,
12348 .help_str = "E-tag ... : E-tag stripping enable/disable",
12350 (void *)&cmd_config_e_tag_e_tag,
12351 (void *)&cmd_config_e_tag_set,
12352 (void *)&cmd_config_e_tag_stripping,
12353 (void *)&cmd_config_e_tag_on_off,
12354 (void *)&cmd_config_e_tag_port,
12355 (void *)&cmd_config_e_tag_port_id,
12360 /* E-tag forwarding configuration */
12362 cmd_config_e_tag_forwarding_parsed(
12363 void *parsed_result,
12364 __attribute__((unused)) struct cmdline *cl,
12365 __attribute__((unused)) void *data)
12367 struct cmd_config_e_tag_result *res = parsed_result;
12368 struct rte_eth_l2_tunnel_conf entry;
12370 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12373 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12375 if (!strcmp(res->on_off, "on"))
12376 rte_eth_dev_l2_tunnel_offload_set
12379 ETH_L2_TUNNEL_FORWARDING_MASK,
12382 rte_eth_dev_l2_tunnel_offload_set
12385 ETH_L2_TUNNEL_FORWARDING_MASK,
12389 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12390 .f = cmd_config_e_tag_forwarding_parsed,
12392 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12394 (void *)&cmd_config_e_tag_e_tag,
12395 (void *)&cmd_config_e_tag_set,
12396 (void *)&cmd_config_e_tag_forwarding,
12397 (void *)&cmd_config_e_tag_on_off,
12398 (void *)&cmd_config_e_tag_port,
12399 (void *)&cmd_config_e_tag_port_id,
12404 /* E-tag filter configuration */
12406 cmd_config_e_tag_filter_add_parsed(
12407 void *parsed_result,
12408 __attribute__((unused)) struct cmdline *cl,
12409 __attribute__((unused)) void *data)
12411 struct cmd_config_e_tag_result *res = parsed_result;
12412 struct rte_eth_l2_tunnel_conf entry;
12415 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12418 if (res->e_tag_id_val > 0x3fff) {
12419 printf("e-tag-id must be equal or less than 0x3fff.\n");
12423 ret = rte_eth_dev_filter_supported(res->port_id,
12424 RTE_ETH_FILTER_L2_TUNNEL);
12426 printf("E-tag filter is not supported on port %u.\n",
12431 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12432 entry.tunnel_id = res->e_tag_id_val;
12433 entry.pool = res->dst_pool_val;
12435 ret = rte_eth_dev_filter_ctrl(res->port_id,
12436 RTE_ETH_FILTER_L2_TUNNEL,
12437 RTE_ETH_FILTER_ADD,
12440 printf("E-tag filter programming error: (%s)\n",
12444 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12445 .f = cmd_config_e_tag_filter_add_parsed,
12447 .help_str = "E-tag ... : E-tag filter add",
12449 (void *)&cmd_config_e_tag_e_tag,
12450 (void *)&cmd_config_e_tag_set,
12451 (void *)&cmd_config_e_tag_filter,
12452 (void *)&cmd_config_e_tag_add,
12453 (void *)&cmd_config_e_tag_e_tag_id,
12454 (void *)&cmd_config_e_tag_e_tag_id_val,
12455 (void *)&cmd_config_e_tag_dst_pool,
12456 (void *)&cmd_config_e_tag_dst_pool_val,
12457 (void *)&cmd_config_e_tag_port,
12458 (void *)&cmd_config_e_tag_port_id,
12464 cmd_config_e_tag_filter_del_parsed(
12465 void *parsed_result,
12466 __attribute__((unused)) struct cmdline *cl,
12467 __attribute__((unused)) void *data)
12469 struct cmd_config_e_tag_result *res = parsed_result;
12470 struct rte_eth_l2_tunnel_conf entry;
12473 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12476 if (res->e_tag_id_val > 0x3fff) {
12477 printf("e-tag-id must be less than 0x3fff.\n");
12481 ret = rte_eth_dev_filter_supported(res->port_id,
12482 RTE_ETH_FILTER_L2_TUNNEL);
12484 printf("E-tag filter is not supported on port %u.\n",
12489 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12490 entry.tunnel_id = res->e_tag_id_val;
12492 ret = rte_eth_dev_filter_ctrl(res->port_id,
12493 RTE_ETH_FILTER_L2_TUNNEL,
12494 RTE_ETH_FILTER_DELETE,
12497 printf("E-tag filter programming error: (%s)\n",
12501 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12502 .f = cmd_config_e_tag_filter_del_parsed,
12504 .help_str = "E-tag ... : E-tag filter delete",
12506 (void *)&cmd_config_e_tag_e_tag,
12507 (void *)&cmd_config_e_tag_set,
12508 (void *)&cmd_config_e_tag_filter,
12509 (void *)&cmd_config_e_tag_del,
12510 (void *)&cmd_config_e_tag_e_tag_id,
12511 (void *)&cmd_config_e_tag_e_tag_id_val,
12512 (void *)&cmd_config_e_tag_port,
12513 (void *)&cmd_config_e_tag_port_id,
12518 /* vf vlan anti spoof configuration */
12520 /* Common result structure for vf vlan anti spoof */
12521 struct cmd_vf_vlan_anti_spoof_result {
12522 cmdline_fixed_string_t set;
12523 cmdline_fixed_string_t vf;
12524 cmdline_fixed_string_t vlan;
12525 cmdline_fixed_string_t antispoof;
12528 cmdline_fixed_string_t on_off;
12531 /* Common CLI fields for vf vlan anti spoof enable disable */
12532 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12533 TOKEN_STRING_INITIALIZER
12534 (struct cmd_vf_vlan_anti_spoof_result,
12536 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12537 TOKEN_STRING_INITIALIZER
12538 (struct cmd_vf_vlan_anti_spoof_result,
12540 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12541 TOKEN_STRING_INITIALIZER
12542 (struct cmd_vf_vlan_anti_spoof_result,
12544 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12545 TOKEN_STRING_INITIALIZER
12546 (struct cmd_vf_vlan_anti_spoof_result,
12547 antispoof, "antispoof");
12548 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12549 TOKEN_NUM_INITIALIZER
12550 (struct cmd_vf_vlan_anti_spoof_result,
12552 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12553 TOKEN_NUM_INITIALIZER
12554 (struct cmd_vf_vlan_anti_spoof_result,
12556 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12557 TOKEN_STRING_INITIALIZER
12558 (struct cmd_vf_vlan_anti_spoof_result,
12562 cmd_set_vf_vlan_anti_spoof_parsed(
12563 void *parsed_result,
12564 __attribute__((unused)) struct cmdline *cl,
12565 __attribute__((unused)) void *data)
12567 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12568 int ret = -ENOTSUP;
12570 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12575 #ifdef RTE_LIBRTE_IXGBE_PMD
12576 if (ret == -ENOTSUP)
12577 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12578 res->vf_id, is_on);
12580 #ifdef RTE_LIBRTE_I40E_PMD
12581 if (ret == -ENOTSUP)
12582 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12583 res->vf_id, is_on);
12585 #ifdef RTE_LIBRTE_BNXT_PMD
12586 if (ret == -ENOTSUP)
12587 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12588 res->vf_id, is_on);
12595 printf("invalid vf_id %d\n", res->vf_id);
12598 printf("invalid port_id %d\n", res->port_id);
12601 printf("function not implemented\n");
12604 printf("programming error: (%s)\n", strerror(-ret));
12608 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12609 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12611 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12613 (void *)&cmd_vf_vlan_anti_spoof_set,
12614 (void *)&cmd_vf_vlan_anti_spoof_vf,
12615 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12616 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12617 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12618 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12619 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12624 /* vf mac anti spoof configuration */
12626 /* Common result structure for vf mac anti spoof */
12627 struct cmd_vf_mac_anti_spoof_result {
12628 cmdline_fixed_string_t set;
12629 cmdline_fixed_string_t vf;
12630 cmdline_fixed_string_t mac;
12631 cmdline_fixed_string_t antispoof;
12634 cmdline_fixed_string_t on_off;
12637 /* Common CLI fields for vf mac anti spoof enable disable */
12638 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12639 TOKEN_STRING_INITIALIZER
12640 (struct cmd_vf_mac_anti_spoof_result,
12642 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12643 TOKEN_STRING_INITIALIZER
12644 (struct cmd_vf_mac_anti_spoof_result,
12646 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12647 TOKEN_STRING_INITIALIZER
12648 (struct cmd_vf_mac_anti_spoof_result,
12650 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12651 TOKEN_STRING_INITIALIZER
12652 (struct cmd_vf_mac_anti_spoof_result,
12653 antispoof, "antispoof");
12654 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12655 TOKEN_NUM_INITIALIZER
12656 (struct cmd_vf_mac_anti_spoof_result,
12658 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12659 TOKEN_NUM_INITIALIZER
12660 (struct cmd_vf_mac_anti_spoof_result,
12662 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12663 TOKEN_STRING_INITIALIZER
12664 (struct cmd_vf_mac_anti_spoof_result,
12668 cmd_set_vf_mac_anti_spoof_parsed(
12669 void *parsed_result,
12670 __attribute__((unused)) struct cmdline *cl,
12671 __attribute__((unused)) void *data)
12673 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12674 int ret = -ENOTSUP;
12676 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12681 #ifdef RTE_LIBRTE_IXGBE_PMD
12682 if (ret == -ENOTSUP)
12683 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12684 res->vf_id, is_on);
12686 #ifdef RTE_LIBRTE_I40E_PMD
12687 if (ret == -ENOTSUP)
12688 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12689 res->vf_id, is_on);
12691 #ifdef RTE_LIBRTE_BNXT_PMD
12692 if (ret == -ENOTSUP)
12693 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12694 res->vf_id, is_on);
12701 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12704 printf("invalid port_id %d\n", res->port_id);
12707 printf("function not implemented\n");
12710 printf("programming error: (%s)\n", strerror(-ret));
12714 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12715 .f = cmd_set_vf_mac_anti_spoof_parsed,
12717 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12719 (void *)&cmd_vf_mac_anti_spoof_set,
12720 (void *)&cmd_vf_mac_anti_spoof_vf,
12721 (void *)&cmd_vf_mac_anti_spoof_mac,
12722 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12723 (void *)&cmd_vf_mac_anti_spoof_port_id,
12724 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12725 (void *)&cmd_vf_mac_anti_spoof_on_off,
12730 /* vf vlan strip queue configuration */
12732 /* Common result structure for vf mac anti spoof */
12733 struct cmd_vf_vlan_stripq_result {
12734 cmdline_fixed_string_t set;
12735 cmdline_fixed_string_t vf;
12736 cmdline_fixed_string_t vlan;
12737 cmdline_fixed_string_t stripq;
12740 cmdline_fixed_string_t on_off;
12743 /* Common CLI fields for vf vlan strip enable disable */
12744 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12745 TOKEN_STRING_INITIALIZER
12746 (struct cmd_vf_vlan_stripq_result,
12748 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12749 TOKEN_STRING_INITIALIZER
12750 (struct cmd_vf_vlan_stripq_result,
12752 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12753 TOKEN_STRING_INITIALIZER
12754 (struct cmd_vf_vlan_stripq_result,
12756 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12757 TOKEN_STRING_INITIALIZER
12758 (struct cmd_vf_vlan_stripq_result,
12760 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12761 TOKEN_NUM_INITIALIZER
12762 (struct cmd_vf_vlan_stripq_result,
12764 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12765 TOKEN_NUM_INITIALIZER
12766 (struct cmd_vf_vlan_stripq_result,
12768 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12769 TOKEN_STRING_INITIALIZER
12770 (struct cmd_vf_vlan_stripq_result,
12774 cmd_set_vf_vlan_stripq_parsed(
12775 void *parsed_result,
12776 __attribute__((unused)) struct cmdline *cl,
12777 __attribute__((unused)) void *data)
12779 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12780 int ret = -ENOTSUP;
12782 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12784 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12787 #ifdef RTE_LIBRTE_IXGBE_PMD
12788 if (ret == -ENOTSUP)
12789 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12790 res->vf_id, is_on);
12792 #ifdef RTE_LIBRTE_I40E_PMD
12793 if (ret == -ENOTSUP)
12794 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12795 res->vf_id, is_on);
12797 #ifdef RTE_LIBRTE_BNXT_PMD
12798 if (ret == -ENOTSUP)
12799 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12800 res->vf_id, is_on);
12807 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12810 printf("invalid port_id %d\n", res->port_id);
12813 printf("function not implemented\n");
12816 printf("programming error: (%s)\n", strerror(-ret));
12820 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12821 .f = cmd_set_vf_vlan_stripq_parsed,
12823 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12825 (void *)&cmd_vf_vlan_stripq_set,
12826 (void *)&cmd_vf_vlan_stripq_vf,
12827 (void *)&cmd_vf_vlan_stripq_vlan,
12828 (void *)&cmd_vf_vlan_stripq_stripq,
12829 (void *)&cmd_vf_vlan_stripq_port_id,
12830 (void *)&cmd_vf_vlan_stripq_vf_id,
12831 (void *)&cmd_vf_vlan_stripq_on_off,
12836 /* vf vlan insert configuration */
12838 /* Common result structure for vf vlan insert */
12839 struct cmd_vf_vlan_insert_result {
12840 cmdline_fixed_string_t set;
12841 cmdline_fixed_string_t vf;
12842 cmdline_fixed_string_t vlan;
12843 cmdline_fixed_string_t insert;
12849 /* Common CLI fields for vf vlan insert enable disable */
12850 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12851 TOKEN_STRING_INITIALIZER
12852 (struct cmd_vf_vlan_insert_result,
12854 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12855 TOKEN_STRING_INITIALIZER
12856 (struct cmd_vf_vlan_insert_result,
12858 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12859 TOKEN_STRING_INITIALIZER
12860 (struct cmd_vf_vlan_insert_result,
12862 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12863 TOKEN_STRING_INITIALIZER
12864 (struct cmd_vf_vlan_insert_result,
12866 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12867 TOKEN_NUM_INITIALIZER
12868 (struct cmd_vf_vlan_insert_result,
12870 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12871 TOKEN_NUM_INITIALIZER
12872 (struct cmd_vf_vlan_insert_result,
12874 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12875 TOKEN_NUM_INITIALIZER
12876 (struct cmd_vf_vlan_insert_result,
12880 cmd_set_vf_vlan_insert_parsed(
12881 void *parsed_result,
12882 __attribute__((unused)) struct cmdline *cl,
12883 __attribute__((unused)) void *data)
12885 struct cmd_vf_vlan_insert_result *res = parsed_result;
12886 int ret = -ENOTSUP;
12888 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12891 #ifdef RTE_LIBRTE_IXGBE_PMD
12892 if (ret == -ENOTSUP)
12893 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12896 #ifdef RTE_LIBRTE_I40E_PMD
12897 if (ret == -ENOTSUP)
12898 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12901 #ifdef RTE_LIBRTE_BNXT_PMD
12902 if (ret == -ENOTSUP)
12903 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12911 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12914 printf("invalid port_id %d\n", res->port_id);
12917 printf("function not implemented\n");
12920 printf("programming error: (%s)\n", strerror(-ret));
12924 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12925 .f = cmd_set_vf_vlan_insert_parsed,
12927 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12929 (void *)&cmd_vf_vlan_insert_set,
12930 (void *)&cmd_vf_vlan_insert_vf,
12931 (void *)&cmd_vf_vlan_insert_vlan,
12932 (void *)&cmd_vf_vlan_insert_insert,
12933 (void *)&cmd_vf_vlan_insert_port_id,
12934 (void *)&cmd_vf_vlan_insert_vf_id,
12935 (void *)&cmd_vf_vlan_insert_vlan_id,
12940 /* tx loopback configuration */
12942 /* Common result structure for tx loopback */
12943 struct cmd_tx_loopback_result {
12944 cmdline_fixed_string_t set;
12945 cmdline_fixed_string_t tx;
12946 cmdline_fixed_string_t loopback;
12948 cmdline_fixed_string_t on_off;
12951 /* Common CLI fields for tx loopback enable disable */
12952 cmdline_parse_token_string_t cmd_tx_loopback_set =
12953 TOKEN_STRING_INITIALIZER
12954 (struct cmd_tx_loopback_result,
12956 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12957 TOKEN_STRING_INITIALIZER
12958 (struct cmd_tx_loopback_result,
12960 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12961 TOKEN_STRING_INITIALIZER
12962 (struct cmd_tx_loopback_result,
12963 loopback, "loopback");
12964 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12965 TOKEN_NUM_INITIALIZER
12966 (struct cmd_tx_loopback_result,
12968 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12969 TOKEN_STRING_INITIALIZER
12970 (struct cmd_tx_loopback_result,
12974 cmd_set_tx_loopback_parsed(
12975 void *parsed_result,
12976 __attribute__((unused)) struct cmdline *cl,
12977 __attribute__((unused)) void *data)
12979 struct cmd_tx_loopback_result *res = parsed_result;
12980 int ret = -ENOTSUP;
12982 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12984 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12987 #ifdef RTE_LIBRTE_IXGBE_PMD
12988 if (ret == -ENOTSUP)
12989 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12991 #ifdef RTE_LIBRTE_I40E_PMD
12992 if (ret == -ENOTSUP)
12993 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12995 #ifdef RTE_LIBRTE_BNXT_PMD
12996 if (ret == -ENOTSUP)
12997 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12999 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13000 if (ret == -ENOTSUP)
13001 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13008 printf("invalid is_on %d\n", is_on);
13011 printf("invalid port_id %d\n", res->port_id);
13014 printf("function not implemented\n");
13017 printf("programming error: (%s)\n", strerror(-ret));
13021 cmdline_parse_inst_t cmd_set_tx_loopback = {
13022 .f = cmd_set_tx_loopback_parsed,
13024 .help_str = "set tx loopback <port_id> on|off",
13026 (void *)&cmd_tx_loopback_set,
13027 (void *)&cmd_tx_loopback_tx,
13028 (void *)&cmd_tx_loopback_loopback,
13029 (void *)&cmd_tx_loopback_port_id,
13030 (void *)&cmd_tx_loopback_on_off,
13035 /* all queues drop enable configuration */
13037 /* Common result structure for all queues drop enable */
13038 struct cmd_all_queues_drop_en_result {
13039 cmdline_fixed_string_t set;
13040 cmdline_fixed_string_t all;
13041 cmdline_fixed_string_t queues;
13042 cmdline_fixed_string_t drop;
13044 cmdline_fixed_string_t on_off;
13047 /* Common CLI fields for tx loopback enable disable */
13048 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13049 TOKEN_STRING_INITIALIZER
13050 (struct cmd_all_queues_drop_en_result,
13052 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13053 TOKEN_STRING_INITIALIZER
13054 (struct cmd_all_queues_drop_en_result,
13056 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13057 TOKEN_STRING_INITIALIZER
13058 (struct cmd_all_queues_drop_en_result,
13060 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13061 TOKEN_STRING_INITIALIZER
13062 (struct cmd_all_queues_drop_en_result,
13064 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13065 TOKEN_NUM_INITIALIZER
13066 (struct cmd_all_queues_drop_en_result,
13068 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13069 TOKEN_STRING_INITIALIZER
13070 (struct cmd_all_queues_drop_en_result,
13074 cmd_set_all_queues_drop_en_parsed(
13075 void *parsed_result,
13076 __attribute__((unused)) struct cmdline *cl,
13077 __attribute__((unused)) void *data)
13079 struct cmd_all_queues_drop_en_result *res = parsed_result;
13080 int ret = -ENOTSUP;
13081 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13086 #ifdef RTE_LIBRTE_IXGBE_PMD
13087 if (ret == -ENOTSUP)
13088 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13090 #ifdef RTE_LIBRTE_BNXT_PMD
13091 if (ret == -ENOTSUP)
13092 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13098 printf("invalid is_on %d\n", is_on);
13101 printf("invalid port_id %d\n", res->port_id);
13104 printf("function not implemented\n");
13107 printf("programming error: (%s)\n", strerror(-ret));
13111 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13112 .f = cmd_set_all_queues_drop_en_parsed,
13114 .help_str = "set all queues drop <port_id> on|off",
13116 (void *)&cmd_all_queues_drop_en_set,
13117 (void *)&cmd_all_queues_drop_en_all,
13118 (void *)&cmd_all_queues_drop_en_queues,
13119 (void *)&cmd_all_queues_drop_en_drop,
13120 (void *)&cmd_all_queues_drop_en_port_id,
13121 (void *)&cmd_all_queues_drop_en_on_off,
13126 /* vf split drop enable configuration */
13128 /* Common result structure for vf split drop enable */
13129 struct cmd_vf_split_drop_en_result {
13130 cmdline_fixed_string_t set;
13131 cmdline_fixed_string_t vf;
13132 cmdline_fixed_string_t split;
13133 cmdline_fixed_string_t drop;
13136 cmdline_fixed_string_t on_off;
13139 /* Common CLI fields for vf split drop enable disable */
13140 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13141 TOKEN_STRING_INITIALIZER
13142 (struct cmd_vf_split_drop_en_result,
13144 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13145 TOKEN_STRING_INITIALIZER
13146 (struct cmd_vf_split_drop_en_result,
13148 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13149 TOKEN_STRING_INITIALIZER
13150 (struct cmd_vf_split_drop_en_result,
13152 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13153 TOKEN_STRING_INITIALIZER
13154 (struct cmd_vf_split_drop_en_result,
13156 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13157 TOKEN_NUM_INITIALIZER
13158 (struct cmd_vf_split_drop_en_result,
13160 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13161 TOKEN_NUM_INITIALIZER
13162 (struct cmd_vf_split_drop_en_result,
13164 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13165 TOKEN_STRING_INITIALIZER
13166 (struct cmd_vf_split_drop_en_result,
13170 cmd_set_vf_split_drop_en_parsed(
13171 void *parsed_result,
13172 __attribute__((unused)) struct cmdline *cl,
13173 __attribute__((unused)) void *data)
13175 struct cmd_vf_split_drop_en_result *res = parsed_result;
13176 int ret = -ENOTSUP;
13177 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13179 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13182 #ifdef RTE_LIBRTE_IXGBE_PMD
13183 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13190 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13193 printf("invalid port_id %d\n", res->port_id);
13196 printf("not supported on port %d\n", res->port_id);
13199 printf("programming error: (%s)\n", strerror(-ret));
13203 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13204 .f = cmd_set_vf_split_drop_en_parsed,
13206 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13208 (void *)&cmd_vf_split_drop_en_set,
13209 (void *)&cmd_vf_split_drop_en_vf,
13210 (void *)&cmd_vf_split_drop_en_split,
13211 (void *)&cmd_vf_split_drop_en_drop,
13212 (void *)&cmd_vf_split_drop_en_port_id,
13213 (void *)&cmd_vf_split_drop_en_vf_id,
13214 (void *)&cmd_vf_split_drop_en_on_off,
13219 /* vf mac address configuration */
13221 /* Common result structure for vf mac address */
13222 struct cmd_set_vf_mac_addr_result {
13223 cmdline_fixed_string_t set;
13224 cmdline_fixed_string_t vf;
13225 cmdline_fixed_string_t mac;
13226 cmdline_fixed_string_t addr;
13229 struct ether_addr mac_addr;
13233 /* Common CLI fields for vf split drop enable disable */
13234 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13235 TOKEN_STRING_INITIALIZER
13236 (struct cmd_set_vf_mac_addr_result,
13238 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13239 TOKEN_STRING_INITIALIZER
13240 (struct cmd_set_vf_mac_addr_result,
13242 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13243 TOKEN_STRING_INITIALIZER
13244 (struct cmd_set_vf_mac_addr_result,
13246 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13247 TOKEN_STRING_INITIALIZER
13248 (struct cmd_set_vf_mac_addr_result,
13250 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13251 TOKEN_NUM_INITIALIZER
13252 (struct cmd_set_vf_mac_addr_result,
13254 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13255 TOKEN_NUM_INITIALIZER
13256 (struct cmd_set_vf_mac_addr_result,
13258 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13259 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13263 cmd_set_vf_mac_addr_parsed(
13264 void *parsed_result,
13265 __attribute__((unused)) struct cmdline *cl,
13266 __attribute__((unused)) void *data)
13268 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13269 int ret = -ENOTSUP;
13271 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13274 #ifdef RTE_LIBRTE_IXGBE_PMD
13275 if (ret == -ENOTSUP)
13276 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13279 #ifdef RTE_LIBRTE_I40E_PMD
13280 if (ret == -ENOTSUP)
13281 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13284 #ifdef RTE_LIBRTE_BNXT_PMD
13285 if (ret == -ENOTSUP)
13286 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13294 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13297 printf("invalid port_id %d\n", res->port_id);
13300 printf("function not implemented\n");
13303 printf("programming error: (%s)\n", strerror(-ret));
13307 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13308 .f = cmd_set_vf_mac_addr_parsed,
13310 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13312 (void *)&cmd_set_vf_mac_addr_set,
13313 (void *)&cmd_set_vf_mac_addr_vf,
13314 (void *)&cmd_set_vf_mac_addr_mac,
13315 (void *)&cmd_set_vf_mac_addr_addr,
13316 (void *)&cmd_set_vf_mac_addr_port_id,
13317 (void *)&cmd_set_vf_mac_addr_vf_id,
13318 (void *)&cmd_set_vf_mac_addr_mac_addr,
13323 /* MACsec configuration */
13325 /* Common result structure for MACsec offload enable */
13326 struct cmd_macsec_offload_on_result {
13327 cmdline_fixed_string_t set;
13328 cmdline_fixed_string_t macsec;
13329 cmdline_fixed_string_t offload;
13331 cmdline_fixed_string_t on;
13332 cmdline_fixed_string_t encrypt;
13333 cmdline_fixed_string_t en_on_off;
13334 cmdline_fixed_string_t replay_protect;
13335 cmdline_fixed_string_t rp_on_off;
13338 /* Common CLI fields for MACsec offload disable */
13339 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13340 TOKEN_STRING_INITIALIZER
13341 (struct cmd_macsec_offload_on_result,
13343 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13344 TOKEN_STRING_INITIALIZER
13345 (struct cmd_macsec_offload_on_result,
13347 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13348 TOKEN_STRING_INITIALIZER
13349 (struct cmd_macsec_offload_on_result,
13350 offload, "offload");
13351 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13352 TOKEN_NUM_INITIALIZER
13353 (struct cmd_macsec_offload_on_result,
13355 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13356 TOKEN_STRING_INITIALIZER
13357 (struct cmd_macsec_offload_on_result,
13359 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13360 TOKEN_STRING_INITIALIZER
13361 (struct cmd_macsec_offload_on_result,
13362 encrypt, "encrypt");
13363 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13364 TOKEN_STRING_INITIALIZER
13365 (struct cmd_macsec_offload_on_result,
13366 en_on_off, "on#off");
13367 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13368 TOKEN_STRING_INITIALIZER
13369 (struct cmd_macsec_offload_on_result,
13370 replay_protect, "replay-protect");
13371 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13372 TOKEN_STRING_INITIALIZER
13373 (struct cmd_macsec_offload_on_result,
13374 rp_on_off, "on#off");
13377 cmd_set_macsec_offload_on_parsed(
13378 void *parsed_result,
13379 __attribute__((unused)) struct cmdline *cl,
13380 __attribute__((unused)) void *data)
13382 struct cmd_macsec_offload_on_result *res = parsed_result;
13383 int ret = -ENOTSUP;
13384 portid_t port_id = res->port_id;
13385 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13386 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13387 struct rte_eth_dev_info dev_info;
13389 if (port_id_is_invalid(port_id, ENABLED_WARN))
13391 if (!port_is_stopped(port_id)) {
13392 printf("Please stop port %d first\n", port_id);
13396 rte_eth_dev_info_get(port_id, &dev_info);
13397 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13398 #ifdef RTE_LIBRTE_IXGBE_PMD
13399 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13407 ports[port_id].dev_conf.txmode.offloads |=
13408 DEV_TX_OFFLOAD_MACSEC_INSERT;
13409 cmd_reconfig_device_queue(port_id, 1, 1);
13412 printf("invalid port_id %d\n", port_id);
13415 printf("not supported on port %d\n", port_id);
13418 printf("programming error: (%s)\n", strerror(-ret));
13422 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13423 .f = cmd_set_macsec_offload_on_parsed,
13425 .help_str = "set macsec offload <port_id> on "
13426 "encrypt on|off replay-protect on|off",
13428 (void *)&cmd_macsec_offload_on_set,
13429 (void *)&cmd_macsec_offload_on_macsec,
13430 (void *)&cmd_macsec_offload_on_offload,
13431 (void *)&cmd_macsec_offload_on_port_id,
13432 (void *)&cmd_macsec_offload_on_on,
13433 (void *)&cmd_macsec_offload_on_encrypt,
13434 (void *)&cmd_macsec_offload_on_en_on_off,
13435 (void *)&cmd_macsec_offload_on_replay_protect,
13436 (void *)&cmd_macsec_offload_on_rp_on_off,
13441 /* Common result structure for MACsec offload disable */
13442 struct cmd_macsec_offload_off_result {
13443 cmdline_fixed_string_t set;
13444 cmdline_fixed_string_t macsec;
13445 cmdline_fixed_string_t offload;
13447 cmdline_fixed_string_t off;
13450 /* Common CLI fields for MACsec offload disable */
13451 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13452 TOKEN_STRING_INITIALIZER
13453 (struct cmd_macsec_offload_off_result,
13455 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13456 TOKEN_STRING_INITIALIZER
13457 (struct cmd_macsec_offload_off_result,
13459 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13460 TOKEN_STRING_INITIALIZER
13461 (struct cmd_macsec_offload_off_result,
13462 offload, "offload");
13463 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13464 TOKEN_NUM_INITIALIZER
13465 (struct cmd_macsec_offload_off_result,
13467 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13468 TOKEN_STRING_INITIALIZER
13469 (struct cmd_macsec_offload_off_result,
13473 cmd_set_macsec_offload_off_parsed(
13474 void *parsed_result,
13475 __attribute__((unused)) struct cmdline *cl,
13476 __attribute__((unused)) void *data)
13478 struct cmd_macsec_offload_off_result *res = parsed_result;
13479 int ret = -ENOTSUP;
13480 struct rte_eth_dev_info dev_info;
13481 portid_t port_id = res->port_id;
13483 if (port_id_is_invalid(port_id, ENABLED_WARN))
13485 if (!port_is_stopped(port_id)) {
13486 printf("Please stop port %d first\n", port_id);
13490 rte_eth_dev_info_get(port_id, &dev_info);
13491 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13492 #ifdef RTE_LIBRTE_IXGBE_PMD
13493 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13498 ports[port_id].dev_conf.txmode.offloads &=
13499 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13500 cmd_reconfig_device_queue(port_id, 1, 1);
13503 printf("invalid port_id %d\n", port_id);
13506 printf("not supported on port %d\n", port_id);
13509 printf("programming error: (%s)\n", strerror(-ret));
13513 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13514 .f = cmd_set_macsec_offload_off_parsed,
13516 .help_str = "set macsec offload <port_id> off",
13518 (void *)&cmd_macsec_offload_off_set,
13519 (void *)&cmd_macsec_offload_off_macsec,
13520 (void *)&cmd_macsec_offload_off_offload,
13521 (void *)&cmd_macsec_offload_off_port_id,
13522 (void *)&cmd_macsec_offload_off_off,
13527 /* Common result structure for MACsec secure connection configure */
13528 struct cmd_macsec_sc_result {
13529 cmdline_fixed_string_t set;
13530 cmdline_fixed_string_t macsec;
13531 cmdline_fixed_string_t sc;
13532 cmdline_fixed_string_t tx_rx;
13534 struct ether_addr mac;
13538 /* Common CLI fields for MACsec secure connection configure */
13539 cmdline_parse_token_string_t cmd_macsec_sc_set =
13540 TOKEN_STRING_INITIALIZER
13541 (struct cmd_macsec_sc_result,
13543 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13544 TOKEN_STRING_INITIALIZER
13545 (struct cmd_macsec_sc_result,
13547 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13548 TOKEN_STRING_INITIALIZER
13549 (struct cmd_macsec_sc_result,
13551 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13552 TOKEN_STRING_INITIALIZER
13553 (struct cmd_macsec_sc_result,
13555 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13556 TOKEN_NUM_INITIALIZER
13557 (struct cmd_macsec_sc_result,
13559 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13560 TOKEN_ETHERADDR_INITIALIZER
13561 (struct cmd_macsec_sc_result,
13563 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13564 TOKEN_NUM_INITIALIZER
13565 (struct cmd_macsec_sc_result,
13569 cmd_set_macsec_sc_parsed(
13570 void *parsed_result,
13571 __attribute__((unused)) struct cmdline *cl,
13572 __attribute__((unused)) void *data)
13574 struct cmd_macsec_sc_result *res = parsed_result;
13575 int ret = -ENOTSUP;
13576 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13578 #ifdef RTE_LIBRTE_IXGBE_PMD
13580 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13581 res->mac.addr_bytes) :
13582 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13583 res->mac.addr_bytes, res->pi);
13585 RTE_SET_USED(is_tx);
13591 printf("invalid port_id %d\n", res->port_id);
13594 printf("not supported on port %d\n", res->port_id);
13597 printf("programming error: (%s)\n", strerror(-ret));
13601 cmdline_parse_inst_t cmd_set_macsec_sc = {
13602 .f = cmd_set_macsec_sc_parsed,
13604 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13606 (void *)&cmd_macsec_sc_set,
13607 (void *)&cmd_macsec_sc_macsec,
13608 (void *)&cmd_macsec_sc_sc,
13609 (void *)&cmd_macsec_sc_tx_rx,
13610 (void *)&cmd_macsec_sc_port_id,
13611 (void *)&cmd_macsec_sc_mac,
13612 (void *)&cmd_macsec_sc_pi,
13617 /* Common result structure for MACsec secure connection configure */
13618 struct cmd_macsec_sa_result {
13619 cmdline_fixed_string_t set;
13620 cmdline_fixed_string_t macsec;
13621 cmdline_fixed_string_t sa;
13622 cmdline_fixed_string_t tx_rx;
13627 cmdline_fixed_string_t key;
13630 /* Common CLI fields for MACsec secure connection configure */
13631 cmdline_parse_token_string_t cmd_macsec_sa_set =
13632 TOKEN_STRING_INITIALIZER
13633 (struct cmd_macsec_sa_result,
13635 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13636 TOKEN_STRING_INITIALIZER
13637 (struct cmd_macsec_sa_result,
13639 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13640 TOKEN_STRING_INITIALIZER
13641 (struct cmd_macsec_sa_result,
13643 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13644 TOKEN_STRING_INITIALIZER
13645 (struct cmd_macsec_sa_result,
13647 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13648 TOKEN_NUM_INITIALIZER
13649 (struct cmd_macsec_sa_result,
13651 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13652 TOKEN_NUM_INITIALIZER
13653 (struct cmd_macsec_sa_result,
13655 cmdline_parse_token_num_t cmd_macsec_sa_an =
13656 TOKEN_NUM_INITIALIZER
13657 (struct cmd_macsec_sa_result,
13659 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13660 TOKEN_NUM_INITIALIZER
13661 (struct cmd_macsec_sa_result,
13663 cmdline_parse_token_string_t cmd_macsec_sa_key =
13664 TOKEN_STRING_INITIALIZER
13665 (struct cmd_macsec_sa_result,
13669 cmd_set_macsec_sa_parsed(
13670 void *parsed_result,
13671 __attribute__((unused)) struct cmdline *cl,
13672 __attribute__((unused)) void *data)
13674 struct cmd_macsec_sa_result *res = parsed_result;
13675 int ret = -ENOTSUP;
13676 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13677 uint8_t key[16] = { 0 };
13683 key_len = strlen(res->key) / 2;
13687 for (i = 0; i < key_len; i++) {
13688 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13691 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13694 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13697 #ifdef RTE_LIBRTE_IXGBE_PMD
13699 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13700 res->idx, res->an, res->pn, key) :
13701 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13702 res->idx, res->an, res->pn, key);
13704 RTE_SET_USED(is_tx);
13711 printf("invalid idx %d or an %d\n", res->idx, res->an);
13714 printf("invalid port_id %d\n", res->port_id);
13717 printf("not supported on port %d\n", res->port_id);
13720 printf("programming error: (%s)\n", strerror(-ret));
13724 cmdline_parse_inst_t cmd_set_macsec_sa = {
13725 .f = cmd_set_macsec_sa_parsed,
13727 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13729 (void *)&cmd_macsec_sa_set,
13730 (void *)&cmd_macsec_sa_macsec,
13731 (void *)&cmd_macsec_sa_sa,
13732 (void *)&cmd_macsec_sa_tx_rx,
13733 (void *)&cmd_macsec_sa_port_id,
13734 (void *)&cmd_macsec_sa_idx,
13735 (void *)&cmd_macsec_sa_an,
13736 (void *)&cmd_macsec_sa_pn,
13737 (void *)&cmd_macsec_sa_key,
13742 /* VF unicast promiscuous mode configuration */
13744 /* Common result structure for VF unicast promiscuous mode */
13745 struct cmd_vf_promisc_result {
13746 cmdline_fixed_string_t set;
13747 cmdline_fixed_string_t vf;
13748 cmdline_fixed_string_t promisc;
13751 cmdline_fixed_string_t on_off;
13754 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13755 cmdline_parse_token_string_t cmd_vf_promisc_set =
13756 TOKEN_STRING_INITIALIZER
13757 (struct cmd_vf_promisc_result,
13759 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13760 TOKEN_STRING_INITIALIZER
13761 (struct cmd_vf_promisc_result,
13763 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13764 TOKEN_STRING_INITIALIZER
13765 (struct cmd_vf_promisc_result,
13766 promisc, "promisc");
13767 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13768 TOKEN_NUM_INITIALIZER
13769 (struct cmd_vf_promisc_result,
13771 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13772 TOKEN_NUM_INITIALIZER
13773 (struct cmd_vf_promisc_result,
13775 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13776 TOKEN_STRING_INITIALIZER
13777 (struct cmd_vf_promisc_result,
13781 cmd_set_vf_promisc_parsed(
13782 void *parsed_result,
13783 __attribute__((unused)) struct cmdline *cl,
13784 __attribute__((unused)) void *data)
13786 struct cmd_vf_promisc_result *res = parsed_result;
13787 int ret = -ENOTSUP;
13789 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13791 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13794 #ifdef RTE_LIBRTE_I40E_PMD
13795 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13796 res->vf_id, is_on);
13803 printf("invalid vf_id %d\n", res->vf_id);
13806 printf("invalid port_id %d\n", res->port_id);
13809 printf("function not implemented\n");
13812 printf("programming error: (%s)\n", strerror(-ret));
13816 cmdline_parse_inst_t cmd_set_vf_promisc = {
13817 .f = cmd_set_vf_promisc_parsed,
13819 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13820 "Set unicast promiscuous mode for a VF from the PF",
13822 (void *)&cmd_vf_promisc_set,
13823 (void *)&cmd_vf_promisc_vf,
13824 (void *)&cmd_vf_promisc_promisc,
13825 (void *)&cmd_vf_promisc_port_id,
13826 (void *)&cmd_vf_promisc_vf_id,
13827 (void *)&cmd_vf_promisc_on_off,
13832 /* VF multicast promiscuous mode configuration */
13834 /* Common result structure for VF multicast promiscuous mode */
13835 struct cmd_vf_allmulti_result {
13836 cmdline_fixed_string_t set;
13837 cmdline_fixed_string_t vf;
13838 cmdline_fixed_string_t allmulti;
13841 cmdline_fixed_string_t on_off;
13844 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13845 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13846 TOKEN_STRING_INITIALIZER
13847 (struct cmd_vf_allmulti_result,
13849 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13850 TOKEN_STRING_INITIALIZER
13851 (struct cmd_vf_allmulti_result,
13853 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13854 TOKEN_STRING_INITIALIZER
13855 (struct cmd_vf_allmulti_result,
13856 allmulti, "allmulti");
13857 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13858 TOKEN_NUM_INITIALIZER
13859 (struct cmd_vf_allmulti_result,
13861 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13862 TOKEN_NUM_INITIALIZER
13863 (struct cmd_vf_allmulti_result,
13865 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13866 TOKEN_STRING_INITIALIZER
13867 (struct cmd_vf_allmulti_result,
13871 cmd_set_vf_allmulti_parsed(
13872 void *parsed_result,
13873 __attribute__((unused)) struct cmdline *cl,
13874 __attribute__((unused)) void *data)
13876 struct cmd_vf_allmulti_result *res = parsed_result;
13877 int ret = -ENOTSUP;
13879 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13881 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13884 #ifdef RTE_LIBRTE_I40E_PMD
13885 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13886 res->vf_id, is_on);
13893 printf("invalid vf_id %d\n", res->vf_id);
13896 printf("invalid port_id %d\n", res->port_id);
13899 printf("function not implemented\n");
13902 printf("programming error: (%s)\n", strerror(-ret));
13906 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13907 .f = cmd_set_vf_allmulti_parsed,
13909 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13910 "Set multicast promiscuous mode for a VF from the PF",
13912 (void *)&cmd_vf_allmulti_set,
13913 (void *)&cmd_vf_allmulti_vf,
13914 (void *)&cmd_vf_allmulti_allmulti,
13915 (void *)&cmd_vf_allmulti_port_id,
13916 (void *)&cmd_vf_allmulti_vf_id,
13917 (void *)&cmd_vf_allmulti_on_off,
13922 /* vf broadcast mode configuration */
13924 /* Common result structure for vf broadcast */
13925 struct cmd_set_vf_broadcast_result {
13926 cmdline_fixed_string_t set;
13927 cmdline_fixed_string_t vf;
13928 cmdline_fixed_string_t broadcast;
13931 cmdline_fixed_string_t on_off;
13934 /* Common CLI fields for vf broadcast enable disable */
13935 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13936 TOKEN_STRING_INITIALIZER
13937 (struct cmd_set_vf_broadcast_result,
13939 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13940 TOKEN_STRING_INITIALIZER
13941 (struct cmd_set_vf_broadcast_result,
13943 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13944 TOKEN_STRING_INITIALIZER
13945 (struct cmd_set_vf_broadcast_result,
13946 broadcast, "broadcast");
13947 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13948 TOKEN_NUM_INITIALIZER
13949 (struct cmd_set_vf_broadcast_result,
13951 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13952 TOKEN_NUM_INITIALIZER
13953 (struct cmd_set_vf_broadcast_result,
13955 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13956 TOKEN_STRING_INITIALIZER
13957 (struct cmd_set_vf_broadcast_result,
13961 cmd_set_vf_broadcast_parsed(
13962 void *parsed_result,
13963 __attribute__((unused)) struct cmdline *cl,
13964 __attribute__((unused)) void *data)
13966 struct cmd_set_vf_broadcast_result *res = parsed_result;
13967 int ret = -ENOTSUP;
13969 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13971 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13974 #ifdef RTE_LIBRTE_I40E_PMD
13975 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13976 res->vf_id, is_on);
13983 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13986 printf("invalid port_id %d\n", res->port_id);
13989 printf("function not implemented\n");
13992 printf("programming error: (%s)\n", strerror(-ret));
13996 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13997 .f = cmd_set_vf_broadcast_parsed,
13999 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14001 (void *)&cmd_set_vf_broadcast_set,
14002 (void *)&cmd_set_vf_broadcast_vf,
14003 (void *)&cmd_set_vf_broadcast_broadcast,
14004 (void *)&cmd_set_vf_broadcast_port_id,
14005 (void *)&cmd_set_vf_broadcast_vf_id,
14006 (void *)&cmd_set_vf_broadcast_on_off,
14011 /* vf vlan tag configuration */
14013 /* Common result structure for vf vlan tag */
14014 struct cmd_set_vf_vlan_tag_result {
14015 cmdline_fixed_string_t set;
14016 cmdline_fixed_string_t vf;
14017 cmdline_fixed_string_t vlan;
14018 cmdline_fixed_string_t tag;
14021 cmdline_fixed_string_t on_off;
14024 /* Common CLI fields for vf vlan tag enable disable */
14025 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14026 TOKEN_STRING_INITIALIZER
14027 (struct cmd_set_vf_vlan_tag_result,
14029 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14030 TOKEN_STRING_INITIALIZER
14031 (struct cmd_set_vf_vlan_tag_result,
14033 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14034 TOKEN_STRING_INITIALIZER
14035 (struct cmd_set_vf_vlan_tag_result,
14037 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14038 TOKEN_STRING_INITIALIZER
14039 (struct cmd_set_vf_vlan_tag_result,
14041 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14042 TOKEN_NUM_INITIALIZER
14043 (struct cmd_set_vf_vlan_tag_result,
14045 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14046 TOKEN_NUM_INITIALIZER
14047 (struct cmd_set_vf_vlan_tag_result,
14049 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14050 TOKEN_STRING_INITIALIZER
14051 (struct cmd_set_vf_vlan_tag_result,
14055 cmd_set_vf_vlan_tag_parsed(
14056 void *parsed_result,
14057 __attribute__((unused)) struct cmdline *cl,
14058 __attribute__((unused)) void *data)
14060 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14061 int ret = -ENOTSUP;
14063 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14065 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14068 #ifdef RTE_LIBRTE_I40E_PMD
14069 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14070 res->vf_id, is_on);
14077 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14080 printf("invalid port_id %d\n", res->port_id);
14083 printf("function not implemented\n");
14086 printf("programming error: (%s)\n", strerror(-ret));
14090 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14091 .f = cmd_set_vf_vlan_tag_parsed,
14093 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14095 (void *)&cmd_set_vf_vlan_tag_set,
14096 (void *)&cmd_set_vf_vlan_tag_vf,
14097 (void *)&cmd_set_vf_vlan_tag_vlan,
14098 (void *)&cmd_set_vf_vlan_tag_tag,
14099 (void *)&cmd_set_vf_vlan_tag_port_id,
14100 (void *)&cmd_set_vf_vlan_tag_vf_id,
14101 (void *)&cmd_set_vf_vlan_tag_on_off,
14106 /* Common definition of VF and TC TX bandwidth configuration */
14107 struct cmd_vf_tc_bw_result {
14108 cmdline_fixed_string_t set;
14109 cmdline_fixed_string_t vf;
14110 cmdline_fixed_string_t tc;
14111 cmdline_fixed_string_t tx;
14112 cmdline_fixed_string_t min_bw;
14113 cmdline_fixed_string_t max_bw;
14114 cmdline_fixed_string_t strict_link_prio;
14119 cmdline_fixed_string_t bw_list;
14123 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14124 TOKEN_STRING_INITIALIZER
14125 (struct cmd_vf_tc_bw_result,
14127 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14128 TOKEN_STRING_INITIALIZER
14129 (struct cmd_vf_tc_bw_result,
14131 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14132 TOKEN_STRING_INITIALIZER
14133 (struct cmd_vf_tc_bw_result,
14135 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14136 TOKEN_STRING_INITIALIZER
14137 (struct cmd_vf_tc_bw_result,
14139 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14140 TOKEN_STRING_INITIALIZER
14141 (struct cmd_vf_tc_bw_result,
14142 strict_link_prio, "strict-link-priority");
14143 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14144 TOKEN_STRING_INITIALIZER
14145 (struct cmd_vf_tc_bw_result,
14146 min_bw, "min-bandwidth");
14147 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14148 TOKEN_STRING_INITIALIZER
14149 (struct cmd_vf_tc_bw_result,
14150 max_bw, "max-bandwidth");
14151 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14152 TOKEN_NUM_INITIALIZER
14153 (struct cmd_vf_tc_bw_result,
14155 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14156 TOKEN_NUM_INITIALIZER
14157 (struct cmd_vf_tc_bw_result,
14159 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14160 TOKEN_NUM_INITIALIZER
14161 (struct cmd_vf_tc_bw_result,
14163 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14164 TOKEN_NUM_INITIALIZER
14165 (struct cmd_vf_tc_bw_result,
14167 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14168 TOKEN_STRING_INITIALIZER
14169 (struct cmd_vf_tc_bw_result,
14171 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14172 TOKEN_NUM_INITIALIZER
14173 (struct cmd_vf_tc_bw_result,
14176 /* VF max bandwidth setting */
14178 cmd_vf_max_bw_parsed(
14179 void *parsed_result,
14180 __attribute__((unused)) struct cmdline *cl,
14181 __attribute__((unused)) void *data)
14183 struct cmd_vf_tc_bw_result *res = parsed_result;
14184 int ret = -ENOTSUP;
14186 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14189 #ifdef RTE_LIBRTE_I40E_PMD
14190 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14191 res->vf_id, res->bw);
14198 printf("invalid vf_id %d or bandwidth %d\n",
14199 res->vf_id, res->bw);
14202 printf("invalid port_id %d\n", res->port_id);
14205 printf("function not implemented\n");
14208 printf("programming error: (%s)\n", strerror(-ret));
14212 cmdline_parse_inst_t cmd_vf_max_bw = {
14213 .f = cmd_vf_max_bw_parsed,
14215 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14217 (void *)&cmd_vf_tc_bw_set,
14218 (void *)&cmd_vf_tc_bw_vf,
14219 (void *)&cmd_vf_tc_bw_tx,
14220 (void *)&cmd_vf_tc_bw_max_bw,
14221 (void *)&cmd_vf_tc_bw_port_id,
14222 (void *)&cmd_vf_tc_bw_vf_id,
14223 (void *)&cmd_vf_tc_bw_bw,
14229 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14234 const char *p, *p0 = str;
14241 p = strchr(p0, '(');
14243 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14247 p0 = strchr(p, ')');
14249 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14253 if (size >= sizeof(s)) {
14254 printf("The string size exceeds the internal buffer size\n");
14257 snprintf(s, sizeof(s), "%.*s", size, p);
14258 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14260 printf("Failed to get the bandwidth list. ");
14264 for (i = 0; i < ret; i++)
14265 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14270 /* TC min bandwidth setting */
14272 cmd_vf_tc_min_bw_parsed(
14273 void *parsed_result,
14274 __attribute__((unused)) struct cmdline *cl,
14275 __attribute__((unused)) void *data)
14277 struct cmd_vf_tc_bw_result *res = parsed_result;
14280 int ret = -ENOTSUP;
14282 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14285 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14289 #ifdef RTE_LIBRTE_I40E_PMD
14290 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14298 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14301 printf("invalid port_id %d\n", res->port_id);
14304 printf("function not implemented\n");
14307 printf("programming error: (%s)\n", strerror(-ret));
14311 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14312 .f = cmd_vf_tc_min_bw_parsed,
14314 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14315 " <bw1, bw2, ...>",
14317 (void *)&cmd_vf_tc_bw_set,
14318 (void *)&cmd_vf_tc_bw_vf,
14319 (void *)&cmd_vf_tc_bw_tc,
14320 (void *)&cmd_vf_tc_bw_tx,
14321 (void *)&cmd_vf_tc_bw_min_bw,
14322 (void *)&cmd_vf_tc_bw_port_id,
14323 (void *)&cmd_vf_tc_bw_vf_id,
14324 (void *)&cmd_vf_tc_bw_bw_list,
14330 cmd_tc_min_bw_parsed(
14331 void *parsed_result,
14332 __attribute__((unused)) struct cmdline *cl,
14333 __attribute__((unused)) void *data)
14335 struct cmd_vf_tc_bw_result *res = parsed_result;
14336 struct rte_port *port;
14339 int ret = -ENOTSUP;
14341 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14344 port = &ports[res->port_id];
14345 /** Check if the port is not started **/
14346 if (port->port_status != RTE_PORT_STOPPED) {
14347 printf("Please stop port %d first\n", res->port_id);
14351 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14355 #ifdef RTE_LIBRTE_IXGBE_PMD
14356 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14363 printf("invalid bandwidth\n");
14366 printf("invalid port_id %d\n", res->port_id);
14369 printf("function not implemented\n");
14372 printf("programming error: (%s)\n", strerror(-ret));
14376 cmdline_parse_inst_t cmd_tc_min_bw = {
14377 .f = cmd_tc_min_bw_parsed,
14379 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14381 (void *)&cmd_vf_tc_bw_set,
14382 (void *)&cmd_vf_tc_bw_tc,
14383 (void *)&cmd_vf_tc_bw_tx,
14384 (void *)&cmd_vf_tc_bw_min_bw,
14385 (void *)&cmd_vf_tc_bw_port_id,
14386 (void *)&cmd_vf_tc_bw_bw_list,
14391 /* TC max bandwidth setting */
14393 cmd_vf_tc_max_bw_parsed(
14394 void *parsed_result,
14395 __attribute__((unused)) struct cmdline *cl,
14396 __attribute__((unused)) void *data)
14398 struct cmd_vf_tc_bw_result *res = parsed_result;
14399 int ret = -ENOTSUP;
14401 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14404 #ifdef RTE_LIBRTE_I40E_PMD
14405 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14406 res->tc_no, res->bw);
14413 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14414 res->vf_id, res->tc_no, res->bw);
14417 printf("invalid port_id %d\n", res->port_id);
14420 printf("function not implemented\n");
14423 printf("programming error: (%s)\n", strerror(-ret));
14427 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14428 .f = cmd_vf_tc_max_bw_parsed,
14430 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14433 (void *)&cmd_vf_tc_bw_set,
14434 (void *)&cmd_vf_tc_bw_vf,
14435 (void *)&cmd_vf_tc_bw_tc,
14436 (void *)&cmd_vf_tc_bw_tx,
14437 (void *)&cmd_vf_tc_bw_max_bw,
14438 (void *)&cmd_vf_tc_bw_port_id,
14439 (void *)&cmd_vf_tc_bw_vf_id,
14440 (void *)&cmd_vf_tc_bw_tc_no,
14441 (void *)&cmd_vf_tc_bw_bw,
14447 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14449 /* *** Set Port default Traffic Management Hierarchy *** */
14450 struct cmd_set_port_tm_hierarchy_default_result {
14451 cmdline_fixed_string_t set;
14452 cmdline_fixed_string_t port;
14453 cmdline_fixed_string_t tm;
14454 cmdline_fixed_string_t hierarchy;
14455 cmdline_fixed_string_t def;
14459 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14460 TOKEN_STRING_INITIALIZER(
14461 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14462 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14463 TOKEN_STRING_INITIALIZER(
14464 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14465 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14466 TOKEN_STRING_INITIALIZER(
14467 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14468 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14469 TOKEN_STRING_INITIALIZER(
14470 struct cmd_set_port_tm_hierarchy_default_result,
14471 hierarchy, "hierarchy");
14472 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14473 TOKEN_STRING_INITIALIZER(
14474 struct cmd_set_port_tm_hierarchy_default_result,
14476 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14477 TOKEN_NUM_INITIALIZER(
14478 struct cmd_set_port_tm_hierarchy_default_result,
14481 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14482 __attribute__((unused)) struct cmdline *cl,
14483 __attribute__((unused)) void *data)
14485 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14486 struct rte_port *p;
14487 portid_t port_id = res->port_id;
14489 if (port_id_is_invalid(port_id, ENABLED_WARN))
14492 p = &ports[port_id];
14495 if (p->softport.tm_flag == 0) {
14496 printf(" tm not enabled on port %u (error)\n", port_id);
14500 /* Forward mode: tm */
14501 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14502 printf(" tm mode not enabled(error)\n");
14506 /* Set the default tm hierarchy */
14507 p->softport.tm.default_hierarchy_enable = 1;
14510 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14511 .f = cmd_set_port_tm_hierarchy_default_parsed,
14513 .help_str = "set port tm hierarchy default <port_id>",
14515 (void *)&cmd_set_port_tm_hierarchy_default_set,
14516 (void *)&cmd_set_port_tm_hierarchy_default_port,
14517 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14518 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14519 (void *)&cmd_set_port_tm_hierarchy_default_default,
14520 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14526 /* Strict link priority scheduling mode setting */
14528 cmd_strict_link_prio_parsed(
14529 void *parsed_result,
14530 __attribute__((unused)) struct cmdline *cl,
14531 __attribute__((unused)) void *data)
14533 struct cmd_vf_tc_bw_result *res = parsed_result;
14534 int ret = -ENOTSUP;
14536 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14539 #ifdef RTE_LIBRTE_I40E_PMD
14540 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14547 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14550 printf("invalid port_id %d\n", res->port_id);
14553 printf("function not implemented\n");
14556 printf("programming error: (%s)\n", strerror(-ret));
14560 cmdline_parse_inst_t cmd_strict_link_prio = {
14561 .f = cmd_strict_link_prio_parsed,
14563 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14565 (void *)&cmd_vf_tc_bw_set,
14566 (void *)&cmd_vf_tc_bw_tx,
14567 (void *)&cmd_vf_tc_bw_strict_link_prio,
14568 (void *)&cmd_vf_tc_bw_port_id,
14569 (void *)&cmd_vf_tc_bw_tc_map,
14574 /* Load dynamic device personalization*/
14575 struct cmd_ddp_add_result {
14576 cmdline_fixed_string_t ddp;
14577 cmdline_fixed_string_t add;
14582 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14583 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14584 cmdline_parse_token_string_t cmd_ddp_add_add =
14585 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14586 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14587 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14588 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14589 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14592 cmd_ddp_add_parsed(
14593 void *parsed_result,
14594 __attribute__((unused)) struct cmdline *cl,
14595 __attribute__((unused)) void *data)
14597 struct cmd_ddp_add_result *res = parsed_result;
14603 int ret = -ENOTSUP;
14605 if (!all_ports_stopped()) {
14606 printf("Please stop all ports first\n");
14610 filepath = strdup(res->filepath);
14611 if (filepath == NULL) {
14612 printf("Failed to allocate memory\n");
14615 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14617 buff = open_file(file_fld[0], &size);
14619 free((void *)filepath);
14623 #ifdef RTE_LIBRTE_I40E_PMD
14624 if (ret == -ENOTSUP)
14625 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14627 RTE_PMD_I40E_PKG_OP_WR_ADD);
14630 if (ret == -EEXIST)
14631 printf("Profile has already existed.\n");
14633 printf("Failed to load profile.\n");
14634 else if (file_num == 2)
14635 save_file(file_fld[1], buff, size);
14638 free((void *)filepath);
14641 cmdline_parse_inst_t cmd_ddp_add = {
14642 .f = cmd_ddp_add_parsed,
14644 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14646 (void *)&cmd_ddp_add_ddp,
14647 (void *)&cmd_ddp_add_add,
14648 (void *)&cmd_ddp_add_port_id,
14649 (void *)&cmd_ddp_add_filepath,
14654 /* Delete dynamic device personalization*/
14655 struct cmd_ddp_del_result {
14656 cmdline_fixed_string_t ddp;
14657 cmdline_fixed_string_t del;
14662 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14663 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14664 cmdline_parse_token_string_t cmd_ddp_del_del =
14665 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14666 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14667 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14668 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14669 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14672 cmd_ddp_del_parsed(
14673 void *parsed_result,
14674 __attribute__((unused)) struct cmdline *cl,
14675 __attribute__((unused)) void *data)
14677 struct cmd_ddp_del_result *res = parsed_result;
14680 int ret = -ENOTSUP;
14682 if (!all_ports_stopped()) {
14683 printf("Please stop all ports first\n");
14687 buff = open_file(res->filepath, &size);
14691 #ifdef RTE_LIBRTE_I40E_PMD
14692 if (ret == -ENOTSUP)
14693 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14695 RTE_PMD_I40E_PKG_OP_WR_DEL);
14698 if (ret == -EACCES)
14699 printf("Profile does not exist.\n");
14701 printf("Failed to delete profile.\n");
14706 cmdline_parse_inst_t cmd_ddp_del = {
14707 .f = cmd_ddp_del_parsed,
14709 .help_str = "ddp del <port_id> <backup_profile_path>",
14711 (void *)&cmd_ddp_del_ddp,
14712 (void *)&cmd_ddp_del_del,
14713 (void *)&cmd_ddp_del_port_id,
14714 (void *)&cmd_ddp_del_filepath,
14719 /* Get dynamic device personalization profile info */
14720 struct cmd_ddp_info_result {
14721 cmdline_fixed_string_t ddp;
14722 cmdline_fixed_string_t get;
14723 cmdline_fixed_string_t info;
14727 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14728 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14729 cmdline_parse_token_string_t cmd_ddp_info_get =
14730 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14731 cmdline_parse_token_string_t cmd_ddp_info_info =
14732 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14733 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14734 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14737 cmd_ddp_info_parsed(
14738 void *parsed_result,
14739 __attribute__((unused)) struct cmdline *cl,
14740 __attribute__((unused)) void *data)
14742 struct cmd_ddp_info_result *res = parsed_result;
14745 int ret = -ENOTSUP;
14746 #ifdef RTE_LIBRTE_I40E_PMD
14749 uint32_t buff_size = 0;
14750 struct rte_pmd_i40e_profile_info info;
14751 uint32_t dev_num = 0;
14752 struct rte_pmd_i40e_ddp_device_id *devs;
14753 uint32_t proto_num = 0;
14754 struct rte_pmd_i40e_proto_info *proto = NULL;
14755 uint32_t pctype_num = 0;
14756 struct rte_pmd_i40e_ptype_info *pctype;
14757 uint32_t ptype_num = 0;
14758 struct rte_pmd_i40e_ptype_info *ptype;
14763 pkg = open_file(res->filepath, &pkg_size);
14767 #ifdef RTE_LIBRTE_I40E_PMD
14768 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14769 (uint8_t *)&info, sizeof(info),
14770 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14772 printf("Global Track id: 0x%x\n", info.track_id);
14773 printf("Global Version: %d.%d.%d.%d\n",
14774 info.version.major,
14775 info.version.minor,
14776 info.version.update,
14777 info.version.draft);
14778 printf("Global Package name: %s\n\n", info.name);
14781 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14782 (uint8_t *)&info, sizeof(info),
14783 RTE_PMD_I40E_PKG_INFO_HEADER);
14785 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14786 printf("i40e Profile Version: %d.%d.%d.%d\n",
14787 info.version.major,
14788 info.version.minor,
14789 info.version.update,
14790 info.version.draft);
14791 printf("i40e Profile name: %s\n\n", info.name);
14794 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14795 (uint8_t *)&buff_size, sizeof(buff_size),
14796 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14797 if (!ret && buff_size) {
14798 buff = (uint8_t *)malloc(buff_size);
14800 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14802 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14804 printf("Package Notes:\n%s\n\n", buff);
14809 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14810 (uint8_t *)&dev_num, sizeof(dev_num),
14811 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14812 if (!ret && dev_num) {
14813 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14814 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14816 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14817 (uint8_t *)devs, buff_size,
14818 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14820 printf("List of supported devices:\n");
14821 for (i = 0; i < dev_num; i++) {
14822 printf(" %04X:%04X %04X:%04X\n",
14823 devs[i].vendor_dev_id >> 16,
14824 devs[i].vendor_dev_id & 0xFFFF,
14825 devs[i].sub_vendor_dev_id >> 16,
14826 devs[i].sub_vendor_dev_id & 0xFFFF);
14834 /* get information about protocols and packet types */
14835 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14836 (uint8_t *)&proto_num, sizeof(proto_num),
14837 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14838 if (ret || !proto_num)
14839 goto no_print_return;
14841 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14842 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14844 goto no_print_return;
14846 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14848 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14850 printf("List of used protocols:\n");
14851 for (i = 0; i < proto_num; i++)
14852 printf(" %2u: %s\n", proto[i].proto_id,
14856 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14857 (uint8_t *)&pctype_num, sizeof(pctype_num),
14858 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14859 if (ret || !pctype_num)
14860 goto no_print_pctypes;
14862 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14863 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14865 goto no_print_pctypes;
14867 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14869 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14872 goto no_print_pctypes;
14875 printf("List of defined packet classification types:\n");
14876 for (i = 0; i < pctype_num; i++) {
14877 printf(" %2u:", pctype[i].ptype_id);
14878 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14879 proto_id = pctype[i].protocols[j];
14880 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14881 for (n = 0; n < proto_num; n++) {
14882 if (proto[n].proto_id == proto_id) {
14883 printf(" %s", proto[n].name);
14896 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14898 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14899 if (ret || !ptype_num)
14900 goto no_print_return;
14902 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14903 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14905 goto no_print_return;
14907 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14909 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14912 goto no_print_return;
14914 printf("List of defined packet types:\n");
14915 for (i = 0; i < ptype_num; i++) {
14916 printf(" %2u:", ptype[i].ptype_id);
14917 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14918 proto_id = ptype[i].protocols[j];
14919 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14920 for (n = 0; n < proto_num; n++) {
14921 if (proto[n].proto_id == proto_id) {
14922 printf(" %s", proto[n].name);
14938 if (ret == -ENOTSUP)
14939 printf("Function not supported in PMD driver\n");
14943 cmdline_parse_inst_t cmd_ddp_get_info = {
14944 .f = cmd_ddp_info_parsed,
14946 .help_str = "ddp get info <profile_path>",
14948 (void *)&cmd_ddp_info_ddp,
14949 (void *)&cmd_ddp_info_get,
14950 (void *)&cmd_ddp_info_info,
14951 (void *)&cmd_ddp_info_filepath,
14956 /* Get dynamic device personalization profile info list*/
14957 #define PROFILE_INFO_SIZE 48
14958 #define MAX_PROFILE_NUM 16
14960 struct cmd_ddp_get_list_result {
14961 cmdline_fixed_string_t ddp;
14962 cmdline_fixed_string_t get;
14963 cmdline_fixed_string_t list;
14967 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14968 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14969 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14970 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14971 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14972 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14973 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14974 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14977 cmd_ddp_get_list_parsed(
14978 __attribute__((unused)) void *parsed_result,
14979 __attribute__((unused)) struct cmdline *cl,
14980 __attribute__((unused)) void *data)
14982 #ifdef RTE_LIBRTE_I40E_PMD
14983 struct cmd_ddp_get_list_result *res = parsed_result;
14984 struct rte_pmd_i40e_profile_list *p_list;
14985 struct rte_pmd_i40e_profile_info *p_info;
14990 int ret = -ENOTSUP;
14992 #ifdef RTE_LIBRTE_I40E_PMD
14993 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14994 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14996 printf("%s: Failed to malloc buffer\n", __func__);
14998 if (ret == -ENOTSUP)
14999 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15000 (uint8_t *)p_list, size);
15003 p_num = p_list->p_count;
15004 printf("Profile number is: %d\n\n", p_num);
15006 for (i = 0; i < p_num; i++) {
15007 p_info = &p_list->p_info[i];
15008 printf("Profile %d:\n", i);
15009 printf("Track id: 0x%x\n", p_info->track_id);
15010 printf("Version: %d.%d.%d.%d\n",
15011 p_info->version.major,
15012 p_info->version.minor,
15013 p_info->version.update,
15014 p_info->version.draft);
15015 printf("Profile name: %s\n\n", p_info->name);
15023 printf("Failed to get ddp list\n");
15026 cmdline_parse_inst_t cmd_ddp_get_list = {
15027 .f = cmd_ddp_get_list_parsed,
15029 .help_str = "ddp get list <port_id>",
15031 (void *)&cmd_ddp_get_list_ddp,
15032 (void *)&cmd_ddp_get_list_get,
15033 (void *)&cmd_ddp_get_list_list,
15034 (void *)&cmd_ddp_get_list_port_id,
15039 /* Configure input set */
15040 struct cmd_cfg_input_set_result {
15041 cmdline_fixed_string_t port;
15042 cmdline_fixed_string_t cfg;
15044 cmdline_fixed_string_t pctype;
15046 cmdline_fixed_string_t inset_type;
15047 cmdline_fixed_string_t opt;
15048 cmdline_fixed_string_t field;
15053 cmd_cfg_input_set_parsed(
15054 __attribute__((unused)) void *parsed_result,
15055 __attribute__((unused)) struct cmdline *cl,
15056 __attribute__((unused)) void *data)
15058 #ifdef RTE_LIBRTE_I40E_PMD
15059 struct cmd_cfg_input_set_result *res = parsed_result;
15060 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15061 struct rte_pmd_i40e_inset inset;
15063 int ret = -ENOTSUP;
15065 if (!all_ports_stopped()) {
15066 printf("Please stop all ports first\n");
15070 #ifdef RTE_LIBRTE_I40E_PMD
15071 if (!strcmp(res->inset_type, "hash_inset"))
15072 inset_type = INSET_HASH;
15073 else if (!strcmp(res->inset_type, "fdir_inset"))
15074 inset_type = INSET_FDIR;
15075 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15076 inset_type = INSET_FDIR_FLX;
15077 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15078 &inset, inset_type);
15080 printf("Failed to get input set.\n");
15084 if (!strcmp(res->opt, "get")) {
15085 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15088 printf("Field index %d is enabled.\n", res->field_idx);
15090 printf("Field index %d is disabled.\n", res->field_idx);
15092 } else if (!strcmp(res->opt, "set"))
15093 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15095 else if (!strcmp(res->opt, "clear"))
15096 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15099 printf("Failed to configure input set field.\n");
15103 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15104 &inset, inset_type);
15106 printf("Failed to set input set.\n");
15111 if (ret == -ENOTSUP)
15112 printf("Function not supported\n");
15115 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15116 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15118 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15119 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15121 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15122 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15124 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15125 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15127 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15128 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15130 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15131 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15133 "hash_inset#fdir_inset#fdir_flx_inset");
15134 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15135 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15136 opt, "get#set#clear");
15137 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15138 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15140 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15141 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15144 cmdline_parse_inst_t cmd_cfg_input_set = {
15145 .f = cmd_cfg_input_set_parsed,
15147 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15148 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15150 (void *)&cmd_cfg_input_set_port,
15151 (void *)&cmd_cfg_input_set_cfg,
15152 (void *)&cmd_cfg_input_set_port_id,
15153 (void *)&cmd_cfg_input_set_pctype,
15154 (void *)&cmd_cfg_input_set_pctype_id,
15155 (void *)&cmd_cfg_input_set_inset_type,
15156 (void *)&cmd_cfg_input_set_opt,
15157 (void *)&cmd_cfg_input_set_field,
15158 (void *)&cmd_cfg_input_set_field_idx,
15163 /* Clear input set */
15164 struct cmd_clear_input_set_result {
15165 cmdline_fixed_string_t port;
15166 cmdline_fixed_string_t cfg;
15168 cmdline_fixed_string_t pctype;
15170 cmdline_fixed_string_t inset_type;
15171 cmdline_fixed_string_t clear;
15172 cmdline_fixed_string_t all;
15176 cmd_clear_input_set_parsed(
15177 __attribute__((unused)) void *parsed_result,
15178 __attribute__((unused)) struct cmdline *cl,
15179 __attribute__((unused)) void *data)
15181 #ifdef RTE_LIBRTE_I40E_PMD
15182 struct cmd_clear_input_set_result *res = parsed_result;
15183 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15184 struct rte_pmd_i40e_inset inset;
15186 int ret = -ENOTSUP;
15188 if (!all_ports_stopped()) {
15189 printf("Please stop all ports first\n");
15193 #ifdef RTE_LIBRTE_I40E_PMD
15194 if (!strcmp(res->inset_type, "hash_inset"))
15195 inset_type = INSET_HASH;
15196 else if (!strcmp(res->inset_type, "fdir_inset"))
15197 inset_type = INSET_FDIR;
15198 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15199 inset_type = INSET_FDIR_FLX;
15201 memset(&inset, 0, sizeof(inset));
15203 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15204 &inset, inset_type);
15206 printf("Failed to clear input set.\n");
15212 if (ret == -ENOTSUP)
15213 printf("Function not supported\n");
15216 cmdline_parse_token_string_t cmd_clear_input_set_port =
15217 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15219 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15220 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15222 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15223 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15225 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15226 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15228 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15229 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15231 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15232 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15234 "hash_inset#fdir_inset#fdir_flx_inset");
15235 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15236 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15238 cmdline_parse_token_string_t cmd_clear_input_set_all =
15239 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15242 cmdline_parse_inst_t cmd_clear_input_set = {
15243 .f = cmd_clear_input_set_parsed,
15245 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15246 "fdir_inset|fdir_flx_inset clear all",
15248 (void *)&cmd_clear_input_set_port,
15249 (void *)&cmd_clear_input_set_cfg,
15250 (void *)&cmd_clear_input_set_port_id,
15251 (void *)&cmd_clear_input_set_pctype,
15252 (void *)&cmd_clear_input_set_pctype_id,
15253 (void *)&cmd_clear_input_set_inset_type,
15254 (void *)&cmd_clear_input_set_clear,
15255 (void *)&cmd_clear_input_set_all,
15260 /* show vf stats */
15262 /* Common result structure for show vf stats */
15263 struct cmd_show_vf_stats_result {
15264 cmdline_fixed_string_t show;
15265 cmdline_fixed_string_t vf;
15266 cmdline_fixed_string_t stats;
15271 /* Common CLI fields show vf stats*/
15272 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15273 TOKEN_STRING_INITIALIZER
15274 (struct cmd_show_vf_stats_result,
15276 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15277 TOKEN_STRING_INITIALIZER
15278 (struct cmd_show_vf_stats_result,
15280 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15281 TOKEN_STRING_INITIALIZER
15282 (struct cmd_show_vf_stats_result,
15284 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15285 TOKEN_NUM_INITIALIZER
15286 (struct cmd_show_vf_stats_result,
15288 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15289 TOKEN_NUM_INITIALIZER
15290 (struct cmd_show_vf_stats_result,
15294 cmd_show_vf_stats_parsed(
15295 void *parsed_result,
15296 __attribute__((unused)) struct cmdline *cl,
15297 __attribute__((unused)) void *data)
15299 struct cmd_show_vf_stats_result *res = parsed_result;
15300 struct rte_eth_stats stats;
15301 int ret = -ENOTSUP;
15302 static const char *nic_stats_border = "########################";
15304 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15307 memset(&stats, 0, sizeof(stats));
15309 #ifdef RTE_LIBRTE_I40E_PMD
15310 if (ret == -ENOTSUP)
15311 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15315 #ifdef RTE_LIBRTE_BNXT_PMD
15316 if (ret == -ENOTSUP)
15317 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15326 printf("invalid vf_id %d\n", res->vf_id);
15329 printf("invalid port_id %d\n", res->port_id);
15332 printf("function not implemented\n");
15335 printf("programming error: (%s)\n", strerror(-ret));
15338 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15339 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15341 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15343 stats.ipackets, stats.imissed, stats.ibytes);
15344 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15345 printf(" RX-nombuf: %-10"PRIu64"\n",
15347 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15349 stats.opackets, stats.oerrors, stats.obytes);
15351 printf(" %s############################%s\n",
15352 nic_stats_border, nic_stats_border);
15355 cmdline_parse_inst_t cmd_show_vf_stats = {
15356 .f = cmd_show_vf_stats_parsed,
15358 .help_str = "show vf stats <port_id> <vf_id>",
15360 (void *)&cmd_show_vf_stats_show,
15361 (void *)&cmd_show_vf_stats_vf,
15362 (void *)&cmd_show_vf_stats_stats,
15363 (void *)&cmd_show_vf_stats_port_id,
15364 (void *)&cmd_show_vf_stats_vf_id,
15369 /* clear vf stats */
15371 /* Common result structure for clear vf stats */
15372 struct cmd_clear_vf_stats_result {
15373 cmdline_fixed_string_t clear;
15374 cmdline_fixed_string_t vf;
15375 cmdline_fixed_string_t stats;
15380 /* Common CLI fields clear vf stats*/
15381 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15382 TOKEN_STRING_INITIALIZER
15383 (struct cmd_clear_vf_stats_result,
15385 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15386 TOKEN_STRING_INITIALIZER
15387 (struct cmd_clear_vf_stats_result,
15389 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15390 TOKEN_STRING_INITIALIZER
15391 (struct cmd_clear_vf_stats_result,
15393 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15394 TOKEN_NUM_INITIALIZER
15395 (struct cmd_clear_vf_stats_result,
15397 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15398 TOKEN_NUM_INITIALIZER
15399 (struct cmd_clear_vf_stats_result,
15403 cmd_clear_vf_stats_parsed(
15404 void *parsed_result,
15405 __attribute__((unused)) struct cmdline *cl,
15406 __attribute__((unused)) void *data)
15408 struct cmd_clear_vf_stats_result *res = parsed_result;
15409 int ret = -ENOTSUP;
15411 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15414 #ifdef RTE_LIBRTE_I40E_PMD
15415 if (ret == -ENOTSUP)
15416 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15419 #ifdef RTE_LIBRTE_BNXT_PMD
15420 if (ret == -ENOTSUP)
15421 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15429 printf("invalid vf_id %d\n", res->vf_id);
15432 printf("invalid port_id %d\n", res->port_id);
15435 printf("function not implemented\n");
15438 printf("programming error: (%s)\n", strerror(-ret));
15442 cmdline_parse_inst_t cmd_clear_vf_stats = {
15443 .f = cmd_clear_vf_stats_parsed,
15445 .help_str = "clear vf stats <port_id> <vf_id>",
15447 (void *)&cmd_clear_vf_stats_clear,
15448 (void *)&cmd_clear_vf_stats_vf,
15449 (void *)&cmd_clear_vf_stats_stats,
15450 (void *)&cmd_clear_vf_stats_port_id,
15451 (void *)&cmd_clear_vf_stats_vf_id,
15456 /* port config pctype mapping reset */
15458 /* Common result structure for port config pctype mapping reset */
15459 struct cmd_pctype_mapping_reset_result {
15460 cmdline_fixed_string_t port;
15461 cmdline_fixed_string_t config;
15463 cmdline_fixed_string_t pctype;
15464 cmdline_fixed_string_t mapping;
15465 cmdline_fixed_string_t reset;
15468 /* Common CLI fields for port config pctype mapping reset*/
15469 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15470 TOKEN_STRING_INITIALIZER
15471 (struct cmd_pctype_mapping_reset_result,
15473 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15474 TOKEN_STRING_INITIALIZER
15475 (struct cmd_pctype_mapping_reset_result,
15477 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15478 TOKEN_NUM_INITIALIZER
15479 (struct cmd_pctype_mapping_reset_result,
15481 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15482 TOKEN_STRING_INITIALIZER
15483 (struct cmd_pctype_mapping_reset_result,
15485 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15486 TOKEN_STRING_INITIALIZER
15487 (struct cmd_pctype_mapping_reset_result,
15488 mapping, "mapping");
15489 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15490 TOKEN_STRING_INITIALIZER
15491 (struct cmd_pctype_mapping_reset_result,
15495 cmd_pctype_mapping_reset_parsed(
15496 void *parsed_result,
15497 __attribute__((unused)) struct cmdline *cl,
15498 __attribute__((unused)) void *data)
15500 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15501 int ret = -ENOTSUP;
15503 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15506 #ifdef RTE_LIBRTE_I40E_PMD
15507 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15514 printf("invalid port_id %d\n", res->port_id);
15517 printf("function not implemented\n");
15520 printf("programming error: (%s)\n", strerror(-ret));
15524 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15525 .f = cmd_pctype_mapping_reset_parsed,
15527 .help_str = "port config <port_id> pctype mapping reset",
15529 (void *)&cmd_pctype_mapping_reset_port,
15530 (void *)&cmd_pctype_mapping_reset_config,
15531 (void *)&cmd_pctype_mapping_reset_port_id,
15532 (void *)&cmd_pctype_mapping_reset_pctype,
15533 (void *)&cmd_pctype_mapping_reset_mapping,
15534 (void *)&cmd_pctype_mapping_reset_reset,
15539 /* show port pctype mapping */
15541 /* Common result structure for show port pctype mapping */
15542 struct cmd_pctype_mapping_get_result {
15543 cmdline_fixed_string_t show;
15544 cmdline_fixed_string_t port;
15546 cmdline_fixed_string_t pctype;
15547 cmdline_fixed_string_t mapping;
15550 /* Common CLI fields for pctype mapping get */
15551 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15552 TOKEN_STRING_INITIALIZER
15553 (struct cmd_pctype_mapping_get_result,
15555 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15556 TOKEN_STRING_INITIALIZER
15557 (struct cmd_pctype_mapping_get_result,
15559 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15560 TOKEN_NUM_INITIALIZER
15561 (struct cmd_pctype_mapping_get_result,
15563 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15564 TOKEN_STRING_INITIALIZER
15565 (struct cmd_pctype_mapping_get_result,
15567 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15568 TOKEN_STRING_INITIALIZER
15569 (struct cmd_pctype_mapping_get_result,
15570 mapping, "mapping");
15573 cmd_pctype_mapping_get_parsed(
15574 void *parsed_result,
15575 __attribute__((unused)) struct cmdline *cl,
15576 __attribute__((unused)) void *data)
15578 struct cmd_pctype_mapping_get_result *res = parsed_result;
15579 int ret = -ENOTSUP;
15580 #ifdef RTE_LIBRTE_I40E_PMD
15581 struct rte_pmd_i40e_flow_type_mapping
15582 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15583 int i, j, first_pctype;
15586 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15589 #ifdef RTE_LIBRTE_I40E_PMD
15590 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15597 printf("invalid port_id %d\n", res->port_id);
15600 printf("function not implemented\n");
15603 printf("programming error: (%s)\n", strerror(-ret));
15607 #ifdef RTE_LIBRTE_I40E_PMD
15608 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15609 if (mapping[i].pctype != 0ULL) {
15612 printf("pctype: ");
15613 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15614 if (mapping[i].pctype & (1ULL << j)) {
15615 printf(first_pctype ?
15616 "%02d" : ",%02d", j);
15620 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15626 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15627 .f = cmd_pctype_mapping_get_parsed,
15629 .help_str = "show port <port_id> pctype mapping",
15631 (void *)&cmd_pctype_mapping_get_show,
15632 (void *)&cmd_pctype_mapping_get_port,
15633 (void *)&cmd_pctype_mapping_get_port_id,
15634 (void *)&cmd_pctype_mapping_get_pctype,
15635 (void *)&cmd_pctype_mapping_get_mapping,
15640 /* port config pctype mapping update */
15642 /* Common result structure for port config pctype mapping update */
15643 struct cmd_pctype_mapping_update_result {
15644 cmdline_fixed_string_t port;
15645 cmdline_fixed_string_t config;
15647 cmdline_fixed_string_t pctype;
15648 cmdline_fixed_string_t mapping;
15649 cmdline_fixed_string_t update;
15650 cmdline_fixed_string_t pctype_list;
15651 uint16_t flow_type;
15654 /* Common CLI fields for pctype mapping update*/
15655 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15656 TOKEN_STRING_INITIALIZER
15657 (struct cmd_pctype_mapping_update_result,
15659 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15660 TOKEN_STRING_INITIALIZER
15661 (struct cmd_pctype_mapping_update_result,
15663 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15664 TOKEN_NUM_INITIALIZER
15665 (struct cmd_pctype_mapping_update_result,
15667 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15668 TOKEN_STRING_INITIALIZER
15669 (struct cmd_pctype_mapping_update_result,
15671 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15672 TOKEN_STRING_INITIALIZER
15673 (struct cmd_pctype_mapping_update_result,
15674 mapping, "mapping");
15675 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15676 TOKEN_STRING_INITIALIZER
15677 (struct cmd_pctype_mapping_update_result,
15679 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15680 TOKEN_STRING_INITIALIZER
15681 (struct cmd_pctype_mapping_update_result,
15682 pctype_list, NULL);
15683 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15684 TOKEN_NUM_INITIALIZER
15685 (struct cmd_pctype_mapping_update_result,
15686 flow_type, UINT16);
15689 cmd_pctype_mapping_update_parsed(
15690 void *parsed_result,
15691 __attribute__((unused)) struct cmdline *cl,
15692 __attribute__((unused)) void *data)
15694 struct cmd_pctype_mapping_update_result *res = parsed_result;
15695 int ret = -ENOTSUP;
15696 #ifdef RTE_LIBRTE_I40E_PMD
15697 struct rte_pmd_i40e_flow_type_mapping mapping;
15699 unsigned int nb_item;
15700 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15706 #ifdef RTE_LIBRTE_I40E_PMD
15707 nb_item = parse_item_list(res->pctype_list, "pctypes",
15708 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15709 mapping.flow_type = res->flow_type;
15710 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15711 mapping.pctype |= (1ULL << pctype_list[i]);
15712 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15722 printf("invalid pctype or flow type\n");
15725 printf("invalid port_id %d\n", res->port_id);
15728 printf("function not implemented\n");
15731 printf("programming error: (%s)\n", strerror(-ret));
15735 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15736 .f = cmd_pctype_mapping_update_parsed,
15738 .help_str = "port config <port_id> pctype mapping update"
15739 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15741 (void *)&cmd_pctype_mapping_update_port,
15742 (void *)&cmd_pctype_mapping_update_config,
15743 (void *)&cmd_pctype_mapping_update_port_id,
15744 (void *)&cmd_pctype_mapping_update_pctype,
15745 (void *)&cmd_pctype_mapping_update_mapping,
15746 (void *)&cmd_pctype_mapping_update_update,
15747 (void *)&cmd_pctype_mapping_update_pc_type,
15748 (void *)&cmd_pctype_mapping_update_flow_type,
15753 /* ptype mapping get */
15755 /* Common result structure for ptype mapping get */
15756 struct cmd_ptype_mapping_get_result {
15757 cmdline_fixed_string_t ptype;
15758 cmdline_fixed_string_t mapping;
15759 cmdline_fixed_string_t get;
15761 uint8_t valid_only;
15764 /* Common CLI fields for ptype mapping get */
15765 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15766 TOKEN_STRING_INITIALIZER
15767 (struct cmd_ptype_mapping_get_result,
15769 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15770 TOKEN_STRING_INITIALIZER
15771 (struct cmd_ptype_mapping_get_result,
15772 mapping, "mapping");
15773 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15774 TOKEN_STRING_INITIALIZER
15775 (struct cmd_ptype_mapping_get_result,
15777 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15778 TOKEN_NUM_INITIALIZER
15779 (struct cmd_ptype_mapping_get_result,
15781 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15782 TOKEN_NUM_INITIALIZER
15783 (struct cmd_ptype_mapping_get_result,
15784 valid_only, UINT8);
15787 cmd_ptype_mapping_get_parsed(
15788 void *parsed_result,
15789 __attribute__((unused)) struct cmdline *cl,
15790 __attribute__((unused)) void *data)
15792 struct cmd_ptype_mapping_get_result *res = parsed_result;
15793 int ret = -ENOTSUP;
15794 #ifdef RTE_LIBRTE_I40E_PMD
15795 int max_ptype_num = 256;
15796 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15801 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15804 #ifdef RTE_LIBRTE_I40E_PMD
15805 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15816 printf("invalid port_id %d\n", res->port_id);
15819 printf("function not implemented\n");
15822 printf("programming error: (%s)\n", strerror(-ret));
15825 #ifdef RTE_LIBRTE_I40E_PMD
15827 for (i = 0; i < count; i++)
15828 printf("%3d\t0x%08x\n",
15829 mapping[i].hw_ptype, mapping[i].sw_ptype);
15834 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15835 .f = cmd_ptype_mapping_get_parsed,
15837 .help_str = "ptype mapping get <port_id> <valid_only>",
15839 (void *)&cmd_ptype_mapping_get_ptype,
15840 (void *)&cmd_ptype_mapping_get_mapping,
15841 (void *)&cmd_ptype_mapping_get_get,
15842 (void *)&cmd_ptype_mapping_get_port_id,
15843 (void *)&cmd_ptype_mapping_get_valid_only,
15848 /* ptype mapping replace */
15850 /* Common result structure for ptype mapping replace */
15851 struct cmd_ptype_mapping_replace_result {
15852 cmdline_fixed_string_t ptype;
15853 cmdline_fixed_string_t mapping;
15854 cmdline_fixed_string_t replace;
15861 /* Common CLI fields for ptype mapping replace */
15862 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15863 TOKEN_STRING_INITIALIZER
15864 (struct cmd_ptype_mapping_replace_result,
15866 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15867 TOKEN_STRING_INITIALIZER
15868 (struct cmd_ptype_mapping_replace_result,
15869 mapping, "mapping");
15870 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15871 TOKEN_STRING_INITIALIZER
15872 (struct cmd_ptype_mapping_replace_result,
15873 replace, "replace");
15874 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15875 TOKEN_NUM_INITIALIZER
15876 (struct cmd_ptype_mapping_replace_result,
15878 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15879 TOKEN_NUM_INITIALIZER
15880 (struct cmd_ptype_mapping_replace_result,
15882 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15883 TOKEN_NUM_INITIALIZER
15884 (struct cmd_ptype_mapping_replace_result,
15886 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15887 TOKEN_NUM_INITIALIZER
15888 (struct cmd_ptype_mapping_replace_result,
15892 cmd_ptype_mapping_replace_parsed(
15893 void *parsed_result,
15894 __attribute__((unused)) struct cmdline *cl,
15895 __attribute__((unused)) void *data)
15897 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15898 int ret = -ENOTSUP;
15900 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15903 #ifdef RTE_LIBRTE_I40E_PMD
15904 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15914 printf("invalid ptype 0x%8x or 0x%8x\n",
15915 res->target, res->pkt_type);
15918 printf("invalid port_id %d\n", res->port_id);
15921 printf("function not implemented\n");
15924 printf("programming error: (%s)\n", strerror(-ret));
15928 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15929 .f = cmd_ptype_mapping_replace_parsed,
15932 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15934 (void *)&cmd_ptype_mapping_replace_ptype,
15935 (void *)&cmd_ptype_mapping_replace_mapping,
15936 (void *)&cmd_ptype_mapping_replace_replace,
15937 (void *)&cmd_ptype_mapping_replace_port_id,
15938 (void *)&cmd_ptype_mapping_replace_target,
15939 (void *)&cmd_ptype_mapping_replace_mask,
15940 (void *)&cmd_ptype_mapping_replace_pkt_type,
15945 /* ptype mapping reset */
15947 /* Common result structure for ptype mapping reset */
15948 struct cmd_ptype_mapping_reset_result {
15949 cmdline_fixed_string_t ptype;
15950 cmdline_fixed_string_t mapping;
15951 cmdline_fixed_string_t reset;
15955 /* Common CLI fields for ptype mapping reset*/
15956 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15957 TOKEN_STRING_INITIALIZER
15958 (struct cmd_ptype_mapping_reset_result,
15960 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15961 TOKEN_STRING_INITIALIZER
15962 (struct cmd_ptype_mapping_reset_result,
15963 mapping, "mapping");
15964 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15965 TOKEN_STRING_INITIALIZER
15966 (struct cmd_ptype_mapping_reset_result,
15968 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15969 TOKEN_NUM_INITIALIZER
15970 (struct cmd_ptype_mapping_reset_result,
15974 cmd_ptype_mapping_reset_parsed(
15975 void *parsed_result,
15976 __attribute__((unused)) struct cmdline *cl,
15977 __attribute__((unused)) void *data)
15979 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15980 int ret = -ENOTSUP;
15982 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15985 #ifdef RTE_LIBRTE_I40E_PMD
15986 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15993 printf("invalid port_id %d\n", res->port_id);
15996 printf("function not implemented\n");
15999 printf("programming error: (%s)\n", strerror(-ret));
16003 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16004 .f = cmd_ptype_mapping_reset_parsed,
16006 .help_str = "ptype mapping reset <port_id>",
16008 (void *)&cmd_ptype_mapping_reset_ptype,
16009 (void *)&cmd_ptype_mapping_reset_mapping,
16010 (void *)&cmd_ptype_mapping_reset_reset,
16011 (void *)&cmd_ptype_mapping_reset_port_id,
16016 /* ptype mapping update */
16018 /* Common result structure for ptype mapping update */
16019 struct cmd_ptype_mapping_update_result {
16020 cmdline_fixed_string_t ptype;
16021 cmdline_fixed_string_t mapping;
16022 cmdline_fixed_string_t reset;
16028 /* Common CLI fields for ptype mapping update*/
16029 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16030 TOKEN_STRING_INITIALIZER
16031 (struct cmd_ptype_mapping_update_result,
16033 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16034 TOKEN_STRING_INITIALIZER
16035 (struct cmd_ptype_mapping_update_result,
16036 mapping, "mapping");
16037 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16038 TOKEN_STRING_INITIALIZER
16039 (struct cmd_ptype_mapping_update_result,
16041 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16042 TOKEN_NUM_INITIALIZER
16043 (struct cmd_ptype_mapping_update_result,
16045 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16046 TOKEN_NUM_INITIALIZER
16047 (struct cmd_ptype_mapping_update_result,
16049 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16050 TOKEN_NUM_INITIALIZER
16051 (struct cmd_ptype_mapping_update_result,
16055 cmd_ptype_mapping_update_parsed(
16056 void *parsed_result,
16057 __attribute__((unused)) struct cmdline *cl,
16058 __attribute__((unused)) void *data)
16060 struct cmd_ptype_mapping_update_result *res = parsed_result;
16061 int ret = -ENOTSUP;
16062 #ifdef RTE_LIBRTE_I40E_PMD
16063 struct rte_pmd_i40e_ptype_mapping mapping;
16065 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16068 #ifdef RTE_LIBRTE_I40E_PMD
16069 mapping.hw_ptype = res->hw_ptype;
16070 mapping.sw_ptype = res->sw_ptype;
16071 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16081 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16084 printf("invalid port_id %d\n", res->port_id);
16087 printf("function not implemented\n");
16090 printf("programming error: (%s)\n", strerror(-ret));
16094 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16095 .f = cmd_ptype_mapping_update_parsed,
16097 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16099 (void *)&cmd_ptype_mapping_update_ptype,
16100 (void *)&cmd_ptype_mapping_update_mapping,
16101 (void *)&cmd_ptype_mapping_update_update,
16102 (void *)&cmd_ptype_mapping_update_port_id,
16103 (void *)&cmd_ptype_mapping_update_hw_ptype,
16104 (void *)&cmd_ptype_mapping_update_sw_ptype,
16109 /* Common result structure for file commands */
16110 struct cmd_cmdfile_result {
16111 cmdline_fixed_string_t load;
16112 cmdline_fixed_string_t filename;
16115 /* Common CLI fields for file commands */
16116 cmdline_parse_token_string_t cmd_load_cmdfile =
16117 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16118 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16119 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16122 cmd_load_from_file_parsed(
16123 void *parsed_result,
16124 __attribute__((unused)) struct cmdline *cl,
16125 __attribute__((unused)) void *data)
16127 struct cmd_cmdfile_result *res = parsed_result;
16129 cmdline_read_from_file(res->filename);
16132 cmdline_parse_inst_t cmd_load_from_file = {
16133 .f = cmd_load_from_file_parsed,
16135 .help_str = "load <filename>",
16137 (void *)&cmd_load_cmdfile,
16138 (void *)&cmd_load_cmdfile_filename,
16143 /* ******************************************************************************** */
16145 /* list of instructions */
16146 cmdline_parse_ctx_t main_ctx[] = {
16147 (cmdline_parse_inst_t *)&cmd_help_brief,
16148 (cmdline_parse_inst_t *)&cmd_help_long,
16149 (cmdline_parse_inst_t *)&cmd_quit,
16150 (cmdline_parse_inst_t *)&cmd_load_from_file,
16151 (cmdline_parse_inst_t *)&cmd_showport,
16152 (cmdline_parse_inst_t *)&cmd_showqueue,
16153 (cmdline_parse_inst_t *)&cmd_showportall,
16154 (cmdline_parse_inst_t *)&cmd_showcfg,
16155 (cmdline_parse_inst_t *)&cmd_start,
16156 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16157 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16158 (cmdline_parse_inst_t *)&cmd_set_link_up,
16159 (cmdline_parse_inst_t *)&cmd_set_link_down,
16160 (cmdline_parse_inst_t *)&cmd_reset,
16161 (cmdline_parse_inst_t *)&cmd_set_numbers,
16162 (cmdline_parse_inst_t *)&cmd_set_log,
16163 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16164 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16165 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16166 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16167 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16168 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16169 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16170 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16171 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16172 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16173 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16174 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16175 (cmdline_parse_inst_t *)&cmd_set_link_check,
16176 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16177 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16178 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16179 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16180 #ifdef RTE_LIBRTE_PMD_BOND
16181 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16182 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16183 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16184 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16185 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16186 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16187 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16188 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16189 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16190 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16191 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16193 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16194 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16195 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16196 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16197 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16198 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16199 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16200 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16201 (cmdline_parse_inst_t *)&cmd_csum_set,
16202 (cmdline_parse_inst_t *)&cmd_csum_show,
16203 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16204 (cmdline_parse_inst_t *)&cmd_tso_set,
16205 (cmdline_parse_inst_t *)&cmd_tso_show,
16206 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16207 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16208 (cmdline_parse_inst_t *)&cmd_gro_enable,
16209 (cmdline_parse_inst_t *)&cmd_gro_flush,
16210 (cmdline_parse_inst_t *)&cmd_gro_show,
16211 (cmdline_parse_inst_t *)&cmd_gso_enable,
16212 (cmdline_parse_inst_t *)&cmd_gso_size,
16213 (cmdline_parse_inst_t *)&cmd_gso_show,
16214 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16215 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16216 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16217 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16218 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16219 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16220 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16221 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16222 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16223 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16224 (cmdline_parse_inst_t *)&cmd_config_dcb,
16225 (cmdline_parse_inst_t *)&cmd_read_reg,
16226 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16227 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16228 (cmdline_parse_inst_t *)&cmd_write_reg,
16229 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16230 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16231 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16232 (cmdline_parse_inst_t *)&cmd_stop,
16233 (cmdline_parse_inst_t *)&cmd_mac_addr,
16234 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16235 (cmdline_parse_inst_t *)&cmd_set_qmap,
16236 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16237 (cmdline_parse_inst_t *)&cmd_operate_port,
16238 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16239 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16240 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16241 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16242 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16243 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16244 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16245 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16246 (cmdline_parse_inst_t *)&cmd_config_mtu,
16247 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16248 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16249 (cmdline_parse_inst_t *)&cmd_config_rss,
16250 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16251 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16252 (cmdline_parse_inst_t *)&cmd_showport_reta,
16253 (cmdline_parse_inst_t *)&cmd_config_burst,
16254 (cmdline_parse_inst_t *)&cmd_config_thresh,
16255 (cmdline_parse_inst_t *)&cmd_config_threshold,
16256 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16257 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16258 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16259 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16260 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16261 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16262 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16263 (cmdline_parse_inst_t *)&cmd_global_config,
16264 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16265 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16266 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16267 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16268 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16269 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16270 (cmdline_parse_inst_t *)&cmd_dump,
16271 (cmdline_parse_inst_t *)&cmd_dump_one,
16272 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16273 (cmdline_parse_inst_t *)&cmd_syn_filter,
16274 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16275 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16276 (cmdline_parse_inst_t *)&cmd_flex_filter,
16277 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16278 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16279 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16280 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16281 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16282 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16283 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16284 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16285 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16286 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16287 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16288 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16289 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16290 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16291 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16292 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16293 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16294 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16295 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16296 (cmdline_parse_inst_t *)&cmd_flow,
16297 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16298 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16299 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16300 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16301 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16302 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16303 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16304 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16305 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16306 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16307 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16308 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16309 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16310 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16311 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16312 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16313 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16314 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16315 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16316 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16317 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16318 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16319 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16320 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16321 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16322 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16323 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16324 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16325 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16326 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16327 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16328 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16329 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16330 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16331 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16332 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16333 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16334 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16335 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16336 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16337 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16338 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16339 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16340 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16341 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16342 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16343 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16344 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16345 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16346 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16347 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16349 (cmdline_parse_inst_t *)&cmd_ddp_add,
16350 (cmdline_parse_inst_t *)&cmd_ddp_del,
16351 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16352 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16353 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16354 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16355 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16356 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16357 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16358 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16359 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16360 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16362 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16363 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16364 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16365 (cmdline_parse_inst_t *)&cmd_queue_region,
16366 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16367 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16368 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16369 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16370 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16371 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16372 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16373 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16374 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16375 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16376 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16377 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16378 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16379 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16380 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16381 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16382 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16383 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16384 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16385 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16386 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16390 /* read cmdline commands from file */
16392 cmdline_read_from_file(const char *filename)
16394 struct cmdline *cl;
16396 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16398 printf("Failed to create file based cmdline context: %s\n",
16403 cmdline_interact(cl);
16408 printf("Read CLI commands from %s\n", filename);
16411 /* prompt function, called from main on MASTER lcore */
16415 /* initialize non-constant commands */
16416 cmd_set_fwd_mode_init();
16417 cmd_set_fwd_retry_mode_init();
16419 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16420 if (testpmd_cl == NULL)
16422 cmdline_interact(testpmd_cl);
16423 cmdline_stdin_exit(testpmd_cl);
16429 if (testpmd_cl != NULL)
16430 cmdline_quit(testpmd_cl);
16434 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16436 if (id == (portid_t)RTE_PORT_ALL) {
16439 RTE_ETH_FOREACH_DEV(pid) {
16440 /* check if need_reconfig has been set to 1 */
16441 if (ports[pid].need_reconfig == 0)
16442 ports[pid].need_reconfig = dev;
16443 /* check if need_reconfig_queues has been set to 1 */
16444 if (ports[pid].need_reconfig_queues == 0)
16445 ports[pid].need_reconfig_queues = queue;
16447 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16448 /* check if need_reconfig has been set to 1 */
16449 if (ports[id].need_reconfig == 0)
16450 ports[id].need_reconfig = dev;
16451 /* check if need_reconfig_queues has been set to 1 */
16452 if (ports[id].need_reconfig_queues == 0)
16453 ports[id].need_reconfig_queues = queue;