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);
4171 cmd_tunnel_tso_set_parsed(void *parsed_result,
4172 __attribute__((unused)) struct cmdline *cl,
4173 __attribute__((unused)) void *data)
4175 struct cmd_tunnel_tso_set_result *res = parsed_result;
4176 struct rte_eth_dev_info dev_info;
4178 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4180 if (!port_is_stopped(res->port_id)) {
4181 printf("Please stop port %d first\n", res->port_id);
4185 if (!strcmp(res->mode, "set"))
4186 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4188 dev_info = check_tunnel_tso_nic_support(res->port_id);
4189 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4190 ports[res->port_id].dev_conf.txmode.offloads &=
4191 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4192 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4193 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4194 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4195 printf("TSO for tunneled packets is disabled\n");
4197 uint64_t tso_offloads = (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);
4202 ports[res->port_id].dev_conf.txmode.offloads |=
4203 (tso_offloads & dev_info.tx_offload_capa);
4204 printf("TSO segment size for tunneled packets is %d\n",
4205 ports[res->port_id].tunnel_tso_segsz);
4207 /* Below conditions are needed to make it work:
4208 * (1) tunnel TSO is supported by the NIC;
4209 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4211 * (3) for tunneled pkts with outer L3 of IPv4,
4212 * "csum set outer-ip" must be set to hw, because after tso,
4213 * total_len of outer IP header is changed, and the checksum
4214 * of outer IP header calculated by sw should be wrong; that
4215 * is not necessary for IPv6 tunneled pkts because there's no
4216 * checksum in IP header anymore.
4219 if (!ports[res->port_id].parse_tunnel)
4220 printf("Warning: csum parse_tunnel must be set "
4221 "so that tunneled packets are recognized\n");
4222 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4223 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4224 printf("Warning: csum set outer-ip must be set to hw "
4225 "if outer L3 is IPv4; not necessary for IPv6\n");
4228 cmd_reconfig_device_queue(res->port_id, 1, 1);
4231 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4232 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4234 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4235 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4237 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4238 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4240 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4241 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4244 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4245 .f = cmd_tunnel_tso_set_parsed,
4247 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4248 "Set TSO segment size of tunneled packets for csum engine "
4251 (void *)&cmd_tunnel_tso_set_tso,
4252 (void *)&cmd_tunnel_tso_set_mode,
4253 (void *)&cmd_tunnel_tso_set_tso_segsz,
4254 (void *)&cmd_tunnel_tso_set_portid,
4259 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4260 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4264 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4265 .f = cmd_tunnel_tso_set_parsed,
4267 .help_str = "tunnel_tso show <port_id> "
4268 "Show TSO segment size of tunneled packets for csum engine",
4270 (void *)&cmd_tunnel_tso_set_tso,
4271 (void *)&cmd_tunnel_tso_show_mode,
4272 (void *)&cmd_tunnel_tso_set_portid,
4277 /* *** SET GRO FOR A PORT *** */
4278 struct cmd_gro_enable_result {
4279 cmdline_fixed_string_t cmd_set;
4280 cmdline_fixed_string_t cmd_port;
4281 cmdline_fixed_string_t cmd_keyword;
4282 cmdline_fixed_string_t cmd_onoff;
4287 cmd_gro_enable_parsed(void *parsed_result,
4288 __attribute__((unused)) struct cmdline *cl,
4289 __attribute__((unused)) void *data)
4291 struct cmd_gro_enable_result *res;
4293 res = parsed_result;
4294 if (!strcmp(res->cmd_keyword, "gro"))
4295 setup_gro(res->cmd_onoff, res->cmd_pid);
4298 cmdline_parse_token_string_t cmd_gro_enable_set =
4299 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4301 cmdline_parse_token_string_t cmd_gro_enable_port =
4302 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4303 cmd_keyword, "port");
4304 cmdline_parse_token_num_t cmd_gro_enable_pid =
4305 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4307 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4308 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4309 cmd_keyword, "gro");
4310 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4311 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4312 cmd_onoff, "on#off");
4314 cmdline_parse_inst_t cmd_gro_enable = {
4315 .f = cmd_gro_enable_parsed,
4317 .help_str = "set port <port_id> gro on|off",
4319 (void *)&cmd_gro_enable_set,
4320 (void *)&cmd_gro_enable_port,
4321 (void *)&cmd_gro_enable_pid,
4322 (void *)&cmd_gro_enable_keyword,
4323 (void *)&cmd_gro_enable_onoff,
4328 /* *** DISPLAY GRO CONFIGURATION *** */
4329 struct cmd_gro_show_result {
4330 cmdline_fixed_string_t cmd_show;
4331 cmdline_fixed_string_t cmd_port;
4332 cmdline_fixed_string_t cmd_keyword;
4337 cmd_gro_show_parsed(void *parsed_result,
4338 __attribute__((unused)) struct cmdline *cl,
4339 __attribute__((unused)) void *data)
4341 struct cmd_gro_show_result *res;
4343 res = parsed_result;
4344 if (!strcmp(res->cmd_keyword, "gro"))
4345 show_gro(res->cmd_pid);
4348 cmdline_parse_token_string_t cmd_gro_show_show =
4349 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4351 cmdline_parse_token_string_t cmd_gro_show_port =
4352 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4354 cmdline_parse_token_num_t cmd_gro_show_pid =
4355 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4357 cmdline_parse_token_string_t cmd_gro_show_keyword =
4358 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4359 cmd_keyword, "gro");
4361 cmdline_parse_inst_t cmd_gro_show = {
4362 .f = cmd_gro_show_parsed,
4364 .help_str = "show port <port_id> gro",
4366 (void *)&cmd_gro_show_show,
4367 (void *)&cmd_gro_show_port,
4368 (void *)&cmd_gro_show_pid,
4369 (void *)&cmd_gro_show_keyword,
4374 /* *** SET FLUSH CYCLES FOR GRO *** */
4375 struct cmd_gro_flush_result {
4376 cmdline_fixed_string_t cmd_set;
4377 cmdline_fixed_string_t cmd_keyword;
4378 cmdline_fixed_string_t cmd_flush;
4383 cmd_gro_flush_parsed(void *parsed_result,
4384 __attribute__((unused)) struct cmdline *cl,
4385 __attribute__((unused)) void *data)
4387 struct cmd_gro_flush_result *res;
4389 res = parsed_result;
4390 if ((!strcmp(res->cmd_keyword, "gro")) &&
4391 (!strcmp(res->cmd_flush, "flush")))
4392 setup_gro_flush_cycles(res->cmd_cycles);
4395 cmdline_parse_token_string_t cmd_gro_flush_set =
4396 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4398 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4399 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4400 cmd_keyword, "gro");
4401 cmdline_parse_token_string_t cmd_gro_flush_flush =
4402 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4403 cmd_flush, "flush");
4404 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4405 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4408 cmdline_parse_inst_t cmd_gro_flush = {
4409 .f = cmd_gro_flush_parsed,
4411 .help_str = "set gro flush <cycles>",
4413 (void *)&cmd_gro_flush_set,
4414 (void *)&cmd_gro_flush_keyword,
4415 (void *)&cmd_gro_flush_flush,
4416 (void *)&cmd_gro_flush_cycles,
4421 /* *** ENABLE/DISABLE GSO *** */
4422 struct cmd_gso_enable_result {
4423 cmdline_fixed_string_t cmd_set;
4424 cmdline_fixed_string_t cmd_port;
4425 cmdline_fixed_string_t cmd_keyword;
4426 cmdline_fixed_string_t cmd_mode;
4431 cmd_gso_enable_parsed(void *parsed_result,
4432 __attribute__((unused)) struct cmdline *cl,
4433 __attribute__((unused)) void *data)
4435 struct cmd_gso_enable_result *res;
4437 res = parsed_result;
4438 if (!strcmp(res->cmd_keyword, "gso"))
4439 setup_gso(res->cmd_mode, res->cmd_pid);
4442 cmdline_parse_token_string_t cmd_gso_enable_set =
4443 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4445 cmdline_parse_token_string_t cmd_gso_enable_port =
4446 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4448 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4449 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4450 cmd_keyword, "gso");
4451 cmdline_parse_token_string_t cmd_gso_enable_mode =
4452 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4453 cmd_mode, "on#off");
4454 cmdline_parse_token_num_t cmd_gso_enable_pid =
4455 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4458 cmdline_parse_inst_t cmd_gso_enable = {
4459 .f = cmd_gso_enable_parsed,
4461 .help_str = "set port <port_id> gso on|off",
4463 (void *)&cmd_gso_enable_set,
4464 (void *)&cmd_gso_enable_port,
4465 (void *)&cmd_gso_enable_pid,
4466 (void *)&cmd_gso_enable_keyword,
4467 (void *)&cmd_gso_enable_mode,
4472 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4473 struct cmd_gso_size_result {
4474 cmdline_fixed_string_t cmd_set;
4475 cmdline_fixed_string_t cmd_keyword;
4476 cmdline_fixed_string_t cmd_segsz;
4481 cmd_gso_size_parsed(void *parsed_result,
4482 __attribute__((unused)) struct cmdline *cl,
4483 __attribute__((unused)) void *data)
4485 struct cmd_gso_size_result *res = parsed_result;
4487 if (test_done == 0) {
4488 printf("Before setting GSO segsz, please first"
4489 " stop fowarding\n");
4493 if (!strcmp(res->cmd_keyword, "gso") &&
4494 !strcmp(res->cmd_segsz, "segsz")) {
4495 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4496 printf("gso_size should be larger than %zu."
4497 " Please input a legal value\n",
4498 RTE_GSO_SEG_SIZE_MIN);
4500 gso_max_segment_size = res->cmd_size;
4504 cmdline_parse_token_string_t cmd_gso_size_set =
4505 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4507 cmdline_parse_token_string_t cmd_gso_size_keyword =
4508 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4509 cmd_keyword, "gso");
4510 cmdline_parse_token_string_t cmd_gso_size_segsz =
4511 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4512 cmd_segsz, "segsz");
4513 cmdline_parse_token_num_t cmd_gso_size_size =
4514 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4517 cmdline_parse_inst_t cmd_gso_size = {
4518 .f = cmd_gso_size_parsed,
4520 .help_str = "set gso segsz <length>",
4522 (void *)&cmd_gso_size_set,
4523 (void *)&cmd_gso_size_keyword,
4524 (void *)&cmd_gso_size_segsz,
4525 (void *)&cmd_gso_size_size,
4530 /* *** SHOW GSO CONFIGURATION *** */
4531 struct cmd_gso_show_result {
4532 cmdline_fixed_string_t cmd_show;
4533 cmdline_fixed_string_t cmd_port;
4534 cmdline_fixed_string_t cmd_keyword;
4539 cmd_gso_show_parsed(void *parsed_result,
4540 __attribute__((unused)) struct cmdline *cl,
4541 __attribute__((unused)) void *data)
4543 struct cmd_gso_show_result *res = parsed_result;
4545 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4546 printf("invalid port id %u\n", res->cmd_pid);
4549 if (!strcmp(res->cmd_keyword, "gso")) {
4550 if (gso_ports[res->cmd_pid].enable) {
4551 printf("Max GSO'd packet size: %uB\n"
4552 "Supported GSO types: TCP/IPv4, "
4553 "VxLAN with inner TCP/IPv4 packet, "
4554 "GRE with inner TCP/IPv4 packet\n",
4555 gso_max_segment_size);
4557 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4561 cmdline_parse_token_string_t cmd_gso_show_show =
4562 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4564 cmdline_parse_token_string_t cmd_gso_show_port =
4565 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4567 cmdline_parse_token_string_t cmd_gso_show_keyword =
4568 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4569 cmd_keyword, "gso");
4570 cmdline_parse_token_num_t cmd_gso_show_pid =
4571 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4574 cmdline_parse_inst_t cmd_gso_show = {
4575 .f = cmd_gso_show_parsed,
4577 .help_str = "show port <port_id> gso",
4579 (void *)&cmd_gso_show_show,
4580 (void *)&cmd_gso_show_port,
4581 (void *)&cmd_gso_show_pid,
4582 (void *)&cmd_gso_show_keyword,
4587 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4588 struct cmd_set_flush_rx {
4589 cmdline_fixed_string_t set;
4590 cmdline_fixed_string_t flush_rx;
4591 cmdline_fixed_string_t mode;
4595 cmd_set_flush_rx_parsed(void *parsed_result,
4596 __attribute__((unused)) struct cmdline *cl,
4597 __attribute__((unused)) void *data)
4599 struct cmd_set_flush_rx *res = parsed_result;
4600 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4603 cmdline_parse_token_string_t cmd_setflushrx_set =
4604 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4606 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4607 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4608 flush_rx, "flush_rx");
4609 cmdline_parse_token_string_t cmd_setflushrx_mode =
4610 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4614 cmdline_parse_inst_t cmd_set_flush_rx = {
4615 .f = cmd_set_flush_rx_parsed,
4616 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4619 (void *)&cmd_setflushrx_set,
4620 (void *)&cmd_setflushrx_flush_rx,
4621 (void *)&cmd_setflushrx_mode,
4626 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4627 struct cmd_set_link_check {
4628 cmdline_fixed_string_t set;
4629 cmdline_fixed_string_t link_check;
4630 cmdline_fixed_string_t mode;
4634 cmd_set_link_check_parsed(void *parsed_result,
4635 __attribute__((unused)) struct cmdline *cl,
4636 __attribute__((unused)) void *data)
4638 struct cmd_set_link_check *res = parsed_result;
4639 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4642 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4643 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4645 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4646 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4647 link_check, "link_check");
4648 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4649 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4653 cmdline_parse_inst_t cmd_set_link_check = {
4654 .f = cmd_set_link_check_parsed,
4655 .help_str = "set link_check on|off: Enable/Disable link status check "
4656 "when starting/stopping a port",
4659 (void *)&cmd_setlinkcheck_set,
4660 (void *)&cmd_setlinkcheck_link_check,
4661 (void *)&cmd_setlinkcheck_mode,
4666 /* *** SET NIC BYPASS MODE *** */
4667 struct cmd_set_bypass_mode_result {
4668 cmdline_fixed_string_t set;
4669 cmdline_fixed_string_t bypass;
4670 cmdline_fixed_string_t mode;
4671 cmdline_fixed_string_t value;
4676 cmd_set_bypass_mode_parsed(void *parsed_result,
4677 __attribute__((unused)) struct cmdline *cl,
4678 __attribute__((unused)) void *data)
4680 struct cmd_set_bypass_mode_result *res = parsed_result;
4681 portid_t port_id = res->port_id;
4682 int32_t rc = -EINVAL;
4684 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4685 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4687 if (!strcmp(res->value, "bypass"))
4688 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4689 else if (!strcmp(res->value, "isolate"))
4690 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4692 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4694 /* Set the bypass mode for the relevant port. */
4695 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4698 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4701 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4702 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4704 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4705 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4707 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4708 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4710 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4711 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4712 value, "normal#bypass#isolate");
4713 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4714 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4717 cmdline_parse_inst_t cmd_set_bypass_mode = {
4718 .f = cmd_set_bypass_mode_parsed,
4719 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4720 "Set the NIC bypass mode for port_id",
4723 (void *)&cmd_setbypass_mode_set,
4724 (void *)&cmd_setbypass_mode_bypass,
4725 (void *)&cmd_setbypass_mode_mode,
4726 (void *)&cmd_setbypass_mode_value,
4727 (void *)&cmd_setbypass_mode_port,
4732 /* *** SET NIC BYPASS EVENT *** */
4733 struct cmd_set_bypass_event_result {
4734 cmdline_fixed_string_t set;
4735 cmdline_fixed_string_t bypass;
4736 cmdline_fixed_string_t event;
4737 cmdline_fixed_string_t event_value;
4738 cmdline_fixed_string_t mode;
4739 cmdline_fixed_string_t mode_value;
4744 cmd_set_bypass_event_parsed(void *parsed_result,
4745 __attribute__((unused)) struct cmdline *cl,
4746 __attribute__((unused)) void *data)
4748 int32_t rc = -EINVAL;
4749 struct cmd_set_bypass_event_result *res = parsed_result;
4750 portid_t port_id = res->port_id;
4752 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4753 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4754 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4756 if (!strcmp(res->event_value, "timeout"))
4757 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4758 else if (!strcmp(res->event_value, "os_on"))
4759 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4760 else if (!strcmp(res->event_value, "os_off"))
4761 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4762 else if (!strcmp(res->event_value, "power_on"))
4763 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4764 else if (!strcmp(res->event_value, "power_off"))
4765 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4767 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4769 if (!strcmp(res->mode_value, "bypass"))
4770 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4771 else if (!strcmp(res->mode_value, "isolate"))
4772 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4774 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4776 /* Set the watchdog timeout. */
4777 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4780 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4781 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4785 printf("Failed to set timeout value %u "
4786 "for port %d, errto code: %d.\n",
4787 bypass_timeout, port_id, rc);
4791 /* Set the bypass event to transition to bypass mode. */
4792 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4797 printf("\t Failed to set bypass event for port = %d.\n",
4801 cmdline_parse_token_string_t cmd_setbypass_event_set =
4802 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4804 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4805 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4807 cmdline_parse_token_string_t cmd_setbypass_event_event =
4808 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4810 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4811 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4812 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4813 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4814 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4816 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4817 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4818 mode_value, "normal#bypass#isolate");
4819 cmdline_parse_token_num_t cmd_setbypass_event_port =
4820 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4823 cmdline_parse_inst_t cmd_set_bypass_event = {
4824 .f = cmd_set_bypass_event_parsed,
4825 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4826 "power_off mode normal|bypass|isolate <port_id>: "
4827 "Set the NIC bypass event mode for port_id",
4830 (void *)&cmd_setbypass_event_set,
4831 (void *)&cmd_setbypass_event_bypass,
4832 (void *)&cmd_setbypass_event_event,
4833 (void *)&cmd_setbypass_event_event_value,
4834 (void *)&cmd_setbypass_event_mode,
4835 (void *)&cmd_setbypass_event_mode_value,
4836 (void *)&cmd_setbypass_event_port,
4842 /* *** SET NIC BYPASS TIMEOUT *** */
4843 struct cmd_set_bypass_timeout_result {
4844 cmdline_fixed_string_t set;
4845 cmdline_fixed_string_t bypass;
4846 cmdline_fixed_string_t timeout;
4847 cmdline_fixed_string_t value;
4851 cmd_set_bypass_timeout_parsed(void *parsed_result,
4852 __attribute__((unused)) struct cmdline *cl,
4853 __attribute__((unused)) void *data)
4855 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4857 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4858 if (!strcmp(res->value, "1.5"))
4859 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4860 else if (!strcmp(res->value, "2"))
4861 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4862 else if (!strcmp(res->value, "3"))
4863 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4864 else if (!strcmp(res->value, "4"))
4865 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4866 else if (!strcmp(res->value, "8"))
4867 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4868 else if (!strcmp(res->value, "16"))
4869 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4870 else if (!strcmp(res->value, "32"))
4871 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4873 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4877 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4878 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4880 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4883 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4884 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4885 timeout, "timeout");
4886 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4887 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4888 value, "0#1.5#2#3#4#8#16#32");
4890 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4891 .f = cmd_set_bypass_timeout_parsed,
4892 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4893 "Set the NIC bypass watchdog timeout in seconds",
4896 (void *)&cmd_setbypass_timeout_set,
4897 (void *)&cmd_setbypass_timeout_bypass,
4898 (void *)&cmd_setbypass_timeout_timeout,
4899 (void *)&cmd_setbypass_timeout_value,
4904 /* *** SHOW NIC BYPASS MODE *** */
4905 struct cmd_show_bypass_config_result {
4906 cmdline_fixed_string_t show;
4907 cmdline_fixed_string_t bypass;
4908 cmdline_fixed_string_t config;
4913 cmd_show_bypass_config_parsed(void *parsed_result,
4914 __attribute__((unused)) struct cmdline *cl,
4915 __attribute__((unused)) void *data)
4917 struct cmd_show_bypass_config_result *res = parsed_result;
4918 portid_t port_id = res->port_id;
4920 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4921 uint32_t event_mode;
4922 uint32_t bypass_mode;
4923 uint32_t timeout = bypass_timeout;
4926 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4927 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4928 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4929 {"UNKNOWN", "normal", "bypass", "isolate"};
4930 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4937 int num_events = (sizeof events) / (sizeof events[0]);
4939 /* Display the bypass mode.*/
4940 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4941 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4945 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4946 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4948 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4951 /* Display the bypass timeout.*/
4952 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4953 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4955 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4957 /* Display the bypass events and associated modes. */
4958 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4960 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4961 printf("\tFailed to get bypass mode for event = %s\n",
4964 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4965 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4967 printf("\tbypass event: %-16s = %s\n", events[i],
4973 printf("\tFailed to get bypass configuration for port = %d\n",
4977 cmdline_parse_token_string_t cmd_showbypass_config_show =
4978 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4980 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4981 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4983 cmdline_parse_token_string_t cmd_showbypass_config_config =
4984 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4986 cmdline_parse_token_num_t cmd_showbypass_config_port =
4987 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4990 cmdline_parse_inst_t cmd_show_bypass_config = {
4991 .f = cmd_show_bypass_config_parsed,
4992 .help_str = "show bypass config <port_id>: "
4993 "Show the NIC bypass config for port_id",
4996 (void *)&cmd_showbypass_config_show,
4997 (void *)&cmd_showbypass_config_bypass,
4998 (void *)&cmd_showbypass_config_config,
4999 (void *)&cmd_showbypass_config_port,
5004 #ifdef RTE_LIBRTE_PMD_BOND
5005 /* *** SET BONDING MODE *** */
5006 struct cmd_set_bonding_mode_result {
5007 cmdline_fixed_string_t set;
5008 cmdline_fixed_string_t bonding;
5009 cmdline_fixed_string_t mode;
5014 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5015 __attribute__((unused)) struct cmdline *cl,
5016 __attribute__((unused)) void *data)
5018 struct cmd_set_bonding_mode_result *res = parsed_result;
5019 portid_t port_id = res->port_id;
5021 /* Set the bonding mode for the relevant port. */
5022 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5023 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5026 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5027 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5029 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5030 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5031 bonding, "bonding");
5032 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5033 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5035 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5036 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5038 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5039 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5042 cmdline_parse_inst_t cmd_set_bonding_mode = {
5043 .f = cmd_set_bonding_mode_parsed,
5044 .help_str = "set bonding mode <mode_value> <port_id>: "
5045 "Set the bonding mode for port_id",
5048 (void *) &cmd_setbonding_mode_set,
5049 (void *) &cmd_setbonding_mode_bonding,
5050 (void *) &cmd_setbonding_mode_mode,
5051 (void *) &cmd_setbonding_mode_value,
5052 (void *) &cmd_setbonding_mode_port,
5057 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5058 struct cmd_set_bonding_lacp_dedicated_queues_result {
5059 cmdline_fixed_string_t set;
5060 cmdline_fixed_string_t bonding;
5061 cmdline_fixed_string_t lacp;
5062 cmdline_fixed_string_t dedicated_queues;
5064 cmdline_fixed_string_t mode;
5067 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5068 __attribute__((unused)) struct cmdline *cl,
5069 __attribute__((unused)) void *data)
5071 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5072 portid_t port_id = res->port_id;
5073 struct rte_port *port;
5075 port = &ports[port_id];
5077 /** Check if the port is not started **/
5078 if (port->port_status != RTE_PORT_STOPPED) {
5079 printf("Please stop port %d first\n", port_id);
5083 if (!strcmp(res->mode, "enable")) {
5084 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5085 printf("Dedicate queues for LACP control packets"
5088 printf("Enabling dedicate queues for LACP control "
5089 "packets on port %d failed\n", port_id);
5090 } else if (!strcmp(res->mode, "disable")) {
5091 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5092 printf("Dedicated queues for LACP control packets "
5095 printf("Disabling dedicated queues for LACP control "
5096 "traffic on port %d failed\n", port_id);
5100 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5101 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5103 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5104 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5105 bonding, "bonding");
5106 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5107 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5109 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5110 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5111 dedicated_queues, "dedicated_queues");
5112 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5113 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5115 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5116 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5117 mode, "enable#disable");
5119 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5120 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5121 .help_str = "set bonding lacp dedicated_queues <port_id> "
5123 "Enable/disable dedicated queues for LACP control traffic for port_id",
5126 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5127 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5128 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5129 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5130 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5131 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5136 /* *** SET BALANCE XMIT POLICY *** */
5137 struct cmd_set_bonding_balance_xmit_policy_result {
5138 cmdline_fixed_string_t set;
5139 cmdline_fixed_string_t bonding;
5140 cmdline_fixed_string_t balance_xmit_policy;
5142 cmdline_fixed_string_t policy;
5145 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5146 __attribute__((unused)) struct cmdline *cl,
5147 __attribute__((unused)) void *data)
5149 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5150 portid_t port_id = res->port_id;
5153 if (!strcmp(res->policy, "l2")) {
5154 policy = BALANCE_XMIT_POLICY_LAYER2;
5155 } else if (!strcmp(res->policy, "l23")) {
5156 policy = BALANCE_XMIT_POLICY_LAYER23;
5157 } else if (!strcmp(res->policy, "l34")) {
5158 policy = BALANCE_XMIT_POLICY_LAYER34;
5160 printf("\t Invalid xmit policy selection");
5164 /* Set the bonding mode for the relevant port. */
5165 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5166 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5171 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5172 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5174 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5175 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5176 bonding, "bonding");
5177 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5178 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5179 balance_xmit_policy, "balance_xmit_policy");
5180 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5181 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5183 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5184 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5185 policy, "l2#l23#l34");
5187 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5188 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5189 .help_str = "set bonding balance_xmit_policy <port_id> "
5191 "Set the bonding balance_xmit_policy for port_id",
5194 (void *)&cmd_setbonding_balance_xmit_policy_set,
5195 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5196 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5197 (void *)&cmd_setbonding_balance_xmit_policy_port,
5198 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5203 /* *** SHOW NIC BONDING CONFIGURATION *** */
5204 struct cmd_show_bonding_config_result {
5205 cmdline_fixed_string_t show;
5206 cmdline_fixed_string_t bonding;
5207 cmdline_fixed_string_t config;
5211 static void cmd_show_bonding_config_parsed(void *parsed_result,
5212 __attribute__((unused)) struct cmdline *cl,
5213 __attribute__((unused)) void *data)
5215 struct cmd_show_bonding_config_result *res = parsed_result;
5216 int bonding_mode, agg_mode;
5217 portid_t slaves[RTE_MAX_ETHPORTS];
5218 int num_slaves, num_active_slaves;
5221 portid_t port_id = res->port_id;
5223 /* Display the bonding mode.*/
5224 bonding_mode = rte_eth_bond_mode_get(port_id);
5225 if (bonding_mode < 0) {
5226 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5229 printf("\tBonding mode: %d\n", bonding_mode);
5231 if (bonding_mode == BONDING_MODE_BALANCE) {
5232 int balance_xmit_policy;
5234 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5235 if (balance_xmit_policy < 0) {
5236 printf("\tFailed to get balance xmit policy for port = %d\n",
5240 printf("\tBalance Xmit Policy: ");
5242 switch (balance_xmit_policy) {
5243 case BALANCE_XMIT_POLICY_LAYER2:
5244 printf("BALANCE_XMIT_POLICY_LAYER2");
5246 case BALANCE_XMIT_POLICY_LAYER23:
5247 printf("BALANCE_XMIT_POLICY_LAYER23");
5249 case BALANCE_XMIT_POLICY_LAYER34:
5250 printf("BALANCE_XMIT_POLICY_LAYER34");
5257 if (bonding_mode == BONDING_MODE_8023AD) {
5258 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5259 printf("\tIEEE802.3AD Aggregator Mode: ");
5262 printf("bandwidth");
5274 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5276 if (num_slaves < 0) {
5277 printf("\tFailed to get slave list for port = %d\n", port_id);
5280 if (num_slaves > 0) {
5281 printf("\tSlaves (%d): [", num_slaves);
5282 for (i = 0; i < num_slaves - 1; i++)
5283 printf("%d ", slaves[i]);
5285 printf("%d]\n", slaves[num_slaves - 1]);
5287 printf("\tSlaves: []\n");
5291 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5294 if (num_active_slaves < 0) {
5295 printf("\tFailed to get active slave list for port = %d\n", port_id);
5298 if (num_active_slaves > 0) {
5299 printf("\tActive Slaves (%d): [", num_active_slaves);
5300 for (i = 0; i < num_active_slaves - 1; i++)
5301 printf("%d ", slaves[i]);
5303 printf("%d]\n", slaves[num_active_slaves - 1]);
5306 printf("\tActive Slaves: []\n");
5310 primary_id = rte_eth_bond_primary_get(port_id);
5311 if (primary_id < 0) {
5312 printf("\tFailed to get primary slave for port = %d\n", port_id);
5315 printf("\tPrimary: [%d]\n", primary_id);
5319 cmdline_parse_token_string_t cmd_showbonding_config_show =
5320 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5322 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5323 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5324 bonding, "bonding");
5325 cmdline_parse_token_string_t cmd_showbonding_config_config =
5326 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5328 cmdline_parse_token_num_t cmd_showbonding_config_port =
5329 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5332 cmdline_parse_inst_t cmd_show_bonding_config = {
5333 .f = cmd_show_bonding_config_parsed,
5334 .help_str = "show bonding config <port_id>: "
5335 "Show the bonding config for port_id",
5338 (void *)&cmd_showbonding_config_show,
5339 (void *)&cmd_showbonding_config_bonding,
5340 (void *)&cmd_showbonding_config_config,
5341 (void *)&cmd_showbonding_config_port,
5346 /* *** SET BONDING PRIMARY *** */
5347 struct cmd_set_bonding_primary_result {
5348 cmdline_fixed_string_t set;
5349 cmdline_fixed_string_t bonding;
5350 cmdline_fixed_string_t primary;
5355 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5356 __attribute__((unused)) struct cmdline *cl,
5357 __attribute__((unused)) void *data)
5359 struct cmd_set_bonding_primary_result *res = parsed_result;
5360 portid_t master_port_id = res->port_id;
5361 portid_t slave_port_id = res->slave_id;
5363 /* Set the primary slave for a bonded device. */
5364 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5365 printf("\t Failed to set primary slave for port = %d.\n",
5372 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5373 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5375 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5376 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5377 bonding, "bonding");
5378 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5379 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5380 primary, "primary");
5381 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5382 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5384 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5385 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5388 cmdline_parse_inst_t cmd_set_bonding_primary = {
5389 .f = cmd_set_bonding_primary_parsed,
5390 .help_str = "set bonding primary <slave_id> <port_id>: "
5391 "Set the primary slave for port_id",
5394 (void *)&cmd_setbonding_primary_set,
5395 (void *)&cmd_setbonding_primary_bonding,
5396 (void *)&cmd_setbonding_primary_primary,
5397 (void *)&cmd_setbonding_primary_slave,
5398 (void *)&cmd_setbonding_primary_port,
5403 /* *** ADD SLAVE *** */
5404 struct cmd_add_bonding_slave_result {
5405 cmdline_fixed_string_t add;
5406 cmdline_fixed_string_t bonding;
5407 cmdline_fixed_string_t slave;
5412 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5413 __attribute__((unused)) struct cmdline *cl,
5414 __attribute__((unused)) void *data)
5416 struct cmd_add_bonding_slave_result *res = parsed_result;
5417 portid_t master_port_id = res->port_id;
5418 portid_t slave_port_id = res->slave_id;
5420 /* add the slave for a bonded device. */
5421 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5422 printf("\t Failed to add slave %d to master port = %d.\n",
5423 slave_port_id, master_port_id);
5427 set_port_slave_flag(slave_port_id);
5430 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5431 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5433 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5434 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5435 bonding, "bonding");
5436 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5437 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5439 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5440 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5442 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5443 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5446 cmdline_parse_inst_t cmd_add_bonding_slave = {
5447 .f = cmd_add_bonding_slave_parsed,
5448 .help_str = "add bonding slave <slave_id> <port_id>: "
5449 "Add a slave device to a bonded device",
5452 (void *)&cmd_addbonding_slave_add,
5453 (void *)&cmd_addbonding_slave_bonding,
5454 (void *)&cmd_addbonding_slave_slave,
5455 (void *)&cmd_addbonding_slave_slaveid,
5456 (void *)&cmd_addbonding_slave_port,
5461 /* *** REMOVE SLAVE *** */
5462 struct cmd_remove_bonding_slave_result {
5463 cmdline_fixed_string_t remove;
5464 cmdline_fixed_string_t bonding;
5465 cmdline_fixed_string_t slave;
5470 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5471 __attribute__((unused)) struct cmdline *cl,
5472 __attribute__((unused)) void *data)
5474 struct cmd_remove_bonding_slave_result *res = parsed_result;
5475 portid_t master_port_id = res->port_id;
5476 portid_t slave_port_id = res->slave_id;
5478 /* remove the slave from a bonded device. */
5479 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5480 printf("\t Failed to remove slave %d from master port = %d.\n",
5481 slave_port_id, master_port_id);
5485 clear_port_slave_flag(slave_port_id);
5488 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5489 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5491 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5492 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5493 bonding, "bonding");
5494 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5495 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5497 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5498 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5500 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5501 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5504 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5505 .f = cmd_remove_bonding_slave_parsed,
5506 .help_str = "remove bonding slave <slave_id> <port_id>: "
5507 "Remove a slave device from a bonded device",
5510 (void *)&cmd_removebonding_slave_remove,
5511 (void *)&cmd_removebonding_slave_bonding,
5512 (void *)&cmd_removebonding_slave_slave,
5513 (void *)&cmd_removebonding_slave_slaveid,
5514 (void *)&cmd_removebonding_slave_port,
5519 /* *** CREATE BONDED DEVICE *** */
5520 struct cmd_create_bonded_device_result {
5521 cmdline_fixed_string_t create;
5522 cmdline_fixed_string_t bonded;
5523 cmdline_fixed_string_t device;
5528 static int bond_dev_num = 0;
5530 static void cmd_create_bonded_device_parsed(void *parsed_result,
5531 __attribute__((unused)) struct cmdline *cl,
5532 __attribute__((unused)) void *data)
5534 struct cmd_create_bonded_device_result *res = parsed_result;
5535 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5538 if (test_done == 0) {
5539 printf("Please stop forwarding first\n");
5543 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5546 /* Create a new bonded device. */
5547 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5549 printf("\t Failed to create bonded device.\n");
5552 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5555 /* Update number of ports */
5556 nb_ports = rte_eth_dev_count_avail();
5557 reconfig(port_id, res->socket);
5558 rte_eth_promiscuous_enable(port_id);
5563 cmdline_parse_token_string_t cmd_createbonded_device_create =
5564 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5566 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5567 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5569 cmdline_parse_token_string_t cmd_createbonded_device_device =
5570 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5572 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5573 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5575 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5576 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5579 cmdline_parse_inst_t cmd_create_bonded_device = {
5580 .f = cmd_create_bonded_device_parsed,
5581 .help_str = "create bonded device <mode> <socket>: "
5582 "Create a new bonded device with specific bonding mode and socket",
5585 (void *)&cmd_createbonded_device_create,
5586 (void *)&cmd_createbonded_device_bonded,
5587 (void *)&cmd_createbonded_device_device,
5588 (void *)&cmd_createbonded_device_mode,
5589 (void *)&cmd_createbonded_device_socket,
5594 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5595 struct cmd_set_bond_mac_addr_result {
5596 cmdline_fixed_string_t set;
5597 cmdline_fixed_string_t bonding;
5598 cmdline_fixed_string_t mac_addr;
5600 struct ether_addr address;
5603 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5604 __attribute__((unused)) struct cmdline *cl,
5605 __attribute__((unused)) void *data)
5607 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5610 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5613 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5615 /* check the return value and print it if is < 0 */
5617 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5620 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5621 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5622 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5623 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5625 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5626 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5628 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5629 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5631 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5632 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5634 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5635 .f = cmd_set_bond_mac_addr_parsed,
5637 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5639 (void *)&cmd_set_bond_mac_addr_set,
5640 (void *)&cmd_set_bond_mac_addr_bonding,
5641 (void *)&cmd_set_bond_mac_addr_mac,
5642 (void *)&cmd_set_bond_mac_addr_portnum,
5643 (void *)&cmd_set_bond_mac_addr_addr,
5649 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5650 struct cmd_set_bond_mon_period_result {
5651 cmdline_fixed_string_t set;
5652 cmdline_fixed_string_t bonding;
5653 cmdline_fixed_string_t mon_period;
5658 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5659 __attribute__((unused)) struct cmdline *cl,
5660 __attribute__((unused)) void *data)
5662 struct cmd_set_bond_mon_period_result *res = parsed_result;
5665 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5667 /* check the return value and print it if is < 0 */
5669 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5672 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5673 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5675 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5676 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5677 bonding, "bonding");
5678 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5679 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5680 mon_period, "mon_period");
5681 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5682 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5684 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5685 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5688 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5689 .f = cmd_set_bond_mon_period_parsed,
5691 .help_str = "set bonding mon_period <port_id> <period_ms>",
5693 (void *)&cmd_set_bond_mon_period_set,
5694 (void *)&cmd_set_bond_mon_period_bonding,
5695 (void *)&cmd_set_bond_mon_period_mon_period,
5696 (void *)&cmd_set_bond_mon_period_portnum,
5697 (void *)&cmd_set_bond_mon_period_period_ms,
5704 struct cmd_set_bonding_agg_mode_policy_result {
5705 cmdline_fixed_string_t set;
5706 cmdline_fixed_string_t bonding;
5707 cmdline_fixed_string_t agg_mode;
5709 cmdline_fixed_string_t policy;
5714 cmd_set_bonding_agg_mode(void *parsed_result,
5715 __attribute__((unused)) struct cmdline *cl,
5716 __attribute__((unused)) void *data)
5718 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5719 uint8_t policy = AGG_BANDWIDTH;
5721 if (!strcmp(res->policy, "bandwidth"))
5722 policy = AGG_BANDWIDTH;
5723 else if (!strcmp(res->policy, "stable"))
5724 policy = AGG_STABLE;
5725 else if (!strcmp(res->policy, "count"))
5728 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5732 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5733 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5735 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5736 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5737 bonding, "bonding");
5739 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5740 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5741 agg_mode, "agg_mode");
5743 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5744 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5747 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5748 TOKEN_STRING_INITIALIZER(
5749 struct cmd_set_bonding_balance_xmit_policy_result,
5750 policy, "stable#bandwidth#count");
5752 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5753 .f = cmd_set_bonding_agg_mode,
5755 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5757 (void *)&cmd_set_bonding_agg_mode_set,
5758 (void *)&cmd_set_bonding_agg_mode_bonding,
5759 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5760 (void *)&cmd_set_bonding_agg_mode_portnum,
5761 (void *)&cmd_set_bonding_agg_mode_policy_string,
5767 #endif /* RTE_LIBRTE_PMD_BOND */
5769 /* *** SET FORWARDING MODE *** */
5770 struct cmd_set_fwd_mode_result {
5771 cmdline_fixed_string_t set;
5772 cmdline_fixed_string_t fwd;
5773 cmdline_fixed_string_t mode;
5776 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5777 __attribute__((unused)) struct cmdline *cl,
5778 __attribute__((unused)) void *data)
5780 struct cmd_set_fwd_mode_result *res = parsed_result;
5783 set_pkt_forwarding_mode(res->mode);
5786 cmdline_parse_token_string_t cmd_setfwd_set =
5787 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5788 cmdline_parse_token_string_t cmd_setfwd_fwd =
5789 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5790 cmdline_parse_token_string_t cmd_setfwd_mode =
5791 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5792 "" /* defined at init */);
5794 cmdline_parse_inst_t cmd_set_fwd_mode = {
5795 .f = cmd_set_fwd_mode_parsed,
5797 .help_str = NULL, /* defined at init */
5799 (void *)&cmd_setfwd_set,
5800 (void *)&cmd_setfwd_fwd,
5801 (void *)&cmd_setfwd_mode,
5806 static void cmd_set_fwd_mode_init(void)
5809 static char token[128];
5810 static char help[256];
5811 cmdline_parse_token_string_t *token_struct;
5813 modes = list_pkt_forwarding_modes();
5814 snprintf(help, sizeof(help), "set fwd %s: "
5815 "Set packet forwarding mode", modes);
5816 cmd_set_fwd_mode.help_str = help;
5818 /* string token separator is # */
5819 for (c = token; *modes != '\0'; modes++)
5824 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5825 token_struct->string_data.str = token;
5828 /* *** SET RETRY FORWARDING MODE *** */
5829 struct cmd_set_fwd_retry_mode_result {
5830 cmdline_fixed_string_t set;
5831 cmdline_fixed_string_t fwd;
5832 cmdline_fixed_string_t mode;
5833 cmdline_fixed_string_t retry;
5836 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5837 __attribute__((unused)) struct cmdline *cl,
5838 __attribute__((unused)) void *data)
5840 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5843 set_pkt_forwarding_mode(res->mode);
5846 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5849 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5852 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5855 "" /* defined at init */);
5856 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5857 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5860 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5861 .f = cmd_set_fwd_retry_mode_parsed,
5863 .help_str = NULL, /* defined at init */
5865 (void *)&cmd_setfwd_retry_set,
5866 (void *)&cmd_setfwd_retry_fwd,
5867 (void *)&cmd_setfwd_retry_mode,
5868 (void *)&cmd_setfwd_retry_retry,
5873 static void cmd_set_fwd_retry_mode_init(void)
5876 static char token[128];
5877 static char help[256];
5878 cmdline_parse_token_string_t *token_struct;
5880 modes = list_pkt_forwarding_retry_modes();
5881 snprintf(help, sizeof(help), "set fwd %s retry: "
5882 "Set packet forwarding mode with retry", modes);
5883 cmd_set_fwd_retry_mode.help_str = help;
5885 /* string token separator is # */
5886 for (c = token; *modes != '\0'; modes++)
5891 token_struct = (cmdline_parse_token_string_t *)
5892 cmd_set_fwd_retry_mode.tokens[2];
5893 token_struct->string_data.str = token;
5896 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5897 struct cmd_set_burst_tx_retry_result {
5898 cmdline_fixed_string_t set;
5899 cmdline_fixed_string_t burst;
5900 cmdline_fixed_string_t tx;
5901 cmdline_fixed_string_t delay;
5903 cmdline_fixed_string_t retry;
5907 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5908 __attribute__((unused)) struct cmdline *cl,
5909 __attribute__((unused)) void *data)
5911 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5913 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5914 && !strcmp(res->tx, "tx")) {
5915 if (!strcmp(res->delay, "delay"))
5916 burst_tx_delay_time = res->time;
5917 if (!strcmp(res->retry, "retry"))
5918 burst_tx_retry_num = res->retry_num;
5923 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5925 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5926 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5928 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5929 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5930 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5932 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5933 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5934 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5935 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5936 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5937 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5939 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5940 .f = cmd_set_burst_tx_retry_parsed,
5941 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5943 (void *)&cmd_set_burst_tx_retry_set,
5944 (void *)&cmd_set_burst_tx_retry_burst,
5945 (void *)&cmd_set_burst_tx_retry_tx,
5946 (void *)&cmd_set_burst_tx_retry_delay,
5947 (void *)&cmd_set_burst_tx_retry_time,
5948 (void *)&cmd_set_burst_tx_retry_retry,
5949 (void *)&cmd_set_burst_tx_retry_retry_num,
5954 /* *** SET PROMISC MODE *** */
5955 struct cmd_set_promisc_mode_result {
5956 cmdline_fixed_string_t set;
5957 cmdline_fixed_string_t promisc;
5958 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5959 uint16_t port_num; /* valid if "allports" argument == 0 */
5960 cmdline_fixed_string_t mode;
5963 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5964 __attribute__((unused)) struct cmdline *cl,
5967 struct cmd_set_promisc_mode_result *res = parsed_result;
5971 if (!strcmp(res->mode, "on"))
5978 RTE_ETH_FOREACH_DEV(i) {
5980 rte_eth_promiscuous_enable(i);
5982 rte_eth_promiscuous_disable(i);
5987 rte_eth_promiscuous_enable(res->port_num);
5989 rte_eth_promiscuous_disable(res->port_num);
5993 cmdline_parse_token_string_t cmd_setpromisc_set =
5994 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5995 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5996 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5998 cmdline_parse_token_string_t cmd_setpromisc_portall =
5999 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6001 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6002 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6004 cmdline_parse_token_string_t cmd_setpromisc_mode =
6005 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6008 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6009 .f = cmd_set_promisc_mode_parsed,
6011 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6013 (void *)&cmd_setpromisc_set,
6014 (void *)&cmd_setpromisc_promisc,
6015 (void *)&cmd_setpromisc_portall,
6016 (void *)&cmd_setpromisc_mode,
6021 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6022 .f = cmd_set_promisc_mode_parsed,
6024 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6026 (void *)&cmd_setpromisc_set,
6027 (void *)&cmd_setpromisc_promisc,
6028 (void *)&cmd_setpromisc_portnum,
6029 (void *)&cmd_setpromisc_mode,
6034 /* *** SET ALLMULTI MODE *** */
6035 struct cmd_set_allmulti_mode_result {
6036 cmdline_fixed_string_t set;
6037 cmdline_fixed_string_t allmulti;
6038 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6039 uint16_t port_num; /* valid if "allports" argument == 0 */
6040 cmdline_fixed_string_t mode;
6043 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6044 __attribute__((unused)) struct cmdline *cl,
6047 struct cmd_set_allmulti_mode_result *res = parsed_result;
6051 if (!strcmp(res->mode, "on"))
6058 RTE_ETH_FOREACH_DEV(i) {
6060 rte_eth_allmulticast_enable(i);
6062 rte_eth_allmulticast_disable(i);
6067 rte_eth_allmulticast_enable(res->port_num);
6069 rte_eth_allmulticast_disable(res->port_num);
6073 cmdline_parse_token_string_t cmd_setallmulti_set =
6074 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6075 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6076 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6078 cmdline_parse_token_string_t cmd_setallmulti_portall =
6079 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6081 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6082 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6084 cmdline_parse_token_string_t cmd_setallmulti_mode =
6085 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6088 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6089 .f = cmd_set_allmulti_mode_parsed,
6091 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6093 (void *)&cmd_setallmulti_set,
6094 (void *)&cmd_setallmulti_allmulti,
6095 (void *)&cmd_setallmulti_portall,
6096 (void *)&cmd_setallmulti_mode,
6101 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6102 .f = cmd_set_allmulti_mode_parsed,
6104 .help_str = "set allmulti <port_id> on|off: "
6105 "Set allmulti mode on port_id",
6107 (void *)&cmd_setallmulti_set,
6108 (void *)&cmd_setallmulti_allmulti,
6109 (void *)&cmd_setallmulti_portnum,
6110 (void *)&cmd_setallmulti_mode,
6115 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6116 struct cmd_link_flow_ctrl_set_result {
6117 cmdline_fixed_string_t set;
6118 cmdline_fixed_string_t flow_ctrl;
6119 cmdline_fixed_string_t rx;
6120 cmdline_fixed_string_t rx_lfc_mode;
6121 cmdline_fixed_string_t tx;
6122 cmdline_fixed_string_t tx_lfc_mode;
6123 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6124 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6125 cmdline_fixed_string_t autoneg_str;
6126 cmdline_fixed_string_t autoneg;
6127 cmdline_fixed_string_t hw_str;
6128 uint32_t high_water;
6129 cmdline_fixed_string_t lw_str;
6131 cmdline_fixed_string_t pt_str;
6132 uint16_t pause_time;
6133 cmdline_fixed_string_t xon_str;
6138 cmdline_parse_token_string_t cmd_lfc_set_set =
6139 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6141 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6142 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6143 flow_ctrl, "flow_ctrl");
6144 cmdline_parse_token_string_t cmd_lfc_set_rx =
6145 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6147 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6148 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6149 rx_lfc_mode, "on#off");
6150 cmdline_parse_token_string_t cmd_lfc_set_tx =
6151 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6153 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6154 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6155 tx_lfc_mode, "on#off");
6156 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6157 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6158 hw_str, "high_water");
6159 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6160 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6161 high_water, UINT32);
6162 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6163 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6164 lw_str, "low_water");
6165 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6166 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6168 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6169 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6170 pt_str, "pause_time");
6171 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6172 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6173 pause_time, UINT16);
6174 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6175 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6176 xon_str, "send_xon");
6177 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6178 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6180 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6181 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6182 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6183 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6184 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6185 mac_ctrl_frame_fwd_mode, "on#off");
6186 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6187 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6188 autoneg_str, "autoneg");
6189 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6190 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6192 cmdline_parse_token_num_t cmd_lfc_set_portid =
6193 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6196 /* forward declaration */
6198 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6201 cmdline_parse_inst_t cmd_link_flow_control_set = {
6202 .f = cmd_link_flow_ctrl_set_parsed,
6204 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6205 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6206 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6208 (void *)&cmd_lfc_set_set,
6209 (void *)&cmd_lfc_set_flow_ctrl,
6210 (void *)&cmd_lfc_set_rx,
6211 (void *)&cmd_lfc_set_rx_mode,
6212 (void *)&cmd_lfc_set_tx,
6213 (void *)&cmd_lfc_set_tx_mode,
6214 (void *)&cmd_lfc_set_high_water,
6215 (void *)&cmd_lfc_set_low_water,
6216 (void *)&cmd_lfc_set_pause_time,
6217 (void *)&cmd_lfc_set_send_xon,
6218 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6219 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6220 (void *)&cmd_lfc_set_autoneg_str,
6221 (void *)&cmd_lfc_set_autoneg,
6222 (void *)&cmd_lfc_set_portid,
6227 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6228 .f = cmd_link_flow_ctrl_set_parsed,
6229 .data = (void *)&cmd_link_flow_control_set_rx,
6230 .help_str = "set flow_ctrl rx on|off <port_id>: "
6231 "Change rx flow control parameter",
6233 (void *)&cmd_lfc_set_set,
6234 (void *)&cmd_lfc_set_flow_ctrl,
6235 (void *)&cmd_lfc_set_rx,
6236 (void *)&cmd_lfc_set_rx_mode,
6237 (void *)&cmd_lfc_set_portid,
6242 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6243 .f = cmd_link_flow_ctrl_set_parsed,
6244 .data = (void *)&cmd_link_flow_control_set_tx,
6245 .help_str = "set flow_ctrl tx on|off <port_id>: "
6246 "Change tx flow control parameter",
6248 (void *)&cmd_lfc_set_set,
6249 (void *)&cmd_lfc_set_flow_ctrl,
6250 (void *)&cmd_lfc_set_tx,
6251 (void *)&cmd_lfc_set_tx_mode,
6252 (void *)&cmd_lfc_set_portid,
6257 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6258 .f = cmd_link_flow_ctrl_set_parsed,
6259 .data = (void *)&cmd_link_flow_control_set_hw,
6260 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6261 "Change high water flow control parameter",
6263 (void *)&cmd_lfc_set_set,
6264 (void *)&cmd_lfc_set_flow_ctrl,
6265 (void *)&cmd_lfc_set_high_water_str,
6266 (void *)&cmd_lfc_set_high_water,
6267 (void *)&cmd_lfc_set_portid,
6272 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6273 .f = cmd_link_flow_ctrl_set_parsed,
6274 .data = (void *)&cmd_link_flow_control_set_lw,
6275 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6276 "Change low water flow control parameter",
6278 (void *)&cmd_lfc_set_set,
6279 (void *)&cmd_lfc_set_flow_ctrl,
6280 (void *)&cmd_lfc_set_low_water_str,
6281 (void *)&cmd_lfc_set_low_water,
6282 (void *)&cmd_lfc_set_portid,
6287 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6288 .f = cmd_link_flow_ctrl_set_parsed,
6289 .data = (void *)&cmd_link_flow_control_set_pt,
6290 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6291 "Change pause time flow control parameter",
6293 (void *)&cmd_lfc_set_set,
6294 (void *)&cmd_lfc_set_flow_ctrl,
6295 (void *)&cmd_lfc_set_pause_time_str,
6296 (void *)&cmd_lfc_set_pause_time,
6297 (void *)&cmd_lfc_set_portid,
6302 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6303 .f = cmd_link_flow_ctrl_set_parsed,
6304 .data = (void *)&cmd_link_flow_control_set_xon,
6305 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6306 "Change send_xon flow control parameter",
6308 (void *)&cmd_lfc_set_set,
6309 (void *)&cmd_lfc_set_flow_ctrl,
6310 (void *)&cmd_lfc_set_send_xon_str,
6311 (void *)&cmd_lfc_set_send_xon,
6312 (void *)&cmd_lfc_set_portid,
6317 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6318 .f = cmd_link_flow_ctrl_set_parsed,
6319 .data = (void *)&cmd_link_flow_control_set_macfwd,
6320 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6321 "Change mac ctrl fwd flow control parameter",
6323 (void *)&cmd_lfc_set_set,
6324 (void *)&cmd_lfc_set_flow_ctrl,
6325 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6326 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6327 (void *)&cmd_lfc_set_portid,
6332 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6333 .f = cmd_link_flow_ctrl_set_parsed,
6334 .data = (void *)&cmd_link_flow_control_set_autoneg,
6335 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6336 "Change autoneg flow control parameter",
6338 (void *)&cmd_lfc_set_set,
6339 (void *)&cmd_lfc_set_flow_ctrl,
6340 (void *)&cmd_lfc_set_autoneg_str,
6341 (void *)&cmd_lfc_set_autoneg,
6342 (void *)&cmd_lfc_set_portid,
6348 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6349 __attribute__((unused)) struct cmdline *cl,
6352 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6353 cmdline_parse_inst_t *cmd = data;
6354 struct rte_eth_fc_conf fc_conf;
6360 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6361 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6362 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6363 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6365 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6366 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6369 /* Partial command line, retrieve current configuration */
6371 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6373 printf("cannot get current flow ctrl parameters, return"
6374 "code = %d\n", ret);
6378 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6379 (fc_conf.mode == RTE_FC_FULL))
6381 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6382 (fc_conf.mode == RTE_FC_FULL))
6386 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6387 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6389 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6390 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6392 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6394 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6395 fc_conf.high_water = res->high_water;
6397 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6398 fc_conf.low_water = res->low_water;
6400 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6401 fc_conf.pause_time = res->pause_time;
6403 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6404 fc_conf.send_xon = res->send_xon;
6406 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6407 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6408 fc_conf.mac_ctrl_frame_fwd = 1;
6410 fc_conf.mac_ctrl_frame_fwd = 0;
6413 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6414 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6416 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6418 printf("bad flow contrl parameter, return code = %d \n", ret);
6421 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6422 struct cmd_priority_flow_ctrl_set_result {
6423 cmdline_fixed_string_t set;
6424 cmdline_fixed_string_t pfc_ctrl;
6425 cmdline_fixed_string_t rx;
6426 cmdline_fixed_string_t rx_pfc_mode;
6427 cmdline_fixed_string_t tx;
6428 cmdline_fixed_string_t tx_pfc_mode;
6429 uint32_t high_water;
6431 uint16_t pause_time;
6437 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6438 __attribute__((unused)) struct cmdline *cl,
6439 __attribute__((unused)) void *data)
6441 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6442 struct rte_eth_pfc_conf pfc_conf;
6443 int rx_fc_enable, tx_fc_enable;
6447 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6448 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6449 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6450 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6452 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6453 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6456 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6457 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6458 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6459 pfc_conf.fc.high_water = res->high_water;
6460 pfc_conf.fc.low_water = res->low_water;
6461 pfc_conf.fc.pause_time = res->pause_time;
6462 pfc_conf.priority = res->priority;
6464 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6466 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6469 cmdline_parse_token_string_t cmd_pfc_set_set =
6470 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6472 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6473 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6474 pfc_ctrl, "pfc_ctrl");
6475 cmdline_parse_token_string_t cmd_pfc_set_rx =
6476 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6478 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6479 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6480 rx_pfc_mode, "on#off");
6481 cmdline_parse_token_string_t cmd_pfc_set_tx =
6482 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6484 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6485 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6486 tx_pfc_mode, "on#off");
6487 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6488 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6489 high_water, UINT32);
6490 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6491 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6493 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6494 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6495 pause_time, UINT16);
6496 cmdline_parse_token_num_t cmd_pfc_set_priority =
6497 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6499 cmdline_parse_token_num_t cmd_pfc_set_portid =
6500 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6503 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6504 .f = cmd_priority_flow_ctrl_set_parsed,
6506 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6507 "<pause_time> <priority> <port_id>: "
6508 "Configure the Ethernet priority flow control",
6510 (void *)&cmd_pfc_set_set,
6511 (void *)&cmd_pfc_set_flow_ctrl,
6512 (void *)&cmd_pfc_set_rx,
6513 (void *)&cmd_pfc_set_rx_mode,
6514 (void *)&cmd_pfc_set_tx,
6515 (void *)&cmd_pfc_set_tx_mode,
6516 (void *)&cmd_pfc_set_high_water,
6517 (void *)&cmd_pfc_set_low_water,
6518 (void *)&cmd_pfc_set_pause_time,
6519 (void *)&cmd_pfc_set_priority,
6520 (void *)&cmd_pfc_set_portid,
6525 /* *** RESET CONFIGURATION *** */
6526 struct cmd_reset_result {
6527 cmdline_fixed_string_t reset;
6528 cmdline_fixed_string_t def;
6531 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6533 __attribute__((unused)) void *data)
6535 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6536 set_def_fwd_config();
6539 cmdline_parse_token_string_t cmd_reset_set =
6540 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6541 cmdline_parse_token_string_t cmd_reset_def =
6542 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6545 cmdline_parse_inst_t cmd_reset = {
6546 .f = cmd_reset_parsed,
6548 .help_str = "set default: Reset default forwarding configuration",
6550 (void *)&cmd_reset_set,
6551 (void *)&cmd_reset_def,
6556 /* *** START FORWARDING *** */
6557 struct cmd_start_result {
6558 cmdline_fixed_string_t start;
6561 cmdline_parse_token_string_t cmd_start_start =
6562 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6564 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6565 __attribute__((unused)) struct cmdline *cl,
6566 __attribute__((unused)) void *data)
6568 start_packet_forwarding(0);
6571 cmdline_parse_inst_t cmd_start = {
6572 .f = cmd_start_parsed,
6574 .help_str = "start: Start packet forwarding",
6576 (void *)&cmd_start_start,
6581 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6582 struct cmd_start_tx_first_result {
6583 cmdline_fixed_string_t start;
6584 cmdline_fixed_string_t tx_first;
6588 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6589 __attribute__((unused)) struct cmdline *cl,
6590 __attribute__((unused)) void *data)
6592 start_packet_forwarding(1);
6595 cmdline_parse_token_string_t cmd_start_tx_first_start =
6596 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6598 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6599 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6600 tx_first, "tx_first");
6602 cmdline_parse_inst_t cmd_start_tx_first = {
6603 .f = cmd_start_tx_first_parsed,
6605 .help_str = "start tx_first: Start packet forwarding, "
6606 "after sending 1 burst of packets",
6608 (void *)&cmd_start_tx_first_start,
6609 (void *)&cmd_start_tx_first_tx_first,
6614 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6615 struct cmd_start_tx_first_n_result {
6616 cmdline_fixed_string_t start;
6617 cmdline_fixed_string_t tx_first;
6622 cmd_start_tx_first_n_parsed(void *parsed_result,
6623 __attribute__((unused)) struct cmdline *cl,
6624 __attribute__((unused)) void *data)
6626 struct cmd_start_tx_first_n_result *res = parsed_result;
6628 start_packet_forwarding(res->tx_num);
6631 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6632 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6634 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6635 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6636 tx_first, "tx_first");
6637 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6638 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6641 cmdline_parse_inst_t cmd_start_tx_first_n = {
6642 .f = cmd_start_tx_first_n_parsed,
6644 .help_str = "start tx_first <num>: "
6645 "packet forwarding, after sending <num> bursts of packets",
6647 (void *)&cmd_start_tx_first_n_start,
6648 (void *)&cmd_start_tx_first_n_tx_first,
6649 (void *)&cmd_start_tx_first_n_tx_num,
6654 /* *** SET LINK UP *** */
6655 struct cmd_set_link_up_result {
6656 cmdline_fixed_string_t set;
6657 cmdline_fixed_string_t link_up;
6658 cmdline_fixed_string_t port;
6662 cmdline_parse_token_string_t cmd_set_link_up_set =
6663 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6664 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6665 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6667 cmdline_parse_token_string_t cmd_set_link_up_port =
6668 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6669 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6670 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6672 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6673 __attribute__((unused)) struct cmdline *cl,
6674 __attribute__((unused)) void *data)
6676 struct cmd_set_link_up_result *res = parsed_result;
6677 dev_set_link_up(res->port_id);
6680 cmdline_parse_inst_t cmd_set_link_up = {
6681 .f = cmd_set_link_up_parsed,
6683 .help_str = "set link-up port <port id>",
6685 (void *)&cmd_set_link_up_set,
6686 (void *)&cmd_set_link_up_link_up,
6687 (void *)&cmd_set_link_up_port,
6688 (void *)&cmd_set_link_up_port_id,
6693 /* *** SET LINK DOWN *** */
6694 struct cmd_set_link_down_result {
6695 cmdline_fixed_string_t set;
6696 cmdline_fixed_string_t link_down;
6697 cmdline_fixed_string_t port;
6701 cmdline_parse_token_string_t cmd_set_link_down_set =
6702 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6703 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6704 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6706 cmdline_parse_token_string_t cmd_set_link_down_port =
6707 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6708 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6709 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6711 static void cmd_set_link_down_parsed(
6712 __attribute__((unused)) void *parsed_result,
6713 __attribute__((unused)) struct cmdline *cl,
6714 __attribute__((unused)) void *data)
6716 struct cmd_set_link_down_result *res = parsed_result;
6717 dev_set_link_down(res->port_id);
6720 cmdline_parse_inst_t cmd_set_link_down = {
6721 .f = cmd_set_link_down_parsed,
6723 .help_str = "set link-down port <port id>",
6725 (void *)&cmd_set_link_down_set,
6726 (void *)&cmd_set_link_down_link_down,
6727 (void *)&cmd_set_link_down_port,
6728 (void *)&cmd_set_link_down_port_id,
6733 /* *** SHOW CFG *** */
6734 struct cmd_showcfg_result {
6735 cmdline_fixed_string_t show;
6736 cmdline_fixed_string_t cfg;
6737 cmdline_fixed_string_t what;
6740 static void cmd_showcfg_parsed(void *parsed_result,
6741 __attribute__((unused)) struct cmdline *cl,
6742 __attribute__((unused)) void *data)
6744 struct cmd_showcfg_result *res = parsed_result;
6745 if (!strcmp(res->what, "rxtx"))
6746 rxtx_config_display();
6747 else if (!strcmp(res->what, "cores"))
6748 fwd_lcores_config_display();
6749 else if (!strcmp(res->what, "fwd"))
6750 pkt_fwd_config_display(&cur_fwd_config);
6751 else if (!strcmp(res->what, "txpkts"))
6752 show_tx_pkt_segments();
6755 cmdline_parse_token_string_t cmd_showcfg_show =
6756 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6757 cmdline_parse_token_string_t cmd_showcfg_port =
6758 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6759 cmdline_parse_token_string_t cmd_showcfg_what =
6760 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6761 "rxtx#cores#fwd#txpkts");
6763 cmdline_parse_inst_t cmd_showcfg = {
6764 .f = cmd_showcfg_parsed,
6766 .help_str = "show config rxtx|cores|fwd|txpkts",
6768 (void *)&cmd_showcfg_show,
6769 (void *)&cmd_showcfg_port,
6770 (void *)&cmd_showcfg_what,
6775 /* *** SHOW ALL PORT INFO *** */
6776 struct cmd_showportall_result {
6777 cmdline_fixed_string_t show;
6778 cmdline_fixed_string_t port;
6779 cmdline_fixed_string_t what;
6780 cmdline_fixed_string_t all;
6783 static void cmd_showportall_parsed(void *parsed_result,
6784 __attribute__((unused)) struct cmdline *cl,
6785 __attribute__((unused)) void *data)
6789 struct cmd_showportall_result *res = parsed_result;
6790 if (!strcmp(res->show, "clear")) {
6791 if (!strcmp(res->what, "stats"))
6792 RTE_ETH_FOREACH_DEV(i)
6794 else if (!strcmp(res->what, "xstats"))
6795 RTE_ETH_FOREACH_DEV(i)
6796 nic_xstats_clear(i);
6797 } else if (!strcmp(res->what, "info"))
6798 RTE_ETH_FOREACH_DEV(i)
6799 port_infos_display(i);
6800 else if (!strcmp(res->what, "stats"))
6801 RTE_ETH_FOREACH_DEV(i)
6802 nic_stats_display(i);
6803 else if (!strcmp(res->what, "xstats"))
6804 RTE_ETH_FOREACH_DEV(i)
6805 nic_xstats_display(i);
6806 else if (!strcmp(res->what, "fdir"))
6807 RTE_ETH_FOREACH_DEV(i)
6809 else if (!strcmp(res->what, "stat_qmap"))
6810 RTE_ETH_FOREACH_DEV(i)
6811 nic_stats_mapping_display(i);
6812 else if (!strcmp(res->what, "dcb_tc"))
6813 RTE_ETH_FOREACH_DEV(i)
6814 port_dcb_info_display(i);
6815 else if (!strcmp(res->what, "cap"))
6816 RTE_ETH_FOREACH_DEV(i)
6817 port_offload_cap_display(i);
6820 cmdline_parse_token_string_t cmd_showportall_show =
6821 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6823 cmdline_parse_token_string_t cmd_showportall_port =
6824 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6825 cmdline_parse_token_string_t cmd_showportall_what =
6826 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6827 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6828 cmdline_parse_token_string_t cmd_showportall_all =
6829 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6830 cmdline_parse_inst_t cmd_showportall = {
6831 .f = cmd_showportall_parsed,
6833 .help_str = "show|clear port "
6834 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6836 (void *)&cmd_showportall_show,
6837 (void *)&cmd_showportall_port,
6838 (void *)&cmd_showportall_what,
6839 (void *)&cmd_showportall_all,
6844 /* *** SHOW PORT INFO *** */
6845 struct cmd_showport_result {
6846 cmdline_fixed_string_t show;
6847 cmdline_fixed_string_t port;
6848 cmdline_fixed_string_t what;
6852 static void cmd_showport_parsed(void *parsed_result,
6853 __attribute__((unused)) struct cmdline *cl,
6854 __attribute__((unused)) void *data)
6856 struct cmd_showport_result *res = parsed_result;
6857 if (!strcmp(res->show, "clear")) {
6858 if (!strcmp(res->what, "stats"))
6859 nic_stats_clear(res->portnum);
6860 else if (!strcmp(res->what, "xstats"))
6861 nic_xstats_clear(res->portnum);
6862 } else if (!strcmp(res->what, "info"))
6863 port_infos_display(res->portnum);
6864 else if (!strcmp(res->what, "stats"))
6865 nic_stats_display(res->portnum);
6866 else if (!strcmp(res->what, "xstats"))
6867 nic_xstats_display(res->portnum);
6868 else if (!strcmp(res->what, "fdir"))
6869 fdir_get_infos(res->portnum);
6870 else if (!strcmp(res->what, "stat_qmap"))
6871 nic_stats_mapping_display(res->portnum);
6872 else if (!strcmp(res->what, "dcb_tc"))
6873 port_dcb_info_display(res->portnum);
6874 else if (!strcmp(res->what, "cap"))
6875 port_offload_cap_display(res->portnum);
6878 cmdline_parse_token_string_t cmd_showport_show =
6879 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6881 cmdline_parse_token_string_t cmd_showport_port =
6882 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6883 cmdline_parse_token_string_t cmd_showport_what =
6884 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6885 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6886 cmdline_parse_token_num_t cmd_showport_portnum =
6887 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6889 cmdline_parse_inst_t cmd_showport = {
6890 .f = cmd_showport_parsed,
6892 .help_str = "show|clear port "
6893 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6896 (void *)&cmd_showport_show,
6897 (void *)&cmd_showport_port,
6898 (void *)&cmd_showport_what,
6899 (void *)&cmd_showport_portnum,
6904 /* *** SHOW QUEUE INFO *** */
6905 struct cmd_showqueue_result {
6906 cmdline_fixed_string_t show;
6907 cmdline_fixed_string_t type;
6908 cmdline_fixed_string_t what;
6914 cmd_showqueue_parsed(void *parsed_result,
6915 __attribute__((unused)) struct cmdline *cl,
6916 __attribute__((unused)) void *data)
6918 struct cmd_showqueue_result *res = parsed_result;
6920 if (!strcmp(res->type, "rxq"))
6921 rx_queue_infos_display(res->portnum, res->queuenum);
6922 else if (!strcmp(res->type, "txq"))
6923 tx_queue_infos_display(res->portnum, res->queuenum);
6926 cmdline_parse_token_string_t cmd_showqueue_show =
6927 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6928 cmdline_parse_token_string_t cmd_showqueue_type =
6929 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6930 cmdline_parse_token_string_t cmd_showqueue_what =
6931 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6932 cmdline_parse_token_num_t cmd_showqueue_portnum =
6933 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6934 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6935 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6937 cmdline_parse_inst_t cmd_showqueue = {
6938 .f = cmd_showqueue_parsed,
6940 .help_str = "show rxq|txq info <port_id> <queue_id>",
6942 (void *)&cmd_showqueue_show,
6943 (void *)&cmd_showqueue_type,
6944 (void *)&cmd_showqueue_what,
6945 (void *)&cmd_showqueue_portnum,
6946 (void *)&cmd_showqueue_queuenum,
6951 /* *** READ PORT REGISTER *** */
6952 struct cmd_read_reg_result {
6953 cmdline_fixed_string_t read;
6954 cmdline_fixed_string_t reg;
6960 cmd_read_reg_parsed(void *parsed_result,
6961 __attribute__((unused)) struct cmdline *cl,
6962 __attribute__((unused)) void *data)
6964 struct cmd_read_reg_result *res = parsed_result;
6965 port_reg_display(res->port_id, res->reg_off);
6968 cmdline_parse_token_string_t cmd_read_reg_read =
6969 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6970 cmdline_parse_token_string_t cmd_read_reg_reg =
6971 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6972 cmdline_parse_token_num_t cmd_read_reg_port_id =
6973 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6974 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6975 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6977 cmdline_parse_inst_t cmd_read_reg = {
6978 .f = cmd_read_reg_parsed,
6980 .help_str = "read reg <port_id> <reg_off>",
6982 (void *)&cmd_read_reg_read,
6983 (void *)&cmd_read_reg_reg,
6984 (void *)&cmd_read_reg_port_id,
6985 (void *)&cmd_read_reg_reg_off,
6990 /* *** READ PORT REGISTER BIT FIELD *** */
6991 struct cmd_read_reg_bit_field_result {
6992 cmdline_fixed_string_t read;
6993 cmdline_fixed_string_t regfield;
7001 cmd_read_reg_bit_field_parsed(void *parsed_result,
7002 __attribute__((unused)) struct cmdline *cl,
7003 __attribute__((unused)) void *data)
7005 struct cmd_read_reg_bit_field_result *res = parsed_result;
7006 port_reg_bit_field_display(res->port_id, res->reg_off,
7007 res->bit1_pos, res->bit2_pos);
7010 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7011 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7013 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7014 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7015 regfield, "regfield");
7016 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7017 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7019 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7020 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7022 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7023 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7025 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7026 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7029 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7030 .f = cmd_read_reg_bit_field_parsed,
7032 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7033 "Read register bit field between bit_x and bit_y included",
7035 (void *)&cmd_read_reg_bit_field_read,
7036 (void *)&cmd_read_reg_bit_field_regfield,
7037 (void *)&cmd_read_reg_bit_field_port_id,
7038 (void *)&cmd_read_reg_bit_field_reg_off,
7039 (void *)&cmd_read_reg_bit_field_bit1_pos,
7040 (void *)&cmd_read_reg_bit_field_bit2_pos,
7045 /* *** READ PORT REGISTER BIT *** */
7046 struct cmd_read_reg_bit_result {
7047 cmdline_fixed_string_t read;
7048 cmdline_fixed_string_t regbit;
7055 cmd_read_reg_bit_parsed(void *parsed_result,
7056 __attribute__((unused)) struct cmdline *cl,
7057 __attribute__((unused)) void *data)
7059 struct cmd_read_reg_bit_result *res = parsed_result;
7060 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7063 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7064 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7065 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7066 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7068 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7069 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7070 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7071 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7072 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7073 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7075 cmdline_parse_inst_t cmd_read_reg_bit = {
7076 .f = cmd_read_reg_bit_parsed,
7078 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7080 (void *)&cmd_read_reg_bit_read,
7081 (void *)&cmd_read_reg_bit_regbit,
7082 (void *)&cmd_read_reg_bit_port_id,
7083 (void *)&cmd_read_reg_bit_reg_off,
7084 (void *)&cmd_read_reg_bit_bit_pos,
7089 /* *** WRITE PORT REGISTER *** */
7090 struct cmd_write_reg_result {
7091 cmdline_fixed_string_t write;
7092 cmdline_fixed_string_t reg;
7099 cmd_write_reg_parsed(void *parsed_result,
7100 __attribute__((unused)) struct cmdline *cl,
7101 __attribute__((unused)) void *data)
7103 struct cmd_write_reg_result *res = parsed_result;
7104 port_reg_set(res->port_id, res->reg_off, res->value);
7107 cmdline_parse_token_string_t cmd_write_reg_write =
7108 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7109 cmdline_parse_token_string_t cmd_write_reg_reg =
7110 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7111 cmdline_parse_token_num_t cmd_write_reg_port_id =
7112 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7113 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7114 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7115 cmdline_parse_token_num_t cmd_write_reg_value =
7116 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7118 cmdline_parse_inst_t cmd_write_reg = {
7119 .f = cmd_write_reg_parsed,
7121 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7123 (void *)&cmd_write_reg_write,
7124 (void *)&cmd_write_reg_reg,
7125 (void *)&cmd_write_reg_port_id,
7126 (void *)&cmd_write_reg_reg_off,
7127 (void *)&cmd_write_reg_value,
7132 /* *** WRITE PORT REGISTER BIT FIELD *** */
7133 struct cmd_write_reg_bit_field_result {
7134 cmdline_fixed_string_t write;
7135 cmdline_fixed_string_t regfield;
7144 cmd_write_reg_bit_field_parsed(void *parsed_result,
7145 __attribute__((unused)) struct cmdline *cl,
7146 __attribute__((unused)) void *data)
7148 struct cmd_write_reg_bit_field_result *res = parsed_result;
7149 port_reg_bit_field_set(res->port_id, res->reg_off,
7150 res->bit1_pos, res->bit2_pos, res->value);
7153 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7154 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7156 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7157 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7158 regfield, "regfield");
7159 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7160 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7162 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7163 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7165 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7166 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7168 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7169 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7171 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7172 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7175 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7176 .f = cmd_write_reg_bit_field_parsed,
7178 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7180 "Set register bit field between bit_x and bit_y included",
7182 (void *)&cmd_write_reg_bit_field_write,
7183 (void *)&cmd_write_reg_bit_field_regfield,
7184 (void *)&cmd_write_reg_bit_field_port_id,
7185 (void *)&cmd_write_reg_bit_field_reg_off,
7186 (void *)&cmd_write_reg_bit_field_bit1_pos,
7187 (void *)&cmd_write_reg_bit_field_bit2_pos,
7188 (void *)&cmd_write_reg_bit_field_value,
7193 /* *** WRITE PORT REGISTER BIT *** */
7194 struct cmd_write_reg_bit_result {
7195 cmdline_fixed_string_t write;
7196 cmdline_fixed_string_t regbit;
7204 cmd_write_reg_bit_parsed(void *parsed_result,
7205 __attribute__((unused)) struct cmdline *cl,
7206 __attribute__((unused)) void *data)
7208 struct cmd_write_reg_bit_result *res = parsed_result;
7209 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7212 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7213 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7215 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7216 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7218 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7219 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7220 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7221 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7222 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7223 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7224 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7225 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7227 cmdline_parse_inst_t cmd_write_reg_bit = {
7228 .f = cmd_write_reg_bit_parsed,
7230 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7233 (void *)&cmd_write_reg_bit_write,
7234 (void *)&cmd_write_reg_bit_regbit,
7235 (void *)&cmd_write_reg_bit_port_id,
7236 (void *)&cmd_write_reg_bit_reg_off,
7237 (void *)&cmd_write_reg_bit_bit_pos,
7238 (void *)&cmd_write_reg_bit_value,
7243 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7244 struct cmd_read_rxd_txd_result {
7245 cmdline_fixed_string_t read;
7246 cmdline_fixed_string_t rxd_txd;
7253 cmd_read_rxd_txd_parsed(void *parsed_result,
7254 __attribute__((unused)) struct cmdline *cl,
7255 __attribute__((unused)) void *data)
7257 struct cmd_read_rxd_txd_result *res = parsed_result;
7259 if (!strcmp(res->rxd_txd, "rxd"))
7260 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7261 else if (!strcmp(res->rxd_txd, "txd"))
7262 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7265 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7266 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7267 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7268 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7270 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7271 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7272 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7273 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7274 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7275 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7277 cmdline_parse_inst_t cmd_read_rxd_txd = {
7278 .f = cmd_read_rxd_txd_parsed,
7280 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7282 (void *)&cmd_read_rxd_txd_read,
7283 (void *)&cmd_read_rxd_txd_rxd_txd,
7284 (void *)&cmd_read_rxd_txd_port_id,
7285 (void *)&cmd_read_rxd_txd_queue_id,
7286 (void *)&cmd_read_rxd_txd_desc_id,
7292 struct cmd_quit_result {
7293 cmdline_fixed_string_t quit;
7296 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7298 __attribute__((unused)) void *data)
7304 cmdline_parse_token_string_t cmd_quit_quit =
7305 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7307 cmdline_parse_inst_t cmd_quit = {
7308 .f = cmd_quit_parsed,
7310 .help_str = "quit: Exit application",
7312 (void *)&cmd_quit_quit,
7317 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7318 struct cmd_mac_addr_result {
7319 cmdline_fixed_string_t mac_addr_cmd;
7320 cmdline_fixed_string_t what;
7322 struct ether_addr address;
7325 static void cmd_mac_addr_parsed(void *parsed_result,
7326 __attribute__((unused)) struct cmdline *cl,
7327 __attribute__((unused)) void *data)
7329 struct cmd_mac_addr_result *res = parsed_result;
7332 if (strcmp(res->what, "add") == 0)
7333 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7334 else if (strcmp(res->what, "set") == 0)
7335 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7338 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7340 /* check the return value and print it if is < 0 */
7342 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7346 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7347 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7349 cmdline_parse_token_string_t cmd_mac_addr_what =
7350 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7352 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7353 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7355 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7356 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7358 cmdline_parse_inst_t cmd_mac_addr = {
7359 .f = cmd_mac_addr_parsed,
7361 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7362 "Add/Remove/Set MAC address on port_id",
7364 (void *)&cmd_mac_addr_cmd,
7365 (void *)&cmd_mac_addr_what,
7366 (void *)&cmd_mac_addr_portnum,
7367 (void *)&cmd_mac_addr_addr,
7372 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7373 struct cmd_eth_peer_result {
7374 cmdline_fixed_string_t set;
7375 cmdline_fixed_string_t eth_peer;
7377 cmdline_fixed_string_t peer_addr;
7380 static void cmd_set_eth_peer_parsed(void *parsed_result,
7381 __attribute__((unused)) struct cmdline *cl,
7382 __attribute__((unused)) void *data)
7384 struct cmd_eth_peer_result *res = parsed_result;
7386 if (test_done == 0) {
7387 printf("Please stop forwarding first\n");
7390 if (!strcmp(res->eth_peer, "eth-peer")) {
7391 set_fwd_eth_peer(res->port_id, res->peer_addr);
7395 cmdline_parse_token_string_t cmd_eth_peer_set =
7396 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7397 cmdline_parse_token_string_t cmd_eth_peer =
7398 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7399 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7400 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7401 cmdline_parse_token_string_t cmd_eth_peer_addr =
7402 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7404 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7405 .f = cmd_set_eth_peer_parsed,
7407 .help_str = "set eth-peer <port_id> <peer_mac>",
7409 (void *)&cmd_eth_peer_set,
7410 (void *)&cmd_eth_peer,
7411 (void *)&cmd_eth_peer_port_id,
7412 (void *)&cmd_eth_peer_addr,
7417 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7418 struct cmd_set_qmap_result {
7419 cmdline_fixed_string_t set;
7420 cmdline_fixed_string_t qmap;
7421 cmdline_fixed_string_t what;
7428 cmd_set_qmap_parsed(void *parsed_result,
7429 __attribute__((unused)) struct cmdline *cl,
7430 __attribute__((unused)) void *data)
7432 struct cmd_set_qmap_result *res = parsed_result;
7433 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7435 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7438 cmdline_parse_token_string_t cmd_setqmap_set =
7439 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7441 cmdline_parse_token_string_t cmd_setqmap_qmap =
7442 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7444 cmdline_parse_token_string_t cmd_setqmap_what =
7445 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7447 cmdline_parse_token_num_t cmd_setqmap_portid =
7448 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7450 cmdline_parse_token_num_t cmd_setqmap_queueid =
7451 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7453 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7454 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7457 cmdline_parse_inst_t cmd_set_qmap = {
7458 .f = cmd_set_qmap_parsed,
7460 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7461 "Set statistics mapping value on tx|rx queue_id of port_id",
7463 (void *)&cmd_setqmap_set,
7464 (void *)&cmd_setqmap_qmap,
7465 (void *)&cmd_setqmap_what,
7466 (void *)&cmd_setqmap_portid,
7467 (void *)&cmd_setqmap_queueid,
7468 (void *)&cmd_setqmap_mapvalue,
7473 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7474 struct cmd_set_xstats_hide_zero_result {
7475 cmdline_fixed_string_t keyword;
7476 cmdline_fixed_string_t name;
7477 cmdline_fixed_string_t on_off;
7481 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7482 __attribute__((unused)) struct cmdline *cl,
7483 __attribute__((unused)) void *data)
7485 struct cmd_set_xstats_hide_zero_result *res;
7486 uint16_t on_off = 0;
7488 res = parsed_result;
7489 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7490 set_xstats_hide_zero(on_off);
7493 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7494 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7496 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7497 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7498 name, "xstats-hide-zero");
7499 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7500 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7503 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7504 .f = cmd_set_xstats_hide_zero_parsed,
7506 .help_str = "set xstats-hide-zero on|off",
7508 (void *)&cmd_set_xstats_hide_zero_keyword,
7509 (void *)&cmd_set_xstats_hide_zero_name,
7510 (void *)&cmd_set_xstats_hide_zero_on_off,
7515 /* *** CONFIGURE UNICAST HASH TABLE *** */
7516 struct cmd_set_uc_hash_table {
7517 cmdline_fixed_string_t set;
7518 cmdline_fixed_string_t port;
7520 cmdline_fixed_string_t what;
7521 struct ether_addr address;
7522 cmdline_fixed_string_t mode;
7526 cmd_set_uc_hash_parsed(void *parsed_result,
7527 __attribute__((unused)) struct cmdline *cl,
7528 __attribute__((unused)) void *data)
7531 struct cmd_set_uc_hash_table *res = parsed_result;
7533 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7535 if (strcmp(res->what, "uta") == 0)
7536 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7537 &res->address,(uint8_t)is_on);
7539 printf("bad unicast hash table parameter, return code = %d \n", ret);
7543 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7544 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7546 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7547 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7549 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7550 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7552 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7553 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7555 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7556 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7558 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7559 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7562 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7563 .f = cmd_set_uc_hash_parsed,
7565 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7567 (void *)&cmd_set_uc_hash_set,
7568 (void *)&cmd_set_uc_hash_port,
7569 (void *)&cmd_set_uc_hash_portid,
7570 (void *)&cmd_set_uc_hash_what,
7571 (void *)&cmd_set_uc_hash_mac,
7572 (void *)&cmd_set_uc_hash_mode,
7577 struct cmd_set_uc_all_hash_table {
7578 cmdline_fixed_string_t set;
7579 cmdline_fixed_string_t port;
7581 cmdline_fixed_string_t what;
7582 cmdline_fixed_string_t value;
7583 cmdline_fixed_string_t mode;
7587 cmd_set_uc_all_hash_parsed(void *parsed_result,
7588 __attribute__((unused)) struct cmdline *cl,
7589 __attribute__((unused)) void *data)
7592 struct cmd_set_uc_all_hash_table *res = parsed_result;
7594 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7596 if ((strcmp(res->what, "uta") == 0) &&
7597 (strcmp(res->value, "all") == 0))
7598 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7600 printf("bad unicast hash table parameter,"
7601 "return code = %d \n", ret);
7604 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7605 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7607 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7608 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7610 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7611 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7613 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7614 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7616 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7617 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7619 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7620 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7623 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7624 .f = cmd_set_uc_all_hash_parsed,
7626 .help_str = "set port <port_id> uta all on|off",
7628 (void *)&cmd_set_uc_all_hash_set,
7629 (void *)&cmd_set_uc_all_hash_port,
7630 (void *)&cmd_set_uc_all_hash_portid,
7631 (void *)&cmd_set_uc_all_hash_what,
7632 (void *)&cmd_set_uc_all_hash_value,
7633 (void *)&cmd_set_uc_all_hash_mode,
7638 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7639 struct cmd_set_vf_macvlan_filter {
7640 cmdline_fixed_string_t set;
7641 cmdline_fixed_string_t port;
7643 cmdline_fixed_string_t vf;
7645 struct ether_addr address;
7646 cmdline_fixed_string_t filter_type;
7647 cmdline_fixed_string_t mode;
7651 cmd_set_vf_macvlan_parsed(void *parsed_result,
7652 __attribute__((unused)) struct cmdline *cl,
7653 __attribute__((unused)) void *data)
7656 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7657 struct rte_eth_mac_filter filter;
7659 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7661 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7663 /* set VF MAC filter */
7667 filter.dst_id = res->vf_id;
7669 if (!strcmp(res->filter_type, "exact-mac"))
7670 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7671 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7672 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7673 else if (!strcmp(res->filter_type, "hashmac"))
7674 filter.filter_type = RTE_MAC_HASH_MATCH;
7675 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7676 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7678 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7681 ret = rte_eth_dev_filter_ctrl(res->port_id,
7682 RTE_ETH_FILTER_MACVLAN,
7686 ret = rte_eth_dev_filter_ctrl(res->port_id,
7687 RTE_ETH_FILTER_MACVLAN,
7688 RTE_ETH_FILTER_DELETE,
7692 printf("bad set MAC hash parameter, return code = %d\n", ret);
7696 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7697 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7699 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7700 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7702 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7703 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7705 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7706 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7708 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7709 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7711 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7712 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7714 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7715 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7716 filter_type, "exact-mac#exact-mac-vlan"
7717 "#hashmac#hashmac-vlan");
7718 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7719 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7722 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7723 .f = cmd_set_vf_macvlan_parsed,
7725 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7726 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7727 "Exact match rule: exact match of MAC or MAC and VLAN; "
7728 "hash match rule: hash match of MAC and exact match of VLAN",
7730 (void *)&cmd_set_vf_macvlan_set,
7731 (void *)&cmd_set_vf_macvlan_port,
7732 (void *)&cmd_set_vf_macvlan_portid,
7733 (void *)&cmd_set_vf_macvlan_vf,
7734 (void *)&cmd_set_vf_macvlan_vf_id,
7735 (void *)&cmd_set_vf_macvlan_mac,
7736 (void *)&cmd_set_vf_macvlan_filter_type,
7737 (void *)&cmd_set_vf_macvlan_mode,
7742 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7743 struct cmd_set_vf_traffic {
7744 cmdline_fixed_string_t set;
7745 cmdline_fixed_string_t port;
7747 cmdline_fixed_string_t vf;
7749 cmdline_fixed_string_t what;
7750 cmdline_fixed_string_t mode;
7754 cmd_set_vf_traffic_parsed(void *parsed_result,
7755 __attribute__((unused)) struct cmdline *cl,
7756 __attribute__((unused)) void *data)
7758 struct cmd_set_vf_traffic *res = parsed_result;
7759 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7760 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7762 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7765 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7766 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7768 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7769 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7771 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7772 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7774 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7775 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7777 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7778 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7780 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7781 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7783 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7784 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7787 cmdline_parse_inst_t cmd_set_vf_traffic = {
7788 .f = cmd_set_vf_traffic_parsed,
7790 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7792 (void *)&cmd_setvf_traffic_set,
7793 (void *)&cmd_setvf_traffic_port,
7794 (void *)&cmd_setvf_traffic_portid,
7795 (void *)&cmd_setvf_traffic_vf,
7796 (void *)&cmd_setvf_traffic_vfid,
7797 (void *)&cmd_setvf_traffic_what,
7798 (void *)&cmd_setvf_traffic_mode,
7803 /* *** CONFIGURE VF RECEIVE MODE *** */
7804 struct cmd_set_vf_rxmode {
7805 cmdline_fixed_string_t set;
7806 cmdline_fixed_string_t port;
7808 cmdline_fixed_string_t vf;
7810 cmdline_fixed_string_t what;
7811 cmdline_fixed_string_t mode;
7812 cmdline_fixed_string_t on;
7816 cmd_set_vf_rxmode_parsed(void *parsed_result,
7817 __attribute__((unused)) struct cmdline *cl,
7818 __attribute__((unused)) void *data)
7821 uint16_t rx_mode = 0;
7822 struct cmd_set_vf_rxmode *res = parsed_result;
7824 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7825 if (!strcmp(res->what,"rxmode")) {
7826 if (!strcmp(res->mode, "AUPE"))
7827 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7828 else if (!strcmp(res->mode, "ROPE"))
7829 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7830 else if (!strcmp(res->mode, "BAM"))
7831 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7832 else if (!strncmp(res->mode, "MPE",3))
7833 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7836 RTE_SET_USED(is_on);
7838 #ifdef RTE_LIBRTE_IXGBE_PMD
7839 if (ret == -ENOTSUP)
7840 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7841 rx_mode, (uint8_t)is_on);
7843 #ifdef RTE_LIBRTE_BNXT_PMD
7844 if (ret == -ENOTSUP)
7845 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7846 rx_mode, (uint8_t)is_on);
7849 printf("bad VF receive mode parameter, return code = %d \n",
7853 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7854 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7856 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7857 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7859 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7860 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7862 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7863 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7865 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7866 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7868 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7869 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7871 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7872 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7873 mode, "AUPE#ROPE#BAM#MPE");
7874 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7875 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7878 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7879 .f = cmd_set_vf_rxmode_parsed,
7881 .help_str = "set port <port_id> vf <vf_id> rxmode "
7882 "AUPE|ROPE|BAM|MPE on|off",
7884 (void *)&cmd_set_vf_rxmode_set,
7885 (void *)&cmd_set_vf_rxmode_port,
7886 (void *)&cmd_set_vf_rxmode_portid,
7887 (void *)&cmd_set_vf_rxmode_vf,
7888 (void *)&cmd_set_vf_rxmode_vfid,
7889 (void *)&cmd_set_vf_rxmode_what,
7890 (void *)&cmd_set_vf_rxmode_mode,
7891 (void *)&cmd_set_vf_rxmode_on,
7896 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7897 struct cmd_vf_mac_addr_result {
7898 cmdline_fixed_string_t mac_addr_cmd;
7899 cmdline_fixed_string_t what;
7900 cmdline_fixed_string_t port;
7902 cmdline_fixed_string_t vf;
7904 struct ether_addr address;
7907 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7908 __attribute__((unused)) struct cmdline *cl,
7909 __attribute__((unused)) void *data)
7911 struct cmd_vf_mac_addr_result *res = parsed_result;
7914 if (strcmp(res->what, "add") != 0)
7917 #ifdef RTE_LIBRTE_I40E_PMD
7918 if (ret == -ENOTSUP)
7919 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7922 #ifdef RTE_LIBRTE_BNXT_PMD
7923 if (ret == -ENOTSUP)
7924 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7929 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7933 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7934 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7935 mac_addr_cmd,"mac_addr");
7936 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7937 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7939 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7940 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7942 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7943 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7945 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7946 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7948 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7949 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7951 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7952 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7955 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7956 .f = cmd_vf_mac_addr_parsed,
7958 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7959 "Add MAC address filtering for a VF on port_id",
7961 (void *)&cmd_vf_mac_addr_cmd,
7962 (void *)&cmd_vf_mac_addr_what,
7963 (void *)&cmd_vf_mac_addr_port,
7964 (void *)&cmd_vf_mac_addr_portnum,
7965 (void *)&cmd_vf_mac_addr_vf,
7966 (void *)&cmd_vf_mac_addr_vfnum,
7967 (void *)&cmd_vf_mac_addr_addr,
7972 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7973 struct cmd_vf_rx_vlan_filter {
7974 cmdline_fixed_string_t rx_vlan;
7975 cmdline_fixed_string_t what;
7977 cmdline_fixed_string_t port;
7979 cmdline_fixed_string_t vf;
7984 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7985 __attribute__((unused)) struct cmdline *cl,
7986 __attribute__((unused)) void *data)
7988 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7991 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7993 #ifdef RTE_LIBRTE_IXGBE_PMD
7994 if (ret == -ENOTSUP)
7995 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7996 res->vlan_id, res->vf_mask, is_add);
7998 #ifdef RTE_LIBRTE_I40E_PMD
7999 if (ret == -ENOTSUP)
8000 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8001 res->vlan_id, res->vf_mask, is_add);
8003 #ifdef RTE_LIBRTE_BNXT_PMD
8004 if (ret == -ENOTSUP)
8005 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8006 res->vlan_id, res->vf_mask, is_add);
8013 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8014 res->vlan_id, res->vf_mask);
8017 printf("invalid port_id %d\n", res->port_id);
8020 printf("function not implemented or supported\n");
8023 printf("programming error: (%s)\n", strerror(-ret));
8027 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8028 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8029 rx_vlan, "rx_vlan");
8030 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8031 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8033 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8034 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8036 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8037 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8039 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8040 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8042 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8043 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8045 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8046 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8049 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8050 .f = cmd_vf_rx_vlan_filter_parsed,
8052 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8053 "(vf_mask = hexadecimal VF mask)",
8055 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8056 (void *)&cmd_vf_rx_vlan_filter_what,
8057 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8058 (void *)&cmd_vf_rx_vlan_filter_port,
8059 (void *)&cmd_vf_rx_vlan_filter_portid,
8060 (void *)&cmd_vf_rx_vlan_filter_vf,
8061 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8066 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8067 struct cmd_queue_rate_limit_result {
8068 cmdline_fixed_string_t set;
8069 cmdline_fixed_string_t port;
8071 cmdline_fixed_string_t queue;
8073 cmdline_fixed_string_t rate;
8077 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8078 __attribute__((unused)) struct cmdline *cl,
8079 __attribute__((unused)) void *data)
8081 struct cmd_queue_rate_limit_result *res = parsed_result;
8084 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8085 && (strcmp(res->queue, "queue") == 0)
8086 && (strcmp(res->rate, "rate") == 0))
8087 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8090 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8094 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8095 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8097 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8098 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8100 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8101 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8103 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8104 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8106 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8107 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8109 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8110 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8112 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8113 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8116 cmdline_parse_inst_t cmd_queue_rate_limit = {
8117 .f = cmd_queue_rate_limit_parsed,
8119 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8120 "Set rate limit for a queue on port_id",
8122 (void *)&cmd_queue_rate_limit_set,
8123 (void *)&cmd_queue_rate_limit_port,
8124 (void *)&cmd_queue_rate_limit_portnum,
8125 (void *)&cmd_queue_rate_limit_queue,
8126 (void *)&cmd_queue_rate_limit_queuenum,
8127 (void *)&cmd_queue_rate_limit_rate,
8128 (void *)&cmd_queue_rate_limit_ratenum,
8133 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8134 struct cmd_vf_rate_limit_result {
8135 cmdline_fixed_string_t set;
8136 cmdline_fixed_string_t port;
8138 cmdline_fixed_string_t vf;
8140 cmdline_fixed_string_t rate;
8142 cmdline_fixed_string_t q_msk;
8146 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8147 __attribute__((unused)) struct cmdline *cl,
8148 __attribute__((unused)) void *data)
8150 struct cmd_vf_rate_limit_result *res = parsed_result;
8153 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8154 && (strcmp(res->vf, "vf") == 0)
8155 && (strcmp(res->rate, "rate") == 0)
8156 && (strcmp(res->q_msk, "queue_mask") == 0))
8157 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8158 res->rate_num, res->q_msk_val);
8160 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8164 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8165 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8167 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8168 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8170 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8171 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8173 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8174 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8176 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8177 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8179 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8180 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8182 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8183 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8185 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8186 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8187 q_msk, "queue_mask");
8188 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8189 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8192 cmdline_parse_inst_t cmd_vf_rate_limit = {
8193 .f = cmd_vf_rate_limit_parsed,
8195 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8196 "queue_mask <queue_mask_value>: "
8197 "Set rate limit for queues of VF on port_id",
8199 (void *)&cmd_vf_rate_limit_set,
8200 (void *)&cmd_vf_rate_limit_port,
8201 (void *)&cmd_vf_rate_limit_portnum,
8202 (void *)&cmd_vf_rate_limit_vf,
8203 (void *)&cmd_vf_rate_limit_vfnum,
8204 (void *)&cmd_vf_rate_limit_rate,
8205 (void *)&cmd_vf_rate_limit_ratenum,
8206 (void *)&cmd_vf_rate_limit_q_msk,
8207 (void *)&cmd_vf_rate_limit_q_msk_val,
8212 /* *** ADD TUNNEL FILTER OF A PORT *** */
8213 struct cmd_tunnel_filter_result {
8214 cmdline_fixed_string_t cmd;
8215 cmdline_fixed_string_t what;
8217 struct ether_addr outer_mac;
8218 struct ether_addr inner_mac;
8219 cmdline_ipaddr_t ip_value;
8220 uint16_t inner_vlan;
8221 cmdline_fixed_string_t tunnel_type;
8222 cmdline_fixed_string_t filter_type;
8228 cmd_tunnel_filter_parsed(void *parsed_result,
8229 __attribute__((unused)) struct cmdline *cl,
8230 __attribute__((unused)) void *data)
8232 struct cmd_tunnel_filter_result *res = parsed_result;
8233 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8236 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8238 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8239 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8240 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8242 if (res->ip_value.family == AF_INET) {
8243 tunnel_filter_conf.ip_addr.ipv4_addr =
8244 res->ip_value.addr.ipv4.s_addr;
8245 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8247 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8248 &(res->ip_value.addr.ipv6),
8249 sizeof(struct in6_addr));
8250 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8253 if (!strcmp(res->filter_type, "imac-ivlan"))
8254 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8255 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8256 tunnel_filter_conf.filter_type =
8257 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8258 else if (!strcmp(res->filter_type, "imac-tenid"))
8259 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8260 else if (!strcmp(res->filter_type, "imac"))
8261 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8262 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8263 tunnel_filter_conf.filter_type =
8264 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8265 else if (!strcmp(res->filter_type, "oip"))
8266 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8267 else if (!strcmp(res->filter_type, "iip"))
8268 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8270 printf("The filter type is not supported");
8274 if (!strcmp(res->tunnel_type, "vxlan"))
8275 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8276 else if (!strcmp(res->tunnel_type, "nvgre"))
8277 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8278 else if (!strcmp(res->tunnel_type, "ipingre"))
8279 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8281 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8285 tunnel_filter_conf.tenant_id = res->tenant_id;
8286 tunnel_filter_conf.queue_id = res->queue_num;
8287 if (!strcmp(res->what, "add"))
8288 ret = rte_eth_dev_filter_ctrl(res->port_id,
8289 RTE_ETH_FILTER_TUNNEL,
8291 &tunnel_filter_conf);
8293 ret = rte_eth_dev_filter_ctrl(res->port_id,
8294 RTE_ETH_FILTER_TUNNEL,
8295 RTE_ETH_FILTER_DELETE,
8296 &tunnel_filter_conf);
8298 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8302 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8303 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8304 cmd, "tunnel_filter");
8305 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8306 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8308 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8309 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8311 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8312 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8314 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8315 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8317 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8318 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8319 inner_vlan, UINT16);
8320 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8321 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8323 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8324 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8325 tunnel_type, "vxlan#nvgre#ipingre");
8327 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8328 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8329 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8330 "imac#omac-imac-tenid");
8331 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8332 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8334 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8335 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8338 cmdline_parse_inst_t cmd_tunnel_filter = {
8339 .f = cmd_tunnel_filter_parsed,
8341 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8342 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8343 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8344 "<queue_id>: Add/Rm tunnel filter of a port",
8346 (void *)&cmd_tunnel_filter_cmd,
8347 (void *)&cmd_tunnel_filter_what,
8348 (void *)&cmd_tunnel_filter_port_id,
8349 (void *)&cmd_tunnel_filter_outer_mac,
8350 (void *)&cmd_tunnel_filter_inner_mac,
8351 (void *)&cmd_tunnel_filter_ip_value,
8352 (void *)&cmd_tunnel_filter_innner_vlan,
8353 (void *)&cmd_tunnel_filter_tunnel_type,
8354 (void *)&cmd_tunnel_filter_filter_type,
8355 (void *)&cmd_tunnel_filter_tenant_id,
8356 (void *)&cmd_tunnel_filter_queue_num,
8361 /* *** CONFIGURE TUNNEL UDP PORT *** */
8362 struct cmd_tunnel_udp_config {
8363 cmdline_fixed_string_t cmd;
8364 cmdline_fixed_string_t what;
8370 cmd_tunnel_udp_config_parsed(void *parsed_result,
8371 __attribute__((unused)) struct cmdline *cl,
8372 __attribute__((unused)) void *data)
8374 struct cmd_tunnel_udp_config *res = parsed_result;
8375 struct rte_eth_udp_tunnel tunnel_udp;
8378 tunnel_udp.udp_port = res->udp_port;
8380 if (!strcmp(res->cmd, "rx_vxlan_port"))
8381 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8383 if (!strcmp(res->what, "add"))
8384 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8387 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8391 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8394 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8395 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8396 cmd, "rx_vxlan_port");
8397 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8398 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8400 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8401 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8403 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8404 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8407 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8408 .f = cmd_tunnel_udp_config_parsed,
8410 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8411 "Add/Remove a tunneling UDP port filter",
8413 (void *)&cmd_tunnel_udp_config_cmd,
8414 (void *)&cmd_tunnel_udp_config_what,
8415 (void *)&cmd_tunnel_udp_config_udp_port,
8416 (void *)&cmd_tunnel_udp_config_port_id,
8421 /* *** GLOBAL CONFIG *** */
8422 struct cmd_global_config_result {
8423 cmdline_fixed_string_t cmd;
8425 cmdline_fixed_string_t cfg_type;
8430 cmd_global_config_parsed(void *parsed_result,
8431 __attribute__((unused)) struct cmdline *cl,
8432 __attribute__((unused)) void *data)
8434 struct cmd_global_config_result *res = parsed_result;
8435 struct rte_eth_global_cfg conf;
8438 memset(&conf, 0, sizeof(conf));
8439 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8440 conf.cfg.gre_key_len = res->len;
8441 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8442 RTE_ETH_FILTER_SET, &conf);
8444 printf("Global config error\n");
8447 cmdline_parse_token_string_t cmd_global_config_cmd =
8448 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8450 cmdline_parse_token_num_t cmd_global_config_port_id =
8451 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8453 cmdline_parse_token_string_t cmd_global_config_type =
8454 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8455 cfg_type, "gre-key-len");
8456 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8457 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8460 cmdline_parse_inst_t cmd_global_config = {
8461 .f = cmd_global_config_parsed,
8462 .data = (void *)NULL,
8463 .help_str = "global_config <port_id> gre-key-len <key_len>",
8465 (void *)&cmd_global_config_cmd,
8466 (void *)&cmd_global_config_port_id,
8467 (void *)&cmd_global_config_type,
8468 (void *)&cmd_global_config_gre_key_len,
8473 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8474 struct cmd_set_mirror_mask_result {
8475 cmdline_fixed_string_t set;
8476 cmdline_fixed_string_t port;
8478 cmdline_fixed_string_t mirror;
8480 cmdline_fixed_string_t what;
8481 cmdline_fixed_string_t value;
8482 cmdline_fixed_string_t dstpool;
8484 cmdline_fixed_string_t on;
8487 cmdline_parse_token_string_t cmd_mirror_mask_set =
8488 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8490 cmdline_parse_token_string_t cmd_mirror_mask_port =
8491 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8493 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8494 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8496 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8497 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8498 mirror, "mirror-rule");
8499 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8500 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8502 cmdline_parse_token_string_t cmd_mirror_mask_what =
8503 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8504 what, "pool-mirror-up#pool-mirror-down"
8506 cmdline_parse_token_string_t cmd_mirror_mask_value =
8507 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8509 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8510 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8511 dstpool, "dst-pool");
8512 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8513 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8515 cmdline_parse_token_string_t cmd_mirror_mask_on =
8516 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8520 cmd_set_mirror_mask_parsed(void *parsed_result,
8521 __attribute__((unused)) struct cmdline *cl,
8522 __attribute__((unused)) void *data)
8525 struct cmd_set_mirror_mask_result *res = parsed_result;
8526 struct rte_eth_mirror_conf mr_conf;
8528 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8530 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8532 mr_conf.dst_pool = res->dstpool_id;
8534 if (!strcmp(res->what, "pool-mirror-up")) {
8535 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8536 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8537 } else if (!strcmp(res->what, "pool-mirror-down")) {
8538 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8539 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8540 } else if (!strcmp(res->what, "vlan-mirror")) {
8541 mr_conf.rule_type = ETH_MIRROR_VLAN;
8542 nb_item = parse_item_list(res->value, "vlan",
8543 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8547 for (i = 0; i < nb_item; i++) {
8548 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8549 printf("Invalid vlan_id: must be < 4096\n");
8553 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8554 mr_conf.vlan.vlan_mask |= 1ULL << i;
8558 if (!strcmp(res->on, "on"))
8559 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8562 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8565 printf("mirror rule add error: (%s)\n", strerror(-ret));
8568 cmdline_parse_inst_t cmd_set_mirror_mask = {
8569 .f = cmd_set_mirror_mask_parsed,
8571 .help_str = "set port <port_id> mirror-rule <rule_id> "
8572 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8573 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8575 (void *)&cmd_mirror_mask_set,
8576 (void *)&cmd_mirror_mask_port,
8577 (void *)&cmd_mirror_mask_portid,
8578 (void *)&cmd_mirror_mask_mirror,
8579 (void *)&cmd_mirror_mask_ruleid,
8580 (void *)&cmd_mirror_mask_what,
8581 (void *)&cmd_mirror_mask_value,
8582 (void *)&cmd_mirror_mask_dstpool,
8583 (void *)&cmd_mirror_mask_poolid,
8584 (void *)&cmd_mirror_mask_on,
8589 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8590 struct cmd_set_mirror_link_result {
8591 cmdline_fixed_string_t set;
8592 cmdline_fixed_string_t port;
8594 cmdline_fixed_string_t mirror;
8596 cmdline_fixed_string_t what;
8597 cmdline_fixed_string_t dstpool;
8599 cmdline_fixed_string_t on;
8602 cmdline_parse_token_string_t cmd_mirror_link_set =
8603 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8605 cmdline_parse_token_string_t cmd_mirror_link_port =
8606 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8608 cmdline_parse_token_num_t cmd_mirror_link_portid =
8609 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8611 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8612 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8613 mirror, "mirror-rule");
8614 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8615 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8617 cmdline_parse_token_string_t cmd_mirror_link_what =
8618 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8619 what, "uplink-mirror#downlink-mirror");
8620 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8621 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8622 dstpool, "dst-pool");
8623 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8624 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8626 cmdline_parse_token_string_t cmd_mirror_link_on =
8627 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8631 cmd_set_mirror_link_parsed(void *parsed_result,
8632 __attribute__((unused)) struct cmdline *cl,
8633 __attribute__((unused)) void *data)
8636 struct cmd_set_mirror_link_result *res = parsed_result;
8637 struct rte_eth_mirror_conf mr_conf;
8639 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8640 if (!strcmp(res->what, "uplink-mirror"))
8641 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8643 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8645 mr_conf.dst_pool = res->dstpool_id;
8647 if (!strcmp(res->on, "on"))
8648 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8651 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8654 /* check the return value and print it if is < 0 */
8656 printf("mirror rule add error: (%s)\n", strerror(-ret));
8660 cmdline_parse_inst_t cmd_set_mirror_link = {
8661 .f = cmd_set_mirror_link_parsed,
8663 .help_str = "set port <port_id> mirror-rule <rule_id> "
8664 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8666 (void *)&cmd_mirror_link_set,
8667 (void *)&cmd_mirror_link_port,
8668 (void *)&cmd_mirror_link_portid,
8669 (void *)&cmd_mirror_link_mirror,
8670 (void *)&cmd_mirror_link_ruleid,
8671 (void *)&cmd_mirror_link_what,
8672 (void *)&cmd_mirror_link_dstpool,
8673 (void *)&cmd_mirror_link_poolid,
8674 (void *)&cmd_mirror_link_on,
8679 /* *** RESET VM MIRROR RULE *** */
8680 struct cmd_rm_mirror_rule_result {
8681 cmdline_fixed_string_t reset;
8682 cmdline_fixed_string_t port;
8684 cmdline_fixed_string_t mirror;
8688 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8689 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8691 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8692 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8694 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8695 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8697 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8698 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8699 mirror, "mirror-rule");
8700 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8701 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8705 cmd_reset_mirror_rule_parsed(void *parsed_result,
8706 __attribute__((unused)) struct cmdline *cl,
8707 __attribute__((unused)) void *data)
8710 struct cmd_set_mirror_link_result *res = parsed_result;
8712 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8714 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8717 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8718 .f = cmd_reset_mirror_rule_parsed,
8720 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8722 (void *)&cmd_rm_mirror_rule_reset,
8723 (void *)&cmd_rm_mirror_rule_port,
8724 (void *)&cmd_rm_mirror_rule_portid,
8725 (void *)&cmd_rm_mirror_rule_mirror,
8726 (void *)&cmd_rm_mirror_rule_ruleid,
8731 /* ******************************************************************************** */
8733 struct cmd_dump_result {
8734 cmdline_fixed_string_t dump;
8738 dump_struct_sizes(void)
8740 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8741 DUMP_SIZE(struct rte_mbuf);
8742 DUMP_SIZE(struct rte_mempool);
8743 DUMP_SIZE(struct rte_ring);
8747 static void cmd_dump_parsed(void *parsed_result,
8748 __attribute__((unused)) struct cmdline *cl,
8749 __attribute__((unused)) void *data)
8751 struct cmd_dump_result *res = parsed_result;
8753 if (!strcmp(res->dump, "dump_physmem"))
8754 rte_dump_physmem_layout(stdout);
8755 else if (!strcmp(res->dump, "dump_memzone"))
8756 rte_memzone_dump(stdout);
8757 else if (!strcmp(res->dump, "dump_struct_sizes"))
8758 dump_struct_sizes();
8759 else if (!strcmp(res->dump, "dump_ring"))
8760 rte_ring_list_dump(stdout);
8761 else if (!strcmp(res->dump, "dump_mempool"))
8762 rte_mempool_list_dump(stdout);
8763 else if (!strcmp(res->dump, "dump_devargs"))
8764 rte_devargs_dump(stdout);
8765 else if (!strcmp(res->dump, "dump_log_types"))
8766 rte_log_dump(stdout);
8769 cmdline_parse_token_string_t cmd_dump_dump =
8770 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8773 "dump_struct_sizes#"
8779 cmdline_parse_inst_t cmd_dump = {
8780 .f = cmd_dump_parsed, /* function to call */
8781 .data = NULL, /* 2nd arg of func */
8782 .help_str = "Dump status",
8783 .tokens = { /* token list, NULL terminated */
8784 (void *)&cmd_dump_dump,
8789 /* ******************************************************************************** */
8791 struct cmd_dump_one_result {
8792 cmdline_fixed_string_t dump;
8793 cmdline_fixed_string_t name;
8796 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8797 __attribute__((unused)) void *data)
8799 struct cmd_dump_one_result *res = parsed_result;
8801 if (!strcmp(res->dump, "dump_ring")) {
8803 r = rte_ring_lookup(res->name);
8805 cmdline_printf(cl, "Cannot find ring\n");
8808 rte_ring_dump(stdout, r);
8809 } else if (!strcmp(res->dump, "dump_mempool")) {
8810 struct rte_mempool *mp;
8811 mp = rte_mempool_lookup(res->name);
8813 cmdline_printf(cl, "Cannot find mempool\n");
8816 rte_mempool_dump(stdout, mp);
8820 cmdline_parse_token_string_t cmd_dump_one_dump =
8821 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8822 "dump_ring#dump_mempool");
8824 cmdline_parse_token_string_t cmd_dump_one_name =
8825 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8827 cmdline_parse_inst_t cmd_dump_one = {
8828 .f = cmd_dump_one_parsed, /* function to call */
8829 .data = NULL, /* 2nd arg of func */
8830 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8831 .tokens = { /* token list, NULL terminated */
8832 (void *)&cmd_dump_one_dump,
8833 (void *)&cmd_dump_one_name,
8838 /* *** Add/Del syn filter *** */
8839 struct cmd_syn_filter_result {
8840 cmdline_fixed_string_t filter;
8842 cmdline_fixed_string_t ops;
8843 cmdline_fixed_string_t priority;
8844 cmdline_fixed_string_t high;
8845 cmdline_fixed_string_t queue;
8850 cmd_syn_filter_parsed(void *parsed_result,
8851 __attribute__((unused)) struct cmdline *cl,
8852 __attribute__((unused)) void *data)
8854 struct cmd_syn_filter_result *res = parsed_result;
8855 struct rte_eth_syn_filter syn_filter;
8858 ret = rte_eth_dev_filter_supported(res->port_id,
8859 RTE_ETH_FILTER_SYN);
8861 printf("syn filter is not supported on port %u.\n",
8866 memset(&syn_filter, 0, sizeof(syn_filter));
8868 if (!strcmp(res->ops, "add")) {
8869 if (!strcmp(res->high, "high"))
8870 syn_filter.hig_pri = 1;
8872 syn_filter.hig_pri = 0;
8874 syn_filter.queue = res->queue_id;
8875 ret = rte_eth_dev_filter_ctrl(res->port_id,
8880 ret = rte_eth_dev_filter_ctrl(res->port_id,
8882 RTE_ETH_FILTER_DELETE,
8886 printf("syn filter programming error: (%s)\n",
8890 cmdline_parse_token_string_t cmd_syn_filter_filter =
8891 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8892 filter, "syn_filter");
8893 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8894 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8896 cmdline_parse_token_string_t cmd_syn_filter_ops =
8897 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8899 cmdline_parse_token_string_t cmd_syn_filter_priority =
8900 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8901 priority, "priority");
8902 cmdline_parse_token_string_t cmd_syn_filter_high =
8903 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8905 cmdline_parse_token_string_t cmd_syn_filter_queue =
8906 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8908 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8909 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8912 cmdline_parse_inst_t cmd_syn_filter = {
8913 .f = cmd_syn_filter_parsed,
8915 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8916 "<queue_id>: Add/Delete syn filter",
8918 (void *)&cmd_syn_filter_filter,
8919 (void *)&cmd_syn_filter_port_id,
8920 (void *)&cmd_syn_filter_ops,
8921 (void *)&cmd_syn_filter_priority,
8922 (void *)&cmd_syn_filter_high,
8923 (void *)&cmd_syn_filter_queue,
8924 (void *)&cmd_syn_filter_queue_id,
8929 /* *** queue region set *** */
8930 struct cmd_queue_region_result {
8931 cmdline_fixed_string_t set;
8932 cmdline_fixed_string_t port;
8934 cmdline_fixed_string_t cmd;
8935 cmdline_fixed_string_t region;
8937 cmdline_fixed_string_t queue_start_index;
8939 cmdline_fixed_string_t queue_num;
8940 uint8_t queue_num_value;
8944 cmd_queue_region_parsed(void *parsed_result,
8945 __attribute__((unused)) struct cmdline *cl,
8946 __attribute__((unused)) void *data)
8948 struct cmd_queue_region_result *res = parsed_result;
8950 #ifdef RTE_LIBRTE_I40E_PMD
8951 struct rte_pmd_i40e_queue_region_conf region_conf;
8952 enum rte_pmd_i40e_queue_region_op op_type;
8955 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8958 #ifdef RTE_LIBRTE_I40E_PMD
8959 memset(®ion_conf, 0, sizeof(region_conf));
8960 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8961 region_conf.region_id = res->region_id;
8962 region_conf.queue_num = res->queue_num_value;
8963 region_conf.queue_start_index = res->queue_id;
8965 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8966 op_type, ®ion_conf);
8973 printf("function not implemented or supported\n");
8976 printf("queue region config error: (%s)\n", strerror(-ret));
8980 cmdline_parse_token_string_t cmd_queue_region_set =
8981 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8983 cmdline_parse_token_string_t cmd_queue_region_port =
8984 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8985 cmdline_parse_token_num_t cmd_queue_region_port_id =
8986 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8988 cmdline_parse_token_string_t cmd_queue_region_cmd =
8989 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8990 cmd, "queue-region");
8991 cmdline_parse_token_string_t cmd_queue_region_id =
8992 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8993 region, "region_id");
8994 cmdline_parse_token_num_t cmd_queue_region_index =
8995 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8997 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8998 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8999 queue_start_index, "queue_start_index");
9000 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9001 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9003 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9004 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9005 queue_num, "queue_num");
9006 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9007 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9008 queue_num_value, UINT8);
9010 cmdline_parse_inst_t cmd_queue_region = {
9011 .f = cmd_queue_region_parsed,
9013 .help_str = "set port <port_id> queue-region region_id <value> "
9014 "queue_start_index <value> queue_num <value>: Set a queue region",
9016 (void *)&cmd_queue_region_set,
9017 (void *)&cmd_queue_region_port,
9018 (void *)&cmd_queue_region_port_id,
9019 (void *)&cmd_queue_region_cmd,
9020 (void *)&cmd_queue_region_id,
9021 (void *)&cmd_queue_region_index,
9022 (void *)&cmd_queue_region_queue_start_index,
9023 (void *)&cmd_queue_region_queue_id,
9024 (void *)&cmd_queue_region_queue_num,
9025 (void *)&cmd_queue_region_queue_num_value,
9030 /* *** queue region and flowtype set *** */
9031 struct cmd_region_flowtype_result {
9032 cmdline_fixed_string_t set;
9033 cmdline_fixed_string_t port;
9035 cmdline_fixed_string_t cmd;
9036 cmdline_fixed_string_t region;
9038 cmdline_fixed_string_t flowtype;
9039 uint8_t flowtype_id;
9043 cmd_region_flowtype_parsed(void *parsed_result,
9044 __attribute__((unused)) struct cmdline *cl,
9045 __attribute__((unused)) void *data)
9047 struct cmd_region_flowtype_result *res = parsed_result;
9049 #ifdef RTE_LIBRTE_I40E_PMD
9050 struct rte_pmd_i40e_queue_region_conf region_conf;
9051 enum rte_pmd_i40e_queue_region_op op_type;
9054 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9057 #ifdef RTE_LIBRTE_I40E_PMD
9058 memset(®ion_conf, 0, sizeof(region_conf));
9060 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9061 region_conf.region_id = res->region_id;
9062 region_conf.hw_flowtype = res->flowtype_id;
9064 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9065 op_type, ®ion_conf);
9072 printf("function not implemented or supported\n");
9075 printf("region flowtype config error: (%s)\n", strerror(-ret));
9079 cmdline_parse_token_string_t cmd_region_flowtype_set =
9080 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9082 cmdline_parse_token_string_t cmd_region_flowtype_port =
9083 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9085 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9086 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9088 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9089 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9090 cmd, "queue-region");
9091 cmdline_parse_token_string_t cmd_region_flowtype_index =
9092 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9093 region, "region_id");
9094 cmdline_parse_token_num_t cmd_region_flowtype_id =
9095 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9097 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9098 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9099 flowtype, "flowtype");
9100 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9101 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9102 flowtype_id, UINT8);
9103 cmdline_parse_inst_t cmd_region_flowtype = {
9104 .f = cmd_region_flowtype_parsed,
9106 .help_str = "set port <port_id> queue-region region_id <value> "
9107 "flowtype <value>: Set a flowtype region index",
9109 (void *)&cmd_region_flowtype_set,
9110 (void *)&cmd_region_flowtype_port,
9111 (void *)&cmd_region_flowtype_port_index,
9112 (void *)&cmd_region_flowtype_cmd,
9113 (void *)&cmd_region_flowtype_index,
9114 (void *)&cmd_region_flowtype_id,
9115 (void *)&cmd_region_flowtype_flow_index,
9116 (void *)&cmd_region_flowtype_flow_id,
9121 /* *** User Priority (UP) to queue region (region_id) set *** */
9122 struct cmd_user_priority_region_result {
9123 cmdline_fixed_string_t set;
9124 cmdline_fixed_string_t port;
9126 cmdline_fixed_string_t cmd;
9127 cmdline_fixed_string_t user_priority;
9128 uint8_t user_priority_id;
9129 cmdline_fixed_string_t region;
9134 cmd_user_priority_region_parsed(void *parsed_result,
9135 __attribute__((unused)) struct cmdline *cl,
9136 __attribute__((unused)) void *data)
9138 struct cmd_user_priority_region_result *res = parsed_result;
9140 #ifdef RTE_LIBRTE_I40E_PMD
9141 struct rte_pmd_i40e_queue_region_conf region_conf;
9142 enum rte_pmd_i40e_queue_region_op op_type;
9145 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9148 #ifdef RTE_LIBRTE_I40E_PMD
9149 memset(®ion_conf, 0, sizeof(region_conf));
9150 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9151 region_conf.user_priority = res->user_priority_id;
9152 region_conf.region_id = res->region_id;
9154 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9155 op_type, ®ion_conf);
9162 printf("function not implemented or supported\n");
9165 printf("user_priority region config error: (%s)\n",
9170 cmdline_parse_token_string_t cmd_user_priority_region_set =
9171 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9173 cmdline_parse_token_string_t cmd_user_priority_region_port =
9174 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9176 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9177 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9179 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9180 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9181 cmd, "queue-region");
9182 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9183 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9184 user_priority, "UP");
9185 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9186 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9187 user_priority_id, UINT8);
9188 cmdline_parse_token_string_t cmd_user_priority_region_region =
9189 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9190 region, "region_id");
9191 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9192 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9195 cmdline_parse_inst_t cmd_user_priority_region = {
9196 .f = cmd_user_priority_region_parsed,
9198 .help_str = "set port <port_id> queue-region UP <value> "
9199 "region_id <value>: Set the mapping of User Priority (UP) "
9200 "to queue region (region_id) ",
9202 (void *)&cmd_user_priority_region_set,
9203 (void *)&cmd_user_priority_region_port,
9204 (void *)&cmd_user_priority_region_port_index,
9205 (void *)&cmd_user_priority_region_cmd,
9206 (void *)&cmd_user_priority_region_UP,
9207 (void *)&cmd_user_priority_region_UP_id,
9208 (void *)&cmd_user_priority_region_region,
9209 (void *)&cmd_user_priority_region_region_id,
9214 /* *** flush all queue region related configuration *** */
9215 struct cmd_flush_queue_region_result {
9216 cmdline_fixed_string_t set;
9217 cmdline_fixed_string_t port;
9219 cmdline_fixed_string_t cmd;
9220 cmdline_fixed_string_t flush;
9221 cmdline_fixed_string_t what;
9225 cmd_flush_queue_region_parsed(void *parsed_result,
9226 __attribute__((unused)) struct cmdline *cl,
9227 __attribute__((unused)) void *data)
9229 struct cmd_flush_queue_region_result *res = parsed_result;
9231 #ifdef RTE_LIBRTE_I40E_PMD
9232 struct rte_pmd_i40e_queue_region_conf region_conf;
9233 enum rte_pmd_i40e_queue_region_op op_type;
9236 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9239 #ifdef RTE_LIBRTE_I40E_PMD
9240 memset(®ion_conf, 0, sizeof(region_conf));
9242 if (strcmp(res->what, "on") == 0)
9243 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9245 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9247 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9248 op_type, ®ion_conf);
9255 printf("function not implemented or supported\n");
9258 printf("queue region config flush error: (%s)\n",
9263 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9264 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9266 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9267 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9269 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9270 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9272 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9273 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9274 cmd, "queue-region");
9275 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9276 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9278 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9279 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9282 cmdline_parse_inst_t cmd_flush_queue_region = {
9283 .f = cmd_flush_queue_region_parsed,
9285 .help_str = "set port <port_id> queue-region flush on|off"
9286 ": flush all queue region related configuration",
9288 (void *)&cmd_flush_queue_region_set,
9289 (void *)&cmd_flush_queue_region_port,
9290 (void *)&cmd_flush_queue_region_port_index,
9291 (void *)&cmd_flush_queue_region_cmd,
9292 (void *)&cmd_flush_queue_region_flush,
9293 (void *)&cmd_flush_queue_region_what,
9298 /* *** get all queue region related configuration info *** */
9299 struct cmd_show_queue_region_info {
9300 cmdline_fixed_string_t show;
9301 cmdline_fixed_string_t port;
9303 cmdline_fixed_string_t cmd;
9307 cmd_show_queue_region_info_parsed(void *parsed_result,
9308 __attribute__((unused)) struct cmdline *cl,
9309 __attribute__((unused)) void *data)
9311 struct cmd_show_queue_region_info *res = parsed_result;
9313 #ifdef RTE_LIBRTE_I40E_PMD
9314 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9315 enum rte_pmd_i40e_queue_region_op op_type;
9318 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9321 #ifdef RTE_LIBRTE_I40E_PMD
9322 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9324 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9326 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9327 op_type, &rte_pmd_regions);
9329 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9336 printf("function not implemented or supported\n");
9339 printf("queue region config info show error: (%s)\n",
9344 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9345 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9347 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9348 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9350 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9351 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9353 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9354 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9355 cmd, "queue-region");
9357 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9358 .f = cmd_show_queue_region_info_parsed,
9360 .help_str = "show port <port_id> queue-region"
9361 ": show all queue region related configuration info",
9363 (void *)&cmd_show_queue_region_info_get,
9364 (void *)&cmd_show_queue_region_info_port,
9365 (void *)&cmd_show_queue_region_info_port_index,
9366 (void *)&cmd_show_queue_region_info_cmd,
9371 /* *** ADD/REMOVE A 2tuple FILTER *** */
9372 struct cmd_2tuple_filter_result {
9373 cmdline_fixed_string_t filter;
9375 cmdline_fixed_string_t ops;
9376 cmdline_fixed_string_t dst_port;
9377 uint16_t dst_port_value;
9378 cmdline_fixed_string_t protocol;
9379 uint8_t protocol_value;
9380 cmdline_fixed_string_t mask;
9382 cmdline_fixed_string_t tcp_flags;
9383 uint8_t tcp_flags_value;
9384 cmdline_fixed_string_t priority;
9385 uint8_t priority_value;
9386 cmdline_fixed_string_t queue;
9391 cmd_2tuple_filter_parsed(void *parsed_result,
9392 __attribute__((unused)) struct cmdline *cl,
9393 __attribute__((unused)) void *data)
9395 struct rte_eth_ntuple_filter filter;
9396 struct cmd_2tuple_filter_result *res = parsed_result;
9399 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9401 printf("ntuple filter is not supported on port %u.\n",
9406 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9408 filter.flags = RTE_2TUPLE_FLAGS;
9409 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9410 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9411 filter.proto = res->protocol_value;
9412 filter.priority = res->priority_value;
9413 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9414 printf("nonzero tcp_flags is only meaningful"
9415 " when protocol is TCP.\n");
9418 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9419 printf("invalid TCP flags.\n");
9423 if (res->tcp_flags_value != 0) {
9424 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9425 filter.tcp_flags = res->tcp_flags_value;
9428 /* need convert to big endian. */
9429 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9430 filter.queue = res->queue_id;
9432 if (!strcmp(res->ops, "add"))
9433 ret = rte_eth_dev_filter_ctrl(res->port_id,
9434 RTE_ETH_FILTER_NTUPLE,
9438 ret = rte_eth_dev_filter_ctrl(res->port_id,
9439 RTE_ETH_FILTER_NTUPLE,
9440 RTE_ETH_FILTER_DELETE,
9443 printf("2tuple filter programming error: (%s)\n",
9448 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9449 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9450 filter, "2tuple_filter");
9451 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9452 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9454 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9455 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9457 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9458 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9459 dst_port, "dst_port");
9460 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9461 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9462 dst_port_value, UINT16);
9463 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9464 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9465 protocol, "protocol");
9466 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9467 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9468 protocol_value, UINT8);
9469 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9470 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9472 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9473 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9475 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9476 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9477 tcp_flags, "tcp_flags");
9478 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9479 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9480 tcp_flags_value, UINT8);
9481 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9482 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9483 priority, "priority");
9484 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9485 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9486 priority_value, UINT8);
9487 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9488 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9490 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9491 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9494 cmdline_parse_inst_t cmd_2tuple_filter = {
9495 .f = cmd_2tuple_filter_parsed,
9497 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9498 "<value> mask <value> tcp_flags <value> priority <value> queue "
9499 "<queue_id>: Add a 2tuple filter",
9501 (void *)&cmd_2tuple_filter_filter,
9502 (void *)&cmd_2tuple_filter_port_id,
9503 (void *)&cmd_2tuple_filter_ops,
9504 (void *)&cmd_2tuple_filter_dst_port,
9505 (void *)&cmd_2tuple_filter_dst_port_value,
9506 (void *)&cmd_2tuple_filter_protocol,
9507 (void *)&cmd_2tuple_filter_protocol_value,
9508 (void *)&cmd_2tuple_filter_mask,
9509 (void *)&cmd_2tuple_filter_mask_value,
9510 (void *)&cmd_2tuple_filter_tcp_flags,
9511 (void *)&cmd_2tuple_filter_tcp_flags_value,
9512 (void *)&cmd_2tuple_filter_priority,
9513 (void *)&cmd_2tuple_filter_priority_value,
9514 (void *)&cmd_2tuple_filter_queue,
9515 (void *)&cmd_2tuple_filter_queue_id,
9520 /* *** ADD/REMOVE A 5tuple FILTER *** */
9521 struct cmd_5tuple_filter_result {
9522 cmdline_fixed_string_t filter;
9524 cmdline_fixed_string_t ops;
9525 cmdline_fixed_string_t dst_ip;
9526 cmdline_ipaddr_t dst_ip_value;
9527 cmdline_fixed_string_t src_ip;
9528 cmdline_ipaddr_t src_ip_value;
9529 cmdline_fixed_string_t dst_port;
9530 uint16_t dst_port_value;
9531 cmdline_fixed_string_t src_port;
9532 uint16_t src_port_value;
9533 cmdline_fixed_string_t protocol;
9534 uint8_t protocol_value;
9535 cmdline_fixed_string_t mask;
9537 cmdline_fixed_string_t tcp_flags;
9538 uint8_t tcp_flags_value;
9539 cmdline_fixed_string_t priority;
9540 uint8_t priority_value;
9541 cmdline_fixed_string_t queue;
9546 cmd_5tuple_filter_parsed(void *parsed_result,
9547 __attribute__((unused)) struct cmdline *cl,
9548 __attribute__((unused)) void *data)
9550 struct rte_eth_ntuple_filter filter;
9551 struct cmd_5tuple_filter_result *res = parsed_result;
9554 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9556 printf("ntuple filter is not supported on port %u.\n",
9561 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9563 filter.flags = RTE_5TUPLE_FLAGS;
9564 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9565 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9566 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9567 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9568 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9569 filter.proto = res->protocol_value;
9570 filter.priority = res->priority_value;
9571 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9572 printf("nonzero tcp_flags is only meaningful"
9573 " when protocol is TCP.\n");
9576 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9577 printf("invalid TCP flags.\n");
9581 if (res->tcp_flags_value != 0) {
9582 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9583 filter.tcp_flags = res->tcp_flags_value;
9586 if (res->dst_ip_value.family == AF_INET)
9587 /* no need to convert, already big endian. */
9588 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9590 if (filter.dst_ip_mask == 0) {
9591 printf("can not support ipv6 involved compare.\n");
9597 if (res->src_ip_value.family == AF_INET)
9598 /* no need to convert, already big endian. */
9599 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9601 if (filter.src_ip_mask == 0) {
9602 printf("can not support ipv6 involved compare.\n");
9607 /* need convert to big endian. */
9608 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9609 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9610 filter.queue = res->queue_id;
9612 if (!strcmp(res->ops, "add"))
9613 ret = rte_eth_dev_filter_ctrl(res->port_id,
9614 RTE_ETH_FILTER_NTUPLE,
9618 ret = rte_eth_dev_filter_ctrl(res->port_id,
9619 RTE_ETH_FILTER_NTUPLE,
9620 RTE_ETH_FILTER_DELETE,
9623 printf("5tuple filter programming error: (%s)\n",
9627 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9628 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9629 filter, "5tuple_filter");
9630 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9631 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9633 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9634 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9636 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9637 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9639 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9640 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9642 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9643 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9645 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9646 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9648 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9649 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9650 dst_port, "dst_port");
9651 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9652 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9653 dst_port_value, UINT16);
9654 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9655 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9656 src_port, "src_port");
9657 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9658 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9659 src_port_value, UINT16);
9660 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9661 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9662 protocol, "protocol");
9663 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9664 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9665 protocol_value, UINT8);
9666 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9667 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9669 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9670 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9672 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9673 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9674 tcp_flags, "tcp_flags");
9675 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9676 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9677 tcp_flags_value, UINT8);
9678 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9679 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9680 priority, "priority");
9681 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9682 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9683 priority_value, UINT8);
9684 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9685 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9687 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9688 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9691 cmdline_parse_inst_t cmd_5tuple_filter = {
9692 .f = cmd_5tuple_filter_parsed,
9694 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9695 "src_ip <value> dst_port <value> src_port <value> "
9696 "protocol <value> mask <value> tcp_flags <value> "
9697 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9699 (void *)&cmd_5tuple_filter_filter,
9700 (void *)&cmd_5tuple_filter_port_id,
9701 (void *)&cmd_5tuple_filter_ops,
9702 (void *)&cmd_5tuple_filter_dst_ip,
9703 (void *)&cmd_5tuple_filter_dst_ip_value,
9704 (void *)&cmd_5tuple_filter_src_ip,
9705 (void *)&cmd_5tuple_filter_src_ip_value,
9706 (void *)&cmd_5tuple_filter_dst_port,
9707 (void *)&cmd_5tuple_filter_dst_port_value,
9708 (void *)&cmd_5tuple_filter_src_port,
9709 (void *)&cmd_5tuple_filter_src_port_value,
9710 (void *)&cmd_5tuple_filter_protocol,
9711 (void *)&cmd_5tuple_filter_protocol_value,
9712 (void *)&cmd_5tuple_filter_mask,
9713 (void *)&cmd_5tuple_filter_mask_value,
9714 (void *)&cmd_5tuple_filter_tcp_flags,
9715 (void *)&cmd_5tuple_filter_tcp_flags_value,
9716 (void *)&cmd_5tuple_filter_priority,
9717 (void *)&cmd_5tuple_filter_priority_value,
9718 (void *)&cmd_5tuple_filter_queue,
9719 (void *)&cmd_5tuple_filter_queue_id,
9724 /* *** ADD/REMOVE A flex FILTER *** */
9725 struct cmd_flex_filter_result {
9726 cmdline_fixed_string_t filter;
9727 cmdline_fixed_string_t ops;
9729 cmdline_fixed_string_t len;
9731 cmdline_fixed_string_t bytes;
9732 cmdline_fixed_string_t bytes_value;
9733 cmdline_fixed_string_t mask;
9734 cmdline_fixed_string_t mask_value;
9735 cmdline_fixed_string_t priority;
9736 uint8_t priority_value;
9737 cmdline_fixed_string_t queue;
9741 static int xdigit2val(unsigned char c)
9746 else if (isupper(c))
9754 cmd_flex_filter_parsed(void *parsed_result,
9755 __attribute__((unused)) struct cmdline *cl,
9756 __attribute__((unused)) void *data)
9759 struct rte_eth_flex_filter filter;
9760 struct cmd_flex_filter_result *res = parsed_result;
9761 char *bytes_ptr, *mask_ptr;
9762 uint16_t len, i, j = 0;
9767 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9768 printf("the len exceed the max length 128\n");
9771 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9772 filter.len = res->len_value;
9773 filter.priority = res->priority_value;
9774 filter.queue = res->queue_id;
9775 bytes_ptr = res->bytes_value;
9776 mask_ptr = res->mask_value;
9778 /* translate bytes string to array. */
9779 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9780 (bytes_ptr[1] == 'X')))
9782 len = strnlen(bytes_ptr, res->len_value * 2);
9783 if (len == 0 || (len % 8 != 0)) {
9784 printf("please check len and bytes input\n");
9787 for (i = 0; i < len; i++) {
9789 if (isxdigit(c) == 0) {
9790 /* invalid characters. */
9791 printf("invalid input\n");
9794 val = xdigit2val(c);
9797 filter.bytes[j] = byte;
9798 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9805 /* translate mask string to uint8_t array. */
9806 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9807 (mask_ptr[1] == 'X')))
9809 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9811 printf("invalid input\n");
9816 for (i = 0; i < len; i++) {
9818 if (isxdigit(c) == 0) {
9819 /* invalid characters. */
9820 printf("invalid input\n");
9823 val = xdigit2val(c);
9826 filter.mask[j] = byte;
9827 printf("mask[%d]:%02x ", j, filter.mask[j]);
9835 if (!strcmp(res->ops, "add"))
9836 ret = rte_eth_dev_filter_ctrl(res->port_id,
9837 RTE_ETH_FILTER_FLEXIBLE,
9841 ret = rte_eth_dev_filter_ctrl(res->port_id,
9842 RTE_ETH_FILTER_FLEXIBLE,
9843 RTE_ETH_FILTER_DELETE,
9847 printf("flex filter setting error: (%s)\n", strerror(-ret));
9850 cmdline_parse_token_string_t cmd_flex_filter_filter =
9851 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9852 filter, "flex_filter");
9853 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9854 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9856 cmdline_parse_token_string_t cmd_flex_filter_ops =
9857 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9859 cmdline_parse_token_string_t cmd_flex_filter_len =
9860 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9862 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9863 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9865 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9866 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9868 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9869 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9871 cmdline_parse_token_string_t cmd_flex_filter_mask =
9872 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9874 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9875 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9877 cmdline_parse_token_string_t cmd_flex_filter_priority =
9878 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9879 priority, "priority");
9880 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9881 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9882 priority_value, UINT8);
9883 cmdline_parse_token_string_t cmd_flex_filter_queue =
9884 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9886 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9887 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9889 cmdline_parse_inst_t cmd_flex_filter = {
9890 .f = cmd_flex_filter_parsed,
9892 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9893 "<value> mask <value> priority <value> queue <queue_id>: "
9894 "Add/Del a flex filter",
9896 (void *)&cmd_flex_filter_filter,
9897 (void *)&cmd_flex_filter_port_id,
9898 (void *)&cmd_flex_filter_ops,
9899 (void *)&cmd_flex_filter_len,
9900 (void *)&cmd_flex_filter_len_value,
9901 (void *)&cmd_flex_filter_bytes,
9902 (void *)&cmd_flex_filter_bytes_value,
9903 (void *)&cmd_flex_filter_mask,
9904 (void *)&cmd_flex_filter_mask_value,
9905 (void *)&cmd_flex_filter_priority,
9906 (void *)&cmd_flex_filter_priority_value,
9907 (void *)&cmd_flex_filter_queue,
9908 (void *)&cmd_flex_filter_queue_id,
9913 /* *** Filters Control *** */
9915 /* *** deal with ethertype filter *** */
9916 struct cmd_ethertype_filter_result {
9917 cmdline_fixed_string_t filter;
9919 cmdline_fixed_string_t ops;
9920 cmdline_fixed_string_t mac;
9921 struct ether_addr mac_addr;
9922 cmdline_fixed_string_t ethertype;
9923 uint16_t ethertype_value;
9924 cmdline_fixed_string_t drop;
9925 cmdline_fixed_string_t queue;
9929 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9930 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9931 filter, "ethertype_filter");
9932 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9933 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9935 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9936 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9938 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9939 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9940 mac, "mac_addr#mac_ignr");
9941 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9942 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9944 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9945 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9946 ethertype, "ethertype");
9947 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9948 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9949 ethertype_value, UINT16);
9950 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9951 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9953 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9954 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9956 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9957 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9961 cmd_ethertype_filter_parsed(void *parsed_result,
9962 __attribute__((unused)) struct cmdline *cl,
9963 __attribute__((unused)) void *data)
9965 struct cmd_ethertype_filter_result *res = parsed_result;
9966 struct rte_eth_ethertype_filter filter;
9969 ret = rte_eth_dev_filter_supported(res->port_id,
9970 RTE_ETH_FILTER_ETHERTYPE);
9972 printf("ethertype filter is not supported on port %u.\n",
9977 memset(&filter, 0, sizeof(filter));
9978 if (!strcmp(res->mac, "mac_addr")) {
9979 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9980 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9981 sizeof(struct ether_addr));
9983 if (!strcmp(res->drop, "drop"))
9984 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9985 filter.ether_type = res->ethertype_value;
9986 filter.queue = res->queue_id;
9988 if (!strcmp(res->ops, "add"))
9989 ret = rte_eth_dev_filter_ctrl(res->port_id,
9990 RTE_ETH_FILTER_ETHERTYPE,
9994 ret = rte_eth_dev_filter_ctrl(res->port_id,
9995 RTE_ETH_FILTER_ETHERTYPE,
9996 RTE_ETH_FILTER_DELETE,
9999 printf("ethertype filter programming error: (%s)\n",
10003 cmdline_parse_inst_t cmd_ethertype_filter = {
10004 .f = cmd_ethertype_filter_parsed,
10006 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10007 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10008 "Add or delete an ethertype filter entry",
10010 (void *)&cmd_ethertype_filter_filter,
10011 (void *)&cmd_ethertype_filter_port_id,
10012 (void *)&cmd_ethertype_filter_ops,
10013 (void *)&cmd_ethertype_filter_mac,
10014 (void *)&cmd_ethertype_filter_mac_addr,
10015 (void *)&cmd_ethertype_filter_ethertype,
10016 (void *)&cmd_ethertype_filter_ethertype_value,
10017 (void *)&cmd_ethertype_filter_drop,
10018 (void *)&cmd_ethertype_filter_queue,
10019 (void *)&cmd_ethertype_filter_queue_id,
10024 /* *** deal with flow director filter *** */
10025 struct cmd_flow_director_result {
10026 cmdline_fixed_string_t flow_director_filter;
10028 cmdline_fixed_string_t mode;
10029 cmdline_fixed_string_t mode_value;
10030 cmdline_fixed_string_t ops;
10031 cmdline_fixed_string_t flow;
10032 cmdline_fixed_string_t flow_type;
10033 cmdline_fixed_string_t ether;
10034 uint16_t ether_type;
10035 cmdline_fixed_string_t src;
10036 cmdline_ipaddr_t ip_src;
10038 cmdline_fixed_string_t dst;
10039 cmdline_ipaddr_t ip_dst;
10041 cmdline_fixed_string_t verify_tag;
10042 uint32_t verify_tag_value;
10043 cmdline_fixed_string_t tos;
10045 cmdline_fixed_string_t proto;
10046 uint8_t proto_value;
10047 cmdline_fixed_string_t ttl;
10049 cmdline_fixed_string_t vlan;
10050 uint16_t vlan_value;
10051 cmdline_fixed_string_t flexbytes;
10052 cmdline_fixed_string_t flexbytes_value;
10053 cmdline_fixed_string_t pf_vf;
10054 cmdline_fixed_string_t drop;
10055 cmdline_fixed_string_t queue;
10057 cmdline_fixed_string_t fd_id;
10058 uint32_t fd_id_value;
10059 cmdline_fixed_string_t mac;
10060 struct ether_addr mac_addr;
10061 cmdline_fixed_string_t tunnel;
10062 cmdline_fixed_string_t tunnel_type;
10063 cmdline_fixed_string_t tunnel_id;
10064 uint32_t tunnel_id_value;
10065 cmdline_fixed_string_t packet;
10070 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10073 const char *p, *p0 = q_arg;
10075 unsigned long int_fld;
10076 char *str_fld[max_num];
10081 p = strchr(p0, '(');
10085 p0 = strchr(p, ')');
10090 if (size >= sizeof(s))
10093 snprintf(s, sizeof(s), "%.*s", size, p);
10094 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10095 if (ret < 0 || ret > max_num)
10097 for (i = 0; i < ret; i++) {
10099 int_fld = strtoul(str_fld[i], &end, 0);
10100 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10102 flexbytes[i] = (uint8_t)int_fld;
10108 str2flowtype(char *string)
10111 static const struct {
10114 } flowtype_str[] = {
10115 {"raw", RTE_ETH_FLOW_RAW},
10116 {"ipv4", RTE_ETH_FLOW_IPV4},
10117 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10118 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10119 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10120 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10121 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10122 {"ipv6", RTE_ETH_FLOW_IPV6},
10123 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10124 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10125 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10126 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10127 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10128 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10131 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10132 if (!strcmp(flowtype_str[i].str, string))
10133 return flowtype_str[i].type;
10136 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10137 return (uint16_t)atoi(string);
10139 return RTE_ETH_FLOW_UNKNOWN;
10142 static enum rte_eth_fdir_tunnel_type
10143 str2fdir_tunneltype(char *string)
10147 static const struct {
10149 enum rte_eth_fdir_tunnel_type type;
10150 } tunneltype_str[] = {
10151 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10152 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10155 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10156 if (!strcmp(tunneltype_str[i].str, string))
10157 return tunneltype_str[i].type;
10159 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10162 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10164 if ((ip_addr).family == AF_INET) \
10165 (ip) = (ip_addr).addr.ipv4.s_addr; \
10167 printf("invalid parameter.\n"); \
10172 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10174 if ((ip_addr).family == AF_INET6) \
10175 rte_memcpy(&(ip), \
10176 &((ip_addr).addr.ipv6), \
10177 sizeof(struct in6_addr)); \
10179 printf("invalid parameter.\n"); \
10185 cmd_flow_director_filter_parsed(void *parsed_result,
10186 __attribute__((unused)) struct cmdline *cl,
10187 __attribute__((unused)) void *data)
10189 struct cmd_flow_director_result *res = parsed_result;
10190 struct rte_eth_fdir_filter entry;
10191 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10193 unsigned long vf_id;
10196 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10198 printf("flow director is not supported on port %u.\n",
10202 memset(flexbytes, 0, sizeof(flexbytes));
10203 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10205 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10206 if (strcmp(res->mode_value, "MAC-VLAN")) {
10207 printf("Please set mode to MAC-VLAN.\n");
10210 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10211 if (strcmp(res->mode_value, "Tunnel")) {
10212 printf("Please set mode to Tunnel.\n");
10216 if (!strcmp(res->mode_value, "raw")) {
10217 #ifdef RTE_LIBRTE_I40E_PMD
10218 struct rte_pmd_i40e_flow_type_mapping
10219 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10220 struct rte_pmd_i40e_pkt_template_conf conf;
10221 uint16_t flow_type = str2flowtype(res->flow_type);
10222 uint16_t i, port = res->port_id;
10225 memset(&conf, 0, sizeof(conf));
10227 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10228 printf("Invalid flow type specified.\n");
10231 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10235 if (mapping[flow_type].pctype == 0ULL) {
10236 printf("Invalid flow type specified.\n");
10239 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10240 if (mapping[flow_type].pctype & (1ULL << i)) {
10241 conf.input.pctype = i;
10246 conf.input.packet = open_file(res->filepath,
10247 &conf.input.length);
10248 if (!conf.input.packet)
10250 if (!strcmp(res->drop, "drop"))
10251 conf.action.behavior =
10252 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10254 conf.action.behavior =
10255 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10256 conf.action.report_status =
10257 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10258 conf.action.rx_queue = res->queue_id;
10259 conf.soft_id = res->fd_id_value;
10260 add = strcmp(res->ops, "del") ? 1 : 0;
10261 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10265 printf("flow director config error: (%s)\n",
10267 close_file(conf.input.packet);
10270 } else if (strcmp(res->mode_value, "IP")) {
10271 printf("Please set mode to IP or raw.\n");
10274 entry.input.flow_type = str2flowtype(res->flow_type);
10277 ret = parse_flexbytes(res->flexbytes_value,
10279 RTE_ETH_FDIR_MAX_FLEXLEN);
10281 printf("error: Cannot parse flexbytes input.\n");
10285 switch (entry.input.flow_type) {
10286 case RTE_ETH_FLOW_FRAG_IPV4:
10287 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10288 entry.input.flow.ip4_flow.proto = res->proto_value;
10290 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10291 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10292 IPV4_ADDR_TO_UINT(res->ip_dst,
10293 entry.input.flow.ip4_flow.dst_ip);
10294 IPV4_ADDR_TO_UINT(res->ip_src,
10295 entry.input.flow.ip4_flow.src_ip);
10296 entry.input.flow.ip4_flow.tos = res->tos_value;
10297 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10298 /* need convert to big endian. */
10299 entry.input.flow.udp4_flow.dst_port =
10300 rte_cpu_to_be_16(res->port_dst);
10301 entry.input.flow.udp4_flow.src_port =
10302 rte_cpu_to_be_16(res->port_src);
10304 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10305 IPV4_ADDR_TO_UINT(res->ip_dst,
10306 entry.input.flow.sctp4_flow.ip.dst_ip);
10307 IPV4_ADDR_TO_UINT(res->ip_src,
10308 entry.input.flow.sctp4_flow.ip.src_ip);
10309 entry.input.flow.ip4_flow.tos = res->tos_value;
10310 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10311 /* need convert to big endian. */
10312 entry.input.flow.sctp4_flow.dst_port =
10313 rte_cpu_to_be_16(res->port_dst);
10314 entry.input.flow.sctp4_flow.src_port =
10315 rte_cpu_to_be_16(res->port_src);
10316 entry.input.flow.sctp4_flow.verify_tag =
10317 rte_cpu_to_be_32(res->verify_tag_value);
10319 case RTE_ETH_FLOW_FRAG_IPV6:
10320 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10321 entry.input.flow.ipv6_flow.proto = res->proto_value;
10323 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10324 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10325 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10326 entry.input.flow.ipv6_flow.dst_ip);
10327 IPV6_ADDR_TO_ARRAY(res->ip_src,
10328 entry.input.flow.ipv6_flow.src_ip);
10329 entry.input.flow.ipv6_flow.tc = res->tos_value;
10330 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10331 /* need convert to big endian. */
10332 entry.input.flow.udp6_flow.dst_port =
10333 rte_cpu_to_be_16(res->port_dst);
10334 entry.input.flow.udp6_flow.src_port =
10335 rte_cpu_to_be_16(res->port_src);
10337 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10338 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10339 entry.input.flow.sctp6_flow.ip.dst_ip);
10340 IPV6_ADDR_TO_ARRAY(res->ip_src,
10341 entry.input.flow.sctp6_flow.ip.src_ip);
10342 entry.input.flow.ipv6_flow.tc = res->tos_value;
10343 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10344 /* need convert to big endian. */
10345 entry.input.flow.sctp6_flow.dst_port =
10346 rte_cpu_to_be_16(res->port_dst);
10347 entry.input.flow.sctp6_flow.src_port =
10348 rte_cpu_to_be_16(res->port_src);
10349 entry.input.flow.sctp6_flow.verify_tag =
10350 rte_cpu_to_be_32(res->verify_tag_value);
10352 case RTE_ETH_FLOW_L2_PAYLOAD:
10353 entry.input.flow.l2_flow.ether_type =
10354 rte_cpu_to_be_16(res->ether_type);
10360 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10361 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10363 sizeof(struct ether_addr));
10365 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10366 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10368 sizeof(struct ether_addr));
10369 entry.input.flow.tunnel_flow.tunnel_type =
10370 str2fdir_tunneltype(res->tunnel_type);
10371 entry.input.flow.tunnel_flow.tunnel_id =
10372 rte_cpu_to_be_32(res->tunnel_id_value);
10375 rte_memcpy(entry.input.flow_ext.flexbytes,
10377 RTE_ETH_FDIR_MAX_FLEXLEN);
10379 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10381 entry.action.flex_off = 0; /*use 0 by default */
10382 if (!strcmp(res->drop, "drop"))
10383 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10385 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10387 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10388 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10389 if (!strcmp(res->pf_vf, "pf"))
10390 entry.input.flow_ext.is_vf = 0;
10391 else if (!strncmp(res->pf_vf, "vf", 2)) {
10392 struct rte_eth_dev_info dev_info;
10394 memset(&dev_info, 0, sizeof(dev_info));
10395 rte_eth_dev_info_get(res->port_id, &dev_info);
10397 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10398 if (errno != 0 || *end != '\0' ||
10399 vf_id >= dev_info.max_vfs) {
10400 printf("invalid parameter %s.\n", res->pf_vf);
10403 entry.input.flow_ext.is_vf = 1;
10404 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10406 printf("invalid parameter %s.\n", res->pf_vf);
10411 /* set to report FD ID by default */
10412 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10413 entry.action.rx_queue = res->queue_id;
10414 entry.soft_id = res->fd_id_value;
10415 if (!strcmp(res->ops, "add"))
10416 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10417 RTE_ETH_FILTER_ADD, &entry);
10418 else if (!strcmp(res->ops, "del"))
10419 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10420 RTE_ETH_FILTER_DELETE, &entry);
10422 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10423 RTE_ETH_FILTER_UPDATE, &entry);
10425 printf("flow director programming error: (%s)\n",
10429 cmdline_parse_token_string_t cmd_flow_director_filter =
10430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10431 flow_director_filter, "flow_director_filter");
10432 cmdline_parse_token_num_t cmd_flow_director_port_id =
10433 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10435 cmdline_parse_token_string_t cmd_flow_director_ops =
10436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10437 ops, "add#del#update");
10438 cmdline_parse_token_string_t cmd_flow_director_flow =
10439 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10441 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10444 cmdline_parse_token_string_t cmd_flow_director_ether =
10445 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10447 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10448 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10449 ether_type, UINT16);
10450 cmdline_parse_token_string_t cmd_flow_director_src =
10451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10453 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10454 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10456 cmdline_parse_token_num_t cmd_flow_director_port_src =
10457 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10459 cmdline_parse_token_string_t cmd_flow_director_dst =
10460 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10462 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10463 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10465 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10466 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10468 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10469 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10470 verify_tag, "verify_tag");
10471 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10472 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10473 verify_tag_value, UINT32);
10474 cmdline_parse_token_string_t cmd_flow_director_tos =
10475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10477 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10478 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10480 cmdline_parse_token_string_t cmd_flow_director_proto =
10481 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10483 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10484 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10485 proto_value, UINT8);
10486 cmdline_parse_token_string_t cmd_flow_director_ttl =
10487 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10489 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10490 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10492 cmdline_parse_token_string_t cmd_flow_director_vlan =
10493 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10495 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10496 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10497 vlan_value, UINT16);
10498 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10499 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10500 flexbytes, "flexbytes");
10501 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10502 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10503 flexbytes_value, NULL);
10504 cmdline_parse_token_string_t cmd_flow_director_drop =
10505 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10507 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10508 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10510 cmdline_parse_token_string_t cmd_flow_director_queue =
10511 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10513 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10514 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10516 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10517 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10519 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10520 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10521 fd_id_value, UINT32);
10523 cmdline_parse_token_string_t cmd_flow_director_mode =
10524 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10526 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10527 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10529 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10530 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10531 mode_value, "MAC-VLAN");
10532 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10533 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10534 mode_value, "Tunnel");
10535 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10536 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10537 mode_value, "raw");
10538 cmdline_parse_token_string_t cmd_flow_director_mac =
10539 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10541 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10542 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10544 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10547 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10548 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10549 tunnel_type, "NVGRE#VxLAN");
10550 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10551 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10552 tunnel_id, "tunnel-id");
10553 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10554 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10555 tunnel_id_value, UINT32);
10556 cmdline_parse_token_string_t cmd_flow_director_packet =
10557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10559 cmdline_parse_token_string_t cmd_flow_director_filepath =
10560 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10563 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10564 .f = cmd_flow_director_filter_parsed,
10566 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10567 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10568 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10569 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10570 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10571 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10572 "fd_id <fd_id_value>: "
10573 "Add or delete an ip flow director entry on NIC",
10575 (void *)&cmd_flow_director_filter,
10576 (void *)&cmd_flow_director_port_id,
10577 (void *)&cmd_flow_director_mode,
10578 (void *)&cmd_flow_director_mode_ip,
10579 (void *)&cmd_flow_director_ops,
10580 (void *)&cmd_flow_director_flow,
10581 (void *)&cmd_flow_director_flow_type,
10582 (void *)&cmd_flow_director_src,
10583 (void *)&cmd_flow_director_ip_src,
10584 (void *)&cmd_flow_director_dst,
10585 (void *)&cmd_flow_director_ip_dst,
10586 (void *)&cmd_flow_director_tos,
10587 (void *)&cmd_flow_director_tos_value,
10588 (void *)&cmd_flow_director_proto,
10589 (void *)&cmd_flow_director_proto_value,
10590 (void *)&cmd_flow_director_ttl,
10591 (void *)&cmd_flow_director_ttl_value,
10592 (void *)&cmd_flow_director_vlan,
10593 (void *)&cmd_flow_director_vlan_value,
10594 (void *)&cmd_flow_director_flexbytes,
10595 (void *)&cmd_flow_director_flexbytes_value,
10596 (void *)&cmd_flow_director_drop,
10597 (void *)&cmd_flow_director_pf_vf,
10598 (void *)&cmd_flow_director_queue,
10599 (void *)&cmd_flow_director_queue_id,
10600 (void *)&cmd_flow_director_fd_id,
10601 (void *)&cmd_flow_director_fd_id_value,
10606 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10607 .f = cmd_flow_director_filter_parsed,
10609 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10610 "director entry on NIC",
10612 (void *)&cmd_flow_director_filter,
10613 (void *)&cmd_flow_director_port_id,
10614 (void *)&cmd_flow_director_mode,
10615 (void *)&cmd_flow_director_mode_ip,
10616 (void *)&cmd_flow_director_ops,
10617 (void *)&cmd_flow_director_flow,
10618 (void *)&cmd_flow_director_flow_type,
10619 (void *)&cmd_flow_director_src,
10620 (void *)&cmd_flow_director_ip_src,
10621 (void *)&cmd_flow_director_port_src,
10622 (void *)&cmd_flow_director_dst,
10623 (void *)&cmd_flow_director_ip_dst,
10624 (void *)&cmd_flow_director_port_dst,
10625 (void *)&cmd_flow_director_tos,
10626 (void *)&cmd_flow_director_tos_value,
10627 (void *)&cmd_flow_director_ttl,
10628 (void *)&cmd_flow_director_ttl_value,
10629 (void *)&cmd_flow_director_vlan,
10630 (void *)&cmd_flow_director_vlan_value,
10631 (void *)&cmd_flow_director_flexbytes,
10632 (void *)&cmd_flow_director_flexbytes_value,
10633 (void *)&cmd_flow_director_drop,
10634 (void *)&cmd_flow_director_pf_vf,
10635 (void *)&cmd_flow_director_queue,
10636 (void *)&cmd_flow_director_queue_id,
10637 (void *)&cmd_flow_director_fd_id,
10638 (void *)&cmd_flow_director_fd_id_value,
10643 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10644 .f = cmd_flow_director_filter_parsed,
10646 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10647 "director entry on NIC",
10649 (void *)&cmd_flow_director_filter,
10650 (void *)&cmd_flow_director_port_id,
10651 (void *)&cmd_flow_director_mode,
10652 (void *)&cmd_flow_director_mode_ip,
10653 (void *)&cmd_flow_director_ops,
10654 (void *)&cmd_flow_director_flow,
10655 (void *)&cmd_flow_director_flow_type,
10656 (void *)&cmd_flow_director_src,
10657 (void *)&cmd_flow_director_ip_src,
10658 (void *)&cmd_flow_director_port_src,
10659 (void *)&cmd_flow_director_dst,
10660 (void *)&cmd_flow_director_ip_dst,
10661 (void *)&cmd_flow_director_port_dst,
10662 (void *)&cmd_flow_director_verify_tag,
10663 (void *)&cmd_flow_director_verify_tag_value,
10664 (void *)&cmd_flow_director_tos,
10665 (void *)&cmd_flow_director_tos_value,
10666 (void *)&cmd_flow_director_ttl,
10667 (void *)&cmd_flow_director_ttl_value,
10668 (void *)&cmd_flow_director_vlan,
10669 (void *)&cmd_flow_director_vlan_value,
10670 (void *)&cmd_flow_director_flexbytes,
10671 (void *)&cmd_flow_director_flexbytes_value,
10672 (void *)&cmd_flow_director_drop,
10673 (void *)&cmd_flow_director_pf_vf,
10674 (void *)&cmd_flow_director_queue,
10675 (void *)&cmd_flow_director_queue_id,
10676 (void *)&cmd_flow_director_fd_id,
10677 (void *)&cmd_flow_director_fd_id_value,
10682 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10683 .f = cmd_flow_director_filter_parsed,
10685 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10686 "director entry on NIC",
10688 (void *)&cmd_flow_director_filter,
10689 (void *)&cmd_flow_director_port_id,
10690 (void *)&cmd_flow_director_mode,
10691 (void *)&cmd_flow_director_mode_ip,
10692 (void *)&cmd_flow_director_ops,
10693 (void *)&cmd_flow_director_flow,
10694 (void *)&cmd_flow_director_flow_type,
10695 (void *)&cmd_flow_director_ether,
10696 (void *)&cmd_flow_director_ether_type,
10697 (void *)&cmd_flow_director_flexbytes,
10698 (void *)&cmd_flow_director_flexbytes_value,
10699 (void *)&cmd_flow_director_drop,
10700 (void *)&cmd_flow_director_pf_vf,
10701 (void *)&cmd_flow_director_queue,
10702 (void *)&cmd_flow_director_queue_id,
10703 (void *)&cmd_flow_director_fd_id,
10704 (void *)&cmd_flow_director_fd_id_value,
10709 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10710 .f = cmd_flow_director_filter_parsed,
10712 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10713 "director entry on NIC",
10715 (void *)&cmd_flow_director_filter,
10716 (void *)&cmd_flow_director_port_id,
10717 (void *)&cmd_flow_director_mode,
10718 (void *)&cmd_flow_director_mode_mac_vlan,
10719 (void *)&cmd_flow_director_ops,
10720 (void *)&cmd_flow_director_mac,
10721 (void *)&cmd_flow_director_mac_addr,
10722 (void *)&cmd_flow_director_vlan,
10723 (void *)&cmd_flow_director_vlan_value,
10724 (void *)&cmd_flow_director_flexbytes,
10725 (void *)&cmd_flow_director_flexbytes_value,
10726 (void *)&cmd_flow_director_drop,
10727 (void *)&cmd_flow_director_queue,
10728 (void *)&cmd_flow_director_queue_id,
10729 (void *)&cmd_flow_director_fd_id,
10730 (void *)&cmd_flow_director_fd_id_value,
10735 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10736 .f = cmd_flow_director_filter_parsed,
10738 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10739 "director entry on NIC",
10741 (void *)&cmd_flow_director_filter,
10742 (void *)&cmd_flow_director_port_id,
10743 (void *)&cmd_flow_director_mode,
10744 (void *)&cmd_flow_director_mode_tunnel,
10745 (void *)&cmd_flow_director_ops,
10746 (void *)&cmd_flow_director_mac,
10747 (void *)&cmd_flow_director_mac_addr,
10748 (void *)&cmd_flow_director_vlan,
10749 (void *)&cmd_flow_director_vlan_value,
10750 (void *)&cmd_flow_director_tunnel,
10751 (void *)&cmd_flow_director_tunnel_type,
10752 (void *)&cmd_flow_director_tunnel_id,
10753 (void *)&cmd_flow_director_tunnel_id_value,
10754 (void *)&cmd_flow_director_flexbytes,
10755 (void *)&cmd_flow_director_flexbytes_value,
10756 (void *)&cmd_flow_director_drop,
10757 (void *)&cmd_flow_director_queue,
10758 (void *)&cmd_flow_director_queue_id,
10759 (void *)&cmd_flow_director_fd_id,
10760 (void *)&cmd_flow_director_fd_id_value,
10765 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10766 .f = cmd_flow_director_filter_parsed,
10768 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10769 "director entry on NIC",
10771 (void *)&cmd_flow_director_filter,
10772 (void *)&cmd_flow_director_port_id,
10773 (void *)&cmd_flow_director_mode,
10774 (void *)&cmd_flow_director_mode_raw,
10775 (void *)&cmd_flow_director_ops,
10776 (void *)&cmd_flow_director_flow,
10777 (void *)&cmd_flow_director_flow_type,
10778 (void *)&cmd_flow_director_drop,
10779 (void *)&cmd_flow_director_queue,
10780 (void *)&cmd_flow_director_queue_id,
10781 (void *)&cmd_flow_director_fd_id,
10782 (void *)&cmd_flow_director_fd_id_value,
10783 (void *)&cmd_flow_director_packet,
10784 (void *)&cmd_flow_director_filepath,
10789 struct cmd_flush_flow_director_result {
10790 cmdline_fixed_string_t flush_flow_director;
10794 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10795 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10796 flush_flow_director, "flush_flow_director");
10797 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10798 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10802 cmd_flush_flow_director_parsed(void *parsed_result,
10803 __attribute__((unused)) struct cmdline *cl,
10804 __attribute__((unused)) void *data)
10806 struct cmd_flow_director_result *res = parsed_result;
10809 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10811 printf("flow director is not supported on port %u.\n",
10816 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10817 RTE_ETH_FILTER_FLUSH, NULL);
10819 printf("flow director table flushing error: (%s)\n",
10823 cmdline_parse_inst_t cmd_flush_flow_director = {
10824 .f = cmd_flush_flow_director_parsed,
10826 .help_str = "flush_flow_director <port_id>: "
10827 "Flush all flow director entries of a device on NIC",
10829 (void *)&cmd_flush_flow_director_flush,
10830 (void *)&cmd_flush_flow_director_port_id,
10835 /* *** deal with flow director mask *** */
10836 struct cmd_flow_director_mask_result {
10837 cmdline_fixed_string_t flow_director_mask;
10839 cmdline_fixed_string_t mode;
10840 cmdline_fixed_string_t mode_value;
10841 cmdline_fixed_string_t vlan;
10842 uint16_t vlan_mask;
10843 cmdline_fixed_string_t src_mask;
10844 cmdline_ipaddr_t ipv4_src;
10845 cmdline_ipaddr_t ipv6_src;
10847 cmdline_fixed_string_t dst_mask;
10848 cmdline_ipaddr_t ipv4_dst;
10849 cmdline_ipaddr_t ipv6_dst;
10851 cmdline_fixed_string_t mac;
10852 uint8_t mac_addr_byte_mask;
10853 cmdline_fixed_string_t tunnel_id;
10854 uint32_t tunnel_id_mask;
10855 cmdline_fixed_string_t tunnel_type;
10856 uint8_t tunnel_type_mask;
10860 cmd_flow_director_mask_parsed(void *parsed_result,
10861 __attribute__((unused)) struct cmdline *cl,
10862 __attribute__((unused)) void *data)
10864 struct cmd_flow_director_mask_result *res = parsed_result;
10865 struct rte_eth_fdir_masks *mask;
10866 struct rte_port *port;
10868 port = &ports[res->port_id];
10869 /** Check if the port is not started **/
10870 if (port->port_status != RTE_PORT_STOPPED) {
10871 printf("Please stop port %d first\n", res->port_id);
10875 mask = &port->dev_conf.fdir_conf.mask;
10877 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10878 if (strcmp(res->mode_value, "MAC-VLAN")) {
10879 printf("Please set mode to MAC-VLAN.\n");
10883 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10884 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10885 if (strcmp(res->mode_value, "Tunnel")) {
10886 printf("Please set mode to Tunnel.\n");
10890 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10891 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10892 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10893 mask->tunnel_type_mask = res->tunnel_type_mask;
10895 if (strcmp(res->mode_value, "IP")) {
10896 printf("Please set mode to IP.\n");
10900 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10901 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10902 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10903 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10904 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10905 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10906 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10909 cmd_reconfig_device_queue(res->port_id, 1, 1);
10912 cmdline_parse_token_string_t cmd_flow_director_mask =
10913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10914 flow_director_mask, "flow_director_mask");
10915 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10916 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10918 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10921 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10922 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10923 vlan_mask, UINT16);
10924 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10926 src_mask, "src_mask");
10927 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10928 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10930 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10931 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10933 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10934 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10936 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10937 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10938 dst_mask, "dst_mask");
10939 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10940 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10942 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10943 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10945 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10946 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10949 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10952 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10955 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10957 mode_value, "MAC-VLAN");
10958 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10960 mode_value, "Tunnel");
10961 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10964 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10965 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10966 mac_addr_byte_mask, UINT8);
10967 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10969 tunnel_type, "tunnel-type");
10970 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10971 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10972 tunnel_type_mask, UINT8);
10973 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10975 tunnel_id, "tunnel-id");
10976 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10977 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10978 tunnel_id_mask, UINT32);
10980 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10981 .f = cmd_flow_director_mask_parsed,
10983 .help_str = "flow_director_mask ... : "
10984 "Set IP mode flow director's mask on NIC",
10986 (void *)&cmd_flow_director_mask,
10987 (void *)&cmd_flow_director_mask_port_id,
10988 (void *)&cmd_flow_director_mask_mode,
10989 (void *)&cmd_flow_director_mask_mode_ip,
10990 (void *)&cmd_flow_director_mask_vlan,
10991 (void *)&cmd_flow_director_mask_vlan_value,
10992 (void *)&cmd_flow_director_mask_src,
10993 (void *)&cmd_flow_director_mask_ipv4_src,
10994 (void *)&cmd_flow_director_mask_ipv6_src,
10995 (void *)&cmd_flow_director_mask_port_src,
10996 (void *)&cmd_flow_director_mask_dst,
10997 (void *)&cmd_flow_director_mask_ipv4_dst,
10998 (void *)&cmd_flow_director_mask_ipv6_dst,
10999 (void *)&cmd_flow_director_mask_port_dst,
11004 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11005 .f = cmd_flow_director_mask_parsed,
11007 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11008 "flow director's mask on NIC",
11010 (void *)&cmd_flow_director_mask,
11011 (void *)&cmd_flow_director_mask_port_id,
11012 (void *)&cmd_flow_director_mask_mode,
11013 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11014 (void *)&cmd_flow_director_mask_vlan,
11015 (void *)&cmd_flow_director_mask_vlan_value,
11020 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11021 .f = cmd_flow_director_mask_parsed,
11023 .help_str = "flow_director_mask ... : Set tunnel mode "
11024 "flow director's mask on NIC",
11026 (void *)&cmd_flow_director_mask,
11027 (void *)&cmd_flow_director_mask_port_id,
11028 (void *)&cmd_flow_director_mask_mode,
11029 (void *)&cmd_flow_director_mask_mode_tunnel,
11030 (void *)&cmd_flow_director_mask_vlan,
11031 (void *)&cmd_flow_director_mask_vlan_value,
11032 (void *)&cmd_flow_director_mask_mac,
11033 (void *)&cmd_flow_director_mask_mac_value,
11034 (void *)&cmd_flow_director_mask_tunnel_type,
11035 (void *)&cmd_flow_director_mask_tunnel_type_value,
11036 (void *)&cmd_flow_director_mask_tunnel_id,
11037 (void *)&cmd_flow_director_mask_tunnel_id_value,
11042 /* *** deal with flow director mask on flexible payload *** */
11043 struct cmd_flow_director_flex_mask_result {
11044 cmdline_fixed_string_t flow_director_flexmask;
11046 cmdline_fixed_string_t flow;
11047 cmdline_fixed_string_t flow_type;
11048 cmdline_fixed_string_t mask;
11052 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11053 __attribute__((unused)) struct cmdline *cl,
11054 __attribute__((unused)) void *data)
11056 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11057 struct rte_eth_fdir_info fdir_info;
11058 struct rte_eth_fdir_flex_mask flex_mask;
11059 struct rte_port *port;
11060 uint64_t flow_type_mask;
11064 port = &ports[res->port_id];
11065 /** Check if the port is not started **/
11066 if (port->port_status != RTE_PORT_STOPPED) {
11067 printf("Please stop port %d first\n", res->port_id);
11071 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11072 ret = parse_flexbytes(res->mask,
11074 RTE_ETH_FDIR_MAX_FLEXLEN);
11076 printf("error: Cannot parse mask input.\n");
11080 memset(&fdir_info, 0, sizeof(fdir_info));
11081 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11082 RTE_ETH_FILTER_INFO, &fdir_info);
11084 printf("Cannot get FDir filter info\n");
11088 if (!strcmp(res->flow_type, "none")) {
11089 /* means don't specify the flow type */
11090 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11091 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11092 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11093 0, sizeof(struct rte_eth_fdir_flex_mask));
11094 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11095 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11097 sizeof(struct rte_eth_fdir_flex_mask));
11098 cmd_reconfig_device_queue(res->port_id, 1, 1);
11101 flow_type_mask = fdir_info.flow_types_mask[0];
11102 if (!strcmp(res->flow_type, "all")) {
11103 if (!flow_type_mask) {
11104 printf("No flow type supported\n");
11107 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11108 if (flow_type_mask & (1ULL << i)) {
11109 flex_mask.flow_type = i;
11110 fdir_set_flex_mask(res->port_id, &flex_mask);
11113 cmd_reconfig_device_queue(res->port_id, 1, 1);
11116 flex_mask.flow_type = str2flowtype(res->flow_type);
11117 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11118 printf("Flow type %s not supported on port %d\n",
11119 res->flow_type, res->port_id);
11122 fdir_set_flex_mask(res->port_id, &flex_mask);
11123 cmd_reconfig_device_queue(res->port_id, 1, 1);
11126 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11127 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11128 flow_director_flexmask,
11129 "flow_director_flex_mask");
11130 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11131 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11133 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11136 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11137 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11138 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11139 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11140 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11141 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11144 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11145 .f = cmd_flow_director_flex_mask_parsed,
11147 .help_str = "flow_director_flex_mask ... : "
11148 "Set flow director's flex mask on NIC",
11150 (void *)&cmd_flow_director_flexmask,
11151 (void *)&cmd_flow_director_flexmask_port_id,
11152 (void *)&cmd_flow_director_flexmask_flow,
11153 (void *)&cmd_flow_director_flexmask_flow_type,
11154 (void *)&cmd_flow_director_flexmask_mask,
11159 /* *** deal with flow director flexible payload configuration *** */
11160 struct cmd_flow_director_flexpayload_result {
11161 cmdline_fixed_string_t flow_director_flexpayload;
11163 cmdline_fixed_string_t payload_layer;
11164 cmdline_fixed_string_t payload_cfg;
11168 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11171 const char *p, *p0 = q_arg;
11173 unsigned long int_fld;
11174 char *str_fld[max_num];
11179 p = strchr(p0, '(');
11183 p0 = strchr(p, ')');
11188 if (size >= sizeof(s))
11191 snprintf(s, sizeof(s), "%.*s", size, p);
11192 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11193 if (ret < 0 || ret > max_num)
11195 for (i = 0; i < ret; i++) {
11197 int_fld = strtoul(str_fld[i], &end, 0);
11198 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11200 offsets[i] = (uint16_t)int_fld;
11206 cmd_flow_director_flxpld_parsed(void *parsed_result,
11207 __attribute__((unused)) struct cmdline *cl,
11208 __attribute__((unused)) void *data)
11210 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11211 struct rte_eth_flex_payload_cfg flex_cfg;
11212 struct rte_port *port;
11215 port = &ports[res->port_id];
11216 /** Check if the port is not started **/
11217 if (port->port_status != RTE_PORT_STOPPED) {
11218 printf("Please stop port %d first\n", res->port_id);
11222 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11224 if (!strcmp(res->payload_layer, "raw"))
11225 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11226 else if (!strcmp(res->payload_layer, "l2"))
11227 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11228 else if (!strcmp(res->payload_layer, "l3"))
11229 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11230 else if (!strcmp(res->payload_layer, "l4"))
11231 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11233 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11234 RTE_ETH_FDIR_MAX_FLEXLEN);
11236 printf("error: Cannot parse flex payload input.\n");
11240 fdir_set_flex_payload(res->port_id, &flex_cfg);
11241 cmd_reconfig_device_queue(res->port_id, 1, 1);
11244 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11246 flow_director_flexpayload,
11247 "flow_director_flex_payload");
11248 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11249 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11251 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11253 payload_layer, "raw#l2#l3#l4");
11254 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11256 payload_cfg, NULL);
11258 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11259 .f = cmd_flow_director_flxpld_parsed,
11261 .help_str = "flow_director_flexpayload ... : "
11262 "Set flow director's flex payload on NIC",
11264 (void *)&cmd_flow_director_flexpayload,
11265 (void *)&cmd_flow_director_flexpayload_port_id,
11266 (void *)&cmd_flow_director_flexpayload_payload_layer,
11267 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11272 /* Generic flow interface command. */
11273 extern cmdline_parse_inst_t cmd_flow;
11275 /* *** Classification Filters Control *** */
11276 /* *** Get symmetric hash enable per port *** */
11277 struct cmd_get_sym_hash_ena_per_port_result {
11278 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11283 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11284 __rte_unused struct cmdline *cl,
11285 __rte_unused void *data)
11287 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11288 struct rte_eth_hash_filter_info info;
11291 if (rte_eth_dev_filter_supported(res->port_id,
11292 RTE_ETH_FILTER_HASH) < 0) {
11293 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11298 memset(&info, 0, sizeof(info));
11299 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11300 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11301 RTE_ETH_FILTER_GET, &info);
11304 printf("Cannot get symmetric hash enable per port "
11305 "on port %u\n", res->port_id);
11309 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11310 "enabled" : "disabled", res->port_id);
11313 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11314 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11315 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11316 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11317 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11320 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11321 .f = cmd_get_sym_hash_per_port_parsed,
11323 .help_str = "get_sym_hash_ena_per_port <port_id>",
11325 (void *)&cmd_get_sym_hash_ena_per_port_all,
11326 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11331 /* *** Set symmetric hash enable per port *** */
11332 struct cmd_set_sym_hash_ena_per_port_result {
11333 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11334 cmdline_fixed_string_t enable;
11339 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11340 __rte_unused struct cmdline *cl,
11341 __rte_unused void *data)
11343 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11344 struct rte_eth_hash_filter_info info;
11347 if (rte_eth_dev_filter_supported(res->port_id,
11348 RTE_ETH_FILTER_HASH) < 0) {
11349 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11354 memset(&info, 0, sizeof(info));
11355 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11356 if (!strcmp(res->enable, "enable"))
11357 info.info.enable = 1;
11358 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11359 RTE_ETH_FILTER_SET, &info);
11361 printf("Cannot set symmetric hash enable per port on "
11362 "port %u\n", res->port_id);
11365 printf("Symmetric hash has been set to %s on port %u\n",
11366 res->enable, res->port_id);
11369 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11370 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11371 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11372 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11373 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11375 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11376 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11377 enable, "enable#disable");
11379 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11380 .f = cmd_set_sym_hash_per_port_parsed,
11382 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11384 (void *)&cmd_set_sym_hash_ena_per_port_all,
11385 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11386 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11391 /* Get global config of hash function */
11392 struct cmd_get_hash_global_config_result {
11393 cmdline_fixed_string_t get_hash_global_config;
11398 flowtype_to_str(uint16_t ftype)
11404 } ftype_table[] = {
11405 {"ipv4", RTE_ETH_FLOW_IPV4},
11406 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11407 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11408 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11409 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11410 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11411 {"ipv6", RTE_ETH_FLOW_IPV6},
11412 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11413 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11414 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11415 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11416 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11417 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11418 {"port", RTE_ETH_FLOW_PORT},
11419 {"vxlan", RTE_ETH_FLOW_VXLAN},
11420 {"geneve", RTE_ETH_FLOW_GENEVE},
11421 {"nvgre", RTE_ETH_FLOW_NVGRE},
11424 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11425 if (ftype_table[i].ftype == ftype)
11426 return ftype_table[i].str;
11433 cmd_get_hash_global_config_parsed(void *parsed_result,
11434 __rte_unused struct cmdline *cl,
11435 __rte_unused void *data)
11437 struct cmd_get_hash_global_config_result *res = parsed_result;
11438 struct rte_eth_hash_filter_info info;
11439 uint32_t idx, offset;
11444 if (rte_eth_dev_filter_supported(res->port_id,
11445 RTE_ETH_FILTER_HASH) < 0) {
11446 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11451 memset(&info, 0, sizeof(info));
11452 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11453 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11454 RTE_ETH_FILTER_GET, &info);
11456 printf("Cannot get hash global configurations by port %d\n",
11461 switch (info.info.global_conf.hash_func) {
11462 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11463 printf("Hash function is Toeplitz\n");
11465 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11466 printf("Hash function is Simple XOR\n");
11469 printf("Unknown hash function\n");
11473 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11474 idx = i / UINT64_BIT;
11475 offset = i % UINT64_BIT;
11476 if (!(info.info.global_conf.valid_bit_mask[idx] &
11479 str = flowtype_to_str(i);
11482 printf("Symmetric hash is %s globally for flow type %s "
11484 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11485 (1ULL << offset)) ? "enabled" : "disabled"), str,
11490 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11491 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11492 get_hash_global_config, "get_hash_global_config");
11493 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11494 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11497 cmdline_parse_inst_t cmd_get_hash_global_config = {
11498 .f = cmd_get_hash_global_config_parsed,
11500 .help_str = "get_hash_global_config <port_id>",
11502 (void *)&cmd_get_hash_global_config_all,
11503 (void *)&cmd_get_hash_global_config_port_id,
11508 /* Set global config of hash function */
11509 struct cmd_set_hash_global_config_result {
11510 cmdline_fixed_string_t set_hash_global_config;
11512 cmdline_fixed_string_t hash_func;
11513 cmdline_fixed_string_t flow_type;
11514 cmdline_fixed_string_t enable;
11518 cmd_set_hash_global_config_parsed(void *parsed_result,
11519 __rte_unused struct cmdline *cl,
11520 __rte_unused void *data)
11522 struct cmd_set_hash_global_config_result *res = parsed_result;
11523 struct rte_eth_hash_filter_info info;
11524 uint32_t ftype, idx, offset;
11527 if (rte_eth_dev_filter_supported(res->port_id,
11528 RTE_ETH_FILTER_HASH) < 0) {
11529 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11533 memset(&info, 0, sizeof(info));
11534 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11535 if (!strcmp(res->hash_func, "toeplitz"))
11536 info.info.global_conf.hash_func =
11537 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11538 else if (!strcmp(res->hash_func, "simple_xor"))
11539 info.info.global_conf.hash_func =
11540 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11541 else if (!strcmp(res->hash_func, "default"))
11542 info.info.global_conf.hash_func =
11543 RTE_ETH_HASH_FUNCTION_DEFAULT;
11545 ftype = str2flowtype(res->flow_type);
11546 idx = ftype / UINT64_BIT;
11547 offset = ftype % UINT64_BIT;
11548 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11549 if (!strcmp(res->enable, "enable"))
11550 info.info.global_conf.sym_hash_enable_mask[idx] |=
11552 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11553 RTE_ETH_FILTER_SET, &info);
11555 printf("Cannot set global hash configurations by port %d\n",
11558 printf("Global hash configurations have been set "
11559 "succcessfully by port %d\n", res->port_id);
11562 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11563 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11564 set_hash_global_config, "set_hash_global_config");
11565 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11566 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11568 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11569 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11570 hash_func, "toeplitz#simple_xor#default");
11571 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11572 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11574 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11575 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11576 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11577 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11578 enable, "enable#disable");
11580 cmdline_parse_inst_t cmd_set_hash_global_config = {
11581 .f = cmd_set_hash_global_config_parsed,
11583 .help_str = "set_hash_global_config <port_id> "
11584 "toeplitz|simple_xor|default "
11585 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11586 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11587 "l2_payload enable|disable",
11589 (void *)&cmd_set_hash_global_config_all,
11590 (void *)&cmd_set_hash_global_config_port_id,
11591 (void *)&cmd_set_hash_global_config_hash_func,
11592 (void *)&cmd_set_hash_global_config_flow_type,
11593 (void *)&cmd_set_hash_global_config_enable,
11598 /* Set hash input set */
11599 struct cmd_set_hash_input_set_result {
11600 cmdline_fixed_string_t set_hash_input_set;
11602 cmdline_fixed_string_t flow_type;
11603 cmdline_fixed_string_t inset_field;
11604 cmdline_fixed_string_t select;
11607 static enum rte_eth_input_set_field
11608 str2inset(char *string)
11612 static const struct {
11614 enum rte_eth_input_set_field inset;
11615 } inset_table[] = {
11616 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11617 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11618 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11619 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11620 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11621 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11622 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11623 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11624 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11625 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11626 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11627 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11628 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11629 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11630 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11631 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11632 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11633 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11634 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11635 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11636 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11637 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11638 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11639 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11640 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11641 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11642 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11643 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11644 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11645 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11646 {"none", RTE_ETH_INPUT_SET_NONE},
11649 for (i = 0; i < RTE_DIM(inset_table); i++) {
11650 if (!strcmp(string, inset_table[i].str))
11651 return inset_table[i].inset;
11654 return RTE_ETH_INPUT_SET_UNKNOWN;
11658 cmd_set_hash_input_set_parsed(void *parsed_result,
11659 __rte_unused struct cmdline *cl,
11660 __rte_unused void *data)
11662 struct cmd_set_hash_input_set_result *res = parsed_result;
11663 struct rte_eth_hash_filter_info info;
11665 memset(&info, 0, sizeof(info));
11666 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11667 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11668 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11669 info.info.input_set_conf.inset_size = 1;
11670 if (!strcmp(res->select, "select"))
11671 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11672 else if (!strcmp(res->select, "add"))
11673 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11674 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11675 RTE_ETH_FILTER_SET, &info);
11678 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11679 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11680 set_hash_input_set, "set_hash_input_set");
11681 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11682 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11684 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11685 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11687 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11688 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11690 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11691 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11692 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11693 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11694 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11696 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11697 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11698 select, "select#add");
11700 cmdline_parse_inst_t cmd_set_hash_input_set = {
11701 .f = cmd_set_hash_input_set_parsed,
11703 .help_str = "set_hash_input_set <port_id> "
11704 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11705 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11706 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11707 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11708 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11709 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11710 "fld-7th|fld-8th|none select|add",
11712 (void *)&cmd_set_hash_input_set_cmd,
11713 (void *)&cmd_set_hash_input_set_port_id,
11714 (void *)&cmd_set_hash_input_set_flow_type,
11715 (void *)&cmd_set_hash_input_set_field,
11716 (void *)&cmd_set_hash_input_set_select,
11721 /* Set flow director input set */
11722 struct cmd_set_fdir_input_set_result {
11723 cmdline_fixed_string_t set_fdir_input_set;
11725 cmdline_fixed_string_t flow_type;
11726 cmdline_fixed_string_t inset_field;
11727 cmdline_fixed_string_t select;
11731 cmd_set_fdir_input_set_parsed(void *parsed_result,
11732 __rte_unused struct cmdline *cl,
11733 __rte_unused void *data)
11735 struct cmd_set_fdir_input_set_result *res = parsed_result;
11736 struct rte_eth_fdir_filter_info info;
11738 memset(&info, 0, sizeof(info));
11739 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11740 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11741 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11742 info.info.input_set_conf.inset_size = 1;
11743 if (!strcmp(res->select, "select"))
11744 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11745 else if (!strcmp(res->select, "add"))
11746 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11747 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11748 RTE_ETH_FILTER_SET, &info);
11751 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11752 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11753 set_fdir_input_set, "set_fdir_input_set");
11754 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11755 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11757 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11758 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11760 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11761 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11762 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11763 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11765 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11766 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11767 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11768 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11769 "sctp-veri-tag#none");
11770 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11771 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11772 select, "select#add");
11774 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11775 .f = cmd_set_fdir_input_set_parsed,
11777 .help_str = "set_fdir_input_set <port_id> "
11778 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11779 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11780 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11781 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11782 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11783 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11784 "sctp-veri-tag|none select|add",
11786 (void *)&cmd_set_fdir_input_set_cmd,
11787 (void *)&cmd_set_fdir_input_set_port_id,
11788 (void *)&cmd_set_fdir_input_set_flow_type,
11789 (void *)&cmd_set_fdir_input_set_field,
11790 (void *)&cmd_set_fdir_input_set_select,
11795 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11796 struct cmd_mcast_addr_result {
11797 cmdline_fixed_string_t mcast_addr_cmd;
11798 cmdline_fixed_string_t what;
11800 struct ether_addr mc_addr;
11803 static void cmd_mcast_addr_parsed(void *parsed_result,
11804 __attribute__((unused)) struct cmdline *cl,
11805 __attribute__((unused)) void *data)
11807 struct cmd_mcast_addr_result *res = parsed_result;
11809 if (!is_multicast_ether_addr(&res->mc_addr)) {
11810 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11811 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11812 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11813 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11816 if (strcmp(res->what, "add") == 0)
11817 mcast_addr_add(res->port_num, &res->mc_addr);
11819 mcast_addr_remove(res->port_num, &res->mc_addr);
11822 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11823 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11824 mcast_addr_cmd, "mcast_addr");
11825 cmdline_parse_token_string_t cmd_mcast_addr_what =
11826 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11828 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11829 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11830 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11831 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11833 cmdline_parse_inst_t cmd_mcast_addr = {
11834 .f = cmd_mcast_addr_parsed,
11836 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11837 "Add/Remove multicast MAC address on port_id",
11839 (void *)&cmd_mcast_addr_cmd,
11840 (void *)&cmd_mcast_addr_what,
11841 (void *)&cmd_mcast_addr_portnum,
11842 (void *)&cmd_mcast_addr_addr,
11847 /* l2 tunnel config
11848 * only support E-tag now.
11851 /* Ether type config */
11852 struct cmd_config_l2_tunnel_eth_type_result {
11853 cmdline_fixed_string_t port;
11854 cmdline_fixed_string_t config;
11855 cmdline_fixed_string_t all;
11857 cmdline_fixed_string_t l2_tunnel;
11858 cmdline_fixed_string_t l2_tunnel_type;
11859 cmdline_fixed_string_t eth_type;
11860 uint16_t eth_type_val;
11863 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11864 TOKEN_STRING_INITIALIZER
11865 (struct cmd_config_l2_tunnel_eth_type_result,
11867 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11868 TOKEN_STRING_INITIALIZER
11869 (struct cmd_config_l2_tunnel_eth_type_result,
11871 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11872 TOKEN_STRING_INITIALIZER
11873 (struct cmd_config_l2_tunnel_eth_type_result,
11875 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11876 TOKEN_NUM_INITIALIZER
11877 (struct cmd_config_l2_tunnel_eth_type_result,
11879 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11880 TOKEN_STRING_INITIALIZER
11881 (struct cmd_config_l2_tunnel_eth_type_result,
11882 l2_tunnel, "l2-tunnel");
11883 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11884 TOKEN_STRING_INITIALIZER
11885 (struct cmd_config_l2_tunnel_eth_type_result,
11886 l2_tunnel_type, "E-tag");
11887 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11888 TOKEN_STRING_INITIALIZER
11889 (struct cmd_config_l2_tunnel_eth_type_result,
11890 eth_type, "ether-type");
11891 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11892 TOKEN_NUM_INITIALIZER
11893 (struct cmd_config_l2_tunnel_eth_type_result,
11894 eth_type_val, UINT16);
11896 static enum rte_eth_tunnel_type
11897 str2fdir_l2_tunnel_type(char *string)
11901 static const struct {
11903 enum rte_eth_tunnel_type type;
11904 } l2_tunnel_type_str[] = {
11905 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11908 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11909 if (!strcmp(l2_tunnel_type_str[i].str, string))
11910 return l2_tunnel_type_str[i].type;
11912 return RTE_TUNNEL_TYPE_NONE;
11915 /* ether type config for all ports */
11917 cmd_config_l2_tunnel_eth_type_all_parsed
11918 (void *parsed_result,
11919 __attribute__((unused)) struct cmdline *cl,
11920 __attribute__((unused)) void *data)
11922 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11923 struct rte_eth_l2_tunnel_conf entry;
11926 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11927 entry.ether_type = res->eth_type_val;
11929 RTE_ETH_FOREACH_DEV(pid) {
11930 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11934 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11935 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11937 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11939 (void *)&cmd_config_l2_tunnel_eth_type_port,
11940 (void *)&cmd_config_l2_tunnel_eth_type_config,
11941 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11942 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11943 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11944 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11945 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11950 /* ether type config for a specific port */
11952 cmd_config_l2_tunnel_eth_type_specific_parsed(
11953 void *parsed_result,
11954 __attribute__((unused)) struct cmdline *cl,
11955 __attribute__((unused)) void *data)
11957 struct cmd_config_l2_tunnel_eth_type_result *res =
11959 struct rte_eth_l2_tunnel_conf entry;
11961 if (port_id_is_invalid(res->id, ENABLED_WARN))
11964 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11965 entry.ether_type = res->eth_type_val;
11967 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11970 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11971 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11973 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11975 (void *)&cmd_config_l2_tunnel_eth_type_port,
11976 (void *)&cmd_config_l2_tunnel_eth_type_config,
11977 (void *)&cmd_config_l2_tunnel_eth_type_id,
11978 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11979 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11980 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11981 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11986 /* Enable/disable l2 tunnel */
11987 struct cmd_config_l2_tunnel_en_dis_result {
11988 cmdline_fixed_string_t port;
11989 cmdline_fixed_string_t config;
11990 cmdline_fixed_string_t all;
11992 cmdline_fixed_string_t l2_tunnel;
11993 cmdline_fixed_string_t l2_tunnel_type;
11994 cmdline_fixed_string_t en_dis;
11997 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11998 TOKEN_STRING_INITIALIZER
11999 (struct cmd_config_l2_tunnel_en_dis_result,
12001 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12002 TOKEN_STRING_INITIALIZER
12003 (struct cmd_config_l2_tunnel_en_dis_result,
12005 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12006 TOKEN_STRING_INITIALIZER
12007 (struct cmd_config_l2_tunnel_en_dis_result,
12009 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12010 TOKEN_NUM_INITIALIZER
12011 (struct cmd_config_l2_tunnel_en_dis_result,
12013 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12014 TOKEN_STRING_INITIALIZER
12015 (struct cmd_config_l2_tunnel_en_dis_result,
12016 l2_tunnel, "l2-tunnel");
12017 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12018 TOKEN_STRING_INITIALIZER
12019 (struct cmd_config_l2_tunnel_en_dis_result,
12020 l2_tunnel_type, "E-tag");
12021 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12022 TOKEN_STRING_INITIALIZER
12023 (struct cmd_config_l2_tunnel_en_dis_result,
12024 en_dis, "enable#disable");
12026 /* enable/disable l2 tunnel for all ports */
12028 cmd_config_l2_tunnel_en_dis_all_parsed(
12029 void *parsed_result,
12030 __attribute__((unused)) struct cmdline *cl,
12031 __attribute__((unused)) void *data)
12033 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12034 struct rte_eth_l2_tunnel_conf entry;
12038 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12040 if (!strcmp("enable", res->en_dis))
12045 RTE_ETH_FOREACH_DEV(pid) {
12046 rte_eth_dev_l2_tunnel_offload_set(pid,
12048 ETH_L2_TUNNEL_ENABLE_MASK,
12053 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12054 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12056 .help_str = "port config all l2-tunnel E-tag enable|disable",
12058 (void *)&cmd_config_l2_tunnel_en_dis_port,
12059 (void *)&cmd_config_l2_tunnel_en_dis_config,
12060 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12061 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12062 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12063 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12068 /* enable/disable l2 tunnel for a port */
12070 cmd_config_l2_tunnel_en_dis_specific_parsed(
12071 void *parsed_result,
12072 __attribute__((unused)) struct cmdline *cl,
12073 __attribute__((unused)) void *data)
12075 struct cmd_config_l2_tunnel_en_dis_result *res =
12077 struct rte_eth_l2_tunnel_conf entry;
12079 if (port_id_is_invalid(res->id, ENABLED_WARN))
12082 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12084 if (!strcmp("enable", res->en_dis))
12085 rte_eth_dev_l2_tunnel_offload_set(res->id,
12087 ETH_L2_TUNNEL_ENABLE_MASK,
12090 rte_eth_dev_l2_tunnel_offload_set(res->id,
12092 ETH_L2_TUNNEL_ENABLE_MASK,
12096 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12097 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12099 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12101 (void *)&cmd_config_l2_tunnel_en_dis_port,
12102 (void *)&cmd_config_l2_tunnel_en_dis_config,
12103 (void *)&cmd_config_l2_tunnel_en_dis_id,
12104 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12105 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12106 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12111 /* E-tag configuration */
12113 /* Common result structure for all E-tag configuration */
12114 struct cmd_config_e_tag_result {
12115 cmdline_fixed_string_t e_tag;
12116 cmdline_fixed_string_t set;
12117 cmdline_fixed_string_t insertion;
12118 cmdline_fixed_string_t stripping;
12119 cmdline_fixed_string_t forwarding;
12120 cmdline_fixed_string_t filter;
12121 cmdline_fixed_string_t add;
12122 cmdline_fixed_string_t del;
12123 cmdline_fixed_string_t on;
12124 cmdline_fixed_string_t off;
12125 cmdline_fixed_string_t on_off;
12126 cmdline_fixed_string_t port_tag_id;
12127 uint32_t port_tag_id_val;
12128 cmdline_fixed_string_t e_tag_id;
12129 uint16_t e_tag_id_val;
12130 cmdline_fixed_string_t dst_pool;
12131 uint8_t dst_pool_val;
12132 cmdline_fixed_string_t port;
12134 cmdline_fixed_string_t vf;
12138 /* Common CLI fields for all E-tag configuration */
12139 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12140 TOKEN_STRING_INITIALIZER
12141 (struct cmd_config_e_tag_result,
12143 cmdline_parse_token_string_t cmd_config_e_tag_set =
12144 TOKEN_STRING_INITIALIZER
12145 (struct cmd_config_e_tag_result,
12147 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12148 TOKEN_STRING_INITIALIZER
12149 (struct cmd_config_e_tag_result,
12150 insertion, "insertion");
12151 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12152 TOKEN_STRING_INITIALIZER
12153 (struct cmd_config_e_tag_result,
12154 stripping, "stripping");
12155 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12156 TOKEN_STRING_INITIALIZER
12157 (struct cmd_config_e_tag_result,
12158 forwarding, "forwarding");
12159 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12160 TOKEN_STRING_INITIALIZER
12161 (struct cmd_config_e_tag_result,
12163 cmdline_parse_token_string_t cmd_config_e_tag_add =
12164 TOKEN_STRING_INITIALIZER
12165 (struct cmd_config_e_tag_result,
12167 cmdline_parse_token_string_t cmd_config_e_tag_del =
12168 TOKEN_STRING_INITIALIZER
12169 (struct cmd_config_e_tag_result,
12171 cmdline_parse_token_string_t cmd_config_e_tag_on =
12172 TOKEN_STRING_INITIALIZER
12173 (struct cmd_config_e_tag_result,
12175 cmdline_parse_token_string_t cmd_config_e_tag_off =
12176 TOKEN_STRING_INITIALIZER
12177 (struct cmd_config_e_tag_result,
12179 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12180 TOKEN_STRING_INITIALIZER
12181 (struct cmd_config_e_tag_result,
12183 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12184 TOKEN_STRING_INITIALIZER
12185 (struct cmd_config_e_tag_result,
12186 port_tag_id, "port-tag-id");
12187 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12188 TOKEN_NUM_INITIALIZER
12189 (struct cmd_config_e_tag_result,
12190 port_tag_id_val, UINT32);
12191 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12192 TOKEN_STRING_INITIALIZER
12193 (struct cmd_config_e_tag_result,
12194 e_tag_id, "e-tag-id");
12195 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12196 TOKEN_NUM_INITIALIZER
12197 (struct cmd_config_e_tag_result,
12198 e_tag_id_val, UINT16);
12199 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12200 TOKEN_STRING_INITIALIZER
12201 (struct cmd_config_e_tag_result,
12202 dst_pool, "dst-pool");
12203 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12204 TOKEN_NUM_INITIALIZER
12205 (struct cmd_config_e_tag_result,
12206 dst_pool_val, UINT8);
12207 cmdline_parse_token_string_t cmd_config_e_tag_port =
12208 TOKEN_STRING_INITIALIZER
12209 (struct cmd_config_e_tag_result,
12211 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12212 TOKEN_NUM_INITIALIZER
12213 (struct cmd_config_e_tag_result,
12215 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12216 TOKEN_STRING_INITIALIZER
12217 (struct cmd_config_e_tag_result,
12219 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12220 TOKEN_NUM_INITIALIZER
12221 (struct cmd_config_e_tag_result,
12224 /* E-tag insertion configuration */
12226 cmd_config_e_tag_insertion_en_parsed(
12227 void *parsed_result,
12228 __attribute__((unused)) struct cmdline *cl,
12229 __attribute__((unused)) void *data)
12231 struct cmd_config_e_tag_result *res =
12233 struct rte_eth_l2_tunnel_conf entry;
12235 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12238 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12239 entry.tunnel_id = res->port_tag_id_val;
12240 entry.vf_id = res->vf_id;
12241 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12243 ETH_L2_TUNNEL_INSERTION_MASK,
12248 cmd_config_e_tag_insertion_dis_parsed(
12249 void *parsed_result,
12250 __attribute__((unused)) struct cmdline *cl,
12251 __attribute__((unused)) void *data)
12253 struct cmd_config_e_tag_result *res =
12255 struct rte_eth_l2_tunnel_conf entry;
12257 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12260 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12261 entry.vf_id = res->vf_id;
12263 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12265 ETH_L2_TUNNEL_INSERTION_MASK,
12269 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12270 .f = cmd_config_e_tag_insertion_en_parsed,
12272 .help_str = "E-tag ... : E-tag insertion enable",
12274 (void *)&cmd_config_e_tag_e_tag,
12275 (void *)&cmd_config_e_tag_set,
12276 (void *)&cmd_config_e_tag_insertion,
12277 (void *)&cmd_config_e_tag_on,
12278 (void *)&cmd_config_e_tag_port_tag_id,
12279 (void *)&cmd_config_e_tag_port_tag_id_val,
12280 (void *)&cmd_config_e_tag_port,
12281 (void *)&cmd_config_e_tag_port_id,
12282 (void *)&cmd_config_e_tag_vf,
12283 (void *)&cmd_config_e_tag_vf_id,
12288 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12289 .f = cmd_config_e_tag_insertion_dis_parsed,
12291 .help_str = "E-tag ... : E-tag insertion disable",
12293 (void *)&cmd_config_e_tag_e_tag,
12294 (void *)&cmd_config_e_tag_set,
12295 (void *)&cmd_config_e_tag_insertion,
12296 (void *)&cmd_config_e_tag_off,
12297 (void *)&cmd_config_e_tag_port,
12298 (void *)&cmd_config_e_tag_port_id,
12299 (void *)&cmd_config_e_tag_vf,
12300 (void *)&cmd_config_e_tag_vf_id,
12305 /* E-tag stripping configuration */
12307 cmd_config_e_tag_stripping_parsed(
12308 void *parsed_result,
12309 __attribute__((unused)) struct cmdline *cl,
12310 __attribute__((unused)) void *data)
12312 struct cmd_config_e_tag_result *res =
12314 struct rte_eth_l2_tunnel_conf entry;
12316 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12319 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12321 if (!strcmp(res->on_off, "on"))
12322 rte_eth_dev_l2_tunnel_offload_set
12325 ETH_L2_TUNNEL_STRIPPING_MASK,
12328 rte_eth_dev_l2_tunnel_offload_set
12331 ETH_L2_TUNNEL_STRIPPING_MASK,
12335 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12336 .f = cmd_config_e_tag_stripping_parsed,
12338 .help_str = "E-tag ... : E-tag stripping enable/disable",
12340 (void *)&cmd_config_e_tag_e_tag,
12341 (void *)&cmd_config_e_tag_set,
12342 (void *)&cmd_config_e_tag_stripping,
12343 (void *)&cmd_config_e_tag_on_off,
12344 (void *)&cmd_config_e_tag_port,
12345 (void *)&cmd_config_e_tag_port_id,
12350 /* E-tag forwarding configuration */
12352 cmd_config_e_tag_forwarding_parsed(
12353 void *parsed_result,
12354 __attribute__((unused)) struct cmdline *cl,
12355 __attribute__((unused)) void *data)
12357 struct cmd_config_e_tag_result *res = parsed_result;
12358 struct rte_eth_l2_tunnel_conf entry;
12360 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12363 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12365 if (!strcmp(res->on_off, "on"))
12366 rte_eth_dev_l2_tunnel_offload_set
12369 ETH_L2_TUNNEL_FORWARDING_MASK,
12372 rte_eth_dev_l2_tunnel_offload_set
12375 ETH_L2_TUNNEL_FORWARDING_MASK,
12379 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12380 .f = cmd_config_e_tag_forwarding_parsed,
12382 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12384 (void *)&cmd_config_e_tag_e_tag,
12385 (void *)&cmd_config_e_tag_set,
12386 (void *)&cmd_config_e_tag_forwarding,
12387 (void *)&cmd_config_e_tag_on_off,
12388 (void *)&cmd_config_e_tag_port,
12389 (void *)&cmd_config_e_tag_port_id,
12394 /* E-tag filter configuration */
12396 cmd_config_e_tag_filter_add_parsed(
12397 void *parsed_result,
12398 __attribute__((unused)) struct cmdline *cl,
12399 __attribute__((unused)) void *data)
12401 struct cmd_config_e_tag_result *res = parsed_result;
12402 struct rte_eth_l2_tunnel_conf entry;
12405 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12408 if (res->e_tag_id_val > 0x3fff) {
12409 printf("e-tag-id must be equal or less than 0x3fff.\n");
12413 ret = rte_eth_dev_filter_supported(res->port_id,
12414 RTE_ETH_FILTER_L2_TUNNEL);
12416 printf("E-tag filter is not supported on port %u.\n",
12421 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12422 entry.tunnel_id = res->e_tag_id_val;
12423 entry.pool = res->dst_pool_val;
12425 ret = rte_eth_dev_filter_ctrl(res->port_id,
12426 RTE_ETH_FILTER_L2_TUNNEL,
12427 RTE_ETH_FILTER_ADD,
12430 printf("E-tag filter programming error: (%s)\n",
12434 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12435 .f = cmd_config_e_tag_filter_add_parsed,
12437 .help_str = "E-tag ... : E-tag filter add",
12439 (void *)&cmd_config_e_tag_e_tag,
12440 (void *)&cmd_config_e_tag_set,
12441 (void *)&cmd_config_e_tag_filter,
12442 (void *)&cmd_config_e_tag_add,
12443 (void *)&cmd_config_e_tag_e_tag_id,
12444 (void *)&cmd_config_e_tag_e_tag_id_val,
12445 (void *)&cmd_config_e_tag_dst_pool,
12446 (void *)&cmd_config_e_tag_dst_pool_val,
12447 (void *)&cmd_config_e_tag_port,
12448 (void *)&cmd_config_e_tag_port_id,
12454 cmd_config_e_tag_filter_del_parsed(
12455 void *parsed_result,
12456 __attribute__((unused)) struct cmdline *cl,
12457 __attribute__((unused)) void *data)
12459 struct cmd_config_e_tag_result *res = parsed_result;
12460 struct rte_eth_l2_tunnel_conf entry;
12463 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12466 if (res->e_tag_id_val > 0x3fff) {
12467 printf("e-tag-id must be less than 0x3fff.\n");
12471 ret = rte_eth_dev_filter_supported(res->port_id,
12472 RTE_ETH_FILTER_L2_TUNNEL);
12474 printf("E-tag filter is not supported on port %u.\n",
12479 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12480 entry.tunnel_id = res->e_tag_id_val;
12482 ret = rte_eth_dev_filter_ctrl(res->port_id,
12483 RTE_ETH_FILTER_L2_TUNNEL,
12484 RTE_ETH_FILTER_DELETE,
12487 printf("E-tag filter programming error: (%s)\n",
12491 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12492 .f = cmd_config_e_tag_filter_del_parsed,
12494 .help_str = "E-tag ... : E-tag filter delete",
12496 (void *)&cmd_config_e_tag_e_tag,
12497 (void *)&cmd_config_e_tag_set,
12498 (void *)&cmd_config_e_tag_filter,
12499 (void *)&cmd_config_e_tag_del,
12500 (void *)&cmd_config_e_tag_e_tag_id,
12501 (void *)&cmd_config_e_tag_e_tag_id_val,
12502 (void *)&cmd_config_e_tag_port,
12503 (void *)&cmd_config_e_tag_port_id,
12508 /* vf vlan anti spoof configuration */
12510 /* Common result structure for vf vlan anti spoof */
12511 struct cmd_vf_vlan_anti_spoof_result {
12512 cmdline_fixed_string_t set;
12513 cmdline_fixed_string_t vf;
12514 cmdline_fixed_string_t vlan;
12515 cmdline_fixed_string_t antispoof;
12518 cmdline_fixed_string_t on_off;
12521 /* Common CLI fields for vf vlan anti spoof enable disable */
12522 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12523 TOKEN_STRING_INITIALIZER
12524 (struct cmd_vf_vlan_anti_spoof_result,
12526 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12527 TOKEN_STRING_INITIALIZER
12528 (struct cmd_vf_vlan_anti_spoof_result,
12530 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12531 TOKEN_STRING_INITIALIZER
12532 (struct cmd_vf_vlan_anti_spoof_result,
12534 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12535 TOKEN_STRING_INITIALIZER
12536 (struct cmd_vf_vlan_anti_spoof_result,
12537 antispoof, "antispoof");
12538 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12539 TOKEN_NUM_INITIALIZER
12540 (struct cmd_vf_vlan_anti_spoof_result,
12542 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12543 TOKEN_NUM_INITIALIZER
12544 (struct cmd_vf_vlan_anti_spoof_result,
12546 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12547 TOKEN_STRING_INITIALIZER
12548 (struct cmd_vf_vlan_anti_spoof_result,
12552 cmd_set_vf_vlan_anti_spoof_parsed(
12553 void *parsed_result,
12554 __attribute__((unused)) struct cmdline *cl,
12555 __attribute__((unused)) void *data)
12557 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12558 int ret = -ENOTSUP;
12560 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12562 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12565 #ifdef RTE_LIBRTE_IXGBE_PMD
12566 if (ret == -ENOTSUP)
12567 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12568 res->vf_id, is_on);
12570 #ifdef RTE_LIBRTE_I40E_PMD
12571 if (ret == -ENOTSUP)
12572 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12573 res->vf_id, is_on);
12575 #ifdef RTE_LIBRTE_BNXT_PMD
12576 if (ret == -ENOTSUP)
12577 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12578 res->vf_id, is_on);
12585 printf("invalid vf_id %d\n", res->vf_id);
12588 printf("invalid port_id %d\n", res->port_id);
12591 printf("function not implemented\n");
12594 printf("programming error: (%s)\n", strerror(-ret));
12598 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12599 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12601 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12603 (void *)&cmd_vf_vlan_anti_spoof_set,
12604 (void *)&cmd_vf_vlan_anti_spoof_vf,
12605 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12606 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12607 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12608 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12609 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12614 /* vf mac anti spoof configuration */
12616 /* Common result structure for vf mac anti spoof */
12617 struct cmd_vf_mac_anti_spoof_result {
12618 cmdline_fixed_string_t set;
12619 cmdline_fixed_string_t vf;
12620 cmdline_fixed_string_t mac;
12621 cmdline_fixed_string_t antispoof;
12624 cmdline_fixed_string_t on_off;
12627 /* Common CLI fields for vf mac anti spoof enable disable */
12628 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12629 TOKEN_STRING_INITIALIZER
12630 (struct cmd_vf_mac_anti_spoof_result,
12632 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12633 TOKEN_STRING_INITIALIZER
12634 (struct cmd_vf_mac_anti_spoof_result,
12636 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12637 TOKEN_STRING_INITIALIZER
12638 (struct cmd_vf_mac_anti_spoof_result,
12640 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12641 TOKEN_STRING_INITIALIZER
12642 (struct cmd_vf_mac_anti_spoof_result,
12643 antispoof, "antispoof");
12644 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12645 TOKEN_NUM_INITIALIZER
12646 (struct cmd_vf_mac_anti_spoof_result,
12648 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12649 TOKEN_NUM_INITIALIZER
12650 (struct cmd_vf_mac_anti_spoof_result,
12652 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12653 TOKEN_STRING_INITIALIZER
12654 (struct cmd_vf_mac_anti_spoof_result,
12658 cmd_set_vf_mac_anti_spoof_parsed(
12659 void *parsed_result,
12660 __attribute__((unused)) struct cmdline *cl,
12661 __attribute__((unused)) void *data)
12663 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12664 int ret = -ENOTSUP;
12666 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12668 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12671 #ifdef RTE_LIBRTE_IXGBE_PMD
12672 if (ret == -ENOTSUP)
12673 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12674 res->vf_id, is_on);
12676 #ifdef RTE_LIBRTE_I40E_PMD
12677 if (ret == -ENOTSUP)
12678 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12679 res->vf_id, is_on);
12681 #ifdef RTE_LIBRTE_BNXT_PMD
12682 if (ret == -ENOTSUP)
12683 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12684 res->vf_id, is_on);
12691 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12694 printf("invalid port_id %d\n", res->port_id);
12697 printf("function not implemented\n");
12700 printf("programming error: (%s)\n", strerror(-ret));
12704 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12705 .f = cmd_set_vf_mac_anti_spoof_parsed,
12707 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12709 (void *)&cmd_vf_mac_anti_spoof_set,
12710 (void *)&cmd_vf_mac_anti_spoof_vf,
12711 (void *)&cmd_vf_mac_anti_spoof_mac,
12712 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12713 (void *)&cmd_vf_mac_anti_spoof_port_id,
12714 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12715 (void *)&cmd_vf_mac_anti_spoof_on_off,
12720 /* vf vlan strip queue configuration */
12722 /* Common result structure for vf mac anti spoof */
12723 struct cmd_vf_vlan_stripq_result {
12724 cmdline_fixed_string_t set;
12725 cmdline_fixed_string_t vf;
12726 cmdline_fixed_string_t vlan;
12727 cmdline_fixed_string_t stripq;
12730 cmdline_fixed_string_t on_off;
12733 /* Common CLI fields for vf vlan strip enable disable */
12734 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12735 TOKEN_STRING_INITIALIZER
12736 (struct cmd_vf_vlan_stripq_result,
12738 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12739 TOKEN_STRING_INITIALIZER
12740 (struct cmd_vf_vlan_stripq_result,
12742 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12743 TOKEN_STRING_INITIALIZER
12744 (struct cmd_vf_vlan_stripq_result,
12746 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12747 TOKEN_STRING_INITIALIZER
12748 (struct cmd_vf_vlan_stripq_result,
12750 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12751 TOKEN_NUM_INITIALIZER
12752 (struct cmd_vf_vlan_stripq_result,
12754 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12755 TOKEN_NUM_INITIALIZER
12756 (struct cmd_vf_vlan_stripq_result,
12758 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12759 TOKEN_STRING_INITIALIZER
12760 (struct cmd_vf_vlan_stripq_result,
12764 cmd_set_vf_vlan_stripq_parsed(
12765 void *parsed_result,
12766 __attribute__((unused)) struct cmdline *cl,
12767 __attribute__((unused)) void *data)
12769 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12770 int ret = -ENOTSUP;
12772 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12774 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12777 #ifdef RTE_LIBRTE_IXGBE_PMD
12778 if (ret == -ENOTSUP)
12779 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12780 res->vf_id, is_on);
12782 #ifdef RTE_LIBRTE_I40E_PMD
12783 if (ret == -ENOTSUP)
12784 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12785 res->vf_id, is_on);
12787 #ifdef RTE_LIBRTE_BNXT_PMD
12788 if (ret == -ENOTSUP)
12789 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12790 res->vf_id, is_on);
12797 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12800 printf("invalid port_id %d\n", res->port_id);
12803 printf("function not implemented\n");
12806 printf("programming error: (%s)\n", strerror(-ret));
12810 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12811 .f = cmd_set_vf_vlan_stripq_parsed,
12813 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12815 (void *)&cmd_vf_vlan_stripq_set,
12816 (void *)&cmd_vf_vlan_stripq_vf,
12817 (void *)&cmd_vf_vlan_stripq_vlan,
12818 (void *)&cmd_vf_vlan_stripq_stripq,
12819 (void *)&cmd_vf_vlan_stripq_port_id,
12820 (void *)&cmd_vf_vlan_stripq_vf_id,
12821 (void *)&cmd_vf_vlan_stripq_on_off,
12826 /* vf vlan insert configuration */
12828 /* Common result structure for vf vlan insert */
12829 struct cmd_vf_vlan_insert_result {
12830 cmdline_fixed_string_t set;
12831 cmdline_fixed_string_t vf;
12832 cmdline_fixed_string_t vlan;
12833 cmdline_fixed_string_t insert;
12839 /* Common CLI fields for vf vlan insert enable disable */
12840 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12841 TOKEN_STRING_INITIALIZER
12842 (struct cmd_vf_vlan_insert_result,
12844 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12845 TOKEN_STRING_INITIALIZER
12846 (struct cmd_vf_vlan_insert_result,
12848 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12849 TOKEN_STRING_INITIALIZER
12850 (struct cmd_vf_vlan_insert_result,
12852 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12853 TOKEN_STRING_INITIALIZER
12854 (struct cmd_vf_vlan_insert_result,
12856 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12857 TOKEN_NUM_INITIALIZER
12858 (struct cmd_vf_vlan_insert_result,
12860 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12861 TOKEN_NUM_INITIALIZER
12862 (struct cmd_vf_vlan_insert_result,
12864 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12865 TOKEN_NUM_INITIALIZER
12866 (struct cmd_vf_vlan_insert_result,
12870 cmd_set_vf_vlan_insert_parsed(
12871 void *parsed_result,
12872 __attribute__((unused)) struct cmdline *cl,
12873 __attribute__((unused)) void *data)
12875 struct cmd_vf_vlan_insert_result *res = parsed_result;
12876 int ret = -ENOTSUP;
12878 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12881 #ifdef RTE_LIBRTE_IXGBE_PMD
12882 if (ret == -ENOTSUP)
12883 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12886 #ifdef RTE_LIBRTE_I40E_PMD
12887 if (ret == -ENOTSUP)
12888 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12891 #ifdef RTE_LIBRTE_BNXT_PMD
12892 if (ret == -ENOTSUP)
12893 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12901 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12904 printf("invalid port_id %d\n", res->port_id);
12907 printf("function not implemented\n");
12910 printf("programming error: (%s)\n", strerror(-ret));
12914 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12915 .f = cmd_set_vf_vlan_insert_parsed,
12917 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12919 (void *)&cmd_vf_vlan_insert_set,
12920 (void *)&cmd_vf_vlan_insert_vf,
12921 (void *)&cmd_vf_vlan_insert_vlan,
12922 (void *)&cmd_vf_vlan_insert_insert,
12923 (void *)&cmd_vf_vlan_insert_port_id,
12924 (void *)&cmd_vf_vlan_insert_vf_id,
12925 (void *)&cmd_vf_vlan_insert_vlan_id,
12930 /* tx loopback configuration */
12932 /* Common result structure for tx loopback */
12933 struct cmd_tx_loopback_result {
12934 cmdline_fixed_string_t set;
12935 cmdline_fixed_string_t tx;
12936 cmdline_fixed_string_t loopback;
12938 cmdline_fixed_string_t on_off;
12941 /* Common CLI fields for tx loopback enable disable */
12942 cmdline_parse_token_string_t cmd_tx_loopback_set =
12943 TOKEN_STRING_INITIALIZER
12944 (struct cmd_tx_loopback_result,
12946 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12947 TOKEN_STRING_INITIALIZER
12948 (struct cmd_tx_loopback_result,
12950 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12951 TOKEN_STRING_INITIALIZER
12952 (struct cmd_tx_loopback_result,
12953 loopback, "loopback");
12954 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12955 TOKEN_NUM_INITIALIZER
12956 (struct cmd_tx_loopback_result,
12958 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12959 TOKEN_STRING_INITIALIZER
12960 (struct cmd_tx_loopback_result,
12964 cmd_set_tx_loopback_parsed(
12965 void *parsed_result,
12966 __attribute__((unused)) struct cmdline *cl,
12967 __attribute__((unused)) void *data)
12969 struct cmd_tx_loopback_result *res = parsed_result;
12970 int ret = -ENOTSUP;
12972 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12974 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12977 #ifdef RTE_LIBRTE_IXGBE_PMD
12978 if (ret == -ENOTSUP)
12979 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12981 #ifdef RTE_LIBRTE_I40E_PMD
12982 if (ret == -ENOTSUP)
12983 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12985 #ifdef RTE_LIBRTE_BNXT_PMD
12986 if (ret == -ENOTSUP)
12987 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12989 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
12990 if (ret == -ENOTSUP)
12991 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12998 printf("invalid is_on %d\n", is_on);
13001 printf("invalid port_id %d\n", res->port_id);
13004 printf("function not implemented\n");
13007 printf("programming error: (%s)\n", strerror(-ret));
13011 cmdline_parse_inst_t cmd_set_tx_loopback = {
13012 .f = cmd_set_tx_loopback_parsed,
13014 .help_str = "set tx loopback <port_id> on|off",
13016 (void *)&cmd_tx_loopback_set,
13017 (void *)&cmd_tx_loopback_tx,
13018 (void *)&cmd_tx_loopback_loopback,
13019 (void *)&cmd_tx_loopback_port_id,
13020 (void *)&cmd_tx_loopback_on_off,
13025 /* all queues drop enable configuration */
13027 /* Common result structure for all queues drop enable */
13028 struct cmd_all_queues_drop_en_result {
13029 cmdline_fixed_string_t set;
13030 cmdline_fixed_string_t all;
13031 cmdline_fixed_string_t queues;
13032 cmdline_fixed_string_t drop;
13034 cmdline_fixed_string_t on_off;
13037 /* Common CLI fields for tx loopback enable disable */
13038 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13039 TOKEN_STRING_INITIALIZER
13040 (struct cmd_all_queues_drop_en_result,
13042 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13043 TOKEN_STRING_INITIALIZER
13044 (struct cmd_all_queues_drop_en_result,
13046 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13047 TOKEN_STRING_INITIALIZER
13048 (struct cmd_all_queues_drop_en_result,
13050 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13051 TOKEN_STRING_INITIALIZER
13052 (struct cmd_all_queues_drop_en_result,
13054 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13055 TOKEN_NUM_INITIALIZER
13056 (struct cmd_all_queues_drop_en_result,
13058 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13059 TOKEN_STRING_INITIALIZER
13060 (struct cmd_all_queues_drop_en_result,
13064 cmd_set_all_queues_drop_en_parsed(
13065 void *parsed_result,
13066 __attribute__((unused)) struct cmdline *cl,
13067 __attribute__((unused)) void *data)
13069 struct cmd_all_queues_drop_en_result *res = parsed_result;
13070 int ret = -ENOTSUP;
13071 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13073 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13076 #ifdef RTE_LIBRTE_IXGBE_PMD
13077 if (ret == -ENOTSUP)
13078 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13080 #ifdef RTE_LIBRTE_BNXT_PMD
13081 if (ret == -ENOTSUP)
13082 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13088 printf("invalid is_on %d\n", is_on);
13091 printf("invalid port_id %d\n", res->port_id);
13094 printf("function not implemented\n");
13097 printf("programming error: (%s)\n", strerror(-ret));
13101 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13102 .f = cmd_set_all_queues_drop_en_parsed,
13104 .help_str = "set all queues drop <port_id> on|off",
13106 (void *)&cmd_all_queues_drop_en_set,
13107 (void *)&cmd_all_queues_drop_en_all,
13108 (void *)&cmd_all_queues_drop_en_queues,
13109 (void *)&cmd_all_queues_drop_en_drop,
13110 (void *)&cmd_all_queues_drop_en_port_id,
13111 (void *)&cmd_all_queues_drop_en_on_off,
13116 /* vf split drop enable configuration */
13118 /* Common result structure for vf split drop enable */
13119 struct cmd_vf_split_drop_en_result {
13120 cmdline_fixed_string_t set;
13121 cmdline_fixed_string_t vf;
13122 cmdline_fixed_string_t split;
13123 cmdline_fixed_string_t drop;
13126 cmdline_fixed_string_t on_off;
13129 /* Common CLI fields for vf split drop enable disable */
13130 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13131 TOKEN_STRING_INITIALIZER
13132 (struct cmd_vf_split_drop_en_result,
13134 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13135 TOKEN_STRING_INITIALIZER
13136 (struct cmd_vf_split_drop_en_result,
13138 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13139 TOKEN_STRING_INITIALIZER
13140 (struct cmd_vf_split_drop_en_result,
13142 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13143 TOKEN_STRING_INITIALIZER
13144 (struct cmd_vf_split_drop_en_result,
13146 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13147 TOKEN_NUM_INITIALIZER
13148 (struct cmd_vf_split_drop_en_result,
13150 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13151 TOKEN_NUM_INITIALIZER
13152 (struct cmd_vf_split_drop_en_result,
13154 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13155 TOKEN_STRING_INITIALIZER
13156 (struct cmd_vf_split_drop_en_result,
13160 cmd_set_vf_split_drop_en_parsed(
13161 void *parsed_result,
13162 __attribute__((unused)) struct cmdline *cl,
13163 __attribute__((unused)) void *data)
13165 struct cmd_vf_split_drop_en_result *res = parsed_result;
13166 int ret = -ENOTSUP;
13167 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13169 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13172 #ifdef RTE_LIBRTE_IXGBE_PMD
13173 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13180 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13183 printf("invalid port_id %d\n", res->port_id);
13186 printf("not supported on port %d\n", res->port_id);
13189 printf("programming error: (%s)\n", strerror(-ret));
13193 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13194 .f = cmd_set_vf_split_drop_en_parsed,
13196 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13198 (void *)&cmd_vf_split_drop_en_set,
13199 (void *)&cmd_vf_split_drop_en_vf,
13200 (void *)&cmd_vf_split_drop_en_split,
13201 (void *)&cmd_vf_split_drop_en_drop,
13202 (void *)&cmd_vf_split_drop_en_port_id,
13203 (void *)&cmd_vf_split_drop_en_vf_id,
13204 (void *)&cmd_vf_split_drop_en_on_off,
13209 /* vf mac address configuration */
13211 /* Common result structure for vf mac address */
13212 struct cmd_set_vf_mac_addr_result {
13213 cmdline_fixed_string_t set;
13214 cmdline_fixed_string_t vf;
13215 cmdline_fixed_string_t mac;
13216 cmdline_fixed_string_t addr;
13219 struct ether_addr mac_addr;
13223 /* Common CLI fields for vf split drop enable disable */
13224 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13225 TOKEN_STRING_INITIALIZER
13226 (struct cmd_set_vf_mac_addr_result,
13228 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13229 TOKEN_STRING_INITIALIZER
13230 (struct cmd_set_vf_mac_addr_result,
13232 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13233 TOKEN_STRING_INITIALIZER
13234 (struct cmd_set_vf_mac_addr_result,
13236 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13237 TOKEN_STRING_INITIALIZER
13238 (struct cmd_set_vf_mac_addr_result,
13240 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13241 TOKEN_NUM_INITIALIZER
13242 (struct cmd_set_vf_mac_addr_result,
13244 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13245 TOKEN_NUM_INITIALIZER
13246 (struct cmd_set_vf_mac_addr_result,
13248 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13249 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13253 cmd_set_vf_mac_addr_parsed(
13254 void *parsed_result,
13255 __attribute__((unused)) struct cmdline *cl,
13256 __attribute__((unused)) void *data)
13258 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13259 int ret = -ENOTSUP;
13261 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13264 #ifdef RTE_LIBRTE_IXGBE_PMD
13265 if (ret == -ENOTSUP)
13266 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13269 #ifdef RTE_LIBRTE_I40E_PMD
13270 if (ret == -ENOTSUP)
13271 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13274 #ifdef RTE_LIBRTE_BNXT_PMD
13275 if (ret == -ENOTSUP)
13276 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13284 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13287 printf("invalid port_id %d\n", res->port_id);
13290 printf("function not implemented\n");
13293 printf("programming error: (%s)\n", strerror(-ret));
13297 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13298 .f = cmd_set_vf_mac_addr_parsed,
13300 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13302 (void *)&cmd_set_vf_mac_addr_set,
13303 (void *)&cmd_set_vf_mac_addr_vf,
13304 (void *)&cmd_set_vf_mac_addr_mac,
13305 (void *)&cmd_set_vf_mac_addr_addr,
13306 (void *)&cmd_set_vf_mac_addr_port_id,
13307 (void *)&cmd_set_vf_mac_addr_vf_id,
13308 (void *)&cmd_set_vf_mac_addr_mac_addr,
13313 /* MACsec configuration */
13315 /* Common result structure for MACsec offload enable */
13316 struct cmd_macsec_offload_on_result {
13317 cmdline_fixed_string_t set;
13318 cmdline_fixed_string_t macsec;
13319 cmdline_fixed_string_t offload;
13321 cmdline_fixed_string_t on;
13322 cmdline_fixed_string_t encrypt;
13323 cmdline_fixed_string_t en_on_off;
13324 cmdline_fixed_string_t replay_protect;
13325 cmdline_fixed_string_t rp_on_off;
13328 /* Common CLI fields for MACsec offload disable */
13329 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13330 TOKEN_STRING_INITIALIZER
13331 (struct cmd_macsec_offload_on_result,
13333 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13334 TOKEN_STRING_INITIALIZER
13335 (struct cmd_macsec_offload_on_result,
13337 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13338 TOKEN_STRING_INITIALIZER
13339 (struct cmd_macsec_offload_on_result,
13340 offload, "offload");
13341 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13342 TOKEN_NUM_INITIALIZER
13343 (struct cmd_macsec_offload_on_result,
13345 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13346 TOKEN_STRING_INITIALIZER
13347 (struct cmd_macsec_offload_on_result,
13349 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13350 TOKEN_STRING_INITIALIZER
13351 (struct cmd_macsec_offload_on_result,
13352 encrypt, "encrypt");
13353 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13354 TOKEN_STRING_INITIALIZER
13355 (struct cmd_macsec_offload_on_result,
13356 en_on_off, "on#off");
13357 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13358 TOKEN_STRING_INITIALIZER
13359 (struct cmd_macsec_offload_on_result,
13360 replay_protect, "replay-protect");
13361 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13362 TOKEN_STRING_INITIALIZER
13363 (struct cmd_macsec_offload_on_result,
13364 rp_on_off, "on#off");
13367 cmd_set_macsec_offload_on_parsed(
13368 void *parsed_result,
13369 __attribute__((unused)) struct cmdline *cl,
13370 __attribute__((unused)) void *data)
13372 struct cmd_macsec_offload_on_result *res = parsed_result;
13373 int ret = -ENOTSUP;
13374 portid_t port_id = res->port_id;
13375 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13376 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13377 struct rte_eth_dev_info dev_info;
13379 if (port_id_is_invalid(port_id, ENABLED_WARN))
13381 if (!port_is_stopped(port_id)) {
13382 printf("Please stop port %d first\n", port_id);
13386 rte_eth_dev_info_get(port_id, &dev_info);
13387 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13388 #ifdef RTE_LIBRTE_IXGBE_PMD
13389 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13397 ports[port_id].dev_conf.txmode.offloads |=
13398 DEV_TX_OFFLOAD_MACSEC_INSERT;
13399 cmd_reconfig_device_queue(port_id, 1, 1);
13402 printf("invalid port_id %d\n", port_id);
13405 printf("not supported on port %d\n", port_id);
13408 printf("programming error: (%s)\n", strerror(-ret));
13412 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13413 .f = cmd_set_macsec_offload_on_parsed,
13415 .help_str = "set macsec offload <port_id> on "
13416 "encrypt on|off replay-protect on|off",
13418 (void *)&cmd_macsec_offload_on_set,
13419 (void *)&cmd_macsec_offload_on_macsec,
13420 (void *)&cmd_macsec_offload_on_offload,
13421 (void *)&cmd_macsec_offload_on_port_id,
13422 (void *)&cmd_macsec_offload_on_on,
13423 (void *)&cmd_macsec_offload_on_encrypt,
13424 (void *)&cmd_macsec_offload_on_en_on_off,
13425 (void *)&cmd_macsec_offload_on_replay_protect,
13426 (void *)&cmd_macsec_offload_on_rp_on_off,
13431 /* Common result structure for MACsec offload disable */
13432 struct cmd_macsec_offload_off_result {
13433 cmdline_fixed_string_t set;
13434 cmdline_fixed_string_t macsec;
13435 cmdline_fixed_string_t offload;
13437 cmdline_fixed_string_t off;
13440 /* Common CLI fields for MACsec offload disable */
13441 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13442 TOKEN_STRING_INITIALIZER
13443 (struct cmd_macsec_offload_off_result,
13445 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13446 TOKEN_STRING_INITIALIZER
13447 (struct cmd_macsec_offload_off_result,
13449 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13450 TOKEN_STRING_INITIALIZER
13451 (struct cmd_macsec_offload_off_result,
13452 offload, "offload");
13453 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13454 TOKEN_NUM_INITIALIZER
13455 (struct cmd_macsec_offload_off_result,
13457 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13458 TOKEN_STRING_INITIALIZER
13459 (struct cmd_macsec_offload_off_result,
13463 cmd_set_macsec_offload_off_parsed(
13464 void *parsed_result,
13465 __attribute__((unused)) struct cmdline *cl,
13466 __attribute__((unused)) void *data)
13468 struct cmd_macsec_offload_off_result *res = parsed_result;
13469 int ret = -ENOTSUP;
13470 struct rte_eth_dev_info dev_info;
13471 portid_t port_id = res->port_id;
13473 if (port_id_is_invalid(port_id, ENABLED_WARN))
13475 if (!port_is_stopped(port_id)) {
13476 printf("Please stop port %d first\n", port_id);
13480 rte_eth_dev_info_get(port_id, &dev_info);
13481 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13482 #ifdef RTE_LIBRTE_IXGBE_PMD
13483 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13488 ports[port_id].dev_conf.txmode.offloads &=
13489 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13490 cmd_reconfig_device_queue(port_id, 1, 1);
13493 printf("invalid port_id %d\n", port_id);
13496 printf("not supported on port %d\n", port_id);
13499 printf("programming error: (%s)\n", strerror(-ret));
13503 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13504 .f = cmd_set_macsec_offload_off_parsed,
13506 .help_str = "set macsec offload <port_id> off",
13508 (void *)&cmd_macsec_offload_off_set,
13509 (void *)&cmd_macsec_offload_off_macsec,
13510 (void *)&cmd_macsec_offload_off_offload,
13511 (void *)&cmd_macsec_offload_off_port_id,
13512 (void *)&cmd_macsec_offload_off_off,
13517 /* Common result structure for MACsec secure connection configure */
13518 struct cmd_macsec_sc_result {
13519 cmdline_fixed_string_t set;
13520 cmdline_fixed_string_t macsec;
13521 cmdline_fixed_string_t sc;
13522 cmdline_fixed_string_t tx_rx;
13524 struct ether_addr mac;
13528 /* Common CLI fields for MACsec secure connection configure */
13529 cmdline_parse_token_string_t cmd_macsec_sc_set =
13530 TOKEN_STRING_INITIALIZER
13531 (struct cmd_macsec_sc_result,
13533 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13534 TOKEN_STRING_INITIALIZER
13535 (struct cmd_macsec_sc_result,
13537 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13538 TOKEN_STRING_INITIALIZER
13539 (struct cmd_macsec_sc_result,
13541 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13542 TOKEN_STRING_INITIALIZER
13543 (struct cmd_macsec_sc_result,
13545 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13546 TOKEN_NUM_INITIALIZER
13547 (struct cmd_macsec_sc_result,
13549 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13550 TOKEN_ETHERADDR_INITIALIZER
13551 (struct cmd_macsec_sc_result,
13553 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13554 TOKEN_NUM_INITIALIZER
13555 (struct cmd_macsec_sc_result,
13559 cmd_set_macsec_sc_parsed(
13560 void *parsed_result,
13561 __attribute__((unused)) struct cmdline *cl,
13562 __attribute__((unused)) void *data)
13564 struct cmd_macsec_sc_result *res = parsed_result;
13565 int ret = -ENOTSUP;
13566 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13568 #ifdef RTE_LIBRTE_IXGBE_PMD
13570 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13571 res->mac.addr_bytes) :
13572 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13573 res->mac.addr_bytes, res->pi);
13575 RTE_SET_USED(is_tx);
13581 printf("invalid port_id %d\n", res->port_id);
13584 printf("not supported on port %d\n", res->port_id);
13587 printf("programming error: (%s)\n", strerror(-ret));
13591 cmdline_parse_inst_t cmd_set_macsec_sc = {
13592 .f = cmd_set_macsec_sc_parsed,
13594 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13596 (void *)&cmd_macsec_sc_set,
13597 (void *)&cmd_macsec_sc_macsec,
13598 (void *)&cmd_macsec_sc_sc,
13599 (void *)&cmd_macsec_sc_tx_rx,
13600 (void *)&cmd_macsec_sc_port_id,
13601 (void *)&cmd_macsec_sc_mac,
13602 (void *)&cmd_macsec_sc_pi,
13607 /* Common result structure for MACsec secure connection configure */
13608 struct cmd_macsec_sa_result {
13609 cmdline_fixed_string_t set;
13610 cmdline_fixed_string_t macsec;
13611 cmdline_fixed_string_t sa;
13612 cmdline_fixed_string_t tx_rx;
13617 cmdline_fixed_string_t key;
13620 /* Common CLI fields for MACsec secure connection configure */
13621 cmdline_parse_token_string_t cmd_macsec_sa_set =
13622 TOKEN_STRING_INITIALIZER
13623 (struct cmd_macsec_sa_result,
13625 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13626 TOKEN_STRING_INITIALIZER
13627 (struct cmd_macsec_sa_result,
13629 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13630 TOKEN_STRING_INITIALIZER
13631 (struct cmd_macsec_sa_result,
13633 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13634 TOKEN_STRING_INITIALIZER
13635 (struct cmd_macsec_sa_result,
13637 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13638 TOKEN_NUM_INITIALIZER
13639 (struct cmd_macsec_sa_result,
13641 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13642 TOKEN_NUM_INITIALIZER
13643 (struct cmd_macsec_sa_result,
13645 cmdline_parse_token_num_t cmd_macsec_sa_an =
13646 TOKEN_NUM_INITIALIZER
13647 (struct cmd_macsec_sa_result,
13649 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13650 TOKEN_NUM_INITIALIZER
13651 (struct cmd_macsec_sa_result,
13653 cmdline_parse_token_string_t cmd_macsec_sa_key =
13654 TOKEN_STRING_INITIALIZER
13655 (struct cmd_macsec_sa_result,
13659 cmd_set_macsec_sa_parsed(
13660 void *parsed_result,
13661 __attribute__((unused)) struct cmdline *cl,
13662 __attribute__((unused)) void *data)
13664 struct cmd_macsec_sa_result *res = parsed_result;
13665 int ret = -ENOTSUP;
13666 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13667 uint8_t key[16] = { 0 };
13673 key_len = strlen(res->key) / 2;
13677 for (i = 0; i < key_len; i++) {
13678 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13681 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13684 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13687 #ifdef RTE_LIBRTE_IXGBE_PMD
13689 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13690 res->idx, res->an, res->pn, key) :
13691 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13692 res->idx, res->an, res->pn, key);
13694 RTE_SET_USED(is_tx);
13701 printf("invalid idx %d or an %d\n", res->idx, res->an);
13704 printf("invalid port_id %d\n", res->port_id);
13707 printf("not supported on port %d\n", res->port_id);
13710 printf("programming error: (%s)\n", strerror(-ret));
13714 cmdline_parse_inst_t cmd_set_macsec_sa = {
13715 .f = cmd_set_macsec_sa_parsed,
13717 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13719 (void *)&cmd_macsec_sa_set,
13720 (void *)&cmd_macsec_sa_macsec,
13721 (void *)&cmd_macsec_sa_sa,
13722 (void *)&cmd_macsec_sa_tx_rx,
13723 (void *)&cmd_macsec_sa_port_id,
13724 (void *)&cmd_macsec_sa_idx,
13725 (void *)&cmd_macsec_sa_an,
13726 (void *)&cmd_macsec_sa_pn,
13727 (void *)&cmd_macsec_sa_key,
13732 /* VF unicast promiscuous mode configuration */
13734 /* Common result structure for VF unicast promiscuous mode */
13735 struct cmd_vf_promisc_result {
13736 cmdline_fixed_string_t set;
13737 cmdline_fixed_string_t vf;
13738 cmdline_fixed_string_t promisc;
13741 cmdline_fixed_string_t on_off;
13744 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13745 cmdline_parse_token_string_t cmd_vf_promisc_set =
13746 TOKEN_STRING_INITIALIZER
13747 (struct cmd_vf_promisc_result,
13749 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13750 TOKEN_STRING_INITIALIZER
13751 (struct cmd_vf_promisc_result,
13753 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13754 TOKEN_STRING_INITIALIZER
13755 (struct cmd_vf_promisc_result,
13756 promisc, "promisc");
13757 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13758 TOKEN_NUM_INITIALIZER
13759 (struct cmd_vf_promisc_result,
13761 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13762 TOKEN_NUM_INITIALIZER
13763 (struct cmd_vf_promisc_result,
13765 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13766 TOKEN_STRING_INITIALIZER
13767 (struct cmd_vf_promisc_result,
13771 cmd_set_vf_promisc_parsed(
13772 void *parsed_result,
13773 __attribute__((unused)) struct cmdline *cl,
13774 __attribute__((unused)) void *data)
13776 struct cmd_vf_promisc_result *res = parsed_result;
13777 int ret = -ENOTSUP;
13779 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13781 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13784 #ifdef RTE_LIBRTE_I40E_PMD
13785 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13786 res->vf_id, is_on);
13793 printf("invalid vf_id %d\n", res->vf_id);
13796 printf("invalid port_id %d\n", res->port_id);
13799 printf("function not implemented\n");
13802 printf("programming error: (%s)\n", strerror(-ret));
13806 cmdline_parse_inst_t cmd_set_vf_promisc = {
13807 .f = cmd_set_vf_promisc_parsed,
13809 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13810 "Set unicast promiscuous mode for a VF from the PF",
13812 (void *)&cmd_vf_promisc_set,
13813 (void *)&cmd_vf_promisc_vf,
13814 (void *)&cmd_vf_promisc_promisc,
13815 (void *)&cmd_vf_promisc_port_id,
13816 (void *)&cmd_vf_promisc_vf_id,
13817 (void *)&cmd_vf_promisc_on_off,
13822 /* VF multicast promiscuous mode configuration */
13824 /* Common result structure for VF multicast promiscuous mode */
13825 struct cmd_vf_allmulti_result {
13826 cmdline_fixed_string_t set;
13827 cmdline_fixed_string_t vf;
13828 cmdline_fixed_string_t allmulti;
13831 cmdline_fixed_string_t on_off;
13834 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13835 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13836 TOKEN_STRING_INITIALIZER
13837 (struct cmd_vf_allmulti_result,
13839 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13840 TOKEN_STRING_INITIALIZER
13841 (struct cmd_vf_allmulti_result,
13843 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13844 TOKEN_STRING_INITIALIZER
13845 (struct cmd_vf_allmulti_result,
13846 allmulti, "allmulti");
13847 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13848 TOKEN_NUM_INITIALIZER
13849 (struct cmd_vf_allmulti_result,
13851 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13852 TOKEN_NUM_INITIALIZER
13853 (struct cmd_vf_allmulti_result,
13855 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13856 TOKEN_STRING_INITIALIZER
13857 (struct cmd_vf_allmulti_result,
13861 cmd_set_vf_allmulti_parsed(
13862 void *parsed_result,
13863 __attribute__((unused)) struct cmdline *cl,
13864 __attribute__((unused)) void *data)
13866 struct cmd_vf_allmulti_result *res = parsed_result;
13867 int ret = -ENOTSUP;
13869 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13871 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13874 #ifdef RTE_LIBRTE_I40E_PMD
13875 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13876 res->vf_id, is_on);
13883 printf("invalid vf_id %d\n", res->vf_id);
13886 printf("invalid port_id %d\n", res->port_id);
13889 printf("function not implemented\n");
13892 printf("programming error: (%s)\n", strerror(-ret));
13896 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13897 .f = cmd_set_vf_allmulti_parsed,
13899 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13900 "Set multicast promiscuous mode for a VF from the PF",
13902 (void *)&cmd_vf_allmulti_set,
13903 (void *)&cmd_vf_allmulti_vf,
13904 (void *)&cmd_vf_allmulti_allmulti,
13905 (void *)&cmd_vf_allmulti_port_id,
13906 (void *)&cmd_vf_allmulti_vf_id,
13907 (void *)&cmd_vf_allmulti_on_off,
13912 /* vf broadcast mode configuration */
13914 /* Common result structure for vf broadcast */
13915 struct cmd_set_vf_broadcast_result {
13916 cmdline_fixed_string_t set;
13917 cmdline_fixed_string_t vf;
13918 cmdline_fixed_string_t broadcast;
13921 cmdline_fixed_string_t on_off;
13924 /* Common CLI fields for vf broadcast enable disable */
13925 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13926 TOKEN_STRING_INITIALIZER
13927 (struct cmd_set_vf_broadcast_result,
13929 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13930 TOKEN_STRING_INITIALIZER
13931 (struct cmd_set_vf_broadcast_result,
13933 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13934 TOKEN_STRING_INITIALIZER
13935 (struct cmd_set_vf_broadcast_result,
13936 broadcast, "broadcast");
13937 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13938 TOKEN_NUM_INITIALIZER
13939 (struct cmd_set_vf_broadcast_result,
13941 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13942 TOKEN_NUM_INITIALIZER
13943 (struct cmd_set_vf_broadcast_result,
13945 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13946 TOKEN_STRING_INITIALIZER
13947 (struct cmd_set_vf_broadcast_result,
13951 cmd_set_vf_broadcast_parsed(
13952 void *parsed_result,
13953 __attribute__((unused)) struct cmdline *cl,
13954 __attribute__((unused)) void *data)
13956 struct cmd_set_vf_broadcast_result *res = parsed_result;
13957 int ret = -ENOTSUP;
13959 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13961 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13964 #ifdef RTE_LIBRTE_I40E_PMD
13965 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13966 res->vf_id, is_on);
13973 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13976 printf("invalid port_id %d\n", res->port_id);
13979 printf("function not implemented\n");
13982 printf("programming error: (%s)\n", strerror(-ret));
13986 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13987 .f = cmd_set_vf_broadcast_parsed,
13989 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13991 (void *)&cmd_set_vf_broadcast_set,
13992 (void *)&cmd_set_vf_broadcast_vf,
13993 (void *)&cmd_set_vf_broadcast_broadcast,
13994 (void *)&cmd_set_vf_broadcast_port_id,
13995 (void *)&cmd_set_vf_broadcast_vf_id,
13996 (void *)&cmd_set_vf_broadcast_on_off,
14001 /* vf vlan tag configuration */
14003 /* Common result structure for vf vlan tag */
14004 struct cmd_set_vf_vlan_tag_result {
14005 cmdline_fixed_string_t set;
14006 cmdline_fixed_string_t vf;
14007 cmdline_fixed_string_t vlan;
14008 cmdline_fixed_string_t tag;
14011 cmdline_fixed_string_t on_off;
14014 /* Common CLI fields for vf vlan tag enable disable */
14015 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14016 TOKEN_STRING_INITIALIZER
14017 (struct cmd_set_vf_vlan_tag_result,
14019 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14020 TOKEN_STRING_INITIALIZER
14021 (struct cmd_set_vf_vlan_tag_result,
14023 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14024 TOKEN_STRING_INITIALIZER
14025 (struct cmd_set_vf_vlan_tag_result,
14027 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14028 TOKEN_STRING_INITIALIZER
14029 (struct cmd_set_vf_vlan_tag_result,
14031 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14032 TOKEN_NUM_INITIALIZER
14033 (struct cmd_set_vf_vlan_tag_result,
14035 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14036 TOKEN_NUM_INITIALIZER
14037 (struct cmd_set_vf_vlan_tag_result,
14039 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14040 TOKEN_STRING_INITIALIZER
14041 (struct cmd_set_vf_vlan_tag_result,
14045 cmd_set_vf_vlan_tag_parsed(
14046 void *parsed_result,
14047 __attribute__((unused)) struct cmdline *cl,
14048 __attribute__((unused)) void *data)
14050 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14051 int ret = -ENOTSUP;
14053 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14055 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14058 #ifdef RTE_LIBRTE_I40E_PMD
14059 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14060 res->vf_id, is_on);
14067 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14070 printf("invalid port_id %d\n", res->port_id);
14073 printf("function not implemented\n");
14076 printf("programming error: (%s)\n", strerror(-ret));
14080 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14081 .f = cmd_set_vf_vlan_tag_parsed,
14083 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14085 (void *)&cmd_set_vf_vlan_tag_set,
14086 (void *)&cmd_set_vf_vlan_tag_vf,
14087 (void *)&cmd_set_vf_vlan_tag_vlan,
14088 (void *)&cmd_set_vf_vlan_tag_tag,
14089 (void *)&cmd_set_vf_vlan_tag_port_id,
14090 (void *)&cmd_set_vf_vlan_tag_vf_id,
14091 (void *)&cmd_set_vf_vlan_tag_on_off,
14096 /* Common definition of VF and TC TX bandwidth configuration */
14097 struct cmd_vf_tc_bw_result {
14098 cmdline_fixed_string_t set;
14099 cmdline_fixed_string_t vf;
14100 cmdline_fixed_string_t tc;
14101 cmdline_fixed_string_t tx;
14102 cmdline_fixed_string_t min_bw;
14103 cmdline_fixed_string_t max_bw;
14104 cmdline_fixed_string_t strict_link_prio;
14109 cmdline_fixed_string_t bw_list;
14113 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14114 TOKEN_STRING_INITIALIZER
14115 (struct cmd_vf_tc_bw_result,
14117 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14118 TOKEN_STRING_INITIALIZER
14119 (struct cmd_vf_tc_bw_result,
14121 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14122 TOKEN_STRING_INITIALIZER
14123 (struct cmd_vf_tc_bw_result,
14125 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14126 TOKEN_STRING_INITIALIZER
14127 (struct cmd_vf_tc_bw_result,
14129 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14130 TOKEN_STRING_INITIALIZER
14131 (struct cmd_vf_tc_bw_result,
14132 strict_link_prio, "strict-link-priority");
14133 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14134 TOKEN_STRING_INITIALIZER
14135 (struct cmd_vf_tc_bw_result,
14136 min_bw, "min-bandwidth");
14137 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14138 TOKEN_STRING_INITIALIZER
14139 (struct cmd_vf_tc_bw_result,
14140 max_bw, "max-bandwidth");
14141 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14142 TOKEN_NUM_INITIALIZER
14143 (struct cmd_vf_tc_bw_result,
14145 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14146 TOKEN_NUM_INITIALIZER
14147 (struct cmd_vf_tc_bw_result,
14149 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14150 TOKEN_NUM_INITIALIZER
14151 (struct cmd_vf_tc_bw_result,
14153 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14154 TOKEN_NUM_INITIALIZER
14155 (struct cmd_vf_tc_bw_result,
14157 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14158 TOKEN_STRING_INITIALIZER
14159 (struct cmd_vf_tc_bw_result,
14161 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14162 TOKEN_NUM_INITIALIZER
14163 (struct cmd_vf_tc_bw_result,
14166 /* VF max bandwidth setting */
14168 cmd_vf_max_bw_parsed(
14169 void *parsed_result,
14170 __attribute__((unused)) struct cmdline *cl,
14171 __attribute__((unused)) void *data)
14173 struct cmd_vf_tc_bw_result *res = parsed_result;
14174 int ret = -ENOTSUP;
14176 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14179 #ifdef RTE_LIBRTE_I40E_PMD
14180 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14181 res->vf_id, res->bw);
14188 printf("invalid vf_id %d or bandwidth %d\n",
14189 res->vf_id, res->bw);
14192 printf("invalid port_id %d\n", res->port_id);
14195 printf("function not implemented\n");
14198 printf("programming error: (%s)\n", strerror(-ret));
14202 cmdline_parse_inst_t cmd_vf_max_bw = {
14203 .f = cmd_vf_max_bw_parsed,
14205 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14207 (void *)&cmd_vf_tc_bw_set,
14208 (void *)&cmd_vf_tc_bw_vf,
14209 (void *)&cmd_vf_tc_bw_tx,
14210 (void *)&cmd_vf_tc_bw_max_bw,
14211 (void *)&cmd_vf_tc_bw_port_id,
14212 (void *)&cmd_vf_tc_bw_vf_id,
14213 (void *)&cmd_vf_tc_bw_bw,
14219 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14224 const char *p, *p0 = str;
14231 p = strchr(p0, '(');
14233 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14237 p0 = strchr(p, ')');
14239 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14243 if (size >= sizeof(s)) {
14244 printf("The string size exceeds the internal buffer size\n");
14247 snprintf(s, sizeof(s), "%.*s", size, p);
14248 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14250 printf("Failed to get the bandwidth list. ");
14254 for (i = 0; i < ret; i++)
14255 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14260 /* TC min bandwidth setting */
14262 cmd_vf_tc_min_bw_parsed(
14263 void *parsed_result,
14264 __attribute__((unused)) struct cmdline *cl,
14265 __attribute__((unused)) void *data)
14267 struct cmd_vf_tc_bw_result *res = parsed_result;
14270 int ret = -ENOTSUP;
14272 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14275 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14279 #ifdef RTE_LIBRTE_I40E_PMD
14280 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14288 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14291 printf("invalid port_id %d\n", res->port_id);
14294 printf("function not implemented\n");
14297 printf("programming error: (%s)\n", strerror(-ret));
14301 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14302 .f = cmd_vf_tc_min_bw_parsed,
14304 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14305 " <bw1, bw2, ...>",
14307 (void *)&cmd_vf_tc_bw_set,
14308 (void *)&cmd_vf_tc_bw_vf,
14309 (void *)&cmd_vf_tc_bw_tc,
14310 (void *)&cmd_vf_tc_bw_tx,
14311 (void *)&cmd_vf_tc_bw_min_bw,
14312 (void *)&cmd_vf_tc_bw_port_id,
14313 (void *)&cmd_vf_tc_bw_vf_id,
14314 (void *)&cmd_vf_tc_bw_bw_list,
14320 cmd_tc_min_bw_parsed(
14321 void *parsed_result,
14322 __attribute__((unused)) struct cmdline *cl,
14323 __attribute__((unused)) void *data)
14325 struct cmd_vf_tc_bw_result *res = parsed_result;
14326 struct rte_port *port;
14329 int ret = -ENOTSUP;
14331 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14334 port = &ports[res->port_id];
14335 /** Check if the port is not started **/
14336 if (port->port_status != RTE_PORT_STOPPED) {
14337 printf("Please stop port %d first\n", res->port_id);
14341 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14345 #ifdef RTE_LIBRTE_IXGBE_PMD
14346 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14353 printf("invalid bandwidth\n");
14356 printf("invalid port_id %d\n", res->port_id);
14359 printf("function not implemented\n");
14362 printf("programming error: (%s)\n", strerror(-ret));
14366 cmdline_parse_inst_t cmd_tc_min_bw = {
14367 .f = cmd_tc_min_bw_parsed,
14369 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14371 (void *)&cmd_vf_tc_bw_set,
14372 (void *)&cmd_vf_tc_bw_tc,
14373 (void *)&cmd_vf_tc_bw_tx,
14374 (void *)&cmd_vf_tc_bw_min_bw,
14375 (void *)&cmd_vf_tc_bw_port_id,
14376 (void *)&cmd_vf_tc_bw_bw_list,
14381 /* TC max bandwidth setting */
14383 cmd_vf_tc_max_bw_parsed(
14384 void *parsed_result,
14385 __attribute__((unused)) struct cmdline *cl,
14386 __attribute__((unused)) void *data)
14388 struct cmd_vf_tc_bw_result *res = parsed_result;
14389 int ret = -ENOTSUP;
14391 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14394 #ifdef RTE_LIBRTE_I40E_PMD
14395 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14396 res->tc_no, res->bw);
14403 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14404 res->vf_id, res->tc_no, res->bw);
14407 printf("invalid port_id %d\n", res->port_id);
14410 printf("function not implemented\n");
14413 printf("programming error: (%s)\n", strerror(-ret));
14417 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14418 .f = cmd_vf_tc_max_bw_parsed,
14420 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14423 (void *)&cmd_vf_tc_bw_set,
14424 (void *)&cmd_vf_tc_bw_vf,
14425 (void *)&cmd_vf_tc_bw_tc,
14426 (void *)&cmd_vf_tc_bw_tx,
14427 (void *)&cmd_vf_tc_bw_max_bw,
14428 (void *)&cmd_vf_tc_bw_port_id,
14429 (void *)&cmd_vf_tc_bw_vf_id,
14430 (void *)&cmd_vf_tc_bw_tc_no,
14431 (void *)&cmd_vf_tc_bw_bw,
14437 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14439 /* *** Set Port default Traffic Management Hierarchy *** */
14440 struct cmd_set_port_tm_hierarchy_default_result {
14441 cmdline_fixed_string_t set;
14442 cmdline_fixed_string_t port;
14443 cmdline_fixed_string_t tm;
14444 cmdline_fixed_string_t hierarchy;
14445 cmdline_fixed_string_t def;
14449 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14450 TOKEN_STRING_INITIALIZER(
14451 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14452 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14453 TOKEN_STRING_INITIALIZER(
14454 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14455 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14456 TOKEN_STRING_INITIALIZER(
14457 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14458 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14459 TOKEN_STRING_INITIALIZER(
14460 struct cmd_set_port_tm_hierarchy_default_result,
14461 hierarchy, "hierarchy");
14462 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14463 TOKEN_STRING_INITIALIZER(
14464 struct cmd_set_port_tm_hierarchy_default_result,
14466 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14467 TOKEN_NUM_INITIALIZER(
14468 struct cmd_set_port_tm_hierarchy_default_result,
14471 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14472 __attribute__((unused)) struct cmdline *cl,
14473 __attribute__((unused)) void *data)
14475 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14476 struct rte_port *p;
14477 portid_t port_id = res->port_id;
14479 if (port_id_is_invalid(port_id, ENABLED_WARN))
14482 p = &ports[port_id];
14485 if (p->softport.tm_flag == 0) {
14486 printf(" tm not enabled on port %u (error)\n", port_id);
14490 /* Forward mode: tm */
14491 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14492 printf(" tm mode not enabled(error)\n");
14496 /* Set the default tm hierarchy */
14497 p->softport.tm.default_hierarchy_enable = 1;
14500 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14501 .f = cmd_set_port_tm_hierarchy_default_parsed,
14503 .help_str = "set port tm hierarchy default <port_id>",
14505 (void *)&cmd_set_port_tm_hierarchy_default_set,
14506 (void *)&cmd_set_port_tm_hierarchy_default_port,
14507 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14508 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14509 (void *)&cmd_set_port_tm_hierarchy_default_default,
14510 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14516 /* Strict link priority scheduling mode setting */
14518 cmd_strict_link_prio_parsed(
14519 void *parsed_result,
14520 __attribute__((unused)) struct cmdline *cl,
14521 __attribute__((unused)) void *data)
14523 struct cmd_vf_tc_bw_result *res = parsed_result;
14524 int ret = -ENOTSUP;
14526 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14529 #ifdef RTE_LIBRTE_I40E_PMD
14530 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14537 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14540 printf("invalid port_id %d\n", res->port_id);
14543 printf("function not implemented\n");
14546 printf("programming error: (%s)\n", strerror(-ret));
14550 cmdline_parse_inst_t cmd_strict_link_prio = {
14551 .f = cmd_strict_link_prio_parsed,
14553 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14555 (void *)&cmd_vf_tc_bw_set,
14556 (void *)&cmd_vf_tc_bw_tx,
14557 (void *)&cmd_vf_tc_bw_strict_link_prio,
14558 (void *)&cmd_vf_tc_bw_port_id,
14559 (void *)&cmd_vf_tc_bw_tc_map,
14564 /* Load dynamic device personalization*/
14565 struct cmd_ddp_add_result {
14566 cmdline_fixed_string_t ddp;
14567 cmdline_fixed_string_t add;
14572 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14573 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14574 cmdline_parse_token_string_t cmd_ddp_add_add =
14575 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14576 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14577 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14578 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14579 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14582 cmd_ddp_add_parsed(
14583 void *parsed_result,
14584 __attribute__((unused)) struct cmdline *cl,
14585 __attribute__((unused)) void *data)
14587 struct cmd_ddp_add_result *res = parsed_result;
14593 int ret = -ENOTSUP;
14595 if (!all_ports_stopped()) {
14596 printf("Please stop all ports first\n");
14600 filepath = strdup(res->filepath);
14601 if (filepath == NULL) {
14602 printf("Failed to allocate memory\n");
14605 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14607 buff = open_file(file_fld[0], &size);
14609 free((void *)filepath);
14613 #ifdef RTE_LIBRTE_I40E_PMD
14614 if (ret == -ENOTSUP)
14615 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14617 RTE_PMD_I40E_PKG_OP_WR_ADD);
14620 if (ret == -EEXIST)
14621 printf("Profile has already existed.\n");
14623 printf("Failed to load profile.\n");
14624 else if (file_num == 2)
14625 save_file(file_fld[1], buff, size);
14628 free((void *)filepath);
14631 cmdline_parse_inst_t cmd_ddp_add = {
14632 .f = cmd_ddp_add_parsed,
14634 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14636 (void *)&cmd_ddp_add_ddp,
14637 (void *)&cmd_ddp_add_add,
14638 (void *)&cmd_ddp_add_port_id,
14639 (void *)&cmd_ddp_add_filepath,
14644 /* Delete dynamic device personalization*/
14645 struct cmd_ddp_del_result {
14646 cmdline_fixed_string_t ddp;
14647 cmdline_fixed_string_t del;
14652 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14653 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14654 cmdline_parse_token_string_t cmd_ddp_del_del =
14655 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14656 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14657 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14658 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14659 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14662 cmd_ddp_del_parsed(
14663 void *parsed_result,
14664 __attribute__((unused)) struct cmdline *cl,
14665 __attribute__((unused)) void *data)
14667 struct cmd_ddp_del_result *res = parsed_result;
14670 int ret = -ENOTSUP;
14672 if (!all_ports_stopped()) {
14673 printf("Please stop all ports first\n");
14677 buff = open_file(res->filepath, &size);
14681 #ifdef RTE_LIBRTE_I40E_PMD
14682 if (ret == -ENOTSUP)
14683 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14685 RTE_PMD_I40E_PKG_OP_WR_DEL);
14688 if (ret == -EACCES)
14689 printf("Profile does not exist.\n");
14691 printf("Failed to delete profile.\n");
14696 cmdline_parse_inst_t cmd_ddp_del = {
14697 .f = cmd_ddp_del_parsed,
14699 .help_str = "ddp del <port_id> <backup_profile_path>",
14701 (void *)&cmd_ddp_del_ddp,
14702 (void *)&cmd_ddp_del_del,
14703 (void *)&cmd_ddp_del_port_id,
14704 (void *)&cmd_ddp_del_filepath,
14709 /* Get dynamic device personalization profile info */
14710 struct cmd_ddp_info_result {
14711 cmdline_fixed_string_t ddp;
14712 cmdline_fixed_string_t get;
14713 cmdline_fixed_string_t info;
14717 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14718 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14719 cmdline_parse_token_string_t cmd_ddp_info_get =
14720 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14721 cmdline_parse_token_string_t cmd_ddp_info_info =
14722 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14723 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14724 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14727 cmd_ddp_info_parsed(
14728 void *parsed_result,
14729 __attribute__((unused)) struct cmdline *cl,
14730 __attribute__((unused)) void *data)
14732 struct cmd_ddp_info_result *res = parsed_result;
14735 int ret = -ENOTSUP;
14736 #ifdef RTE_LIBRTE_I40E_PMD
14739 uint32_t buff_size = 0;
14740 struct rte_pmd_i40e_profile_info info;
14741 uint32_t dev_num = 0;
14742 struct rte_pmd_i40e_ddp_device_id *devs;
14743 uint32_t proto_num = 0;
14744 struct rte_pmd_i40e_proto_info *proto = NULL;
14745 uint32_t pctype_num = 0;
14746 struct rte_pmd_i40e_ptype_info *pctype;
14747 uint32_t ptype_num = 0;
14748 struct rte_pmd_i40e_ptype_info *ptype;
14753 pkg = open_file(res->filepath, &pkg_size);
14757 #ifdef RTE_LIBRTE_I40E_PMD
14758 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14759 (uint8_t *)&info, sizeof(info),
14760 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14762 printf("Global Track id: 0x%x\n", info.track_id);
14763 printf("Global Version: %d.%d.%d.%d\n",
14764 info.version.major,
14765 info.version.minor,
14766 info.version.update,
14767 info.version.draft);
14768 printf("Global Package name: %s\n\n", info.name);
14771 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14772 (uint8_t *)&info, sizeof(info),
14773 RTE_PMD_I40E_PKG_INFO_HEADER);
14775 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14776 printf("i40e Profile Version: %d.%d.%d.%d\n",
14777 info.version.major,
14778 info.version.minor,
14779 info.version.update,
14780 info.version.draft);
14781 printf("i40e Profile name: %s\n\n", info.name);
14784 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14785 (uint8_t *)&buff_size, sizeof(buff_size),
14786 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14787 if (!ret && buff_size) {
14788 buff = (uint8_t *)malloc(buff_size);
14790 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14792 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14794 printf("Package Notes:\n%s\n\n", buff);
14799 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14800 (uint8_t *)&dev_num, sizeof(dev_num),
14801 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14802 if (!ret && dev_num) {
14803 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14804 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14806 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14807 (uint8_t *)devs, buff_size,
14808 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14810 printf("List of supported devices:\n");
14811 for (i = 0; i < dev_num; i++) {
14812 printf(" %04X:%04X %04X:%04X\n",
14813 devs[i].vendor_dev_id >> 16,
14814 devs[i].vendor_dev_id & 0xFFFF,
14815 devs[i].sub_vendor_dev_id >> 16,
14816 devs[i].sub_vendor_dev_id & 0xFFFF);
14824 /* get information about protocols and packet types */
14825 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14826 (uint8_t *)&proto_num, sizeof(proto_num),
14827 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14828 if (ret || !proto_num)
14829 goto no_print_return;
14831 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14832 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14834 goto no_print_return;
14836 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14838 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14840 printf("List of used protocols:\n");
14841 for (i = 0; i < proto_num; i++)
14842 printf(" %2u: %s\n", proto[i].proto_id,
14846 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14847 (uint8_t *)&pctype_num, sizeof(pctype_num),
14848 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14849 if (ret || !pctype_num)
14850 goto no_print_pctypes;
14852 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14853 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14855 goto no_print_pctypes;
14857 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14859 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14862 goto no_print_pctypes;
14865 printf("List of defined packet classification types:\n");
14866 for (i = 0; i < pctype_num; i++) {
14867 printf(" %2u:", pctype[i].ptype_id);
14868 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14869 proto_id = pctype[i].protocols[j];
14870 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14871 for (n = 0; n < proto_num; n++) {
14872 if (proto[n].proto_id == proto_id) {
14873 printf(" %s", proto[n].name);
14886 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14888 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14889 if (ret || !ptype_num)
14890 goto no_print_return;
14892 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14893 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14895 goto no_print_return;
14897 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14899 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14902 goto no_print_return;
14904 printf("List of defined packet types:\n");
14905 for (i = 0; i < ptype_num; i++) {
14906 printf(" %2u:", ptype[i].ptype_id);
14907 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14908 proto_id = ptype[i].protocols[j];
14909 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14910 for (n = 0; n < proto_num; n++) {
14911 if (proto[n].proto_id == proto_id) {
14912 printf(" %s", proto[n].name);
14928 if (ret == -ENOTSUP)
14929 printf("Function not supported in PMD driver\n");
14933 cmdline_parse_inst_t cmd_ddp_get_info = {
14934 .f = cmd_ddp_info_parsed,
14936 .help_str = "ddp get info <profile_path>",
14938 (void *)&cmd_ddp_info_ddp,
14939 (void *)&cmd_ddp_info_get,
14940 (void *)&cmd_ddp_info_info,
14941 (void *)&cmd_ddp_info_filepath,
14946 /* Get dynamic device personalization profile info list*/
14947 #define PROFILE_INFO_SIZE 48
14948 #define MAX_PROFILE_NUM 16
14950 struct cmd_ddp_get_list_result {
14951 cmdline_fixed_string_t ddp;
14952 cmdline_fixed_string_t get;
14953 cmdline_fixed_string_t list;
14957 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14958 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14959 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14960 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14961 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14962 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14963 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14964 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14967 cmd_ddp_get_list_parsed(
14968 __attribute__((unused)) void *parsed_result,
14969 __attribute__((unused)) struct cmdline *cl,
14970 __attribute__((unused)) void *data)
14972 #ifdef RTE_LIBRTE_I40E_PMD
14973 struct cmd_ddp_get_list_result *res = parsed_result;
14974 struct rte_pmd_i40e_profile_list *p_list;
14975 struct rte_pmd_i40e_profile_info *p_info;
14980 int ret = -ENOTSUP;
14982 #ifdef RTE_LIBRTE_I40E_PMD
14983 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14984 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14986 printf("%s: Failed to malloc buffer\n", __func__);
14988 if (ret == -ENOTSUP)
14989 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14990 (uint8_t *)p_list, size);
14993 p_num = p_list->p_count;
14994 printf("Profile number is: %d\n\n", p_num);
14996 for (i = 0; i < p_num; i++) {
14997 p_info = &p_list->p_info[i];
14998 printf("Profile %d:\n", i);
14999 printf("Track id: 0x%x\n", p_info->track_id);
15000 printf("Version: %d.%d.%d.%d\n",
15001 p_info->version.major,
15002 p_info->version.minor,
15003 p_info->version.update,
15004 p_info->version.draft);
15005 printf("Profile name: %s\n\n", p_info->name);
15013 printf("Failed to get ddp list\n");
15016 cmdline_parse_inst_t cmd_ddp_get_list = {
15017 .f = cmd_ddp_get_list_parsed,
15019 .help_str = "ddp get list <port_id>",
15021 (void *)&cmd_ddp_get_list_ddp,
15022 (void *)&cmd_ddp_get_list_get,
15023 (void *)&cmd_ddp_get_list_list,
15024 (void *)&cmd_ddp_get_list_port_id,
15029 /* Configure input set */
15030 struct cmd_cfg_input_set_result {
15031 cmdline_fixed_string_t port;
15032 cmdline_fixed_string_t cfg;
15034 cmdline_fixed_string_t pctype;
15036 cmdline_fixed_string_t inset_type;
15037 cmdline_fixed_string_t opt;
15038 cmdline_fixed_string_t field;
15043 cmd_cfg_input_set_parsed(
15044 __attribute__((unused)) void *parsed_result,
15045 __attribute__((unused)) struct cmdline *cl,
15046 __attribute__((unused)) void *data)
15048 #ifdef RTE_LIBRTE_I40E_PMD
15049 struct cmd_cfg_input_set_result *res = parsed_result;
15050 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15051 struct rte_pmd_i40e_inset inset;
15053 int ret = -ENOTSUP;
15055 if (!all_ports_stopped()) {
15056 printf("Please stop all ports first\n");
15060 #ifdef RTE_LIBRTE_I40E_PMD
15061 if (!strcmp(res->inset_type, "hash_inset"))
15062 inset_type = INSET_HASH;
15063 else if (!strcmp(res->inset_type, "fdir_inset"))
15064 inset_type = INSET_FDIR;
15065 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15066 inset_type = INSET_FDIR_FLX;
15067 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15068 &inset, inset_type);
15070 printf("Failed to get input set.\n");
15074 if (!strcmp(res->opt, "get")) {
15075 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15078 printf("Field index %d is enabled.\n", res->field_idx);
15080 printf("Field index %d is disabled.\n", res->field_idx);
15082 } else if (!strcmp(res->opt, "set"))
15083 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15085 else if (!strcmp(res->opt, "clear"))
15086 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15089 printf("Failed to configure input set field.\n");
15093 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15094 &inset, inset_type);
15096 printf("Failed to set input set.\n");
15101 if (ret == -ENOTSUP)
15102 printf("Function not supported\n");
15105 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15106 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15108 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15109 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15111 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15112 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15114 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15115 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15117 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15118 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15120 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15121 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15123 "hash_inset#fdir_inset#fdir_flx_inset");
15124 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15125 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15126 opt, "get#set#clear");
15127 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15128 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15130 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15131 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15134 cmdline_parse_inst_t cmd_cfg_input_set = {
15135 .f = cmd_cfg_input_set_parsed,
15137 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15138 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15140 (void *)&cmd_cfg_input_set_port,
15141 (void *)&cmd_cfg_input_set_cfg,
15142 (void *)&cmd_cfg_input_set_port_id,
15143 (void *)&cmd_cfg_input_set_pctype,
15144 (void *)&cmd_cfg_input_set_pctype_id,
15145 (void *)&cmd_cfg_input_set_inset_type,
15146 (void *)&cmd_cfg_input_set_opt,
15147 (void *)&cmd_cfg_input_set_field,
15148 (void *)&cmd_cfg_input_set_field_idx,
15153 /* Clear input set */
15154 struct cmd_clear_input_set_result {
15155 cmdline_fixed_string_t port;
15156 cmdline_fixed_string_t cfg;
15158 cmdline_fixed_string_t pctype;
15160 cmdline_fixed_string_t inset_type;
15161 cmdline_fixed_string_t clear;
15162 cmdline_fixed_string_t all;
15166 cmd_clear_input_set_parsed(
15167 __attribute__((unused)) void *parsed_result,
15168 __attribute__((unused)) struct cmdline *cl,
15169 __attribute__((unused)) void *data)
15171 #ifdef RTE_LIBRTE_I40E_PMD
15172 struct cmd_clear_input_set_result *res = parsed_result;
15173 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15174 struct rte_pmd_i40e_inset inset;
15176 int ret = -ENOTSUP;
15178 if (!all_ports_stopped()) {
15179 printf("Please stop all ports first\n");
15183 #ifdef RTE_LIBRTE_I40E_PMD
15184 if (!strcmp(res->inset_type, "hash_inset"))
15185 inset_type = INSET_HASH;
15186 else if (!strcmp(res->inset_type, "fdir_inset"))
15187 inset_type = INSET_FDIR;
15188 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15189 inset_type = INSET_FDIR_FLX;
15191 memset(&inset, 0, sizeof(inset));
15193 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15194 &inset, inset_type);
15196 printf("Failed to clear input set.\n");
15202 if (ret == -ENOTSUP)
15203 printf("Function not supported\n");
15206 cmdline_parse_token_string_t cmd_clear_input_set_port =
15207 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15209 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15210 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15212 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15213 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15215 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15216 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15218 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15219 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15221 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15222 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15224 "hash_inset#fdir_inset#fdir_flx_inset");
15225 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15226 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15228 cmdline_parse_token_string_t cmd_clear_input_set_all =
15229 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15232 cmdline_parse_inst_t cmd_clear_input_set = {
15233 .f = cmd_clear_input_set_parsed,
15235 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15236 "fdir_inset|fdir_flx_inset clear all",
15238 (void *)&cmd_clear_input_set_port,
15239 (void *)&cmd_clear_input_set_cfg,
15240 (void *)&cmd_clear_input_set_port_id,
15241 (void *)&cmd_clear_input_set_pctype,
15242 (void *)&cmd_clear_input_set_pctype_id,
15243 (void *)&cmd_clear_input_set_inset_type,
15244 (void *)&cmd_clear_input_set_clear,
15245 (void *)&cmd_clear_input_set_all,
15250 /* show vf stats */
15252 /* Common result structure for show vf stats */
15253 struct cmd_show_vf_stats_result {
15254 cmdline_fixed_string_t show;
15255 cmdline_fixed_string_t vf;
15256 cmdline_fixed_string_t stats;
15261 /* Common CLI fields show vf stats*/
15262 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15263 TOKEN_STRING_INITIALIZER
15264 (struct cmd_show_vf_stats_result,
15266 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15267 TOKEN_STRING_INITIALIZER
15268 (struct cmd_show_vf_stats_result,
15270 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15271 TOKEN_STRING_INITIALIZER
15272 (struct cmd_show_vf_stats_result,
15274 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15275 TOKEN_NUM_INITIALIZER
15276 (struct cmd_show_vf_stats_result,
15278 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15279 TOKEN_NUM_INITIALIZER
15280 (struct cmd_show_vf_stats_result,
15284 cmd_show_vf_stats_parsed(
15285 void *parsed_result,
15286 __attribute__((unused)) struct cmdline *cl,
15287 __attribute__((unused)) void *data)
15289 struct cmd_show_vf_stats_result *res = parsed_result;
15290 struct rte_eth_stats stats;
15291 int ret = -ENOTSUP;
15292 static const char *nic_stats_border = "########################";
15294 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15297 memset(&stats, 0, sizeof(stats));
15299 #ifdef RTE_LIBRTE_I40E_PMD
15300 if (ret == -ENOTSUP)
15301 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15305 #ifdef RTE_LIBRTE_BNXT_PMD
15306 if (ret == -ENOTSUP)
15307 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15316 printf("invalid vf_id %d\n", res->vf_id);
15319 printf("invalid port_id %d\n", res->port_id);
15322 printf("function not implemented\n");
15325 printf("programming error: (%s)\n", strerror(-ret));
15328 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15329 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15331 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15333 stats.ipackets, stats.imissed, stats.ibytes);
15334 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15335 printf(" RX-nombuf: %-10"PRIu64"\n",
15337 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15339 stats.opackets, stats.oerrors, stats.obytes);
15341 printf(" %s############################%s\n",
15342 nic_stats_border, nic_stats_border);
15345 cmdline_parse_inst_t cmd_show_vf_stats = {
15346 .f = cmd_show_vf_stats_parsed,
15348 .help_str = "show vf stats <port_id> <vf_id>",
15350 (void *)&cmd_show_vf_stats_show,
15351 (void *)&cmd_show_vf_stats_vf,
15352 (void *)&cmd_show_vf_stats_stats,
15353 (void *)&cmd_show_vf_stats_port_id,
15354 (void *)&cmd_show_vf_stats_vf_id,
15359 /* clear vf stats */
15361 /* Common result structure for clear vf stats */
15362 struct cmd_clear_vf_stats_result {
15363 cmdline_fixed_string_t clear;
15364 cmdline_fixed_string_t vf;
15365 cmdline_fixed_string_t stats;
15370 /* Common CLI fields clear vf stats*/
15371 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15372 TOKEN_STRING_INITIALIZER
15373 (struct cmd_clear_vf_stats_result,
15375 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15376 TOKEN_STRING_INITIALIZER
15377 (struct cmd_clear_vf_stats_result,
15379 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15380 TOKEN_STRING_INITIALIZER
15381 (struct cmd_clear_vf_stats_result,
15383 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15384 TOKEN_NUM_INITIALIZER
15385 (struct cmd_clear_vf_stats_result,
15387 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15388 TOKEN_NUM_INITIALIZER
15389 (struct cmd_clear_vf_stats_result,
15393 cmd_clear_vf_stats_parsed(
15394 void *parsed_result,
15395 __attribute__((unused)) struct cmdline *cl,
15396 __attribute__((unused)) void *data)
15398 struct cmd_clear_vf_stats_result *res = parsed_result;
15399 int ret = -ENOTSUP;
15401 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15404 #ifdef RTE_LIBRTE_I40E_PMD
15405 if (ret == -ENOTSUP)
15406 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15409 #ifdef RTE_LIBRTE_BNXT_PMD
15410 if (ret == -ENOTSUP)
15411 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15419 printf("invalid vf_id %d\n", res->vf_id);
15422 printf("invalid port_id %d\n", res->port_id);
15425 printf("function not implemented\n");
15428 printf("programming error: (%s)\n", strerror(-ret));
15432 cmdline_parse_inst_t cmd_clear_vf_stats = {
15433 .f = cmd_clear_vf_stats_parsed,
15435 .help_str = "clear vf stats <port_id> <vf_id>",
15437 (void *)&cmd_clear_vf_stats_clear,
15438 (void *)&cmd_clear_vf_stats_vf,
15439 (void *)&cmd_clear_vf_stats_stats,
15440 (void *)&cmd_clear_vf_stats_port_id,
15441 (void *)&cmd_clear_vf_stats_vf_id,
15446 /* port config pctype mapping reset */
15448 /* Common result structure for port config pctype mapping reset */
15449 struct cmd_pctype_mapping_reset_result {
15450 cmdline_fixed_string_t port;
15451 cmdline_fixed_string_t config;
15453 cmdline_fixed_string_t pctype;
15454 cmdline_fixed_string_t mapping;
15455 cmdline_fixed_string_t reset;
15458 /* Common CLI fields for port config pctype mapping reset*/
15459 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15460 TOKEN_STRING_INITIALIZER
15461 (struct cmd_pctype_mapping_reset_result,
15463 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15464 TOKEN_STRING_INITIALIZER
15465 (struct cmd_pctype_mapping_reset_result,
15467 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15468 TOKEN_NUM_INITIALIZER
15469 (struct cmd_pctype_mapping_reset_result,
15471 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15472 TOKEN_STRING_INITIALIZER
15473 (struct cmd_pctype_mapping_reset_result,
15475 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15476 TOKEN_STRING_INITIALIZER
15477 (struct cmd_pctype_mapping_reset_result,
15478 mapping, "mapping");
15479 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15480 TOKEN_STRING_INITIALIZER
15481 (struct cmd_pctype_mapping_reset_result,
15485 cmd_pctype_mapping_reset_parsed(
15486 void *parsed_result,
15487 __attribute__((unused)) struct cmdline *cl,
15488 __attribute__((unused)) void *data)
15490 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15491 int ret = -ENOTSUP;
15493 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15496 #ifdef RTE_LIBRTE_I40E_PMD
15497 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15504 printf("invalid port_id %d\n", res->port_id);
15507 printf("function not implemented\n");
15510 printf("programming error: (%s)\n", strerror(-ret));
15514 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15515 .f = cmd_pctype_mapping_reset_parsed,
15517 .help_str = "port config <port_id> pctype mapping reset",
15519 (void *)&cmd_pctype_mapping_reset_port,
15520 (void *)&cmd_pctype_mapping_reset_config,
15521 (void *)&cmd_pctype_mapping_reset_port_id,
15522 (void *)&cmd_pctype_mapping_reset_pctype,
15523 (void *)&cmd_pctype_mapping_reset_mapping,
15524 (void *)&cmd_pctype_mapping_reset_reset,
15529 /* show port pctype mapping */
15531 /* Common result structure for show port pctype mapping */
15532 struct cmd_pctype_mapping_get_result {
15533 cmdline_fixed_string_t show;
15534 cmdline_fixed_string_t port;
15536 cmdline_fixed_string_t pctype;
15537 cmdline_fixed_string_t mapping;
15540 /* Common CLI fields for pctype mapping get */
15541 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15542 TOKEN_STRING_INITIALIZER
15543 (struct cmd_pctype_mapping_get_result,
15545 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15546 TOKEN_STRING_INITIALIZER
15547 (struct cmd_pctype_mapping_get_result,
15549 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15550 TOKEN_NUM_INITIALIZER
15551 (struct cmd_pctype_mapping_get_result,
15553 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15554 TOKEN_STRING_INITIALIZER
15555 (struct cmd_pctype_mapping_get_result,
15557 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15558 TOKEN_STRING_INITIALIZER
15559 (struct cmd_pctype_mapping_get_result,
15560 mapping, "mapping");
15563 cmd_pctype_mapping_get_parsed(
15564 void *parsed_result,
15565 __attribute__((unused)) struct cmdline *cl,
15566 __attribute__((unused)) void *data)
15568 struct cmd_pctype_mapping_get_result *res = parsed_result;
15569 int ret = -ENOTSUP;
15570 #ifdef RTE_LIBRTE_I40E_PMD
15571 struct rte_pmd_i40e_flow_type_mapping
15572 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15573 int i, j, first_pctype;
15576 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15579 #ifdef RTE_LIBRTE_I40E_PMD
15580 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15587 printf("invalid port_id %d\n", res->port_id);
15590 printf("function not implemented\n");
15593 printf("programming error: (%s)\n", strerror(-ret));
15597 #ifdef RTE_LIBRTE_I40E_PMD
15598 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15599 if (mapping[i].pctype != 0ULL) {
15602 printf("pctype: ");
15603 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15604 if (mapping[i].pctype & (1ULL << j)) {
15605 printf(first_pctype ?
15606 "%02d" : ",%02d", j);
15610 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15616 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15617 .f = cmd_pctype_mapping_get_parsed,
15619 .help_str = "show port <port_id> pctype mapping",
15621 (void *)&cmd_pctype_mapping_get_show,
15622 (void *)&cmd_pctype_mapping_get_port,
15623 (void *)&cmd_pctype_mapping_get_port_id,
15624 (void *)&cmd_pctype_mapping_get_pctype,
15625 (void *)&cmd_pctype_mapping_get_mapping,
15630 /* port config pctype mapping update */
15632 /* Common result structure for port config pctype mapping update */
15633 struct cmd_pctype_mapping_update_result {
15634 cmdline_fixed_string_t port;
15635 cmdline_fixed_string_t config;
15637 cmdline_fixed_string_t pctype;
15638 cmdline_fixed_string_t mapping;
15639 cmdline_fixed_string_t update;
15640 cmdline_fixed_string_t pctype_list;
15641 uint16_t flow_type;
15644 /* Common CLI fields for pctype mapping update*/
15645 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15646 TOKEN_STRING_INITIALIZER
15647 (struct cmd_pctype_mapping_update_result,
15649 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15650 TOKEN_STRING_INITIALIZER
15651 (struct cmd_pctype_mapping_update_result,
15653 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15654 TOKEN_NUM_INITIALIZER
15655 (struct cmd_pctype_mapping_update_result,
15657 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15658 TOKEN_STRING_INITIALIZER
15659 (struct cmd_pctype_mapping_update_result,
15661 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15662 TOKEN_STRING_INITIALIZER
15663 (struct cmd_pctype_mapping_update_result,
15664 mapping, "mapping");
15665 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15666 TOKEN_STRING_INITIALIZER
15667 (struct cmd_pctype_mapping_update_result,
15669 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15670 TOKEN_STRING_INITIALIZER
15671 (struct cmd_pctype_mapping_update_result,
15672 pctype_list, NULL);
15673 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15674 TOKEN_NUM_INITIALIZER
15675 (struct cmd_pctype_mapping_update_result,
15676 flow_type, UINT16);
15679 cmd_pctype_mapping_update_parsed(
15680 void *parsed_result,
15681 __attribute__((unused)) struct cmdline *cl,
15682 __attribute__((unused)) void *data)
15684 struct cmd_pctype_mapping_update_result *res = parsed_result;
15685 int ret = -ENOTSUP;
15686 #ifdef RTE_LIBRTE_I40E_PMD
15687 struct rte_pmd_i40e_flow_type_mapping mapping;
15689 unsigned int nb_item;
15690 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15693 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15696 #ifdef RTE_LIBRTE_I40E_PMD
15697 nb_item = parse_item_list(res->pctype_list, "pctypes",
15698 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15699 mapping.flow_type = res->flow_type;
15700 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15701 mapping.pctype |= (1ULL << pctype_list[i]);
15702 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15712 printf("invalid pctype or flow type\n");
15715 printf("invalid port_id %d\n", res->port_id);
15718 printf("function not implemented\n");
15721 printf("programming error: (%s)\n", strerror(-ret));
15725 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15726 .f = cmd_pctype_mapping_update_parsed,
15728 .help_str = "port config <port_id> pctype mapping update"
15729 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15731 (void *)&cmd_pctype_mapping_update_port,
15732 (void *)&cmd_pctype_mapping_update_config,
15733 (void *)&cmd_pctype_mapping_update_port_id,
15734 (void *)&cmd_pctype_mapping_update_pctype,
15735 (void *)&cmd_pctype_mapping_update_mapping,
15736 (void *)&cmd_pctype_mapping_update_update,
15737 (void *)&cmd_pctype_mapping_update_pc_type,
15738 (void *)&cmd_pctype_mapping_update_flow_type,
15743 /* ptype mapping get */
15745 /* Common result structure for ptype mapping get */
15746 struct cmd_ptype_mapping_get_result {
15747 cmdline_fixed_string_t ptype;
15748 cmdline_fixed_string_t mapping;
15749 cmdline_fixed_string_t get;
15751 uint8_t valid_only;
15754 /* Common CLI fields for ptype mapping get */
15755 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15756 TOKEN_STRING_INITIALIZER
15757 (struct cmd_ptype_mapping_get_result,
15759 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15760 TOKEN_STRING_INITIALIZER
15761 (struct cmd_ptype_mapping_get_result,
15762 mapping, "mapping");
15763 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15764 TOKEN_STRING_INITIALIZER
15765 (struct cmd_ptype_mapping_get_result,
15767 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15768 TOKEN_NUM_INITIALIZER
15769 (struct cmd_ptype_mapping_get_result,
15771 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15772 TOKEN_NUM_INITIALIZER
15773 (struct cmd_ptype_mapping_get_result,
15774 valid_only, UINT8);
15777 cmd_ptype_mapping_get_parsed(
15778 void *parsed_result,
15779 __attribute__((unused)) struct cmdline *cl,
15780 __attribute__((unused)) void *data)
15782 struct cmd_ptype_mapping_get_result *res = parsed_result;
15783 int ret = -ENOTSUP;
15784 #ifdef RTE_LIBRTE_I40E_PMD
15785 int max_ptype_num = 256;
15786 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15791 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15794 #ifdef RTE_LIBRTE_I40E_PMD
15795 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15806 printf("invalid port_id %d\n", res->port_id);
15809 printf("function not implemented\n");
15812 printf("programming error: (%s)\n", strerror(-ret));
15815 #ifdef RTE_LIBRTE_I40E_PMD
15817 for (i = 0; i < count; i++)
15818 printf("%3d\t0x%08x\n",
15819 mapping[i].hw_ptype, mapping[i].sw_ptype);
15824 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15825 .f = cmd_ptype_mapping_get_parsed,
15827 .help_str = "ptype mapping get <port_id> <valid_only>",
15829 (void *)&cmd_ptype_mapping_get_ptype,
15830 (void *)&cmd_ptype_mapping_get_mapping,
15831 (void *)&cmd_ptype_mapping_get_get,
15832 (void *)&cmd_ptype_mapping_get_port_id,
15833 (void *)&cmd_ptype_mapping_get_valid_only,
15838 /* ptype mapping replace */
15840 /* Common result structure for ptype mapping replace */
15841 struct cmd_ptype_mapping_replace_result {
15842 cmdline_fixed_string_t ptype;
15843 cmdline_fixed_string_t mapping;
15844 cmdline_fixed_string_t replace;
15851 /* Common CLI fields for ptype mapping replace */
15852 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15853 TOKEN_STRING_INITIALIZER
15854 (struct cmd_ptype_mapping_replace_result,
15856 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15857 TOKEN_STRING_INITIALIZER
15858 (struct cmd_ptype_mapping_replace_result,
15859 mapping, "mapping");
15860 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15861 TOKEN_STRING_INITIALIZER
15862 (struct cmd_ptype_mapping_replace_result,
15863 replace, "replace");
15864 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15865 TOKEN_NUM_INITIALIZER
15866 (struct cmd_ptype_mapping_replace_result,
15868 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15869 TOKEN_NUM_INITIALIZER
15870 (struct cmd_ptype_mapping_replace_result,
15872 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15873 TOKEN_NUM_INITIALIZER
15874 (struct cmd_ptype_mapping_replace_result,
15876 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15877 TOKEN_NUM_INITIALIZER
15878 (struct cmd_ptype_mapping_replace_result,
15882 cmd_ptype_mapping_replace_parsed(
15883 void *parsed_result,
15884 __attribute__((unused)) struct cmdline *cl,
15885 __attribute__((unused)) void *data)
15887 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15888 int ret = -ENOTSUP;
15890 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15893 #ifdef RTE_LIBRTE_I40E_PMD
15894 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15904 printf("invalid ptype 0x%8x or 0x%8x\n",
15905 res->target, res->pkt_type);
15908 printf("invalid port_id %d\n", res->port_id);
15911 printf("function not implemented\n");
15914 printf("programming error: (%s)\n", strerror(-ret));
15918 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15919 .f = cmd_ptype_mapping_replace_parsed,
15922 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15924 (void *)&cmd_ptype_mapping_replace_ptype,
15925 (void *)&cmd_ptype_mapping_replace_mapping,
15926 (void *)&cmd_ptype_mapping_replace_replace,
15927 (void *)&cmd_ptype_mapping_replace_port_id,
15928 (void *)&cmd_ptype_mapping_replace_target,
15929 (void *)&cmd_ptype_mapping_replace_mask,
15930 (void *)&cmd_ptype_mapping_replace_pkt_type,
15935 /* ptype mapping reset */
15937 /* Common result structure for ptype mapping reset */
15938 struct cmd_ptype_mapping_reset_result {
15939 cmdline_fixed_string_t ptype;
15940 cmdline_fixed_string_t mapping;
15941 cmdline_fixed_string_t reset;
15945 /* Common CLI fields for ptype mapping reset*/
15946 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15947 TOKEN_STRING_INITIALIZER
15948 (struct cmd_ptype_mapping_reset_result,
15950 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15951 TOKEN_STRING_INITIALIZER
15952 (struct cmd_ptype_mapping_reset_result,
15953 mapping, "mapping");
15954 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15955 TOKEN_STRING_INITIALIZER
15956 (struct cmd_ptype_mapping_reset_result,
15958 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15959 TOKEN_NUM_INITIALIZER
15960 (struct cmd_ptype_mapping_reset_result,
15964 cmd_ptype_mapping_reset_parsed(
15965 void *parsed_result,
15966 __attribute__((unused)) struct cmdline *cl,
15967 __attribute__((unused)) void *data)
15969 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15970 int ret = -ENOTSUP;
15972 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15975 #ifdef RTE_LIBRTE_I40E_PMD
15976 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15983 printf("invalid port_id %d\n", res->port_id);
15986 printf("function not implemented\n");
15989 printf("programming error: (%s)\n", strerror(-ret));
15993 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15994 .f = cmd_ptype_mapping_reset_parsed,
15996 .help_str = "ptype mapping reset <port_id>",
15998 (void *)&cmd_ptype_mapping_reset_ptype,
15999 (void *)&cmd_ptype_mapping_reset_mapping,
16000 (void *)&cmd_ptype_mapping_reset_reset,
16001 (void *)&cmd_ptype_mapping_reset_port_id,
16006 /* ptype mapping update */
16008 /* Common result structure for ptype mapping update */
16009 struct cmd_ptype_mapping_update_result {
16010 cmdline_fixed_string_t ptype;
16011 cmdline_fixed_string_t mapping;
16012 cmdline_fixed_string_t reset;
16018 /* Common CLI fields for ptype mapping update*/
16019 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16020 TOKEN_STRING_INITIALIZER
16021 (struct cmd_ptype_mapping_update_result,
16023 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16024 TOKEN_STRING_INITIALIZER
16025 (struct cmd_ptype_mapping_update_result,
16026 mapping, "mapping");
16027 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16028 TOKEN_STRING_INITIALIZER
16029 (struct cmd_ptype_mapping_update_result,
16031 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16032 TOKEN_NUM_INITIALIZER
16033 (struct cmd_ptype_mapping_update_result,
16035 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16036 TOKEN_NUM_INITIALIZER
16037 (struct cmd_ptype_mapping_update_result,
16039 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16040 TOKEN_NUM_INITIALIZER
16041 (struct cmd_ptype_mapping_update_result,
16045 cmd_ptype_mapping_update_parsed(
16046 void *parsed_result,
16047 __attribute__((unused)) struct cmdline *cl,
16048 __attribute__((unused)) void *data)
16050 struct cmd_ptype_mapping_update_result *res = parsed_result;
16051 int ret = -ENOTSUP;
16052 #ifdef RTE_LIBRTE_I40E_PMD
16053 struct rte_pmd_i40e_ptype_mapping mapping;
16055 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16058 #ifdef RTE_LIBRTE_I40E_PMD
16059 mapping.hw_ptype = res->hw_ptype;
16060 mapping.sw_ptype = res->sw_ptype;
16061 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16071 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16074 printf("invalid port_id %d\n", res->port_id);
16077 printf("function not implemented\n");
16080 printf("programming error: (%s)\n", strerror(-ret));
16084 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16085 .f = cmd_ptype_mapping_update_parsed,
16087 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16089 (void *)&cmd_ptype_mapping_update_ptype,
16090 (void *)&cmd_ptype_mapping_update_mapping,
16091 (void *)&cmd_ptype_mapping_update_update,
16092 (void *)&cmd_ptype_mapping_update_port_id,
16093 (void *)&cmd_ptype_mapping_update_hw_ptype,
16094 (void *)&cmd_ptype_mapping_update_sw_ptype,
16099 /* Common result structure for file commands */
16100 struct cmd_cmdfile_result {
16101 cmdline_fixed_string_t load;
16102 cmdline_fixed_string_t filename;
16105 /* Common CLI fields for file commands */
16106 cmdline_parse_token_string_t cmd_load_cmdfile =
16107 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16108 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16109 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16112 cmd_load_from_file_parsed(
16113 void *parsed_result,
16114 __attribute__((unused)) struct cmdline *cl,
16115 __attribute__((unused)) void *data)
16117 struct cmd_cmdfile_result *res = parsed_result;
16119 cmdline_read_from_file(res->filename);
16122 cmdline_parse_inst_t cmd_load_from_file = {
16123 .f = cmd_load_from_file_parsed,
16125 .help_str = "load <filename>",
16127 (void *)&cmd_load_cmdfile,
16128 (void *)&cmd_load_cmdfile_filename,
16133 /* ******************************************************************************** */
16135 /* list of instructions */
16136 cmdline_parse_ctx_t main_ctx[] = {
16137 (cmdline_parse_inst_t *)&cmd_help_brief,
16138 (cmdline_parse_inst_t *)&cmd_help_long,
16139 (cmdline_parse_inst_t *)&cmd_quit,
16140 (cmdline_parse_inst_t *)&cmd_load_from_file,
16141 (cmdline_parse_inst_t *)&cmd_showport,
16142 (cmdline_parse_inst_t *)&cmd_showqueue,
16143 (cmdline_parse_inst_t *)&cmd_showportall,
16144 (cmdline_parse_inst_t *)&cmd_showcfg,
16145 (cmdline_parse_inst_t *)&cmd_start,
16146 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16147 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16148 (cmdline_parse_inst_t *)&cmd_set_link_up,
16149 (cmdline_parse_inst_t *)&cmd_set_link_down,
16150 (cmdline_parse_inst_t *)&cmd_reset,
16151 (cmdline_parse_inst_t *)&cmd_set_numbers,
16152 (cmdline_parse_inst_t *)&cmd_set_log,
16153 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16154 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16155 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16156 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16157 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16158 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16159 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16160 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16161 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16162 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16163 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16164 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16165 (cmdline_parse_inst_t *)&cmd_set_link_check,
16166 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16167 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16168 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16169 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16170 #ifdef RTE_LIBRTE_PMD_BOND
16171 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16172 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16173 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16174 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16175 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16176 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16177 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16178 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16179 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16180 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16181 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16183 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16184 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16185 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16186 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16187 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16188 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16189 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16190 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16191 (cmdline_parse_inst_t *)&cmd_csum_set,
16192 (cmdline_parse_inst_t *)&cmd_csum_show,
16193 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16194 (cmdline_parse_inst_t *)&cmd_tso_set,
16195 (cmdline_parse_inst_t *)&cmd_tso_show,
16196 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16197 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16198 (cmdline_parse_inst_t *)&cmd_gro_enable,
16199 (cmdline_parse_inst_t *)&cmd_gro_flush,
16200 (cmdline_parse_inst_t *)&cmd_gro_show,
16201 (cmdline_parse_inst_t *)&cmd_gso_enable,
16202 (cmdline_parse_inst_t *)&cmd_gso_size,
16203 (cmdline_parse_inst_t *)&cmd_gso_show,
16204 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16205 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16206 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16207 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16208 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16209 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16210 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16211 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16212 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16213 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16214 (cmdline_parse_inst_t *)&cmd_config_dcb,
16215 (cmdline_parse_inst_t *)&cmd_read_reg,
16216 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16217 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16218 (cmdline_parse_inst_t *)&cmd_write_reg,
16219 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16220 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16221 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16222 (cmdline_parse_inst_t *)&cmd_stop,
16223 (cmdline_parse_inst_t *)&cmd_mac_addr,
16224 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16225 (cmdline_parse_inst_t *)&cmd_set_qmap,
16226 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16227 (cmdline_parse_inst_t *)&cmd_operate_port,
16228 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16229 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16230 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16231 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16232 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16233 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16234 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16235 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16236 (cmdline_parse_inst_t *)&cmd_config_mtu,
16237 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16238 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16239 (cmdline_parse_inst_t *)&cmd_config_rss,
16240 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16241 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16242 (cmdline_parse_inst_t *)&cmd_showport_reta,
16243 (cmdline_parse_inst_t *)&cmd_config_burst,
16244 (cmdline_parse_inst_t *)&cmd_config_thresh,
16245 (cmdline_parse_inst_t *)&cmd_config_threshold,
16246 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16247 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16248 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16249 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16250 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16251 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16252 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16253 (cmdline_parse_inst_t *)&cmd_global_config,
16254 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16255 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16256 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16257 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16258 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16259 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16260 (cmdline_parse_inst_t *)&cmd_dump,
16261 (cmdline_parse_inst_t *)&cmd_dump_one,
16262 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16263 (cmdline_parse_inst_t *)&cmd_syn_filter,
16264 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16265 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16266 (cmdline_parse_inst_t *)&cmd_flex_filter,
16267 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16268 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16269 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16270 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16271 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16272 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16273 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16274 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16275 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16276 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16277 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16278 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16279 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16280 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16281 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16282 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16283 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16284 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16285 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16286 (cmdline_parse_inst_t *)&cmd_flow,
16287 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16288 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16289 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16290 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16291 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16292 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16293 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16294 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16295 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16296 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16297 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16298 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16299 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16300 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16301 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16302 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16303 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16304 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16305 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16306 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16307 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16308 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16309 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16310 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16311 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16312 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16313 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16314 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16315 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16316 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16317 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16318 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16319 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16320 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16321 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16322 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16323 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16324 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16325 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16326 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16327 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16328 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16329 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16330 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16331 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16332 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16333 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16334 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16335 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16336 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16337 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16339 (cmdline_parse_inst_t *)&cmd_ddp_add,
16340 (cmdline_parse_inst_t *)&cmd_ddp_del,
16341 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16342 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16343 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16344 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16345 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16346 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16347 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16348 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16349 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16350 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16352 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16353 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16354 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16355 (cmdline_parse_inst_t *)&cmd_queue_region,
16356 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16357 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16358 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16359 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16360 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16361 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16362 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16363 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16364 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16365 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16366 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16367 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16368 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16369 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16370 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16371 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16372 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16373 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16374 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16375 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16376 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16380 /* read cmdline commands from file */
16382 cmdline_read_from_file(const char *filename)
16384 struct cmdline *cl;
16386 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16388 printf("Failed to create file based cmdline context: %s\n",
16393 cmdline_interact(cl);
16398 printf("Read CLI commands from %s\n", filename);
16401 /* prompt function, called from main on MASTER lcore */
16405 /* initialize non-constant commands */
16406 cmd_set_fwd_mode_init();
16407 cmd_set_fwd_retry_mode_init();
16409 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16410 if (testpmd_cl == NULL)
16412 cmdline_interact(testpmd_cl);
16413 cmdline_stdin_exit(testpmd_cl);
16419 if (testpmd_cl != NULL)
16420 cmdline_quit(testpmd_cl);
16424 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16426 if (id == (portid_t)RTE_PORT_ALL) {
16429 RTE_ETH_FOREACH_DEV(pid) {
16430 /* check if need_reconfig has been set to 1 */
16431 if (ports[pid].need_reconfig == 0)
16432 ports[pid].need_reconfig = dev;
16433 /* check if need_reconfig_queues has been set to 1 */
16434 if (ports[pid].need_reconfig_queues == 0)
16435 ports[pid].need_reconfig_queues = queue;
16437 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16438 /* check if need_reconfig has been set to 1 */
16439 if (ports[id].need_reconfig == 0)
16440 ports[id].need_reconfig = dev;
16441 /* check if need_reconfig_queues has been set to 1 */
16442 if (ports[id].need_reconfig_queues == 0)
16443 ports[id].need_reconfig_queues = queue;