1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
16 #include <net/socket.h>
18 #include <sys/socket.h>
21 #include <netinet/in.h>
23 #include <sys/queue.h>
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
47 #include <rte_eth_ctrl.h>
51 #include <cmdline_rdline.h>
52 #include <cmdline_parse.h>
53 #include <cmdline_parse_num.h>
54 #include <cmdline_parse_string.h>
55 #include <cmdline_parse_ipaddr.h>
56 #include <cmdline_parse_etheraddr.h>
57 #include <cmdline_socket.h>
59 #ifdef RTE_LIBRTE_PMD_BOND
60 #include <rte_eth_bond.h>
61 #include <rte_eth_bond_8023ad.h>
63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
64 #include <rte_pmd_dpaa.h>
66 #ifdef RTE_LIBRTE_IXGBE_PMD
67 #include <rte_pmd_ixgbe.h>
69 #ifdef RTE_LIBRTE_I40E_PMD
70 #include <rte_pmd_i40e.h>
72 #ifdef RTE_LIBRTE_BNXT_PMD
73 #include <rte_pmd_bnxt.h>
76 #include "cmdline_mtr.h"
77 #include "cmdline_tm.h"
79 static struct cmdline *testpmd_cl;
81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
83 /* *** Help command with introduction. *** */
84 struct cmd_help_brief_result {
85 cmdline_fixed_string_t help;
88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
90 __attribute__((unused)) void *data)
95 "Help is available for the following sections:\n\n"
96 " help control : Start and stop forwarding.\n"
97 " help display : Displaying port, stats and config "
99 " help config : Configuration information.\n"
100 " help ports : Configuring ports.\n"
101 " help registers : Reading and setting port registers.\n"
102 " help filters : Filters configuration help.\n"
103 " help all : All of the above sections.\n\n"
108 cmdline_parse_token_string_t cmd_help_brief_help =
109 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
111 cmdline_parse_inst_t cmd_help_brief = {
112 .f = cmd_help_brief_parsed,
114 .help_str = "help: Show help",
116 (void *)&cmd_help_brief_help,
121 /* *** Help command with help sections. *** */
122 struct cmd_help_long_result {
123 cmdline_fixed_string_t help;
124 cmdline_fixed_string_t section;
127 static void cmd_help_long_parsed(void *parsed_result,
129 __attribute__((unused)) void *data)
132 struct cmd_help_long_result *res = parsed_result;
134 if (!strcmp(res->section, "all"))
137 if (show_all || !strcmp(res->section, "control")) {
142 "Control forwarding:\n"
143 "-------------------\n\n"
146 " Start packet forwarding with current configuration.\n\n"
149 " Start packet forwarding with current config"
150 " after sending one burst of packets.\n\n"
153 " Stop packet forwarding, and display accumulated"
157 " Quit to prompt.\n\n"
161 if (show_all || !strcmp(res->section, "display")) {
169 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
170 " Display information for port_id, or all.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
178 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
179 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
180 " Display the RSS hash functions and RSS hash key"
183 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
184 " Clear information for port_id, or all.\n\n"
186 "show (rxq|txq) info (port_id) (queue_id)\n"
187 " Display information for configured RX/TX queue.\n\n"
189 "show config (rxtx|cores|fwd|txpkts)\n"
190 " Display the given configuration.\n\n"
192 "read rxd (port_id) (queue_id) (rxd_id)\n"
193 " Display an RX descriptor of a port RX queue.\n\n"
195 "read txd (port_id) (queue_id) (txd_id)\n"
196 " Display a TX descriptor of a port TX queue.\n\n"
198 "ddp get list (port_id)\n"
199 " Get ddp profile info list\n\n"
201 "ddp get info (profile_path)\n"
202 " Get ddp profile information.\n\n"
204 "show vf stats (port_id) (vf_id)\n"
205 " Display a VF's statistics.\n\n"
207 "clear vf stats (port_id) (vf_id)\n"
208 " Reset a VF's statistics.\n\n"
210 "show port (port_id) pctype mapping\n"
211 " Get flow ptype to pctype mapping on a port\n\n"
213 "show port meter stats (port_id) (meter_id) (clear)\n"
214 " Get meter stats on a port\n\n"
215 "show port tm cap (port_id)\n"
216 " Display the port TM capability.\n\n"
218 "show port tm level cap (port_id) (level_id)\n"
219 " Display the port TM hierarchical level capability.\n\n"
221 "show port tm node cap (port_id) (node_id)\n"
222 " Display the port TM node capability.\n\n"
224 "show port tm node type (port_id) (node_id)\n"
225 " Display the port TM node type.\n\n"
227 "show port tm node stats (port_id) (node_id) (clear)\n"
228 " Display the port TM node stats.\n\n"
233 if (show_all || !strcmp(res->section, "config")) {
239 "Configuration changes only become active when"
240 " forwarding is started/restarted.\n\n"
243 " Reset forwarding to the default configuration.\n\n"
245 "set verbose (level)\n"
246 " Set the debug verbosity level X.\n\n"
248 "set log global|(type) (level)\n"
249 " Set the log level.\n\n"
252 " Set number of ports.\n\n"
255 " Set number of cores.\n\n"
257 "set coremask (mask)\n"
258 " Set the forwarding cores hexadecimal mask.\n\n"
260 "set portmask (mask)\n"
261 " Set the forwarding ports hexadecimal mask.\n\n"
264 " Set number of packets per burst.\n\n"
266 "set burst tx delay (microseconds) retry (num)\n"
267 " Set the transmit delay time and number of retries,"
268 " effective when retry is enabled.\n\n"
270 "set txpkts (x[,y]*)\n"
271 " Set the length of each segment of TXONLY"
272 " and optionally CSUM packets.\n\n"
274 "set txsplit (off|on|rand)\n"
275 " Set the split policy for the TX packets."
276 " Right now only applicable for CSUM and TXONLY"
279 "set corelist (x[,y]*)\n"
280 " Set the list of forwarding cores.\n\n"
282 "set portlist (x[,y]*)\n"
283 " Set the list of forwarding ports.\n\n"
285 "set tx loopback (port_id) (on|off)\n"
286 " Enable or disable tx loopback.\n\n"
288 "set all queues drop (port_id) (on|off)\n"
289 " Set drop enable bit for all queues.\n\n"
291 "set vf split drop (port_id) (vf_id) (on|off)\n"
292 " Set split drop enable bit for a VF from the PF.\n\n"
294 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
295 " Set MAC antispoof for a VF from the PF.\n\n"
297 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
298 " Enable MACsec offload.\n\n"
300 "set macsec offload (port_id) off\n"
301 " Disable MACsec offload.\n\n"
303 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
304 " Configure MACsec secure connection (SC).\n\n"
306 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
307 " Configure MACsec secure association (SA).\n\n"
309 "set vf broadcast (port_id) (vf_id) (on|off)\n"
310 " Set VF broadcast for a VF from the PF.\n\n"
312 "vlan set strip (on|off) (port_id)\n"
313 " Set the VLAN strip on a port.\n\n"
315 "vlan set stripq (on|off) (port_id,queue_id)\n"
316 " Set the VLAN strip for a queue on a port.\n\n"
318 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
319 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
321 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
322 " Set VLAN insert for a VF from the PF.\n\n"
324 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
325 " Set VLAN antispoof for a VF from the PF.\n\n"
327 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
328 " Set VLAN tag for a VF from the PF.\n\n"
330 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
331 " Set a VF's max bandwidth(Mbps).\n\n"
333 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
334 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
336 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
337 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
339 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
340 " Set some TCs' strict link priority mode on a physical port.\n\n"
342 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
343 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
345 "vlan set filter (on|off) (port_id)\n"
346 " Set the VLAN filter on a port.\n\n"
348 "vlan set qinq (on|off) (port_id)\n"
349 " Set the VLAN QinQ (extended queue in queue)"
352 "vlan set (inner|outer) tpid (value) (port_id)\n"
353 " Set the VLAN TPID for Packet Filtering on"
356 "rx_vlan add (vlan_id|all) (port_id)\n"
357 " Add a vlan_id, or all identifiers, to the set"
358 " of VLAN identifiers filtered by port_id.\n\n"
360 "rx_vlan rm (vlan_id|all) (port_id)\n"
361 " Remove a vlan_id, or all identifiers, from the set"
362 " of VLAN identifiers filtered by port_id.\n\n"
364 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
365 " Add a vlan_id, to the set of VLAN identifiers"
366 "filtered for VF(s) from port_id.\n\n"
368 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
369 " Remove a vlan_id, to the set of VLAN identifiers"
370 "filtered for VF(s) from port_id.\n\n"
372 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
373 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
374 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
375 " add a tunnel filter of a port.\n\n"
377 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
378 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
379 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
380 " remove a tunnel filter of a port.\n\n"
382 "rx_vxlan_port add (udp_port) (port_id)\n"
383 " Add an UDP port for VXLAN packet filter on a port\n\n"
385 "rx_vxlan_port rm (udp_port) (port_id)\n"
386 " Remove an UDP port for VXLAN packet filter on a port\n\n"
388 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
389 " Set hardware insertion of VLAN IDs (single or double VLAN "
390 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
392 "tx_vlan set pvid port_id vlan_id (on|off)\n"
393 " Set port based TX VLAN insertion.\n\n"
395 "tx_vlan reset (port_id)\n"
396 " Disable hardware insertion of a VLAN header in"
397 " packets sent on a port.\n\n"
399 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
400 " Select hardware or software calculation of the"
401 " checksum when transmitting a packet using the"
402 " csum forward engine.\n"
403 " ip|udp|tcp|sctp always concern the inner layer.\n"
404 " outer-ip concerns the outer IP layer in"
405 " case the packet is recognized as a tunnel packet by"
406 " the forward engine (vxlan, gre and ipip are supported)\n"
407 " Please check the NIC datasheet for HW limits.\n\n"
409 "csum parse-tunnel (on|off) (tx_port_id)\n"
410 " If disabled, treat tunnel packets as non-tunneled"
411 " packets (treat inner headers as payload). The port\n"
412 " argument is the port used for TX in csum forward"
415 "csum show (port_id)\n"
416 " Display tx checksum offload configuration\n\n"
418 "tso set (segsize) (portid)\n"
419 " Enable TCP Segmentation Offload in csum forward"
421 " Please check the NIC datasheet for HW limits.\n\n"
424 " Display the status of TCP Segmentation Offload.\n\n"
426 "set port (port_id) gro on|off\n"
427 " Enable or disable Generic Receive Offload in"
428 " csum forwarding engine.\n\n"
430 "show port (port_id) gro\n"
431 " Display GRO configuration.\n\n"
433 "set gro flush (cycles)\n"
434 " Set the cycle to flush GROed packets from"
435 " reassembly tables.\n\n"
437 "set port (port_id) gso (on|off)"
438 " Enable or disable Generic Segmentation Offload in"
439 " csum forwarding engine.\n\n"
441 "set gso segsz (length)\n"
442 " Set max packet length for output GSO segments,"
443 " including packet header and payload.\n\n"
445 "show port (port_id) gso\n"
446 " Show GSO configuration.\n\n"
449 " Set packet forwarding mode.\n\n"
451 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
452 " Add a MAC address on port_id.\n\n"
454 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
455 " Remove a MAC address from port_id.\n\n"
457 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
458 " Set the default MAC address for port_id.\n\n"
460 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
461 " Add a MAC address for a VF on the port.\n\n"
463 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
464 " Set the MAC address for a VF from the PF.\n\n"
466 "set eth-peer (port_id) (peer_addr)\n"
467 " set the peer address for certain port.\n\n"
469 "set port (port_id) uta (mac_address|all) (on|off)\n"
470 " Add/Remove a or all unicast hash filter(s)"
473 "set promisc (port_id|all) (on|off)\n"
474 " Set the promiscuous mode on port_id, or all.\n\n"
476 "set allmulti (port_id|all) (on|off)\n"
477 " Set the allmulti mode on port_id, or all.\n\n"
479 "set vf promisc (port_id) (vf_id) (on|off)\n"
480 " Set unicast promiscuous mode for a VF from the PF.\n\n"
482 "set vf allmulti (port_id) (vf_id) (on|off)\n"
483 " Set multicast promiscuous mode for a VF from the PF.\n\n"
485 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
486 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
487 " (on|off) autoneg (on|off) (port_id)\n"
488 "set flow_ctrl rx (on|off) (portid)\n"
489 "set flow_ctrl tx (on|off) (portid)\n"
490 "set flow_ctrl high_water (high_water) (portid)\n"
491 "set flow_ctrl low_water (low_water) (portid)\n"
492 "set flow_ctrl pause_time (pause_time) (portid)\n"
493 "set flow_ctrl send_xon (send_xon) (portid)\n"
494 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
495 "set flow_ctrl autoneg (on|off) (port_id)\n"
496 " Set the link flow control parameter on a port.\n\n"
498 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
499 " (low_water) (pause_time) (priority) (port_id)\n"
500 " Set the priority flow control parameter on a"
503 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
504 " Set statistics mapping (qmapping 0..15) for RX/TX"
506 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
507 " on port 0 to mapping 5.\n\n"
509 "set xstats-hide-zero on|off\n"
510 " Set the option to hide the zero values"
511 " for xstats display.\n"
513 "set port (port_id) vf (vf_id) rx|tx on|off\n"
514 " Enable/Disable a VF receive/tranmit from a port\n\n"
516 "set port (port_id) vf (vf_id) (mac_addr)"
517 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
518 " Add/Remove unicast or multicast MAC addr filter"
521 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
523 " AUPE:accepts untagged VLAN;"
524 "ROPE:accept unicast hash\n\n"
525 " BAM:accepts broadcast packets;"
526 "MPE:accepts all multicast packets\n\n"
527 " Enable/Disable a VF receive mode of a port\n\n"
529 "set port (port_id) queue (queue_id) rate (rate_num)\n"
530 " Set rate limit for a queue of a port\n\n"
532 "set port (port_id) vf (vf_id) rate (rate_num) "
533 "queue_mask (queue_mask_value)\n"
534 " Set rate limit for queues in VF of a port\n\n"
536 "set port (port_id) mirror-rule (rule_id)"
537 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
538 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
539 " Set pool or vlan type mirror rule on a port.\n"
540 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
541 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
544 "set port (port_id) mirror-rule (rule_id)"
545 " (uplink-mirror|downlink-mirror) dst-pool"
546 " (pool_id) (on|off)\n"
547 " Set uplink or downlink type mirror rule on a port.\n"
548 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
549 " 0 on' enable mirror income traffic to pool 0.\n\n"
551 "reset port (port_id) mirror-rule (rule_id)\n"
552 " Reset a mirror rule.\n\n"
554 "set flush_rx (on|off)\n"
555 " Flush (default) or don't flush RX streams before"
556 " forwarding. Mainly used with PCAP drivers.\n\n"
558 "set bypass mode (normal|bypass|isolate) (port_id)\n"
559 " Set the bypass mode for the lowest port on bypass enabled"
562 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
563 "mode (normal|bypass|isolate) (port_id)\n"
564 " Set the event required to initiate specified bypass mode for"
565 " the lowest port on a bypass enabled NIC where:\n"
566 " timeout = enable bypass after watchdog timeout.\n"
567 " os_on = enable bypass when OS/board is powered on.\n"
568 " os_off = enable bypass when OS/board is powered off.\n"
569 " power_on = enable bypass when power supply is turned on.\n"
570 " power_off = enable bypass when power supply is turned off."
573 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
574 " Set the bypass watchdog timeout to 'n' seconds"
575 " where 0 = instant.\n\n"
577 "show bypass config (port_id)\n"
578 " Show the bypass configuration for a bypass enabled NIC"
579 " using the lowest port on the NIC.\n\n"
581 #ifdef RTE_LIBRTE_PMD_BOND
582 "create bonded device (mode) (socket)\n"
583 " Create a new bonded device with specific bonding mode and socket.\n\n"
585 "add bonding slave (slave_id) (port_id)\n"
586 " Add a slave device to a bonded device.\n\n"
588 "remove bonding slave (slave_id) (port_id)\n"
589 " Remove a slave device from a bonded device.\n\n"
591 "set bonding mode (value) (port_id)\n"
592 " Set the bonding mode on a bonded device.\n\n"
594 "set bonding primary (slave_id) (port_id)\n"
595 " Set the primary slave for a bonded device.\n\n"
597 "show bonding config (port_id)\n"
598 " Show the bonding config for port_id.\n\n"
600 "set bonding mac_addr (port_id) (address)\n"
601 " Set the MAC address of a bonded device.\n\n"
603 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
604 " Set Aggregation mode for IEEE802.3AD (mode 4)"
606 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
607 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
609 "set bonding mon_period (port_id) (value)\n"
610 " Set the bonding link status monitoring polling period in ms.\n\n"
612 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
613 " Enable/disable dedicated queues for LACP control traffic.\n\n"
616 "set link-up port (port_id)\n"
617 " Set link up for a port.\n\n"
619 "set link-down port (port_id)\n"
620 " Set link down for a port.\n\n"
622 "E-tag set insertion on port-tag-id (value)"
623 " port (port_id) vf (vf_id)\n"
624 " Enable E-tag insertion for a VF on a port\n\n"
626 "E-tag set insertion off port (port_id) vf (vf_id)\n"
627 " Disable E-tag insertion for a VF on a port\n\n"
629 "E-tag set stripping (on|off) port (port_id)\n"
630 " Enable/disable E-tag stripping on a port\n\n"
632 "E-tag set forwarding (on|off) port (port_id)\n"
633 " Enable/disable E-tag based forwarding"
636 "E-tag set filter add e-tag-id (value) dst-pool"
637 " (pool_id) port (port_id)\n"
638 " Add an E-tag forwarding filter on a port\n\n"
640 "E-tag set filter del e-tag-id (value) port (port_id)\n"
641 " Delete an E-tag forwarding filter on a port\n\n"
643 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
644 "set port tm hierarchy default (port_id)\n"
645 " Set default traffic Management hierarchy on a port\n\n"
648 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
649 " Load a profile package on a port\n\n"
651 "ddp del (port_id) (backup_profile_path)\n"
652 " Delete a profile package from a port\n\n"
654 "ptype mapping get (port_id) (valid_only)\n"
655 " Get ptype mapping on a port\n\n"
657 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
658 " Replace target with the pkt_type in ptype mapping\n\n"
660 "ptype mapping reset (port_id)\n"
661 " Reset ptype mapping on a port\n\n"
663 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
664 " Update a ptype mapping item on a port\n\n"
666 "set port (port_id) queue-region region_id (value) "
667 "queue_start_index (value) queue_num (value)\n"
668 " Set a queue region on a port\n\n"
670 "set port (port_id) queue-region region_id (value) "
672 " Set a flowtype region index on a port\n\n"
674 "set port (port_id) queue-region UP (value) region_id (value)\n"
675 " Set the mapping of User Priority to "
676 "queue region on a port\n\n"
678 "set port (port_id) queue-region flush (on|off)\n"
679 " flush all queue region related configuration\n\n"
681 "show port meter cap (port_id)\n"
682 " Show port meter capability information\n\n"
684 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
685 " meter profile add - srtcm rfc 2697\n\n"
687 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
688 " meter profile add - trtcm rfc 2698\n\n"
690 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
691 " meter profile add - trtcm rfc 4115\n\n"
693 "del port meter profile (port_id) (profile_id)\n"
694 " meter profile delete\n\n"
696 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
697 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
698 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
699 "(dscp_tbl_entry63)]\n"
702 "enable port meter (port_id) (mtr_id)\n"
705 "disable port meter (port_id) (mtr_id)\n"
708 "del port meter (port_id) (mtr_id)\n"
711 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
712 " meter update meter profile\n\n"
714 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
715 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
716 " update meter dscp table entries\n\n"
718 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
719 "(action0) [(action1) (action2)]\n"
720 " meter update policer action\n\n"
722 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
723 " meter update stats\n\n"
725 "show port (port_id) queue-region\n"
726 " show all queue region related configuration info\n\n"
728 "add port tm node shaper profile (port_id) (shaper_profile_id)"
729 " (tb_rate) (tb_size) (packet_length_adjust)\n"
730 " Add port tm node private shaper profile.\n\n"
732 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
733 " Delete port tm node private shaper profile.\n\n"
735 "add port tm node shared shaper (port_id) (shared_shaper_id)"
736 " (shaper_profile_id)\n"
737 " Add/update port tm node shared shaper.\n\n"
739 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
740 " Delete port tm node shared shaper.\n\n"
742 "set port tm node shaper profile (port_id) (node_id)"
743 " (shaper_profile_id)\n"
744 " Set port tm node shaper profile.\n\n"
746 "add port tm node wred profile (port_id) (wred_profile_id)"
747 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
748 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
749 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
750 " Add port tm node wred profile.\n\n"
752 "del port tm node wred profile (port_id) (wred_profile_id)\n"
753 " Delete port tm node wred profile.\n\n"
755 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
756 " (priority) (weight) (level_id) (shaper_profile_id)"
757 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
758 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
759 " Add port tm nonleaf node.\n\n"
761 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
762 " (priority) (weight) (level_id) (shaper_profile_id)"
763 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
764 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
765 " Add port tm leaf node.\n\n"
767 "del port tm node (port_id) (node_id)\n"
768 " Delete port tm node.\n\n"
770 "set port tm node parent (port_id) (node_id) (parent_node_id)"
771 " (priority) (weight)\n"
772 " Set port tm node parent.\n\n"
774 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
775 " Commit tm hierarchy.\n\n"
777 , list_pkt_forwarding_modes()
781 if (show_all || !strcmp(res->section, "ports")) {
787 "----------------\n\n"
789 "port start (port_id|all)\n"
790 " Start all ports or port_id.\n\n"
792 "port stop (port_id|all)\n"
793 " Stop all ports or port_id.\n\n"
795 "port close (port_id|all)\n"
796 " Close all ports or port_id.\n\n"
798 "port attach (ident)\n"
799 " Attach physical or virtual dev by pci address or virtual device name\n\n"
801 "port detach (port_id)\n"
802 " Detach physical or virtual dev by port_id\n\n"
804 "port config (port_id|all)"
805 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
806 " duplex (half|full|auto)\n"
807 " Set speed and duplex for all ports or port_id\n\n"
809 "port config (port_id|all) loopback (mode)\n"
810 " Set loopback mode for all ports or port_id\n\n"
812 "port config all (rxq|txq|rxd|txd) (value)\n"
813 " Set number for rxq/txq/rxd/txd.\n\n"
815 "port config all max-pkt-len (value)\n"
816 " Set the max packet length.\n\n"
818 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
819 "hw-vlan-strip|hw-vlan-extend|drop-en)"
821 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
824 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
825 "geneve|nvgre|none|<flowtype_id>)\n"
826 " Set the RSS mode.\n\n"
828 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
829 " Set the RSS redirection table.\n\n"
831 "port config (port_id) dcb vt (on|off) (traffic_class)"
833 " Set the DCB mode.\n\n"
835 "port config all burst (value)\n"
836 " Set the number of packets per burst.\n\n"
838 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
840 " Set the ring prefetch/host/writeback threshold"
841 " for tx/rx queue.\n\n"
843 "port config all (txfreet|txrst|rxfreet) (value)\n"
844 " Set free threshold for rx/tx, or set"
845 " tx rs bit threshold.\n\n"
846 "port config mtu X value\n"
847 " Set the MTU of port X to a given value\n\n"
849 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
850 " Start/stop a rx/tx queue of port X. Only take effect"
851 " when port X is started\n\n"
853 "port config (port_id|all) l2-tunnel E-tag ether-type"
855 " Set the value of E-tag ether-type.\n\n"
857 "port config (port_id|all) l2-tunnel E-tag"
858 " (enable|disable)\n"
859 " Enable/disable the E-tag support.\n\n"
861 "port config (port_id) pctype mapping reset\n"
862 " Reset flow type to pctype mapping on a port\n\n"
864 "port config (port_id) pctype mapping update"
865 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
866 " Update a flow type to pctype mapping item on a port\n\n"
868 "port config (port_id) pctype (pctype_id) hash_inset|"
869 "fdir_inset|fdir_flx_inset get|set|clear field\n"
871 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
873 "port config (port_id) pctype (pctype_id) hash_inset|"
874 "fdir_inset|fdir_flx_inset clear all"
875 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
879 if (show_all || !strcmp(res->section, "registers")) {
887 "read reg (port_id) (address)\n"
888 " Display value of a port register.\n\n"
890 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
891 " Display a port register bit field.\n\n"
893 "read regbit (port_id) (address) (bit_x)\n"
894 " Display a single port register bit.\n\n"
896 "write reg (port_id) (address) (value)\n"
897 " Set value of a port register.\n\n"
899 "write regfield (port_id) (address) (bit_x) (bit_y)"
901 " Set bit field of a port register.\n\n"
903 "write regbit (port_id) (address) (bit_x) (value)\n"
904 " Set single bit value of a port register.\n\n"
907 if (show_all || !strcmp(res->section, "filters")) {
915 "ethertype_filter (port_id) (add|del)"
916 " (mac_addr|mac_ignr) (mac_address) ethertype"
917 " (ether_type) (drop|fwd) queue (queue_id)\n"
918 " Add/Del an ethertype filter.\n\n"
920 "2tuple_filter (port_id) (add|del)"
921 " dst_port (dst_port_value) protocol (protocol_value)"
922 " mask (mask_value) tcp_flags (tcp_flags_value)"
923 " priority (prio_value) queue (queue_id)\n"
924 " Add/Del a 2tuple filter.\n\n"
926 "5tuple_filter (port_id) (add|del)"
927 " dst_ip (dst_address) src_ip (src_address)"
928 " dst_port (dst_port_value) src_port (src_port_value)"
929 " protocol (protocol_value)"
930 " mask (mask_value) tcp_flags (tcp_flags_value)"
931 " priority (prio_value) queue (queue_id)\n"
932 " Add/Del a 5tuple filter.\n\n"
934 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
935 " Add/Del syn filter.\n\n"
937 "flex_filter (port_id) (add|del) len (len_value)"
938 " bytes (bytes_value) mask (mask_value)"
939 " priority (prio_value) queue (queue_id)\n"
940 " Add/Del a flex filter.\n\n"
942 "flow_director_filter (port_id) mode IP (add|del|update)"
943 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
944 " src (src_ip_address) dst (dst_ip_address)"
945 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
946 " vlan (vlan_value) flexbytes (flexbytes_value)"
947 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
948 " fd_id (fd_id_value)\n"
949 " Add/Del an IP type flow director filter.\n\n"
951 "flow_director_filter (port_id) mode IP (add|del|update)"
952 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
953 " src (src_ip_address) (src_port)"
954 " dst (dst_ip_address) (dst_port)"
955 " tos (tos_value) ttl (ttl_value)"
956 " vlan (vlan_value) flexbytes (flexbytes_value)"
957 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
958 " fd_id (fd_id_value)\n"
959 " Add/Del an UDP/TCP type flow director filter.\n\n"
961 "flow_director_filter (port_id) mode IP (add|del|update)"
962 " flow (ipv4-sctp|ipv6-sctp)"
963 " src (src_ip_address) (src_port)"
964 " dst (dst_ip_address) (dst_port)"
965 " tag (verification_tag) "
966 " tos (tos_value) ttl (ttl_value)"
968 " flexbytes (flexbytes_value) (drop|fwd)"
969 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
970 " Add/Del a SCTP type flow director filter.\n\n"
972 "flow_director_filter (port_id) mode IP (add|del|update)"
973 " flow l2_payload ether (ethertype)"
974 " flexbytes (flexbytes_value) (drop|fwd)"
975 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
976 " Add/Del a l2 payload type flow director filter.\n\n"
978 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
979 " mac (mac_address) vlan (vlan_value)"
980 " flexbytes (flexbytes_value) (drop|fwd)"
981 " queue (queue_id) fd_id (fd_id_value)\n"
982 " Add/Del a MAC-VLAN flow director filter.\n\n"
984 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
985 " mac (mac_address) vlan (vlan_value)"
986 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
987 " flexbytes (flexbytes_value) (drop|fwd)"
988 " queue (queue_id) fd_id (fd_id_value)\n"
989 " Add/Del a Tunnel flow director filter.\n\n"
991 "flow_director_filter (port_id) mode raw (add|del|update)"
992 " flow (flow_id) (drop|fwd) queue (queue_id)"
993 " fd_id (fd_id_value) packet (packet file name)\n"
994 " Add/Del a raw type flow director filter.\n\n"
996 "flush_flow_director (port_id)\n"
997 " Flush all flow director entries of a device.\n\n"
999 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1000 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1001 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1002 " Set flow director IP mask.\n\n"
1004 "flow_director_mask (port_id) mode MAC-VLAN"
1005 " vlan (vlan_value)\n"
1006 " Set flow director MAC-VLAN mask.\n\n"
1008 "flow_director_mask (port_id) mode Tunnel"
1009 " vlan (vlan_value) mac (mac_value)"
1010 " tunnel-type (tunnel_type_value)"
1011 " tunnel-id (tunnel_id_value)\n"
1012 " Set flow director Tunnel mask.\n\n"
1014 "flow_director_flex_mask (port_id)"
1015 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1016 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1018 " Configure mask of flex payload.\n\n"
1020 "flow_director_flex_payload (port_id)"
1021 " (raw|l2|l3|l4) (config)\n"
1022 " Configure flex payload selection.\n\n"
1024 "get_sym_hash_ena_per_port (port_id)\n"
1025 " get symmetric hash enable configuration per port.\n\n"
1027 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1028 " set symmetric hash enable configuration per port"
1029 " to enable or disable.\n\n"
1031 "get_hash_global_config (port_id)\n"
1032 " Get the global configurations of hash filters.\n\n"
1034 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1035 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1036 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1037 " (enable|disable)\n"
1038 " Set the global configurations of hash filters.\n\n"
1040 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1041 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1042 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1043 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1044 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1045 "ipv6-next-header|udp-src-port|udp-dst-port|"
1046 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1047 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1048 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1049 "fld-8th|none) (select|add)\n"
1050 " Set the input set for hash.\n\n"
1052 "set_fdir_input_set (port_id) "
1053 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1054 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1055 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1056 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1057 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1058 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1059 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1061 " Set the input set for FDir.\n\n"
1063 "flow validate {port_id}"
1064 " [group {group_id}] [priority {level}]"
1065 " [ingress] [egress]"
1066 " pattern {item} [/ {item} [...]] / end"
1067 " actions {action} [/ {action} [...]] / end\n"
1068 " Check whether a flow rule can be created.\n\n"
1070 "flow create {port_id}"
1071 " [group {group_id}] [priority {level}]"
1072 " [ingress] [egress]"
1073 " pattern {item} [/ {item} [...]] / end"
1074 " actions {action} [/ {action} [...]] / end\n"
1075 " Create a flow rule.\n\n"
1077 "flow destroy {port_id} rule {rule_id} [...]\n"
1078 " Destroy specific flow rules.\n\n"
1080 "flow flush {port_id}\n"
1081 " Destroy all flow rules.\n\n"
1083 "flow query {port_id} {rule_id} {action}\n"
1084 " Query an existing flow rule.\n\n"
1086 "flow list {port_id} [group {group_id}] [...]\n"
1087 " List existing flow rules sorted by priority,"
1088 " filtered by group identifiers.\n\n"
1090 "flow isolate {port_id} {boolean}\n"
1091 " Restrict ingress traffic to the defined"
1097 cmdline_parse_token_string_t cmd_help_long_help =
1098 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1100 cmdline_parse_token_string_t cmd_help_long_section =
1101 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1102 "all#control#display#config#"
1103 "ports#registers#filters");
1105 cmdline_parse_inst_t cmd_help_long = {
1106 .f = cmd_help_long_parsed,
1108 .help_str = "help all|control|display|config|ports|register|filters: "
1111 (void *)&cmd_help_long_help,
1112 (void *)&cmd_help_long_section,
1118 /* *** start/stop/close all ports *** */
1119 struct cmd_operate_port_result {
1120 cmdline_fixed_string_t keyword;
1121 cmdline_fixed_string_t name;
1122 cmdline_fixed_string_t value;
1125 static void cmd_operate_port_parsed(void *parsed_result,
1126 __attribute__((unused)) struct cmdline *cl,
1127 __attribute__((unused)) void *data)
1129 struct cmd_operate_port_result *res = parsed_result;
1131 if (!strcmp(res->name, "start"))
1132 start_port(RTE_PORT_ALL);
1133 else if (!strcmp(res->name, "stop"))
1134 stop_port(RTE_PORT_ALL);
1135 else if (!strcmp(res->name, "close"))
1136 close_port(RTE_PORT_ALL);
1137 else if (!strcmp(res->name, "reset"))
1138 reset_port(RTE_PORT_ALL);
1140 printf("Unknown parameter\n");
1143 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1144 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1146 cmdline_parse_token_string_t cmd_operate_port_all_port =
1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1148 "start#stop#close#reset");
1149 cmdline_parse_token_string_t cmd_operate_port_all_all =
1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1152 cmdline_parse_inst_t cmd_operate_port = {
1153 .f = cmd_operate_port_parsed,
1155 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1157 (void *)&cmd_operate_port_all_cmd,
1158 (void *)&cmd_operate_port_all_port,
1159 (void *)&cmd_operate_port_all_all,
1164 /* *** start/stop/close specific port *** */
1165 struct cmd_operate_specific_port_result {
1166 cmdline_fixed_string_t keyword;
1167 cmdline_fixed_string_t name;
1171 static void cmd_operate_specific_port_parsed(void *parsed_result,
1172 __attribute__((unused)) struct cmdline *cl,
1173 __attribute__((unused)) void *data)
1175 struct cmd_operate_specific_port_result *res = parsed_result;
1177 if (!strcmp(res->name, "start"))
1178 start_port(res->value);
1179 else if (!strcmp(res->name, "stop"))
1180 stop_port(res->value);
1181 else if (!strcmp(res->name, "close"))
1182 close_port(res->value);
1183 else if (!strcmp(res->name, "reset"))
1184 reset_port(res->value);
1186 printf("Unknown parameter\n");
1189 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1190 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1192 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1194 name, "start#stop#close#reset");
1195 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1196 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1199 cmdline_parse_inst_t cmd_operate_specific_port = {
1200 .f = cmd_operate_specific_port_parsed,
1202 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1204 (void *)&cmd_operate_specific_port_cmd,
1205 (void *)&cmd_operate_specific_port_port,
1206 (void *)&cmd_operate_specific_port_id,
1211 /* *** attach a specified port *** */
1212 struct cmd_operate_attach_port_result {
1213 cmdline_fixed_string_t port;
1214 cmdline_fixed_string_t keyword;
1215 cmdline_fixed_string_t identifier;
1218 static void cmd_operate_attach_port_parsed(void *parsed_result,
1219 __attribute__((unused)) struct cmdline *cl,
1220 __attribute__((unused)) void *data)
1222 struct cmd_operate_attach_port_result *res = parsed_result;
1224 if (!strcmp(res->keyword, "attach"))
1225 attach_port(res->identifier);
1227 printf("Unknown parameter\n");
1230 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1231 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1233 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1236 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1240 cmdline_parse_inst_t cmd_operate_attach_port = {
1241 .f = cmd_operate_attach_port_parsed,
1243 .help_str = "port attach <identifier>: "
1244 "(identifier: pci address or virtual dev name)",
1246 (void *)&cmd_operate_attach_port_port,
1247 (void *)&cmd_operate_attach_port_keyword,
1248 (void *)&cmd_operate_attach_port_identifier,
1253 /* *** detach a specified port *** */
1254 struct cmd_operate_detach_port_result {
1255 cmdline_fixed_string_t port;
1256 cmdline_fixed_string_t keyword;
1260 static void cmd_operate_detach_port_parsed(void *parsed_result,
1261 __attribute__((unused)) struct cmdline *cl,
1262 __attribute__((unused)) void *data)
1264 struct cmd_operate_detach_port_result *res = parsed_result;
1266 if (!strcmp(res->keyword, "detach"))
1267 detach_port(res->port_id);
1269 printf("Unknown parameter\n");
1272 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1273 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1275 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1278 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1279 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1282 cmdline_parse_inst_t cmd_operate_detach_port = {
1283 .f = cmd_operate_detach_port_parsed,
1285 .help_str = "port detach <port_id>",
1287 (void *)&cmd_operate_detach_port_port,
1288 (void *)&cmd_operate_detach_port_keyword,
1289 (void *)&cmd_operate_detach_port_port_id,
1294 /* *** configure speed for all ports *** */
1295 struct cmd_config_speed_all {
1296 cmdline_fixed_string_t port;
1297 cmdline_fixed_string_t keyword;
1298 cmdline_fixed_string_t all;
1299 cmdline_fixed_string_t item1;
1300 cmdline_fixed_string_t item2;
1301 cmdline_fixed_string_t value1;
1302 cmdline_fixed_string_t value2;
1306 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1311 if (!strcmp(duplexstr, "half")) {
1312 duplex = ETH_LINK_HALF_DUPLEX;
1313 } else if (!strcmp(duplexstr, "full")) {
1314 duplex = ETH_LINK_FULL_DUPLEX;
1315 } else if (!strcmp(duplexstr, "auto")) {
1316 duplex = ETH_LINK_FULL_DUPLEX;
1318 printf("Unknown duplex parameter\n");
1322 if (!strcmp(speedstr, "10")) {
1323 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1324 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1325 } else if (!strcmp(speedstr, "100")) {
1326 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1327 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1329 if (duplex != ETH_LINK_FULL_DUPLEX) {
1330 printf("Invalid speed/duplex parameters\n");
1333 if (!strcmp(speedstr, "1000")) {
1334 *speed = ETH_LINK_SPEED_1G;
1335 } else if (!strcmp(speedstr, "10000")) {
1336 *speed = ETH_LINK_SPEED_10G;
1337 } else if (!strcmp(speedstr, "25000")) {
1338 *speed = ETH_LINK_SPEED_25G;
1339 } else if (!strcmp(speedstr, "40000")) {
1340 *speed = ETH_LINK_SPEED_40G;
1341 } else if (!strcmp(speedstr, "50000")) {
1342 *speed = ETH_LINK_SPEED_50G;
1343 } else if (!strcmp(speedstr, "100000")) {
1344 *speed = ETH_LINK_SPEED_100G;
1345 } else if (!strcmp(speedstr, "auto")) {
1346 *speed = ETH_LINK_SPEED_AUTONEG;
1348 printf("Unknown speed parameter\n");
1357 cmd_config_speed_all_parsed(void *parsed_result,
1358 __attribute__((unused)) struct cmdline *cl,
1359 __attribute__((unused)) void *data)
1361 struct cmd_config_speed_all *res = parsed_result;
1362 uint32_t link_speed;
1365 if (!all_ports_stopped()) {
1366 printf("Please stop all ports first\n");
1370 if (parse_and_check_speed_duplex(res->value1, res->value2,
1374 RTE_ETH_FOREACH_DEV(pid) {
1375 ports[pid].dev_conf.link_speeds = link_speed;
1378 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1381 cmdline_parse_token_string_t cmd_config_speed_all_port =
1382 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1383 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1384 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1386 cmdline_parse_token_string_t cmd_config_speed_all_all =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1388 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1389 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1390 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1391 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1392 "10#100#1000#10000#25000#40000#50000#100000#auto");
1393 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1395 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1399 cmdline_parse_inst_t cmd_config_speed_all = {
1400 .f = cmd_config_speed_all_parsed,
1402 .help_str = "port config all speed "
1403 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1406 (void *)&cmd_config_speed_all_port,
1407 (void *)&cmd_config_speed_all_keyword,
1408 (void *)&cmd_config_speed_all_all,
1409 (void *)&cmd_config_speed_all_item1,
1410 (void *)&cmd_config_speed_all_value1,
1411 (void *)&cmd_config_speed_all_item2,
1412 (void *)&cmd_config_speed_all_value2,
1417 /* *** configure speed for specific port *** */
1418 struct cmd_config_speed_specific {
1419 cmdline_fixed_string_t port;
1420 cmdline_fixed_string_t keyword;
1422 cmdline_fixed_string_t item1;
1423 cmdline_fixed_string_t item2;
1424 cmdline_fixed_string_t value1;
1425 cmdline_fixed_string_t value2;
1429 cmd_config_speed_specific_parsed(void *parsed_result,
1430 __attribute__((unused)) struct cmdline *cl,
1431 __attribute__((unused)) void *data)
1433 struct cmd_config_speed_specific *res = parsed_result;
1434 uint32_t link_speed;
1436 if (!all_ports_stopped()) {
1437 printf("Please stop all ports first\n");
1441 if (port_id_is_invalid(res->id, ENABLED_WARN))
1444 if (parse_and_check_speed_duplex(res->value1, res->value2,
1448 ports[res->id].dev_conf.link_speeds = link_speed;
1450 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1454 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1455 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1457 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1460 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1461 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1462 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1463 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1465 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1467 "10#100#1000#10000#25000#40000#50000#100000#auto");
1468 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1471 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1475 cmdline_parse_inst_t cmd_config_speed_specific = {
1476 .f = cmd_config_speed_specific_parsed,
1478 .help_str = "port config <port_id> speed "
1479 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1482 (void *)&cmd_config_speed_specific_port,
1483 (void *)&cmd_config_speed_specific_keyword,
1484 (void *)&cmd_config_speed_specific_id,
1485 (void *)&cmd_config_speed_specific_item1,
1486 (void *)&cmd_config_speed_specific_value1,
1487 (void *)&cmd_config_speed_specific_item2,
1488 (void *)&cmd_config_speed_specific_value2,
1493 /* *** configure loopback for all ports *** */
1494 struct cmd_config_loopback_all {
1495 cmdline_fixed_string_t port;
1496 cmdline_fixed_string_t keyword;
1497 cmdline_fixed_string_t all;
1498 cmdline_fixed_string_t item;
1503 cmd_config_loopback_all_parsed(void *parsed_result,
1504 __attribute__((unused)) struct cmdline *cl,
1505 __attribute__((unused)) void *data)
1507 struct cmd_config_loopback_all *res = parsed_result;
1510 if (!all_ports_stopped()) {
1511 printf("Please stop all ports first\n");
1515 RTE_ETH_FOREACH_DEV(pid) {
1516 ports[pid].dev_conf.lpbk_mode = res->mode;
1519 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1522 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1523 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1524 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1525 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1527 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1528 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1529 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1530 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1532 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1533 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1535 cmdline_parse_inst_t cmd_config_loopback_all = {
1536 .f = cmd_config_loopback_all_parsed,
1538 .help_str = "port config all loopback <mode>",
1540 (void *)&cmd_config_loopback_all_port,
1541 (void *)&cmd_config_loopback_all_keyword,
1542 (void *)&cmd_config_loopback_all_all,
1543 (void *)&cmd_config_loopback_all_item,
1544 (void *)&cmd_config_loopback_all_mode,
1549 /* *** configure loopback for specific port *** */
1550 struct cmd_config_loopback_specific {
1551 cmdline_fixed_string_t port;
1552 cmdline_fixed_string_t keyword;
1554 cmdline_fixed_string_t item;
1559 cmd_config_loopback_specific_parsed(void *parsed_result,
1560 __attribute__((unused)) struct cmdline *cl,
1561 __attribute__((unused)) void *data)
1563 struct cmd_config_loopback_specific *res = parsed_result;
1565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1568 if (!port_is_stopped(res->port_id)) {
1569 printf("Please stop port %u first\n", res->port_id);
1573 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1575 cmd_reconfig_device_queue(res->port_id, 1, 1);
1579 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1582 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1585 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1586 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1588 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1589 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1591 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1592 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1595 cmdline_parse_inst_t cmd_config_loopback_specific = {
1596 .f = cmd_config_loopback_specific_parsed,
1598 .help_str = "port config <port_id> loopback <mode>",
1600 (void *)&cmd_config_loopback_specific_port,
1601 (void *)&cmd_config_loopback_specific_keyword,
1602 (void *)&cmd_config_loopback_specific_id,
1603 (void *)&cmd_config_loopback_specific_item,
1604 (void *)&cmd_config_loopback_specific_mode,
1609 /* *** configure txq/rxq, txd/rxd *** */
1610 struct cmd_config_rx_tx {
1611 cmdline_fixed_string_t port;
1612 cmdline_fixed_string_t keyword;
1613 cmdline_fixed_string_t all;
1614 cmdline_fixed_string_t name;
1619 cmd_config_rx_tx_parsed(void *parsed_result,
1620 __attribute__((unused)) struct cmdline *cl,
1621 __attribute__((unused)) void *data)
1623 struct cmd_config_rx_tx *res = parsed_result;
1625 if (!all_ports_stopped()) {
1626 printf("Please stop all ports first\n");
1629 if (!strcmp(res->name, "rxq")) {
1630 if (!res->value && !nb_txq) {
1631 printf("Warning: Either rx or tx queues should be non zero\n");
1634 if (check_nb_rxq(res->value) != 0)
1636 nb_rxq = res->value;
1638 else if (!strcmp(res->name, "txq")) {
1639 if (!res->value && !nb_rxq) {
1640 printf("Warning: Either rx or tx queues should be non zero\n");
1643 if (check_nb_txq(res->value) != 0)
1645 nb_txq = res->value;
1647 else if (!strcmp(res->name, "rxd")) {
1648 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1649 printf("rxd %d invalid - must be > 0 && <= %d\n",
1650 res->value, RTE_TEST_RX_DESC_MAX);
1653 nb_rxd = res->value;
1654 } else if (!strcmp(res->name, "txd")) {
1655 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1656 printf("txd %d invalid - must be > 0 && <= %d\n",
1657 res->value, RTE_TEST_TX_DESC_MAX);
1660 nb_txd = res->value;
1662 printf("Unknown parameter\n");
1670 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1673 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1675 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1677 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1678 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1679 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1680 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1682 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1683 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1685 cmdline_parse_inst_t cmd_config_rx_tx = {
1686 .f = cmd_config_rx_tx_parsed,
1688 .help_str = "port config all rxq|txq|rxd|txd <value>",
1690 (void *)&cmd_config_rx_tx_port,
1691 (void *)&cmd_config_rx_tx_keyword,
1692 (void *)&cmd_config_rx_tx_all,
1693 (void *)&cmd_config_rx_tx_name,
1694 (void *)&cmd_config_rx_tx_value,
1699 /* *** config max packet length *** */
1700 struct cmd_config_max_pkt_len_result {
1701 cmdline_fixed_string_t port;
1702 cmdline_fixed_string_t keyword;
1703 cmdline_fixed_string_t all;
1704 cmdline_fixed_string_t name;
1709 cmd_config_max_pkt_len_parsed(void *parsed_result,
1710 __attribute__((unused)) struct cmdline *cl,
1711 __attribute__((unused)) void *data)
1713 struct cmd_config_max_pkt_len_result *res = parsed_result;
1716 if (!all_ports_stopped()) {
1717 printf("Please stop all ports first\n");
1721 RTE_ETH_FOREACH_DEV(pid) {
1722 struct rte_port *port = &ports[pid];
1723 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1725 if (!strcmp(res->name, "max-pkt-len")) {
1726 if (res->value < ETHER_MIN_LEN) {
1727 printf("max-pkt-len can not be less than %d\n",
1731 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1734 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1735 if (res->value > ETHER_MAX_LEN)
1736 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1738 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1739 port->dev_conf.rxmode.offloads = rx_offloads;
1741 printf("Unknown parameter\n");
1748 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1751 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1752 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1754 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1755 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1757 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1758 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1760 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1761 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1763 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1764 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1767 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1768 .f = cmd_config_max_pkt_len_parsed,
1770 .help_str = "port config all max-pkt-len <value>",
1772 (void *)&cmd_config_max_pkt_len_port,
1773 (void *)&cmd_config_max_pkt_len_keyword,
1774 (void *)&cmd_config_max_pkt_len_all,
1775 (void *)&cmd_config_max_pkt_len_name,
1776 (void *)&cmd_config_max_pkt_len_value,
1781 /* *** configure port MTU *** */
1782 struct cmd_config_mtu_result {
1783 cmdline_fixed_string_t port;
1784 cmdline_fixed_string_t keyword;
1785 cmdline_fixed_string_t mtu;
1791 cmd_config_mtu_parsed(void *parsed_result,
1792 __attribute__((unused)) struct cmdline *cl,
1793 __attribute__((unused)) void *data)
1795 struct cmd_config_mtu_result *res = parsed_result;
1797 if (res->value < ETHER_MIN_LEN) {
1798 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1801 port_mtu_set(res->port_id, res->value);
1804 cmdline_parse_token_string_t cmd_config_mtu_port =
1805 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1807 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1808 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1810 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1811 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1813 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1814 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1815 cmdline_parse_token_num_t cmd_config_mtu_value =
1816 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1818 cmdline_parse_inst_t cmd_config_mtu = {
1819 .f = cmd_config_mtu_parsed,
1821 .help_str = "port config mtu <port_id> <value>",
1823 (void *)&cmd_config_mtu_port,
1824 (void *)&cmd_config_mtu_keyword,
1825 (void *)&cmd_config_mtu_mtu,
1826 (void *)&cmd_config_mtu_port_id,
1827 (void *)&cmd_config_mtu_value,
1832 /* *** configure rx mode *** */
1833 struct cmd_config_rx_mode_flag {
1834 cmdline_fixed_string_t port;
1835 cmdline_fixed_string_t keyword;
1836 cmdline_fixed_string_t all;
1837 cmdline_fixed_string_t name;
1838 cmdline_fixed_string_t value;
1842 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1843 __attribute__((unused)) struct cmdline *cl,
1844 __attribute__((unused)) void *data)
1846 struct cmd_config_rx_mode_flag *res = parsed_result;
1849 if (!all_ports_stopped()) {
1850 printf("Please stop all ports first\n");
1854 RTE_ETH_FOREACH_DEV(pid) {
1855 struct rte_port *port;
1856 uint64_t rx_offloads;
1859 rx_offloads = port->dev_conf.rxmode.offloads;
1860 if (!strcmp(res->name, "crc-strip")) {
1861 if (!strcmp(res->value, "on"))
1862 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1863 else if (!strcmp(res->value, "off"))
1864 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1866 printf("Unknown parameter\n");
1869 } else if (!strcmp(res->name, "scatter")) {
1870 if (!strcmp(res->value, "on")) {
1871 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1872 } else if (!strcmp(res->value, "off")) {
1873 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1875 printf("Unknown parameter\n");
1878 } else if (!strcmp(res->name, "rx-cksum")) {
1879 if (!strcmp(res->value, "on"))
1880 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1881 else if (!strcmp(res->value, "off"))
1882 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1884 printf("Unknown parameter\n");
1887 } else if (!strcmp(res->name, "rx-timestamp")) {
1888 if (!strcmp(res->value, "on"))
1889 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1890 else if (!strcmp(res->value, "off"))
1891 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1893 printf("Unknown parameter\n");
1896 } else if (!strcmp(res->name, "hw-vlan")) {
1897 if (!strcmp(res->value, "on")) {
1898 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1899 DEV_RX_OFFLOAD_VLAN_STRIP);
1900 } else if (!strcmp(res->value, "off")) {
1901 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1902 DEV_RX_OFFLOAD_VLAN_STRIP);
1904 printf("Unknown parameter\n");
1907 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1908 if (!strcmp(res->value, "on"))
1909 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1910 else if (!strcmp(res->value, "off"))
1911 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1913 printf("Unknown parameter\n");
1916 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1917 if (!strcmp(res->value, "on"))
1918 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1919 else if (!strcmp(res->value, "off"))
1920 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1922 printf("Unknown parameter\n");
1925 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1926 if (!strcmp(res->value, "on"))
1927 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1928 else if (!strcmp(res->value, "off"))
1929 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1931 printf("Unknown parameter\n");
1934 } else if (!strcmp(res->name, "drop-en")) {
1935 if (!strcmp(res->value, "on"))
1937 else if (!strcmp(res->value, "off"))
1940 printf("Unknown parameter\n");
1944 printf("Unknown parameter\n");
1947 port->dev_conf.rxmode.offloads = rx_offloads;
1952 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1955 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1956 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1957 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1960 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1962 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1964 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1965 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1966 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1970 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1971 .f = cmd_config_rx_mode_flag_parsed,
1973 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1974 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1976 (void *)&cmd_config_rx_mode_flag_port,
1977 (void *)&cmd_config_rx_mode_flag_keyword,
1978 (void *)&cmd_config_rx_mode_flag_all,
1979 (void *)&cmd_config_rx_mode_flag_name,
1980 (void *)&cmd_config_rx_mode_flag_value,
1985 /* *** configure rss *** */
1986 struct cmd_config_rss {
1987 cmdline_fixed_string_t port;
1988 cmdline_fixed_string_t keyword;
1989 cmdline_fixed_string_t all;
1990 cmdline_fixed_string_t name;
1991 cmdline_fixed_string_t value;
1995 cmd_config_rss_parsed(void *parsed_result,
1996 __attribute__((unused)) struct cmdline *cl,
1997 __attribute__((unused)) void *data)
1999 struct cmd_config_rss *res = parsed_result;
2000 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2004 if (!strcmp(res->value, "all"))
2005 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2006 ETH_RSS_UDP | ETH_RSS_SCTP |
2008 else if (!strcmp(res->value, "ip"))
2009 rss_conf.rss_hf = ETH_RSS_IP;
2010 else if (!strcmp(res->value, "udp"))
2011 rss_conf.rss_hf = ETH_RSS_UDP;
2012 else if (!strcmp(res->value, "tcp"))
2013 rss_conf.rss_hf = ETH_RSS_TCP;
2014 else if (!strcmp(res->value, "sctp"))
2015 rss_conf.rss_hf = ETH_RSS_SCTP;
2016 else if (!strcmp(res->value, "ether"))
2017 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2018 else if (!strcmp(res->value, "port"))
2019 rss_conf.rss_hf = ETH_RSS_PORT;
2020 else if (!strcmp(res->value, "vxlan"))
2021 rss_conf.rss_hf = ETH_RSS_VXLAN;
2022 else if (!strcmp(res->value, "geneve"))
2023 rss_conf.rss_hf = ETH_RSS_GENEVE;
2024 else if (!strcmp(res->value, "nvgre"))
2025 rss_conf.rss_hf = ETH_RSS_NVGRE;
2026 else if (!strcmp(res->value, "none"))
2027 rss_conf.rss_hf = 0;
2028 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2029 atoi(res->value) < 64)
2030 rss_conf.rss_hf = 1ULL << atoi(res->value);
2032 printf("Unknown parameter\n");
2035 rss_conf.rss_key = NULL;
2036 RTE_ETH_FOREACH_DEV(i) {
2037 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2039 printf("Configuration of RSS hash at ethernet port %d "
2040 "failed with error (%d): %s.\n",
2041 i, -diag, strerror(-diag));
2045 cmdline_parse_token_string_t cmd_config_rss_port =
2046 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2047 cmdline_parse_token_string_t cmd_config_rss_keyword =
2048 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2049 cmdline_parse_token_string_t cmd_config_rss_all =
2050 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2051 cmdline_parse_token_string_t cmd_config_rss_name =
2052 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2053 cmdline_parse_token_string_t cmd_config_rss_value =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2056 cmdline_parse_inst_t cmd_config_rss = {
2057 .f = cmd_config_rss_parsed,
2059 .help_str = "port config all rss "
2060 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2062 (void *)&cmd_config_rss_port,
2063 (void *)&cmd_config_rss_keyword,
2064 (void *)&cmd_config_rss_all,
2065 (void *)&cmd_config_rss_name,
2066 (void *)&cmd_config_rss_value,
2071 /* *** configure rss hash key *** */
2072 struct cmd_config_rss_hash_key {
2073 cmdline_fixed_string_t port;
2074 cmdline_fixed_string_t config;
2076 cmdline_fixed_string_t rss_hash_key;
2077 cmdline_fixed_string_t rss_type;
2078 cmdline_fixed_string_t key;
2082 hexa_digit_to_value(char hexa_digit)
2084 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2085 return (uint8_t) (hexa_digit - '0');
2086 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2087 return (uint8_t) ((hexa_digit - 'a') + 10);
2088 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2089 return (uint8_t) ((hexa_digit - 'A') + 10);
2090 /* Invalid hexa digit */
2095 parse_and_check_key_hexa_digit(char *key, int idx)
2099 hexa_v = hexa_digit_to_value(key[idx]);
2101 printf("invalid key: character %c at position %d is not a "
2102 "valid hexa digit\n", key[idx], idx);
2107 cmd_config_rss_hash_key_parsed(void *parsed_result,
2108 __attribute__((unused)) struct cmdline *cl,
2109 __attribute__((unused)) void *data)
2111 struct cmd_config_rss_hash_key *res = parsed_result;
2112 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2116 struct rte_eth_dev_info dev_info;
2117 uint8_t hash_key_size;
2120 memset(&dev_info, 0, sizeof(dev_info));
2121 rte_eth_dev_info_get(res->port_id, &dev_info);
2122 if (dev_info.hash_key_size > 0 &&
2123 dev_info.hash_key_size <= sizeof(hash_key))
2124 hash_key_size = dev_info.hash_key_size;
2126 printf("dev_info did not provide a valid hash key size\n");
2129 /* Check the length of the RSS hash key */
2130 key_len = strlen(res->key);
2131 if (key_len != (hash_key_size * 2)) {
2132 printf("key length: %d invalid - key must be a string of %d"
2133 " hexa-decimal numbers\n",
2134 (int) key_len, hash_key_size * 2);
2137 /* Translate RSS hash key into binary representation */
2138 for (i = 0; i < hash_key_size; i++) {
2139 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2142 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2145 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2147 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2151 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2152 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2153 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2154 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2156 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2157 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2158 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2159 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2160 rss_hash_key, "rss-hash-key");
2161 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2162 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2163 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2164 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2165 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2166 "ipv6-tcp-ex#ipv6-udp-ex");
2167 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2168 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2170 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2171 .f = cmd_config_rss_hash_key_parsed,
2173 .help_str = "port config <port_id> rss-hash-key "
2174 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2175 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2176 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2177 "<string of hex digits (variable length, NIC dependent)>",
2179 (void *)&cmd_config_rss_hash_key_port,
2180 (void *)&cmd_config_rss_hash_key_config,
2181 (void *)&cmd_config_rss_hash_key_port_id,
2182 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2183 (void *)&cmd_config_rss_hash_key_rss_type,
2184 (void *)&cmd_config_rss_hash_key_value,
2189 /* *** configure port rxq/txq start/stop *** */
2190 struct cmd_config_rxtx_queue {
2191 cmdline_fixed_string_t port;
2193 cmdline_fixed_string_t rxtxq;
2195 cmdline_fixed_string_t opname;
2199 cmd_config_rxtx_queue_parsed(void *parsed_result,
2200 __attribute__((unused)) struct cmdline *cl,
2201 __attribute__((unused)) void *data)
2203 struct cmd_config_rxtx_queue *res = parsed_result;
2208 if (test_done == 0) {
2209 printf("Please stop forwarding first\n");
2213 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2216 if (port_is_started(res->portid) != 1) {
2217 printf("Please start port %u first\n", res->portid);
2221 if (!strcmp(res->rxtxq, "rxq"))
2223 else if (!strcmp(res->rxtxq, "txq"))
2226 printf("Unknown parameter\n");
2230 if (isrx && rx_queue_id_is_invalid(res->qid))
2232 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2235 if (!strcmp(res->opname, "start"))
2237 else if (!strcmp(res->opname, "stop"))
2240 printf("Unknown parameter\n");
2244 if (isstart && isrx)
2245 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2246 else if (!isstart && isrx)
2247 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2248 else if (isstart && !isrx)
2249 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2251 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2253 if (ret == -ENOTSUP)
2254 printf("Function not supported in PMD driver\n");
2257 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2258 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2259 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2260 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2261 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2262 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2263 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2264 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2265 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2269 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2270 .f = cmd_config_rxtx_queue_parsed,
2272 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2274 (void *)&cmd_config_speed_all_port,
2275 (void *)&cmd_config_rxtx_queue_portid,
2276 (void *)&cmd_config_rxtx_queue_rxtxq,
2277 (void *)&cmd_config_rxtx_queue_qid,
2278 (void *)&cmd_config_rxtx_queue_opname,
2283 /* *** Configure RSS RETA *** */
2284 struct cmd_config_rss_reta {
2285 cmdline_fixed_string_t port;
2286 cmdline_fixed_string_t keyword;
2288 cmdline_fixed_string_t name;
2289 cmdline_fixed_string_t list_name;
2290 cmdline_fixed_string_t list_of_items;
2294 parse_reta_config(const char *str,
2295 struct rte_eth_rss_reta_entry64 *reta_conf,
2296 uint16_t nb_entries)
2300 uint16_t hash_index, idx, shift;
2303 const char *p, *p0 = str;
2310 unsigned long int_fld[_NUM_FLD];
2311 char *str_fld[_NUM_FLD];
2313 while ((p = strchr(p0,'(')) != NULL) {
2315 if((p0 = strchr(p,')')) == NULL)
2319 if(size >= sizeof(s))
2322 snprintf(s, sizeof(s), "%.*s", size, p);
2323 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2325 for (i = 0; i < _NUM_FLD; i++) {
2327 int_fld[i] = strtoul(str_fld[i], &end, 0);
2328 if (errno != 0 || end == str_fld[i] ||
2333 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2334 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2336 if (hash_index >= nb_entries) {
2337 printf("Invalid RETA hash index=%d\n", hash_index);
2341 idx = hash_index / RTE_RETA_GROUP_SIZE;
2342 shift = hash_index % RTE_RETA_GROUP_SIZE;
2343 reta_conf[idx].mask |= (1ULL << shift);
2344 reta_conf[idx].reta[shift] = nb_queue;
2351 cmd_set_rss_reta_parsed(void *parsed_result,
2352 __attribute__((unused)) struct cmdline *cl,
2353 __attribute__((unused)) void *data)
2356 struct rte_eth_dev_info dev_info;
2357 struct rte_eth_rss_reta_entry64 reta_conf[8];
2358 struct cmd_config_rss_reta *res = parsed_result;
2360 memset(&dev_info, 0, sizeof(dev_info));
2361 rte_eth_dev_info_get(res->port_id, &dev_info);
2362 if (dev_info.reta_size == 0) {
2363 printf("Redirection table size is 0 which is "
2364 "invalid for RSS\n");
2367 printf("The reta size of port %d is %u\n",
2368 res->port_id, dev_info.reta_size);
2369 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2370 printf("Currently do not support more than %u entries of "
2371 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2375 memset(reta_conf, 0, sizeof(reta_conf));
2376 if (!strcmp(res->list_name, "reta")) {
2377 if (parse_reta_config(res->list_of_items, reta_conf,
2378 dev_info.reta_size)) {
2379 printf("Invalid RSS Redirection Table "
2380 "config entered\n");
2383 ret = rte_eth_dev_rss_reta_update(res->port_id,
2384 reta_conf, dev_info.reta_size);
2386 printf("Bad redirection table parameter, "
2387 "return code = %d \n", ret);
2391 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2392 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2393 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2394 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2395 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2396 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2397 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2398 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2399 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2401 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2402 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2404 cmdline_parse_inst_t cmd_config_rss_reta = {
2405 .f = cmd_set_rss_reta_parsed,
2407 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2409 (void *)&cmd_config_rss_reta_port,
2410 (void *)&cmd_config_rss_reta_keyword,
2411 (void *)&cmd_config_rss_reta_port_id,
2412 (void *)&cmd_config_rss_reta_name,
2413 (void *)&cmd_config_rss_reta_list_name,
2414 (void *)&cmd_config_rss_reta_list_of_items,
2419 /* *** SHOW PORT RETA INFO *** */
2420 struct cmd_showport_reta {
2421 cmdline_fixed_string_t show;
2422 cmdline_fixed_string_t port;
2424 cmdline_fixed_string_t rss;
2425 cmdline_fixed_string_t reta;
2427 cmdline_fixed_string_t list_of_items;
2431 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2432 uint16_t nb_entries,
2436 const char *p, *p0 = str;
2441 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2442 RTE_RETA_GROUP_SIZE;
2445 p = strchr(p0, '(');
2449 p0 = strchr(p, ')');
2453 if (size >= sizeof(s)) {
2454 printf("The string size exceeds the internal buffer size\n");
2457 snprintf(s, sizeof(s), "%.*s", size, p);
2458 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2459 if (ret <= 0 || ret != num) {
2460 printf("The bits of masks do not match the number of "
2461 "reta entries: %u\n", num);
2464 for (i = 0; i < ret; i++)
2465 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2471 cmd_showport_reta_parsed(void *parsed_result,
2472 __attribute__((unused)) struct cmdline *cl,
2473 __attribute__((unused)) void *data)
2475 struct cmd_showport_reta *res = parsed_result;
2476 struct rte_eth_rss_reta_entry64 reta_conf[8];
2477 struct rte_eth_dev_info dev_info;
2478 uint16_t max_reta_size;
2480 memset(&dev_info, 0, sizeof(dev_info));
2481 rte_eth_dev_info_get(res->port_id, &dev_info);
2482 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2483 if (res->size == 0 || res->size > max_reta_size) {
2484 printf("Invalid redirection table size: %u (1-%u)\n",
2485 res->size, max_reta_size);
2489 memset(reta_conf, 0, sizeof(reta_conf));
2490 if (showport_parse_reta_config(reta_conf, res->size,
2491 res->list_of_items) < 0) {
2492 printf("Invalid string: %s for reta masks\n",
2493 res->list_of_items);
2496 port_rss_reta_info(res->port_id, reta_conf, res->size);
2499 cmdline_parse_token_string_t cmd_showport_reta_show =
2500 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2501 cmdline_parse_token_string_t cmd_showport_reta_port =
2502 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2503 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2504 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2505 cmdline_parse_token_string_t cmd_showport_reta_rss =
2506 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2507 cmdline_parse_token_string_t cmd_showport_reta_reta =
2508 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2509 cmdline_parse_token_num_t cmd_showport_reta_size =
2510 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2511 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2512 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2513 list_of_items, NULL);
2515 cmdline_parse_inst_t cmd_showport_reta = {
2516 .f = cmd_showport_reta_parsed,
2518 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2520 (void *)&cmd_showport_reta_show,
2521 (void *)&cmd_showport_reta_port,
2522 (void *)&cmd_showport_reta_port_id,
2523 (void *)&cmd_showport_reta_rss,
2524 (void *)&cmd_showport_reta_reta,
2525 (void *)&cmd_showport_reta_size,
2526 (void *)&cmd_showport_reta_list_of_items,
2531 /* *** Show RSS hash configuration *** */
2532 struct cmd_showport_rss_hash {
2533 cmdline_fixed_string_t show;
2534 cmdline_fixed_string_t port;
2536 cmdline_fixed_string_t rss_hash;
2537 cmdline_fixed_string_t rss_type;
2538 cmdline_fixed_string_t key; /* optional argument */
2541 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2542 __attribute__((unused)) struct cmdline *cl,
2545 struct cmd_showport_rss_hash *res = parsed_result;
2547 port_rss_hash_conf_show(res->port_id, res->rss_type,
2548 show_rss_key != NULL);
2551 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2552 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2553 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2554 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2555 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2556 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2557 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2558 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2560 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2561 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2562 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2563 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2564 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2565 "ipv6-tcp-ex#ipv6-udp-ex");
2566 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2567 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2569 cmdline_parse_inst_t cmd_showport_rss_hash = {
2570 .f = cmd_showport_rss_hash_parsed,
2572 .help_str = "show port <port_id> rss-hash "
2573 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2574 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2575 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2577 (void *)&cmd_showport_rss_hash_show,
2578 (void *)&cmd_showport_rss_hash_port,
2579 (void *)&cmd_showport_rss_hash_port_id,
2580 (void *)&cmd_showport_rss_hash_rss_hash,
2581 (void *)&cmd_showport_rss_hash_rss_hash_info,
2586 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2587 .f = cmd_showport_rss_hash_parsed,
2589 .help_str = "show port <port_id> rss-hash "
2590 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2591 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2592 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2594 (void *)&cmd_showport_rss_hash_show,
2595 (void *)&cmd_showport_rss_hash_port,
2596 (void *)&cmd_showport_rss_hash_port_id,
2597 (void *)&cmd_showport_rss_hash_rss_hash,
2598 (void *)&cmd_showport_rss_hash_rss_hash_info,
2599 (void *)&cmd_showport_rss_hash_rss_key,
2604 /* *** Configure DCB *** */
2605 struct cmd_config_dcb {
2606 cmdline_fixed_string_t port;
2607 cmdline_fixed_string_t config;
2609 cmdline_fixed_string_t dcb;
2610 cmdline_fixed_string_t vt;
2611 cmdline_fixed_string_t vt_en;
2613 cmdline_fixed_string_t pfc;
2614 cmdline_fixed_string_t pfc_en;
2618 cmd_config_dcb_parsed(void *parsed_result,
2619 __attribute__((unused)) struct cmdline *cl,
2620 __attribute__((unused)) void *data)
2622 struct cmd_config_dcb *res = parsed_result;
2623 portid_t port_id = res->port_id;
2624 struct rte_port *port;
2628 port = &ports[port_id];
2629 /** Check if the port is not started **/
2630 if (port->port_status != RTE_PORT_STOPPED) {
2631 printf("Please stop port %d first\n", port_id);
2635 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2636 printf("The invalid number of traffic class,"
2637 " only 4 or 8 allowed.\n");
2641 if (nb_fwd_lcores < res->num_tcs) {
2642 printf("nb_cores shouldn't be less than number of TCs.\n");
2645 if (!strncmp(res->pfc_en, "on", 2))
2650 /* DCB in VT mode */
2651 if (!strncmp(res->vt_en, "on", 2))
2652 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2653 (enum rte_eth_nb_tcs)res->num_tcs,
2656 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2657 (enum rte_eth_nb_tcs)res->num_tcs,
2662 printf("Cannot initialize network ports.\n");
2666 cmd_reconfig_device_queue(port_id, 1, 1);
2669 cmdline_parse_token_string_t cmd_config_dcb_port =
2670 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2671 cmdline_parse_token_string_t cmd_config_dcb_config =
2672 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2673 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2674 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2675 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2676 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2677 cmdline_parse_token_string_t cmd_config_dcb_vt =
2678 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2679 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2680 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2681 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2682 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2683 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2684 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2685 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2686 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2688 cmdline_parse_inst_t cmd_config_dcb = {
2689 .f = cmd_config_dcb_parsed,
2691 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2693 (void *)&cmd_config_dcb_port,
2694 (void *)&cmd_config_dcb_config,
2695 (void *)&cmd_config_dcb_port_id,
2696 (void *)&cmd_config_dcb_dcb,
2697 (void *)&cmd_config_dcb_vt,
2698 (void *)&cmd_config_dcb_vt_en,
2699 (void *)&cmd_config_dcb_num_tcs,
2700 (void *)&cmd_config_dcb_pfc,
2701 (void *)&cmd_config_dcb_pfc_en,
2706 /* *** configure number of packets per burst *** */
2707 struct cmd_config_burst {
2708 cmdline_fixed_string_t port;
2709 cmdline_fixed_string_t keyword;
2710 cmdline_fixed_string_t all;
2711 cmdline_fixed_string_t name;
2716 cmd_config_burst_parsed(void *parsed_result,
2717 __attribute__((unused)) struct cmdline *cl,
2718 __attribute__((unused)) void *data)
2720 struct cmd_config_burst *res = parsed_result;
2721 struct rte_eth_dev_info dev_info;
2722 uint16_t rec_nb_pkts;
2724 if (!all_ports_stopped()) {
2725 printf("Please stop all ports first\n");
2729 if (!strcmp(res->name, "burst")) {
2730 if (res->value == 0) {
2731 /* If user gives a value of zero, query the PMD for
2732 * its recommended Rx burst size. Testpmd uses a single
2733 * size for all ports, so assume all ports are the same
2734 * NIC model and use the values from Port 0.
2736 rte_eth_dev_info_get(0, &dev_info);
2737 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2739 if (rec_nb_pkts == 0) {
2740 printf("PMD does not recommend a burst size.\n"
2741 "User provided value must be between"
2742 " 1 and %d\n", MAX_PKT_BURST);
2744 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2745 printf("PMD recommended burst size of %d"
2746 " exceeds maximum value of %d\n",
2747 rec_nb_pkts, MAX_PKT_BURST);
2750 printf("Using PMD-provided burst value of %d\n",
2752 nb_pkt_per_burst = rec_nb_pkts;
2753 } else if (res->value > MAX_PKT_BURST) {
2754 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2757 nb_pkt_per_burst = res->value;
2759 printf("Unknown parameter\n");
2765 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2768 cmdline_parse_token_string_t cmd_config_burst_port =
2769 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2770 cmdline_parse_token_string_t cmd_config_burst_keyword =
2771 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2772 cmdline_parse_token_string_t cmd_config_burst_all =
2773 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2774 cmdline_parse_token_string_t cmd_config_burst_name =
2775 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2776 cmdline_parse_token_num_t cmd_config_burst_value =
2777 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2779 cmdline_parse_inst_t cmd_config_burst = {
2780 .f = cmd_config_burst_parsed,
2782 .help_str = "port config all burst <value>",
2784 (void *)&cmd_config_burst_port,
2785 (void *)&cmd_config_burst_keyword,
2786 (void *)&cmd_config_burst_all,
2787 (void *)&cmd_config_burst_name,
2788 (void *)&cmd_config_burst_value,
2793 /* *** configure rx/tx queues *** */
2794 struct cmd_config_thresh {
2795 cmdline_fixed_string_t port;
2796 cmdline_fixed_string_t keyword;
2797 cmdline_fixed_string_t all;
2798 cmdline_fixed_string_t name;
2803 cmd_config_thresh_parsed(void *parsed_result,
2804 __attribute__((unused)) struct cmdline *cl,
2805 __attribute__((unused)) void *data)
2807 struct cmd_config_thresh *res = parsed_result;
2809 if (!all_ports_stopped()) {
2810 printf("Please stop all ports first\n");
2814 if (!strcmp(res->name, "txpt"))
2815 tx_pthresh = res->value;
2816 else if(!strcmp(res->name, "txht"))
2817 tx_hthresh = res->value;
2818 else if(!strcmp(res->name, "txwt"))
2819 tx_wthresh = res->value;
2820 else if(!strcmp(res->name, "rxpt"))
2821 rx_pthresh = res->value;
2822 else if(!strcmp(res->name, "rxht"))
2823 rx_hthresh = res->value;
2824 else if(!strcmp(res->name, "rxwt"))
2825 rx_wthresh = res->value;
2827 printf("Unknown parameter\n");
2833 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2836 cmdline_parse_token_string_t cmd_config_thresh_port =
2837 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2838 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2839 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2840 cmdline_parse_token_string_t cmd_config_thresh_all =
2841 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2842 cmdline_parse_token_string_t cmd_config_thresh_name =
2843 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2844 "txpt#txht#txwt#rxpt#rxht#rxwt");
2845 cmdline_parse_token_num_t cmd_config_thresh_value =
2846 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2848 cmdline_parse_inst_t cmd_config_thresh = {
2849 .f = cmd_config_thresh_parsed,
2851 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2853 (void *)&cmd_config_thresh_port,
2854 (void *)&cmd_config_thresh_keyword,
2855 (void *)&cmd_config_thresh_all,
2856 (void *)&cmd_config_thresh_name,
2857 (void *)&cmd_config_thresh_value,
2862 /* *** configure free/rs threshold *** */
2863 struct cmd_config_threshold {
2864 cmdline_fixed_string_t port;
2865 cmdline_fixed_string_t keyword;
2866 cmdline_fixed_string_t all;
2867 cmdline_fixed_string_t name;
2872 cmd_config_threshold_parsed(void *parsed_result,
2873 __attribute__((unused)) struct cmdline *cl,
2874 __attribute__((unused)) void *data)
2876 struct cmd_config_threshold *res = parsed_result;
2878 if (!all_ports_stopped()) {
2879 printf("Please stop all ports first\n");
2883 if (!strcmp(res->name, "txfreet"))
2884 tx_free_thresh = res->value;
2885 else if (!strcmp(res->name, "txrst"))
2886 tx_rs_thresh = res->value;
2887 else if (!strcmp(res->name, "rxfreet"))
2888 rx_free_thresh = res->value;
2890 printf("Unknown parameter\n");
2896 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2899 cmdline_parse_token_string_t cmd_config_threshold_port =
2900 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2901 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2904 cmdline_parse_token_string_t cmd_config_threshold_all =
2905 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2906 cmdline_parse_token_string_t cmd_config_threshold_name =
2907 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2908 "txfreet#txrst#rxfreet");
2909 cmdline_parse_token_num_t cmd_config_threshold_value =
2910 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2912 cmdline_parse_inst_t cmd_config_threshold = {
2913 .f = cmd_config_threshold_parsed,
2915 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2917 (void *)&cmd_config_threshold_port,
2918 (void *)&cmd_config_threshold_keyword,
2919 (void *)&cmd_config_threshold_all,
2920 (void *)&cmd_config_threshold_name,
2921 (void *)&cmd_config_threshold_value,
2927 struct cmd_stop_result {
2928 cmdline_fixed_string_t stop;
2931 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2932 __attribute__((unused)) struct cmdline *cl,
2933 __attribute__((unused)) void *data)
2935 stop_packet_forwarding();
2938 cmdline_parse_token_string_t cmd_stop_stop =
2939 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2941 cmdline_parse_inst_t cmd_stop = {
2942 .f = cmd_stop_parsed,
2944 .help_str = "stop: Stop packet forwarding",
2946 (void *)&cmd_stop_stop,
2951 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2954 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2955 unsigned int *parsed_items, int check_unique_values)
2957 unsigned int nb_item;
2965 * First parse all items in the list and store their value.
2970 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2972 if ((c >= '0') && (c <= '9')) {
2973 value = (unsigned int) (value * 10 + (c - '0'));
2978 printf("character %c is not a decimal digit\n", c);
2982 printf("No valid value before comma\n");
2985 if (nb_item < max_items) {
2986 parsed_items[nb_item] = value;
2992 if (nb_item >= max_items) {
2993 printf("Number of %s = %u > %u (maximum items)\n",
2994 item_name, nb_item + 1, max_items);
2997 parsed_items[nb_item++] = value;
2998 if (! check_unique_values)
3002 * Then, check that all values in the list are differents.
3003 * No optimization here...
3005 for (i = 0; i < nb_item; i++) {
3006 for (j = i + 1; j < nb_item; j++) {
3007 if (parsed_items[j] == parsed_items[i]) {
3008 printf("duplicated %s %u at index %u and %u\n",
3009 item_name, parsed_items[i], i, j);
3017 struct cmd_set_list_result {
3018 cmdline_fixed_string_t cmd_keyword;
3019 cmdline_fixed_string_t list_name;
3020 cmdline_fixed_string_t list_of_items;
3023 static void cmd_set_list_parsed(void *parsed_result,
3024 __attribute__((unused)) struct cmdline *cl,
3025 __attribute__((unused)) void *data)
3027 struct cmd_set_list_result *res;
3029 unsigned int lcorelist[RTE_MAX_LCORE];
3030 unsigned int portlist[RTE_MAX_ETHPORTS];
3032 unsigned int nb_item;
3034 if (test_done == 0) {
3035 printf("Please stop forwarding first\n");
3039 res = parsed_result;
3040 if (!strcmp(res->list_name, "corelist")) {
3041 nb_item = parse_item_list(res->list_of_items, "core",
3043 parsed_items.lcorelist, 1);
3045 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3050 if (!strcmp(res->list_name, "portlist")) {
3051 nb_item = parse_item_list(res->list_of_items, "port",
3053 parsed_items.portlist, 1);
3055 set_fwd_ports_list(parsed_items.portlist, nb_item);
3061 cmdline_parse_token_string_t cmd_set_list_keyword =
3062 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3064 cmdline_parse_token_string_t cmd_set_list_name =
3065 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3066 "corelist#portlist");
3067 cmdline_parse_token_string_t cmd_set_list_of_items =
3068 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3071 cmdline_parse_inst_t cmd_set_fwd_list = {
3072 .f = cmd_set_list_parsed,
3074 .help_str = "set corelist|portlist <list0[,list1]*>",
3076 (void *)&cmd_set_list_keyword,
3077 (void *)&cmd_set_list_name,
3078 (void *)&cmd_set_list_of_items,
3083 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3085 struct cmd_setmask_result {
3086 cmdline_fixed_string_t set;
3087 cmdline_fixed_string_t mask;
3091 static void cmd_set_mask_parsed(void *parsed_result,
3092 __attribute__((unused)) struct cmdline *cl,
3093 __attribute__((unused)) void *data)
3095 struct cmd_setmask_result *res = parsed_result;
3097 if (test_done == 0) {
3098 printf("Please stop forwarding first\n");
3101 if (!strcmp(res->mask, "coremask")) {
3102 set_fwd_lcores_mask(res->hexavalue);
3104 } else if (!strcmp(res->mask, "portmask")) {
3105 set_fwd_ports_mask(res->hexavalue);
3110 cmdline_parse_token_string_t cmd_setmask_set =
3111 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3112 cmdline_parse_token_string_t cmd_setmask_mask =
3113 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3114 "coremask#portmask");
3115 cmdline_parse_token_num_t cmd_setmask_value =
3116 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3118 cmdline_parse_inst_t cmd_set_fwd_mask = {
3119 .f = cmd_set_mask_parsed,
3121 .help_str = "set coremask|portmask <hexadecimal value>",
3123 (void *)&cmd_setmask_set,
3124 (void *)&cmd_setmask_mask,
3125 (void *)&cmd_setmask_value,
3131 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3133 struct cmd_set_result {
3134 cmdline_fixed_string_t set;
3135 cmdline_fixed_string_t what;
3139 static void cmd_set_parsed(void *parsed_result,
3140 __attribute__((unused)) struct cmdline *cl,
3141 __attribute__((unused)) void *data)
3143 struct cmd_set_result *res = parsed_result;
3144 if (!strcmp(res->what, "nbport")) {
3145 set_fwd_ports_number(res->value);
3147 } else if (!strcmp(res->what, "nbcore")) {
3148 set_fwd_lcores_number(res->value);
3150 } else if (!strcmp(res->what, "burst"))
3151 set_nb_pkt_per_burst(res->value);
3152 else if (!strcmp(res->what, "verbose"))
3153 set_verbose_level(res->value);
3156 cmdline_parse_token_string_t cmd_set_set =
3157 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3158 cmdline_parse_token_string_t cmd_set_what =
3159 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3160 "nbport#nbcore#burst#verbose");
3161 cmdline_parse_token_num_t cmd_set_value =
3162 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3164 cmdline_parse_inst_t cmd_set_numbers = {
3165 .f = cmd_set_parsed,
3167 .help_str = "set nbport|nbcore|burst|verbose <value>",
3169 (void *)&cmd_set_set,
3170 (void *)&cmd_set_what,
3171 (void *)&cmd_set_value,
3176 /* *** SET LOG LEVEL CONFIGURATION *** */
3178 struct cmd_set_log_result {
3179 cmdline_fixed_string_t set;
3180 cmdline_fixed_string_t log;
3181 cmdline_fixed_string_t type;
3186 cmd_set_log_parsed(void *parsed_result,
3187 __attribute__((unused)) struct cmdline *cl,
3188 __attribute__((unused)) void *data)
3190 struct cmd_set_log_result *res;
3193 res = parsed_result;
3194 if (!strcmp(res->type, "global"))
3195 rte_log_set_global_level(res->level);
3197 ret = rte_log_set_level_regexp(res->type, res->level);
3199 printf("Unable to set log level\n");
3203 cmdline_parse_token_string_t cmd_set_log_set =
3204 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3205 cmdline_parse_token_string_t cmd_set_log_log =
3206 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3207 cmdline_parse_token_string_t cmd_set_log_type =
3208 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3209 cmdline_parse_token_num_t cmd_set_log_level =
3210 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3212 cmdline_parse_inst_t cmd_set_log = {
3213 .f = cmd_set_log_parsed,
3215 .help_str = "set log global|<type> <level>",
3217 (void *)&cmd_set_log_set,
3218 (void *)&cmd_set_log_log,
3219 (void *)&cmd_set_log_type,
3220 (void *)&cmd_set_log_level,
3225 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3227 struct cmd_set_txpkts_result {
3228 cmdline_fixed_string_t cmd_keyword;
3229 cmdline_fixed_string_t txpkts;
3230 cmdline_fixed_string_t seg_lengths;
3234 cmd_set_txpkts_parsed(void *parsed_result,
3235 __attribute__((unused)) struct cmdline *cl,
3236 __attribute__((unused)) void *data)
3238 struct cmd_set_txpkts_result *res;
3239 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3240 unsigned int nb_segs;
3242 res = parsed_result;
3243 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3244 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3246 set_tx_pkt_segments(seg_lengths, nb_segs);
3249 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3250 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3251 cmd_keyword, "set");
3252 cmdline_parse_token_string_t cmd_set_txpkts_name =
3253 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3255 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3256 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3259 cmdline_parse_inst_t cmd_set_txpkts = {
3260 .f = cmd_set_txpkts_parsed,
3262 .help_str = "set txpkts <len0[,len1]*>",
3264 (void *)&cmd_set_txpkts_keyword,
3265 (void *)&cmd_set_txpkts_name,
3266 (void *)&cmd_set_txpkts_lengths,
3271 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3273 struct cmd_set_txsplit_result {
3274 cmdline_fixed_string_t cmd_keyword;
3275 cmdline_fixed_string_t txsplit;
3276 cmdline_fixed_string_t mode;
3280 cmd_set_txsplit_parsed(void *parsed_result,
3281 __attribute__((unused)) struct cmdline *cl,
3282 __attribute__((unused)) void *data)
3284 struct cmd_set_txsplit_result *res;
3286 res = parsed_result;
3287 set_tx_pkt_split(res->mode);
3290 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3291 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3292 cmd_keyword, "set");
3293 cmdline_parse_token_string_t cmd_set_txsplit_name =
3294 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3295 txsplit, "txsplit");
3296 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3297 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3300 cmdline_parse_inst_t cmd_set_txsplit = {
3301 .f = cmd_set_txsplit_parsed,
3303 .help_str = "set txsplit on|off|rand",
3305 (void *)&cmd_set_txsplit_keyword,
3306 (void *)&cmd_set_txsplit_name,
3307 (void *)&cmd_set_txsplit_mode,
3312 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3313 struct cmd_rx_vlan_filter_all_result {
3314 cmdline_fixed_string_t rx_vlan;
3315 cmdline_fixed_string_t what;
3316 cmdline_fixed_string_t all;
3321 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3322 __attribute__((unused)) struct cmdline *cl,
3323 __attribute__((unused)) void *data)
3325 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3327 if (!strcmp(res->what, "add"))
3328 rx_vlan_all_filter_set(res->port_id, 1);
3330 rx_vlan_all_filter_set(res->port_id, 0);
3333 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3334 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3335 rx_vlan, "rx_vlan");
3336 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3337 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3339 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3340 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3342 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3343 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3346 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3347 .f = cmd_rx_vlan_filter_all_parsed,
3349 .help_str = "rx_vlan add|rm all <port_id>: "
3350 "Add/Remove all identifiers to/from the set of VLAN "
3351 "identifiers filtered by a port",
3353 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3354 (void *)&cmd_rx_vlan_filter_all_what,
3355 (void *)&cmd_rx_vlan_filter_all_all,
3356 (void *)&cmd_rx_vlan_filter_all_portid,
3361 /* *** VLAN OFFLOAD SET ON A PORT *** */
3362 struct cmd_vlan_offload_result {
3363 cmdline_fixed_string_t vlan;
3364 cmdline_fixed_string_t set;
3365 cmdline_fixed_string_t vlan_type;
3366 cmdline_fixed_string_t what;
3367 cmdline_fixed_string_t on;
3368 cmdline_fixed_string_t port_id;
3372 cmd_vlan_offload_parsed(void *parsed_result,
3373 __attribute__((unused)) struct cmdline *cl,
3374 __attribute__((unused)) void *data)
3377 struct cmd_vlan_offload_result *res = parsed_result;
3380 portid_t port_id = 0;
3384 len = strnlen(str, STR_TOKEN_SIZE);
3386 /* Get port_id first */
3394 tmp = strtoul(str, NULL, 0);
3395 /* If port_id greater that what portid_t can represent, return */
3396 if(tmp >= RTE_MAX_ETHPORTS)
3398 port_id = (portid_t)tmp;
3400 if (!strcmp(res->on, "on"))
3405 if (!strcmp(res->what, "strip"))
3406 rx_vlan_strip_set(port_id, on);
3407 else if(!strcmp(res->what, "stripq")){
3408 uint16_t queue_id = 0;
3410 /* No queue_id, return */
3412 printf("must specify (port,queue_id)\n");
3415 tmp = strtoul(str + i + 1, NULL, 0);
3416 /* If queue_id greater that what 16-bits can represent, return */
3420 queue_id = (uint16_t)tmp;
3421 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3423 else if (!strcmp(res->what, "filter"))
3424 rx_vlan_filter_set(port_id, on);
3426 vlan_extend_set(port_id, on);
3431 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3432 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3434 cmdline_parse_token_string_t cmd_vlan_offload_set =
3435 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3437 cmdline_parse_token_string_t cmd_vlan_offload_what =
3438 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3439 what, "strip#filter#qinq#stripq");
3440 cmdline_parse_token_string_t cmd_vlan_offload_on =
3441 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3443 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3444 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3447 cmdline_parse_inst_t cmd_vlan_offload = {
3448 .f = cmd_vlan_offload_parsed,
3450 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3451 "<port_id[,queue_id]>: "
3452 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3454 (void *)&cmd_vlan_offload_vlan,
3455 (void *)&cmd_vlan_offload_set,
3456 (void *)&cmd_vlan_offload_what,
3457 (void *)&cmd_vlan_offload_on,
3458 (void *)&cmd_vlan_offload_portid,
3463 /* *** VLAN TPID SET ON A PORT *** */
3464 struct cmd_vlan_tpid_result {
3465 cmdline_fixed_string_t vlan;
3466 cmdline_fixed_string_t set;
3467 cmdline_fixed_string_t vlan_type;
3468 cmdline_fixed_string_t what;
3474 cmd_vlan_tpid_parsed(void *parsed_result,
3475 __attribute__((unused)) struct cmdline *cl,
3476 __attribute__((unused)) void *data)
3478 struct cmd_vlan_tpid_result *res = parsed_result;
3479 enum rte_vlan_type vlan_type;
3481 if (!strcmp(res->vlan_type, "inner"))
3482 vlan_type = ETH_VLAN_TYPE_INNER;
3483 else if (!strcmp(res->vlan_type, "outer"))
3484 vlan_type = ETH_VLAN_TYPE_OUTER;
3486 printf("Unknown vlan type\n");
3489 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3492 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3493 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3495 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3496 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3498 cmdline_parse_token_string_t cmd_vlan_type =
3499 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3500 vlan_type, "inner#outer");
3501 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3502 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3504 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3505 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3507 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3508 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3511 cmdline_parse_inst_t cmd_vlan_tpid = {
3512 .f = cmd_vlan_tpid_parsed,
3514 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3515 "Set the VLAN Ether type",
3517 (void *)&cmd_vlan_tpid_vlan,
3518 (void *)&cmd_vlan_tpid_set,
3519 (void *)&cmd_vlan_type,
3520 (void *)&cmd_vlan_tpid_what,
3521 (void *)&cmd_vlan_tpid_tpid,
3522 (void *)&cmd_vlan_tpid_portid,
3527 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3528 struct cmd_rx_vlan_filter_result {
3529 cmdline_fixed_string_t rx_vlan;
3530 cmdline_fixed_string_t what;
3536 cmd_rx_vlan_filter_parsed(void *parsed_result,
3537 __attribute__((unused)) struct cmdline *cl,
3538 __attribute__((unused)) void *data)
3540 struct cmd_rx_vlan_filter_result *res = parsed_result;
3542 if (!strcmp(res->what, "add"))
3543 rx_vft_set(res->port_id, res->vlan_id, 1);
3545 rx_vft_set(res->port_id, res->vlan_id, 0);
3548 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3549 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3550 rx_vlan, "rx_vlan");
3551 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3552 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3554 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3555 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3557 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3558 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3561 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3562 .f = cmd_rx_vlan_filter_parsed,
3564 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3565 "Add/Remove a VLAN identifier to/from the set of VLAN "
3566 "identifiers filtered by a port",
3568 (void *)&cmd_rx_vlan_filter_rx_vlan,
3569 (void *)&cmd_rx_vlan_filter_what,
3570 (void *)&cmd_rx_vlan_filter_vlanid,
3571 (void *)&cmd_rx_vlan_filter_portid,
3576 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3577 struct cmd_tx_vlan_set_result {
3578 cmdline_fixed_string_t tx_vlan;
3579 cmdline_fixed_string_t set;
3585 cmd_tx_vlan_set_parsed(void *parsed_result,
3586 __attribute__((unused)) struct cmdline *cl,
3587 __attribute__((unused)) void *data)
3589 struct cmd_tx_vlan_set_result *res = parsed_result;
3591 if (!port_is_stopped(res->port_id)) {
3592 printf("Please stop port %d first\n", res->port_id);
3596 tx_vlan_set(res->port_id, res->vlan_id);
3598 cmd_reconfig_device_queue(res->port_id, 1, 1);
3601 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3602 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3603 tx_vlan, "tx_vlan");
3604 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3605 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3607 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3608 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3610 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3611 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3614 cmdline_parse_inst_t cmd_tx_vlan_set = {
3615 .f = cmd_tx_vlan_set_parsed,
3617 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3618 "Enable hardware insertion of a single VLAN header "
3619 "with a given TAG Identifier in packets sent on a port",
3621 (void *)&cmd_tx_vlan_set_tx_vlan,
3622 (void *)&cmd_tx_vlan_set_set,
3623 (void *)&cmd_tx_vlan_set_portid,
3624 (void *)&cmd_tx_vlan_set_vlanid,
3629 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3630 struct cmd_tx_vlan_set_qinq_result {
3631 cmdline_fixed_string_t tx_vlan;
3632 cmdline_fixed_string_t set;
3635 uint16_t vlan_id_outer;
3639 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3640 __attribute__((unused)) struct cmdline *cl,
3641 __attribute__((unused)) void *data)
3643 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3645 if (!port_is_stopped(res->port_id)) {
3646 printf("Please stop port %d first\n", res->port_id);
3650 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3652 cmd_reconfig_device_queue(res->port_id, 1, 1);
3655 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3656 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3657 tx_vlan, "tx_vlan");
3658 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3659 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3661 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3662 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3664 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3665 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3667 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3668 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3669 vlan_id_outer, UINT16);
3671 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3672 .f = cmd_tx_vlan_set_qinq_parsed,
3674 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3675 "Enable hardware insertion of double VLAN header "
3676 "with given TAG Identifiers in packets sent on a port",
3678 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3679 (void *)&cmd_tx_vlan_set_qinq_set,
3680 (void *)&cmd_tx_vlan_set_qinq_portid,
3681 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3682 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3687 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3688 struct cmd_tx_vlan_set_pvid_result {
3689 cmdline_fixed_string_t tx_vlan;
3690 cmdline_fixed_string_t set;
3691 cmdline_fixed_string_t pvid;
3694 cmdline_fixed_string_t mode;
3698 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3699 __attribute__((unused)) struct cmdline *cl,
3700 __attribute__((unused)) void *data)
3702 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3704 if (strcmp(res->mode, "on") == 0)
3705 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3707 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3710 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3711 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3712 tx_vlan, "tx_vlan");
3713 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3714 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3716 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3717 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3719 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3720 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3722 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3723 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3725 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3726 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3729 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3730 .f = cmd_tx_vlan_set_pvid_parsed,
3732 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3734 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3735 (void *)&cmd_tx_vlan_set_pvid_set,
3736 (void *)&cmd_tx_vlan_set_pvid_pvid,
3737 (void *)&cmd_tx_vlan_set_pvid_port_id,
3738 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3739 (void *)&cmd_tx_vlan_set_pvid_mode,
3744 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3745 struct cmd_tx_vlan_reset_result {
3746 cmdline_fixed_string_t tx_vlan;
3747 cmdline_fixed_string_t reset;
3752 cmd_tx_vlan_reset_parsed(void *parsed_result,
3753 __attribute__((unused)) struct cmdline *cl,
3754 __attribute__((unused)) void *data)
3756 struct cmd_tx_vlan_reset_result *res = parsed_result;
3758 if (!port_is_stopped(res->port_id)) {
3759 printf("Please stop port %d first\n", res->port_id);
3763 tx_vlan_reset(res->port_id);
3765 cmd_reconfig_device_queue(res->port_id, 1, 1);
3768 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3769 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3770 tx_vlan, "tx_vlan");
3771 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3772 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3774 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3775 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3778 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3779 .f = cmd_tx_vlan_reset_parsed,
3781 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3782 "VLAN header in packets sent on a port",
3784 (void *)&cmd_tx_vlan_reset_tx_vlan,
3785 (void *)&cmd_tx_vlan_reset_reset,
3786 (void *)&cmd_tx_vlan_reset_portid,
3792 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3793 struct cmd_csum_result {
3794 cmdline_fixed_string_t csum;
3795 cmdline_fixed_string_t mode;
3796 cmdline_fixed_string_t proto;
3797 cmdline_fixed_string_t hwsw;
3802 csum_show(int port_id)
3804 struct rte_eth_dev_info dev_info;
3805 uint64_t tx_offloads;
3807 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3808 printf("Parse tunnel is %s\n",
3809 (ports[port_id].parse_tunnel) ? "on" : "off");
3810 printf("IP checksum offload is %s\n",
3811 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3812 printf("UDP checksum offload is %s\n",
3813 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3814 printf("TCP checksum offload is %s\n",
3815 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3816 printf("SCTP checksum offload is %s\n",
3817 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3818 printf("Outer-Ip checksum offload is %s\n",
3819 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3821 /* display warnings if configuration is not supported by the NIC */
3822 rte_eth_dev_info_get(port_id, &dev_info);
3823 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3824 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3825 printf("Warning: hardware IP checksum enabled but not "
3826 "supported by port %d\n", port_id);
3828 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3829 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3830 printf("Warning: hardware UDP checksum enabled but not "
3831 "supported by port %d\n", port_id);
3833 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3834 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3835 printf("Warning: hardware TCP checksum enabled but not "
3836 "supported by port %d\n", port_id);
3838 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3839 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3840 printf("Warning: hardware SCTP checksum enabled but not "
3841 "supported by port %d\n", port_id);
3843 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3844 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3845 printf("Warning: hardware outer IP checksum enabled but not "
3846 "supported by port %d\n", port_id);
3851 cmd_csum_parsed(void *parsed_result,
3852 __attribute__((unused)) struct cmdline *cl,
3853 __attribute__((unused)) void *data)
3855 struct cmd_csum_result *res = parsed_result;
3857 uint64_t csum_offloads = 0;
3858 struct rte_eth_dev_info dev_info;
3860 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3861 printf("invalid port %d\n", res->port_id);
3864 if (!port_is_stopped(res->port_id)) {
3865 printf("Please stop port %d first\n", res->port_id);
3869 rte_eth_dev_info_get(res->port_id, &dev_info);
3870 if (!strcmp(res->mode, "set")) {
3872 if (!strcmp(res->hwsw, "hw"))
3875 if (!strcmp(res->proto, "ip")) {
3876 if (hw == 0 || (dev_info.tx_offload_capa &
3877 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
3878 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3880 printf("IP checksum offload is not supported "
3881 "by port %u\n", res->port_id);
3883 } else if (!strcmp(res->proto, "udp")) {
3884 if (hw == 0 || (dev_info.tx_offload_capa &
3885 DEV_TX_OFFLOAD_UDP_CKSUM)) {
3886 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3888 printf("UDP checksum offload is not supported "
3889 "by port %u\n", res->port_id);
3891 } else if (!strcmp(res->proto, "tcp")) {
3892 if (hw == 0 || (dev_info.tx_offload_capa &
3893 DEV_TX_OFFLOAD_TCP_CKSUM)) {
3894 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3896 printf("TCP checksum offload is not supported "
3897 "by port %u\n", res->port_id);
3899 } else if (!strcmp(res->proto, "sctp")) {
3900 if (hw == 0 || (dev_info.tx_offload_capa &
3901 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
3902 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3904 printf("SCTP checksum offload is not supported "
3905 "by port %u\n", res->port_id);
3907 } else if (!strcmp(res->proto, "outer-ip")) {
3908 if (hw == 0 || (dev_info.tx_offload_capa &
3909 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
3911 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3913 printf("Outer IP checksum offload is not "
3914 "supported by port %u\n", res->port_id);
3919 ports[res->port_id].dev_conf.txmode.offloads |=
3922 ports[res->port_id].dev_conf.txmode.offloads &=
3926 csum_show(res->port_id);
3928 cmd_reconfig_device_queue(res->port_id, 1, 1);
3931 cmdline_parse_token_string_t cmd_csum_csum =
3932 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3934 cmdline_parse_token_string_t cmd_csum_mode =
3935 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3937 cmdline_parse_token_string_t cmd_csum_proto =
3938 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3939 proto, "ip#tcp#udp#sctp#outer-ip");
3940 cmdline_parse_token_string_t cmd_csum_hwsw =
3941 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3943 cmdline_parse_token_num_t cmd_csum_portid =
3944 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3947 cmdline_parse_inst_t cmd_csum_set = {
3948 .f = cmd_csum_parsed,
3950 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3951 "Enable/Disable hardware calculation of L3/L4 checksum when "
3952 "using csum forward engine",
3954 (void *)&cmd_csum_csum,
3955 (void *)&cmd_csum_mode,
3956 (void *)&cmd_csum_proto,
3957 (void *)&cmd_csum_hwsw,
3958 (void *)&cmd_csum_portid,
3963 cmdline_parse_token_string_t cmd_csum_mode_show =
3964 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3967 cmdline_parse_inst_t cmd_csum_show = {
3968 .f = cmd_csum_parsed,
3970 .help_str = "csum show <port_id>: Show checksum offload configuration",
3972 (void *)&cmd_csum_csum,
3973 (void *)&cmd_csum_mode_show,
3974 (void *)&cmd_csum_portid,
3979 /* Enable/disable tunnel parsing */
3980 struct cmd_csum_tunnel_result {
3981 cmdline_fixed_string_t csum;
3982 cmdline_fixed_string_t parse;
3983 cmdline_fixed_string_t onoff;
3988 cmd_csum_tunnel_parsed(void *parsed_result,
3989 __attribute__((unused)) struct cmdline *cl,
3990 __attribute__((unused)) void *data)
3992 struct cmd_csum_tunnel_result *res = parsed_result;
3994 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3997 if (!strcmp(res->onoff, "on"))
3998 ports[res->port_id].parse_tunnel = 1;
4000 ports[res->port_id].parse_tunnel = 0;
4002 csum_show(res->port_id);
4005 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4006 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4008 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4009 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4010 parse, "parse_tunnel");
4011 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4012 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4014 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4015 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4018 cmdline_parse_inst_t cmd_csum_tunnel = {
4019 .f = cmd_csum_tunnel_parsed,
4021 .help_str = "csum parse_tunnel on|off <port_id>: "
4022 "Enable/Disable parsing of tunnels for csum engine",
4024 (void *)&cmd_csum_tunnel_csum,
4025 (void *)&cmd_csum_tunnel_parse,
4026 (void *)&cmd_csum_tunnel_onoff,
4027 (void *)&cmd_csum_tunnel_portid,
4032 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4033 struct cmd_tso_set_result {
4034 cmdline_fixed_string_t tso;
4035 cmdline_fixed_string_t mode;
4041 cmd_tso_set_parsed(void *parsed_result,
4042 __attribute__((unused)) struct cmdline *cl,
4043 __attribute__((unused)) void *data)
4045 struct cmd_tso_set_result *res = parsed_result;
4046 struct rte_eth_dev_info dev_info;
4048 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4050 if (!port_is_stopped(res->port_id)) {
4051 printf("Please stop port %d first\n", res->port_id);
4055 if (!strcmp(res->mode, "set"))
4056 ports[res->port_id].tso_segsz = res->tso_segsz;
4058 rte_eth_dev_info_get(res->port_id, &dev_info);
4059 if ((ports[res->port_id].tso_segsz != 0) &&
4060 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4061 printf("Error: TSO is not supported by port %d\n",
4066 if (ports[res->port_id].tso_segsz == 0) {
4067 ports[res->port_id].dev_conf.txmode.offloads &=
4068 ~DEV_TX_OFFLOAD_TCP_TSO;
4069 printf("TSO for non-tunneled packets is disabled\n");
4071 ports[res->port_id].dev_conf.txmode.offloads |=
4072 DEV_TX_OFFLOAD_TCP_TSO;
4073 printf("TSO segment size for non-tunneled packets is %d\n",
4074 ports[res->port_id].tso_segsz);
4077 /* display warnings if configuration is not supported by the NIC */
4078 rte_eth_dev_info_get(res->port_id, &dev_info);
4079 if ((ports[res->port_id].tso_segsz != 0) &&
4080 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4081 printf("Warning: TSO enabled but not "
4082 "supported by port %d\n", res->port_id);
4085 cmd_reconfig_device_queue(res->port_id, 1, 1);
4088 cmdline_parse_token_string_t cmd_tso_set_tso =
4089 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4091 cmdline_parse_token_string_t cmd_tso_set_mode =
4092 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4094 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4095 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4097 cmdline_parse_token_num_t cmd_tso_set_portid =
4098 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4101 cmdline_parse_inst_t cmd_tso_set = {
4102 .f = cmd_tso_set_parsed,
4104 .help_str = "tso set <tso_segsz> <port_id>: "
4105 "Set TSO segment size of non-tunneled packets for csum engine "
4108 (void *)&cmd_tso_set_tso,
4109 (void *)&cmd_tso_set_mode,
4110 (void *)&cmd_tso_set_tso_segsz,
4111 (void *)&cmd_tso_set_portid,
4116 cmdline_parse_token_string_t cmd_tso_show_mode =
4117 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4121 cmdline_parse_inst_t cmd_tso_show = {
4122 .f = cmd_tso_set_parsed,
4124 .help_str = "tso show <port_id>: "
4125 "Show TSO segment size of non-tunneled packets for csum engine",
4127 (void *)&cmd_tso_set_tso,
4128 (void *)&cmd_tso_show_mode,
4129 (void *)&cmd_tso_set_portid,
4134 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4135 struct cmd_tunnel_tso_set_result {
4136 cmdline_fixed_string_t tso;
4137 cmdline_fixed_string_t mode;
4142 static struct rte_eth_dev_info
4143 check_tunnel_tso_nic_support(portid_t port_id)
4145 struct rte_eth_dev_info dev_info;
4147 rte_eth_dev_info_get(port_id, &dev_info);
4148 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4149 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4150 "not enabled for port %d\n", port_id);
4151 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4152 printf("Warning: GRE TUNNEL TSO not supported therefore "
4153 "not enabled for port %d\n", port_id);
4154 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4155 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4156 "not enabled for port %d\n", port_id);
4157 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4158 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4159 "not enabled for port %d\n", port_id);
4164 cmd_tunnel_tso_set_parsed(void *parsed_result,
4165 __attribute__((unused)) struct cmdline *cl,
4166 __attribute__((unused)) void *data)
4168 struct cmd_tunnel_tso_set_result *res = parsed_result;
4169 struct rte_eth_dev_info dev_info;
4171 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4173 if (!port_is_stopped(res->port_id)) {
4174 printf("Please stop port %d first\n", res->port_id);
4178 if (!strcmp(res->mode, "set"))
4179 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4181 dev_info = check_tunnel_tso_nic_support(res->port_id);
4182 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4183 ports[res->port_id].dev_conf.txmode.offloads &=
4184 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4185 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4186 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4187 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4188 printf("TSO for tunneled packets is disabled\n");
4190 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4191 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4192 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4193 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4195 ports[res->port_id].dev_conf.txmode.offloads |=
4196 (tso_offloads & dev_info.tx_offload_capa);
4197 printf("TSO segment size for tunneled packets is %d\n",
4198 ports[res->port_id].tunnel_tso_segsz);
4200 /* Below conditions are needed to make it work:
4201 * (1) tunnel TSO is supported by the NIC;
4202 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4204 * (3) for tunneled pkts with outer L3 of IPv4,
4205 * "csum set outer-ip" must be set to hw, because after tso,
4206 * total_len of outer IP header is changed, and the checksum
4207 * of outer IP header calculated by sw should be wrong; that
4208 * is not necessary for IPv6 tunneled pkts because there's no
4209 * checksum in IP header anymore.
4212 if (!ports[res->port_id].parse_tunnel)
4213 printf("Warning: csum parse_tunnel must be set "
4214 "so that tunneled packets are recognized\n");
4215 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4216 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4217 printf("Warning: csum set outer-ip must be set to hw "
4218 "if outer L3 is IPv4; not necessary for IPv6\n");
4221 cmd_reconfig_device_queue(res->port_id, 1, 1);
4224 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4225 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4227 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4228 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4230 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4231 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4233 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4234 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4237 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4238 .f = cmd_tunnel_tso_set_parsed,
4240 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4241 "Set TSO segment size of tunneled packets for csum engine "
4244 (void *)&cmd_tunnel_tso_set_tso,
4245 (void *)&cmd_tunnel_tso_set_mode,
4246 (void *)&cmd_tunnel_tso_set_tso_segsz,
4247 (void *)&cmd_tunnel_tso_set_portid,
4252 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4253 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4257 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4258 .f = cmd_tunnel_tso_set_parsed,
4260 .help_str = "tunnel_tso show <port_id> "
4261 "Show TSO segment size of tunneled packets for csum engine",
4263 (void *)&cmd_tunnel_tso_set_tso,
4264 (void *)&cmd_tunnel_tso_show_mode,
4265 (void *)&cmd_tunnel_tso_set_portid,
4270 /* *** SET GRO FOR A PORT *** */
4271 struct cmd_gro_enable_result {
4272 cmdline_fixed_string_t cmd_set;
4273 cmdline_fixed_string_t cmd_port;
4274 cmdline_fixed_string_t cmd_keyword;
4275 cmdline_fixed_string_t cmd_onoff;
4280 cmd_gro_enable_parsed(void *parsed_result,
4281 __attribute__((unused)) struct cmdline *cl,
4282 __attribute__((unused)) void *data)
4284 struct cmd_gro_enable_result *res;
4286 res = parsed_result;
4287 if (!strcmp(res->cmd_keyword, "gro"))
4288 setup_gro(res->cmd_onoff, res->cmd_pid);
4291 cmdline_parse_token_string_t cmd_gro_enable_set =
4292 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4294 cmdline_parse_token_string_t cmd_gro_enable_port =
4295 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4296 cmd_keyword, "port");
4297 cmdline_parse_token_num_t cmd_gro_enable_pid =
4298 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4300 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4301 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4302 cmd_keyword, "gro");
4303 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4304 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4305 cmd_onoff, "on#off");
4307 cmdline_parse_inst_t cmd_gro_enable = {
4308 .f = cmd_gro_enable_parsed,
4310 .help_str = "set port <port_id> gro on|off",
4312 (void *)&cmd_gro_enable_set,
4313 (void *)&cmd_gro_enable_port,
4314 (void *)&cmd_gro_enable_pid,
4315 (void *)&cmd_gro_enable_keyword,
4316 (void *)&cmd_gro_enable_onoff,
4321 /* *** DISPLAY GRO CONFIGURATION *** */
4322 struct cmd_gro_show_result {
4323 cmdline_fixed_string_t cmd_show;
4324 cmdline_fixed_string_t cmd_port;
4325 cmdline_fixed_string_t cmd_keyword;
4330 cmd_gro_show_parsed(void *parsed_result,
4331 __attribute__((unused)) struct cmdline *cl,
4332 __attribute__((unused)) void *data)
4334 struct cmd_gro_show_result *res;
4336 res = parsed_result;
4337 if (!strcmp(res->cmd_keyword, "gro"))
4338 show_gro(res->cmd_pid);
4341 cmdline_parse_token_string_t cmd_gro_show_show =
4342 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4344 cmdline_parse_token_string_t cmd_gro_show_port =
4345 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4347 cmdline_parse_token_num_t cmd_gro_show_pid =
4348 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4350 cmdline_parse_token_string_t cmd_gro_show_keyword =
4351 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4352 cmd_keyword, "gro");
4354 cmdline_parse_inst_t cmd_gro_show = {
4355 .f = cmd_gro_show_parsed,
4357 .help_str = "show port <port_id> gro",
4359 (void *)&cmd_gro_show_show,
4360 (void *)&cmd_gro_show_port,
4361 (void *)&cmd_gro_show_pid,
4362 (void *)&cmd_gro_show_keyword,
4367 /* *** SET FLUSH CYCLES FOR GRO *** */
4368 struct cmd_gro_flush_result {
4369 cmdline_fixed_string_t cmd_set;
4370 cmdline_fixed_string_t cmd_keyword;
4371 cmdline_fixed_string_t cmd_flush;
4376 cmd_gro_flush_parsed(void *parsed_result,
4377 __attribute__((unused)) struct cmdline *cl,
4378 __attribute__((unused)) void *data)
4380 struct cmd_gro_flush_result *res;
4382 res = parsed_result;
4383 if ((!strcmp(res->cmd_keyword, "gro")) &&
4384 (!strcmp(res->cmd_flush, "flush")))
4385 setup_gro_flush_cycles(res->cmd_cycles);
4388 cmdline_parse_token_string_t cmd_gro_flush_set =
4389 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4391 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4392 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4393 cmd_keyword, "gro");
4394 cmdline_parse_token_string_t cmd_gro_flush_flush =
4395 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4396 cmd_flush, "flush");
4397 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4398 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4401 cmdline_parse_inst_t cmd_gro_flush = {
4402 .f = cmd_gro_flush_parsed,
4404 .help_str = "set gro flush <cycles>",
4406 (void *)&cmd_gro_flush_set,
4407 (void *)&cmd_gro_flush_keyword,
4408 (void *)&cmd_gro_flush_flush,
4409 (void *)&cmd_gro_flush_cycles,
4414 /* *** ENABLE/DISABLE GSO *** */
4415 struct cmd_gso_enable_result {
4416 cmdline_fixed_string_t cmd_set;
4417 cmdline_fixed_string_t cmd_port;
4418 cmdline_fixed_string_t cmd_keyword;
4419 cmdline_fixed_string_t cmd_mode;
4424 cmd_gso_enable_parsed(void *parsed_result,
4425 __attribute__((unused)) struct cmdline *cl,
4426 __attribute__((unused)) void *data)
4428 struct cmd_gso_enable_result *res;
4430 res = parsed_result;
4431 if (!strcmp(res->cmd_keyword, "gso"))
4432 setup_gso(res->cmd_mode, res->cmd_pid);
4435 cmdline_parse_token_string_t cmd_gso_enable_set =
4436 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4438 cmdline_parse_token_string_t cmd_gso_enable_port =
4439 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4441 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4442 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4443 cmd_keyword, "gso");
4444 cmdline_parse_token_string_t cmd_gso_enable_mode =
4445 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4446 cmd_mode, "on#off");
4447 cmdline_parse_token_num_t cmd_gso_enable_pid =
4448 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4451 cmdline_parse_inst_t cmd_gso_enable = {
4452 .f = cmd_gso_enable_parsed,
4454 .help_str = "set port <port_id> gso on|off",
4456 (void *)&cmd_gso_enable_set,
4457 (void *)&cmd_gso_enable_port,
4458 (void *)&cmd_gso_enable_pid,
4459 (void *)&cmd_gso_enable_keyword,
4460 (void *)&cmd_gso_enable_mode,
4465 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4466 struct cmd_gso_size_result {
4467 cmdline_fixed_string_t cmd_set;
4468 cmdline_fixed_string_t cmd_keyword;
4469 cmdline_fixed_string_t cmd_segsz;
4474 cmd_gso_size_parsed(void *parsed_result,
4475 __attribute__((unused)) struct cmdline *cl,
4476 __attribute__((unused)) void *data)
4478 struct cmd_gso_size_result *res = parsed_result;
4480 if (test_done == 0) {
4481 printf("Before setting GSO segsz, please first"
4482 " stop fowarding\n");
4486 if (!strcmp(res->cmd_keyword, "gso") &&
4487 !strcmp(res->cmd_segsz, "segsz")) {
4488 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4489 printf("gso_size should be larger than %zu."
4490 " Please input a legal value\n",
4491 RTE_GSO_SEG_SIZE_MIN);
4493 gso_max_segment_size = res->cmd_size;
4497 cmdline_parse_token_string_t cmd_gso_size_set =
4498 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4500 cmdline_parse_token_string_t cmd_gso_size_keyword =
4501 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4502 cmd_keyword, "gso");
4503 cmdline_parse_token_string_t cmd_gso_size_segsz =
4504 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4505 cmd_segsz, "segsz");
4506 cmdline_parse_token_num_t cmd_gso_size_size =
4507 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4510 cmdline_parse_inst_t cmd_gso_size = {
4511 .f = cmd_gso_size_parsed,
4513 .help_str = "set gso segsz <length>",
4515 (void *)&cmd_gso_size_set,
4516 (void *)&cmd_gso_size_keyword,
4517 (void *)&cmd_gso_size_segsz,
4518 (void *)&cmd_gso_size_size,
4523 /* *** SHOW GSO CONFIGURATION *** */
4524 struct cmd_gso_show_result {
4525 cmdline_fixed_string_t cmd_show;
4526 cmdline_fixed_string_t cmd_port;
4527 cmdline_fixed_string_t cmd_keyword;
4532 cmd_gso_show_parsed(void *parsed_result,
4533 __attribute__((unused)) struct cmdline *cl,
4534 __attribute__((unused)) void *data)
4536 struct cmd_gso_show_result *res = parsed_result;
4538 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4539 printf("invalid port id %u\n", res->cmd_pid);
4542 if (!strcmp(res->cmd_keyword, "gso")) {
4543 if (gso_ports[res->cmd_pid].enable) {
4544 printf("Max GSO'd packet size: %uB\n"
4545 "Supported GSO types: TCP/IPv4, "
4546 "VxLAN with inner TCP/IPv4 packet, "
4547 "GRE with inner TCP/IPv4 packet\n",
4548 gso_max_segment_size);
4550 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4554 cmdline_parse_token_string_t cmd_gso_show_show =
4555 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4557 cmdline_parse_token_string_t cmd_gso_show_port =
4558 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4560 cmdline_parse_token_string_t cmd_gso_show_keyword =
4561 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4562 cmd_keyword, "gso");
4563 cmdline_parse_token_num_t cmd_gso_show_pid =
4564 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4567 cmdline_parse_inst_t cmd_gso_show = {
4568 .f = cmd_gso_show_parsed,
4570 .help_str = "show port <port_id> gso",
4572 (void *)&cmd_gso_show_show,
4573 (void *)&cmd_gso_show_port,
4574 (void *)&cmd_gso_show_pid,
4575 (void *)&cmd_gso_show_keyword,
4580 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4581 struct cmd_set_flush_rx {
4582 cmdline_fixed_string_t set;
4583 cmdline_fixed_string_t flush_rx;
4584 cmdline_fixed_string_t mode;
4588 cmd_set_flush_rx_parsed(void *parsed_result,
4589 __attribute__((unused)) struct cmdline *cl,
4590 __attribute__((unused)) void *data)
4592 struct cmd_set_flush_rx *res = parsed_result;
4593 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4596 cmdline_parse_token_string_t cmd_setflushrx_set =
4597 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4599 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4600 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4601 flush_rx, "flush_rx");
4602 cmdline_parse_token_string_t cmd_setflushrx_mode =
4603 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4607 cmdline_parse_inst_t cmd_set_flush_rx = {
4608 .f = cmd_set_flush_rx_parsed,
4609 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4612 (void *)&cmd_setflushrx_set,
4613 (void *)&cmd_setflushrx_flush_rx,
4614 (void *)&cmd_setflushrx_mode,
4619 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4620 struct cmd_set_link_check {
4621 cmdline_fixed_string_t set;
4622 cmdline_fixed_string_t link_check;
4623 cmdline_fixed_string_t mode;
4627 cmd_set_link_check_parsed(void *parsed_result,
4628 __attribute__((unused)) struct cmdline *cl,
4629 __attribute__((unused)) void *data)
4631 struct cmd_set_link_check *res = parsed_result;
4632 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4635 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4636 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4638 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4639 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4640 link_check, "link_check");
4641 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4642 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4646 cmdline_parse_inst_t cmd_set_link_check = {
4647 .f = cmd_set_link_check_parsed,
4648 .help_str = "set link_check on|off: Enable/Disable link status check "
4649 "when starting/stopping a port",
4652 (void *)&cmd_setlinkcheck_set,
4653 (void *)&cmd_setlinkcheck_link_check,
4654 (void *)&cmd_setlinkcheck_mode,
4659 /* *** SET NIC BYPASS MODE *** */
4660 struct cmd_set_bypass_mode_result {
4661 cmdline_fixed_string_t set;
4662 cmdline_fixed_string_t bypass;
4663 cmdline_fixed_string_t mode;
4664 cmdline_fixed_string_t value;
4669 cmd_set_bypass_mode_parsed(void *parsed_result,
4670 __attribute__((unused)) struct cmdline *cl,
4671 __attribute__((unused)) void *data)
4673 struct cmd_set_bypass_mode_result *res = parsed_result;
4674 portid_t port_id = res->port_id;
4675 int32_t rc = -EINVAL;
4677 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4678 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4680 if (!strcmp(res->value, "bypass"))
4681 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4682 else if (!strcmp(res->value, "isolate"))
4683 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4685 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4687 /* Set the bypass mode for the relevant port. */
4688 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4691 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4694 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4695 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4697 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4698 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4700 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4701 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4703 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4704 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4705 value, "normal#bypass#isolate");
4706 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4707 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4710 cmdline_parse_inst_t cmd_set_bypass_mode = {
4711 .f = cmd_set_bypass_mode_parsed,
4712 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4713 "Set the NIC bypass mode for port_id",
4716 (void *)&cmd_setbypass_mode_set,
4717 (void *)&cmd_setbypass_mode_bypass,
4718 (void *)&cmd_setbypass_mode_mode,
4719 (void *)&cmd_setbypass_mode_value,
4720 (void *)&cmd_setbypass_mode_port,
4725 /* *** SET NIC BYPASS EVENT *** */
4726 struct cmd_set_bypass_event_result {
4727 cmdline_fixed_string_t set;
4728 cmdline_fixed_string_t bypass;
4729 cmdline_fixed_string_t event;
4730 cmdline_fixed_string_t event_value;
4731 cmdline_fixed_string_t mode;
4732 cmdline_fixed_string_t mode_value;
4737 cmd_set_bypass_event_parsed(void *parsed_result,
4738 __attribute__((unused)) struct cmdline *cl,
4739 __attribute__((unused)) void *data)
4741 int32_t rc = -EINVAL;
4742 struct cmd_set_bypass_event_result *res = parsed_result;
4743 portid_t port_id = res->port_id;
4745 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4746 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4747 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4749 if (!strcmp(res->event_value, "timeout"))
4750 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4751 else if (!strcmp(res->event_value, "os_on"))
4752 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4753 else if (!strcmp(res->event_value, "os_off"))
4754 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4755 else if (!strcmp(res->event_value, "power_on"))
4756 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4757 else if (!strcmp(res->event_value, "power_off"))
4758 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4760 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4762 if (!strcmp(res->mode_value, "bypass"))
4763 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4764 else if (!strcmp(res->mode_value, "isolate"))
4765 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4767 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4769 /* Set the watchdog timeout. */
4770 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4773 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4774 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4778 printf("Failed to set timeout value %u "
4779 "for port %d, errto code: %d.\n",
4780 bypass_timeout, port_id, rc);
4784 /* Set the bypass event to transition to bypass mode. */
4785 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4790 printf("\t Failed to set bypass event for port = %d.\n",
4794 cmdline_parse_token_string_t cmd_setbypass_event_set =
4795 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4797 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4798 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4800 cmdline_parse_token_string_t cmd_setbypass_event_event =
4801 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4803 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4804 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4805 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4806 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4807 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4809 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4810 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4811 mode_value, "normal#bypass#isolate");
4812 cmdline_parse_token_num_t cmd_setbypass_event_port =
4813 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4816 cmdline_parse_inst_t cmd_set_bypass_event = {
4817 .f = cmd_set_bypass_event_parsed,
4818 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4819 "power_off mode normal|bypass|isolate <port_id>: "
4820 "Set the NIC bypass event mode for port_id",
4823 (void *)&cmd_setbypass_event_set,
4824 (void *)&cmd_setbypass_event_bypass,
4825 (void *)&cmd_setbypass_event_event,
4826 (void *)&cmd_setbypass_event_event_value,
4827 (void *)&cmd_setbypass_event_mode,
4828 (void *)&cmd_setbypass_event_mode_value,
4829 (void *)&cmd_setbypass_event_port,
4835 /* *** SET NIC BYPASS TIMEOUT *** */
4836 struct cmd_set_bypass_timeout_result {
4837 cmdline_fixed_string_t set;
4838 cmdline_fixed_string_t bypass;
4839 cmdline_fixed_string_t timeout;
4840 cmdline_fixed_string_t value;
4844 cmd_set_bypass_timeout_parsed(void *parsed_result,
4845 __attribute__((unused)) struct cmdline *cl,
4846 __attribute__((unused)) void *data)
4848 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4850 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4851 if (!strcmp(res->value, "1.5"))
4852 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4853 else if (!strcmp(res->value, "2"))
4854 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4855 else if (!strcmp(res->value, "3"))
4856 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4857 else if (!strcmp(res->value, "4"))
4858 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4859 else if (!strcmp(res->value, "8"))
4860 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4861 else if (!strcmp(res->value, "16"))
4862 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4863 else if (!strcmp(res->value, "32"))
4864 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4866 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4870 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4871 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4873 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4874 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4876 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4877 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4878 timeout, "timeout");
4879 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4880 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4881 value, "0#1.5#2#3#4#8#16#32");
4883 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4884 .f = cmd_set_bypass_timeout_parsed,
4885 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4886 "Set the NIC bypass watchdog timeout in seconds",
4889 (void *)&cmd_setbypass_timeout_set,
4890 (void *)&cmd_setbypass_timeout_bypass,
4891 (void *)&cmd_setbypass_timeout_timeout,
4892 (void *)&cmd_setbypass_timeout_value,
4897 /* *** SHOW NIC BYPASS MODE *** */
4898 struct cmd_show_bypass_config_result {
4899 cmdline_fixed_string_t show;
4900 cmdline_fixed_string_t bypass;
4901 cmdline_fixed_string_t config;
4906 cmd_show_bypass_config_parsed(void *parsed_result,
4907 __attribute__((unused)) struct cmdline *cl,
4908 __attribute__((unused)) void *data)
4910 struct cmd_show_bypass_config_result *res = parsed_result;
4911 portid_t port_id = res->port_id;
4913 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4914 uint32_t event_mode;
4915 uint32_t bypass_mode;
4916 uint32_t timeout = bypass_timeout;
4919 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4920 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4921 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4922 {"UNKNOWN", "normal", "bypass", "isolate"};
4923 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4930 int num_events = (sizeof events) / (sizeof events[0]);
4932 /* Display the bypass mode.*/
4933 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4934 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4938 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4939 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4941 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4944 /* Display the bypass timeout.*/
4945 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4946 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4948 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4950 /* Display the bypass events and associated modes. */
4951 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4953 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4954 printf("\tFailed to get bypass mode for event = %s\n",
4957 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4958 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4960 printf("\tbypass event: %-16s = %s\n", events[i],
4966 printf("\tFailed to get bypass configuration for port = %d\n",
4970 cmdline_parse_token_string_t cmd_showbypass_config_show =
4971 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4973 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4974 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4976 cmdline_parse_token_string_t cmd_showbypass_config_config =
4977 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4979 cmdline_parse_token_num_t cmd_showbypass_config_port =
4980 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4983 cmdline_parse_inst_t cmd_show_bypass_config = {
4984 .f = cmd_show_bypass_config_parsed,
4985 .help_str = "show bypass config <port_id>: "
4986 "Show the NIC bypass config for port_id",
4989 (void *)&cmd_showbypass_config_show,
4990 (void *)&cmd_showbypass_config_bypass,
4991 (void *)&cmd_showbypass_config_config,
4992 (void *)&cmd_showbypass_config_port,
4997 #ifdef RTE_LIBRTE_PMD_BOND
4998 /* *** SET BONDING MODE *** */
4999 struct cmd_set_bonding_mode_result {
5000 cmdline_fixed_string_t set;
5001 cmdline_fixed_string_t bonding;
5002 cmdline_fixed_string_t mode;
5007 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5008 __attribute__((unused)) struct cmdline *cl,
5009 __attribute__((unused)) void *data)
5011 struct cmd_set_bonding_mode_result *res = parsed_result;
5012 portid_t port_id = res->port_id;
5014 /* Set the bonding mode for the relevant port. */
5015 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5016 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5019 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5020 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5022 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5023 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5024 bonding, "bonding");
5025 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5026 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5028 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5029 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5031 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5032 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5035 cmdline_parse_inst_t cmd_set_bonding_mode = {
5036 .f = cmd_set_bonding_mode_parsed,
5037 .help_str = "set bonding mode <mode_value> <port_id>: "
5038 "Set the bonding mode for port_id",
5041 (void *) &cmd_setbonding_mode_set,
5042 (void *) &cmd_setbonding_mode_bonding,
5043 (void *) &cmd_setbonding_mode_mode,
5044 (void *) &cmd_setbonding_mode_value,
5045 (void *) &cmd_setbonding_mode_port,
5050 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5051 struct cmd_set_bonding_lacp_dedicated_queues_result {
5052 cmdline_fixed_string_t set;
5053 cmdline_fixed_string_t bonding;
5054 cmdline_fixed_string_t lacp;
5055 cmdline_fixed_string_t dedicated_queues;
5057 cmdline_fixed_string_t mode;
5060 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5061 __attribute__((unused)) struct cmdline *cl,
5062 __attribute__((unused)) void *data)
5064 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5065 portid_t port_id = res->port_id;
5066 struct rte_port *port;
5068 port = &ports[port_id];
5070 /** Check if the port is not started **/
5071 if (port->port_status != RTE_PORT_STOPPED) {
5072 printf("Please stop port %d first\n", port_id);
5076 if (!strcmp(res->mode, "enable")) {
5077 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5078 printf("Dedicate queues for LACP control packets"
5081 printf("Enabling dedicate queues for LACP control "
5082 "packets on port %d failed\n", port_id);
5083 } else if (!strcmp(res->mode, "disable")) {
5084 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5085 printf("Dedicated queues for LACP control packets "
5088 printf("Disabling dedicated queues for LACP control "
5089 "traffic on port %d failed\n", port_id);
5093 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5094 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5096 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5097 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5098 bonding, "bonding");
5099 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5100 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5102 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5103 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5104 dedicated_queues, "dedicated_queues");
5105 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5106 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5108 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5109 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5110 mode, "enable#disable");
5112 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5113 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5114 .help_str = "set bonding lacp dedicated_queues <port_id> "
5116 "Enable/disable dedicated queues for LACP control traffic for port_id",
5119 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5120 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5121 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5122 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5123 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5124 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5129 /* *** SET BALANCE XMIT POLICY *** */
5130 struct cmd_set_bonding_balance_xmit_policy_result {
5131 cmdline_fixed_string_t set;
5132 cmdline_fixed_string_t bonding;
5133 cmdline_fixed_string_t balance_xmit_policy;
5135 cmdline_fixed_string_t policy;
5138 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5139 __attribute__((unused)) struct cmdline *cl,
5140 __attribute__((unused)) void *data)
5142 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5143 portid_t port_id = res->port_id;
5146 if (!strcmp(res->policy, "l2")) {
5147 policy = BALANCE_XMIT_POLICY_LAYER2;
5148 } else if (!strcmp(res->policy, "l23")) {
5149 policy = BALANCE_XMIT_POLICY_LAYER23;
5150 } else if (!strcmp(res->policy, "l34")) {
5151 policy = BALANCE_XMIT_POLICY_LAYER34;
5153 printf("\t Invalid xmit policy selection");
5157 /* Set the bonding mode for the relevant port. */
5158 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5159 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5164 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5165 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5167 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5168 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5169 bonding, "bonding");
5170 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5171 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5172 balance_xmit_policy, "balance_xmit_policy");
5173 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5174 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5176 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5177 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5178 policy, "l2#l23#l34");
5180 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5181 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5182 .help_str = "set bonding balance_xmit_policy <port_id> "
5184 "Set the bonding balance_xmit_policy for port_id",
5187 (void *)&cmd_setbonding_balance_xmit_policy_set,
5188 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5189 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5190 (void *)&cmd_setbonding_balance_xmit_policy_port,
5191 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5196 /* *** SHOW NIC BONDING CONFIGURATION *** */
5197 struct cmd_show_bonding_config_result {
5198 cmdline_fixed_string_t show;
5199 cmdline_fixed_string_t bonding;
5200 cmdline_fixed_string_t config;
5204 static void cmd_show_bonding_config_parsed(void *parsed_result,
5205 __attribute__((unused)) struct cmdline *cl,
5206 __attribute__((unused)) void *data)
5208 struct cmd_show_bonding_config_result *res = parsed_result;
5209 int bonding_mode, agg_mode;
5210 portid_t slaves[RTE_MAX_ETHPORTS];
5211 int num_slaves, num_active_slaves;
5214 portid_t port_id = res->port_id;
5216 /* Display the bonding mode.*/
5217 bonding_mode = rte_eth_bond_mode_get(port_id);
5218 if (bonding_mode < 0) {
5219 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5222 printf("\tBonding mode: %d\n", bonding_mode);
5224 if (bonding_mode == BONDING_MODE_BALANCE) {
5225 int balance_xmit_policy;
5227 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5228 if (balance_xmit_policy < 0) {
5229 printf("\tFailed to get balance xmit policy for port = %d\n",
5233 printf("\tBalance Xmit Policy: ");
5235 switch (balance_xmit_policy) {
5236 case BALANCE_XMIT_POLICY_LAYER2:
5237 printf("BALANCE_XMIT_POLICY_LAYER2");
5239 case BALANCE_XMIT_POLICY_LAYER23:
5240 printf("BALANCE_XMIT_POLICY_LAYER23");
5242 case BALANCE_XMIT_POLICY_LAYER34:
5243 printf("BALANCE_XMIT_POLICY_LAYER34");
5250 if (bonding_mode == BONDING_MODE_8023AD) {
5251 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5252 printf("\tIEEE802.3AD Aggregator Mode: ");
5255 printf("bandwidth");
5267 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5269 if (num_slaves < 0) {
5270 printf("\tFailed to get slave list for port = %d\n", port_id);
5273 if (num_slaves > 0) {
5274 printf("\tSlaves (%d): [", num_slaves);
5275 for (i = 0; i < num_slaves - 1; i++)
5276 printf("%d ", slaves[i]);
5278 printf("%d]\n", slaves[num_slaves - 1]);
5280 printf("\tSlaves: []\n");
5284 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5287 if (num_active_slaves < 0) {
5288 printf("\tFailed to get active slave list for port = %d\n", port_id);
5291 if (num_active_slaves > 0) {
5292 printf("\tActive Slaves (%d): [", num_active_slaves);
5293 for (i = 0; i < num_active_slaves - 1; i++)
5294 printf("%d ", slaves[i]);
5296 printf("%d]\n", slaves[num_active_slaves - 1]);
5299 printf("\tActive Slaves: []\n");
5303 primary_id = rte_eth_bond_primary_get(port_id);
5304 if (primary_id < 0) {
5305 printf("\tFailed to get primary slave for port = %d\n", port_id);
5308 printf("\tPrimary: [%d]\n", primary_id);
5312 cmdline_parse_token_string_t cmd_showbonding_config_show =
5313 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5315 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5316 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5317 bonding, "bonding");
5318 cmdline_parse_token_string_t cmd_showbonding_config_config =
5319 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5321 cmdline_parse_token_num_t cmd_showbonding_config_port =
5322 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5325 cmdline_parse_inst_t cmd_show_bonding_config = {
5326 .f = cmd_show_bonding_config_parsed,
5327 .help_str = "show bonding config <port_id>: "
5328 "Show the bonding config for port_id",
5331 (void *)&cmd_showbonding_config_show,
5332 (void *)&cmd_showbonding_config_bonding,
5333 (void *)&cmd_showbonding_config_config,
5334 (void *)&cmd_showbonding_config_port,
5339 /* *** SET BONDING PRIMARY *** */
5340 struct cmd_set_bonding_primary_result {
5341 cmdline_fixed_string_t set;
5342 cmdline_fixed_string_t bonding;
5343 cmdline_fixed_string_t primary;
5348 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5349 __attribute__((unused)) struct cmdline *cl,
5350 __attribute__((unused)) void *data)
5352 struct cmd_set_bonding_primary_result *res = parsed_result;
5353 portid_t master_port_id = res->port_id;
5354 portid_t slave_port_id = res->slave_id;
5356 /* Set the primary slave for a bonded device. */
5357 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5358 printf("\t Failed to set primary slave for port = %d.\n",
5365 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5366 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5368 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5369 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5370 bonding, "bonding");
5371 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5372 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5373 primary, "primary");
5374 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5375 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5377 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5378 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5381 cmdline_parse_inst_t cmd_set_bonding_primary = {
5382 .f = cmd_set_bonding_primary_parsed,
5383 .help_str = "set bonding primary <slave_id> <port_id>: "
5384 "Set the primary slave for port_id",
5387 (void *)&cmd_setbonding_primary_set,
5388 (void *)&cmd_setbonding_primary_bonding,
5389 (void *)&cmd_setbonding_primary_primary,
5390 (void *)&cmd_setbonding_primary_slave,
5391 (void *)&cmd_setbonding_primary_port,
5396 /* *** ADD SLAVE *** */
5397 struct cmd_add_bonding_slave_result {
5398 cmdline_fixed_string_t add;
5399 cmdline_fixed_string_t bonding;
5400 cmdline_fixed_string_t slave;
5405 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5406 __attribute__((unused)) struct cmdline *cl,
5407 __attribute__((unused)) void *data)
5409 struct cmd_add_bonding_slave_result *res = parsed_result;
5410 portid_t master_port_id = res->port_id;
5411 portid_t slave_port_id = res->slave_id;
5413 /* add the slave for a bonded device. */
5414 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5415 printf("\t Failed to add slave %d to master port = %d.\n",
5416 slave_port_id, master_port_id);
5420 set_port_slave_flag(slave_port_id);
5423 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5424 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5426 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5427 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5428 bonding, "bonding");
5429 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5430 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5432 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5433 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5435 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5436 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5439 cmdline_parse_inst_t cmd_add_bonding_slave = {
5440 .f = cmd_add_bonding_slave_parsed,
5441 .help_str = "add bonding slave <slave_id> <port_id>: "
5442 "Add a slave device to a bonded device",
5445 (void *)&cmd_addbonding_slave_add,
5446 (void *)&cmd_addbonding_slave_bonding,
5447 (void *)&cmd_addbonding_slave_slave,
5448 (void *)&cmd_addbonding_slave_slaveid,
5449 (void *)&cmd_addbonding_slave_port,
5454 /* *** REMOVE SLAVE *** */
5455 struct cmd_remove_bonding_slave_result {
5456 cmdline_fixed_string_t remove;
5457 cmdline_fixed_string_t bonding;
5458 cmdline_fixed_string_t slave;
5463 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5464 __attribute__((unused)) struct cmdline *cl,
5465 __attribute__((unused)) void *data)
5467 struct cmd_remove_bonding_slave_result *res = parsed_result;
5468 portid_t master_port_id = res->port_id;
5469 portid_t slave_port_id = res->slave_id;
5471 /* remove the slave from a bonded device. */
5472 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5473 printf("\t Failed to remove slave %d from master port = %d.\n",
5474 slave_port_id, master_port_id);
5478 clear_port_slave_flag(slave_port_id);
5481 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5482 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5484 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5485 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5486 bonding, "bonding");
5487 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5488 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5490 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5491 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5493 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5494 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5497 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5498 .f = cmd_remove_bonding_slave_parsed,
5499 .help_str = "remove bonding slave <slave_id> <port_id>: "
5500 "Remove a slave device from a bonded device",
5503 (void *)&cmd_removebonding_slave_remove,
5504 (void *)&cmd_removebonding_slave_bonding,
5505 (void *)&cmd_removebonding_slave_slave,
5506 (void *)&cmd_removebonding_slave_slaveid,
5507 (void *)&cmd_removebonding_slave_port,
5512 /* *** CREATE BONDED DEVICE *** */
5513 struct cmd_create_bonded_device_result {
5514 cmdline_fixed_string_t create;
5515 cmdline_fixed_string_t bonded;
5516 cmdline_fixed_string_t device;
5521 static int bond_dev_num = 0;
5523 static void cmd_create_bonded_device_parsed(void *parsed_result,
5524 __attribute__((unused)) struct cmdline *cl,
5525 __attribute__((unused)) void *data)
5527 struct cmd_create_bonded_device_result *res = parsed_result;
5528 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5531 if (test_done == 0) {
5532 printf("Please stop forwarding first\n");
5536 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5539 /* Create a new bonded device. */
5540 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5542 printf("\t Failed to create bonded device.\n");
5545 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5548 /* Update number of ports */
5549 nb_ports = rte_eth_dev_count_avail();
5550 reconfig(port_id, res->socket);
5551 rte_eth_promiscuous_enable(port_id);
5556 cmdline_parse_token_string_t cmd_createbonded_device_create =
5557 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5559 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5560 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5562 cmdline_parse_token_string_t cmd_createbonded_device_device =
5563 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5565 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5566 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5568 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5569 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5572 cmdline_parse_inst_t cmd_create_bonded_device = {
5573 .f = cmd_create_bonded_device_parsed,
5574 .help_str = "create bonded device <mode> <socket>: "
5575 "Create a new bonded device with specific bonding mode and socket",
5578 (void *)&cmd_createbonded_device_create,
5579 (void *)&cmd_createbonded_device_bonded,
5580 (void *)&cmd_createbonded_device_device,
5581 (void *)&cmd_createbonded_device_mode,
5582 (void *)&cmd_createbonded_device_socket,
5587 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5588 struct cmd_set_bond_mac_addr_result {
5589 cmdline_fixed_string_t set;
5590 cmdline_fixed_string_t bonding;
5591 cmdline_fixed_string_t mac_addr;
5593 struct ether_addr address;
5596 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5597 __attribute__((unused)) struct cmdline *cl,
5598 __attribute__((unused)) void *data)
5600 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5603 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5606 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5608 /* check the return value and print it if is < 0 */
5610 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5613 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5615 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5618 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5621 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5622 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5624 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5625 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5627 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5628 .f = cmd_set_bond_mac_addr_parsed,
5630 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5632 (void *)&cmd_set_bond_mac_addr_set,
5633 (void *)&cmd_set_bond_mac_addr_bonding,
5634 (void *)&cmd_set_bond_mac_addr_mac,
5635 (void *)&cmd_set_bond_mac_addr_portnum,
5636 (void *)&cmd_set_bond_mac_addr_addr,
5642 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5643 struct cmd_set_bond_mon_period_result {
5644 cmdline_fixed_string_t set;
5645 cmdline_fixed_string_t bonding;
5646 cmdline_fixed_string_t mon_period;
5651 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5652 __attribute__((unused)) struct cmdline *cl,
5653 __attribute__((unused)) void *data)
5655 struct cmd_set_bond_mon_period_result *res = parsed_result;
5658 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5660 /* check the return value and print it if is < 0 */
5662 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5665 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5666 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5668 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5669 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5670 bonding, "bonding");
5671 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5672 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5673 mon_period, "mon_period");
5674 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5675 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5677 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5678 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5681 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5682 .f = cmd_set_bond_mon_period_parsed,
5684 .help_str = "set bonding mon_period <port_id> <period_ms>",
5686 (void *)&cmd_set_bond_mon_period_set,
5687 (void *)&cmd_set_bond_mon_period_bonding,
5688 (void *)&cmd_set_bond_mon_period_mon_period,
5689 (void *)&cmd_set_bond_mon_period_portnum,
5690 (void *)&cmd_set_bond_mon_period_period_ms,
5697 struct cmd_set_bonding_agg_mode_policy_result {
5698 cmdline_fixed_string_t set;
5699 cmdline_fixed_string_t bonding;
5700 cmdline_fixed_string_t agg_mode;
5702 cmdline_fixed_string_t policy;
5707 cmd_set_bonding_agg_mode(void *parsed_result,
5708 __attribute__((unused)) struct cmdline *cl,
5709 __attribute__((unused)) void *data)
5711 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5712 uint8_t policy = AGG_BANDWIDTH;
5714 if (!strcmp(res->policy, "bandwidth"))
5715 policy = AGG_BANDWIDTH;
5716 else if (!strcmp(res->policy, "stable"))
5717 policy = AGG_STABLE;
5718 else if (!strcmp(res->policy, "count"))
5721 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5725 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5726 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5728 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5729 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5730 bonding, "bonding");
5732 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5733 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5734 agg_mode, "agg_mode");
5736 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5737 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5740 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5741 TOKEN_STRING_INITIALIZER(
5742 struct cmd_set_bonding_balance_xmit_policy_result,
5743 policy, "stable#bandwidth#count");
5745 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5746 .f = cmd_set_bonding_agg_mode,
5748 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5750 (void *)&cmd_set_bonding_agg_mode_set,
5751 (void *)&cmd_set_bonding_agg_mode_bonding,
5752 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5753 (void *)&cmd_set_bonding_agg_mode_portnum,
5754 (void *)&cmd_set_bonding_agg_mode_policy_string,
5760 #endif /* RTE_LIBRTE_PMD_BOND */
5762 /* *** SET FORWARDING MODE *** */
5763 struct cmd_set_fwd_mode_result {
5764 cmdline_fixed_string_t set;
5765 cmdline_fixed_string_t fwd;
5766 cmdline_fixed_string_t mode;
5769 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5770 __attribute__((unused)) struct cmdline *cl,
5771 __attribute__((unused)) void *data)
5773 struct cmd_set_fwd_mode_result *res = parsed_result;
5776 set_pkt_forwarding_mode(res->mode);
5779 cmdline_parse_token_string_t cmd_setfwd_set =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5781 cmdline_parse_token_string_t cmd_setfwd_fwd =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5783 cmdline_parse_token_string_t cmd_setfwd_mode =
5784 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5785 "" /* defined at init */);
5787 cmdline_parse_inst_t cmd_set_fwd_mode = {
5788 .f = cmd_set_fwd_mode_parsed,
5790 .help_str = NULL, /* defined at init */
5792 (void *)&cmd_setfwd_set,
5793 (void *)&cmd_setfwd_fwd,
5794 (void *)&cmd_setfwd_mode,
5799 static void cmd_set_fwd_mode_init(void)
5802 static char token[128];
5803 static char help[256];
5804 cmdline_parse_token_string_t *token_struct;
5806 modes = list_pkt_forwarding_modes();
5807 snprintf(help, sizeof(help), "set fwd %s: "
5808 "Set packet forwarding mode", modes);
5809 cmd_set_fwd_mode.help_str = help;
5811 /* string token separator is # */
5812 for (c = token; *modes != '\0'; modes++)
5817 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5818 token_struct->string_data.str = token;
5821 /* *** SET RETRY FORWARDING MODE *** */
5822 struct cmd_set_fwd_retry_mode_result {
5823 cmdline_fixed_string_t set;
5824 cmdline_fixed_string_t fwd;
5825 cmdline_fixed_string_t mode;
5826 cmdline_fixed_string_t retry;
5829 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5830 __attribute__((unused)) struct cmdline *cl,
5831 __attribute__((unused)) void *data)
5833 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5836 set_pkt_forwarding_mode(res->mode);
5839 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5840 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5842 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5843 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5845 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5846 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5848 "" /* defined at init */);
5849 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5853 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5854 .f = cmd_set_fwd_retry_mode_parsed,
5856 .help_str = NULL, /* defined at init */
5858 (void *)&cmd_setfwd_retry_set,
5859 (void *)&cmd_setfwd_retry_fwd,
5860 (void *)&cmd_setfwd_retry_mode,
5861 (void *)&cmd_setfwd_retry_retry,
5866 static void cmd_set_fwd_retry_mode_init(void)
5869 static char token[128];
5870 static char help[256];
5871 cmdline_parse_token_string_t *token_struct;
5873 modes = list_pkt_forwarding_retry_modes();
5874 snprintf(help, sizeof(help), "set fwd %s retry: "
5875 "Set packet forwarding mode with retry", modes);
5876 cmd_set_fwd_retry_mode.help_str = help;
5878 /* string token separator is # */
5879 for (c = token; *modes != '\0'; modes++)
5884 token_struct = (cmdline_parse_token_string_t *)
5885 cmd_set_fwd_retry_mode.tokens[2];
5886 token_struct->string_data.str = token;
5889 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5890 struct cmd_set_burst_tx_retry_result {
5891 cmdline_fixed_string_t set;
5892 cmdline_fixed_string_t burst;
5893 cmdline_fixed_string_t tx;
5894 cmdline_fixed_string_t delay;
5896 cmdline_fixed_string_t retry;
5900 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5901 __attribute__((unused)) struct cmdline *cl,
5902 __attribute__((unused)) void *data)
5904 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5906 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5907 && !strcmp(res->tx, "tx")) {
5908 if (!strcmp(res->delay, "delay"))
5909 burst_tx_delay_time = res->time;
5910 if (!strcmp(res->retry, "retry"))
5911 burst_tx_retry_num = res->retry_num;
5916 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5917 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5918 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5919 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5921 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5922 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5923 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5925 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5926 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5927 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5929 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5930 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5932 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5933 .f = cmd_set_burst_tx_retry_parsed,
5934 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5936 (void *)&cmd_set_burst_tx_retry_set,
5937 (void *)&cmd_set_burst_tx_retry_burst,
5938 (void *)&cmd_set_burst_tx_retry_tx,
5939 (void *)&cmd_set_burst_tx_retry_delay,
5940 (void *)&cmd_set_burst_tx_retry_time,
5941 (void *)&cmd_set_burst_tx_retry_retry,
5942 (void *)&cmd_set_burst_tx_retry_retry_num,
5947 /* *** SET PROMISC MODE *** */
5948 struct cmd_set_promisc_mode_result {
5949 cmdline_fixed_string_t set;
5950 cmdline_fixed_string_t promisc;
5951 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5952 uint16_t port_num; /* valid if "allports" argument == 0 */
5953 cmdline_fixed_string_t mode;
5956 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5957 __attribute__((unused)) struct cmdline *cl,
5960 struct cmd_set_promisc_mode_result *res = parsed_result;
5964 if (!strcmp(res->mode, "on"))
5971 RTE_ETH_FOREACH_DEV(i) {
5973 rte_eth_promiscuous_enable(i);
5975 rte_eth_promiscuous_disable(i);
5980 rte_eth_promiscuous_enable(res->port_num);
5982 rte_eth_promiscuous_disable(res->port_num);
5986 cmdline_parse_token_string_t cmd_setpromisc_set =
5987 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5988 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5989 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5991 cmdline_parse_token_string_t cmd_setpromisc_portall =
5992 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5994 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5995 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5997 cmdline_parse_token_string_t cmd_setpromisc_mode =
5998 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6001 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6002 .f = cmd_set_promisc_mode_parsed,
6004 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6006 (void *)&cmd_setpromisc_set,
6007 (void *)&cmd_setpromisc_promisc,
6008 (void *)&cmd_setpromisc_portall,
6009 (void *)&cmd_setpromisc_mode,
6014 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6015 .f = cmd_set_promisc_mode_parsed,
6017 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6019 (void *)&cmd_setpromisc_set,
6020 (void *)&cmd_setpromisc_promisc,
6021 (void *)&cmd_setpromisc_portnum,
6022 (void *)&cmd_setpromisc_mode,
6027 /* *** SET ALLMULTI MODE *** */
6028 struct cmd_set_allmulti_mode_result {
6029 cmdline_fixed_string_t set;
6030 cmdline_fixed_string_t allmulti;
6031 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6032 uint16_t port_num; /* valid if "allports" argument == 0 */
6033 cmdline_fixed_string_t mode;
6036 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6037 __attribute__((unused)) struct cmdline *cl,
6040 struct cmd_set_allmulti_mode_result *res = parsed_result;
6044 if (!strcmp(res->mode, "on"))
6051 RTE_ETH_FOREACH_DEV(i) {
6053 rte_eth_allmulticast_enable(i);
6055 rte_eth_allmulticast_disable(i);
6060 rte_eth_allmulticast_enable(res->port_num);
6062 rte_eth_allmulticast_disable(res->port_num);
6066 cmdline_parse_token_string_t cmd_setallmulti_set =
6067 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6068 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6069 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6071 cmdline_parse_token_string_t cmd_setallmulti_portall =
6072 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6074 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6075 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6077 cmdline_parse_token_string_t cmd_setallmulti_mode =
6078 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6081 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6082 .f = cmd_set_allmulti_mode_parsed,
6084 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6086 (void *)&cmd_setallmulti_set,
6087 (void *)&cmd_setallmulti_allmulti,
6088 (void *)&cmd_setallmulti_portall,
6089 (void *)&cmd_setallmulti_mode,
6094 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6095 .f = cmd_set_allmulti_mode_parsed,
6097 .help_str = "set allmulti <port_id> on|off: "
6098 "Set allmulti mode on port_id",
6100 (void *)&cmd_setallmulti_set,
6101 (void *)&cmd_setallmulti_allmulti,
6102 (void *)&cmd_setallmulti_portnum,
6103 (void *)&cmd_setallmulti_mode,
6108 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6109 struct cmd_link_flow_ctrl_set_result {
6110 cmdline_fixed_string_t set;
6111 cmdline_fixed_string_t flow_ctrl;
6112 cmdline_fixed_string_t rx;
6113 cmdline_fixed_string_t rx_lfc_mode;
6114 cmdline_fixed_string_t tx;
6115 cmdline_fixed_string_t tx_lfc_mode;
6116 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6117 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6118 cmdline_fixed_string_t autoneg_str;
6119 cmdline_fixed_string_t autoneg;
6120 cmdline_fixed_string_t hw_str;
6121 uint32_t high_water;
6122 cmdline_fixed_string_t lw_str;
6124 cmdline_fixed_string_t pt_str;
6125 uint16_t pause_time;
6126 cmdline_fixed_string_t xon_str;
6131 cmdline_parse_token_string_t cmd_lfc_set_set =
6132 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6134 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6135 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6136 flow_ctrl, "flow_ctrl");
6137 cmdline_parse_token_string_t cmd_lfc_set_rx =
6138 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6140 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6141 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6142 rx_lfc_mode, "on#off");
6143 cmdline_parse_token_string_t cmd_lfc_set_tx =
6144 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6146 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6147 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6148 tx_lfc_mode, "on#off");
6149 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6150 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6151 hw_str, "high_water");
6152 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6153 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6154 high_water, UINT32);
6155 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6156 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6157 lw_str, "low_water");
6158 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6159 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6161 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6162 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6163 pt_str, "pause_time");
6164 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6165 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6166 pause_time, UINT16);
6167 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6168 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6169 xon_str, "send_xon");
6170 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6171 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6173 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6174 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6175 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6176 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6177 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6178 mac_ctrl_frame_fwd_mode, "on#off");
6179 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6180 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6181 autoneg_str, "autoneg");
6182 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6183 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6185 cmdline_parse_token_num_t cmd_lfc_set_portid =
6186 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6189 /* forward declaration */
6191 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6194 cmdline_parse_inst_t cmd_link_flow_control_set = {
6195 .f = cmd_link_flow_ctrl_set_parsed,
6197 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6198 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6199 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6201 (void *)&cmd_lfc_set_set,
6202 (void *)&cmd_lfc_set_flow_ctrl,
6203 (void *)&cmd_lfc_set_rx,
6204 (void *)&cmd_lfc_set_rx_mode,
6205 (void *)&cmd_lfc_set_tx,
6206 (void *)&cmd_lfc_set_tx_mode,
6207 (void *)&cmd_lfc_set_high_water,
6208 (void *)&cmd_lfc_set_low_water,
6209 (void *)&cmd_lfc_set_pause_time,
6210 (void *)&cmd_lfc_set_send_xon,
6211 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6212 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6213 (void *)&cmd_lfc_set_autoneg_str,
6214 (void *)&cmd_lfc_set_autoneg,
6215 (void *)&cmd_lfc_set_portid,
6220 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6221 .f = cmd_link_flow_ctrl_set_parsed,
6222 .data = (void *)&cmd_link_flow_control_set_rx,
6223 .help_str = "set flow_ctrl rx on|off <port_id>: "
6224 "Change rx flow control parameter",
6226 (void *)&cmd_lfc_set_set,
6227 (void *)&cmd_lfc_set_flow_ctrl,
6228 (void *)&cmd_lfc_set_rx,
6229 (void *)&cmd_lfc_set_rx_mode,
6230 (void *)&cmd_lfc_set_portid,
6235 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6236 .f = cmd_link_flow_ctrl_set_parsed,
6237 .data = (void *)&cmd_link_flow_control_set_tx,
6238 .help_str = "set flow_ctrl tx on|off <port_id>: "
6239 "Change tx flow control parameter",
6241 (void *)&cmd_lfc_set_set,
6242 (void *)&cmd_lfc_set_flow_ctrl,
6243 (void *)&cmd_lfc_set_tx,
6244 (void *)&cmd_lfc_set_tx_mode,
6245 (void *)&cmd_lfc_set_portid,
6250 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6251 .f = cmd_link_flow_ctrl_set_parsed,
6252 .data = (void *)&cmd_link_flow_control_set_hw,
6253 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6254 "Change high water flow control parameter",
6256 (void *)&cmd_lfc_set_set,
6257 (void *)&cmd_lfc_set_flow_ctrl,
6258 (void *)&cmd_lfc_set_high_water_str,
6259 (void *)&cmd_lfc_set_high_water,
6260 (void *)&cmd_lfc_set_portid,
6265 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6266 .f = cmd_link_flow_ctrl_set_parsed,
6267 .data = (void *)&cmd_link_flow_control_set_lw,
6268 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6269 "Change low water flow control parameter",
6271 (void *)&cmd_lfc_set_set,
6272 (void *)&cmd_lfc_set_flow_ctrl,
6273 (void *)&cmd_lfc_set_low_water_str,
6274 (void *)&cmd_lfc_set_low_water,
6275 (void *)&cmd_lfc_set_portid,
6280 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6281 .f = cmd_link_flow_ctrl_set_parsed,
6282 .data = (void *)&cmd_link_flow_control_set_pt,
6283 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6284 "Change pause time flow control parameter",
6286 (void *)&cmd_lfc_set_set,
6287 (void *)&cmd_lfc_set_flow_ctrl,
6288 (void *)&cmd_lfc_set_pause_time_str,
6289 (void *)&cmd_lfc_set_pause_time,
6290 (void *)&cmd_lfc_set_portid,
6295 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6296 .f = cmd_link_flow_ctrl_set_parsed,
6297 .data = (void *)&cmd_link_flow_control_set_xon,
6298 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6299 "Change send_xon flow control parameter",
6301 (void *)&cmd_lfc_set_set,
6302 (void *)&cmd_lfc_set_flow_ctrl,
6303 (void *)&cmd_lfc_set_send_xon_str,
6304 (void *)&cmd_lfc_set_send_xon,
6305 (void *)&cmd_lfc_set_portid,
6310 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6311 .f = cmd_link_flow_ctrl_set_parsed,
6312 .data = (void *)&cmd_link_flow_control_set_macfwd,
6313 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6314 "Change mac ctrl fwd flow control parameter",
6316 (void *)&cmd_lfc_set_set,
6317 (void *)&cmd_lfc_set_flow_ctrl,
6318 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6319 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6320 (void *)&cmd_lfc_set_portid,
6325 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6326 .f = cmd_link_flow_ctrl_set_parsed,
6327 .data = (void *)&cmd_link_flow_control_set_autoneg,
6328 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6329 "Change autoneg flow control parameter",
6331 (void *)&cmd_lfc_set_set,
6332 (void *)&cmd_lfc_set_flow_ctrl,
6333 (void *)&cmd_lfc_set_autoneg_str,
6334 (void *)&cmd_lfc_set_autoneg,
6335 (void *)&cmd_lfc_set_portid,
6341 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6342 __attribute__((unused)) struct cmdline *cl,
6345 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6346 cmdline_parse_inst_t *cmd = data;
6347 struct rte_eth_fc_conf fc_conf;
6353 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6354 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6355 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6356 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6358 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6359 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6362 /* Partial command line, retrieve current configuration */
6364 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6366 printf("cannot get current flow ctrl parameters, return"
6367 "code = %d\n", ret);
6371 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6372 (fc_conf.mode == RTE_FC_FULL))
6374 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6375 (fc_conf.mode == RTE_FC_FULL))
6379 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6380 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6382 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6383 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6385 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6387 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6388 fc_conf.high_water = res->high_water;
6390 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6391 fc_conf.low_water = res->low_water;
6393 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6394 fc_conf.pause_time = res->pause_time;
6396 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6397 fc_conf.send_xon = res->send_xon;
6399 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6400 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6401 fc_conf.mac_ctrl_frame_fwd = 1;
6403 fc_conf.mac_ctrl_frame_fwd = 0;
6406 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6407 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6409 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6411 printf("bad flow contrl parameter, return code = %d \n", ret);
6414 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6415 struct cmd_priority_flow_ctrl_set_result {
6416 cmdline_fixed_string_t set;
6417 cmdline_fixed_string_t pfc_ctrl;
6418 cmdline_fixed_string_t rx;
6419 cmdline_fixed_string_t rx_pfc_mode;
6420 cmdline_fixed_string_t tx;
6421 cmdline_fixed_string_t tx_pfc_mode;
6422 uint32_t high_water;
6424 uint16_t pause_time;
6430 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6431 __attribute__((unused)) struct cmdline *cl,
6432 __attribute__((unused)) void *data)
6434 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6435 struct rte_eth_pfc_conf pfc_conf;
6436 int rx_fc_enable, tx_fc_enable;
6440 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6441 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6442 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6443 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6445 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6446 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6449 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6450 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6451 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6452 pfc_conf.fc.high_water = res->high_water;
6453 pfc_conf.fc.low_water = res->low_water;
6454 pfc_conf.fc.pause_time = res->pause_time;
6455 pfc_conf.priority = res->priority;
6457 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6459 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6462 cmdline_parse_token_string_t cmd_pfc_set_set =
6463 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6465 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6466 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6467 pfc_ctrl, "pfc_ctrl");
6468 cmdline_parse_token_string_t cmd_pfc_set_rx =
6469 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6471 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6472 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6473 rx_pfc_mode, "on#off");
6474 cmdline_parse_token_string_t cmd_pfc_set_tx =
6475 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6477 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6478 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6479 tx_pfc_mode, "on#off");
6480 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6481 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6482 high_water, UINT32);
6483 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6484 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6486 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6487 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6488 pause_time, UINT16);
6489 cmdline_parse_token_num_t cmd_pfc_set_priority =
6490 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6492 cmdline_parse_token_num_t cmd_pfc_set_portid =
6493 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6496 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6497 .f = cmd_priority_flow_ctrl_set_parsed,
6499 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6500 "<pause_time> <priority> <port_id>: "
6501 "Configure the Ethernet priority flow control",
6503 (void *)&cmd_pfc_set_set,
6504 (void *)&cmd_pfc_set_flow_ctrl,
6505 (void *)&cmd_pfc_set_rx,
6506 (void *)&cmd_pfc_set_rx_mode,
6507 (void *)&cmd_pfc_set_tx,
6508 (void *)&cmd_pfc_set_tx_mode,
6509 (void *)&cmd_pfc_set_high_water,
6510 (void *)&cmd_pfc_set_low_water,
6511 (void *)&cmd_pfc_set_pause_time,
6512 (void *)&cmd_pfc_set_priority,
6513 (void *)&cmd_pfc_set_portid,
6518 /* *** RESET CONFIGURATION *** */
6519 struct cmd_reset_result {
6520 cmdline_fixed_string_t reset;
6521 cmdline_fixed_string_t def;
6524 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6526 __attribute__((unused)) void *data)
6528 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6529 set_def_fwd_config();
6532 cmdline_parse_token_string_t cmd_reset_set =
6533 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6534 cmdline_parse_token_string_t cmd_reset_def =
6535 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6538 cmdline_parse_inst_t cmd_reset = {
6539 .f = cmd_reset_parsed,
6541 .help_str = "set default: Reset default forwarding configuration",
6543 (void *)&cmd_reset_set,
6544 (void *)&cmd_reset_def,
6549 /* *** START FORWARDING *** */
6550 struct cmd_start_result {
6551 cmdline_fixed_string_t start;
6554 cmdline_parse_token_string_t cmd_start_start =
6555 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6557 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6558 __attribute__((unused)) struct cmdline *cl,
6559 __attribute__((unused)) void *data)
6561 start_packet_forwarding(0);
6564 cmdline_parse_inst_t cmd_start = {
6565 .f = cmd_start_parsed,
6567 .help_str = "start: Start packet forwarding",
6569 (void *)&cmd_start_start,
6574 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6575 struct cmd_start_tx_first_result {
6576 cmdline_fixed_string_t start;
6577 cmdline_fixed_string_t tx_first;
6581 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6582 __attribute__((unused)) struct cmdline *cl,
6583 __attribute__((unused)) void *data)
6585 start_packet_forwarding(1);
6588 cmdline_parse_token_string_t cmd_start_tx_first_start =
6589 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6591 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6592 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6593 tx_first, "tx_first");
6595 cmdline_parse_inst_t cmd_start_tx_first = {
6596 .f = cmd_start_tx_first_parsed,
6598 .help_str = "start tx_first: Start packet forwarding, "
6599 "after sending 1 burst of packets",
6601 (void *)&cmd_start_tx_first_start,
6602 (void *)&cmd_start_tx_first_tx_first,
6607 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6608 struct cmd_start_tx_first_n_result {
6609 cmdline_fixed_string_t start;
6610 cmdline_fixed_string_t tx_first;
6615 cmd_start_tx_first_n_parsed(void *parsed_result,
6616 __attribute__((unused)) struct cmdline *cl,
6617 __attribute__((unused)) void *data)
6619 struct cmd_start_tx_first_n_result *res = parsed_result;
6621 start_packet_forwarding(res->tx_num);
6624 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6625 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6627 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6628 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6629 tx_first, "tx_first");
6630 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6631 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6634 cmdline_parse_inst_t cmd_start_tx_first_n = {
6635 .f = cmd_start_tx_first_n_parsed,
6637 .help_str = "start tx_first <num>: "
6638 "packet forwarding, after sending <num> bursts of packets",
6640 (void *)&cmd_start_tx_first_n_start,
6641 (void *)&cmd_start_tx_first_n_tx_first,
6642 (void *)&cmd_start_tx_first_n_tx_num,
6647 /* *** SET LINK UP *** */
6648 struct cmd_set_link_up_result {
6649 cmdline_fixed_string_t set;
6650 cmdline_fixed_string_t link_up;
6651 cmdline_fixed_string_t port;
6655 cmdline_parse_token_string_t cmd_set_link_up_set =
6656 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6657 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6658 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6660 cmdline_parse_token_string_t cmd_set_link_up_port =
6661 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6662 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6663 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6665 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6666 __attribute__((unused)) struct cmdline *cl,
6667 __attribute__((unused)) void *data)
6669 struct cmd_set_link_up_result *res = parsed_result;
6670 dev_set_link_up(res->port_id);
6673 cmdline_parse_inst_t cmd_set_link_up = {
6674 .f = cmd_set_link_up_parsed,
6676 .help_str = "set link-up port <port id>",
6678 (void *)&cmd_set_link_up_set,
6679 (void *)&cmd_set_link_up_link_up,
6680 (void *)&cmd_set_link_up_port,
6681 (void *)&cmd_set_link_up_port_id,
6686 /* *** SET LINK DOWN *** */
6687 struct cmd_set_link_down_result {
6688 cmdline_fixed_string_t set;
6689 cmdline_fixed_string_t link_down;
6690 cmdline_fixed_string_t port;
6694 cmdline_parse_token_string_t cmd_set_link_down_set =
6695 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6696 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6697 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6699 cmdline_parse_token_string_t cmd_set_link_down_port =
6700 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6701 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6702 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6704 static void cmd_set_link_down_parsed(
6705 __attribute__((unused)) void *parsed_result,
6706 __attribute__((unused)) struct cmdline *cl,
6707 __attribute__((unused)) void *data)
6709 struct cmd_set_link_down_result *res = parsed_result;
6710 dev_set_link_down(res->port_id);
6713 cmdline_parse_inst_t cmd_set_link_down = {
6714 .f = cmd_set_link_down_parsed,
6716 .help_str = "set link-down port <port id>",
6718 (void *)&cmd_set_link_down_set,
6719 (void *)&cmd_set_link_down_link_down,
6720 (void *)&cmd_set_link_down_port,
6721 (void *)&cmd_set_link_down_port_id,
6726 /* *** SHOW CFG *** */
6727 struct cmd_showcfg_result {
6728 cmdline_fixed_string_t show;
6729 cmdline_fixed_string_t cfg;
6730 cmdline_fixed_string_t what;
6733 static void cmd_showcfg_parsed(void *parsed_result,
6734 __attribute__((unused)) struct cmdline *cl,
6735 __attribute__((unused)) void *data)
6737 struct cmd_showcfg_result *res = parsed_result;
6738 if (!strcmp(res->what, "rxtx"))
6739 rxtx_config_display();
6740 else if (!strcmp(res->what, "cores"))
6741 fwd_lcores_config_display();
6742 else if (!strcmp(res->what, "fwd"))
6743 pkt_fwd_config_display(&cur_fwd_config);
6744 else if (!strcmp(res->what, "txpkts"))
6745 show_tx_pkt_segments();
6748 cmdline_parse_token_string_t cmd_showcfg_show =
6749 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6750 cmdline_parse_token_string_t cmd_showcfg_port =
6751 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6752 cmdline_parse_token_string_t cmd_showcfg_what =
6753 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6754 "rxtx#cores#fwd#txpkts");
6756 cmdline_parse_inst_t cmd_showcfg = {
6757 .f = cmd_showcfg_parsed,
6759 .help_str = "show config rxtx|cores|fwd|txpkts",
6761 (void *)&cmd_showcfg_show,
6762 (void *)&cmd_showcfg_port,
6763 (void *)&cmd_showcfg_what,
6768 /* *** SHOW ALL PORT INFO *** */
6769 struct cmd_showportall_result {
6770 cmdline_fixed_string_t show;
6771 cmdline_fixed_string_t port;
6772 cmdline_fixed_string_t what;
6773 cmdline_fixed_string_t all;
6776 static void cmd_showportall_parsed(void *parsed_result,
6777 __attribute__((unused)) struct cmdline *cl,
6778 __attribute__((unused)) void *data)
6782 struct cmd_showportall_result *res = parsed_result;
6783 if (!strcmp(res->show, "clear")) {
6784 if (!strcmp(res->what, "stats"))
6785 RTE_ETH_FOREACH_DEV(i)
6787 else if (!strcmp(res->what, "xstats"))
6788 RTE_ETH_FOREACH_DEV(i)
6789 nic_xstats_clear(i);
6790 } else if (!strcmp(res->what, "info"))
6791 RTE_ETH_FOREACH_DEV(i)
6792 port_infos_display(i);
6793 else if (!strcmp(res->what, "stats"))
6794 RTE_ETH_FOREACH_DEV(i)
6795 nic_stats_display(i);
6796 else if (!strcmp(res->what, "xstats"))
6797 RTE_ETH_FOREACH_DEV(i)
6798 nic_xstats_display(i);
6799 else if (!strcmp(res->what, "fdir"))
6800 RTE_ETH_FOREACH_DEV(i)
6802 else if (!strcmp(res->what, "stat_qmap"))
6803 RTE_ETH_FOREACH_DEV(i)
6804 nic_stats_mapping_display(i);
6805 else if (!strcmp(res->what, "dcb_tc"))
6806 RTE_ETH_FOREACH_DEV(i)
6807 port_dcb_info_display(i);
6808 else if (!strcmp(res->what, "cap"))
6809 RTE_ETH_FOREACH_DEV(i)
6810 port_offload_cap_display(i);
6813 cmdline_parse_token_string_t cmd_showportall_show =
6814 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6816 cmdline_parse_token_string_t cmd_showportall_port =
6817 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6818 cmdline_parse_token_string_t cmd_showportall_what =
6819 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6820 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6821 cmdline_parse_token_string_t cmd_showportall_all =
6822 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6823 cmdline_parse_inst_t cmd_showportall = {
6824 .f = cmd_showportall_parsed,
6826 .help_str = "show|clear port "
6827 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6829 (void *)&cmd_showportall_show,
6830 (void *)&cmd_showportall_port,
6831 (void *)&cmd_showportall_what,
6832 (void *)&cmd_showportall_all,
6837 /* *** SHOW PORT INFO *** */
6838 struct cmd_showport_result {
6839 cmdline_fixed_string_t show;
6840 cmdline_fixed_string_t port;
6841 cmdline_fixed_string_t what;
6845 static void cmd_showport_parsed(void *parsed_result,
6846 __attribute__((unused)) struct cmdline *cl,
6847 __attribute__((unused)) void *data)
6849 struct cmd_showport_result *res = parsed_result;
6850 if (!strcmp(res->show, "clear")) {
6851 if (!strcmp(res->what, "stats"))
6852 nic_stats_clear(res->portnum);
6853 else if (!strcmp(res->what, "xstats"))
6854 nic_xstats_clear(res->portnum);
6855 } else if (!strcmp(res->what, "info"))
6856 port_infos_display(res->portnum);
6857 else if (!strcmp(res->what, "stats"))
6858 nic_stats_display(res->portnum);
6859 else if (!strcmp(res->what, "xstats"))
6860 nic_xstats_display(res->portnum);
6861 else if (!strcmp(res->what, "fdir"))
6862 fdir_get_infos(res->portnum);
6863 else if (!strcmp(res->what, "stat_qmap"))
6864 nic_stats_mapping_display(res->portnum);
6865 else if (!strcmp(res->what, "dcb_tc"))
6866 port_dcb_info_display(res->portnum);
6867 else if (!strcmp(res->what, "cap"))
6868 port_offload_cap_display(res->portnum);
6871 cmdline_parse_token_string_t cmd_showport_show =
6872 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6874 cmdline_parse_token_string_t cmd_showport_port =
6875 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6876 cmdline_parse_token_string_t cmd_showport_what =
6877 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6878 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6879 cmdline_parse_token_num_t cmd_showport_portnum =
6880 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6882 cmdline_parse_inst_t cmd_showport = {
6883 .f = cmd_showport_parsed,
6885 .help_str = "show|clear port "
6886 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6889 (void *)&cmd_showport_show,
6890 (void *)&cmd_showport_port,
6891 (void *)&cmd_showport_what,
6892 (void *)&cmd_showport_portnum,
6897 /* *** SHOW QUEUE INFO *** */
6898 struct cmd_showqueue_result {
6899 cmdline_fixed_string_t show;
6900 cmdline_fixed_string_t type;
6901 cmdline_fixed_string_t what;
6907 cmd_showqueue_parsed(void *parsed_result,
6908 __attribute__((unused)) struct cmdline *cl,
6909 __attribute__((unused)) void *data)
6911 struct cmd_showqueue_result *res = parsed_result;
6913 if (!strcmp(res->type, "rxq"))
6914 rx_queue_infos_display(res->portnum, res->queuenum);
6915 else if (!strcmp(res->type, "txq"))
6916 tx_queue_infos_display(res->portnum, res->queuenum);
6919 cmdline_parse_token_string_t cmd_showqueue_show =
6920 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6921 cmdline_parse_token_string_t cmd_showqueue_type =
6922 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6923 cmdline_parse_token_string_t cmd_showqueue_what =
6924 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6925 cmdline_parse_token_num_t cmd_showqueue_portnum =
6926 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6927 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6928 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6930 cmdline_parse_inst_t cmd_showqueue = {
6931 .f = cmd_showqueue_parsed,
6933 .help_str = "show rxq|txq info <port_id> <queue_id>",
6935 (void *)&cmd_showqueue_show,
6936 (void *)&cmd_showqueue_type,
6937 (void *)&cmd_showqueue_what,
6938 (void *)&cmd_showqueue_portnum,
6939 (void *)&cmd_showqueue_queuenum,
6944 /* *** READ PORT REGISTER *** */
6945 struct cmd_read_reg_result {
6946 cmdline_fixed_string_t read;
6947 cmdline_fixed_string_t reg;
6953 cmd_read_reg_parsed(void *parsed_result,
6954 __attribute__((unused)) struct cmdline *cl,
6955 __attribute__((unused)) void *data)
6957 struct cmd_read_reg_result *res = parsed_result;
6958 port_reg_display(res->port_id, res->reg_off);
6961 cmdline_parse_token_string_t cmd_read_reg_read =
6962 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6963 cmdline_parse_token_string_t cmd_read_reg_reg =
6964 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6965 cmdline_parse_token_num_t cmd_read_reg_port_id =
6966 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6967 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6968 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6970 cmdline_parse_inst_t cmd_read_reg = {
6971 .f = cmd_read_reg_parsed,
6973 .help_str = "read reg <port_id> <reg_off>",
6975 (void *)&cmd_read_reg_read,
6976 (void *)&cmd_read_reg_reg,
6977 (void *)&cmd_read_reg_port_id,
6978 (void *)&cmd_read_reg_reg_off,
6983 /* *** READ PORT REGISTER BIT FIELD *** */
6984 struct cmd_read_reg_bit_field_result {
6985 cmdline_fixed_string_t read;
6986 cmdline_fixed_string_t regfield;
6994 cmd_read_reg_bit_field_parsed(void *parsed_result,
6995 __attribute__((unused)) struct cmdline *cl,
6996 __attribute__((unused)) void *data)
6998 struct cmd_read_reg_bit_field_result *res = parsed_result;
6999 port_reg_bit_field_display(res->port_id, res->reg_off,
7000 res->bit1_pos, res->bit2_pos);
7003 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7004 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7006 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7007 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7008 regfield, "regfield");
7009 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7010 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7012 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7013 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7015 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7016 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7018 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7019 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7022 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7023 .f = cmd_read_reg_bit_field_parsed,
7025 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7026 "Read register bit field between bit_x and bit_y included",
7028 (void *)&cmd_read_reg_bit_field_read,
7029 (void *)&cmd_read_reg_bit_field_regfield,
7030 (void *)&cmd_read_reg_bit_field_port_id,
7031 (void *)&cmd_read_reg_bit_field_reg_off,
7032 (void *)&cmd_read_reg_bit_field_bit1_pos,
7033 (void *)&cmd_read_reg_bit_field_bit2_pos,
7038 /* *** READ PORT REGISTER BIT *** */
7039 struct cmd_read_reg_bit_result {
7040 cmdline_fixed_string_t read;
7041 cmdline_fixed_string_t regbit;
7048 cmd_read_reg_bit_parsed(void *parsed_result,
7049 __attribute__((unused)) struct cmdline *cl,
7050 __attribute__((unused)) void *data)
7052 struct cmd_read_reg_bit_result *res = parsed_result;
7053 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7056 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7057 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7058 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7059 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7061 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7062 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7063 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7064 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7065 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7066 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7068 cmdline_parse_inst_t cmd_read_reg_bit = {
7069 .f = cmd_read_reg_bit_parsed,
7071 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7073 (void *)&cmd_read_reg_bit_read,
7074 (void *)&cmd_read_reg_bit_regbit,
7075 (void *)&cmd_read_reg_bit_port_id,
7076 (void *)&cmd_read_reg_bit_reg_off,
7077 (void *)&cmd_read_reg_bit_bit_pos,
7082 /* *** WRITE PORT REGISTER *** */
7083 struct cmd_write_reg_result {
7084 cmdline_fixed_string_t write;
7085 cmdline_fixed_string_t reg;
7092 cmd_write_reg_parsed(void *parsed_result,
7093 __attribute__((unused)) struct cmdline *cl,
7094 __attribute__((unused)) void *data)
7096 struct cmd_write_reg_result *res = parsed_result;
7097 port_reg_set(res->port_id, res->reg_off, res->value);
7100 cmdline_parse_token_string_t cmd_write_reg_write =
7101 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7102 cmdline_parse_token_string_t cmd_write_reg_reg =
7103 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7104 cmdline_parse_token_num_t cmd_write_reg_port_id =
7105 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7106 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7107 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7108 cmdline_parse_token_num_t cmd_write_reg_value =
7109 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7111 cmdline_parse_inst_t cmd_write_reg = {
7112 .f = cmd_write_reg_parsed,
7114 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7116 (void *)&cmd_write_reg_write,
7117 (void *)&cmd_write_reg_reg,
7118 (void *)&cmd_write_reg_port_id,
7119 (void *)&cmd_write_reg_reg_off,
7120 (void *)&cmd_write_reg_value,
7125 /* *** WRITE PORT REGISTER BIT FIELD *** */
7126 struct cmd_write_reg_bit_field_result {
7127 cmdline_fixed_string_t write;
7128 cmdline_fixed_string_t regfield;
7137 cmd_write_reg_bit_field_parsed(void *parsed_result,
7138 __attribute__((unused)) struct cmdline *cl,
7139 __attribute__((unused)) void *data)
7141 struct cmd_write_reg_bit_field_result *res = parsed_result;
7142 port_reg_bit_field_set(res->port_id, res->reg_off,
7143 res->bit1_pos, res->bit2_pos, res->value);
7146 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7147 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7149 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7150 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7151 regfield, "regfield");
7152 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7153 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7155 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7156 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7158 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7159 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7161 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7162 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7164 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7165 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7168 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7169 .f = cmd_write_reg_bit_field_parsed,
7171 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7173 "Set register bit field between bit_x and bit_y included",
7175 (void *)&cmd_write_reg_bit_field_write,
7176 (void *)&cmd_write_reg_bit_field_regfield,
7177 (void *)&cmd_write_reg_bit_field_port_id,
7178 (void *)&cmd_write_reg_bit_field_reg_off,
7179 (void *)&cmd_write_reg_bit_field_bit1_pos,
7180 (void *)&cmd_write_reg_bit_field_bit2_pos,
7181 (void *)&cmd_write_reg_bit_field_value,
7186 /* *** WRITE PORT REGISTER BIT *** */
7187 struct cmd_write_reg_bit_result {
7188 cmdline_fixed_string_t write;
7189 cmdline_fixed_string_t regbit;
7197 cmd_write_reg_bit_parsed(void *parsed_result,
7198 __attribute__((unused)) struct cmdline *cl,
7199 __attribute__((unused)) void *data)
7201 struct cmd_write_reg_bit_result *res = parsed_result;
7202 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7205 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7206 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7208 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7209 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7211 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7212 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7213 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7214 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7215 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7216 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7217 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7218 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7220 cmdline_parse_inst_t cmd_write_reg_bit = {
7221 .f = cmd_write_reg_bit_parsed,
7223 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7226 (void *)&cmd_write_reg_bit_write,
7227 (void *)&cmd_write_reg_bit_regbit,
7228 (void *)&cmd_write_reg_bit_port_id,
7229 (void *)&cmd_write_reg_bit_reg_off,
7230 (void *)&cmd_write_reg_bit_bit_pos,
7231 (void *)&cmd_write_reg_bit_value,
7236 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7237 struct cmd_read_rxd_txd_result {
7238 cmdline_fixed_string_t read;
7239 cmdline_fixed_string_t rxd_txd;
7246 cmd_read_rxd_txd_parsed(void *parsed_result,
7247 __attribute__((unused)) struct cmdline *cl,
7248 __attribute__((unused)) void *data)
7250 struct cmd_read_rxd_txd_result *res = parsed_result;
7252 if (!strcmp(res->rxd_txd, "rxd"))
7253 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7254 else if (!strcmp(res->rxd_txd, "txd"))
7255 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7258 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7259 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7260 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7261 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7263 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7264 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7265 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7266 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7267 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7268 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7270 cmdline_parse_inst_t cmd_read_rxd_txd = {
7271 .f = cmd_read_rxd_txd_parsed,
7273 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7275 (void *)&cmd_read_rxd_txd_read,
7276 (void *)&cmd_read_rxd_txd_rxd_txd,
7277 (void *)&cmd_read_rxd_txd_port_id,
7278 (void *)&cmd_read_rxd_txd_queue_id,
7279 (void *)&cmd_read_rxd_txd_desc_id,
7285 struct cmd_quit_result {
7286 cmdline_fixed_string_t quit;
7289 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7291 __attribute__((unused)) void *data)
7297 cmdline_parse_token_string_t cmd_quit_quit =
7298 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7300 cmdline_parse_inst_t cmd_quit = {
7301 .f = cmd_quit_parsed,
7303 .help_str = "quit: Exit application",
7305 (void *)&cmd_quit_quit,
7310 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7311 struct cmd_mac_addr_result {
7312 cmdline_fixed_string_t mac_addr_cmd;
7313 cmdline_fixed_string_t what;
7315 struct ether_addr address;
7318 static void cmd_mac_addr_parsed(void *parsed_result,
7319 __attribute__((unused)) struct cmdline *cl,
7320 __attribute__((unused)) void *data)
7322 struct cmd_mac_addr_result *res = parsed_result;
7325 if (strcmp(res->what, "add") == 0)
7326 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7327 else if (strcmp(res->what, "set") == 0)
7328 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7331 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7333 /* check the return value and print it if is < 0 */
7335 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7339 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7340 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7342 cmdline_parse_token_string_t cmd_mac_addr_what =
7343 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7345 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7346 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7348 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7349 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7351 cmdline_parse_inst_t cmd_mac_addr = {
7352 .f = cmd_mac_addr_parsed,
7354 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7355 "Add/Remove/Set MAC address on port_id",
7357 (void *)&cmd_mac_addr_cmd,
7358 (void *)&cmd_mac_addr_what,
7359 (void *)&cmd_mac_addr_portnum,
7360 (void *)&cmd_mac_addr_addr,
7365 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7366 struct cmd_eth_peer_result {
7367 cmdline_fixed_string_t set;
7368 cmdline_fixed_string_t eth_peer;
7370 cmdline_fixed_string_t peer_addr;
7373 static void cmd_set_eth_peer_parsed(void *parsed_result,
7374 __attribute__((unused)) struct cmdline *cl,
7375 __attribute__((unused)) void *data)
7377 struct cmd_eth_peer_result *res = parsed_result;
7379 if (test_done == 0) {
7380 printf("Please stop forwarding first\n");
7383 if (!strcmp(res->eth_peer, "eth-peer")) {
7384 set_fwd_eth_peer(res->port_id, res->peer_addr);
7388 cmdline_parse_token_string_t cmd_eth_peer_set =
7389 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7390 cmdline_parse_token_string_t cmd_eth_peer =
7391 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7392 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7393 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7394 cmdline_parse_token_string_t cmd_eth_peer_addr =
7395 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7397 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7398 .f = cmd_set_eth_peer_parsed,
7400 .help_str = "set eth-peer <port_id> <peer_mac>",
7402 (void *)&cmd_eth_peer_set,
7403 (void *)&cmd_eth_peer,
7404 (void *)&cmd_eth_peer_port_id,
7405 (void *)&cmd_eth_peer_addr,
7410 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7411 struct cmd_set_qmap_result {
7412 cmdline_fixed_string_t set;
7413 cmdline_fixed_string_t qmap;
7414 cmdline_fixed_string_t what;
7421 cmd_set_qmap_parsed(void *parsed_result,
7422 __attribute__((unused)) struct cmdline *cl,
7423 __attribute__((unused)) void *data)
7425 struct cmd_set_qmap_result *res = parsed_result;
7426 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7428 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7431 cmdline_parse_token_string_t cmd_setqmap_set =
7432 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7434 cmdline_parse_token_string_t cmd_setqmap_qmap =
7435 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7437 cmdline_parse_token_string_t cmd_setqmap_what =
7438 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7440 cmdline_parse_token_num_t cmd_setqmap_portid =
7441 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7443 cmdline_parse_token_num_t cmd_setqmap_queueid =
7444 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7446 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7447 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7450 cmdline_parse_inst_t cmd_set_qmap = {
7451 .f = cmd_set_qmap_parsed,
7453 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7454 "Set statistics mapping value on tx|rx queue_id of port_id",
7456 (void *)&cmd_setqmap_set,
7457 (void *)&cmd_setqmap_qmap,
7458 (void *)&cmd_setqmap_what,
7459 (void *)&cmd_setqmap_portid,
7460 (void *)&cmd_setqmap_queueid,
7461 (void *)&cmd_setqmap_mapvalue,
7466 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7467 struct cmd_set_xstats_hide_zero_result {
7468 cmdline_fixed_string_t keyword;
7469 cmdline_fixed_string_t name;
7470 cmdline_fixed_string_t on_off;
7474 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7475 __attribute__((unused)) struct cmdline *cl,
7476 __attribute__((unused)) void *data)
7478 struct cmd_set_xstats_hide_zero_result *res;
7479 uint16_t on_off = 0;
7481 res = parsed_result;
7482 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7483 set_xstats_hide_zero(on_off);
7486 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7487 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7489 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7490 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7491 name, "xstats-hide-zero");
7492 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7493 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7496 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7497 .f = cmd_set_xstats_hide_zero_parsed,
7499 .help_str = "set xstats-hide-zero on|off",
7501 (void *)&cmd_set_xstats_hide_zero_keyword,
7502 (void *)&cmd_set_xstats_hide_zero_name,
7503 (void *)&cmd_set_xstats_hide_zero_on_off,
7508 /* *** CONFIGURE UNICAST HASH TABLE *** */
7509 struct cmd_set_uc_hash_table {
7510 cmdline_fixed_string_t set;
7511 cmdline_fixed_string_t port;
7513 cmdline_fixed_string_t what;
7514 struct ether_addr address;
7515 cmdline_fixed_string_t mode;
7519 cmd_set_uc_hash_parsed(void *parsed_result,
7520 __attribute__((unused)) struct cmdline *cl,
7521 __attribute__((unused)) void *data)
7524 struct cmd_set_uc_hash_table *res = parsed_result;
7526 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7528 if (strcmp(res->what, "uta") == 0)
7529 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7530 &res->address,(uint8_t)is_on);
7532 printf("bad unicast hash table parameter, return code = %d \n", ret);
7536 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7537 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7539 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7540 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7542 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7543 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7545 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7546 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7548 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7549 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7551 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7552 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7555 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7556 .f = cmd_set_uc_hash_parsed,
7558 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7560 (void *)&cmd_set_uc_hash_set,
7561 (void *)&cmd_set_uc_hash_port,
7562 (void *)&cmd_set_uc_hash_portid,
7563 (void *)&cmd_set_uc_hash_what,
7564 (void *)&cmd_set_uc_hash_mac,
7565 (void *)&cmd_set_uc_hash_mode,
7570 struct cmd_set_uc_all_hash_table {
7571 cmdline_fixed_string_t set;
7572 cmdline_fixed_string_t port;
7574 cmdline_fixed_string_t what;
7575 cmdline_fixed_string_t value;
7576 cmdline_fixed_string_t mode;
7580 cmd_set_uc_all_hash_parsed(void *parsed_result,
7581 __attribute__((unused)) struct cmdline *cl,
7582 __attribute__((unused)) void *data)
7585 struct cmd_set_uc_all_hash_table *res = parsed_result;
7587 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7589 if ((strcmp(res->what, "uta") == 0) &&
7590 (strcmp(res->value, "all") == 0))
7591 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7593 printf("bad unicast hash table parameter,"
7594 "return code = %d \n", ret);
7597 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7598 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7600 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7601 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7603 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7604 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7606 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7607 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7609 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7610 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7612 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7613 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7616 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7617 .f = cmd_set_uc_all_hash_parsed,
7619 .help_str = "set port <port_id> uta all on|off",
7621 (void *)&cmd_set_uc_all_hash_set,
7622 (void *)&cmd_set_uc_all_hash_port,
7623 (void *)&cmd_set_uc_all_hash_portid,
7624 (void *)&cmd_set_uc_all_hash_what,
7625 (void *)&cmd_set_uc_all_hash_value,
7626 (void *)&cmd_set_uc_all_hash_mode,
7631 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7632 struct cmd_set_vf_macvlan_filter {
7633 cmdline_fixed_string_t set;
7634 cmdline_fixed_string_t port;
7636 cmdline_fixed_string_t vf;
7638 struct ether_addr address;
7639 cmdline_fixed_string_t filter_type;
7640 cmdline_fixed_string_t mode;
7644 cmd_set_vf_macvlan_parsed(void *parsed_result,
7645 __attribute__((unused)) struct cmdline *cl,
7646 __attribute__((unused)) void *data)
7649 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7650 struct rte_eth_mac_filter filter;
7652 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7654 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7656 /* set VF MAC filter */
7660 filter.dst_id = res->vf_id;
7662 if (!strcmp(res->filter_type, "exact-mac"))
7663 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7664 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7665 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7666 else if (!strcmp(res->filter_type, "hashmac"))
7667 filter.filter_type = RTE_MAC_HASH_MATCH;
7668 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7669 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7671 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7674 ret = rte_eth_dev_filter_ctrl(res->port_id,
7675 RTE_ETH_FILTER_MACVLAN,
7679 ret = rte_eth_dev_filter_ctrl(res->port_id,
7680 RTE_ETH_FILTER_MACVLAN,
7681 RTE_ETH_FILTER_DELETE,
7685 printf("bad set MAC hash parameter, return code = %d\n", ret);
7689 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7690 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7692 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7693 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7695 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7696 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7698 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7699 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7701 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7702 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7704 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7705 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7707 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7708 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7709 filter_type, "exact-mac#exact-mac-vlan"
7710 "#hashmac#hashmac-vlan");
7711 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7712 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7715 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7716 .f = cmd_set_vf_macvlan_parsed,
7718 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7719 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7720 "Exact match rule: exact match of MAC or MAC and VLAN; "
7721 "hash match rule: hash match of MAC and exact match of VLAN",
7723 (void *)&cmd_set_vf_macvlan_set,
7724 (void *)&cmd_set_vf_macvlan_port,
7725 (void *)&cmd_set_vf_macvlan_portid,
7726 (void *)&cmd_set_vf_macvlan_vf,
7727 (void *)&cmd_set_vf_macvlan_vf_id,
7728 (void *)&cmd_set_vf_macvlan_mac,
7729 (void *)&cmd_set_vf_macvlan_filter_type,
7730 (void *)&cmd_set_vf_macvlan_mode,
7735 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7736 struct cmd_set_vf_traffic {
7737 cmdline_fixed_string_t set;
7738 cmdline_fixed_string_t port;
7740 cmdline_fixed_string_t vf;
7742 cmdline_fixed_string_t what;
7743 cmdline_fixed_string_t mode;
7747 cmd_set_vf_traffic_parsed(void *parsed_result,
7748 __attribute__((unused)) struct cmdline *cl,
7749 __attribute__((unused)) void *data)
7751 struct cmd_set_vf_traffic *res = parsed_result;
7752 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7753 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7755 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7758 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7759 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7761 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7762 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7764 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7765 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7767 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7768 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7770 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7771 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7773 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7774 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7776 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7777 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7780 cmdline_parse_inst_t cmd_set_vf_traffic = {
7781 .f = cmd_set_vf_traffic_parsed,
7783 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7785 (void *)&cmd_setvf_traffic_set,
7786 (void *)&cmd_setvf_traffic_port,
7787 (void *)&cmd_setvf_traffic_portid,
7788 (void *)&cmd_setvf_traffic_vf,
7789 (void *)&cmd_setvf_traffic_vfid,
7790 (void *)&cmd_setvf_traffic_what,
7791 (void *)&cmd_setvf_traffic_mode,
7796 /* *** CONFIGURE VF RECEIVE MODE *** */
7797 struct cmd_set_vf_rxmode {
7798 cmdline_fixed_string_t set;
7799 cmdline_fixed_string_t port;
7801 cmdline_fixed_string_t vf;
7803 cmdline_fixed_string_t what;
7804 cmdline_fixed_string_t mode;
7805 cmdline_fixed_string_t on;
7809 cmd_set_vf_rxmode_parsed(void *parsed_result,
7810 __attribute__((unused)) struct cmdline *cl,
7811 __attribute__((unused)) void *data)
7814 uint16_t rx_mode = 0;
7815 struct cmd_set_vf_rxmode *res = parsed_result;
7817 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7818 if (!strcmp(res->what,"rxmode")) {
7819 if (!strcmp(res->mode, "AUPE"))
7820 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7821 else if (!strcmp(res->mode, "ROPE"))
7822 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7823 else if (!strcmp(res->mode, "BAM"))
7824 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7825 else if (!strncmp(res->mode, "MPE",3))
7826 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7829 RTE_SET_USED(is_on);
7831 #ifdef RTE_LIBRTE_IXGBE_PMD
7832 if (ret == -ENOTSUP)
7833 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7834 rx_mode, (uint8_t)is_on);
7836 #ifdef RTE_LIBRTE_BNXT_PMD
7837 if (ret == -ENOTSUP)
7838 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7839 rx_mode, (uint8_t)is_on);
7842 printf("bad VF receive mode parameter, return code = %d \n",
7846 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7847 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7849 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7850 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7852 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7853 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7855 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7856 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7858 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7859 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7861 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7862 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7864 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7865 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7866 mode, "AUPE#ROPE#BAM#MPE");
7867 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7868 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7871 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7872 .f = cmd_set_vf_rxmode_parsed,
7874 .help_str = "set port <port_id> vf <vf_id> rxmode "
7875 "AUPE|ROPE|BAM|MPE on|off",
7877 (void *)&cmd_set_vf_rxmode_set,
7878 (void *)&cmd_set_vf_rxmode_port,
7879 (void *)&cmd_set_vf_rxmode_portid,
7880 (void *)&cmd_set_vf_rxmode_vf,
7881 (void *)&cmd_set_vf_rxmode_vfid,
7882 (void *)&cmd_set_vf_rxmode_what,
7883 (void *)&cmd_set_vf_rxmode_mode,
7884 (void *)&cmd_set_vf_rxmode_on,
7889 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7890 struct cmd_vf_mac_addr_result {
7891 cmdline_fixed_string_t mac_addr_cmd;
7892 cmdline_fixed_string_t what;
7893 cmdline_fixed_string_t port;
7895 cmdline_fixed_string_t vf;
7897 struct ether_addr address;
7900 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7901 __attribute__((unused)) struct cmdline *cl,
7902 __attribute__((unused)) void *data)
7904 struct cmd_vf_mac_addr_result *res = parsed_result;
7907 if (strcmp(res->what, "add") != 0)
7910 #ifdef RTE_LIBRTE_I40E_PMD
7911 if (ret == -ENOTSUP)
7912 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7915 #ifdef RTE_LIBRTE_BNXT_PMD
7916 if (ret == -ENOTSUP)
7917 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7922 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7926 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7927 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7928 mac_addr_cmd,"mac_addr");
7929 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7930 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7932 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7933 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7935 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7936 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7938 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7939 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7941 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7942 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7944 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7945 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7948 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7949 .f = cmd_vf_mac_addr_parsed,
7951 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7952 "Add MAC address filtering for a VF on port_id",
7954 (void *)&cmd_vf_mac_addr_cmd,
7955 (void *)&cmd_vf_mac_addr_what,
7956 (void *)&cmd_vf_mac_addr_port,
7957 (void *)&cmd_vf_mac_addr_portnum,
7958 (void *)&cmd_vf_mac_addr_vf,
7959 (void *)&cmd_vf_mac_addr_vfnum,
7960 (void *)&cmd_vf_mac_addr_addr,
7965 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7966 struct cmd_vf_rx_vlan_filter {
7967 cmdline_fixed_string_t rx_vlan;
7968 cmdline_fixed_string_t what;
7970 cmdline_fixed_string_t port;
7972 cmdline_fixed_string_t vf;
7977 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7978 __attribute__((unused)) struct cmdline *cl,
7979 __attribute__((unused)) void *data)
7981 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7984 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7986 #ifdef RTE_LIBRTE_IXGBE_PMD
7987 if (ret == -ENOTSUP)
7988 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7989 res->vlan_id, res->vf_mask, is_add);
7991 #ifdef RTE_LIBRTE_I40E_PMD
7992 if (ret == -ENOTSUP)
7993 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7994 res->vlan_id, res->vf_mask, is_add);
7996 #ifdef RTE_LIBRTE_BNXT_PMD
7997 if (ret == -ENOTSUP)
7998 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7999 res->vlan_id, res->vf_mask, is_add);
8006 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8007 res->vlan_id, res->vf_mask);
8010 printf("invalid port_id %d\n", res->port_id);
8013 printf("function not implemented or supported\n");
8016 printf("programming error: (%s)\n", strerror(-ret));
8020 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8021 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8022 rx_vlan, "rx_vlan");
8023 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8024 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8026 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8027 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8029 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8030 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8032 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8033 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8035 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8036 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8038 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8039 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8042 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8043 .f = cmd_vf_rx_vlan_filter_parsed,
8045 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8046 "(vf_mask = hexadecimal VF mask)",
8048 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8049 (void *)&cmd_vf_rx_vlan_filter_what,
8050 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8051 (void *)&cmd_vf_rx_vlan_filter_port,
8052 (void *)&cmd_vf_rx_vlan_filter_portid,
8053 (void *)&cmd_vf_rx_vlan_filter_vf,
8054 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8059 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8060 struct cmd_queue_rate_limit_result {
8061 cmdline_fixed_string_t set;
8062 cmdline_fixed_string_t port;
8064 cmdline_fixed_string_t queue;
8066 cmdline_fixed_string_t rate;
8070 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8071 __attribute__((unused)) struct cmdline *cl,
8072 __attribute__((unused)) void *data)
8074 struct cmd_queue_rate_limit_result *res = parsed_result;
8077 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8078 && (strcmp(res->queue, "queue") == 0)
8079 && (strcmp(res->rate, "rate") == 0))
8080 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8083 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8087 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8088 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8090 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8091 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8093 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8094 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8096 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8097 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8099 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8100 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8102 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8103 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8105 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8106 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8109 cmdline_parse_inst_t cmd_queue_rate_limit = {
8110 .f = cmd_queue_rate_limit_parsed,
8112 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8113 "Set rate limit for a queue on port_id",
8115 (void *)&cmd_queue_rate_limit_set,
8116 (void *)&cmd_queue_rate_limit_port,
8117 (void *)&cmd_queue_rate_limit_portnum,
8118 (void *)&cmd_queue_rate_limit_queue,
8119 (void *)&cmd_queue_rate_limit_queuenum,
8120 (void *)&cmd_queue_rate_limit_rate,
8121 (void *)&cmd_queue_rate_limit_ratenum,
8126 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8127 struct cmd_vf_rate_limit_result {
8128 cmdline_fixed_string_t set;
8129 cmdline_fixed_string_t port;
8131 cmdline_fixed_string_t vf;
8133 cmdline_fixed_string_t rate;
8135 cmdline_fixed_string_t q_msk;
8139 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8140 __attribute__((unused)) struct cmdline *cl,
8141 __attribute__((unused)) void *data)
8143 struct cmd_vf_rate_limit_result *res = parsed_result;
8146 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8147 && (strcmp(res->vf, "vf") == 0)
8148 && (strcmp(res->rate, "rate") == 0)
8149 && (strcmp(res->q_msk, "queue_mask") == 0))
8150 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8151 res->rate_num, res->q_msk_val);
8153 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8157 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8158 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8160 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8161 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8163 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8164 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8166 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8167 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8169 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8170 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8172 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8173 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8175 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8176 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8178 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8179 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8180 q_msk, "queue_mask");
8181 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8182 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8185 cmdline_parse_inst_t cmd_vf_rate_limit = {
8186 .f = cmd_vf_rate_limit_parsed,
8188 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8189 "queue_mask <queue_mask_value>: "
8190 "Set rate limit for queues of VF on port_id",
8192 (void *)&cmd_vf_rate_limit_set,
8193 (void *)&cmd_vf_rate_limit_port,
8194 (void *)&cmd_vf_rate_limit_portnum,
8195 (void *)&cmd_vf_rate_limit_vf,
8196 (void *)&cmd_vf_rate_limit_vfnum,
8197 (void *)&cmd_vf_rate_limit_rate,
8198 (void *)&cmd_vf_rate_limit_ratenum,
8199 (void *)&cmd_vf_rate_limit_q_msk,
8200 (void *)&cmd_vf_rate_limit_q_msk_val,
8205 /* *** ADD TUNNEL FILTER OF A PORT *** */
8206 struct cmd_tunnel_filter_result {
8207 cmdline_fixed_string_t cmd;
8208 cmdline_fixed_string_t what;
8210 struct ether_addr outer_mac;
8211 struct ether_addr inner_mac;
8212 cmdline_ipaddr_t ip_value;
8213 uint16_t inner_vlan;
8214 cmdline_fixed_string_t tunnel_type;
8215 cmdline_fixed_string_t filter_type;
8221 cmd_tunnel_filter_parsed(void *parsed_result,
8222 __attribute__((unused)) struct cmdline *cl,
8223 __attribute__((unused)) void *data)
8225 struct cmd_tunnel_filter_result *res = parsed_result;
8226 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8229 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8231 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8232 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8233 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8235 if (res->ip_value.family == AF_INET) {
8236 tunnel_filter_conf.ip_addr.ipv4_addr =
8237 res->ip_value.addr.ipv4.s_addr;
8238 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8240 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8241 &(res->ip_value.addr.ipv6),
8242 sizeof(struct in6_addr));
8243 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8246 if (!strcmp(res->filter_type, "imac-ivlan"))
8247 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8248 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8249 tunnel_filter_conf.filter_type =
8250 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8251 else if (!strcmp(res->filter_type, "imac-tenid"))
8252 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8253 else if (!strcmp(res->filter_type, "imac"))
8254 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8255 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8256 tunnel_filter_conf.filter_type =
8257 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8258 else if (!strcmp(res->filter_type, "oip"))
8259 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8260 else if (!strcmp(res->filter_type, "iip"))
8261 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8263 printf("The filter type is not supported");
8267 if (!strcmp(res->tunnel_type, "vxlan"))
8268 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8269 else if (!strcmp(res->tunnel_type, "nvgre"))
8270 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8271 else if (!strcmp(res->tunnel_type, "ipingre"))
8272 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8274 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8278 tunnel_filter_conf.tenant_id = res->tenant_id;
8279 tunnel_filter_conf.queue_id = res->queue_num;
8280 if (!strcmp(res->what, "add"))
8281 ret = rte_eth_dev_filter_ctrl(res->port_id,
8282 RTE_ETH_FILTER_TUNNEL,
8284 &tunnel_filter_conf);
8286 ret = rte_eth_dev_filter_ctrl(res->port_id,
8287 RTE_ETH_FILTER_TUNNEL,
8288 RTE_ETH_FILTER_DELETE,
8289 &tunnel_filter_conf);
8291 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8295 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8296 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8297 cmd, "tunnel_filter");
8298 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8299 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8301 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8302 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8304 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8305 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8307 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8308 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8310 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8311 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8312 inner_vlan, UINT16);
8313 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8314 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8316 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8317 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8318 tunnel_type, "vxlan#nvgre#ipingre");
8320 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8321 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8322 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8323 "imac#omac-imac-tenid");
8324 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8325 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8327 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8328 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8331 cmdline_parse_inst_t cmd_tunnel_filter = {
8332 .f = cmd_tunnel_filter_parsed,
8334 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8335 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8336 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8337 "<queue_id>: Add/Rm tunnel filter of a port",
8339 (void *)&cmd_tunnel_filter_cmd,
8340 (void *)&cmd_tunnel_filter_what,
8341 (void *)&cmd_tunnel_filter_port_id,
8342 (void *)&cmd_tunnel_filter_outer_mac,
8343 (void *)&cmd_tunnel_filter_inner_mac,
8344 (void *)&cmd_tunnel_filter_ip_value,
8345 (void *)&cmd_tunnel_filter_innner_vlan,
8346 (void *)&cmd_tunnel_filter_tunnel_type,
8347 (void *)&cmd_tunnel_filter_filter_type,
8348 (void *)&cmd_tunnel_filter_tenant_id,
8349 (void *)&cmd_tunnel_filter_queue_num,
8354 /* *** CONFIGURE TUNNEL UDP PORT *** */
8355 struct cmd_tunnel_udp_config {
8356 cmdline_fixed_string_t cmd;
8357 cmdline_fixed_string_t what;
8363 cmd_tunnel_udp_config_parsed(void *parsed_result,
8364 __attribute__((unused)) struct cmdline *cl,
8365 __attribute__((unused)) void *data)
8367 struct cmd_tunnel_udp_config *res = parsed_result;
8368 struct rte_eth_udp_tunnel tunnel_udp;
8371 tunnel_udp.udp_port = res->udp_port;
8373 if (!strcmp(res->cmd, "rx_vxlan_port"))
8374 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8376 if (!strcmp(res->what, "add"))
8377 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8380 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8384 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8387 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8388 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8389 cmd, "rx_vxlan_port");
8390 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8391 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8393 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8394 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8396 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8397 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8400 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8401 .f = cmd_tunnel_udp_config_parsed,
8403 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8404 "Add/Remove a tunneling UDP port filter",
8406 (void *)&cmd_tunnel_udp_config_cmd,
8407 (void *)&cmd_tunnel_udp_config_what,
8408 (void *)&cmd_tunnel_udp_config_udp_port,
8409 (void *)&cmd_tunnel_udp_config_port_id,
8414 /* *** GLOBAL CONFIG *** */
8415 struct cmd_global_config_result {
8416 cmdline_fixed_string_t cmd;
8418 cmdline_fixed_string_t cfg_type;
8423 cmd_global_config_parsed(void *parsed_result,
8424 __attribute__((unused)) struct cmdline *cl,
8425 __attribute__((unused)) void *data)
8427 struct cmd_global_config_result *res = parsed_result;
8428 struct rte_eth_global_cfg conf;
8431 memset(&conf, 0, sizeof(conf));
8432 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8433 conf.cfg.gre_key_len = res->len;
8434 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8435 RTE_ETH_FILTER_SET, &conf);
8437 printf("Global config error\n");
8440 cmdline_parse_token_string_t cmd_global_config_cmd =
8441 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8443 cmdline_parse_token_num_t cmd_global_config_port_id =
8444 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8446 cmdline_parse_token_string_t cmd_global_config_type =
8447 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8448 cfg_type, "gre-key-len");
8449 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8450 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8453 cmdline_parse_inst_t cmd_global_config = {
8454 .f = cmd_global_config_parsed,
8455 .data = (void *)NULL,
8456 .help_str = "global_config <port_id> gre-key-len <key_len>",
8458 (void *)&cmd_global_config_cmd,
8459 (void *)&cmd_global_config_port_id,
8460 (void *)&cmd_global_config_type,
8461 (void *)&cmd_global_config_gre_key_len,
8466 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8467 struct cmd_set_mirror_mask_result {
8468 cmdline_fixed_string_t set;
8469 cmdline_fixed_string_t port;
8471 cmdline_fixed_string_t mirror;
8473 cmdline_fixed_string_t what;
8474 cmdline_fixed_string_t value;
8475 cmdline_fixed_string_t dstpool;
8477 cmdline_fixed_string_t on;
8480 cmdline_parse_token_string_t cmd_mirror_mask_set =
8481 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8483 cmdline_parse_token_string_t cmd_mirror_mask_port =
8484 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8486 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8487 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8489 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8490 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8491 mirror, "mirror-rule");
8492 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8493 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8495 cmdline_parse_token_string_t cmd_mirror_mask_what =
8496 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8497 what, "pool-mirror-up#pool-mirror-down"
8499 cmdline_parse_token_string_t cmd_mirror_mask_value =
8500 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8502 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8503 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8504 dstpool, "dst-pool");
8505 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8506 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8508 cmdline_parse_token_string_t cmd_mirror_mask_on =
8509 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8513 cmd_set_mirror_mask_parsed(void *parsed_result,
8514 __attribute__((unused)) struct cmdline *cl,
8515 __attribute__((unused)) void *data)
8518 struct cmd_set_mirror_mask_result *res = parsed_result;
8519 struct rte_eth_mirror_conf mr_conf;
8521 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8523 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8525 mr_conf.dst_pool = res->dstpool_id;
8527 if (!strcmp(res->what, "pool-mirror-up")) {
8528 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8529 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8530 } else if (!strcmp(res->what, "pool-mirror-down")) {
8531 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8532 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8533 } else if (!strcmp(res->what, "vlan-mirror")) {
8534 mr_conf.rule_type = ETH_MIRROR_VLAN;
8535 nb_item = parse_item_list(res->value, "vlan",
8536 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8540 for (i = 0; i < nb_item; i++) {
8541 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8542 printf("Invalid vlan_id: must be < 4096\n");
8546 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8547 mr_conf.vlan.vlan_mask |= 1ULL << i;
8551 if (!strcmp(res->on, "on"))
8552 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8555 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8558 printf("mirror rule add error: (%s)\n", strerror(-ret));
8561 cmdline_parse_inst_t cmd_set_mirror_mask = {
8562 .f = cmd_set_mirror_mask_parsed,
8564 .help_str = "set port <port_id> mirror-rule <rule_id> "
8565 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8566 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8568 (void *)&cmd_mirror_mask_set,
8569 (void *)&cmd_mirror_mask_port,
8570 (void *)&cmd_mirror_mask_portid,
8571 (void *)&cmd_mirror_mask_mirror,
8572 (void *)&cmd_mirror_mask_ruleid,
8573 (void *)&cmd_mirror_mask_what,
8574 (void *)&cmd_mirror_mask_value,
8575 (void *)&cmd_mirror_mask_dstpool,
8576 (void *)&cmd_mirror_mask_poolid,
8577 (void *)&cmd_mirror_mask_on,
8582 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8583 struct cmd_set_mirror_link_result {
8584 cmdline_fixed_string_t set;
8585 cmdline_fixed_string_t port;
8587 cmdline_fixed_string_t mirror;
8589 cmdline_fixed_string_t what;
8590 cmdline_fixed_string_t dstpool;
8592 cmdline_fixed_string_t on;
8595 cmdline_parse_token_string_t cmd_mirror_link_set =
8596 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8598 cmdline_parse_token_string_t cmd_mirror_link_port =
8599 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8601 cmdline_parse_token_num_t cmd_mirror_link_portid =
8602 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8604 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8605 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8606 mirror, "mirror-rule");
8607 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8608 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8610 cmdline_parse_token_string_t cmd_mirror_link_what =
8611 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8612 what, "uplink-mirror#downlink-mirror");
8613 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8614 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8615 dstpool, "dst-pool");
8616 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8617 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8619 cmdline_parse_token_string_t cmd_mirror_link_on =
8620 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8624 cmd_set_mirror_link_parsed(void *parsed_result,
8625 __attribute__((unused)) struct cmdline *cl,
8626 __attribute__((unused)) void *data)
8629 struct cmd_set_mirror_link_result *res = parsed_result;
8630 struct rte_eth_mirror_conf mr_conf;
8632 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8633 if (!strcmp(res->what, "uplink-mirror"))
8634 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8636 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8638 mr_conf.dst_pool = res->dstpool_id;
8640 if (!strcmp(res->on, "on"))
8641 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8644 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8647 /* check the return value and print it if is < 0 */
8649 printf("mirror rule add error: (%s)\n", strerror(-ret));
8653 cmdline_parse_inst_t cmd_set_mirror_link = {
8654 .f = cmd_set_mirror_link_parsed,
8656 .help_str = "set port <port_id> mirror-rule <rule_id> "
8657 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8659 (void *)&cmd_mirror_link_set,
8660 (void *)&cmd_mirror_link_port,
8661 (void *)&cmd_mirror_link_portid,
8662 (void *)&cmd_mirror_link_mirror,
8663 (void *)&cmd_mirror_link_ruleid,
8664 (void *)&cmd_mirror_link_what,
8665 (void *)&cmd_mirror_link_dstpool,
8666 (void *)&cmd_mirror_link_poolid,
8667 (void *)&cmd_mirror_link_on,
8672 /* *** RESET VM MIRROR RULE *** */
8673 struct cmd_rm_mirror_rule_result {
8674 cmdline_fixed_string_t reset;
8675 cmdline_fixed_string_t port;
8677 cmdline_fixed_string_t mirror;
8681 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8682 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8684 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8685 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8687 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8688 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8690 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8691 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8692 mirror, "mirror-rule");
8693 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8694 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8698 cmd_reset_mirror_rule_parsed(void *parsed_result,
8699 __attribute__((unused)) struct cmdline *cl,
8700 __attribute__((unused)) void *data)
8703 struct cmd_set_mirror_link_result *res = parsed_result;
8705 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8707 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8710 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8711 .f = cmd_reset_mirror_rule_parsed,
8713 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8715 (void *)&cmd_rm_mirror_rule_reset,
8716 (void *)&cmd_rm_mirror_rule_port,
8717 (void *)&cmd_rm_mirror_rule_portid,
8718 (void *)&cmd_rm_mirror_rule_mirror,
8719 (void *)&cmd_rm_mirror_rule_ruleid,
8724 /* ******************************************************************************** */
8726 struct cmd_dump_result {
8727 cmdline_fixed_string_t dump;
8731 dump_struct_sizes(void)
8733 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8734 DUMP_SIZE(struct rte_mbuf);
8735 DUMP_SIZE(struct rte_mempool);
8736 DUMP_SIZE(struct rte_ring);
8740 static void cmd_dump_parsed(void *parsed_result,
8741 __attribute__((unused)) struct cmdline *cl,
8742 __attribute__((unused)) void *data)
8744 struct cmd_dump_result *res = parsed_result;
8746 if (!strcmp(res->dump, "dump_physmem"))
8747 rte_dump_physmem_layout(stdout);
8748 else if (!strcmp(res->dump, "dump_memzone"))
8749 rte_memzone_dump(stdout);
8750 else if (!strcmp(res->dump, "dump_struct_sizes"))
8751 dump_struct_sizes();
8752 else if (!strcmp(res->dump, "dump_ring"))
8753 rte_ring_list_dump(stdout);
8754 else if (!strcmp(res->dump, "dump_mempool"))
8755 rte_mempool_list_dump(stdout);
8756 else if (!strcmp(res->dump, "dump_devargs"))
8757 rte_devargs_dump(stdout);
8758 else if (!strcmp(res->dump, "dump_log_types"))
8759 rte_log_dump(stdout);
8762 cmdline_parse_token_string_t cmd_dump_dump =
8763 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8766 "dump_struct_sizes#"
8772 cmdline_parse_inst_t cmd_dump = {
8773 .f = cmd_dump_parsed, /* function to call */
8774 .data = NULL, /* 2nd arg of func */
8775 .help_str = "Dump status",
8776 .tokens = { /* token list, NULL terminated */
8777 (void *)&cmd_dump_dump,
8782 /* ******************************************************************************** */
8784 struct cmd_dump_one_result {
8785 cmdline_fixed_string_t dump;
8786 cmdline_fixed_string_t name;
8789 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8790 __attribute__((unused)) void *data)
8792 struct cmd_dump_one_result *res = parsed_result;
8794 if (!strcmp(res->dump, "dump_ring")) {
8796 r = rte_ring_lookup(res->name);
8798 cmdline_printf(cl, "Cannot find ring\n");
8801 rte_ring_dump(stdout, r);
8802 } else if (!strcmp(res->dump, "dump_mempool")) {
8803 struct rte_mempool *mp;
8804 mp = rte_mempool_lookup(res->name);
8806 cmdline_printf(cl, "Cannot find mempool\n");
8809 rte_mempool_dump(stdout, mp);
8813 cmdline_parse_token_string_t cmd_dump_one_dump =
8814 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8815 "dump_ring#dump_mempool");
8817 cmdline_parse_token_string_t cmd_dump_one_name =
8818 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8820 cmdline_parse_inst_t cmd_dump_one = {
8821 .f = cmd_dump_one_parsed, /* function to call */
8822 .data = NULL, /* 2nd arg of func */
8823 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8824 .tokens = { /* token list, NULL terminated */
8825 (void *)&cmd_dump_one_dump,
8826 (void *)&cmd_dump_one_name,
8831 /* *** Add/Del syn filter *** */
8832 struct cmd_syn_filter_result {
8833 cmdline_fixed_string_t filter;
8835 cmdline_fixed_string_t ops;
8836 cmdline_fixed_string_t priority;
8837 cmdline_fixed_string_t high;
8838 cmdline_fixed_string_t queue;
8843 cmd_syn_filter_parsed(void *parsed_result,
8844 __attribute__((unused)) struct cmdline *cl,
8845 __attribute__((unused)) void *data)
8847 struct cmd_syn_filter_result *res = parsed_result;
8848 struct rte_eth_syn_filter syn_filter;
8851 ret = rte_eth_dev_filter_supported(res->port_id,
8852 RTE_ETH_FILTER_SYN);
8854 printf("syn filter is not supported on port %u.\n",
8859 memset(&syn_filter, 0, sizeof(syn_filter));
8861 if (!strcmp(res->ops, "add")) {
8862 if (!strcmp(res->high, "high"))
8863 syn_filter.hig_pri = 1;
8865 syn_filter.hig_pri = 0;
8867 syn_filter.queue = res->queue_id;
8868 ret = rte_eth_dev_filter_ctrl(res->port_id,
8873 ret = rte_eth_dev_filter_ctrl(res->port_id,
8875 RTE_ETH_FILTER_DELETE,
8879 printf("syn filter programming error: (%s)\n",
8883 cmdline_parse_token_string_t cmd_syn_filter_filter =
8884 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8885 filter, "syn_filter");
8886 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8887 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8889 cmdline_parse_token_string_t cmd_syn_filter_ops =
8890 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8892 cmdline_parse_token_string_t cmd_syn_filter_priority =
8893 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8894 priority, "priority");
8895 cmdline_parse_token_string_t cmd_syn_filter_high =
8896 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8898 cmdline_parse_token_string_t cmd_syn_filter_queue =
8899 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8901 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8902 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8905 cmdline_parse_inst_t cmd_syn_filter = {
8906 .f = cmd_syn_filter_parsed,
8908 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8909 "<queue_id>: Add/Delete syn filter",
8911 (void *)&cmd_syn_filter_filter,
8912 (void *)&cmd_syn_filter_port_id,
8913 (void *)&cmd_syn_filter_ops,
8914 (void *)&cmd_syn_filter_priority,
8915 (void *)&cmd_syn_filter_high,
8916 (void *)&cmd_syn_filter_queue,
8917 (void *)&cmd_syn_filter_queue_id,
8922 /* *** queue region set *** */
8923 struct cmd_queue_region_result {
8924 cmdline_fixed_string_t set;
8925 cmdline_fixed_string_t port;
8927 cmdline_fixed_string_t cmd;
8928 cmdline_fixed_string_t region;
8930 cmdline_fixed_string_t queue_start_index;
8932 cmdline_fixed_string_t queue_num;
8933 uint8_t queue_num_value;
8937 cmd_queue_region_parsed(void *parsed_result,
8938 __attribute__((unused)) struct cmdline *cl,
8939 __attribute__((unused)) void *data)
8941 struct cmd_queue_region_result *res = parsed_result;
8943 #ifdef RTE_LIBRTE_I40E_PMD
8944 struct rte_pmd_i40e_queue_region_conf region_conf;
8945 enum rte_pmd_i40e_queue_region_op op_type;
8948 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8951 #ifdef RTE_LIBRTE_I40E_PMD
8952 memset(®ion_conf, 0, sizeof(region_conf));
8953 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8954 region_conf.region_id = res->region_id;
8955 region_conf.queue_num = res->queue_num_value;
8956 region_conf.queue_start_index = res->queue_id;
8958 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8959 op_type, ®ion_conf);
8966 printf("function not implemented or supported\n");
8969 printf("queue region config error: (%s)\n", strerror(-ret));
8973 cmdline_parse_token_string_t cmd_queue_region_set =
8974 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8976 cmdline_parse_token_string_t cmd_queue_region_port =
8977 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8978 cmdline_parse_token_num_t cmd_queue_region_port_id =
8979 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8981 cmdline_parse_token_string_t cmd_queue_region_cmd =
8982 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8983 cmd, "queue-region");
8984 cmdline_parse_token_string_t cmd_queue_region_id =
8985 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8986 region, "region_id");
8987 cmdline_parse_token_num_t cmd_queue_region_index =
8988 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8990 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8991 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8992 queue_start_index, "queue_start_index");
8993 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8994 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8996 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8997 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8998 queue_num, "queue_num");
8999 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9000 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9001 queue_num_value, UINT8);
9003 cmdline_parse_inst_t cmd_queue_region = {
9004 .f = cmd_queue_region_parsed,
9006 .help_str = "set port <port_id> queue-region region_id <value> "
9007 "queue_start_index <value> queue_num <value>: Set a queue region",
9009 (void *)&cmd_queue_region_set,
9010 (void *)&cmd_queue_region_port,
9011 (void *)&cmd_queue_region_port_id,
9012 (void *)&cmd_queue_region_cmd,
9013 (void *)&cmd_queue_region_id,
9014 (void *)&cmd_queue_region_index,
9015 (void *)&cmd_queue_region_queue_start_index,
9016 (void *)&cmd_queue_region_queue_id,
9017 (void *)&cmd_queue_region_queue_num,
9018 (void *)&cmd_queue_region_queue_num_value,
9023 /* *** queue region and flowtype set *** */
9024 struct cmd_region_flowtype_result {
9025 cmdline_fixed_string_t set;
9026 cmdline_fixed_string_t port;
9028 cmdline_fixed_string_t cmd;
9029 cmdline_fixed_string_t region;
9031 cmdline_fixed_string_t flowtype;
9032 uint8_t flowtype_id;
9036 cmd_region_flowtype_parsed(void *parsed_result,
9037 __attribute__((unused)) struct cmdline *cl,
9038 __attribute__((unused)) void *data)
9040 struct cmd_region_flowtype_result *res = parsed_result;
9042 #ifdef RTE_LIBRTE_I40E_PMD
9043 struct rte_pmd_i40e_queue_region_conf region_conf;
9044 enum rte_pmd_i40e_queue_region_op op_type;
9047 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9050 #ifdef RTE_LIBRTE_I40E_PMD
9051 memset(®ion_conf, 0, sizeof(region_conf));
9053 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9054 region_conf.region_id = res->region_id;
9055 region_conf.hw_flowtype = res->flowtype_id;
9057 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9058 op_type, ®ion_conf);
9065 printf("function not implemented or supported\n");
9068 printf("region flowtype config error: (%s)\n", strerror(-ret));
9072 cmdline_parse_token_string_t cmd_region_flowtype_set =
9073 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9075 cmdline_parse_token_string_t cmd_region_flowtype_port =
9076 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9078 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9079 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9081 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9082 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9083 cmd, "queue-region");
9084 cmdline_parse_token_string_t cmd_region_flowtype_index =
9085 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9086 region, "region_id");
9087 cmdline_parse_token_num_t cmd_region_flowtype_id =
9088 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9090 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9091 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9092 flowtype, "flowtype");
9093 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9094 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9095 flowtype_id, UINT8);
9096 cmdline_parse_inst_t cmd_region_flowtype = {
9097 .f = cmd_region_flowtype_parsed,
9099 .help_str = "set port <port_id> queue-region region_id <value> "
9100 "flowtype <value>: Set a flowtype region index",
9102 (void *)&cmd_region_flowtype_set,
9103 (void *)&cmd_region_flowtype_port,
9104 (void *)&cmd_region_flowtype_port_index,
9105 (void *)&cmd_region_flowtype_cmd,
9106 (void *)&cmd_region_flowtype_index,
9107 (void *)&cmd_region_flowtype_id,
9108 (void *)&cmd_region_flowtype_flow_index,
9109 (void *)&cmd_region_flowtype_flow_id,
9114 /* *** User Priority (UP) to queue region (region_id) set *** */
9115 struct cmd_user_priority_region_result {
9116 cmdline_fixed_string_t set;
9117 cmdline_fixed_string_t port;
9119 cmdline_fixed_string_t cmd;
9120 cmdline_fixed_string_t user_priority;
9121 uint8_t user_priority_id;
9122 cmdline_fixed_string_t region;
9127 cmd_user_priority_region_parsed(void *parsed_result,
9128 __attribute__((unused)) struct cmdline *cl,
9129 __attribute__((unused)) void *data)
9131 struct cmd_user_priority_region_result *res = parsed_result;
9133 #ifdef RTE_LIBRTE_I40E_PMD
9134 struct rte_pmd_i40e_queue_region_conf region_conf;
9135 enum rte_pmd_i40e_queue_region_op op_type;
9138 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9141 #ifdef RTE_LIBRTE_I40E_PMD
9142 memset(®ion_conf, 0, sizeof(region_conf));
9143 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9144 region_conf.user_priority = res->user_priority_id;
9145 region_conf.region_id = res->region_id;
9147 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9148 op_type, ®ion_conf);
9155 printf("function not implemented or supported\n");
9158 printf("user_priority region config error: (%s)\n",
9163 cmdline_parse_token_string_t cmd_user_priority_region_set =
9164 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9166 cmdline_parse_token_string_t cmd_user_priority_region_port =
9167 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9169 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9170 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9172 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9173 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9174 cmd, "queue-region");
9175 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9176 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9177 user_priority, "UP");
9178 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9179 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9180 user_priority_id, UINT8);
9181 cmdline_parse_token_string_t cmd_user_priority_region_region =
9182 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9183 region, "region_id");
9184 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9185 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9188 cmdline_parse_inst_t cmd_user_priority_region = {
9189 .f = cmd_user_priority_region_parsed,
9191 .help_str = "set port <port_id> queue-region UP <value> "
9192 "region_id <value>: Set the mapping of User Priority (UP) "
9193 "to queue region (region_id) ",
9195 (void *)&cmd_user_priority_region_set,
9196 (void *)&cmd_user_priority_region_port,
9197 (void *)&cmd_user_priority_region_port_index,
9198 (void *)&cmd_user_priority_region_cmd,
9199 (void *)&cmd_user_priority_region_UP,
9200 (void *)&cmd_user_priority_region_UP_id,
9201 (void *)&cmd_user_priority_region_region,
9202 (void *)&cmd_user_priority_region_region_id,
9207 /* *** flush all queue region related configuration *** */
9208 struct cmd_flush_queue_region_result {
9209 cmdline_fixed_string_t set;
9210 cmdline_fixed_string_t port;
9212 cmdline_fixed_string_t cmd;
9213 cmdline_fixed_string_t flush;
9214 cmdline_fixed_string_t what;
9218 cmd_flush_queue_region_parsed(void *parsed_result,
9219 __attribute__((unused)) struct cmdline *cl,
9220 __attribute__((unused)) void *data)
9222 struct cmd_flush_queue_region_result *res = parsed_result;
9224 #ifdef RTE_LIBRTE_I40E_PMD
9225 struct rte_pmd_i40e_queue_region_conf region_conf;
9226 enum rte_pmd_i40e_queue_region_op op_type;
9229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9232 #ifdef RTE_LIBRTE_I40E_PMD
9233 memset(®ion_conf, 0, sizeof(region_conf));
9235 if (strcmp(res->what, "on") == 0)
9236 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9238 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9240 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9241 op_type, ®ion_conf);
9248 printf("function not implemented or supported\n");
9251 printf("queue region config flush error: (%s)\n",
9256 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9257 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9259 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9260 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9262 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9263 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9265 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9266 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9267 cmd, "queue-region");
9268 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9269 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9271 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9272 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9275 cmdline_parse_inst_t cmd_flush_queue_region = {
9276 .f = cmd_flush_queue_region_parsed,
9278 .help_str = "set port <port_id> queue-region flush on|off"
9279 ": flush all queue region related configuration",
9281 (void *)&cmd_flush_queue_region_set,
9282 (void *)&cmd_flush_queue_region_port,
9283 (void *)&cmd_flush_queue_region_port_index,
9284 (void *)&cmd_flush_queue_region_cmd,
9285 (void *)&cmd_flush_queue_region_flush,
9286 (void *)&cmd_flush_queue_region_what,
9291 /* *** get all queue region related configuration info *** */
9292 struct cmd_show_queue_region_info {
9293 cmdline_fixed_string_t show;
9294 cmdline_fixed_string_t port;
9296 cmdline_fixed_string_t cmd;
9300 cmd_show_queue_region_info_parsed(void *parsed_result,
9301 __attribute__((unused)) struct cmdline *cl,
9302 __attribute__((unused)) void *data)
9304 struct cmd_show_queue_region_info *res = parsed_result;
9306 #ifdef RTE_LIBRTE_I40E_PMD
9307 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9308 enum rte_pmd_i40e_queue_region_op op_type;
9311 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9314 #ifdef RTE_LIBRTE_I40E_PMD
9315 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9317 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9319 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9320 op_type, &rte_pmd_regions);
9322 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9329 printf("function not implemented or supported\n");
9332 printf("queue region config info show error: (%s)\n",
9337 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9338 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9340 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9341 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9343 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9344 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9346 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9347 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9348 cmd, "queue-region");
9350 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9351 .f = cmd_show_queue_region_info_parsed,
9353 .help_str = "show port <port_id> queue-region"
9354 ": show all queue region related configuration info",
9356 (void *)&cmd_show_queue_region_info_get,
9357 (void *)&cmd_show_queue_region_info_port,
9358 (void *)&cmd_show_queue_region_info_port_index,
9359 (void *)&cmd_show_queue_region_info_cmd,
9364 /* *** ADD/REMOVE A 2tuple FILTER *** */
9365 struct cmd_2tuple_filter_result {
9366 cmdline_fixed_string_t filter;
9368 cmdline_fixed_string_t ops;
9369 cmdline_fixed_string_t dst_port;
9370 uint16_t dst_port_value;
9371 cmdline_fixed_string_t protocol;
9372 uint8_t protocol_value;
9373 cmdline_fixed_string_t mask;
9375 cmdline_fixed_string_t tcp_flags;
9376 uint8_t tcp_flags_value;
9377 cmdline_fixed_string_t priority;
9378 uint8_t priority_value;
9379 cmdline_fixed_string_t queue;
9384 cmd_2tuple_filter_parsed(void *parsed_result,
9385 __attribute__((unused)) struct cmdline *cl,
9386 __attribute__((unused)) void *data)
9388 struct rte_eth_ntuple_filter filter;
9389 struct cmd_2tuple_filter_result *res = parsed_result;
9392 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9394 printf("ntuple filter is not supported on port %u.\n",
9399 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9401 filter.flags = RTE_2TUPLE_FLAGS;
9402 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9403 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9404 filter.proto = res->protocol_value;
9405 filter.priority = res->priority_value;
9406 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9407 printf("nonzero tcp_flags is only meaningful"
9408 " when protocol is TCP.\n");
9411 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9412 printf("invalid TCP flags.\n");
9416 if (res->tcp_flags_value != 0) {
9417 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9418 filter.tcp_flags = res->tcp_flags_value;
9421 /* need convert to big endian. */
9422 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9423 filter.queue = res->queue_id;
9425 if (!strcmp(res->ops, "add"))
9426 ret = rte_eth_dev_filter_ctrl(res->port_id,
9427 RTE_ETH_FILTER_NTUPLE,
9431 ret = rte_eth_dev_filter_ctrl(res->port_id,
9432 RTE_ETH_FILTER_NTUPLE,
9433 RTE_ETH_FILTER_DELETE,
9436 printf("2tuple filter programming error: (%s)\n",
9441 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9442 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9443 filter, "2tuple_filter");
9444 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9445 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9447 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9448 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9450 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9451 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9452 dst_port, "dst_port");
9453 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9454 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9455 dst_port_value, UINT16);
9456 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9457 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9458 protocol, "protocol");
9459 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9460 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9461 protocol_value, UINT8);
9462 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9463 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9465 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9466 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9468 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9469 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9470 tcp_flags, "tcp_flags");
9471 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9472 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9473 tcp_flags_value, UINT8);
9474 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9475 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9476 priority, "priority");
9477 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9478 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9479 priority_value, UINT8);
9480 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9481 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9483 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9484 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9487 cmdline_parse_inst_t cmd_2tuple_filter = {
9488 .f = cmd_2tuple_filter_parsed,
9490 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9491 "<value> mask <value> tcp_flags <value> priority <value> queue "
9492 "<queue_id>: Add a 2tuple filter",
9494 (void *)&cmd_2tuple_filter_filter,
9495 (void *)&cmd_2tuple_filter_port_id,
9496 (void *)&cmd_2tuple_filter_ops,
9497 (void *)&cmd_2tuple_filter_dst_port,
9498 (void *)&cmd_2tuple_filter_dst_port_value,
9499 (void *)&cmd_2tuple_filter_protocol,
9500 (void *)&cmd_2tuple_filter_protocol_value,
9501 (void *)&cmd_2tuple_filter_mask,
9502 (void *)&cmd_2tuple_filter_mask_value,
9503 (void *)&cmd_2tuple_filter_tcp_flags,
9504 (void *)&cmd_2tuple_filter_tcp_flags_value,
9505 (void *)&cmd_2tuple_filter_priority,
9506 (void *)&cmd_2tuple_filter_priority_value,
9507 (void *)&cmd_2tuple_filter_queue,
9508 (void *)&cmd_2tuple_filter_queue_id,
9513 /* *** ADD/REMOVE A 5tuple FILTER *** */
9514 struct cmd_5tuple_filter_result {
9515 cmdline_fixed_string_t filter;
9517 cmdline_fixed_string_t ops;
9518 cmdline_fixed_string_t dst_ip;
9519 cmdline_ipaddr_t dst_ip_value;
9520 cmdline_fixed_string_t src_ip;
9521 cmdline_ipaddr_t src_ip_value;
9522 cmdline_fixed_string_t dst_port;
9523 uint16_t dst_port_value;
9524 cmdline_fixed_string_t src_port;
9525 uint16_t src_port_value;
9526 cmdline_fixed_string_t protocol;
9527 uint8_t protocol_value;
9528 cmdline_fixed_string_t mask;
9530 cmdline_fixed_string_t tcp_flags;
9531 uint8_t tcp_flags_value;
9532 cmdline_fixed_string_t priority;
9533 uint8_t priority_value;
9534 cmdline_fixed_string_t queue;
9539 cmd_5tuple_filter_parsed(void *parsed_result,
9540 __attribute__((unused)) struct cmdline *cl,
9541 __attribute__((unused)) void *data)
9543 struct rte_eth_ntuple_filter filter;
9544 struct cmd_5tuple_filter_result *res = parsed_result;
9547 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9549 printf("ntuple filter is not supported on port %u.\n",
9554 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9556 filter.flags = RTE_5TUPLE_FLAGS;
9557 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9558 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9559 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9560 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9561 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9562 filter.proto = res->protocol_value;
9563 filter.priority = res->priority_value;
9564 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9565 printf("nonzero tcp_flags is only meaningful"
9566 " when protocol is TCP.\n");
9569 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9570 printf("invalid TCP flags.\n");
9574 if (res->tcp_flags_value != 0) {
9575 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9576 filter.tcp_flags = res->tcp_flags_value;
9579 if (res->dst_ip_value.family == AF_INET)
9580 /* no need to convert, already big endian. */
9581 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9583 if (filter.dst_ip_mask == 0) {
9584 printf("can not support ipv6 involved compare.\n");
9590 if (res->src_ip_value.family == AF_INET)
9591 /* no need to convert, already big endian. */
9592 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9594 if (filter.src_ip_mask == 0) {
9595 printf("can not support ipv6 involved compare.\n");
9600 /* need convert to big endian. */
9601 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9602 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9603 filter.queue = res->queue_id;
9605 if (!strcmp(res->ops, "add"))
9606 ret = rte_eth_dev_filter_ctrl(res->port_id,
9607 RTE_ETH_FILTER_NTUPLE,
9611 ret = rte_eth_dev_filter_ctrl(res->port_id,
9612 RTE_ETH_FILTER_NTUPLE,
9613 RTE_ETH_FILTER_DELETE,
9616 printf("5tuple filter programming error: (%s)\n",
9620 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9621 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9622 filter, "5tuple_filter");
9623 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9624 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9626 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9627 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9629 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9630 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9632 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9633 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9635 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9636 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9638 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9639 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9641 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9642 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9643 dst_port, "dst_port");
9644 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9645 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9646 dst_port_value, UINT16);
9647 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9648 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9649 src_port, "src_port");
9650 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9651 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9652 src_port_value, UINT16);
9653 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9654 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9655 protocol, "protocol");
9656 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9657 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9658 protocol_value, UINT8);
9659 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9660 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9662 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9663 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9665 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9666 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9667 tcp_flags, "tcp_flags");
9668 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9669 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9670 tcp_flags_value, UINT8);
9671 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9672 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9673 priority, "priority");
9674 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9675 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9676 priority_value, UINT8);
9677 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9678 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9680 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9681 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9684 cmdline_parse_inst_t cmd_5tuple_filter = {
9685 .f = cmd_5tuple_filter_parsed,
9687 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9688 "src_ip <value> dst_port <value> src_port <value> "
9689 "protocol <value> mask <value> tcp_flags <value> "
9690 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9692 (void *)&cmd_5tuple_filter_filter,
9693 (void *)&cmd_5tuple_filter_port_id,
9694 (void *)&cmd_5tuple_filter_ops,
9695 (void *)&cmd_5tuple_filter_dst_ip,
9696 (void *)&cmd_5tuple_filter_dst_ip_value,
9697 (void *)&cmd_5tuple_filter_src_ip,
9698 (void *)&cmd_5tuple_filter_src_ip_value,
9699 (void *)&cmd_5tuple_filter_dst_port,
9700 (void *)&cmd_5tuple_filter_dst_port_value,
9701 (void *)&cmd_5tuple_filter_src_port,
9702 (void *)&cmd_5tuple_filter_src_port_value,
9703 (void *)&cmd_5tuple_filter_protocol,
9704 (void *)&cmd_5tuple_filter_protocol_value,
9705 (void *)&cmd_5tuple_filter_mask,
9706 (void *)&cmd_5tuple_filter_mask_value,
9707 (void *)&cmd_5tuple_filter_tcp_flags,
9708 (void *)&cmd_5tuple_filter_tcp_flags_value,
9709 (void *)&cmd_5tuple_filter_priority,
9710 (void *)&cmd_5tuple_filter_priority_value,
9711 (void *)&cmd_5tuple_filter_queue,
9712 (void *)&cmd_5tuple_filter_queue_id,
9717 /* *** ADD/REMOVE A flex FILTER *** */
9718 struct cmd_flex_filter_result {
9719 cmdline_fixed_string_t filter;
9720 cmdline_fixed_string_t ops;
9722 cmdline_fixed_string_t len;
9724 cmdline_fixed_string_t bytes;
9725 cmdline_fixed_string_t bytes_value;
9726 cmdline_fixed_string_t mask;
9727 cmdline_fixed_string_t mask_value;
9728 cmdline_fixed_string_t priority;
9729 uint8_t priority_value;
9730 cmdline_fixed_string_t queue;
9734 static int xdigit2val(unsigned char c)
9739 else if (isupper(c))
9747 cmd_flex_filter_parsed(void *parsed_result,
9748 __attribute__((unused)) struct cmdline *cl,
9749 __attribute__((unused)) void *data)
9752 struct rte_eth_flex_filter filter;
9753 struct cmd_flex_filter_result *res = parsed_result;
9754 char *bytes_ptr, *mask_ptr;
9755 uint16_t len, i, j = 0;
9760 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9761 printf("the len exceed the max length 128\n");
9764 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9765 filter.len = res->len_value;
9766 filter.priority = res->priority_value;
9767 filter.queue = res->queue_id;
9768 bytes_ptr = res->bytes_value;
9769 mask_ptr = res->mask_value;
9771 /* translate bytes string to array. */
9772 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9773 (bytes_ptr[1] == 'X')))
9775 len = strnlen(bytes_ptr, res->len_value * 2);
9776 if (len == 0 || (len % 8 != 0)) {
9777 printf("please check len and bytes input\n");
9780 for (i = 0; i < len; i++) {
9782 if (isxdigit(c) == 0) {
9783 /* invalid characters. */
9784 printf("invalid input\n");
9787 val = xdigit2val(c);
9790 filter.bytes[j] = byte;
9791 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9798 /* translate mask string to uint8_t array. */
9799 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9800 (mask_ptr[1] == 'X')))
9802 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9804 printf("invalid input\n");
9809 for (i = 0; i < len; i++) {
9811 if (isxdigit(c) == 0) {
9812 /* invalid characters. */
9813 printf("invalid input\n");
9816 val = xdigit2val(c);
9819 filter.mask[j] = byte;
9820 printf("mask[%d]:%02x ", j, filter.mask[j]);
9828 if (!strcmp(res->ops, "add"))
9829 ret = rte_eth_dev_filter_ctrl(res->port_id,
9830 RTE_ETH_FILTER_FLEXIBLE,
9834 ret = rte_eth_dev_filter_ctrl(res->port_id,
9835 RTE_ETH_FILTER_FLEXIBLE,
9836 RTE_ETH_FILTER_DELETE,
9840 printf("flex filter setting error: (%s)\n", strerror(-ret));
9843 cmdline_parse_token_string_t cmd_flex_filter_filter =
9844 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9845 filter, "flex_filter");
9846 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9847 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9849 cmdline_parse_token_string_t cmd_flex_filter_ops =
9850 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9852 cmdline_parse_token_string_t cmd_flex_filter_len =
9853 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9855 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9856 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9858 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9859 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9861 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9862 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9864 cmdline_parse_token_string_t cmd_flex_filter_mask =
9865 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9867 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9868 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9870 cmdline_parse_token_string_t cmd_flex_filter_priority =
9871 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9872 priority, "priority");
9873 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9874 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9875 priority_value, UINT8);
9876 cmdline_parse_token_string_t cmd_flex_filter_queue =
9877 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9879 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9880 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9882 cmdline_parse_inst_t cmd_flex_filter = {
9883 .f = cmd_flex_filter_parsed,
9885 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9886 "<value> mask <value> priority <value> queue <queue_id>: "
9887 "Add/Del a flex filter",
9889 (void *)&cmd_flex_filter_filter,
9890 (void *)&cmd_flex_filter_port_id,
9891 (void *)&cmd_flex_filter_ops,
9892 (void *)&cmd_flex_filter_len,
9893 (void *)&cmd_flex_filter_len_value,
9894 (void *)&cmd_flex_filter_bytes,
9895 (void *)&cmd_flex_filter_bytes_value,
9896 (void *)&cmd_flex_filter_mask,
9897 (void *)&cmd_flex_filter_mask_value,
9898 (void *)&cmd_flex_filter_priority,
9899 (void *)&cmd_flex_filter_priority_value,
9900 (void *)&cmd_flex_filter_queue,
9901 (void *)&cmd_flex_filter_queue_id,
9906 /* *** Filters Control *** */
9908 /* *** deal with ethertype filter *** */
9909 struct cmd_ethertype_filter_result {
9910 cmdline_fixed_string_t filter;
9912 cmdline_fixed_string_t ops;
9913 cmdline_fixed_string_t mac;
9914 struct ether_addr mac_addr;
9915 cmdline_fixed_string_t ethertype;
9916 uint16_t ethertype_value;
9917 cmdline_fixed_string_t drop;
9918 cmdline_fixed_string_t queue;
9922 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9923 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9924 filter, "ethertype_filter");
9925 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9926 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9928 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9929 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9931 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9932 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9933 mac, "mac_addr#mac_ignr");
9934 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9935 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9937 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9938 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9939 ethertype, "ethertype");
9940 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9941 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9942 ethertype_value, UINT16);
9943 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9944 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9946 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9947 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9949 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9950 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9954 cmd_ethertype_filter_parsed(void *parsed_result,
9955 __attribute__((unused)) struct cmdline *cl,
9956 __attribute__((unused)) void *data)
9958 struct cmd_ethertype_filter_result *res = parsed_result;
9959 struct rte_eth_ethertype_filter filter;
9962 ret = rte_eth_dev_filter_supported(res->port_id,
9963 RTE_ETH_FILTER_ETHERTYPE);
9965 printf("ethertype filter is not supported on port %u.\n",
9970 memset(&filter, 0, sizeof(filter));
9971 if (!strcmp(res->mac, "mac_addr")) {
9972 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9973 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9974 sizeof(struct ether_addr));
9976 if (!strcmp(res->drop, "drop"))
9977 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9978 filter.ether_type = res->ethertype_value;
9979 filter.queue = res->queue_id;
9981 if (!strcmp(res->ops, "add"))
9982 ret = rte_eth_dev_filter_ctrl(res->port_id,
9983 RTE_ETH_FILTER_ETHERTYPE,
9987 ret = rte_eth_dev_filter_ctrl(res->port_id,
9988 RTE_ETH_FILTER_ETHERTYPE,
9989 RTE_ETH_FILTER_DELETE,
9992 printf("ethertype filter programming error: (%s)\n",
9996 cmdline_parse_inst_t cmd_ethertype_filter = {
9997 .f = cmd_ethertype_filter_parsed,
9999 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10000 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10001 "Add or delete an ethertype filter entry",
10003 (void *)&cmd_ethertype_filter_filter,
10004 (void *)&cmd_ethertype_filter_port_id,
10005 (void *)&cmd_ethertype_filter_ops,
10006 (void *)&cmd_ethertype_filter_mac,
10007 (void *)&cmd_ethertype_filter_mac_addr,
10008 (void *)&cmd_ethertype_filter_ethertype,
10009 (void *)&cmd_ethertype_filter_ethertype_value,
10010 (void *)&cmd_ethertype_filter_drop,
10011 (void *)&cmd_ethertype_filter_queue,
10012 (void *)&cmd_ethertype_filter_queue_id,
10017 /* *** deal with flow director filter *** */
10018 struct cmd_flow_director_result {
10019 cmdline_fixed_string_t flow_director_filter;
10021 cmdline_fixed_string_t mode;
10022 cmdline_fixed_string_t mode_value;
10023 cmdline_fixed_string_t ops;
10024 cmdline_fixed_string_t flow;
10025 cmdline_fixed_string_t flow_type;
10026 cmdline_fixed_string_t ether;
10027 uint16_t ether_type;
10028 cmdline_fixed_string_t src;
10029 cmdline_ipaddr_t ip_src;
10031 cmdline_fixed_string_t dst;
10032 cmdline_ipaddr_t ip_dst;
10034 cmdline_fixed_string_t verify_tag;
10035 uint32_t verify_tag_value;
10036 cmdline_fixed_string_t tos;
10038 cmdline_fixed_string_t proto;
10039 uint8_t proto_value;
10040 cmdline_fixed_string_t ttl;
10042 cmdline_fixed_string_t vlan;
10043 uint16_t vlan_value;
10044 cmdline_fixed_string_t flexbytes;
10045 cmdline_fixed_string_t flexbytes_value;
10046 cmdline_fixed_string_t pf_vf;
10047 cmdline_fixed_string_t drop;
10048 cmdline_fixed_string_t queue;
10050 cmdline_fixed_string_t fd_id;
10051 uint32_t fd_id_value;
10052 cmdline_fixed_string_t mac;
10053 struct ether_addr mac_addr;
10054 cmdline_fixed_string_t tunnel;
10055 cmdline_fixed_string_t tunnel_type;
10056 cmdline_fixed_string_t tunnel_id;
10057 uint32_t tunnel_id_value;
10058 cmdline_fixed_string_t packet;
10063 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10066 const char *p, *p0 = q_arg;
10068 unsigned long int_fld;
10069 char *str_fld[max_num];
10074 p = strchr(p0, '(');
10078 p0 = strchr(p, ')');
10083 if (size >= sizeof(s))
10086 snprintf(s, sizeof(s), "%.*s", size, p);
10087 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10088 if (ret < 0 || ret > max_num)
10090 for (i = 0; i < ret; i++) {
10092 int_fld = strtoul(str_fld[i], &end, 0);
10093 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10095 flexbytes[i] = (uint8_t)int_fld;
10101 str2flowtype(char *string)
10104 static const struct {
10107 } flowtype_str[] = {
10108 {"raw", RTE_ETH_FLOW_RAW},
10109 {"ipv4", RTE_ETH_FLOW_IPV4},
10110 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10111 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10112 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10113 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10114 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10115 {"ipv6", RTE_ETH_FLOW_IPV6},
10116 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10117 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10118 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10119 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10120 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10121 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10124 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10125 if (!strcmp(flowtype_str[i].str, string))
10126 return flowtype_str[i].type;
10129 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10130 return (uint16_t)atoi(string);
10132 return RTE_ETH_FLOW_UNKNOWN;
10135 static enum rte_eth_fdir_tunnel_type
10136 str2fdir_tunneltype(char *string)
10140 static const struct {
10142 enum rte_eth_fdir_tunnel_type type;
10143 } tunneltype_str[] = {
10144 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10145 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10148 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10149 if (!strcmp(tunneltype_str[i].str, string))
10150 return tunneltype_str[i].type;
10152 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10155 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10157 if ((ip_addr).family == AF_INET) \
10158 (ip) = (ip_addr).addr.ipv4.s_addr; \
10160 printf("invalid parameter.\n"); \
10165 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10167 if ((ip_addr).family == AF_INET6) \
10168 rte_memcpy(&(ip), \
10169 &((ip_addr).addr.ipv6), \
10170 sizeof(struct in6_addr)); \
10172 printf("invalid parameter.\n"); \
10178 cmd_flow_director_filter_parsed(void *parsed_result,
10179 __attribute__((unused)) struct cmdline *cl,
10180 __attribute__((unused)) void *data)
10182 struct cmd_flow_director_result *res = parsed_result;
10183 struct rte_eth_fdir_filter entry;
10184 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10186 unsigned long vf_id;
10189 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10191 printf("flow director is not supported on port %u.\n",
10195 memset(flexbytes, 0, sizeof(flexbytes));
10196 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10198 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10199 if (strcmp(res->mode_value, "MAC-VLAN")) {
10200 printf("Please set mode to MAC-VLAN.\n");
10203 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10204 if (strcmp(res->mode_value, "Tunnel")) {
10205 printf("Please set mode to Tunnel.\n");
10209 if (!strcmp(res->mode_value, "raw")) {
10210 #ifdef RTE_LIBRTE_I40E_PMD
10211 struct rte_pmd_i40e_flow_type_mapping
10212 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10213 struct rte_pmd_i40e_pkt_template_conf conf;
10214 uint16_t flow_type = str2flowtype(res->flow_type);
10215 uint16_t i, port = res->port_id;
10218 memset(&conf, 0, sizeof(conf));
10220 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10221 printf("Invalid flow type specified.\n");
10224 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10228 if (mapping[flow_type].pctype == 0ULL) {
10229 printf("Invalid flow type specified.\n");
10232 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10233 if (mapping[flow_type].pctype & (1ULL << i)) {
10234 conf.input.pctype = i;
10239 conf.input.packet = open_file(res->filepath,
10240 &conf.input.length);
10241 if (!conf.input.packet)
10243 if (!strcmp(res->drop, "drop"))
10244 conf.action.behavior =
10245 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10247 conf.action.behavior =
10248 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10249 conf.action.report_status =
10250 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10251 conf.action.rx_queue = res->queue_id;
10252 conf.soft_id = res->fd_id_value;
10253 add = strcmp(res->ops, "del") ? 1 : 0;
10254 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10258 printf("flow director config error: (%s)\n",
10260 close_file(conf.input.packet);
10263 } else if (strcmp(res->mode_value, "IP")) {
10264 printf("Please set mode to IP or raw.\n");
10267 entry.input.flow_type = str2flowtype(res->flow_type);
10270 ret = parse_flexbytes(res->flexbytes_value,
10272 RTE_ETH_FDIR_MAX_FLEXLEN);
10274 printf("error: Cannot parse flexbytes input.\n");
10278 switch (entry.input.flow_type) {
10279 case RTE_ETH_FLOW_FRAG_IPV4:
10280 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10281 entry.input.flow.ip4_flow.proto = res->proto_value;
10283 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10284 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10285 IPV4_ADDR_TO_UINT(res->ip_dst,
10286 entry.input.flow.ip4_flow.dst_ip);
10287 IPV4_ADDR_TO_UINT(res->ip_src,
10288 entry.input.flow.ip4_flow.src_ip);
10289 entry.input.flow.ip4_flow.tos = res->tos_value;
10290 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10291 /* need convert to big endian. */
10292 entry.input.flow.udp4_flow.dst_port =
10293 rte_cpu_to_be_16(res->port_dst);
10294 entry.input.flow.udp4_flow.src_port =
10295 rte_cpu_to_be_16(res->port_src);
10297 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10298 IPV4_ADDR_TO_UINT(res->ip_dst,
10299 entry.input.flow.sctp4_flow.ip.dst_ip);
10300 IPV4_ADDR_TO_UINT(res->ip_src,
10301 entry.input.flow.sctp4_flow.ip.src_ip);
10302 entry.input.flow.ip4_flow.tos = res->tos_value;
10303 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10304 /* need convert to big endian. */
10305 entry.input.flow.sctp4_flow.dst_port =
10306 rte_cpu_to_be_16(res->port_dst);
10307 entry.input.flow.sctp4_flow.src_port =
10308 rte_cpu_to_be_16(res->port_src);
10309 entry.input.flow.sctp4_flow.verify_tag =
10310 rte_cpu_to_be_32(res->verify_tag_value);
10312 case RTE_ETH_FLOW_FRAG_IPV6:
10313 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10314 entry.input.flow.ipv6_flow.proto = res->proto_value;
10316 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10317 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10318 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10319 entry.input.flow.ipv6_flow.dst_ip);
10320 IPV6_ADDR_TO_ARRAY(res->ip_src,
10321 entry.input.flow.ipv6_flow.src_ip);
10322 entry.input.flow.ipv6_flow.tc = res->tos_value;
10323 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10324 /* need convert to big endian. */
10325 entry.input.flow.udp6_flow.dst_port =
10326 rte_cpu_to_be_16(res->port_dst);
10327 entry.input.flow.udp6_flow.src_port =
10328 rte_cpu_to_be_16(res->port_src);
10330 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10331 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10332 entry.input.flow.sctp6_flow.ip.dst_ip);
10333 IPV6_ADDR_TO_ARRAY(res->ip_src,
10334 entry.input.flow.sctp6_flow.ip.src_ip);
10335 entry.input.flow.ipv6_flow.tc = res->tos_value;
10336 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10337 /* need convert to big endian. */
10338 entry.input.flow.sctp6_flow.dst_port =
10339 rte_cpu_to_be_16(res->port_dst);
10340 entry.input.flow.sctp6_flow.src_port =
10341 rte_cpu_to_be_16(res->port_src);
10342 entry.input.flow.sctp6_flow.verify_tag =
10343 rte_cpu_to_be_32(res->verify_tag_value);
10345 case RTE_ETH_FLOW_L2_PAYLOAD:
10346 entry.input.flow.l2_flow.ether_type =
10347 rte_cpu_to_be_16(res->ether_type);
10353 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10354 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10356 sizeof(struct ether_addr));
10358 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10359 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10361 sizeof(struct ether_addr));
10362 entry.input.flow.tunnel_flow.tunnel_type =
10363 str2fdir_tunneltype(res->tunnel_type);
10364 entry.input.flow.tunnel_flow.tunnel_id =
10365 rte_cpu_to_be_32(res->tunnel_id_value);
10368 rte_memcpy(entry.input.flow_ext.flexbytes,
10370 RTE_ETH_FDIR_MAX_FLEXLEN);
10372 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10374 entry.action.flex_off = 0; /*use 0 by default */
10375 if (!strcmp(res->drop, "drop"))
10376 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10378 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10380 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10381 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10382 if (!strcmp(res->pf_vf, "pf"))
10383 entry.input.flow_ext.is_vf = 0;
10384 else if (!strncmp(res->pf_vf, "vf", 2)) {
10385 struct rte_eth_dev_info dev_info;
10387 memset(&dev_info, 0, sizeof(dev_info));
10388 rte_eth_dev_info_get(res->port_id, &dev_info);
10390 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10391 if (errno != 0 || *end != '\0' ||
10392 vf_id >= dev_info.max_vfs) {
10393 printf("invalid parameter %s.\n", res->pf_vf);
10396 entry.input.flow_ext.is_vf = 1;
10397 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10399 printf("invalid parameter %s.\n", res->pf_vf);
10404 /* set to report FD ID by default */
10405 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10406 entry.action.rx_queue = res->queue_id;
10407 entry.soft_id = res->fd_id_value;
10408 if (!strcmp(res->ops, "add"))
10409 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10410 RTE_ETH_FILTER_ADD, &entry);
10411 else if (!strcmp(res->ops, "del"))
10412 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10413 RTE_ETH_FILTER_DELETE, &entry);
10415 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10416 RTE_ETH_FILTER_UPDATE, &entry);
10418 printf("flow director programming error: (%s)\n",
10422 cmdline_parse_token_string_t cmd_flow_director_filter =
10423 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10424 flow_director_filter, "flow_director_filter");
10425 cmdline_parse_token_num_t cmd_flow_director_port_id =
10426 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10428 cmdline_parse_token_string_t cmd_flow_director_ops =
10429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10430 ops, "add#del#update");
10431 cmdline_parse_token_string_t cmd_flow_director_flow =
10432 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10434 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10435 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10437 cmdline_parse_token_string_t cmd_flow_director_ether =
10438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10440 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10441 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10442 ether_type, UINT16);
10443 cmdline_parse_token_string_t cmd_flow_director_src =
10444 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10446 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10447 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10449 cmdline_parse_token_num_t cmd_flow_director_port_src =
10450 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10452 cmdline_parse_token_string_t cmd_flow_director_dst =
10453 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10455 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10456 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10458 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10459 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10461 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10462 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10463 verify_tag, "verify_tag");
10464 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10465 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10466 verify_tag_value, UINT32);
10467 cmdline_parse_token_string_t cmd_flow_director_tos =
10468 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10470 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10471 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10473 cmdline_parse_token_string_t cmd_flow_director_proto =
10474 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10476 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10477 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10478 proto_value, UINT8);
10479 cmdline_parse_token_string_t cmd_flow_director_ttl =
10480 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10482 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10483 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10485 cmdline_parse_token_string_t cmd_flow_director_vlan =
10486 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10488 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10489 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10490 vlan_value, UINT16);
10491 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10492 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10493 flexbytes, "flexbytes");
10494 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10495 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10496 flexbytes_value, NULL);
10497 cmdline_parse_token_string_t cmd_flow_director_drop =
10498 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10500 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10501 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10503 cmdline_parse_token_string_t cmd_flow_director_queue =
10504 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10506 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10507 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10509 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10510 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10512 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10513 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10514 fd_id_value, UINT32);
10516 cmdline_parse_token_string_t cmd_flow_director_mode =
10517 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10519 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10520 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10522 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10523 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10524 mode_value, "MAC-VLAN");
10525 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10526 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10527 mode_value, "Tunnel");
10528 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10529 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10530 mode_value, "raw");
10531 cmdline_parse_token_string_t cmd_flow_director_mac =
10532 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10534 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10535 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10537 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10538 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10540 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10541 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10542 tunnel_type, "NVGRE#VxLAN");
10543 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10544 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10545 tunnel_id, "tunnel-id");
10546 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10547 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10548 tunnel_id_value, UINT32);
10549 cmdline_parse_token_string_t cmd_flow_director_packet =
10550 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10552 cmdline_parse_token_string_t cmd_flow_director_filepath =
10553 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10556 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10557 .f = cmd_flow_director_filter_parsed,
10559 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10560 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10561 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10562 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10563 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10564 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10565 "fd_id <fd_id_value>: "
10566 "Add or delete an ip flow director entry on NIC",
10568 (void *)&cmd_flow_director_filter,
10569 (void *)&cmd_flow_director_port_id,
10570 (void *)&cmd_flow_director_mode,
10571 (void *)&cmd_flow_director_mode_ip,
10572 (void *)&cmd_flow_director_ops,
10573 (void *)&cmd_flow_director_flow,
10574 (void *)&cmd_flow_director_flow_type,
10575 (void *)&cmd_flow_director_src,
10576 (void *)&cmd_flow_director_ip_src,
10577 (void *)&cmd_flow_director_dst,
10578 (void *)&cmd_flow_director_ip_dst,
10579 (void *)&cmd_flow_director_tos,
10580 (void *)&cmd_flow_director_tos_value,
10581 (void *)&cmd_flow_director_proto,
10582 (void *)&cmd_flow_director_proto_value,
10583 (void *)&cmd_flow_director_ttl,
10584 (void *)&cmd_flow_director_ttl_value,
10585 (void *)&cmd_flow_director_vlan,
10586 (void *)&cmd_flow_director_vlan_value,
10587 (void *)&cmd_flow_director_flexbytes,
10588 (void *)&cmd_flow_director_flexbytes_value,
10589 (void *)&cmd_flow_director_drop,
10590 (void *)&cmd_flow_director_pf_vf,
10591 (void *)&cmd_flow_director_queue,
10592 (void *)&cmd_flow_director_queue_id,
10593 (void *)&cmd_flow_director_fd_id,
10594 (void *)&cmd_flow_director_fd_id_value,
10599 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10600 .f = cmd_flow_director_filter_parsed,
10602 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10603 "director entry on NIC",
10605 (void *)&cmd_flow_director_filter,
10606 (void *)&cmd_flow_director_port_id,
10607 (void *)&cmd_flow_director_mode,
10608 (void *)&cmd_flow_director_mode_ip,
10609 (void *)&cmd_flow_director_ops,
10610 (void *)&cmd_flow_director_flow,
10611 (void *)&cmd_flow_director_flow_type,
10612 (void *)&cmd_flow_director_src,
10613 (void *)&cmd_flow_director_ip_src,
10614 (void *)&cmd_flow_director_port_src,
10615 (void *)&cmd_flow_director_dst,
10616 (void *)&cmd_flow_director_ip_dst,
10617 (void *)&cmd_flow_director_port_dst,
10618 (void *)&cmd_flow_director_tos,
10619 (void *)&cmd_flow_director_tos_value,
10620 (void *)&cmd_flow_director_ttl,
10621 (void *)&cmd_flow_director_ttl_value,
10622 (void *)&cmd_flow_director_vlan,
10623 (void *)&cmd_flow_director_vlan_value,
10624 (void *)&cmd_flow_director_flexbytes,
10625 (void *)&cmd_flow_director_flexbytes_value,
10626 (void *)&cmd_flow_director_drop,
10627 (void *)&cmd_flow_director_pf_vf,
10628 (void *)&cmd_flow_director_queue,
10629 (void *)&cmd_flow_director_queue_id,
10630 (void *)&cmd_flow_director_fd_id,
10631 (void *)&cmd_flow_director_fd_id_value,
10636 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10637 .f = cmd_flow_director_filter_parsed,
10639 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10640 "director entry on NIC",
10642 (void *)&cmd_flow_director_filter,
10643 (void *)&cmd_flow_director_port_id,
10644 (void *)&cmd_flow_director_mode,
10645 (void *)&cmd_flow_director_mode_ip,
10646 (void *)&cmd_flow_director_ops,
10647 (void *)&cmd_flow_director_flow,
10648 (void *)&cmd_flow_director_flow_type,
10649 (void *)&cmd_flow_director_src,
10650 (void *)&cmd_flow_director_ip_src,
10651 (void *)&cmd_flow_director_port_src,
10652 (void *)&cmd_flow_director_dst,
10653 (void *)&cmd_flow_director_ip_dst,
10654 (void *)&cmd_flow_director_port_dst,
10655 (void *)&cmd_flow_director_verify_tag,
10656 (void *)&cmd_flow_director_verify_tag_value,
10657 (void *)&cmd_flow_director_tos,
10658 (void *)&cmd_flow_director_tos_value,
10659 (void *)&cmd_flow_director_ttl,
10660 (void *)&cmd_flow_director_ttl_value,
10661 (void *)&cmd_flow_director_vlan,
10662 (void *)&cmd_flow_director_vlan_value,
10663 (void *)&cmd_flow_director_flexbytes,
10664 (void *)&cmd_flow_director_flexbytes_value,
10665 (void *)&cmd_flow_director_drop,
10666 (void *)&cmd_flow_director_pf_vf,
10667 (void *)&cmd_flow_director_queue,
10668 (void *)&cmd_flow_director_queue_id,
10669 (void *)&cmd_flow_director_fd_id,
10670 (void *)&cmd_flow_director_fd_id_value,
10675 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10676 .f = cmd_flow_director_filter_parsed,
10678 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10679 "director entry on NIC",
10681 (void *)&cmd_flow_director_filter,
10682 (void *)&cmd_flow_director_port_id,
10683 (void *)&cmd_flow_director_mode,
10684 (void *)&cmd_flow_director_mode_ip,
10685 (void *)&cmd_flow_director_ops,
10686 (void *)&cmd_flow_director_flow,
10687 (void *)&cmd_flow_director_flow_type,
10688 (void *)&cmd_flow_director_ether,
10689 (void *)&cmd_flow_director_ether_type,
10690 (void *)&cmd_flow_director_flexbytes,
10691 (void *)&cmd_flow_director_flexbytes_value,
10692 (void *)&cmd_flow_director_drop,
10693 (void *)&cmd_flow_director_pf_vf,
10694 (void *)&cmd_flow_director_queue,
10695 (void *)&cmd_flow_director_queue_id,
10696 (void *)&cmd_flow_director_fd_id,
10697 (void *)&cmd_flow_director_fd_id_value,
10702 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10703 .f = cmd_flow_director_filter_parsed,
10705 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10706 "director entry on NIC",
10708 (void *)&cmd_flow_director_filter,
10709 (void *)&cmd_flow_director_port_id,
10710 (void *)&cmd_flow_director_mode,
10711 (void *)&cmd_flow_director_mode_mac_vlan,
10712 (void *)&cmd_flow_director_ops,
10713 (void *)&cmd_flow_director_mac,
10714 (void *)&cmd_flow_director_mac_addr,
10715 (void *)&cmd_flow_director_vlan,
10716 (void *)&cmd_flow_director_vlan_value,
10717 (void *)&cmd_flow_director_flexbytes,
10718 (void *)&cmd_flow_director_flexbytes_value,
10719 (void *)&cmd_flow_director_drop,
10720 (void *)&cmd_flow_director_queue,
10721 (void *)&cmd_flow_director_queue_id,
10722 (void *)&cmd_flow_director_fd_id,
10723 (void *)&cmd_flow_director_fd_id_value,
10728 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10729 .f = cmd_flow_director_filter_parsed,
10731 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10732 "director entry on NIC",
10734 (void *)&cmd_flow_director_filter,
10735 (void *)&cmd_flow_director_port_id,
10736 (void *)&cmd_flow_director_mode,
10737 (void *)&cmd_flow_director_mode_tunnel,
10738 (void *)&cmd_flow_director_ops,
10739 (void *)&cmd_flow_director_mac,
10740 (void *)&cmd_flow_director_mac_addr,
10741 (void *)&cmd_flow_director_vlan,
10742 (void *)&cmd_flow_director_vlan_value,
10743 (void *)&cmd_flow_director_tunnel,
10744 (void *)&cmd_flow_director_tunnel_type,
10745 (void *)&cmd_flow_director_tunnel_id,
10746 (void *)&cmd_flow_director_tunnel_id_value,
10747 (void *)&cmd_flow_director_flexbytes,
10748 (void *)&cmd_flow_director_flexbytes_value,
10749 (void *)&cmd_flow_director_drop,
10750 (void *)&cmd_flow_director_queue,
10751 (void *)&cmd_flow_director_queue_id,
10752 (void *)&cmd_flow_director_fd_id,
10753 (void *)&cmd_flow_director_fd_id_value,
10758 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10759 .f = cmd_flow_director_filter_parsed,
10761 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10762 "director entry on NIC",
10764 (void *)&cmd_flow_director_filter,
10765 (void *)&cmd_flow_director_port_id,
10766 (void *)&cmd_flow_director_mode,
10767 (void *)&cmd_flow_director_mode_raw,
10768 (void *)&cmd_flow_director_ops,
10769 (void *)&cmd_flow_director_flow,
10770 (void *)&cmd_flow_director_flow_type,
10771 (void *)&cmd_flow_director_drop,
10772 (void *)&cmd_flow_director_queue,
10773 (void *)&cmd_flow_director_queue_id,
10774 (void *)&cmd_flow_director_fd_id,
10775 (void *)&cmd_flow_director_fd_id_value,
10776 (void *)&cmd_flow_director_packet,
10777 (void *)&cmd_flow_director_filepath,
10782 struct cmd_flush_flow_director_result {
10783 cmdline_fixed_string_t flush_flow_director;
10787 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10788 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10789 flush_flow_director, "flush_flow_director");
10790 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10791 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10795 cmd_flush_flow_director_parsed(void *parsed_result,
10796 __attribute__((unused)) struct cmdline *cl,
10797 __attribute__((unused)) void *data)
10799 struct cmd_flow_director_result *res = parsed_result;
10802 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10804 printf("flow director is not supported on port %u.\n",
10809 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10810 RTE_ETH_FILTER_FLUSH, NULL);
10812 printf("flow director table flushing error: (%s)\n",
10816 cmdline_parse_inst_t cmd_flush_flow_director = {
10817 .f = cmd_flush_flow_director_parsed,
10819 .help_str = "flush_flow_director <port_id>: "
10820 "Flush all flow director entries of a device on NIC",
10822 (void *)&cmd_flush_flow_director_flush,
10823 (void *)&cmd_flush_flow_director_port_id,
10828 /* *** deal with flow director mask *** */
10829 struct cmd_flow_director_mask_result {
10830 cmdline_fixed_string_t flow_director_mask;
10832 cmdline_fixed_string_t mode;
10833 cmdline_fixed_string_t mode_value;
10834 cmdline_fixed_string_t vlan;
10835 uint16_t vlan_mask;
10836 cmdline_fixed_string_t src_mask;
10837 cmdline_ipaddr_t ipv4_src;
10838 cmdline_ipaddr_t ipv6_src;
10840 cmdline_fixed_string_t dst_mask;
10841 cmdline_ipaddr_t ipv4_dst;
10842 cmdline_ipaddr_t ipv6_dst;
10844 cmdline_fixed_string_t mac;
10845 uint8_t mac_addr_byte_mask;
10846 cmdline_fixed_string_t tunnel_id;
10847 uint32_t tunnel_id_mask;
10848 cmdline_fixed_string_t tunnel_type;
10849 uint8_t tunnel_type_mask;
10853 cmd_flow_director_mask_parsed(void *parsed_result,
10854 __attribute__((unused)) struct cmdline *cl,
10855 __attribute__((unused)) void *data)
10857 struct cmd_flow_director_mask_result *res = parsed_result;
10858 struct rte_eth_fdir_masks *mask;
10859 struct rte_port *port;
10861 port = &ports[res->port_id];
10862 /** Check if the port is not started **/
10863 if (port->port_status != RTE_PORT_STOPPED) {
10864 printf("Please stop port %d first\n", res->port_id);
10868 mask = &port->dev_conf.fdir_conf.mask;
10870 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10871 if (strcmp(res->mode_value, "MAC-VLAN")) {
10872 printf("Please set mode to MAC-VLAN.\n");
10876 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10877 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10878 if (strcmp(res->mode_value, "Tunnel")) {
10879 printf("Please set mode to Tunnel.\n");
10883 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10884 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10885 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10886 mask->tunnel_type_mask = res->tunnel_type_mask;
10888 if (strcmp(res->mode_value, "IP")) {
10889 printf("Please set mode to IP.\n");
10893 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10894 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10895 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10896 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10897 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10898 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10899 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10902 cmd_reconfig_device_queue(res->port_id, 1, 1);
10905 cmdline_parse_token_string_t cmd_flow_director_mask =
10906 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10907 flow_director_mask, "flow_director_mask");
10908 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10909 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10911 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10912 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10914 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10915 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10916 vlan_mask, UINT16);
10917 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10918 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10919 src_mask, "src_mask");
10920 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10921 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10923 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10924 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10926 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10927 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10929 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10930 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10931 dst_mask, "dst_mask");
10932 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10933 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10935 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10936 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10938 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10939 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10942 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10943 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10945 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10948 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10949 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10950 mode_value, "MAC-VLAN");
10951 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10952 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10953 mode_value, "Tunnel");
10954 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10955 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10957 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10958 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10959 mac_addr_byte_mask, UINT8);
10960 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10961 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10962 tunnel_type, "tunnel-type");
10963 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10964 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10965 tunnel_type_mask, UINT8);
10966 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10967 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10968 tunnel_id, "tunnel-id");
10969 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10970 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10971 tunnel_id_mask, UINT32);
10973 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10974 .f = cmd_flow_director_mask_parsed,
10976 .help_str = "flow_director_mask ... : "
10977 "Set IP mode flow director's mask on NIC",
10979 (void *)&cmd_flow_director_mask,
10980 (void *)&cmd_flow_director_mask_port_id,
10981 (void *)&cmd_flow_director_mask_mode,
10982 (void *)&cmd_flow_director_mask_mode_ip,
10983 (void *)&cmd_flow_director_mask_vlan,
10984 (void *)&cmd_flow_director_mask_vlan_value,
10985 (void *)&cmd_flow_director_mask_src,
10986 (void *)&cmd_flow_director_mask_ipv4_src,
10987 (void *)&cmd_flow_director_mask_ipv6_src,
10988 (void *)&cmd_flow_director_mask_port_src,
10989 (void *)&cmd_flow_director_mask_dst,
10990 (void *)&cmd_flow_director_mask_ipv4_dst,
10991 (void *)&cmd_flow_director_mask_ipv6_dst,
10992 (void *)&cmd_flow_director_mask_port_dst,
10997 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10998 .f = cmd_flow_director_mask_parsed,
11000 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11001 "flow director's mask on NIC",
11003 (void *)&cmd_flow_director_mask,
11004 (void *)&cmd_flow_director_mask_port_id,
11005 (void *)&cmd_flow_director_mask_mode,
11006 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11007 (void *)&cmd_flow_director_mask_vlan,
11008 (void *)&cmd_flow_director_mask_vlan_value,
11013 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11014 .f = cmd_flow_director_mask_parsed,
11016 .help_str = "flow_director_mask ... : Set tunnel mode "
11017 "flow director's mask on NIC",
11019 (void *)&cmd_flow_director_mask,
11020 (void *)&cmd_flow_director_mask_port_id,
11021 (void *)&cmd_flow_director_mask_mode,
11022 (void *)&cmd_flow_director_mask_mode_tunnel,
11023 (void *)&cmd_flow_director_mask_vlan,
11024 (void *)&cmd_flow_director_mask_vlan_value,
11025 (void *)&cmd_flow_director_mask_mac,
11026 (void *)&cmd_flow_director_mask_mac_value,
11027 (void *)&cmd_flow_director_mask_tunnel_type,
11028 (void *)&cmd_flow_director_mask_tunnel_type_value,
11029 (void *)&cmd_flow_director_mask_tunnel_id,
11030 (void *)&cmd_flow_director_mask_tunnel_id_value,
11035 /* *** deal with flow director mask on flexible payload *** */
11036 struct cmd_flow_director_flex_mask_result {
11037 cmdline_fixed_string_t flow_director_flexmask;
11039 cmdline_fixed_string_t flow;
11040 cmdline_fixed_string_t flow_type;
11041 cmdline_fixed_string_t mask;
11045 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11046 __attribute__((unused)) struct cmdline *cl,
11047 __attribute__((unused)) void *data)
11049 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11050 struct rte_eth_fdir_info fdir_info;
11051 struct rte_eth_fdir_flex_mask flex_mask;
11052 struct rte_port *port;
11053 uint64_t flow_type_mask;
11057 port = &ports[res->port_id];
11058 /** Check if the port is not started **/
11059 if (port->port_status != RTE_PORT_STOPPED) {
11060 printf("Please stop port %d first\n", res->port_id);
11064 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11065 ret = parse_flexbytes(res->mask,
11067 RTE_ETH_FDIR_MAX_FLEXLEN);
11069 printf("error: Cannot parse mask input.\n");
11073 memset(&fdir_info, 0, sizeof(fdir_info));
11074 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11075 RTE_ETH_FILTER_INFO, &fdir_info);
11077 printf("Cannot get FDir filter info\n");
11081 if (!strcmp(res->flow_type, "none")) {
11082 /* means don't specify the flow type */
11083 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11084 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11085 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11086 0, sizeof(struct rte_eth_fdir_flex_mask));
11087 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11088 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11090 sizeof(struct rte_eth_fdir_flex_mask));
11091 cmd_reconfig_device_queue(res->port_id, 1, 1);
11094 flow_type_mask = fdir_info.flow_types_mask[0];
11095 if (!strcmp(res->flow_type, "all")) {
11096 if (!flow_type_mask) {
11097 printf("No flow type supported\n");
11100 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11101 if (flow_type_mask & (1ULL << i)) {
11102 flex_mask.flow_type = i;
11103 fdir_set_flex_mask(res->port_id, &flex_mask);
11106 cmd_reconfig_device_queue(res->port_id, 1, 1);
11109 flex_mask.flow_type = str2flowtype(res->flow_type);
11110 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11111 printf("Flow type %s not supported on port %d\n",
11112 res->flow_type, res->port_id);
11115 fdir_set_flex_mask(res->port_id, &flex_mask);
11116 cmd_reconfig_device_queue(res->port_id, 1, 1);
11119 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11120 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11121 flow_director_flexmask,
11122 "flow_director_flex_mask");
11123 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11124 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11126 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11127 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11129 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11131 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11132 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11133 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11137 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11138 .f = cmd_flow_director_flex_mask_parsed,
11140 .help_str = "flow_director_flex_mask ... : "
11141 "Set flow director's flex mask on NIC",
11143 (void *)&cmd_flow_director_flexmask,
11144 (void *)&cmd_flow_director_flexmask_port_id,
11145 (void *)&cmd_flow_director_flexmask_flow,
11146 (void *)&cmd_flow_director_flexmask_flow_type,
11147 (void *)&cmd_flow_director_flexmask_mask,
11152 /* *** deal with flow director flexible payload configuration *** */
11153 struct cmd_flow_director_flexpayload_result {
11154 cmdline_fixed_string_t flow_director_flexpayload;
11156 cmdline_fixed_string_t payload_layer;
11157 cmdline_fixed_string_t payload_cfg;
11161 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11164 const char *p, *p0 = q_arg;
11166 unsigned long int_fld;
11167 char *str_fld[max_num];
11172 p = strchr(p0, '(');
11176 p0 = strchr(p, ')');
11181 if (size >= sizeof(s))
11184 snprintf(s, sizeof(s), "%.*s", size, p);
11185 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11186 if (ret < 0 || ret > max_num)
11188 for (i = 0; i < ret; i++) {
11190 int_fld = strtoul(str_fld[i], &end, 0);
11191 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11193 offsets[i] = (uint16_t)int_fld;
11199 cmd_flow_director_flxpld_parsed(void *parsed_result,
11200 __attribute__((unused)) struct cmdline *cl,
11201 __attribute__((unused)) void *data)
11203 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11204 struct rte_eth_flex_payload_cfg flex_cfg;
11205 struct rte_port *port;
11208 port = &ports[res->port_id];
11209 /** Check if the port is not started **/
11210 if (port->port_status != RTE_PORT_STOPPED) {
11211 printf("Please stop port %d first\n", res->port_id);
11215 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11217 if (!strcmp(res->payload_layer, "raw"))
11218 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11219 else if (!strcmp(res->payload_layer, "l2"))
11220 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11221 else if (!strcmp(res->payload_layer, "l3"))
11222 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11223 else if (!strcmp(res->payload_layer, "l4"))
11224 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11226 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11227 RTE_ETH_FDIR_MAX_FLEXLEN);
11229 printf("error: Cannot parse flex payload input.\n");
11233 fdir_set_flex_payload(res->port_id, &flex_cfg);
11234 cmd_reconfig_device_queue(res->port_id, 1, 1);
11237 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11238 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11239 flow_director_flexpayload,
11240 "flow_director_flex_payload");
11241 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11242 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11244 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11246 payload_layer, "raw#l2#l3#l4");
11247 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11249 payload_cfg, NULL);
11251 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11252 .f = cmd_flow_director_flxpld_parsed,
11254 .help_str = "flow_director_flexpayload ... : "
11255 "Set flow director's flex payload on NIC",
11257 (void *)&cmd_flow_director_flexpayload,
11258 (void *)&cmd_flow_director_flexpayload_port_id,
11259 (void *)&cmd_flow_director_flexpayload_payload_layer,
11260 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11265 /* Generic flow interface command. */
11266 extern cmdline_parse_inst_t cmd_flow;
11268 /* *** Classification Filters Control *** */
11269 /* *** Get symmetric hash enable per port *** */
11270 struct cmd_get_sym_hash_ena_per_port_result {
11271 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11276 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11277 __rte_unused struct cmdline *cl,
11278 __rte_unused void *data)
11280 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11281 struct rte_eth_hash_filter_info info;
11284 if (rte_eth_dev_filter_supported(res->port_id,
11285 RTE_ETH_FILTER_HASH) < 0) {
11286 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11291 memset(&info, 0, sizeof(info));
11292 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11293 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11294 RTE_ETH_FILTER_GET, &info);
11297 printf("Cannot get symmetric hash enable per port "
11298 "on port %u\n", res->port_id);
11302 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11303 "enabled" : "disabled", res->port_id);
11306 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11307 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11308 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11309 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11310 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11313 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11314 .f = cmd_get_sym_hash_per_port_parsed,
11316 .help_str = "get_sym_hash_ena_per_port <port_id>",
11318 (void *)&cmd_get_sym_hash_ena_per_port_all,
11319 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11324 /* *** Set symmetric hash enable per port *** */
11325 struct cmd_set_sym_hash_ena_per_port_result {
11326 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11327 cmdline_fixed_string_t enable;
11332 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11333 __rte_unused struct cmdline *cl,
11334 __rte_unused void *data)
11336 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11337 struct rte_eth_hash_filter_info info;
11340 if (rte_eth_dev_filter_supported(res->port_id,
11341 RTE_ETH_FILTER_HASH) < 0) {
11342 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11347 memset(&info, 0, sizeof(info));
11348 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11349 if (!strcmp(res->enable, "enable"))
11350 info.info.enable = 1;
11351 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11352 RTE_ETH_FILTER_SET, &info);
11354 printf("Cannot set symmetric hash enable per port on "
11355 "port %u\n", res->port_id);
11358 printf("Symmetric hash has been set to %s on port %u\n",
11359 res->enable, res->port_id);
11362 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11363 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11364 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11365 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11366 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11368 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11369 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11370 enable, "enable#disable");
11372 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11373 .f = cmd_set_sym_hash_per_port_parsed,
11375 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11377 (void *)&cmd_set_sym_hash_ena_per_port_all,
11378 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11379 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11384 /* Get global config of hash function */
11385 struct cmd_get_hash_global_config_result {
11386 cmdline_fixed_string_t get_hash_global_config;
11391 flowtype_to_str(uint16_t ftype)
11397 } ftype_table[] = {
11398 {"ipv4", RTE_ETH_FLOW_IPV4},
11399 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11400 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11401 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11402 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11403 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11404 {"ipv6", RTE_ETH_FLOW_IPV6},
11405 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11406 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11407 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11408 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11409 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11410 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11411 {"port", RTE_ETH_FLOW_PORT},
11412 {"vxlan", RTE_ETH_FLOW_VXLAN},
11413 {"geneve", RTE_ETH_FLOW_GENEVE},
11414 {"nvgre", RTE_ETH_FLOW_NVGRE},
11417 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11418 if (ftype_table[i].ftype == ftype)
11419 return ftype_table[i].str;
11426 cmd_get_hash_global_config_parsed(void *parsed_result,
11427 __rte_unused struct cmdline *cl,
11428 __rte_unused void *data)
11430 struct cmd_get_hash_global_config_result *res = parsed_result;
11431 struct rte_eth_hash_filter_info info;
11432 uint32_t idx, offset;
11437 if (rte_eth_dev_filter_supported(res->port_id,
11438 RTE_ETH_FILTER_HASH) < 0) {
11439 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11444 memset(&info, 0, sizeof(info));
11445 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11446 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11447 RTE_ETH_FILTER_GET, &info);
11449 printf("Cannot get hash global configurations by port %d\n",
11454 switch (info.info.global_conf.hash_func) {
11455 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11456 printf("Hash function is Toeplitz\n");
11458 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11459 printf("Hash function is Simple XOR\n");
11462 printf("Unknown hash function\n");
11466 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11467 idx = i / UINT64_BIT;
11468 offset = i % UINT64_BIT;
11469 if (!(info.info.global_conf.valid_bit_mask[idx] &
11472 str = flowtype_to_str(i);
11475 printf("Symmetric hash is %s globally for flow type %s "
11477 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11478 (1ULL << offset)) ? "enabled" : "disabled"), str,
11483 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11484 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11485 get_hash_global_config, "get_hash_global_config");
11486 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11487 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11490 cmdline_parse_inst_t cmd_get_hash_global_config = {
11491 .f = cmd_get_hash_global_config_parsed,
11493 .help_str = "get_hash_global_config <port_id>",
11495 (void *)&cmd_get_hash_global_config_all,
11496 (void *)&cmd_get_hash_global_config_port_id,
11501 /* Set global config of hash function */
11502 struct cmd_set_hash_global_config_result {
11503 cmdline_fixed_string_t set_hash_global_config;
11505 cmdline_fixed_string_t hash_func;
11506 cmdline_fixed_string_t flow_type;
11507 cmdline_fixed_string_t enable;
11511 cmd_set_hash_global_config_parsed(void *parsed_result,
11512 __rte_unused struct cmdline *cl,
11513 __rte_unused void *data)
11515 struct cmd_set_hash_global_config_result *res = parsed_result;
11516 struct rte_eth_hash_filter_info info;
11517 uint32_t ftype, idx, offset;
11520 if (rte_eth_dev_filter_supported(res->port_id,
11521 RTE_ETH_FILTER_HASH) < 0) {
11522 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11526 memset(&info, 0, sizeof(info));
11527 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11528 if (!strcmp(res->hash_func, "toeplitz"))
11529 info.info.global_conf.hash_func =
11530 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11531 else if (!strcmp(res->hash_func, "simple_xor"))
11532 info.info.global_conf.hash_func =
11533 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11534 else if (!strcmp(res->hash_func, "default"))
11535 info.info.global_conf.hash_func =
11536 RTE_ETH_HASH_FUNCTION_DEFAULT;
11538 ftype = str2flowtype(res->flow_type);
11539 idx = ftype / UINT64_BIT;
11540 offset = ftype % UINT64_BIT;
11541 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11542 if (!strcmp(res->enable, "enable"))
11543 info.info.global_conf.sym_hash_enable_mask[idx] |=
11545 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11546 RTE_ETH_FILTER_SET, &info);
11548 printf("Cannot set global hash configurations by port %d\n",
11551 printf("Global hash configurations have been set "
11552 "succcessfully by port %d\n", res->port_id);
11555 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11556 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11557 set_hash_global_config, "set_hash_global_config");
11558 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11559 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11561 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11562 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11563 hash_func, "toeplitz#simple_xor#default");
11564 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11565 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11567 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11568 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11569 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11570 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11571 enable, "enable#disable");
11573 cmdline_parse_inst_t cmd_set_hash_global_config = {
11574 .f = cmd_set_hash_global_config_parsed,
11576 .help_str = "set_hash_global_config <port_id> "
11577 "toeplitz|simple_xor|default "
11578 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11579 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11580 "l2_payload enable|disable",
11582 (void *)&cmd_set_hash_global_config_all,
11583 (void *)&cmd_set_hash_global_config_port_id,
11584 (void *)&cmd_set_hash_global_config_hash_func,
11585 (void *)&cmd_set_hash_global_config_flow_type,
11586 (void *)&cmd_set_hash_global_config_enable,
11591 /* Set hash input set */
11592 struct cmd_set_hash_input_set_result {
11593 cmdline_fixed_string_t set_hash_input_set;
11595 cmdline_fixed_string_t flow_type;
11596 cmdline_fixed_string_t inset_field;
11597 cmdline_fixed_string_t select;
11600 static enum rte_eth_input_set_field
11601 str2inset(char *string)
11605 static const struct {
11607 enum rte_eth_input_set_field inset;
11608 } inset_table[] = {
11609 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11610 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11611 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11612 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11613 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11614 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11615 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11616 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11617 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11618 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11619 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11620 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11621 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11622 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11623 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11624 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11625 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11626 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11627 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11628 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11629 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11630 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11631 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11632 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11633 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11634 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11635 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11636 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11637 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11638 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11639 {"none", RTE_ETH_INPUT_SET_NONE},
11642 for (i = 0; i < RTE_DIM(inset_table); i++) {
11643 if (!strcmp(string, inset_table[i].str))
11644 return inset_table[i].inset;
11647 return RTE_ETH_INPUT_SET_UNKNOWN;
11651 cmd_set_hash_input_set_parsed(void *parsed_result,
11652 __rte_unused struct cmdline *cl,
11653 __rte_unused void *data)
11655 struct cmd_set_hash_input_set_result *res = parsed_result;
11656 struct rte_eth_hash_filter_info info;
11658 memset(&info, 0, sizeof(info));
11659 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11660 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11661 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11662 info.info.input_set_conf.inset_size = 1;
11663 if (!strcmp(res->select, "select"))
11664 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11665 else if (!strcmp(res->select, "add"))
11666 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11667 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11668 RTE_ETH_FILTER_SET, &info);
11671 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11672 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11673 set_hash_input_set, "set_hash_input_set");
11674 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11675 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11677 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11678 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11680 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11681 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11683 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11684 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11685 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11686 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11687 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11689 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11690 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11691 select, "select#add");
11693 cmdline_parse_inst_t cmd_set_hash_input_set = {
11694 .f = cmd_set_hash_input_set_parsed,
11696 .help_str = "set_hash_input_set <port_id> "
11697 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11698 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11699 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11700 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11701 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11702 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11703 "fld-7th|fld-8th|none select|add",
11705 (void *)&cmd_set_hash_input_set_cmd,
11706 (void *)&cmd_set_hash_input_set_port_id,
11707 (void *)&cmd_set_hash_input_set_flow_type,
11708 (void *)&cmd_set_hash_input_set_field,
11709 (void *)&cmd_set_hash_input_set_select,
11714 /* Set flow director input set */
11715 struct cmd_set_fdir_input_set_result {
11716 cmdline_fixed_string_t set_fdir_input_set;
11718 cmdline_fixed_string_t flow_type;
11719 cmdline_fixed_string_t inset_field;
11720 cmdline_fixed_string_t select;
11724 cmd_set_fdir_input_set_parsed(void *parsed_result,
11725 __rte_unused struct cmdline *cl,
11726 __rte_unused void *data)
11728 struct cmd_set_fdir_input_set_result *res = parsed_result;
11729 struct rte_eth_fdir_filter_info info;
11731 memset(&info, 0, sizeof(info));
11732 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11733 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11734 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11735 info.info.input_set_conf.inset_size = 1;
11736 if (!strcmp(res->select, "select"))
11737 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11738 else if (!strcmp(res->select, "add"))
11739 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11740 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11741 RTE_ETH_FILTER_SET, &info);
11744 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11745 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11746 set_fdir_input_set, "set_fdir_input_set");
11747 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11748 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11750 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11751 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11753 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11754 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11755 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11756 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11758 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11759 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11760 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11761 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11762 "sctp-veri-tag#none");
11763 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11764 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11765 select, "select#add");
11767 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11768 .f = cmd_set_fdir_input_set_parsed,
11770 .help_str = "set_fdir_input_set <port_id> "
11771 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11772 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11773 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11774 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11775 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11776 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11777 "sctp-veri-tag|none select|add",
11779 (void *)&cmd_set_fdir_input_set_cmd,
11780 (void *)&cmd_set_fdir_input_set_port_id,
11781 (void *)&cmd_set_fdir_input_set_flow_type,
11782 (void *)&cmd_set_fdir_input_set_field,
11783 (void *)&cmd_set_fdir_input_set_select,
11788 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11789 struct cmd_mcast_addr_result {
11790 cmdline_fixed_string_t mcast_addr_cmd;
11791 cmdline_fixed_string_t what;
11793 struct ether_addr mc_addr;
11796 static void cmd_mcast_addr_parsed(void *parsed_result,
11797 __attribute__((unused)) struct cmdline *cl,
11798 __attribute__((unused)) void *data)
11800 struct cmd_mcast_addr_result *res = parsed_result;
11802 if (!is_multicast_ether_addr(&res->mc_addr)) {
11803 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11804 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11805 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11806 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11809 if (strcmp(res->what, "add") == 0)
11810 mcast_addr_add(res->port_num, &res->mc_addr);
11812 mcast_addr_remove(res->port_num, &res->mc_addr);
11815 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11816 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11817 mcast_addr_cmd, "mcast_addr");
11818 cmdline_parse_token_string_t cmd_mcast_addr_what =
11819 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11821 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11822 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11823 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11824 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11826 cmdline_parse_inst_t cmd_mcast_addr = {
11827 .f = cmd_mcast_addr_parsed,
11829 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11830 "Add/Remove multicast MAC address on port_id",
11832 (void *)&cmd_mcast_addr_cmd,
11833 (void *)&cmd_mcast_addr_what,
11834 (void *)&cmd_mcast_addr_portnum,
11835 (void *)&cmd_mcast_addr_addr,
11840 /* l2 tunnel config
11841 * only support E-tag now.
11844 /* Ether type config */
11845 struct cmd_config_l2_tunnel_eth_type_result {
11846 cmdline_fixed_string_t port;
11847 cmdline_fixed_string_t config;
11848 cmdline_fixed_string_t all;
11850 cmdline_fixed_string_t l2_tunnel;
11851 cmdline_fixed_string_t l2_tunnel_type;
11852 cmdline_fixed_string_t eth_type;
11853 uint16_t eth_type_val;
11856 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11857 TOKEN_STRING_INITIALIZER
11858 (struct cmd_config_l2_tunnel_eth_type_result,
11860 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11861 TOKEN_STRING_INITIALIZER
11862 (struct cmd_config_l2_tunnel_eth_type_result,
11864 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11865 TOKEN_STRING_INITIALIZER
11866 (struct cmd_config_l2_tunnel_eth_type_result,
11868 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11869 TOKEN_NUM_INITIALIZER
11870 (struct cmd_config_l2_tunnel_eth_type_result,
11872 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11873 TOKEN_STRING_INITIALIZER
11874 (struct cmd_config_l2_tunnel_eth_type_result,
11875 l2_tunnel, "l2-tunnel");
11876 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11877 TOKEN_STRING_INITIALIZER
11878 (struct cmd_config_l2_tunnel_eth_type_result,
11879 l2_tunnel_type, "E-tag");
11880 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11881 TOKEN_STRING_INITIALIZER
11882 (struct cmd_config_l2_tunnel_eth_type_result,
11883 eth_type, "ether-type");
11884 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11885 TOKEN_NUM_INITIALIZER
11886 (struct cmd_config_l2_tunnel_eth_type_result,
11887 eth_type_val, UINT16);
11889 static enum rte_eth_tunnel_type
11890 str2fdir_l2_tunnel_type(char *string)
11894 static const struct {
11896 enum rte_eth_tunnel_type type;
11897 } l2_tunnel_type_str[] = {
11898 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11901 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11902 if (!strcmp(l2_tunnel_type_str[i].str, string))
11903 return l2_tunnel_type_str[i].type;
11905 return RTE_TUNNEL_TYPE_NONE;
11908 /* ether type config for all ports */
11910 cmd_config_l2_tunnel_eth_type_all_parsed
11911 (void *parsed_result,
11912 __attribute__((unused)) struct cmdline *cl,
11913 __attribute__((unused)) void *data)
11915 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11916 struct rte_eth_l2_tunnel_conf entry;
11919 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11920 entry.ether_type = res->eth_type_val;
11922 RTE_ETH_FOREACH_DEV(pid) {
11923 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11927 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11928 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11930 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11932 (void *)&cmd_config_l2_tunnel_eth_type_port,
11933 (void *)&cmd_config_l2_tunnel_eth_type_config,
11934 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11935 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11936 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11937 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11938 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11943 /* ether type config for a specific port */
11945 cmd_config_l2_tunnel_eth_type_specific_parsed(
11946 void *parsed_result,
11947 __attribute__((unused)) struct cmdline *cl,
11948 __attribute__((unused)) void *data)
11950 struct cmd_config_l2_tunnel_eth_type_result *res =
11952 struct rte_eth_l2_tunnel_conf entry;
11954 if (port_id_is_invalid(res->id, ENABLED_WARN))
11957 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11958 entry.ether_type = res->eth_type_val;
11960 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11963 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11964 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11966 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11968 (void *)&cmd_config_l2_tunnel_eth_type_port,
11969 (void *)&cmd_config_l2_tunnel_eth_type_config,
11970 (void *)&cmd_config_l2_tunnel_eth_type_id,
11971 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11972 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11973 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11974 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11979 /* Enable/disable l2 tunnel */
11980 struct cmd_config_l2_tunnel_en_dis_result {
11981 cmdline_fixed_string_t port;
11982 cmdline_fixed_string_t config;
11983 cmdline_fixed_string_t all;
11985 cmdline_fixed_string_t l2_tunnel;
11986 cmdline_fixed_string_t l2_tunnel_type;
11987 cmdline_fixed_string_t en_dis;
11990 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11991 TOKEN_STRING_INITIALIZER
11992 (struct cmd_config_l2_tunnel_en_dis_result,
11994 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11995 TOKEN_STRING_INITIALIZER
11996 (struct cmd_config_l2_tunnel_en_dis_result,
11998 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11999 TOKEN_STRING_INITIALIZER
12000 (struct cmd_config_l2_tunnel_en_dis_result,
12002 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12003 TOKEN_NUM_INITIALIZER
12004 (struct cmd_config_l2_tunnel_en_dis_result,
12006 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12007 TOKEN_STRING_INITIALIZER
12008 (struct cmd_config_l2_tunnel_en_dis_result,
12009 l2_tunnel, "l2-tunnel");
12010 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12011 TOKEN_STRING_INITIALIZER
12012 (struct cmd_config_l2_tunnel_en_dis_result,
12013 l2_tunnel_type, "E-tag");
12014 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12015 TOKEN_STRING_INITIALIZER
12016 (struct cmd_config_l2_tunnel_en_dis_result,
12017 en_dis, "enable#disable");
12019 /* enable/disable l2 tunnel for all ports */
12021 cmd_config_l2_tunnel_en_dis_all_parsed(
12022 void *parsed_result,
12023 __attribute__((unused)) struct cmdline *cl,
12024 __attribute__((unused)) void *data)
12026 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12027 struct rte_eth_l2_tunnel_conf entry;
12031 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12033 if (!strcmp("enable", res->en_dis))
12038 RTE_ETH_FOREACH_DEV(pid) {
12039 rte_eth_dev_l2_tunnel_offload_set(pid,
12041 ETH_L2_TUNNEL_ENABLE_MASK,
12046 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12047 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12049 .help_str = "port config all l2-tunnel E-tag enable|disable",
12051 (void *)&cmd_config_l2_tunnel_en_dis_port,
12052 (void *)&cmd_config_l2_tunnel_en_dis_config,
12053 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12054 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12055 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12056 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12061 /* enable/disable l2 tunnel for a port */
12063 cmd_config_l2_tunnel_en_dis_specific_parsed(
12064 void *parsed_result,
12065 __attribute__((unused)) struct cmdline *cl,
12066 __attribute__((unused)) void *data)
12068 struct cmd_config_l2_tunnel_en_dis_result *res =
12070 struct rte_eth_l2_tunnel_conf entry;
12072 if (port_id_is_invalid(res->id, ENABLED_WARN))
12075 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12077 if (!strcmp("enable", res->en_dis))
12078 rte_eth_dev_l2_tunnel_offload_set(res->id,
12080 ETH_L2_TUNNEL_ENABLE_MASK,
12083 rte_eth_dev_l2_tunnel_offload_set(res->id,
12085 ETH_L2_TUNNEL_ENABLE_MASK,
12089 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12090 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12092 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12094 (void *)&cmd_config_l2_tunnel_en_dis_port,
12095 (void *)&cmd_config_l2_tunnel_en_dis_config,
12096 (void *)&cmd_config_l2_tunnel_en_dis_id,
12097 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12098 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12099 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12104 /* E-tag configuration */
12106 /* Common result structure for all E-tag configuration */
12107 struct cmd_config_e_tag_result {
12108 cmdline_fixed_string_t e_tag;
12109 cmdline_fixed_string_t set;
12110 cmdline_fixed_string_t insertion;
12111 cmdline_fixed_string_t stripping;
12112 cmdline_fixed_string_t forwarding;
12113 cmdline_fixed_string_t filter;
12114 cmdline_fixed_string_t add;
12115 cmdline_fixed_string_t del;
12116 cmdline_fixed_string_t on;
12117 cmdline_fixed_string_t off;
12118 cmdline_fixed_string_t on_off;
12119 cmdline_fixed_string_t port_tag_id;
12120 uint32_t port_tag_id_val;
12121 cmdline_fixed_string_t e_tag_id;
12122 uint16_t e_tag_id_val;
12123 cmdline_fixed_string_t dst_pool;
12124 uint8_t dst_pool_val;
12125 cmdline_fixed_string_t port;
12127 cmdline_fixed_string_t vf;
12131 /* Common CLI fields for all E-tag configuration */
12132 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12133 TOKEN_STRING_INITIALIZER
12134 (struct cmd_config_e_tag_result,
12136 cmdline_parse_token_string_t cmd_config_e_tag_set =
12137 TOKEN_STRING_INITIALIZER
12138 (struct cmd_config_e_tag_result,
12140 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12141 TOKEN_STRING_INITIALIZER
12142 (struct cmd_config_e_tag_result,
12143 insertion, "insertion");
12144 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12145 TOKEN_STRING_INITIALIZER
12146 (struct cmd_config_e_tag_result,
12147 stripping, "stripping");
12148 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12149 TOKEN_STRING_INITIALIZER
12150 (struct cmd_config_e_tag_result,
12151 forwarding, "forwarding");
12152 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12153 TOKEN_STRING_INITIALIZER
12154 (struct cmd_config_e_tag_result,
12156 cmdline_parse_token_string_t cmd_config_e_tag_add =
12157 TOKEN_STRING_INITIALIZER
12158 (struct cmd_config_e_tag_result,
12160 cmdline_parse_token_string_t cmd_config_e_tag_del =
12161 TOKEN_STRING_INITIALIZER
12162 (struct cmd_config_e_tag_result,
12164 cmdline_parse_token_string_t cmd_config_e_tag_on =
12165 TOKEN_STRING_INITIALIZER
12166 (struct cmd_config_e_tag_result,
12168 cmdline_parse_token_string_t cmd_config_e_tag_off =
12169 TOKEN_STRING_INITIALIZER
12170 (struct cmd_config_e_tag_result,
12172 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12173 TOKEN_STRING_INITIALIZER
12174 (struct cmd_config_e_tag_result,
12176 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12177 TOKEN_STRING_INITIALIZER
12178 (struct cmd_config_e_tag_result,
12179 port_tag_id, "port-tag-id");
12180 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12181 TOKEN_NUM_INITIALIZER
12182 (struct cmd_config_e_tag_result,
12183 port_tag_id_val, UINT32);
12184 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12185 TOKEN_STRING_INITIALIZER
12186 (struct cmd_config_e_tag_result,
12187 e_tag_id, "e-tag-id");
12188 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12189 TOKEN_NUM_INITIALIZER
12190 (struct cmd_config_e_tag_result,
12191 e_tag_id_val, UINT16);
12192 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12193 TOKEN_STRING_INITIALIZER
12194 (struct cmd_config_e_tag_result,
12195 dst_pool, "dst-pool");
12196 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12197 TOKEN_NUM_INITIALIZER
12198 (struct cmd_config_e_tag_result,
12199 dst_pool_val, UINT8);
12200 cmdline_parse_token_string_t cmd_config_e_tag_port =
12201 TOKEN_STRING_INITIALIZER
12202 (struct cmd_config_e_tag_result,
12204 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12205 TOKEN_NUM_INITIALIZER
12206 (struct cmd_config_e_tag_result,
12208 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12209 TOKEN_STRING_INITIALIZER
12210 (struct cmd_config_e_tag_result,
12212 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12213 TOKEN_NUM_INITIALIZER
12214 (struct cmd_config_e_tag_result,
12217 /* E-tag insertion configuration */
12219 cmd_config_e_tag_insertion_en_parsed(
12220 void *parsed_result,
12221 __attribute__((unused)) struct cmdline *cl,
12222 __attribute__((unused)) void *data)
12224 struct cmd_config_e_tag_result *res =
12226 struct rte_eth_l2_tunnel_conf entry;
12228 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12231 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12232 entry.tunnel_id = res->port_tag_id_val;
12233 entry.vf_id = res->vf_id;
12234 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12236 ETH_L2_TUNNEL_INSERTION_MASK,
12241 cmd_config_e_tag_insertion_dis_parsed(
12242 void *parsed_result,
12243 __attribute__((unused)) struct cmdline *cl,
12244 __attribute__((unused)) void *data)
12246 struct cmd_config_e_tag_result *res =
12248 struct rte_eth_l2_tunnel_conf entry;
12250 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12253 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12254 entry.vf_id = res->vf_id;
12256 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12258 ETH_L2_TUNNEL_INSERTION_MASK,
12262 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12263 .f = cmd_config_e_tag_insertion_en_parsed,
12265 .help_str = "E-tag ... : E-tag insertion enable",
12267 (void *)&cmd_config_e_tag_e_tag,
12268 (void *)&cmd_config_e_tag_set,
12269 (void *)&cmd_config_e_tag_insertion,
12270 (void *)&cmd_config_e_tag_on,
12271 (void *)&cmd_config_e_tag_port_tag_id,
12272 (void *)&cmd_config_e_tag_port_tag_id_val,
12273 (void *)&cmd_config_e_tag_port,
12274 (void *)&cmd_config_e_tag_port_id,
12275 (void *)&cmd_config_e_tag_vf,
12276 (void *)&cmd_config_e_tag_vf_id,
12281 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12282 .f = cmd_config_e_tag_insertion_dis_parsed,
12284 .help_str = "E-tag ... : E-tag insertion disable",
12286 (void *)&cmd_config_e_tag_e_tag,
12287 (void *)&cmd_config_e_tag_set,
12288 (void *)&cmd_config_e_tag_insertion,
12289 (void *)&cmd_config_e_tag_off,
12290 (void *)&cmd_config_e_tag_port,
12291 (void *)&cmd_config_e_tag_port_id,
12292 (void *)&cmd_config_e_tag_vf,
12293 (void *)&cmd_config_e_tag_vf_id,
12298 /* E-tag stripping configuration */
12300 cmd_config_e_tag_stripping_parsed(
12301 void *parsed_result,
12302 __attribute__((unused)) struct cmdline *cl,
12303 __attribute__((unused)) void *data)
12305 struct cmd_config_e_tag_result *res =
12307 struct rte_eth_l2_tunnel_conf entry;
12309 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12312 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12314 if (!strcmp(res->on_off, "on"))
12315 rte_eth_dev_l2_tunnel_offload_set
12318 ETH_L2_TUNNEL_STRIPPING_MASK,
12321 rte_eth_dev_l2_tunnel_offload_set
12324 ETH_L2_TUNNEL_STRIPPING_MASK,
12328 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12329 .f = cmd_config_e_tag_stripping_parsed,
12331 .help_str = "E-tag ... : E-tag stripping enable/disable",
12333 (void *)&cmd_config_e_tag_e_tag,
12334 (void *)&cmd_config_e_tag_set,
12335 (void *)&cmd_config_e_tag_stripping,
12336 (void *)&cmd_config_e_tag_on_off,
12337 (void *)&cmd_config_e_tag_port,
12338 (void *)&cmd_config_e_tag_port_id,
12343 /* E-tag forwarding configuration */
12345 cmd_config_e_tag_forwarding_parsed(
12346 void *parsed_result,
12347 __attribute__((unused)) struct cmdline *cl,
12348 __attribute__((unused)) void *data)
12350 struct cmd_config_e_tag_result *res = parsed_result;
12351 struct rte_eth_l2_tunnel_conf entry;
12353 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12356 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12358 if (!strcmp(res->on_off, "on"))
12359 rte_eth_dev_l2_tunnel_offload_set
12362 ETH_L2_TUNNEL_FORWARDING_MASK,
12365 rte_eth_dev_l2_tunnel_offload_set
12368 ETH_L2_TUNNEL_FORWARDING_MASK,
12372 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12373 .f = cmd_config_e_tag_forwarding_parsed,
12375 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12377 (void *)&cmd_config_e_tag_e_tag,
12378 (void *)&cmd_config_e_tag_set,
12379 (void *)&cmd_config_e_tag_forwarding,
12380 (void *)&cmd_config_e_tag_on_off,
12381 (void *)&cmd_config_e_tag_port,
12382 (void *)&cmd_config_e_tag_port_id,
12387 /* E-tag filter configuration */
12389 cmd_config_e_tag_filter_add_parsed(
12390 void *parsed_result,
12391 __attribute__((unused)) struct cmdline *cl,
12392 __attribute__((unused)) void *data)
12394 struct cmd_config_e_tag_result *res = parsed_result;
12395 struct rte_eth_l2_tunnel_conf entry;
12398 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12401 if (res->e_tag_id_val > 0x3fff) {
12402 printf("e-tag-id must be equal or less than 0x3fff.\n");
12406 ret = rte_eth_dev_filter_supported(res->port_id,
12407 RTE_ETH_FILTER_L2_TUNNEL);
12409 printf("E-tag filter is not supported on port %u.\n",
12414 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12415 entry.tunnel_id = res->e_tag_id_val;
12416 entry.pool = res->dst_pool_val;
12418 ret = rte_eth_dev_filter_ctrl(res->port_id,
12419 RTE_ETH_FILTER_L2_TUNNEL,
12420 RTE_ETH_FILTER_ADD,
12423 printf("E-tag filter programming error: (%s)\n",
12427 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12428 .f = cmd_config_e_tag_filter_add_parsed,
12430 .help_str = "E-tag ... : E-tag filter add",
12432 (void *)&cmd_config_e_tag_e_tag,
12433 (void *)&cmd_config_e_tag_set,
12434 (void *)&cmd_config_e_tag_filter,
12435 (void *)&cmd_config_e_tag_add,
12436 (void *)&cmd_config_e_tag_e_tag_id,
12437 (void *)&cmd_config_e_tag_e_tag_id_val,
12438 (void *)&cmd_config_e_tag_dst_pool,
12439 (void *)&cmd_config_e_tag_dst_pool_val,
12440 (void *)&cmd_config_e_tag_port,
12441 (void *)&cmd_config_e_tag_port_id,
12447 cmd_config_e_tag_filter_del_parsed(
12448 void *parsed_result,
12449 __attribute__((unused)) struct cmdline *cl,
12450 __attribute__((unused)) void *data)
12452 struct cmd_config_e_tag_result *res = parsed_result;
12453 struct rte_eth_l2_tunnel_conf entry;
12456 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12459 if (res->e_tag_id_val > 0x3fff) {
12460 printf("e-tag-id must be less than 0x3fff.\n");
12464 ret = rte_eth_dev_filter_supported(res->port_id,
12465 RTE_ETH_FILTER_L2_TUNNEL);
12467 printf("E-tag filter is not supported on port %u.\n",
12472 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12473 entry.tunnel_id = res->e_tag_id_val;
12475 ret = rte_eth_dev_filter_ctrl(res->port_id,
12476 RTE_ETH_FILTER_L2_TUNNEL,
12477 RTE_ETH_FILTER_DELETE,
12480 printf("E-tag filter programming error: (%s)\n",
12484 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12485 .f = cmd_config_e_tag_filter_del_parsed,
12487 .help_str = "E-tag ... : E-tag filter delete",
12489 (void *)&cmd_config_e_tag_e_tag,
12490 (void *)&cmd_config_e_tag_set,
12491 (void *)&cmd_config_e_tag_filter,
12492 (void *)&cmd_config_e_tag_del,
12493 (void *)&cmd_config_e_tag_e_tag_id,
12494 (void *)&cmd_config_e_tag_e_tag_id_val,
12495 (void *)&cmd_config_e_tag_port,
12496 (void *)&cmd_config_e_tag_port_id,
12501 /* vf vlan anti spoof configuration */
12503 /* Common result structure for vf vlan anti spoof */
12504 struct cmd_vf_vlan_anti_spoof_result {
12505 cmdline_fixed_string_t set;
12506 cmdline_fixed_string_t vf;
12507 cmdline_fixed_string_t vlan;
12508 cmdline_fixed_string_t antispoof;
12511 cmdline_fixed_string_t on_off;
12514 /* Common CLI fields for vf vlan anti spoof enable disable */
12515 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12516 TOKEN_STRING_INITIALIZER
12517 (struct cmd_vf_vlan_anti_spoof_result,
12519 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12520 TOKEN_STRING_INITIALIZER
12521 (struct cmd_vf_vlan_anti_spoof_result,
12523 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12524 TOKEN_STRING_INITIALIZER
12525 (struct cmd_vf_vlan_anti_spoof_result,
12527 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12528 TOKEN_STRING_INITIALIZER
12529 (struct cmd_vf_vlan_anti_spoof_result,
12530 antispoof, "antispoof");
12531 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12532 TOKEN_NUM_INITIALIZER
12533 (struct cmd_vf_vlan_anti_spoof_result,
12535 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12536 TOKEN_NUM_INITIALIZER
12537 (struct cmd_vf_vlan_anti_spoof_result,
12539 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12540 TOKEN_STRING_INITIALIZER
12541 (struct cmd_vf_vlan_anti_spoof_result,
12545 cmd_set_vf_vlan_anti_spoof_parsed(
12546 void *parsed_result,
12547 __attribute__((unused)) struct cmdline *cl,
12548 __attribute__((unused)) void *data)
12550 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12551 int ret = -ENOTSUP;
12553 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12555 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12558 #ifdef RTE_LIBRTE_IXGBE_PMD
12559 if (ret == -ENOTSUP)
12560 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12561 res->vf_id, is_on);
12563 #ifdef RTE_LIBRTE_I40E_PMD
12564 if (ret == -ENOTSUP)
12565 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12566 res->vf_id, is_on);
12568 #ifdef RTE_LIBRTE_BNXT_PMD
12569 if (ret == -ENOTSUP)
12570 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12571 res->vf_id, is_on);
12578 printf("invalid vf_id %d\n", res->vf_id);
12581 printf("invalid port_id %d\n", res->port_id);
12584 printf("function not implemented\n");
12587 printf("programming error: (%s)\n", strerror(-ret));
12591 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12592 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12594 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12596 (void *)&cmd_vf_vlan_anti_spoof_set,
12597 (void *)&cmd_vf_vlan_anti_spoof_vf,
12598 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12599 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12600 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12601 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12602 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12607 /* vf mac anti spoof configuration */
12609 /* Common result structure for vf mac anti spoof */
12610 struct cmd_vf_mac_anti_spoof_result {
12611 cmdline_fixed_string_t set;
12612 cmdline_fixed_string_t vf;
12613 cmdline_fixed_string_t mac;
12614 cmdline_fixed_string_t antispoof;
12617 cmdline_fixed_string_t on_off;
12620 /* Common CLI fields for vf mac anti spoof enable disable */
12621 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12622 TOKEN_STRING_INITIALIZER
12623 (struct cmd_vf_mac_anti_spoof_result,
12625 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12626 TOKEN_STRING_INITIALIZER
12627 (struct cmd_vf_mac_anti_spoof_result,
12629 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12630 TOKEN_STRING_INITIALIZER
12631 (struct cmd_vf_mac_anti_spoof_result,
12633 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12634 TOKEN_STRING_INITIALIZER
12635 (struct cmd_vf_mac_anti_spoof_result,
12636 antispoof, "antispoof");
12637 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12638 TOKEN_NUM_INITIALIZER
12639 (struct cmd_vf_mac_anti_spoof_result,
12641 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12642 TOKEN_NUM_INITIALIZER
12643 (struct cmd_vf_mac_anti_spoof_result,
12645 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12646 TOKEN_STRING_INITIALIZER
12647 (struct cmd_vf_mac_anti_spoof_result,
12651 cmd_set_vf_mac_anti_spoof_parsed(
12652 void *parsed_result,
12653 __attribute__((unused)) struct cmdline *cl,
12654 __attribute__((unused)) void *data)
12656 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12657 int ret = -ENOTSUP;
12659 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12661 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12664 #ifdef RTE_LIBRTE_IXGBE_PMD
12665 if (ret == -ENOTSUP)
12666 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12667 res->vf_id, is_on);
12669 #ifdef RTE_LIBRTE_I40E_PMD
12670 if (ret == -ENOTSUP)
12671 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12672 res->vf_id, is_on);
12674 #ifdef RTE_LIBRTE_BNXT_PMD
12675 if (ret == -ENOTSUP)
12676 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12677 res->vf_id, is_on);
12684 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12687 printf("invalid port_id %d\n", res->port_id);
12690 printf("function not implemented\n");
12693 printf("programming error: (%s)\n", strerror(-ret));
12697 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12698 .f = cmd_set_vf_mac_anti_spoof_parsed,
12700 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12702 (void *)&cmd_vf_mac_anti_spoof_set,
12703 (void *)&cmd_vf_mac_anti_spoof_vf,
12704 (void *)&cmd_vf_mac_anti_spoof_mac,
12705 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12706 (void *)&cmd_vf_mac_anti_spoof_port_id,
12707 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12708 (void *)&cmd_vf_mac_anti_spoof_on_off,
12713 /* vf vlan strip queue configuration */
12715 /* Common result structure for vf mac anti spoof */
12716 struct cmd_vf_vlan_stripq_result {
12717 cmdline_fixed_string_t set;
12718 cmdline_fixed_string_t vf;
12719 cmdline_fixed_string_t vlan;
12720 cmdline_fixed_string_t stripq;
12723 cmdline_fixed_string_t on_off;
12726 /* Common CLI fields for vf vlan strip enable disable */
12727 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12728 TOKEN_STRING_INITIALIZER
12729 (struct cmd_vf_vlan_stripq_result,
12731 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12732 TOKEN_STRING_INITIALIZER
12733 (struct cmd_vf_vlan_stripq_result,
12735 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12736 TOKEN_STRING_INITIALIZER
12737 (struct cmd_vf_vlan_stripq_result,
12739 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12740 TOKEN_STRING_INITIALIZER
12741 (struct cmd_vf_vlan_stripq_result,
12743 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12744 TOKEN_NUM_INITIALIZER
12745 (struct cmd_vf_vlan_stripq_result,
12747 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12748 TOKEN_NUM_INITIALIZER
12749 (struct cmd_vf_vlan_stripq_result,
12751 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12752 TOKEN_STRING_INITIALIZER
12753 (struct cmd_vf_vlan_stripq_result,
12757 cmd_set_vf_vlan_stripq_parsed(
12758 void *parsed_result,
12759 __attribute__((unused)) struct cmdline *cl,
12760 __attribute__((unused)) void *data)
12762 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12763 int ret = -ENOTSUP;
12765 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12767 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12770 #ifdef RTE_LIBRTE_IXGBE_PMD
12771 if (ret == -ENOTSUP)
12772 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12773 res->vf_id, is_on);
12775 #ifdef RTE_LIBRTE_I40E_PMD
12776 if (ret == -ENOTSUP)
12777 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12778 res->vf_id, is_on);
12780 #ifdef RTE_LIBRTE_BNXT_PMD
12781 if (ret == -ENOTSUP)
12782 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12783 res->vf_id, is_on);
12790 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12793 printf("invalid port_id %d\n", res->port_id);
12796 printf("function not implemented\n");
12799 printf("programming error: (%s)\n", strerror(-ret));
12803 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12804 .f = cmd_set_vf_vlan_stripq_parsed,
12806 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12808 (void *)&cmd_vf_vlan_stripq_set,
12809 (void *)&cmd_vf_vlan_stripq_vf,
12810 (void *)&cmd_vf_vlan_stripq_vlan,
12811 (void *)&cmd_vf_vlan_stripq_stripq,
12812 (void *)&cmd_vf_vlan_stripq_port_id,
12813 (void *)&cmd_vf_vlan_stripq_vf_id,
12814 (void *)&cmd_vf_vlan_stripq_on_off,
12819 /* vf vlan insert configuration */
12821 /* Common result structure for vf vlan insert */
12822 struct cmd_vf_vlan_insert_result {
12823 cmdline_fixed_string_t set;
12824 cmdline_fixed_string_t vf;
12825 cmdline_fixed_string_t vlan;
12826 cmdline_fixed_string_t insert;
12832 /* Common CLI fields for vf vlan insert enable disable */
12833 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12834 TOKEN_STRING_INITIALIZER
12835 (struct cmd_vf_vlan_insert_result,
12837 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12838 TOKEN_STRING_INITIALIZER
12839 (struct cmd_vf_vlan_insert_result,
12841 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12842 TOKEN_STRING_INITIALIZER
12843 (struct cmd_vf_vlan_insert_result,
12845 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12846 TOKEN_STRING_INITIALIZER
12847 (struct cmd_vf_vlan_insert_result,
12849 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12850 TOKEN_NUM_INITIALIZER
12851 (struct cmd_vf_vlan_insert_result,
12853 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12854 TOKEN_NUM_INITIALIZER
12855 (struct cmd_vf_vlan_insert_result,
12857 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12858 TOKEN_NUM_INITIALIZER
12859 (struct cmd_vf_vlan_insert_result,
12863 cmd_set_vf_vlan_insert_parsed(
12864 void *parsed_result,
12865 __attribute__((unused)) struct cmdline *cl,
12866 __attribute__((unused)) void *data)
12868 struct cmd_vf_vlan_insert_result *res = parsed_result;
12869 int ret = -ENOTSUP;
12871 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12874 #ifdef RTE_LIBRTE_IXGBE_PMD
12875 if (ret == -ENOTSUP)
12876 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12879 #ifdef RTE_LIBRTE_I40E_PMD
12880 if (ret == -ENOTSUP)
12881 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12884 #ifdef RTE_LIBRTE_BNXT_PMD
12885 if (ret == -ENOTSUP)
12886 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12894 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12897 printf("invalid port_id %d\n", res->port_id);
12900 printf("function not implemented\n");
12903 printf("programming error: (%s)\n", strerror(-ret));
12907 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12908 .f = cmd_set_vf_vlan_insert_parsed,
12910 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12912 (void *)&cmd_vf_vlan_insert_set,
12913 (void *)&cmd_vf_vlan_insert_vf,
12914 (void *)&cmd_vf_vlan_insert_vlan,
12915 (void *)&cmd_vf_vlan_insert_insert,
12916 (void *)&cmd_vf_vlan_insert_port_id,
12917 (void *)&cmd_vf_vlan_insert_vf_id,
12918 (void *)&cmd_vf_vlan_insert_vlan_id,
12923 /* tx loopback configuration */
12925 /* Common result structure for tx loopback */
12926 struct cmd_tx_loopback_result {
12927 cmdline_fixed_string_t set;
12928 cmdline_fixed_string_t tx;
12929 cmdline_fixed_string_t loopback;
12931 cmdline_fixed_string_t on_off;
12934 /* Common CLI fields for tx loopback enable disable */
12935 cmdline_parse_token_string_t cmd_tx_loopback_set =
12936 TOKEN_STRING_INITIALIZER
12937 (struct cmd_tx_loopback_result,
12939 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12940 TOKEN_STRING_INITIALIZER
12941 (struct cmd_tx_loopback_result,
12943 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12944 TOKEN_STRING_INITIALIZER
12945 (struct cmd_tx_loopback_result,
12946 loopback, "loopback");
12947 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12948 TOKEN_NUM_INITIALIZER
12949 (struct cmd_tx_loopback_result,
12951 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12952 TOKEN_STRING_INITIALIZER
12953 (struct cmd_tx_loopback_result,
12957 cmd_set_tx_loopback_parsed(
12958 void *parsed_result,
12959 __attribute__((unused)) struct cmdline *cl,
12960 __attribute__((unused)) void *data)
12962 struct cmd_tx_loopback_result *res = parsed_result;
12963 int ret = -ENOTSUP;
12965 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12970 #ifdef RTE_LIBRTE_IXGBE_PMD
12971 if (ret == -ENOTSUP)
12972 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12974 #ifdef RTE_LIBRTE_I40E_PMD
12975 if (ret == -ENOTSUP)
12976 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12978 #ifdef RTE_LIBRTE_BNXT_PMD
12979 if (ret == -ENOTSUP)
12980 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12982 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
12983 if (ret == -ENOTSUP)
12984 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12991 printf("invalid is_on %d\n", is_on);
12994 printf("invalid port_id %d\n", res->port_id);
12997 printf("function not implemented\n");
13000 printf("programming error: (%s)\n", strerror(-ret));
13004 cmdline_parse_inst_t cmd_set_tx_loopback = {
13005 .f = cmd_set_tx_loopback_parsed,
13007 .help_str = "set tx loopback <port_id> on|off",
13009 (void *)&cmd_tx_loopback_set,
13010 (void *)&cmd_tx_loopback_tx,
13011 (void *)&cmd_tx_loopback_loopback,
13012 (void *)&cmd_tx_loopback_port_id,
13013 (void *)&cmd_tx_loopback_on_off,
13018 /* all queues drop enable configuration */
13020 /* Common result structure for all queues drop enable */
13021 struct cmd_all_queues_drop_en_result {
13022 cmdline_fixed_string_t set;
13023 cmdline_fixed_string_t all;
13024 cmdline_fixed_string_t queues;
13025 cmdline_fixed_string_t drop;
13027 cmdline_fixed_string_t on_off;
13030 /* Common CLI fields for tx loopback enable disable */
13031 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13032 TOKEN_STRING_INITIALIZER
13033 (struct cmd_all_queues_drop_en_result,
13035 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13036 TOKEN_STRING_INITIALIZER
13037 (struct cmd_all_queues_drop_en_result,
13039 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13040 TOKEN_STRING_INITIALIZER
13041 (struct cmd_all_queues_drop_en_result,
13043 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13044 TOKEN_STRING_INITIALIZER
13045 (struct cmd_all_queues_drop_en_result,
13047 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13048 TOKEN_NUM_INITIALIZER
13049 (struct cmd_all_queues_drop_en_result,
13051 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13052 TOKEN_STRING_INITIALIZER
13053 (struct cmd_all_queues_drop_en_result,
13057 cmd_set_all_queues_drop_en_parsed(
13058 void *parsed_result,
13059 __attribute__((unused)) struct cmdline *cl,
13060 __attribute__((unused)) void *data)
13062 struct cmd_all_queues_drop_en_result *res = parsed_result;
13063 int ret = -ENOTSUP;
13064 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13066 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13069 #ifdef RTE_LIBRTE_IXGBE_PMD
13070 if (ret == -ENOTSUP)
13071 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13073 #ifdef RTE_LIBRTE_BNXT_PMD
13074 if (ret == -ENOTSUP)
13075 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13081 printf("invalid is_on %d\n", is_on);
13084 printf("invalid port_id %d\n", res->port_id);
13087 printf("function not implemented\n");
13090 printf("programming error: (%s)\n", strerror(-ret));
13094 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13095 .f = cmd_set_all_queues_drop_en_parsed,
13097 .help_str = "set all queues drop <port_id> on|off",
13099 (void *)&cmd_all_queues_drop_en_set,
13100 (void *)&cmd_all_queues_drop_en_all,
13101 (void *)&cmd_all_queues_drop_en_queues,
13102 (void *)&cmd_all_queues_drop_en_drop,
13103 (void *)&cmd_all_queues_drop_en_port_id,
13104 (void *)&cmd_all_queues_drop_en_on_off,
13109 /* vf split drop enable configuration */
13111 /* Common result structure for vf split drop enable */
13112 struct cmd_vf_split_drop_en_result {
13113 cmdline_fixed_string_t set;
13114 cmdline_fixed_string_t vf;
13115 cmdline_fixed_string_t split;
13116 cmdline_fixed_string_t drop;
13119 cmdline_fixed_string_t on_off;
13122 /* Common CLI fields for vf split drop enable disable */
13123 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13124 TOKEN_STRING_INITIALIZER
13125 (struct cmd_vf_split_drop_en_result,
13127 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13128 TOKEN_STRING_INITIALIZER
13129 (struct cmd_vf_split_drop_en_result,
13131 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13132 TOKEN_STRING_INITIALIZER
13133 (struct cmd_vf_split_drop_en_result,
13135 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13136 TOKEN_STRING_INITIALIZER
13137 (struct cmd_vf_split_drop_en_result,
13139 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13140 TOKEN_NUM_INITIALIZER
13141 (struct cmd_vf_split_drop_en_result,
13143 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13144 TOKEN_NUM_INITIALIZER
13145 (struct cmd_vf_split_drop_en_result,
13147 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13148 TOKEN_STRING_INITIALIZER
13149 (struct cmd_vf_split_drop_en_result,
13153 cmd_set_vf_split_drop_en_parsed(
13154 void *parsed_result,
13155 __attribute__((unused)) struct cmdline *cl,
13156 __attribute__((unused)) void *data)
13158 struct cmd_vf_split_drop_en_result *res = parsed_result;
13159 int ret = -ENOTSUP;
13160 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13162 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13165 #ifdef RTE_LIBRTE_IXGBE_PMD
13166 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13173 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13176 printf("invalid port_id %d\n", res->port_id);
13179 printf("not supported on port %d\n", res->port_id);
13182 printf("programming error: (%s)\n", strerror(-ret));
13186 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13187 .f = cmd_set_vf_split_drop_en_parsed,
13189 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13191 (void *)&cmd_vf_split_drop_en_set,
13192 (void *)&cmd_vf_split_drop_en_vf,
13193 (void *)&cmd_vf_split_drop_en_split,
13194 (void *)&cmd_vf_split_drop_en_drop,
13195 (void *)&cmd_vf_split_drop_en_port_id,
13196 (void *)&cmd_vf_split_drop_en_vf_id,
13197 (void *)&cmd_vf_split_drop_en_on_off,
13202 /* vf mac address configuration */
13204 /* Common result structure for vf mac address */
13205 struct cmd_set_vf_mac_addr_result {
13206 cmdline_fixed_string_t set;
13207 cmdline_fixed_string_t vf;
13208 cmdline_fixed_string_t mac;
13209 cmdline_fixed_string_t addr;
13212 struct ether_addr mac_addr;
13216 /* Common CLI fields for vf split drop enable disable */
13217 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13218 TOKEN_STRING_INITIALIZER
13219 (struct cmd_set_vf_mac_addr_result,
13221 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13222 TOKEN_STRING_INITIALIZER
13223 (struct cmd_set_vf_mac_addr_result,
13225 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13226 TOKEN_STRING_INITIALIZER
13227 (struct cmd_set_vf_mac_addr_result,
13229 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13230 TOKEN_STRING_INITIALIZER
13231 (struct cmd_set_vf_mac_addr_result,
13233 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13234 TOKEN_NUM_INITIALIZER
13235 (struct cmd_set_vf_mac_addr_result,
13237 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13238 TOKEN_NUM_INITIALIZER
13239 (struct cmd_set_vf_mac_addr_result,
13241 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13242 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13246 cmd_set_vf_mac_addr_parsed(
13247 void *parsed_result,
13248 __attribute__((unused)) struct cmdline *cl,
13249 __attribute__((unused)) void *data)
13251 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13252 int ret = -ENOTSUP;
13254 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13257 #ifdef RTE_LIBRTE_IXGBE_PMD
13258 if (ret == -ENOTSUP)
13259 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13262 #ifdef RTE_LIBRTE_I40E_PMD
13263 if (ret == -ENOTSUP)
13264 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13267 #ifdef RTE_LIBRTE_BNXT_PMD
13268 if (ret == -ENOTSUP)
13269 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13277 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13280 printf("invalid port_id %d\n", res->port_id);
13283 printf("function not implemented\n");
13286 printf("programming error: (%s)\n", strerror(-ret));
13290 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13291 .f = cmd_set_vf_mac_addr_parsed,
13293 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13295 (void *)&cmd_set_vf_mac_addr_set,
13296 (void *)&cmd_set_vf_mac_addr_vf,
13297 (void *)&cmd_set_vf_mac_addr_mac,
13298 (void *)&cmd_set_vf_mac_addr_addr,
13299 (void *)&cmd_set_vf_mac_addr_port_id,
13300 (void *)&cmd_set_vf_mac_addr_vf_id,
13301 (void *)&cmd_set_vf_mac_addr_mac_addr,
13306 /* MACsec configuration */
13308 /* Common result structure for MACsec offload enable */
13309 struct cmd_macsec_offload_on_result {
13310 cmdline_fixed_string_t set;
13311 cmdline_fixed_string_t macsec;
13312 cmdline_fixed_string_t offload;
13314 cmdline_fixed_string_t on;
13315 cmdline_fixed_string_t encrypt;
13316 cmdline_fixed_string_t en_on_off;
13317 cmdline_fixed_string_t replay_protect;
13318 cmdline_fixed_string_t rp_on_off;
13321 /* Common CLI fields for MACsec offload disable */
13322 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13323 TOKEN_STRING_INITIALIZER
13324 (struct cmd_macsec_offload_on_result,
13326 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13327 TOKEN_STRING_INITIALIZER
13328 (struct cmd_macsec_offload_on_result,
13330 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13331 TOKEN_STRING_INITIALIZER
13332 (struct cmd_macsec_offload_on_result,
13333 offload, "offload");
13334 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13335 TOKEN_NUM_INITIALIZER
13336 (struct cmd_macsec_offload_on_result,
13338 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13339 TOKEN_STRING_INITIALIZER
13340 (struct cmd_macsec_offload_on_result,
13342 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13343 TOKEN_STRING_INITIALIZER
13344 (struct cmd_macsec_offload_on_result,
13345 encrypt, "encrypt");
13346 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13347 TOKEN_STRING_INITIALIZER
13348 (struct cmd_macsec_offload_on_result,
13349 en_on_off, "on#off");
13350 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13351 TOKEN_STRING_INITIALIZER
13352 (struct cmd_macsec_offload_on_result,
13353 replay_protect, "replay-protect");
13354 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13355 TOKEN_STRING_INITIALIZER
13356 (struct cmd_macsec_offload_on_result,
13357 rp_on_off, "on#off");
13360 cmd_set_macsec_offload_on_parsed(
13361 void *parsed_result,
13362 __attribute__((unused)) struct cmdline *cl,
13363 __attribute__((unused)) void *data)
13365 struct cmd_macsec_offload_on_result *res = parsed_result;
13366 int ret = -ENOTSUP;
13367 portid_t port_id = res->port_id;
13368 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13369 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13370 struct rte_eth_dev_info dev_info;
13372 if (port_id_is_invalid(port_id, ENABLED_WARN))
13374 if (!port_is_stopped(port_id)) {
13375 printf("Please stop port %d first\n", port_id);
13379 rte_eth_dev_info_get(port_id, &dev_info);
13380 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13381 #ifdef RTE_LIBRTE_IXGBE_PMD
13382 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13390 ports[port_id].dev_conf.txmode.offloads |=
13391 DEV_TX_OFFLOAD_MACSEC_INSERT;
13392 cmd_reconfig_device_queue(port_id, 1, 1);
13395 printf("invalid port_id %d\n", port_id);
13398 printf("not supported on port %d\n", port_id);
13401 printf("programming error: (%s)\n", strerror(-ret));
13405 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13406 .f = cmd_set_macsec_offload_on_parsed,
13408 .help_str = "set macsec offload <port_id> on "
13409 "encrypt on|off replay-protect on|off",
13411 (void *)&cmd_macsec_offload_on_set,
13412 (void *)&cmd_macsec_offload_on_macsec,
13413 (void *)&cmd_macsec_offload_on_offload,
13414 (void *)&cmd_macsec_offload_on_port_id,
13415 (void *)&cmd_macsec_offload_on_on,
13416 (void *)&cmd_macsec_offload_on_encrypt,
13417 (void *)&cmd_macsec_offload_on_en_on_off,
13418 (void *)&cmd_macsec_offload_on_replay_protect,
13419 (void *)&cmd_macsec_offload_on_rp_on_off,
13424 /* Common result structure for MACsec offload disable */
13425 struct cmd_macsec_offload_off_result {
13426 cmdline_fixed_string_t set;
13427 cmdline_fixed_string_t macsec;
13428 cmdline_fixed_string_t offload;
13430 cmdline_fixed_string_t off;
13433 /* Common CLI fields for MACsec offload disable */
13434 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13435 TOKEN_STRING_INITIALIZER
13436 (struct cmd_macsec_offload_off_result,
13438 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13439 TOKEN_STRING_INITIALIZER
13440 (struct cmd_macsec_offload_off_result,
13442 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13443 TOKEN_STRING_INITIALIZER
13444 (struct cmd_macsec_offload_off_result,
13445 offload, "offload");
13446 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13447 TOKEN_NUM_INITIALIZER
13448 (struct cmd_macsec_offload_off_result,
13450 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13451 TOKEN_STRING_INITIALIZER
13452 (struct cmd_macsec_offload_off_result,
13456 cmd_set_macsec_offload_off_parsed(
13457 void *parsed_result,
13458 __attribute__((unused)) struct cmdline *cl,
13459 __attribute__((unused)) void *data)
13461 struct cmd_macsec_offload_off_result *res = parsed_result;
13462 int ret = -ENOTSUP;
13463 struct rte_eth_dev_info dev_info;
13464 portid_t port_id = res->port_id;
13466 if (port_id_is_invalid(port_id, ENABLED_WARN))
13468 if (!port_is_stopped(port_id)) {
13469 printf("Please stop port %d first\n", port_id);
13473 rte_eth_dev_info_get(port_id, &dev_info);
13474 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13475 #ifdef RTE_LIBRTE_IXGBE_PMD
13476 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13481 ports[port_id].dev_conf.txmode.offloads &=
13482 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13483 cmd_reconfig_device_queue(port_id, 1, 1);
13486 printf("invalid port_id %d\n", port_id);
13489 printf("not supported on port %d\n", port_id);
13492 printf("programming error: (%s)\n", strerror(-ret));
13496 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13497 .f = cmd_set_macsec_offload_off_parsed,
13499 .help_str = "set macsec offload <port_id> off",
13501 (void *)&cmd_macsec_offload_off_set,
13502 (void *)&cmd_macsec_offload_off_macsec,
13503 (void *)&cmd_macsec_offload_off_offload,
13504 (void *)&cmd_macsec_offload_off_port_id,
13505 (void *)&cmd_macsec_offload_off_off,
13510 /* Common result structure for MACsec secure connection configure */
13511 struct cmd_macsec_sc_result {
13512 cmdline_fixed_string_t set;
13513 cmdline_fixed_string_t macsec;
13514 cmdline_fixed_string_t sc;
13515 cmdline_fixed_string_t tx_rx;
13517 struct ether_addr mac;
13521 /* Common CLI fields for MACsec secure connection configure */
13522 cmdline_parse_token_string_t cmd_macsec_sc_set =
13523 TOKEN_STRING_INITIALIZER
13524 (struct cmd_macsec_sc_result,
13526 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13527 TOKEN_STRING_INITIALIZER
13528 (struct cmd_macsec_sc_result,
13530 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13531 TOKEN_STRING_INITIALIZER
13532 (struct cmd_macsec_sc_result,
13534 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13535 TOKEN_STRING_INITIALIZER
13536 (struct cmd_macsec_sc_result,
13538 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13539 TOKEN_NUM_INITIALIZER
13540 (struct cmd_macsec_sc_result,
13542 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13543 TOKEN_ETHERADDR_INITIALIZER
13544 (struct cmd_macsec_sc_result,
13546 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13547 TOKEN_NUM_INITIALIZER
13548 (struct cmd_macsec_sc_result,
13552 cmd_set_macsec_sc_parsed(
13553 void *parsed_result,
13554 __attribute__((unused)) struct cmdline *cl,
13555 __attribute__((unused)) void *data)
13557 struct cmd_macsec_sc_result *res = parsed_result;
13558 int ret = -ENOTSUP;
13559 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13561 #ifdef RTE_LIBRTE_IXGBE_PMD
13563 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13564 res->mac.addr_bytes) :
13565 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13566 res->mac.addr_bytes, res->pi);
13568 RTE_SET_USED(is_tx);
13574 printf("invalid port_id %d\n", res->port_id);
13577 printf("not supported on port %d\n", res->port_id);
13580 printf("programming error: (%s)\n", strerror(-ret));
13584 cmdline_parse_inst_t cmd_set_macsec_sc = {
13585 .f = cmd_set_macsec_sc_parsed,
13587 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13589 (void *)&cmd_macsec_sc_set,
13590 (void *)&cmd_macsec_sc_macsec,
13591 (void *)&cmd_macsec_sc_sc,
13592 (void *)&cmd_macsec_sc_tx_rx,
13593 (void *)&cmd_macsec_sc_port_id,
13594 (void *)&cmd_macsec_sc_mac,
13595 (void *)&cmd_macsec_sc_pi,
13600 /* Common result structure for MACsec secure connection configure */
13601 struct cmd_macsec_sa_result {
13602 cmdline_fixed_string_t set;
13603 cmdline_fixed_string_t macsec;
13604 cmdline_fixed_string_t sa;
13605 cmdline_fixed_string_t tx_rx;
13610 cmdline_fixed_string_t key;
13613 /* Common CLI fields for MACsec secure connection configure */
13614 cmdline_parse_token_string_t cmd_macsec_sa_set =
13615 TOKEN_STRING_INITIALIZER
13616 (struct cmd_macsec_sa_result,
13618 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13619 TOKEN_STRING_INITIALIZER
13620 (struct cmd_macsec_sa_result,
13622 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13623 TOKEN_STRING_INITIALIZER
13624 (struct cmd_macsec_sa_result,
13626 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13627 TOKEN_STRING_INITIALIZER
13628 (struct cmd_macsec_sa_result,
13630 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13631 TOKEN_NUM_INITIALIZER
13632 (struct cmd_macsec_sa_result,
13634 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13635 TOKEN_NUM_INITIALIZER
13636 (struct cmd_macsec_sa_result,
13638 cmdline_parse_token_num_t cmd_macsec_sa_an =
13639 TOKEN_NUM_INITIALIZER
13640 (struct cmd_macsec_sa_result,
13642 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13643 TOKEN_NUM_INITIALIZER
13644 (struct cmd_macsec_sa_result,
13646 cmdline_parse_token_string_t cmd_macsec_sa_key =
13647 TOKEN_STRING_INITIALIZER
13648 (struct cmd_macsec_sa_result,
13652 cmd_set_macsec_sa_parsed(
13653 void *parsed_result,
13654 __attribute__((unused)) struct cmdline *cl,
13655 __attribute__((unused)) void *data)
13657 struct cmd_macsec_sa_result *res = parsed_result;
13658 int ret = -ENOTSUP;
13659 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13660 uint8_t key[16] = { 0 };
13666 key_len = strlen(res->key) / 2;
13670 for (i = 0; i < key_len; i++) {
13671 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13674 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13677 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13680 #ifdef RTE_LIBRTE_IXGBE_PMD
13682 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13683 res->idx, res->an, res->pn, key) :
13684 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13685 res->idx, res->an, res->pn, key);
13687 RTE_SET_USED(is_tx);
13694 printf("invalid idx %d or an %d\n", res->idx, res->an);
13697 printf("invalid port_id %d\n", res->port_id);
13700 printf("not supported on port %d\n", res->port_id);
13703 printf("programming error: (%s)\n", strerror(-ret));
13707 cmdline_parse_inst_t cmd_set_macsec_sa = {
13708 .f = cmd_set_macsec_sa_parsed,
13710 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13712 (void *)&cmd_macsec_sa_set,
13713 (void *)&cmd_macsec_sa_macsec,
13714 (void *)&cmd_macsec_sa_sa,
13715 (void *)&cmd_macsec_sa_tx_rx,
13716 (void *)&cmd_macsec_sa_port_id,
13717 (void *)&cmd_macsec_sa_idx,
13718 (void *)&cmd_macsec_sa_an,
13719 (void *)&cmd_macsec_sa_pn,
13720 (void *)&cmd_macsec_sa_key,
13725 /* VF unicast promiscuous mode configuration */
13727 /* Common result structure for VF unicast promiscuous mode */
13728 struct cmd_vf_promisc_result {
13729 cmdline_fixed_string_t set;
13730 cmdline_fixed_string_t vf;
13731 cmdline_fixed_string_t promisc;
13734 cmdline_fixed_string_t on_off;
13737 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13738 cmdline_parse_token_string_t cmd_vf_promisc_set =
13739 TOKEN_STRING_INITIALIZER
13740 (struct cmd_vf_promisc_result,
13742 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13743 TOKEN_STRING_INITIALIZER
13744 (struct cmd_vf_promisc_result,
13746 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13747 TOKEN_STRING_INITIALIZER
13748 (struct cmd_vf_promisc_result,
13749 promisc, "promisc");
13750 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13751 TOKEN_NUM_INITIALIZER
13752 (struct cmd_vf_promisc_result,
13754 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13755 TOKEN_NUM_INITIALIZER
13756 (struct cmd_vf_promisc_result,
13758 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13759 TOKEN_STRING_INITIALIZER
13760 (struct cmd_vf_promisc_result,
13764 cmd_set_vf_promisc_parsed(
13765 void *parsed_result,
13766 __attribute__((unused)) struct cmdline *cl,
13767 __attribute__((unused)) void *data)
13769 struct cmd_vf_promisc_result *res = parsed_result;
13770 int ret = -ENOTSUP;
13772 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13774 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13777 #ifdef RTE_LIBRTE_I40E_PMD
13778 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13779 res->vf_id, is_on);
13786 printf("invalid vf_id %d\n", res->vf_id);
13789 printf("invalid port_id %d\n", res->port_id);
13792 printf("function not implemented\n");
13795 printf("programming error: (%s)\n", strerror(-ret));
13799 cmdline_parse_inst_t cmd_set_vf_promisc = {
13800 .f = cmd_set_vf_promisc_parsed,
13802 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13803 "Set unicast promiscuous mode for a VF from the PF",
13805 (void *)&cmd_vf_promisc_set,
13806 (void *)&cmd_vf_promisc_vf,
13807 (void *)&cmd_vf_promisc_promisc,
13808 (void *)&cmd_vf_promisc_port_id,
13809 (void *)&cmd_vf_promisc_vf_id,
13810 (void *)&cmd_vf_promisc_on_off,
13815 /* VF multicast promiscuous mode configuration */
13817 /* Common result structure for VF multicast promiscuous mode */
13818 struct cmd_vf_allmulti_result {
13819 cmdline_fixed_string_t set;
13820 cmdline_fixed_string_t vf;
13821 cmdline_fixed_string_t allmulti;
13824 cmdline_fixed_string_t on_off;
13827 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13828 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13829 TOKEN_STRING_INITIALIZER
13830 (struct cmd_vf_allmulti_result,
13832 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13833 TOKEN_STRING_INITIALIZER
13834 (struct cmd_vf_allmulti_result,
13836 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13837 TOKEN_STRING_INITIALIZER
13838 (struct cmd_vf_allmulti_result,
13839 allmulti, "allmulti");
13840 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13841 TOKEN_NUM_INITIALIZER
13842 (struct cmd_vf_allmulti_result,
13844 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13845 TOKEN_NUM_INITIALIZER
13846 (struct cmd_vf_allmulti_result,
13848 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13849 TOKEN_STRING_INITIALIZER
13850 (struct cmd_vf_allmulti_result,
13854 cmd_set_vf_allmulti_parsed(
13855 void *parsed_result,
13856 __attribute__((unused)) struct cmdline *cl,
13857 __attribute__((unused)) void *data)
13859 struct cmd_vf_allmulti_result *res = parsed_result;
13860 int ret = -ENOTSUP;
13862 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13864 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13867 #ifdef RTE_LIBRTE_I40E_PMD
13868 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13869 res->vf_id, is_on);
13876 printf("invalid vf_id %d\n", res->vf_id);
13879 printf("invalid port_id %d\n", res->port_id);
13882 printf("function not implemented\n");
13885 printf("programming error: (%s)\n", strerror(-ret));
13889 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13890 .f = cmd_set_vf_allmulti_parsed,
13892 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13893 "Set multicast promiscuous mode for a VF from the PF",
13895 (void *)&cmd_vf_allmulti_set,
13896 (void *)&cmd_vf_allmulti_vf,
13897 (void *)&cmd_vf_allmulti_allmulti,
13898 (void *)&cmd_vf_allmulti_port_id,
13899 (void *)&cmd_vf_allmulti_vf_id,
13900 (void *)&cmd_vf_allmulti_on_off,
13905 /* vf broadcast mode configuration */
13907 /* Common result structure for vf broadcast */
13908 struct cmd_set_vf_broadcast_result {
13909 cmdline_fixed_string_t set;
13910 cmdline_fixed_string_t vf;
13911 cmdline_fixed_string_t broadcast;
13914 cmdline_fixed_string_t on_off;
13917 /* Common CLI fields for vf broadcast enable disable */
13918 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13919 TOKEN_STRING_INITIALIZER
13920 (struct cmd_set_vf_broadcast_result,
13922 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13923 TOKEN_STRING_INITIALIZER
13924 (struct cmd_set_vf_broadcast_result,
13926 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13927 TOKEN_STRING_INITIALIZER
13928 (struct cmd_set_vf_broadcast_result,
13929 broadcast, "broadcast");
13930 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13931 TOKEN_NUM_INITIALIZER
13932 (struct cmd_set_vf_broadcast_result,
13934 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13935 TOKEN_NUM_INITIALIZER
13936 (struct cmd_set_vf_broadcast_result,
13938 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13939 TOKEN_STRING_INITIALIZER
13940 (struct cmd_set_vf_broadcast_result,
13944 cmd_set_vf_broadcast_parsed(
13945 void *parsed_result,
13946 __attribute__((unused)) struct cmdline *cl,
13947 __attribute__((unused)) void *data)
13949 struct cmd_set_vf_broadcast_result *res = parsed_result;
13950 int ret = -ENOTSUP;
13952 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13954 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13957 #ifdef RTE_LIBRTE_I40E_PMD
13958 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13959 res->vf_id, is_on);
13966 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13969 printf("invalid port_id %d\n", res->port_id);
13972 printf("function not implemented\n");
13975 printf("programming error: (%s)\n", strerror(-ret));
13979 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13980 .f = cmd_set_vf_broadcast_parsed,
13982 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13984 (void *)&cmd_set_vf_broadcast_set,
13985 (void *)&cmd_set_vf_broadcast_vf,
13986 (void *)&cmd_set_vf_broadcast_broadcast,
13987 (void *)&cmd_set_vf_broadcast_port_id,
13988 (void *)&cmd_set_vf_broadcast_vf_id,
13989 (void *)&cmd_set_vf_broadcast_on_off,
13994 /* vf vlan tag configuration */
13996 /* Common result structure for vf vlan tag */
13997 struct cmd_set_vf_vlan_tag_result {
13998 cmdline_fixed_string_t set;
13999 cmdline_fixed_string_t vf;
14000 cmdline_fixed_string_t vlan;
14001 cmdline_fixed_string_t tag;
14004 cmdline_fixed_string_t on_off;
14007 /* Common CLI fields for vf vlan tag enable disable */
14008 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14009 TOKEN_STRING_INITIALIZER
14010 (struct cmd_set_vf_vlan_tag_result,
14012 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14013 TOKEN_STRING_INITIALIZER
14014 (struct cmd_set_vf_vlan_tag_result,
14016 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14017 TOKEN_STRING_INITIALIZER
14018 (struct cmd_set_vf_vlan_tag_result,
14020 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14021 TOKEN_STRING_INITIALIZER
14022 (struct cmd_set_vf_vlan_tag_result,
14024 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14025 TOKEN_NUM_INITIALIZER
14026 (struct cmd_set_vf_vlan_tag_result,
14028 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14029 TOKEN_NUM_INITIALIZER
14030 (struct cmd_set_vf_vlan_tag_result,
14032 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14033 TOKEN_STRING_INITIALIZER
14034 (struct cmd_set_vf_vlan_tag_result,
14038 cmd_set_vf_vlan_tag_parsed(
14039 void *parsed_result,
14040 __attribute__((unused)) struct cmdline *cl,
14041 __attribute__((unused)) void *data)
14043 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14044 int ret = -ENOTSUP;
14046 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14048 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14051 #ifdef RTE_LIBRTE_I40E_PMD
14052 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14053 res->vf_id, is_on);
14060 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14063 printf("invalid port_id %d\n", res->port_id);
14066 printf("function not implemented\n");
14069 printf("programming error: (%s)\n", strerror(-ret));
14073 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14074 .f = cmd_set_vf_vlan_tag_parsed,
14076 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14078 (void *)&cmd_set_vf_vlan_tag_set,
14079 (void *)&cmd_set_vf_vlan_tag_vf,
14080 (void *)&cmd_set_vf_vlan_tag_vlan,
14081 (void *)&cmd_set_vf_vlan_tag_tag,
14082 (void *)&cmd_set_vf_vlan_tag_port_id,
14083 (void *)&cmd_set_vf_vlan_tag_vf_id,
14084 (void *)&cmd_set_vf_vlan_tag_on_off,
14089 /* Common definition of VF and TC TX bandwidth configuration */
14090 struct cmd_vf_tc_bw_result {
14091 cmdline_fixed_string_t set;
14092 cmdline_fixed_string_t vf;
14093 cmdline_fixed_string_t tc;
14094 cmdline_fixed_string_t tx;
14095 cmdline_fixed_string_t min_bw;
14096 cmdline_fixed_string_t max_bw;
14097 cmdline_fixed_string_t strict_link_prio;
14102 cmdline_fixed_string_t bw_list;
14106 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14107 TOKEN_STRING_INITIALIZER
14108 (struct cmd_vf_tc_bw_result,
14110 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14111 TOKEN_STRING_INITIALIZER
14112 (struct cmd_vf_tc_bw_result,
14114 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14115 TOKEN_STRING_INITIALIZER
14116 (struct cmd_vf_tc_bw_result,
14118 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14119 TOKEN_STRING_INITIALIZER
14120 (struct cmd_vf_tc_bw_result,
14122 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14123 TOKEN_STRING_INITIALIZER
14124 (struct cmd_vf_tc_bw_result,
14125 strict_link_prio, "strict-link-priority");
14126 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14127 TOKEN_STRING_INITIALIZER
14128 (struct cmd_vf_tc_bw_result,
14129 min_bw, "min-bandwidth");
14130 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14131 TOKEN_STRING_INITIALIZER
14132 (struct cmd_vf_tc_bw_result,
14133 max_bw, "max-bandwidth");
14134 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14135 TOKEN_NUM_INITIALIZER
14136 (struct cmd_vf_tc_bw_result,
14138 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14139 TOKEN_NUM_INITIALIZER
14140 (struct cmd_vf_tc_bw_result,
14142 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14143 TOKEN_NUM_INITIALIZER
14144 (struct cmd_vf_tc_bw_result,
14146 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14147 TOKEN_NUM_INITIALIZER
14148 (struct cmd_vf_tc_bw_result,
14150 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14151 TOKEN_STRING_INITIALIZER
14152 (struct cmd_vf_tc_bw_result,
14154 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14155 TOKEN_NUM_INITIALIZER
14156 (struct cmd_vf_tc_bw_result,
14159 /* VF max bandwidth setting */
14161 cmd_vf_max_bw_parsed(
14162 void *parsed_result,
14163 __attribute__((unused)) struct cmdline *cl,
14164 __attribute__((unused)) void *data)
14166 struct cmd_vf_tc_bw_result *res = parsed_result;
14167 int ret = -ENOTSUP;
14169 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14172 #ifdef RTE_LIBRTE_I40E_PMD
14173 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14174 res->vf_id, res->bw);
14181 printf("invalid vf_id %d or bandwidth %d\n",
14182 res->vf_id, res->bw);
14185 printf("invalid port_id %d\n", res->port_id);
14188 printf("function not implemented\n");
14191 printf("programming error: (%s)\n", strerror(-ret));
14195 cmdline_parse_inst_t cmd_vf_max_bw = {
14196 .f = cmd_vf_max_bw_parsed,
14198 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14200 (void *)&cmd_vf_tc_bw_set,
14201 (void *)&cmd_vf_tc_bw_vf,
14202 (void *)&cmd_vf_tc_bw_tx,
14203 (void *)&cmd_vf_tc_bw_max_bw,
14204 (void *)&cmd_vf_tc_bw_port_id,
14205 (void *)&cmd_vf_tc_bw_vf_id,
14206 (void *)&cmd_vf_tc_bw_bw,
14212 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14217 const char *p, *p0 = str;
14224 p = strchr(p0, '(');
14226 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14230 p0 = strchr(p, ')');
14232 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14236 if (size >= sizeof(s)) {
14237 printf("The string size exceeds the internal buffer size\n");
14240 snprintf(s, sizeof(s), "%.*s", size, p);
14241 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14243 printf("Failed to get the bandwidth list. ");
14247 for (i = 0; i < ret; i++)
14248 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14253 /* TC min bandwidth setting */
14255 cmd_vf_tc_min_bw_parsed(
14256 void *parsed_result,
14257 __attribute__((unused)) struct cmdline *cl,
14258 __attribute__((unused)) void *data)
14260 struct cmd_vf_tc_bw_result *res = parsed_result;
14263 int ret = -ENOTSUP;
14265 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14268 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14272 #ifdef RTE_LIBRTE_I40E_PMD
14273 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14281 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14284 printf("invalid port_id %d\n", res->port_id);
14287 printf("function not implemented\n");
14290 printf("programming error: (%s)\n", strerror(-ret));
14294 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14295 .f = cmd_vf_tc_min_bw_parsed,
14297 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14298 " <bw1, bw2, ...>",
14300 (void *)&cmd_vf_tc_bw_set,
14301 (void *)&cmd_vf_tc_bw_vf,
14302 (void *)&cmd_vf_tc_bw_tc,
14303 (void *)&cmd_vf_tc_bw_tx,
14304 (void *)&cmd_vf_tc_bw_min_bw,
14305 (void *)&cmd_vf_tc_bw_port_id,
14306 (void *)&cmd_vf_tc_bw_vf_id,
14307 (void *)&cmd_vf_tc_bw_bw_list,
14313 cmd_tc_min_bw_parsed(
14314 void *parsed_result,
14315 __attribute__((unused)) struct cmdline *cl,
14316 __attribute__((unused)) void *data)
14318 struct cmd_vf_tc_bw_result *res = parsed_result;
14319 struct rte_port *port;
14322 int ret = -ENOTSUP;
14324 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14327 port = &ports[res->port_id];
14328 /** Check if the port is not started **/
14329 if (port->port_status != RTE_PORT_STOPPED) {
14330 printf("Please stop port %d first\n", res->port_id);
14334 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14338 #ifdef RTE_LIBRTE_IXGBE_PMD
14339 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14346 printf("invalid bandwidth\n");
14349 printf("invalid port_id %d\n", res->port_id);
14352 printf("function not implemented\n");
14355 printf("programming error: (%s)\n", strerror(-ret));
14359 cmdline_parse_inst_t cmd_tc_min_bw = {
14360 .f = cmd_tc_min_bw_parsed,
14362 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14364 (void *)&cmd_vf_tc_bw_set,
14365 (void *)&cmd_vf_tc_bw_tc,
14366 (void *)&cmd_vf_tc_bw_tx,
14367 (void *)&cmd_vf_tc_bw_min_bw,
14368 (void *)&cmd_vf_tc_bw_port_id,
14369 (void *)&cmd_vf_tc_bw_bw_list,
14374 /* TC max bandwidth setting */
14376 cmd_vf_tc_max_bw_parsed(
14377 void *parsed_result,
14378 __attribute__((unused)) struct cmdline *cl,
14379 __attribute__((unused)) void *data)
14381 struct cmd_vf_tc_bw_result *res = parsed_result;
14382 int ret = -ENOTSUP;
14384 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14387 #ifdef RTE_LIBRTE_I40E_PMD
14388 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14389 res->tc_no, res->bw);
14396 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14397 res->vf_id, res->tc_no, res->bw);
14400 printf("invalid port_id %d\n", res->port_id);
14403 printf("function not implemented\n");
14406 printf("programming error: (%s)\n", strerror(-ret));
14410 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14411 .f = cmd_vf_tc_max_bw_parsed,
14413 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14416 (void *)&cmd_vf_tc_bw_set,
14417 (void *)&cmd_vf_tc_bw_vf,
14418 (void *)&cmd_vf_tc_bw_tc,
14419 (void *)&cmd_vf_tc_bw_tx,
14420 (void *)&cmd_vf_tc_bw_max_bw,
14421 (void *)&cmd_vf_tc_bw_port_id,
14422 (void *)&cmd_vf_tc_bw_vf_id,
14423 (void *)&cmd_vf_tc_bw_tc_no,
14424 (void *)&cmd_vf_tc_bw_bw,
14430 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14432 /* *** Set Port default Traffic Management Hierarchy *** */
14433 struct cmd_set_port_tm_hierarchy_default_result {
14434 cmdline_fixed_string_t set;
14435 cmdline_fixed_string_t port;
14436 cmdline_fixed_string_t tm;
14437 cmdline_fixed_string_t hierarchy;
14438 cmdline_fixed_string_t def;
14442 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14443 TOKEN_STRING_INITIALIZER(
14444 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14445 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14446 TOKEN_STRING_INITIALIZER(
14447 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14448 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14449 TOKEN_STRING_INITIALIZER(
14450 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14451 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14452 TOKEN_STRING_INITIALIZER(
14453 struct cmd_set_port_tm_hierarchy_default_result,
14454 hierarchy, "hierarchy");
14455 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14456 TOKEN_STRING_INITIALIZER(
14457 struct cmd_set_port_tm_hierarchy_default_result,
14459 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14460 TOKEN_NUM_INITIALIZER(
14461 struct cmd_set_port_tm_hierarchy_default_result,
14464 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14465 __attribute__((unused)) struct cmdline *cl,
14466 __attribute__((unused)) void *data)
14468 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14469 struct rte_port *p;
14470 portid_t port_id = res->port_id;
14472 if (port_id_is_invalid(port_id, ENABLED_WARN))
14475 p = &ports[port_id];
14478 if (p->softport.tm_flag == 0) {
14479 printf(" tm not enabled on port %u (error)\n", port_id);
14483 /* Forward mode: tm */
14484 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14485 printf(" tm mode not enabled(error)\n");
14489 /* Set the default tm hierarchy */
14490 p->softport.tm.default_hierarchy_enable = 1;
14493 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14494 .f = cmd_set_port_tm_hierarchy_default_parsed,
14496 .help_str = "set port tm hierarchy default <port_id>",
14498 (void *)&cmd_set_port_tm_hierarchy_default_set,
14499 (void *)&cmd_set_port_tm_hierarchy_default_port,
14500 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14501 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14502 (void *)&cmd_set_port_tm_hierarchy_default_default,
14503 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14509 /* Strict link priority scheduling mode setting */
14511 cmd_strict_link_prio_parsed(
14512 void *parsed_result,
14513 __attribute__((unused)) struct cmdline *cl,
14514 __attribute__((unused)) void *data)
14516 struct cmd_vf_tc_bw_result *res = parsed_result;
14517 int ret = -ENOTSUP;
14519 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14522 #ifdef RTE_LIBRTE_I40E_PMD
14523 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14530 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14533 printf("invalid port_id %d\n", res->port_id);
14536 printf("function not implemented\n");
14539 printf("programming error: (%s)\n", strerror(-ret));
14543 cmdline_parse_inst_t cmd_strict_link_prio = {
14544 .f = cmd_strict_link_prio_parsed,
14546 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14548 (void *)&cmd_vf_tc_bw_set,
14549 (void *)&cmd_vf_tc_bw_tx,
14550 (void *)&cmd_vf_tc_bw_strict_link_prio,
14551 (void *)&cmd_vf_tc_bw_port_id,
14552 (void *)&cmd_vf_tc_bw_tc_map,
14557 /* Load dynamic device personalization*/
14558 struct cmd_ddp_add_result {
14559 cmdline_fixed_string_t ddp;
14560 cmdline_fixed_string_t add;
14565 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14566 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14567 cmdline_parse_token_string_t cmd_ddp_add_add =
14568 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14569 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14570 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14571 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14572 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14575 cmd_ddp_add_parsed(
14576 void *parsed_result,
14577 __attribute__((unused)) struct cmdline *cl,
14578 __attribute__((unused)) void *data)
14580 struct cmd_ddp_add_result *res = parsed_result;
14586 int ret = -ENOTSUP;
14588 if (!all_ports_stopped()) {
14589 printf("Please stop all ports first\n");
14593 filepath = strdup(res->filepath);
14594 if (filepath == NULL) {
14595 printf("Failed to allocate memory\n");
14598 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14600 buff = open_file(file_fld[0], &size);
14602 free((void *)filepath);
14606 #ifdef RTE_LIBRTE_I40E_PMD
14607 if (ret == -ENOTSUP)
14608 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14610 RTE_PMD_I40E_PKG_OP_WR_ADD);
14613 if (ret == -EEXIST)
14614 printf("Profile has already existed.\n");
14616 printf("Failed to load profile.\n");
14617 else if (file_num == 2)
14618 save_file(file_fld[1], buff, size);
14621 free((void *)filepath);
14624 cmdline_parse_inst_t cmd_ddp_add = {
14625 .f = cmd_ddp_add_parsed,
14627 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14629 (void *)&cmd_ddp_add_ddp,
14630 (void *)&cmd_ddp_add_add,
14631 (void *)&cmd_ddp_add_port_id,
14632 (void *)&cmd_ddp_add_filepath,
14637 /* Delete dynamic device personalization*/
14638 struct cmd_ddp_del_result {
14639 cmdline_fixed_string_t ddp;
14640 cmdline_fixed_string_t del;
14645 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14646 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14647 cmdline_parse_token_string_t cmd_ddp_del_del =
14648 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14649 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14650 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14651 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14652 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14655 cmd_ddp_del_parsed(
14656 void *parsed_result,
14657 __attribute__((unused)) struct cmdline *cl,
14658 __attribute__((unused)) void *data)
14660 struct cmd_ddp_del_result *res = parsed_result;
14663 int ret = -ENOTSUP;
14665 if (!all_ports_stopped()) {
14666 printf("Please stop all ports first\n");
14670 buff = open_file(res->filepath, &size);
14674 #ifdef RTE_LIBRTE_I40E_PMD
14675 if (ret == -ENOTSUP)
14676 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14678 RTE_PMD_I40E_PKG_OP_WR_DEL);
14681 if (ret == -EACCES)
14682 printf("Profile does not exist.\n");
14684 printf("Failed to delete profile.\n");
14689 cmdline_parse_inst_t cmd_ddp_del = {
14690 .f = cmd_ddp_del_parsed,
14692 .help_str = "ddp del <port_id> <backup_profile_path>",
14694 (void *)&cmd_ddp_del_ddp,
14695 (void *)&cmd_ddp_del_del,
14696 (void *)&cmd_ddp_del_port_id,
14697 (void *)&cmd_ddp_del_filepath,
14702 /* Get dynamic device personalization profile info */
14703 struct cmd_ddp_info_result {
14704 cmdline_fixed_string_t ddp;
14705 cmdline_fixed_string_t get;
14706 cmdline_fixed_string_t info;
14710 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14711 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14712 cmdline_parse_token_string_t cmd_ddp_info_get =
14713 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14714 cmdline_parse_token_string_t cmd_ddp_info_info =
14715 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14716 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14717 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14720 cmd_ddp_info_parsed(
14721 void *parsed_result,
14722 __attribute__((unused)) struct cmdline *cl,
14723 __attribute__((unused)) void *data)
14725 struct cmd_ddp_info_result *res = parsed_result;
14728 int ret = -ENOTSUP;
14729 #ifdef RTE_LIBRTE_I40E_PMD
14732 uint32_t buff_size = 0;
14733 struct rte_pmd_i40e_profile_info info;
14734 uint32_t dev_num = 0;
14735 struct rte_pmd_i40e_ddp_device_id *devs;
14736 uint32_t proto_num = 0;
14737 struct rte_pmd_i40e_proto_info *proto = NULL;
14738 uint32_t pctype_num = 0;
14739 struct rte_pmd_i40e_ptype_info *pctype;
14740 uint32_t ptype_num = 0;
14741 struct rte_pmd_i40e_ptype_info *ptype;
14746 pkg = open_file(res->filepath, &pkg_size);
14750 #ifdef RTE_LIBRTE_I40E_PMD
14751 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14752 (uint8_t *)&info, sizeof(info),
14753 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14755 printf("Global Track id: 0x%x\n", info.track_id);
14756 printf("Global Version: %d.%d.%d.%d\n",
14757 info.version.major,
14758 info.version.minor,
14759 info.version.update,
14760 info.version.draft);
14761 printf("Global Package name: %s\n\n", info.name);
14764 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14765 (uint8_t *)&info, sizeof(info),
14766 RTE_PMD_I40E_PKG_INFO_HEADER);
14768 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14769 printf("i40e Profile Version: %d.%d.%d.%d\n",
14770 info.version.major,
14771 info.version.minor,
14772 info.version.update,
14773 info.version.draft);
14774 printf("i40e Profile name: %s\n\n", info.name);
14777 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14778 (uint8_t *)&buff_size, sizeof(buff_size),
14779 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14780 if (!ret && buff_size) {
14781 buff = (uint8_t *)malloc(buff_size);
14783 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14785 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14787 printf("Package Notes:\n%s\n\n", buff);
14792 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14793 (uint8_t *)&dev_num, sizeof(dev_num),
14794 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14795 if (!ret && dev_num) {
14796 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14797 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14799 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14800 (uint8_t *)devs, buff_size,
14801 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14803 printf("List of supported devices:\n");
14804 for (i = 0; i < dev_num; i++) {
14805 printf(" %04X:%04X %04X:%04X\n",
14806 devs[i].vendor_dev_id >> 16,
14807 devs[i].vendor_dev_id & 0xFFFF,
14808 devs[i].sub_vendor_dev_id >> 16,
14809 devs[i].sub_vendor_dev_id & 0xFFFF);
14817 /* get information about protocols and packet types */
14818 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14819 (uint8_t *)&proto_num, sizeof(proto_num),
14820 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14821 if (ret || !proto_num)
14822 goto no_print_return;
14824 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14825 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14827 goto no_print_return;
14829 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14831 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14833 printf("List of used protocols:\n");
14834 for (i = 0; i < proto_num; i++)
14835 printf(" %2u: %s\n", proto[i].proto_id,
14839 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14840 (uint8_t *)&pctype_num, sizeof(pctype_num),
14841 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14842 if (ret || !pctype_num)
14843 goto no_print_pctypes;
14845 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14846 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14848 goto no_print_pctypes;
14850 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14852 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14855 goto no_print_pctypes;
14858 printf("List of defined packet classification types:\n");
14859 for (i = 0; i < pctype_num; i++) {
14860 printf(" %2u:", pctype[i].ptype_id);
14861 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14862 proto_id = pctype[i].protocols[j];
14863 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14864 for (n = 0; n < proto_num; n++) {
14865 if (proto[n].proto_id == proto_id) {
14866 printf(" %s", proto[n].name);
14879 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14881 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14882 if (ret || !ptype_num)
14883 goto no_print_return;
14885 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14886 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14888 goto no_print_return;
14890 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14892 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14895 goto no_print_return;
14897 printf("List of defined packet types:\n");
14898 for (i = 0; i < ptype_num; i++) {
14899 printf(" %2u:", ptype[i].ptype_id);
14900 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14901 proto_id = ptype[i].protocols[j];
14902 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14903 for (n = 0; n < proto_num; n++) {
14904 if (proto[n].proto_id == proto_id) {
14905 printf(" %s", proto[n].name);
14921 if (ret == -ENOTSUP)
14922 printf("Function not supported in PMD driver\n");
14926 cmdline_parse_inst_t cmd_ddp_get_info = {
14927 .f = cmd_ddp_info_parsed,
14929 .help_str = "ddp get info <profile_path>",
14931 (void *)&cmd_ddp_info_ddp,
14932 (void *)&cmd_ddp_info_get,
14933 (void *)&cmd_ddp_info_info,
14934 (void *)&cmd_ddp_info_filepath,
14939 /* Get dynamic device personalization profile info list*/
14940 #define PROFILE_INFO_SIZE 48
14941 #define MAX_PROFILE_NUM 16
14943 struct cmd_ddp_get_list_result {
14944 cmdline_fixed_string_t ddp;
14945 cmdline_fixed_string_t get;
14946 cmdline_fixed_string_t list;
14950 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14951 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14952 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14953 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14954 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14955 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14956 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14957 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14960 cmd_ddp_get_list_parsed(
14961 __attribute__((unused)) void *parsed_result,
14962 __attribute__((unused)) struct cmdline *cl,
14963 __attribute__((unused)) void *data)
14965 #ifdef RTE_LIBRTE_I40E_PMD
14966 struct cmd_ddp_get_list_result *res = parsed_result;
14967 struct rte_pmd_i40e_profile_list *p_list;
14968 struct rte_pmd_i40e_profile_info *p_info;
14973 int ret = -ENOTSUP;
14975 #ifdef RTE_LIBRTE_I40E_PMD
14976 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14977 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14979 printf("%s: Failed to malloc buffer\n", __func__);
14981 if (ret == -ENOTSUP)
14982 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14983 (uint8_t *)p_list, size);
14986 p_num = p_list->p_count;
14987 printf("Profile number is: %d\n\n", p_num);
14989 for (i = 0; i < p_num; i++) {
14990 p_info = &p_list->p_info[i];
14991 printf("Profile %d:\n", i);
14992 printf("Track id: 0x%x\n", p_info->track_id);
14993 printf("Version: %d.%d.%d.%d\n",
14994 p_info->version.major,
14995 p_info->version.minor,
14996 p_info->version.update,
14997 p_info->version.draft);
14998 printf("Profile name: %s\n\n", p_info->name);
15006 printf("Failed to get ddp list\n");
15009 cmdline_parse_inst_t cmd_ddp_get_list = {
15010 .f = cmd_ddp_get_list_parsed,
15012 .help_str = "ddp get list <port_id>",
15014 (void *)&cmd_ddp_get_list_ddp,
15015 (void *)&cmd_ddp_get_list_get,
15016 (void *)&cmd_ddp_get_list_list,
15017 (void *)&cmd_ddp_get_list_port_id,
15022 /* Configure input set */
15023 struct cmd_cfg_input_set_result {
15024 cmdline_fixed_string_t port;
15025 cmdline_fixed_string_t cfg;
15027 cmdline_fixed_string_t pctype;
15029 cmdline_fixed_string_t inset_type;
15030 cmdline_fixed_string_t opt;
15031 cmdline_fixed_string_t field;
15036 cmd_cfg_input_set_parsed(
15037 __attribute__((unused)) void *parsed_result,
15038 __attribute__((unused)) struct cmdline *cl,
15039 __attribute__((unused)) void *data)
15041 #ifdef RTE_LIBRTE_I40E_PMD
15042 struct cmd_cfg_input_set_result *res = parsed_result;
15043 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15044 struct rte_pmd_i40e_inset inset;
15046 int ret = -ENOTSUP;
15048 if (!all_ports_stopped()) {
15049 printf("Please stop all ports first\n");
15053 #ifdef RTE_LIBRTE_I40E_PMD
15054 if (!strcmp(res->inset_type, "hash_inset"))
15055 inset_type = INSET_HASH;
15056 else if (!strcmp(res->inset_type, "fdir_inset"))
15057 inset_type = INSET_FDIR;
15058 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15059 inset_type = INSET_FDIR_FLX;
15060 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15061 &inset, inset_type);
15063 printf("Failed to get input set.\n");
15067 if (!strcmp(res->opt, "get")) {
15068 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15071 printf("Field index %d is enabled.\n", res->field_idx);
15073 printf("Field index %d is disabled.\n", res->field_idx);
15075 } else if (!strcmp(res->opt, "set"))
15076 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15078 else if (!strcmp(res->opt, "clear"))
15079 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15082 printf("Failed to configure input set field.\n");
15086 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15087 &inset, inset_type);
15089 printf("Failed to set input set.\n");
15094 if (ret == -ENOTSUP)
15095 printf("Function not supported\n");
15098 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15099 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15101 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15102 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15104 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15105 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15107 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15108 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15110 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15111 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15113 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15114 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15116 "hash_inset#fdir_inset#fdir_flx_inset");
15117 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15118 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15119 opt, "get#set#clear");
15120 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15121 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15123 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15124 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15127 cmdline_parse_inst_t cmd_cfg_input_set = {
15128 .f = cmd_cfg_input_set_parsed,
15130 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15131 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15133 (void *)&cmd_cfg_input_set_port,
15134 (void *)&cmd_cfg_input_set_cfg,
15135 (void *)&cmd_cfg_input_set_port_id,
15136 (void *)&cmd_cfg_input_set_pctype,
15137 (void *)&cmd_cfg_input_set_pctype_id,
15138 (void *)&cmd_cfg_input_set_inset_type,
15139 (void *)&cmd_cfg_input_set_opt,
15140 (void *)&cmd_cfg_input_set_field,
15141 (void *)&cmd_cfg_input_set_field_idx,
15146 /* Clear input set */
15147 struct cmd_clear_input_set_result {
15148 cmdline_fixed_string_t port;
15149 cmdline_fixed_string_t cfg;
15151 cmdline_fixed_string_t pctype;
15153 cmdline_fixed_string_t inset_type;
15154 cmdline_fixed_string_t clear;
15155 cmdline_fixed_string_t all;
15159 cmd_clear_input_set_parsed(
15160 __attribute__((unused)) void *parsed_result,
15161 __attribute__((unused)) struct cmdline *cl,
15162 __attribute__((unused)) void *data)
15164 #ifdef RTE_LIBRTE_I40E_PMD
15165 struct cmd_clear_input_set_result *res = parsed_result;
15166 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15167 struct rte_pmd_i40e_inset inset;
15169 int ret = -ENOTSUP;
15171 if (!all_ports_stopped()) {
15172 printf("Please stop all ports first\n");
15176 #ifdef RTE_LIBRTE_I40E_PMD
15177 if (!strcmp(res->inset_type, "hash_inset"))
15178 inset_type = INSET_HASH;
15179 else if (!strcmp(res->inset_type, "fdir_inset"))
15180 inset_type = INSET_FDIR;
15181 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15182 inset_type = INSET_FDIR_FLX;
15184 memset(&inset, 0, sizeof(inset));
15186 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15187 &inset, inset_type);
15189 printf("Failed to clear input set.\n");
15195 if (ret == -ENOTSUP)
15196 printf("Function not supported\n");
15199 cmdline_parse_token_string_t cmd_clear_input_set_port =
15200 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15202 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15203 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15205 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15206 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15208 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15209 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15211 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15212 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15214 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15215 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15217 "hash_inset#fdir_inset#fdir_flx_inset");
15218 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15219 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15221 cmdline_parse_token_string_t cmd_clear_input_set_all =
15222 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15225 cmdline_parse_inst_t cmd_clear_input_set = {
15226 .f = cmd_clear_input_set_parsed,
15228 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15229 "fdir_inset|fdir_flx_inset clear all",
15231 (void *)&cmd_clear_input_set_port,
15232 (void *)&cmd_clear_input_set_cfg,
15233 (void *)&cmd_clear_input_set_port_id,
15234 (void *)&cmd_clear_input_set_pctype,
15235 (void *)&cmd_clear_input_set_pctype_id,
15236 (void *)&cmd_clear_input_set_inset_type,
15237 (void *)&cmd_clear_input_set_clear,
15238 (void *)&cmd_clear_input_set_all,
15243 /* show vf stats */
15245 /* Common result structure for show vf stats */
15246 struct cmd_show_vf_stats_result {
15247 cmdline_fixed_string_t show;
15248 cmdline_fixed_string_t vf;
15249 cmdline_fixed_string_t stats;
15254 /* Common CLI fields show vf stats*/
15255 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15256 TOKEN_STRING_INITIALIZER
15257 (struct cmd_show_vf_stats_result,
15259 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15260 TOKEN_STRING_INITIALIZER
15261 (struct cmd_show_vf_stats_result,
15263 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15264 TOKEN_STRING_INITIALIZER
15265 (struct cmd_show_vf_stats_result,
15267 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15268 TOKEN_NUM_INITIALIZER
15269 (struct cmd_show_vf_stats_result,
15271 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15272 TOKEN_NUM_INITIALIZER
15273 (struct cmd_show_vf_stats_result,
15277 cmd_show_vf_stats_parsed(
15278 void *parsed_result,
15279 __attribute__((unused)) struct cmdline *cl,
15280 __attribute__((unused)) void *data)
15282 struct cmd_show_vf_stats_result *res = parsed_result;
15283 struct rte_eth_stats stats;
15284 int ret = -ENOTSUP;
15285 static const char *nic_stats_border = "########################";
15287 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15290 memset(&stats, 0, sizeof(stats));
15292 #ifdef RTE_LIBRTE_I40E_PMD
15293 if (ret == -ENOTSUP)
15294 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15298 #ifdef RTE_LIBRTE_BNXT_PMD
15299 if (ret == -ENOTSUP)
15300 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15309 printf("invalid vf_id %d\n", res->vf_id);
15312 printf("invalid port_id %d\n", res->port_id);
15315 printf("function not implemented\n");
15318 printf("programming error: (%s)\n", strerror(-ret));
15321 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15322 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15324 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15326 stats.ipackets, stats.imissed, stats.ibytes);
15327 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15328 printf(" RX-nombuf: %-10"PRIu64"\n",
15330 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15332 stats.opackets, stats.oerrors, stats.obytes);
15334 printf(" %s############################%s\n",
15335 nic_stats_border, nic_stats_border);
15338 cmdline_parse_inst_t cmd_show_vf_stats = {
15339 .f = cmd_show_vf_stats_parsed,
15341 .help_str = "show vf stats <port_id> <vf_id>",
15343 (void *)&cmd_show_vf_stats_show,
15344 (void *)&cmd_show_vf_stats_vf,
15345 (void *)&cmd_show_vf_stats_stats,
15346 (void *)&cmd_show_vf_stats_port_id,
15347 (void *)&cmd_show_vf_stats_vf_id,
15352 /* clear vf stats */
15354 /* Common result structure for clear vf stats */
15355 struct cmd_clear_vf_stats_result {
15356 cmdline_fixed_string_t clear;
15357 cmdline_fixed_string_t vf;
15358 cmdline_fixed_string_t stats;
15363 /* Common CLI fields clear vf stats*/
15364 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15365 TOKEN_STRING_INITIALIZER
15366 (struct cmd_clear_vf_stats_result,
15368 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15369 TOKEN_STRING_INITIALIZER
15370 (struct cmd_clear_vf_stats_result,
15372 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15373 TOKEN_STRING_INITIALIZER
15374 (struct cmd_clear_vf_stats_result,
15376 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15377 TOKEN_NUM_INITIALIZER
15378 (struct cmd_clear_vf_stats_result,
15380 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15381 TOKEN_NUM_INITIALIZER
15382 (struct cmd_clear_vf_stats_result,
15386 cmd_clear_vf_stats_parsed(
15387 void *parsed_result,
15388 __attribute__((unused)) struct cmdline *cl,
15389 __attribute__((unused)) void *data)
15391 struct cmd_clear_vf_stats_result *res = parsed_result;
15392 int ret = -ENOTSUP;
15394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15397 #ifdef RTE_LIBRTE_I40E_PMD
15398 if (ret == -ENOTSUP)
15399 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15402 #ifdef RTE_LIBRTE_BNXT_PMD
15403 if (ret == -ENOTSUP)
15404 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15412 printf("invalid vf_id %d\n", res->vf_id);
15415 printf("invalid port_id %d\n", res->port_id);
15418 printf("function not implemented\n");
15421 printf("programming error: (%s)\n", strerror(-ret));
15425 cmdline_parse_inst_t cmd_clear_vf_stats = {
15426 .f = cmd_clear_vf_stats_parsed,
15428 .help_str = "clear vf stats <port_id> <vf_id>",
15430 (void *)&cmd_clear_vf_stats_clear,
15431 (void *)&cmd_clear_vf_stats_vf,
15432 (void *)&cmd_clear_vf_stats_stats,
15433 (void *)&cmd_clear_vf_stats_port_id,
15434 (void *)&cmd_clear_vf_stats_vf_id,
15439 /* port config pctype mapping reset */
15441 /* Common result structure for port config pctype mapping reset */
15442 struct cmd_pctype_mapping_reset_result {
15443 cmdline_fixed_string_t port;
15444 cmdline_fixed_string_t config;
15446 cmdline_fixed_string_t pctype;
15447 cmdline_fixed_string_t mapping;
15448 cmdline_fixed_string_t reset;
15451 /* Common CLI fields for port config pctype mapping reset*/
15452 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15453 TOKEN_STRING_INITIALIZER
15454 (struct cmd_pctype_mapping_reset_result,
15456 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15457 TOKEN_STRING_INITIALIZER
15458 (struct cmd_pctype_mapping_reset_result,
15460 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15461 TOKEN_NUM_INITIALIZER
15462 (struct cmd_pctype_mapping_reset_result,
15464 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15465 TOKEN_STRING_INITIALIZER
15466 (struct cmd_pctype_mapping_reset_result,
15468 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15469 TOKEN_STRING_INITIALIZER
15470 (struct cmd_pctype_mapping_reset_result,
15471 mapping, "mapping");
15472 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15473 TOKEN_STRING_INITIALIZER
15474 (struct cmd_pctype_mapping_reset_result,
15478 cmd_pctype_mapping_reset_parsed(
15479 void *parsed_result,
15480 __attribute__((unused)) struct cmdline *cl,
15481 __attribute__((unused)) void *data)
15483 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15484 int ret = -ENOTSUP;
15486 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15489 #ifdef RTE_LIBRTE_I40E_PMD
15490 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15497 printf("invalid port_id %d\n", res->port_id);
15500 printf("function not implemented\n");
15503 printf("programming error: (%s)\n", strerror(-ret));
15507 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15508 .f = cmd_pctype_mapping_reset_parsed,
15510 .help_str = "port config <port_id> pctype mapping reset",
15512 (void *)&cmd_pctype_mapping_reset_port,
15513 (void *)&cmd_pctype_mapping_reset_config,
15514 (void *)&cmd_pctype_mapping_reset_port_id,
15515 (void *)&cmd_pctype_mapping_reset_pctype,
15516 (void *)&cmd_pctype_mapping_reset_mapping,
15517 (void *)&cmd_pctype_mapping_reset_reset,
15522 /* show port pctype mapping */
15524 /* Common result structure for show port pctype mapping */
15525 struct cmd_pctype_mapping_get_result {
15526 cmdline_fixed_string_t show;
15527 cmdline_fixed_string_t port;
15529 cmdline_fixed_string_t pctype;
15530 cmdline_fixed_string_t mapping;
15533 /* Common CLI fields for pctype mapping get */
15534 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15535 TOKEN_STRING_INITIALIZER
15536 (struct cmd_pctype_mapping_get_result,
15538 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15539 TOKEN_STRING_INITIALIZER
15540 (struct cmd_pctype_mapping_get_result,
15542 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15543 TOKEN_NUM_INITIALIZER
15544 (struct cmd_pctype_mapping_get_result,
15546 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15547 TOKEN_STRING_INITIALIZER
15548 (struct cmd_pctype_mapping_get_result,
15550 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15551 TOKEN_STRING_INITIALIZER
15552 (struct cmd_pctype_mapping_get_result,
15553 mapping, "mapping");
15556 cmd_pctype_mapping_get_parsed(
15557 void *parsed_result,
15558 __attribute__((unused)) struct cmdline *cl,
15559 __attribute__((unused)) void *data)
15561 struct cmd_pctype_mapping_get_result *res = parsed_result;
15562 int ret = -ENOTSUP;
15563 #ifdef RTE_LIBRTE_I40E_PMD
15564 struct rte_pmd_i40e_flow_type_mapping
15565 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15566 int i, j, first_pctype;
15569 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15572 #ifdef RTE_LIBRTE_I40E_PMD
15573 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15580 printf("invalid port_id %d\n", res->port_id);
15583 printf("function not implemented\n");
15586 printf("programming error: (%s)\n", strerror(-ret));
15590 #ifdef RTE_LIBRTE_I40E_PMD
15591 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15592 if (mapping[i].pctype != 0ULL) {
15595 printf("pctype: ");
15596 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15597 if (mapping[i].pctype & (1ULL << j)) {
15598 printf(first_pctype ?
15599 "%02d" : ",%02d", j);
15603 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15609 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15610 .f = cmd_pctype_mapping_get_parsed,
15612 .help_str = "show port <port_id> pctype mapping",
15614 (void *)&cmd_pctype_mapping_get_show,
15615 (void *)&cmd_pctype_mapping_get_port,
15616 (void *)&cmd_pctype_mapping_get_port_id,
15617 (void *)&cmd_pctype_mapping_get_pctype,
15618 (void *)&cmd_pctype_mapping_get_mapping,
15623 /* port config pctype mapping update */
15625 /* Common result structure for port config pctype mapping update */
15626 struct cmd_pctype_mapping_update_result {
15627 cmdline_fixed_string_t port;
15628 cmdline_fixed_string_t config;
15630 cmdline_fixed_string_t pctype;
15631 cmdline_fixed_string_t mapping;
15632 cmdline_fixed_string_t update;
15633 cmdline_fixed_string_t pctype_list;
15634 uint16_t flow_type;
15637 /* Common CLI fields for pctype mapping update*/
15638 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15639 TOKEN_STRING_INITIALIZER
15640 (struct cmd_pctype_mapping_update_result,
15642 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15643 TOKEN_STRING_INITIALIZER
15644 (struct cmd_pctype_mapping_update_result,
15646 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15647 TOKEN_NUM_INITIALIZER
15648 (struct cmd_pctype_mapping_update_result,
15650 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15651 TOKEN_STRING_INITIALIZER
15652 (struct cmd_pctype_mapping_update_result,
15654 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15655 TOKEN_STRING_INITIALIZER
15656 (struct cmd_pctype_mapping_update_result,
15657 mapping, "mapping");
15658 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15659 TOKEN_STRING_INITIALIZER
15660 (struct cmd_pctype_mapping_update_result,
15662 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15663 TOKEN_STRING_INITIALIZER
15664 (struct cmd_pctype_mapping_update_result,
15665 pctype_list, NULL);
15666 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15667 TOKEN_NUM_INITIALIZER
15668 (struct cmd_pctype_mapping_update_result,
15669 flow_type, UINT16);
15672 cmd_pctype_mapping_update_parsed(
15673 void *parsed_result,
15674 __attribute__((unused)) struct cmdline *cl,
15675 __attribute__((unused)) void *data)
15677 struct cmd_pctype_mapping_update_result *res = parsed_result;
15678 int ret = -ENOTSUP;
15679 #ifdef RTE_LIBRTE_I40E_PMD
15680 struct rte_pmd_i40e_flow_type_mapping mapping;
15682 unsigned int nb_item;
15683 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15686 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15689 #ifdef RTE_LIBRTE_I40E_PMD
15690 nb_item = parse_item_list(res->pctype_list, "pctypes",
15691 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15692 mapping.flow_type = res->flow_type;
15693 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15694 mapping.pctype |= (1ULL << pctype_list[i]);
15695 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15705 printf("invalid pctype or flow type\n");
15708 printf("invalid port_id %d\n", res->port_id);
15711 printf("function not implemented\n");
15714 printf("programming error: (%s)\n", strerror(-ret));
15718 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15719 .f = cmd_pctype_mapping_update_parsed,
15721 .help_str = "port config <port_id> pctype mapping update"
15722 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15724 (void *)&cmd_pctype_mapping_update_port,
15725 (void *)&cmd_pctype_mapping_update_config,
15726 (void *)&cmd_pctype_mapping_update_port_id,
15727 (void *)&cmd_pctype_mapping_update_pctype,
15728 (void *)&cmd_pctype_mapping_update_mapping,
15729 (void *)&cmd_pctype_mapping_update_update,
15730 (void *)&cmd_pctype_mapping_update_pc_type,
15731 (void *)&cmd_pctype_mapping_update_flow_type,
15736 /* ptype mapping get */
15738 /* Common result structure for ptype mapping get */
15739 struct cmd_ptype_mapping_get_result {
15740 cmdline_fixed_string_t ptype;
15741 cmdline_fixed_string_t mapping;
15742 cmdline_fixed_string_t get;
15744 uint8_t valid_only;
15747 /* Common CLI fields for ptype mapping get */
15748 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15749 TOKEN_STRING_INITIALIZER
15750 (struct cmd_ptype_mapping_get_result,
15752 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15753 TOKEN_STRING_INITIALIZER
15754 (struct cmd_ptype_mapping_get_result,
15755 mapping, "mapping");
15756 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15757 TOKEN_STRING_INITIALIZER
15758 (struct cmd_ptype_mapping_get_result,
15760 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15761 TOKEN_NUM_INITIALIZER
15762 (struct cmd_ptype_mapping_get_result,
15764 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15765 TOKEN_NUM_INITIALIZER
15766 (struct cmd_ptype_mapping_get_result,
15767 valid_only, UINT8);
15770 cmd_ptype_mapping_get_parsed(
15771 void *parsed_result,
15772 __attribute__((unused)) struct cmdline *cl,
15773 __attribute__((unused)) void *data)
15775 struct cmd_ptype_mapping_get_result *res = parsed_result;
15776 int ret = -ENOTSUP;
15777 #ifdef RTE_LIBRTE_I40E_PMD
15778 int max_ptype_num = 256;
15779 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15784 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15787 #ifdef RTE_LIBRTE_I40E_PMD
15788 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15799 printf("invalid port_id %d\n", res->port_id);
15802 printf("function not implemented\n");
15805 printf("programming error: (%s)\n", strerror(-ret));
15808 #ifdef RTE_LIBRTE_I40E_PMD
15810 for (i = 0; i < count; i++)
15811 printf("%3d\t0x%08x\n",
15812 mapping[i].hw_ptype, mapping[i].sw_ptype);
15817 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15818 .f = cmd_ptype_mapping_get_parsed,
15820 .help_str = "ptype mapping get <port_id> <valid_only>",
15822 (void *)&cmd_ptype_mapping_get_ptype,
15823 (void *)&cmd_ptype_mapping_get_mapping,
15824 (void *)&cmd_ptype_mapping_get_get,
15825 (void *)&cmd_ptype_mapping_get_port_id,
15826 (void *)&cmd_ptype_mapping_get_valid_only,
15831 /* ptype mapping replace */
15833 /* Common result structure for ptype mapping replace */
15834 struct cmd_ptype_mapping_replace_result {
15835 cmdline_fixed_string_t ptype;
15836 cmdline_fixed_string_t mapping;
15837 cmdline_fixed_string_t replace;
15844 /* Common CLI fields for ptype mapping replace */
15845 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15846 TOKEN_STRING_INITIALIZER
15847 (struct cmd_ptype_mapping_replace_result,
15849 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15850 TOKEN_STRING_INITIALIZER
15851 (struct cmd_ptype_mapping_replace_result,
15852 mapping, "mapping");
15853 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15854 TOKEN_STRING_INITIALIZER
15855 (struct cmd_ptype_mapping_replace_result,
15856 replace, "replace");
15857 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15858 TOKEN_NUM_INITIALIZER
15859 (struct cmd_ptype_mapping_replace_result,
15861 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15862 TOKEN_NUM_INITIALIZER
15863 (struct cmd_ptype_mapping_replace_result,
15865 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15866 TOKEN_NUM_INITIALIZER
15867 (struct cmd_ptype_mapping_replace_result,
15869 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15870 TOKEN_NUM_INITIALIZER
15871 (struct cmd_ptype_mapping_replace_result,
15875 cmd_ptype_mapping_replace_parsed(
15876 void *parsed_result,
15877 __attribute__((unused)) struct cmdline *cl,
15878 __attribute__((unused)) void *data)
15880 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15881 int ret = -ENOTSUP;
15883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15886 #ifdef RTE_LIBRTE_I40E_PMD
15887 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15897 printf("invalid ptype 0x%8x or 0x%8x\n",
15898 res->target, res->pkt_type);
15901 printf("invalid port_id %d\n", res->port_id);
15904 printf("function not implemented\n");
15907 printf("programming error: (%s)\n", strerror(-ret));
15911 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15912 .f = cmd_ptype_mapping_replace_parsed,
15915 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15917 (void *)&cmd_ptype_mapping_replace_ptype,
15918 (void *)&cmd_ptype_mapping_replace_mapping,
15919 (void *)&cmd_ptype_mapping_replace_replace,
15920 (void *)&cmd_ptype_mapping_replace_port_id,
15921 (void *)&cmd_ptype_mapping_replace_target,
15922 (void *)&cmd_ptype_mapping_replace_mask,
15923 (void *)&cmd_ptype_mapping_replace_pkt_type,
15928 /* ptype mapping reset */
15930 /* Common result structure for ptype mapping reset */
15931 struct cmd_ptype_mapping_reset_result {
15932 cmdline_fixed_string_t ptype;
15933 cmdline_fixed_string_t mapping;
15934 cmdline_fixed_string_t reset;
15938 /* Common CLI fields for ptype mapping reset*/
15939 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15940 TOKEN_STRING_INITIALIZER
15941 (struct cmd_ptype_mapping_reset_result,
15943 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15944 TOKEN_STRING_INITIALIZER
15945 (struct cmd_ptype_mapping_reset_result,
15946 mapping, "mapping");
15947 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15948 TOKEN_STRING_INITIALIZER
15949 (struct cmd_ptype_mapping_reset_result,
15951 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15952 TOKEN_NUM_INITIALIZER
15953 (struct cmd_ptype_mapping_reset_result,
15957 cmd_ptype_mapping_reset_parsed(
15958 void *parsed_result,
15959 __attribute__((unused)) struct cmdline *cl,
15960 __attribute__((unused)) void *data)
15962 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15963 int ret = -ENOTSUP;
15965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15968 #ifdef RTE_LIBRTE_I40E_PMD
15969 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15976 printf("invalid port_id %d\n", res->port_id);
15979 printf("function not implemented\n");
15982 printf("programming error: (%s)\n", strerror(-ret));
15986 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15987 .f = cmd_ptype_mapping_reset_parsed,
15989 .help_str = "ptype mapping reset <port_id>",
15991 (void *)&cmd_ptype_mapping_reset_ptype,
15992 (void *)&cmd_ptype_mapping_reset_mapping,
15993 (void *)&cmd_ptype_mapping_reset_reset,
15994 (void *)&cmd_ptype_mapping_reset_port_id,
15999 /* ptype mapping update */
16001 /* Common result structure for ptype mapping update */
16002 struct cmd_ptype_mapping_update_result {
16003 cmdline_fixed_string_t ptype;
16004 cmdline_fixed_string_t mapping;
16005 cmdline_fixed_string_t reset;
16011 /* Common CLI fields for ptype mapping update*/
16012 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16013 TOKEN_STRING_INITIALIZER
16014 (struct cmd_ptype_mapping_update_result,
16016 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16017 TOKEN_STRING_INITIALIZER
16018 (struct cmd_ptype_mapping_update_result,
16019 mapping, "mapping");
16020 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16021 TOKEN_STRING_INITIALIZER
16022 (struct cmd_ptype_mapping_update_result,
16024 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16025 TOKEN_NUM_INITIALIZER
16026 (struct cmd_ptype_mapping_update_result,
16028 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16029 TOKEN_NUM_INITIALIZER
16030 (struct cmd_ptype_mapping_update_result,
16032 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16033 TOKEN_NUM_INITIALIZER
16034 (struct cmd_ptype_mapping_update_result,
16038 cmd_ptype_mapping_update_parsed(
16039 void *parsed_result,
16040 __attribute__((unused)) struct cmdline *cl,
16041 __attribute__((unused)) void *data)
16043 struct cmd_ptype_mapping_update_result *res = parsed_result;
16044 int ret = -ENOTSUP;
16045 #ifdef RTE_LIBRTE_I40E_PMD
16046 struct rte_pmd_i40e_ptype_mapping mapping;
16048 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16051 #ifdef RTE_LIBRTE_I40E_PMD
16052 mapping.hw_ptype = res->hw_ptype;
16053 mapping.sw_ptype = res->sw_ptype;
16054 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16064 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16067 printf("invalid port_id %d\n", res->port_id);
16070 printf("function not implemented\n");
16073 printf("programming error: (%s)\n", strerror(-ret));
16077 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16078 .f = cmd_ptype_mapping_update_parsed,
16080 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16082 (void *)&cmd_ptype_mapping_update_ptype,
16083 (void *)&cmd_ptype_mapping_update_mapping,
16084 (void *)&cmd_ptype_mapping_update_update,
16085 (void *)&cmd_ptype_mapping_update_port_id,
16086 (void *)&cmd_ptype_mapping_update_hw_ptype,
16087 (void *)&cmd_ptype_mapping_update_sw_ptype,
16092 /* Common result structure for file commands */
16093 struct cmd_cmdfile_result {
16094 cmdline_fixed_string_t load;
16095 cmdline_fixed_string_t filename;
16098 /* Common CLI fields for file commands */
16099 cmdline_parse_token_string_t cmd_load_cmdfile =
16100 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16101 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16102 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16105 cmd_load_from_file_parsed(
16106 void *parsed_result,
16107 __attribute__((unused)) struct cmdline *cl,
16108 __attribute__((unused)) void *data)
16110 struct cmd_cmdfile_result *res = parsed_result;
16112 cmdline_read_from_file(res->filename);
16115 cmdline_parse_inst_t cmd_load_from_file = {
16116 .f = cmd_load_from_file_parsed,
16118 .help_str = "load <filename>",
16120 (void *)&cmd_load_cmdfile,
16121 (void *)&cmd_load_cmdfile_filename,
16126 /* ******************************************************************************** */
16128 /* list of instructions */
16129 cmdline_parse_ctx_t main_ctx[] = {
16130 (cmdline_parse_inst_t *)&cmd_help_brief,
16131 (cmdline_parse_inst_t *)&cmd_help_long,
16132 (cmdline_parse_inst_t *)&cmd_quit,
16133 (cmdline_parse_inst_t *)&cmd_load_from_file,
16134 (cmdline_parse_inst_t *)&cmd_showport,
16135 (cmdline_parse_inst_t *)&cmd_showqueue,
16136 (cmdline_parse_inst_t *)&cmd_showportall,
16137 (cmdline_parse_inst_t *)&cmd_showcfg,
16138 (cmdline_parse_inst_t *)&cmd_start,
16139 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16140 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16141 (cmdline_parse_inst_t *)&cmd_set_link_up,
16142 (cmdline_parse_inst_t *)&cmd_set_link_down,
16143 (cmdline_parse_inst_t *)&cmd_reset,
16144 (cmdline_parse_inst_t *)&cmd_set_numbers,
16145 (cmdline_parse_inst_t *)&cmd_set_log,
16146 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16147 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16148 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16149 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16150 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16151 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16152 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16153 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16154 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16155 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16156 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16157 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16158 (cmdline_parse_inst_t *)&cmd_set_link_check,
16159 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16160 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16161 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16162 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16163 #ifdef RTE_LIBRTE_PMD_BOND
16164 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16165 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16166 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16167 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16168 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16169 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16170 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16171 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16172 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16173 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16174 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16176 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16177 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16178 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16179 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16180 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16181 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16182 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16183 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16184 (cmdline_parse_inst_t *)&cmd_csum_set,
16185 (cmdline_parse_inst_t *)&cmd_csum_show,
16186 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16187 (cmdline_parse_inst_t *)&cmd_tso_set,
16188 (cmdline_parse_inst_t *)&cmd_tso_show,
16189 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16190 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16191 (cmdline_parse_inst_t *)&cmd_gro_enable,
16192 (cmdline_parse_inst_t *)&cmd_gro_flush,
16193 (cmdline_parse_inst_t *)&cmd_gro_show,
16194 (cmdline_parse_inst_t *)&cmd_gso_enable,
16195 (cmdline_parse_inst_t *)&cmd_gso_size,
16196 (cmdline_parse_inst_t *)&cmd_gso_show,
16197 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16198 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16199 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16200 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16201 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16202 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16203 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16204 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16205 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16206 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16207 (cmdline_parse_inst_t *)&cmd_config_dcb,
16208 (cmdline_parse_inst_t *)&cmd_read_reg,
16209 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16210 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16211 (cmdline_parse_inst_t *)&cmd_write_reg,
16212 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16213 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16214 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16215 (cmdline_parse_inst_t *)&cmd_stop,
16216 (cmdline_parse_inst_t *)&cmd_mac_addr,
16217 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16218 (cmdline_parse_inst_t *)&cmd_set_qmap,
16219 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16220 (cmdline_parse_inst_t *)&cmd_operate_port,
16221 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16222 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16223 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16224 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16225 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16226 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16227 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16228 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16229 (cmdline_parse_inst_t *)&cmd_config_mtu,
16230 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16231 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16232 (cmdline_parse_inst_t *)&cmd_config_rss,
16233 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16234 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16235 (cmdline_parse_inst_t *)&cmd_showport_reta,
16236 (cmdline_parse_inst_t *)&cmd_config_burst,
16237 (cmdline_parse_inst_t *)&cmd_config_thresh,
16238 (cmdline_parse_inst_t *)&cmd_config_threshold,
16239 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16240 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16241 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16242 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16243 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16244 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16245 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16246 (cmdline_parse_inst_t *)&cmd_global_config,
16247 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16248 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16249 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16250 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16251 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16252 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16253 (cmdline_parse_inst_t *)&cmd_dump,
16254 (cmdline_parse_inst_t *)&cmd_dump_one,
16255 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16256 (cmdline_parse_inst_t *)&cmd_syn_filter,
16257 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16258 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16259 (cmdline_parse_inst_t *)&cmd_flex_filter,
16260 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16261 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16262 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16263 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16264 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16265 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16266 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16267 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16268 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16269 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16270 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16271 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16272 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16273 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16274 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16275 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16276 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16277 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16278 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16279 (cmdline_parse_inst_t *)&cmd_flow,
16280 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16281 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16282 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16283 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16284 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16285 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16286 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16287 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16288 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16289 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16290 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16291 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16292 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16293 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16294 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16295 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16296 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16297 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16298 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16299 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16300 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16301 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16302 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16303 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16304 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16305 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16306 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16307 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16308 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16309 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16310 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16311 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16312 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16313 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16314 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16315 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16316 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16317 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16318 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16319 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16320 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16321 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16322 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16323 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16324 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16325 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16326 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16327 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16328 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16329 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16330 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16332 (cmdline_parse_inst_t *)&cmd_ddp_add,
16333 (cmdline_parse_inst_t *)&cmd_ddp_del,
16334 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16335 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16336 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16337 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16338 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16339 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16340 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16341 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16342 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16343 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16345 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16346 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16347 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16348 (cmdline_parse_inst_t *)&cmd_queue_region,
16349 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16350 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16351 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16352 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16353 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16354 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16355 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16356 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16357 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16358 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16359 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16360 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16361 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16362 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16363 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16364 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16365 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16366 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16367 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16368 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16369 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16373 /* read cmdline commands from file */
16375 cmdline_read_from_file(const char *filename)
16377 struct cmdline *cl;
16379 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16381 printf("Failed to create file based cmdline context: %s\n",
16386 cmdline_interact(cl);
16391 printf("Read CLI commands from %s\n", filename);
16394 /* prompt function, called from main on MASTER lcore */
16398 /* initialize non-constant commands */
16399 cmd_set_fwd_mode_init();
16400 cmd_set_fwd_retry_mode_init();
16402 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16403 if (testpmd_cl == NULL)
16405 cmdline_interact(testpmd_cl);
16406 cmdline_stdin_exit(testpmd_cl);
16412 if (testpmd_cl != NULL)
16413 cmdline_quit(testpmd_cl);
16417 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16419 if (id == (portid_t)RTE_PORT_ALL) {
16422 RTE_ETH_FOREACH_DEV(pid) {
16423 /* check if need_reconfig has been set to 1 */
16424 if (ports[pid].need_reconfig == 0)
16425 ports[pid].need_reconfig = dev;
16426 /* check if need_reconfig_queues has been set to 1 */
16427 if (ports[pid].need_reconfig_queues == 0)
16428 ports[pid].need_reconfig_queues = queue;
16430 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16431 /* check if need_reconfig has been set to 1 */
16432 if (ports[id].need_reconfig == 0)
16433 ports[id].need_reconfig = dev;
16434 /* check if need_reconfig_queues has been set to 1 */
16435 if (ports[id].need_reconfig_queues == 0)
16436 ports[id].need_reconfig_queues = queue;