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"
80 static struct cmdline *testpmd_cl;
82 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
84 /* *** Help command with introduction. *** */
85 struct cmd_help_brief_result {
86 cmdline_fixed_string_t help;
89 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
91 __attribute__((unused)) void *data)
96 "Help is available for the following sections:\n\n"
97 " help control : Start and stop forwarding.\n"
98 " help display : Displaying port, stats and config "
100 " help config : Configuration information.\n"
101 " help ports : Configuring ports.\n"
102 " help registers : Reading and setting port registers.\n"
103 " help filters : Filters configuration help.\n"
104 " help all : All of the above sections.\n\n"
109 cmdline_parse_token_string_t cmd_help_brief_help =
110 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
112 cmdline_parse_inst_t cmd_help_brief = {
113 .f = cmd_help_brief_parsed,
115 .help_str = "help: Show help",
117 (void *)&cmd_help_brief_help,
122 /* *** Help command with help sections. *** */
123 struct cmd_help_long_result {
124 cmdline_fixed_string_t help;
125 cmdline_fixed_string_t section;
128 static void cmd_help_long_parsed(void *parsed_result,
130 __attribute__((unused)) void *data)
133 struct cmd_help_long_result *res = parsed_result;
135 if (!strcmp(res->section, "all"))
138 if (show_all || !strcmp(res->section, "control")) {
143 "Control forwarding:\n"
144 "-------------------\n\n"
147 " Start packet forwarding with current configuration.\n\n"
150 " Start packet forwarding with current config"
151 " after sending one burst of packets.\n\n"
154 " Stop packet forwarding, and display accumulated"
158 " Quit to prompt.\n\n"
162 if (show_all || !strcmp(res->section, "display")) {
170 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
171 " Display information for port_id, or all.\n\n"
173 "show port X rss reta (size) (mask0,mask1,...)\n"
174 " Display the rss redirection table entry indicated"
175 " by masks on port X. size is used to indicate the"
176 " hardware supported reta size\n\n"
178 "show port (port_id) rss-hash [key]\n"
179 " Display the RSS hash functions and RSS hash key of port\n\n"
181 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
182 " Clear information for port_id, or all.\n\n"
184 "show (rxq|txq) info (port_id) (queue_id)\n"
185 " Display information for configured RX/TX queue.\n\n"
187 "show config (rxtx|cores|fwd|txpkts)\n"
188 " Display the given configuration.\n\n"
190 "read rxd (port_id) (queue_id) (rxd_id)\n"
191 " Display an RX descriptor of a port RX queue.\n\n"
193 "read txd (port_id) (queue_id) (txd_id)\n"
194 " Display a TX descriptor of a port TX queue.\n\n"
196 "ddp get list (port_id)\n"
197 " Get ddp profile info list\n\n"
199 "ddp get info (profile_path)\n"
200 " Get ddp profile information.\n\n"
202 "show vf stats (port_id) (vf_id)\n"
203 " Display a VF's statistics.\n\n"
205 "clear vf stats (port_id) (vf_id)\n"
206 " Reset a VF's statistics.\n\n"
208 "show port (port_id) pctype mapping\n"
209 " Get flow ptype to pctype mapping on a port\n\n"
211 "show port meter stats (port_id) (meter_id) (clear)\n"
212 " Get meter stats on a port\n\n"
213 "show port tm cap (port_id)\n"
214 " Display the port TM capability.\n\n"
216 "show port tm level cap (port_id) (level_id)\n"
217 " Display the port TM hierarchical level capability.\n\n"
219 "show port tm node cap (port_id) (node_id)\n"
220 " Display the port TM node capability.\n\n"
222 "show port tm node type (port_id) (node_id)\n"
223 " Display the port TM node type.\n\n"
225 "show port tm node stats (port_id) (node_id) (clear)\n"
226 " Display the port TM node stats.\n\n"
228 "show fwd stats all\n"
229 " Display statistics for all fwd engines.\n\n"
231 "clear fwd stats all\n"
232 " Clear statistics for all fwd engines.\n\n"
236 if (show_all || !strcmp(res->section, "config")) {
242 "Configuration changes only become active when"
243 " forwarding is started/restarted.\n\n"
246 " Reset forwarding to the default configuration.\n\n"
248 "set verbose (level)\n"
249 " Set the debug verbosity level X.\n\n"
251 "set log global|(type) (level)\n"
252 " Set the log level.\n\n"
255 " Set number of ports.\n\n"
258 " Set number of cores.\n\n"
260 "set coremask (mask)\n"
261 " Set the forwarding cores hexadecimal mask.\n\n"
263 "set portmask (mask)\n"
264 " Set the forwarding ports hexadecimal mask.\n\n"
267 " Set number of packets per burst.\n\n"
269 "set burst tx delay (microseconds) retry (num)\n"
270 " Set the transmit delay time and number of retries,"
271 " effective when retry is enabled.\n\n"
273 "set txpkts (x[,y]*)\n"
274 " Set the length of each segment of TXONLY"
275 " and optionally CSUM packets.\n\n"
277 "set txsplit (off|on|rand)\n"
278 " Set the split policy for the TX packets."
279 " Right now only applicable for CSUM and TXONLY"
282 "set corelist (x[,y]*)\n"
283 " Set the list of forwarding cores.\n\n"
285 "set portlist (x[,y]*)\n"
286 " Set the list of forwarding ports.\n\n"
288 "set port setup on (iterator|event)\n"
289 " Select how attached port is retrieved for setup.\n\n"
291 "set tx loopback (port_id) (on|off)\n"
292 " Enable or disable tx loopback.\n\n"
294 "set all queues drop (port_id) (on|off)\n"
295 " Set drop enable bit for all queues.\n\n"
297 "set vf split drop (port_id) (vf_id) (on|off)\n"
298 " Set split drop enable bit for a VF from the PF.\n\n"
300 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
301 " Set MAC antispoof for a VF from the PF.\n\n"
303 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
304 " Enable MACsec offload.\n\n"
306 "set macsec offload (port_id) off\n"
307 " Disable MACsec offload.\n\n"
309 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
310 " Configure MACsec secure connection (SC).\n\n"
312 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
313 " Configure MACsec secure association (SA).\n\n"
315 "set vf broadcast (port_id) (vf_id) (on|off)\n"
316 " Set VF broadcast for a VF from the PF.\n\n"
318 "vlan set strip (on|off) (port_id)\n"
319 " Set the VLAN strip on a port.\n\n"
321 "vlan set stripq (on|off) (port_id,queue_id)\n"
322 " Set the VLAN strip for a queue on a port.\n\n"
324 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
325 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
327 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
328 " Set VLAN insert for a VF from the PF.\n\n"
330 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
331 " Set VLAN antispoof for a VF from the PF.\n\n"
333 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
334 " Set VLAN tag for a VF from the PF.\n\n"
336 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
337 " Set a VF's max bandwidth(Mbps).\n\n"
339 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
340 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
342 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
343 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
345 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
346 " Set some TCs' strict link priority mode on a physical port.\n\n"
348 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
349 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
351 "vlan set filter (on|off) (port_id)\n"
352 " Set the VLAN filter on a port.\n\n"
354 "vlan set qinq (on|off) (port_id)\n"
355 " Set the VLAN QinQ (extended queue in queue)"
358 "vlan set (inner|outer) tpid (value) (port_id)\n"
359 " Set the VLAN TPID for Packet Filtering on"
362 "rx_vlan add (vlan_id|all) (port_id)\n"
363 " Add a vlan_id, or all identifiers, to the set"
364 " of VLAN identifiers filtered by port_id.\n\n"
366 "rx_vlan rm (vlan_id|all) (port_id)\n"
367 " Remove a vlan_id, or all identifiers, from the set"
368 " of VLAN identifiers filtered by port_id.\n\n"
370 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
371 " Add a vlan_id, to the set of VLAN identifiers"
372 "filtered for VF(s) from port_id.\n\n"
374 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
375 " Remove a vlan_id, to the set of VLAN identifiers"
376 "filtered for VF(s) from port_id.\n\n"
378 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
379 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
380 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
381 " add a tunnel filter of a port.\n\n"
383 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
384 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
385 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
386 " remove a tunnel filter of a port.\n\n"
388 "rx_vxlan_port add (udp_port) (port_id)\n"
389 " Add an UDP port for VXLAN packet filter on a port\n\n"
391 "rx_vxlan_port rm (udp_port) (port_id)\n"
392 " Remove an UDP port for VXLAN packet filter on a port\n\n"
394 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
395 " Set hardware insertion of VLAN IDs (single or double VLAN "
396 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
398 "tx_vlan set pvid port_id vlan_id (on|off)\n"
399 " Set port based TX VLAN insertion.\n\n"
401 "tx_vlan reset (port_id)\n"
402 " Disable hardware insertion of a VLAN header in"
403 " packets sent on a port.\n\n"
405 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
406 " Select hardware or software calculation of the"
407 " checksum when transmitting a packet using the"
408 " csum forward engine.\n"
409 " ip|udp|tcp|sctp always concern the inner layer.\n"
410 " outer-ip concerns the outer IP layer in"
411 " outer-udp concerns the outer UDP layer in"
412 " case the packet is recognized as a tunnel packet by"
413 " the forward engine (vxlan, gre and ipip are supported)\n"
414 " Please check the NIC datasheet for HW limits.\n\n"
416 "csum parse-tunnel (on|off) (tx_port_id)\n"
417 " If disabled, treat tunnel packets as non-tunneled"
418 " packets (treat inner headers as payload). The port\n"
419 " argument is the port used for TX in csum forward"
422 "csum show (port_id)\n"
423 " Display tx checksum offload configuration\n\n"
425 "tso set (segsize) (portid)\n"
426 " Enable TCP Segmentation Offload in csum forward"
428 " Please check the NIC datasheet for HW limits.\n\n"
431 " Display the status of TCP Segmentation Offload.\n\n"
433 "set port (port_id) gro on|off\n"
434 " Enable or disable Generic Receive Offload in"
435 " csum forwarding engine.\n\n"
437 "show port (port_id) gro\n"
438 " Display GRO configuration.\n\n"
440 "set gro flush (cycles)\n"
441 " Set the cycle to flush GROed packets from"
442 " reassembly tables.\n\n"
444 "set port (port_id) gso (on|off)"
445 " Enable or disable Generic Segmentation Offload in"
446 " csum forwarding engine.\n\n"
448 "set gso segsz (length)\n"
449 " Set max packet length for output GSO segments,"
450 " including packet header and payload.\n\n"
452 "show port (port_id) gso\n"
453 " Show GSO configuration.\n\n"
456 " Set packet forwarding mode.\n\n"
458 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
459 " Add a MAC address on port_id.\n\n"
461 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
462 " Remove a MAC address from port_id.\n\n"
464 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
465 " Set the default MAC address for port_id.\n\n"
467 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
468 " Add a MAC address for a VF on the port.\n\n"
470 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
471 " Set the MAC address for a VF from the PF.\n\n"
473 "set eth-peer (port_id) (peer_addr)\n"
474 " set the peer address for certain port.\n\n"
476 "set port (port_id) uta (mac_address|all) (on|off)\n"
477 " Add/Remove a or all unicast hash filter(s)"
480 "set promisc (port_id|all) (on|off)\n"
481 " Set the promiscuous mode on port_id, or all.\n\n"
483 "set allmulti (port_id|all) (on|off)\n"
484 " Set the allmulti mode on port_id, or all.\n\n"
486 "set vf promisc (port_id) (vf_id) (on|off)\n"
487 " Set unicast promiscuous mode for a VF from the PF.\n\n"
489 "set vf allmulti (port_id) (vf_id) (on|off)\n"
490 " Set multicast promiscuous mode for a VF from the PF.\n\n"
492 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
493 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
494 " (on|off) autoneg (on|off) (port_id)\n"
495 "set flow_ctrl rx (on|off) (portid)\n"
496 "set flow_ctrl tx (on|off) (portid)\n"
497 "set flow_ctrl high_water (high_water) (portid)\n"
498 "set flow_ctrl low_water (low_water) (portid)\n"
499 "set flow_ctrl pause_time (pause_time) (portid)\n"
500 "set flow_ctrl send_xon (send_xon) (portid)\n"
501 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
502 "set flow_ctrl autoneg (on|off) (port_id)\n"
503 " Set the link flow control parameter on a port.\n\n"
505 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
506 " (low_water) (pause_time) (priority) (port_id)\n"
507 " Set the priority flow control parameter on a"
510 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
511 " Set statistics mapping (qmapping 0..15) for RX/TX"
513 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
514 " on port 0 to mapping 5.\n\n"
516 "set xstats-hide-zero on|off\n"
517 " Set the option to hide the zero values"
518 " for xstats display.\n"
520 "set port (port_id) vf (vf_id) rx|tx on|off\n"
521 " Enable/Disable a VF receive/tranmit from a port\n\n"
523 "set port (port_id) vf (vf_id) (mac_addr)"
524 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
525 " Add/Remove unicast or multicast MAC addr filter"
528 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
530 " AUPE:accepts untagged VLAN;"
531 "ROPE:accept unicast hash\n\n"
532 " BAM:accepts broadcast packets;"
533 "MPE:accepts all multicast packets\n\n"
534 " Enable/Disable a VF receive mode of a port\n\n"
536 "set port (port_id) queue (queue_id) rate (rate_num)\n"
537 " Set rate limit for a queue of a port\n\n"
539 "set port (port_id) vf (vf_id) rate (rate_num) "
540 "queue_mask (queue_mask_value)\n"
541 " Set rate limit for queues in VF of a port\n\n"
543 "set port (port_id) mirror-rule (rule_id)"
544 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
545 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
546 " Set pool or vlan type mirror rule on a port.\n"
547 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
548 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
551 "set port (port_id) mirror-rule (rule_id)"
552 " (uplink-mirror|downlink-mirror) dst-pool"
553 " (pool_id) (on|off)\n"
554 " Set uplink or downlink type mirror rule on a port.\n"
555 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
556 " 0 on' enable mirror income traffic to pool 0.\n\n"
558 "reset port (port_id) mirror-rule (rule_id)\n"
559 " Reset a mirror rule.\n\n"
561 "set flush_rx (on|off)\n"
562 " Flush (default) or don't flush RX streams before"
563 " forwarding. Mainly used with PCAP drivers.\n\n"
565 "set bypass mode (normal|bypass|isolate) (port_id)\n"
566 " Set the bypass mode for the lowest port on bypass enabled"
569 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
570 "mode (normal|bypass|isolate) (port_id)\n"
571 " Set the event required to initiate specified bypass mode for"
572 " the lowest port on a bypass enabled NIC where:\n"
573 " timeout = enable bypass after watchdog timeout.\n"
574 " os_on = enable bypass when OS/board is powered on.\n"
575 " os_off = enable bypass when OS/board is powered off.\n"
576 " power_on = enable bypass when power supply is turned on.\n"
577 " power_off = enable bypass when power supply is turned off."
580 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
581 " Set the bypass watchdog timeout to 'n' seconds"
582 " where 0 = instant.\n\n"
584 "show bypass config (port_id)\n"
585 " Show the bypass configuration for a bypass enabled NIC"
586 " using the lowest port on the NIC.\n\n"
588 #ifdef RTE_LIBRTE_PMD_BOND
589 "create bonded device (mode) (socket)\n"
590 " Create a new bonded device with specific bonding mode and socket.\n\n"
592 "add bonding slave (slave_id) (port_id)\n"
593 " Add a slave device to a bonded device.\n\n"
595 "remove bonding slave (slave_id) (port_id)\n"
596 " Remove a slave device from a bonded device.\n\n"
598 "set bonding mode (value) (port_id)\n"
599 " Set the bonding mode on a bonded device.\n\n"
601 "set bonding primary (slave_id) (port_id)\n"
602 " Set the primary slave for a bonded device.\n\n"
604 "show bonding config (port_id)\n"
605 " Show the bonding config for port_id.\n\n"
607 "set bonding mac_addr (port_id) (address)\n"
608 " Set the MAC address of a bonded device.\n\n"
610 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
611 " Set Aggregation mode for IEEE802.3AD (mode 4)"
613 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
614 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
616 "set bonding mon_period (port_id) (value)\n"
617 " Set the bonding link status monitoring polling period in ms.\n\n"
619 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
620 " Enable/disable dedicated queues for LACP control traffic.\n\n"
623 "set link-up port (port_id)\n"
624 " Set link up for a port.\n\n"
626 "set link-down port (port_id)\n"
627 " Set link down for a port.\n\n"
629 "E-tag set insertion on port-tag-id (value)"
630 " port (port_id) vf (vf_id)\n"
631 " Enable E-tag insertion for a VF on a port\n\n"
633 "E-tag set insertion off port (port_id) vf (vf_id)\n"
634 " Disable E-tag insertion for a VF on a port\n\n"
636 "E-tag set stripping (on|off) port (port_id)\n"
637 " Enable/disable E-tag stripping on a port\n\n"
639 "E-tag set forwarding (on|off) port (port_id)\n"
640 " Enable/disable E-tag based forwarding"
643 "E-tag set filter add e-tag-id (value) dst-pool"
644 " (pool_id) port (port_id)\n"
645 " Add an E-tag forwarding filter on a port\n\n"
647 "E-tag set filter del e-tag-id (value) port (port_id)\n"
648 " Delete an E-tag forwarding filter on a port\n\n"
650 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
651 "set port tm hierarchy default (port_id)\n"
652 " Set default traffic Management hierarchy on a port\n\n"
655 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
656 " Load a profile package on a port\n\n"
658 "ddp del (port_id) (backup_profile_path)\n"
659 " Delete a profile package from a port\n\n"
661 "ptype mapping get (port_id) (valid_only)\n"
662 " Get ptype mapping on a port\n\n"
664 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
665 " Replace target with the pkt_type in ptype mapping\n\n"
667 "ptype mapping reset (port_id)\n"
668 " Reset ptype mapping on a port\n\n"
670 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
671 " Update a ptype mapping item on a port\n\n"
673 "set port (port_id) queue-region region_id (value) "
674 "queue_start_index (value) queue_num (value)\n"
675 " Set a queue region on a port\n\n"
677 "set port (port_id) queue-region region_id (value) "
679 " Set a flowtype region index on a port\n\n"
681 "set port (port_id) queue-region UP (value) region_id (value)\n"
682 " Set the mapping of User Priority to "
683 "queue region on a port\n\n"
685 "set port (port_id) queue-region flush (on|off)\n"
686 " flush all queue region related configuration\n\n"
688 "show port meter cap (port_id)\n"
689 " Show port meter capability information\n\n"
691 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
692 " meter profile add - srtcm rfc 2697\n\n"
694 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
695 " meter profile add - trtcm rfc 2698\n\n"
697 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
698 " meter profile add - trtcm rfc 4115\n\n"
700 "del port meter profile (port_id) (profile_id)\n"
701 " meter profile delete\n\n"
703 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
704 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
705 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
706 "(dscp_tbl_entry63)]\n"
709 "enable port meter (port_id) (mtr_id)\n"
712 "disable port meter (port_id) (mtr_id)\n"
715 "del port meter (port_id) (mtr_id)\n"
718 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
719 " meter update meter profile\n\n"
721 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
722 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
723 " update meter dscp table entries\n\n"
725 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
726 "(action0) [(action1) (action2)]\n"
727 " meter update policer action\n\n"
729 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
730 " meter update stats\n\n"
732 "show port (port_id) queue-region\n"
733 " show all queue region related configuration info\n\n"
735 "add port tm node shaper profile (port_id) (shaper_profile_id)"
736 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
737 " (packet_length_adjust)\n"
738 " Add port tm node private shaper profile.\n\n"
740 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
741 " Delete port tm node private shaper profile.\n\n"
743 "add port tm node shared shaper (port_id) (shared_shaper_id)"
744 " (shaper_profile_id)\n"
745 " Add/update port tm node shared shaper.\n\n"
747 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
748 " Delete port tm node shared shaper.\n\n"
750 "set port tm node shaper profile (port_id) (node_id)"
751 " (shaper_profile_id)\n"
752 " Set port tm node shaper profile.\n\n"
754 "add port tm node wred profile (port_id) (wred_profile_id)"
755 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
756 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
757 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
758 " Add port tm node wred profile.\n\n"
760 "del port tm node wred profile (port_id) (wred_profile_id)\n"
761 " Delete port tm node wred profile.\n\n"
763 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
764 " (priority) (weight) (level_id) (shaper_profile_id)"
765 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
766 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
767 " Add port tm nonleaf node.\n\n"
769 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
770 " (priority) (weight) (level_id) (shaper_profile_id)"
771 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
772 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
773 " Add port tm leaf node.\n\n"
775 "del port tm node (port_id) (node_id)\n"
776 " Delete port tm node.\n\n"
778 "set port tm node parent (port_id) (node_id) (parent_node_id)"
779 " (priority) (weight)\n"
780 " Set port tm node parent.\n\n"
782 "suspend port tm node (port_id) (node_id)"
783 " Suspend tm node.\n\n"
785 "resume port tm node (port_id) (node_id)"
786 " Resume tm node.\n\n"
788 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
789 " Commit tm hierarchy.\n\n"
791 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
792 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
793 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
794 " Configure the VXLAN encapsulation for flows.\n\n"
796 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
797 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
798 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
799 " eth-dst (eth-dst)\n"
800 " Configure the VXLAN encapsulation for flows.\n\n"
802 "vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
803 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
804 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
805 " eth-dst (eth-dst)\n"
806 " Configure the VXLAN encapsulation for flows.\n\n"
808 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
809 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
811 " Configure the NVGRE encapsulation for flows.\n\n"
813 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
814 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
815 " eth-src (eth-src) eth-dst (eth-dst)\n"
816 " Configure the NVGRE encapsulation for flows.\n\n"
818 , list_pkt_forwarding_modes()
822 if (show_all || !strcmp(res->section, "ports")) {
828 "----------------\n\n"
830 "port start (port_id|all)\n"
831 " Start all ports or port_id.\n\n"
833 "port stop (port_id|all)\n"
834 " Stop all ports or port_id.\n\n"
836 "port close (port_id|all)\n"
837 " Close all ports or port_id.\n\n"
839 "port attach (ident)\n"
840 " Attach physical or virtual dev by pci address or virtual device name\n\n"
842 "port detach (port_id)\n"
843 " Detach physical or virtual dev by port_id\n\n"
845 "port config (port_id|all)"
846 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
847 " duplex (half|full|auto)\n"
848 " Set speed and duplex for all ports or port_id\n\n"
850 "port config (port_id|all) loopback (mode)\n"
851 " Set loopback mode for all ports or port_id\n\n"
853 "port config all (rxq|txq|rxd|txd) (value)\n"
854 " Set number for rxq/txq/rxd/txd.\n\n"
856 "port config all max-pkt-len (value)\n"
857 " Set the max packet length.\n\n"
859 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
860 "hw-vlan-strip|hw-vlan-extend|drop-en)"
862 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
865 "port config all rss (all|default|ip|tcp|udp|sctp|"
866 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
867 " Set the RSS mode.\n\n"
869 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
870 " Set the RSS redirection table.\n\n"
872 "port config (port_id) dcb vt (on|off) (traffic_class)"
874 " Set the DCB mode.\n\n"
876 "port config all burst (value)\n"
877 " Set the number of packets per burst.\n\n"
879 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
881 " Set the ring prefetch/host/writeback threshold"
882 " for tx/rx queue.\n\n"
884 "port config all (txfreet|txrst|rxfreet) (value)\n"
885 " Set free threshold for rx/tx, or set"
886 " tx rs bit threshold.\n\n"
887 "port config mtu X value\n"
888 " Set the MTU of port X to a given value\n\n"
890 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
891 " Set a rx/tx queue's ring size configuration, the new"
892 " value will take effect after command that (re-)start the port"
893 " or command that setup the specific queue\n\n"
895 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
896 " Start/stop a rx/tx queue of port X. Only take effect"
897 " when port X is started\n\n"
899 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
900 " Switch on/off a deferred start of port X rx/tx queue. Only"
901 " take effect when port X is stopped.\n\n"
903 "port (port_id) (rxq|txq) (queue_id) setup\n"
904 " Setup a rx/tx queue of port X.\n\n"
906 "port config (port_id|all) l2-tunnel E-tag ether-type"
908 " Set the value of E-tag ether-type.\n\n"
910 "port config (port_id|all) l2-tunnel E-tag"
911 " (enable|disable)\n"
912 " Enable/disable the E-tag support.\n\n"
914 "port config (port_id) pctype mapping reset\n"
915 " Reset flow type to pctype mapping on a port\n\n"
917 "port config (port_id) pctype mapping update"
918 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
919 " Update a flow type to pctype mapping item on a port\n\n"
921 "port config (port_id) pctype (pctype_id) hash_inset|"
922 "fdir_inset|fdir_flx_inset get|set|clear field\n"
924 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
926 "port config (port_id) pctype (pctype_id) hash_inset|"
927 "fdir_inset|fdir_flx_inset clear all"
928 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
930 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
931 " Add/remove UDP tunnel port for tunneling offload\n\n"
935 if (show_all || !strcmp(res->section, "registers")) {
943 "read reg (port_id) (address)\n"
944 " Display value of a port register.\n\n"
946 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
947 " Display a port register bit field.\n\n"
949 "read regbit (port_id) (address) (bit_x)\n"
950 " Display a single port register bit.\n\n"
952 "write reg (port_id) (address) (value)\n"
953 " Set value of a port register.\n\n"
955 "write regfield (port_id) (address) (bit_x) (bit_y)"
957 " Set bit field of a port register.\n\n"
959 "write regbit (port_id) (address) (bit_x) (value)\n"
960 " Set single bit value of a port register.\n\n"
963 if (show_all || !strcmp(res->section, "filters")) {
971 "ethertype_filter (port_id) (add|del)"
972 " (mac_addr|mac_ignr) (mac_address) ethertype"
973 " (ether_type) (drop|fwd) queue (queue_id)\n"
974 " Add/Del an ethertype filter.\n\n"
976 "2tuple_filter (port_id) (add|del)"
977 " dst_port (dst_port_value) protocol (protocol_value)"
978 " mask (mask_value) tcp_flags (tcp_flags_value)"
979 " priority (prio_value) queue (queue_id)\n"
980 " Add/Del a 2tuple filter.\n\n"
982 "5tuple_filter (port_id) (add|del)"
983 " dst_ip (dst_address) src_ip (src_address)"
984 " dst_port (dst_port_value) src_port (src_port_value)"
985 " protocol (protocol_value)"
986 " mask (mask_value) tcp_flags (tcp_flags_value)"
987 " priority (prio_value) queue (queue_id)\n"
988 " Add/Del a 5tuple filter.\n\n"
990 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
991 " Add/Del syn filter.\n\n"
993 "flex_filter (port_id) (add|del) len (len_value)"
994 " bytes (bytes_value) mask (mask_value)"
995 " priority (prio_value) queue (queue_id)\n"
996 " Add/Del a flex filter.\n\n"
998 "flow_director_filter (port_id) mode IP (add|del|update)"
999 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
1000 " src (src_ip_address) dst (dst_ip_address)"
1001 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
1002 " vlan (vlan_value) flexbytes (flexbytes_value)"
1003 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1004 " fd_id (fd_id_value)\n"
1005 " Add/Del an IP type flow director filter.\n\n"
1007 "flow_director_filter (port_id) mode IP (add|del|update)"
1008 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1009 " src (src_ip_address) (src_port)"
1010 " dst (dst_ip_address) (dst_port)"
1011 " tos (tos_value) ttl (ttl_value)"
1012 " vlan (vlan_value) flexbytes (flexbytes_value)"
1013 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1014 " fd_id (fd_id_value)\n"
1015 " Add/Del an UDP/TCP type flow director filter.\n\n"
1017 "flow_director_filter (port_id) mode IP (add|del|update)"
1018 " flow (ipv4-sctp|ipv6-sctp)"
1019 " src (src_ip_address) (src_port)"
1020 " dst (dst_ip_address) (dst_port)"
1021 " tag (verification_tag) "
1022 " tos (tos_value) ttl (ttl_value)"
1023 " vlan (vlan_value)"
1024 " flexbytes (flexbytes_value) (drop|fwd)"
1025 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1026 " Add/Del a SCTP type flow director filter.\n\n"
1028 "flow_director_filter (port_id) mode IP (add|del|update)"
1029 " flow l2_payload ether (ethertype)"
1030 " flexbytes (flexbytes_value) (drop|fwd)"
1031 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1032 " Add/Del a l2 payload type flow director filter.\n\n"
1034 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1035 " mac (mac_address) vlan (vlan_value)"
1036 " flexbytes (flexbytes_value) (drop|fwd)"
1037 " queue (queue_id) fd_id (fd_id_value)\n"
1038 " Add/Del a MAC-VLAN flow director filter.\n\n"
1040 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1041 " mac (mac_address) vlan (vlan_value)"
1042 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1043 " flexbytes (flexbytes_value) (drop|fwd)"
1044 " queue (queue_id) fd_id (fd_id_value)\n"
1045 " Add/Del a Tunnel flow director filter.\n\n"
1047 "flow_director_filter (port_id) mode raw (add|del|update)"
1048 " flow (flow_id) (drop|fwd) queue (queue_id)"
1049 " fd_id (fd_id_value) packet (packet file name)\n"
1050 " Add/Del a raw type flow director filter.\n\n"
1052 "flush_flow_director (port_id)\n"
1053 " Flush all flow director entries of a device.\n\n"
1055 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1056 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1057 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1058 " Set flow director IP mask.\n\n"
1060 "flow_director_mask (port_id) mode MAC-VLAN"
1061 " vlan (vlan_value)\n"
1062 " Set flow director MAC-VLAN mask.\n\n"
1064 "flow_director_mask (port_id) mode Tunnel"
1065 " vlan (vlan_value) mac (mac_value)"
1066 " tunnel-type (tunnel_type_value)"
1067 " tunnel-id (tunnel_id_value)\n"
1068 " Set flow director Tunnel mask.\n\n"
1070 "flow_director_flex_mask (port_id)"
1071 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1072 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1074 " Configure mask of flex payload.\n\n"
1076 "flow_director_flex_payload (port_id)"
1077 " (raw|l2|l3|l4) (config)\n"
1078 " Configure flex payload selection.\n\n"
1080 "get_sym_hash_ena_per_port (port_id)\n"
1081 " get symmetric hash enable configuration per port.\n\n"
1083 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1084 " set symmetric hash enable configuration per port"
1085 " to enable or disable.\n\n"
1087 "get_hash_global_config (port_id)\n"
1088 " Get the global configurations of hash filters.\n\n"
1090 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1091 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1092 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1093 " (enable|disable)\n"
1094 " Set the global configurations of hash filters.\n\n"
1096 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1097 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1098 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1099 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1100 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1101 "ipv6-next-header|udp-src-port|udp-dst-port|"
1102 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1103 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1104 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1105 "fld-8th|none) (select|add)\n"
1106 " Set the input set for hash.\n\n"
1108 "set_fdir_input_set (port_id) "
1109 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1110 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1111 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1112 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1113 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1114 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1115 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1117 " Set the input set for FDir.\n\n"
1119 "flow validate {port_id}"
1120 " [group {group_id}] [priority {level}]"
1121 " [ingress] [egress]"
1122 " pattern {item} [/ {item} [...]] / end"
1123 " actions {action} [/ {action} [...]] / end\n"
1124 " Check whether a flow rule can be created.\n\n"
1126 "flow create {port_id}"
1127 " [group {group_id}] [priority {level}]"
1128 " [ingress] [egress]"
1129 " pattern {item} [/ {item} [...]] / end"
1130 " actions {action} [/ {action} [...]] / end\n"
1131 " Create a flow rule.\n\n"
1133 "flow destroy {port_id} rule {rule_id} [...]\n"
1134 " Destroy specific flow rules.\n\n"
1136 "flow flush {port_id}\n"
1137 " Destroy all flow rules.\n\n"
1139 "flow query {port_id} {rule_id} {action}\n"
1140 " Query an existing flow rule.\n\n"
1142 "flow list {port_id} [group {group_id}] [...]\n"
1143 " List existing flow rules sorted by priority,"
1144 " filtered by group identifiers.\n\n"
1146 "flow isolate {port_id} {boolean}\n"
1147 " Restrict ingress traffic to the defined"
1153 cmdline_parse_token_string_t cmd_help_long_help =
1154 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1156 cmdline_parse_token_string_t cmd_help_long_section =
1157 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1158 "all#control#display#config#"
1159 "ports#registers#filters");
1161 cmdline_parse_inst_t cmd_help_long = {
1162 .f = cmd_help_long_parsed,
1164 .help_str = "help all|control|display|config|ports|register|filters: "
1167 (void *)&cmd_help_long_help,
1168 (void *)&cmd_help_long_section,
1174 /* *** start/stop/close all ports *** */
1175 struct cmd_operate_port_result {
1176 cmdline_fixed_string_t keyword;
1177 cmdline_fixed_string_t name;
1178 cmdline_fixed_string_t value;
1181 static void cmd_operate_port_parsed(void *parsed_result,
1182 __attribute__((unused)) struct cmdline *cl,
1183 __attribute__((unused)) void *data)
1185 struct cmd_operate_port_result *res = parsed_result;
1187 if (!strcmp(res->name, "start"))
1188 start_port(RTE_PORT_ALL);
1189 else if (!strcmp(res->name, "stop"))
1190 stop_port(RTE_PORT_ALL);
1191 else if (!strcmp(res->name, "close"))
1192 close_port(RTE_PORT_ALL);
1193 else if (!strcmp(res->name, "reset"))
1194 reset_port(RTE_PORT_ALL);
1196 printf("Unknown parameter\n");
1199 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1200 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1202 cmdline_parse_token_string_t cmd_operate_port_all_port =
1203 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1204 "start#stop#close#reset");
1205 cmdline_parse_token_string_t cmd_operate_port_all_all =
1206 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1208 cmdline_parse_inst_t cmd_operate_port = {
1209 .f = cmd_operate_port_parsed,
1211 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1213 (void *)&cmd_operate_port_all_cmd,
1214 (void *)&cmd_operate_port_all_port,
1215 (void *)&cmd_operate_port_all_all,
1220 /* *** start/stop/close specific port *** */
1221 struct cmd_operate_specific_port_result {
1222 cmdline_fixed_string_t keyword;
1223 cmdline_fixed_string_t name;
1227 static void cmd_operate_specific_port_parsed(void *parsed_result,
1228 __attribute__((unused)) struct cmdline *cl,
1229 __attribute__((unused)) void *data)
1231 struct cmd_operate_specific_port_result *res = parsed_result;
1233 if (!strcmp(res->name, "start"))
1234 start_port(res->value);
1235 else if (!strcmp(res->name, "stop"))
1236 stop_port(res->value);
1237 else if (!strcmp(res->name, "close"))
1238 close_port(res->value);
1239 else if (!strcmp(res->name, "reset"))
1240 reset_port(res->value);
1242 printf("Unknown parameter\n");
1245 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1246 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1248 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1249 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1250 name, "start#stop#close#reset");
1251 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1252 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1255 cmdline_parse_inst_t cmd_operate_specific_port = {
1256 .f = cmd_operate_specific_port_parsed,
1258 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1260 (void *)&cmd_operate_specific_port_cmd,
1261 (void *)&cmd_operate_specific_port_port,
1262 (void *)&cmd_operate_specific_port_id,
1267 /* *** enable port setup (after attach) via iterator or event *** */
1268 struct cmd_set_port_setup_on_result {
1269 cmdline_fixed_string_t set;
1270 cmdline_fixed_string_t port;
1271 cmdline_fixed_string_t setup;
1272 cmdline_fixed_string_t on;
1273 cmdline_fixed_string_t mode;
1276 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1277 __attribute__((unused)) struct cmdline *cl,
1278 __attribute__((unused)) void *data)
1280 struct cmd_set_port_setup_on_result *res = parsed_result;
1282 if (strcmp(res->mode, "event") == 0)
1283 setup_on_probe_event = true;
1284 else if (strcmp(res->mode, "iterator") == 0)
1285 setup_on_probe_event = false;
1287 printf("Unknown mode\n");
1290 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1291 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1293 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1294 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1296 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1297 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1299 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1300 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1302 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1303 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1304 mode, "iterator#event");
1306 cmdline_parse_inst_t cmd_set_port_setup_on = {
1307 .f = cmd_set_port_setup_on_parsed,
1309 .help_str = "set port setup on iterator|event",
1311 (void *)&cmd_set_port_setup_on_set,
1312 (void *)&cmd_set_port_setup_on_port,
1313 (void *)&cmd_set_port_setup_on_setup,
1314 (void *)&cmd_set_port_setup_on_on,
1315 (void *)&cmd_set_port_setup_on_mode,
1320 /* *** attach a specified port *** */
1321 struct cmd_operate_attach_port_result {
1322 cmdline_fixed_string_t port;
1323 cmdline_fixed_string_t keyword;
1324 cmdline_fixed_string_t identifier;
1327 static void cmd_operate_attach_port_parsed(void *parsed_result,
1328 __attribute__((unused)) struct cmdline *cl,
1329 __attribute__((unused)) void *data)
1331 struct cmd_operate_attach_port_result *res = parsed_result;
1333 if (!strcmp(res->keyword, "attach"))
1334 attach_port(res->identifier);
1336 printf("Unknown parameter\n");
1339 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1340 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1342 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1343 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1345 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1346 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1349 cmdline_parse_inst_t cmd_operate_attach_port = {
1350 .f = cmd_operate_attach_port_parsed,
1352 .help_str = "port attach <identifier>: "
1353 "(identifier: pci address or virtual dev name)",
1355 (void *)&cmd_operate_attach_port_port,
1356 (void *)&cmd_operate_attach_port_keyword,
1357 (void *)&cmd_operate_attach_port_identifier,
1362 /* *** detach a specified port *** */
1363 struct cmd_operate_detach_port_result {
1364 cmdline_fixed_string_t port;
1365 cmdline_fixed_string_t keyword;
1369 static void cmd_operate_detach_port_parsed(void *parsed_result,
1370 __attribute__((unused)) struct cmdline *cl,
1371 __attribute__((unused)) void *data)
1373 struct cmd_operate_detach_port_result *res = parsed_result;
1375 if (!strcmp(res->keyword, "detach"))
1376 detach_port_device(res->port_id);
1378 printf("Unknown parameter\n");
1381 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1382 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1384 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1385 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1387 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1388 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1391 cmdline_parse_inst_t cmd_operate_detach_port = {
1392 .f = cmd_operate_detach_port_parsed,
1394 .help_str = "port detach <port_id>",
1396 (void *)&cmd_operate_detach_port_port,
1397 (void *)&cmd_operate_detach_port_keyword,
1398 (void *)&cmd_operate_detach_port_port_id,
1403 /* *** configure speed for all ports *** */
1404 struct cmd_config_speed_all {
1405 cmdline_fixed_string_t port;
1406 cmdline_fixed_string_t keyword;
1407 cmdline_fixed_string_t all;
1408 cmdline_fixed_string_t item1;
1409 cmdline_fixed_string_t item2;
1410 cmdline_fixed_string_t value1;
1411 cmdline_fixed_string_t value2;
1415 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1420 if (!strcmp(duplexstr, "half")) {
1421 duplex = ETH_LINK_HALF_DUPLEX;
1422 } else if (!strcmp(duplexstr, "full")) {
1423 duplex = ETH_LINK_FULL_DUPLEX;
1424 } else if (!strcmp(duplexstr, "auto")) {
1425 duplex = ETH_LINK_FULL_DUPLEX;
1427 printf("Unknown duplex parameter\n");
1431 if (!strcmp(speedstr, "10")) {
1432 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1433 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1434 } else if (!strcmp(speedstr, "100")) {
1435 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1436 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1438 if (duplex != ETH_LINK_FULL_DUPLEX) {
1439 printf("Invalid speed/duplex parameters\n");
1442 if (!strcmp(speedstr, "1000")) {
1443 *speed = ETH_LINK_SPEED_1G;
1444 } else if (!strcmp(speedstr, "10000")) {
1445 *speed = ETH_LINK_SPEED_10G;
1446 } else if (!strcmp(speedstr, "25000")) {
1447 *speed = ETH_LINK_SPEED_25G;
1448 } else if (!strcmp(speedstr, "40000")) {
1449 *speed = ETH_LINK_SPEED_40G;
1450 } else if (!strcmp(speedstr, "50000")) {
1451 *speed = ETH_LINK_SPEED_50G;
1452 } else if (!strcmp(speedstr, "100000")) {
1453 *speed = ETH_LINK_SPEED_100G;
1454 } else if (!strcmp(speedstr, "auto")) {
1455 *speed = ETH_LINK_SPEED_AUTONEG;
1457 printf("Unknown speed parameter\n");
1466 cmd_config_speed_all_parsed(void *parsed_result,
1467 __attribute__((unused)) struct cmdline *cl,
1468 __attribute__((unused)) void *data)
1470 struct cmd_config_speed_all *res = parsed_result;
1471 uint32_t link_speed;
1474 if (!all_ports_stopped()) {
1475 printf("Please stop all ports first\n");
1479 if (parse_and_check_speed_duplex(res->value1, res->value2,
1483 RTE_ETH_FOREACH_DEV(pid) {
1484 ports[pid].dev_conf.link_speeds = link_speed;
1487 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1490 cmdline_parse_token_string_t cmd_config_speed_all_port =
1491 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1492 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1495 cmdline_parse_token_string_t cmd_config_speed_all_all =
1496 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1497 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1499 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1500 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1501 "10#100#1000#10000#25000#40000#50000#100000#auto");
1502 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1503 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1504 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1505 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1508 cmdline_parse_inst_t cmd_config_speed_all = {
1509 .f = cmd_config_speed_all_parsed,
1511 .help_str = "port config all speed "
1512 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1515 (void *)&cmd_config_speed_all_port,
1516 (void *)&cmd_config_speed_all_keyword,
1517 (void *)&cmd_config_speed_all_all,
1518 (void *)&cmd_config_speed_all_item1,
1519 (void *)&cmd_config_speed_all_value1,
1520 (void *)&cmd_config_speed_all_item2,
1521 (void *)&cmd_config_speed_all_value2,
1526 /* *** configure speed for specific port *** */
1527 struct cmd_config_speed_specific {
1528 cmdline_fixed_string_t port;
1529 cmdline_fixed_string_t keyword;
1531 cmdline_fixed_string_t item1;
1532 cmdline_fixed_string_t item2;
1533 cmdline_fixed_string_t value1;
1534 cmdline_fixed_string_t value2;
1538 cmd_config_speed_specific_parsed(void *parsed_result,
1539 __attribute__((unused)) struct cmdline *cl,
1540 __attribute__((unused)) void *data)
1542 struct cmd_config_speed_specific *res = parsed_result;
1543 uint32_t link_speed;
1545 if (!all_ports_stopped()) {
1546 printf("Please stop all ports first\n");
1550 if (port_id_is_invalid(res->id, ENABLED_WARN))
1553 if (parse_and_check_speed_duplex(res->value1, res->value2,
1557 ports[res->id].dev_conf.link_speeds = link_speed;
1559 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1563 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1566 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1569 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1570 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1571 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1572 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1574 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1575 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1576 "10#100#1000#10000#25000#40000#50000#100000#auto");
1577 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1580 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1584 cmdline_parse_inst_t cmd_config_speed_specific = {
1585 .f = cmd_config_speed_specific_parsed,
1587 .help_str = "port config <port_id> speed "
1588 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1591 (void *)&cmd_config_speed_specific_port,
1592 (void *)&cmd_config_speed_specific_keyword,
1593 (void *)&cmd_config_speed_specific_id,
1594 (void *)&cmd_config_speed_specific_item1,
1595 (void *)&cmd_config_speed_specific_value1,
1596 (void *)&cmd_config_speed_specific_item2,
1597 (void *)&cmd_config_speed_specific_value2,
1602 /* *** configure loopback for all ports *** */
1603 struct cmd_config_loopback_all {
1604 cmdline_fixed_string_t port;
1605 cmdline_fixed_string_t keyword;
1606 cmdline_fixed_string_t all;
1607 cmdline_fixed_string_t item;
1612 cmd_config_loopback_all_parsed(void *parsed_result,
1613 __attribute__((unused)) struct cmdline *cl,
1614 __attribute__((unused)) void *data)
1616 struct cmd_config_loopback_all *res = parsed_result;
1619 if (!all_ports_stopped()) {
1620 printf("Please stop all ports first\n");
1624 RTE_ETH_FOREACH_DEV(pid) {
1625 ports[pid].dev_conf.lpbk_mode = res->mode;
1628 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1631 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1632 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1633 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1636 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1638 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1639 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1641 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1642 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1644 cmdline_parse_inst_t cmd_config_loopback_all = {
1645 .f = cmd_config_loopback_all_parsed,
1647 .help_str = "port config all loopback <mode>",
1649 (void *)&cmd_config_loopback_all_port,
1650 (void *)&cmd_config_loopback_all_keyword,
1651 (void *)&cmd_config_loopback_all_all,
1652 (void *)&cmd_config_loopback_all_item,
1653 (void *)&cmd_config_loopback_all_mode,
1658 /* *** configure loopback for specific port *** */
1659 struct cmd_config_loopback_specific {
1660 cmdline_fixed_string_t port;
1661 cmdline_fixed_string_t keyword;
1663 cmdline_fixed_string_t item;
1668 cmd_config_loopback_specific_parsed(void *parsed_result,
1669 __attribute__((unused)) struct cmdline *cl,
1670 __attribute__((unused)) void *data)
1672 struct cmd_config_loopback_specific *res = parsed_result;
1674 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1677 if (!port_is_stopped(res->port_id)) {
1678 printf("Please stop port %u first\n", res->port_id);
1682 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1684 cmd_reconfig_device_queue(res->port_id, 1, 1);
1688 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1689 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1691 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1692 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1694 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1695 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1697 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1700 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1701 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1704 cmdline_parse_inst_t cmd_config_loopback_specific = {
1705 .f = cmd_config_loopback_specific_parsed,
1707 .help_str = "port config <port_id> loopback <mode>",
1709 (void *)&cmd_config_loopback_specific_port,
1710 (void *)&cmd_config_loopback_specific_keyword,
1711 (void *)&cmd_config_loopback_specific_id,
1712 (void *)&cmd_config_loopback_specific_item,
1713 (void *)&cmd_config_loopback_specific_mode,
1718 /* *** configure txq/rxq, txd/rxd *** */
1719 struct cmd_config_rx_tx {
1720 cmdline_fixed_string_t port;
1721 cmdline_fixed_string_t keyword;
1722 cmdline_fixed_string_t all;
1723 cmdline_fixed_string_t name;
1728 cmd_config_rx_tx_parsed(void *parsed_result,
1729 __attribute__((unused)) struct cmdline *cl,
1730 __attribute__((unused)) void *data)
1732 struct cmd_config_rx_tx *res = parsed_result;
1734 if (!all_ports_stopped()) {
1735 printf("Please stop all ports first\n");
1738 if (!strcmp(res->name, "rxq")) {
1739 if (!res->value && !nb_txq) {
1740 printf("Warning: Either rx or tx queues should be non zero\n");
1743 if (check_nb_rxq(res->value) != 0)
1745 nb_rxq = res->value;
1747 else if (!strcmp(res->name, "txq")) {
1748 if (!res->value && !nb_rxq) {
1749 printf("Warning: Either rx or tx queues should be non zero\n");
1752 if (check_nb_txq(res->value) != 0)
1754 nb_txq = res->value;
1756 else if (!strcmp(res->name, "rxd")) {
1757 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1758 printf("rxd %d invalid - must be > 0 && <= %d\n",
1759 res->value, RTE_TEST_RX_DESC_MAX);
1762 nb_rxd = res->value;
1763 } else if (!strcmp(res->name, "txd")) {
1764 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1765 printf("txd %d invalid - must be > 0 && <= %d\n",
1766 res->value, RTE_TEST_TX_DESC_MAX);
1769 nb_txd = res->value;
1771 printf("Unknown parameter\n");
1779 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1782 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1783 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1784 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1786 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1787 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1788 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1791 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1792 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1794 cmdline_parse_inst_t cmd_config_rx_tx = {
1795 .f = cmd_config_rx_tx_parsed,
1797 .help_str = "port config all rxq|txq|rxd|txd <value>",
1799 (void *)&cmd_config_rx_tx_port,
1800 (void *)&cmd_config_rx_tx_keyword,
1801 (void *)&cmd_config_rx_tx_all,
1802 (void *)&cmd_config_rx_tx_name,
1803 (void *)&cmd_config_rx_tx_value,
1808 /* *** config max packet length *** */
1809 struct cmd_config_max_pkt_len_result {
1810 cmdline_fixed_string_t port;
1811 cmdline_fixed_string_t keyword;
1812 cmdline_fixed_string_t all;
1813 cmdline_fixed_string_t name;
1818 cmd_config_max_pkt_len_parsed(void *parsed_result,
1819 __attribute__((unused)) struct cmdline *cl,
1820 __attribute__((unused)) void *data)
1822 struct cmd_config_max_pkt_len_result *res = parsed_result;
1825 if (!all_ports_stopped()) {
1826 printf("Please stop all ports first\n");
1830 RTE_ETH_FOREACH_DEV(pid) {
1831 struct rte_port *port = &ports[pid];
1832 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1834 if (!strcmp(res->name, "max-pkt-len")) {
1835 if (res->value < ETHER_MIN_LEN) {
1836 printf("max-pkt-len can not be less than %d\n",
1840 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1843 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1844 if (res->value > ETHER_MAX_LEN)
1845 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1847 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1848 port->dev_conf.rxmode.offloads = rx_offloads;
1850 printf("Unknown parameter\n");
1857 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1860 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1863 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1864 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1866 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1867 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1869 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1870 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1872 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1873 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1876 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1877 .f = cmd_config_max_pkt_len_parsed,
1879 .help_str = "port config all max-pkt-len <value>",
1881 (void *)&cmd_config_max_pkt_len_port,
1882 (void *)&cmd_config_max_pkt_len_keyword,
1883 (void *)&cmd_config_max_pkt_len_all,
1884 (void *)&cmd_config_max_pkt_len_name,
1885 (void *)&cmd_config_max_pkt_len_value,
1890 /* *** configure port MTU *** */
1891 struct cmd_config_mtu_result {
1892 cmdline_fixed_string_t port;
1893 cmdline_fixed_string_t keyword;
1894 cmdline_fixed_string_t mtu;
1900 cmd_config_mtu_parsed(void *parsed_result,
1901 __attribute__((unused)) struct cmdline *cl,
1902 __attribute__((unused)) void *data)
1904 struct cmd_config_mtu_result *res = parsed_result;
1906 if (res->value < ETHER_MIN_LEN) {
1907 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1910 port_mtu_set(res->port_id, res->value);
1913 cmdline_parse_token_string_t cmd_config_mtu_port =
1914 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1916 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1917 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1919 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1922 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1923 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1924 cmdline_parse_token_num_t cmd_config_mtu_value =
1925 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1927 cmdline_parse_inst_t cmd_config_mtu = {
1928 .f = cmd_config_mtu_parsed,
1930 .help_str = "port config mtu <port_id> <value>",
1932 (void *)&cmd_config_mtu_port,
1933 (void *)&cmd_config_mtu_keyword,
1934 (void *)&cmd_config_mtu_mtu,
1935 (void *)&cmd_config_mtu_port_id,
1936 (void *)&cmd_config_mtu_value,
1941 /* *** configure rx mode *** */
1942 struct cmd_config_rx_mode_flag {
1943 cmdline_fixed_string_t port;
1944 cmdline_fixed_string_t keyword;
1945 cmdline_fixed_string_t all;
1946 cmdline_fixed_string_t name;
1947 cmdline_fixed_string_t value;
1951 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1952 __attribute__((unused)) struct cmdline *cl,
1953 __attribute__((unused)) void *data)
1955 struct cmd_config_rx_mode_flag *res = parsed_result;
1958 if (!all_ports_stopped()) {
1959 printf("Please stop all ports first\n");
1963 RTE_ETH_FOREACH_DEV(pid) {
1964 struct rte_port *port;
1965 uint64_t rx_offloads;
1968 rx_offloads = port->dev_conf.rxmode.offloads;
1969 if (!strcmp(res->name, "crc-strip")) {
1970 if (!strcmp(res->value, "on")) {
1971 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
1972 } else if (!strcmp(res->value, "off")) {
1973 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
1975 printf("Unknown parameter\n");
1978 } else if (!strcmp(res->name, "scatter")) {
1979 if (!strcmp(res->value, "on")) {
1980 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1981 } else if (!strcmp(res->value, "off")) {
1982 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1984 printf("Unknown parameter\n");
1987 } else if (!strcmp(res->name, "rx-cksum")) {
1988 if (!strcmp(res->value, "on"))
1989 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1990 else if (!strcmp(res->value, "off"))
1991 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1993 printf("Unknown parameter\n");
1996 } else if (!strcmp(res->name, "rx-timestamp")) {
1997 if (!strcmp(res->value, "on"))
1998 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1999 else if (!strcmp(res->value, "off"))
2000 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
2002 printf("Unknown parameter\n");
2005 } else if (!strcmp(res->name, "hw-vlan")) {
2006 if (!strcmp(res->value, "on")) {
2007 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
2008 DEV_RX_OFFLOAD_VLAN_STRIP);
2009 } else if (!strcmp(res->value, "off")) {
2010 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
2011 DEV_RX_OFFLOAD_VLAN_STRIP);
2013 printf("Unknown parameter\n");
2016 } else if (!strcmp(res->name, "hw-vlan-filter")) {
2017 if (!strcmp(res->value, "on"))
2018 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2019 else if (!strcmp(res->value, "off"))
2020 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2022 printf("Unknown parameter\n");
2025 } else if (!strcmp(res->name, "hw-vlan-strip")) {
2026 if (!strcmp(res->value, "on"))
2027 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2028 else if (!strcmp(res->value, "off"))
2029 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2031 printf("Unknown parameter\n");
2034 } else if (!strcmp(res->name, "hw-vlan-extend")) {
2035 if (!strcmp(res->value, "on"))
2036 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2037 else if (!strcmp(res->value, "off"))
2038 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2040 printf("Unknown parameter\n");
2043 } else if (!strcmp(res->name, "drop-en")) {
2044 if (!strcmp(res->value, "on"))
2046 else if (!strcmp(res->value, "off"))
2049 printf("Unknown parameter\n");
2053 printf("Unknown parameter\n");
2056 port->dev_conf.rxmode.offloads = rx_offloads;
2061 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2064 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2066 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2069 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2071 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2073 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2074 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2075 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2076 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2079 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2080 .f = cmd_config_rx_mode_flag_parsed,
2082 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2083 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2085 (void *)&cmd_config_rx_mode_flag_port,
2086 (void *)&cmd_config_rx_mode_flag_keyword,
2087 (void *)&cmd_config_rx_mode_flag_all,
2088 (void *)&cmd_config_rx_mode_flag_name,
2089 (void *)&cmd_config_rx_mode_flag_value,
2094 /* *** configure rss *** */
2095 struct cmd_config_rss {
2096 cmdline_fixed_string_t port;
2097 cmdline_fixed_string_t keyword;
2098 cmdline_fixed_string_t all;
2099 cmdline_fixed_string_t name;
2100 cmdline_fixed_string_t value;
2104 cmd_config_rss_parsed(void *parsed_result,
2105 __attribute__((unused)) struct cmdline *cl,
2106 __attribute__((unused)) void *data)
2108 struct cmd_config_rss *res = parsed_result;
2109 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2110 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2111 int use_default = 0;
2112 int all_updated = 1;
2116 if (!strcmp(res->value, "all"))
2117 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2118 ETH_RSS_UDP | ETH_RSS_SCTP |
2120 else if (!strcmp(res->value, "ip"))
2121 rss_conf.rss_hf = ETH_RSS_IP;
2122 else if (!strcmp(res->value, "udp"))
2123 rss_conf.rss_hf = ETH_RSS_UDP;
2124 else if (!strcmp(res->value, "tcp"))
2125 rss_conf.rss_hf = ETH_RSS_TCP;
2126 else if (!strcmp(res->value, "sctp"))
2127 rss_conf.rss_hf = ETH_RSS_SCTP;
2128 else if (!strcmp(res->value, "ether"))
2129 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2130 else if (!strcmp(res->value, "port"))
2131 rss_conf.rss_hf = ETH_RSS_PORT;
2132 else if (!strcmp(res->value, "vxlan"))
2133 rss_conf.rss_hf = ETH_RSS_VXLAN;
2134 else if (!strcmp(res->value, "geneve"))
2135 rss_conf.rss_hf = ETH_RSS_GENEVE;
2136 else if (!strcmp(res->value, "nvgre"))
2137 rss_conf.rss_hf = ETH_RSS_NVGRE;
2138 else if (!strcmp(res->value, "none"))
2139 rss_conf.rss_hf = 0;
2140 else if (!strcmp(res->value, "default"))
2142 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2143 atoi(res->value) < 64)
2144 rss_conf.rss_hf = 1ULL << atoi(res->value);
2146 printf("Unknown parameter\n");
2149 rss_conf.rss_key = NULL;
2150 /* Update global configuration for RSS types. */
2151 RTE_ETH_FOREACH_DEV(i) {
2152 struct rte_eth_rss_conf local_rss_conf;
2154 rte_eth_dev_info_get(i, &dev_info);
2156 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2158 local_rss_conf = rss_conf;
2159 local_rss_conf.rss_hf = rss_conf.rss_hf &
2160 dev_info.flow_type_rss_offloads;
2161 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2162 printf("Port %u modified RSS hash function based on hardware support,"
2163 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2164 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2166 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2169 printf("Configuration of RSS hash at ethernet port %d "
2170 "failed with error (%d): %s.\n",
2171 i, -diag, strerror(-diag));
2174 if (all_updated && !use_default)
2175 rss_hf = rss_conf.rss_hf;
2178 cmdline_parse_token_string_t cmd_config_rss_port =
2179 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2180 cmdline_parse_token_string_t cmd_config_rss_keyword =
2181 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2182 cmdline_parse_token_string_t cmd_config_rss_all =
2183 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2184 cmdline_parse_token_string_t cmd_config_rss_name =
2185 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2186 cmdline_parse_token_string_t cmd_config_rss_value =
2187 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2189 cmdline_parse_inst_t cmd_config_rss = {
2190 .f = cmd_config_rss_parsed,
2192 .help_str = "port config all rss "
2193 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2195 (void *)&cmd_config_rss_port,
2196 (void *)&cmd_config_rss_keyword,
2197 (void *)&cmd_config_rss_all,
2198 (void *)&cmd_config_rss_name,
2199 (void *)&cmd_config_rss_value,
2204 /* *** configure rss hash key *** */
2205 struct cmd_config_rss_hash_key {
2206 cmdline_fixed_string_t port;
2207 cmdline_fixed_string_t config;
2209 cmdline_fixed_string_t rss_hash_key;
2210 cmdline_fixed_string_t rss_type;
2211 cmdline_fixed_string_t key;
2215 hexa_digit_to_value(char hexa_digit)
2217 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2218 return (uint8_t) (hexa_digit - '0');
2219 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2220 return (uint8_t) ((hexa_digit - 'a') + 10);
2221 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2222 return (uint8_t) ((hexa_digit - 'A') + 10);
2223 /* Invalid hexa digit */
2228 parse_and_check_key_hexa_digit(char *key, int idx)
2232 hexa_v = hexa_digit_to_value(key[idx]);
2234 printf("invalid key: character %c at position %d is not a "
2235 "valid hexa digit\n", key[idx], idx);
2240 cmd_config_rss_hash_key_parsed(void *parsed_result,
2241 __attribute__((unused)) struct cmdline *cl,
2242 __attribute__((unused)) void *data)
2244 struct cmd_config_rss_hash_key *res = parsed_result;
2245 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2249 struct rte_eth_dev_info dev_info;
2250 uint8_t hash_key_size;
2253 memset(&dev_info, 0, sizeof(dev_info));
2254 rte_eth_dev_info_get(res->port_id, &dev_info);
2255 if (dev_info.hash_key_size > 0 &&
2256 dev_info.hash_key_size <= sizeof(hash_key))
2257 hash_key_size = dev_info.hash_key_size;
2259 printf("dev_info did not provide a valid hash key size\n");
2262 /* Check the length of the RSS hash key */
2263 key_len = strlen(res->key);
2264 if (key_len != (hash_key_size * 2)) {
2265 printf("key length: %d invalid - key must be a string of %d"
2266 " hexa-decimal numbers\n",
2267 (int) key_len, hash_key_size * 2);
2270 /* Translate RSS hash key into binary representation */
2271 for (i = 0; i < hash_key_size; i++) {
2272 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2275 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2278 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2280 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2284 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2286 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2287 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2289 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2290 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2291 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2292 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2293 rss_hash_key, "rss-hash-key");
2294 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2295 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2296 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2297 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2298 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2299 "ipv6-tcp-ex#ipv6-udp-ex");
2300 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2303 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2304 .f = cmd_config_rss_hash_key_parsed,
2306 .help_str = "port config <port_id> rss-hash-key "
2307 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2308 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2309 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2310 "<string of hex digits (variable length, NIC dependent)>",
2312 (void *)&cmd_config_rss_hash_key_port,
2313 (void *)&cmd_config_rss_hash_key_config,
2314 (void *)&cmd_config_rss_hash_key_port_id,
2315 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2316 (void *)&cmd_config_rss_hash_key_rss_type,
2317 (void *)&cmd_config_rss_hash_key_value,
2322 /* *** configure port rxq/txq ring size *** */
2323 struct cmd_config_rxtx_ring_size {
2324 cmdline_fixed_string_t port;
2325 cmdline_fixed_string_t config;
2327 cmdline_fixed_string_t rxtxq;
2329 cmdline_fixed_string_t rsize;
2334 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2335 __attribute__((unused)) struct cmdline *cl,
2336 __attribute__((unused)) void *data)
2338 struct cmd_config_rxtx_ring_size *res = parsed_result;
2339 struct rte_port *port;
2342 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2345 if (res->portid == (portid_t)RTE_PORT_ALL) {
2346 printf("Invalid port id\n");
2350 port = &ports[res->portid];
2352 if (!strcmp(res->rxtxq, "rxq"))
2354 else if (!strcmp(res->rxtxq, "txq"))
2357 printf("Unknown parameter\n");
2361 if (isrx && rx_queue_id_is_invalid(res->qid))
2363 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2366 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2367 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2373 port->nb_rx_desc[res->qid] = res->size;
2375 port->nb_tx_desc[res->qid] = res->size;
2377 cmd_reconfig_device_queue(res->portid, 0, 1);
2380 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2381 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2383 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2384 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2386 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2387 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2389 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2390 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2392 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2393 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2395 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2396 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2397 rsize, "ring_size");
2398 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2399 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2402 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2403 .f = cmd_config_rxtx_ring_size_parsed,
2405 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2407 (void *)&cmd_config_rxtx_ring_size_port,
2408 (void *)&cmd_config_rxtx_ring_size_config,
2409 (void *)&cmd_config_rxtx_ring_size_portid,
2410 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2411 (void *)&cmd_config_rxtx_ring_size_qid,
2412 (void *)&cmd_config_rxtx_ring_size_rsize,
2413 (void *)&cmd_config_rxtx_ring_size_size,
2418 /* *** configure port rxq/txq start/stop *** */
2419 struct cmd_config_rxtx_queue {
2420 cmdline_fixed_string_t port;
2422 cmdline_fixed_string_t rxtxq;
2424 cmdline_fixed_string_t opname;
2428 cmd_config_rxtx_queue_parsed(void *parsed_result,
2429 __attribute__((unused)) struct cmdline *cl,
2430 __attribute__((unused)) void *data)
2432 struct cmd_config_rxtx_queue *res = parsed_result;
2437 if (test_done == 0) {
2438 printf("Please stop forwarding first\n");
2442 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2445 if (port_is_started(res->portid) != 1) {
2446 printf("Please start port %u first\n", res->portid);
2450 if (!strcmp(res->rxtxq, "rxq"))
2452 else if (!strcmp(res->rxtxq, "txq"))
2455 printf("Unknown parameter\n");
2459 if (isrx && rx_queue_id_is_invalid(res->qid))
2461 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2464 if (!strcmp(res->opname, "start"))
2466 else if (!strcmp(res->opname, "stop"))
2469 printf("Unknown parameter\n");
2473 if (isstart && isrx)
2474 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2475 else if (!isstart && isrx)
2476 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2477 else if (isstart && !isrx)
2478 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2480 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2482 if (ret == -ENOTSUP)
2483 printf("Function not supported in PMD driver\n");
2486 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2487 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2488 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2489 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2490 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2491 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2492 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2493 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2494 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2495 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2498 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2499 .f = cmd_config_rxtx_queue_parsed,
2501 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2503 (void *)&cmd_config_rxtx_queue_port,
2504 (void *)&cmd_config_rxtx_queue_portid,
2505 (void *)&cmd_config_rxtx_queue_rxtxq,
2506 (void *)&cmd_config_rxtx_queue_qid,
2507 (void *)&cmd_config_rxtx_queue_opname,
2512 /* *** configure port rxq/txq deferred start on/off *** */
2513 struct cmd_config_deferred_start_rxtx_queue {
2514 cmdline_fixed_string_t port;
2516 cmdline_fixed_string_t rxtxq;
2518 cmdline_fixed_string_t opname;
2519 cmdline_fixed_string_t state;
2523 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2524 __attribute__((unused)) struct cmdline *cl,
2525 __attribute__((unused)) void *data)
2527 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2528 struct rte_port *port;
2531 uint8_t needreconfig = 0;
2533 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2536 if (port_is_started(res->port_id) != 0) {
2537 printf("Please stop port %u first\n", res->port_id);
2541 port = &ports[res->port_id];
2543 isrx = !strcmp(res->rxtxq, "rxq");
2545 if (isrx && rx_queue_id_is_invalid(res->qid))
2547 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2550 ison = !strcmp(res->state, "on");
2552 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2553 port->rx_conf[res->qid].rx_deferred_start = ison;
2555 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2556 port->tx_conf[res->qid].tx_deferred_start = ison;
2561 cmd_reconfig_device_queue(res->port_id, 0, 1);
2564 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2565 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2567 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2568 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2570 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2571 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2573 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2574 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2576 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2577 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2578 opname, "deferred_start");
2579 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2580 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2583 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2584 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2586 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2588 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2589 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2590 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2591 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2592 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2593 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2598 /* *** configure port rxq/txq setup *** */
2599 struct cmd_setup_rxtx_queue {
2600 cmdline_fixed_string_t port;
2602 cmdline_fixed_string_t rxtxq;
2604 cmdline_fixed_string_t setup;
2607 /* Common CLI fields for queue setup */
2608 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2609 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2610 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2611 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2612 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2613 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2614 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2615 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2616 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2617 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2620 cmd_setup_rxtx_queue_parsed(
2621 void *parsed_result,
2622 __attribute__((unused)) struct cmdline *cl,
2623 __attribute__((unused)) void *data)
2625 struct cmd_setup_rxtx_queue *res = parsed_result;
2626 struct rte_port *port;
2627 struct rte_mempool *mp;
2628 unsigned int socket_id;
2632 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2635 if (res->portid == (portid_t)RTE_PORT_ALL) {
2636 printf("Invalid port id\n");
2640 if (!strcmp(res->rxtxq, "rxq"))
2642 else if (!strcmp(res->rxtxq, "txq"))
2645 printf("Unknown parameter\n");
2649 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2650 printf("Invalid rx queue\n");
2652 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2653 printf("Invalid tx queue\n");
2657 port = &ports[res->portid];
2659 socket_id = rxring_numa[res->portid];
2660 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2661 socket_id = port->socket_id;
2663 mp = mbuf_pool_find(socket_id);
2665 printf("Failed to setup RX queue: "
2666 "No mempool allocation"
2667 " on the socket %d\n",
2668 rxring_numa[res->portid]);
2671 ret = rte_eth_rx_queue_setup(res->portid,
2673 port->nb_rx_desc[res->qid],
2675 &port->rx_conf[res->qid],
2678 printf("Failed to setup RX queue\n");
2680 socket_id = txring_numa[res->portid];
2681 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2682 socket_id = port->socket_id;
2684 ret = rte_eth_tx_queue_setup(res->portid,
2686 port->nb_tx_desc[res->qid],
2688 &port->tx_conf[res->qid]);
2690 printf("Failed to setup TX queue\n");
2694 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2695 .f = cmd_setup_rxtx_queue_parsed,
2697 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2699 (void *)&cmd_setup_rxtx_queue_port,
2700 (void *)&cmd_setup_rxtx_queue_portid,
2701 (void *)&cmd_setup_rxtx_queue_rxtxq,
2702 (void *)&cmd_setup_rxtx_queue_qid,
2703 (void *)&cmd_setup_rxtx_queue_setup,
2709 /* *** Configure RSS RETA *** */
2710 struct cmd_config_rss_reta {
2711 cmdline_fixed_string_t port;
2712 cmdline_fixed_string_t keyword;
2714 cmdline_fixed_string_t name;
2715 cmdline_fixed_string_t list_name;
2716 cmdline_fixed_string_t list_of_items;
2720 parse_reta_config(const char *str,
2721 struct rte_eth_rss_reta_entry64 *reta_conf,
2722 uint16_t nb_entries)
2726 uint16_t hash_index, idx, shift;
2729 const char *p, *p0 = str;
2736 unsigned long int_fld[_NUM_FLD];
2737 char *str_fld[_NUM_FLD];
2739 while ((p = strchr(p0,'(')) != NULL) {
2741 if((p0 = strchr(p,')')) == NULL)
2745 if(size >= sizeof(s))
2748 snprintf(s, sizeof(s), "%.*s", size, p);
2749 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2751 for (i = 0; i < _NUM_FLD; i++) {
2753 int_fld[i] = strtoul(str_fld[i], &end, 0);
2754 if (errno != 0 || end == str_fld[i] ||
2759 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2760 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2762 if (hash_index >= nb_entries) {
2763 printf("Invalid RETA hash index=%d\n", hash_index);
2767 idx = hash_index / RTE_RETA_GROUP_SIZE;
2768 shift = hash_index % RTE_RETA_GROUP_SIZE;
2769 reta_conf[idx].mask |= (1ULL << shift);
2770 reta_conf[idx].reta[shift] = nb_queue;
2777 cmd_set_rss_reta_parsed(void *parsed_result,
2778 __attribute__((unused)) struct cmdline *cl,
2779 __attribute__((unused)) void *data)
2782 struct rte_eth_dev_info dev_info;
2783 struct rte_eth_rss_reta_entry64 reta_conf[8];
2784 struct cmd_config_rss_reta *res = parsed_result;
2786 memset(&dev_info, 0, sizeof(dev_info));
2787 rte_eth_dev_info_get(res->port_id, &dev_info);
2788 if (dev_info.reta_size == 0) {
2789 printf("Redirection table size is 0 which is "
2790 "invalid for RSS\n");
2793 printf("The reta size of port %d is %u\n",
2794 res->port_id, dev_info.reta_size);
2795 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2796 printf("Currently do not support more than %u entries of "
2797 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2801 memset(reta_conf, 0, sizeof(reta_conf));
2802 if (!strcmp(res->list_name, "reta")) {
2803 if (parse_reta_config(res->list_of_items, reta_conf,
2804 dev_info.reta_size)) {
2805 printf("Invalid RSS Redirection Table "
2806 "config entered\n");
2809 ret = rte_eth_dev_rss_reta_update(res->port_id,
2810 reta_conf, dev_info.reta_size);
2812 printf("Bad redirection table parameter, "
2813 "return code = %d \n", ret);
2817 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2818 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2819 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2820 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2821 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2822 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2823 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2824 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2825 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2826 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2827 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2828 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2830 cmdline_parse_inst_t cmd_config_rss_reta = {
2831 .f = cmd_set_rss_reta_parsed,
2833 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2835 (void *)&cmd_config_rss_reta_port,
2836 (void *)&cmd_config_rss_reta_keyword,
2837 (void *)&cmd_config_rss_reta_port_id,
2838 (void *)&cmd_config_rss_reta_name,
2839 (void *)&cmd_config_rss_reta_list_name,
2840 (void *)&cmd_config_rss_reta_list_of_items,
2845 /* *** SHOW PORT RETA INFO *** */
2846 struct cmd_showport_reta {
2847 cmdline_fixed_string_t show;
2848 cmdline_fixed_string_t port;
2850 cmdline_fixed_string_t rss;
2851 cmdline_fixed_string_t reta;
2853 cmdline_fixed_string_t list_of_items;
2857 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2858 uint16_t nb_entries,
2862 const char *p, *p0 = str;
2867 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2868 RTE_RETA_GROUP_SIZE;
2871 p = strchr(p0, '(');
2875 p0 = strchr(p, ')');
2879 if (size >= sizeof(s)) {
2880 printf("The string size exceeds the internal buffer size\n");
2883 snprintf(s, sizeof(s), "%.*s", size, p);
2884 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2885 if (ret <= 0 || ret != num) {
2886 printf("The bits of masks do not match the number of "
2887 "reta entries: %u\n", num);
2890 for (i = 0; i < ret; i++)
2891 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2897 cmd_showport_reta_parsed(void *parsed_result,
2898 __attribute__((unused)) struct cmdline *cl,
2899 __attribute__((unused)) void *data)
2901 struct cmd_showport_reta *res = parsed_result;
2902 struct rte_eth_rss_reta_entry64 reta_conf[8];
2903 struct rte_eth_dev_info dev_info;
2904 uint16_t max_reta_size;
2906 memset(&dev_info, 0, sizeof(dev_info));
2907 rte_eth_dev_info_get(res->port_id, &dev_info);
2908 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2909 if (res->size == 0 || res->size > max_reta_size) {
2910 printf("Invalid redirection table size: %u (1-%u)\n",
2911 res->size, max_reta_size);
2915 memset(reta_conf, 0, sizeof(reta_conf));
2916 if (showport_parse_reta_config(reta_conf, res->size,
2917 res->list_of_items) < 0) {
2918 printf("Invalid string: %s for reta masks\n",
2919 res->list_of_items);
2922 port_rss_reta_info(res->port_id, reta_conf, res->size);
2925 cmdline_parse_token_string_t cmd_showport_reta_show =
2926 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2927 cmdline_parse_token_string_t cmd_showport_reta_port =
2928 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2929 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2930 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2931 cmdline_parse_token_string_t cmd_showport_reta_rss =
2932 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2933 cmdline_parse_token_string_t cmd_showport_reta_reta =
2934 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2935 cmdline_parse_token_num_t cmd_showport_reta_size =
2936 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2937 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2938 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2939 list_of_items, NULL);
2941 cmdline_parse_inst_t cmd_showport_reta = {
2942 .f = cmd_showport_reta_parsed,
2944 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2946 (void *)&cmd_showport_reta_show,
2947 (void *)&cmd_showport_reta_port,
2948 (void *)&cmd_showport_reta_port_id,
2949 (void *)&cmd_showport_reta_rss,
2950 (void *)&cmd_showport_reta_reta,
2951 (void *)&cmd_showport_reta_size,
2952 (void *)&cmd_showport_reta_list_of_items,
2957 /* *** Show RSS hash configuration *** */
2958 struct cmd_showport_rss_hash {
2959 cmdline_fixed_string_t show;
2960 cmdline_fixed_string_t port;
2962 cmdline_fixed_string_t rss_hash;
2963 cmdline_fixed_string_t rss_type;
2964 cmdline_fixed_string_t key; /* optional argument */
2967 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2968 __attribute__((unused)) struct cmdline *cl,
2971 struct cmd_showport_rss_hash *res = parsed_result;
2973 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
2976 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2977 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2978 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2979 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2980 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2981 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2982 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2983 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2985 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2986 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2988 cmdline_parse_inst_t cmd_showport_rss_hash = {
2989 .f = cmd_showport_rss_hash_parsed,
2991 .help_str = "show port <port_id> rss-hash",
2993 (void *)&cmd_showport_rss_hash_show,
2994 (void *)&cmd_showport_rss_hash_port,
2995 (void *)&cmd_showport_rss_hash_port_id,
2996 (void *)&cmd_showport_rss_hash_rss_hash,
3001 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3002 .f = cmd_showport_rss_hash_parsed,
3004 .help_str = "show port <port_id> rss-hash key",
3006 (void *)&cmd_showport_rss_hash_show,
3007 (void *)&cmd_showport_rss_hash_port,
3008 (void *)&cmd_showport_rss_hash_port_id,
3009 (void *)&cmd_showport_rss_hash_rss_hash,
3010 (void *)&cmd_showport_rss_hash_rss_key,
3015 /* *** Configure DCB *** */
3016 struct cmd_config_dcb {
3017 cmdline_fixed_string_t port;
3018 cmdline_fixed_string_t config;
3020 cmdline_fixed_string_t dcb;
3021 cmdline_fixed_string_t vt;
3022 cmdline_fixed_string_t vt_en;
3024 cmdline_fixed_string_t pfc;
3025 cmdline_fixed_string_t pfc_en;
3029 cmd_config_dcb_parsed(void *parsed_result,
3030 __attribute__((unused)) struct cmdline *cl,
3031 __attribute__((unused)) void *data)
3033 struct cmd_config_dcb *res = parsed_result;
3034 portid_t port_id = res->port_id;
3035 struct rte_port *port;
3039 port = &ports[port_id];
3040 /** Check if the port is not started **/
3041 if (port->port_status != RTE_PORT_STOPPED) {
3042 printf("Please stop port %d first\n", port_id);
3046 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3047 printf("The invalid number of traffic class,"
3048 " only 4 or 8 allowed.\n");
3052 if (nb_fwd_lcores < res->num_tcs) {
3053 printf("nb_cores shouldn't be less than number of TCs.\n");
3056 if (!strncmp(res->pfc_en, "on", 2))
3061 /* DCB in VT mode */
3062 if (!strncmp(res->vt_en, "on", 2))
3063 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3064 (enum rte_eth_nb_tcs)res->num_tcs,
3067 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3068 (enum rte_eth_nb_tcs)res->num_tcs,
3073 printf("Cannot initialize network ports.\n");
3077 cmd_reconfig_device_queue(port_id, 1, 1);
3080 cmdline_parse_token_string_t cmd_config_dcb_port =
3081 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3082 cmdline_parse_token_string_t cmd_config_dcb_config =
3083 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3084 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3085 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3086 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3087 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3088 cmdline_parse_token_string_t cmd_config_dcb_vt =
3089 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3090 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3091 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3092 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3093 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3094 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3095 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3096 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3097 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3099 cmdline_parse_inst_t cmd_config_dcb = {
3100 .f = cmd_config_dcb_parsed,
3102 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3104 (void *)&cmd_config_dcb_port,
3105 (void *)&cmd_config_dcb_config,
3106 (void *)&cmd_config_dcb_port_id,
3107 (void *)&cmd_config_dcb_dcb,
3108 (void *)&cmd_config_dcb_vt,
3109 (void *)&cmd_config_dcb_vt_en,
3110 (void *)&cmd_config_dcb_num_tcs,
3111 (void *)&cmd_config_dcb_pfc,
3112 (void *)&cmd_config_dcb_pfc_en,
3117 /* *** configure number of packets per burst *** */
3118 struct cmd_config_burst {
3119 cmdline_fixed_string_t port;
3120 cmdline_fixed_string_t keyword;
3121 cmdline_fixed_string_t all;
3122 cmdline_fixed_string_t name;
3127 cmd_config_burst_parsed(void *parsed_result,
3128 __attribute__((unused)) struct cmdline *cl,
3129 __attribute__((unused)) void *data)
3131 struct cmd_config_burst *res = parsed_result;
3132 struct rte_eth_dev_info dev_info;
3133 uint16_t rec_nb_pkts;
3135 if (!all_ports_stopped()) {
3136 printf("Please stop all ports first\n");
3140 if (!strcmp(res->name, "burst")) {
3141 if (res->value == 0) {
3142 /* If user gives a value of zero, query the PMD for
3143 * its recommended Rx burst size. Testpmd uses a single
3144 * size for all ports, so assume all ports are the same
3145 * NIC model and use the values from Port 0.
3147 rte_eth_dev_info_get(0, &dev_info);
3148 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3150 if (rec_nb_pkts == 0) {
3151 printf("PMD does not recommend a burst size.\n"
3152 "User provided value must be between"
3153 " 1 and %d\n", MAX_PKT_BURST);
3155 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3156 printf("PMD recommended burst size of %d"
3157 " exceeds maximum value of %d\n",
3158 rec_nb_pkts, MAX_PKT_BURST);
3161 printf("Using PMD-provided burst value of %d\n",
3163 nb_pkt_per_burst = rec_nb_pkts;
3164 } else if (res->value > MAX_PKT_BURST) {
3165 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3168 nb_pkt_per_burst = res->value;
3170 printf("Unknown parameter\n");
3176 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3179 cmdline_parse_token_string_t cmd_config_burst_port =
3180 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3181 cmdline_parse_token_string_t cmd_config_burst_keyword =
3182 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3183 cmdline_parse_token_string_t cmd_config_burst_all =
3184 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3185 cmdline_parse_token_string_t cmd_config_burst_name =
3186 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3187 cmdline_parse_token_num_t cmd_config_burst_value =
3188 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3190 cmdline_parse_inst_t cmd_config_burst = {
3191 .f = cmd_config_burst_parsed,
3193 .help_str = "port config all burst <value>",
3195 (void *)&cmd_config_burst_port,
3196 (void *)&cmd_config_burst_keyword,
3197 (void *)&cmd_config_burst_all,
3198 (void *)&cmd_config_burst_name,
3199 (void *)&cmd_config_burst_value,
3204 /* *** configure rx/tx queues *** */
3205 struct cmd_config_thresh {
3206 cmdline_fixed_string_t port;
3207 cmdline_fixed_string_t keyword;
3208 cmdline_fixed_string_t all;
3209 cmdline_fixed_string_t name;
3214 cmd_config_thresh_parsed(void *parsed_result,
3215 __attribute__((unused)) struct cmdline *cl,
3216 __attribute__((unused)) void *data)
3218 struct cmd_config_thresh *res = parsed_result;
3220 if (!all_ports_stopped()) {
3221 printf("Please stop all ports first\n");
3225 if (!strcmp(res->name, "txpt"))
3226 tx_pthresh = res->value;
3227 else if(!strcmp(res->name, "txht"))
3228 tx_hthresh = res->value;
3229 else if(!strcmp(res->name, "txwt"))
3230 tx_wthresh = res->value;
3231 else if(!strcmp(res->name, "rxpt"))
3232 rx_pthresh = res->value;
3233 else if(!strcmp(res->name, "rxht"))
3234 rx_hthresh = res->value;
3235 else if(!strcmp(res->name, "rxwt"))
3236 rx_wthresh = res->value;
3238 printf("Unknown parameter\n");
3244 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3247 cmdline_parse_token_string_t cmd_config_thresh_port =
3248 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3249 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3250 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3251 cmdline_parse_token_string_t cmd_config_thresh_all =
3252 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3253 cmdline_parse_token_string_t cmd_config_thresh_name =
3254 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3255 "txpt#txht#txwt#rxpt#rxht#rxwt");
3256 cmdline_parse_token_num_t cmd_config_thresh_value =
3257 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3259 cmdline_parse_inst_t cmd_config_thresh = {
3260 .f = cmd_config_thresh_parsed,
3262 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3264 (void *)&cmd_config_thresh_port,
3265 (void *)&cmd_config_thresh_keyword,
3266 (void *)&cmd_config_thresh_all,
3267 (void *)&cmd_config_thresh_name,
3268 (void *)&cmd_config_thresh_value,
3273 /* *** configure free/rs threshold *** */
3274 struct cmd_config_threshold {
3275 cmdline_fixed_string_t port;
3276 cmdline_fixed_string_t keyword;
3277 cmdline_fixed_string_t all;
3278 cmdline_fixed_string_t name;
3283 cmd_config_threshold_parsed(void *parsed_result,
3284 __attribute__((unused)) struct cmdline *cl,
3285 __attribute__((unused)) void *data)
3287 struct cmd_config_threshold *res = parsed_result;
3289 if (!all_ports_stopped()) {
3290 printf("Please stop all ports first\n");
3294 if (!strcmp(res->name, "txfreet"))
3295 tx_free_thresh = res->value;
3296 else if (!strcmp(res->name, "txrst"))
3297 tx_rs_thresh = res->value;
3298 else if (!strcmp(res->name, "rxfreet"))
3299 rx_free_thresh = res->value;
3301 printf("Unknown parameter\n");
3307 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3310 cmdline_parse_token_string_t cmd_config_threshold_port =
3311 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3312 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3313 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3315 cmdline_parse_token_string_t cmd_config_threshold_all =
3316 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3317 cmdline_parse_token_string_t cmd_config_threshold_name =
3318 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3319 "txfreet#txrst#rxfreet");
3320 cmdline_parse_token_num_t cmd_config_threshold_value =
3321 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3323 cmdline_parse_inst_t cmd_config_threshold = {
3324 .f = cmd_config_threshold_parsed,
3326 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3328 (void *)&cmd_config_threshold_port,
3329 (void *)&cmd_config_threshold_keyword,
3330 (void *)&cmd_config_threshold_all,
3331 (void *)&cmd_config_threshold_name,
3332 (void *)&cmd_config_threshold_value,
3338 struct cmd_stop_result {
3339 cmdline_fixed_string_t stop;
3342 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3343 __attribute__((unused)) struct cmdline *cl,
3344 __attribute__((unused)) void *data)
3346 stop_packet_forwarding();
3349 cmdline_parse_token_string_t cmd_stop_stop =
3350 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3352 cmdline_parse_inst_t cmd_stop = {
3353 .f = cmd_stop_parsed,
3355 .help_str = "stop: Stop packet forwarding",
3357 (void *)&cmd_stop_stop,
3362 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3365 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3366 unsigned int *parsed_items, int check_unique_values)
3368 unsigned int nb_item;
3376 * First parse all items in the list and store their value.
3381 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3383 if ((c >= '0') && (c <= '9')) {
3384 value = (unsigned int) (value * 10 + (c - '0'));
3389 printf("character %c is not a decimal digit\n", c);
3393 printf("No valid value before comma\n");
3396 if (nb_item < max_items) {
3397 parsed_items[nb_item] = value;
3403 if (nb_item >= max_items) {
3404 printf("Number of %s = %u > %u (maximum items)\n",
3405 item_name, nb_item + 1, max_items);
3408 parsed_items[nb_item++] = value;
3409 if (! check_unique_values)
3413 * Then, check that all values in the list are differents.
3414 * No optimization here...
3416 for (i = 0; i < nb_item; i++) {
3417 for (j = i + 1; j < nb_item; j++) {
3418 if (parsed_items[j] == parsed_items[i]) {
3419 printf("duplicated %s %u at index %u and %u\n",
3420 item_name, parsed_items[i], i, j);
3428 struct cmd_set_list_result {
3429 cmdline_fixed_string_t cmd_keyword;
3430 cmdline_fixed_string_t list_name;
3431 cmdline_fixed_string_t list_of_items;
3434 static void cmd_set_list_parsed(void *parsed_result,
3435 __attribute__((unused)) struct cmdline *cl,
3436 __attribute__((unused)) void *data)
3438 struct cmd_set_list_result *res;
3440 unsigned int lcorelist[RTE_MAX_LCORE];
3441 unsigned int portlist[RTE_MAX_ETHPORTS];
3443 unsigned int nb_item;
3445 if (test_done == 0) {
3446 printf("Please stop forwarding first\n");
3450 res = parsed_result;
3451 if (!strcmp(res->list_name, "corelist")) {
3452 nb_item = parse_item_list(res->list_of_items, "core",
3454 parsed_items.lcorelist, 1);
3456 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3461 if (!strcmp(res->list_name, "portlist")) {
3462 nb_item = parse_item_list(res->list_of_items, "port",
3464 parsed_items.portlist, 1);
3466 set_fwd_ports_list(parsed_items.portlist, nb_item);
3472 cmdline_parse_token_string_t cmd_set_list_keyword =
3473 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3475 cmdline_parse_token_string_t cmd_set_list_name =
3476 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3477 "corelist#portlist");
3478 cmdline_parse_token_string_t cmd_set_list_of_items =
3479 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3482 cmdline_parse_inst_t cmd_set_fwd_list = {
3483 .f = cmd_set_list_parsed,
3485 .help_str = "set corelist|portlist <list0[,list1]*>",
3487 (void *)&cmd_set_list_keyword,
3488 (void *)&cmd_set_list_name,
3489 (void *)&cmd_set_list_of_items,
3494 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3496 struct cmd_setmask_result {
3497 cmdline_fixed_string_t set;
3498 cmdline_fixed_string_t mask;
3502 static void cmd_set_mask_parsed(void *parsed_result,
3503 __attribute__((unused)) struct cmdline *cl,
3504 __attribute__((unused)) void *data)
3506 struct cmd_setmask_result *res = parsed_result;
3508 if (test_done == 0) {
3509 printf("Please stop forwarding first\n");
3512 if (!strcmp(res->mask, "coremask")) {
3513 set_fwd_lcores_mask(res->hexavalue);
3515 } else if (!strcmp(res->mask, "portmask")) {
3516 set_fwd_ports_mask(res->hexavalue);
3521 cmdline_parse_token_string_t cmd_setmask_set =
3522 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3523 cmdline_parse_token_string_t cmd_setmask_mask =
3524 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3525 "coremask#portmask");
3526 cmdline_parse_token_num_t cmd_setmask_value =
3527 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3529 cmdline_parse_inst_t cmd_set_fwd_mask = {
3530 .f = cmd_set_mask_parsed,
3532 .help_str = "set coremask|portmask <hexadecimal value>",
3534 (void *)&cmd_setmask_set,
3535 (void *)&cmd_setmask_mask,
3536 (void *)&cmd_setmask_value,
3542 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3544 struct cmd_set_result {
3545 cmdline_fixed_string_t set;
3546 cmdline_fixed_string_t what;
3550 static void cmd_set_parsed(void *parsed_result,
3551 __attribute__((unused)) struct cmdline *cl,
3552 __attribute__((unused)) void *data)
3554 struct cmd_set_result *res = parsed_result;
3555 if (!strcmp(res->what, "nbport")) {
3556 set_fwd_ports_number(res->value);
3558 } else if (!strcmp(res->what, "nbcore")) {
3559 set_fwd_lcores_number(res->value);
3561 } else if (!strcmp(res->what, "burst"))
3562 set_nb_pkt_per_burst(res->value);
3563 else if (!strcmp(res->what, "verbose"))
3564 set_verbose_level(res->value);
3567 cmdline_parse_token_string_t cmd_set_set =
3568 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3569 cmdline_parse_token_string_t cmd_set_what =
3570 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3571 "nbport#nbcore#burst#verbose");
3572 cmdline_parse_token_num_t cmd_set_value =
3573 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3575 cmdline_parse_inst_t cmd_set_numbers = {
3576 .f = cmd_set_parsed,
3578 .help_str = "set nbport|nbcore|burst|verbose <value>",
3580 (void *)&cmd_set_set,
3581 (void *)&cmd_set_what,
3582 (void *)&cmd_set_value,
3587 /* *** SET LOG LEVEL CONFIGURATION *** */
3589 struct cmd_set_log_result {
3590 cmdline_fixed_string_t set;
3591 cmdline_fixed_string_t log;
3592 cmdline_fixed_string_t type;
3597 cmd_set_log_parsed(void *parsed_result,
3598 __attribute__((unused)) struct cmdline *cl,
3599 __attribute__((unused)) void *data)
3601 struct cmd_set_log_result *res;
3604 res = parsed_result;
3605 if (!strcmp(res->type, "global"))
3606 rte_log_set_global_level(res->level);
3608 ret = rte_log_set_level_regexp(res->type, res->level);
3610 printf("Unable to set log level\n");
3614 cmdline_parse_token_string_t cmd_set_log_set =
3615 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3616 cmdline_parse_token_string_t cmd_set_log_log =
3617 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3618 cmdline_parse_token_string_t cmd_set_log_type =
3619 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3620 cmdline_parse_token_num_t cmd_set_log_level =
3621 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3623 cmdline_parse_inst_t cmd_set_log = {
3624 .f = cmd_set_log_parsed,
3626 .help_str = "set log global|<type> <level>",
3628 (void *)&cmd_set_log_set,
3629 (void *)&cmd_set_log_log,
3630 (void *)&cmd_set_log_type,
3631 (void *)&cmd_set_log_level,
3636 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3638 struct cmd_set_txpkts_result {
3639 cmdline_fixed_string_t cmd_keyword;
3640 cmdline_fixed_string_t txpkts;
3641 cmdline_fixed_string_t seg_lengths;
3645 cmd_set_txpkts_parsed(void *parsed_result,
3646 __attribute__((unused)) struct cmdline *cl,
3647 __attribute__((unused)) void *data)
3649 struct cmd_set_txpkts_result *res;
3650 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3651 unsigned int nb_segs;
3653 res = parsed_result;
3654 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3655 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3657 set_tx_pkt_segments(seg_lengths, nb_segs);
3660 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3661 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3662 cmd_keyword, "set");
3663 cmdline_parse_token_string_t cmd_set_txpkts_name =
3664 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3666 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3667 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3670 cmdline_parse_inst_t cmd_set_txpkts = {
3671 .f = cmd_set_txpkts_parsed,
3673 .help_str = "set txpkts <len0[,len1]*>",
3675 (void *)&cmd_set_txpkts_keyword,
3676 (void *)&cmd_set_txpkts_name,
3677 (void *)&cmd_set_txpkts_lengths,
3682 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3684 struct cmd_set_txsplit_result {
3685 cmdline_fixed_string_t cmd_keyword;
3686 cmdline_fixed_string_t txsplit;
3687 cmdline_fixed_string_t mode;
3691 cmd_set_txsplit_parsed(void *parsed_result,
3692 __attribute__((unused)) struct cmdline *cl,
3693 __attribute__((unused)) void *data)
3695 struct cmd_set_txsplit_result *res;
3697 res = parsed_result;
3698 set_tx_pkt_split(res->mode);
3701 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3702 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3703 cmd_keyword, "set");
3704 cmdline_parse_token_string_t cmd_set_txsplit_name =
3705 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3706 txsplit, "txsplit");
3707 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3708 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3711 cmdline_parse_inst_t cmd_set_txsplit = {
3712 .f = cmd_set_txsplit_parsed,
3714 .help_str = "set txsplit on|off|rand",
3716 (void *)&cmd_set_txsplit_keyword,
3717 (void *)&cmd_set_txsplit_name,
3718 (void *)&cmd_set_txsplit_mode,
3723 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3724 struct cmd_rx_vlan_filter_all_result {
3725 cmdline_fixed_string_t rx_vlan;
3726 cmdline_fixed_string_t what;
3727 cmdline_fixed_string_t all;
3732 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3733 __attribute__((unused)) struct cmdline *cl,
3734 __attribute__((unused)) void *data)
3736 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3738 if (!strcmp(res->what, "add"))
3739 rx_vlan_all_filter_set(res->port_id, 1);
3741 rx_vlan_all_filter_set(res->port_id, 0);
3744 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3745 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3746 rx_vlan, "rx_vlan");
3747 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3748 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3750 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3751 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3753 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3754 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3757 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3758 .f = cmd_rx_vlan_filter_all_parsed,
3760 .help_str = "rx_vlan add|rm all <port_id>: "
3761 "Add/Remove all identifiers to/from the set of VLAN "
3762 "identifiers filtered by a port",
3764 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3765 (void *)&cmd_rx_vlan_filter_all_what,
3766 (void *)&cmd_rx_vlan_filter_all_all,
3767 (void *)&cmd_rx_vlan_filter_all_portid,
3772 /* *** VLAN OFFLOAD SET ON A PORT *** */
3773 struct cmd_vlan_offload_result {
3774 cmdline_fixed_string_t vlan;
3775 cmdline_fixed_string_t set;
3776 cmdline_fixed_string_t vlan_type;
3777 cmdline_fixed_string_t what;
3778 cmdline_fixed_string_t on;
3779 cmdline_fixed_string_t port_id;
3783 cmd_vlan_offload_parsed(void *parsed_result,
3784 __attribute__((unused)) struct cmdline *cl,
3785 __attribute__((unused)) void *data)
3788 struct cmd_vlan_offload_result *res = parsed_result;
3791 portid_t port_id = 0;
3795 len = strnlen(str, STR_TOKEN_SIZE);
3797 /* Get port_id first */
3805 tmp = strtoul(str, NULL, 0);
3806 /* If port_id greater that what portid_t can represent, return */
3807 if(tmp >= RTE_MAX_ETHPORTS)
3809 port_id = (portid_t)tmp;
3811 if (!strcmp(res->on, "on"))
3816 if (!strcmp(res->what, "strip"))
3817 rx_vlan_strip_set(port_id, on);
3818 else if(!strcmp(res->what, "stripq")){
3819 uint16_t queue_id = 0;
3821 /* No queue_id, return */
3823 printf("must specify (port,queue_id)\n");
3826 tmp = strtoul(str + i + 1, NULL, 0);
3827 /* If queue_id greater that what 16-bits can represent, return */
3831 queue_id = (uint16_t)tmp;
3832 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3834 else if (!strcmp(res->what, "filter"))
3835 rx_vlan_filter_set(port_id, on);
3837 vlan_extend_set(port_id, on);
3842 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3843 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3845 cmdline_parse_token_string_t cmd_vlan_offload_set =
3846 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3848 cmdline_parse_token_string_t cmd_vlan_offload_what =
3849 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3850 what, "strip#filter#qinq#stripq");
3851 cmdline_parse_token_string_t cmd_vlan_offload_on =
3852 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3854 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3855 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3858 cmdline_parse_inst_t cmd_vlan_offload = {
3859 .f = cmd_vlan_offload_parsed,
3861 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3862 "<port_id[,queue_id]>: "
3863 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3865 (void *)&cmd_vlan_offload_vlan,
3866 (void *)&cmd_vlan_offload_set,
3867 (void *)&cmd_vlan_offload_what,
3868 (void *)&cmd_vlan_offload_on,
3869 (void *)&cmd_vlan_offload_portid,
3874 /* *** VLAN TPID SET ON A PORT *** */
3875 struct cmd_vlan_tpid_result {
3876 cmdline_fixed_string_t vlan;
3877 cmdline_fixed_string_t set;
3878 cmdline_fixed_string_t vlan_type;
3879 cmdline_fixed_string_t what;
3885 cmd_vlan_tpid_parsed(void *parsed_result,
3886 __attribute__((unused)) struct cmdline *cl,
3887 __attribute__((unused)) void *data)
3889 struct cmd_vlan_tpid_result *res = parsed_result;
3890 enum rte_vlan_type vlan_type;
3892 if (!strcmp(res->vlan_type, "inner"))
3893 vlan_type = ETH_VLAN_TYPE_INNER;
3894 else if (!strcmp(res->vlan_type, "outer"))
3895 vlan_type = ETH_VLAN_TYPE_OUTER;
3897 printf("Unknown vlan type\n");
3900 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3903 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3904 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3906 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3907 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3909 cmdline_parse_token_string_t cmd_vlan_type =
3910 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3911 vlan_type, "inner#outer");
3912 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3913 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3915 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3916 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3918 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3919 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3922 cmdline_parse_inst_t cmd_vlan_tpid = {
3923 .f = cmd_vlan_tpid_parsed,
3925 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3926 "Set the VLAN Ether type",
3928 (void *)&cmd_vlan_tpid_vlan,
3929 (void *)&cmd_vlan_tpid_set,
3930 (void *)&cmd_vlan_type,
3931 (void *)&cmd_vlan_tpid_what,
3932 (void *)&cmd_vlan_tpid_tpid,
3933 (void *)&cmd_vlan_tpid_portid,
3938 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3939 struct cmd_rx_vlan_filter_result {
3940 cmdline_fixed_string_t rx_vlan;
3941 cmdline_fixed_string_t what;
3947 cmd_rx_vlan_filter_parsed(void *parsed_result,
3948 __attribute__((unused)) struct cmdline *cl,
3949 __attribute__((unused)) void *data)
3951 struct cmd_rx_vlan_filter_result *res = parsed_result;
3953 if (!strcmp(res->what, "add"))
3954 rx_vft_set(res->port_id, res->vlan_id, 1);
3956 rx_vft_set(res->port_id, res->vlan_id, 0);
3959 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3960 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3961 rx_vlan, "rx_vlan");
3962 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3963 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3965 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3966 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3968 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3969 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3972 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3973 .f = cmd_rx_vlan_filter_parsed,
3975 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3976 "Add/Remove a VLAN identifier to/from the set of VLAN "
3977 "identifiers filtered by a port",
3979 (void *)&cmd_rx_vlan_filter_rx_vlan,
3980 (void *)&cmd_rx_vlan_filter_what,
3981 (void *)&cmd_rx_vlan_filter_vlanid,
3982 (void *)&cmd_rx_vlan_filter_portid,
3987 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3988 struct cmd_tx_vlan_set_result {
3989 cmdline_fixed_string_t tx_vlan;
3990 cmdline_fixed_string_t set;
3996 cmd_tx_vlan_set_parsed(void *parsed_result,
3997 __attribute__((unused)) struct cmdline *cl,
3998 __attribute__((unused)) void *data)
4000 struct cmd_tx_vlan_set_result *res = parsed_result;
4002 if (!port_is_stopped(res->port_id)) {
4003 printf("Please stop port %d first\n", res->port_id);
4007 tx_vlan_set(res->port_id, res->vlan_id);
4009 cmd_reconfig_device_queue(res->port_id, 1, 1);
4012 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4013 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4014 tx_vlan, "tx_vlan");
4015 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4016 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4018 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4019 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4021 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4022 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4025 cmdline_parse_inst_t cmd_tx_vlan_set = {
4026 .f = cmd_tx_vlan_set_parsed,
4028 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4029 "Enable hardware insertion of a single VLAN header "
4030 "with a given TAG Identifier in packets sent on a port",
4032 (void *)&cmd_tx_vlan_set_tx_vlan,
4033 (void *)&cmd_tx_vlan_set_set,
4034 (void *)&cmd_tx_vlan_set_portid,
4035 (void *)&cmd_tx_vlan_set_vlanid,
4040 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4041 struct cmd_tx_vlan_set_qinq_result {
4042 cmdline_fixed_string_t tx_vlan;
4043 cmdline_fixed_string_t set;
4046 uint16_t vlan_id_outer;
4050 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4051 __attribute__((unused)) struct cmdline *cl,
4052 __attribute__((unused)) void *data)
4054 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4056 if (!port_is_stopped(res->port_id)) {
4057 printf("Please stop port %d first\n", res->port_id);
4061 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4063 cmd_reconfig_device_queue(res->port_id, 1, 1);
4066 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4067 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4068 tx_vlan, "tx_vlan");
4069 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4070 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4072 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4073 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4075 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4076 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4078 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4079 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4080 vlan_id_outer, UINT16);
4082 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4083 .f = cmd_tx_vlan_set_qinq_parsed,
4085 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4086 "Enable hardware insertion of double VLAN header "
4087 "with given TAG Identifiers in packets sent on a port",
4089 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4090 (void *)&cmd_tx_vlan_set_qinq_set,
4091 (void *)&cmd_tx_vlan_set_qinq_portid,
4092 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4093 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4098 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4099 struct cmd_tx_vlan_set_pvid_result {
4100 cmdline_fixed_string_t tx_vlan;
4101 cmdline_fixed_string_t set;
4102 cmdline_fixed_string_t pvid;
4105 cmdline_fixed_string_t mode;
4109 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4110 __attribute__((unused)) struct cmdline *cl,
4111 __attribute__((unused)) void *data)
4113 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4115 if (strcmp(res->mode, "on") == 0)
4116 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4118 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4121 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4122 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4123 tx_vlan, "tx_vlan");
4124 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4125 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4127 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4128 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4130 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4131 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4133 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4134 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4136 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4137 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4140 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4141 .f = cmd_tx_vlan_set_pvid_parsed,
4143 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4145 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4146 (void *)&cmd_tx_vlan_set_pvid_set,
4147 (void *)&cmd_tx_vlan_set_pvid_pvid,
4148 (void *)&cmd_tx_vlan_set_pvid_port_id,
4149 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4150 (void *)&cmd_tx_vlan_set_pvid_mode,
4155 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4156 struct cmd_tx_vlan_reset_result {
4157 cmdline_fixed_string_t tx_vlan;
4158 cmdline_fixed_string_t reset;
4163 cmd_tx_vlan_reset_parsed(void *parsed_result,
4164 __attribute__((unused)) struct cmdline *cl,
4165 __attribute__((unused)) void *data)
4167 struct cmd_tx_vlan_reset_result *res = parsed_result;
4169 if (!port_is_stopped(res->port_id)) {
4170 printf("Please stop port %d first\n", res->port_id);
4174 tx_vlan_reset(res->port_id);
4176 cmd_reconfig_device_queue(res->port_id, 1, 1);
4179 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4180 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4181 tx_vlan, "tx_vlan");
4182 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4183 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4185 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4186 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4189 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4190 .f = cmd_tx_vlan_reset_parsed,
4192 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4193 "VLAN header in packets sent on a port",
4195 (void *)&cmd_tx_vlan_reset_tx_vlan,
4196 (void *)&cmd_tx_vlan_reset_reset,
4197 (void *)&cmd_tx_vlan_reset_portid,
4203 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4204 struct cmd_csum_result {
4205 cmdline_fixed_string_t csum;
4206 cmdline_fixed_string_t mode;
4207 cmdline_fixed_string_t proto;
4208 cmdline_fixed_string_t hwsw;
4213 csum_show(int port_id)
4215 struct rte_eth_dev_info dev_info;
4216 uint64_t tx_offloads;
4218 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4219 printf("Parse tunnel is %s\n",
4220 (ports[port_id].parse_tunnel) ? "on" : "off");
4221 printf("IP checksum offload is %s\n",
4222 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4223 printf("UDP checksum offload is %s\n",
4224 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4225 printf("TCP checksum offload is %s\n",
4226 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4227 printf("SCTP checksum offload is %s\n",
4228 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4229 printf("Outer-Ip checksum offload is %s\n",
4230 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4231 printf("Outer-Udp checksum offload is %s\n",
4232 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4234 /* display warnings if configuration is not supported by the NIC */
4235 rte_eth_dev_info_get(port_id, &dev_info);
4236 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4237 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4238 printf("Warning: hardware IP checksum enabled but not "
4239 "supported by port %d\n", port_id);
4241 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4242 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4243 printf("Warning: hardware UDP checksum enabled but not "
4244 "supported by port %d\n", port_id);
4246 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4247 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4248 printf("Warning: hardware TCP checksum enabled but not "
4249 "supported by port %d\n", port_id);
4251 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4252 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4253 printf("Warning: hardware SCTP checksum enabled but not "
4254 "supported by port %d\n", port_id);
4256 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4257 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4258 printf("Warning: hardware outer IP checksum enabled but not "
4259 "supported by port %d\n", port_id);
4261 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4262 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4264 printf("Warning: hardware outer UDP checksum enabled but not "
4265 "supported by port %d\n", port_id);
4270 cmd_csum_parsed(void *parsed_result,
4271 __attribute__((unused)) struct cmdline *cl,
4272 __attribute__((unused)) void *data)
4274 struct cmd_csum_result *res = parsed_result;
4276 uint64_t csum_offloads = 0;
4277 struct rte_eth_dev_info dev_info;
4279 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4280 printf("invalid port %d\n", res->port_id);
4283 if (!port_is_stopped(res->port_id)) {
4284 printf("Please stop port %d first\n", res->port_id);
4288 rte_eth_dev_info_get(res->port_id, &dev_info);
4289 if (!strcmp(res->mode, "set")) {
4291 if (!strcmp(res->hwsw, "hw"))
4294 if (!strcmp(res->proto, "ip")) {
4295 if (hw == 0 || (dev_info.tx_offload_capa &
4296 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4297 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4299 printf("IP checksum offload is not supported "
4300 "by port %u\n", res->port_id);
4302 } else if (!strcmp(res->proto, "udp")) {
4303 if (hw == 0 || (dev_info.tx_offload_capa &
4304 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4305 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4307 printf("UDP checksum offload is not supported "
4308 "by port %u\n", res->port_id);
4310 } else if (!strcmp(res->proto, "tcp")) {
4311 if (hw == 0 || (dev_info.tx_offload_capa &
4312 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4313 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4315 printf("TCP checksum offload is not supported "
4316 "by port %u\n", res->port_id);
4318 } else if (!strcmp(res->proto, "sctp")) {
4319 if (hw == 0 || (dev_info.tx_offload_capa &
4320 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4321 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4323 printf("SCTP checksum offload is not supported "
4324 "by port %u\n", res->port_id);
4326 } else if (!strcmp(res->proto, "outer-ip")) {
4327 if (hw == 0 || (dev_info.tx_offload_capa &
4328 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4330 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4332 printf("Outer IP checksum offload is not "
4333 "supported by port %u\n", res->port_id);
4335 } else if (!strcmp(res->proto, "outer-udp")) {
4336 if (hw == 0 || (dev_info.tx_offload_capa &
4337 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4339 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4341 printf("Outer UDP checksum offload is not "
4342 "supported by port %u\n", res->port_id);
4347 ports[res->port_id].dev_conf.txmode.offloads |=
4350 ports[res->port_id].dev_conf.txmode.offloads &=
4354 csum_show(res->port_id);
4356 cmd_reconfig_device_queue(res->port_id, 1, 1);
4359 cmdline_parse_token_string_t cmd_csum_csum =
4360 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4362 cmdline_parse_token_string_t cmd_csum_mode =
4363 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4365 cmdline_parse_token_string_t cmd_csum_proto =
4366 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4367 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4368 cmdline_parse_token_string_t cmd_csum_hwsw =
4369 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4371 cmdline_parse_token_num_t cmd_csum_portid =
4372 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4375 cmdline_parse_inst_t cmd_csum_set = {
4376 .f = cmd_csum_parsed,
4378 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4379 "Enable/Disable hardware calculation of L3/L4 checksum when "
4380 "using csum forward engine",
4382 (void *)&cmd_csum_csum,
4383 (void *)&cmd_csum_mode,
4384 (void *)&cmd_csum_proto,
4385 (void *)&cmd_csum_hwsw,
4386 (void *)&cmd_csum_portid,
4391 cmdline_parse_token_string_t cmd_csum_mode_show =
4392 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4395 cmdline_parse_inst_t cmd_csum_show = {
4396 .f = cmd_csum_parsed,
4398 .help_str = "csum show <port_id>: Show checksum offload configuration",
4400 (void *)&cmd_csum_csum,
4401 (void *)&cmd_csum_mode_show,
4402 (void *)&cmd_csum_portid,
4407 /* Enable/disable tunnel parsing */
4408 struct cmd_csum_tunnel_result {
4409 cmdline_fixed_string_t csum;
4410 cmdline_fixed_string_t parse;
4411 cmdline_fixed_string_t onoff;
4416 cmd_csum_tunnel_parsed(void *parsed_result,
4417 __attribute__((unused)) struct cmdline *cl,
4418 __attribute__((unused)) void *data)
4420 struct cmd_csum_tunnel_result *res = parsed_result;
4422 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4425 if (!strcmp(res->onoff, "on"))
4426 ports[res->port_id].parse_tunnel = 1;
4428 ports[res->port_id].parse_tunnel = 0;
4430 csum_show(res->port_id);
4433 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4434 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4436 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4437 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4438 parse, "parse-tunnel");
4439 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4440 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4442 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4443 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4446 cmdline_parse_inst_t cmd_csum_tunnel = {
4447 .f = cmd_csum_tunnel_parsed,
4449 .help_str = "csum parse-tunnel on|off <port_id>: "
4450 "Enable/Disable parsing of tunnels for csum engine",
4452 (void *)&cmd_csum_tunnel_csum,
4453 (void *)&cmd_csum_tunnel_parse,
4454 (void *)&cmd_csum_tunnel_onoff,
4455 (void *)&cmd_csum_tunnel_portid,
4460 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4461 struct cmd_tso_set_result {
4462 cmdline_fixed_string_t tso;
4463 cmdline_fixed_string_t mode;
4469 cmd_tso_set_parsed(void *parsed_result,
4470 __attribute__((unused)) struct cmdline *cl,
4471 __attribute__((unused)) void *data)
4473 struct cmd_tso_set_result *res = parsed_result;
4474 struct rte_eth_dev_info dev_info;
4476 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4478 if (!port_is_stopped(res->port_id)) {
4479 printf("Please stop port %d first\n", res->port_id);
4483 if (!strcmp(res->mode, "set"))
4484 ports[res->port_id].tso_segsz = res->tso_segsz;
4486 rte_eth_dev_info_get(res->port_id, &dev_info);
4487 if ((ports[res->port_id].tso_segsz != 0) &&
4488 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4489 printf("Error: TSO is not supported by port %d\n",
4494 if (ports[res->port_id].tso_segsz == 0) {
4495 ports[res->port_id].dev_conf.txmode.offloads &=
4496 ~DEV_TX_OFFLOAD_TCP_TSO;
4497 printf("TSO for non-tunneled packets is disabled\n");
4499 ports[res->port_id].dev_conf.txmode.offloads |=
4500 DEV_TX_OFFLOAD_TCP_TSO;
4501 printf("TSO segment size for non-tunneled packets is %d\n",
4502 ports[res->port_id].tso_segsz);
4505 /* display warnings if configuration is not supported by the NIC */
4506 rte_eth_dev_info_get(res->port_id, &dev_info);
4507 if ((ports[res->port_id].tso_segsz != 0) &&
4508 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4509 printf("Warning: TSO enabled but not "
4510 "supported by port %d\n", res->port_id);
4513 cmd_reconfig_device_queue(res->port_id, 1, 1);
4516 cmdline_parse_token_string_t cmd_tso_set_tso =
4517 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4519 cmdline_parse_token_string_t cmd_tso_set_mode =
4520 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4522 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4523 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4525 cmdline_parse_token_num_t cmd_tso_set_portid =
4526 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4529 cmdline_parse_inst_t cmd_tso_set = {
4530 .f = cmd_tso_set_parsed,
4532 .help_str = "tso set <tso_segsz> <port_id>: "
4533 "Set TSO segment size of non-tunneled packets for csum engine "
4536 (void *)&cmd_tso_set_tso,
4537 (void *)&cmd_tso_set_mode,
4538 (void *)&cmd_tso_set_tso_segsz,
4539 (void *)&cmd_tso_set_portid,
4544 cmdline_parse_token_string_t cmd_tso_show_mode =
4545 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4549 cmdline_parse_inst_t cmd_tso_show = {
4550 .f = cmd_tso_set_parsed,
4552 .help_str = "tso show <port_id>: "
4553 "Show TSO segment size of non-tunneled packets for csum engine",
4555 (void *)&cmd_tso_set_tso,
4556 (void *)&cmd_tso_show_mode,
4557 (void *)&cmd_tso_set_portid,
4562 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4563 struct cmd_tunnel_tso_set_result {
4564 cmdline_fixed_string_t tso;
4565 cmdline_fixed_string_t mode;
4570 static struct rte_eth_dev_info
4571 check_tunnel_tso_nic_support(portid_t port_id)
4573 struct rte_eth_dev_info dev_info;
4575 rte_eth_dev_info_get(port_id, &dev_info);
4576 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4577 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4578 "not enabled for port %d\n", port_id);
4579 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4580 printf("Warning: GRE TUNNEL TSO not supported therefore "
4581 "not enabled for port %d\n", port_id);
4582 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4583 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4584 "not enabled for port %d\n", port_id);
4585 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4586 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4587 "not enabled for port %d\n", port_id);
4588 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4589 printf("Warning: IP TUNNEL TSO not supported therefore "
4590 "not enabled for port %d\n", port_id);
4591 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4592 printf("Warning: UDP TUNNEL TSO not supported therefore "
4593 "not enabled for port %d\n", port_id);
4598 cmd_tunnel_tso_set_parsed(void *parsed_result,
4599 __attribute__((unused)) struct cmdline *cl,
4600 __attribute__((unused)) void *data)
4602 struct cmd_tunnel_tso_set_result *res = parsed_result;
4603 struct rte_eth_dev_info dev_info;
4605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4607 if (!port_is_stopped(res->port_id)) {
4608 printf("Please stop port %d first\n", res->port_id);
4612 if (!strcmp(res->mode, "set"))
4613 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4615 dev_info = check_tunnel_tso_nic_support(res->port_id);
4616 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4617 ports[res->port_id].dev_conf.txmode.offloads &=
4618 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4619 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4620 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4621 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4622 DEV_TX_OFFLOAD_IP_TNL_TSO |
4623 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4624 printf("TSO for tunneled packets is disabled\n");
4626 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4627 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4628 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4629 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4630 DEV_TX_OFFLOAD_IP_TNL_TSO |
4631 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4633 ports[res->port_id].dev_conf.txmode.offloads |=
4634 (tso_offloads & dev_info.tx_offload_capa);
4635 printf("TSO segment size for tunneled packets is %d\n",
4636 ports[res->port_id].tunnel_tso_segsz);
4638 /* Below conditions are needed to make it work:
4639 * (1) tunnel TSO is supported by the NIC;
4640 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4642 * (3) for tunneled pkts with outer L3 of IPv4,
4643 * "csum set outer-ip" must be set to hw, because after tso,
4644 * total_len of outer IP header is changed, and the checksum
4645 * of outer IP header calculated by sw should be wrong; that
4646 * is not necessary for IPv6 tunneled pkts because there's no
4647 * checksum in IP header anymore.
4650 if (!ports[res->port_id].parse_tunnel)
4651 printf("Warning: csum parse_tunnel must be set "
4652 "so that tunneled packets are recognized\n");
4653 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4654 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4655 printf("Warning: csum set outer-ip must be set to hw "
4656 "if outer L3 is IPv4; not necessary for IPv6\n");
4659 cmd_reconfig_device_queue(res->port_id, 1, 1);
4662 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4663 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4665 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4666 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4668 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4669 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4671 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4672 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4675 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4676 .f = cmd_tunnel_tso_set_parsed,
4678 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4679 "Set TSO segment size of tunneled packets for csum engine "
4682 (void *)&cmd_tunnel_tso_set_tso,
4683 (void *)&cmd_tunnel_tso_set_mode,
4684 (void *)&cmd_tunnel_tso_set_tso_segsz,
4685 (void *)&cmd_tunnel_tso_set_portid,
4690 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4691 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4695 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4696 .f = cmd_tunnel_tso_set_parsed,
4698 .help_str = "tunnel_tso show <port_id> "
4699 "Show TSO segment size of tunneled packets for csum engine",
4701 (void *)&cmd_tunnel_tso_set_tso,
4702 (void *)&cmd_tunnel_tso_show_mode,
4703 (void *)&cmd_tunnel_tso_set_portid,
4708 /* *** SET GRO FOR A PORT *** */
4709 struct cmd_gro_enable_result {
4710 cmdline_fixed_string_t cmd_set;
4711 cmdline_fixed_string_t cmd_port;
4712 cmdline_fixed_string_t cmd_keyword;
4713 cmdline_fixed_string_t cmd_onoff;
4718 cmd_gro_enable_parsed(void *parsed_result,
4719 __attribute__((unused)) struct cmdline *cl,
4720 __attribute__((unused)) void *data)
4722 struct cmd_gro_enable_result *res;
4724 res = parsed_result;
4725 if (!strcmp(res->cmd_keyword, "gro"))
4726 setup_gro(res->cmd_onoff, res->cmd_pid);
4729 cmdline_parse_token_string_t cmd_gro_enable_set =
4730 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4732 cmdline_parse_token_string_t cmd_gro_enable_port =
4733 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4734 cmd_keyword, "port");
4735 cmdline_parse_token_num_t cmd_gro_enable_pid =
4736 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4738 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4739 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4740 cmd_keyword, "gro");
4741 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4742 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4743 cmd_onoff, "on#off");
4745 cmdline_parse_inst_t cmd_gro_enable = {
4746 .f = cmd_gro_enable_parsed,
4748 .help_str = "set port <port_id> gro on|off",
4750 (void *)&cmd_gro_enable_set,
4751 (void *)&cmd_gro_enable_port,
4752 (void *)&cmd_gro_enable_pid,
4753 (void *)&cmd_gro_enable_keyword,
4754 (void *)&cmd_gro_enable_onoff,
4759 /* *** DISPLAY GRO CONFIGURATION *** */
4760 struct cmd_gro_show_result {
4761 cmdline_fixed_string_t cmd_show;
4762 cmdline_fixed_string_t cmd_port;
4763 cmdline_fixed_string_t cmd_keyword;
4768 cmd_gro_show_parsed(void *parsed_result,
4769 __attribute__((unused)) struct cmdline *cl,
4770 __attribute__((unused)) void *data)
4772 struct cmd_gro_show_result *res;
4774 res = parsed_result;
4775 if (!strcmp(res->cmd_keyword, "gro"))
4776 show_gro(res->cmd_pid);
4779 cmdline_parse_token_string_t cmd_gro_show_show =
4780 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4782 cmdline_parse_token_string_t cmd_gro_show_port =
4783 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4785 cmdline_parse_token_num_t cmd_gro_show_pid =
4786 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4788 cmdline_parse_token_string_t cmd_gro_show_keyword =
4789 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4790 cmd_keyword, "gro");
4792 cmdline_parse_inst_t cmd_gro_show = {
4793 .f = cmd_gro_show_parsed,
4795 .help_str = "show port <port_id> gro",
4797 (void *)&cmd_gro_show_show,
4798 (void *)&cmd_gro_show_port,
4799 (void *)&cmd_gro_show_pid,
4800 (void *)&cmd_gro_show_keyword,
4805 /* *** SET FLUSH CYCLES FOR GRO *** */
4806 struct cmd_gro_flush_result {
4807 cmdline_fixed_string_t cmd_set;
4808 cmdline_fixed_string_t cmd_keyword;
4809 cmdline_fixed_string_t cmd_flush;
4814 cmd_gro_flush_parsed(void *parsed_result,
4815 __attribute__((unused)) struct cmdline *cl,
4816 __attribute__((unused)) void *data)
4818 struct cmd_gro_flush_result *res;
4820 res = parsed_result;
4821 if ((!strcmp(res->cmd_keyword, "gro")) &&
4822 (!strcmp(res->cmd_flush, "flush")))
4823 setup_gro_flush_cycles(res->cmd_cycles);
4826 cmdline_parse_token_string_t cmd_gro_flush_set =
4827 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4829 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4830 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4831 cmd_keyword, "gro");
4832 cmdline_parse_token_string_t cmd_gro_flush_flush =
4833 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4834 cmd_flush, "flush");
4835 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4836 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4839 cmdline_parse_inst_t cmd_gro_flush = {
4840 .f = cmd_gro_flush_parsed,
4842 .help_str = "set gro flush <cycles>",
4844 (void *)&cmd_gro_flush_set,
4845 (void *)&cmd_gro_flush_keyword,
4846 (void *)&cmd_gro_flush_flush,
4847 (void *)&cmd_gro_flush_cycles,
4852 /* *** ENABLE/DISABLE GSO *** */
4853 struct cmd_gso_enable_result {
4854 cmdline_fixed_string_t cmd_set;
4855 cmdline_fixed_string_t cmd_port;
4856 cmdline_fixed_string_t cmd_keyword;
4857 cmdline_fixed_string_t cmd_mode;
4862 cmd_gso_enable_parsed(void *parsed_result,
4863 __attribute__((unused)) struct cmdline *cl,
4864 __attribute__((unused)) void *data)
4866 struct cmd_gso_enable_result *res;
4868 res = parsed_result;
4869 if (!strcmp(res->cmd_keyword, "gso"))
4870 setup_gso(res->cmd_mode, res->cmd_pid);
4873 cmdline_parse_token_string_t cmd_gso_enable_set =
4874 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4876 cmdline_parse_token_string_t cmd_gso_enable_port =
4877 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4879 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4880 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4881 cmd_keyword, "gso");
4882 cmdline_parse_token_string_t cmd_gso_enable_mode =
4883 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4884 cmd_mode, "on#off");
4885 cmdline_parse_token_num_t cmd_gso_enable_pid =
4886 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4889 cmdline_parse_inst_t cmd_gso_enable = {
4890 .f = cmd_gso_enable_parsed,
4892 .help_str = "set port <port_id> gso on|off",
4894 (void *)&cmd_gso_enable_set,
4895 (void *)&cmd_gso_enable_port,
4896 (void *)&cmd_gso_enable_pid,
4897 (void *)&cmd_gso_enable_keyword,
4898 (void *)&cmd_gso_enable_mode,
4903 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4904 struct cmd_gso_size_result {
4905 cmdline_fixed_string_t cmd_set;
4906 cmdline_fixed_string_t cmd_keyword;
4907 cmdline_fixed_string_t cmd_segsz;
4912 cmd_gso_size_parsed(void *parsed_result,
4913 __attribute__((unused)) struct cmdline *cl,
4914 __attribute__((unused)) void *data)
4916 struct cmd_gso_size_result *res = parsed_result;
4918 if (test_done == 0) {
4919 printf("Before setting GSO segsz, please first"
4920 " stop fowarding\n");
4924 if (!strcmp(res->cmd_keyword, "gso") &&
4925 !strcmp(res->cmd_segsz, "segsz")) {
4926 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4927 printf("gso_size should be larger than %zu."
4928 " Please input a legal value\n",
4929 RTE_GSO_SEG_SIZE_MIN);
4931 gso_max_segment_size = res->cmd_size;
4935 cmdline_parse_token_string_t cmd_gso_size_set =
4936 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4938 cmdline_parse_token_string_t cmd_gso_size_keyword =
4939 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4940 cmd_keyword, "gso");
4941 cmdline_parse_token_string_t cmd_gso_size_segsz =
4942 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4943 cmd_segsz, "segsz");
4944 cmdline_parse_token_num_t cmd_gso_size_size =
4945 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4948 cmdline_parse_inst_t cmd_gso_size = {
4949 .f = cmd_gso_size_parsed,
4951 .help_str = "set gso segsz <length>",
4953 (void *)&cmd_gso_size_set,
4954 (void *)&cmd_gso_size_keyword,
4955 (void *)&cmd_gso_size_segsz,
4956 (void *)&cmd_gso_size_size,
4961 /* *** SHOW GSO CONFIGURATION *** */
4962 struct cmd_gso_show_result {
4963 cmdline_fixed_string_t cmd_show;
4964 cmdline_fixed_string_t cmd_port;
4965 cmdline_fixed_string_t cmd_keyword;
4970 cmd_gso_show_parsed(void *parsed_result,
4971 __attribute__((unused)) struct cmdline *cl,
4972 __attribute__((unused)) void *data)
4974 struct cmd_gso_show_result *res = parsed_result;
4976 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4977 printf("invalid port id %u\n", res->cmd_pid);
4980 if (!strcmp(res->cmd_keyword, "gso")) {
4981 if (gso_ports[res->cmd_pid].enable) {
4982 printf("Max GSO'd packet size: %uB\n"
4983 "Supported GSO types: TCP/IPv4, "
4984 "UDP/IPv4, VxLAN with inner "
4985 "TCP/IPv4 packet, GRE with inner "
4986 "TCP/IPv4 packet\n",
4987 gso_max_segment_size);
4989 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4993 cmdline_parse_token_string_t cmd_gso_show_show =
4994 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4996 cmdline_parse_token_string_t cmd_gso_show_port =
4997 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4999 cmdline_parse_token_string_t cmd_gso_show_keyword =
5000 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5001 cmd_keyword, "gso");
5002 cmdline_parse_token_num_t cmd_gso_show_pid =
5003 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5006 cmdline_parse_inst_t cmd_gso_show = {
5007 .f = cmd_gso_show_parsed,
5009 .help_str = "show port <port_id> gso",
5011 (void *)&cmd_gso_show_show,
5012 (void *)&cmd_gso_show_port,
5013 (void *)&cmd_gso_show_pid,
5014 (void *)&cmd_gso_show_keyword,
5019 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5020 struct cmd_set_flush_rx {
5021 cmdline_fixed_string_t set;
5022 cmdline_fixed_string_t flush_rx;
5023 cmdline_fixed_string_t mode;
5027 cmd_set_flush_rx_parsed(void *parsed_result,
5028 __attribute__((unused)) struct cmdline *cl,
5029 __attribute__((unused)) void *data)
5031 struct cmd_set_flush_rx *res = parsed_result;
5032 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5035 cmdline_parse_token_string_t cmd_setflushrx_set =
5036 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5038 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5039 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5040 flush_rx, "flush_rx");
5041 cmdline_parse_token_string_t cmd_setflushrx_mode =
5042 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5046 cmdline_parse_inst_t cmd_set_flush_rx = {
5047 .f = cmd_set_flush_rx_parsed,
5048 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5051 (void *)&cmd_setflushrx_set,
5052 (void *)&cmd_setflushrx_flush_rx,
5053 (void *)&cmd_setflushrx_mode,
5058 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5059 struct cmd_set_link_check {
5060 cmdline_fixed_string_t set;
5061 cmdline_fixed_string_t link_check;
5062 cmdline_fixed_string_t mode;
5066 cmd_set_link_check_parsed(void *parsed_result,
5067 __attribute__((unused)) struct cmdline *cl,
5068 __attribute__((unused)) void *data)
5070 struct cmd_set_link_check *res = parsed_result;
5071 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5074 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5075 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5077 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5078 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5079 link_check, "link_check");
5080 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5081 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5085 cmdline_parse_inst_t cmd_set_link_check = {
5086 .f = cmd_set_link_check_parsed,
5087 .help_str = "set link_check on|off: Enable/Disable link status check "
5088 "when starting/stopping a port",
5091 (void *)&cmd_setlinkcheck_set,
5092 (void *)&cmd_setlinkcheck_link_check,
5093 (void *)&cmd_setlinkcheck_mode,
5098 /* *** SET NIC BYPASS MODE *** */
5099 struct cmd_set_bypass_mode_result {
5100 cmdline_fixed_string_t set;
5101 cmdline_fixed_string_t bypass;
5102 cmdline_fixed_string_t mode;
5103 cmdline_fixed_string_t value;
5108 cmd_set_bypass_mode_parsed(void *parsed_result,
5109 __attribute__((unused)) struct cmdline *cl,
5110 __attribute__((unused)) void *data)
5112 struct cmd_set_bypass_mode_result *res = parsed_result;
5113 portid_t port_id = res->port_id;
5114 int32_t rc = -EINVAL;
5116 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5117 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5119 if (!strcmp(res->value, "bypass"))
5120 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5121 else if (!strcmp(res->value, "isolate"))
5122 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5124 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5126 /* Set the bypass mode for the relevant port. */
5127 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5130 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5133 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5134 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5136 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5137 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5139 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5140 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5142 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5143 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5144 value, "normal#bypass#isolate");
5145 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5146 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5149 cmdline_parse_inst_t cmd_set_bypass_mode = {
5150 .f = cmd_set_bypass_mode_parsed,
5151 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5152 "Set the NIC bypass mode for port_id",
5155 (void *)&cmd_setbypass_mode_set,
5156 (void *)&cmd_setbypass_mode_bypass,
5157 (void *)&cmd_setbypass_mode_mode,
5158 (void *)&cmd_setbypass_mode_value,
5159 (void *)&cmd_setbypass_mode_port,
5164 /* *** SET NIC BYPASS EVENT *** */
5165 struct cmd_set_bypass_event_result {
5166 cmdline_fixed_string_t set;
5167 cmdline_fixed_string_t bypass;
5168 cmdline_fixed_string_t event;
5169 cmdline_fixed_string_t event_value;
5170 cmdline_fixed_string_t mode;
5171 cmdline_fixed_string_t mode_value;
5176 cmd_set_bypass_event_parsed(void *parsed_result,
5177 __attribute__((unused)) struct cmdline *cl,
5178 __attribute__((unused)) void *data)
5180 int32_t rc = -EINVAL;
5181 struct cmd_set_bypass_event_result *res = parsed_result;
5182 portid_t port_id = res->port_id;
5184 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5185 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5186 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5188 if (!strcmp(res->event_value, "timeout"))
5189 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5190 else if (!strcmp(res->event_value, "os_on"))
5191 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5192 else if (!strcmp(res->event_value, "os_off"))
5193 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5194 else if (!strcmp(res->event_value, "power_on"))
5195 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5196 else if (!strcmp(res->event_value, "power_off"))
5197 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5199 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5201 if (!strcmp(res->mode_value, "bypass"))
5202 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5203 else if (!strcmp(res->mode_value, "isolate"))
5204 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5206 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5208 /* Set the watchdog timeout. */
5209 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5212 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5213 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5217 printf("Failed to set timeout value %u "
5218 "for port %d, errto code: %d.\n",
5219 bypass_timeout, port_id, rc);
5223 /* Set the bypass event to transition to bypass mode. */
5224 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5229 printf("\t Failed to set bypass event for port = %d.\n",
5233 cmdline_parse_token_string_t cmd_setbypass_event_set =
5234 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5236 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5237 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5239 cmdline_parse_token_string_t cmd_setbypass_event_event =
5240 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5242 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5243 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5244 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5245 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5246 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5248 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5249 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5250 mode_value, "normal#bypass#isolate");
5251 cmdline_parse_token_num_t cmd_setbypass_event_port =
5252 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5255 cmdline_parse_inst_t cmd_set_bypass_event = {
5256 .f = cmd_set_bypass_event_parsed,
5257 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5258 "power_off mode normal|bypass|isolate <port_id>: "
5259 "Set the NIC bypass event mode for port_id",
5262 (void *)&cmd_setbypass_event_set,
5263 (void *)&cmd_setbypass_event_bypass,
5264 (void *)&cmd_setbypass_event_event,
5265 (void *)&cmd_setbypass_event_event_value,
5266 (void *)&cmd_setbypass_event_mode,
5267 (void *)&cmd_setbypass_event_mode_value,
5268 (void *)&cmd_setbypass_event_port,
5274 /* *** SET NIC BYPASS TIMEOUT *** */
5275 struct cmd_set_bypass_timeout_result {
5276 cmdline_fixed_string_t set;
5277 cmdline_fixed_string_t bypass;
5278 cmdline_fixed_string_t timeout;
5279 cmdline_fixed_string_t value;
5283 cmd_set_bypass_timeout_parsed(void *parsed_result,
5284 __attribute__((unused)) struct cmdline *cl,
5285 __attribute__((unused)) void *data)
5287 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5289 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5290 if (!strcmp(res->value, "1.5"))
5291 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5292 else if (!strcmp(res->value, "2"))
5293 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5294 else if (!strcmp(res->value, "3"))
5295 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5296 else if (!strcmp(res->value, "4"))
5297 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5298 else if (!strcmp(res->value, "8"))
5299 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5300 else if (!strcmp(res->value, "16"))
5301 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5302 else if (!strcmp(res->value, "32"))
5303 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5305 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5309 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5310 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5312 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5313 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5315 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5316 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5317 timeout, "timeout");
5318 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5319 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5320 value, "0#1.5#2#3#4#8#16#32");
5322 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5323 .f = cmd_set_bypass_timeout_parsed,
5324 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5325 "Set the NIC bypass watchdog timeout in seconds",
5328 (void *)&cmd_setbypass_timeout_set,
5329 (void *)&cmd_setbypass_timeout_bypass,
5330 (void *)&cmd_setbypass_timeout_timeout,
5331 (void *)&cmd_setbypass_timeout_value,
5336 /* *** SHOW NIC BYPASS MODE *** */
5337 struct cmd_show_bypass_config_result {
5338 cmdline_fixed_string_t show;
5339 cmdline_fixed_string_t bypass;
5340 cmdline_fixed_string_t config;
5345 cmd_show_bypass_config_parsed(void *parsed_result,
5346 __attribute__((unused)) struct cmdline *cl,
5347 __attribute__((unused)) void *data)
5349 struct cmd_show_bypass_config_result *res = parsed_result;
5350 portid_t port_id = res->port_id;
5352 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5353 uint32_t event_mode;
5354 uint32_t bypass_mode;
5355 uint32_t timeout = bypass_timeout;
5358 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5359 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5360 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5361 {"UNKNOWN", "normal", "bypass", "isolate"};
5362 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5369 int num_events = (sizeof events) / (sizeof events[0]);
5371 /* Display the bypass mode.*/
5372 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5373 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5377 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5378 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5380 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5383 /* Display the bypass timeout.*/
5384 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5385 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5387 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5389 /* Display the bypass events and associated modes. */
5390 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5392 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5393 printf("\tFailed to get bypass mode for event = %s\n",
5396 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5397 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5399 printf("\tbypass event: %-16s = %s\n", events[i],
5405 printf("\tFailed to get bypass configuration for port = %d\n",
5409 cmdline_parse_token_string_t cmd_showbypass_config_show =
5410 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5412 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5413 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5415 cmdline_parse_token_string_t cmd_showbypass_config_config =
5416 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5418 cmdline_parse_token_num_t cmd_showbypass_config_port =
5419 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5422 cmdline_parse_inst_t cmd_show_bypass_config = {
5423 .f = cmd_show_bypass_config_parsed,
5424 .help_str = "show bypass config <port_id>: "
5425 "Show the NIC bypass config for port_id",
5428 (void *)&cmd_showbypass_config_show,
5429 (void *)&cmd_showbypass_config_bypass,
5430 (void *)&cmd_showbypass_config_config,
5431 (void *)&cmd_showbypass_config_port,
5436 #ifdef RTE_LIBRTE_PMD_BOND
5437 /* *** SET BONDING MODE *** */
5438 struct cmd_set_bonding_mode_result {
5439 cmdline_fixed_string_t set;
5440 cmdline_fixed_string_t bonding;
5441 cmdline_fixed_string_t mode;
5446 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5447 __attribute__((unused)) struct cmdline *cl,
5448 __attribute__((unused)) void *data)
5450 struct cmd_set_bonding_mode_result *res = parsed_result;
5451 portid_t port_id = res->port_id;
5453 /* Set the bonding mode for the relevant port. */
5454 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5455 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5458 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5459 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5461 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5462 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5463 bonding, "bonding");
5464 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5465 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5467 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5468 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5470 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5471 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5474 cmdline_parse_inst_t cmd_set_bonding_mode = {
5475 .f = cmd_set_bonding_mode_parsed,
5476 .help_str = "set bonding mode <mode_value> <port_id>: "
5477 "Set the bonding mode for port_id",
5480 (void *) &cmd_setbonding_mode_set,
5481 (void *) &cmd_setbonding_mode_bonding,
5482 (void *) &cmd_setbonding_mode_mode,
5483 (void *) &cmd_setbonding_mode_value,
5484 (void *) &cmd_setbonding_mode_port,
5489 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5490 struct cmd_set_bonding_lacp_dedicated_queues_result {
5491 cmdline_fixed_string_t set;
5492 cmdline_fixed_string_t bonding;
5493 cmdline_fixed_string_t lacp;
5494 cmdline_fixed_string_t dedicated_queues;
5496 cmdline_fixed_string_t mode;
5499 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5500 __attribute__((unused)) struct cmdline *cl,
5501 __attribute__((unused)) void *data)
5503 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5504 portid_t port_id = res->port_id;
5505 struct rte_port *port;
5507 port = &ports[port_id];
5509 /** Check if the port is not started **/
5510 if (port->port_status != RTE_PORT_STOPPED) {
5511 printf("Please stop port %d first\n", port_id);
5515 if (!strcmp(res->mode, "enable")) {
5516 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5517 printf("Dedicate queues for LACP control packets"
5520 printf("Enabling dedicate queues for LACP control "
5521 "packets on port %d failed\n", port_id);
5522 } else if (!strcmp(res->mode, "disable")) {
5523 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5524 printf("Dedicated queues for LACP control packets "
5527 printf("Disabling dedicated queues for LACP control "
5528 "traffic on port %d failed\n", port_id);
5532 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5533 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5535 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5536 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5537 bonding, "bonding");
5538 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5539 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5541 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5542 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5543 dedicated_queues, "dedicated_queues");
5544 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5545 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5547 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5549 mode, "enable#disable");
5551 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5552 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5553 .help_str = "set bonding lacp dedicated_queues <port_id> "
5555 "Enable/disable dedicated queues for LACP control traffic for port_id",
5558 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5559 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5560 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5561 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5562 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5563 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5568 /* *** SET BALANCE XMIT POLICY *** */
5569 struct cmd_set_bonding_balance_xmit_policy_result {
5570 cmdline_fixed_string_t set;
5571 cmdline_fixed_string_t bonding;
5572 cmdline_fixed_string_t balance_xmit_policy;
5574 cmdline_fixed_string_t policy;
5577 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5578 __attribute__((unused)) struct cmdline *cl,
5579 __attribute__((unused)) void *data)
5581 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5582 portid_t port_id = res->port_id;
5585 if (!strcmp(res->policy, "l2")) {
5586 policy = BALANCE_XMIT_POLICY_LAYER2;
5587 } else if (!strcmp(res->policy, "l23")) {
5588 policy = BALANCE_XMIT_POLICY_LAYER23;
5589 } else if (!strcmp(res->policy, "l34")) {
5590 policy = BALANCE_XMIT_POLICY_LAYER34;
5592 printf("\t Invalid xmit policy selection");
5596 /* Set the bonding mode for the relevant port. */
5597 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5598 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5603 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5606 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5607 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5608 bonding, "bonding");
5609 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5610 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5611 balance_xmit_policy, "balance_xmit_policy");
5612 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5613 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5615 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5617 policy, "l2#l23#l34");
5619 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5620 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5621 .help_str = "set bonding balance_xmit_policy <port_id> "
5623 "Set the bonding balance_xmit_policy for port_id",
5626 (void *)&cmd_setbonding_balance_xmit_policy_set,
5627 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5628 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5629 (void *)&cmd_setbonding_balance_xmit_policy_port,
5630 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5635 /* *** SHOW NIC BONDING CONFIGURATION *** */
5636 struct cmd_show_bonding_config_result {
5637 cmdline_fixed_string_t show;
5638 cmdline_fixed_string_t bonding;
5639 cmdline_fixed_string_t config;
5643 static void cmd_show_bonding_config_parsed(void *parsed_result,
5644 __attribute__((unused)) struct cmdline *cl,
5645 __attribute__((unused)) void *data)
5647 struct cmd_show_bonding_config_result *res = parsed_result;
5648 int bonding_mode, agg_mode;
5649 portid_t slaves[RTE_MAX_ETHPORTS];
5650 int num_slaves, num_active_slaves;
5653 portid_t port_id = res->port_id;
5655 /* Display the bonding mode.*/
5656 bonding_mode = rte_eth_bond_mode_get(port_id);
5657 if (bonding_mode < 0) {
5658 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5661 printf("\tBonding mode: %d\n", bonding_mode);
5663 if (bonding_mode == BONDING_MODE_BALANCE) {
5664 int balance_xmit_policy;
5666 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5667 if (balance_xmit_policy < 0) {
5668 printf("\tFailed to get balance xmit policy for port = %d\n",
5672 printf("\tBalance Xmit Policy: ");
5674 switch (balance_xmit_policy) {
5675 case BALANCE_XMIT_POLICY_LAYER2:
5676 printf("BALANCE_XMIT_POLICY_LAYER2");
5678 case BALANCE_XMIT_POLICY_LAYER23:
5679 printf("BALANCE_XMIT_POLICY_LAYER23");
5681 case BALANCE_XMIT_POLICY_LAYER34:
5682 printf("BALANCE_XMIT_POLICY_LAYER34");
5689 if (bonding_mode == BONDING_MODE_8023AD) {
5690 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5691 printf("\tIEEE802.3AD Aggregator Mode: ");
5694 printf("bandwidth");
5706 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5708 if (num_slaves < 0) {
5709 printf("\tFailed to get slave list for port = %d\n", port_id);
5712 if (num_slaves > 0) {
5713 printf("\tSlaves (%d): [", num_slaves);
5714 for (i = 0; i < num_slaves - 1; i++)
5715 printf("%d ", slaves[i]);
5717 printf("%d]\n", slaves[num_slaves - 1]);
5719 printf("\tSlaves: []\n");
5723 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5726 if (num_active_slaves < 0) {
5727 printf("\tFailed to get active slave list for port = %d\n", port_id);
5730 if (num_active_slaves > 0) {
5731 printf("\tActive Slaves (%d): [", num_active_slaves);
5732 for (i = 0; i < num_active_slaves - 1; i++)
5733 printf("%d ", slaves[i]);
5735 printf("%d]\n", slaves[num_active_slaves - 1]);
5738 printf("\tActive Slaves: []\n");
5742 primary_id = rte_eth_bond_primary_get(port_id);
5743 if (primary_id < 0) {
5744 printf("\tFailed to get primary slave for port = %d\n", port_id);
5747 printf("\tPrimary: [%d]\n", primary_id);
5751 cmdline_parse_token_string_t cmd_showbonding_config_show =
5752 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5754 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5755 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5756 bonding, "bonding");
5757 cmdline_parse_token_string_t cmd_showbonding_config_config =
5758 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5760 cmdline_parse_token_num_t cmd_showbonding_config_port =
5761 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5764 cmdline_parse_inst_t cmd_show_bonding_config = {
5765 .f = cmd_show_bonding_config_parsed,
5766 .help_str = "show bonding config <port_id>: "
5767 "Show the bonding config for port_id",
5770 (void *)&cmd_showbonding_config_show,
5771 (void *)&cmd_showbonding_config_bonding,
5772 (void *)&cmd_showbonding_config_config,
5773 (void *)&cmd_showbonding_config_port,
5778 /* *** SET BONDING PRIMARY *** */
5779 struct cmd_set_bonding_primary_result {
5780 cmdline_fixed_string_t set;
5781 cmdline_fixed_string_t bonding;
5782 cmdline_fixed_string_t primary;
5787 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5788 __attribute__((unused)) struct cmdline *cl,
5789 __attribute__((unused)) void *data)
5791 struct cmd_set_bonding_primary_result *res = parsed_result;
5792 portid_t master_port_id = res->port_id;
5793 portid_t slave_port_id = res->slave_id;
5795 /* Set the primary slave for a bonded device. */
5796 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5797 printf("\t Failed to set primary slave for port = %d.\n",
5804 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5805 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5807 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5808 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5809 bonding, "bonding");
5810 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5811 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5812 primary, "primary");
5813 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5814 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5816 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5817 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5820 cmdline_parse_inst_t cmd_set_bonding_primary = {
5821 .f = cmd_set_bonding_primary_parsed,
5822 .help_str = "set bonding primary <slave_id> <port_id>: "
5823 "Set the primary slave for port_id",
5826 (void *)&cmd_setbonding_primary_set,
5827 (void *)&cmd_setbonding_primary_bonding,
5828 (void *)&cmd_setbonding_primary_primary,
5829 (void *)&cmd_setbonding_primary_slave,
5830 (void *)&cmd_setbonding_primary_port,
5835 /* *** ADD SLAVE *** */
5836 struct cmd_add_bonding_slave_result {
5837 cmdline_fixed_string_t add;
5838 cmdline_fixed_string_t bonding;
5839 cmdline_fixed_string_t slave;
5844 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5845 __attribute__((unused)) struct cmdline *cl,
5846 __attribute__((unused)) void *data)
5848 struct cmd_add_bonding_slave_result *res = parsed_result;
5849 portid_t master_port_id = res->port_id;
5850 portid_t slave_port_id = res->slave_id;
5852 /* add the slave for a bonded device. */
5853 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5854 printf("\t Failed to add slave %d to master port = %d.\n",
5855 slave_port_id, master_port_id);
5859 set_port_slave_flag(slave_port_id);
5862 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5863 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5865 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5866 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5867 bonding, "bonding");
5868 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5869 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5871 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5872 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5874 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5875 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5878 cmdline_parse_inst_t cmd_add_bonding_slave = {
5879 .f = cmd_add_bonding_slave_parsed,
5880 .help_str = "add bonding slave <slave_id> <port_id>: "
5881 "Add a slave device to a bonded device",
5884 (void *)&cmd_addbonding_slave_add,
5885 (void *)&cmd_addbonding_slave_bonding,
5886 (void *)&cmd_addbonding_slave_slave,
5887 (void *)&cmd_addbonding_slave_slaveid,
5888 (void *)&cmd_addbonding_slave_port,
5893 /* *** REMOVE SLAVE *** */
5894 struct cmd_remove_bonding_slave_result {
5895 cmdline_fixed_string_t remove;
5896 cmdline_fixed_string_t bonding;
5897 cmdline_fixed_string_t slave;
5902 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5903 __attribute__((unused)) struct cmdline *cl,
5904 __attribute__((unused)) void *data)
5906 struct cmd_remove_bonding_slave_result *res = parsed_result;
5907 portid_t master_port_id = res->port_id;
5908 portid_t slave_port_id = res->slave_id;
5910 /* remove the slave from a bonded device. */
5911 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5912 printf("\t Failed to remove slave %d from master port = %d.\n",
5913 slave_port_id, master_port_id);
5917 clear_port_slave_flag(slave_port_id);
5920 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5921 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5923 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5924 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5925 bonding, "bonding");
5926 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5927 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5929 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5930 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5932 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5933 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5936 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5937 .f = cmd_remove_bonding_slave_parsed,
5938 .help_str = "remove bonding slave <slave_id> <port_id>: "
5939 "Remove a slave device from a bonded device",
5942 (void *)&cmd_removebonding_slave_remove,
5943 (void *)&cmd_removebonding_slave_bonding,
5944 (void *)&cmd_removebonding_slave_slave,
5945 (void *)&cmd_removebonding_slave_slaveid,
5946 (void *)&cmd_removebonding_slave_port,
5951 /* *** CREATE BONDED DEVICE *** */
5952 struct cmd_create_bonded_device_result {
5953 cmdline_fixed_string_t create;
5954 cmdline_fixed_string_t bonded;
5955 cmdline_fixed_string_t device;
5960 static int bond_dev_num = 0;
5962 static void cmd_create_bonded_device_parsed(void *parsed_result,
5963 __attribute__((unused)) struct cmdline *cl,
5964 __attribute__((unused)) void *data)
5966 struct cmd_create_bonded_device_result *res = parsed_result;
5967 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5970 if (test_done == 0) {
5971 printf("Please stop forwarding first\n");
5975 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5978 /* Create a new bonded device. */
5979 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5981 printf("\t Failed to create bonded device.\n");
5984 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5987 /* Update number of ports */
5988 nb_ports = rte_eth_dev_count_avail();
5989 reconfig(port_id, res->socket);
5990 rte_eth_promiscuous_enable(port_id);
5991 ports[port_id].need_setup = 0;
5992 ports[port_id].port_status = RTE_PORT_STOPPED;
5997 cmdline_parse_token_string_t cmd_createbonded_device_create =
5998 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6000 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6001 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6003 cmdline_parse_token_string_t cmd_createbonded_device_device =
6004 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6006 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6007 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6009 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6010 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6013 cmdline_parse_inst_t cmd_create_bonded_device = {
6014 .f = cmd_create_bonded_device_parsed,
6015 .help_str = "create bonded device <mode> <socket>: "
6016 "Create a new bonded device with specific bonding mode and socket",
6019 (void *)&cmd_createbonded_device_create,
6020 (void *)&cmd_createbonded_device_bonded,
6021 (void *)&cmd_createbonded_device_device,
6022 (void *)&cmd_createbonded_device_mode,
6023 (void *)&cmd_createbonded_device_socket,
6028 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6029 struct cmd_set_bond_mac_addr_result {
6030 cmdline_fixed_string_t set;
6031 cmdline_fixed_string_t bonding;
6032 cmdline_fixed_string_t mac_addr;
6034 struct ether_addr address;
6037 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6038 __attribute__((unused)) struct cmdline *cl,
6039 __attribute__((unused)) void *data)
6041 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6044 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6047 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6049 /* check the return value and print it if is < 0 */
6051 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6054 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6055 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6056 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6057 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6059 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6060 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6062 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6063 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6065 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6066 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6068 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6069 .f = cmd_set_bond_mac_addr_parsed,
6071 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6073 (void *)&cmd_set_bond_mac_addr_set,
6074 (void *)&cmd_set_bond_mac_addr_bonding,
6075 (void *)&cmd_set_bond_mac_addr_mac,
6076 (void *)&cmd_set_bond_mac_addr_portnum,
6077 (void *)&cmd_set_bond_mac_addr_addr,
6083 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6084 struct cmd_set_bond_mon_period_result {
6085 cmdline_fixed_string_t set;
6086 cmdline_fixed_string_t bonding;
6087 cmdline_fixed_string_t mon_period;
6092 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6093 __attribute__((unused)) struct cmdline *cl,
6094 __attribute__((unused)) void *data)
6096 struct cmd_set_bond_mon_period_result *res = parsed_result;
6099 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6101 /* check the return value and print it if is < 0 */
6103 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6106 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6107 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6109 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6111 bonding, "bonding");
6112 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6113 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6114 mon_period, "mon_period");
6115 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6116 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6118 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6119 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6122 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6123 .f = cmd_set_bond_mon_period_parsed,
6125 .help_str = "set bonding mon_period <port_id> <period_ms>",
6127 (void *)&cmd_set_bond_mon_period_set,
6128 (void *)&cmd_set_bond_mon_period_bonding,
6129 (void *)&cmd_set_bond_mon_period_mon_period,
6130 (void *)&cmd_set_bond_mon_period_portnum,
6131 (void *)&cmd_set_bond_mon_period_period_ms,
6138 struct cmd_set_bonding_agg_mode_policy_result {
6139 cmdline_fixed_string_t set;
6140 cmdline_fixed_string_t bonding;
6141 cmdline_fixed_string_t agg_mode;
6143 cmdline_fixed_string_t policy;
6148 cmd_set_bonding_agg_mode(void *parsed_result,
6149 __attribute__((unused)) struct cmdline *cl,
6150 __attribute__((unused)) void *data)
6152 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6153 uint8_t policy = AGG_BANDWIDTH;
6155 if (!strcmp(res->policy, "bandwidth"))
6156 policy = AGG_BANDWIDTH;
6157 else if (!strcmp(res->policy, "stable"))
6158 policy = AGG_STABLE;
6159 else if (!strcmp(res->policy, "count"))
6162 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6166 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6167 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6169 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6170 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6171 bonding, "bonding");
6173 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6174 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6175 agg_mode, "agg_mode");
6177 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6178 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6181 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6182 TOKEN_STRING_INITIALIZER(
6183 struct cmd_set_bonding_balance_xmit_policy_result,
6184 policy, "stable#bandwidth#count");
6186 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6187 .f = cmd_set_bonding_agg_mode,
6189 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6191 (void *)&cmd_set_bonding_agg_mode_set,
6192 (void *)&cmd_set_bonding_agg_mode_bonding,
6193 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6194 (void *)&cmd_set_bonding_agg_mode_portnum,
6195 (void *)&cmd_set_bonding_agg_mode_policy_string,
6201 #endif /* RTE_LIBRTE_PMD_BOND */
6203 /* *** SET FORWARDING MODE *** */
6204 struct cmd_set_fwd_mode_result {
6205 cmdline_fixed_string_t set;
6206 cmdline_fixed_string_t fwd;
6207 cmdline_fixed_string_t mode;
6210 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6211 __attribute__((unused)) struct cmdline *cl,
6212 __attribute__((unused)) void *data)
6214 struct cmd_set_fwd_mode_result *res = parsed_result;
6217 set_pkt_forwarding_mode(res->mode);
6220 cmdline_parse_token_string_t cmd_setfwd_set =
6221 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6222 cmdline_parse_token_string_t cmd_setfwd_fwd =
6223 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6224 cmdline_parse_token_string_t cmd_setfwd_mode =
6225 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6226 "" /* defined at init */);
6228 cmdline_parse_inst_t cmd_set_fwd_mode = {
6229 .f = cmd_set_fwd_mode_parsed,
6231 .help_str = NULL, /* defined at init */
6233 (void *)&cmd_setfwd_set,
6234 (void *)&cmd_setfwd_fwd,
6235 (void *)&cmd_setfwd_mode,
6240 static void cmd_set_fwd_mode_init(void)
6243 static char token[128];
6244 static char help[256];
6245 cmdline_parse_token_string_t *token_struct;
6247 modes = list_pkt_forwarding_modes();
6248 snprintf(help, sizeof(help), "set fwd %s: "
6249 "Set packet forwarding mode", modes);
6250 cmd_set_fwd_mode.help_str = help;
6252 /* string token separator is # */
6253 for (c = token; *modes != '\0'; modes++)
6258 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6259 token_struct->string_data.str = token;
6262 /* *** SET RETRY FORWARDING MODE *** */
6263 struct cmd_set_fwd_retry_mode_result {
6264 cmdline_fixed_string_t set;
6265 cmdline_fixed_string_t fwd;
6266 cmdline_fixed_string_t mode;
6267 cmdline_fixed_string_t retry;
6270 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6271 __attribute__((unused)) struct cmdline *cl,
6272 __attribute__((unused)) void *data)
6274 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6277 set_pkt_forwarding_mode(res->mode);
6280 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6281 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6283 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6284 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6286 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6287 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6289 "" /* defined at init */);
6290 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6291 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6294 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6295 .f = cmd_set_fwd_retry_mode_parsed,
6297 .help_str = NULL, /* defined at init */
6299 (void *)&cmd_setfwd_retry_set,
6300 (void *)&cmd_setfwd_retry_fwd,
6301 (void *)&cmd_setfwd_retry_mode,
6302 (void *)&cmd_setfwd_retry_retry,
6307 static void cmd_set_fwd_retry_mode_init(void)
6310 static char token[128];
6311 static char help[256];
6312 cmdline_parse_token_string_t *token_struct;
6314 modes = list_pkt_forwarding_retry_modes();
6315 snprintf(help, sizeof(help), "set fwd %s retry: "
6316 "Set packet forwarding mode with retry", modes);
6317 cmd_set_fwd_retry_mode.help_str = help;
6319 /* string token separator is # */
6320 for (c = token; *modes != '\0'; modes++)
6325 token_struct = (cmdline_parse_token_string_t *)
6326 cmd_set_fwd_retry_mode.tokens[2];
6327 token_struct->string_data.str = token;
6330 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6331 struct cmd_set_burst_tx_retry_result {
6332 cmdline_fixed_string_t set;
6333 cmdline_fixed_string_t burst;
6334 cmdline_fixed_string_t tx;
6335 cmdline_fixed_string_t delay;
6337 cmdline_fixed_string_t retry;
6341 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6342 __attribute__((unused)) struct cmdline *cl,
6343 __attribute__((unused)) void *data)
6345 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6347 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6348 && !strcmp(res->tx, "tx")) {
6349 if (!strcmp(res->delay, "delay"))
6350 burst_tx_delay_time = res->time;
6351 if (!strcmp(res->retry, "retry"))
6352 burst_tx_retry_num = res->retry_num;
6357 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6358 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6359 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6360 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6362 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6363 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6364 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6365 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6366 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6367 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6368 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6369 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6370 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6371 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6373 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6374 .f = cmd_set_burst_tx_retry_parsed,
6375 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6377 (void *)&cmd_set_burst_tx_retry_set,
6378 (void *)&cmd_set_burst_tx_retry_burst,
6379 (void *)&cmd_set_burst_tx_retry_tx,
6380 (void *)&cmd_set_burst_tx_retry_delay,
6381 (void *)&cmd_set_burst_tx_retry_time,
6382 (void *)&cmd_set_burst_tx_retry_retry,
6383 (void *)&cmd_set_burst_tx_retry_retry_num,
6388 /* *** SET PROMISC MODE *** */
6389 struct cmd_set_promisc_mode_result {
6390 cmdline_fixed_string_t set;
6391 cmdline_fixed_string_t promisc;
6392 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6393 uint16_t port_num; /* valid if "allports" argument == 0 */
6394 cmdline_fixed_string_t mode;
6397 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6398 __attribute__((unused)) struct cmdline *cl,
6401 struct cmd_set_promisc_mode_result *res = parsed_result;
6405 if (!strcmp(res->mode, "on"))
6412 RTE_ETH_FOREACH_DEV(i) {
6414 rte_eth_promiscuous_enable(i);
6416 rte_eth_promiscuous_disable(i);
6421 rte_eth_promiscuous_enable(res->port_num);
6423 rte_eth_promiscuous_disable(res->port_num);
6427 cmdline_parse_token_string_t cmd_setpromisc_set =
6428 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6429 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6430 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6432 cmdline_parse_token_string_t cmd_setpromisc_portall =
6433 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6435 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6436 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6438 cmdline_parse_token_string_t cmd_setpromisc_mode =
6439 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6442 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6443 .f = cmd_set_promisc_mode_parsed,
6445 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6447 (void *)&cmd_setpromisc_set,
6448 (void *)&cmd_setpromisc_promisc,
6449 (void *)&cmd_setpromisc_portall,
6450 (void *)&cmd_setpromisc_mode,
6455 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6456 .f = cmd_set_promisc_mode_parsed,
6458 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6460 (void *)&cmd_setpromisc_set,
6461 (void *)&cmd_setpromisc_promisc,
6462 (void *)&cmd_setpromisc_portnum,
6463 (void *)&cmd_setpromisc_mode,
6468 /* *** SET ALLMULTI MODE *** */
6469 struct cmd_set_allmulti_mode_result {
6470 cmdline_fixed_string_t set;
6471 cmdline_fixed_string_t allmulti;
6472 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6473 uint16_t port_num; /* valid if "allports" argument == 0 */
6474 cmdline_fixed_string_t mode;
6477 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6478 __attribute__((unused)) struct cmdline *cl,
6481 struct cmd_set_allmulti_mode_result *res = parsed_result;
6485 if (!strcmp(res->mode, "on"))
6492 RTE_ETH_FOREACH_DEV(i) {
6494 rte_eth_allmulticast_enable(i);
6496 rte_eth_allmulticast_disable(i);
6501 rte_eth_allmulticast_enable(res->port_num);
6503 rte_eth_allmulticast_disable(res->port_num);
6507 cmdline_parse_token_string_t cmd_setallmulti_set =
6508 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6509 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6510 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6512 cmdline_parse_token_string_t cmd_setallmulti_portall =
6513 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6515 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6516 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6518 cmdline_parse_token_string_t cmd_setallmulti_mode =
6519 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6522 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6523 .f = cmd_set_allmulti_mode_parsed,
6525 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6527 (void *)&cmd_setallmulti_set,
6528 (void *)&cmd_setallmulti_allmulti,
6529 (void *)&cmd_setallmulti_portall,
6530 (void *)&cmd_setallmulti_mode,
6535 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6536 .f = cmd_set_allmulti_mode_parsed,
6538 .help_str = "set allmulti <port_id> on|off: "
6539 "Set allmulti mode on port_id",
6541 (void *)&cmd_setallmulti_set,
6542 (void *)&cmd_setallmulti_allmulti,
6543 (void *)&cmd_setallmulti_portnum,
6544 (void *)&cmd_setallmulti_mode,
6549 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6550 struct cmd_link_flow_ctrl_set_result {
6551 cmdline_fixed_string_t set;
6552 cmdline_fixed_string_t flow_ctrl;
6553 cmdline_fixed_string_t rx;
6554 cmdline_fixed_string_t rx_lfc_mode;
6555 cmdline_fixed_string_t tx;
6556 cmdline_fixed_string_t tx_lfc_mode;
6557 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6558 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6559 cmdline_fixed_string_t autoneg_str;
6560 cmdline_fixed_string_t autoneg;
6561 cmdline_fixed_string_t hw_str;
6562 uint32_t high_water;
6563 cmdline_fixed_string_t lw_str;
6565 cmdline_fixed_string_t pt_str;
6566 uint16_t pause_time;
6567 cmdline_fixed_string_t xon_str;
6572 cmdline_parse_token_string_t cmd_lfc_set_set =
6573 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6575 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6576 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6577 flow_ctrl, "flow_ctrl");
6578 cmdline_parse_token_string_t cmd_lfc_set_rx =
6579 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6581 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6582 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6583 rx_lfc_mode, "on#off");
6584 cmdline_parse_token_string_t cmd_lfc_set_tx =
6585 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6587 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6588 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6589 tx_lfc_mode, "on#off");
6590 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6591 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6592 hw_str, "high_water");
6593 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6594 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6595 high_water, UINT32);
6596 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6597 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6598 lw_str, "low_water");
6599 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6600 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6602 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6603 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6604 pt_str, "pause_time");
6605 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6606 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6607 pause_time, UINT16);
6608 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6609 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6610 xon_str, "send_xon");
6611 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6612 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6614 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6615 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6616 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6617 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6618 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6619 mac_ctrl_frame_fwd_mode, "on#off");
6620 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6621 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6622 autoneg_str, "autoneg");
6623 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6624 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6626 cmdline_parse_token_num_t cmd_lfc_set_portid =
6627 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6630 /* forward declaration */
6632 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6635 cmdline_parse_inst_t cmd_link_flow_control_set = {
6636 .f = cmd_link_flow_ctrl_set_parsed,
6638 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6639 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6640 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6642 (void *)&cmd_lfc_set_set,
6643 (void *)&cmd_lfc_set_flow_ctrl,
6644 (void *)&cmd_lfc_set_rx,
6645 (void *)&cmd_lfc_set_rx_mode,
6646 (void *)&cmd_lfc_set_tx,
6647 (void *)&cmd_lfc_set_tx_mode,
6648 (void *)&cmd_lfc_set_high_water,
6649 (void *)&cmd_lfc_set_low_water,
6650 (void *)&cmd_lfc_set_pause_time,
6651 (void *)&cmd_lfc_set_send_xon,
6652 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6653 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6654 (void *)&cmd_lfc_set_autoneg_str,
6655 (void *)&cmd_lfc_set_autoneg,
6656 (void *)&cmd_lfc_set_portid,
6661 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6662 .f = cmd_link_flow_ctrl_set_parsed,
6663 .data = (void *)&cmd_link_flow_control_set_rx,
6664 .help_str = "set flow_ctrl rx on|off <port_id>: "
6665 "Change rx flow control parameter",
6667 (void *)&cmd_lfc_set_set,
6668 (void *)&cmd_lfc_set_flow_ctrl,
6669 (void *)&cmd_lfc_set_rx,
6670 (void *)&cmd_lfc_set_rx_mode,
6671 (void *)&cmd_lfc_set_portid,
6676 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6677 .f = cmd_link_flow_ctrl_set_parsed,
6678 .data = (void *)&cmd_link_flow_control_set_tx,
6679 .help_str = "set flow_ctrl tx on|off <port_id>: "
6680 "Change tx flow control parameter",
6682 (void *)&cmd_lfc_set_set,
6683 (void *)&cmd_lfc_set_flow_ctrl,
6684 (void *)&cmd_lfc_set_tx,
6685 (void *)&cmd_lfc_set_tx_mode,
6686 (void *)&cmd_lfc_set_portid,
6691 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6692 .f = cmd_link_flow_ctrl_set_parsed,
6693 .data = (void *)&cmd_link_flow_control_set_hw,
6694 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6695 "Change high water flow control parameter",
6697 (void *)&cmd_lfc_set_set,
6698 (void *)&cmd_lfc_set_flow_ctrl,
6699 (void *)&cmd_lfc_set_high_water_str,
6700 (void *)&cmd_lfc_set_high_water,
6701 (void *)&cmd_lfc_set_portid,
6706 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6707 .f = cmd_link_flow_ctrl_set_parsed,
6708 .data = (void *)&cmd_link_flow_control_set_lw,
6709 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6710 "Change low water flow control parameter",
6712 (void *)&cmd_lfc_set_set,
6713 (void *)&cmd_lfc_set_flow_ctrl,
6714 (void *)&cmd_lfc_set_low_water_str,
6715 (void *)&cmd_lfc_set_low_water,
6716 (void *)&cmd_lfc_set_portid,
6721 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6722 .f = cmd_link_flow_ctrl_set_parsed,
6723 .data = (void *)&cmd_link_flow_control_set_pt,
6724 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6725 "Change pause time flow control parameter",
6727 (void *)&cmd_lfc_set_set,
6728 (void *)&cmd_lfc_set_flow_ctrl,
6729 (void *)&cmd_lfc_set_pause_time_str,
6730 (void *)&cmd_lfc_set_pause_time,
6731 (void *)&cmd_lfc_set_portid,
6736 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6737 .f = cmd_link_flow_ctrl_set_parsed,
6738 .data = (void *)&cmd_link_flow_control_set_xon,
6739 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6740 "Change send_xon flow control parameter",
6742 (void *)&cmd_lfc_set_set,
6743 (void *)&cmd_lfc_set_flow_ctrl,
6744 (void *)&cmd_lfc_set_send_xon_str,
6745 (void *)&cmd_lfc_set_send_xon,
6746 (void *)&cmd_lfc_set_portid,
6751 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6752 .f = cmd_link_flow_ctrl_set_parsed,
6753 .data = (void *)&cmd_link_flow_control_set_macfwd,
6754 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6755 "Change mac ctrl fwd flow control parameter",
6757 (void *)&cmd_lfc_set_set,
6758 (void *)&cmd_lfc_set_flow_ctrl,
6759 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6760 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6761 (void *)&cmd_lfc_set_portid,
6766 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6767 .f = cmd_link_flow_ctrl_set_parsed,
6768 .data = (void *)&cmd_link_flow_control_set_autoneg,
6769 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6770 "Change autoneg flow control parameter",
6772 (void *)&cmd_lfc_set_set,
6773 (void *)&cmd_lfc_set_flow_ctrl,
6774 (void *)&cmd_lfc_set_autoneg_str,
6775 (void *)&cmd_lfc_set_autoneg,
6776 (void *)&cmd_lfc_set_portid,
6782 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6783 __attribute__((unused)) struct cmdline *cl,
6786 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6787 cmdline_parse_inst_t *cmd = data;
6788 struct rte_eth_fc_conf fc_conf;
6794 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6795 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6796 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6797 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6799 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6800 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6803 /* Partial command line, retrieve current configuration */
6805 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6807 printf("cannot get current flow ctrl parameters, return"
6808 "code = %d\n", ret);
6812 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6813 (fc_conf.mode == RTE_FC_FULL))
6815 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6816 (fc_conf.mode == RTE_FC_FULL))
6820 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6821 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6823 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6824 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6826 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6828 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6829 fc_conf.high_water = res->high_water;
6831 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6832 fc_conf.low_water = res->low_water;
6834 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6835 fc_conf.pause_time = res->pause_time;
6837 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6838 fc_conf.send_xon = res->send_xon;
6840 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6841 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6842 fc_conf.mac_ctrl_frame_fwd = 1;
6844 fc_conf.mac_ctrl_frame_fwd = 0;
6847 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6848 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6850 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6852 printf("bad flow contrl parameter, return code = %d \n", ret);
6855 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6856 struct cmd_priority_flow_ctrl_set_result {
6857 cmdline_fixed_string_t set;
6858 cmdline_fixed_string_t pfc_ctrl;
6859 cmdline_fixed_string_t rx;
6860 cmdline_fixed_string_t rx_pfc_mode;
6861 cmdline_fixed_string_t tx;
6862 cmdline_fixed_string_t tx_pfc_mode;
6863 uint32_t high_water;
6865 uint16_t pause_time;
6871 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6872 __attribute__((unused)) struct cmdline *cl,
6873 __attribute__((unused)) void *data)
6875 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6876 struct rte_eth_pfc_conf pfc_conf;
6877 int rx_fc_enable, tx_fc_enable;
6881 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6882 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6883 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6884 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6886 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6887 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6890 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6891 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6892 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6893 pfc_conf.fc.high_water = res->high_water;
6894 pfc_conf.fc.low_water = res->low_water;
6895 pfc_conf.fc.pause_time = res->pause_time;
6896 pfc_conf.priority = res->priority;
6898 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6900 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6903 cmdline_parse_token_string_t cmd_pfc_set_set =
6904 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6906 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6907 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6908 pfc_ctrl, "pfc_ctrl");
6909 cmdline_parse_token_string_t cmd_pfc_set_rx =
6910 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6912 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6913 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6914 rx_pfc_mode, "on#off");
6915 cmdline_parse_token_string_t cmd_pfc_set_tx =
6916 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6918 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6919 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6920 tx_pfc_mode, "on#off");
6921 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6922 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6923 high_water, UINT32);
6924 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6925 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6927 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6928 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6929 pause_time, UINT16);
6930 cmdline_parse_token_num_t cmd_pfc_set_priority =
6931 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6933 cmdline_parse_token_num_t cmd_pfc_set_portid =
6934 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6937 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6938 .f = cmd_priority_flow_ctrl_set_parsed,
6940 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6941 "<pause_time> <priority> <port_id>: "
6942 "Configure the Ethernet priority flow control",
6944 (void *)&cmd_pfc_set_set,
6945 (void *)&cmd_pfc_set_flow_ctrl,
6946 (void *)&cmd_pfc_set_rx,
6947 (void *)&cmd_pfc_set_rx_mode,
6948 (void *)&cmd_pfc_set_tx,
6949 (void *)&cmd_pfc_set_tx_mode,
6950 (void *)&cmd_pfc_set_high_water,
6951 (void *)&cmd_pfc_set_low_water,
6952 (void *)&cmd_pfc_set_pause_time,
6953 (void *)&cmd_pfc_set_priority,
6954 (void *)&cmd_pfc_set_portid,
6959 /* *** RESET CONFIGURATION *** */
6960 struct cmd_reset_result {
6961 cmdline_fixed_string_t reset;
6962 cmdline_fixed_string_t def;
6965 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6967 __attribute__((unused)) void *data)
6969 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6970 set_def_fwd_config();
6973 cmdline_parse_token_string_t cmd_reset_set =
6974 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6975 cmdline_parse_token_string_t cmd_reset_def =
6976 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6979 cmdline_parse_inst_t cmd_reset = {
6980 .f = cmd_reset_parsed,
6982 .help_str = "set default: Reset default forwarding configuration",
6984 (void *)&cmd_reset_set,
6985 (void *)&cmd_reset_def,
6990 /* *** START FORWARDING *** */
6991 struct cmd_start_result {
6992 cmdline_fixed_string_t start;
6995 cmdline_parse_token_string_t cmd_start_start =
6996 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6998 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6999 __attribute__((unused)) struct cmdline *cl,
7000 __attribute__((unused)) void *data)
7002 start_packet_forwarding(0);
7005 cmdline_parse_inst_t cmd_start = {
7006 .f = cmd_start_parsed,
7008 .help_str = "start: Start packet forwarding",
7010 (void *)&cmd_start_start,
7015 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7016 struct cmd_start_tx_first_result {
7017 cmdline_fixed_string_t start;
7018 cmdline_fixed_string_t tx_first;
7022 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7023 __attribute__((unused)) struct cmdline *cl,
7024 __attribute__((unused)) void *data)
7026 start_packet_forwarding(1);
7029 cmdline_parse_token_string_t cmd_start_tx_first_start =
7030 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7032 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7033 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7034 tx_first, "tx_first");
7036 cmdline_parse_inst_t cmd_start_tx_first = {
7037 .f = cmd_start_tx_first_parsed,
7039 .help_str = "start tx_first: Start packet forwarding, "
7040 "after sending 1 burst of packets",
7042 (void *)&cmd_start_tx_first_start,
7043 (void *)&cmd_start_tx_first_tx_first,
7048 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7049 struct cmd_start_tx_first_n_result {
7050 cmdline_fixed_string_t start;
7051 cmdline_fixed_string_t tx_first;
7056 cmd_start_tx_first_n_parsed(void *parsed_result,
7057 __attribute__((unused)) struct cmdline *cl,
7058 __attribute__((unused)) void *data)
7060 struct cmd_start_tx_first_n_result *res = parsed_result;
7062 start_packet_forwarding(res->tx_num);
7065 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7066 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7068 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7069 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7070 tx_first, "tx_first");
7071 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7072 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7075 cmdline_parse_inst_t cmd_start_tx_first_n = {
7076 .f = cmd_start_tx_first_n_parsed,
7078 .help_str = "start tx_first <num>: "
7079 "packet forwarding, after sending <num> bursts of packets",
7081 (void *)&cmd_start_tx_first_n_start,
7082 (void *)&cmd_start_tx_first_n_tx_first,
7083 (void *)&cmd_start_tx_first_n_tx_num,
7088 /* *** SET LINK UP *** */
7089 struct cmd_set_link_up_result {
7090 cmdline_fixed_string_t set;
7091 cmdline_fixed_string_t link_up;
7092 cmdline_fixed_string_t port;
7096 cmdline_parse_token_string_t cmd_set_link_up_set =
7097 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7098 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7099 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7101 cmdline_parse_token_string_t cmd_set_link_up_port =
7102 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7103 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7104 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7106 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7107 __attribute__((unused)) struct cmdline *cl,
7108 __attribute__((unused)) void *data)
7110 struct cmd_set_link_up_result *res = parsed_result;
7111 dev_set_link_up(res->port_id);
7114 cmdline_parse_inst_t cmd_set_link_up = {
7115 .f = cmd_set_link_up_parsed,
7117 .help_str = "set link-up port <port id>",
7119 (void *)&cmd_set_link_up_set,
7120 (void *)&cmd_set_link_up_link_up,
7121 (void *)&cmd_set_link_up_port,
7122 (void *)&cmd_set_link_up_port_id,
7127 /* *** SET LINK DOWN *** */
7128 struct cmd_set_link_down_result {
7129 cmdline_fixed_string_t set;
7130 cmdline_fixed_string_t link_down;
7131 cmdline_fixed_string_t port;
7135 cmdline_parse_token_string_t cmd_set_link_down_set =
7136 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7137 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7138 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7140 cmdline_parse_token_string_t cmd_set_link_down_port =
7141 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7142 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7143 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7145 static void cmd_set_link_down_parsed(
7146 __attribute__((unused)) void *parsed_result,
7147 __attribute__((unused)) struct cmdline *cl,
7148 __attribute__((unused)) void *data)
7150 struct cmd_set_link_down_result *res = parsed_result;
7151 dev_set_link_down(res->port_id);
7154 cmdline_parse_inst_t cmd_set_link_down = {
7155 .f = cmd_set_link_down_parsed,
7157 .help_str = "set link-down port <port id>",
7159 (void *)&cmd_set_link_down_set,
7160 (void *)&cmd_set_link_down_link_down,
7161 (void *)&cmd_set_link_down_port,
7162 (void *)&cmd_set_link_down_port_id,
7167 /* *** SHOW CFG *** */
7168 struct cmd_showcfg_result {
7169 cmdline_fixed_string_t show;
7170 cmdline_fixed_string_t cfg;
7171 cmdline_fixed_string_t what;
7174 static void cmd_showcfg_parsed(void *parsed_result,
7175 __attribute__((unused)) struct cmdline *cl,
7176 __attribute__((unused)) void *data)
7178 struct cmd_showcfg_result *res = parsed_result;
7179 if (!strcmp(res->what, "rxtx"))
7180 rxtx_config_display();
7181 else if (!strcmp(res->what, "cores"))
7182 fwd_lcores_config_display();
7183 else if (!strcmp(res->what, "fwd"))
7184 pkt_fwd_config_display(&cur_fwd_config);
7185 else if (!strcmp(res->what, "txpkts"))
7186 show_tx_pkt_segments();
7189 cmdline_parse_token_string_t cmd_showcfg_show =
7190 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7191 cmdline_parse_token_string_t cmd_showcfg_port =
7192 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7193 cmdline_parse_token_string_t cmd_showcfg_what =
7194 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7195 "rxtx#cores#fwd#txpkts");
7197 cmdline_parse_inst_t cmd_showcfg = {
7198 .f = cmd_showcfg_parsed,
7200 .help_str = "show config rxtx|cores|fwd|txpkts",
7202 (void *)&cmd_showcfg_show,
7203 (void *)&cmd_showcfg_port,
7204 (void *)&cmd_showcfg_what,
7209 /* *** SHOW ALL PORT INFO *** */
7210 struct cmd_showportall_result {
7211 cmdline_fixed_string_t show;
7212 cmdline_fixed_string_t port;
7213 cmdline_fixed_string_t what;
7214 cmdline_fixed_string_t all;
7217 static void cmd_showportall_parsed(void *parsed_result,
7218 __attribute__((unused)) struct cmdline *cl,
7219 __attribute__((unused)) void *data)
7223 struct cmd_showportall_result *res = parsed_result;
7224 if (!strcmp(res->show, "clear")) {
7225 if (!strcmp(res->what, "stats"))
7226 RTE_ETH_FOREACH_DEV(i)
7228 else if (!strcmp(res->what, "xstats"))
7229 RTE_ETH_FOREACH_DEV(i)
7230 nic_xstats_clear(i);
7231 } else if (!strcmp(res->what, "info"))
7232 RTE_ETH_FOREACH_DEV(i)
7233 port_infos_display(i);
7234 else if (!strcmp(res->what, "summary")) {
7235 port_summary_header_display();
7236 RTE_ETH_FOREACH_DEV(i)
7237 port_summary_display(i);
7239 else if (!strcmp(res->what, "stats"))
7240 RTE_ETH_FOREACH_DEV(i)
7241 nic_stats_display(i);
7242 else if (!strcmp(res->what, "xstats"))
7243 RTE_ETH_FOREACH_DEV(i)
7244 nic_xstats_display(i);
7245 else if (!strcmp(res->what, "fdir"))
7246 RTE_ETH_FOREACH_DEV(i)
7248 else if (!strcmp(res->what, "stat_qmap"))
7249 RTE_ETH_FOREACH_DEV(i)
7250 nic_stats_mapping_display(i);
7251 else if (!strcmp(res->what, "dcb_tc"))
7252 RTE_ETH_FOREACH_DEV(i)
7253 port_dcb_info_display(i);
7254 else if (!strcmp(res->what, "cap"))
7255 RTE_ETH_FOREACH_DEV(i)
7256 port_offload_cap_display(i);
7259 cmdline_parse_token_string_t cmd_showportall_show =
7260 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7262 cmdline_parse_token_string_t cmd_showportall_port =
7263 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7264 cmdline_parse_token_string_t cmd_showportall_what =
7265 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7266 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7267 cmdline_parse_token_string_t cmd_showportall_all =
7268 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7269 cmdline_parse_inst_t cmd_showportall = {
7270 .f = cmd_showportall_parsed,
7272 .help_str = "show|clear port "
7273 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7275 (void *)&cmd_showportall_show,
7276 (void *)&cmd_showportall_port,
7277 (void *)&cmd_showportall_what,
7278 (void *)&cmd_showportall_all,
7283 /* *** SHOW PORT INFO *** */
7284 struct cmd_showport_result {
7285 cmdline_fixed_string_t show;
7286 cmdline_fixed_string_t port;
7287 cmdline_fixed_string_t what;
7291 static void cmd_showport_parsed(void *parsed_result,
7292 __attribute__((unused)) struct cmdline *cl,
7293 __attribute__((unused)) void *data)
7295 struct cmd_showport_result *res = parsed_result;
7296 if (!strcmp(res->show, "clear")) {
7297 if (!strcmp(res->what, "stats"))
7298 nic_stats_clear(res->portnum);
7299 else if (!strcmp(res->what, "xstats"))
7300 nic_xstats_clear(res->portnum);
7301 } else if (!strcmp(res->what, "info"))
7302 port_infos_display(res->portnum);
7303 else if (!strcmp(res->what, "summary")) {
7304 port_summary_header_display();
7305 port_summary_display(res->portnum);
7307 else if (!strcmp(res->what, "stats"))
7308 nic_stats_display(res->portnum);
7309 else if (!strcmp(res->what, "xstats"))
7310 nic_xstats_display(res->portnum);
7311 else if (!strcmp(res->what, "fdir"))
7312 fdir_get_infos(res->portnum);
7313 else if (!strcmp(res->what, "stat_qmap"))
7314 nic_stats_mapping_display(res->portnum);
7315 else if (!strcmp(res->what, "dcb_tc"))
7316 port_dcb_info_display(res->portnum);
7317 else if (!strcmp(res->what, "cap"))
7318 port_offload_cap_display(res->portnum);
7321 cmdline_parse_token_string_t cmd_showport_show =
7322 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7324 cmdline_parse_token_string_t cmd_showport_port =
7325 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7326 cmdline_parse_token_string_t cmd_showport_what =
7327 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7328 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7329 cmdline_parse_token_num_t cmd_showport_portnum =
7330 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7332 cmdline_parse_inst_t cmd_showport = {
7333 .f = cmd_showport_parsed,
7335 .help_str = "show|clear port "
7336 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7339 (void *)&cmd_showport_show,
7340 (void *)&cmd_showport_port,
7341 (void *)&cmd_showport_what,
7342 (void *)&cmd_showport_portnum,
7347 /* *** SHOW QUEUE INFO *** */
7348 struct cmd_showqueue_result {
7349 cmdline_fixed_string_t show;
7350 cmdline_fixed_string_t type;
7351 cmdline_fixed_string_t what;
7357 cmd_showqueue_parsed(void *parsed_result,
7358 __attribute__((unused)) struct cmdline *cl,
7359 __attribute__((unused)) void *data)
7361 struct cmd_showqueue_result *res = parsed_result;
7363 if (!strcmp(res->type, "rxq"))
7364 rx_queue_infos_display(res->portnum, res->queuenum);
7365 else if (!strcmp(res->type, "txq"))
7366 tx_queue_infos_display(res->portnum, res->queuenum);
7369 cmdline_parse_token_string_t cmd_showqueue_show =
7370 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7371 cmdline_parse_token_string_t cmd_showqueue_type =
7372 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7373 cmdline_parse_token_string_t cmd_showqueue_what =
7374 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7375 cmdline_parse_token_num_t cmd_showqueue_portnum =
7376 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7377 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7378 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7380 cmdline_parse_inst_t cmd_showqueue = {
7381 .f = cmd_showqueue_parsed,
7383 .help_str = "show rxq|txq info <port_id> <queue_id>",
7385 (void *)&cmd_showqueue_show,
7386 (void *)&cmd_showqueue_type,
7387 (void *)&cmd_showqueue_what,
7388 (void *)&cmd_showqueue_portnum,
7389 (void *)&cmd_showqueue_queuenum,
7394 /* show/clear fwd engine statistics */
7396 cmdline_fixed_string_t action;
7397 cmdline_fixed_string_t fwd;
7398 cmdline_fixed_string_t stats;
7399 cmdline_fixed_string_t all;
7402 cmdline_parse_token_string_t cmd_fwd_action =
7403 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7404 cmdline_parse_token_string_t cmd_fwd_fwd =
7405 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7406 cmdline_parse_token_string_t cmd_fwd_stats =
7407 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7408 cmdline_parse_token_string_t cmd_fwd_all =
7409 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7412 cmd_showfwdall_parsed(void *parsed_result,
7413 __rte_unused struct cmdline *cl,
7414 __rte_unused void *data)
7416 struct fwd_result *res = parsed_result;
7418 if (!strcmp(res->action, "show"))
7419 fwd_stats_display();
7424 static cmdline_parse_inst_t cmd_showfwdall = {
7425 .f = cmd_showfwdall_parsed,
7427 .help_str = "show|clear fwd stats all",
7429 (void *)&cmd_fwd_action,
7430 (void *)&cmd_fwd_fwd,
7431 (void *)&cmd_fwd_stats,
7432 (void *)&cmd_fwd_all,
7437 /* *** READ PORT REGISTER *** */
7438 struct cmd_read_reg_result {
7439 cmdline_fixed_string_t read;
7440 cmdline_fixed_string_t reg;
7446 cmd_read_reg_parsed(void *parsed_result,
7447 __attribute__((unused)) struct cmdline *cl,
7448 __attribute__((unused)) void *data)
7450 struct cmd_read_reg_result *res = parsed_result;
7451 port_reg_display(res->port_id, res->reg_off);
7454 cmdline_parse_token_string_t cmd_read_reg_read =
7455 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7456 cmdline_parse_token_string_t cmd_read_reg_reg =
7457 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7458 cmdline_parse_token_num_t cmd_read_reg_port_id =
7459 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7460 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7461 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7463 cmdline_parse_inst_t cmd_read_reg = {
7464 .f = cmd_read_reg_parsed,
7466 .help_str = "read reg <port_id> <reg_off>",
7468 (void *)&cmd_read_reg_read,
7469 (void *)&cmd_read_reg_reg,
7470 (void *)&cmd_read_reg_port_id,
7471 (void *)&cmd_read_reg_reg_off,
7476 /* *** READ PORT REGISTER BIT FIELD *** */
7477 struct cmd_read_reg_bit_field_result {
7478 cmdline_fixed_string_t read;
7479 cmdline_fixed_string_t regfield;
7487 cmd_read_reg_bit_field_parsed(void *parsed_result,
7488 __attribute__((unused)) struct cmdline *cl,
7489 __attribute__((unused)) void *data)
7491 struct cmd_read_reg_bit_field_result *res = parsed_result;
7492 port_reg_bit_field_display(res->port_id, res->reg_off,
7493 res->bit1_pos, res->bit2_pos);
7496 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7497 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7499 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7500 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7501 regfield, "regfield");
7502 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7503 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7505 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7506 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7508 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7509 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7511 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7512 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7515 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7516 .f = cmd_read_reg_bit_field_parsed,
7518 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7519 "Read register bit field between bit_x and bit_y included",
7521 (void *)&cmd_read_reg_bit_field_read,
7522 (void *)&cmd_read_reg_bit_field_regfield,
7523 (void *)&cmd_read_reg_bit_field_port_id,
7524 (void *)&cmd_read_reg_bit_field_reg_off,
7525 (void *)&cmd_read_reg_bit_field_bit1_pos,
7526 (void *)&cmd_read_reg_bit_field_bit2_pos,
7531 /* *** READ PORT REGISTER BIT *** */
7532 struct cmd_read_reg_bit_result {
7533 cmdline_fixed_string_t read;
7534 cmdline_fixed_string_t regbit;
7541 cmd_read_reg_bit_parsed(void *parsed_result,
7542 __attribute__((unused)) struct cmdline *cl,
7543 __attribute__((unused)) void *data)
7545 struct cmd_read_reg_bit_result *res = parsed_result;
7546 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7549 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7550 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7551 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7552 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7554 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7555 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7556 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7557 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7558 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7559 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7561 cmdline_parse_inst_t cmd_read_reg_bit = {
7562 .f = cmd_read_reg_bit_parsed,
7564 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7566 (void *)&cmd_read_reg_bit_read,
7567 (void *)&cmd_read_reg_bit_regbit,
7568 (void *)&cmd_read_reg_bit_port_id,
7569 (void *)&cmd_read_reg_bit_reg_off,
7570 (void *)&cmd_read_reg_bit_bit_pos,
7575 /* *** WRITE PORT REGISTER *** */
7576 struct cmd_write_reg_result {
7577 cmdline_fixed_string_t write;
7578 cmdline_fixed_string_t reg;
7585 cmd_write_reg_parsed(void *parsed_result,
7586 __attribute__((unused)) struct cmdline *cl,
7587 __attribute__((unused)) void *data)
7589 struct cmd_write_reg_result *res = parsed_result;
7590 port_reg_set(res->port_id, res->reg_off, res->value);
7593 cmdline_parse_token_string_t cmd_write_reg_write =
7594 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7595 cmdline_parse_token_string_t cmd_write_reg_reg =
7596 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7597 cmdline_parse_token_num_t cmd_write_reg_port_id =
7598 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7599 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7600 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7601 cmdline_parse_token_num_t cmd_write_reg_value =
7602 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7604 cmdline_parse_inst_t cmd_write_reg = {
7605 .f = cmd_write_reg_parsed,
7607 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7609 (void *)&cmd_write_reg_write,
7610 (void *)&cmd_write_reg_reg,
7611 (void *)&cmd_write_reg_port_id,
7612 (void *)&cmd_write_reg_reg_off,
7613 (void *)&cmd_write_reg_value,
7618 /* *** WRITE PORT REGISTER BIT FIELD *** */
7619 struct cmd_write_reg_bit_field_result {
7620 cmdline_fixed_string_t write;
7621 cmdline_fixed_string_t regfield;
7630 cmd_write_reg_bit_field_parsed(void *parsed_result,
7631 __attribute__((unused)) struct cmdline *cl,
7632 __attribute__((unused)) void *data)
7634 struct cmd_write_reg_bit_field_result *res = parsed_result;
7635 port_reg_bit_field_set(res->port_id, res->reg_off,
7636 res->bit1_pos, res->bit2_pos, res->value);
7639 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7640 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7642 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7643 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7644 regfield, "regfield");
7645 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7646 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7648 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7649 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7651 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7652 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7654 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7655 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7657 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7658 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7661 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7662 .f = cmd_write_reg_bit_field_parsed,
7664 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7666 "Set register bit field between bit_x and bit_y included",
7668 (void *)&cmd_write_reg_bit_field_write,
7669 (void *)&cmd_write_reg_bit_field_regfield,
7670 (void *)&cmd_write_reg_bit_field_port_id,
7671 (void *)&cmd_write_reg_bit_field_reg_off,
7672 (void *)&cmd_write_reg_bit_field_bit1_pos,
7673 (void *)&cmd_write_reg_bit_field_bit2_pos,
7674 (void *)&cmd_write_reg_bit_field_value,
7679 /* *** WRITE PORT REGISTER BIT *** */
7680 struct cmd_write_reg_bit_result {
7681 cmdline_fixed_string_t write;
7682 cmdline_fixed_string_t regbit;
7690 cmd_write_reg_bit_parsed(void *parsed_result,
7691 __attribute__((unused)) struct cmdline *cl,
7692 __attribute__((unused)) void *data)
7694 struct cmd_write_reg_bit_result *res = parsed_result;
7695 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7698 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7699 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7701 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7702 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7704 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7705 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7706 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7707 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7708 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7709 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7710 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7711 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7713 cmdline_parse_inst_t cmd_write_reg_bit = {
7714 .f = cmd_write_reg_bit_parsed,
7716 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7719 (void *)&cmd_write_reg_bit_write,
7720 (void *)&cmd_write_reg_bit_regbit,
7721 (void *)&cmd_write_reg_bit_port_id,
7722 (void *)&cmd_write_reg_bit_reg_off,
7723 (void *)&cmd_write_reg_bit_bit_pos,
7724 (void *)&cmd_write_reg_bit_value,
7729 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7730 struct cmd_read_rxd_txd_result {
7731 cmdline_fixed_string_t read;
7732 cmdline_fixed_string_t rxd_txd;
7739 cmd_read_rxd_txd_parsed(void *parsed_result,
7740 __attribute__((unused)) struct cmdline *cl,
7741 __attribute__((unused)) void *data)
7743 struct cmd_read_rxd_txd_result *res = parsed_result;
7745 if (!strcmp(res->rxd_txd, "rxd"))
7746 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7747 else if (!strcmp(res->rxd_txd, "txd"))
7748 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7751 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7752 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7753 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7754 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7756 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7757 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7758 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7759 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7760 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7761 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7763 cmdline_parse_inst_t cmd_read_rxd_txd = {
7764 .f = cmd_read_rxd_txd_parsed,
7766 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7768 (void *)&cmd_read_rxd_txd_read,
7769 (void *)&cmd_read_rxd_txd_rxd_txd,
7770 (void *)&cmd_read_rxd_txd_port_id,
7771 (void *)&cmd_read_rxd_txd_queue_id,
7772 (void *)&cmd_read_rxd_txd_desc_id,
7778 struct cmd_quit_result {
7779 cmdline_fixed_string_t quit;
7782 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7784 __attribute__((unused)) void *data)
7789 cmdline_parse_token_string_t cmd_quit_quit =
7790 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7792 cmdline_parse_inst_t cmd_quit = {
7793 .f = cmd_quit_parsed,
7795 .help_str = "quit: Exit application",
7797 (void *)&cmd_quit_quit,
7802 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7803 struct cmd_mac_addr_result {
7804 cmdline_fixed_string_t mac_addr_cmd;
7805 cmdline_fixed_string_t what;
7807 struct ether_addr address;
7810 static void cmd_mac_addr_parsed(void *parsed_result,
7811 __attribute__((unused)) struct cmdline *cl,
7812 __attribute__((unused)) void *data)
7814 struct cmd_mac_addr_result *res = parsed_result;
7817 if (strcmp(res->what, "add") == 0)
7818 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7819 else if (strcmp(res->what, "set") == 0)
7820 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7823 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7825 /* check the return value and print it if is < 0 */
7827 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7831 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7832 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7834 cmdline_parse_token_string_t cmd_mac_addr_what =
7835 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7837 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7838 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7840 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7841 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7843 cmdline_parse_inst_t cmd_mac_addr = {
7844 .f = cmd_mac_addr_parsed,
7846 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7847 "Add/Remove/Set MAC address on port_id",
7849 (void *)&cmd_mac_addr_cmd,
7850 (void *)&cmd_mac_addr_what,
7851 (void *)&cmd_mac_addr_portnum,
7852 (void *)&cmd_mac_addr_addr,
7857 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7858 struct cmd_eth_peer_result {
7859 cmdline_fixed_string_t set;
7860 cmdline_fixed_string_t eth_peer;
7862 cmdline_fixed_string_t peer_addr;
7865 static void cmd_set_eth_peer_parsed(void *parsed_result,
7866 __attribute__((unused)) struct cmdline *cl,
7867 __attribute__((unused)) void *data)
7869 struct cmd_eth_peer_result *res = parsed_result;
7871 if (test_done == 0) {
7872 printf("Please stop forwarding first\n");
7875 if (!strcmp(res->eth_peer, "eth-peer")) {
7876 set_fwd_eth_peer(res->port_id, res->peer_addr);
7880 cmdline_parse_token_string_t cmd_eth_peer_set =
7881 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7882 cmdline_parse_token_string_t cmd_eth_peer =
7883 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7884 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7885 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7886 cmdline_parse_token_string_t cmd_eth_peer_addr =
7887 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7889 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7890 .f = cmd_set_eth_peer_parsed,
7892 .help_str = "set eth-peer <port_id> <peer_mac>",
7894 (void *)&cmd_eth_peer_set,
7895 (void *)&cmd_eth_peer,
7896 (void *)&cmd_eth_peer_port_id,
7897 (void *)&cmd_eth_peer_addr,
7902 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7903 struct cmd_set_qmap_result {
7904 cmdline_fixed_string_t set;
7905 cmdline_fixed_string_t qmap;
7906 cmdline_fixed_string_t what;
7913 cmd_set_qmap_parsed(void *parsed_result,
7914 __attribute__((unused)) struct cmdline *cl,
7915 __attribute__((unused)) void *data)
7917 struct cmd_set_qmap_result *res = parsed_result;
7918 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7920 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7923 cmdline_parse_token_string_t cmd_setqmap_set =
7924 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7926 cmdline_parse_token_string_t cmd_setqmap_qmap =
7927 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7929 cmdline_parse_token_string_t cmd_setqmap_what =
7930 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7932 cmdline_parse_token_num_t cmd_setqmap_portid =
7933 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7935 cmdline_parse_token_num_t cmd_setqmap_queueid =
7936 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7938 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7939 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7942 cmdline_parse_inst_t cmd_set_qmap = {
7943 .f = cmd_set_qmap_parsed,
7945 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7946 "Set statistics mapping value on tx|rx queue_id of port_id",
7948 (void *)&cmd_setqmap_set,
7949 (void *)&cmd_setqmap_qmap,
7950 (void *)&cmd_setqmap_what,
7951 (void *)&cmd_setqmap_portid,
7952 (void *)&cmd_setqmap_queueid,
7953 (void *)&cmd_setqmap_mapvalue,
7958 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7959 struct cmd_set_xstats_hide_zero_result {
7960 cmdline_fixed_string_t keyword;
7961 cmdline_fixed_string_t name;
7962 cmdline_fixed_string_t on_off;
7966 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7967 __attribute__((unused)) struct cmdline *cl,
7968 __attribute__((unused)) void *data)
7970 struct cmd_set_xstats_hide_zero_result *res;
7971 uint16_t on_off = 0;
7973 res = parsed_result;
7974 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7975 set_xstats_hide_zero(on_off);
7978 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7979 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7981 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7982 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7983 name, "xstats-hide-zero");
7984 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7985 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7988 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7989 .f = cmd_set_xstats_hide_zero_parsed,
7991 .help_str = "set xstats-hide-zero on|off",
7993 (void *)&cmd_set_xstats_hide_zero_keyword,
7994 (void *)&cmd_set_xstats_hide_zero_name,
7995 (void *)&cmd_set_xstats_hide_zero_on_off,
8000 /* *** CONFIGURE UNICAST HASH TABLE *** */
8001 struct cmd_set_uc_hash_table {
8002 cmdline_fixed_string_t set;
8003 cmdline_fixed_string_t port;
8005 cmdline_fixed_string_t what;
8006 struct ether_addr address;
8007 cmdline_fixed_string_t mode;
8011 cmd_set_uc_hash_parsed(void *parsed_result,
8012 __attribute__((unused)) struct cmdline *cl,
8013 __attribute__((unused)) void *data)
8016 struct cmd_set_uc_hash_table *res = parsed_result;
8018 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8020 if (strcmp(res->what, "uta") == 0)
8021 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8022 &res->address,(uint8_t)is_on);
8024 printf("bad unicast hash table parameter, return code = %d \n", ret);
8028 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8029 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8031 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8032 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8034 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8035 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8037 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8038 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8040 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8041 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8043 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8044 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8047 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8048 .f = cmd_set_uc_hash_parsed,
8050 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8052 (void *)&cmd_set_uc_hash_set,
8053 (void *)&cmd_set_uc_hash_port,
8054 (void *)&cmd_set_uc_hash_portid,
8055 (void *)&cmd_set_uc_hash_what,
8056 (void *)&cmd_set_uc_hash_mac,
8057 (void *)&cmd_set_uc_hash_mode,
8062 struct cmd_set_uc_all_hash_table {
8063 cmdline_fixed_string_t set;
8064 cmdline_fixed_string_t port;
8066 cmdline_fixed_string_t what;
8067 cmdline_fixed_string_t value;
8068 cmdline_fixed_string_t mode;
8072 cmd_set_uc_all_hash_parsed(void *parsed_result,
8073 __attribute__((unused)) struct cmdline *cl,
8074 __attribute__((unused)) void *data)
8077 struct cmd_set_uc_all_hash_table *res = parsed_result;
8079 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8081 if ((strcmp(res->what, "uta") == 0) &&
8082 (strcmp(res->value, "all") == 0))
8083 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8085 printf("bad unicast hash table parameter,"
8086 "return code = %d \n", ret);
8089 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8090 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8092 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8093 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8095 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8096 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8098 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8099 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8101 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8102 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8104 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8105 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8108 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8109 .f = cmd_set_uc_all_hash_parsed,
8111 .help_str = "set port <port_id> uta all on|off",
8113 (void *)&cmd_set_uc_all_hash_set,
8114 (void *)&cmd_set_uc_all_hash_port,
8115 (void *)&cmd_set_uc_all_hash_portid,
8116 (void *)&cmd_set_uc_all_hash_what,
8117 (void *)&cmd_set_uc_all_hash_value,
8118 (void *)&cmd_set_uc_all_hash_mode,
8123 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8124 struct cmd_set_vf_macvlan_filter {
8125 cmdline_fixed_string_t set;
8126 cmdline_fixed_string_t port;
8128 cmdline_fixed_string_t vf;
8130 struct ether_addr address;
8131 cmdline_fixed_string_t filter_type;
8132 cmdline_fixed_string_t mode;
8136 cmd_set_vf_macvlan_parsed(void *parsed_result,
8137 __attribute__((unused)) struct cmdline *cl,
8138 __attribute__((unused)) void *data)
8141 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8142 struct rte_eth_mac_filter filter;
8144 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8146 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
8148 /* set VF MAC filter */
8152 filter.dst_id = res->vf_id;
8154 if (!strcmp(res->filter_type, "exact-mac"))
8155 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8156 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8157 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8158 else if (!strcmp(res->filter_type, "hashmac"))
8159 filter.filter_type = RTE_MAC_HASH_MATCH;
8160 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8161 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8163 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8166 ret = rte_eth_dev_filter_ctrl(res->port_id,
8167 RTE_ETH_FILTER_MACVLAN,
8171 ret = rte_eth_dev_filter_ctrl(res->port_id,
8172 RTE_ETH_FILTER_MACVLAN,
8173 RTE_ETH_FILTER_DELETE,
8177 printf("bad set MAC hash parameter, return code = %d\n", ret);
8181 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8182 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8184 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8185 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8187 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8188 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8190 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8191 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8193 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8194 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8196 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8197 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8199 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8200 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8201 filter_type, "exact-mac#exact-mac-vlan"
8202 "#hashmac#hashmac-vlan");
8203 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8204 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8207 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8208 .f = cmd_set_vf_macvlan_parsed,
8210 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8211 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8212 "Exact match rule: exact match of MAC or MAC and VLAN; "
8213 "hash match rule: hash match of MAC and exact match of VLAN",
8215 (void *)&cmd_set_vf_macvlan_set,
8216 (void *)&cmd_set_vf_macvlan_port,
8217 (void *)&cmd_set_vf_macvlan_portid,
8218 (void *)&cmd_set_vf_macvlan_vf,
8219 (void *)&cmd_set_vf_macvlan_vf_id,
8220 (void *)&cmd_set_vf_macvlan_mac,
8221 (void *)&cmd_set_vf_macvlan_filter_type,
8222 (void *)&cmd_set_vf_macvlan_mode,
8227 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8228 struct cmd_set_vf_traffic {
8229 cmdline_fixed_string_t set;
8230 cmdline_fixed_string_t port;
8232 cmdline_fixed_string_t vf;
8234 cmdline_fixed_string_t what;
8235 cmdline_fixed_string_t mode;
8239 cmd_set_vf_traffic_parsed(void *parsed_result,
8240 __attribute__((unused)) struct cmdline *cl,
8241 __attribute__((unused)) void *data)
8243 struct cmd_set_vf_traffic *res = parsed_result;
8244 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8245 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8247 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8250 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8251 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8253 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8254 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8256 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8257 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8259 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8260 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8262 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8263 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8265 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8266 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8268 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8269 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8272 cmdline_parse_inst_t cmd_set_vf_traffic = {
8273 .f = cmd_set_vf_traffic_parsed,
8275 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8277 (void *)&cmd_setvf_traffic_set,
8278 (void *)&cmd_setvf_traffic_port,
8279 (void *)&cmd_setvf_traffic_portid,
8280 (void *)&cmd_setvf_traffic_vf,
8281 (void *)&cmd_setvf_traffic_vfid,
8282 (void *)&cmd_setvf_traffic_what,
8283 (void *)&cmd_setvf_traffic_mode,
8288 /* *** CONFIGURE VF RECEIVE MODE *** */
8289 struct cmd_set_vf_rxmode {
8290 cmdline_fixed_string_t set;
8291 cmdline_fixed_string_t port;
8293 cmdline_fixed_string_t vf;
8295 cmdline_fixed_string_t what;
8296 cmdline_fixed_string_t mode;
8297 cmdline_fixed_string_t on;
8301 cmd_set_vf_rxmode_parsed(void *parsed_result,
8302 __attribute__((unused)) struct cmdline *cl,
8303 __attribute__((unused)) void *data)
8306 uint16_t rx_mode = 0;
8307 struct cmd_set_vf_rxmode *res = parsed_result;
8309 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8310 if (!strcmp(res->what,"rxmode")) {
8311 if (!strcmp(res->mode, "AUPE"))
8312 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8313 else if (!strcmp(res->mode, "ROPE"))
8314 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8315 else if (!strcmp(res->mode, "BAM"))
8316 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8317 else if (!strncmp(res->mode, "MPE",3))
8318 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8321 RTE_SET_USED(is_on);
8323 #ifdef RTE_LIBRTE_IXGBE_PMD
8324 if (ret == -ENOTSUP)
8325 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8326 rx_mode, (uint8_t)is_on);
8328 #ifdef RTE_LIBRTE_BNXT_PMD
8329 if (ret == -ENOTSUP)
8330 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8331 rx_mode, (uint8_t)is_on);
8334 printf("bad VF receive mode parameter, return code = %d \n",
8338 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8339 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8341 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8342 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8344 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8345 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8347 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8348 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8350 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8351 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8353 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8354 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8356 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8357 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8358 mode, "AUPE#ROPE#BAM#MPE");
8359 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8360 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8363 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8364 .f = cmd_set_vf_rxmode_parsed,
8366 .help_str = "set port <port_id> vf <vf_id> rxmode "
8367 "AUPE|ROPE|BAM|MPE on|off",
8369 (void *)&cmd_set_vf_rxmode_set,
8370 (void *)&cmd_set_vf_rxmode_port,
8371 (void *)&cmd_set_vf_rxmode_portid,
8372 (void *)&cmd_set_vf_rxmode_vf,
8373 (void *)&cmd_set_vf_rxmode_vfid,
8374 (void *)&cmd_set_vf_rxmode_what,
8375 (void *)&cmd_set_vf_rxmode_mode,
8376 (void *)&cmd_set_vf_rxmode_on,
8381 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8382 struct cmd_vf_mac_addr_result {
8383 cmdline_fixed_string_t mac_addr_cmd;
8384 cmdline_fixed_string_t what;
8385 cmdline_fixed_string_t port;
8387 cmdline_fixed_string_t vf;
8389 struct ether_addr address;
8392 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8393 __attribute__((unused)) struct cmdline *cl,
8394 __attribute__((unused)) void *data)
8396 struct cmd_vf_mac_addr_result *res = parsed_result;
8399 if (strcmp(res->what, "add") != 0)
8402 #ifdef RTE_LIBRTE_I40E_PMD
8403 if (ret == -ENOTSUP)
8404 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8407 #ifdef RTE_LIBRTE_BNXT_PMD
8408 if (ret == -ENOTSUP)
8409 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8414 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8418 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8419 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8420 mac_addr_cmd,"mac_addr");
8421 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8422 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8424 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8425 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8427 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8428 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8430 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8431 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8433 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8434 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8436 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8437 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8440 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8441 .f = cmd_vf_mac_addr_parsed,
8443 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8444 "Add MAC address filtering for a VF on port_id",
8446 (void *)&cmd_vf_mac_addr_cmd,
8447 (void *)&cmd_vf_mac_addr_what,
8448 (void *)&cmd_vf_mac_addr_port,
8449 (void *)&cmd_vf_mac_addr_portnum,
8450 (void *)&cmd_vf_mac_addr_vf,
8451 (void *)&cmd_vf_mac_addr_vfnum,
8452 (void *)&cmd_vf_mac_addr_addr,
8457 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8458 struct cmd_vf_rx_vlan_filter {
8459 cmdline_fixed_string_t rx_vlan;
8460 cmdline_fixed_string_t what;
8462 cmdline_fixed_string_t port;
8464 cmdline_fixed_string_t vf;
8469 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8470 __attribute__((unused)) struct cmdline *cl,
8471 __attribute__((unused)) void *data)
8473 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8476 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8478 #ifdef RTE_LIBRTE_IXGBE_PMD
8479 if (ret == -ENOTSUP)
8480 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8481 res->vlan_id, res->vf_mask, is_add);
8483 #ifdef RTE_LIBRTE_I40E_PMD
8484 if (ret == -ENOTSUP)
8485 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8486 res->vlan_id, res->vf_mask, is_add);
8488 #ifdef RTE_LIBRTE_BNXT_PMD
8489 if (ret == -ENOTSUP)
8490 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8491 res->vlan_id, res->vf_mask, is_add);
8498 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8499 res->vlan_id, res->vf_mask);
8502 printf("invalid port_id %d\n", res->port_id);
8505 printf("function not implemented or supported\n");
8508 printf("programming error: (%s)\n", strerror(-ret));
8512 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8513 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8514 rx_vlan, "rx_vlan");
8515 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8516 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8518 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8519 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8521 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8522 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8524 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8525 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8527 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8528 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8530 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8531 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8534 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8535 .f = cmd_vf_rx_vlan_filter_parsed,
8537 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8538 "(vf_mask = hexadecimal VF mask)",
8540 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8541 (void *)&cmd_vf_rx_vlan_filter_what,
8542 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8543 (void *)&cmd_vf_rx_vlan_filter_port,
8544 (void *)&cmd_vf_rx_vlan_filter_portid,
8545 (void *)&cmd_vf_rx_vlan_filter_vf,
8546 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8551 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8552 struct cmd_queue_rate_limit_result {
8553 cmdline_fixed_string_t set;
8554 cmdline_fixed_string_t port;
8556 cmdline_fixed_string_t queue;
8558 cmdline_fixed_string_t rate;
8562 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8563 __attribute__((unused)) struct cmdline *cl,
8564 __attribute__((unused)) void *data)
8566 struct cmd_queue_rate_limit_result *res = parsed_result;
8569 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8570 && (strcmp(res->queue, "queue") == 0)
8571 && (strcmp(res->rate, "rate") == 0))
8572 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8575 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8579 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8580 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8582 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8583 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8585 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8586 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8588 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8589 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8591 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8592 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8594 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8595 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8597 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8598 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8601 cmdline_parse_inst_t cmd_queue_rate_limit = {
8602 .f = cmd_queue_rate_limit_parsed,
8604 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8605 "Set rate limit for a queue on port_id",
8607 (void *)&cmd_queue_rate_limit_set,
8608 (void *)&cmd_queue_rate_limit_port,
8609 (void *)&cmd_queue_rate_limit_portnum,
8610 (void *)&cmd_queue_rate_limit_queue,
8611 (void *)&cmd_queue_rate_limit_queuenum,
8612 (void *)&cmd_queue_rate_limit_rate,
8613 (void *)&cmd_queue_rate_limit_ratenum,
8618 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8619 struct cmd_vf_rate_limit_result {
8620 cmdline_fixed_string_t set;
8621 cmdline_fixed_string_t port;
8623 cmdline_fixed_string_t vf;
8625 cmdline_fixed_string_t rate;
8627 cmdline_fixed_string_t q_msk;
8631 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8632 __attribute__((unused)) struct cmdline *cl,
8633 __attribute__((unused)) void *data)
8635 struct cmd_vf_rate_limit_result *res = parsed_result;
8638 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8639 && (strcmp(res->vf, "vf") == 0)
8640 && (strcmp(res->rate, "rate") == 0)
8641 && (strcmp(res->q_msk, "queue_mask") == 0))
8642 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8643 res->rate_num, res->q_msk_val);
8645 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8649 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8650 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8652 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8653 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8655 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8656 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8658 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8659 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8661 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8662 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8664 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8665 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8667 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8668 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8670 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8671 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8672 q_msk, "queue_mask");
8673 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8674 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8677 cmdline_parse_inst_t cmd_vf_rate_limit = {
8678 .f = cmd_vf_rate_limit_parsed,
8680 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8681 "queue_mask <queue_mask_value>: "
8682 "Set rate limit for queues of VF on port_id",
8684 (void *)&cmd_vf_rate_limit_set,
8685 (void *)&cmd_vf_rate_limit_port,
8686 (void *)&cmd_vf_rate_limit_portnum,
8687 (void *)&cmd_vf_rate_limit_vf,
8688 (void *)&cmd_vf_rate_limit_vfnum,
8689 (void *)&cmd_vf_rate_limit_rate,
8690 (void *)&cmd_vf_rate_limit_ratenum,
8691 (void *)&cmd_vf_rate_limit_q_msk,
8692 (void *)&cmd_vf_rate_limit_q_msk_val,
8697 /* *** ADD TUNNEL FILTER OF A PORT *** */
8698 struct cmd_tunnel_filter_result {
8699 cmdline_fixed_string_t cmd;
8700 cmdline_fixed_string_t what;
8702 struct ether_addr outer_mac;
8703 struct ether_addr inner_mac;
8704 cmdline_ipaddr_t ip_value;
8705 uint16_t inner_vlan;
8706 cmdline_fixed_string_t tunnel_type;
8707 cmdline_fixed_string_t filter_type;
8713 cmd_tunnel_filter_parsed(void *parsed_result,
8714 __attribute__((unused)) struct cmdline *cl,
8715 __attribute__((unused)) void *data)
8717 struct cmd_tunnel_filter_result *res = parsed_result;
8718 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8721 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8723 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8724 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8725 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8727 if (res->ip_value.family == AF_INET) {
8728 tunnel_filter_conf.ip_addr.ipv4_addr =
8729 res->ip_value.addr.ipv4.s_addr;
8730 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8732 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8733 &(res->ip_value.addr.ipv6),
8734 sizeof(struct in6_addr));
8735 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8738 if (!strcmp(res->filter_type, "imac-ivlan"))
8739 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8740 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8741 tunnel_filter_conf.filter_type =
8742 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8743 else if (!strcmp(res->filter_type, "imac-tenid"))
8744 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8745 else if (!strcmp(res->filter_type, "imac"))
8746 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8747 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8748 tunnel_filter_conf.filter_type =
8749 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8750 else if (!strcmp(res->filter_type, "oip"))
8751 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8752 else if (!strcmp(res->filter_type, "iip"))
8753 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8755 printf("The filter type is not supported");
8759 if (!strcmp(res->tunnel_type, "vxlan"))
8760 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8761 else if (!strcmp(res->tunnel_type, "nvgre"))
8762 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8763 else if (!strcmp(res->tunnel_type, "ipingre"))
8764 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8766 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8770 tunnel_filter_conf.tenant_id = res->tenant_id;
8771 tunnel_filter_conf.queue_id = res->queue_num;
8772 if (!strcmp(res->what, "add"))
8773 ret = rte_eth_dev_filter_ctrl(res->port_id,
8774 RTE_ETH_FILTER_TUNNEL,
8776 &tunnel_filter_conf);
8778 ret = rte_eth_dev_filter_ctrl(res->port_id,
8779 RTE_ETH_FILTER_TUNNEL,
8780 RTE_ETH_FILTER_DELETE,
8781 &tunnel_filter_conf);
8783 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8787 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8788 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8789 cmd, "tunnel_filter");
8790 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8791 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8793 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8794 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8796 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8797 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8799 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8800 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8802 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8803 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8804 inner_vlan, UINT16);
8805 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8806 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8808 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8809 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8810 tunnel_type, "vxlan#nvgre#ipingre");
8812 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8813 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8814 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8815 "imac#omac-imac-tenid");
8816 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8817 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8819 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8820 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8823 cmdline_parse_inst_t cmd_tunnel_filter = {
8824 .f = cmd_tunnel_filter_parsed,
8826 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8827 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8828 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8829 "<queue_id>: Add/Rm tunnel filter of a port",
8831 (void *)&cmd_tunnel_filter_cmd,
8832 (void *)&cmd_tunnel_filter_what,
8833 (void *)&cmd_tunnel_filter_port_id,
8834 (void *)&cmd_tunnel_filter_outer_mac,
8835 (void *)&cmd_tunnel_filter_inner_mac,
8836 (void *)&cmd_tunnel_filter_ip_value,
8837 (void *)&cmd_tunnel_filter_innner_vlan,
8838 (void *)&cmd_tunnel_filter_tunnel_type,
8839 (void *)&cmd_tunnel_filter_filter_type,
8840 (void *)&cmd_tunnel_filter_tenant_id,
8841 (void *)&cmd_tunnel_filter_queue_num,
8846 /* *** CONFIGURE TUNNEL UDP PORT *** */
8847 struct cmd_tunnel_udp_config {
8848 cmdline_fixed_string_t cmd;
8849 cmdline_fixed_string_t what;
8855 cmd_tunnel_udp_config_parsed(void *parsed_result,
8856 __attribute__((unused)) struct cmdline *cl,
8857 __attribute__((unused)) void *data)
8859 struct cmd_tunnel_udp_config *res = parsed_result;
8860 struct rte_eth_udp_tunnel tunnel_udp;
8863 tunnel_udp.udp_port = res->udp_port;
8865 if (!strcmp(res->cmd, "rx_vxlan_port"))
8866 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8868 if (!strcmp(res->what, "add"))
8869 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8872 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8876 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8879 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8880 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8881 cmd, "rx_vxlan_port");
8882 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8883 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8885 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8886 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8888 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8889 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8892 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8893 .f = cmd_tunnel_udp_config_parsed,
8895 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8896 "Add/Remove a tunneling UDP port filter",
8898 (void *)&cmd_tunnel_udp_config_cmd,
8899 (void *)&cmd_tunnel_udp_config_what,
8900 (void *)&cmd_tunnel_udp_config_udp_port,
8901 (void *)&cmd_tunnel_udp_config_port_id,
8906 struct cmd_config_tunnel_udp_port {
8907 cmdline_fixed_string_t port;
8908 cmdline_fixed_string_t config;
8910 cmdline_fixed_string_t udp_tunnel_port;
8911 cmdline_fixed_string_t action;
8912 cmdline_fixed_string_t tunnel_type;
8917 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8918 __attribute__((unused)) struct cmdline *cl,
8919 __attribute__((unused)) void *data)
8921 struct cmd_config_tunnel_udp_port *res = parsed_result;
8922 struct rte_eth_udp_tunnel tunnel_udp;
8925 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8928 tunnel_udp.udp_port = res->udp_port;
8930 if (!strcmp(res->tunnel_type, "vxlan")) {
8931 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8932 } else if (!strcmp(res->tunnel_type, "geneve")) {
8933 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8935 printf("Invalid tunnel type\n");
8939 if (!strcmp(res->action, "add"))
8940 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8943 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8947 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8950 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8951 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8953 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8954 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8956 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8957 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8959 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8960 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8963 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8964 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8966 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8967 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8969 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8970 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8973 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8974 .f = cmd_cfg_tunnel_udp_port_parsed,
8976 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8978 (void *)&cmd_config_tunnel_udp_port_port,
8979 (void *)&cmd_config_tunnel_udp_port_config,
8980 (void *)&cmd_config_tunnel_udp_port_port_id,
8981 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8982 (void *)&cmd_config_tunnel_udp_port_action,
8983 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8984 (void *)&cmd_config_tunnel_udp_port_value,
8989 /* *** GLOBAL CONFIG *** */
8990 struct cmd_global_config_result {
8991 cmdline_fixed_string_t cmd;
8993 cmdline_fixed_string_t cfg_type;
8998 cmd_global_config_parsed(void *parsed_result,
8999 __attribute__((unused)) struct cmdline *cl,
9000 __attribute__((unused)) void *data)
9002 struct cmd_global_config_result *res = parsed_result;
9003 struct rte_eth_global_cfg conf;
9006 memset(&conf, 0, sizeof(conf));
9007 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9008 conf.cfg.gre_key_len = res->len;
9009 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9010 RTE_ETH_FILTER_SET, &conf);
9012 printf("Global config error\n");
9015 cmdline_parse_token_string_t cmd_global_config_cmd =
9016 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9018 cmdline_parse_token_num_t cmd_global_config_port_id =
9019 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9021 cmdline_parse_token_string_t cmd_global_config_type =
9022 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9023 cfg_type, "gre-key-len");
9024 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9025 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9028 cmdline_parse_inst_t cmd_global_config = {
9029 .f = cmd_global_config_parsed,
9030 .data = (void *)NULL,
9031 .help_str = "global_config <port_id> gre-key-len <key_len>",
9033 (void *)&cmd_global_config_cmd,
9034 (void *)&cmd_global_config_port_id,
9035 (void *)&cmd_global_config_type,
9036 (void *)&cmd_global_config_gre_key_len,
9041 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9042 struct cmd_set_mirror_mask_result {
9043 cmdline_fixed_string_t set;
9044 cmdline_fixed_string_t port;
9046 cmdline_fixed_string_t mirror;
9048 cmdline_fixed_string_t what;
9049 cmdline_fixed_string_t value;
9050 cmdline_fixed_string_t dstpool;
9052 cmdline_fixed_string_t on;
9055 cmdline_parse_token_string_t cmd_mirror_mask_set =
9056 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9058 cmdline_parse_token_string_t cmd_mirror_mask_port =
9059 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9061 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9062 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9064 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9065 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9066 mirror, "mirror-rule");
9067 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9068 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9070 cmdline_parse_token_string_t cmd_mirror_mask_what =
9071 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9072 what, "pool-mirror-up#pool-mirror-down"
9074 cmdline_parse_token_string_t cmd_mirror_mask_value =
9075 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9077 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9078 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9079 dstpool, "dst-pool");
9080 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9081 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9083 cmdline_parse_token_string_t cmd_mirror_mask_on =
9084 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9088 cmd_set_mirror_mask_parsed(void *parsed_result,
9089 __attribute__((unused)) struct cmdline *cl,
9090 __attribute__((unused)) void *data)
9093 struct cmd_set_mirror_mask_result *res = parsed_result;
9094 struct rte_eth_mirror_conf mr_conf;
9096 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9098 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9100 mr_conf.dst_pool = res->dstpool_id;
9102 if (!strcmp(res->what, "pool-mirror-up")) {
9103 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9104 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9105 } else if (!strcmp(res->what, "pool-mirror-down")) {
9106 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9107 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9108 } else if (!strcmp(res->what, "vlan-mirror")) {
9109 mr_conf.rule_type = ETH_MIRROR_VLAN;
9110 nb_item = parse_item_list(res->value, "vlan",
9111 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9115 for (i = 0; i < nb_item; i++) {
9116 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
9117 printf("Invalid vlan_id: must be < 4096\n");
9121 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9122 mr_conf.vlan.vlan_mask |= 1ULL << i;
9126 if (!strcmp(res->on, "on"))
9127 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9130 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9133 printf("mirror rule add error: (%s)\n", strerror(-ret));
9136 cmdline_parse_inst_t cmd_set_mirror_mask = {
9137 .f = cmd_set_mirror_mask_parsed,
9139 .help_str = "set port <port_id> mirror-rule <rule_id> "
9140 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9141 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9143 (void *)&cmd_mirror_mask_set,
9144 (void *)&cmd_mirror_mask_port,
9145 (void *)&cmd_mirror_mask_portid,
9146 (void *)&cmd_mirror_mask_mirror,
9147 (void *)&cmd_mirror_mask_ruleid,
9148 (void *)&cmd_mirror_mask_what,
9149 (void *)&cmd_mirror_mask_value,
9150 (void *)&cmd_mirror_mask_dstpool,
9151 (void *)&cmd_mirror_mask_poolid,
9152 (void *)&cmd_mirror_mask_on,
9157 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9158 struct cmd_set_mirror_link_result {
9159 cmdline_fixed_string_t set;
9160 cmdline_fixed_string_t port;
9162 cmdline_fixed_string_t mirror;
9164 cmdline_fixed_string_t what;
9165 cmdline_fixed_string_t dstpool;
9167 cmdline_fixed_string_t on;
9170 cmdline_parse_token_string_t cmd_mirror_link_set =
9171 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9173 cmdline_parse_token_string_t cmd_mirror_link_port =
9174 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9176 cmdline_parse_token_num_t cmd_mirror_link_portid =
9177 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9179 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9180 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9181 mirror, "mirror-rule");
9182 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9183 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9185 cmdline_parse_token_string_t cmd_mirror_link_what =
9186 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9187 what, "uplink-mirror#downlink-mirror");
9188 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9189 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9190 dstpool, "dst-pool");
9191 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9192 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9194 cmdline_parse_token_string_t cmd_mirror_link_on =
9195 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9199 cmd_set_mirror_link_parsed(void *parsed_result,
9200 __attribute__((unused)) struct cmdline *cl,
9201 __attribute__((unused)) void *data)
9204 struct cmd_set_mirror_link_result *res = parsed_result;
9205 struct rte_eth_mirror_conf mr_conf;
9207 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9208 if (!strcmp(res->what, "uplink-mirror"))
9209 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9211 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9213 mr_conf.dst_pool = res->dstpool_id;
9215 if (!strcmp(res->on, "on"))
9216 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9219 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9222 /* check the return value and print it if is < 0 */
9224 printf("mirror rule add error: (%s)\n", strerror(-ret));
9228 cmdline_parse_inst_t cmd_set_mirror_link = {
9229 .f = cmd_set_mirror_link_parsed,
9231 .help_str = "set port <port_id> mirror-rule <rule_id> "
9232 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9234 (void *)&cmd_mirror_link_set,
9235 (void *)&cmd_mirror_link_port,
9236 (void *)&cmd_mirror_link_portid,
9237 (void *)&cmd_mirror_link_mirror,
9238 (void *)&cmd_mirror_link_ruleid,
9239 (void *)&cmd_mirror_link_what,
9240 (void *)&cmd_mirror_link_dstpool,
9241 (void *)&cmd_mirror_link_poolid,
9242 (void *)&cmd_mirror_link_on,
9247 /* *** RESET VM MIRROR RULE *** */
9248 struct cmd_rm_mirror_rule_result {
9249 cmdline_fixed_string_t reset;
9250 cmdline_fixed_string_t port;
9252 cmdline_fixed_string_t mirror;
9256 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9257 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9259 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9260 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9262 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9263 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9265 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9266 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9267 mirror, "mirror-rule");
9268 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9269 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9273 cmd_reset_mirror_rule_parsed(void *parsed_result,
9274 __attribute__((unused)) struct cmdline *cl,
9275 __attribute__((unused)) void *data)
9278 struct cmd_set_mirror_link_result *res = parsed_result;
9280 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9282 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9285 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9286 .f = cmd_reset_mirror_rule_parsed,
9288 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9290 (void *)&cmd_rm_mirror_rule_reset,
9291 (void *)&cmd_rm_mirror_rule_port,
9292 (void *)&cmd_rm_mirror_rule_portid,
9293 (void *)&cmd_rm_mirror_rule_mirror,
9294 (void *)&cmd_rm_mirror_rule_ruleid,
9299 /* ******************************************************************************** */
9301 struct cmd_dump_result {
9302 cmdline_fixed_string_t dump;
9306 dump_struct_sizes(void)
9308 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9309 DUMP_SIZE(struct rte_mbuf);
9310 DUMP_SIZE(struct rte_mempool);
9311 DUMP_SIZE(struct rte_ring);
9315 static void cmd_dump_parsed(void *parsed_result,
9316 __attribute__((unused)) struct cmdline *cl,
9317 __attribute__((unused)) void *data)
9319 struct cmd_dump_result *res = parsed_result;
9321 if (!strcmp(res->dump, "dump_physmem"))
9322 rte_dump_physmem_layout(stdout);
9323 else if (!strcmp(res->dump, "dump_memzone"))
9324 rte_memzone_dump(stdout);
9325 else if (!strcmp(res->dump, "dump_struct_sizes"))
9326 dump_struct_sizes();
9327 else if (!strcmp(res->dump, "dump_ring"))
9328 rte_ring_list_dump(stdout);
9329 else if (!strcmp(res->dump, "dump_mempool"))
9330 rte_mempool_list_dump(stdout);
9331 else if (!strcmp(res->dump, "dump_devargs"))
9332 rte_devargs_dump(stdout);
9333 else if (!strcmp(res->dump, "dump_log_types"))
9334 rte_log_dump(stdout);
9337 cmdline_parse_token_string_t cmd_dump_dump =
9338 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9341 "dump_struct_sizes#"
9347 cmdline_parse_inst_t cmd_dump = {
9348 .f = cmd_dump_parsed, /* function to call */
9349 .data = NULL, /* 2nd arg of func */
9350 .help_str = "Dump status",
9351 .tokens = { /* token list, NULL terminated */
9352 (void *)&cmd_dump_dump,
9357 /* ******************************************************************************** */
9359 struct cmd_dump_one_result {
9360 cmdline_fixed_string_t dump;
9361 cmdline_fixed_string_t name;
9364 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9365 __attribute__((unused)) void *data)
9367 struct cmd_dump_one_result *res = parsed_result;
9369 if (!strcmp(res->dump, "dump_ring")) {
9371 r = rte_ring_lookup(res->name);
9373 cmdline_printf(cl, "Cannot find ring\n");
9376 rte_ring_dump(stdout, r);
9377 } else if (!strcmp(res->dump, "dump_mempool")) {
9378 struct rte_mempool *mp;
9379 mp = rte_mempool_lookup(res->name);
9381 cmdline_printf(cl, "Cannot find mempool\n");
9384 rte_mempool_dump(stdout, mp);
9388 cmdline_parse_token_string_t cmd_dump_one_dump =
9389 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9390 "dump_ring#dump_mempool");
9392 cmdline_parse_token_string_t cmd_dump_one_name =
9393 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9395 cmdline_parse_inst_t cmd_dump_one = {
9396 .f = cmd_dump_one_parsed, /* function to call */
9397 .data = NULL, /* 2nd arg of func */
9398 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9399 .tokens = { /* token list, NULL terminated */
9400 (void *)&cmd_dump_one_dump,
9401 (void *)&cmd_dump_one_name,
9406 /* *** Add/Del syn filter *** */
9407 struct cmd_syn_filter_result {
9408 cmdline_fixed_string_t filter;
9410 cmdline_fixed_string_t ops;
9411 cmdline_fixed_string_t priority;
9412 cmdline_fixed_string_t high;
9413 cmdline_fixed_string_t queue;
9418 cmd_syn_filter_parsed(void *parsed_result,
9419 __attribute__((unused)) struct cmdline *cl,
9420 __attribute__((unused)) void *data)
9422 struct cmd_syn_filter_result *res = parsed_result;
9423 struct rte_eth_syn_filter syn_filter;
9426 ret = rte_eth_dev_filter_supported(res->port_id,
9427 RTE_ETH_FILTER_SYN);
9429 printf("syn filter is not supported on port %u.\n",
9434 memset(&syn_filter, 0, sizeof(syn_filter));
9436 if (!strcmp(res->ops, "add")) {
9437 if (!strcmp(res->high, "high"))
9438 syn_filter.hig_pri = 1;
9440 syn_filter.hig_pri = 0;
9442 syn_filter.queue = res->queue_id;
9443 ret = rte_eth_dev_filter_ctrl(res->port_id,
9448 ret = rte_eth_dev_filter_ctrl(res->port_id,
9450 RTE_ETH_FILTER_DELETE,
9454 printf("syn filter programming error: (%s)\n",
9458 cmdline_parse_token_string_t cmd_syn_filter_filter =
9459 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9460 filter, "syn_filter");
9461 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9462 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9464 cmdline_parse_token_string_t cmd_syn_filter_ops =
9465 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9467 cmdline_parse_token_string_t cmd_syn_filter_priority =
9468 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9469 priority, "priority");
9470 cmdline_parse_token_string_t cmd_syn_filter_high =
9471 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9473 cmdline_parse_token_string_t cmd_syn_filter_queue =
9474 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9476 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9477 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9480 cmdline_parse_inst_t cmd_syn_filter = {
9481 .f = cmd_syn_filter_parsed,
9483 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9484 "<queue_id>: Add/Delete syn filter",
9486 (void *)&cmd_syn_filter_filter,
9487 (void *)&cmd_syn_filter_port_id,
9488 (void *)&cmd_syn_filter_ops,
9489 (void *)&cmd_syn_filter_priority,
9490 (void *)&cmd_syn_filter_high,
9491 (void *)&cmd_syn_filter_queue,
9492 (void *)&cmd_syn_filter_queue_id,
9497 /* *** queue region set *** */
9498 struct cmd_queue_region_result {
9499 cmdline_fixed_string_t set;
9500 cmdline_fixed_string_t port;
9502 cmdline_fixed_string_t cmd;
9503 cmdline_fixed_string_t region;
9505 cmdline_fixed_string_t queue_start_index;
9507 cmdline_fixed_string_t queue_num;
9508 uint8_t queue_num_value;
9512 cmd_queue_region_parsed(void *parsed_result,
9513 __attribute__((unused)) struct cmdline *cl,
9514 __attribute__((unused)) void *data)
9516 struct cmd_queue_region_result *res = parsed_result;
9518 #ifdef RTE_LIBRTE_I40E_PMD
9519 struct rte_pmd_i40e_queue_region_conf region_conf;
9520 enum rte_pmd_i40e_queue_region_op op_type;
9523 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9526 #ifdef RTE_LIBRTE_I40E_PMD
9527 memset(®ion_conf, 0, sizeof(region_conf));
9528 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9529 region_conf.region_id = res->region_id;
9530 region_conf.queue_num = res->queue_num_value;
9531 region_conf.queue_start_index = res->queue_id;
9533 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9534 op_type, ®ion_conf);
9541 printf("function not implemented or supported\n");
9544 printf("queue region config error: (%s)\n", strerror(-ret));
9548 cmdline_parse_token_string_t cmd_queue_region_set =
9549 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9551 cmdline_parse_token_string_t cmd_queue_region_port =
9552 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9553 cmdline_parse_token_num_t cmd_queue_region_port_id =
9554 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9556 cmdline_parse_token_string_t cmd_queue_region_cmd =
9557 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9558 cmd, "queue-region");
9559 cmdline_parse_token_string_t cmd_queue_region_id =
9560 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9561 region, "region_id");
9562 cmdline_parse_token_num_t cmd_queue_region_index =
9563 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9565 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9566 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9567 queue_start_index, "queue_start_index");
9568 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9569 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9571 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9572 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9573 queue_num, "queue_num");
9574 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9575 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9576 queue_num_value, UINT8);
9578 cmdline_parse_inst_t cmd_queue_region = {
9579 .f = cmd_queue_region_parsed,
9581 .help_str = "set port <port_id> queue-region region_id <value> "
9582 "queue_start_index <value> queue_num <value>: Set a queue region",
9584 (void *)&cmd_queue_region_set,
9585 (void *)&cmd_queue_region_port,
9586 (void *)&cmd_queue_region_port_id,
9587 (void *)&cmd_queue_region_cmd,
9588 (void *)&cmd_queue_region_id,
9589 (void *)&cmd_queue_region_index,
9590 (void *)&cmd_queue_region_queue_start_index,
9591 (void *)&cmd_queue_region_queue_id,
9592 (void *)&cmd_queue_region_queue_num,
9593 (void *)&cmd_queue_region_queue_num_value,
9598 /* *** queue region and flowtype set *** */
9599 struct cmd_region_flowtype_result {
9600 cmdline_fixed_string_t set;
9601 cmdline_fixed_string_t port;
9603 cmdline_fixed_string_t cmd;
9604 cmdline_fixed_string_t region;
9606 cmdline_fixed_string_t flowtype;
9607 uint8_t flowtype_id;
9611 cmd_region_flowtype_parsed(void *parsed_result,
9612 __attribute__((unused)) struct cmdline *cl,
9613 __attribute__((unused)) void *data)
9615 struct cmd_region_flowtype_result *res = parsed_result;
9617 #ifdef RTE_LIBRTE_I40E_PMD
9618 struct rte_pmd_i40e_queue_region_conf region_conf;
9619 enum rte_pmd_i40e_queue_region_op op_type;
9622 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9625 #ifdef RTE_LIBRTE_I40E_PMD
9626 memset(®ion_conf, 0, sizeof(region_conf));
9628 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9629 region_conf.region_id = res->region_id;
9630 region_conf.hw_flowtype = res->flowtype_id;
9632 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9633 op_type, ®ion_conf);
9640 printf("function not implemented or supported\n");
9643 printf("region flowtype config error: (%s)\n", strerror(-ret));
9647 cmdline_parse_token_string_t cmd_region_flowtype_set =
9648 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9650 cmdline_parse_token_string_t cmd_region_flowtype_port =
9651 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9653 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9654 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9656 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9657 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9658 cmd, "queue-region");
9659 cmdline_parse_token_string_t cmd_region_flowtype_index =
9660 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9661 region, "region_id");
9662 cmdline_parse_token_num_t cmd_region_flowtype_id =
9663 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9665 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9666 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9667 flowtype, "flowtype");
9668 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9669 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9670 flowtype_id, UINT8);
9671 cmdline_parse_inst_t cmd_region_flowtype = {
9672 .f = cmd_region_flowtype_parsed,
9674 .help_str = "set port <port_id> queue-region region_id <value> "
9675 "flowtype <value>: Set a flowtype region index",
9677 (void *)&cmd_region_flowtype_set,
9678 (void *)&cmd_region_flowtype_port,
9679 (void *)&cmd_region_flowtype_port_index,
9680 (void *)&cmd_region_flowtype_cmd,
9681 (void *)&cmd_region_flowtype_index,
9682 (void *)&cmd_region_flowtype_id,
9683 (void *)&cmd_region_flowtype_flow_index,
9684 (void *)&cmd_region_flowtype_flow_id,
9689 /* *** User Priority (UP) to queue region (region_id) set *** */
9690 struct cmd_user_priority_region_result {
9691 cmdline_fixed_string_t set;
9692 cmdline_fixed_string_t port;
9694 cmdline_fixed_string_t cmd;
9695 cmdline_fixed_string_t user_priority;
9696 uint8_t user_priority_id;
9697 cmdline_fixed_string_t region;
9702 cmd_user_priority_region_parsed(void *parsed_result,
9703 __attribute__((unused)) struct cmdline *cl,
9704 __attribute__((unused)) void *data)
9706 struct cmd_user_priority_region_result *res = parsed_result;
9708 #ifdef RTE_LIBRTE_I40E_PMD
9709 struct rte_pmd_i40e_queue_region_conf region_conf;
9710 enum rte_pmd_i40e_queue_region_op op_type;
9713 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9716 #ifdef RTE_LIBRTE_I40E_PMD
9717 memset(®ion_conf, 0, sizeof(region_conf));
9718 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9719 region_conf.user_priority = res->user_priority_id;
9720 region_conf.region_id = res->region_id;
9722 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9723 op_type, ®ion_conf);
9730 printf("function not implemented or supported\n");
9733 printf("user_priority region config error: (%s)\n",
9738 cmdline_parse_token_string_t cmd_user_priority_region_set =
9739 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9741 cmdline_parse_token_string_t cmd_user_priority_region_port =
9742 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9744 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9745 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9747 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9748 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9749 cmd, "queue-region");
9750 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9751 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9752 user_priority, "UP");
9753 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9754 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9755 user_priority_id, UINT8);
9756 cmdline_parse_token_string_t cmd_user_priority_region_region =
9757 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9758 region, "region_id");
9759 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9760 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9763 cmdline_parse_inst_t cmd_user_priority_region = {
9764 .f = cmd_user_priority_region_parsed,
9766 .help_str = "set port <port_id> queue-region UP <value> "
9767 "region_id <value>: Set the mapping of User Priority (UP) "
9768 "to queue region (region_id) ",
9770 (void *)&cmd_user_priority_region_set,
9771 (void *)&cmd_user_priority_region_port,
9772 (void *)&cmd_user_priority_region_port_index,
9773 (void *)&cmd_user_priority_region_cmd,
9774 (void *)&cmd_user_priority_region_UP,
9775 (void *)&cmd_user_priority_region_UP_id,
9776 (void *)&cmd_user_priority_region_region,
9777 (void *)&cmd_user_priority_region_region_id,
9782 /* *** flush all queue region related configuration *** */
9783 struct cmd_flush_queue_region_result {
9784 cmdline_fixed_string_t set;
9785 cmdline_fixed_string_t port;
9787 cmdline_fixed_string_t cmd;
9788 cmdline_fixed_string_t flush;
9789 cmdline_fixed_string_t what;
9793 cmd_flush_queue_region_parsed(void *parsed_result,
9794 __attribute__((unused)) struct cmdline *cl,
9795 __attribute__((unused)) void *data)
9797 struct cmd_flush_queue_region_result *res = parsed_result;
9799 #ifdef RTE_LIBRTE_I40E_PMD
9800 struct rte_pmd_i40e_queue_region_conf region_conf;
9801 enum rte_pmd_i40e_queue_region_op op_type;
9804 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9807 #ifdef RTE_LIBRTE_I40E_PMD
9808 memset(®ion_conf, 0, sizeof(region_conf));
9810 if (strcmp(res->what, "on") == 0)
9811 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9813 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9815 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9816 op_type, ®ion_conf);
9823 printf("function not implemented or supported\n");
9826 printf("queue region config flush error: (%s)\n",
9831 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9832 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9834 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9835 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9837 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9838 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9840 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9841 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9842 cmd, "queue-region");
9843 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9844 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9846 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9847 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9850 cmdline_parse_inst_t cmd_flush_queue_region = {
9851 .f = cmd_flush_queue_region_parsed,
9853 .help_str = "set port <port_id> queue-region flush on|off"
9854 ": flush all queue region related configuration",
9856 (void *)&cmd_flush_queue_region_set,
9857 (void *)&cmd_flush_queue_region_port,
9858 (void *)&cmd_flush_queue_region_port_index,
9859 (void *)&cmd_flush_queue_region_cmd,
9860 (void *)&cmd_flush_queue_region_flush,
9861 (void *)&cmd_flush_queue_region_what,
9866 /* *** get all queue region related configuration info *** */
9867 struct cmd_show_queue_region_info {
9868 cmdline_fixed_string_t show;
9869 cmdline_fixed_string_t port;
9871 cmdline_fixed_string_t cmd;
9875 cmd_show_queue_region_info_parsed(void *parsed_result,
9876 __attribute__((unused)) struct cmdline *cl,
9877 __attribute__((unused)) void *data)
9879 struct cmd_show_queue_region_info *res = parsed_result;
9881 #ifdef RTE_LIBRTE_I40E_PMD
9882 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9883 enum rte_pmd_i40e_queue_region_op op_type;
9886 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9889 #ifdef RTE_LIBRTE_I40E_PMD
9890 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9892 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9894 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9895 op_type, &rte_pmd_regions);
9897 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9904 printf("function not implemented or supported\n");
9907 printf("queue region config info show error: (%s)\n",
9912 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9913 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9915 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9916 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9918 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9919 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9921 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9922 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9923 cmd, "queue-region");
9925 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9926 .f = cmd_show_queue_region_info_parsed,
9928 .help_str = "show port <port_id> queue-region"
9929 ": show all queue region related configuration info",
9931 (void *)&cmd_show_queue_region_info_get,
9932 (void *)&cmd_show_queue_region_info_port,
9933 (void *)&cmd_show_queue_region_info_port_index,
9934 (void *)&cmd_show_queue_region_info_cmd,
9939 /* *** ADD/REMOVE A 2tuple FILTER *** */
9940 struct cmd_2tuple_filter_result {
9941 cmdline_fixed_string_t filter;
9943 cmdline_fixed_string_t ops;
9944 cmdline_fixed_string_t dst_port;
9945 uint16_t dst_port_value;
9946 cmdline_fixed_string_t protocol;
9947 uint8_t protocol_value;
9948 cmdline_fixed_string_t mask;
9950 cmdline_fixed_string_t tcp_flags;
9951 uint8_t tcp_flags_value;
9952 cmdline_fixed_string_t priority;
9953 uint8_t priority_value;
9954 cmdline_fixed_string_t queue;
9959 cmd_2tuple_filter_parsed(void *parsed_result,
9960 __attribute__((unused)) struct cmdline *cl,
9961 __attribute__((unused)) void *data)
9963 struct rte_eth_ntuple_filter filter;
9964 struct cmd_2tuple_filter_result *res = parsed_result;
9967 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9969 printf("ntuple filter is not supported on port %u.\n",
9974 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9976 filter.flags = RTE_2TUPLE_FLAGS;
9977 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9978 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9979 filter.proto = res->protocol_value;
9980 filter.priority = res->priority_value;
9981 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9982 printf("nonzero tcp_flags is only meaningful"
9983 " when protocol is TCP.\n");
9986 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9987 printf("invalid TCP flags.\n");
9991 if (res->tcp_flags_value != 0) {
9992 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9993 filter.tcp_flags = res->tcp_flags_value;
9996 /* need convert to big endian. */
9997 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9998 filter.queue = res->queue_id;
10000 if (!strcmp(res->ops, "add"))
10001 ret = rte_eth_dev_filter_ctrl(res->port_id,
10002 RTE_ETH_FILTER_NTUPLE,
10003 RTE_ETH_FILTER_ADD,
10006 ret = rte_eth_dev_filter_ctrl(res->port_id,
10007 RTE_ETH_FILTER_NTUPLE,
10008 RTE_ETH_FILTER_DELETE,
10011 printf("2tuple filter programming error: (%s)\n",
10016 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10017 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10018 filter, "2tuple_filter");
10019 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10020 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10022 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10023 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10025 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10026 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10027 dst_port, "dst_port");
10028 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10029 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10030 dst_port_value, UINT16);
10031 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10032 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10033 protocol, "protocol");
10034 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10035 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10036 protocol_value, UINT8);
10037 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10038 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10040 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10041 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10043 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10044 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10045 tcp_flags, "tcp_flags");
10046 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10047 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10048 tcp_flags_value, UINT8);
10049 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10050 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10051 priority, "priority");
10052 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10053 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10054 priority_value, UINT8);
10055 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10056 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10058 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10059 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10062 cmdline_parse_inst_t cmd_2tuple_filter = {
10063 .f = cmd_2tuple_filter_parsed,
10065 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10066 "<value> mask <value> tcp_flags <value> priority <value> queue "
10067 "<queue_id>: Add a 2tuple filter",
10069 (void *)&cmd_2tuple_filter_filter,
10070 (void *)&cmd_2tuple_filter_port_id,
10071 (void *)&cmd_2tuple_filter_ops,
10072 (void *)&cmd_2tuple_filter_dst_port,
10073 (void *)&cmd_2tuple_filter_dst_port_value,
10074 (void *)&cmd_2tuple_filter_protocol,
10075 (void *)&cmd_2tuple_filter_protocol_value,
10076 (void *)&cmd_2tuple_filter_mask,
10077 (void *)&cmd_2tuple_filter_mask_value,
10078 (void *)&cmd_2tuple_filter_tcp_flags,
10079 (void *)&cmd_2tuple_filter_tcp_flags_value,
10080 (void *)&cmd_2tuple_filter_priority,
10081 (void *)&cmd_2tuple_filter_priority_value,
10082 (void *)&cmd_2tuple_filter_queue,
10083 (void *)&cmd_2tuple_filter_queue_id,
10088 /* *** ADD/REMOVE A 5tuple FILTER *** */
10089 struct cmd_5tuple_filter_result {
10090 cmdline_fixed_string_t filter;
10092 cmdline_fixed_string_t ops;
10093 cmdline_fixed_string_t dst_ip;
10094 cmdline_ipaddr_t dst_ip_value;
10095 cmdline_fixed_string_t src_ip;
10096 cmdline_ipaddr_t src_ip_value;
10097 cmdline_fixed_string_t dst_port;
10098 uint16_t dst_port_value;
10099 cmdline_fixed_string_t src_port;
10100 uint16_t src_port_value;
10101 cmdline_fixed_string_t protocol;
10102 uint8_t protocol_value;
10103 cmdline_fixed_string_t mask;
10104 uint8_t mask_value;
10105 cmdline_fixed_string_t tcp_flags;
10106 uint8_t tcp_flags_value;
10107 cmdline_fixed_string_t priority;
10108 uint8_t priority_value;
10109 cmdline_fixed_string_t queue;
10114 cmd_5tuple_filter_parsed(void *parsed_result,
10115 __attribute__((unused)) struct cmdline *cl,
10116 __attribute__((unused)) void *data)
10118 struct rte_eth_ntuple_filter filter;
10119 struct cmd_5tuple_filter_result *res = parsed_result;
10122 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10124 printf("ntuple filter is not supported on port %u.\n",
10129 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10131 filter.flags = RTE_5TUPLE_FLAGS;
10132 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10133 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10134 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10135 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10136 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10137 filter.proto = res->protocol_value;
10138 filter.priority = res->priority_value;
10139 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10140 printf("nonzero tcp_flags is only meaningful"
10141 " when protocol is TCP.\n");
10144 if (res->tcp_flags_value > TCP_FLAG_ALL) {
10145 printf("invalid TCP flags.\n");
10149 if (res->tcp_flags_value != 0) {
10150 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10151 filter.tcp_flags = res->tcp_flags_value;
10154 if (res->dst_ip_value.family == AF_INET)
10155 /* no need to convert, already big endian. */
10156 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10158 if (filter.dst_ip_mask == 0) {
10159 printf("can not support ipv6 involved compare.\n");
10165 if (res->src_ip_value.family == AF_INET)
10166 /* no need to convert, already big endian. */
10167 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10169 if (filter.src_ip_mask == 0) {
10170 printf("can not support ipv6 involved compare.\n");
10175 /* need convert to big endian. */
10176 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10177 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10178 filter.queue = res->queue_id;
10180 if (!strcmp(res->ops, "add"))
10181 ret = rte_eth_dev_filter_ctrl(res->port_id,
10182 RTE_ETH_FILTER_NTUPLE,
10183 RTE_ETH_FILTER_ADD,
10186 ret = rte_eth_dev_filter_ctrl(res->port_id,
10187 RTE_ETH_FILTER_NTUPLE,
10188 RTE_ETH_FILTER_DELETE,
10191 printf("5tuple filter programming error: (%s)\n",
10195 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10196 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10197 filter, "5tuple_filter");
10198 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10199 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10201 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10202 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10204 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10205 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10207 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10208 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10210 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10211 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10213 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10214 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10216 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10217 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10218 dst_port, "dst_port");
10219 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10220 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10221 dst_port_value, UINT16);
10222 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10223 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10224 src_port, "src_port");
10225 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10226 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10227 src_port_value, UINT16);
10228 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10229 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10230 protocol, "protocol");
10231 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10232 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10233 protocol_value, UINT8);
10234 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10235 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10237 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10238 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10240 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10241 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10242 tcp_flags, "tcp_flags");
10243 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10244 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10245 tcp_flags_value, UINT8);
10246 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10247 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10248 priority, "priority");
10249 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10250 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10251 priority_value, UINT8);
10252 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10253 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10255 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10256 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10259 cmdline_parse_inst_t cmd_5tuple_filter = {
10260 .f = cmd_5tuple_filter_parsed,
10262 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10263 "src_ip <value> dst_port <value> src_port <value> "
10264 "protocol <value> mask <value> tcp_flags <value> "
10265 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10267 (void *)&cmd_5tuple_filter_filter,
10268 (void *)&cmd_5tuple_filter_port_id,
10269 (void *)&cmd_5tuple_filter_ops,
10270 (void *)&cmd_5tuple_filter_dst_ip,
10271 (void *)&cmd_5tuple_filter_dst_ip_value,
10272 (void *)&cmd_5tuple_filter_src_ip,
10273 (void *)&cmd_5tuple_filter_src_ip_value,
10274 (void *)&cmd_5tuple_filter_dst_port,
10275 (void *)&cmd_5tuple_filter_dst_port_value,
10276 (void *)&cmd_5tuple_filter_src_port,
10277 (void *)&cmd_5tuple_filter_src_port_value,
10278 (void *)&cmd_5tuple_filter_protocol,
10279 (void *)&cmd_5tuple_filter_protocol_value,
10280 (void *)&cmd_5tuple_filter_mask,
10281 (void *)&cmd_5tuple_filter_mask_value,
10282 (void *)&cmd_5tuple_filter_tcp_flags,
10283 (void *)&cmd_5tuple_filter_tcp_flags_value,
10284 (void *)&cmd_5tuple_filter_priority,
10285 (void *)&cmd_5tuple_filter_priority_value,
10286 (void *)&cmd_5tuple_filter_queue,
10287 (void *)&cmd_5tuple_filter_queue_id,
10292 /* *** ADD/REMOVE A flex FILTER *** */
10293 struct cmd_flex_filter_result {
10294 cmdline_fixed_string_t filter;
10295 cmdline_fixed_string_t ops;
10297 cmdline_fixed_string_t len;
10299 cmdline_fixed_string_t bytes;
10300 cmdline_fixed_string_t bytes_value;
10301 cmdline_fixed_string_t mask;
10302 cmdline_fixed_string_t mask_value;
10303 cmdline_fixed_string_t priority;
10304 uint8_t priority_value;
10305 cmdline_fixed_string_t queue;
10309 static int xdigit2val(unsigned char c)
10314 else if (isupper(c))
10315 val = c - 'A' + 10;
10317 val = c - 'a' + 10;
10322 cmd_flex_filter_parsed(void *parsed_result,
10323 __attribute__((unused)) struct cmdline *cl,
10324 __attribute__((unused)) void *data)
10327 struct rte_eth_flex_filter filter;
10328 struct cmd_flex_filter_result *res = parsed_result;
10329 char *bytes_ptr, *mask_ptr;
10330 uint16_t len, i, j = 0;
10335 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10336 printf("the len exceed the max length 128\n");
10339 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10340 filter.len = res->len_value;
10341 filter.priority = res->priority_value;
10342 filter.queue = res->queue_id;
10343 bytes_ptr = res->bytes_value;
10344 mask_ptr = res->mask_value;
10346 /* translate bytes string to array. */
10347 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10348 (bytes_ptr[1] == 'X')))
10350 len = strnlen(bytes_ptr, res->len_value * 2);
10351 if (len == 0 || (len % 8 != 0)) {
10352 printf("please check len and bytes input\n");
10355 for (i = 0; i < len; i++) {
10357 if (isxdigit(c) == 0) {
10358 /* invalid characters. */
10359 printf("invalid input\n");
10362 val = xdigit2val(c);
10365 filter.bytes[j] = byte;
10366 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10373 /* translate mask string to uint8_t array. */
10374 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10375 (mask_ptr[1] == 'X')))
10377 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10379 printf("invalid input\n");
10384 for (i = 0; i < len; i++) {
10386 if (isxdigit(c) == 0) {
10387 /* invalid characters. */
10388 printf("invalid input\n");
10391 val = xdigit2val(c);
10394 filter.mask[j] = byte;
10395 printf("mask[%d]:%02x ", j, filter.mask[j]);
10403 if (!strcmp(res->ops, "add"))
10404 ret = rte_eth_dev_filter_ctrl(res->port_id,
10405 RTE_ETH_FILTER_FLEXIBLE,
10406 RTE_ETH_FILTER_ADD,
10409 ret = rte_eth_dev_filter_ctrl(res->port_id,
10410 RTE_ETH_FILTER_FLEXIBLE,
10411 RTE_ETH_FILTER_DELETE,
10415 printf("flex filter setting error: (%s)\n", strerror(-ret));
10418 cmdline_parse_token_string_t cmd_flex_filter_filter =
10419 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10420 filter, "flex_filter");
10421 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10422 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10424 cmdline_parse_token_string_t cmd_flex_filter_ops =
10425 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10427 cmdline_parse_token_string_t cmd_flex_filter_len =
10428 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10430 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10431 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10433 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10434 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10436 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10437 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10438 bytes_value, NULL);
10439 cmdline_parse_token_string_t cmd_flex_filter_mask =
10440 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10442 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10443 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10445 cmdline_parse_token_string_t cmd_flex_filter_priority =
10446 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10447 priority, "priority");
10448 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10449 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10450 priority_value, UINT8);
10451 cmdline_parse_token_string_t cmd_flex_filter_queue =
10452 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10454 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10455 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10457 cmdline_parse_inst_t cmd_flex_filter = {
10458 .f = cmd_flex_filter_parsed,
10460 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10461 "<value> mask <value> priority <value> queue <queue_id>: "
10462 "Add/Del a flex filter",
10464 (void *)&cmd_flex_filter_filter,
10465 (void *)&cmd_flex_filter_port_id,
10466 (void *)&cmd_flex_filter_ops,
10467 (void *)&cmd_flex_filter_len,
10468 (void *)&cmd_flex_filter_len_value,
10469 (void *)&cmd_flex_filter_bytes,
10470 (void *)&cmd_flex_filter_bytes_value,
10471 (void *)&cmd_flex_filter_mask,
10472 (void *)&cmd_flex_filter_mask_value,
10473 (void *)&cmd_flex_filter_priority,
10474 (void *)&cmd_flex_filter_priority_value,
10475 (void *)&cmd_flex_filter_queue,
10476 (void *)&cmd_flex_filter_queue_id,
10481 /* *** Filters Control *** */
10483 /* *** deal with ethertype filter *** */
10484 struct cmd_ethertype_filter_result {
10485 cmdline_fixed_string_t filter;
10487 cmdline_fixed_string_t ops;
10488 cmdline_fixed_string_t mac;
10489 struct ether_addr mac_addr;
10490 cmdline_fixed_string_t ethertype;
10491 uint16_t ethertype_value;
10492 cmdline_fixed_string_t drop;
10493 cmdline_fixed_string_t queue;
10497 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10498 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10499 filter, "ethertype_filter");
10500 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10501 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10503 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10504 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10506 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10507 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10508 mac, "mac_addr#mac_ignr");
10509 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10510 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10512 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10513 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10514 ethertype, "ethertype");
10515 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10516 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10517 ethertype_value, UINT16);
10518 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10519 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10521 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10522 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10524 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10525 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10529 cmd_ethertype_filter_parsed(void *parsed_result,
10530 __attribute__((unused)) struct cmdline *cl,
10531 __attribute__((unused)) void *data)
10533 struct cmd_ethertype_filter_result *res = parsed_result;
10534 struct rte_eth_ethertype_filter filter;
10537 ret = rte_eth_dev_filter_supported(res->port_id,
10538 RTE_ETH_FILTER_ETHERTYPE);
10540 printf("ethertype filter is not supported on port %u.\n",
10545 memset(&filter, 0, sizeof(filter));
10546 if (!strcmp(res->mac, "mac_addr")) {
10547 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10548 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10549 sizeof(struct ether_addr));
10551 if (!strcmp(res->drop, "drop"))
10552 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10553 filter.ether_type = res->ethertype_value;
10554 filter.queue = res->queue_id;
10556 if (!strcmp(res->ops, "add"))
10557 ret = rte_eth_dev_filter_ctrl(res->port_id,
10558 RTE_ETH_FILTER_ETHERTYPE,
10559 RTE_ETH_FILTER_ADD,
10562 ret = rte_eth_dev_filter_ctrl(res->port_id,
10563 RTE_ETH_FILTER_ETHERTYPE,
10564 RTE_ETH_FILTER_DELETE,
10567 printf("ethertype filter programming error: (%s)\n",
10571 cmdline_parse_inst_t cmd_ethertype_filter = {
10572 .f = cmd_ethertype_filter_parsed,
10574 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10575 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10576 "Add or delete an ethertype filter entry",
10578 (void *)&cmd_ethertype_filter_filter,
10579 (void *)&cmd_ethertype_filter_port_id,
10580 (void *)&cmd_ethertype_filter_ops,
10581 (void *)&cmd_ethertype_filter_mac,
10582 (void *)&cmd_ethertype_filter_mac_addr,
10583 (void *)&cmd_ethertype_filter_ethertype,
10584 (void *)&cmd_ethertype_filter_ethertype_value,
10585 (void *)&cmd_ethertype_filter_drop,
10586 (void *)&cmd_ethertype_filter_queue,
10587 (void *)&cmd_ethertype_filter_queue_id,
10592 /* *** deal with flow director filter *** */
10593 struct cmd_flow_director_result {
10594 cmdline_fixed_string_t flow_director_filter;
10596 cmdline_fixed_string_t mode;
10597 cmdline_fixed_string_t mode_value;
10598 cmdline_fixed_string_t ops;
10599 cmdline_fixed_string_t flow;
10600 cmdline_fixed_string_t flow_type;
10601 cmdline_fixed_string_t ether;
10602 uint16_t ether_type;
10603 cmdline_fixed_string_t src;
10604 cmdline_ipaddr_t ip_src;
10606 cmdline_fixed_string_t dst;
10607 cmdline_ipaddr_t ip_dst;
10609 cmdline_fixed_string_t verify_tag;
10610 uint32_t verify_tag_value;
10611 cmdline_fixed_string_t tos;
10613 cmdline_fixed_string_t proto;
10614 uint8_t proto_value;
10615 cmdline_fixed_string_t ttl;
10617 cmdline_fixed_string_t vlan;
10618 uint16_t vlan_value;
10619 cmdline_fixed_string_t flexbytes;
10620 cmdline_fixed_string_t flexbytes_value;
10621 cmdline_fixed_string_t pf_vf;
10622 cmdline_fixed_string_t drop;
10623 cmdline_fixed_string_t queue;
10625 cmdline_fixed_string_t fd_id;
10626 uint32_t fd_id_value;
10627 cmdline_fixed_string_t mac;
10628 struct ether_addr mac_addr;
10629 cmdline_fixed_string_t tunnel;
10630 cmdline_fixed_string_t tunnel_type;
10631 cmdline_fixed_string_t tunnel_id;
10632 uint32_t tunnel_id_value;
10633 cmdline_fixed_string_t packet;
10638 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10641 const char *p, *p0 = q_arg;
10643 unsigned long int_fld;
10644 char *str_fld[max_num];
10649 p = strchr(p0, '(');
10653 p0 = strchr(p, ')');
10658 if (size >= sizeof(s))
10661 snprintf(s, sizeof(s), "%.*s", size, p);
10662 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10663 if (ret < 0 || ret > max_num)
10665 for (i = 0; i < ret; i++) {
10667 int_fld = strtoul(str_fld[i], &end, 0);
10668 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10670 flexbytes[i] = (uint8_t)int_fld;
10676 str2flowtype(char *string)
10679 static const struct {
10682 } flowtype_str[] = {
10683 {"raw", RTE_ETH_FLOW_RAW},
10684 {"ipv4", RTE_ETH_FLOW_IPV4},
10685 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10686 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10687 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10688 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10689 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10690 {"ipv6", RTE_ETH_FLOW_IPV6},
10691 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10692 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10693 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10694 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10695 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10696 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10699 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10700 if (!strcmp(flowtype_str[i].str, string))
10701 return flowtype_str[i].type;
10704 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10705 return (uint16_t)atoi(string);
10707 return RTE_ETH_FLOW_UNKNOWN;
10710 static enum rte_eth_fdir_tunnel_type
10711 str2fdir_tunneltype(char *string)
10715 static const struct {
10717 enum rte_eth_fdir_tunnel_type type;
10718 } tunneltype_str[] = {
10719 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10720 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10723 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10724 if (!strcmp(tunneltype_str[i].str, string))
10725 return tunneltype_str[i].type;
10727 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10730 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10732 if ((ip_addr).family == AF_INET) \
10733 (ip) = (ip_addr).addr.ipv4.s_addr; \
10735 printf("invalid parameter.\n"); \
10740 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10742 if ((ip_addr).family == AF_INET6) \
10743 rte_memcpy(&(ip), \
10744 &((ip_addr).addr.ipv6), \
10745 sizeof(struct in6_addr)); \
10747 printf("invalid parameter.\n"); \
10753 cmd_flow_director_filter_parsed(void *parsed_result,
10754 __attribute__((unused)) struct cmdline *cl,
10755 __attribute__((unused)) void *data)
10757 struct cmd_flow_director_result *res = parsed_result;
10758 struct rte_eth_fdir_filter entry;
10759 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10761 unsigned long vf_id;
10764 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10766 printf("flow director is not supported on port %u.\n",
10770 memset(flexbytes, 0, sizeof(flexbytes));
10771 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10773 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10774 if (strcmp(res->mode_value, "MAC-VLAN")) {
10775 printf("Please set mode to MAC-VLAN.\n");
10778 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10779 if (strcmp(res->mode_value, "Tunnel")) {
10780 printf("Please set mode to Tunnel.\n");
10784 if (!strcmp(res->mode_value, "raw")) {
10785 #ifdef RTE_LIBRTE_I40E_PMD
10786 struct rte_pmd_i40e_flow_type_mapping
10787 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10788 struct rte_pmd_i40e_pkt_template_conf conf;
10789 uint16_t flow_type = str2flowtype(res->flow_type);
10790 uint16_t i, port = res->port_id;
10793 memset(&conf, 0, sizeof(conf));
10795 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10796 printf("Invalid flow type specified.\n");
10799 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10803 if (mapping[flow_type].pctype == 0ULL) {
10804 printf("Invalid flow type specified.\n");
10807 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10808 if (mapping[flow_type].pctype & (1ULL << i)) {
10809 conf.input.pctype = i;
10814 conf.input.packet = open_file(res->filepath,
10815 &conf.input.length);
10816 if (!conf.input.packet)
10818 if (!strcmp(res->drop, "drop"))
10819 conf.action.behavior =
10820 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10822 conf.action.behavior =
10823 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10824 conf.action.report_status =
10825 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10826 conf.action.rx_queue = res->queue_id;
10827 conf.soft_id = res->fd_id_value;
10828 add = strcmp(res->ops, "del") ? 1 : 0;
10829 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10833 printf("flow director config error: (%s)\n",
10835 close_file(conf.input.packet);
10838 } else if (strcmp(res->mode_value, "IP")) {
10839 printf("Please set mode to IP or raw.\n");
10842 entry.input.flow_type = str2flowtype(res->flow_type);
10845 ret = parse_flexbytes(res->flexbytes_value,
10847 RTE_ETH_FDIR_MAX_FLEXLEN);
10849 printf("error: Cannot parse flexbytes input.\n");
10853 switch (entry.input.flow_type) {
10854 case RTE_ETH_FLOW_FRAG_IPV4:
10855 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10856 entry.input.flow.ip4_flow.proto = res->proto_value;
10858 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10859 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10860 IPV4_ADDR_TO_UINT(res->ip_dst,
10861 entry.input.flow.ip4_flow.dst_ip);
10862 IPV4_ADDR_TO_UINT(res->ip_src,
10863 entry.input.flow.ip4_flow.src_ip);
10864 entry.input.flow.ip4_flow.tos = res->tos_value;
10865 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10866 /* need convert to big endian. */
10867 entry.input.flow.udp4_flow.dst_port =
10868 rte_cpu_to_be_16(res->port_dst);
10869 entry.input.flow.udp4_flow.src_port =
10870 rte_cpu_to_be_16(res->port_src);
10872 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10873 IPV4_ADDR_TO_UINT(res->ip_dst,
10874 entry.input.flow.sctp4_flow.ip.dst_ip);
10875 IPV4_ADDR_TO_UINT(res->ip_src,
10876 entry.input.flow.sctp4_flow.ip.src_ip);
10877 entry.input.flow.ip4_flow.tos = res->tos_value;
10878 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10879 /* need convert to big endian. */
10880 entry.input.flow.sctp4_flow.dst_port =
10881 rte_cpu_to_be_16(res->port_dst);
10882 entry.input.flow.sctp4_flow.src_port =
10883 rte_cpu_to_be_16(res->port_src);
10884 entry.input.flow.sctp4_flow.verify_tag =
10885 rte_cpu_to_be_32(res->verify_tag_value);
10887 case RTE_ETH_FLOW_FRAG_IPV6:
10888 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10889 entry.input.flow.ipv6_flow.proto = res->proto_value;
10891 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10892 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10893 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10894 entry.input.flow.ipv6_flow.dst_ip);
10895 IPV6_ADDR_TO_ARRAY(res->ip_src,
10896 entry.input.flow.ipv6_flow.src_ip);
10897 entry.input.flow.ipv6_flow.tc = res->tos_value;
10898 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10899 /* need convert to big endian. */
10900 entry.input.flow.udp6_flow.dst_port =
10901 rte_cpu_to_be_16(res->port_dst);
10902 entry.input.flow.udp6_flow.src_port =
10903 rte_cpu_to_be_16(res->port_src);
10905 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10906 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10907 entry.input.flow.sctp6_flow.ip.dst_ip);
10908 IPV6_ADDR_TO_ARRAY(res->ip_src,
10909 entry.input.flow.sctp6_flow.ip.src_ip);
10910 entry.input.flow.ipv6_flow.tc = res->tos_value;
10911 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10912 /* need convert to big endian. */
10913 entry.input.flow.sctp6_flow.dst_port =
10914 rte_cpu_to_be_16(res->port_dst);
10915 entry.input.flow.sctp6_flow.src_port =
10916 rte_cpu_to_be_16(res->port_src);
10917 entry.input.flow.sctp6_flow.verify_tag =
10918 rte_cpu_to_be_32(res->verify_tag_value);
10920 case RTE_ETH_FLOW_L2_PAYLOAD:
10921 entry.input.flow.l2_flow.ether_type =
10922 rte_cpu_to_be_16(res->ether_type);
10928 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10929 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10931 sizeof(struct ether_addr));
10933 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10934 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10936 sizeof(struct ether_addr));
10937 entry.input.flow.tunnel_flow.tunnel_type =
10938 str2fdir_tunneltype(res->tunnel_type);
10939 entry.input.flow.tunnel_flow.tunnel_id =
10940 rte_cpu_to_be_32(res->tunnel_id_value);
10943 rte_memcpy(entry.input.flow_ext.flexbytes,
10945 RTE_ETH_FDIR_MAX_FLEXLEN);
10947 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10949 entry.action.flex_off = 0; /*use 0 by default */
10950 if (!strcmp(res->drop, "drop"))
10951 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10953 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10955 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10956 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10957 if (!strcmp(res->pf_vf, "pf"))
10958 entry.input.flow_ext.is_vf = 0;
10959 else if (!strncmp(res->pf_vf, "vf", 2)) {
10960 struct rte_eth_dev_info dev_info;
10962 memset(&dev_info, 0, sizeof(dev_info));
10963 rte_eth_dev_info_get(res->port_id, &dev_info);
10965 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10966 if (errno != 0 || *end != '\0' ||
10967 vf_id >= dev_info.max_vfs) {
10968 printf("invalid parameter %s.\n", res->pf_vf);
10971 entry.input.flow_ext.is_vf = 1;
10972 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10974 printf("invalid parameter %s.\n", res->pf_vf);
10979 /* set to report FD ID by default */
10980 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10981 entry.action.rx_queue = res->queue_id;
10982 entry.soft_id = res->fd_id_value;
10983 if (!strcmp(res->ops, "add"))
10984 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10985 RTE_ETH_FILTER_ADD, &entry);
10986 else if (!strcmp(res->ops, "del"))
10987 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10988 RTE_ETH_FILTER_DELETE, &entry);
10990 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10991 RTE_ETH_FILTER_UPDATE, &entry);
10993 printf("flow director programming error: (%s)\n",
10997 cmdline_parse_token_string_t cmd_flow_director_filter =
10998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10999 flow_director_filter, "flow_director_filter");
11000 cmdline_parse_token_num_t cmd_flow_director_port_id =
11001 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11003 cmdline_parse_token_string_t cmd_flow_director_ops =
11004 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11005 ops, "add#del#update");
11006 cmdline_parse_token_string_t cmd_flow_director_flow =
11007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11009 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11010 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11012 cmdline_parse_token_string_t cmd_flow_director_ether =
11013 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11015 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11016 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11017 ether_type, UINT16);
11018 cmdline_parse_token_string_t cmd_flow_director_src =
11019 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11021 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11022 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11024 cmdline_parse_token_num_t cmd_flow_director_port_src =
11025 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11027 cmdline_parse_token_string_t cmd_flow_director_dst =
11028 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11030 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11031 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11033 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11034 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11036 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11037 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11038 verify_tag, "verify_tag");
11039 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11040 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11041 verify_tag_value, UINT32);
11042 cmdline_parse_token_string_t cmd_flow_director_tos =
11043 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11045 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11046 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11048 cmdline_parse_token_string_t cmd_flow_director_proto =
11049 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11051 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11052 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11053 proto_value, UINT8);
11054 cmdline_parse_token_string_t cmd_flow_director_ttl =
11055 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11057 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11058 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11060 cmdline_parse_token_string_t cmd_flow_director_vlan =
11061 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11063 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11064 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11065 vlan_value, UINT16);
11066 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11067 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11068 flexbytes, "flexbytes");
11069 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11070 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11071 flexbytes_value, NULL);
11072 cmdline_parse_token_string_t cmd_flow_director_drop =
11073 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11075 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11076 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11078 cmdline_parse_token_string_t cmd_flow_director_queue =
11079 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11081 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11082 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11084 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11085 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11087 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11088 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11089 fd_id_value, UINT32);
11091 cmdline_parse_token_string_t cmd_flow_director_mode =
11092 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11094 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11095 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11097 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11098 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11099 mode_value, "MAC-VLAN");
11100 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11101 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11102 mode_value, "Tunnel");
11103 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11104 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11105 mode_value, "raw");
11106 cmdline_parse_token_string_t cmd_flow_director_mac =
11107 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11109 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11110 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11112 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11113 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11115 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11116 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11117 tunnel_type, "NVGRE#VxLAN");
11118 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11119 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11120 tunnel_id, "tunnel-id");
11121 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11122 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11123 tunnel_id_value, UINT32);
11124 cmdline_parse_token_string_t cmd_flow_director_packet =
11125 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11127 cmdline_parse_token_string_t cmd_flow_director_filepath =
11128 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11131 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11132 .f = cmd_flow_director_filter_parsed,
11134 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11135 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11136 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11137 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11138 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11139 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11140 "fd_id <fd_id_value>: "
11141 "Add or delete an ip flow director entry on NIC",
11143 (void *)&cmd_flow_director_filter,
11144 (void *)&cmd_flow_director_port_id,
11145 (void *)&cmd_flow_director_mode,
11146 (void *)&cmd_flow_director_mode_ip,
11147 (void *)&cmd_flow_director_ops,
11148 (void *)&cmd_flow_director_flow,
11149 (void *)&cmd_flow_director_flow_type,
11150 (void *)&cmd_flow_director_src,
11151 (void *)&cmd_flow_director_ip_src,
11152 (void *)&cmd_flow_director_dst,
11153 (void *)&cmd_flow_director_ip_dst,
11154 (void *)&cmd_flow_director_tos,
11155 (void *)&cmd_flow_director_tos_value,
11156 (void *)&cmd_flow_director_proto,
11157 (void *)&cmd_flow_director_proto_value,
11158 (void *)&cmd_flow_director_ttl,
11159 (void *)&cmd_flow_director_ttl_value,
11160 (void *)&cmd_flow_director_vlan,
11161 (void *)&cmd_flow_director_vlan_value,
11162 (void *)&cmd_flow_director_flexbytes,
11163 (void *)&cmd_flow_director_flexbytes_value,
11164 (void *)&cmd_flow_director_drop,
11165 (void *)&cmd_flow_director_pf_vf,
11166 (void *)&cmd_flow_director_queue,
11167 (void *)&cmd_flow_director_queue_id,
11168 (void *)&cmd_flow_director_fd_id,
11169 (void *)&cmd_flow_director_fd_id_value,
11174 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11175 .f = cmd_flow_director_filter_parsed,
11177 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11178 "director entry on NIC",
11180 (void *)&cmd_flow_director_filter,
11181 (void *)&cmd_flow_director_port_id,
11182 (void *)&cmd_flow_director_mode,
11183 (void *)&cmd_flow_director_mode_ip,
11184 (void *)&cmd_flow_director_ops,
11185 (void *)&cmd_flow_director_flow,
11186 (void *)&cmd_flow_director_flow_type,
11187 (void *)&cmd_flow_director_src,
11188 (void *)&cmd_flow_director_ip_src,
11189 (void *)&cmd_flow_director_port_src,
11190 (void *)&cmd_flow_director_dst,
11191 (void *)&cmd_flow_director_ip_dst,
11192 (void *)&cmd_flow_director_port_dst,
11193 (void *)&cmd_flow_director_tos,
11194 (void *)&cmd_flow_director_tos_value,
11195 (void *)&cmd_flow_director_ttl,
11196 (void *)&cmd_flow_director_ttl_value,
11197 (void *)&cmd_flow_director_vlan,
11198 (void *)&cmd_flow_director_vlan_value,
11199 (void *)&cmd_flow_director_flexbytes,
11200 (void *)&cmd_flow_director_flexbytes_value,
11201 (void *)&cmd_flow_director_drop,
11202 (void *)&cmd_flow_director_pf_vf,
11203 (void *)&cmd_flow_director_queue,
11204 (void *)&cmd_flow_director_queue_id,
11205 (void *)&cmd_flow_director_fd_id,
11206 (void *)&cmd_flow_director_fd_id_value,
11211 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11212 .f = cmd_flow_director_filter_parsed,
11214 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11215 "director entry on NIC",
11217 (void *)&cmd_flow_director_filter,
11218 (void *)&cmd_flow_director_port_id,
11219 (void *)&cmd_flow_director_mode,
11220 (void *)&cmd_flow_director_mode_ip,
11221 (void *)&cmd_flow_director_ops,
11222 (void *)&cmd_flow_director_flow,
11223 (void *)&cmd_flow_director_flow_type,
11224 (void *)&cmd_flow_director_src,
11225 (void *)&cmd_flow_director_ip_src,
11226 (void *)&cmd_flow_director_port_src,
11227 (void *)&cmd_flow_director_dst,
11228 (void *)&cmd_flow_director_ip_dst,
11229 (void *)&cmd_flow_director_port_dst,
11230 (void *)&cmd_flow_director_verify_tag,
11231 (void *)&cmd_flow_director_verify_tag_value,
11232 (void *)&cmd_flow_director_tos,
11233 (void *)&cmd_flow_director_tos_value,
11234 (void *)&cmd_flow_director_ttl,
11235 (void *)&cmd_flow_director_ttl_value,
11236 (void *)&cmd_flow_director_vlan,
11237 (void *)&cmd_flow_director_vlan_value,
11238 (void *)&cmd_flow_director_flexbytes,
11239 (void *)&cmd_flow_director_flexbytes_value,
11240 (void *)&cmd_flow_director_drop,
11241 (void *)&cmd_flow_director_pf_vf,
11242 (void *)&cmd_flow_director_queue,
11243 (void *)&cmd_flow_director_queue_id,
11244 (void *)&cmd_flow_director_fd_id,
11245 (void *)&cmd_flow_director_fd_id_value,
11250 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11251 .f = cmd_flow_director_filter_parsed,
11253 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11254 "director entry on NIC",
11256 (void *)&cmd_flow_director_filter,
11257 (void *)&cmd_flow_director_port_id,
11258 (void *)&cmd_flow_director_mode,
11259 (void *)&cmd_flow_director_mode_ip,
11260 (void *)&cmd_flow_director_ops,
11261 (void *)&cmd_flow_director_flow,
11262 (void *)&cmd_flow_director_flow_type,
11263 (void *)&cmd_flow_director_ether,
11264 (void *)&cmd_flow_director_ether_type,
11265 (void *)&cmd_flow_director_flexbytes,
11266 (void *)&cmd_flow_director_flexbytes_value,
11267 (void *)&cmd_flow_director_drop,
11268 (void *)&cmd_flow_director_pf_vf,
11269 (void *)&cmd_flow_director_queue,
11270 (void *)&cmd_flow_director_queue_id,
11271 (void *)&cmd_flow_director_fd_id,
11272 (void *)&cmd_flow_director_fd_id_value,
11277 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11278 .f = cmd_flow_director_filter_parsed,
11280 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11281 "director entry on NIC",
11283 (void *)&cmd_flow_director_filter,
11284 (void *)&cmd_flow_director_port_id,
11285 (void *)&cmd_flow_director_mode,
11286 (void *)&cmd_flow_director_mode_mac_vlan,
11287 (void *)&cmd_flow_director_ops,
11288 (void *)&cmd_flow_director_mac,
11289 (void *)&cmd_flow_director_mac_addr,
11290 (void *)&cmd_flow_director_vlan,
11291 (void *)&cmd_flow_director_vlan_value,
11292 (void *)&cmd_flow_director_flexbytes,
11293 (void *)&cmd_flow_director_flexbytes_value,
11294 (void *)&cmd_flow_director_drop,
11295 (void *)&cmd_flow_director_queue,
11296 (void *)&cmd_flow_director_queue_id,
11297 (void *)&cmd_flow_director_fd_id,
11298 (void *)&cmd_flow_director_fd_id_value,
11303 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11304 .f = cmd_flow_director_filter_parsed,
11306 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11307 "director entry on NIC",
11309 (void *)&cmd_flow_director_filter,
11310 (void *)&cmd_flow_director_port_id,
11311 (void *)&cmd_flow_director_mode,
11312 (void *)&cmd_flow_director_mode_tunnel,
11313 (void *)&cmd_flow_director_ops,
11314 (void *)&cmd_flow_director_mac,
11315 (void *)&cmd_flow_director_mac_addr,
11316 (void *)&cmd_flow_director_vlan,
11317 (void *)&cmd_flow_director_vlan_value,
11318 (void *)&cmd_flow_director_tunnel,
11319 (void *)&cmd_flow_director_tunnel_type,
11320 (void *)&cmd_flow_director_tunnel_id,
11321 (void *)&cmd_flow_director_tunnel_id_value,
11322 (void *)&cmd_flow_director_flexbytes,
11323 (void *)&cmd_flow_director_flexbytes_value,
11324 (void *)&cmd_flow_director_drop,
11325 (void *)&cmd_flow_director_queue,
11326 (void *)&cmd_flow_director_queue_id,
11327 (void *)&cmd_flow_director_fd_id,
11328 (void *)&cmd_flow_director_fd_id_value,
11333 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11334 .f = cmd_flow_director_filter_parsed,
11336 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11337 "director entry on NIC",
11339 (void *)&cmd_flow_director_filter,
11340 (void *)&cmd_flow_director_port_id,
11341 (void *)&cmd_flow_director_mode,
11342 (void *)&cmd_flow_director_mode_raw,
11343 (void *)&cmd_flow_director_ops,
11344 (void *)&cmd_flow_director_flow,
11345 (void *)&cmd_flow_director_flow_type,
11346 (void *)&cmd_flow_director_drop,
11347 (void *)&cmd_flow_director_queue,
11348 (void *)&cmd_flow_director_queue_id,
11349 (void *)&cmd_flow_director_fd_id,
11350 (void *)&cmd_flow_director_fd_id_value,
11351 (void *)&cmd_flow_director_packet,
11352 (void *)&cmd_flow_director_filepath,
11357 struct cmd_flush_flow_director_result {
11358 cmdline_fixed_string_t flush_flow_director;
11362 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11363 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11364 flush_flow_director, "flush_flow_director");
11365 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11366 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11370 cmd_flush_flow_director_parsed(void *parsed_result,
11371 __attribute__((unused)) struct cmdline *cl,
11372 __attribute__((unused)) void *data)
11374 struct cmd_flow_director_result *res = parsed_result;
11377 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11379 printf("flow director is not supported on port %u.\n",
11384 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11385 RTE_ETH_FILTER_FLUSH, NULL);
11387 printf("flow director table flushing error: (%s)\n",
11391 cmdline_parse_inst_t cmd_flush_flow_director = {
11392 .f = cmd_flush_flow_director_parsed,
11394 .help_str = "flush_flow_director <port_id>: "
11395 "Flush all flow director entries of a device on NIC",
11397 (void *)&cmd_flush_flow_director_flush,
11398 (void *)&cmd_flush_flow_director_port_id,
11403 /* *** deal with flow director mask *** */
11404 struct cmd_flow_director_mask_result {
11405 cmdline_fixed_string_t flow_director_mask;
11407 cmdline_fixed_string_t mode;
11408 cmdline_fixed_string_t mode_value;
11409 cmdline_fixed_string_t vlan;
11410 uint16_t vlan_mask;
11411 cmdline_fixed_string_t src_mask;
11412 cmdline_ipaddr_t ipv4_src;
11413 cmdline_ipaddr_t ipv6_src;
11415 cmdline_fixed_string_t dst_mask;
11416 cmdline_ipaddr_t ipv4_dst;
11417 cmdline_ipaddr_t ipv6_dst;
11419 cmdline_fixed_string_t mac;
11420 uint8_t mac_addr_byte_mask;
11421 cmdline_fixed_string_t tunnel_id;
11422 uint32_t tunnel_id_mask;
11423 cmdline_fixed_string_t tunnel_type;
11424 uint8_t tunnel_type_mask;
11428 cmd_flow_director_mask_parsed(void *parsed_result,
11429 __attribute__((unused)) struct cmdline *cl,
11430 __attribute__((unused)) void *data)
11432 struct cmd_flow_director_mask_result *res = parsed_result;
11433 struct rte_eth_fdir_masks *mask;
11434 struct rte_port *port;
11436 port = &ports[res->port_id];
11437 /** Check if the port is not started **/
11438 if (port->port_status != RTE_PORT_STOPPED) {
11439 printf("Please stop port %d first\n", res->port_id);
11443 mask = &port->dev_conf.fdir_conf.mask;
11445 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11446 if (strcmp(res->mode_value, "MAC-VLAN")) {
11447 printf("Please set mode to MAC-VLAN.\n");
11451 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11452 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11453 if (strcmp(res->mode_value, "Tunnel")) {
11454 printf("Please set mode to Tunnel.\n");
11458 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11459 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11460 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11461 mask->tunnel_type_mask = res->tunnel_type_mask;
11463 if (strcmp(res->mode_value, "IP")) {
11464 printf("Please set mode to IP.\n");
11468 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11469 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11470 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11471 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11472 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11473 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11474 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11477 cmd_reconfig_device_queue(res->port_id, 1, 1);
11480 cmdline_parse_token_string_t cmd_flow_director_mask =
11481 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11482 flow_director_mask, "flow_director_mask");
11483 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11484 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11486 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11487 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11489 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11490 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11491 vlan_mask, UINT16);
11492 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11493 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11494 src_mask, "src_mask");
11495 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11496 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11498 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11499 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11501 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11502 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11504 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11505 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11506 dst_mask, "dst_mask");
11507 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11508 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11510 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11511 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11513 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11514 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11517 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11518 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11520 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11523 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11524 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11525 mode_value, "MAC-VLAN");
11526 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11527 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11528 mode_value, "Tunnel");
11529 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11530 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11532 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11533 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11534 mac_addr_byte_mask, UINT8);
11535 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11536 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11537 tunnel_type, "tunnel-type");
11538 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11539 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11540 tunnel_type_mask, UINT8);
11541 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11542 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11543 tunnel_id, "tunnel-id");
11544 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11545 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11546 tunnel_id_mask, UINT32);
11548 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11549 .f = cmd_flow_director_mask_parsed,
11551 .help_str = "flow_director_mask ... : "
11552 "Set IP mode flow director's mask on NIC",
11554 (void *)&cmd_flow_director_mask,
11555 (void *)&cmd_flow_director_mask_port_id,
11556 (void *)&cmd_flow_director_mask_mode,
11557 (void *)&cmd_flow_director_mask_mode_ip,
11558 (void *)&cmd_flow_director_mask_vlan,
11559 (void *)&cmd_flow_director_mask_vlan_value,
11560 (void *)&cmd_flow_director_mask_src,
11561 (void *)&cmd_flow_director_mask_ipv4_src,
11562 (void *)&cmd_flow_director_mask_ipv6_src,
11563 (void *)&cmd_flow_director_mask_port_src,
11564 (void *)&cmd_flow_director_mask_dst,
11565 (void *)&cmd_flow_director_mask_ipv4_dst,
11566 (void *)&cmd_flow_director_mask_ipv6_dst,
11567 (void *)&cmd_flow_director_mask_port_dst,
11572 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11573 .f = cmd_flow_director_mask_parsed,
11575 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11576 "flow director's mask on NIC",
11578 (void *)&cmd_flow_director_mask,
11579 (void *)&cmd_flow_director_mask_port_id,
11580 (void *)&cmd_flow_director_mask_mode,
11581 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11582 (void *)&cmd_flow_director_mask_vlan,
11583 (void *)&cmd_flow_director_mask_vlan_value,
11588 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11589 .f = cmd_flow_director_mask_parsed,
11591 .help_str = "flow_director_mask ... : Set tunnel mode "
11592 "flow director's mask on NIC",
11594 (void *)&cmd_flow_director_mask,
11595 (void *)&cmd_flow_director_mask_port_id,
11596 (void *)&cmd_flow_director_mask_mode,
11597 (void *)&cmd_flow_director_mask_mode_tunnel,
11598 (void *)&cmd_flow_director_mask_vlan,
11599 (void *)&cmd_flow_director_mask_vlan_value,
11600 (void *)&cmd_flow_director_mask_mac,
11601 (void *)&cmd_flow_director_mask_mac_value,
11602 (void *)&cmd_flow_director_mask_tunnel_type,
11603 (void *)&cmd_flow_director_mask_tunnel_type_value,
11604 (void *)&cmd_flow_director_mask_tunnel_id,
11605 (void *)&cmd_flow_director_mask_tunnel_id_value,
11610 /* *** deal with flow director mask on flexible payload *** */
11611 struct cmd_flow_director_flex_mask_result {
11612 cmdline_fixed_string_t flow_director_flexmask;
11614 cmdline_fixed_string_t flow;
11615 cmdline_fixed_string_t flow_type;
11616 cmdline_fixed_string_t mask;
11620 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11621 __attribute__((unused)) struct cmdline *cl,
11622 __attribute__((unused)) void *data)
11624 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11625 struct rte_eth_fdir_info fdir_info;
11626 struct rte_eth_fdir_flex_mask flex_mask;
11627 struct rte_port *port;
11628 uint64_t flow_type_mask;
11632 port = &ports[res->port_id];
11633 /** Check if the port is not started **/
11634 if (port->port_status != RTE_PORT_STOPPED) {
11635 printf("Please stop port %d first\n", res->port_id);
11639 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11640 ret = parse_flexbytes(res->mask,
11642 RTE_ETH_FDIR_MAX_FLEXLEN);
11644 printf("error: Cannot parse mask input.\n");
11648 memset(&fdir_info, 0, sizeof(fdir_info));
11649 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11650 RTE_ETH_FILTER_INFO, &fdir_info);
11652 printf("Cannot get FDir filter info\n");
11656 if (!strcmp(res->flow_type, "none")) {
11657 /* means don't specify the flow type */
11658 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11659 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11660 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11661 0, sizeof(struct rte_eth_fdir_flex_mask));
11662 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11663 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11665 sizeof(struct rte_eth_fdir_flex_mask));
11666 cmd_reconfig_device_queue(res->port_id, 1, 1);
11669 flow_type_mask = fdir_info.flow_types_mask[0];
11670 if (!strcmp(res->flow_type, "all")) {
11671 if (!flow_type_mask) {
11672 printf("No flow type supported\n");
11675 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11676 if (flow_type_mask & (1ULL << i)) {
11677 flex_mask.flow_type = i;
11678 fdir_set_flex_mask(res->port_id, &flex_mask);
11681 cmd_reconfig_device_queue(res->port_id, 1, 1);
11684 flex_mask.flow_type = str2flowtype(res->flow_type);
11685 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11686 printf("Flow type %s not supported on port %d\n",
11687 res->flow_type, res->port_id);
11690 fdir_set_flex_mask(res->port_id, &flex_mask);
11691 cmd_reconfig_device_queue(res->port_id, 1, 1);
11694 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11696 flow_director_flexmask,
11697 "flow_director_flex_mask");
11698 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11699 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11701 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11702 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11704 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11706 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11707 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11708 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11709 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11712 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11713 .f = cmd_flow_director_flex_mask_parsed,
11715 .help_str = "flow_director_flex_mask ... : "
11716 "Set flow director's flex mask on NIC",
11718 (void *)&cmd_flow_director_flexmask,
11719 (void *)&cmd_flow_director_flexmask_port_id,
11720 (void *)&cmd_flow_director_flexmask_flow,
11721 (void *)&cmd_flow_director_flexmask_flow_type,
11722 (void *)&cmd_flow_director_flexmask_mask,
11727 /* *** deal with flow director flexible payload configuration *** */
11728 struct cmd_flow_director_flexpayload_result {
11729 cmdline_fixed_string_t flow_director_flexpayload;
11731 cmdline_fixed_string_t payload_layer;
11732 cmdline_fixed_string_t payload_cfg;
11736 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11739 const char *p, *p0 = q_arg;
11741 unsigned long int_fld;
11742 char *str_fld[max_num];
11747 p = strchr(p0, '(');
11751 p0 = strchr(p, ')');
11756 if (size >= sizeof(s))
11759 snprintf(s, sizeof(s), "%.*s", size, p);
11760 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11761 if (ret < 0 || ret > max_num)
11763 for (i = 0; i < ret; i++) {
11765 int_fld = strtoul(str_fld[i], &end, 0);
11766 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11768 offsets[i] = (uint16_t)int_fld;
11774 cmd_flow_director_flxpld_parsed(void *parsed_result,
11775 __attribute__((unused)) struct cmdline *cl,
11776 __attribute__((unused)) void *data)
11778 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11779 struct rte_eth_flex_payload_cfg flex_cfg;
11780 struct rte_port *port;
11783 port = &ports[res->port_id];
11784 /** Check if the port is not started **/
11785 if (port->port_status != RTE_PORT_STOPPED) {
11786 printf("Please stop port %d first\n", res->port_id);
11790 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11792 if (!strcmp(res->payload_layer, "raw"))
11793 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11794 else if (!strcmp(res->payload_layer, "l2"))
11795 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11796 else if (!strcmp(res->payload_layer, "l3"))
11797 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11798 else if (!strcmp(res->payload_layer, "l4"))
11799 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11801 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11802 RTE_ETH_FDIR_MAX_FLEXLEN);
11804 printf("error: Cannot parse flex payload input.\n");
11808 fdir_set_flex_payload(res->port_id, &flex_cfg);
11809 cmd_reconfig_device_queue(res->port_id, 1, 1);
11812 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11813 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11814 flow_director_flexpayload,
11815 "flow_director_flex_payload");
11816 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11817 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11819 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11820 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11821 payload_layer, "raw#l2#l3#l4");
11822 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11824 payload_cfg, NULL);
11826 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11827 .f = cmd_flow_director_flxpld_parsed,
11829 .help_str = "flow_director_flexpayload ... : "
11830 "Set flow director's flex payload on NIC",
11832 (void *)&cmd_flow_director_flexpayload,
11833 (void *)&cmd_flow_director_flexpayload_port_id,
11834 (void *)&cmd_flow_director_flexpayload_payload_layer,
11835 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11840 /* Generic flow interface command. */
11841 extern cmdline_parse_inst_t cmd_flow;
11843 /* *** Classification Filters Control *** */
11844 /* *** Get symmetric hash enable per port *** */
11845 struct cmd_get_sym_hash_ena_per_port_result {
11846 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11851 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11852 __rte_unused struct cmdline *cl,
11853 __rte_unused void *data)
11855 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11856 struct rte_eth_hash_filter_info info;
11859 if (rte_eth_dev_filter_supported(res->port_id,
11860 RTE_ETH_FILTER_HASH) < 0) {
11861 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11866 memset(&info, 0, sizeof(info));
11867 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11868 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11869 RTE_ETH_FILTER_GET, &info);
11872 printf("Cannot get symmetric hash enable per port "
11873 "on port %u\n", res->port_id);
11877 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11878 "enabled" : "disabled", res->port_id);
11881 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11882 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11883 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11884 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11885 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11888 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11889 .f = cmd_get_sym_hash_per_port_parsed,
11891 .help_str = "get_sym_hash_ena_per_port <port_id>",
11893 (void *)&cmd_get_sym_hash_ena_per_port_all,
11894 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11899 /* *** Set symmetric hash enable per port *** */
11900 struct cmd_set_sym_hash_ena_per_port_result {
11901 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11902 cmdline_fixed_string_t enable;
11907 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11908 __rte_unused struct cmdline *cl,
11909 __rte_unused void *data)
11911 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11912 struct rte_eth_hash_filter_info info;
11915 if (rte_eth_dev_filter_supported(res->port_id,
11916 RTE_ETH_FILTER_HASH) < 0) {
11917 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11922 memset(&info, 0, sizeof(info));
11923 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11924 if (!strcmp(res->enable, "enable"))
11925 info.info.enable = 1;
11926 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11927 RTE_ETH_FILTER_SET, &info);
11929 printf("Cannot set symmetric hash enable per port on "
11930 "port %u\n", res->port_id);
11933 printf("Symmetric hash has been set to %s on port %u\n",
11934 res->enable, res->port_id);
11937 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11938 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11939 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11940 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11941 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11943 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11944 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11945 enable, "enable#disable");
11947 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11948 .f = cmd_set_sym_hash_per_port_parsed,
11950 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11952 (void *)&cmd_set_sym_hash_ena_per_port_all,
11953 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11954 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11959 /* Get global config of hash function */
11960 struct cmd_get_hash_global_config_result {
11961 cmdline_fixed_string_t get_hash_global_config;
11966 flowtype_to_str(uint16_t ftype)
11972 } ftype_table[] = {
11973 {"ipv4", RTE_ETH_FLOW_IPV4},
11974 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11975 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11976 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11977 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11978 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11979 {"ipv6", RTE_ETH_FLOW_IPV6},
11980 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11981 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11982 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11983 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11984 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11985 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11986 {"port", RTE_ETH_FLOW_PORT},
11987 {"vxlan", RTE_ETH_FLOW_VXLAN},
11988 {"geneve", RTE_ETH_FLOW_GENEVE},
11989 {"nvgre", RTE_ETH_FLOW_NVGRE},
11992 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11993 if (ftype_table[i].ftype == ftype)
11994 return ftype_table[i].str;
12001 cmd_get_hash_global_config_parsed(void *parsed_result,
12002 __rte_unused struct cmdline *cl,
12003 __rte_unused void *data)
12005 struct cmd_get_hash_global_config_result *res = parsed_result;
12006 struct rte_eth_hash_filter_info info;
12007 uint32_t idx, offset;
12012 if (rte_eth_dev_filter_supported(res->port_id,
12013 RTE_ETH_FILTER_HASH) < 0) {
12014 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12019 memset(&info, 0, sizeof(info));
12020 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12021 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12022 RTE_ETH_FILTER_GET, &info);
12024 printf("Cannot get hash global configurations by port %d\n",
12029 switch (info.info.global_conf.hash_func) {
12030 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12031 printf("Hash function is Toeplitz\n");
12033 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12034 printf("Hash function is Simple XOR\n");
12037 printf("Unknown hash function\n");
12041 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12042 idx = i / UINT64_BIT;
12043 offset = i % UINT64_BIT;
12044 if (!(info.info.global_conf.valid_bit_mask[idx] &
12047 str = flowtype_to_str(i);
12050 printf("Symmetric hash is %s globally for flow type %s "
12052 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12053 (1ULL << offset)) ? "enabled" : "disabled"), str,
12058 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12059 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12060 get_hash_global_config, "get_hash_global_config");
12061 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12062 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12065 cmdline_parse_inst_t cmd_get_hash_global_config = {
12066 .f = cmd_get_hash_global_config_parsed,
12068 .help_str = "get_hash_global_config <port_id>",
12070 (void *)&cmd_get_hash_global_config_all,
12071 (void *)&cmd_get_hash_global_config_port_id,
12076 /* Set global config of hash function */
12077 struct cmd_set_hash_global_config_result {
12078 cmdline_fixed_string_t set_hash_global_config;
12080 cmdline_fixed_string_t hash_func;
12081 cmdline_fixed_string_t flow_type;
12082 cmdline_fixed_string_t enable;
12086 cmd_set_hash_global_config_parsed(void *parsed_result,
12087 __rte_unused struct cmdline *cl,
12088 __rte_unused void *data)
12090 struct cmd_set_hash_global_config_result *res = parsed_result;
12091 struct rte_eth_hash_filter_info info;
12092 uint32_t ftype, idx, offset;
12095 if (rte_eth_dev_filter_supported(res->port_id,
12096 RTE_ETH_FILTER_HASH) < 0) {
12097 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12101 memset(&info, 0, sizeof(info));
12102 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12103 if (!strcmp(res->hash_func, "toeplitz"))
12104 info.info.global_conf.hash_func =
12105 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12106 else if (!strcmp(res->hash_func, "simple_xor"))
12107 info.info.global_conf.hash_func =
12108 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12109 else if (!strcmp(res->hash_func, "default"))
12110 info.info.global_conf.hash_func =
12111 RTE_ETH_HASH_FUNCTION_DEFAULT;
12113 ftype = str2flowtype(res->flow_type);
12114 idx = ftype / UINT64_BIT;
12115 offset = ftype % UINT64_BIT;
12116 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12117 if (!strcmp(res->enable, "enable"))
12118 info.info.global_conf.sym_hash_enable_mask[idx] |=
12120 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12121 RTE_ETH_FILTER_SET, &info);
12123 printf("Cannot set global hash configurations by port %d\n",
12126 printf("Global hash configurations have been set "
12127 "successfully by port %d\n", res->port_id);
12130 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12131 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12132 set_hash_global_config, "set_hash_global_config");
12133 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12134 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12136 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12137 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12138 hash_func, "toeplitz#simple_xor#default");
12139 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12140 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12142 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12143 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12144 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12145 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12146 enable, "enable#disable");
12148 cmdline_parse_inst_t cmd_set_hash_global_config = {
12149 .f = cmd_set_hash_global_config_parsed,
12151 .help_str = "set_hash_global_config <port_id> "
12152 "toeplitz|simple_xor|default "
12153 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12154 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12155 "l2_payload enable|disable",
12157 (void *)&cmd_set_hash_global_config_all,
12158 (void *)&cmd_set_hash_global_config_port_id,
12159 (void *)&cmd_set_hash_global_config_hash_func,
12160 (void *)&cmd_set_hash_global_config_flow_type,
12161 (void *)&cmd_set_hash_global_config_enable,
12166 /* Set hash input set */
12167 struct cmd_set_hash_input_set_result {
12168 cmdline_fixed_string_t set_hash_input_set;
12170 cmdline_fixed_string_t flow_type;
12171 cmdline_fixed_string_t inset_field;
12172 cmdline_fixed_string_t select;
12175 static enum rte_eth_input_set_field
12176 str2inset(char *string)
12180 static const struct {
12182 enum rte_eth_input_set_field inset;
12183 } inset_table[] = {
12184 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12185 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12186 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12187 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12188 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12189 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12190 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12191 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12192 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12193 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12194 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12195 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12196 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12197 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12198 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12199 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12200 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12201 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12202 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12203 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12204 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12205 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12206 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12207 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12208 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12209 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12210 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12211 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12212 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12213 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12214 {"none", RTE_ETH_INPUT_SET_NONE},
12217 for (i = 0; i < RTE_DIM(inset_table); i++) {
12218 if (!strcmp(string, inset_table[i].str))
12219 return inset_table[i].inset;
12222 return RTE_ETH_INPUT_SET_UNKNOWN;
12226 cmd_set_hash_input_set_parsed(void *parsed_result,
12227 __rte_unused struct cmdline *cl,
12228 __rte_unused void *data)
12230 struct cmd_set_hash_input_set_result *res = parsed_result;
12231 struct rte_eth_hash_filter_info info;
12233 memset(&info, 0, sizeof(info));
12234 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12235 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12236 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12237 info.info.input_set_conf.inset_size = 1;
12238 if (!strcmp(res->select, "select"))
12239 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12240 else if (!strcmp(res->select, "add"))
12241 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12242 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12243 RTE_ETH_FILTER_SET, &info);
12246 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12247 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12248 set_hash_input_set, "set_hash_input_set");
12249 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12250 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12252 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12253 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12255 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12256 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12258 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12259 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12260 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12261 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12262 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12264 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12265 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12266 select, "select#add");
12268 cmdline_parse_inst_t cmd_set_hash_input_set = {
12269 .f = cmd_set_hash_input_set_parsed,
12271 .help_str = "set_hash_input_set <port_id> "
12272 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12273 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12274 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12275 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12276 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12277 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12278 "fld-7th|fld-8th|none select|add",
12280 (void *)&cmd_set_hash_input_set_cmd,
12281 (void *)&cmd_set_hash_input_set_port_id,
12282 (void *)&cmd_set_hash_input_set_flow_type,
12283 (void *)&cmd_set_hash_input_set_field,
12284 (void *)&cmd_set_hash_input_set_select,
12289 /* Set flow director input set */
12290 struct cmd_set_fdir_input_set_result {
12291 cmdline_fixed_string_t set_fdir_input_set;
12293 cmdline_fixed_string_t flow_type;
12294 cmdline_fixed_string_t inset_field;
12295 cmdline_fixed_string_t select;
12299 cmd_set_fdir_input_set_parsed(void *parsed_result,
12300 __rte_unused struct cmdline *cl,
12301 __rte_unused void *data)
12303 struct cmd_set_fdir_input_set_result *res = parsed_result;
12304 struct rte_eth_fdir_filter_info info;
12306 memset(&info, 0, sizeof(info));
12307 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12308 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12309 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12310 info.info.input_set_conf.inset_size = 1;
12311 if (!strcmp(res->select, "select"))
12312 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12313 else if (!strcmp(res->select, "add"))
12314 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12315 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12316 RTE_ETH_FILTER_SET, &info);
12319 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12320 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12321 set_fdir_input_set, "set_fdir_input_set");
12322 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12323 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12325 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12326 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12328 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12329 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12330 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12331 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12333 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12334 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12335 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12336 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12337 "sctp-veri-tag#none");
12338 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12339 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12340 select, "select#add");
12342 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12343 .f = cmd_set_fdir_input_set_parsed,
12345 .help_str = "set_fdir_input_set <port_id> "
12346 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12347 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12348 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12349 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12350 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12351 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12352 "sctp-veri-tag|none select|add",
12354 (void *)&cmd_set_fdir_input_set_cmd,
12355 (void *)&cmd_set_fdir_input_set_port_id,
12356 (void *)&cmd_set_fdir_input_set_flow_type,
12357 (void *)&cmd_set_fdir_input_set_field,
12358 (void *)&cmd_set_fdir_input_set_select,
12363 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12364 struct cmd_mcast_addr_result {
12365 cmdline_fixed_string_t mcast_addr_cmd;
12366 cmdline_fixed_string_t what;
12368 struct ether_addr mc_addr;
12371 static void cmd_mcast_addr_parsed(void *parsed_result,
12372 __attribute__((unused)) struct cmdline *cl,
12373 __attribute__((unused)) void *data)
12375 struct cmd_mcast_addr_result *res = parsed_result;
12377 if (!is_multicast_ether_addr(&res->mc_addr)) {
12378 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12379 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12380 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12381 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12384 if (strcmp(res->what, "add") == 0)
12385 mcast_addr_add(res->port_num, &res->mc_addr);
12387 mcast_addr_remove(res->port_num, &res->mc_addr);
12390 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12391 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12392 mcast_addr_cmd, "mcast_addr");
12393 cmdline_parse_token_string_t cmd_mcast_addr_what =
12394 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12396 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12397 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12398 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12399 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12401 cmdline_parse_inst_t cmd_mcast_addr = {
12402 .f = cmd_mcast_addr_parsed,
12404 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12405 "Add/Remove multicast MAC address on port_id",
12407 (void *)&cmd_mcast_addr_cmd,
12408 (void *)&cmd_mcast_addr_what,
12409 (void *)&cmd_mcast_addr_portnum,
12410 (void *)&cmd_mcast_addr_addr,
12415 /* l2 tunnel config
12416 * only support E-tag now.
12419 /* Ether type config */
12420 struct cmd_config_l2_tunnel_eth_type_result {
12421 cmdline_fixed_string_t port;
12422 cmdline_fixed_string_t config;
12423 cmdline_fixed_string_t all;
12425 cmdline_fixed_string_t l2_tunnel;
12426 cmdline_fixed_string_t l2_tunnel_type;
12427 cmdline_fixed_string_t eth_type;
12428 uint16_t eth_type_val;
12431 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12432 TOKEN_STRING_INITIALIZER
12433 (struct cmd_config_l2_tunnel_eth_type_result,
12435 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12436 TOKEN_STRING_INITIALIZER
12437 (struct cmd_config_l2_tunnel_eth_type_result,
12439 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12440 TOKEN_STRING_INITIALIZER
12441 (struct cmd_config_l2_tunnel_eth_type_result,
12443 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12444 TOKEN_NUM_INITIALIZER
12445 (struct cmd_config_l2_tunnel_eth_type_result,
12447 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12448 TOKEN_STRING_INITIALIZER
12449 (struct cmd_config_l2_tunnel_eth_type_result,
12450 l2_tunnel, "l2-tunnel");
12451 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12452 TOKEN_STRING_INITIALIZER
12453 (struct cmd_config_l2_tunnel_eth_type_result,
12454 l2_tunnel_type, "E-tag");
12455 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12456 TOKEN_STRING_INITIALIZER
12457 (struct cmd_config_l2_tunnel_eth_type_result,
12458 eth_type, "ether-type");
12459 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12460 TOKEN_NUM_INITIALIZER
12461 (struct cmd_config_l2_tunnel_eth_type_result,
12462 eth_type_val, UINT16);
12464 static enum rte_eth_tunnel_type
12465 str2fdir_l2_tunnel_type(char *string)
12469 static const struct {
12471 enum rte_eth_tunnel_type type;
12472 } l2_tunnel_type_str[] = {
12473 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12476 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12477 if (!strcmp(l2_tunnel_type_str[i].str, string))
12478 return l2_tunnel_type_str[i].type;
12480 return RTE_TUNNEL_TYPE_NONE;
12483 /* ether type config for all ports */
12485 cmd_config_l2_tunnel_eth_type_all_parsed
12486 (void *parsed_result,
12487 __attribute__((unused)) struct cmdline *cl,
12488 __attribute__((unused)) void *data)
12490 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12491 struct rte_eth_l2_tunnel_conf entry;
12494 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12495 entry.ether_type = res->eth_type_val;
12497 RTE_ETH_FOREACH_DEV(pid) {
12498 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12502 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12503 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12505 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12507 (void *)&cmd_config_l2_tunnel_eth_type_port,
12508 (void *)&cmd_config_l2_tunnel_eth_type_config,
12509 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12510 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12511 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12512 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12513 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12518 /* ether type config for a specific port */
12520 cmd_config_l2_tunnel_eth_type_specific_parsed(
12521 void *parsed_result,
12522 __attribute__((unused)) struct cmdline *cl,
12523 __attribute__((unused)) void *data)
12525 struct cmd_config_l2_tunnel_eth_type_result *res =
12527 struct rte_eth_l2_tunnel_conf entry;
12529 if (port_id_is_invalid(res->id, ENABLED_WARN))
12532 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12533 entry.ether_type = res->eth_type_val;
12535 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12538 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12539 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12541 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12543 (void *)&cmd_config_l2_tunnel_eth_type_port,
12544 (void *)&cmd_config_l2_tunnel_eth_type_config,
12545 (void *)&cmd_config_l2_tunnel_eth_type_id,
12546 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12547 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12548 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12549 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12554 /* Enable/disable l2 tunnel */
12555 struct cmd_config_l2_tunnel_en_dis_result {
12556 cmdline_fixed_string_t port;
12557 cmdline_fixed_string_t config;
12558 cmdline_fixed_string_t all;
12560 cmdline_fixed_string_t l2_tunnel;
12561 cmdline_fixed_string_t l2_tunnel_type;
12562 cmdline_fixed_string_t en_dis;
12565 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12566 TOKEN_STRING_INITIALIZER
12567 (struct cmd_config_l2_tunnel_en_dis_result,
12569 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12570 TOKEN_STRING_INITIALIZER
12571 (struct cmd_config_l2_tunnel_en_dis_result,
12573 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12574 TOKEN_STRING_INITIALIZER
12575 (struct cmd_config_l2_tunnel_en_dis_result,
12577 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12578 TOKEN_NUM_INITIALIZER
12579 (struct cmd_config_l2_tunnel_en_dis_result,
12581 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12582 TOKEN_STRING_INITIALIZER
12583 (struct cmd_config_l2_tunnel_en_dis_result,
12584 l2_tunnel, "l2-tunnel");
12585 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12586 TOKEN_STRING_INITIALIZER
12587 (struct cmd_config_l2_tunnel_en_dis_result,
12588 l2_tunnel_type, "E-tag");
12589 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12590 TOKEN_STRING_INITIALIZER
12591 (struct cmd_config_l2_tunnel_en_dis_result,
12592 en_dis, "enable#disable");
12594 /* enable/disable l2 tunnel for all ports */
12596 cmd_config_l2_tunnel_en_dis_all_parsed(
12597 void *parsed_result,
12598 __attribute__((unused)) struct cmdline *cl,
12599 __attribute__((unused)) void *data)
12601 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12602 struct rte_eth_l2_tunnel_conf entry;
12606 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12608 if (!strcmp("enable", res->en_dis))
12613 RTE_ETH_FOREACH_DEV(pid) {
12614 rte_eth_dev_l2_tunnel_offload_set(pid,
12616 ETH_L2_TUNNEL_ENABLE_MASK,
12621 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12622 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12624 .help_str = "port config all l2-tunnel E-tag enable|disable",
12626 (void *)&cmd_config_l2_tunnel_en_dis_port,
12627 (void *)&cmd_config_l2_tunnel_en_dis_config,
12628 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12629 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12630 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12631 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12636 /* enable/disable l2 tunnel for a port */
12638 cmd_config_l2_tunnel_en_dis_specific_parsed(
12639 void *parsed_result,
12640 __attribute__((unused)) struct cmdline *cl,
12641 __attribute__((unused)) void *data)
12643 struct cmd_config_l2_tunnel_en_dis_result *res =
12645 struct rte_eth_l2_tunnel_conf entry;
12647 if (port_id_is_invalid(res->id, ENABLED_WARN))
12650 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12652 if (!strcmp("enable", res->en_dis))
12653 rte_eth_dev_l2_tunnel_offload_set(res->id,
12655 ETH_L2_TUNNEL_ENABLE_MASK,
12658 rte_eth_dev_l2_tunnel_offload_set(res->id,
12660 ETH_L2_TUNNEL_ENABLE_MASK,
12664 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12665 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12667 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12669 (void *)&cmd_config_l2_tunnel_en_dis_port,
12670 (void *)&cmd_config_l2_tunnel_en_dis_config,
12671 (void *)&cmd_config_l2_tunnel_en_dis_id,
12672 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12673 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12674 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12679 /* E-tag configuration */
12681 /* Common result structure for all E-tag configuration */
12682 struct cmd_config_e_tag_result {
12683 cmdline_fixed_string_t e_tag;
12684 cmdline_fixed_string_t set;
12685 cmdline_fixed_string_t insertion;
12686 cmdline_fixed_string_t stripping;
12687 cmdline_fixed_string_t forwarding;
12688 cmdline_fixed_string_t filter;
12689 cmdline_fixed_string_t add;
12690 cmdline_fixed_string_t del;
12691 cmdline_fixed_string_t on;
12692 cmdline_fixed_string_t off;
12693 cmdline_fixed_string_t on_off;
12694 cmdline_fixed_string_t port_tag_id;
12695 uint32_t port_tag_id_val;
12696 cmdline_fixed_string_t e_tag_id;
12697 uint16_t e_tag_id_val;
12698 cmdline_fixed_string_t dst_pool;
12699 uint8_t dst_pool_val;
12700 cmdline_fixed_string_t port;
12702 cmdline_fixed_string_t vf;
12706 /* Common CLI fields for all E-tag configuration */
12707 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12708 TOKEN_STRING_INITIALIZER
12709 (struct cmd_config_e_tag_result,
12711 cmdline_parse_token_string_t cmd_config_e_tag_set =
12712 TOKEN_STRING_INITIALIZER
12713 (struct cmd_config_e_tag_result,
12715 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12716 TOKEN_STRING_INITIALIZER
12717 (struct cmd_config_e_tag_result,
12718 insertion, "insertion");
12719 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12720 TOKEN_STRING_INITIALIZER
12721 (struct cmd_config_e_tag_result,
12722 stripping, "stripping");
12723 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12724 TOKEN_STRING_INITIALIZER
12725 (struct cmd_config_e_tag_result,
12726 forwarding, "forwarding");
12727 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12728 TOKEN_STRING_INITIALIZER
12729 (struct cmd_config_e_tag_result,
12731 cmdline_parse_token_string_t cmd_config_e_tag_add =
12732 TOKEN_STRING_INITIALIZER
12733 (struct cmd_config_e_tag_result,
12735 cmdline_parse_token_string_t cmd_config_e_tag_del =
12736 TOKEN_STRING_INITIALIZER
12737 (struct cmd_config_e_tag_result,
12739 cmdline_parse_token_string_t cmd_config_e_tag_on =
12740 TOKEN_STRING_INITIALIZER
12741 (struct cmd_config_e_tag_result,
12743 cmdline_parse_token_string_t cmd_config_e_tag_off =
12744 TOKEN_STRING_INITIALIZER
12745 (struct cmd_config_e_tag_result,
12747 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12748 TOKEN_STRING_INITIALIZER
12749 (struct cmd_config_e_tag_result,
12751 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12752 TOKEN_STRING_INITIALIZER
12753 (struct cmd_config_e_tag_result,
12754 port_tag_id, "port-tag-id");
12755 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12756 TOKEN_NUM_INITIALIZER
12757 (struct cmd_config_e_tag_result,
12758 port_tag_id_val, UINT32);
12759 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12760 TOKEN_STRING_INITIALIZER
12761 (struct cmd_config_e_tag_result,
12762 e_tag_id, "e-tag-id");
12763 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12764 TOKEN_NUM_INITIALIZER
12765 (struct cmd_config_e_tag_result,
12766 e_tag_id_val, UINT16);
12767 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12768 TOKEN_STRING_INITIALIZER
12769 (struct cmd_config_e_tag_result,
12770 dst_pool, "dst-pool");
12771 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12772 TOKEN_NUM_INITIALIZER
12773 (struct cmd_config_e_tag_result,
12774 dst_pool_val, UINT8);
12775 cmdline_parse_token_string_t cmd_config_e_tag_port =
12776 TOKEN_STRING_INITIALIZER
12777 (struct cmd_config_e_tag_result,
12779 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12780 TOKEN_NUM_INITIALIZER
12781 (struct cmd_config_e_tag_result,
12783 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12784 TOKEN_STRING_INITIALIZER
12785 (struct cmd_config_e_tag_result,
12787 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12788 TOKEN_NUM_INITIALIZER
12789 (struct cmd_config_e_tag_result,
12792 /* E-tag insertion configuration */
12794 cmd_config_e_tag_insertion_en_parsed(
12795 void *parsed_result,
12796 __attribute__((unused)) struct cmdline *cl,
12797 __attribute__((unused)) void *data)
12799 struct cmd_config_e_tag_result *res =
12801 struct rte_eth_l2_tunnel_conf entry;
12803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12806 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12807 entry.tunnel_id = res->port_tag_id_val;
12808 entry.vf_id = res->vf_id;
12809 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12811 ETH_L2_TUNNEL_INSERTION_MASK,
12816 cmd_config_e_tag_insertion_dis_parsed(
12817 void *parsed_result,
12818 __attribute__((unused)) struct cmdline *cl,
12819 __attribute__((unused)) void *data)
12821 struct cmd_config_e_tag_result *res =
12823 struct rte_eth_l2_tunnel_conf entry;
12825 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12828 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12829 entry.vf_id = res->vf_id;
12831 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12833 ETH_L2_TUNNEL_INSERTION_MASK,
12837 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12838 .f = cmd_config_e_tag_insertion_en_parsed,
12840 .help_str = "E-tag ... : E-tag insertion enable",
12842 (void *)&cmd_config_e_tag_e_tag,
12843 (void *)&cmd_config_e_tag_set,
12844 (void *)&cmd_config_e_tag_insertion,
12845 (void *)&cmd_config_e_tag_on,
12846 (void *)&cmd_config_e_tag_port_tag_id,
12847 (void *)&cmd_config_e_tag_port_tag_id_val,
12848 (void *)&cmd_config_e_tag_port,
12849 (void *)&cmd_config_e_tag_port_id,
12850 (void *)&cmd_config_e_tag_vf,
12851 (void *)&cmd_config_e_tag_vf_id,
12856 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12857 .f = cmd_config_e_tag_insertion_dis_parsed,
12859 .help_str = "E-tag ... : E-tag insertion disable",
12861 (void *)&cmd_config_e_tag_e_tag,
12862 (void *)&cmd_config_e_tag_set,
12863 (void *)&cmd_config_e_tag_insertion,
12864 (void *)&cmd_config_e_tag_off,
12865 (void *)&cmd_config_e_tag_port,
12866 (void *)&cmd_config_e_tag_port_id,
12867 (void *)&cmd_config_e_tag_vf,
12868 (void *)&cmd_config_e_tag_vf_id,
12873 /* E-tag stripping configuration */
12875 cmd_config_e_tag_stripping_parsed(
12876 void *parsed_result,
12877 __attribute__((unused)) struct cmdline *cl,
12878 __attribute__((unused)) void *data)
12880 struct cmd_config_e_tag_result *res =
12882 struct rte_eth_l2_tunnel_conf entry;
12884 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12887 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12889 if (!strcmp(res->on_off, "on"))
12890 rte_eth_dev_l2_tunnel_offload_set
12893 ETH_L2_TUNNEL_STRIPPING_MASK,
12896 rte_eth_dev_l2_tunnel_offload_set
12899 ETH_L2_TUNNEL_STRIPPING_MASK,
12903 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12904 .f = cmd_config_e_tag_stripping_parsed,
12906 .help_str = "E-tag ... : E-tag stripping enable/disable",
12908 (void *)&cmd_config_e_tag_e_tag,
12909 (void *)&cmd_config_e_tag_set,
12910 (void *)&cmd_config_e_tag_stripping,
12911 (void *)&cmd_config_e_tag_on_off,
12912 (void *)&cmd_config_e_tag_port,
12913 (void *)&cmd_config_e_tag_port_id,
12918 /* E-tag forwarding configuration */
12920 cmd_config_e_tag_forwarding_parsed(
12921 void *parsed_result,
12922 __attribute__((unused)) struct cmdline *cl,
12923 __attribute__((unused)) void *data)
12925 struct cmd_config_e_tag_result *res = parsed_result;
12926 struct rte_eth_l2_tunnel_conf entry;
12928 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12931 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12933 if (!strcmp(res->on_off, "on"))
12934 rte_eth_dev_l2_tunnel_offload_set
12937 ETH_L2_TUNNEL_FORWARDING_MASK,
12940 rte_eth_dev_l2_tunnel_offload_set
12943 ETH_L2_TUNNEL_FORWARDING_MASK,
12947 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12948 .f = cmd_config_e_tag_forwarding_parsed,
12950 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12952 (void *)&cmd_config_e_tag_e_tag,
12953 (void *)&cmd_config_e_tag_set,
12954 (void *)&cmd_config_e_tag_forwarding,
12955 (void *)&cmd_config_e_tag_on_off,
12956 (void *)&cmd_config_e_tag_port,
12957 (void *)&cmd_config_e_tag_port_id,
12962 /* E-tag filter configuration */
12964 cmd_config_e_tag_filter_add_parsed(
12965 void *parsed_result,
12966 __attribute__((unused)) struct cmdline *cl,
12967 __attribute__((unused)) void *data)
12969 struct cmd_config_e_tag_result *res = parsed_result;
12970 struct rte_eth_l2_tunnel_conf entry;
12973 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12976 if (res->e_tag_id_val > 0x3fff) {
12977 printf("e-tag-id must be equal or less than 0x3fff.\n");
12981 ret = rte_eth_dev_filter_supported(res->port_id,
12982 RTE_ETH_FILTER_L2_TUNNEL);
12984 printf("E-tag filter is not supported on port %u.\n",
12989 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12990 entry.tunnel_id = res->e_tag_id_val;
12991 entry.pool = res->dst_pool_val;
12993 ret = rte_eth_dev_filter_ctrl(res->port_id,
12994 RTE_ETH_FILTER_L2_TUNNEL,
12995 RTE_ETH_FILTER_ADD,
12998 printf("E-tag filter programming error: (%s)\n",
13002 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13003 .f = cmd_config_e_tag_filter_add_parsed,
13005 .help_str = "E-tag ... : E-tag filter add",
13007 (void *)&cmd_config_e_tag_e_tag,
13008 (void *)&cmd_config_e_tag_set,
13009 (void *)&cmd_config_e_tag_filter,
13010 (void *)&cmd_config_e_tag_add,
13011 (void *)&cmd_config_e_tag_e_tag_id,
13012 (void *)&cmd_config_e_tag_e_tag_id_val,
13013 (void *)&cmd_config_e_tag_dst_pool,
13014 (void *)&cmd_config_e_tag_dst_pool_val,
13015 (void *)&cmd_config_e_tag_port,
13016 (void *)&cmd_config_e_tag_port_id,
13022 cmd_config_e_tag_filter_del_parsed(
13023 void *parsed_result,
13024 __attribute__((unused)) struct cmdline *cl,
13025 __attribute__((unused)) void *data)
13027 struct cmd_config_e_tag_result *res = parsed_result;
13028 struct rte_eth_l2_tunnel_conf entry;
13031 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13034 if (res->e_tag_id_val > 0x3fff) {
13035 printf("e-tag-id must be less than 0x3fff.\n");
13039 ret = rte_eth_dev_filter_supported(res->port_id,
13040 RTE_ETH_FILTER_L2_TUNNEL);
13042 printf("E-tag filter is not supported on port %u.\n",
13047 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13048 entry.tunnel_id = res->e_tag_id_val;
13050 ret = rte_eth_dev_filter_ctrl(res->port_id,
13051 RTE_ETH_FILTER_L2_TUNNEL,
13052 RTE_ETH_FILTER_DELETE,
13055 printf("E-tag filter programming error: (%s)\n",
13059 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13060 .f = cmd_config_e_tag_filter_del_parsed,
13062 .help_str = "E-tag ... : E-tag filter delete",
13064 (void *)&cmd_config_e_tag_e_tag,
13065 (void *)&cmd_config_e_tag_set,
13066 (void *)&cmd_config_e_tag_filter,
13067 (void *)&cmd_config_e_tag_del,
13068 (void *)&cmd_config_e_tag_e_tag_id,
13069 (void *)&cmd_config_e_tag_e_tag_id_val,
13070 (void *)&cmd_config_e_tag_port,
13071 (void *)&cmd_config_e_tag_port_id,
13076 /* vf vlan anti spoof configuration */
13078 /* Common result structure for vf vlan anti spoof */
13079 struct cmd_vf_vlan_anti_spoof_result {
13080 cmdline_fixed_string_t set;
13081 cmdline_fixed_string_t vf;
13082 cmdline_fixed_string_t vlan;
13083 cmdline_fixed_string_t antispoof;
13086 cmdline_fixed_string_t on_off;
13089 /* Common CLI fields for vf vlan anti spoof enable disable */
13090 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13091 TOKEN_STRING_INITIALIZER
13092 (struct cmd_vf_vlan_anti_spoof_result,
13094 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13095 TOKEN_STRING_INITIALIZER
13096 (struct cmd_vf_vlan_anti_spoof_result,
13098 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13099 TOKEN_STRING_INITIALIZER
13100 (struct cmd_vf_vlan_anti_spoof_result,
13102 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13103 TOKEN_STRING_INITIALIZER
13104 (struct cmd_vf_vlan_anti_spoof_result,
13105 antispoof, "antispoof");
13106 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13107 TOKEN_NUM_INITIALIZER
13108 (struct cmd_vf_vlan_anti_spoof_result,
13110 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13111 TOKEN_NUM_INITIALIZER
13112 (struct cmd_vf_vlan_anti_spoof_result,
13114 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13115 TOKEN_STRING_INITIALIZER
13116 (struct cmd_vf_vlan_anti_spoof_result,
13120 cmd_set_vf_vlan_anti_spoof_parsed(
13121 void *parsed_result,
13122 __attribute__((unused)) struct cmdline *cl,
13123 __attribute__((unused)) void *data)
13125 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13126 int ret = -ENOTSUP;
13128 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13130 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13133 #ifdef RTE_LIBRTE_IXGBE_PMD
13134 if (ret == -ENOTSUP)
13135 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13136 res->vf_id, is_on);
13138 #ifdef RTE_LIBRTE_I40E_PMD
13139 if (ret == -ENOTSUP)
13140 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13141 res->vf_id, is_on);
13143 #ifdef RTE_LIBRTE_BNXT_PMD
13144 if (ret == -ENOTSUP)
13145 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13146 res->vf_id, is_on);
13153 printf("invalid vf_id %d\n", res->vf_id);
13156 printf("invalid port_id %d\n", res->port_id);
13159 printf("function not implemented\n");
13162 printf("programming error: (%s)\n", strerror(-ret));
13166 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13167 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13169 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13171 (void *)&cmd_vf_vlan_anti_spoof_set,
13172 (void *)&cmd_vf_vlan_anti_spoof_vf,
13173 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13174 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13175 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13176 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13177 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13182 /* vf mac anti spoof configuration */
13184 /* Common result structure for vf mac anti spoof */
13185 struct cmd_vf_mac_anti_spoof_result {
13186 cmdline_fixed_string_t set;
13187 cmdline_fixed_string_t vf;
13188 cmdline_fixed_string_t mac;
13189 cmdline_fixed_string_t antispoof;
13192 cmdline_fixed_string_t on_off;
13195 /* Common CLI fields for vf mac anti spoof enable disable */
13196 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13197 TOKEN_STRING_INITIALIZER
13198 (struct cmd_vf_mac_anti_spoof_result,
13200 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13201 TOKEN_STRING_INITIALIZER
13202 (struct cmd_vf_mac_anti_spoof_result,
13204 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13205 TOKEN_STRING_INITIALIZER
13206 (struct cmd_vf_mac_anti_spoof_result,
13208 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13209 TOKEN_STRING_INITIALIZER
13210 (struct cmd_vf_mac_anti_spoof_result,
13211 antispoof, "antispoof");
13212 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13213 TOKEN_NUM_INITIALIZER
13214 (struct cmd_vf_mac_anti_spoof_result,
13216 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13217 TOKEN_NUM_INITIALIZER
13218 (struct cmd_vf_mac_anti_spoof_result,
13220 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13221 TOKEN_STRING_INITIALIZER
13222 (struct cmd_vf_mac_anti_spoof_result,
13226 cmd_set_vf_mac_anti_spoof_parsed(
13227 void *parsed_result,
13228 __attribute__((unused)) struct cmdline *cl,
13229 __attribute__((unused)) void *data)
13231 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13232 int ret = -ENOTSUP;
13234 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13236 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13239 #ifdef RTE_LIBRTE_IXGBE_PMD
13240 if (ret == -ENOTSUP)
13241 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13242 res->vf_id, is_on);
13244 #ifdef RTE_LIBRTE_I40E_PMD
13245 if (ret == -ENOTSUP)
13246 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13247 res->vf_id, is_on);
13249 #ifdef RTE_LIBRTE_BNXT_PMD
13250 if (ret == -ENOTSUP)
13251 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13252 res->vf_id, is_on);
13259 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13262 printf("invalid port_id %d\n", res->port_id);
13265 printf("function not implemented\n");
13268 printf("programming error: (%s)\n", strerror(-ret));
13272 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13273 .f = cmd_set_vf_mac_anti_spoof_parsed,
13275 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13277 (void *)&cmd_vf_mac_anti_spoof_set,
13278 (void *)&cmd_vf_mac_anti_spoof_vf,
13279 (void *)&cmd_vf_mac_anti_spoof_mac,
13280 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13281 (void *)&cmd_vf_mac_anti_spoof_port_id,
13282 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13283 (void *)&cmd_vf_mac_anti_spoof_on_off,
13288 /* vf vlan strip queue configuration */
13290 /* Common result structure for vf mac anti spoof */
13291 struct cmd_vf_vlan_stripq_result {
13292 cmdline_fixed_string_t set;
13293 cmdline_fixed_string_t vf;
13294 cmdline_fixed_string_t vlan;
13295 cmdline_fixed_string_t stripq;
13298 cmdline_fixed_string_t on_off;
13301 /* Common CLI fields for vf vlan strip enable disable */
13302 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13303 TOKEN_STRING_INITIALIZER
13304 (struct cmd_vf_vlan_stripq_result,
13306 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13307 TOKEN_STRING_INITIALIZER
13308 (struct cmd_vf_vlan_stripq_result,
13310 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13311 TOKEN_STRING_INITIALIZER
13312 (struct cmd_vf_vlan_stripq_result,
13314 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13315 TOKEN_STRING_INITIALIZER
13316 (struct cmd_vf_vlan_stripq_result,
13318 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13319 TOKEN_NUM_INITIALIZER
13320 (struct cmd_vf_vlan_stripq_result,
13322 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13323 TOKEN_NUM_INITIALIZER
13324 (struct cmd_vf_vlan_stripq_result,
13326 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13327 TOKEN_STRING_INITIALIZER
13328 (struct cmd_vf_vlan_stripq_result,
13332 cmd_set_vf_vlan_stripq_parsed(
13333 void *parsed_result,
13334 __attribute__((unused)) struct cmdline *cl,
13335 __attribute__((unused)) void *data)
13337 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13338 int ret = -ENOTSUP;
13340 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13342 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13345 #ifdef RTE_LIBRTE_IXGBE_PMD
13346 if (ret == -ENOTSUP)
13347 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13348 res->vf_id, is_on);
13350 #ifdef RTE_LIBRTE_I40E_PMD
13351 if (ret == -ENOTSUP)
13352 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13353 res->vf_id, is_on);
13355 #ifdef RTE_LIBRTE_BNXT_PMD
13356 if (ret == -ENOTSUP)
13357 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13358 res->vf_id, is_on);
13365 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13368 printf("invalid port_id %d\n", res->port_id);
13371 printf("function not implemented\n");
13374 printf("programming error: (%s)\n", strerror(-ret));
13378 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13379 .f = cmd_set_vf_vlan_stripq_parsed,
13381 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13383 (void *)&cmd_vf_vlan_stripq_set,
13384 (void *)&cmd_vf_vlan_stripq_vf,
13385 (void *)&cmd_vf_vlan_stripq_vlan,
13386 (void *)&cmd_vf_vlan_stripq_stripq,
13387 (void *)&cmd_vf_vlan_stripq_port_id,
13388 (void *)&cmd_vf_vlan_stripq_vf_id,
13389 (void *)&cmd_vf_vlan_stripq_on_off,
13394 /* vf vlan insert configuration */
13396 /* Common result structure for vf vlan insert */
13397 struct cmd_vf_vlan_insert_result {
13398 cmdline_fixed_string_t set;
13399 cmdline_fixed_string_t vf;
13400 cmdline_fixed_string_t vlan;
13401 cmdline_fixed_string_t insert;
13407 /* Common CLI fields for vf vlan insert enable disable */
13408 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13409 TOKEN_STRING_INITIALIZER
13410 (struct cmd_vf_vlan_insert_result,
13412 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13413 TOKEN_STRING_INITIALIZER
13414 (struct cmd_vf_vlan_insert_result,
13416 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13417 TOKEN_STRING_INITIALIZER
13418 (struct cmd_vf_vlan_insert_result,
13420 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13421 TOKEN_STRING_INITIALIZER
13422 (struct cmd_vf_vlan_insert_result,
13424 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13425 TOKEN_NUM_INITIALIZER
13426 (struct cmd_vf_vlan_insert_result,
13428 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13429 TOKEN_NUM_INITIALIZER
13430 (struct cmd_vf_vlan_insert_result,
13432 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13433 TOKEN_NUM_INITIALIZER
13434 (struct cmd_vf_vlan_insert_result,
13438 cmd_set_vf_vlan_insert_parsed(
13439 void *parsed_result,
13440 __attribute__((unused)) struct cmdline *cl,
13441 __attribute__((unused)) void *data)
13443 struct cmd_vf_vlan_insert_result *res = parsed_result;
13444 int ret = -ENOTSUP;
13446 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13449 #ifdef RTE_LIBRTE_IXGBE_PMD
13450 if (ret == -ENOTSUP)
13451 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13454 #ifdef RTE_LIBRTE_I40E_PMD
13455 if (ret == -ENOTSUP)
13456 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13459 #ifdef RTE_LIBRTE_BNXT_PMD
13460 if (ret == -ENOTSUP)
13461 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13469 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13472 printf("invalid port_id %d\n", res->port_id);
13475 printf("function not implemented\n");
13478 printf("programming error: (%s)\n", strerror(-ret));
13482 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13483 .f = cmd_set_vf_vlan_insert_parsed,
13485 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13487 (void *)&cmd_vf_vlan_insert_set,
13488 (void *)&cmd_vf_vlan_insert_vf,
13489 (void *)&cmd_vf_vlan_insert_vlan,
13490 (void *)&cmd_vf_vlan_insert_insert,
13491 (void *)&cmd_vf_vlan_insert_port_id,
13492 (void *)&cmd_vf_vlan_insert_vf_id,
13493 (void *)&cmd_vf_vlan_insert_vlan_id,
13498 /* tx loopback configuration */
13500 /* Common result structure for tx loopback */
13501 struct cmd_tx_loopback_result {
13502 cmdline_fixed_string_t set;
13503 cmdline_fixed_string_t tx;
13504 cmdline_fixed_string_t loopback;
13506 cmdline_fixed_string_t on_off;
13509 /* Common CLI fields for tx loopback enable disable */
13510 cmdline_parse_token_string_t cmd_tx_loopback_set =
13511 TOKEN_STRING_INITIALIZER
13512 (struct cmd_tx_loopback_result,
13514 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13515 TOKEN_STRING_INITIALIZER
13516 (struct cmd_tx_loopback_result,
13518 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13519 TOKEN_STRING_INITIALIZER
13520 (struct cmd_tx_loopback_result,
13521 loopback, "loopback");
13522 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13523 TOKEN_NUM_INITIALIZER
13524 (struct cmd_tx_loopback_result,
13526 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13527 TOKEN_STRING_INITIALIZER
13528 (struct cmd_tx_loopback_result,
13532 cmd_set_tx_loopback_parsed(
13533 void *parsed_result,
13534 __attribute__((unused)) struct cmdline *cl,
13535 __attribute__((unused)) void *data)
13537 struct cmd_tx_loopback_result *res = parsed_result;
13538 int ret = -ENOTSUP;
13540 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13542 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13545 #ifdef RTE_LIBRTE_IXGBE_PMD
13546 if (ret == -ENOTSUP)
13547 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13549 #ifdef RTE_LIBRTE_I40E_PMD
13550 if (ret == -ENOTSUP)
13551 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13553 #ifdef RTE_LIBRTE_BNXT_PMD
13554 if (ret == -ENOTSUP)
13555 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13557 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13558 if (ret == -ENOTSUP)
13559 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13566 printf("invalid is_on %d\n", is_on);
13569 printf("invalid port_id %d\n", res->port_id);
13572 printf("function not implemented\n");
13575 printf("programming error: (%s)\n", strerror(-ret));
13579 cmdline_parse_inst_t cmd_set_tx_loopback = {
13580 .f = cmd_set_tx_loopback_parsed,
13582 .help_str = "set tx loopback <port_id> on|off",
13584 (void *)&cmd_tx_loopback_set,
13585 (void *)&cmd_tx_loopback_tx,
13586 (void *)&cmd_tx_loopback_loopback,
13587 (void *)&cmd_tx_loopback_port_id,
13588 (void *)&cmd_tx_loopback_on_off,
13593 /* all queues drop enable configuration */
13595 /* Common result structure for all queues drop enable */
13596 struct cmd_all_queues_drop_en_result {
13597 cmdline_fixed_string_t set;
13598 cmdline_fixed_string_t all;
13599 cmdline_fixed_string_t queues;
13600 cmdline_fixed_string_t drop;
13602 cmdline_fixed_string_t on_off;
13605 /* Common CLI fields for tx loopback enable disable */
13606 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13607 TOKEN_STRING_INITIALIZER
13608 (struct cmd_all_queues_drop_en_result,
13610 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13611 TOKEN_STRING_INITIALIZER
13612 (struct cmd_all_queues_drop_en_result,
13614 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13615 TOKEN_STRING_INITIALIZER
13616 (struct cmd_all_queues_drop_en_result,
13618 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13619 TOKEN_STRING_INITIALIZER
13620 (struct cmd_all_queues_drop_en_result,
13622 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13623 TOKEN_NUM_INITIALIZER
13624 (struct cmd_all_queues_drop_en_result,
13626 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13627 TOKEN_STRING_INITIALIZER
13628 (struct cmd_all_queues_drop_en_result,
13632 cmd_set_all_queues_drop_en_parsed(
13633 void *parsed_result,
13634 __attribute__((unused)) struct cmdline *cl,
13635 __attribute__((unused)) void *data)
13637 struct cmd_all_queues_drop_en_result *res = parsed_result;
13638 int ret = -ENOTSUP;
13639 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13641 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13644 #ifdef RTE_LIBRTE_IXGBE_PMD
13645 if (ret == -ENOTSUP)
13646 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13648 #ifdef RTE_LIBRTE_BNXT_PMD
13649 if (ret == -ENOTSUP)
13650 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13656 printf("invalid is_on %d\n", is_on);
13659 printf("invalid port_id %d\n", res->port_id);
13662 printf("function not implemented\n");
13665 printf("programming error: (%s)\n", strerror(-ret));
13669 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13670 .f = cmd_set_all_queues_drop_en_parsed,
13672 .help_str = "set all queues drop <port_id> on|off",
13674 (void *)&cmd_all_queues_drop_en_set,
13675 (void *)&cmd_all_queues_drop_en_all,
13676 (void *)&cmd_all_queues_drop_en_queues,
13677 (void *)&cmd_all_queues_drop_en_drop,
13678 (void *)&cmd_all_queues_drop_en_port_id,
13679 (void *)&cmd_all_queues_drop_en_on_off,
13684 /* vf split drop enable configuration */
13686 /* Common result structure for vf split drop enable */
13687 struct cmd_vf_split_drop_en_result {
13688 cmdline_fixed_string_t set;
13689 cmdline_fixed_string_t vf;
13690 cmdline_fixed_string_t split;
13691 cmdline_fixed_string_t drop;
13694 cmdline_fixed_string_t on_off;
13697 /* Common CLI fields for vf split drop enable disable */
13698 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13699 TOKEN_STRING_INITIALIZER
13700 (struct cmd_vf_split_drop_en_result,
13702 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13703 TOKEN_STRING_INITIALIZER
13704 (struct cmd_vf_split_drop_en_result,
13706 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13707 TOKEN_STRING_INITIALIZER
13708 (struct cmd_vf_split_drop_en_result,
13710 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13711 TOKEN_STRING_INITIALIZER
13712 (struct cmd_vf_split_drop_en_result,
13714 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13715 TOKEN_NUM_INITIALIZER
13716 (struct cmd_vf_split_drop_en_result,
13718 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13719 TOKEN_NUM_INITIALIZER
13720 (struct cmd_vf_split_drop_en_result,
13722 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13723 TOKEN_STRING_INITIALIZER
13724 (struct cmd_vf_split_drop_en_result,
13728 cmd_set_vf_split_drop_en_parsed(
13729 void *parsed_result,
13730 __attribute__((unused)) struct cmdline *cl,
13731 __attribute__((unused)) void *data)
13733 struct cmd_vf_split_drop_en_result *res = parsed_result;
13734 int ret = -ENOTSUP;
13735 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13737 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13740 #ifdef RTE_LIBRTE_IXGBE_PMD
13741 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13748 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13751 printf("invalid port_id %d\n", res->port_id);
13754 printf("not supported on port %d\n", res->port_id);
13757 printf("programming error: (%s)\n", strerror(-ret));
13761 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13762 .f = cmd_set_vf_split_drop_en_parsed,
13764 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13766 (void *)&cmd_vf_split_drop_en_set,
13767 (void *)&cmd_vf_split_drop_en_vf,
13768 (void *)&cmd_vf_split_drop_en_split,
13769 (void *)&cmd_vf_split_drop_en_drop,
13770 (void *)&cmd_vf_split_drop_en_port_id,
13771 (void *)&cmd_vf_split_drop_en_vf_id,
13772 (void *)&cmd_vf_split_drop_en_on_off,
13777 /* vf mac address configuration */
13779 /* Common result structure for vf mac address */
13780 struct cmd_set_vf_mac_addr_result {
13781 cmdline_fixed_string_t set;
13782 cmdline_fixed_string_t vf;
13783 cmdline_fixed_string_t mac;
13784 cmdline_fixed_string_t addr;
13787 struct ether_addr mac_addr;
13791 /* Common CLI fields for vf split drop enable disable */
13792 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13793 TOKEN_STRING_INITIALIZER
13794 (struct cmd_set_vf_mac_addr_result,
13796 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13797 TOKEN_STRING_INITIALIZER
13798 (struct cmd_set_vf_mac_addr_result,
13800 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13801 TOKEN_STRING_INITIALIZER
13802 (struct cmd_set_vf_mac_addr_result,
13804 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13805 TOKEN_STRING_INITIALIZER
13806 (struct cmd_set_vf_mac_addr_result,
13808 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13809 TOKEN_NUM_INITIALIZER
13810 (struct cmd_set_vf_mac_addr_result,
13812 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13813 TOKEN_NUM_INITIALIZER
13814 (struct cmd_set_vf_mac_addr_result,
13816 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13817 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13821 cmd_set_vf_mac_addr_parsed(
13822 void *parsed_result,
13823 __attribute__((unused)) struct cmdline *cl,
13824 __attribute__((unused)) void *data)
13826 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13827 int ret = -ENOTSUP;
13829 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13832 #ifdef RTE_LIBRTE_IXGBE_PMD
13833 if (ret == -ENOTSUP)
13834 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13837 #ifdef RTE_LIBRTE_I40E_PMD
13838 if (ret == -ENOTSUP)
13839 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13842 #ifdef RTE_LIBRTE_BNXT_PMD
13843 if (ret == -ENOTSUP)
13844 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13852 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13855 printf("invalid port_id %d\n", res->port_id);
13858 printf("function not implemented\n");
13861 printf("programming error: (%s)\n", strerror(-ret));
13865 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13866 .f = cmd_set_vf_mac_addr_parsed,
13868 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13870 (void *)&cmd_set_vf_mac_addr_set,
13871 (void *)&cmd_set_vf_mac_addr_vf,
13872 (void *)&cmd_set_vf_mac_addr_mac,
13873 (void *)&cmd_set_vf_mac_addr_addr,
13874 (void *)&cmd_set_vf_mac_addr_port_id,
13875 (void *)&cmd_set_vf_mac_addr_vf_id,
13876 (void *)&cmd_set_vf_mac_addr_mac_addr,
13881 /* MACsec configuration */
13883 /* Common result structure for MACsec offload enable */
13884 struct cmd_macsec_offload_on_result {
13885 cmdline_fixed_string_t set;
13886 cmdline_fixed_string_t macsec;
13887 cmdline_fixed_string_t offload;
13889 cmdline_fixed_string_t on;
13890 cmdline_fixed_string_t encrypt;
13891 cmdline_fixed_string_t en_on_off;
13892 cmdline_fixed_string_t replay_protect;
13893 cmdline_fixed_string_t rp_on_off;
13896 /* Common CLI fields for MACsec offload disable */
13897 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13898 TOKEN_STRING_INITIALIZER
13899 (struct cmd_macsec_offload_on_result,
13901 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13902 TOKEN_STRING_INITIALIZER
13903 (struct cmd_macsec_offload_on_result,
13905 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13906 TOKEN_STRING_INITIALIZER
13907 (struct cmd_macsec_offload_on_result,
13908 offload, "offload");
13909 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13910 TOKEN_NUM_INITIALIZER
13911 (struct cmd_macsec_offload_on_result,
13913 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13914 TOKEN_STRING_INITIALIZER
13915 (struct cmd_macsec_offload_on_result,
13917 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13918 TOKEN_STRING_INITIALIZER
13919 (struct cmd_macsec_offload_on_result,
13920 encrypt, "encrypt");
13921 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13922 TOKEN_STRING_INITIALIZER
13923 (struct cmd_macsec_offload_on_result,
13924 en_on_off, "on#off");
13925 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13926 TOKEN_STRING_INITIALIZER
13927 (struct cmd_macsec_offload_on_result,
13928 replay_protect, "replay-protect");
13929 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13930 TOKEN_STRING_INITIALIZER
13931 (struct cmd_macsec_offload_on_result,
13932 rp_on_off, "on#off");
13935 cmd_set_macsec_offload_on_parsed(
13936 void *parsed_result,
13937 __attribute__((unused)) struct cmdline *cl,
13938 __attribute__((unused)) void *data)
13940 struct cmd_macsec_offload_on_result *res = parsed_result;
13941 int ret = -ENOTSUP;
13942 portid_t port_id = res->port_id;
13943 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13944 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13945 struct rte_eth_dev_info dev_info;
13947 if (port_id_is_invalid(port_id, ENABLED_WARN))
13949 if (!port_is_stopped(port_id)) {
13950 printf("Please stop port %d first\n", port_id);
13954 rte_eth_dev_info_get(port_id, &dev_info);
13955 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13956 #ifdef RTE_LIBRTE_IXGBE_PMD
13957 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13965 ports[port_id].dev_conf.txmode.offloads |=
13966 DEV_TX_OFFLOAD_MACSEC_INSERT;
13967 cmd_reconfig_device_queue(port_id, 1, 1);
13970 printf("invalid port_id %d\n", port_id);
13973 printf("not supported on port %d\n", port_id);
13976 printf("programming error: (%s)\n", strerror(-ret));
13980 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13981 .f = cmd_set_macsec_offload_on_parsed,
13983 .help_str = "set macsec offload <port_id> on "
13984 "encrypt on|off replay-protect on|off",
13986 (void *)&cmd_macsec_offload_on_set,
13987 (void *)&cmd_macsec_offload_on_macsec,
13988 (void *)&cmd_macsec_offload_on_offload,
13989 (void *)&cmd_macsec_offload_on_port_id,
13990 (void *)&cmd_macsec_offload_on_on,
13991 (void *)&cmd_macsec_offload_on_encrypt,
13992 (void *)&cmd_macsec_offload_on_en_on_off,
13993 (void *)&cmd_macsec_offload_on_replay_protect,
13994 (void *)&cmd_macsec_offload_on_rp_on_off,
13999 /* Common result structure for MACsec offload disable */
14000 struct cmd_macsec_offload_off_result {
14001 cmdline_fixed_string_t set;
14002 cmdline_fixed_string_t macsec;
14003 cmdline_fixed_string_t offload;
14005 cmdline_fixed_string_t off;
14008 /* Common CLI fields for MACsec offload disable */
14009 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14010 TOKEN_STRING_INITIALIZER
14011 (struct cmd_macsec_offload_off_result,
14013 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14014 TOKEN_STRING_INITIALIZER
14015 (struct cmd_macsec_offload_off_result,
14017 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14018 TOKEN_STRING_INITIALIZER
14019 (struct cmd_macsec_offload_off_result,
14020 offload, "offload");
14021 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14022 TOKEN_NUM_INITIALIZER
14023 (struct cmd_macsec_offload_off_result,
14025 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14026 TOKEN_STRING_INITIALIZER
14027 (struct cmd_macsec_offload_off_result,
14031 cmd_set_macsec_offload_off_parsed(
14032 void *parsed_result,
14033 __attribute__((unused)) struct cmdline *cl,
14034 __attribute__((unused)) void *data)
14036 struct cmd_macsec_offload_off_result *res = parsed_result;
14037 int ret = -ENOTSUP;
14038 struct rte_eth_dev_info dev_info;
14039 portid_t port_id = res->port_id;
14041 if (port_id_is_invalid(port_id, ENABLED_WARN))
14043 if (!port_is_stopped(port_id)) {
14044 printf("Please stop port %d first\n", port_id);
14048 rte_eth_dev_info_get(port_id, &dev_info);
14049 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14050 #ifdef RTE_LIBRTE_IXGBE_PMD
14051 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14056 ports[port_id].dev_conf.txmode.offloads &=
14057 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14058 cmd_reconfig_device_queue(port_id, 1, 1);
14061 printf("invalid port_id %d\n", port_id);
14064 printf("not supported on port %d\n", port_id);
14067 printf("programming error: (%s)\n", strerror(-ret));
14071 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14072 .f = cmd_set_macsec_offload_off_parsed,
14074 .help_str = "set macsec offload <port_id> off",
14076 (void *)&cmd_macsec_offload_off_set,
14077 (void *)&cmd_macsec_offload_off_macsec,
14078 (void *)&cmd_macsec_offload_off_offload,
14079 (void *)&cmd_macsec_offload_off_port_id,
14080 (void *)&cmd_macsec_offload_off_off,
14085 /* Common result structure for MACsec secure connection configure */
14086 struct cmd_macsec_sc_result {
14087 cmdline_fixed_string_t set;
14088 cmdline_fixed_string_t macsec;
14089 cmdline_fixed_string_t sc;
14090 cmdline_fixed_string_t tx_rx;
14092 struct ether_addr mac;
14096 /* Common CLI fields for MACsec secure connection configure */
14097 cmdline_parse_token_string_t cmd_macsec_sc_set =
14098 TOKEN_STRING_INITIALIZER
14099 (struct cmd_macsec_sc_result,
14101 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14102 TOKEN_STRING_INITIALIZER
14103 (struct cmd_macsec_sc_result,
14105 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14106 TOKEN_STRING_INITIALIZER
14107 (struct cmd_macsec_sc_result,
14109 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14110 TOKEN_STRING_INITIALIZER
14111 (struct cmd_macsec_sc_result,
14113 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14114 TOKEN_NUM_INITIALIZER
14115 (struct cmd_macsec_sc_result,
14117 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14118 TOKEN_ETHERADDR_INITIALIZER
14119 (struct cmd_macsec_sc_result,
14121 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14122 TOKEN_NUM_INITIALIZER
14123 (struct cmd_macsec_sc_result,
14127 cmd_set_macsec_sc_parsed(
14128 void *parsed_result,
14129 __attribute__((unused)) struct cmdline *cl,
14130 __attribute__((unused)) void *data)
14132 struct cmd_macsec_sc_result *res = parsed_result;
14133 int ret = -ENOTSUP;
14134 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14136 #ifdef RTE_LIBRTE_IXGBE_PMD
14138 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14139 res->mac.addr_bytes) :
14140 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14141 res->mac.addr_bytes, res->pi);
14143 RTE_SET_USED(is_tx);
14149 printf("invalid port_id %d\n", res->port_id);
14152 printf("not supported on port %d\n", res->port_id);
14155 printf("programming error: (%s)\n", strerror(-ret));
14159 cmdline_parse_inst_t cmd_set_macsec_sc = {
14160 .f = cmd_set_macsec_sc_parsed,
14162 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14164 (void *)&cmd_macsec_sc_set,
14165 (void *)&cmd_macsec_sc_macsec,
14166 (void *)&cmd_macsec_sc_sc,
14167 (void *)&cmd_macsec_sc_tx_rx,
14168 (void *)&cmd_macsec_sc_port_id,
14169 (void *)&cmd_macsec_sc_mac,
14170 (void *)&cmd_macsec_sc_pi,
14175 /* Common result structure for MACsec secure connection configure */
14176 struct cmd_macsec_sa_result {
14177 cmdline_fixed_string_t set;
14178 cmdline_fixed_string_t macsec;
14179 cmdline_fixed_string_t sa;
14180 cmdline_fixed_string_t tx_rx;
14185 cmdline_fixed_string_t key;
14188 /* Common CLI fields for MACsec secure connection configure */
14189 cmdline_parse_token_string_t cmd_macsec_sa_set =
14190 TOKEN_STRING_INITIALIZER
14191 (struct cmd_macsec_sa_result,
14193 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14194 TOKEN_STRING_INITIALIZER
14195 (struct cmd_macsec_sa_result,
14197 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14198 TOKEN_STRING_INITIALIZER
14199 (struct cmd_macsec_sa_result,
14201 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14202 TOKEN_STRING_INITIALIZER
14203 (struct cmd_macsec_sa_result,
14205 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14206 TOKEN_NUM_INITIALIZER
14207 (struct cmd_macsec_sa_result,
14209 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14210 TOKEN_NUM_INITIALIZER
14211 (struct cmd_macsec_sa_result,
14213 cmdline_parse_token_num_t cmd_macsec_sa_an =
14214 TOKEN_NUM_INITIALIZER
14215 (struct cmd_macsec_sa_result,
14217 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14218 TOKEN_NUM_INITIALIZER
14219 (struct cmd_macsec_sa_result,
14221 cmdline_parse_token_string_t cmd_macsec_sa_key =
14222 TOKEN_STRING_INITIALIZER
14223 (struct cmd_macsec_sa_result,
14227 cmd_set_macsec_sa_parsed(
14228 void *parsed_result,
14229 __attribute__((unused)) struct cmdline *cl,
14230 __attribute__((unused)) void *data)
14232 struct cmd_macsec_sa_result *res = parsed_result;
14233 int ret = -ENOTSUP;
14234 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14235 uint8_t key[16] = { 0 };
14241 key_len = strlen(res->key) / 2;
14245 for (i = 0; i < key_len; i++) {
14246 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14249 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14252 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14255 #ifdef RTE_LIBRTE_IXGBE_PMD
14257 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14258 res->idx, res->an, res->pn, key) :
14259 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14260 res->idx, res->an, res->pn, key);
14262 RTE_SET_USED(is_tx);
14269 printf("invalid idx %d or an %d\n", res->idx, res->an);
14272 printf("invalid port_id %d\n", res->port_id);
14275 printf("not supported on port %d\n", res->port_id);
14278 printf("programming error: (%s)\n", strerror(-ret));
14282 cmdline_parse_inst_t cmd_set_macsec_sa = {
14283 .f = cmd_set_macsec_sa_parsed,
14285 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14287 (void *)&cmd_macsec_sa_set,
14288 (void *)&cmd_macsec_sa_macsec,
14289 (void *)&cmd_macsec_sa_sa,
14290 (void *)&cmd_macsec_sa_tx_rx,
14291 (void *)&cmd_macsec_sa_port_id,
14292 (void *)&cmd_macsec_sa_idx,
14293 (void *)&cmd_macsec_sa_an,
14294 (void *)&cmd_macsec_sa_pn,
14295 (void *)&cmd_macsec_sa_key,
14300 /* VF unicast promiscuous mode configuration */
14302 /* Common result structure for VF unicast promiscuous mode */
14303 struct cmd_vf_promisc_result {
14304 cmdline_fixed_string_t set;
14305 cmdline_fixed_string_t vf;
14306 cmdline_fixed_string_t promisc;
14309 cmdline_fixed_string_t on_off;
14312 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14313 cmdline_parse_token_string_t cmd_vf_promisc_set =
14314 TOKEN_STRING_INITIALIZER
14315 (struct cmd_vf_promisc_result,
14317 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14318 TOKEN_STRING_INITIALIZER
14319 (struct cmd_vf_promisc_result,
14321 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14322 TOKEN_STRING_INITIALIZER
14323 (struct cmd_vf_promisc_result,
14324 promisc, "promisc");
14325 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14326 TOKEN_NUM_INITIALIZER
14327 (struct cmd_vf_promisc_result,
14329 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14330 TOKEN_NUM_INITIALIZER
14331 (struct cmd_vf_promisc_result,
14333 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14334 TOKEN_STRING_INITIALIZER
14335 (struct cmd_vf_promisc_result,
14339 cmd_set_vf_promisc_parsed(
14340 void *parsed_result,
14341 __attribute__((unused)) struct cmdline *cl,
14342 __attribute__((unused)) void *data)
14344 struct cmd_vf_promisc_result *res = parsed_result;
14345 int ret = -ENOTSUP;
14347 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14352 #ifdef RTE_LIBRTE_I40E_PMD
14353 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14354 res->vf_id, is_on);
14361 printf("invalid vf_id %d\n", res->vf_id);
14364 printf("invalid port_id %d\n", res->port_id);
14367 printf("function not implemented\n");
14370 printf("programming error: (%s)\n", strerror(-ret));
14374 cmdline_parse_inst_t cmd_set_vf_promisc = {
14375 .f = cmd_set_vf_promisc_parsed,
14377 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14378 "Set unicast promiscuous mode for a VF from the PF",
14380 (void *)&cmd_vf_promisc_set,
14381 (void *)&cmd_vf_promisc_vf,
14382 (void *)&cmd_vf_promisc_promisc,
14383 (void *)&cmd_vf_promisc_port_id,
14384 (void *)&cmd_vf_promisc_vf_id,
14385 (void *)&cmd_vf_promisc_on_off,
14390 /* VF multicast promiscuous mode configuration */
14392 /* Common result structure for VF multicast promiscuous mode */
14393 struct cmd_vf_allmulti_result {
14394 cmdline_fixed_string_t set;
14395 cmdline_fixed_string_t vf;
14396 cmdline_fixed_string_t allmulti;
14399 cmdline_fixed_string_t on_off;
14402 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14403 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14404 TOKEN_STRING_INITIALIZER
14405 (struct cmd_vf_allmulti_result,
14407 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14408 TOKEN_STRING_INITIALIZER
14409 (struct cmd_vf_allmulti_result,
14411 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14412 TOKEN_STRING_INITIALIZER
14413 (struct cmd_vf_allmulti_result,
14414 allmulti, "allmulti");
14415 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14416 TOKEN_NUM_INITIALIZER
14417 (struct cmd_vf_allmulti_result,
14419 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14420 TOKEN_NUM_INITIALIZER
14421 (struct cmd_vf_allmulti_result,
14423 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14424 TOKEN_STRING_INITIALIZER
14425 (struct cmd_vf_allmulti_result,
14429 cmd_set_vf_allmulti_parsed(
14430 void *parsed_result,
14431 __attribute__((unused)) struct cmdline *cl,
14432 __attribute__((unused)) void *data)
14434 struct cmd_vf_allmulti_result *res = parsed_result;
14435 int ret = -ENOTSUP;
14437 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14439 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14442 #ifdef RTE_LIBRTE_I40E_PMD
14443 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14444 res->vf_id, is_on);
14451 printf("invalid vf_id %d\n", res->vf_id);
14454 printf("invalid port_id %d\n", res->port_id);
14457 printf("function not implemented\n");
14460 printf("programming error: (%s)\n", strerror(-ret));
14464 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14465 .f = cmd_set_vf_allmulti_parsed,
14467 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14468 "Set multicast promiscuous mode for a VF from the PF",
14470 (void *)&cmd_vf_allmulti_set,
14471 (void *)&cmd_vf_allmulti_vf,
14472 (void *)&cmd_vf_allmulti_allmulti,
14473 (void *)&cmd_vf_allmulti_port_id,
14474 (void *)&cmd_vf_allmulti_vf_id,
14475 (void *)&cmd_vf_allmulti_on_off,
14480 /* vf broadcast mode configuration */
14482 /* Common result structure for vf broadcast */
14483 struct cmd_set_vf_broadcast_result {
14484 cmdline_fixed_string_t set;
14485 cmdline_fixed_string_t vf;
14486 cmdline_fixed_string_t broadcast;
14489 cmdline_fixed_string_t on_off;
14492 /* Common CLI fields for vf broadcast enable disable */
14493 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14494 TOKEN_STRING_INITIALIZER
14495 (struct cmd_set_vf_broadcast_result,
14497 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14498 TOKEN_STRING_INITIALIZER
14499 (struct cmd_set_vf_broadcast_result,
14501 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14502 TOKEN_STRING_INITIALIZER
14503 (struct cmd_set_vf_broadcast_result,
14504 broadcast, "broadcast");
14505 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14506 TOKEN_NUM_INITIALIZER
14507 (struct cmd_set_vf_broadcast_result,
14509 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14510 TOKEN_NUM_INITIALIZER
14511 (struct cmd_set_vf_broadcast_result,
14513 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14514 TOKEN_STRING_INITIALIZER
14515 (struct cmd_set_vf_broadcast_result,
14519 cmd_set_vf_broadcast_parsed(
14520 void *parsed_result,
14521 __attribute__((unused)) struct cmdline *cl,
14522 __attribute__((unused)) void *data)
14524 struct cmd_set_vf_broadcast_result *res = parsed_result;
14525 int ret = -ENOTSUP;
14527 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14529 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14532 #ifdef RTE_LIBRTE_I40E_PMD
14533 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14534 res->vf_id, is_on);
14541 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14544 printf("invalid port_id %d\n", res->port_id);
14547 printf("function not implemented\n");
14550 printf("programming error: (%s)\n", strerror(-ret));
14554 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14555 .f = cmd_set_vf_broadcast_parsed,
14557 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14559 (void *)&cmd_set_vf_broadcast_set,
14560 (void *)&cmd_set_vf_broadcast_vf,
14561 (void *)&cmd_set_vf_broadcast_broadcast,
14562 (void *)&cmd_set_vf_broadcast_port_id,
14563 (void *)&cmd_set_vf_broadcast_vf_id,
14564 (void *)&cmd_set_vf_broadcast_on_off,
14569 /* vf vlan tag configuration */
14571 /* Common result structure for vf vlan tag */
14572 struct cmd_set_vf_vlan_tag_result {
14573 cmdline_fixed_string_t set;
14574 cmdline_fixed_string_t vf;
14575 cmdline_fixed_string_t vlan;
14576 cmdline_fixed_string_t tag;
14579 cmdline_fixed_string_t on_off;
14582 /* Common CLI fields for vf vlan tag enable disable */
14583 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14584 TOKEN_STRING_INITIALIZER
14585 (struct cmd_set_vf_vlan_tag_result,
14587 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14588 TOKEN_STRING_INITIALIZER
14589 (struct cmd_set_vf_vlan_tag_result,
14591 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14592 TOKEN_STRING_INITIALIZER
14593 (struct cmd_set_vf_vlan_tag_result,
14595 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14596 TOKEN_STRING_INITIALIZER
14597 (struct cmd_set_vf_vlan_tag_result,
14599 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14600 TOKEN_NUM_INITIALIZER
14601 (struct cmd_set_vf_vlan_tag_result,
14603 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14604 TOKEN_NUM_INITIALIZER
14605 (struct cmd_set_vf_vlan_tag_result,
14607 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14608 TOKEN_STRING_INITIALIZER
14609 (struct cmd_set_vf_vlan_tag_result,
14613 cmd_set_vf_vlan_tag_parsed(
14614 void *parsed_result,
14615 __attribute__((unused)) struct cmdline *cl,
14616 __attribute__((unused)) void *data)
14618 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14619 int ret = -ENOTSUP;
14621 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14623 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14626 #ifdef RTE_LIBRTE_I40E_PMD
14627 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14628 res->vf_id, is_on);
14635 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14638 printf("invalid port_id %d\n", res->port_id);
14641 printf("function not implemented\n");
14644 printf("programming error: (%s)\n", strerror(-ret));
14648 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14649 .f = cmd_set_vf_vlan_tag_parsed,
14651 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14653 (void *)&cmd_set_vf_vlan_tag_set,
14654 (void *)&cmd_set_vf_vlan_tag_vf,
14655 (void *)&cmd_set_vf_vlan_tag_vlan,
14656 (void *)&cmd_set_vf_vlan_tag_tag,
14657 (void *)&cmd_set_vf_vlan_tag_port_id,
14658 (void *)&cmd_set_vf_vlan_tag_vf_id,
14659 (void *)&cmd_set_vf_vlan_tag_on_off,
14664 /* Common definition of VF and TC TX bandwidth configuration */
14665 struct cmd_vf_tc_bw_result {
14666 cmdline_fixed_string_t set;
14667 cmdline_fixed_string_t vf;
14668 cmdline_fixed_string_t tc;
14669 cmdline_fixed_string_t tx;
14670 cmdline_fixed_string_t min_bw;
14671 cmdline_fixed_string_t max_bw;
14672 cmdline_fixed_string_t strict_link_prio;
14677 cmdline_fixed_string_t bw_list;
14681 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14682 TOKEN_STRING_INITIALIZER
14683 (struct cmd_vf_tc_bw_result,
14685 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14686 TOKEN_STRING_INITIALIZER
14687 (struct cmd_vf_tc_bw_result,
14689 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14690 TOKEN_STRING_INITIALIZER
14691 (struct cmd_vf_tc_bw_result,
14693 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14694 TOKEN_STRING_INITIALIZER
14695 (struct cmd_vf_tc_bw_result,
14697 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14698 TOKEN_STRING_INITIALIZER
14699 (struct cmd_vf_tc_bw_result,
14700 strict_link_prio, "strict-link-priority");
14701 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14702 TOKEN_STRING_INITIALIZER
14703 (struct cmd_vf_tc_bw_result,
14704 min_bw, "min-bandwidth");
14705 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14706 TOKEN_STRING_INITIALIZER
14707 (struct cmd_vf_tc_bw_result,
14708 max_bw, "max-bandwidth");
14709 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14710 TOKEN_NUM_INITIALIZER
14711 (struct cmd_vf_tc_bw_result,
14713 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14714 TOKEN_NUM_INITIALIZER
14715 (struct cmd_vf_tc_bw_result,
14717 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14718 TOKEN_NUM_INITIALIZER
14719 (struct cmd_vf_tc_bw_result,
14721 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14722 TOKEN_NUM_INITIALIZER
14723 (struct cmd_vf_tc_bw_result,
14725 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14726 TOKEN_STRING_INITIALIZER
14727 (struct cmd_vf_tc_bw_result,
14729 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14730 TOKEN_NUM_INITIALIZER
14731 (struct cmd_vf_tc_bw_result,
14734 /* VF max bandwidth setting */
14736 cmd_vf_max_bw_parsed(
14737 void *parsed_result,
14738 __attribute__((unused)) struct cmdline *cl,
14739 __attribute__((unused)) void *data)
14741 struct cmd_vf_tc_bw_result *res = parsed_result;
14742 int ret = -ENOTSUP;
14744 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14747 #ifdef RTE_LIBRTE_I40E_PMD
14748 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14749 res->vf_id, res->bw);
14756 printf("invalid vf_id %d or bandwidth %d\n",
14757 res->vf_id, res->bw);
14760 printf("invalid port_id %d\n", res->port_id);
14763 printf("function not implemented\n");
14766 printf("programming error: (%s)\n", strerror(-ret));
14770 cmdline_parse_inst_t cmd_vf_max_bw = {
14771 .f = cmd_vf_max_bw_parsed,
14773 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14775 (void *)&cmd_vf_tc_bw_set,
14776 (void *)&cmd_vf_tc_bw_vf,
14777 (void *)&cmd_vf_tc_bw_tx,
14778 (void *)&cmd_vf_tc_bw_max_bw,
14779 (void *)&cmd_vf_tc_bw_port_id,
14780 (void *)&cmd_vf_tc_bw_vf_id,
14781 (void *)&cmd_vf_tc_bw_bw,
14787 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14792 const char *p, *p0 = str;
14799 p = strchr(p0, '(');
14801 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14805 p0 = strchr(p, ')');
14807 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14811 if (size >= sizeof(s)) {
14812 printf("The string size exceeds the internal buffer size\n");
14815 snprintf(s, sizeof(s), "%.*s", size, p);
14816 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14818 printf("Failed to get the bandwidth list. ");
14822 for (i = 0; i < ret; i++)
14823 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14828 /* TC min bandwidth setting */
14830 cmd_vf_tc_min_bw_parsed(
14831 void *parsed_result,
14832 __attribute__((unused)) struct cmdline *cl,
14833 __attribute__((unused)) void *data)
14835 struct cmd_vf_tc_bw_result *res = parsed_result;
14838 int ret = -ENOTSUP;
14840 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14843 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14847 #ifdef RTE_LIBRTE_I40E_PMD
14848 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14856 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14859 printf("invalid port_id %d\n", res->port_id);
14862 printf("function not implemented\n");
14865 printf("programming error: (%s)\n", strerror(-ret));
14869 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14870 .f = cmd_vf_tc_min_bw_parsed,
14872 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14873 " <bw1, bw2, ...>",
14875 (void *)&cmd_vf_tc_bw_set,
14876 (void *)&cmd_vf_tc_bw_vf,
14877 (void *)&cmd_vf_tc_bw_tc,
14878 (void *)&cmd_vf_tc_bw_tx,
14879 (void *)&cmd_vf_tc_bw_min_bw,
14880 (void *)&cmd_vf_tc_bw_port_id,
14881 (void *)&cmd_vf_tc_bw_vf_id,
14882 (void *)&cmd_vf_tc_bw_bw_list,
14888 cmd_tc_min_bw_parsed(
14889 void *parsed_result,
14890 __attribute__((unused)) struct cmdline *cl,
14891 __attribute__((unused)) void *data)
14893 struct cmd_vf_tc_bw_result *res = parsed_result;
14894 struct rte_port *port;
14897 int ret = -ENOTSUP;
14899 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14902 port = &ports[res->port_id];
14903 /** Check if the port is not started **/
14904 if (port->port_status != RTE_PORT_STOPPED) {
14905 printf("Please stop port %d first\n", res->port_id);
14909 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14913 #ifdef RTE_LIBRTE_IXGBE_PMD
14914 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14921 printf("invalid bandwidth\n");
14924 printf("invalid port_id %d\n", res->port_id);
14927 printf("function not implemented\n");
14930 printf("programming error: (%s)\n", strerror(-ret));
14934 cmdline_parse_inst_t cmd_tc_min_bw = {
14935 .f = cmd_tc_min_bw_parsed,
14937 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14939 (void *)&cmd_vf_tc_bw_set,
14940 (void *)&cmd_vf_tc_bw_tc,
14941 (void *)&cmd_vf_tc_bw_tx,
14942 (void *)&cmd_vf_tc_bw_min_bw,
14943 (void *)&cmd_vf_tc_bw_port_id,
14944 (void *)&cmd_vf_tc_bw_bw_list,
14949 /* TC max bandwidth setting */
14951 cmd_vf_tc_max_bw_parsed(
14952 void *parsed_result,
14953 __attribute__((unused)) struct cmdline *cl,
14954 __attribute__((unused)) void *data)
14956 struct cmd_vf_tc_bw_result *res = parsed_result;
14957 int ret = -ENOTSUP;
14959 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14962 #ifdef RTE_LIBRTE_I40E_PMD
14963 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14964 res->tc_no, res->bw);
14971 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14972 res->vf_id, res->tc_no, res->bw);
14975 printf("invalid port_id %d\n", res->port_id);
14978 printf("function not implemented\n");
14981 printf("programming error: (%s)\n", strerror(-ret));
14985 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14986 .f = cmd_vf_tc_max_bw_parsed,
14988 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14991 (void *)&cmd_vf_tc_bw_set,
14992 (void *)&cmd_vf_tc_bw_vf,
14993 (void *)&cmd_vf_tc_bw_tc,
14994 (void *)&cmd_vf_tc_bw_tx,
14995 (void *)&cmd_vf_tc_bw_max_bw,
14996 (void *)&cmd_vf_tc_bw_port_id,
14997 (void *)&cmd_vf_tc_bw_vf_id,
14998 (void *)&cmd_vf_tc_bw_tc_no,
14999 (void *)&cmd_vf_tc_bw_bw,
15005 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15007 /* *** Set Port default Traffic Management Hierarchy *** */
15008 struct cmd_set_port_tm_hierarchy_default_result {
15009 cmdline_fixed_string_t set;
15010 cmdline_fixed_string_t port;
15011 cmdline_fixed_string_t tm;
15012 cmdline_fixed_string_t hierarchy;
15013 cmdline_fixed_string_t def;
15017 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15018 TOKEN_STRING_INITIALIZER(
15019 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15020 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15021 TOKEN_STRING_INITIALIZER(
15022 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15023 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15024 TOKEN_STRING_INITIALIZER(
15025 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15026 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15027 TOKEN_STRING_INITIALIZER(
15028 struct cmd_set_port_tm_hierarchy_default_result,
15029 hierarchy, "hierarchy");
15030 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15031 TOKEN_STRING_INITIALIZER(
15032 struct cmd_set_port_tm_hierarchy_default_result,
15034 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15035 TOKEN_NUM_INITIALIZER(
15036 struct cmd_set_port_tm_hierarchy_default_result,
15039 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15040 __attribute__((unused)) struct cmdline *cl,
15041 __attribute__((unused)) void *data)
15043 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15044 struct rte_port *p;
15045 portid_t port_id = res->port_id;
15047 if (port_id_is_invalid(port_id, ENABLED_WARN))
15050 p = &ports[port_id];
15052 /* Forward mode: tm */
15053 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15054 printf(" softnicfwd mode not enabled(error)\n");
15058 /* Set the default tm hierarchy */
15059 p->softport.default_tm_hierarchy_enable = 1;
15062 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15063 .f = cmd_set_port_tm_hierarchy_default_parsed,
15065 .help_str = "set port tm hierarchy default <port_id>",
15067 (void *)&cmd_set_port_tm_hierarchy_default_set,
15068 (void *)&cmd_set_port_tm_hierarchy_default_port,
15069 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15070 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15071 (void *)&cmd_set_port_tm_hierarchy_default_default,
15072 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15078 /** Set VXLAN encapsulation details */
15079 struct cmd_set_vxlan_result {
15080 cmdline_fixed_string_t set;
15081 cmdline_fixed_string_t vxlan;
15082 cmdline_fixed_string_t pos_token;
15083 cmdline_fixed_string_t ip_version;
15084 uint32_t vlan_present:1;
15088 cmdline_ipaddr_t ip_src;
15089 cmdline_ipaddr_t ip_dst;
15093 struct ether_addr eth_src;
15094 struct ether_addr eth_dst;
15097 cmdline_parse_token_string_t cmd_set_vxlan_set =
15098 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15099 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15100 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15101 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15102 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15104 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15105 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15106 "vxlan-with-vlan");
15107 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15108 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15110 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15111 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15113 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15114 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15116 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15117 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15118 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15119 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15121 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15122 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15123 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15124 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15126 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15127 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15128 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15129 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15131 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15132 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15133 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15134 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15136 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15137 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15138 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15139 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15141 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15142 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15143 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15144 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15146 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15147 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15148 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15149 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15151 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15152 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15153 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15154 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15156 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15157 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15158 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15159 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15161 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15162 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15164 static void cmd_set_vxlan_parsed(void *parsed_result,
15165 __attribute__((unused)) struct cmdline *cl,
15166 __attribute__((unused)) void *data)
15168 struct cmd_set_vxlan_result *res = parsed_result;
15173 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15176 vxlan_encap_conf.select_tos_ttl = 0;
15177 if (strcmp(res->vxlan, "vxlan") == 0)
15178 vxlan_encap_conf.select_vlan = 0;
15179 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15180 vxlan_encap_conf.select_vlan = 1;
15181 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15182 vxlan_encap_conf.select_vlan = 0;
15183 vxlan_encap_conf.select_tos_ttl = 1;
15185 if (strcmp(res->ip_version, "ipv4") == 0)
15186 vxlan_encap_conf.select_ipv4 = 1;
15187 else if (strcmp(res->ip_version, "ipv6") == 0)
15188 vxlan_encap_conf.select_ipv4 = 0;
15191 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15192 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15193 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15194 vxlan_encap_conf.ip_tos = res->tos;
15195 vxlan_encap_conf.ip_ttl = res->ttl;
15196 if (vxlan_encap_conf.select_ipv4) {
15197 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15198 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15200 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15201 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15203 if (vxlan_encap_conf.select_vlan)
15204 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15205 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15207 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15211 cmdline_parse_inst_t cmd_set_vxlan = {
15212 .f = cmd_set_vxlan_parsed,
15214 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15215 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15216 " eth-src <eth-src> eth-dst <eth-dst>",
15218 (void *)&cmd_set_vxlan_set,
15219 (void *)&cmd_set_vxlan_vxlan,
15220 (void *)&cmd_set_vxlan_ip_version,
15221 (void *)&cmd_set_vxlan_ip_version_value,
15222 (void *)&cmd_set_vxlan_vni,
15223 (void *)&cmd_set_vxlan_vni_value,
15224 (void *)&cmd_set_vxlan_udp_src,
15225 (void *)&cmd_set_vxlan_udp_src_value,
15226 (void *)&cmd_set_vxlan_udp_dst,
15227 (void *)&cmd_set_vxlan_udp_dst_value,
15228 (void *)&cmd_set_vxlan_ip_src,
15229 (void *)&cmd_set_vxlan_ip_src_value,
15230 (void *)&cmd_set_vxlan_ip_dst,
15231 (void *)&cmd_set_vxlan_ip_dst_value,
15232 (void *)&cmd_set_vxlan_eth_src,
15233 (void *)&cmd_set_vxlan_eth_src_value,
15234 (void *)&cmd_set_vxlan_eth_dst,
15235 (void *)&cmd_set_vxlan_eth_dst_value,
15240 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15241 .f = cmd_set_vxlan_parsed,
15243 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15244 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15245 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15246 " eth-dst <eth-dst>",
15248 (void *)&cmd_set_vxlan_set,
15249 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15250 (void *)&cmd_set_vxlan_ip_version,
15251 (void *)&cmd_set_vxlan_ip_version_value,
15252 (void *)&cmd_set_vxlan_vni,
15253 (void *)&cmd_set_vxlan_vni_value,
15254 (void *)&cmd_set_vxlan_udp_src,
15255 (void *)&cmd_set_vxlan_udp_src_value,
15256 (void *)&cmd_set_vxlan_udp_dst,
15257 (void *)&cmd_set_vxlan_udp_dst_value,
15258 (void *)&cmd_set_vxlan_ip_tos,
15259 (void *)&cmd_set_vxlan_ip_tos_value,
15260 (void *)&cmd_set_vxlan_ip_ttl,
15261 (void *)&cmd_set_vxlan_ip_ttl_value,
15262 (void *)&cmd_set_vxlan_ip_src,
15263 (void *)&cmd_set_vxlan_ip_src_value,
15264 (void *)&cmd_set_vxlan_ip_dst,
15265 (void *)&cmd_set_vxlan_ip_dst_value,
15266 (void *)&cmd_set_vxlan_eth_src,
15267 (void *)&cmd_set_vxlan_eth_src_value,
15268 (void *)&cmd_set_vxlan_eth_dst,
15269 (void *)&cmd_set_vxlan_eth_dst_value,
15274 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15275 .f = cmd_set_vxlan_parsed,
15277 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15278 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15279 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15282 (void *)&cmd_set_vxlan_set,
15283 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15284 (void *)&cmd_set_vxlan_ip_version,
15285 (void *)&cmd_set_vxlan_ip_version_value,
15286 (void *)&cmd_set_vxlan_vni,
15287 (void *)&cmd_set_vxlan_vni_value,
15288 (void *)&cmd_set_vxlan_udp_src,
15289 (void *)&cmd_set_vxlan_udp_src_value,
15290 (void *)&cmd_set_vxlan_udp_dst,
15291 (void *)&cmd_set_vxlan_udp_dst_value,
15292 (void *)&cmd_set_vxlan_ip_src,
15293 (void *)&cmd_set_vxlan_ip_src_value,
15294 (void *)&cmd_set_vxlan_ip_dst,
15295 (void *)&cmd_set_vxlan_ip_dst_value,
15296 (void *)&cmd_set_vxlan_vlan,
15297 (void *)&cmd_set_vxlan_vlan_value,
15298 (void *)&cmd_set_vxlan_eth_src,
15299 (void *)&cmd_set_vxlan_eth_src_value,
15300 (void *)&cmd_set_vxlan_eth_dst,
15301 (void *)&cmd_set_vxlan_eth_dst_value,
15306 /** Set NVGRE encapsulation details */
15307 struct cmd_set_nvgre_result {
15308 cmdline_fixed_string_t set;
15309 cmdline_fixed_string_t nvgre;
15310 cmdline_fixed_string_t pos_token;
15311 cmdline_fixed_string_t ip_version;
15313 cmdline_ipaddr_t ip_src;
15314 cmdline_ipaddr_t ip_dst;
15316 struct ether_addr eth_src;
15317 struct ether_addr eth_dst;
15320 cmdline_parse_token_string_t cmd_set_nvgre_set =
15321 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15322 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15323 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15324 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15325 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15326 "nvgre-with-vlan");
15327 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15328 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15330 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15331 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15333 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15334 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15336 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15337 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15338 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15339 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15341 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15342 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15343 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15344 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15346 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15347 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15348 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15349 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15351 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15352 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15353 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15354 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15356 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15357 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15358 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15359 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15361 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15362 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15364 static void cmd_set_nvgre_parsed(void *parsed_result,
15365 __attribute__((unused)) struct cmdline *cl,
15366 __attribute__((unused)) void *data)
15368 struct cmd_set_nvgre_result *res = parsed_result;
15370 uint32_t nvgre_tni;
15373 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15376 if (strcmp(res->nvgre, "nvgre") == 0)
15377 nvgre_encap_conf.select_vlan = 0;
15378 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15379 nvgre_encap_conf.select_vlan = 1;
15380 if (strcmp(res->ip_version, "ipv4") == 0)
15381 nvgre_encap_conf.select_ipv4 = 1;
15382 else if (strcmp(res->ip_version, "ipv6") == 0)
15383 nvgre_encap_conf.select_ipv4 = 0;
15386 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15387 if (nvgre_encap_conf.select_ipv4) {
15388 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15389 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15391 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15392 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15394 if (nvgre_encap_conf.select_vlan)
15395 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15396 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15398 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15402 cmdline_parse_inst_t cmd_set_nvgre = {
15403 .f = cmd_set_nvgre_parsed,
15405 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15406 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15407 " eth-dst <eth-dst>",
15409 (void *)&cmd_set_nvgre_set,
15410 (void *)&cmd_set_nvgre_nvgre,
15411 (void *)&cmd_set_nvgre_ip_version,
15412 (void *)&cmd_set_nvgre_ip_version_value,
15413 (void *)&cmd_set_nvgre_tni,
15414 (void *)&cmd_set_nvgre_tni_value,
15415 (void *)&cmd_set_nvgre_ip_src,
15416 (void *)&cmd_set_nvgre_ip_src_value,
15417 (void *)&cmd_set_nvgre_ip_dst,
15418 (void *)&cmd_set_nvgre_ip_dst_value,
15419 (void *)&cmd_set_nvgre_eth_src,
15420 (void *)&cmd_set_nvgre_eth_src_value,
15421 (void *)&cmd_set_nvgre_eth_dst,
15422 (void *)&cmd_set_nvgre_eth_dst_value,
15427 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15428 .f = cmd_set_nvgre_parsed,
15430 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15431 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15432 " eth-src <eth-src> eth-dst <eth-dst>",
15434 (void *)&cmd_set_nvgre_set,
15435 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15436 (void *)&cmd_set_nvgre_ip_version,
15437 (void *)&cmd_set_nvgre_ip_version_value,
15438 (void *)&cmd_set_nvgre_tni,
15439 (void *)&cmd_set_nvgre_tni_value,
15440 (void *)&cmd_set_nvgre_ip_src,
15441 (void *)&cmd_set_nvgre_ip_src_value,
15442 (void *)&cmd_set_nvgre_ip_dst,
15443 (void *)&cmd_set_nvgre_ip_dst_value,
15444 (void *)&cmd_set_nvgre_vlan,
15445 (void *)&cmd_set_nvgre_vlan_value,
15446 (void *)&cmd_set_nvgre_eth_src,
15447 (void *)&cmd_set_nvgre_eth_src_value,
15448 (void *)&cmd_set_nvgre_eth_dst,
15449 (void *)&cmd_set_nvgre_eth_dst_value,
15454 /** Set L2 encapsulation details */
15455 struct cmd_set_l2_encap_result {
15456 cmdline_fixed_string_t set;
15457 cmdline_fixed_string_t l2_encap;
15458 cmdline_fixed_string_t pos_token;
15459 cmdline_fixed_string_t ip_version;
15460 uint32_t vlan_present:1;
15462 struct ether_addr eth_src;
15463 struct ether_addr eth_dst;
15466 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15467 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15468 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15469 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15470 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15471 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15472 "l2_encap-with-vlan");
15473 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15474 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15476 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15477 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15479 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15480 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15482 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15483 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15484 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15485 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15487 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15488 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15489 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15490 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15492 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15493 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15495 static void cmd_set_l2_encap_parsed(void *parsed_result,
15496 __attribute__((unused)) struct cmdline *cl,
15497 __attribute__((unused)) void *data)
15499 struct cmd_set_l2_encap_result *res = parsed_result;
15501 if (strcmp(res->l2_encap, "l2_encap") == 0)
15502 l2_encap_conf.select_vlan = 0;
15503 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15504 l2_encap_conf.select_vlan = 1;
15505 if (strcmp(res->ip_version, "ipv4") == 0)
15506 l2_encap_conf.select_ipv4 = 1;
15507 else if (strcmp(res->ip_version, "ipv6") == 0)
15508 l2_encap_conf.select_ipv4 = 0;
15511 if (l2_encap_conf.select_vlan)
15512 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15513 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15515 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15519 cmdline_parse_inst_t cmd_set_l2_encap = {
15520 .f = cmd_set_l2_encap_parsed,
15522 .help_str = "set l2_encap ip-version ipv4|ipv6"
15523 " eth-src <eth-src> eth-dst <eth-dst>",
15525 (void *)&cmd_set_l2_encap_set,
15526 (void *)&cmd_set_l2_encap_l2_encap,
15527 (void *)&cmd_set_l2_encap_ip_version,
15528 (void *)&cmd_set_l2_encap_ip_version_value,
15529 (void *)&cmd_set_l2_encap_eth_src,
15530 (void *)&cmd_set_l2_encap_eth_src_value,
15531 (void *)&cmd_set_l2_encap_eth_dst,
15532 (void *)&cmd_set_l2_encap_eth_dst_value,
15537 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15538 .f = cmd_set_l2_encap_parsed,
15540 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15541 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15543 (void *)&cmd_set_l2_encap_set,
15544 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15545 (void *)&cmd_set_l2_encap_ip_version,
15546 (void *)&cmd_set_l2_encap_ip_version_value,
15547 (void *)&cmd_set_l2_encap_vlan,
15548 (void *)&cmd_set_l2_encap_vlan_value,
15549 (void *)&cmd_set_l2_encap_eth_src,
15550 (void *)&cmd_set_l2_encap_eth_src_value,
15551 (void *)&cmd_set_l2_encap_eth_dst,
15552 (void *)&cmd_set_l2_encap_eth_dst_value,
15557 /** Set L2 decapsulation details */
15558 struct cmd_set_l2_decap_result {
15559 cmdline_fixed_string_t set;
15560 cmdline_fixed_string_t l2_decap;
15561 cmdline_fixed_string_t pos_token;
15562 uint32_t vlan_present:1;
15565 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15566 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15567 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15568 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15570 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15571 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15572 "l2_decap-with-vlan");
15574 static void cmd_set_l2_decap_parsed(void *parsed_result,
15575 __attribute__((unused)) struct cmdline *cl,
15576 __attribute__((unused)) void *data)
15578 struct cmd_set_l2_decap_result *res = parsed_result;
15580 if (strcmp(res->l2_decap, "l2_decap") == 0)
15581 l2_decap_conf.select_vlan = 0;
15582 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15583 l2_decap_conf.select_vlan = 1;
15586 cmdline_parse_inst_t cmd_set_l2_decap = {
15587 .f = cmd_set_l2_decap_parsed,
15589 .help_str = "set l2_decap",
15591 (void *)&cmd_set_l2_decap_set,
15592 (void *)&cmd_set_l2_decap_l2_decap,
15597 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15598 .f = cmd_set_l2_decap_parsed,
15600 .help_str = "set l2_decap-with-vlan",
15602 (void *)&cmd_set_l2_decap_set,
15603 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15608 /** Set MPLSoGRE encapsulation details */
15609 struct cmd_set_mplsogre_encap_result {
15610 cmdline_fixed_string_t set;
15611 cmdline_fixed_string_t mplsogre;
15612 cmdline_fixed_string_t pos_token;
15613 cmdline_fixed_string_t ip_version;
15614 uint32_t vlan_present:1;
15616 cmdline_ipaddr_t ip_src;
15617 cmdline_ipaddr_t ip_dst;
15619 struct ether_addr eth_src;
15620 struct ether_addr eth_dst;
15623 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15624 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15626 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15627 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15629 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15630 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15631 mplsogre, "mplsogre_encap-with-vlan");
15632 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15633 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15634 pos_token, "ip-version");
15635 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15636 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15637 ip_version, "ipv4#ipv6");
15638 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15639 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15640 pos_token, "label");
15641 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15642 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15644 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15645 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15646 pos_token, "ip-src");
15647 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15648 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15649 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15650 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15651 pos_token, "ip-dst");
15652 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15653 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15654 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15655 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15656 pos_token, "vlan-tci");
15657 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15658 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15660 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15661 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15662 pos_token, "eth-src");
15663 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15664 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15666 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15667 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15668 pos_token, "eth-dst");
15669 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15670 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15673 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15674 __attribute__((unused)) struct cmdline *cl,
15675 __attribute__((unused)) void *data)
15677 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15679 uint32_t mplsogre_label;
15682 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15685 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15686 mplsogre_encap_conf.select_vlan = 0;
15687 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15688 mplsogre_encap_conf.select_vlan = 1;
15689 if (strcmp(res->ip_version, "ipv4") == 0)
15690 mplsogre_encap_conf.select_ipv4 = 1;
15691 else if (strcmp(res->ip_version, "ipv6") == 0)
15692 mplsogre_encap_conf.select_ipv4 = 0;
15695 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15696 if (mplsogre_encap_conf.select_ipv4) {
15697 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15698 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15700 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15701 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15703 if (mplsogre_encap_conf.select_vlan)
15704 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15705 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15707 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15711 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15712 .f = cmd_set_mplsogre_encap_parsed,
15714 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15715 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15716 " eth-dst <eth-dst>",
15718 (void *)&cmd_set_mplsogre_encap_set,
15719 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15720 (void *)&cmd_set_mplsogre_encap_ip_version,
15721 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15722 (void *)&cmd_set_mplsogre_encap_label,
15723 (void *)&cmd_set_mplsogre_encap_label_value,
15724 (void *)&cmd_set_mplsogre_encap_ip_src,
15725 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15726 (void *)&cmd_set_mplsogre_encap_ip_dst,
15727 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15728 (void *)&cmd_set_mplsogre_encap_eth_src,
15729 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15730 (void *)&cmd_set_mplsogre_encap_eth_dst,
15731 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15736 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15737 .f = cmd_set_mplsogre_encap_parsed,
15739 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15740 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15741 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15743 (void *)&cmd_set_mplsogre_encap_set,
15744 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15745 (void *)&cmd_set_mplsogre_encap_ip_version,
15746 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15747 (void *)&cmd_set_mplsogre_encap_label,
15748 (void *)&cmd_set_mplsogre_encap_label_value,
15749 (void *)&cmd_set_mplsogre_encap_ip_src,
15750 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15751 (void *)&cmd_set_mplsogre_encap_ip_dst,
15752 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15753 (void *)&cmd_set_mplsogre_encap_vlan,
15754 (void *)&cmd_set_mplsogre_encap_vlan_value,
15755 (void *)&cmd_set_mplsogre_encap_eth_src,
15756 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15757 (void *)&cmd_set_mplsogre_encap_eth_dst,
15758 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15763 /** Set MPLSoGRE decapsulation details */
15764 struct cmd_set_mplsogre_decap_result {
15765 cmdline_fixed_string_t set;
15766 cmdline_fixed_string_t mplsogre;
15767 cmdline_fixed_string_t pos_token;
15768 cmdline_fixed_string_t ip_version;
15769 uint32_t vlan_present:1;
15772 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15773 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15775 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15776 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15778 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15779 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15780 mplsogre, "mplsogre_decap-with-vlan");
15781 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15782 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15783 pos_token, "ip-version");
15784 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15785 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15786 ip_version, "ipv4#ipv6");
15788 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15789 __attribute__((unused)) struct cmdline *cl,
15790 __attribute__((unused)) void *data)
15792 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15794 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15795 mplsogre_decap_conf.select_vlan = 0;
15796 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15797 mplsogre_decap_conf.select_vlan = 1;
15798 if (strcmp(res->ip_version, "ipv4") == 0)
15799 mplsogre_decap_conf.select_ipv4 = 1;
15800 else if (strcmp(res->ip_version, "ipv6") == 0)
15801 mplsogre_decap_conf.select_ipv4 = 0;
15804 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15805 .f = cmd_set_mplsogre_decap_parsed,
15807 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15809 (void *)&cmd_set_mplsogre_decap_set,
15810 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15811 (void *)&cmd_set_mplsogre_decap_ip_version,
15812 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15817 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15818 .f = cmd_set_mplsogre_decap_parsed,
15820 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15822 (void *)&cmd_set_mplsogre_decap_set,
15823 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15824 (void *)&cmd_set_mplsogre_decap_ip_version,
15825 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15830 /** Set MPLSoUDP encapsulation details */
15831 struct cmd_set_mplsoudp_encap_result {
15832 cmdline_fixed_string_t set;
15833 cmdline_fixed_string_t mplsoudp;
15834 cmdline_fixed_string_t pos_token;
15835 cmdline_fixed_string_t ip_version;
15836 uint32_t vlan_present:1;
15840 cmdline_ipaddr_t ip_src;
15841 cmdline_ipaddr_t ip_dst;
15843 struct ether_addr eth_src;
15844 struct ether_addr eth_dst;
15847 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15848 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15850 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15851 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15853 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15854 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15855 mplsoudp, "mplsoudp_encap-with-vlan");
15856 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15857 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15858 pos_token, "ip-version");
15859 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15860 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15861 ip_version, "ipv4#ipv6");
15862 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15863 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15864 pos_token, "label");
15865 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15866 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15868 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15869 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15870 pos_token, "udp-src");
15871 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15872 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15874 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15875 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15876 pos_token, "udp-dst");
15877 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15878 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15880 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15881 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15882 pos_token, "ip-src");
15883 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
15884 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
15885 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
15886 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15887 pos_token, "ip-dst");
15888 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
15889 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
15890 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
15891 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15892 pos_token, "vlan-tci");
15893 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
15894 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
15896 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
15897 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15898 pos_token, "eth-src");
15899 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
15900 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15902 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
15903 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15904 pos_token, "eth-dst");
15905 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
15906 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15909 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
15910 __attribute__((unused)) struct cmdline *cl,
15911 __attribute__((unused)) void *data)
15913 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
15915 uint32_t mplsoudp_label;
15918 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
15921 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
15922 mplsoudp_encap_conf.select_vlan = 0;
15923 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
15924 mplsoudp_encap_conf.select_vlan = 1;
15925 if (strcmp(res->ip_version, "ipv4") == 0)
15926 mplsoudp_encap_conf.select_ipv4 = 1;
15927 else if (strcmp(res->ip_version, "ipv6") == 0)
15928 mplsoudp_encap_conf.select_ipv4 = 0;
15931 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
15932 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15933 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15934 if (mplsoudp_encap_conf.select_ipv4) {
15935 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
15936 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
15938 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
15939 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
15941 if (mplsoudp_encap_conf.select_vlan)
15942 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15943 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
15945 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15949 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15950 .f = cmd_set_mplsoudp_encap_parsed,
15952 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15953 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15954 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15956 (void *)&cmd_set_mplsoudp_encap_set,
15957 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15958 (void *)&cmd_set_mplsoudp_encap_ip_version,
15959 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15960 (void *)&cmd_set_mplsoudp_encap_label,
15961 (void *)&cmd_set_mplsoudp_encap_label_value,
15962 (void *)&cmd_set_mplsoudp_encap_udp_src,
15963 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15964 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15965 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15966 (void *)&cmd_set_mplsoudp_encap_ip_src,
15967 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15968 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15969 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15970 (void *)&cmd_set_mplsoudp_encap_eth_src,
15971 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15972 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15973 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15978 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15979 .f = cmd_set_mplsoudp_encap_parsed,
15981 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15982 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
15983 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15984 " eth-src <eth-src> eth-dst <eth-dst>",
15986 (void *)&cmd_set_mplsoudp_encap_set,
15987 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15988 (void *)&cmd_set_mplsoudp_encap_ip_version,
15989 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15990 (void *)&cmd_set_mplsoudp_encap_label,
15991 (void *)&cmd_set_mplsoudp_encap_label_value,
15992 (void *)&cmd_set_mplsoudp_encap_udp_src,
15993 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15994 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15995 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15996 (void *)&cmd_set_mplsoudp_encap_ip_src,
15997 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15998 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15999 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16000 (void *)&cmd_set_mplsoudp_encap_vlan,
16001 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16002 (void *)&cmd_set_mplsoudp_encap_eth_src,
16003 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16004 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16005 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16010 /** Set MPLSoUDP decapsulation details */
16011 struct cmd_set_mplsoudp_decap_result {
16012 cmdline_fixed_string_t set;
16013 cmdline_fixed_string_t mplsoudp;
16014 cmdline_fixed_string_t pos_token;
16015 cmdline_fixed_string_t ip_version;
16016 uint32_t vlan_present:1;
16019 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16020 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16022 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16023 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16025 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16026 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16027 mplsoudp, "mplsoudp_decap-with-vlan");
16028 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16029 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16030 pos_token, "ip-version");
16031 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16032 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16033 ip_version, "ipv4#ipv6");
16035 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16036 __attribute__((unused)) struct cmdline *cl,
16037 __attribute__((unused)) void *data)
16039 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16041 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16042 mplsoudp_decap_conf.select_vlan = 0;
16043 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16044 mplsoudp_decap_conf.select_vlan = 1;
16045 if (strcmp(res->ip_version, "ipv4") == 0)
16046 mplsoudp_decap_conf.select_ipv4 = 1;
16047 else if (strcmp(res->ip_version, "ipv6") == 0)
16048 mplsoudp_decap_conf.select_ipv4 = 0;
16051 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16052 .f = cmd_set_mplsoudp_decap_parsed,
16054 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16056 (void *)&cmd_set_mplsoudp_decap_set,
16057 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16058 (void *)&cmd_set_mplsoudp_decap_ip_version,
16059 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16064 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16065 .f = cmd_set_mplsoudp_decap_parsed,
16067 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16069 (void *)&cmd_set_mplsoudp_decap_set,
16070 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16071 (void *)&cmd_set_mplsoudp_decap_ip_version,
16072 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16077 /* Strict link priority scheduling mode setting */
16079 cmd_strict_link_prio_parsed(
16080 void *parsed_result,
16081 __attribute__((unused)) struct cmdline *cl,
16082 __attribute__((unused)) void *data)
16084 struct cmd_vf_tc_bw_result *res = parsed_result;
16085 int ret = -ENOTSUP;
16087 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16090 #ifdef RTE_LIBRTE_I40E_PMD
16091 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16098 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16101 printf("invalid port_id %d\n", res->port_id);
16104 printf("function not implemented\n");
16107 printf("programming error: (%s)\n", strerror(-ret));
16111 cmdline_parse_inst_t cmd_strict_link_prio = {
16112 .f = cmd_strict_link_prio_parsed,
16114 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16116 (void *)&cmd_vf_tc_bw_set,
16117 (void *)&cmd_vf_tc_bw_tx,
16118 (void *)&cmd_vf_tc_bw_strict_link_prio,
16119 (void *)&cmd_vf_tc_bw_port_id,
16120 (void *)&cmd_vf_tc_bw_tc_map,
16125 /* Load dynamic device personalization*/
16126 struct cmd_ddp_add_result {
16127 cmdline_fixed_string_t ddp;
16128 cmdline_fixed_string_t add;
16133 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16134 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16135 cmdline_parse_token_string_t cmd_ddp_add_add =
16136 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16137 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16138 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16139 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16140 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16143 cmd_ddp_add_parsed(
16144 void *parsed_result,
16145 __attribute__((unused)) struct cmdline *cl,
16146 __attribute__((unused)) void *data)
16148 struct cmd_ddp_add_result *res = parsed_result;
16154 int ret = -ENOTSUP;
16156 if (!all_ports_stopped()) {
16157 printf("Please stop all ports first\n");
16161 filepath = strdup(res->filepath);
16162 if (filepath == NULL) {
16163 printf("Failed to allocate memory\n");
16166 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16168 buff = open_file(file_fld[0], &size);
16170 free((void *)filepath);
16174 #ifdef RTE_LIBRTE_I40E_PMD
16175 if (ret == -ENOTSUP)
16176 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16178 RTE_PMD_I40E_PKG_OP_WR_ADD);
16181 if (ret == -EEXIST)
16182 printf("Profile has already existed.\n");
16184 printf("Failed to load profile.\n");
16185 else if (file_num == 2)
16186 save_file(file_fld[1], buff, size);
16189 free((void *)filepath);
16192 cmdline_parse_inst_t cmd_ddp_add = {
16193 .f = cmd_ddp_add_parsed,
16195 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16197 (void *)&cmd_ddp_add_ddp,
16198 (void *)&cmd_ddp_add_add,
16199 (void *)&cmd_ddp_add_port_id,
16200 (void *)&cmd_ddp_add_filepath,
16205 /* Delete dynamic device personalization*/
16206 struct cmd_ddp_del_result {
16207 cmdline_fixed_string_t ddp;
16208 cmdline_fixed_string_t del;
16213 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16214 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16215 cmdline_parse_token_string_t cmd_ddp_del_del =
16216 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16217 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16218 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16219 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16220 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16223 cmd_ddp_del_parsed(
16224 void *parsed_result,
16225 __attribute__((unused)) struct cmdline *cl,
16226 __attribute__((unused)) void *data)
16228 struct cmd_ddp_del_result *res = parsed_result;
16231 int ret = -ENOTSUP;
16233 if (!all_ports_stopped()) {
16234 printf("Please stop all ports first\n");
16238 buff = open_file(res->filepath, &size);
16242 #ifdef RTE_LIBRTE_I40E_PMD
16243 if (ret == -ENOTSUP)
16244 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16246 RTE_PMD_I40E_PKG_OP_WR_DEL);
16249 if (ret == -EACCES)
16250 printf("Profile does not exist.\n");
16252 printf("Failed to delete profile.\n");
16257 cmdline_parse_inst_t cmd_ddp_del = {
16258 .f = cmd_ddp_del_parsed,
16260 .help_str = "ddp del <port_id> <backup_profile_path>",
16262 (void *)&cmd_ddp_del_ddp,
16263 (void *)&cmd_ddp_del_del,
16264 (void *)&cmd_ddp_del_port_id,
16265 (void *)&cmd_ddp_del_filepath,
16270 /* Get dynamic device personalization profile info */
16271 struct cmd_ddp_info_result {
16272 cmdline_fixed_string_t ddp;
16273 cmdline_fixed_string_t get;
16274 cmdline_fixed_string_t info;
16278 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16279 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16280 cmdline_parse_token_string_t cmd_ddp_info_get =
16281 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16282 cmdline_parse_token_string_t cmd_ddp_info_info =
16283 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16284 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16285 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16288 cmd_ddp_info_parsed(
16289 void *parsed_result,
16290 __attribute__((unused)) struct cmdline *cl,
16291 __attribute__((unused)) void *data)
16293 struct cmd_ddp_info_result *res = parsed_result;
16296 int ret = -ENOTSUP;
16297 #ifdef RTE_LIBRTE_I40E_PMD
16300 uint32_t buff_size = 0;
16301 struct rte_pmd_i40e_profile_info info;
16302 uint32_t dev_num = 0;
16303 struct rte_pmd_i40e_ddp_device_id *devs;
16304 uint32_t proto_num = 0;
16305 struct rte_pmd_i40e_proto_info *proto = NULL;
16306 uint32_t pctype_num = 0;
16307 struct rte_pmd_i40e_ptype_info *pctype;
16308 uint32_t ptype_num = 0;
16309 struct rte_pmd_i40e_ptype_info *ptype;
16314 pkg = open_file(res->filepath, &pkg_size);
16318 #ifdef RTE_LIBRTE_I40E_PMD
16319 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16320 (uint8_t *)&info, sizeof(info),
16321 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16323 printf("Global Track id: 0x%x\n", info.track_id);
16324 printf("Global Version: %d.%d.%d.%d\n",
16325 info.version.major,
16326 info.version.minor,
16327 info.version.update,
16328 info.version.draft);
16329 printf("Global Package name: %s\n\n", info.name);
16332 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16333 (uint8_t *)&info, sizeof(info),
16334 RTE_PMD_I40E_PKG_INFO_HEADER);
16336 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16337 printf("i40e Profile Version: %d.%d.%d.%d\n",
16338 info.version.major,
16339 info.version.minor,
16340 info.version.update,
16341 info.version.draft);
16342 printf("i40e Profile name: %s\n\n", info.name);
16345 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16346 (uint8_t *)&buff_size, sizeof(buff_size),
16347 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16348 if (!ret && buff_size) {
16349 buff = (uint8_t *)malloc(buff_size);
16351 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16353 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16355 printf("Package Notes:\n%s\n\n", buff);
16360 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16361 (uint8_t *)&dev_num, sizeof(dev_num),
16362 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16363 if (!ret && dev_num) {
16364 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16365 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16367 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16368 (uint8_t *)devs, buff_size,
16369 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16371 printf("List of supported devices:\n");
16372 for (i = 0; i < dev_num; i++) {
16373 printf(" %04X:%04X %04X:%04X\n",
16374 devs[i].vendor_dev_id >> 16,
16375 devs[i].vendor_dev_id & 0xFFFF,
16376 devs[i].sub_vendor_dev_id >> 16,
16377 devs[i].sub_vendor_dev_id & 0xFFFF);
16385 /* get information about protocols and packet types */
16386 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16387 (uint8_t *)&proto_num, sizeof(proto_num),
16388 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16389 if (ret || !proto_num)
16390 goto no_print_return;
16392 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16393 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16395 goto no_print_return;
16397 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16399 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16401 printf("List of used protocols:\n");
16402 for (i = 0; i < proto_num; i++)
16403 printf(" %2u: %s\n", proto[i].proto_id,
16407 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16408 (uint8_t *)&pctype_num, sizeof(pctype_num),
16409 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16410 if (ret || !pctype_num)
16411 goto no_print_pctypes;
16413 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16414 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16416 goto no_print_pctypes;
16418 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16420 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16423 goto no_print_pctypes;
16426 printf("List of defined packet classification types:\n");
16427 for (i = 0; i < pctype_num; i++) {
16428 printf(" %2u:", pctype[i].ptype_id);
16429 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16430 proto_id = pctype[i].protocols[j];
16431 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16432 for (n = 0; n < proto_num; n++) {
16433 if (proto[n].proto_id == proto_id) {
16434 printf(" %s", proto[n].name);
16447 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16449 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16450 if (ret || !ptype_num)
16451 goto no_print_return;
16453 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16454 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16456 goto no_print_return;
16458 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16460 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16463 goto no_print_return;
16465 printf("List of defined packet types:\n");
16466 for (i = 0; i < ptype_num; i++) {
16467 printf(" %2u:", ptype[i].ptype_id);
16468 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16469 proto_id = ptype[i].protocols[j];
16470 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16471 for (n = 0; n < proto_num; n++) {
16472 if (proto[n].proto_id == proto_id) {
16473 printf(" %s", proto[n].name);
16489 if (ret == -ENOTSUP)
16490 printf("Function not supported in PMD driver\n");
16494 cmdline_parse_inst_t cmd_ddp_get_info = {
16495 .f = cmd_ddp_info_parsed,
16497 .help_str = "ddp get info <profile_path>",
16499 (void *)&cmd_ddp_info_ddp,
16500 (void *)&cmd_ddp_info_get,
16501 (void *)&cmd_ddp_info_info,
16502 (void *)&cmd_ddp_info_filepath,
16507 /* Get dynamic device personalization profile info list*/
16508 #define PROFILE_INFO_SIZE 48
16509 #define MAX_PROFILE_NUM 16
16511 struct cmd_ddp_get_list_result {
16512 cmdline_fixed_string_t ddp;
16513 cmdline_fixed_string_t get;
16514 cmdline_fixed_string_t list;
16518 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16519 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16520 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16521 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16522 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16523 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16524 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16525 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16528 cmd_ddp_get_list_parsed(
16529 __attribute__((unused)) void *parsed_result,
16530 __attribute__((unused)) struct cmdline *cl,
16531 __attribute__((unused)) void *data)
16533 #ifdef RTE_LIBRTE_I40E_PMD
16534 struct cmd_ddp_get_list_result *res = parsed_result;
16535 struct rte_pmd_i40e_profile_list *p_list;
16536 struct rte_pmd_i40e_profile_info *p_info;
16541 int ret = -ENOTSUP;
16543 #ifdef RTE_LIBRTE_I40E_PMD
16544 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16545 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16547 printf("%s: Failed to malloc buffer\n", __func__);
16549 if (ret == -ENOTSUP)
16550 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16551 (uint8_t *)p_list, size);
16554 p_num = p_list->p_count;
16555 printf("Profile number is: %d\n\n", p_num);
16557 for (i = 0; i < p_num; i++) {
16558 p_info = &p_list->p_info[i];
16559 printf("Profile %d:\n", i);
16560 printf("Track id: 0x%x\n", p_info->track_id);
16561 printf("Version: %d.%d.%d.%d\n",
16562 p_info->version.major,
16563 p_info->version.minor,
16564 p_info->version.update,
16565 p_info->version.draft);
16566 printf("Profile name: %s\n\n", p_info->name);
16574 printf("Failed to get ddp list\n");
16577 cmdline_parse_inst_t cmd_ddp_get_list = {
16578 .f = cmd_ddp_get_list_parsed,
16580 .help_str = "ddp get list <port_id>",
16582 (void *)&cmd_ddp_get_list_ddp,
16583 (void *)&cmd_ddp_get_list_get,
16584 (void *)&cmd_ddp_get_list_list,
16585 (void *)&cmd_ddp_get_list_port_id,
16590 /* Configure input set */
16591 struct cmd_cfg_input_set_result {
16592 cmdline_fixed_string_t port;
16593 cmdline_fixed_string_t cfg;
16595 cmdline_fixed_string_t pctype;
16597 cmdline_fixed_string_t inset_type;
16598 cmdline_fixed_string_t opt;
16599 cmdline_fixed_string_t field;
16604 cmd_cfg_input_set_parsed(
16605 __attribute__((unused)) void *parsed_result,
16606 __attribute__((unused)) struct cmdline *cl,
16607 __attribute__((unused)) void *data)
16609 #ifdef RTE_LIBRTE_I40E_PMD
16610 struct cmd_cfg_input_set_result *res = parsed_result;
16611 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16612 struct rte_pmd_i40e_inset inset;
16614 int ret = -ENOTSUP;
16616 if (!all_ports_stopped()) {
16617 printf("Please stop all ports first\n");
16621 #ifdef RTE_LIBRTE_I40E_PMD
16622 if (!strcmp(res->inset_type, "hash_inset"))
16623 inset_type = INSET_HASH;
16624 else if (!strcmp(res->inset_type, "fdir_inset"))
16625 inset_type = INSET_FDIR;
16626 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16627 inset_type = INSET_FDIR_FLX;
16628 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16629 &inset, inset_type);
16631 printf("Failed to get input set.\n");
16635 if (!strcmp(res->opt, "get")) {
16636 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16639 printf("Field index %d is enabled.\n", res->field_idx);
16641 printf("Field index %d is disabled.\n", res->field_idx);
16643 } else if (!strcmp(res->opt, "set"))
16644 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16646 else if (!strcmp(res->opt, "clear"))
16647 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16650 printf("Failed to configure input set field.\n");
16654 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16655 &inset, inset_type);
16657 printf("Failed to set input set.\n");
16662 if (ret == -ENOTSUP)
16663 printf("Function not supported\n");
16666 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16667 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16669 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16670 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16672 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16673 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16675 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16676 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16678 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16679 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16681 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16682 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16684 "hash_inset#fdir_inset#fdir_flx_inset");
16685 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16686 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16687 opt, "get#set#clear");
16688 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16689 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16691 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16692 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16695 cmdline_parse_inst_t cmd_cfg_input_set = {
16696 .f = cmd_cfg_input_set_parsed,
16698 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16699 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16701 (void *)&cmd_cfg_input_set_port,
16702 (void *)&cmd_cfg_input_set_cfg,
16703 (void *)&cmd_cfg_input_set_port_id,
16704 (void *)&cmd_cfg_input_set_pctype,
16705 (void *)&cmd_cfg_input_set_pctype_id,
16706 (void *)&cmd_cfg_input_set_inset_type,
16707 (void *)&cmd_cfg_input_set_opt,
16708 (void *)&cmd_cfg_input_set_field,
16709 (void *)&cmd_cfg_input_set_field_idx,
16714 /* Clear input set */
16715 struct cmd_clear_input_set_result {
16716 cmdline_fixed_string_t port;
16717 cmdline_fixed_string_t cfg;
16719 cmdline_fixed_string_t pctype;
16721 cmdline_fixed_string_t inset_type;
16722 cmdline_fixed_string_t clear;
16723 cmdline_fixed_string_t all;
16727 cmd_clear_input_set_parsed(
16728 __attribute__((unused)) void *parsed_result,
16729 __attribute__((unused)) struct cmdline *cl,
16730 __attribute__((unused)) void *data)
16732 #ifdef RTE_LIBRTE_I40E_PMD
16733 struct cmd_clear_input_set_result *res = parsed_result;
16734 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16735 struct rte_pmd_i40e_inset inset;
16737 int ret = -ENOTSUP;
16739 if (!all_ports_stopped()) {
16740 printf("Please stop all ports first\n");
16744 #ifdef RTE_LIBRTE_I40E_PMD
16745 if (!strcmp(res->inset_type, "hash_inset"))
16746 inset_type = INSET_HASH;
16747 else if (!strcmp(res->inset_type, "fdir_inset"))
16748 inset_type = INSET_FDIR;
16749 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16750 inset_type = INSET_FDIR_FLX;
16752 memset(&inset, 0, sizeof(inset));
16754 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16755 &inset, inset_type);
16757 printf("Failed to clear input set.\n");
16763 if (ret == -ENOTSUP)
16764 printf("Function not supported\n");
16767 cmdline_parse_token_string_t cmd_clear_input_set_port =
16768 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16770 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16771 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16773 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16774 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16776 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16777 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16779 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16780 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16782 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16783 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16785 "hash_inset#fdir_inset#fdir_flx_inset");
16786 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16787 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16789 cmdline_parse_token_string_t cmd_clear_input_set_all =
16790 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16793 cmdline_parse_inst_t cmd_clear_input_set = {
16794 .f = cmd_clear_input_set_parsed,
16796 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16797 "fdir_inset|fdir_flx_inset clear all",
16799 (void *)&cmd_clear_input_set_port,
16800 (void *)&cmd_clear_input_set_cfg,
16801 (void *)&cmd_clear_input_set_port_id,
16802 (void *)&cmd_clear_input_set_pctype,
16803 (void *)&cmd_clear_input_set_pctype_id,
16804 (void *)&cmd_clear_input_set_inset_type,
16805 (void *)&cmd_clear_input_set_clear,
16806 (void *)&cmd_clear_input_set_all,
16811 /* show vf stats */
16813 /* Common result structure for show vf stats */
16814 struct cmd_show_vf_stats_result {
16815 cmdline_fixed_string_t show;
16816 cmdline_fixed_string_t vf;
16817 cmdline_fixed_string_t stats;
16822 /* Common CLI fields show vf stats*/
16823 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16824 TOKEN_STRING_INITIALIZER
16825 (struct cmd_show_vf_stats_result,
16827 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16828 TOKEN_STRING_INITIALIZER
16829 (struct cmd_show_vf_stats_result,
16831 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16832 TOKEN_STRING_INITIALIZER
16833 (struct cmd_show_vf_stats_result,
16835 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16836 TOKEN_NUM_INITIALIZER
16837 (struct cmd_show_vf_stats_result,
16839 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16840 TOKEN_NUM_INITIALIZER
16841 (struct cmd_show_vf_stats_result,
16845 cmd_show_vf_stats_parsed(
16846 void *parsed_result,
16847 __attribute__((unused)) struct cmdline *cl,
16848 __attribute__((unused)) void *data)
16850 struct cmd_show_vf_stats_result *res = parsed_result;
16851 struct rte_eth_stats stats;
16852 int ret = -ENOTSUP;
16853 static const char *nic_stats_border = "########################";
16855 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16858 memset(&stats, 0, sizeof(stats));
16860 #ifdef RTE_LIBRTE_I40E_PMD
16861 if (ret == -ENOTSUP)
16862 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16866 #ifdef RTE_LIBRTE_BNXT_PMD
16867 if (ret == -ENOTSUP)
16868 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16877 printf("invalid vf_id %d\n", res->vf_id);
16880 printf("invalid port_id %d\n", res->port_id);
16883 printf("function not implemented\n");
16886 printf("programming error: (%s)\n", strerror(-ret));
16889 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16890 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16892 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16894 stats.ipackets, stats.imissed, stats.ibytes);
16895 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16896 printf(" RX-nombuf: %-10"PRIu64"\n",
16898 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16900 stats.opackets, stats.oerrors, stats.obytes);
16902 printf(" %s############################%s\n",
16903 nic_stats_border, nic_stats_border);
16906 cmdline_parse_inst_t cmd_show_vf_stats = {
16907 .f = cmd_show_vf_stats_parsed,
16909 .help_str = "show vf stats <port_id> <vf_id>",
16911 (void *)&cmd_show_vf_stats_show,
16912 (void *)&cmd_show_vf_stats_vf,
16913 (void *)&cmd_show_vf_stats_stats,
16914 (void *)&cmd_show_vf_stats_port_id,
16915 (void *)&cmd_show_vf_stats_vf_id,
16920 /* clear vf stats */
16922 /* Common result structure for clear vf stats */
16923 struct cmd_clear_vf_stats_result {
16924 cmdline_fixed_string_t clear;
16925 cmdline_fixed_string_t vf;
16926 cmdline_fixed_string_t stats;
16931 /* Common CLI fields clear vf stats*/
16932 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16933 TOKEN_STRING_INITIALIZER
16934 (struct cmd_clear_vf_stats_result,
16936 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16937 TOKEN_STRING_INITIALIZER
16938 (struct cmd_clear_vf_stats_result,
16940 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16941 TOKEN_STRING_INITIALIZER
16942 (struct cmd_clear_vf_stats_result,
16944 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16945 TOKEN_NUM_INITIALIZER
16946 (struct cmd_clear_vf_stats_result,
16948 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16949 TOKEN_NUM_INITIALIZER
16950 (struct cmd_clear_vf_stats_result,
16954 cmd_clear_vf_stats_parsed(
16955 void *parsed_result,
16956 __attribute__((unused)) struct cmdline *cl,
16957 __attribute__((unused)) void *data)
16959 struct cmd_clear_vf_stats_result *res = parsed_result;
16960 int ret = -ENOTSUP;
16962 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16965 #ifdef RTE_LIBRTE_I40E_PMD
16966 if (ret == -ENOTSUP)
16967 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16970 #ifdef RTE_LIBRTE_BNXT_PMD
16971 if (ret == -ENOTSUP)
16972 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16980 printf("invalid vf_id %d\n", res->vf_id);
16983 printf("invalid port_id %d\n", res->port_id);
16986 printf("function not implemented\n");
16989 printf("programming error: (%s)\n", strerror(-ret));
16993 cmdline_parse_inst_t cmd_clear_vf_stats = {
16994 .f = cmd_clear_vf_stats_parsed,
16996 .help_str = "clear vf stats <port_id> <vf_id>",
16998 (void *)&cmd_clear_vf_stats_clear,
16999 (void *)&cmd_clear_vf_stats_vf,
17000 (void *)&cmd_clear_vf_stats_stats,
17001 (void *)&cmd_clear_vf_stats_port_id,
17002 (void *)&cmd_clear_vf_stats_vf_id,
17007 /* port config pctype mapping reset */
17009 /* Common result structure for port config pctype mapping reset */
17010 struct cmd_pctype_mapping_reset_result {
17011 cmdline_fixed_string_t port;
17012 cmdline_fixed_string_t config;
17014 cmdline_fixed_string_t pctype;
17015 cmdline_fixed_string_t mapping;
17016 cmdline_fixed_string_t reset;
17019 /* Common CLI fields for port config pctype mapping reset*/
17020 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17021 TOKEN_STRING_INITIALIZER
17022 (struct cmd_pctype_mapping_reset_result,
17024 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17025 TOKEN_STRING_INITIALIZER
17026 (struct cmd_pctype_mapping_reset_result,
17028 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17029 TOKEN_NUM_INITIALIZER
17030 (struct cmd_pctype_mapping_reset_result,
17032 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17033 TOKEN_STRING_INITIALIZER
17034 (struct cmd_pctype_mapping_reset_result,
17036 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17037 TOKEN_STRING_INITIALIZER
17038 (struct cmd_pctype_mapping_reset_result,
17039 mapping, "mapping");
17040 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17041 TOKEN_STRING_INITIALIZER
17042 (struct cmd_pctype_mapping_reset_result,
17046 cmd_pctype_mapping_reset_parsed(
17047 void *parsed_result,
17048 __attribute__((unused)) struct cmdline *cl,
17049 __attribute__((unused)) void *data)
17051 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17052 int ret = -ENOTSUP;
17054 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17057 #ifdef RTE_LIBRTE_I40E_PMD
17058 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17065 printf("invalid port_id %d\n", res->port_id);
17068 printf("function not implemented\n");
17071 printf("programming error: (%s)\n", strerror(-ret));
17075 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17076 .f = cmd_pctype_mapping_reset_parsed,
17078 .help_str = "port config <port_id> pctype mapping reset",
17080 (void *)&cmd_pctype_mapping_reset_port,
17081 (void *)&cmd_pctype_mapping_reset_config,
17082 (void *)&cmd_pctype_mapping_reset_port_id,
17083 (void *)&cmd_pctype_mapping_reset_pctype,
17084 (void *)&cmd_pctype_mapping_reset_mapping,
17085 (void *)&cmd_pctype_mapping_reset_reset,
17090 /* show port pctype mapping */
17092 /* Common result structure for show port pctype mapping */
17093 struct cmd_pctype_mapping_get_result {
17094 cmdline_fixed_string_t show;
17095 cmdline_fixed_string_t port;
17097 cmdline_fixed_string_t pctype;
17098 cmdline_fixed_string_t mapping;
17101 /* Common CLI fields for pctype mapping get */
17102 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17103 TOKEN_STRING_INITIALIZER
17104 (struct cmd_pctype_mapping_get_result,
17106 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17107 TOKEN_STRING_INITIALIZER
17108 (struct cmd_pctype_mapping_get_result,
17110 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17111 TOKEN_NUM_INITIALIZER
17112 (struct cmd_pctype_mapping_get_result,
17114 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17115 TOKEN_STRING_INITIALIZER
17116 (struct cmd_pctype_mapping_get_result,
17118 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17119 TOKEN_STRING_INITIALIZER
17120 (struct cmd_pctype_mapping_get_result,
17121 mapping, "mapping");
17124 cmd_pctype_mapping_get_parsed(
17125 void *parsed_result,
17126 __attribute__((unused)) struct cmdline *cl,
17127 __attribute__((unused)) void *data)
17129 struct cmd_pctype_mapping_get_result *res = parsed_result;
17130 int ret = -ENOTSUP;
17131 #ifdef RTE_LIBRTE_I40E_PMD
17132 struct rte_pmd_i40e_flow_type_mapping
17133 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17134 int i, j, first_pctype;
17137 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17140 #ifdef RTE_LIBRTE_I40E_PMD
17141 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17148 printf("invalid port_id %d\n", res->port_id);
17151 printf("function not implemented\n");
17154 printf("programming error: (%s)\n", strerror(-ret));
17158 #ifdef RTE_LIBRTE_I40E_PMD
17159 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17160 if (mapping[i].pctype != 0ULL) {
17163 printf("pctype: ");
17164 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17165 if (mapping[i].pctype & (1ULL << j)) {
17166 printf(first_pctype ?
17167 "%02d" : ",%02d", j);
17171 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17177 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17178 .f = cmd_pctype_mapping_get_parsed,
17180 .help_str = "show port <port_id> pctype mapping",
17182 (void *)&cmd_pctype_mapping_get_show,
17183 (void *)&cmd_pctype_mapping_get_port,
17184 (void *)&cmd_pctype_mapping_get_port_id,
17185 (void *)&cmd_pctype_mapping_get_pctype,
17186 (void *)&cmd_pctype_mapping_get_mapping,
17191 /* port config pctype mapping update */
17193 /* Common result structure for port config pctype mapping update */
17194 struct cmd_pctype_mapping_update_result {
17195 cmdline_fixed_string_t port;
17196 cmdline_fixed_string_t config;
17198 cmdline_fixed_string_t pctype;
17199 cmdline_fixed_string_t mapping;
17200 cmdline_fixed_string_t update;
17201 cmdline_fixed_string_t pctype_list;
17202 uint16_t flow_type;
17205 /* Common CLI fields for pctype mapping update*/
17206 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17207 TOKEN_STRING_INITIALIZER
17208 (struct cmd_pctype_mapping_update_result,
17210 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17211 TOKEN_STRING_INITIALIZER
17212 (struct cmd_pctype_mapping_update_result,
17214 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17215 TOKEN_NUM_INITIALIZER
17216 (struct cmd_pctype_mapping_update_result,
17218 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17219 TOKEN_STRING_INITIALIZER
17220 (struct cmd_pctype_mapping_update_result,
17222 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17223 TOKEN_STRING_INITIALIZER
17224 (struct cmd_pctype_mapping_update_result,
17225 mapping, "mapping");
17226 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17227 TOKEN_STRING_INITIALIZER
17228 (struct cmd_pctype_mapping_update_result,
17230 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17231 TOKEN_STRING_INITIALIZER
17232 (struct cmd_pctype_mapping_update_result,
17233 pctype_list, NULL);
17234 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17235 TOKEN_NUM_INITIALIZER
17236 (struct cmd_pctype_mapping_update_result,
17237 flow_type, UINT16);
17240 cmd_pctype_mapping_update_parsed(
17241 void *parsed_result,
17242 __attribute__((unused)) struct cmdline *cl,
17243 __attribute__((unused)) void *data)
17245 struct cmd_pctype_mapping_update_result *res = parsed_result;
17246 int ret = -ENOTSUP;
17247 #ifdef RTE_LIBRTE_I40E_PMD
17248 struct rte_pmd_i40e_flow_type_mapping mapping;
17250 unsigned int nb_item;
17251 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17254 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17257 #ifdef RTE_LIBRTE_I40E_PMD
17258 nb_item = parse_item_list(res->pctype_list, "pctypes",
17259 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17260 mapping.flow_type = res->flow_type;
17261 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17262 mapping.pctype |= (1ULL << pctype_list[i]);
17263 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17273 printf("invalid pctype or flow type\n");
17276 printf("invalid port_id %d\n", res->port_id);
17279 printf("function not implemented\n");
17282 printf("programming error: (%s)\n", strerror(-ret));
17286 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17287 .f = cmd_pctype_mapping_update_parsed,
17289 .help_str = "port config <port_id> pctype mapping update"
17290 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17292 (void *)&cmd_pctype_mapping_update_port,
17293 (void *)&cmd_pctype_mapping_update_config,
17294 (void *)&cmd_pctype_mapping_update_port_id,
17295 (void *)&cmd_pctype_mapping_update_pctype,
17296 (void *)&cmd_pctype_mapping_update_mapping,
17297 (void *)&cmd_pctype_mapping_update_update,
17298 (void *)&cmd_pctype_mapping_update_pc_type,
17299 (void *)&cmd_pctype_mapping_update_flow_type,
17304 /* ptype mapping get */
17306 /* Common result structure for ptype mapping get */
17307 struct cmd_ptype_mapping_get_result {
17308 cmdline_fixed_string_t ptype;
17309 cmdline_fixed_string_t mapping;
17310 cmdline_fixed_string_t get;
17312 uint8_t valid_only;
17315 /* Common CLI fields for ptype mapping get */
17316 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17317 TOKEN_STRING_INITIALIZER
17318 (struct cmd_ptype_mapping_get_result,
17320 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17321 TOKEN_STRING_INITIALIZER
17322 (struct cmd_ptype_mapping_get_result,
17323 mapping, "mapping");
17324 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17325 TOKEN_STRING_INITIALIZER
17326 (struct cmd_ptype_mapping_get_result,
17328 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17329 TOKEN_NUM_INITIALIZER
17330 (struct cmd_ptype_mapping_get_result,
17332 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17333 TOKEN_NUM_INITIALIZER
17334 (struct cmd_ptype_mapping_get_result,
17335 valid_only, UINT8);
17338 cmd_ptype_mapping_get_parsed(
17339 void *parsed_result,
17340 __attribute__((unused)) struct cmdline *cl,
17341 __attribute__((unused)) void *data)
17343 struct cmd_ptype_mapping_get_result *res = parsed_result;
17344 int ret = -ENOTSUP;
17345 #ifdef RTE_LIBRTE_I40E_PMD
17346 int max_ptype_num = 256;
17347 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17352 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17355 #ifdef RTE_LIBRTE_I40E_PMD
17356 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17367 printf("invalid port_id %d\n", res->port_id);
17370 printf("function not implemented\n");
17373 printf("programming error: (%s)\n", strerror(-ret));
17376 #ifdef RTE_LIBRTE_I40E_PMD
17378 for (i = 0; i < count; i++)
17379 printf("%3d\t0x%08x\n",
17380 mapping[i].hw_ptype, mapping[i].sw_ptype);
17385 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17386 .f = cmd_ptype_mapping_get_parsed,
17388 .help_str = "ptype mapping get <port_id> <valid_only>",
17390 (void *)&cmd_ptype_mapping_get_ptype,
17391 (void *)&cmd_ptype_mapping_get_mapping,
17392 (void *)&cmd_ptype_mapping_get_get,
17393 (void *)&cmd_ptype_mapping_get_port_id,
17394 (void *)&cmd_ptype_mapping_get_valid_only,
17399 /* ptype mapping replace */
17401 /* Common result structure for ptype mapping replace */
17402 struct cmd_ptype_mapping_replace_result {
17403 cmdline_fixed_string_t ptype;
17404 cmdline_fixed_string_t mapping;
17405 cmdline_fixed_string_t replace;
17412 /* Common CLI fields for ptype mapping replace */
17413 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17414 TOKEN_STRING_INITIALIZER
17415 (struct cmd_ptype_mapping_replace_result,
17417 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17418 TOKEN_STRING_INITIALIZER
17419 (struct cmd_ptype_mapping_replace_result,
17420 mapping, "mapping");
17421 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17422 TOKEN_STRING_INITIALIZER
17423 (struct cmd_ptype_mapping_replace_result,
17424 replace, "replace");
17425 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17426 TOKEN_NUM_INITIALIZER
17427 (struct cmd_ptype_mapping_replace_result,
17429 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17430 TOKEN_NUM_INITIALIZER
17431 (struct cmd_ptype_mapping_replace_result,
17433 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17434 TOKEN_NUM_INITIALIZER
17435 (struct cmd_ptype_mapping_replace_result,
17437 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17438 TOKEN_NUM_INITIALIZER
17439 (struct cmd_ptype_mapping_replace_result,
17443 cmd_ptype_mapping_replace_parsed(
17444 void *parsed_result,
17445 __attribute__((unused)) struct cmdline *cl,
17446 __attribute__((unused)) void *data)
17448 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17449 int ret = -ENOTSUP;
17451 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17454 #ifdef RTE_LIBRTE_I40E_PMD
17455 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17465 printf("invalid ptype 0x%8x or 0x%8x\n",
17466 res->target, res->pkt_type);
17469 printf("invalid port_id %d\n", res->port_id);
17472 printf("function not implemented\n");
17475 printf("programming error: (%s)\n", strerror(-ret));
17479 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17480 .f = cmd_ptype_mapping_replace_parsed,
17483 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17485 (void *)&cmd_ptype_mapping_replace_ptype,
17486 (void *)&cmd_ptype_mapping_replace_mapping,
17487 (void *)&cmd_ptype_mapping_replace_replace,
17488 (void *)&cmd_ptype_mapping_replace_port_id,
17489 (void *)&cmd_ptype_mapping_replace_target,
17490 (void *)&cmd_ptype_mapping_replace_mask,
17491 (void *)&cmd_ptype_mapping_replace_pkt_type,
17496 /* ptype mapping reset */
17498 /* Common result structure for ptype mapping reset */
17499 struct cmd_ptype_mapping_reset_result {
17500 cmdline_fixed_string_t ptype;
17501 cmdline_fixed_string_t mapping;
17502 cmdline_fixed_string_t reset;
17506 /* Common CLI fields for ptype mapping reset*/
17507 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17508 TOKEN_STRING_INITIALIZER
17509 (struct cmd_ptype_mapping_reset_result,
17511 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17512 TOKEN_STRING_INITIALIZER
17513 (struct cmd_ptype_mapping_reset_result,
17514 mapping, "mapping");
17515 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17516 TOKEN_STRING_INITIALIZER
17517 (struct cmd_ptype_mapping_reset_result,
17519 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17520 TOKEN_NUM_INITIALIZER
17521 (struct cmd_ptype_mapping_reset_result,
17525 cmd_ptype_mapping_reset_parsed(
17526 void *parsed_result,
17527 __attribute__((unused)) struct cmdline *cl,
17528 __attribute__((unused)) void *data)
17530 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17531 int ret = -ENOTSUP;
17533 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17536 #ifdef RTE_LIBRTE_I40E_PMD
17537 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17544 printf("invalid port_id %d\n", res->port_id);
17547 printf("function not implemented\n");
17550 printf("programming error: (%s)\n", strerror(-ret));
17554 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17555 .f = cmd_ptype_mapping_reset_parsed,
17557 .help_str = "ptype mapping reset <port_id>",
17559 (void *)&cmd_ptype_mapping_reset_ptype,
17560 (void *)&cmd_ptype_mapping_reset_mapping,
17561 (void *)&cmd_ptype_mapping_reset_reset,
17562 (void *)&cmd_ptype_mapping_reset_port_id,
17567 /* ptype mapping update */
17569 /* Common result structure for ptype mapping update */
17570 struct cmd_ptype_mapping_update_result {
17571 cmdline_fixed_string_t ptype;
17572 cmdline_fixed_string_t mapping;
17573 cmdline_fixed_string_t reset;
17579 /* Common CLI fields for ptype mapping update*/
17580 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17581 TOKEN_STRING_INITIALIZER
17582 (struct cmd_ptype_mapping_update_result,
17584 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17585 TOKEN_STRING_INITIALIZER
17586 (struct cmd_ptype_mapping_update_result,
17587 mapping, "mapping");
17588 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17589 TOKEN_STRING_INITIALIZER
17590 (struct cmd_ptype_mapping_update_result,
17592 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17593 TOKEN_NUM_INITIALIZER
17594 (struct cmd_ptype_mapping_update_result,
17596 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17597 TOKEN_NUM_INITIALIZER
17598 (struct cmd_ptype_mapping_update_result,
17600 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17601 TOKEN_NUM_INITIALIZER
17602 (struct cmd_ptype_mapping_update_result,
17606 cmd_ptype_mapping_update_parsed(
17607 void *parsed_result,
17608 __attribute__((unused)) struct cmdline *cl,
17609 __attribute__((unused)) void *data)
17611 struct cmd_ptype_mapping_update_result *res = parsed_result;
17612 int ret = -ENOTSUP;
17613 #ifdef RTE_LIBRTE_I40E_PMD
17614 struct rte_pmd_i40e_ptype_mapping mapping;
17616 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17619 #ifdef RTE_LIBRTE_I40E_PMD
17620 mapping.hw_ptype = res->hw_ptype;
17621 mapping.sw_ptype = res->sw_ptype;
17622 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17632 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17635 printf("invalid port_id %d\n", res->port_id);
17638 printf("function not implemented\n");
17641 printf("programming error: (%s)\n", strerror(-ret));
17645 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17646 .f = cmd_ptype_mapping_update_parsed,
17648 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17650 (void *)&cmd_ptype_mapping_update_ptype,
17651 (void *)&cmd_ptype_mapping_update_mapping,
17652 (void *)&cmd_ptype_mapping_update_update,
17653 (void *)&cmd_ptype_mapping_update_port_id,
17654 (void *)&cmd_ptype_mapping_update_hw_ptype,
17655 (void *)&cmd_ptype_mapping_update_sw_ptype,
17660 /* Common result structure for file commands */
17661 struct cmd_cmdfile_result {
17662 cmdline_fixed_string_t load;
17663 cmdline_fixed_string_t filename;
17666 /* Common CLI fields for file commands */
17667 cmdline_parse_token_string_t cmd_load_cmdfile =
17668 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17669 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17670 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17673 cmd_load_from_file_parsed(
17674 void *parsed_result,
17675 __attribute__((unused)) struct cmdline *cl,
17676 __attribute__((unused)) void *data)
17678 struct cmd_cmdfile_result *res = parsed_result;
17680 cmdline_read_from_file(res->filename);
17683 cmdline_parse_inst_t cmd_load_from_file = {
17684 .f = cmd_load_from_file_parsed,
17686 .help_str = "load <filename>",
17688 (void *)&cmd_load_cmdfile,
17689 (void *)&cmd_load_cmdfile_filename,
17694 /* Get Rx offloads capabilities */
17695 struct cmd_rx_offload_get_capa_result {
17696 cmdline_fixed_string_t show;
17697 cmdline_fixed_string_t port;
17699 cmdline_fixed_string_t rx_offload;
17700 cmdline_fixed_string_t capabilities;
17703 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17704 TOKEN_STRING_INITIALIZER
17705 (struct cmd_rx_offload_get_capa_result,
17707 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17708 TOKEN_STRING_INITIALIZER
17709 (struct cmd_rx_offload_get_capa_result,
17711 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17712 TOKEN_NUM_INITIALIZER
17713 (struct cmd_rx_offload_get_capa_result,
17715 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17716 TOKEN_STRING_INITIALIZER
17717 (struct cmd_rx_offload_get_capa_result,
17718 rx_offload, "rx_offload");
17719 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17720 TOKEN_STRING_INITIALIZER
17721 (struct cmd_rx_offload_get_capa_result,
17722 capabilities, "capabilities");
17725 print_rx_offloads(uint64_t offloads)
17727 uint64_t single_offload;
17735 begin = __builtin_ctzll(offloads);
17736 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17738 single_offload = 1 << begin;
17739 for (bit = begin; bit < end; bit++) {
17740 if (offloads & single_offload)
17742 rte_eth_dev_rx_offload_name(single_offload));
17743 single_offload <<= 1;
17748 cmd_rx_offload_get_capa_parsed(
17749 void *parsed_result,
17750 __attribute__((unused)) struct cmdline *cl,
17751 __attribute__((unused)) void *data)
17753 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17754 struct rte_eth_dev_info dev_info;
17755 portid_t port_id = res->port_id;
17756 uint64_t queue_offloads;
17757 uint64_t port_offloads;
17759 rte_eth_dev_info_get(port_id, &dev_info);
17760 queue_offloads = dev_info.rx_queue_offload_capa;
17761 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17763 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17764 printf(" Per Queue :");
17765 print_rx_offloads(queue_offloads);
17768 printf(" Per Port :");
17769 print_rx_offloads(port_offloads);
17773 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17774 .f = cmd_rx_offload_get_capa_parsed,
17776 .help_str = "show port <port_id> rx_offload capabilities",
17778 (void *)&cmd_rx_offload_get_capa_show,
17779 (void *)&cmd_rx_offload_get_capa_port,
17780 (void *)&cmd_rx_offload_get_capa_port_id,
17781 (void *)&cmd_rx_offload_get_capa_rx_offload,
17782 (void *)&cmd_rx_offload_get_capa_capabilities,
17787 /* Get Rx offloads configuration */
17788 struct cmd_rx_offload_get_configuration_result {
17789 cmdline_fixed_string_t show;
17790 cmdline_fixed_string_t port;
17792 cmdline_fixed_string_t rx_offload;
17793 cmdline_fixed_string_t configuration;
17796 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17797 TOKEN_STRING_INITIALIZER
17798 (struct cmd_rx_offload_get_configuration_result,
17800 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17801 TOKEN_STRING_INITIALIZER
17802 (struct cmd_rx_offload_get_configuration_result,
17804 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17805 TOKEN_NUM_INITIALIZER
17806 (struct cmd_rx_offload_get_configuration_result,
17808 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17809 TOKEN_STRING_INITIALIZER
17810 (struct cmd_rx_offload_get_configuration_result,
17811 rx_offload, "rx_offload");
17812 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17813 TOKEN_STRING_INITIALIZER
17814 (struct cmd_rx_offload_get_configuration_result,
17815 configuration, "configuration");
17818 cmd_rx_offload_get_configuration_parsed(
17819 void *parsed_result,
17820 __attribute__((unused)) struct cmdline *cl,
17821 __attribute__((unused)) void *data)
17823 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17824 struct rte_eth_dev_info dev_info;
17825 portid_t port_id = res->port_id;
17826 struct rte_port *port = &ports[port_id];
17827 uint64_t port_offloads;
17828 uint64_t queue_offloads;
17829 uint16_t nb_rx_queues;
17832 printf("Rx Offloading Configuration of port %d :\n", port_id);
17834 port_offloads = port->dev_conf.rxmode.offloads;
17836 print_rx_offloads(port_offloads);
17839 rte_eth_dev_info_get(port_id, &dev_info);
17840 nb_rx_queues = dev_info.nb_rx_queues;
17841 for (q = 0; q < nb_rx_queues; q++) {
17842 queue_offloads = port->rx_conf[q].offloads;
17843 printf(" Queue[%2d] :", q);
17844 print_rx_offloads(queue_offloads);
17850 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17851 .f = cmd_rx_offload_get_configuration_parsed,
17853 .help_str = "show port <port_id> rx_offload configuration",
17855 (void *)&cmd_rx_offload_get_configuration_show,
17856 (void *)&cmd_rx_offload_get_configuration_port,
17857 (void *)&cmd_rx_offload_get_configuration_port_id,
17858 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17859 (void *)&cmd_rx_offload_get_configuration_configuration,
17864 /* Enable/Disable a per port offloading */
17865 struct cmd_config_per_port_rx_offload_result {
17866 cmdline_fixed_string_t port;
17867 cmdline_fixed_string_t config;
17869 cmdline_fixed_string_t rx_offload;
17870 cmdline_fixed_string_t offload;
17871 cmdline_fixed_string_t on_off;
17874 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17875 TOKEN_STRING_INITIALIZER
17876 (struct cmd_config_per_port_rx_offload_result,
17878 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17879 TOKEN_STRING_INITIALIZER
17880 (struct cmd_config_per_port_rx_offload_result,
17882 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17883 TOKEN_NUM_INITIALIZER
17884 (struct cmd_config_per_port_rx_offload_result,
17886 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17887 TOKEN_STRING_INITIALIZER
17888 (struct cmd_config_per_port_rx_offload_result,
17889 rx_offload, "rx_offload");
17890 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17891 TOKEN_STRING_INITIALIZER
17892 (struct cmd_config_per_port_rx_offload_result,
17893 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17894 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17895 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17896 "crc_strip#scatter#timestamp#security#keep_crc");
17897 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17898 TOKEN_STRING_INITIALIZER
17899 (struct cmd_config_per_port_rx_offload_result,
17903 search_rx_offload(const char *name)
17905 uint64_t single_offload;
17906 const char *single_name;
17910 single_offload = 1;
17911 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17912 single_name = rte_eth_dev_rx_offload_name(single_offload);
17913 if (!strcasecmp(single_name, name)) {
17917 single_offload <<= 1;
17921 return single_offload;
17927 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17928 __attribute__((unused)) struct cmdline *cl,
17929 __attribute__((unused)) void *data)
17931 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17932 portid_t port_id = res->port_id;
17933 struct rte_eth_dev_info dev_info;
17934 struct rte_port *port = &ports[port_id];
17935 uint64_t single_offload;
17936 uint16_t nb_rx_queues;
17939 if (port->port_status != RTE_PORT_STOPPED) {
17940 printf("Error: Can't config offload when Port %d "
17941 "is not stopped\n", port_id);
17945 single_offload = search_rx_offload(res->offload);
17946 if (single_offload == 0) {
17947 printf("Unknown offload name: %s\n", res->offload);
17951 rte_eth_dev_info_get(port_id, &dev_info);
17952 nb_rx_queues = dev_info.nb_rx_queues;
17953 if (!strcmp(res->on_off, "on")) {
17954 port->dev_conf.rxmode.offloads |= single_offload;
17955 for (q = 0; q < nb_rx_queues; q++)
17956 port->rx_conf[q].offloads |= single_offload;
17958 port->dev_conf.rxmode.offloads &= ~single_offload;
17959 for (q = 0; q < nb_rx_queues; q++)
17960 port->rx_conf[q].offloads &= ~single_offload;
17963 cmd_reconfig_device_queue(port_id, 1, 1);
17966 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17967 .f = cmd_config_per_port_rx_offload_parsed,
17969 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17970 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17971 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17972 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17975 (void *)&cmd_config_per_port_rx_offload_result_port,
17976 (void *)&cmd_config_per_port_rx_offload_result_config,
17977 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17978 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17979 (void *)&cmd_config_per_port_rx_offload_result_offload,
17980 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17985 /* Enable/Disable a per queue offloading */
17986 struct cmd_config_per_queue_rx_offload_result {
17987 cmdline_fixed_string_t port;
17989 cmdline_fixed_string_t rxq;
17991 cmdline_fixed_string_t rx_offload;
17992 cmdline_fixed_string_t offload;
17993 cmdline_fixed_string_t on_off;
17996 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17997 TOKEN_STRING_INITIALIZER
17998 (struct cmd_config_per_queue_rx_offload_result,
18000 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18001 TOKEN_NUM_INITIALIZER
18002 (struct cmd_config_per_queue_rx_offload_result,
18004 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18005 TOKEN_STRING_INITIALIZER
18006 (struct cmd_config_per_queue_rx_offload_result,
18008 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18009 TOKEN_NUM_INITIALIZER
18010 (struct cmd_config_per_queue_rx_offload_result,
18012 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18013 TOKEN_STRING_INITIALIZER
18014 (struct cmd_config_per_queue_rx_offload_result,
18015 rx_offload, "rx_offload");
18016 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18017 TOKEN_STRING_INITIALIZER
18018 (struct cmd_config_per_queue_rx_offload_result,
18019 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18020 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18021 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18022 "crc_strip#scatter#timestamp#security#keep_crc");
18023 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18024 TOKEN_STRING_INITIALIZER
18025 (struct cmd_config_per_queue_rx_offload_result,
18029 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18030 __attribute__((unused)) struct cmdline *cl,
18031 __attribute__((unused)) void *data)
18033 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18034 struct rte_eth_dev_info dev_info;
18035 portid_t port_id = res->port_id;
18036 uint16_t queue_id = res->queue_id;
18037 struct rte_port *port = &ports[port_id];
18038 uint64_t single_offload;
18040 if (port->port_status != RTE_PORT_STOPPED) {
18041 printf("Error: Can't config offload when Port %d "
18042 "is not stopped\n", port_id);
18046 rte_eth_dev_info_get(port_id, &dev_info);
18047 if (queue_id >= dev_info.nb_rx_queues) {
18048 printf("Error: input queue_id should be 0 ... "
18049 "%d\n", dev_info.nb_rx_queues - 1);
18053 single_offload = search_rx_offload(res->offload);
18054 if (single_offload == 0) {
18055 printf("Unknown offload name: %s\n", res->offload);
18059 if (!strcmp(res->on_off, "on"))
18060 port->rx_conf[queue_id].offloads |= single_offload;
18062 port->rx_conf[queue_id].offloads &= ~single_offload;
18064 cmd_reconfig_device_queue(port_id, 1, 1);
18067 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18068 .f = cmd_config_per_queue_rx_offload_parsed,
18070 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18071 "vlan_strip|ipv4_cksum|"
18072 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18073 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18074 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18077 (void *)&cmd_config_per_queue_rx_offload_result_port,
18078 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18079 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18080 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18081 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18082 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18083 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18088 /* Get Tx offloads capabilities */
18089 struct cmd_tx_offload_get_capa_result {
18090 cmdline_fixed_string_t show;
18091 cmdline_fixed_string_t port;
18093 cmdline_fixed_string_t tx_offload;
18094 cmdline_fixed_string_t capabilities;
18097 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18098 TOKEN_STRING_INITIALIZER
18099 (struct cmd_tx_offload_get_capa_result,
18101 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18102 TOKEN_STRING_INITIALIZER
18103 (struct cmd_tx_offload_get_capa_result,
18105 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18106 TOKEN_NUM_INITIALIZER
18107 (struct cmd_tx_offload_get_capa_result,
18109 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18110 TOKEN_STRING_INITIALIZER
18111 (struct cmd_tx_offload_get_capa_result,
18112 tx_offload, "tx_offload");
18113 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18114 TOKEN_STRING_INITIALIZER
18115 (struct cmd_tx_offload_get_capa_result,
18116 capabilities, "capabilities");
18119 print_tx_offloads(uint64_t offloads)
18121 uint64_t single_offload;
18129 begin = __builtin_ctzll(offloads);
18130 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18132 single_offload = 1 << begin;
18133 for (bit = begin; bit < end; bit++) {
18134 if (offloads & single_offload)
18136 rte_eth_dev_tx_offload_name(single_offload));
18137 single_offload <<= 1;
18142 cmd_tx_offload_get_capa_parsed(
18143 void *parsed_result,
18144 __attribute__((unused)) struct cmdline *cl,
18145 __attribute__((unused)) void *data)
18147 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18148 struct rte_eth_dev_info dev_info;
18149 portid_t port_id = res->port_id;
18150 uint64_t queue_offloads;
18151 uint64_t port_offloads;
18153 rte_eth_dev_info_get(port_id, &dev_info);
18154 queue_offloads = dev_info.tx_queue_offload_capa;
18155 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18157 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18158 printf(" Per Queue :");
18159 print_tx_offloads(queue_offloads);
18162 printf(" Per Port :");
18163 print_tx_offloads(port_offloads);
18167 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18168 .f = cmd_tx_offload_get_capa_parsed,
18170 .help_str = "show port <port_id> tx_offload capabilities",
18172 (void *)&cmd_tx_offload_get_capa_show,
18173 (void *)&cmd_tx_offload_get_capa_port,
18174 (void *)&cmd_tx_offload_get_capa_port_id,
18175 (void *)&cmd_tx_offload_get_capa_tx_offload,
18176 (void *)&cmd_tx_offload_get_capa_capabilities,
18181 /* Get Tx offloads configuration */
18182 struct cmd_tx_offload_get_configuration_result {
18183 cmdline_fixed_string_t show;
18184 cmdline_fixed_string_t port;
18186 cmdline_fixed_string_t tx_offload;
18187 cmdline_fixed_string_t configuration;
18190 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18191 TOKEN_STRING_INITIALIZER
18192 (struct cmd_tx_offload_get_configuration_result,
18194 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18195 TOKEN_STRING_INITIALIZER
18196 (struct cmd_tx_offload_get_configuration_result,
18198 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18199 TOKEN_NUM_INITIALIZER
18200 (struct cmd_tx_offload_get_configuration_result,
18202 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18203 TOKEN_STRING_INITIALIZER
18204 (struct cmd_tx_offload_get_configuration_result,
18205 tx_offload, "tx_offload");
18206 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18207 TOKEN_STRING_INITIALIZER
18208 (struct cmd_tx_offload_get_configuration_result,
18209 configuration, "configuration");
18212 cmd_tx_offload_get_configuration_parsed(
18213 void *parsed_result,
18214 __attribute__((unused)) struct cmdline *cl,
18215 __attribute__((unused)) void *data)
18217 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18218 struct rte_eth_dev_info dev_info;
18219 portid_t port_id = res->port_id;
18220 struct rte_port *port = &ports[port_id];
18221 uint64_t port_offloads;
18222 uint64_t queue_offloads;
18223 uint16_t nb_tx_queues;
18226 printf("Tx Offloading Configuration of port %d :\n", port_id);
18228 port_offloads = port->dev_conf.txmode.offloads;
18230 print_tx_offloads(port_offloads);
18233 rte_eth_dev_info_get(port_id, &dev_info);
18234 nb_tx_queues = dev_info.nb_tx_queues;
18235 for (q = 0; q < nb_tx_queues; q++) {
18236 queue_offloads = port->tx_conf[q].offloads;
18237 printf(" Queue[%2d] :", q);
18238 print_tx_offloads(queue_offloads);
18244 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18245 .f = cmd_tx_offload_get_configuration_parsed,
18247 .help_str = "show port <port_id> tx_offload configuration",
18249 (void *)&cmd_tx_offload_get_configuration_show,
18250 (void *)&cmd_tx_offload_get_configuration_port,
18251 (void *)&cmd_tx_offload_get_configuration_port_id,
18252 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18253 (void *)&cmd_tx_offload_get_configuration_configuration,
18258 /* Enable/Disable a per port offloading */
18259 struct cmd_config_per_port_tx_offload_result {
18260 cmdline_fixed_string_t port;
18261 cmdline_fixed_string_t config;
18263 cmdline_fixed_string_t tx_offload;
18264 cmdline_fixed_string_t offload;
18265 cmdline_fixed_string_t on_off;
18268 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18269 TOKEN_STRING_INITIALIZER
18270 (struct cmd_config_per_port_tx_offload_result,
18272 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18273 TOKEN_STRING_INITIALIZER
18274 (struct cmd_config_per_port_tx_offload_result,
18276 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18277 TOKEN_NUM_INITIALIZER
18278 (struct cmd_config_per_port_tx_offload_result,
18280 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18281 TOKEN_STRING_INITIALIZER
18282 (struct cmd_config_per_port_tx_offload_result,
18283 tx_offload, "tx_offload");
18284 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18285 TOKEN_STRING_INITIALIZER
18286 (struct cmd_config_per_port_tx_offload_result,
18287 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18288 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18289 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18290 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18291 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18293 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18294 TOKEN_STRING_INITIALIZER
18295 (struct cmd_config_per_port_tx_offload_result,
18299 search_tx_offload(const char *name)
18301 uint64_t single_offload;
18302 const char *single_name;
18306 single_offload = 1;
18307 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18308 single_name = rte_eth_dev_tx_offload_name(single_offload);
18309 if (!strcasecmp(single_name, name)) {
18312 } else if (!strcasecmp(single_name, "UNKNOWN"))
18314 else if (single_name == NULL)
18316 single_offload <<= 1;
18320 return single_offload;
18326 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18327 __attribute__((unused)) struct cmdline *cl,
18328 __attribute__((unused)) void *data)
18330 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18331 portid_t port_id = res->port_id;
18332 struct rte_eth_dev_info dev_info;
18333 struct rte_port *port = &ports[port_id];
18334 uint64_t single_offload;
18335 uint16_t nb_tx_queues;
18338 if (port->port_status != RTE_PORT_STOPPED) {
18339 printf("Error: Can't config offload when Port %d "
18340 "is not stopped\n", port_id);
18344 single_offload = search_tx_offload(res->offload);
18345 if (single_offload == 0) {
18346 printf("Unknown offload name: %s\n", res->offload);
18350 rte_eth_dev_info_get(port_id, &dev_info);
18351 nb_tx_queues = dev_info.nb_tx_queues;
18352 if (!strcmp(res->on_off, "on")) {
18353 port->dev_conf.txmode.offloads |= single_offload;
18354 for (q = 0; q < nb_tx_queues; q++)
18355 port->tx_conf[q].offloads |= single_offload;
18357 port->dev_conf.txmode.offloads &= ~single_offload;
18358 for (q = 0; q < nb_tx_queues; q++)
18359 port->tx_conf[q].offloads &= ~single_offload;
18362 cmd_reconfig_device_queue(port_id, 1, 1);
18365 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18366 .f = cmd_config_per_port_tx_offload_parsed,
18368 .help_str = "port config <port_id> tx_offload "
18369 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18370 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18371 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18372 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18373 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18374 "match_metadata on|off",
18376 (void *)&cmd_config_per_port_tx_offload_result_port,
18377 (void *)&cmd_config_per_port_tx_offload_result_config,
18378 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18379 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18380 (void *)&cmd_config_per_port_tx_offload_result_offload,
18381 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18386 /* Enable/Disable a per queue offloading */
18387 struct cmd_config_per_queue_tx_offload_result {
18388 cmdline_fixed_string_t port;
18390 cmdline_fixed_string_t txq;
18392 cmdline_fixed_string_t tx_offload;
18393 cmdline_fixed_string_t offload;
18394 cmdline_fixed_string_t on_off;
18397 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18398 TOKEN_STRING_INITIALIZER
18399 (struct cmd_config_per_queue_tx_offload_result,
18401 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18402 TOKEN_NUM_INITIALIZER
18403 (struct cmd_config_per_queue_tx_offload_result,
18405 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18406 TOKEN_STRING_INITIALIZER
18407 (struct cmd_config_per_queue_tx_offload_result,
18409 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18410 TOKEN_NUM_INITIALIZER
18411 (struct cmd_config_per_queue_tx_offload_result,
18413 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18414 TOKEN_STRING_INITIALIZER
18415 (struct cmd_config_per_queue_tx_offload_result,
18416 tx_offload, "tx_offload");
18417 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18418 TOKEN_STRING_INITIALIZER
18419 (struct cmd_config_per_queue_tx_offload_result,
18420 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18421 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18422 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18423 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18424 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18425 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18426 TOKEN_STRING_INITIALIZER
18427 (struct cmd_config_per_queue_tx_offload_result,
18431 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18432 __attribute__((unused)) struct cmdline *cl,
18433 __attribute__((unused)) void *data)
18435 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18436 struct rte_eth_dev_info dev_info;
18437 portid_t port_id = res->port_id;
18438 uint16_t queue_id = res->queue_id;
18439 struct rte_port *port = &ports[port_id];
18440 uint64_t single_offload;
18442 if (port->port_status != RTE_PORT_STOPPED) {
18443 printf("Error: Can't config offload when Port %d "
18444 "is not stopped\n", port_id);
18448 rte_eth_dev_info_get(port_id, &dev_info);
18449 if (queue_id >= dev_info.nb_tx_queues) {
18450 printf("Error: input queue_id should be 0 ... "
18451 "%d\n", dev_info.nb_tx_queues - 1);
18455 single_offload = search_tx_offload(res->offload);
18456 if (single_offload == 0) {
18457 printf("Unknown offload name: %s\n", res->offload);
18461 if (!strcmp(res->on_off, "on"))
18462 port->tx_conf[queue_id].offloads |= single_offload;
18464 port->tx_conf[queue_id].offloads &= ~single_offload;
18466 cmd_reconfig_device_queue(port_id, 1, 1);
18469 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18470 .f = cmd_config_per_queue_tx_offload_parsed,
18472 .help_str = "port <port_id> txq <queue_id> tx_offload "
18473 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18474 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18475 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18476 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18477 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18480 (void *)&cmd_config_per_queue_tx_offload_result_port,
18481 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18482 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18483 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18484 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18485 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18486 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18491 /* *** configure tx_metadata for specific port *** */
18492 struct cmd_config_tx_metadata_specific_result {
18493 cmdline_fixed_string_t port;
18494 cmdline_fixed_string_t keyword;
18496 cmdline_fixed_string_t item;
18501 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18502 __attribute__((unused)) struct cmdline *cl,
18503 __attribute__((unused)) void *data)
18505 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18507 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18509 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18510 /* Add/remove callback to insert valid metadata in every Tx packet. */
18511 if (ports[res->port_id].tx_metadata)
18512 add_tx_md_callback(res->port_id);
18514 remove_tx_md_callback(res->port_id);
18517 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18518 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18520 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18521 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18522 keyword, "config");
18523 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18524 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18526 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18527 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18528 item, "tx_metadata");
18529 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18530 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18533 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18534 .f = cmd_config_tx_metadata_specific_parsed,
18536 .help_str = "port config <port_id> tx_metadata <value>",
18538 (void *)&cmd_config_tx_metadata_specific_port,
18539 (void *)&cmd_config_tx_metadata_specific_keyword,
18540 (void *)&cmd_config_tx_metadata_specific_id,
18541 (void *)&cmd_config_tx_metadata_specific_item,
18542 (void *)&cmd_config_tx_metadata_specific_value,
18547 /* *** display tx_metadata per port configuration *** */
18548 struct cmd_show_tx_metadata_result {
18549 cmdline_fixed_string_t cmd_show;
18550 cmdline_fixed_string_t cmd_port;
18551 cmdline_fixed_string_t cmd_keyword;
18556 cmd_show_tx_metadata_parsed(void *parsed_result,
18557 __attribute__((unused)) struct cmdline *cl,
18558 __attribute__((unused)) void *data)
18560 struct cmd_show_tx_metadata_result *res = parsed_result;
18562 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18563 printf("invalid port id %u\n", res->cmd_pid);
18566 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18567 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18568 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18572 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18573 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18575 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18576 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18578 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18579 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18581 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18582 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18583 cmd_keyword, "tx_metadata");
18585 cmdline_parse_inst_t cmd_show_tx_metadata = {
18586 .f = cmd_show_tx_metadata_parsed,
18588 .help_str = "show port <port_id> tx_metadata",
18590 (void *)&cmd_show_tx_metadata_show,
18591 (void *)&cmd_show_tx_metadata_port,
18592 (void *)&cmd_show_tx_metadata_pid,
18593 (void *)&cmd_show_tx_metadata_keyword,
18598 /* ******************************************************************************** */
18600 /* list of instructions */
18601 cmdline_parse_ctx_t main_ctx[] = {
18602 (cmdline_parse_inst_t *)&cmd_help_brief,
18603 (cmdline_parse_inst_t *)&cmd_help_long,
18604 (cmdline_parse_inst_t *)&cmd_quit,
18605 (cmdline_parse_inst_t *)&cmd_load_from_file,
18606 (cmdline_parse_inst_t *)&cmd_showport,
18607 (cmdline_parse_inst_t *)&cmd_showqueue,
18608 (cmdline_parse_inst_t *)&cmd_showportall,
18609 (cmdline_parse_inst_t *)&cmd_showcfg,
18610 (cmdline_parse_inst_t *)&cmd_showfwdall,
18611 (cmdline_parse_inst_t *)&cmd_start,
18612 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18613 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18614 (cmdline_parse_inst_t *)&cmd_set_link_up,
18615 (cmdline_parse_inst_t *)&cmd_set_link_down,
18616 (cmdline_parse_inst_t *)&cmd_reset,
18617 (cmdline_parse_inst_t *)&cmd_set_numbers,
18618 (cmdline_parse_inst_t *)&cmd_set_log,
18619 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18620 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18621 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18622 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18623 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18624 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18625 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18626 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18627 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18628 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18629 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18630 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18631 (cmdline_parse_inst_t *)&cmd_set_link_check,
18632 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18633 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18634 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18635 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18636 #ifdef RTE_LIBRTE_PMD_BOND
18637 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18638 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18639 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18640 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18641 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18642 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18643 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18644 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18645 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18646 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18647 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18649 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18650 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18651 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18652 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18653 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18654 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18655 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18656 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18657 (cmdline_parse_inst_t *)&cmd_csum_set,
18658 (cmdline_parse_inst_t *)&cmd_csum_show,
18659 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18660 (cmdline_parse_inst_t *)&cmd_tso_set,
18661 (cmdline_parse_inst_t *)&cmd_tso_show,
18662 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18663 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18664 (cmdline_parse_inst_t *)&cmd_gro_enable,
18665 (cmdline_parse_inst_t *)&cmd_gro_flush,
18666 (cmdline_parse_inst_t *)&cmd_gro_show,
18667 (cmdline_parse_inst_t *)&cmd_gso_enable,
18668 (cmdline_parse_inst_t *)&cmd_gso_size,
18669 (cmdline_parse_inst_t *)&cmd_gso_show,
18670 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18671 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18672 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18673 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18674 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18675 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18676 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18677 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18678 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18679 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18680 (cmdline_parse_inst_t *)&cmd_config_dcb,
18681 (cmdline_parse_inst_t *)&cmd_read_reg,
18682 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18683 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18684 (cmdline_parse_inst_t *)&cmd_write_reg,
18685 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18686 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18687 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18688 (cmdline_parse_inst_t *)&cmd_stop,
18689 (cmdline_parse_inst_t *)&cmd_mac_addr,
18690 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18691 (cmdline_parse_inst_t *)&cmd_set_qmap,
18692 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18693 (cmdline_parse_inst_t *)&cmd_operate_port,
18694 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18695 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18696 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18697 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18698 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18699 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18700 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18701 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18702 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18703 (cmdline_parse_inst_t *)&cmd_config_mtu,
18704 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18705 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18706 (cmdline_parse_inst_t *)&cmd_config_rss,
18707 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18708 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18709 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18710 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18711 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18712 (cmdline_parse_inst_t *)&cmd_showport_reta,
18713 (cmdline_parse_inst_t *)&cmd_config_burst,
18714 (cmdline_parse_inst_t *)&cmd_config_thresh,
18715 (cmdline_parse_inst_t *)&cmd_config_threshold,
18716 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18717 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18718 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18719 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18720 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18721 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18722 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18723 (cmdline_parse_inst_t *)&cmd_global_config,
18724 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18725 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18726 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18727 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18728 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18729 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18730 (cmdline_parse_inst_t *)&cmd_dump,
18731 (cmdline_parse_inst_t *)&cmd_dump_one,
18732 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18733 (cmdline_parse_inst_t *)&cmd_syn_filter,
18734 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18735 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18736 (cmdline_parse_inst_t *)&cmd_flex_filter,
18737 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18738 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18739 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18740 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18741 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18742 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18743 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18744 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18745 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18746 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18747 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18748 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18749 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18750 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18751 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18752 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18753 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18754 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18755 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18756 (cmdline_parse_inst_t *)&cmd_flow,
18757 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18758 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18759 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18760 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18761 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18762 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18763 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18764 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18765 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18766 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18767 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18768 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18769 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18770 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18771 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18772 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18773 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18774 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18775 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18776 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18777 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18778 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18779 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18780 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18781 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18782 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18783 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18784 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18785 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18786 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18787 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18788 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18789 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18790 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18791 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18792 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18793 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18794 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18795 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18796 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18797 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18798 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18799 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18800 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18801 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18802 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18803 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18804 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18805 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18806 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18807 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18809 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18810 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18811 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18812 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18813 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18814 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18815 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18816 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18817 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18818 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18819 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18820 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18821 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18822 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18823 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18824 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18825 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18826 (cmdline_parse_inst_t *)&cmd_ddp_add,
18827 (cmdline_parse_inst_t *)&cmd_ddp_del,
18828 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18829 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18830 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18831 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18832 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18833 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18834 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18835 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18836 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18837 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18839 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18840 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18841 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18842 (cmdline_parse_inst_t *)&cmd_queue_region,
18843 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18844 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18845 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18846 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18847 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18848 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18849 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18850 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18851 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18852 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18853 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18854 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18855 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18856 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18857 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18858 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18859 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18860 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18861 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18862 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18863 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18864 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18865 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18866 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18867 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18868 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18869 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18870 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18871 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18872 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18873 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18874 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18875 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18876 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18877 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18878 #ifdef RTE_LIBRTE_BPF
18879 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18880 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18882 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18883 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18887 /* read cmdline commands from file */
18889 cmdline_read_from_file(const char *filename)
18891 struct cmdline *cl;
18893 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18895 printf("Failed to create file based cmdline context: %s\n",
18900 cmdline_interact(cl);
18905 printf("Read CLI commands from %s\n", filename);
18908 /* prompt function, called from main on MASTER lcore */
18912 /* initialize non-constant commands */
18913 cmd_set_fwd_mode_init();
18914 cmd_set_fwd_retry_mode_init();
18916 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18917 if (testpmd_cl == NULL)
18919 cmdline_interact(testpmd_cl);
18920 cmdline_stdin_exit(testpmd_cl);
18926 if (testpmd_cl != NULL)
18927 cmdline_quit(testpmd_cl);
18931 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18933 if (id == (portid_t)RTE_PORT_ALL) {
18936 RTE_ETH_FOREACH_DEV(pid) {
18937 /* check if need_reconfig has been set to 1 */
18938 if (ports[pid].need_reconfig == 0)
18939 ports[pid].need_reconfig = dev;
18940 /* check if need_reconfig_queues has been set to 1 */
18941 if (ports[pid].need_reconfig_queues == 0)
18942 ports[pid].need_reconfig_queues = queue;
18944 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18945 /* check if need_reconfig has been set to 1 */
18946 if (ports[id].need_reconfig == 0)
18947 ports[id].need_reconfig = dev;
18948 /* check if need_reconfig_queues has been set to 1 */
18949 if (ports[id].need_reconfig_queues == 0)
18950 ports[id].need_reconfig_queues = queue;