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|vxlan-gpe) (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|vxlan-gpe) (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|vxlan-gpe|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 | ETH_LINK_SPEED_FIXED;
1444 } else if (!strcmp(speedstr, "10000")) {
1445 *speed = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_FIXED;
1446 } else if (!strcmp(speedstr, "25000")) {
1447 *speed = ETH_LINK_SPEED_25G | ETH_LINK_SPEED_FIXED;
1448 } else if (!strcmp(speedstr, "40000")) {
1449 *speed = ETH_LINK_SPEED_40G | ETH_LINK_SPEED_FIXED;
1450 } else if (!strcmp(speedstr, "50000")) {
1451 *speed = ETH_LINK_SPEED_50G | ETH_LINK_SPEED_FIXED;
1452 } else if (!strcmp(speedstr, "100000")) {
1453 *speed = ETH_LINK_SPEED_100G | ETH_LINK_SPEED_FIXED;
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|vxlan-gpe|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, "vxlan-gpe"))
8762 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8763 else if (!strcmp(res->tunnel_type, "nvgre"))
8764 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8765 else if (!strcmp(res->tunnel_type, "ipingre"))
8766 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8768 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8772 tunnel_filter_conf.tenant_id = res->tenant_id;
8773 tunnel_filter_conf.queue_id = res->queue_num;
8774 if (!strcmp(res->what, "add"))
8775 ret = rte_eth_dev_filter_ctrl(res->port_id,
8776 RTE_ETH_FILTER_TUNNEL,
8778 &tunnel_filter_conf);
8780 ret = rte_eth_dev_filter_ctrl(res->port_id,
8781 RTE_ETH_FILTER_TUNNEL,
8782 RTE_ETH_FILTER_DELETE,
8783 &tunnel_filter_conf);
8785 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8789 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8790 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8791 cmd, "tunnel_filter");
8792 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8793 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8795 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8796 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8798 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8799 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8801 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8802 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8804 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8805 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8806 inner_vlan, UINT16);
8807 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8808 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8810 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8811 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8812 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8814 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8815 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8816 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8817 "imac#omac-imac-tenid");
8818 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8819 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8821 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8822 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8825 cmdline_parse_inst_t cmd_tunnel_filter = {
8826 .f = cmd_tunnel_filter_parsed,
8828 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8829 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8830 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8831 "<queue_id>: Add/Rm tunnel filter of a port",
8833 (void *)&cmd_tunnel_filter_cmd,
8834 (void *)&cmd_tunnel_filter_what,
8835 (void *)&cmd_tunnel_filter_port_id,
8836 (void *)&cmd_tunnel_filter_outer_mac,
8837 (void *)&cmd_tunnel_filter_inner_mac,
8838 (void *)&cmd_tunnel_filter_ip_value,
8839 (void *)&cmd_tunnel_filter_innner_vlan,
8840 (void *)&cmd_tunnel_filter_tunnel_type,
8841 (void *)&cmd_tunnel_filter_filter_type,
8842 (void *)&cmd_tunnel_filter_tenant_id,
8843 (void *)&cmd_tunnel_filter_queue_num,
8848 /* *** CONFIGURE TUNNEL UDP PORT *** */
8849 struct cmd_tunnel_udp_config {
8850 cmdline_fixed_string_t cmd;
8851 cmdline_fixed_string_t what;
8857 cmd_tunnel_udp_config_parsed(void *parsed_result,
8858 __attribute__((unused)) struct cmdline *cl,
8859 __attribute__((unused)) void *data)
8861 struct cmd_tunnel_udp_config *res = parsed_result;
8862 struct rte_eth_udp_tunnel tunnel_udp;
8865 tunnel_udp.udp_port = res->udp_port;
8867 if (!strcmp(res->cmd, "rx_vxlan_port"))
8868 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8870 if (!strcmp(res->what, "add"))
8871 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8874 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8878 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8881 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8882 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8883 cmd, "rx_vxlan_port");
8884 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8885 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8887 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8888 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8890 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8891 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8894 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8895 .f = cmd_tunnel_udp_config_parsed,
8897 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8898 "Add/Remove a tunneling UDP port filter",
8900 (void *)&cmd_tunnel_udp_config_cmd,
8901 (void *)&cmd_tunnel_udp_config_what,
8902 (void *)&cmd_tunnel_udp_config_udp_port,
8903 (void *)&cmd_tunnel_udp_config_port_id,
8908 struct cmd_config_tunnel_udp_port {
8909 cmdline_fixed_string_t port;
8910 cmdline_fixed_string_t config;
8912 cmdline_fixed_string_t udp_tunnel_port;
8913 cmdline_fixed_string_t action;
8914 cmdline_fixed_string_t tunnel_type;
8919 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8920 __attribute__((unused)) struct cmdline *cl,
8921 __attribute__((unused)) void *data)
8923 struct cmd_config_tunnel_udp_port *res = parsed_result;
8924 struct rte_eth_udp_tunnel tunnel_udp;
8927 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8930 tunnel_udp.udp_port = res->udp_port;
8932 if (!strcmp(res->tunnel_type, "vxlan")) {
8933 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8934 } else if (!strcmp(res->tunnel_type, "geneve")) {
8935 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8936 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
8937 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8939 printf("Invalid tunnel type\n");
8943 if (!strcmp(res->action, "add"))
8944 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8947 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8951 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8954 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8955 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8957 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8958 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8960 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8961 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8963 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8964 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8967 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8968 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8970 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8971 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8972 "vxlan#geneve#vxlan-gpe");
8973 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8974 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8977 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8978 .f = cmd_cfg_tunnel_udp_port_parsed,
8980 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
8982 (void *)&cmd_config_tunnel_udp_port_port,
8983 (void *)&cmd_config_tunnel_udp_port_config,
8984 (void *)&cmd_config_tunnel_udp_port_port_id,
8985 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8986 (void *)&cmd_config_tunnel_udp_port_action,
8987 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8988 (void *)&cmd_config_tunnel_udp_port_value,
8993 /* *** GLOBAL CONFIG *** */
8994 struct cmd_global_config_result {
8995 cmdline_fixed_string_t cmd;
8997 cmdline_fixed_string_t cfg_type;
9002 cmd_global_config_parsed(void *parsed_result,
9003 __attribute__((unused)) struct cmdline *cl,
9004 __attribute__((unused)) void *data)
9006 struct cmd_global_config_result *res = parsed_result;
9007 struct rte_eth_global_cfg conf;
9010 memset(&conf, 0, sizeof(conf));
9011 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9012 conf.cfg.gre_key_len = res->len;
9013 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9014 RTE_ETH_FILTER_SET, &conf);
9016 printf("Global config error\n");
9019 cmdline_parse_token_string_t cmd_global_config_cmd =
9020 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9022 cmdline_parse_token_num_t cmd_global_config_port_id =
9023 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9025 cmdline_parse_token_string_t cmd_global_config_type =
9026 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9027 cfg_type, "gre-key-len");
9028 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9029 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9032 cmdline_parse_inst_t cmd_global_config = {
9033 .f = cmd_global_config_parsed,
9034 .data = (void *)NULL,
9035 .help_str = "global_config <port_id> gre-key-len <key_len>",
9037 (void *)&cmd_global_config_cmd,
9038 (void *)&cmd_global_config_port_id,
9039 (void *)&cmd_global_config_type,
9040 (void *)&cmd_global_config_gre_key_len,
9045 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9046 struct cmd_set_mirror_mask_result {
9047 cmdline_fixed_string_t set;
9048 cmdline_fixed_string_t port;
9050 cmdline_fixed_string_t mirror;
9052 cmdline_fixed_string_t what;
9053 cmdline_fixed_string_t value;
9054 cmdline_fixed_string_t dstpool;
9056 cmdline_fixed_string_t on;
9059 cmdline_parse_token_string_t cmd_mirror_mask_set =
9060 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9062 cmdline_parse_token_string_t cmd_mirror_mask_port =
9063 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9065 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9066 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9068 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9069 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9070 mirror, "mirror-rule");
9071 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9072 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9074 cmdline_parse_token_string_t cmd_mirror_mask_what =
9075 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9076 what, "pool-mirror-up#pool-mirror-down"
9078 cmdline_parse_token_string_t cmd_mirror_mask_value =
9079 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9081 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9082 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9083 dstpool, "dst-pool");
9084 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9085 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9087 cmdline_parse_token_string_t cmd_mirror_mask_on =
9088 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9092 cmd_set_mirror_mask_parsed(void *parsed_result,
9093 __attribute__((unused)) struct cmdline *cl,
9094 __attribute__((unused)) void *data)
9097 struct cmd_set_mirror_mask_result *res = parsed_result;
9098 struct rte_eth_mirror_conf mr_conf;
9100 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9102 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9104 mr_conf.dst_pool = res->dstpool_id;
9106 if (!strcmp(res->what, "pool-mirror-up")) {
9107 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9108 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9109 } else if (!strcmp(res->what, "pool-mirror-down")) {
9110 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9111 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9112 } else if (!strcmp(res->what, "vlan-mirror")) {
9113 mr_conf.rule_type = ETH_MIRROR_VLAN;
9114 nb_item = parse_item_list(res->value, "vlan",
9115 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9119 for (i = 0; i < nb_item; i++) {
9120 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
9121 printf("Invalid vlan_id: must be < 4096\n");
9125 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9126 mr_conf.vlan.vlan_mask |= 1ULL << i;
9130 if (!strcmp(res->on, "on"))
9131 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9134 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9137 printf("mirror rule add error: (%s)\n", strerror(-ret));
9140 cmdline_parse_inst_t cmd_set_mirror_mask = {
9141 .f = cmd_set_mirror_mask_parsed,
9143 .help_str = "set port <port_id> mirror-rule <rule_id> "
9144 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9145 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9147 (void *)&cmd_mirror_mask_set,
9148 (void *)&cmd_mirror_mask_port,
9149 (void *)&cmd_mirror_mask_portid,
9150 (void *)&cmd_mirror_mask_mirror,
9151 (void *)&cmd_mirror_mask_ruleid,
9152 (void *)&cmd_mirror_mask_what,
9153 (void *)&cmd_mirror_mask_value,
9154 (void *)&cmd_mirror_mask_dstpool,
9155 (void *)&cmd_mirror_mask_poolid,
9156 (void *)&cmd_mirror_mask_on,
9161 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9162 struct cmd_set_mirror_link_result {
9163 cmdline_fixed_string_t set;
9164 cmdline_fixed_string_t port;
9166 cmdline_fixed_string_t mirror;
9168 cmdline_fixed_string_t what;
9169 cmdline_fixed_string_t dstpool;
9171 cmdline_fixed_string_t on;
9174 cmdline_parse_token_string_t cmd_mirror_link_set =
9175 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9177 cmdline_parse_token_string_t cmd_mirror_link_port =
9178 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9180 cmdline_parse_token_num_t cmd_mirror_link_portid =
9181 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9183 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9184 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9185 mirror, "mirror-rule");
9186 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9187 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9189 cmdline_parse_token_string_t cmd_mirror_link_what =
9190 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9191 what, "uplink-mirror#downlink-mirror");
9192 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9193 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9194 dstpool, "dst-pool");
9195 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9196 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9198 cmdline_parse_token_string_t cmd_mirror_link_on =
9199 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9203 cmd_set_mirror_link_parsed(void *parsed_result,
9204 __attribute__((unused)) struct cmdline *cl,
9205 __attribute__((unused)) void *data)
9208 struct cmd_set_mirror_link_result *res = parsed_result;
9209 struct rte_eth_mirror_conf mr_conf;
9211 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9212 if (!strcmp(res->what, "uplink-mirror"))
9213 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9215 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9217 mr_conf.dst_pool = res->dstpool_id;
9219 if (!strcmp(res->on, "on"))
9220 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9223 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9226 /* check the return value and print it if is < 0 */
9228 printf("mirror rule add error: (%s)\n", strerror(-ret));
9232 cmdline_parse_inst_t cmd_set_mirror_link = {
9233 .f = cmd_set_mirror_link_parsed,
9235 .help_str = "set port <port_id> mirror-rule <rule_id> "
9236 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9238 (void *)&cmd_mirror_link_set,
9239 (void *)&cmd_mirror_link_port,
9240 (void *)&cmd_mirror_link_portid,
9241 (void *)&cmd_mirror_link_mirror,
9242 (void *)&cmd_mirror_link_ruleid,
9243 (void *)&cmd_mirror_link_what,
9244 (void *)&cmd_mirror_link_dstpool,
9245 (void *)&cmd_mirror_link_poolid,
9246 (void *)&cmd_mirror_link_on,
9251 /* *** RESET VM MIRROR RULE *** */
9252 struct cmd_rm_mirror_rule_result {
9253 cmdline_fixed_string_t reset;
9254 cmdline_fixed_string_t port;
9256 cmdline_fixed_string_t mirror;
9260 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9261 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9263 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9264 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9266 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9267 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9269 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9270 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9271 mirror, "mirror-rule");
9272 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9273 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9277 cmd_reset_mirror_rule_parsed(void *parsed_result,
9278 __attribute__((unused)) struct cmdline *cl,
9279 __attribute__((unused)) void *data)
9282 struct cmd_set_mirror_link_result *res = parsed_result;
9284 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9286 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9289 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9290 .f = cmd_reset_mirror_rule_parsed,
9292 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9294 (void *)&cmd_rm_mirror_rule_reset,
9295 (void *)&cmd_rm_mirror_rule_port,
9296 (void *)&cmd_rm_mirror_rule_portid,
9297 (void *)&cmd_rm_mirror_rule_mirror,
9298 (void *)&cmd_rm_mirror_rule_ruleid,
9303 /* ******************************************************************************** */
9305 struct cmd_dump_result {
9306 cmdline_fixed_string_t dump;
9310 dump_struct_sizes(void)
9312 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9313 DUMP_SIZE(struct rte_mbuf);
9314 DUMP_SIZE(struct rte_mempool);
9315 DUMP_SIZE(struct rte_ring);
9319 static void cmd_dump_parsed(void *parsed_result,
9320 __attribute__((unused)) struct cmdline *cl,
9321 __attribute__((unused)) void *data)
9323 struct cmd_dump_result *res = parsed_result;
9325 if (!strcmp(res->dump, "dump_physmem"))
9326 rte_dump_physmem_layout(stdout);
9327 else if (!strcmp(res->dump, "dump_memzone"))
9328 rte_memzone_dump(stdout);
9329 else if (!strcmp(res->dump, "dump_struct_sizes"))
9330 dump_struct_sizes();
9331 else if (!strcmp(res->dump, "dump_ring"))
9332 rte_ring_list_dump(stdout);
9333 else if (!strcmp(res->dump, "dump_mempool"))
9334 rte_mempool_list_dump(stdout);
9335 else if (!strcmp(res->dump, "dump_devargs"))
9336 rte_devargs_dump(stdout);
9337 else if (!strcmp(res->dump, "dump_log_types"))
9338 rte_log_dump(stdout);
9341 cmdline_parse_token_string_t cmd_dump_dump =
9342 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9345 "dump_struct_sizes#"
9351 cmdline_parse_inst_t cmd_dump = {
9352 .f = cmd_dump_parsed, /* function to call */
9353 .data = NULL, /* 2nd arg of func */
9354 .help_str = "Dump status",
9355 .tokens = { /* token list, NULL terminated */
9356 (void *)&cmd_dump_dump,
9361 /* ******************************************************************************** */
9363 struct cmd_dump_one_result {
9364 cmdline_fixed_string_t dump;
9365 cmdline_fixed_string_t name;
9368 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9369 __attribute__((unused)) void *data)
9371 struct cmd_dump_one_result *res = parsed_result;
9373 if (!strcmp(res->dump, "dump_ring")) {
9375 r = rte_ring_lookup(res->name);
9377 cmdline_printf(cl, "Cannot find ring\n");
9380 rte_ring_dump(stdout, r);
9381 } else if (!strcmp(res->dump, "dump_mempool")) {
9382 struct rte_mempool *mp;
9383 mp = rte_mempool_lookup(res->name);
9385 cmdline_printf(cl, "Cannot find mempool\n");
9388 rte_mempool_dump(stdout, mp);
9392 cmdline_parse_token_string_t cmd_dump_one_dump =
9393 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9394 "dump_ring#dump_mempool");
9396 cmdline_parse_token_string_t cmd_dump_one_name =
9397 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9399 cmdline_parse_inst_t cmd_dump_one = {
9400 .f = cmd_dump_one_parsed, /* function to call */
9401 .data = NULL, /* 2nd arg of func */
9402 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9403 .tokens = { /* token list, NULL terminated */
9404 (void *)&cmd_dump_one_dump,
9405 (void *)&cmd_dump_one_name,
9410 /* *** Add/Del syn filter *** */
9411 struct cmd_syn_filter_result {
9412 cmdline_fixed_string_t filter;
9414 cmdline_fixed_string_t ops;
9415 cmdline_fixed_string_t priority;
9416 cmdline_fixed_string_t high;
9417 cmdline_fixed_string_t queue;
9422 cmd_syn_filter_parsed(void *parsed_result,
9423 __attribute__((unused)) struct cmdline *cl,
9424 __attribute__((unused)) void *data)
9426 struct cmd_syn_filter_result *res = parsed_result;
9427 struct rte_eth_syn_filter syn_filter;
9430 ret = rte_eth_dev_filter_supported(res->port_id,
9431 RTE_ETH_FILTER_SYN);
9433 printf("syn filter is not supported on port %u.\n",
9438 memset(&syn_filter, 0, sizeof(syn_filter));
9440 if (!strcmp(res->ops, "add")) {
9441 if (!strcmp(res->high, "high"))
9442 syn_filter.hig_pri = 1;
9444 syn_filter.hig_pri = 0;
9446 syn_filter.queue = res->queue_id;
9447 ret = rte_eth_dev_filter_ctrl(res->port_id,
9452 ret = rte_eth_dev_filter_ctrl(res->port_id,
9454 RTE_ETH_FILTER_DELETE,
9458 printf("syn filter programming error: (%s)\n",
9462 cmdline_parse_token_string_t cmd_syn_filter_filter =
9463 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9464 filter, "syn_filter");
9465 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9466 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9468 cmdline_parse_token_string_t cmd_syn_filter_ops =
9469 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9471 cmdline_parse_token_string_t cmd_syn_filter_priority =
9472 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9473 priority, "priority");
9474 cmdline_parse_token_string_t cmd_syn_filter_high =
9475 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9477 cmdline_parse_token_string_t cmd_syn_filter_queue =
9478 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9480 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9481 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9484 cmdline_parse_inst_t cmd_syn_filter = {
9485 .f = cmd_syn_filter_parsed,
9487 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9488 "<queue_id>: Add/Delete syn filter",
9490 (void *)&cmd_syn_filter_filter,
9491 (void *)&cmd_syn_filter_port_id,
9492 (void *)&cmd_syn_filter_ops,
9493 (void *)&cmd_syn_filter_priority,
9494 (void *)&cmd_syn_filter_high,
9495 (void *)&cmd_syn_filter_queue,
9496 (void *)&cmd_syn_filter_queue_id,
9501 /* *** queue region set *** */
9502 struct cmd_queue_region_result {
9503 cmdline_fixed_string_t set;
9504 cmdline_fixed_string_t port;
9506 cmdline_fixed_string_t cmd;
9507 cmdline_fixed_string_t region;
9509 cmdline_fixed_string_t queue_start_index;
9511 cmdline_fixed_string_t queue_num;
9512 uint8_t queue_num_value;
9516 cmd_queue_region_parsed(void *parsed_result,
9517 __attribute__((unused)) struct cmdline *cl,
9518 __attribute__((unused)) void *data)
9520 struct cmd_queue_region_result *res = parsed_result;
9522 #ifdef RTE_LIBRTE_I40E_PMD
9523 struct rte_pmd_i40e_queue_region_conf region_conf;
9524 enum rte_pmd_i40e_queue_region_op op_type;
9527 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9530 #ifdef RTE_LIBRTE_I40E_PMD
9531 memset(®ion_conf, 0, sizeof(region_conf));
9532 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9533 region_conf.region_id = res->region_id;
9534 region_conf.queue_num = res->queue_num_value;
9535 region_conf.queue_start_index = res->queue_id;
9537 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9538 op_type, ®ion_conf);
9545 printf("function not implemented or supported\n");
9548 printf("queue region config error: (%s)\n", strerror(-ret));
9552 cmdline_parse_token_string_t cmd_queue_region_set =
9553 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9555 cmdline_parse_token_string_t cmd_queue_region_port =
9556 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9557 cmdline_parse_token_num_t cmd_queue_region_port_id =
9558 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9560 cmdline_parse_token_string_t cmd_queue_region_cmd =
9561 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9562 cmd, "queue-region");
9563 cmdline_parse_token_string_t cmd_queue_region_id =
9564 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9565 region, "region_id");
9566 cmdline_parse_token_num_t cmd_queue_region_index =
9567 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9569 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9570 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9571 queue_start_index, "queue_start_index");
9572 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9573 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9575 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9576 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9577 queue_num, "queue_num");
9578 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9579 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9580 queue_num_value, UINT8);
9582 cmdline_parse_inst_t cmd_queue_region = {
9583 .f = cmd_queue_region_parsed,
9585 .help_str = "set port <port_id> queue-region region_id <value> "
9586 "queue_start_index <value> queue_num <value>: Set a queue region",
9588 (void *)&cmd_queue_region_set,
9589 (void *)&cmd_queue_region_port,
9590 (void *)&cmd_queue_region_port_id,
9591 (void *)&cmd_queue_region_cmd,
9592 (void *)&cmd_queue_region_id,
9593 (void *)&cmd_queue_region_index,
9594 (void *)&cmd_queue_region_queue_start_index,
9595 (void *)&cmd_queue_region_queue_id,
9596 (void *)&cmd_queue_region_queue_num,
9597 (void *)&cmd_queue_region_queue_num_value,
9602 /* *** queue region and flowtype set *** */
9603 struct cmd_region_flowtype_result {
9604 cmdline_fixed_string_t set;
9605 cmdline_fixed_string_t port;
9607 cmdline_fixed_string_t cmd;
9608 cmdline_fixed_string_t region;
9610 cmdline_fixed_string_t flowtype;
9611 uint8_t flowtype_id;
9615 cmd_region_flowtype_parsed(void *parsed_result,
9616 __attribute__((unused)) struct cmdline *cl,
9617 __attribute__((unused)) void *data)
9619 struct cmd_region_flowtype_result *res = parsed_result;
9621 #ifdef RTE_LIBRTE_I40E_PMD
9622 struct rte_pmd_i40e_queue_region_conf region_conf;
9623 enum rte_pmd_i40e_queue_region_op op_type;
9626 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9629 #ifdef RTE_LIBRTE_I40E_PMD
9630 memset(®ion_conf, 0, sizeof(region_conf));
9632 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9633 region_conf.region_id = res->region_id;
9634 region_conf.hw_flowtype = res->flowtype_id;
9636 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9637 op_type, ®ion_conf);
9644 printf("function not implemented or supported\n");
9647 printf("region flowtype config error: (%s)\n", strerror(-ret));
9651 cmdline_parse_token_string_t cmd_region_flowtype_set =
9652 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9654 cmdline_parse_token_string_t cmd_region_flowtype_port =
9655 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9657 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9658 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9660 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9661 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9662 cmd, "queue-region");
9663 cmdline_parse_token_string_t cmd_region_flowtype_index =
9664 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9665 region, "region_id");
9666 cmdline_parse_token_num_t cmd_region_flowtype_id =
9667 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9669 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9670 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9671 flowtype, "flowtype");
9672 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9673 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9674 flowtype_id, UINT8);
9675 cmdline_parse_inst_t cmd_region_flowtype = {
9676 .f = cmd_region_flowtype_parsed,
9678 .help_str = "set port <port_id> queue-region region_id <value> "
9679 "flowtype <value>: Set a flowtype region index",
9681 (void *)&cmd_region_flowtype_set,
9682 (void *)&cmd_region_flowtype_port,
9683 (void *)&cmd_region_flowtype_port_index,
9684 (void *)&cmd_region_flowtype_cmd,
9685 (void *)&cmd_region_flowtype_index,
9686 (void *)&cmd_region_flowtype_id,
9687 (void *)&cmd_region_flowtype_flow_index,
9688 (void *)&cmd_region_flowtype_flow_id,
9693 /* *** User Priority (UP) to queue region (region_id) set *** */
9694 struct cmd_user_priority_region_result {
9695 cmdline_fixed_string_t set;
9696 cmdline_fixed_string_t port;
9698 cmdline_fixed_string_t cmd;
9699 cmdline_fixed_string_t user_priority;
9700 uint8_t user_priority_id;
9701 cmdline_fixed_string_t region;
9706 cmd_user_priority_region_parsed(void *parsed_result,
9707 __attribute__((unused)) struct cmdline *cl,
9708 __attribute__((unused)) void *data)
9710 struct cmd_user_priority_region_result *res = parsed_result;
9712 #ifdef RTE_LIBRTE_I40E_PMD
9713 struct rte_pmd_i40e_queue_region_conf region_conf;
9714 enum rte_pmd_i40e_queue_region_op op_type;
9717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9720 #ifdef RTE_LIBRTE_I40E_PMD
9721 memset(®ion_conf, 0, sizeof(region_conf));
9722 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9723 region_conf.user_priority = res->user_priority_id;
9724 region_conf.region_id = res->region_id;
9726 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9727 op_type, ®ion_conf);
9734 printf("function not implemented or supported\n");
9737 printf("user_priority region config error: (%s)\n",
9742 cmdline_parse_token_string_t cmd_user_priority_region_set =
9743 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9745 cmdline_parse_token_string_t cmd_user_priority_region_port =
9746 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9748 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9749 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9751 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9752 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9753 cmd, "queue-region");
9754 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9755 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9756 user_priority, "UP");
9757 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9758 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9759 user_priority_id, UINT8);
9760 cmdline_parse_token_string_t cmd_user_priority_region_region =
9761 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9762 region, "region_id");
9763 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9764 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9767 cmdline_parse_inst_t cmd_user_priority_region = {
9768 .f = cmd_user_priority_region_parsed,
9770 .help_str = "set port <port_id> queue-region UP <value> "
9771 "region_id <value>: Set the mapping of User Priority (UP) "
9772 "to queue region (region_id) ",
9774 (void *)&cmd_user_priority_region_set,
9775 (void *)&cmd_user_priority_region_port,
9776 (void *)&cmd_user_priority_region_port_index,
9777 (void *)&cmd_user_priority_region_cmd,
9778 (void *)&cmd_user_priority_region_UP,
9779 (void *)&cmd_user_priority_region_UP_id,
9780 (void *)&cmd_user_priority_region_region,
9781 (void *)&cmd_user_priority_region_region_id,
9786 /* *** flush all queue region related configuration *** */
9787 struct cmd_flush_queue_region_result {
9788 cmdline_fixed_string_t set;
9789 cmdline_fixed_string_t port;
9791 cmdline_fixed_string_t cmd;
9792 cmdline_fixed_string_t flush;
9793 cmdline_fixed_string_t what;
9797 cmd_flush_queue_region_parsed(void *parsed_result,
9798 __attribute__((unused)) struct cmdline *cl,
9799 __attribute__((unused)) void *data)
9801 struct cmd_flush_queue_region_result *res = parsed_result;
9803 #ifdef RTE_LIBRTE_I40E_PMD
9804 struct rte_pmd_i40e_queue_region_conf region_conf;
9805 enum rte_pmd_i40e_queue_region_op op_type;
9808 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9811 #ifdef RTE_LIBRTE_I40E_PMD
9812 memset(®ion_conf, 0, sizeof(region_conf));
9814 if (strcmp(res->what, "on") == 0)
9815 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9817 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9819 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9820 op_type, ®ion_conf);
9827 printf("function not implemented or supported\n");
9830 printf("queue region config flush error: (%s)\n",
9835 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9836 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9838 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9839 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9841 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9842 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9844 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9845 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9846 cmd, "queue-region");
9847 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9848 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9850 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9851 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9854 cmdline_parse_inst_t cmd_flush_queue_region = {
9855 .f = cmd_flush_queue_region_parsed,
9857 .help_str = "set port <port_id> queue-region flush on|off"
9858 ": flush all queue region related configuration",
9860 (void *)&cmd_flush_queue_region_set,
9861 (void *)&cmd_flush_queue_region_port,
9862 (void *)&cmd_flush_queue_region_port_index,
9863 (void *)&cmd_flush_queue_region_cmd,
9864 (void *)&cmd_flush_queue_region_flush,
9865 (void *)&cmd_flush_queue_region_what,
9870 /* *** get all queue region related configuration info *** */
9871 struct cmd_show_queue_region_info {
9872 cmdline_fixed_string_t show;
9873 cmdline_fixed_string_t port;
9875 cmdline_fixed_string_t cmd;
9879 cmd_show_queue_region_info_parsed(void *parsed_result,
9880 __attribute__((unused)) struct cmdline *cl,
9881 __attribute__((unused)) void *data)
9883 struct cmd_show_queue_region_info *res = parsed_result;
9885 #ifdef RTE_LIBRTE_I40E_PMD
9886 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9887 enum rte_pmd_i40e_queue_region_op op_type;
9890 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9893 #ifdef RTE_LIBRTE_I40E_PMD
9894 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9896 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9898 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9899 op_type, &rte_pmd_regions);
9901 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9908 printf("function not implemented or supported\n");
9911 printf("queue region config info show error: (%s)\n",
9916 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9917 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9919 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9920 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9922 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9923 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9925 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9926 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9927 cmd, "queue-region");
9929 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9930 .f = cmd_show_queue_region_info_parsed,
9932 .help_str = "show port <port_id> queue-region"
9933 ": show all queue region related configuration info",
9935 (void *)&cmd_show_queue_region_info_get,
9936 (void *)&cmd_show_queue_region_info_port,
9937 (void *)&cmd_show_queue_region_info_port_index,
9938 (void *)&cmd_show_queue_region_info_cmd,
9943 /* *** ADD/REMOVE A 2tuple FILTER *** */
9944 struct cmd_2tuple_filter_result {
9945 cmdline_fixed_string_t filter;
9947 cmdline_fixed_string_t ops;
9948 cmdline_fixed_string_t dst_port;
9949 uint16_t dst_port_value;
9950 cmdline_fixed_string_t protocol;
9951 uint8_t protocol_value;
9952 cmdline_fixed_string_t mask;
9954 cmdline_fixed_string_t tcp_flags;
9955 uint8_t tcp_flags_value;
9956 cmdline_fixed_string_t priority;
9957 uint8_t priority_value;
9958 cmdline_fixed_string_t queue;
9963 cmd_2tuple_filter_parsed(void *parsed_result,
9964 __attribute__((unused)) struct cmdline *cl,
9965 __attribute__((unused)) void *data)
9967 struct rte_eth_ntuple_filter filter;
9968 struct cmd_2tuple_filter_result *res = parsed_result;
9971 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9973 printf("ntuple filter is not supported on port %u.\n",
9978 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9980 filter.flags = RTE_2TUPLE_FLAGS;
9981 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9982 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9983 filter.proto = res->protocol_value;
9984 filter.priority = res->priority_value;
9985 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9986 printf("nonzero tcp_flags is only meaningful"
9987 " when protocol is TCP.\n");
9990 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9991 printf("invalid TCP flags.\n");
9995 if (res->tcp_flags_value != 0) {
9996 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9997 filter.tcp_flags = res->tcp_flags_value;
10000 /* need convert to big endian. */
10001 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10002 filter.queue = res->queue_id;
10004 if (!strcmp(res->ops, "add"))
10005 ret = rte_eth_dev_filter_ctrl(res->port_id,
10006 RTE_ETH_FILTER_NTUPLE,
10007 RTE_ETH_FILTER_ADD,
10010 ret = rte_eth_dev_filter_ctrl(res->port_id,
10011 RTE_ETH_FILTER_NTUPLE,
10012 RTE_ETH_FILTER_DELETE,
10015 printf("2tuple filter programming error: (%s)\n",
10020 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10021 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10022 filter, "2tuple_filter");
10023 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10024 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10026 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10027 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10029 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10030 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10031 dst_port, "dst_port");
10032 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10033 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10034 dst_port_value, UINT16);
10035 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10036 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10037 protocol, "protocol");
10038 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10039 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10040 protocol_value, UINT8);
10041 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10042 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10044 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10045 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10047 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10048 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10049 tcp_flags, "tcp_flags");
10050 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10051 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10052 tcp_flags_value, UINT8);
10053 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10054 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10055 priority, "priority");
10056 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10057 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10058 priority_value, UINT8);
10059 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10060 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10062 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10063 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10066 cmdline_parse_inst_t cmd_2tuple_filter = {
10067 .f = cmd_2tuple_filter_parsed,
10069 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10070 "<value> mask <value> tcp_flags <value> priority <value> queue "
10071 "<queue_id>: Add a 2tuple filter",
10073 (void *)&cmd_2tuple_filter_filter,
10074 (void *)&cmd_2tuple_filter_port_id,
10075 (void *)&cmd_2tuple_filter_ops,
10076 (void *)&cmd_2tuple_filter_dst_port,
10077 (void *)&cmd_2tuple_filter_dst_port_value,
10078 (void *)&cmd_2tuple_filter_protocol,
10079 (void *)&cmd_2tuple_filter_protocol_value,
10080 (void *)&cmd_2tuple_filter_mask,
10081 (void *)&cmd_2tuple_filter_mask_value,
10082 (void *)&cmd_2tuple_filter_tcp_flags,
10083 (void *)&cmd_2tuple_filter_tcp_flags_value,
10084 (void *)&cmd_2tuple_filter_priority,
10085 (void *)&cmd_2tuple_filter_priority_value,
10086 (void *)&cmd_2tuple_filter_queue,
10087 (void *)&cmd_2tuple_filter_queue_id,
10092 /* *** ADD/REMOVE A 5tuple FILTER *** */
10093 struct cmd_5tuple_filter_result {
10094 cmdline_fixed_string_t filter;
10096 cmdline_fixed_string_t ops;
10097 cmdline_fixed_string_t dst_ip;
10098 cmdline_ipaddr_t dst_ip_value;
10099 cmdline_fixed_string_t src_ip;
10100 cmdline_ipaddr_t src_ip_value;
10101 cmdline_fixed_string_t dst_port;
10102 uint16_t dst_port_value;
10103 cmdline_fixed_string_t src_port;
10104 uint16_t src_port_value;
10105 cmdline_fixed_string_t protocol;
10106 uint8_t protocol_value;
10107 cmdline_fixed_string_t mask;
10108 uint8_t mask_value;
10109 cmdline_fixed_string_t tcp_flags;
10110 uint8_t tcp_flags_value;
10111 cmdline_fixed_string_t priority;
10112 uint8_t priority_value;
10113 cmdline_fixed_string_t queue;
10118 cmd_5tuple_filter_parsed(void *parsed_result,
10119 __attribute__((unused)) struct cmdline *cl,
10120 __attribute__((unused)) void *data)
10122 struct rte_eth_ntuple_filter filter;
10123 struct cmd_5tuple_filter_result *res = parsed_result;
10126 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10128 printf("ntuple filter is not supported on port %u.\n",
10133 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10135 filter.flags = RTE_5TUPLE_FLAGS;
10136 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10137 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10138 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10139 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10140 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10141 filter.proto = res->protocol_value;
10142 filter.priority = res->priority_value;
10143 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10144 printf("nonzero tcp_flags is only meaningful"
10145 " when protocol is TCP.\n");
10148 if (res->tcp_flags_value > TCP_FLAG_ALL) {
10149 printf("invalid TCP flags.\n");
10153 if (res->tcp_flags_value != 0) {
10154 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10155 filter.tcp_flags = res->tcp_flags_value;
10158 if (res->dst_ip_value.family == AF_INET)
10159 /* no need to convert, already big endian. */
10160 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10162 if (filter.dst_ip_mask == 0) {
10163 printf("can not support ipv6 involved compare.\n");
10169 if (res->src_ip_value.family == AF_INET)
10170 /* no need to convert, already big endian. */
10171 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10173 if (filter.src_ip_mask == 0) {
10174 printf("can not support ipv6 involved compare.\n");
10179 /* need convert to big endian. */
10180 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10181 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10182 filter.queue = res->queue_id;
10184 if (!strcmp(res->ops, "add"))
10185 ret = rte_eth_dev_filter_ctrl(res->port_id,
10186 RTE_ETH_FILTER_NTUPLE,
10187 RTE_ETH_FILTER_ADD,
10190 ret = rte_eth_dev_filter_ctrl(res->port_id,
10191 RTE_ETH_FILTER_NTUPLE,
10192 RTE_ETH_FILTER_DELETE,
10195 printf("5tuple filter programming error: (%s)\n",
10199 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10200 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10201 filter, "5tuple_filter");
10202 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10203 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10205 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10206 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10208 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10209 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10211 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10212 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10214 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10215 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10217 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10218 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10220 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10221 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10222 dst_port, "dst_port");
10223 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10224 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10225 dst_port_value, UINT16);
10226 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10227 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10228 src_port, "src_port");
10229 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10230 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10231 src_port_value, UINT16);
10232 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10233 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10234 protocol, "protocol");
10235 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10236 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10237 protocol_value, UINT8);
10238 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10239 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10241 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10242 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10244 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10245 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10246 tcp_flags, "tcp_flags");
10247 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10248 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10249 tcp_flags_value, UINT8);
10250 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10251 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10252 priority, "priority");
10253 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10254 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10255 priority_value, UINT8);
10256 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10257 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10259 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10260 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10263 cmdline_parse_inst_t cmd_5tuple_filter = {
10264 .f = cmd_5tuple_filter_parsed,
10266 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10267 "src_ip <value> dst_port <value> src_port <value> "
10268 "protocol <value> mask <value> tcp_flags <value> "
10269 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10271 (void *)&cmd_5tuple_filter_filter,
10272 (void *)&cmd_5tuple_filter_port_id,
10273 (void *)&cmd_5tuple_filter_ops,
10274 (void *)&cmd_5tuple_filter_dst_ip,
10275 (void *)&cmd_5tuple_filter_dst_ip_value,
10276 (void *)&cmd_5tuple_filter_src_ip,
10277 (void *)&cmd_5tuple_filter_src_ip_value,
10278 (void *)&cmd_5tuple_filter_dst_port,
10279 (void *)&cmd_5tuple_filter_dst_port_value,
10280 (void *)&cmd_5tuple_filter_src_port,
10281 (void *)&cmd_5tuple_filter_src_port_value,
10282 (void *)&cmd_5tuple_filter_protocol,
10283 (void *)&cmd_5tuple_filter_protocol_value,
10284 (void *)&cmd_5tuple_filter_mask,
10285 (void *)&cmd_5tuple_filter_mask_value,
10286 (void *)&cmd_5tuple_filter_tcp_flags,
10287 (void *)&cmd_5tuple_filter_tcp_flags_value,
10288 (void *)&cmd_5tuple_filter_priority,
10289 (void *)&cmd_5tuple_filter_priority_value,
10290 (void *)&cmd_5tuple_filter_queue,
10291 (void *)&cmd_5tuple_filter_queue_id,
10296 /* *** ADD/REMOVE A flex FILTER *** */
10297 struct cmd_flex_filter_result {
10298 cmdline_fixed_string_t filter;
10299 cmdline_fixed_string_t ops;
10301 cmdline_fixed_string_t len;
10303 cmdline_fixed_string_t bytes;
10304 cmdline_fixed_string_t bytes_value;
10305 cmdline_fixed_string_t mask;
10306 cmdline_fixed_string_t mask_value;
10307 cmdline_fixed_string_t priority;
10308 uint8_t priority_value;
10309 cmdline_fixed_string_t queue;
10313 static int xdigit2val(unsigned char c)
10318 else if (isupper(c))
10319 val = c - 'A' + 10;
10321 val = c - 'a' + 10;
10326 cmd_flex_filter_parsed(void *parsed_result,
10327 __attribute__((unused)) struct cmdline *cl,
10328 __attribute__((unused)) void *data)
10331 struct rte_eth_flex_filter filter;
10332 struct cmd_flex_filter_result *res = parsed_result;
10333 char *bytes_ptr, *mask_ptr;
10334 uint16_t len, i, j = 0;
10339 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10340 printf("the len exceed the max length 128\n");
10343 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10344 filter.len = res->len_value;
10345 filter.priority = res->priority_value;
10346 filter.queue = res->queue_id;
10347 bytes_ptr = res->bytes_value;
10348 mask_ptr = res->mask_value;
10350 /* translate bytes string to array. */
10351 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10352 (bytes_ptr[1] == 'X')))
10354 len = strnlen(bytes_ptr, res->len_value * 2);
10355 if (len == 0 || (len % 8 != 0)) {
10356 printf("please check len and bytes input\n");
10359 for (i = 0; i < len; i++) {
10361 if (isxdigit(c) == 0) {
10362 /* invalid characters. */
10363 printf("invalid input\n");
10366 val = xdigit2val(c);
10369 filter.bytes[j] = byte;
10370 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10377 /* translate mask string to uint8_t array. */
10378 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10379 (mask_ptr[1] == 'X')))
10381 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10383 printf("invalid input\n");
10388 for (i = 0; i < len; i++) {
10390 if (isxdigit(c) == 0) {
10391 /* invalid characters. */
10392 printf("invalid input\n");
10395 val = xdigit2val(c);
10398 filter.mask[j] = byte;
10399 printf("mask[%d]:%02x ", j, filter.mask[j]);
10407 if (!strcmp(res->ops, "add"))
10408 ret = rte_eth_dev_filter_ctrl(res->port_id,
10409 RTE_ETH_FILTER_FLEXIBLE,
10410 RTE_ETH_FILTER_ADD,
10413 ret = rte_eth_dev_filter_ctrl(res->port_id,
10414 RTE_ETH_FILTER_FLEXIBLE,
10415 RTE_ETH_FILTER_DELETE,
10419 printf("flex filter setting error: (%s)\n", strerror(-ret));
10422 cmdline_parse_token_string_t cmd_flex_filter_filter =
10423 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10424 filter, "flex_filter");
10425 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10426 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10428 cmdline_parse_token_string_t cmd_flex_filter_ops =
10429 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10431 cmdline_parse_token_string_t cmd_flex_filter_len =
10432 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10434 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10435 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10437 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10438 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10440 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10441 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10442 bytes_value, NULL);
10443 cmdline_parse_token_string_t cmd_flex_filter_mask =
10444 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10446 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10447 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10449 cmdline_parse_token_string_t cmd_flex_filter_priority =
10450 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10451 priority, "priority");
10452 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10453 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10454 priority_value, UINT8);
10455 cmdline_parse_token_string_t cmd_flex_filter_queue =
10456 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10458 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10459 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10461 cmdline_parse_inst_t cmd_flex_filter = {
10462 .f = cmd_flex_filter_parsed,
10464 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10465 "<value> mask <value> priority <value> queue <queue_id>: "
10466 "Add/Del a flex filter",
10468 (void *)&cmd_flex_filter_filter,
10469 (void *)&cmd_flex_filter_port_id,
10470 (void *)&cmd_flex_filter_ops,
10471 (void *)&cmd_flex_filter_len,
10472 (void *)&cmd_flex_filter_len_value,
10473 (void *)&cmd_flex_filter_bytes,
10474 (void *)&cmd_flex_filter_bytes_value,
10475 (void *)&cmd_flex_filter_mask,
10476 (void *)&cmd_flex_filter_mask_value,
10477 (void *)&cmd_flex_filter_priority,
10478 (void *)&cmd_flex_filter_priority_value,
10479 (void *)&cmd_flex_filter_queue,
10480 (void *)&cmd_flex_filter_queue_id,
10485 /* *** Filters Control *** */
10487 /* *** deal with ethertype filter *** */
10488 struct cmd_ethertype_filter_result {
10489 cmdline_fixed_string_t filter;
10491 cmdline_fixed_string_t ops;
10492 cmdline_fixed_string_t mac;
10493 struct ether_addr mac_addr;
10494 cmdline_fixed_string_t ethertype;
10495 uint16_t ethertype_value;
10496 cmdline_fixed_string_t drop;
10497 cmdline_fixed_string_t queue;
10501 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10502 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10503 filter, "ethertype_filter");
10504 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10505 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10507 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10508 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10510 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10511 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10512 mac, "mac_addr#mac_ignr");
10513 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10514 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10516 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10517 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10518 ethertype, "ethertype");
10519 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10520 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10521 ethertype_value, UINT16);
10522 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10523 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10525 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10526 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10528 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10529 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10533 cmd_ethertype_filter_parsed(void *parsed_result,
10534 __attribute__((unused)) struct cmdline *cl,
10535 __attribute__((unused)) void *data)
10537 struct cmd_ethertype_filter_result *res = parsed_result;
10538 struct rte_eth_ethertype_filter filter;
10541 ret = rte_eth_dev_filter_supported(res->port_id,
10542 RTE_ETH_FILTER_ETHERTYPE);
10544 printf("ethertype filter is not supported on port %u.\n",
10549 memset(&filter, 0, sizeof(filter));
10550 if (!strcmp(res->mac, "mac_addr")) {
10551 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10552 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10553 sizeof(struct ether_addr));
10555 if (!strcmp(res->drop, "drop"))
10556 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10557 filter.ether_type = res->ethertype_value;
10558 filter.queue = res->queue_id;
10560 if (!strcmp(res->ops, "add"))
10561 ret = rte_eth_dev_filter_ctrl(res->port_id,
10562 RTE_ETH_FILTER_ETHERTYPE,
10563 RTE_ETH_FILTER_ADD,
10566 ret = rte_eth_dev_filter_ctrl(res->port_id,
10567 RTE_ETH_FILTER_ETHERTYPE,
10568 RTE_ETH_FILTER_DELETE,
10571 printf("ethertype filter programming error: (%s)\n",
10575 cmdline_parse_inst_t cmd_ethertype_filter = {
10576 .f = cmd_ethertype_filter_parsed,
10578 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10579 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10580 "Add or delete an ethertype filter entry",
10582 (void *)&cmd_ethertype_filter_filter,
10583 (void *)&cmd_ethertype_filter_port_id,
10584 (void *)&cmd_ethertype_filter_ops,
10585 (void *)&cmd_ethertype_filter_mac,
10586 (void *)&cmd_ethertype_filter_mac_addr,
10587 (void *)&cmd_ethertype_filter_ethertype,
10588 (void *)&cmd_ethertype_filter_ethertype_value,
10589 (void *)&cmd_ethertype_filter_drop,
10590 (void *)&cmd_ethertype_filter_queue,
10591 (void *)&cmd_ethertype_filter_queue_id,
10596 /* *** deal with flow director filter *** */
10597 struct cmd_flow_director_result {
10598 cmdline_fixed_string_t flow_director_filter;
10600 cmdline_fixed_string_t mode;
10601 cmdline_fixed_string_t mode_value;
10602 cmdline_fixed_string_t ops;
10603 cmdline_fixed_string_t flow;
10604 cmdline_fixed_string_t flow_type;
10605 cmdline_fixed_string_t ether;
10606 uint16_t ether_type;
10607 cmdline_fixed_string_t src;
10608 cmdline_ipaddr_t ip_src;
10610 cmdline_fixed_string_t dst;
10611 cmdline_ipaddr_t ip_dst;
10613 cmdline_fixed_string_t verify_tag;
10614 uint32_t verify_tag_value;
10615 cmdline_fixed_string_t tos;
10617 cmdline_fixed_string_t proto;
10618 uint8_t proto_value;
10619 cmdline_fixed_string_t ttl;
10621 cmdline_fixed_string_t vlan;
10622 uint16_t vlan_value;
10623 cmdline_fixed_string_t flexbytes;
10624 cmdline_fixed_string_t flexbytes_value;
10625 cmdline_fixed_string_t pf_vf;
10626 cmdline_fixed_string_t drop;
10627 cmdline_fixed_string_t queue;
10629 cmdline_fixed_string_t fd_id;
10630 uint32_t fd_id_value;
10631 cmdline_fixed_string_t mac;
10632 struct ether_addr mac_addr;
10633 cmdline_fixed_string_t tunnel;
10634 cmdline_fixed_string_t tunnel_type;
10635 cmdline_fixed_string_t tunnel_id;
10636 uint32_t tunnel_id_value;
10637 cmdline_fixed_string_t packet;
10642 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10645 const char *p, *p0 = q_arg;
10647 unsigned long int_fld;
10648 char *str_fld[max_num];
10653 p = strchr(p0, '(');
10657 p0 = strchr(p, ')');
10662 if (size >= sizeof(s))
10665 snprintf(s, sizeof(s), "%.*s", size, p);
10666 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10667 if (ret < 0 || ret > max_num)
10669 for (i = 0; i < ret; i++) {
10671 int_fld = strtoul(str_fld[i], &end, 0);
10672 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10674 flexbytes[i] = (uint8_t)int_fld;
10680 str2flowtype(char *string)
10683 static const struct {
10686 } flowtype_str[] = {
10687 {"raw", RTE_ETH_FLOW_RAW},
10688 {"ipv4", RTE_ETH_FLOW_IPV4},
10689 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10690 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10691 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10692 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10693 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10694 {"ipv6", RTE_ETH_FLOW_IPV6},
10695 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10696 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10697 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10698 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10699 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10700 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10703 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10704 if (!strcmp(flowtype_str[i].str, string))
10705 return flowtype_str[i].type;
10708 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10709 return (uint16_t)atoi(string);
10711 return RTE_ETH_FLOW_UNKNOWN;
10714 static enum rte_eth_fdir_tunnel_type
10715 str2fdir_tunneltype(char *string)
10719 static const struct {
10721 enum rte_eth_fdir_tunnel_type type;
10722 } tunneltype_str[] = {
10723 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10724 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10727 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10728 if (!strcmp(tunneltype_str[i].str, string))
10729 return tunneltype_str[i].type;
10731 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10734 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10736 if ((ip_addr).family == AF_INET) \
10737 (ip) = (ip_addr).addr.ipv4.s_addr; \
10739 printf("invalid parameter.\n"); \
10744 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10746 if ((ip_addr).family == AF_INET6) \
10747 rte_memcpy(&(ip), \
10748 &((ip_addr).addr.ipv6), \
10749 sizeof(struct in6_addr)); \
10751 printf("invalid parameter.\n"); \
10757 cmd_flow_director_filter_parsed(void *parsed_result,
10758 __attribute__((unused)) struct cmdline *cl,
10759 __attribute__((unused)) void *data)
10761 struct cmd_flow_director_result *res = parsed_result;
10762 struct rte_eth_fdir_filter entry;
10763 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10765 unsigned long vf_id;
10768 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10770 printf("flow director is not supported on port %u.\n",
10774 memset(flexbytes, 0, sizeof(flexbytes));
10775 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10777 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10778 if (strcmp(res->mode_value, "MAC-VLAN")) {
10779 printf("Please set mode to MAC-VLAN.\n");
10782 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10783 if (strcmp(res->mode_value, "Tunnel")) {
10784 printf("Please set mode to Tunnel.\n");
10788 if (!strcmp(res->mode_value, "raw")) {
10789 #ifdef RTE_LIBRTE_I40E_PMD
10790 struct rte_pmd_i40e_flow_type_mapping
10791 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10792 struct rte_pmd_i40e_pkt_template_conf conf;
10793 uint16_t flow_type = str2flowtype(res->flow_type);
10794 uint16_t i, port = res->port_id;
10797 memset(&conf, 0, sizeof(conf));
10799 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10800 printf("Invalid flow type specified.\n");
10803 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10807 if (mapping[flow_type].pctype == 0ULL) {
10808 printf("Invalid flow type specified.\n");
10811 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10812 if (mapping[flow_type].pctype & (1ULL << i)) {
10813 conf.input.pctype = i;
10818 conf.input.packet = open_file(res->filepath,
10819 &conf.input.length);
10820 if (!conf.input.packet)
10822 if (!strcmp(res->drop, "drop"))
10823 conf.action.behavior =
10824 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10826 conf.action.behavior =
10827 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10828 conf.action.report_status =
10829 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10830 conf.action.rx_queue = res->queue_id;
10831 conf.soft_id = res->fd_id_value;
10832 add = strcmp(res->ops, "del") ? 1 : 0;
10833 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10837 printf("flow director config error: (%s)\n",
10839 close_file(conf.input.packet);
10842 } else if (strcmp(res->mode_value, "IP")) {
10843 printf("Please set mode to IP or raw.\n");
10846 entry.input.flow_type = str2flowtype(res->flow_type);
10849 ret = parse_flexbytes(res->flexbytes_value,
10851 RTE_ETH_FDIR_MAX_FLEXLEN);
10853 printf("error: Cannot parse flexbytes input.\n");
10857 switch (entry.input.flow_type) {
10858 case RTE_ETH_FLOW_FRAG_IPV4:
10859 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10860 entry.input.flow.ip4_flow.proto = res->proto_value;
10862 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10863 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10864 IPV4_ADDR_TO_UINT(res->ip_dst,
10865 entry.input.flow.ip4_flow.dst_ip);
10866 IPV4_ADDR_TO_UINT(res->ip_src,
10867 entry.input.flow.ip4_flow.src_ip);
10868 entry.input.flow.ip4_flow.tos = res->tos_value;
10869 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10870 /* need convert to big endian. */
10871 entry.input.flow.udp4_flow.dst_port =
10872 rte_cpu_to_be_16(res->port_dst);
10873 entry.input.flow.udp4_flow.src_port =
10874 rte_cpu_to_be_16(res->port_src);
10876 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10877 IPV4_ADDR_TO_UINT(res->ip_dst,
10878 entry.input.flow.sctp4_flow.ip.dst_ip);
10879 IPV4_ADDR_TO_UINT(res->ip_src,
10880 entry.input.flow.sctp4_flow.ip.src_ip);
10881 entry.input.flow.ip4_flow.tos = res->tos_value;
10882 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10883 /* need convert to big endian. */
10884 entry.input.flow.sctp4_flow.dst_port =
10885 rte_cpu_to_be_16(res->port_dst);
10886 entry.input.flow.sctp4_flow.src_port =
10887 rte_cpu_to_be_16(res->port_src);
10888 entry.input.flow.sctp4_flow.verify_tag =
10889 rte_cpu_to_be_32(res->verify_tag_value);
10891 case RTE_ETH_FLOW_FRAG_IPV6:
10892 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10893 entry.input.flow.ipv6_flow.proto = res->proto_value;
10895 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10896 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10897 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10898 entry.input.flow.ipv6_flow.dst_ip);
10899 IPV6_ADDR_TO_ARRAY(res->ip_src,
10900 entry.input.flow.ipv6_flow.src_ip);
10901 entry.input.flow.ipv6_flow.tc = res->tos_value;
10902 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10903 /* need convert to big endian. */
10904 entry.input.flow.udp6_flow.dst_port =
10905 rte_cpu_to_be_16(res->port_dst);
10906 entry.input.flow.udp6_flow.src_port =
10907 rte_cpu_to_be_16(res->port_src);
10909 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10910 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10911 entry.input.flow.sctp6_flow.ip.dst_ip);
10912 IPV6_ADDR_TO_ARRAY(res->ip_src,
10913 entry.input.flow.sctp6_flow.ip.src_ip);
10914 entry.input.flow.ipv6_flow.tc = res->tos_value;
10915 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10916 /* need convert to big endian. */
10917 entry.input.flow.sctp6_flow.dst_port =
10918 rte_cpu_to_be_16(res->port_dst);
10919 entry.input.flow.sctp6_flow.src_port =
10920 rte_cpu_to_be_16(res->port_src);
10921 entry.input.flow.sctp6_flow.verify_tag =
10922 rte_cpu_to_be_32(res->verify_tag_value);
10924 case RTE_ETH_FLOW_L2_PAYLOAD:
10925 entry.input.flow.l2_flow.ether_type =
10926 rte_cpu_to_be_16(res->ether_type);
10932 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10933 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10935 sizeof(struct ether_addr));
10937 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10938 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10940 sizeof(struct ether_addr));
10941 entry.input.flow.tunnel_flow.tunnel_type =
10942 str2fdir_tunneltype(res->tunnel_type);
10943 entry.input.flow.tunnel_flow.tunnel_id =
10944 rte_cpu_to_be_32(res->tunnel_id_value);
10947 rte_memcpy(entry.input.flow_ext.flexbytes,
10949 RTE_ETH_FDIR_MAX_FLEXLEN);
10951 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10953 entry.action.flex_off = 0; /*use 0 by default */
10954 if (!strcmp(res->drop, "drop"))
10955 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10957 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10959 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10960 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10961 if (!strcmp(res->pf_vf, "pf"))
10962 entry.input.flow_ext.is_vf = 0;
10963 else if (!strncmp(res->pf_vf, "vf", 2)) {
10964 struct rte_eth_dev_info dev_info;
10966 memset(&dev_info, 0, sizeof(dev_info));
10967 rte_eth_dev_info_get(res->port_id, &dev_info);
10969 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10970 if (errno != 0 || *end != '\0' ||
10971 vf_id >= dev_info.max_vfs) {
10972 printf("invalid parameter %s.\n", res->pf_vf);
10975 entry.input.flow_ext.is_vf = 1;
10976 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10978 printf("invalid parameter %s.\n", res->pf_vf);
10983 /* set to report FD ID by default */
10984 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10985 entry.action.rx_queue = res->queue_id;
10986 entry.soft_id = res->fd_id_value;
10987 if (!strcmp(res->ops, "add"))
10988 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10989 RTE_ETH_FILTER_ADD, &entry);
10990 else if (!strcmp(res->ops, "del"))
10991 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10992 RTE_ETH_FILTER_DELETE, &entry);
10994 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10995 RTE_ETH_FILTER_UPDATE, &entry);
10997 printf("flow director programming error: (%s)\n",
11001 cmdline_parse_token_string_t cmd_flow_director_filter =
11002 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11003 flow_director_filter, "flow_director_filter");
11004 cmdline_parse_token_num_t cmd_flow_director_port_id =
11005 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11007 cmdline_parse_token_string_t cmd_flow_director_ops =
11008 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11009 ops, "add#del#update");
11010 cmdline_parse_token_string_t cmd_flow_director_flow =
11011 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11013 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11014 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11016 cmdline_parse_token_string_t cmd_flow_director_ether =
11017 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11019 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11020 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11021 ether_type, UINT16);
11022 cmdline_parse_token_string_t cmd_flow_director_src =
11023 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11025 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11026 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11028 cmdline_parse_token_num_t cmd_flow_director_port_src =
11029 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11031 cmdline_parse_token_string_t cmd_flow_director_dst =
11032 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11034 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11035 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11037 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11038 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11040 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11041 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11042 verify_tag, "verify_tag");
11043 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11044 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11045 verify_tag_value, UINT32);
11046 cmdline_parse_token_string_t cmd_flow_director_tos =
11047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11049 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11050 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11052 cmdline_parse_token_string_t cmd_flow_director_proto =
11053 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11055 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11056 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11057 proto_value, UINT8);
11058 cmdline_parse_token_string_t cmd_flow_director_ttl =
11059 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11061 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11062 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11064 cmdline_parse_token_string_t cmd_flow_director_vlan =
11065 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11067 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11068 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11069 vlan_value, UINT16);
11070 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11071 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11072 flexbytes, "flexbytes");
11073 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11074 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11075 flexbytes_value, NULL);
11076 cmdline_parse_token_string_t cmd_flow_director_drop =
11077 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11079 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11080 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11082 cmdline_parse_token_string_t cmd_flow_director_queue =
11083 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11085 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11086 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11088 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11089 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11091 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11092 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11093 fd_id_value, UINT32);
11095 cmdline_parse_token_string_t cmd_flow_director_mode =
11096 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11098 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11099 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11101 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11102 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11103 mode_value, "MAC-VLAN");
11104 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11105 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11106 mode_value, "Tunnel");
11107 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11108 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11109 mode_value, "raw");
11110 cmdline_parse_token_string_t cmd_flow_director_mac =
11111 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11113 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11114 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11116 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11117 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11119 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11120 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11121 tunnel_type, "NVGRE#VxLAN");
11122 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11123 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11124 tunnel_id, "tunnel-id");
11125 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11126 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11127 tunnel_id_value, UINT32);
11128 cmdline_parse_token_string_t cmd_flow_director_packet =
11129 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11131 cmdline_parse_token_string_t cmd_flow_director_filepath =
11132 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11135 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11136 .f = cmd_flow_director_filter_parsed,
11138 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11139 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11140 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11141 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11142 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11143 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11144 "fd_id <fd_id_value>: "
11145 "Add or delete an ip flow director entry on NIC",
11147 (void *)&cmd_flow_director_filter,
11148 (void *)&cmd_flow_director_port_id,
11149 (void *)&cmd_flow_director_mode,
11150 (void *)&cmd_flow_director_mode_ip,
11151 (void *)&cmd_flow_director_ops,
11152 (void *)&cmd_flow_director_flow,
11153 (void *)&cmd_flow_director_flow_type,
11154 (void *)&cmd_flow_director_src,
11155 (void *)&cmd_flow_director_ip_src,
11156 (void *)&cmd_flow_director_dst,
11157 (void *)&cmd_flow_director_ip_dst,
11158 (void *)&cmd_flow_director_tos,
11159 (void *)&cmd_flow_director_tos_value,
11160 (void *)&cmd_flow_director_proto,
11161 (void *)&cmd_flow_director_proto_value,
11162 (void *)&cmd_flow_director_ttl,
11163 (void *)&cmd_flow_director_ttl_value,
11164 (void *)&cmd_flow_director_vlan,
11165 (void *)&cmd_flow_director_vlan_value,
11166 (void *)&cmd_flow_director_flexbytes,
11167 (void *)&cmd_flow_director_flexbytes_value,
11168 (void *)&cmd_flow_director_drop,
11169 (void *)&cmd_flow_director_pf_vf,
11170 (void *)&cmd_flow_director_queue,
11171 (void *)&cmd_flow_director_queue_id,
11172 (void *)&cmd_flow_director_fd_id,
11173 (void *)&cmd_flow_director_fd_id_value,
11178 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11179 .f = cmd_flow_director_filter_parsed,
11181 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11182 "director entry on NIC",
11184 (void *)&cmd_flow_director_filter,
11185 (void *)&cmd_flow_director_port_id,
11186 (void *)&cmd_flow_director_mode,
11187 (void *)&cmd_flow_director_mode_ip,
11188 (void *)&cmd_flow_director_ops,
11189 (void *)&cmd_flow_director_flow,
11190 (void *)&cmd_flow_director_flow_type,
11191 (void *)&cmd_flow_director_src,
11192 (void *)&cmd_flow_director_ip_src,
11193 (void *)&cmd_flow_director_port_src,
11194 (void *)&cmd_flow_director_dst,
11195 (void *)&cmd_flow_director_ip_dst,
11196 (void *)&cmd_flow_director_port_dst,
11197 (void *)&cmd_flow_director_tos,
11198 (void *)&cmd_flow_director_tos_value,
11199 (void *)&cmd_flow_director_ttl,
11200 (void *)&cmd_flow_director_ttl_value,
11201 (void *)&cmd_flow_director_vlan,
11202 (void *)&cmd_flow_director_vlan_value,
11203 (void *)&cmd_flow_director_flexbytes,
11204 (void *)&cmd_flow_director_flexbytes_value,
11205 (void *)&cmd_flow_director_drop,
11206 (void *)&cmd_flow_director_pf_vf,
11207 (void *)&cmd_flow_director_queue,
11208 (void *)&cmd_flow_director_queue_id,
11209 (void *)&cmd_flow_director_fd_id,
11210 (void *)&cmd_flow_director_fd_id_value,
11215 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11216 .f = cmd_flow_director_filter_parsed,
11218 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11219 "director entry on NIC",
11221 (void *)&cmd_flow_director_filter,
11222 (void *)&cmd_flow_director_port_id,
11223 (void *)&cmd_flow_director_mode,
11224 (void *)&cmd_flow_director_mode_ip,
11225 (void *)&cmd_flow_director_ops,
11226 (void *)&cmd_flow_director_flow,
11227 (void *)&cmd_flow_director_flow_type,
11228 (void *)&cmd_flow_director_src,
11229 (void *)&cmd_flow_director_ip_src,
11230 (void *)&cmd_flow_director_port_src,
11231 (void *)&cmd_flow_director_dst,
11232 (void *)&cmd_flow_director_ip_dst,
11233 (void *)&cmd_flow_director_port_dst,
11234 (void *)&cmd_flow_director_verify_tag,
11235 (void *)&cmd_flow_director_verify_tag_value,
11236 (void *)&cmd_flow_director_tos,
11237 (void *)&cmd_flow_director_tos_value,
11238 (void *)&cmd_flow_director_ttl,
11239 (void *)&cmd_flow_director_ttl_value,
11240 (void *)&cmd_flow_director_vlan,
11241 (void *)&cmd_flow_director_vlan_value,
11242 (void *)&cmd_flow_director_flexbytes,
11243 (void *)&cmd_flow_director_flexbytes_value,
11244 (void *)&cmd_flow_director_drop,
11245 (void *)&cmd_flow_director_pf_vf,
11246 (void *)&cmd_flow_director_queue,
11247 (void *)&cmd_flow_director_queue_id,
11248 (void *)&cmd_flow_director_fd_id,
11249 (void *)&cmd_flow_director_fd_id_value,
11254 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11255 .f = cmd_flow_director_filter_parsed,
11257 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11258 "director entry on NIC",
11260 (void *)&cmd_flow_director_filter,
11261 (void *)&cmd_flow_director_port_id,
11262 (void *)&cmd_flow_director_mode,
11263 (void *)&cmd_flow_director_mode_ip,
11264 (void *)&cmd_flow_director_ops,
11265 (void *)&cmd_flow_director_flow,
11266 (void *)&cmd_flow_director_flow_type,
11267 (void *)&cmd_flow_director_ether,
11268 (void *)&cmd_flow_director_ether_type,
11269 (void *)&cmd_flow_director_flexbytes,
11270 (void *)&cmd_flow_director_flexbytes_value,
11271 (void *)&cmd_flow_director_drop,
11272 (void *)&cmd_flow_director_pf_vf,
11273 (void *)&cmd_flow_director_queue,
11274 (void *)&cmd_flow_director_queue_id,
11275 (void *)&cmd_flow_director_fd_id,
11276 (void *)&cmd_flow_director_fd_id_value,
11281 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11282 .f = cmd_flow_director_filter_parsed,
11284 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11285 "director entry on NIC",
11287 (void *)&cmd_flow_director_filter,
11288 (void *)&cmd_flow_director_port_id,
11289 (void *)&cmd_flow_director_mode,
11290 (void *)&cmd_flow_director_mode_mac_vlan,
11291 (void *)&cmd_flow_director_ops,
11292 (void *)&cmd_flow_director_mac,
11293 (void *)&cmd_flow_director_mac_addr,
11294 (void *)&cmd_flow_director_vlan,
11295 (void *)&cmd_flow_director_vlan_value,
11296 (void *)&cmd_flow_director_flexbytes,
11297 (void *)&cmd_flow_director_flexbytes_value,
11298 (void *)&cmd_flow_director_drop,
11299 (void *)&cmd_flow_director_queue,
11300 (void *)&cmd_flow_director_queue_id,
11301 (void *)&cmd_flow_director_fd_id,
11302 (void *)&cmd_flow_director_fd_id_value,
11307 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11308 .f = cmd_flow_director_filter_parsed,
11310 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11311 "director entry on NIC",
11313 (void *)&cmd_flow_director_filter,
11314 (void *)&cmd_flow_director_port_id,
11315 (void *)&cmd_flow_director_mode,
11316 (void *)&cmd_flow_director_mode_tunnel,
11317 (void *)&cmd_flow_director_ops,
11318 (void *)&cmd_flow_director_mac,
11319 (void *)&cmd_flow_director_mac_addr,
11320 (void *)&cmd_flow_director_vlan,
11321 (void *)&cmd_flow_director_vlan_value,
11322 (void *)&cmd_flow_director_tunnel,
11323 (void *)&cmd_flow_director_tunnel_type,
11324 (void *)&cmd_flow_director_tunnel_id,
11325 (void *)&cmd_flow_director_tunnel_id_value,
11326 (void *)&cmd_flow_director_flexbytes,
11327 (void *)&cmd_flow_director_flexbytes_value,
11328 (void *)&cmd_flow_director_drop,
11329 (void *)&cmd_flow_director_queue,
11330 (void *)&cmd_flow_director_queue_id,
11331 (void *)&cmd_flow_director_fd_id,
11332 (void *)&cmd_flow_director_fd_id_value,
11337 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11338 .f = cmd_flow_director_filter_parsed,
11340 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11341 "director entry on NIC",
11343 (void *)&cmd_flow_director_filter,
11344 (void *)&cmd_flow_director_port_id,
11345 (void *)&cmd_flow_director_mode,
11346 (void *)&cmd_flow_director_mode_raw,
11347 (void *)&cmd_flow_director_ops,
11348 (void *)&cmd_flow_director_flow,
11349 (void *)&cmd_flow_director_flow_type,
11350 (void *)&cmd_flow_director_drop,
11351 (void *)&cmd_flow_director_queue,
11352 (void *)&cmd_flow_director_queue_id,
11353 (void *)&cmd_flow_director_fd_id,
11354 (void *)&cmd_flow_director_fd_id_value,
11355 (void *)&cmd_flow_director_packet,
11356 (void *)&cmd_flow_director_filepath,
11361 struct cmd_flush_flow_director_result {
11362 cmdline_fixed_string_t flush_flow_director;
11366 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11367 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11368 flush_flow_director, "flush_flow_director");
11369 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11370 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11374 cmd_flush_flow_director_parsed(void *parsed_result,
11375 __attribute__((unused)) struct cmdline *cl,
11376 __attribute__((unused)) void *data)
11378 struct cmd_flow_director_result *res = parsed_result;
11381 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11383 printf("flow director is not supported on port %u.\n",
11388 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11389 RTE_ETH_FILTER_FLUSH, NULL);
11391 printf("flow director table flushing error: (%s)\n",
11395 cmdline_parse_inst_t cmd_flush_flow_director = {
11396 .f = cmd_flush_flow_director_parsed,
11398 .help_str = "flush_flow_director <port_id>: "
11399 "Flush all flow director entries of a device on NIC",
11401 (void *)&cmd_flush_flow_director_flush,
11402 (void *)&cmd_flush_flow_director_port_id,
11407 /* *** deal with flow director mask *** */
11408 struct cmd_flow_director_mask_result {
11409 cmdline_fixed_string_t flow_director_mask;
11411 cmdline_fixed_string_t mode;
11412 cmdline_fixed_string_t mode_value;
11413 cmdline_fixed_string_t vlan;
11414 uint16_t vlan_mask;
11415 cmdline_fixed_string_t src_mask;
11416 cmdline_ipaddr_t ipv4_src;
11417 cmdline_ipaddr_t ipv6_src;
11419 cmdline_fixed_string_t dst_mask;
11420 cmdline_ipaddr_t ipv4_dst;
11421 cmdline_ipaddr_t ipv6_dst;
11423 cmdline_fixed_string_t mac;
11424 uint8_t mac_addr_byte_mask;
11425 cmdline_fixed_string_t tunnel_id;
11426 uint32_t tunnel_id_mask;
11427 cmdline_fixed_string_t tunnel_type;
11428 uint8_t tunnel_type_mask;
11432 cmd_flow_director_mask_parsed(void *parsed_result,
11433 __attribute__((unused)) struct cmdline *cl,
11434 __attribute__((unused)) void *data)
11436 struct cmd_flow_director_mask_result *res = parsed_result;
11437 struct rte_eth_fdir_masks *mask;
11438 struct rte_port *port;
11440 port = &ports[res->port_id];
11441 /** Check if the port is not started **/
11442 if (port->port_status != RTE_PORT_STOPPED) {
11443 printf("Please stop port %d first\n", res->port_id);
11447 mask = &port->dev_conf.fdir_conf.mask;
11449 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11450 if (strcmp(res->mode_value, "MAC-VLAN")) {
11451 printf("Please set mode to MAC-VLAN.\n");
11455 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11456 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11457 if (strcmp(res->mode_value, "Tunnel")) {
11458 printf("Please set mode to Tunnel.\n");
11462 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11463 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11464 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11465 mask->tunnel_type_mask = res->tunnel_type_mask;
11467 if (strcmp(res->mode_value, "IP")) {
11468 printf("Please set mode to IP.\n");
11472 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11473 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11474 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11475 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11476 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11477 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11478 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11481 cmd_reconfig_device_queue(res->port_id, 1, 1);
11484 cmdline_parse_token_string_t cmd_flow_director_mask =
11485 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11486 flow_director_mask, "flow_director_mask");
11487 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11488 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11490 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11491 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11493 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11494 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11495 vlan_mask, UINT16);
11496 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11497 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11498 src_mask, "src_mask");
11499 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11500 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11502 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11503 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11505 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11506 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11508 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11509 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11510 dst_mask, "dst_mask");
11511 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11512 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11514 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11515 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11517 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11518 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11521 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11522 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11524 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11525 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11527 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11528 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11529 mode_value, "MAC-VLAN");
11530 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11531 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11532 mode_value, "Tunnel");
11533 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11534 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11536 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11537 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11538 mac_addr_byte_mask, UINT8);
11539 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11540 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11541 tunnel_type, "tunnel-type");
11542 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11543 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11544 tunnel_type_mask, UINT8);
11545 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11546 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11547 tunnel_id, "tunnel-id");
11548 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11549 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11550 tunnel_id_mask, UINT32);
11552 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11553 .f = cmd_flow_director_mask_parsed,
11555 .help_str = "flow_director_mask ... : "
11556 "Set IP mode flow director's mask on NIC",
11558 (void *)&cmd_flow_director_mask,
11559 (void *)&cmd_flow_director_mask_port_id,
11560 (void *)&cmd_flow_director_mask_mode,
11561 (void *)&cmd_flow_director_mask_mode_ip,
11562 (void *)&cmd_flow_director_mask_vlan,
11563 (void *)&cmd_flow_director_mask_vlan_value,
11564 (void *)&cmd_flow_director_mask_src,
11565 (void *)&cmd_flow_director_mask_ipv4_src,
11566 (void *)&cmd_flow_director_mask_ipv6_src,
11567 (void *)&cmd_flow_director_mask_port_src,
11568 (void *)&cmd_flow_director_mask_dst,
11569 (void *)&cmd_flow_director_mask_ipv4_dst,
11570 (void *)&cmd_flow_director_mask_ipv6_dst,
11571 (void *)&cmd_flow_director_mask_port_dst,
11576 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11577 .f = cmd_flow_director_mask_parsed,
11579 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11580 "flow director's mask on NIC",
11582 (void *)&cmd_flow_director_mask,
11583 (void *)&cmd_flow_director_mask_port_id,
11584 (void *)&cmd_flow_director_mask_mode,
11585 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11586 (void *)&cmd_flow_director_mask_vlan,
11587 (void *)&cmd_flow_director_mask_vlan_value,
11592 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11593 .f = cmd_flow_director_mask_parsed,
11595 .help_str = "flow_director_mask ... : Set tunnel mode "
11596 "flow director's mask on NIC",
11598 (void *)&cmd_flow_director_mask,
11599 (void *)&cmd_flow_director_mask_port_id,
11600 (void *)&cmd_flow_director_mask_mode,
11601 (void *)&cmd_flow_director_mask_mode_tunnel,
11602 (void *)&cmd_flow_director_mask_vlan,
11603 (void *)&cmd_flow_director_mask_vlan_value,
11604 (void *)&cmd_flow_director_mask_mac,
11605 (void *)&cmd_flow_director_mask_mac_value,
11606 (void *)&cmd_flow_director_mask_tunnel_type,
11607 (void *)&cmd_flow_director_mask_tunnel_type_value,
11608 (void *)&cmd_flow_director_mask_tunnel_id,
11609 (void *)&cmd_flow_director_mask_tunnel_id_value,
11614 /* *** deal with flow director mask on flexible payload *** */
11615 struct cmd_flow_director_flex_mask_result {
11616 cmdline_fixed_string_t flow_director_flexmask;
11618 cmdline_fixed_string_t flow;
11619 cmdline_fixed_string_t flow_type;
11620 cmdline_fixed_string_t mask;
11624 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11625 __attribute__((unused)) struct cmdline *cl,
11626 __attribute__((unused)) void *data)
11628 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11629 struct rte_eth_fdir_info fdir_info;
11630 struct rte_eth_fdir_flex_mask flex_mask;
11631 struct rte_port *port;
11632 uint64_t flow_type_mask;
11636 port = &ports[res->port_id];
11637 /** Check if the port is not started **/
11638 if (port->port_status != RTE_PORT_STOPPED) {
11639 printf("Please stop port %d first\n", res->port_id);
11643 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11644 ret = parse_flexbytes(res->mask,
11646 RTE_ETH_FDIR_MAX_FLEXLEN);
11648 printf("error: Cannot parse mask input.\n");
11652 memset(&fdir_info, 0, sizeof(fdir_info));
11653 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11654 RTE_ETH_FILTER_INFO, &fdir_info);
11656 printf("Cannot get FDir filter info\n");
11660 if (!strcmp(res->flow_type, "none")) {
11661 /* means don't specify the flow type */
11662 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11663 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11664 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11665 0, sizeof(struct rte_eth_fdir_flex_mask));
11666 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11667 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11669 sizeof(struct rte_eth_fdir_flex_mask));
11670 cmd_reconfig_device_queue(res->port_id, 1, 1);
11673 flow_type_mask = fdir_info.flow_types_mask[0];
11674 if (!strcmp(res->flow_type, "all")) {
11675 if (!flow_type_mask) {
11676 printf("No flow type supported\n");
11679 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11680 if (flow_type_mask & (1ULL << i)) {
11681 flex_mask.flow_type = i;
11682 fdir_set_flex_mask(res->port_id, &flex_mask);
11685 cmd_reconfig_device_queue(res->port_id, 1, 1);
11688 flex_mask.flow_type = str2flowtype(res->flow_type);
11689 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11690 printf("Flow type %s not supported on port %d\n",
11691 res->flow_type, res->port_id);
11694 fdir_set_flex_mask(res->port_id, &flex_mask);
11695 cmd_reconfig_device_queue(res->port_id, 1, 1);
11698 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11699 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11700 flow_director_flexmask,
11701 "flow_director_flex_mask");
11702 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11703 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11705 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11706 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11708 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11709 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11710 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11711 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11712 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11713 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11716 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11717 .f = cmd_flow_director_flex_mask_parsed,
11719 .help_str = "flow_director_flex_mask ... : "
11720 "Set flow director's flex mask on NIC",
11722 (void *)&cmd_flow_director_flexmask,
11723 (void *)&cmd_flow_director_flexmask_port_id,
11724 (void *)&cmd_flow_director_flexmask_flow,
11725 (void *)&cmd_flow_director_flexmask_flow_type,
11726 (void *)&cmd_flow_director_flexmask_mask,
11731 /* *** deal with flow director flexible payload configuration *** */
11732 struct cmd_flow_director_flexpayload_result {
11733 cmdline_fixed_string_t flow_director_flexpayload;
11735 cmdline_fixed_string_t payload_layer;
11736 cmdline_fixed_string_t payload_cfg;
11740 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11743 const char *p, *p0 = q_arg;
11745 unsigned long int_fld;
11746 char *str_fld[max_num];
11751 p = strchr(p0, '(');
11755 p0 = strchr(p, ')');
11760 if (size >= sizeof(s))
11763 snprintf(s, sizeof(s), "%.*s", size, p);
11764 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11765 if (ret < 0 || ret > max_num)
11767 for (i = 0; i < ret; i++) {
11769 int_fld = strtoul(str_fld[i], &end, 0);
11770 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11772 offsets[i] = (uint16_t)int_fld;
11778 cmd_flow_director_flxpld_parsed(void *parsed_result,
11779 __attribute__((unused)) struct cmdline *cl,
11780 __attribute__((unused)) void *data)
11782 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11783 struct rte_eth_flex_payload_cfg flex_cfg;
11784 struct rte_port *port;
11787 port = &ports[res->port_id];
11788 /** Check if the port is not started **/
11789 if (port->port_status != RTE_PORT_STOPPED) {
11790 printf("Please stop port %d first\n", res->port_id);
11794 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11796 if (!strcmp(res->payload_layer, "raw"))
11797 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11798 else if (!strcmp(res->payload_layer, "l2"))
11799 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11800 else if (!strcmp(res->payload_layer, "l3"))
11801 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11802 else if (!strcmp(res->payload_layer, "l4"))
11803 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11805 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11806 RTE_ETH_FDIR_MAX_FLEXLEN);
11808 printf("error: Cannot parse flex payload input.\n");
11812 fdir_set_flex_payload(res->port_id, &flex_cfg);
11813 cmd_reconfig_device_queue(res->port_id, 1, 1);
11816 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11817 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11818 flow_director_flexpayload,
11819 "flow_director_flex_payload");
11820 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11821 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11823 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11824 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11825 payload_layer, "raw#l2#l3#l4");
11826 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11827 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11828 payload_cfg, NULL);
11830 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11831 .f = cmd_flow_director_flxpld_parsed,
11833 .help_str = "flow_director_flexpayload ... : "
11834 "Set flow director's flex payload on NIC",
11836 (void *)&cmd_flow_director_flexpayload,
11837 (void *)&cmd_flow_director_flexpayload_port_id,
11838 (void *)&cmd_flow_director_flexpayload_payload_layer,
11839 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11844 /* Generic flow interface command. */
11845 extern cmdline_parse_inst_t cmd_flow;
11847 /* *** Classification Filters Control *** */
11848 /* *** Get symmetric hash enable per port *** */
11849 struct cmd_get_sym_hash_ena_per_port_result {
11850 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11855 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11856 __rte_unused struct cmdline *cl,
11857 __rte_unused void *data)
11859 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11860 struct rte_eth_hash_filter_info info;
11863 if (rte_eth_dev_filter_supported(res->port_id,
11864 RTE_ETH_FILTER_HASH) < 0) {
11865 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11870 memset(&info, 0, sizeof(info));
11871 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11872 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11873 RTE_ETH_FILTER_GET, &info);
11876 printf("Cannot get symmetric hash enable per port "
11877 "on port %u\n", res->port_id);
11881 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11882 "enabled" : "disabled", res->port_id);
11885 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11886 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11887 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11888 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11889 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11892 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11893 .f = cmd_get_sym_hash_per_port_parsed,
11895 .help_str = "get_sym_hash_ena_per_port <port_id>",
11897 (void *)&cmd_get_sym_hash_ena_per_port_all,
11898 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11903 /* *** Set symmetric hash enable per port *** */
11904 struct cmd_set_sym_hash_ena_per_port_result {
11905 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11906 cmdline_fixed_string_t enable;
11911 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11912 __rte_unused struct cmdline *cl,
11913 __rte_unused void *data)
11915 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11916 struct rte_eth_hash_filter_info info;
11919 if (rte_eth_dev_filter_supported(res->port_id,
11920 RTE_ETH_FILTER_HASH) < 0) {
11921 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11926 memset(&info, 0, sizeof(info));
11927 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11928 if (!strcmp(res->enable, "enable"))
11929 info.info.enable = 1;
11930 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11931 RTE_ETH_FILTER_SET, &info);
11933 printf("Cannot set symmetric hash enable per port on "
11934 "port %u\n", res->port_id);
11937 printf("Symmetric hash has been set to %s on port %u\n",
11938 res->enable, res->port_id);
11941 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11942 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11943 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11944 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11945 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11947 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11948 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11949 enable, "enable#disable");
11951 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11952 .f = cmd_set_sym_hash_per_port_parsed,
11954 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11956 (void *)&cmd_set_sym_hash_ena_per_port_all,
11957 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11958 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11963 /* Get global config of hash function */
11964 struct cmd_get_hash_global_config_result {
11965 cmdline_fixed_string_t get_hash_global_config;
11970 flowtype_to_str(uint16_t ftype)
11976 } ftype_table[] = {
11977 {"ipv4", RTE_ETH_FLOW_IPV4},
11978 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11979 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11980 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11981 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11982 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11983 {"ipv6", RTE_ETH_FLOW_IPV6},
11984 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11985 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11986 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11987 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11988 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11989 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11990 {"port", RTE_ETH_FLOW_PORT},
11991 {"vxlan", RTE_ETH_FLOW_VXLAN},
11992 {"geneve", RTE_ETH_FLOW_GENEVE},
11993 {"nvgre", RTE_ETH_FLOW_NVGRE},
11994 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
11997 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11998 if (ftype_table[i].ftype == ftype)
11999 return ftype_table[i].str;
12006 cmd_get_hash_global_config_parsed(void *parsed_result,
12007 __rte_unused struct cmdline *cl,
12008 __rte_unused void *data)
12010 struct cmd_get_hash_global_config_result *res = parsed_result;
12011 struct rte_eth_hash_filter_info info;
12012 uint32_t idx, offset;
12017 if (rte_eth_dev_filter_supported(res->port_id,
12018 RTE_ETH_FILTER_HASH) < 0) {
12019 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12024 memset(&info, 0, sizeof(info));
12025 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12026 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12027 RTE_ETH_FILTER_GET, &info);
12029 printf("Cannot get hash global configurations by port %d\n",
12034 switch (info.info.global_conf.hash_func) {
12035 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12036 printf("Hash function is Toeplitz\n");
12038 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12039 printf("Hash function is Simple XOR\n");
12042 printf("Unknown hash function\n");
12046 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12047 idx = i / UINT64_BIT;
12048 offset = i % UINT64_BIT;
12049 if (!(info.info.global_conf.valid_bit_mask[idx] &
12052 str = flowtype_to_str(i);
12055 printf("Symmetric hash is %s globally for flow type %s "
12057 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12058 (1ULL << offset)) ? "enabled" : "disabled"), str,
12063 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12064 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12065 get_hash_global_config, "get_hash_global_config");
12066 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12067 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12070 cmdline_parse_inst_t cmd_get_hash_global_config = {
12071 .f = cmd_get_hash_global_config_parsed,
12073 .help_str = "get_hash_global_config <port_id>",
12075 (void *)&cmd_get_hash_global_config_all,
12076 (void *)&cmd_get_hash_global_config_port_id,
12081 /* Set global config of hash function */
12082 struct cmd_set_hash_global_config_result {
12083 cmdline_fixed_string_t set_hash_global_config;
12085 cmdline_fixed_string_t hash_func;
12086 cmdline_fixed_string_t flow_type;
12087 cmdline_fixed_string_t enable;
12091 cmd_set_hash_global_config_parsed(void *parsed_result,
12092 __rte_unused struct cmdline *cl,
12093 __rte_unused void *data)
12095 struct cmd_set_hash_global_config_result *res = parsed_result;
12096 struct rte_eth_hash_filter_info info;
12097 uint32_t ftype, idx, offset;
12100 if (rte_eth_dev_filter_supported(res->port_id,
12101 RTE_ETH_FILTER_HASH) < 0) {
12102 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12106 memset(&info, 0, sizeof(info));
12107 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12108 if (!strcmp(res->hash_func, "toeplitz"))
12109 info.info.global_conf.hash_func =
12110 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12111 else if (!strcmp(res->hash_func, "simple_xor"))
12112 info.info.global_conf.hash_func =
12113 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12114 else if (!strcmp(res->hash_func, "default"))
12115 info.info.global_conf.hash_func =
12116 RTE_ETH_HASH_FUNCTION_DEFAULT;
12118 ftype = str2flowtype(res->flow_type);
12119 idx = ftype / UINT64_BIT;
12120 offset = ftype % UINT64_BIT;
12121 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12122 if (!strcmp(res->enable, "enable"))
12123 info.info.global_conf.sym_hash_enable_mask[idx] |=
12125 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12126 RTE_ETH_FILTER_SET, &info);
12128 printf("Cannot set global hash configurations by port %d\n",
12131 printf("Global hash configurations have been set "
12132 "successfully by port %d\n", res->port_id);
12135 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12136 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12137 set_hash_global_config, "set_hash_global_config");
12138 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12139 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12141 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12142 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12143 hash_func, "toeplitz#simple_xor#default");
12144 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12145 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12147 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12148 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12149 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12150 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12151 enable, "enable#disable");
12153 cmdline_parse_inst_t cmd_set_hash_global_config = {
12154 .f = cmd_set_hash_global_config_parsed,
12156 .help_str = "set_hash_global_config <port_id> "
12157 "toeplitz|simple_xor|default "
12158 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12159 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12160 "l2_payload enable|disable",
12162 (void *)&cmd_set_hash_global_config_all,
12163 (void *)&cmd_set_hash_global_config_port_id,
12164 (void *)&cmd_set_hash_global_config_hash_func,
12165 (void *)&cmd_set_hash_global_config_flow_type,
12166 (void *)&cmd_set_hash_global_config_enable,
12171 /* Set hash input set */
12172 struct cmd_set_hash_input_set_result {
12173 cmdline_fixed_string_t set_hash_input_set;
12175 cmdline_fixed_string_t flow_type;
12176 cmdline_fixed_string_t inset_field;
12177 cmdline_fixed_string_t select;
12180 static enum rte_eth_input_set_field
12181 str2inset(char *string)
12185 static const struct {
12187 enum rte_eth_input_set_field inset;
12188 } inset_table[] = {
12189 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12190 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12191 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12192 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12193 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12194 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12195 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12196 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12197 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12198 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12199 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12200 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12201 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12202 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12203 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12204 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12205 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12206 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12207 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12208 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12209 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12210 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12211 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12212 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12213 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12214 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12215 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12216 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12217 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12218 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12219 {"none", RTE_ETH_INPUT_SET_NONE},
12222 for (i = 0; i < RTE_DIM(inset_table); i++) {
12223 if (!strcmp(string, inset_table[i].str))
12224 return inset_table[i].inset;
12227 return RTE_ETH_INPUT_SET_UNKNOWN;
12231 cmd_set_hash_input_set_parsed(void *parsed_result,
12232 __rte_unused struct cmdline *cl,
12233 __rte_unused void *data)
12235 struct cmd_set_hash_input_set_result *res = parsed_result;
12236 struct rte_eth_hash_filter_info info;
12238 memset(&info, 0, sizeof(info));
12239 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12240 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12241 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12242 info.info.input_set_conf.inset_size = 1;
12243 if (!strcmp(res->select, "select"))
12244 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12245 else if (!strcmp(res->select, "add"))
12246 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12247 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12248 RTE_ETH_FILTER_SET, &info);
12251 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12252 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12253 set_hash_input_set, "set_hash_input_set");
12254 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12255 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12257 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12258 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12260 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12261 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12263 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12264 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12265 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12266 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12267 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12269 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12270 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12271 select, "select#add");
12273 cmdline_parse_inst_t cmd_set_hash_input_set = {
12274 .f = cmd_set_hash_input_set_parsed,
12276 .help_str = "set_hash_input_set <port_id> "
12277 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12278 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12279 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12280 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12281 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12282 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12283 "fld-7th|fld-8th|none select|add",
12285 (void *)&cmd_set_hash_input_set_cmd,
12286 (void *)&cmd_set_hash_input_set_port_id,
12287 (void *)&cmd_set_hash_input_set_flow_type,
12288 (void *)&cmd_set_hash_input_set_field,
12289 (void *)&cmd_set_hash_input_set_select,
12294 /* Set flow director input set */
12295 struct cmd_set_fdir_input_set_result {
12296 cmdline_fixed_string_t set_fdir_input_set;
12298 cmdline_fixed_string_t flow_type;
12299 cmdline_fixed_string_t inset_field;
12300 cmdline_fixed_string_t select;
12304 cmd_set_fdir_input_set_parsed(void *parsed_result,
12305 __rte_unused struct cmdline *cl,
12306 __rte_unused void *data)
12308 struct cmd_set_fdir_input_set_result *res = parsed_result;
12309 struct rte_eth_fdir_filter_info info;
12311 memset(&info, 0, sizeof(info));
12312 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12313 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12314 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12315 info.info.input_set_conf.inset_size = 1;
12316 if (!strcmp(res->select, "select"))
12317 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12318 else if (!strcmp(res->select, "add"))
12319 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12320 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12321 RTE_ETH_FILTER_SET, &info);
12324 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12325 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12326 set_fdir_input_set, "set_fdir_input_set");
12327 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12328 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12330 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12331 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12333 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12334 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12335 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12336 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12338 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12339 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12340 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12341 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12342 "sctp-veri-tag#none");
12343 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12344 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12345 select, "select#add");
12347 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12348 .f = cmd_set_fdir_input_set_parsed,
12350 .help_str = "set_fdir_input_set <port_id> "
12351 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12352 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12353 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12354 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12355 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12356 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12357 "sctp-veri-tag|none select|add",
12359 (void *)&cmd_set_fdir_input_set_cmd,
12360 (void *)&cmd_set_fdir_input_set_port_id,
12361 (void *)&cmd_set_fdir_input_set_flow_type,
12362 (void *)&cmd_set_fdir_input_set_field,
12363 (void *)&cmd_set_fdir_input_set_select,
12368 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12369 struct cmd_mcast_addr_result {
12370 cmdline_fixed_string_t mcast_addr_cmd;
12371 cmdline_fixed_string_t what;
12373 struct ether_addr mc_addr;
12376 static void cmd_mcast_addr_parsed(void *parsed_result,
12377 __attribute__((unused)) struct cmdline *cl,
12378 __attribute__((unused)) void *data)
12380 struct cmd_mcast_addr_result *res = parsed_result;
12382 if (!is_multicast_ether_addr(&res->mc_addr)) {
12383 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12384 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12385 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12386 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12389 if (strcmp(res->what, "add") == 0)
12390 mcast_addr_add(res->port_num, &res->mc_addr);
12392 mcast_addr_remove(res->port_num, &res->mc_addr);
12395 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12396 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12397 mcast_addr_cmd, "mcast_addr");
12398 cmdline_parse_token_string_t cmd_mcast_addr_what =
12399 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12401 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12402 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12403 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12404 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12406 cmdline_parse_inst_t cmd_mcast_addr = {
12407 .f = cmd_mcast_addr_parsed,
12409 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12410 "Add/Remove multicast MAC address on port_id",
12412 (void *)&cmd_mcast_addr_cmd,
12413 (void *)&cmd_mcast_addr_what,
12414 (void *)&cmd_mcast_addr_portnum,
12415 (void *)&cmd_mcast_addr_addr,
12420 /* l2 tunnel config
12421 * only support E-tag now.
12424 /* Ether type config */
12425 struct cmd_config_l2_tunnel_eth_type_result {
12426 cmdline_fixed_string_t port;
12427 cmdline_fixed_string_t config;
12428 cmdline_fixed_string_t all;
12430 cmdline_fixed_string_t l2_tunnel;
12431 cmdline_fixed_string_t l2_tunnel_type;
12432 cmdline_fixed_string_t eth_type;
12433 uint16_t eth_type_val;
12436 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12437 TOKEN_STRING_INITIALIZER
12438 (struct cmd_config_l2_tunnel_eth_type_result,
12440 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12441 TOKEN_STRING_INITIALIZER
12442 (struct cmd_config_l2_tunnel_eth_type_result,
12444 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12445 TOKEN_STRING_INITIALIZER
12446 (struct cmd_config_l2_tunnel_eth_type_result,
12448 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12449 TOKEN_NUM_INITIALIZER
12450 (struct cmd_config_l2_tunnel_eth_type_result,
12452 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12453 TOKEN_STRING_INITIALIZER
12454 (struct cmd_config_l2_tunnel_eth_type_result,
12455 l2_tunnel, "l2-tunnel");
12456 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12457 TOKEN_STRING_INITIALIZER
12458 (struct cmd_config_l2_tunnel_eth_type_result,
12459 l2_tunnel_type, "E-tag");
12460 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12461 TOKEN_STRING_INITIALIZER
12462 (struct cmd_config_l2_tunnel_eth_type_result,
12463 eth_type, "ether-type");
12464 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12465 TOKEN_NUM_INITIALIZER
12466 (struct cmd_config_l2_tunnel_eth_type_result,
12467 eth_type_val, UINT16);
12469 static enum rte_eth_tunnel_type
12470 str2fdir_l2_tunnel_type(char *string)
12474 static const struct {
12476 enum rte_eth_tunnel_type type;
12477 } l2_tunnel_type_str[] = {
12478 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12481 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12482 if (!strcmp(l2_tunnel_type_str[i].str, string))
12483 return l2_tunnel_type_str[i].type;
12485 return RTE_TUNNEL_TYPE_NONE;
12488 /* ether type config for all ports */
12490 cmd_config_l2_tunnel_eth_type_all_parsed
12491 (void *parsed_result,
12492 __attribute__((unused)) struct cmdline *cl,
12493 __attribute__((unused)) void *data)
12495 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12496 struct rte_eth_l2_tunnel_conf entry;
12499 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12500 entry.ether_type = res->eth_type_val;
12502 RTE_ETH_FOREACH_DEV(pid) {
12503 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12507 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12508 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12510 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12512 (void *)&cmd_config_l2_tunnel_eth_type_port,
12513 (void *)&cmd_config_l2_tunnel_eth_type_config,
12514 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12515 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12516 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12517 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12518 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12523 /* ether type config for a specific port */
12525 cmd_config_l2_tunnel_eth_type_specific_parsed(
12526 void *parsed_result,
12527 __attribute__((unused)) struct cmdline *cl,
12528 __attribute__((unused)) void *data)
12530 struct cmd_config_l2_tunnel_eth_type_result *res =
12532 struct rte_eth_l2_tunnel_conf entry;
12534 if (port_id_is_invalid(res->id, ENABLED_WARN))
12537 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12538 entry.ether_type = res->eth_type_val;
12540 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12543 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12544 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12546 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12548 (void *)&cmd_config_l2_tunnel_eth_type_port,
12549 (void *)&cmd_config_l2_tunnel_eth_type_config,
12550 (void *)&cmd_config_l2_tunnel_eth_type_id,
12551 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12552 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12553 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12554 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12559 /* Enable/disable l2 tunnel */
12560 struct cmd_config_l2_tunnel_en_dis_result {
12561 cmdline_fixed_string_t port;
12562 cmdline_fixed_string_t config;
12563 cmdline_fixed_string_t all;
12565 cmdline_fixed_string_t l2_tunnel;
12566 cmdline_fixed_string_t l2_tunnel_type;
12567 cmdline_fixed_string_t en_dis;
12570 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12571 TOKEN_STRING_INITIALIZER
12572 (struct cmd_config_l2_tunnel_en_dis_result,
12574 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12575 TOKEN_STRING_INITIALIZER
12576 (struct cmd_config_l2_tunnel_en_dis_result,
12578 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12579 TOKEN_STRING_INITIALIZER
12580 (struct cmd_config_l2_tunnel_en_dis_result,
12582 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12583 TOKEN_NUM_INITIALIZER
12584 (struct cmd_config_l2_tunnel_en_dis_result,
12586 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12587 TOKEN_STRING_INITIALIZER
12588 (struct cmd_config_l2_tunnel_en_dis_result,
12589 l2_tunnel, "l2-tunnel");
12590 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12591 TOKEN_STRING_INITIALIZER
12592 (struct cmd_config_l2_tunnel_en_dis_result,
12593 l2_tunnel_type, "E-tag");
12594 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12595 TOKEN_STRING_INITIALIZER
12596 (struct cmd_config_l2_tunnel_en_dis_result,
12597 en_dis, "enable#disable");
12599 /* enable/disable l2 tunnel for all ports */
12601 cmd_config_l2_tunnel_en_dis_all_parsed(
12602 void *parsed_result,
12603 __attribute__((unused)) struct cmdline *cl,
12604 __attribute__((unused)) void *data)
12606 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12607 struct rte_eth_l2_tunnel_conf entry;
12611 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12613 if (!strcmp("enable", res->en_dis))
12618 RTE_ETH_FOREACH_DEV(pid) {
12619 rte_eth_dev_l2_tunnel_offload_set(pid,
12621 ETH_L2_TUNNEL_ENABLE_MASK,
12626 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12627 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12629 .help_str = "port config all l2-tunnel E-tag enable|disable",
12631 (void *)&cmd_config_l2_tunnel_en_dis_port,
12632 (void *)&cmd_config_l2_tunnel_en_dis_config,
12633 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12634 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12635 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12636 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12641 /* enable/disable l2 tunnel for a port */
12643 cmd_config_l2_tunnel_en_dis_specific_parsed(
12644 void *parsed_result,
12645 __attribute__((unused)) struct cmdline *cl,
12646 __attribute__((unused)) void *data)
12648 struct cmd_config_l2_tunnel_en_dis_result *res =
12650 struct rte_eth_l2_tunnel_conf entry;
12652 if (port_id_is_invalid(res->id, ENABLED_WARN))
12655 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12657 if (!strcmp("enable", res->en_dis))
12658 rte_eth_dev_l2_tunnel_offload_set(res->id,
12660 ETH_L2_TUNNEL_ENABLE_MASK,
12663 rte_eth_dev_l2_tunnel_offload_set(res->id,
12665 ETH_L2_TUNNEL_ENABLE_MASK,
12669 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12670 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12672 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12674 (void *)&cmd_config_l2_tunnel_en_dis_port,
12675 (void *)&cmd_config_l2_tunnel_en_dis_config,
12676 (void *)&cmd_config_l2_tunnel_en_dis_id,
12677 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12678 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12679 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12684 /* E-tag configuration */
12686 /* Common result structure for all E-tag configuration */
12687 struct cmd_config_e_tag_result {
12688 cmdline_fixed_string_t e_tag;
12689 cmdline_fixed_string_t set;
12690 cmdline_fixed_string_t insertion;
12691 cmdline_fixed_string_t stripping;
12692 cmdline_fixed_string_t forwarding;
12693 cmdline_fixed_string_t filter;
12694 cmdline_fixed_string_t add;
12695 cmdline_fixed_string_t del;
12696 cmdline_fixed_string_t on;
12697 cmdline_fixed_string_t off;
12698 cmdline_fixed_string_t on_off;
12699 cmdline_fixed_string_t port_tag_id;
12700 uint32_t port_tag_id_val;
12701 cmdline_fixed_string_t e_tag_id;
12702 uint16_t e_tag_id_val;
12703 cmdline_fixed_string_t dst_pool;
12704 uint8_t dst_pool_val;
12705 cmdline_fixed_string_t port;
12707 cmdline_fixed_string_t vf;
12711 /* Common CLI fields for all E-tag configuration */
12712 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12713 TOKEN_STRING_INITIALIZER
12714 (struct cmd_config_e_tag_result,
12716 cmdline_parse_token_string_t cmd_config_e_tag_set =
12717 TOKEN_STRING_INITIALIZER
12718 (struct cmd_config_e_tag_result,
12720 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12721 TOKEN_STRING_INITIALIZER
12722 (struct cmd_config_e_tag_result,
12723 insertion, "insertion");
12724 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12725 TOKEN_STRING_INITIALIZER
12726 (struct cmd_config_e_tag_result,
12727 stripping, "stripping");
12728 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12729 TOKEN_STRING_INITIALIZER
12730 (struct cmd_config_e_tag_result,
12731 forwarding, "forwarding");
12732 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12733 TOKEN_STRING_INITIALIZER
12734 (struct cmd_config_e_tag_result,
12736 cmdline_parse_token_string_t cmd_config_e_tag_add =
12737 TOKEN_STRING_INITIALIZER
12738 (struct cmd_config_e_tag_result,
12740 cmdline_parse_token_string_t cmd_config_e_tag_del =
12741 TOKEN_STRING_INITIALIZER
12742 (struct cmd_config_e_tag_result,
12744 cmdline_parse_token_string_t cmd_config_e_tag_on =
12745 TOKEN_STRING_INITIALIZER
12746 (struct cmd_config_e_tag_result,
12748 cmdline_parse_token_string_t cmd_config_e_tag_off =
12749 TOKEN_STRING_INITIALIZER
12750 (struct cmd_config_e_tag_result,
12752 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12753 TOKEN_STRING_INITIALIZER
12754 (struct cmd_config_e_tag_result,
12756 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12757 TOKEN_STRING_INITIALIZER
12758 (struct cmd_config_e_tag_result,
12759 port_tag_id, "port-tag-id");
12760 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12761 TOKEN_NUM_INITIALIZER
12762 (struct cmd_config_e_tag_result,
12763 port_tag_id_val, UINT32);
12764 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12765 TOKEN_STRING_INITIALIZER
12766 (struct cmd_config_e_tag_result,
12767 e_tag_id, "e-tag-id");
12768 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12769 TOKEN_NUM_INITIALIZER
12770 (struct cmd_config_e_tag_result,
12771 e_tag_id_val, UINT16);
12772 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12773 TOKEN_STRING_INITIALIZER
12774 (struct cmd_config_e_tag_result,
12775 dst_pool, "dst-pool");
12776 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12777 TOKEN_NUM_INITIALIZER
12778 (struct cmd_config_e_tag_result,
12779 dst_pool_val, UINT8);
12780 cmdline_parse_token_string_t cmd_config_e_tag_port =
12781 TOKEN_STRING_INITIALIZER
12782 (struct cmd_config_e_tag_result,
12784 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12785 TOKEN_NUM_INITIALIZER
12786 (struct cmd_config_e_tag_result,
12788 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12789 TOKEN_STRING_INITIALIZER
12790 (struct cmd_config_e_tag_result,
12792 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12793 TOKEN_NUM_INITIALIZER
12794 (struct cmd_config_e_tag_result,
12797 /* E-tag insertion configuration */
12799 cmd_config_e_tag_insertion_en_parsed(
12800 void *parsed_result,
12801 __attribute__((unused)) struct cmdline *cl,
12802 __attribute__((unused)) void *data)
12804 struct cmd_config_e_tag_result *res =
12806 struct rte_eth_l2_tunnel_conf entry;
12808 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12811 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12812 entry.tunnel_id = res->port_tag_id_val;
12813 entry.vf_id = res->vf_id;
12814 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12816 ETH_L2_TUNNEL_INSERTION_MASK,
12821 cmd_config_e_tag_insertion_dis_parsed(
12822 void *parsed_result,
12823 __attribute__((unused)) struct cmdline *cl,
12824 __attribute__((unused)) void *data)
12826 struct cmd_config_e_tag_result *res =
12828 struct rte_eth_l2_tunnel_conf entry;
12830 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12833 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12834 entry.vf_id = res->vf_id;
12836 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12838 ETH_L2_TUNNEL_INSERTION_MASK,
12842 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12843 .f = cmd_config_e_tag_insertion_en_parsed,
12845 .help_str = "E-tag ... : E-tag insertion enable",
12847 (void *)&cmd_config_e_tag_e_tag,
12848 (void *)&cmd_config_e_tag_set,
12849 (void *)&cmd_config_e_tag_insertion,
12850 (void *)&cmd_config_e_tag_on,
12851 (void *)&cmd_config_e_tag_port_tag_id,
12852 (void *)&cmd_config_e_tag_port_tag_id_val,
12853 (void *)&cmd_config_e_tag_port,
12854 (void *)&cmd_config_e_tag_port_id,
12855 (void *)&cmd_config_e_tag_vf,
12856 (void *)&cmd_config_e_tag_vf_id,
12861 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12862 .f = cmd_config_e_tag_insertion_dis_parsed,
12864 .help_str = "E-tag ... : E-tag insertion disable",
12866 (void *)&cmd_config_e_tag_e_tag,
12867 (void *)&cmd_config_e_tag_set,
12868 (void *)&cmd_config_e_tag_insertion,
12869 (void *)&cmd_config_e_tag_off,
12870 (void *)&cmd_config_e_tag_port,
12871 (void *)&cmd_config_e_tag_port_id,
12872 (void *)&cmd_config_e_tag_vf,
12873 (void *)&cmd_config_e_tag_vf_id,
12878 /* E-tag stripping configuration */
12880 cmd_config_e_tag_stripping_parsed(
12881 void *parsed_result,
12882 __attribute__((unused)) struct cmdline *cl,
12883 __attribute__((unused)) void *data)
12885 struct cmd_config_e_tag_result *res =
12887 struct rte_eth_l2_tunnel_conf entry;
12889 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12892 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12894 if (!strcmp(res->on_off, "on"))
12895 rte_eth_dev_l2_tunnel_offload_set
12898 ETH_L2_TUNNEL_STRIPPING_MASK,
12901 rte_eth_dev_l2_tunnel_offload_set
12904 ETH_L2_TUNNEL_STRIPPING_MASK,
12908 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12909 .f = cmd_config_e_tag_stripping_parsed,
12911 .help_str = "E-tag ... : E-tag stripping enable/disable",
12913 (void *)&cmd_config_e_tag_e_tag,
12914 (void *)&cmd_config_e_tag_set,
12915 (void *)&cmd_config_e_tag_stripping,
12916 (void *)&cmd_config_e_tag_on_off,
12917 (void *)&cmd_config_e_tag_port,
12918 (void *)&cmd_config_e_tag_port_id,
12923 /* E-tag forwarding configuration */
12925 cmd_config_e_tag_forwarding_parsed(
12926 void *parsed_result,
12927 __attribute__((unused)) struct cmdline *cl,
12928 __attribute__((unused)) void *data)
12930 struct cmd_config_e_tag_result *res = parsed_result;
12931 struct rte_eth_l2_tunnel_conf entry;
12933 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12936 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12938 if (!strcmp(res->on_off, "on"))
12939 rte_eth_dev_l2_tunnel_offload_set
12942 ETH_L2_TUNNEL_FORWARDING_MASK,
12945 rte_eth_dev_l2_tunnel_offload_set
12948 ETH_L2_TUNNEL_FORWARDING_MASK,
12952 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12953 .f = cmd_config_e_tag_forwarding_parsed,
12955 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12957 (void *)&cmd_config_e_tag_e_tag,
12958 (void *)&cmd_config_e_tag_set,
12959 (void *)&cmd_config_e_tag_forwarding,
12960 (void *)&cmd_config_e_tag_on_off,
12961 (void *)&cmd_config_e_tag_port,
12962 (void *)&cmd_config_e_tag_port_id,
12967 /* E-tag filter configuration */
12969 cmd_config_e_tag_filter_add_parsed(
12970 void *parsed_result,
12971 __attribute__((unused)) struct cmdline *cl,
12972 __attribute__((unused)) void *data)
12974 struct cmd_config_e_tag_result *res = parsed_result;
12975 struct rte_eth_l2_tunnel_conf entry;
12978 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12981 if (res->e_tag_id_val > 0x3fff) {
12982 printf("e-tag-id must be equal or less than 0x3fff.\n");
12986 ret = rte_eth_dev_filter_supported(res->port_id,
12987 RTE_ETH_FILTER_L2_TUNNEL);
12989 printf("E-tag filter is not supported on port %u.\n",
12994 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12995 entry.tunnel_id = res->e_tag_id_val;
12996 entry.pool = res->dst_pool_val;
12998 ret = rte_eth_dev_filter_ctrl(res->port_id,
12999 RTE_ETH_FILTER_L2_TUNNEL,
13000 RTE_ETH_FILTER_ADD,
13003 printf("E-tag filter programming error: (%s)\n",
13007 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13008 .f = cmd_config_e_tag_filter_add_parsed,
13010 .help_str = "E-tag ... : E-tag filter add",
13012 (void *)&cmd_config_e_tag_e_tag,
13013 (void *)&cmd_config_e_tag_set,
13014 (void *)&cmd_config_e_tag_filter,
13015 (void *)&cmd_config_e_tag_add,
13016 (void *)&cmd_config_e_tag_e_tag_id,
13017 (void *)&cmd_config_e_tag_e_tag_id_val,
13018 (void *)&cmd_config_e_tag_dst_pool,
13019 (void *)&cmd_config_e_tag_dst_pool_val,
13020 (void *)&cmd_config_e_tag_port,
13021 (void *)&cmd_config_e_tag_port_id,
13027 cmd_config_e_tag_filter_del_parsed(
13028 void *parsed_result,
13029 __attribute__((unused)) struct cmdline *cl,
13030 __attribute__((unused)) void *data)
13032 struct cmd_config_e_tag_result *res = parsed_result;
13033 struct rte_eth_l2_tunnel_conf entry;
13036 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13039 if (res->e_tag_id_val > 0x3fff) {
13040 printf("e-tag-id must be less than 0x3fff.\n");
13044 ret = rte_eth_dev_filter_supported(res->port_id,
13045 RTE_ETH_FILTER_L2_TUNNEL);
13047 printf("E-tag filter is not supported on port %u.\n",
13052 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13053 entry.tunnel_id = res->e_tag_id_val;
13055 ret = rte_eth_dev_filter_ctrl(res->port_id,
13056 RTE_ETH_FILTER_L2_TUNNEL,
13057 RTE_ETH_FILTER_DELETE,
13060 printf("E-tag filter programming error: (%s)\n",
13064 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13065 .f = cmd_config_e_tag_filter_del_parsed,
13067 .help_str = "E-tag ... : E-tag filter delete",
13069 (void *)&cmd_config_e_tag_e_tag,
13070 (void *)&cmd_config_e_tag_set,
13071 (void *)&cmd_config_e_tag_filter,
13072 (void *)&cmd_config_e_tag_del,
13073 (void *)&cmd_config_e_tag_e_tag_id,
13074 (void *)&cmd_config_e_tag_e_tag_id_val,
13075 (void *)&cmd_config_e_tag_port,
13076 (void *)&cmd_config_e_tag_port_id,
13081 /* vf vlan anti spoof configuration */
13083 /* Common result structure for vf vlan anti spoof */
13084 struct cmd_vf_vlan_anti_spoof_result {
13085 cmdline_fixed_string_t set;
13086 cmdline_fixed_string_t vf;
13087 cmdline_fixed_string_t vlan;
13088 cmdline_fixed_string_t antispoof;
13091 cmdline_fixed_string_t on_off;
13094 /* Common CLI fields for vf vlan anti spoof enable disable */
13095 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13096 TOKEN_STRING_INITIALIZER
13097 (struct cmd_vf_vlan_anti_spoof_result,
13099 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13100 TOKEN_STRING_INITIALIZER
13101 (struct cmd_vf_vlan_anti_spoof_result,
13103 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13104 TOKEN_STRING_INITIALIZER
13105 (struct cmd_vf_vlan_anti_spoof_result,
13107 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13108 TOKEN_STRING_INITIALIZER
13109 (struct cmd_vf_vlan_anti_spoof_result,
13110 antispoof, "antispoof");
13111 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13112 TOKEN_NUM_INITIALIZER
13113 (struct cmd_vf_vlan_anti_spoof_result,
13115 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13116 TOKEN_NUM_INITIALIZER
13117 (struct cmd_vf_vlan_anti_spoof_result,
13119 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13120 TOKEN_STRING_INITIALIZER
13121 (struct cmd_vf_vlan_anti_spoof_result,
13125 cmd_set_vf_vlan_anti_spoof_parsed(
13126 void *parsed_result,
13127 __attribute__((unused)) struct cmdline *cl,
13128 __attribute__((unused)) void *data)
13130 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13131 int ret = -ENOTSUP;
13133 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13135 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13138 #ifdef RTE_LIBRTE_IXGBE_PMD
13139 if (ret == -ENOTSUP)
13140 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13141 res->vf_id, is_on);
13143 #ifdef RTE_LIBRTE_I40E_PMD
13144 if (ret == -ENOTSUP)
13145 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13146 res->vf_id, is_on);
13148 #ifdef RTE_LIBRTE_BNXT_PMD
13149 if (ret == -ENOTSUP)
13150 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13151 res->vf_id, is_on);
13158 printf("invalid vf_id %d\n", res->vf_id);
13161 printf("invalid port_id %d\n", res->port_id);
13164 printf("function not implemented\n");
13167 printf("programming error: (%s)\n", strerror(-ret));
13171 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13172 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13174 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13176 (void *)&cmd_vf_vlan_anti_spoof_set,
13177 (void *)&cmd_vf_vlan_anti_spoof_vf,
13178 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13179 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13180 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13181 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13182 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13187 /* vf mac anti spoof configuration */
13189 /* Common result structure for vf mac anti spoof */
13190 struct cmd_vf_mac_anti_spoof_result {
13191 cmdline_fixed_string_t set;
13192 cmdline_fixed_string_t vf;
13193 cmdline_fixed_string_t mac;
13194 cmdline_fixed_string_t antispoof;
13197 cmdline_fixed_string_t on_off;
13200 /* Common CLI fields for vf mac anti spoof enable disable */
13201 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13202 TOKEN_STRING_INITIALIZER
13203 (struct cmd_vf_mac_anti_spoof_result,
13205 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13206 TOKEN_STRING_INITIALIZER
13207 (struct cmd_vf_mac_anti_spoof_result,
13209 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13210 TOKEN_STRING_INITIALIZER
13211 (struct cmd_vf_mac_anti_spoof_result,
13213 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13214 TOKEN_STRING_INITIALIZER
13215 (struct cmd_vf_mac_anti_spoof_result,
13216 antispoof, "antispoof");
13217 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13218 TOKEN_NUM_INITIALIZER
13219 (struct cmd_vf_mac_anti_spoof_result,
13221 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13222 TOKEN_NUM_INITIALIZER
13223 (struct cmd_vf_mac_anti_spoof_result,
13225 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13226 TOKEN_STRING_INITIALIZER
13227 (struct cmd_vf_mac_anti_spoof_result,
13231 cmd_set_vf_mac_anti_spoof_parsed(
13232 void *parsed_result,
13233 __attribute__((unused)) struct cmdline *cl,
13234 __attribute__((unused)) void *data)
13236 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13237 int ret = -ENOTSUP;
13239 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13241 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13244 #ifdef RTE_LIBRTE_IXGBE_PMD
13245 if (ret == -ENOTSUP)
13246 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13247 res->vf_id, is_on);
13249 #ifdef RTE_LIBRTE_I40E_PMD
13250 if (ret == -ENOTSUP)
13251 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13252 res->vf_id, is_on);
13254 #ifdef RTE_LIBRTE_BNXT_PMD
13255 if (ret == -ENOTSUP)
13256 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13257 res->vf_id, is_on);
13264 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13267 printf("invalid port_id %d\n", res->port_id);
13270 printf("function not implemented\n");
13273 printf("programming error: (%s)\n", strerror(-ret));
13277 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13278 .f = cmd_set_vf_mac_anti_spoof_parsed,
13280 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13282 (void *)&cmd_vf_mac_anti_spoof_set,
13283 (void *)&cmd_vf_mac_anti_spoof_vf,
13284 (void *)&cmd_vf_mac_anti_spoof_mac,
13285 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13286 (void *)&cmd_vf_mac_anti_spoof_port_id,
13287 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13288 (void *)&cmd_vf_mac_anti_spoof_on_off,
13293 /* vf vlan strip queue configuration */
13295 /* Common result structure for vf mac anti spoof */
13296 struct cmd_vf_vlan_stripq_result {
13297 cmdline_fixed_string_t set;
13298 cmdline_fixed_string_t vf;
13299 cmdline_fixed_string_t vlan;
13300 cmdline_fixed_string_t stripq;
13303 cmdline_fixed_string_t on_off;
13306 /* Common CLI fields for vf vlan strip enable disable */
13307 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13308 TOKEN_STRING_INITIALIZER
13309 (struct cmd_vf_vlan_stripq_result,
13311 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13312 TOKEN_STRING_INITIALIZER
13313 (struct cmd_vf_vlan_stripq_result,
13315 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13316 TOKEN_STRING_INITIALIZER
13317 (struct cmd_vf_vlan_stripq_result,
13319 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13320 TOKEN_STRING_INITIALIZER
13321 (struct cmd_vf_vlan_stripq_result,
13323 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13324 TOKEN_NUM_INITIALIZER
13325 (struct cmd_vf_vlan_stripq_result,
13327 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13328 TOKEN_NUM_INITIALIZER
13329 (struct cmd_vf_vlan_stripq_result,
13331 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13332 TOKEN_STRING_INITIALIZER
13333 (struct cmd_vf_vlan_stripq_result,
13337 cmd_set_vf_vlan_stripq_parsed(
13338 void *parsed_result,
13339 __attribute__((unused)) struct cmdline *cl,
13340 __attribute__((unused)) void *data)
13342 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13343 int ret = -ENOTSUP;
13345 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13347 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13350 #ifdef RTE_LIBRTE_IXGBE_PMD
13351 if (ret == -ENOTSUP)
13352 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13353 res->vf_id, is_on);
13355 #ifdef RTE_LIBRTE_I40E_PMD
13356 if (ret == -ENOTSUP)
13357 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13358 res->vf_id, is_on);
13360 #ifdef RTE_LIBRTE_BNXT_PMD
13361 if (ret == -ENOTSUP)
13362 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13363 res->vf_id, is_on);
13370 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13373 printf("invalid port_id %d\n", res->port_id);
13376 printf("function not implemented\n");
13379 printf("programming error: (%s)\n", strerror(-ret));
13383 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13384 .f = cmd_set_vf_vlan_stripq_parsed,
13386 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13388 (void *)&cmd_vf_vlan_stripq_set,
13389 (void *)&cmd_vf_vlan_stripq_vf,
13390 (void *)&cmd_vf_vlan_stripq_vlan,
13391 (void *)&cmd_vf_vlan_stripq_stripq,
13392 (void *)&cmd_vf_vlan_stripq_port_id,
13393 (void *)&cmd_vf_vlan_stripq_vf_id,
13394 (void *)&cmd_vf_vlan_stripq_on_off,
13399 /* vf vlan insert configuration */
13401 /* Common result structure for vf vlan insert */
13402 struct cmd_vf_vlan_insert_result {
13403 cmdline_fixed_string_t set;
13404 cmdline_fixed_string_t vf;
13405 cmdline_fixed_string_t vlan;
13406 cmdline_fixed_string_t insert;
13412 /* Common CLI fields for vf vlan insert enable disable */
13413 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13414 TOKEN_STRING_INITIALIZER
13415 (struct cmd_vf_vlan_insert_result,
13417 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13418 TOKEN_STRING_INITIALIZER
13419 (struct cmd_vf_vlan_insert_result,
13421 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13422 TOKEN_STRING_INITIALIZER
13423 (struct cmd_vf_vlan_insert_result,
13425 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13426 TOKEN_STRING_INITIALIZER
13427 (struct cmd_vf_vlan_insert_result,
13429 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13430 TOKEN_NUM_INITIALIZER
13431 (struct cmd_vf_vlan_insert_result,
13433 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13434 TOKEN_NUM_INITIALIZER
13435 (struct cmd_vf_vlan_insert_result,
13437 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13438 TOKEN_NUM_INITIALIZER
13439 (struct cmd_vf_vlan_insert_result,
13443 cmd_set_vf_vlan_insert_parsed(
13444 void *parsed_result,
13445 __attribute__((unused)) struct cmdline *cl,
13446 __attribute__((unused)) void *data)
13448 struct cmd_vf_vlan_insert_result *res = parsed_result;
13449 int ret = -ENOTSUP;
13451 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13454 #ifdef RTE_LIBRTE_IXGBE_PMD
13455 if (ret == -ENOTSUP)
13456 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13459 #ifdef RTE_LIBRTE_I40E_PMD
13460 if (ret == -ENOTSUP)
13461 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13464 #ifdef RTE_LIBRTE_BNXT_PMD
13465 if (ret == -ENOTSUP)
13466 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13474 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13477 printf("invalid port_id %d\n", res->port_id);
13480 printf("function not implemented\n");
13483 printf("programming error: (%s)\n", strerror(-ret));
13487 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13488 .f = cmd_set_vf_vlan_insert_parsed,
13490 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13492 (void *)&cmd_vf_vlan_insert_set,
13493 (void *)&cmd_vf_vlan_insert_vf,
13494 (void *)&cmd_vf_vlan_insert_vlan,
13495 (void *)&cmd_vf_vlan_insert_insert,
13496 (void *)&cmd_vf_vlan_insert_port_id,
13497 (void *)&cmd_vf_vlan_insert_vf_id,
13498 (void *)&cmd_vf_vlan_insert_vlan_id,
13503 /* tx loopback configuration */
13505 /* Common result structure for tx loopback */
13506 struct cmd_tx_loopback_result {
13507 cmdline_fixed_string_t set;
13508 cmdline_fixed_string_t tx;
13509 cmdline_fixed_string_t loopback;
13511 cmdline_fixed_string_t on_off;
13514 /* Common CLI fields for tx loopback enable disable */
13515 cmdline_parse_token_string_t cmd_tx_loopback_set =
13516 TOKEN_STRING_INITIALIZER
13517 (struct cmd_tx_loopback_result,
13519 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13520 TOKEN_STRING_INITIALIZER
13521 (struct cmd_tx_loopback_result,
13523 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13524 TOKEN_STRING_INITIALIZER
13525 (struct cmd_tx_loopback_result,
13526 loopback, "loopback");
13527 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13528 TOKEN_NUM_INITIALIZER
13529 (struct cmd_tx_loopback_result,
13531 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13532 TOKEN_STRING_INITIALIZER
13533 (struct cmd_tx_loopback_result,
13537 cmd_set_tx_loopback_parsed(
13538 void *parsed_result,
13539 __attribute__((unused)) struct cmdline *cl,
13540 __attribute__((unused)) void *data)
13542 struct cmd_tx_loopback_result *res = parsed_result;
13543 int ret = -ENOTSUP;
13545 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13547 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13550 #ifdef RTE_LIBRTE_IXGBE_PMD
13551 if (ret == -ENOTSUP)
13552 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13554 #ifdef RTE_LIBRTE_I40E_PMD
13555 if (ret == -ENOTSUP)
13556 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13558 #ifdef RTE_LIBRTE_BNXT_PMD
13559 if (ret == -ENOTSUP)
13560 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13562 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13563 if (ret == -ENOTSUP)
13564 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13571 printf("invalid is_on %d\n", is_on);
13574 printf("invalid port_id %d\n", res->port_id);
13577 printf("function not implemented\n");
13580 printf("programming error: (%s)\n", strerror(-ret));
13584 cmdline_parse_inst_t cmd_set_tx_loopback = {
13585 .f = cmd_set_tx_loopback_parsed,
13587 .help_str = "set tx loopback <port_id> on|off",
13589 (void *)&cmd_tx_loopback_set,
13590 (void *)&cmd_tx_loopback_tx,
13591 (void *)&cmd_tx_loopback_loopback,
13592 (void *)&cmd_tx_loopback_port_id,
13593 (void *)&cmd_tx_loopback_on_off,
13598 /* all queues drop enable configuration */
13600 /* Common result structure for all queues drop enable */
13601 struct cmd_all_queues_drop_en_result {
13602 cmdline_fixed_string_t set;
13603 cmdline_fixed_string_t all;
13604 cmdline_fixed_string_t queues;
13605 cmdline_fixed_string_t drop;
13607 cmdline_fixed_string_t on_off;
13610 /* Common CLI fields for tx loopback enable disable */
13611 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13612 TOKEN_STRING_INITIALIZER
13613 (struct cmd_all_queues_drop_en_result,
13615 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13616 TOKEN_STRING_INITIALIZER
13617 (struct cmd_all_queues_drop_en_result,
13619 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13620 TOKEN_STRING_INITIALIZER
13621 (struct cmd_all_queues_drop_en_result,
13623 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13624 TOKEN_STRING_INITIALIZER
13625 (struct cmd_all_queues_drop_en_result,
13627 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13628 TOKEN_NUM_INITIALIZER
13629 (struct cmd_all_queues_drop_en_result,
13631 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13632 TOKEN_STRING_INITIALIZER
13633 (struct cmd_all_queues_drop_en_result,
13637 cmd_set_all_queues_drop_en_parsed(
13638 void *parsed_result,
13639 __attribute__((unused)) struct cmdline *cl,
13640 __attribute__((unused)) void *data)
13642 struct cmd_all_queues_drop_en_result *res = parsed_result;
13643 int ret = -ENOTSUP;
13644 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13646 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13649 #ifdef RTE_LIBRTE_IXGBE_PMD
13650 if (ret == -ENOTSUP)
13651 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13653 #ifdef RTE_LIBRTE_BNXT_PMD
13654 if (ret == -ENOTSUP)
13655 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13661 printf("invalid is_on %d\n", is_on);
13664 printf("invalid port_id %d\n", res->port_id);
13667 printf("function not implemented\n");
13670 printf("programming error: (%s)\n", strerror(-ret));
13674 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13675 .f = cmd_set_all_queues_drop_en_parsed,
13677 .help_str = "set all queues drop <port_id> on|off",
13679 (void *)&cmd_all_queues_drop_en_set,
13680 (void *)&cmd_all_queues_drop_en_all,
13681 (void *)&cmd_all_queues_drop_en_queues,
13682 (void *)&cmd_all_queues_drop_en_drop,
13683 (void *)&cmd_all_queues_drop_en_port_id,
13684 (void *)&cmd_all_queues_drop_en_on_off,
13689 /* vf split drop enable configuration */
13691 /* Common result structure for vf split drop enable */
13692 struct cmd_vf_split_drop_en_result {
13693 cmdline_fixed_string_t set;
13694 cmdline_fixed_string_t vf;
13695 cmdline_fixed_string_t split;
13696 cmdline_fixed_string_t drop;
13699 cmdline_fixed_string_t on_off;
13702 /* Common CLI fields for vf split drop enable disable */
13703 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13704 TOKEN_STRING_INITIALIZER
13705 (struct cmd_vf_split_drop_en_result,
13707 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13708 TOKEN_STRING_INITIALIZER
13709 (struct cmd_vf_split_drop_en_result,
13711 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13712 TOKEN_STRING_INITIALIZER
13713 (struct cmd_vf_split_drop_en_result,
13715 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13716 TOKEN_STRING_INITIALIZER
13717 (struct cmd_vf_split_drop_en_result,
13719 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13720 TOKEN_NUM_INITIALIZER
13721 (struct cmd_vf_split_drop_en_result,
13723 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13724 TOKEN_NUM_INITIALIZER
13725 (struct cmd_vf_split_drop_en_result,
13727 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13728 TOKEN_STRING_INITIALIZER
13729 (struct cmd_vf_split_drop_en_result,
13733 cmd_set_vf_split_drop_en_parsed(
13734 void *parsed_result,
13735 __attribute__((unused)) struct cmdline *cl,
13736 __attribute__((unused)) void *data)
13738 struct cmd_vf_split_drop_en_result *res = parsed_result;
13739 int ret = -ENOTSUP;
13740 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13742 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13745 #ifdef RTE_LIBRTE_IXGBE_PMD
13746 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13753 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13756 printf("invalid port_id %d\n", res->port_id);
13759 printf("not supported on port %d\n", res->port_id);
13762 printf("programming error: (%s)\n", strerror(-ret));
13766 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13767 .f = cmd_set_vf_split_drop_en_parsed,
13769 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13771 (void *)&cmd_vf_split_drop_en_set,
13772 (void *)&cmd_vf_split_drop_en_vf,
13773 (void *)&cmd_vf_split_drop_en_split,
13774 (void *)&cmd_vf_split_drop_en_drop,
13775 (void *)&cmd_vf_split_drop_en_port_id,
13776 (void *)&cmd_vf_split_drop_en_vf_id,
13777 (void *)&cmd_vf_split_drop_en_on_off,
13782 /* vf mac address configuration */
13784 /* Common result structure for vf mac address */
13785 struct cmd_set_vf_mac_addr_result {
13786 cmdline_fixed_string_t set;
13787 cmdline_fixed_string_t vf;
13788 cmdline_fixed_string_t mac;
13789 cmdline_fixed_string_t addr;
13792 struct ether_addr mac_addr;
13796 /* Common CLI fields for vf split drop enable disable */
13797 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13798 TOKEN_STRING_INITIALIZER
13799 (struct cmd_set_vf_mac_addr_result,
13801 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13802 TOKEN_STRING_INITIALIZER
13803 (struct cmd_set_vf_mac_addr_result,
13805 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13806 TOKEN_STRING_INITIALIZER
13807 (struct cmd_set_vf_mac_addr_result,
13809 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13810 TOKEN_STRING_INITIALIZER
13811 (struct cmd_set_vf_mac_addr_result,
13813 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13814 TOKEN_NUM_INITIALIZER
13815 (struct cmd_set_vf_mac_addr_result,
13817 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13818 TOKEN_NUM_INITIALIZER
13819 (struct cmd_set_vf_mac_addr_result,
13821 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13822 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13826 cmd_set_vf_mac_addr_parsed(
13827 void *parsed_result,
13828 __attribute__((unused)) struct cmdline *cl,
13829 __attribute__((unused)) void *data)
13831 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13832 int ret = -ENOTSUP;
13834 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13837 #ifdef RTE_LIBRTE_IXGBE_PMD
13838 if (ret == -ENOTSUP)
13839 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13842 #ifdef RTE_LIBRTE_I40E_PMD
13843 if (ret == -ENOTSUP)
13844 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13847 #ifdef RTE_LIBRTE_BNXT_PMD
13848 if (ret == -ENOTSUP)
13849 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13857 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13860 printf("invalid port_id %d\n", res->port_id);
13863 printf("function not implemented\n");
13866 printf("programming error: (%s)\n", strerror(-ret));
13870 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13871 .f = cmd_set_vf_mac_addr_parsed,
13873 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13875 (void *)&cmd_set_vf_mac_addr_set,
13876 (void *)&cmd_set_vf_mac_addr_vf,
13877 (void *)&cmd_set_vf_mac_addr_mac,
13878 (void *)&cmd_set_vf_mac_addr_addr,
13879 (void *)&cmd_set_vf_mac_addr_port_id,
13880 (void *)&cmd_set_vf_mac_addr_vf_id,
13881 (void *)&cmd_set_vf_mac_addr_mac_addr,
13886 /* MACsec configuration */
13888 /* Common result structure for MACsec offload enable */
13889 struct cmd_macsec_offload_on_result {
13890 cmdline_fixed_string_t set;
13891 cmdline_fixed_string_t macsec;
13892 cmdline_fixed_string_t offload;
13894 cmdline_fixed_string_t on;
13895 cmdline_fixed_string_t encrypt;
13896 cmdline_fixed_string_t en_on_off;
13897 cmdline_fixed_string_t replay_protect;
13898 cmdline_fixed_string_t rp_on_off;
13901 /* Common CLI fields for MACsec offload disable */
13902 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13903 TOKEN_STRING_INITIALIZER
13904 (struct cmd_macsec_offload_on_result,
13906 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13907 TOKEN_STRING_INITIALIZER
13908 (struct cmd_macsec_offload_on_result,
13910 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13911 TOKEN_STRING_INITIALIZER
13912 (struct cmd_macsec_offload_on_result,
13913 offload, "offload");
13914 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13915 TOKEN_NUM_INITIALIZER
13916 (struct cmd_macsec_offload_on_result,
13918 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13919 TOKEN_STRING_INITIALIZER
13920 (struct cmd_macsec_offload_on_result,
13922 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13923 TOKEN_STRING_INITIALIZER
13924 (struct cmd_macsec_offload_on_result,
13925 encrypt, "encrypt");
13926 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13927 TOKEN_STRING_INITIALIZER
13928 (struct cmd_macsec_offload_on_result,
13929 en_on_off, "on#off");
13930 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13931 TOKEN_STRING_INITIALIZER
13932 (struct cmd_macsec_offload_on_result,
13933 replay_protect, "replay-protect");
13934 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13935 TOKEN_STRING_INITIALIZER
13936 (struct cmd_macsec_offload_on_result,
13937 rp_on_off, "on#off");
13940 cmd_set_macsec_offload_on_parsed(
13941 void *parsed_result,
13942 __attribute__((unused)) struct cmdline *cl,
13943 __attribute__((unused)) void *data)
13945 struct cmd_macsec_offload_on_result *res = parsed_result;
13946 int ret = -ENOTSUP;
13947 portid_t port_id = res->port_id;
13948 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13949 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13950 struct rte_eth_dev_info dev_info;
13952 if (port_id_is_invalid(port_id, ENABLED_WARN))
13954 if (!port_is_stopped(port_id)) {
13955 printf("Please stop port %d first\n", port_id);
13959 rte_eth_dev_info_get(port_id, &dev_info);
13960 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13961 #ifdef RTE_LIBRTE_IXGBE_PMD
13962 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13970 ports[port_id].dev_conf.txmode.offloads |=
13971 DEV_TX_OFFLOAD_MACSEC_INSERT;
13972 cmd_reconfig_device_queue(port_id, 1, 1);
13975 printf("invalid port_id %d\n", port_id);
13978 printf("not supported on port %d\n", port_id);
13981 printf("programming error: (%s)\n", strerror(-ret));
13985 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13986 .f = cmd_set_macsec_offload_on_parsed,
13988 .help_str = "set macsec offload <port_id> on "
13989 "encrypt on|off replay-protect on|off",
13991 (void *)&cmd_macsec_offload_on_set,
13992 (void *)&cmd_macsec_offload_on_macsec,
13993 (void *)&cmd_macsec_offload_on_offload,
13994 (void *)&cmd_macsec_offload_on_port_id,
13995 (void *)&cmd_macsec_offload_on_on,
13996 (void *)&cmd_macsec_offload_on_encrypt,
13997 (void *)&cmd_macsec_offload_on_en_on_off,
13998 (void *)&cmd_macsec_offload_on_replay_protect,
13999 (void *)&cmd_macsec_offload_on_rp_on_off,
14004 /* Common result structure for MACsec offload disable */
14005 struct cmd_macsec_offload_off_result {
14006 cmdline_fixed_string_t set;
14007 cmdline_fixed_string_t macsec;
14008 cmdline_fixed_string_t offload;
14010 cmdline_fixed_string_t off;
14013 /* Common CLI fields for MACsec offload disable */
14014 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14015 TOKEN_STRING_INITIALIZER
14016 (struct cmd_macsec_offload_off_result,
14018 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14019 TOKEN_STRING_INITIALIZER
14020 (struct cmd_macsec_offload_off_result,
14022 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14023 TOKEN_STRING_INITIALIZER
14024 (struct cmd_macsec_offload_off_result,
14025 offload, "offload");
14026 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14027 TOKEN_NUM_INITIALIZER
14028 (struct cmd_macsec_offload_off_result,
14030 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14031 TOKEN_STRING_INITIALIZER
14032 (struct cmd_macsec_offload_off_result,
14036 cmd_set_macsec_offload_off_parsed(
14037 void *parsed_result,
14038 __attribute__((unused)) struct cmdline *cl,
14039 __attribute__((unused)) void *data)
14041 struct cmd_macsec_offload_off_result *res = parsed_result;
14042 int ret = -ENOTSUP;
14043 struct rte_eth_dev_info dev_info;
14044 portid_t port_id = res->port_id;
14046 if (port_id_is_invalid(port_id, ENABLED_WARN))
14048 if (!port_is_stopped(port_id)) {
14049 printf("Please stop port %d first\n", port_id);
14053 rte_eth_dev_info_get(port_id, &dev_info);
14054 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14055 #ifdef RTE_LIBRTE_IXGBE_PMD
14056 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14061 ports[port_id].dev_conf.txmode.offloads &=
14062 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14063 cmd_reconfig_device_queue(port_id, 1, 1);
14066 printf("invalid port_id %d\n", port_id);
14069 printf("not supported on port %d\n", port_id);
14072 printf("programming error: (%s)\n", strerror(-ret));
14076 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14077 .f = cmd_set_macsec_offload_off_parsed,
14079 .help_str = "set macsec offload <port_id> off",
14081 (void *)&cmd_macsec_offload_off_set,
14082 (void *)&cmd_macsec_offload_off_macsec,
14083 (void *)&cmd_macsec_offload_off_offload,
14084 (void *)&cmd_macsec_offload_off_port_id,
14085 (void *)&cmd_macsec_offload_off_off,
14090 /* Common result structure for MACsec secure connection configure */
14091 struct cmd_macsec_sc_result {
14092 cmdline_fixed_string_t set;
14093 cmdline_fixed_string_t macsec;
14094 cmdline_fixed_string_t sc;
14095 cmdline_fixed_string_t tx_rx;
14097 struct ether_addr mac;
14101 /* Common CLI fields for MACsec secure connection configure */
14102 cmdline_parse_token_string_t cmd_macsec_sc_set =
14103 TOKEN_STRING_INITIALIZER
14104 (struct cmd_macsec_sc_result,
14106 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14107 TOKEN_STRING_INITIALIZER
14108 (struct cmd_macsec_sc_result,
14110 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14111 TOKEN_STRING_INITIALIZER
14112 (struct cmd_macsec_sc_result,
14114 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14115 TOKEN_STRING_INITIALIZER
14116 (struct cmd_macsec_sc_result,
14118 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14119 TOKEN_NUM_INITIALIZER
14120 (struct cmd_macsec_sc_result,
14122 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14123 TOKEN_ETHERADDR_INITIALIZER
14124 (struct cmd_macsec_sc_result,
14126 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14127 TOKEN_NUM_INITIALIZER
14128 (struct cmd_macsec_sc_result,
14132 cmd_set_macsec_sc_parsed(
14133 void *parsed_result,
14134 __attribute__((unused)) struct cmdline *cl,
14135 __attribute__((unused)) void *data)
14137 struct cmd_macsec_sc_result *res = parsed_result;
14138 int ret = -ENOTSUP;
14139 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14141 #ifdef RTE_LIBRTE_IXGBE_PMD
14143 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14144 res->mac.addr_bytes) :
14145 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14146 res->mac.addr_bytes, res->pi);
14148 RTE_SET_USED(is_tx);
14154 printf("invalid port_id %d\n", res->port_id);
14157 printf("not supported on port %d\n", res->port_id);
14160 printf("programming error: (%s)\n", strerror(-ret));
14164 cmdline_parse_inst_t cmd_set_macsec_sc = {
14165 .f = cmd_set_macsec_sc_parsed,
14167 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14169 (void *)&cmd_macsec_sc_set,
14170 (void *)&cmd_macsec_sc_macsec,
14171 (void *)&cmd_macsec_sc_sc,
14172 (void *)&cmd_macsec_sc_tx_rx,
14173 (void *)&cmd_macsec_sc_port_id,
14174 (void *)&cmd_macsec_sc_mac,
14175 (void *)&cmd_macsec_sc_pi,
14180 /* Common result structure for MACsec secure connection configure */
14181 struct cmd_macsec_sa_result {
14182 cmdline_fixed_string_t set;
14183 cmdline_fixed_string_t macsec;
14184 cmdline_fixed_string_t sa;
14185 cmdline_fixed_string_t tx_rx;
14190 cmdline_fixed_string_t key;
14193 /* Common CLI fields for MACsec secure connection configure */
14194 cmdline_parse_token_string_t cmd_macsec_sa_set =
14195 TOKEN_STRING_INITIALIZER
14196 (struct cmd_macsec_sa_result,
14198 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14199 TOKEN_STRING_INITIALIZER
14200 (struct cmd_macsec_sa_result,
14202 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14203 TOKEN_STRING_INITIALIZER
14204 (struct cmd_macsec_sa_result,
14206 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14207 TOKEN_STRING_INITIALIZER
14208 (struct cmd_macsec_sa_result,
14210 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14211 TOKEN_NUM_INITIALIZER
14212 (struct cmd_macsec_sa_result,
14214 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14215 TOKEN_NUM_INITIALIZER
14216 (struct cmd_macsec_sa_result,
14218 cmdline_parse_token_num_t cmd_macsec_sa_an =
14219 TOKEN_NUM_INITIALIZER
14220 (struct cmd_macsec_sa_result,
14222 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14223 TOKEN_NUM_INITIALIZER
14224 (struct cmd_macsec_sa_result,
14226 cmdline_parse_token_string_t cmd_macsec_sa_key =
14227 TOKEN_STRING_INITIALIZER
14228 (struct cmd_macsec_sa_result,
14232 cmd_set_macsec_sa_parsed(
14233 void *parsed_result,
14234 __attribute__((unused)) struct cmdline *cl,
14235 __attribute__((unused)) void *data)
14237 struct cmd_macsec_sa_result *res = parsed_result;
14238 int ret = -ENOTSUP;
14239 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14240 uint8_t key[16] = { 0 };
14246 key_len = strlen(res->key) / 2;
14250 for (i = 0; i < key_len; i++) {
14251 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14254 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14257 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14260 #ifdef RTE_LIBRTE_IXGBE_PMD
14262 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14263 res->idx, res->an, res->pn, key) :
14264 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14265 res->idx, res->an, res->pn, key);
14267 RTE_SET_USED(is_tx);
14274 printf("invalid idx %d or an %d\n", res->idx, res->an);
14277 printf("invalid port_id %d\n", res->port_id);
14280 printf("not supported on port %d\n", res->port_id);
14283 printf("programming error: (%s)\n", strerror(-ret));
14287 cmdline_parse_inst_t cmd_set_macsec_sa = {
14288 .f = cmd_set_macsec_sa_parsed,
14290 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14292 (void *)&cmd_macsec_sa_set,
14293 (void *)&cmd_macsec_sa_macsec,
14294 (void *)&cmd_macsec_sa_sa,
14295 (void *)&cmd_macsec_sa_tx_rx,
14296 (void *)&cmd_macsec_sa_port_id,
14297 (void *)&cmd_macsec_sa_idx,
14298 (void *)&cmd_macsec_sa_an,
14299 (void *)&cmd_macsec_sa_pn,
14300 (void *)&cmd_macsec_sa_key,
14305 /* VF unicast promiscuous mode configuration */
14307 /* Common result structure for VF unicast promiscuous mode */
14308 struct cmd_vf_promisc_result {
14309 cmdline_fixed_string_t set;
14310 cmdline_fixed_string_t vf;
14311 cmdline_fixed_string_t promisc;
14314 cmdline_fixed_string_t on_off;
14317 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14318 cmdline_parse_token_string_t cmd_vf_promisc_set =
14319 TOKEN_STRING_INITIALIZER
14320 (struct cmd_vf_promisc_result,
14322 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14323 TOKEN_STRING_INITIALIZER
14324 (struct cmd_vf_promisc_result,
14326 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14327 TOKEN_STRING_INITIALIZER
14328 (struct cmd_vf_promisc_result,
14329 promisc, "promisc");
14330 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14331 TOKEN_NUM_INITIALIZER
14332 (struct cmd_vf_promisc_result,
14334 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14335 TOKEN_NUM_INITIALIZER
14336 (struct cmd_vf_promisc_result,
14338 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14339 TOKEN_STRING_INITIALIZER
14340 (struct cmd_vf_promisc_result,
14344 cmd_set_vf_promisc_parsed(
14345 void *parsed_result,
14346 __attribute__((unused)) struct cmdline *cl,
14347 __attribute__((unused)) void *data)
14349 struct cmd_vf_promisc_result *res = parsed_result;
14350 int ret = -ENOTSUP;
14352 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14354 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14357 #ifdef RTE_LIBRTE_I40E_PMD
14358 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14359 res->vf_id, is_on);
14366 printf("invalid vf_id %d\n", res->vf_id);
14369 printf("invalid port_id %d\n", res->port_id);
14372 printf("function not implemented\n");
14375 printf("programming error: (%s)\n", strerror(-ret));
14379 cmdline_parse_inst_t cmd_set_vf_promisc = {
14380 .f = cmd_set_vf_promisc_parsed,
14382 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14383 "Set unicast promiscuous mode for a VF from the PF",
14385 (void *)&cmd_vf_promisc_set,
14386 (void *)&cmd_vf_promisc_vf,
14387 (void *)&cmd_vf_promisc_promisc,
14388 (void *)&cmd_vf_promisc_port_id,
14389 (void *)&cmd_vf_promisc_vf_id,
14390 (void *)&cmd_vf_promisc_on_off,
14395 /* VF multicast promiscuous mode configuration */
14397 /* Common result structure for VF multicast promiscuous mode */
14398 struct cmd_vf_allmulti_result {
14399 cmdline_fixed_string_t set;
14400 cmdline_fixed_string_t vf;
14401 cmdline_fixed_string_t allmulti;
14404 cmdline_fixed_string_t on_off;
14407 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14408 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14409 TOKEN_STRING_INITIALIZER
14410 (struct cmd_vf_allmulti_result,
14412 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14413 TOKEN_STRING_INITIALIZER
14414 (struct cmd_vf_allmulti_result,
14416 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14417 TOKEN_STRING_INITIALIZER
14418 (struct cmd_vf_allmulti_result,
14419 allmulti, "allmulti");
14420 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14421 TOKEN_NUM_INITIALIZER
14422 (struct cmd_vf_allmulti_result,
14424 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14425 TOKEN_NUM_INITIALIZER
14426 (struct cmd_vf_allmulti_result,
14428 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14429 TOKEN_STRING_INITIALIZER
14430 (struct cmd_vf_allmulti_result,
14434 cmd_set_vf_allmulti_parsed(
14435 void *parsed_result,
14436 __attribute__((unused)) struct cmdline *cl,
14437 __attribute__((unused)) void *data)
14439 struct cmd_vf_allmulti_result *res = parsed_result;
14440 int ret = -ENOTSUP;
14442 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14444 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14447 #ifdef RTE_LIBRTE_I40E_PMD
14448 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14449 res->vf_id, is_on);
14456 printf("invalid vf_id %d\n", res->vf_id);
14459 printf("invalid port_id %d\n", res->port_id);
14462 printf("function not implemented\n");
14465 printf("programming error: (%s)\n", strerror(-ret));
14469 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14470 .f = cmd_set_vf_allmulti_parsed,
14472 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14473 "Set multicast promiscuous mode for a VF from the PF",
14475 (void *)&cmd_vf_allmulti_set,
14476 (void *)&cmd_vf_allmulti_vf,
14477 (void *)&cmd_vf_allmulti_allmulti,
14478 (void *)&cmd_vf_allmulti_port_id,
14479 (void *)&cmd_vf_allmulti_vf_id,
14480 (void *)&cmd_vf_allmulti_on_off,
14485 /* vf broadcast mode configuration */
14487 /* Common result structure for vf broadcast */
14488 struct cmd_set_vf_broadcast_result {
14489 cmdline_fixed_string_t set;
14490 cmdline_fixed_string_t vf;
14491 cmdline_fixed_string_t broadcast;
14494 cmdline_fixed_string_t on_off;
14497 /* Common CLI fields for vf broadcast enable disable */
14498 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14499 TOKEN_STRING_INITIALIZER
14500 (struct cmd_set_vf_broadcast_result,
14502 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14503 TOKEN_STRING_INITIALIZER
14504 (struct cmd_set_vf_broadcast_result,
14506 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14507 TOKEN_STRING_INITIALIZER
14508 (struct cmd_set_vf_broadcast_result,
14509 broadcast, "broadcast");
14510 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14511 TOKEN_NUM_INITIALIZER
14512 (struct cmd_set_vf_broadcast_result,
14514 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14515 TOKEN_NUM_INITIALIZER
14516 (struct cmd_set_vf_broadcast_result,
14518 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14519 TOKEN_STRING_INITIALIZER
14520 (struct cmd_set_vf_broadcast_result,
14524 cmd_set_vf_broadcast_parsed(
14525 void *parsed_result,
14526 __attribute__((unused)) struct cmdline *cl,
14527 __attribute__((unused)) void *data)
14529 struct cmd_set_vf_broadcast_result *res = parsed_result;
14530 int ret = -ENOTSUP;
14532 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14534 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14537 #ifdef RTE_LIBRTE_I40E_PMD
14538 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14539 res->vf_id, is_on);
14546 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14549 printf("invalid port_id %d\n", res->port_id);
14552 printf("function not implemented\n");
14555 printf("programming error: (%s)\n", strerror(-ret));
14559 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14560 .f = cmd_set_vf_broadcast_parsed,
14562 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14564 (void *)&cmd_set_vf_broadcast_set,
14565 (void *)&cmd_set_vf_broadcast_vf,
14566 (void *)&cmd_set_vf_broadcast_broadcast,
14567 (void *)&cmd_set_vf_broadcast_port_id,
14568 (void *)&cmd_set_vf_broadcast_vf_id,
14569 (void *)&cmd_set_vf_broadcast_on_off,
14574 /* vf vlan tag configuration */
14576 /* Common result structure for vf vlan tag */
14577 struct cmd_set_vf_vlan_tag_result {
14578 cmdline_fixed_string_t set;
14579 cmdline_fixed_string_t vf;
14580 cmdline_fixed_string_t vlan;
14581 cmdline_fixed_string_t tag;
14584 cmdline_fixed_string_t on_off;
14587 /* Common CLI fields for vf vlan tag enable disable */
14588 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14589 TOKEN_STRING_INITIALIZER
14590 (struct cmd_set_vf_vlan_tag_result,
14592 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14593 TOKEN_STRING_INITIALIZER
14594 (struct cmd_set_vf_vlan_tag_result,
14596 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14597 TOKEN_STRING_INITIALIZER
14598 (struct cmd_set_vf_vlan_tag_result,
14600 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14601 TOKEN_STRING_INITIALIZER
14602 (struct cmd_set_vf_vlan_tag_result,
14604 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14605 TOKEN_NUM_INITIALIZER
14606 (struct cmd_set_vf_vlan_tag_result,
14608 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14609 TOKEN_NUM_INITIALIZER
14610 (struct cmd_set_vf_vlan_tag_result,
14612 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14613 TOKEN_STRING_INITIALIZER
14614 (struct cmd_set_vf_vlan_tag_result,
14618 cmd_set_vf_vlan_tag_parsed(
14619 void *parsed_result,
14620 __attribute__((unused)) struct cmdline *cl,
14621 __attribute__((unused)) void *data)
14623 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14624 int ret = -ENOTSUP;
14626 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14628 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14631 #ifdef RTE_LIBRTE_I40E_PMD
14632 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14633 res->vf_id, is_on);
14640 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14643 printf("invalid port_id %d\n", res->port_id);
14646 printf("function not implemented\n");
14649 printf("programming error: (%s)\n", strerror(-ret));
14653 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14654 .f = cmd_set_vf_vlan_tag_parsed,
14656 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14658 (void *)&cmd_set_vf_vlan_tag_set,
14659 (void *)&cmd_set_vf_vlan_tag_vf,
14660 (void *)&cmd_set_vf_vlan_tag_vlan,
14661 (void *)&cmd_set_vf_vlan_tag_tag,
14662 (void *)&cmd_set_vf_vlan_tag_port_id,
14663 (void *)&cmd_set_vf_vlan_tag_vf_id,
14664 (void *)&cmd_set_vf_vlan_tag_on_off,
14669 /* Common definition of VF and TC TX bandwidth configuration */
14670 struct cmd_vf_tc_bw_result {
14671 cmdline_fixed_string_t set;
14672 cmdline_fixed_string_t vf;
14673 cmdline_fixed_string_t tc;
14674 cmdline_fixed_string_t tx;
14675 cmdline_fixed_string_t min_bw;
14676 cmdline_fixed_string_t max_bw;
14677 cmdline_fixed_string_t strict_link_prio;
14682 cmdline_fixed_string_t bw_list;
14686 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14687 TOKEN_STRING_INITIALIZER
14688 (struct cmd_vf_tc_bw_result,
14690 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14691 TOKEN_STRING_INITIALIZER
14692 (struct cmd_vf_tc_bw_result,
14694 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14695 TOKEN_STRING_INITIALIZER
14696 (struct cmd_vf_tc_bw_result,
14698 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14699 TOKEN_STRING_INITIALIZER
14700 (struct cmd_vf_tc_bw_result,
14702 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14703 TOKEN_STRING_INITIALIZER
14704 (struct cmd_vf_tc_bw_result,
14705 strict_link_prio, "strict-link-priority");
14706 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14707 TOKEN_STRING_INITIALIZER
14708 (struct cmd_vf_tc_bw_result,
14709 min_bw, "min-bandwidth");
14710 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14711 TOKEN_STRING_INITIALIZER
14712 (struct cmd_vf_tc_bw_result,
14713 max_bw, "max-bandwidth");
14714 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14715 TOKEN_NUM_INITIALIZER
14716 (struct cmd_vf_tc_bw_result,
14718 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14719 TOKEN_NUM_INITIALIZER
14720 (struct cmd_vf_tc_bw_result,
14722 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14723 TOKEN_NUM_INITIALIZER
14724 (struct cmd_vf_tc_bw_result,
14726 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14727 TOKEN_NUM_INITIALIZER
14728 (struct cmd_vf_tc_bw_result,
14730 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14731 TOKEN_STRING_INITIALIZER
14732 (struct cmd_vf_tc_bw_result,
14734 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14735 TOKEN_NUM_INITIALIZER
14736 (struct cmd_vf_tc_bw_result,
14739 /* VF max bandwidth setting */
14741 cmd_vf_max_bw_parsed(
14742 void *parsed_result,
14743 __attribute__((unused)) struct cmdline *cl,
14744 __attribute__((unused)) void *data)
14746 struct cmd_vf_tc_bw_result *res = parsed_result;
14747 int ret = -ENOTSUP;
14749 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14752 #ifdef RTE_LIBRTE_I40E_PMD
14753 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14754 res->vf_id, res->bw);
14761 printf("invalid vf_id %d or bandwidth %d\n",
14762 res->vf_id, res->bw);
14765 printf("invalid port_id %d\n", res->port_id);
14768 printf("function not implemented\n");
14771 printf("programming error: (%s)\n", strerror(-ret));
14775 cmdline_parse_inst_t cmd_vf_max_bw = {
14776 .f = cmd_vf_max_bw_parsed,
14778 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14780 (void *)&cmd_vf_tc_bw_set,
14781 (void *)&cmd_vf_tc_bw_vf,
14782 (void *)&cmd_vf_tc_bw_tx,
14783 (void *)&cmd_vf_tc_bw_max_bw,
14784 (void *)&cmd_vf_tc_bw_port_id,
14785 (void *)&cmd_vf_tc_bw_vf_id,
14786 (void *)&cmd_vf_tc_bw_bw,
14792 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14797 const char *p, *p0 = str;
14804 p = strchr(p0, '(');
14806 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14810 p0 = strchr(p, ')');
14812 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14816 if (size >= sizeof(s)) {
14817 printf("The string size exceeds the internal buffer size\n");
14820 snprintf(s, sizeof(s), "%.*s", size, p);
14821 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14823 printf("Failed to get the bandwidth list. ");
14827 for (i = 0; i < ret; i++)
14828 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14833 /* TC min bandwidth setting */
14835 cmd_vf_tc_min_bw_parsed(
14836 void *parsed_result,
14837 __attribute__((unused)) struct cmdline *cl,
14838 __attribute__((unused)) void *data)
14840 struct cmd_vf_tc_bw_result *res = parsed_result;
14843 int ret = -ENOTSUP;
14845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14848 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14852 #ifdef RTE_LIBRTE_I40E_PMD
14853 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14861 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14864 printf("invalid port_id %d\n", res->port_id);
14867 printf("function not implemented\n");
14870 printf("programming error: (%s)\n", strerror(-ret));
14874 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14875 .f = cmd_vf_tc_min_bw_parsed,
14877 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14878 " <bw1, bw2, ...>",
14880 (void *)&cmd_vf_tc_bw_set,
14881 (void *)&cmd_vf_tc_bw_vf,
14882 (void *)&cmd_vf_tc_bw_tc,
14883 (void *)&cmd_vf_tc_bw_tx,
14884 (void *)&cmd_vf_tc_bw_min_bw,
14885 (void *)&cmd_vf_tc_bw_port_id,
14886 (void *)&cmd_vf_tc_bw_vf_id,
14887 (void *)&cmd_vf_tc_bw_bw_list,
14893 cmd_tc_min_bw_parsed(
14894 void *parsed_result,
14895 __attribute__((unused)) struct cmdline *cl,
14896 __attribute__((unused)) void *data)
14898 struct cmd_vf_tc_bw_result *res = parsed_result;
14899 struct rte_port *port;
14902 int ret = -ENOTSUP;
14904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14907 port = &ports[res->port_id];
14908 /** Check if the port is not started **/
14909 if (port->port_status != RTE_PORT_STOPPED) {
14910 printf("Please stop port %d first\n", res->port_id);
14914 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14918 #ifdef RTE_LIBRTE_IXGBE_PMD
14919 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14926 printf("invalid bandwidth\n");
14929 printf("invalid port_id %d\n", res->port_id);
14932 printf("function not implemented\n");
14935 printf("programming error: (%s)\n", strerror(-ret));
14939 cmdline_parse_inst_t cmd_tc_min_bw = {
14940 .f = cmd_tc_min_bw_parsed,
14942 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14944 (void *)&cmd_vf_tc_bw_set,
14945 (void *)&cmd_vf_tc_bw_tc,
14946 (void *)&cmd_vf_tc_bw_tx,
14947 (void *)&cmd_vf_tc_bw_min_bw,
14948 (void *)&cmd_vf_tc_bw_port_id,
14949 (void *)&cmd_vf_tc_bw_bw_list,
14954 /* TC max bandwidth setting */
14956 cmd_vf_tc_max_bw_parsed(
14957 void *parsed_result,
14958 __attribute__((unused)) struct cmdline *cl,
14959 __attribute__((unused)) void *data)
14961 struct cmd_vf_tc_bw_result *res = parsed_result;
14962 int ret = -ENOTSUP;
14964 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14967 #ifdef RTE_LIBRTE_I40E_PMD
14968 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14969 res->tc_no, res->bw);
14976 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14977 res->vf_id, res->tc_no, res->bw);
14980 printf("invalid port_id %d\n", res->port_id);
14983 printf("function not implemented\n");
14986 printf("programming error: (%s)\n", strerror(-ret));
14990 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14991 .f = cmd_vf_tc_max_bw_parsed,
14993 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14996 (void *)&cmd_vf_tc_bw_set,
14997 (void *)&cmd_vf_tc_bw_vf,
14998 (void *)&cmd_vf_tc_bw_tc,
14999 (void *)&cmd_vf_tc_bw_tx,
15000 (void *)&cmd_vf_tc_bw_max_bw,
15001 (void *)&cmd_vf_tc_bw_port_id,
15002 (void *)&cmd_vf_tc_bw_vf_id,
15003 (void *)&cmd_vf_tc_bw_tc_no,
15004 (void *)&cmd_vf_tc_bw_bw,
15010 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15012 /* *** Set Port default Traffic Management Hierarchy *** */
15013 struct cmd_set_port_tm_hierarchy_default_result {
15014 cmdline_fixed_string_t set;
15015 cmdline_fixed_string_t port;
15016 cmdline_fixed_string_t tm;
15017 cmdline_fixed_string_t hierarchy;
15018 cmdline_fixed_string_t def;
15022 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15023 TOKEN_STRING_INITIALIZER(
15024 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15025 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15026 TOKEN_STRING_INITIALIZER(
15027 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15028 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15029 TOKEN_STRING_INITIALIZER(
15030 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15031 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15032 TOKEN_STRING_INITIALIZER(
15033 struct cmd_set_port_tm_hierarchy_default_result,
15034 hierarchy, "hierarchy");
15035 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15036 TOKEN_STRING_INITIALIZER(
15037 struct cmd_set_port_tm_hierarchy_default_result,
15039 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15040 TOKEN_NUM_INITIALIZER(
15041 struct cmd_set_port_tm_hierarchy_default_result,
15044 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15045 __attribute__((unused)) struct cmdline *cl,
15046 __attribute__((unused)) void *data)
15048 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15049 struct rte_port *p;
15050 portid_t port_id = res->port_id;
15052 if (port_id_is_invalid(port_id, ENABLED_WARN))
15055 p = &ports[port_id];
15057 /* Forward mode: tm */
15058 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15059 printf(" softnicfwd mode not enabled(error)\n");
15063 /* Set the default tm hierarchy */
15064 p->softport.default_tm_hierarchy_enable = 1;
15067 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15068 .f = cmd_set_port_tm_hierarchy_default_parsed,
15070 .help_str = "set port tm hierarchy default <port_id>",
15072 (void *)&cmd_set_port_tm_hierarchy_default_set,
15073 (void *)&cmd_set_port_tm_hierarchy_default_port,
15074 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15075 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15076 (void *)&cmd_set_port_tm_hierarchy_default_default,
15077 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15083 /** Set VXLAN encapsulation details */
15084 struct cmd_set_vxlan_result {
15085 cmdline_fixed_string_t set;
15086 cmdline_fixed_string_t vxlan;
15087 cmdline_fixed_string_t pos_token;
15088 cmdline_fixed_string_t ip_version;
15089 uint32_t vlan_present:1;
15093 cmdline_ipaddr_t ip_src;
15094 cmdline_ipaddr_t ip_dst;
15098 struct ether_addr eth_src;
15099 struct ether_addr eth_dst;
15102 cmdline_parse_token_string_t cmd_set_vxlan_set =
15103 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15104 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15105 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15106 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15107 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15109 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15110 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15111 "vxlan-with-vlan");
15112 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15113 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15115 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15116 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15118 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15119 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15121 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15122 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15123 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15124 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15126 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15127 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15128 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15129 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15131 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15132 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15133 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15134 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15136 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15137 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15138 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15139 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15141 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15142 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15143 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15144 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15146 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15147 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15148 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15149 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15151 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15152 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15153 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15154 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15156 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15157 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15158 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15159 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15161 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15162 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15163 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15164 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15166 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15167 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15169 static void cmd_set_vxlan_parsed(void *parsed_result,
15170 __attribute__((unused)) struct cmdline *cl,
15171 __attribute__((unused)) void *data)
15173 struct cmd_set_vxlan_result *res = parsed_result;
15178 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15181 vxlan_encap_conf.select_tos_ttl = 0;
15182 if (strcmp(res->vxlan, "vxlan") == 0)
15183 vxlan_encap_conf.select_vlan = 0;
15184 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15185 vxlan_encap_conf.select_vlan = 1;
15186 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15187 vxlan_encap_conf.select_vlan = 0;
15188 vxlan_encap_conf.select_tos_ttl = 1;
15190 if (strcmp(res->ip_version, "ipv4") == 0)
15191 vxlan_encap_conf.select_ipv4 = 1;
15192 else if (strcmp(res->ip_version, "ipv6") == 0)
15193 vxlan_encap_conf.select_ipv4 = 0;
15196 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15197 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15198 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15199 vxlan_encap_conf.ip_tos = res->tos;
15200 vxlan_encap_conf.ip_ttl = res->ttl;
15201 if (vxlan_encap_conf.select_ipv4) {
15202 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15203 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15205 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15206 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15208 if (vxlan_encap_conf.select_vlan)
15209 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15210 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15212 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15216 cmdline_parse_inst_t cmd_set_vxlan = {
15217 .f = cmd_set_vxlan_parsed,
15219 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15220 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15221 " eth-src <eth-src> eth-dst <eth-dst>",
15223 (void *)&cmd_set_vxlan_set,
15224 (void *)&cmd_set_vxlan_vxlan,
15225 (void *)&cmd_set_vxlan_ip_version,
15226 (void *)&cmd_set_vxlan_ip_version_value,
15227 (void *)&cmd_set_vxlan_vni,
15228 (void *)&cmd_set_vxlan_vni_value,
15229 (void *)&cmd_set_vxlan_udp_src,
15230 (void *)&cmd_set_vxlan_udp_src_value,
15231 (void *)&cmd_set_vxlan_udp_dst,
15232 (void *)&cmd_set_vxlan_udp_dst_value,
15233 (void *)&cmd_set_vxlan_ip_src,
15234 (void *)&cmd_set_vxlan_ip_src_value,
15235 (void *)&cmd_set_vxlan_ip_dst,
15236 (void *)&cmd_set_vxlan_ip_dst_value,
15237 (void *)&cmd_set_vxlan_eth_src,
15238 (void *)&cmd_set_vxlan_eth_src_value,
15239 (void *)&cmd_set_vxlan_eth_dst,
15240 (void *)&cmd_set_vxlan_eth_dst_value,
15245 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15246 .f = cmd_set_vxlan_parsed,
15248 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15249 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15250 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15251 " eth-dst <eth-dst>",
15253 (void *)&cmd_set_vxlan_set,
15254 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15255 (void *)&cmd_set_vxlan_ip_version,
15256 (void *)&cmd_set_vxlan_ip_version_value,
15257 (void *)&cmd_set_vxlan_vni,
15258 (void *)&cmd_set_vxlan_vni_value,
15259 (void *)&cmd_set_vxlan_udp_src,
15260 (void *)&cmd_set_vxlan_udp_src_value,
15261 (void *)&cmd_set_vxlan_udp_dst,
15262 (void *)&cmd_set_vxlan_udp_dst_value,
15263 (void *)&cmd_set_vxlan_ip_tos,
15264 (void *)&cmd_set_vxlan_ip_tos_value,
15265 (void *)&cmd_set_vxlan_ip_ttl,
15266 (void *)&cmd_set_vxlan_ip_ttl_value,
15267 (void *)&cmd_set_vxlan_ip_src,
15268 (void *)&cmd_set_vxlan_ip_src_value,
15269 (void *)&cmd_set_vxlan_ip_dst,
15270 (void *)&cmd_set_vxlan_ip_dst_value,
15271 (void *)&cmd_set_vxlan_eth_src,
15272 (void *)&cmd_set_vxlan_eth_src_value,
15273 (void *)&cmd_set_vxlan_eth_dst,
15274 (void *)&cmd_set_vxlan_eth_dst_value,
15279 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15280 .f = cmd_set_vxlan_parsed,
15282 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15283 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15284 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15287 (void *)&cmd_set_vxlan_set,
15288 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15289 (void *)&cmd_set_vxlan_ip_version,
15290 (void *)&cmd_set_vxlan_ip_version_value,
15291 (void *)&cmd_set_vxlan_vni,
15292 (void *)&cmd_set_vxlan_vni_value,
15293 (void *)&cmd_set_vxlan_udp_src,
15294 (void *)&cmd_set_vxlan_udp_src_value,
15295 (void *)&cmd_set_vxlan_udp_dst,
15296 (void *)&cmd_set_vxlan_udp_dst_value,
15297 (void *)&cmd_set_vxlan_ip_src,
15298 (void *)&cmd_set_vxlan_ip_src_value,
15299 (void *)&cmd_set_vxlan_ip_dst,
15300 (void *)&cmd_set_vxlan_ip_dst_value,
15301 (void *)&cmd_set_vxlan_vlan,
15302 (void *)&cmd_set_vxlan_vlan_value,
15303 (void *)&cmd_set_vxlan_eth_src,
15304 (void *)&cmd_set_vxlan_eth_src_value,
15305 (void *)&cmd_set_vxlan_eth_dst,
15306 (void *)&cmd_set_vxlan_eth_dst_value,
15311 /** Set NVGRE encapsulation details */
15312 struct cmd_set_nvgre_result {
15313 cmdline_fixed_string_t set;
15314 cmdline_fixed_string_t nvgre;
15315 cmdline_fixed_string_t pos_token;
15316 cmdline_fixed_string_t ip_version;
15318 cmdline_ipaddr_t ip_src;
15319 cmdline_ipaddr_t ip_dst;
15321 struct ether_addr eth_src;
15322 struct ether_addr eth_dst;
15325 cmdline_parse_token_string_t cmd_set_nvgre_set =
15326 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15327 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15328 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15329 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15330 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15331 "nvgre-with-vlan");
15332 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15333 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15335 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15336 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15338 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15339 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15341 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15342 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15343 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15344 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15346 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15347 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15348 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15349 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15351 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15352 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15353 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15354 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15356 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15357 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15358 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15359 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15361 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15362 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15363 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15364 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15366 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15367 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15369 static void cmd_set_nvgre_parsed(void *parsed_result,
15370 __attribute__((unused)) struct cmdline *cl,
15371 __attribute__((unused)) void *data)
15373 struct cmd_set_nvgre_result *res = parsed_result;
15375 uint32_t nvgre_tni;
15378 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15381 if (strcmp(res->nvgre, "nvgre") == 0)
15382 nvgre_encap_conf.select_vlan = 0;
15383 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15384 nvgre_encap_conf.select_vlan = 1;
15385 if (strcmp(res->ip_version, "ipv4") == 0)
15386 nvgre_encap_conf.select_ipv4 = 1;
15387 else if (strcmp(res->ip_version, "ipv6") == 0)
15388 nvgre_encap_conf.select_ipv4 = 0;
15391 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15392 if (nvgre_encap_conf.select_ipv4) {
15393 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15394 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15396 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15397 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15399 if (nvgre_encap_conf.select_vlan)
15400 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15401 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15403 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15407 cmdline_parse_inst_t cmd_set_nvgre = {
15408 .f = cmd_set_nvgre_parsed,
15410 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15411 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15412 " eth-dst <eth-dst>",
15414 (void *)&cmd_set_nvgre_set,
15415 (void *)&cmd_set_nvgre_nvgre,
15416 (void *)&cmd_set_nvgre_ip_version,
15417 (void *)&cmd_set_nvgre_ip_version_value,
15418 (void *)&cmd_set_nvgre_tni,
15419 (void *)&cmd_set_nvgre_tni_value,
15420 (void *)&cmd_set_nvgre_ip_src,
15421 (void *)&cmd_set_nvgre_ip_src_value,
15422 (void *)&cmd_set_nvgre_ip_dst,
15423 (void *)&cmd_set_nvgre_ip_dst_value,
15424 (void *)&cmd_set_nvgre_eth_src,
15425 (void *)&cmd_set_nvgre_eth_src_value,
15426 (void *)&cmd_set_nvgre_eth_dst,
15427 (void *)&cmd_set_nvgre_eth_dst_value,
15432 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15433 .f = cmd_set_nvgre_parsed,
15435 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15436 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15437 " eth-src <eth-src> eth-dst <eth-dst>",
15439 (void *)&cmd_set_nvgre_set,
15440 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15441 (void *)&cmd_set_nvgre_ip_version,
15442 (void *)&cmd_set_nvgre_ip_version_value,
15443 (void *)&cmd_set_nvgre_tni,
15444 (void *)&cmd_set_nvgre_tni_value,
15445 (void *)&cmd_set_nvgre_ip_src,
15446 (void *)&cmd_set_nvgre_ip_src_value,
15447 (void *)&cmd_set_nvgre_ip_dst,
15448 (void *)&cmd_set_nvgre_ip_dst_value,
15449 (void *)&cmd_set_nvgre_vlan,
15450 (void *)&cmd_set_nvgre_vlan_value,
15451 (void *)&cmd_set_nvgre_eth_src,
15452 (void *)&cmd_set_nvgre_eth_src_value,
15453 (void *)&cmd_set_nvgre_eth_dst,
15454 (void *)&cmd_set_nvgre_eth_dst_value,
15459 /** Set L2 encapsulation details */
15460 struct cmd_set_l2_encap_result {
15461 cmdline_fixed_string_t set;
15462 cmdline_fixed_string_t l2_encap;
15463 cmdline_fixed_string_t pos_token;
15464 cmdline_fixed_string_t ip_version;
15465 uint32_t vlan_present:1;
15467 struct ether_addr eth_src;
15468 struct ether_addr eth_dst;
15471 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15472 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15473 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15474 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15475 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15476 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15477 "l2_encap-with-vlan");
15478 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15479 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15481 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15482 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15484 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15485 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15487 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15488 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15489 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15490 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15492 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15493 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15494 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15495 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15497 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15498 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15500 static void cmd_set_l2_encap_parsed(void *parsed_result,
15501 __attribute__((unused)) struct cmdline *cl,
15502 __attribute__((unused)) void *data)
15504 struct cmd_set_l2_encap_result *res = parsed_result;
15506 if (strcmp(res->l2_encap, "l2_encap") == 0)
15507 l2_encap_conf.select_vlan = 0;
15508 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15509 l2_encap_conf.select_vlan = 1;
15510 if (strcmp(res->ip_version, "ipv4") == 0)
15511 l2_encap_conf.select_ipv4 = 1;
15512 else if (strcmp(res->ip_version, "ipv6") == 0)
15513 l2_encap_conf.select_ipv4 = 0;
15516 if (l2_encap_conf.select_vlan)
15517 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15518 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15520 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15524 cmdline_parse_inst_t cmd_set_l2_encap = {
15525 .f = cmd_set_l2_encap_parsed,
15527 .help_str = "set l2_encap ip-version ipv4|ipv6"
15528 " eth-src <eth-src> eth-dst <eth-dst>",
15530 (void *)&cmd_set_l2_encap_set,
15531 (void *)&cmd_set_l2_encap_l2_encap,
15532 (void *)&cmd_set_l2_encap_ip_version,
15533 (void *)&cmd_set_l2_encap_ip_version_value,
15534 (void *)&cmd_set_l2_encap_eth_src,
15535 (void *)&cmd_set_l2_encap_eth_src_value,
15536 (void *)&cmd_set_l2_encap_eth_dst,
15537 (void *)&cmd_set_l2_encap_eth_dst_value,
15542 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15543 .f = cmd_set_l2_encap_parsed,
15545 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15546 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15548 (void *)&cmd_set_l2_encap_set,
15549 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15550 (void *)&cmd_set_l2_encap_ip_version,
15551 (void *)&cmd_set_l2_encap_ip_version_value,
15552 (void *)&cmd_set_l2_encap_vlan,
15553 (void *)&cmd_set_l2_encap_vlan_value,
15554 (void *)&cmd_set_l2_encap_eth_src,
15555 (void *)&cmd_set_l2_encap_eth_src_value,
15556 (void *)&cmd_set_l2_encap_eth_dst,
15557 (void *)&cmd_set_l2_encap_eth_dst_value,
15562 /** Set L2 decapsulation details */
15563 struct cmd_set_l2_decap_result {
15564 cmdline_fixed_string_t set;
15565 cmdline_fixed_string_t l2_decap;
15566 cmdline_fixed_string_t pos_token;
15567 uint32_t vlan_present:1;
15570 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15571 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15572 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15573 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15575 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15576 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15577 "l2_decap-with-vlan");
15579 static void cmd_set_l2_decap_parsed(void *parsed_result,
15580 __attribute__((unused)) struct cmdline *cl,
15581 __attribute__((unused)) void *data)
15583 struct cmd_set_l2_decap_result *res = parsed_result;
15585 if (strcmp(res->l2_decap, "l2_decap") == 0)
15586 l2_decap_conf.select_vlan = 0;
15587 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15588 l2_decap_conf.select_vlan = 1;
15591 cmdline_parse_inst_t cmd_set_l2_decap = {
15592 .f = cmd_set_l2_decap_parsed,
15594 .help_str = "set l2_decap",
15596 (void *)&cmd_set_l2_decap_set,
15597 (void *)&cmd_set_l2_decap_l2_decap,
15602 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15603 .f = cmd_set_l2_decap_parsed,
15605 .help_str = "set l2_decap-with-vlan",
15607 (void *)&cmd_set_l2_decap_set,
15608 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15613 /** Set MPLSoGRE encapsulation details */
15614 struct cmd_set_mplsogre_encap_result {
15615 cmdline_fixed_string_t set;
15616 cmdline_fixed_string_t mplsogre;
15617 cmdline_fixed_string_t pos_token;
15618 cmdline_fixed_string_t ip_version;
15619 uint32_t vlan_present:1;
15621 cmdline_ipaddr_t ip_src;
15622 cmdline_ipaddr_t ip_dst;
15624 struct ether_addr eth_src;
15625 struct ether_addr eth_dst;
15628 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15629 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15631 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15632 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15634 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15635 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15636 mplsogre, "mplsogre_encap-with-vlan");
15637 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15638 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15639 pos_token, "ip-version");
15640 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15641 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15642 ip_version, "ipv4#ipv6");
15643 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15644 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15645 pos_token, "label");
15646 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15647 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15649 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15650 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15651 pos_token, "ip-src");
15652 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15653 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15654 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15655 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15656 pos_token, "ip-dst");
15657 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15658 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15659 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15660 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15661 pos_token, "vlan-tci");
15662 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15663 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15665 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15666 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15667 pos_token, "eth-src");
15668 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15669 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15671 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15672 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15673 pos_token, "eth-dst");
15674 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15675 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15678 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15679 __attribute__((unused)) struct cmdline *cl,
15680 __attribute__((unused)) void *data)
15682 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15684 uint32_t mplsogre_label;
15687 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15690 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15691 mplsogre_encap_conf.select_vlan = 0;
15692 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15693 mplsogre_encap_conf.select_vlan = 1;
15694 if (strcmp(res->ip_version, "ipv4") == 0)
15695 mplsogre_encap_conf.select_ipv4 = 1;
15696 else if (strcmp(res->ip_version, "ipv6") == 0)
15697 mplsogre_encap_conf.select_ipv4 = 0;
15700 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15701 if (mplsogre_encap_conf.select_ipv4) {
15702 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15703 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15705 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15706 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15708 if (mplsogre_encap_conf.select_vlan)
15709 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15710 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15712 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15716 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15717 .f = cmd_set_mplsogre_encap_parsed,
15719 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15720 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15721 " eth-dst <eth-dst>",
15723 (void *)&cmd_set_mplsogre_encap_set,
15724 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15725 (void *)&cmd_set_mplsogre_encap_ip_version,
15726 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15727 (void *)&cmd_set_mplsogre_encap_label,
15728 (void *)&cmd_set_mplsogre_encap_label_value,
15729 (void *)&cmd_set_mplsogre_encap_ip_src,
15730 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15731 (void *)&cmd_set_mplsogre_encap_ip_dst,
15732 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15733 (void *)&cmd_set_mplsogre_encap_eth_src,
15734 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15735 (void *)&cmd_set_mplsogre_encap_eth_dst,
15736 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15741 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15742 .f = cmd_set_mplsogre_encap_parsed,
15744 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15745 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15746 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15748 (void *)&cmd_set_mplsogre_encap_set,
15749 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15750 (void *)&cmd_set_mplsogre_encap_ip_version,
15751 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15752 (void *)&cmd_set_mplsogre_encap_label,
15753 (void *)&cmd_set_mplsogre_encap_label_value,
15754 (void *)&cmd_set_mplsogre_encap_ip_src,
15755 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15756 (void *)&cmd_set_mplsogre_encap_ip_dst,
15757 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15758 (void *)&cmd_set_mplsogre_encap_vlan,
15759 (void *)&cmd_set_mplsogre_encap_vlan_value,
15760 (void *)&cmd_set_mplsogre_encap_eth_src,
15761 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15762 (void *)&cmd_set_mplsogre_encap_eth_dst,
15763 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15768 /** Set MPLSoGRE decapsulation details */
15769 struct cmd_set_mplsogre_decap_result {
15770 cmdline_fixed_string_t set;
15771 cmdline_fixed_string_t mplsogre;
15772 cmdline_fixed_string_t pos_token;
15773 cmdline_fixed_string_t ip_version;
15774 uint32_t vlan_present:1;
15777 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15778 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15780 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15781 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15783 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15784 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15785 mplsogre, "mplsogre_decap-with-vlan");
15786 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15787 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15788 pos_token, "ip-version");
15789 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15790 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15791 ip_version, "ipv4#ipv6");
15793 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15794 __attribute__((unused)) struct cmdline *cl,
15795 __attribute__((unused)) void *data)
15797 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15799 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15800 mplsogre_decap_conf.select_vlan = 0;
15801 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15802 mplsogre_decap_conf.select_vlan = 1;
15803 if (strcmp(res->ip_version, "ipv4") == 0)
15804 mplsogre_decap_conf.select_ipv4 = 1;
15805 else if (strcmp(res->ip_version, "ipv6") == 0)
15806 mplsogre_decap_conf.select_ipv4 = 0;
15809 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15810 .f = cmd_set_mplsogre_decap_parsed,
15812 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15814 (void *)&cmd_set_mplsogre_decap_set,
15815 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15816 (void *)&cmd_set_mplsogre_decap_ip_version,
15817 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15822 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15823 .f = cmd_set_mplsogre_decap_parsed,
15825 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15827 (void *)&cmd_set_mplsogre_decap_set,
15828 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15829 (void *)&cmd_set_mplsogre_decap_ip_version,
15830 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15835 /** Set MPLSoUDP encapsulation details */
15836 struct cmd_set_mplsoudp_encap_result {
15837 cmdline_fixed_string_t set;
15838 cmdline_fixed_string_t mplsoudp;
15839 cmdline_fixed_string_t pos_token;
15840 cmdline_fixed_string_t ip_version;
15841 uint32_t vlan_present:1;
15845 cmdline_ipaddr_t ip_src;
15846 cmdline_ipaddr_t ip_dst;
15848 struct ether_addr eth_src;
15849 struct ether_addr eth_dst;
15852 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15853 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15855 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15856 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15858 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15859 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15860 mplsoudp, "mplsoudp_encap-with-vlan");
15861 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15862 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15863 pos_token, "ip-version");
15864 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15865 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15866 ip_version, "ipv4#ipv6");
15867 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15868 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15869 pos_token, "label");
15870 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15871 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15873 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15874 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15875 pos_token, "udp-src");
15876 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15877 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15879 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15880 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15881 pos_token, "udp-dst");
15882 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15883 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15885 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15886 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15887 pos_token, "ip-src");
15888 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
15889 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
15890 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
15891 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15892 pos_token, "ip-dst");
15893 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
15894 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
15895 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
15896 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15897 pos_token, "vlan-tci");
15898 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
15899 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
15901 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
15902 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15903 pos_token, "eth-src");
15904 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
15905 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15907 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
15908 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15909 pos_token, "eth-dst");
15910 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
15911 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15914 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
15915 __attribute__((unused)) struct cmdline *cl,
15916 __attribute__((unused)) void *data)
15918 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
15920 uint32_t mplsoudp_label;
15923 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
15926 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
15927 mplsoudp_encap_conf.select_vlan = 0;
15928 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
15929 mplsoudp_encap_conf.select_vlan = 1;
15930 if (strcmp(res->ip_version, "ipv4") == 0)
15931 mplsoudp_encap_conf.select_ipv4 = 1;
15932 else if (strcmp(res->ip_version, "ipv6") == 0)
15933 mplsoudp_encap_conf.select_ipv4 = 0;
15936 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
15937 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15938 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15939 if (mplsoudp_encap_conf.select_ipv4) {
15940 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
15941 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
15943 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
15944 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
15946 if (mplsoudp_encap_conf.select_vlan)
15947 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15948 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
15950 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15954 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15955 .f = cmd_set_mplsoudp_encap_parsed,
15957 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15958 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15959 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15961 (void *)&cmd_set_mplsoudp_encap_set,
15962 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15963 (void *)&cmd_set_mplsoudp_encap_ip_version,
15964 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15965 (void *)&cmd_set_mplsoudp_encap_label,
15966 (void *)&cmd_set_mplsoudp_encap_label_value,
15967 (void *)&cmd_set_mplsoudp_encap_udp_src,
15968 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15969 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15970 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15971 (void *)&cmd_set_mplsoudp_encap_ip_src,
15972 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15973 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15974 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15975 (void *)&cmd_set_mplsoudp_encap_eth_src,
15976 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15977 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15978 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15983 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15984 .f = cmd_set_mplsoudp_encap_parsed,
15986 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15987 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
15988 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15989 " eth-src <eth-src> eth-dst <eth-dst>",
15991 (void *)&cmd_set_mplsoudp_encap_set,
15992 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15993 (void *)&cmd_set_mplsoudp_encap_ip_version,
15994 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15995 (void *)&cmd_set_mplsoudp_encap_label,
15996 (void *)&cmd_set_mplsoudp_encap_label_value,
15997 (void *)&cmd_set_mplsoudp_encap_udp_src,
15998 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15999 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16000 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16001 (void *)&cmd_set_mplsoudp_encap_ip_src,
16002 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16003 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16004 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16005 (void *)&cmd_set_mplsoudp_encap_vlan,
16006 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16007 (void *)&cmd_set_mplsoudp_encap_eth_src,
16008 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16009 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16010 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16015 /** Set MPLSoUDP decapsulation details */
16016 struct cmd_set_mplsoudp_decap_result {
16017 cmdline_fixed_string_t set;
16018 cmdline_fixed_string_t mplsoudp;
16019 cmdline_fixed_string_t pos_token;
16020 cmdline_fixed_string_t ip_version;
16021 uint32_t vlan_present:1;
16024 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16025 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16027 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16028 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16030 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16031 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16032 mplsoudp, "mplsoudp_decap-with-vlan");
16033 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16034 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16035 pos_token, "ip-version");
16036 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16037 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16038 ip_version, "ipv4#ipv6");
16040 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16041 __attribute__((unused)) struct cmdline *cl,
16042 __attribute__((unused)) void *data)
16044 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16046 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16047 mplsoudp_decap_conf.select_vlan = 0;
16048 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16049 mplsoudp_decap_conf.select_vlan = 1;
16050 if (strcmp(res->ip_version, "ipv4") == 0)
16051 mplsoudp_decap_conf.select_ipv4 = 1;
16052 else if (strcmp(res->ip_version, "ipv6") == 0)
16053 mplsoudp_decap_conf.select_ipv4 = 0;
16056 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16057 .f = cmd_set_mplsoudp_decap_parsed,
16059 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16061 (void *)&cmd_set_mplsoudp_decap_set,
16062 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16063 (void *)&cmd_set_mplsoudp_decap_ip_version,
16064 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16069 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16070 .f = cmd_set_mplsoudp_decap_parsed,
16072 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16074 (void *)&cmd_set_mplsoudp_decap_set,
16075 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16076 (void *)&cmd_set_mplsoudp_decap_ip_version,
16077 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16082 /* Strict link priority scheduling mode setting */
16084 cmd_strict_link_prio_parsed(
16085 void *parsed_result,
16086 __attribute__((unused)) struct cmdline *cl,
16087 __attribute__((unused)) void *data)
16089 struct cmd_vf_tc_bw_result *res = parsed_result;
16090 int ret = -ENOTSUP;
16092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16095 #ifdef RTE_LIBRTE_I40E_PMD
16096 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16103 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16106 printf("invalid port_id %d\n", res->port_id);
16109 printf("function not implemented\n");
16112 printf("programming error: (%s)\n", strerror(-ret));
16116 cmdline_parse_inst_t cmd_strict_link_prio = {
16117 .f = cmd_strict_link_prio_parsed,
16119 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16121 (void *)&cmd_vf_tc_bw_set,
16122 (void *)&cmd_vf_tc_bw_tx,
16123 (void *)&cmd_vf_tc_bw_strict_link_prio,
16124 (void *)&cmd_vf_tc_bw_port_id,
16125 (void *)&cmd_vf_tc_bw_tc_map,
16130 /* Load dynamic device personalization*/
16131 struct cmd_ddp_add_result {
16132 cmdline_fixed_string_t ddp;
16133 cmdline_fixed_string_t add;
16138 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16139 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16140 cmdline_parse_token_string_t cmd_ddp_add_add =
16141 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16142 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16143 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16144 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16145 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16148 cmd_ddp_add_parsed(
16149 void *parsed_result,
16150 __attribute__((unused)) struct cmdline *cl,
16151 __attribute__((unused)) void *data)
16153 struct cmd_ddp_add_result *res = parsed_result;
16159 int ret = -ENOTSUP;
16161 if (!all_ports_stopped()) {
16162 printf("Please stop all ports first\n");
16166 filepath = strdup(res->filepath);
16167 if (filepath == NULL) {
16168 printf("Failed to allocate memory\n");
16171 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16173 buff = open_file(file_fld[0], &size);
16175 free((void *)filepath);
16179 #ifdef RTE_LIBRTE_I40E_PMD
16180 if (ret == -ENOTSUP)
16181 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16183 RTE_PMD_I40E_PKG_OP_WR_ADD);
16186 if (ret == -EEXIST)
16187 printf("Profile has already existed.\n");
16189 printf("Failed to load profile.\n");
16190 else if (file_num == 2)
16191 save_file(file_fld[1], buff, size);
16194 free((void *)filepath);
16197 cmdline_parse_inst_t cmd_ddp_add = {
16198 .f = cmd_ddp_add_parsed,
16200 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16202 (void *)&cmd_ddp_add_ddp,
16203 (void *)&cmd_ddp_add_add,
16204 (void *)&cmd_ddp_add_port_id,
16205 (void *)&cmd_ddp_add_filepath,
16210 /* Delete dynamic device personalization*/
16211 struct cmd_ddp_del_result {
16212 cmdline_fixed_string_t ddp;
16213 cmdline_fixed_string_t del;
16218 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16219 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16220 cmdline_parse_token_string_t cmd_ddp_del_del =
16221 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16222 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16223 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16224 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16225 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16228 cmd_ddp_del_parsed(
16229 void *parsed_result,
16230 __attribute__((unused)) struct cmdline *cl,
16231 __attribute__((unused)) void *data)
16233 struct cmd_ddp_del_result *res = parsed_result;
16236 int ret = -ENOTSUP;
16238 if (!all_ports_stopped()) {
16239 printf("Please stop all ports first\n");
16243 buff = open_file(res->filepath, &size);
16247 #ifdef RTE_LIBRTE_I40E_PMD
16248 if (ret == -ENOTSUP)
16249 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16251 RTE_PMD_I40E_PKG_OP_WR_DEL);
16254 if (ret == -EACCES)
16255 printf("Profile does not exist.\n");
16257 printf("Failed to delete profile.\n");
16262 cmdline_parse_inst_t cmd_ddp_del = {
16263 .f = cmd_ddp_del_parsed,
16265 .help_str = "ddp del <port_id> <backup_profile_path>",
16267 (void *)&cmd_ddp_del_ddp,
16268 (void *)&cmd_ddp_del_del,
16269 (void *)&cmd_ddp_del_port_id,
16270 (void *)&cmd_ddp_del_filepath,
16275 /* Get dynamic device personalization profile info */
16276 struct cmd_ddp_info_result {
16277 cmdline_fixed_string_t ddp;
16278 cmdline_fixed_string_t get;
16279 cmdline_fixed_string_t info;
16283 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16284 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16285 cmdline_parse_token_string_t cmd_ddp_info_get =
16286 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16287 cmdline_parse_token_string_t cmd_ddp_info_info =
16288 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16289 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16290 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16293 cmd_ddp_info_parsed(
16294 void *parsed_result,
16295 __attribute__((unused)) struct cmdline *cl,
16296 __attribute__((unused)) void *data)
16298 struct cmd_ddp_info_result *res = parsed_result;
16301 int ret = -ENOTSUP;
16302 #ifdef RTE_LIBRTE_I40E_PMD
16305 uint32_t buff_size = 0;
16306 struct rte_pmd_i40e_profile_info info;
16307 uint32_t dev_num = 0;
16308 struct rte_pmd_i40e_ddp_device_id *devs;
16309 uint32_t proto_num = 0;
16310 struct rte_pmd_i40e_proto_info *proto = NULL;
16311 uint32_t pctype_num = 0;
16312 struct rte_pmd_i40e_ptype_info *pctype;
16313 uint32_t ptype_num = 0;
16314 struct rte_pmd_i40e_ptype_info *ptype;
16319 pkg = open_file(res->filepath, &pkg_size);
16323 #ifdef RTE_LIBRTE_I40E_PMD
16324 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16325 (uint8_t *)&info, sizeof(info),
16326 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16328 printf("Global Track id: 0x%x\n", info.track_id);
16329 printf("Global Version: %d.%d.%d.%d\n",
16330 info.version.major,
16331 info.version.minor,
16332 info.version.update,
16333 info.version.draft);
16334 printf("Global Package name: %s\n\n", info.name);
16337 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16338 (uint8_t *)&info, sizeof(info),
16339 RTE_PMD_I40E_PKG_INFO_HEADER);
16341 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16342 printf("i40e Profile Version: %d.%d.%d.%d\n",
16343 info.version.major,
16344 info.version.minor,
16345 info.version.update,
16346 info.version.draft);
16347 printf("i40e Profile name: %s\n\n", info.name);
16350 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16351 (uint8_t *)&buff_size, sizeof(buff_size),
16352 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16353 if (!ret && buff_size) {
16354 buff = (uint8_t *)malloc(buff_size);
16356 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16358 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16360 printf("Package Notes:\n%s\n\n", buff);
16365 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16366 (uint8_t *)&dev_num, sizeof(dev_num),
16367 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16368 if (!ret && dev_num) {
16369 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16370 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16372 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16373 (uint8_t *)devs, buff_size,
16374 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16376 printf("List of supported devices:\n");
16377 for (i = 0; i < dev_num; i++) {
16378 printf(" %04X:%04X %04X:%04X\n",
16379 devs[i].vendor_dev_id >> 16,
16380 devs[i].vendor_dev_id & 0xFFFF,
16381 devs[i].sub_vendor_dev_id >> 16,
16382 devs[i].sub_vendor_dev_id & 0xFFFF);
16390 /* get information about protocols and packet types */
16391 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16392 (uint8_t *)&proto_num, sizeof(proto_num),
16393 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16394 if (ret || !proto_num)
16395 goto no_print_return;
16397 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16398 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16400 goto no_print_return;
16402 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16404 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16406 printf("List of used protocols:\n");
16407 for (i = 0; i < proto_num; i++)
16408 printf(" %2u: %s\n", proto[i].proto_id,
16412 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16413 (uint8_t *)&pctype_num, sizeof(pctype_num),
16414 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16415 if (ret || !pctype_num)
16416 goto no_print_pctypes;
16418 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16419 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16421 goto no_print_pctypes;
16423 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16425 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16428 goto no_print_pctypes;
16431 printf("List of defined packet classification types:\n");
16432 for (i = 0; i < pctype_num; i++) {
16433 printf(" %2u:", pctype[i].ptype_id);
16434 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16435 proto_id = pctype[i].protocols[j];
16436 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16437 for (n = 0; n < proto_num; n++) {
16438 if (proto[n].proto_id == proto_id) {
16439 printf(" %s", proto[n].name);
16452 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16454 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16455 if (ret || !ptype_num)
16456 goto no_print_return;
16458 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16459 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16461 goto no_print_return;
16463 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16465 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16468 goto no_print_return;
16470 printf("List of defined packet types:\n");
16471 for (i = 0; i < ptype_num; i++) {
16472 printf(" %2u:", ptype[i].ptype_id);
16473 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16474 proto_id = ptype[i].protocols[j];
16475 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16476 for (n = 0; n < proto_num; n++) {
16477 if (proto[n].proto_id == proto_id) {
16478 printf(" %s", proto[n].name);
16494 if (ret == -ENOTSUP)
16495 printf("Function not supported in PMD driver\n");
16499 cmdline_parse_inst_t cmd_ddp_get_info = {
16500 .f = cmd_ddp_info_parsed,
16502 .help_str = "ddp get info <profile_path>",
16504 (void *)&cmd_ddp_info_ddp,
16505 (void *)&cmd_ddp_info_get,
16506 (void *)&cmd_ddp_info_info,
16507 (void *)&cmd_ddp_info_filepath,
16512 /* Get dynamic device personalization profile info list*/
16513 #define PROFILE_INFO_SIZE 48
16514 #define MAX_PROFILE_NUM 16
16516 struct cmd_ddp_get_list_result {
16517 cmdline_fixed_string_t ddp;
16518 cmdline_fixed_string_t get;
16519 cmdline_fixed_string_t list;
16523 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16524 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16525 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16526 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16527 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16528 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16529 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16530 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16533 cmd_ddp_get_list_parsed(
16534 __attribute__((unused)) void *parsed_result,
16535 __attribute__((unused)) struct cmdline *cl,
16536 __attribute__((unused)) void *data)
16538 #ifdef RTE_LIBRTE_I40E_PMD
16539 struct cmd_ddp_get_list_result *res = parsed_result;
16540 struct rte_pmd_i40e_profile_list *p_list;
16541 struct rte_pmd_i40e_profile_info *p_info;
16546 int ret = -ENOTSUP;
16548 #ifdef RTE_LIBRTE_I40E_PMD
16549 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16550 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16552 printf("%s: Failed to malloc buffer\n", __func__);
16554 if (ret == -ENOTSUP)
16555 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16556 (uint8_t *)p_list, size);
16559 p_num = p_list->p_count;
16560 printf("Profile number is: %d\n\n", p_num);
16562 for (i = 0; i < p_num; i++) {
16563 p_info = &p_list->p_info[i];
16564 printf("Profile %d:\n", i);
16565 printf("Track id: 0x%x\n", p_info->track_id);
16566 printf("Version: %d.%d.%d.%d\n",
16567 p_info->version.major,
16568 p_info->version.minor,
16569 p_info->version.update,
16570 p_info->version.draft);
16571 printf("Profile name: %s\n\n", p_info->name);
16579 printf("Failed to get ddp list\n");
16582 cmdline_parse_inst_t cmd_ddp_get_list = {
16583 .f = cmd_ddp_get_list_parsed,
16585 .help_str = "ddp get list <port_id>",
16587 (void *)&cmd_ddp_get_list_ddp,
16588 (void *)&cmd_ddp_get_list_get,
16589 (void *)&cmd_ddp_get_list_list,
16590 (void *)&cmd_ddp_get_list_port_id,
16595 /* Configure input set */
16596 struct cmd_cfg_input_set_result {
16597 cmdline_fixed_string_t port;
16598 cmdline_fixed_string_t cfg;
16600 cmdline_fixed_string_t pctype;
16602 cmdline_fixed_string_t inset_type;
16603 cmdline_fixed_string_t opt;
16604 cmdline_fixed_string_t field;
16609 cmd_cfg_input_set_parsed(
16610 __attribute__((unused)) void *parsed_result,
16611 __attribute__((unused)) struct cmdline *cl,
16612 __attribute__((unused)) void *data)
16614 #ifdef RTE_LIBRTE_I40E_PMD
16615 struct cmd_cfg_input_set_result *res = parsed_result;
16616 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16617 struct rte_pmd_i40e_inset inset;
16619 int ret = -ENOTSUP;
16621 if (!all_ports_stopped()) {
16622 printf("Please stop all ports first\n");
16626 #ifdef RTE_LIBRTE_I40E_PMD
16627 if (!strcmp(res->inset_type, "hash_inset"))
16628 inset_type = INSET_HASH;
16629 else if (!strcmp(res->inset_type, "fdir_inset"))
16630 inset_type = INSET_FDIR;
16631 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16632 inset_type = INSET_FDIR_FLX;
16633 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16634 &inset, inset_type);
16636 printf("Failed to get input set.\n");
16640 if (!strcmp(res->opt, "get")) {
16641 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16644 printf("Field index %d is enabled.\n", res->field_idx);
16646 printf("Field index %d is disabled.\n", res->field_idx);
16648 } else if (!strcmp(res->opt, "set"))
16649 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16651 else if (!strcmp(res->opt, "clear"))
16652 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16655 printf("Failed to configure input set field.\n");
16659 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16660 &inset, inset_type);
16662 printf("Failed to set input set.\n");
16667 if (ret == -ENOTSUP)
16668 printf("Function not supported\n");
16671 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16672 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16674 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16675 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16677 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16678 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16680 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16681 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16683 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16684 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16686 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16687 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16689 "hash_inset#fdir_inset#fdir_flx_inset");
16690 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16691 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16692 opt, "get#set#clear");
16693 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16694 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16696 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16697 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16700 cmdline_parse_inst_t cmd_cfg_input_set = {
16701 .f = cmd_cfg_input_set_parsed,
16703 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16704 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16706 (void *)&cmd_cfg_input_set_port,
16707 (void *)&cmd_cfg_input_set_cfg,
16708 (void *)&cmd_cfg_input_set_port_id,
16709 (void *)&cmd_cfg_input_set_pctype,
16710 (void *)&cmd_cfg_input_set_pctype_id,
16711 (void *)&cmd_cfg_input_set_inset_type,
16712 (void *)&cmd_cfg_input_set_opt,
16713 (void *)&cmd_cfg_input_set_field,
16714 (void *)&cmd_cfg_input_set_field_idx,
16719 /* Clear input set */
16720 struct cmd_clear_input_set_result {
16721 cmdline_fixed_string_t port;
16722 cmdline_fixed_string_t cfg;
16724 cmdline_fixed_string_t pctype;
16726 cmdline_fixed_string_t inset_type;
16727 cmdline_fixed_string_t clear;
16728 cmdline_fixed_string_t all;
16732 cmd_clear_input_set_parsed(
16733 __attribute__((unused)) void *parsed_result,
16734 __attribute__((unused)) struct cmdline *cl,
16735 __attribute__((unused)) void *data)
16737 #ifdef RTE_LIBRTE_I40E_PMD
16738 struct cmd_clear_input_set_result *res = parsed_result;
16739 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16740 struct rte_pmd_i40e_inset inset;
16742 int ret = -ENOTSUP;
16744 if (!all_ports_stopped()) {
16745 printf("Please stop all ports first\n");
16749 #ifdef RTE_LIBRTE_I40E_PMD
16750 if (!strcmp(res->inset_type, "hash_inset"))
16751 inset_type = INSET_HASH;
16752 else if (!strcmp(res->inset_type, "fdir_inset"))
16753 inset_type = INSET_FDIR;
16754 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16755 inset_type = INSET_FDIR_FLX;
16757 memset(&inset, 0, sizeof(inset));
16759 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16760 &inset, inset_type);
16762 printf("Failed to clear input set.\n");
16768 if (ret == -ENOTSUP)
16769 printf("Function not supported\n");
16772 cmdline_parse_token_string_t cmd_clear_input_set_port =
16773 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16775 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16776 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16778 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16779 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16781 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16782 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16784 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16785 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16787 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16788 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16790 "hash_inset#fdir_inset#fdir_flx_inset");
16791 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16792 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16794 cmdline_parse_token_string_t cmd_clear_input_set_all =
16795 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16798 cmdline_parse_inst_t cmd_clear_input_set = {
16799 .f = cmd_clear_input_set_parsed,
16801 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16802 "fdir_inset|fdir_flx_inset clear all",
16804 (void *)&cmd_clear_input_set_port,
16805 (void *)&cmd_clear_input_set_cfg,
16806 (void *)&cmd_clear_input_set_port_id,
16807 (void *)&cmd_clear_input_set_pctype,
16808 (void *)&cmd_clear_input_set_pctype_id,
16809 (void *)&cmd_clear_input_set_inset_type,
16810 (void *)&cmd_clear_input_set_clear,
16811 (void *)&cmd_clear_input_set_all,
16816 /* show vf stats */
16818 /* Common result structure for show vf stats */
16819 struct cmd_show_vf_stats_result {
16820 cmdline_fixed_string_t show;
16821 cmdline_fixed_string_t vf;
16822 cmdline_fixed_string_t stats;
16827 /* Common CLI fields show vf stats*/
16828 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16829 TOKEN_STRING_INITIALIZER
16830 (struct cmd_show_vf_stats_result,
16832 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16833 TOKEN_STRING_INITIALIZER
16834 (struct cmd_show_vf_stats_result,
16836 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16837 TOKEN_STRING_INITIALIZER
16838 (struct cmd_show_vf_stats_result,
16840 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16841 TOKEN_NUM_INITIALIZER
16842 (struct cmd_show_vf_stats_result,
16844 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16845 TOKEN_NUM_INITIALIZER
16846 (struct cmd_show_vf_stats_result,
16850 cmd_show_vf_stats_parsed(
16851 void *parsed_result,
16852 __attribute__((unused)) struct cmdline *cl,
16853 __attribute__((unused)) void *data)
16855 struct cmd_show_vf_stats_result *res = parsed_result;
16856 struct rte_eth_stats stats;
16857 int ret = -ENOTSUP;
16858 static const char *nic_stats_border = "########################";
16860 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16863 memset(&stats, 0, sizeof(stats));
16865 #ifdef RTE_LIBRTE_I40E_PMD
16866 if (ret == -ENOTSUP)
16867 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16871 #ifdef RTE_LIBRTE_BNXT_PMD
16872 if (ret == -ENOTSUP)
16873 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16882 printf("invalid vf_id %d\n", res->vf_id);
16885 printf("invalid port_id %d\n", res->port_id);
16888 printf("function not implemented\n");
16891 printf("programming error: (%s)\n", strerror(-ret));
16894 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16895 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16897 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16899 stats.ipackets, stats.imissed, stats.ibytes);
16900 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16901 printf(" RX-nombuf: %-10"PRIu64"\n",
16903 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16905 stats.opackets, stats.oerrors, stats.obytes);
16907 printf(" %s############################%s\n",
16908 nic_stats_border, nic_stats_border);
16911 cmdline_parse_inst_t cmd_show_vf_stats = {
16912 .f = cmd_show_vf_stats_parsed,
16914 .help_str = "show vf stats <port_id> <vf_id>",
16916 (void *)&cmd_show_vf_stats_show,
16917 (void *)&cmd_show_vf_stats_vf,
16918 (void *)&cmd_show_vf_stats_stats,
16919 (void *)&cmd_show_vf_stats_port_id,
16920 (void *)&cmd_show_vf_stats_vf_id,
16925 /* clear vf stats */
16927 /* Common result structure for clear vf stats */
16928 struct cmd_clear_vf_stats_result {
16929 cmdline_fixed_string_t clear;
16930 cmdline_fixed_string_t vf;
16931 cmdline_fixed_string_t stats;
16936 /* Common CLI fields clear vf stats*/
16937 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16938 TOKEN_STRING_INITIALIZER
16939 (struct cmd_clear_vf_stats_result,
16941 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16942 TOKEN_STRING_INITIALIZER
16943 (struct cmd_clear_vf_stats_result,
16945 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16946 TOKEN_STRING_INITIALIZER
16947 (struct cmd_clear_vf_stats_result,
16949 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16950 TOKEN_NUM_INITIALIZER
16951 (struct cmd_clear_vf_stats_result,
16953 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16954 TOKEN_NUM_INITIALIZER
16955 (struct cmd_clear_vf_stats_result,
16959 cmd_clear_vf_stats_parsed(
16960 void *parsed_result,
16961 __attribute__((unused)) struct cmdline *cl,
16962 __attribute__((unused)) void *data)
16964 struct cmd_clear_vf_stats_result *res = parsed_result;
16965 int ret = -ENOTSUP;
16967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16970 #ifdef RTE_LIBRTE_I40E_PMD
16971 if (ret == -ENOTSUP)
16972 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16975 #ifdef RTE_LIBRTE_BNXT_PMD
16976 if (ret == -ENOTSUP)
16977 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16985 printf("invalid vf_id %d\n", res->vf_id);
16988 printf("invalid port_id %d\n", res->port_id);
16991 printf("function not implemented\n");
16994 printf("programming error: (%s)\n", strerror(-ret));
16998 cmdline_parse_inst_t cmd_clear_vf_stats = {
16999 .f = cmd_clear_vf_stats_parsed,
17001 .help_str = "clear vf stats <port_id> <vf_id>",
17003 (void *)&cmd_clear_vf_stats_clear,
17004 (void *)&cmd_clear_vf_stats_vf,
17005 (void *)&cmd_clear_vf_stats_stats,
17006 (void *)&cmd_clear_vf_stats_port_id,
17007 (void *)&cmd_clear_vf_stats_vf_id,
17012 /* port config pctype mapping reset */
17014 /* Common result structure for port config pctype mapping reset */
17015 struct cmd_pctype_mapping_reset_result {
17016 cmdline_fixed_string_t port;
17017 cmdline_fixed_string_t config;
17019 cmdline_fixed_string_t pctype;
17020 cmdline_fixed_string_t mapping;
17021 cmdline_fixed_string_t reset;
17024 /* Common CLI fields for port config pctype mapping reset*/
17025 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17026 TOKEN_STRING_INITIALIZER
17027 (struct cmd_pctype_mapping_reset_result,
17029 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17030 TOKEN_STRING_INITIALIZER
17031 (struct cmd_pctype_mapping_reset_result,
17033 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17034 TOKEN_NUM_INITIALIZER
17035 (struct cmd_pctype_mapping_reset_result,
17037 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17038 TOKEN_STRING_INITIALIZER
17039 (struct cmd_pctype_mapping_reset_result,
17041 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17042 TOKEN_STRING_INITIALIZER
17043 (struct cmd_pctype_mapping_reset_result,
17044 mapping, "mapping");
17045 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17046 TOKEN_STRING_INITIALIZER
17047 (struct cmd_pctype_mapping_reset_result,
17051 cmd_pctype_mapping_reset_parsed(
17052 void *parsed_result,
17053 __attribute__((unused)) struct cmdline *cl,
17054 __attribute__((unused)) void *data)
17056 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17057 int ret = -ENOTSUP;
17059 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17062 #ifdef RTE_LIBRTE_I40E_PMD
17063 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17070 printf("invalid port_id %d\n", res->port_id);
17073 printf("function not implemented\n");
17076 printf("programming error: (%s)\n", strerror(-ret));
17080 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17081 .f = cmd_pctype_mapping_reset_parsed,
17083 .help_str = "port config <port_id> pctype mapping reset",
17085 (void *)&cmd_pctype_mapping_reset_port,
17086 (void *)&cmd_pctype_mapping_reset_config,
17087 (void *)&cmd_pctype_mapping_reset_port_id,
17088 (void *)&cmd_pctype_mapping_reset_pctype,
17089 (void *)&cmd_pctype_mapping_reset_mapping,
17090 (void *)&cmd_pctype_mapping_reset_reset,
17095 /* show port pctype mapping */
17097 /* Common result structure for show port pctype mapping */
17098 struct cmd_pctype_mapping_get_result {
17099 cmdline_fixed_string_t show;
17100 cmdline_fixed_string_t port;
17102 cmdline_fixed_string_t pctype;
17103 cmdline_fixed_string_t mapping;
17106 /* Common CLI fields for pctype mapping get */
17107 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17108 TOKEN_STRING_INITIALIZER
17109 (struct cmd_pctype_mapping_get_result,
17111 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17112 TOKEN_STRING_INITIALIZER
17113 (struct cmd_pctype_mapping_get_result,
17115 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17116 TOKEN_NUM_INITIALIZER
17117 (struct cmd_pctype_mapping_get_result,
17119 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17120 TOKEN_STRING_INITIALIZER
17121 (struct cmd_pctype_mapping_get_result,
17123 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17124 TOKEN_STRING_INITIALIZER
17125 (struct cmd_pctype_mapping_get_result,
17126 mapping, "mapping");
17129 cmd_pctype_mapping_get_parsed(
17130 void *parsed_result,
17131 __attribute__((unused)) struct cmdline *cl,
17132 __attribute__((unused)) void *data)
17134 struct cmd_pctype_mapping_get_result *res = parsed_result;
17135 int ret = -ENOTSUP;
17136 #ifdef RTE_LIBRTE_I40E_PMD
17137 struct rte_pmd_i40e_flow_type_mapping
17138 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17139 int i, j, first_pctype;
17142 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17145 #ifdef RTE_LIBRTE_I40E_PMD
17146 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17153 printf("invalid port_id %d\n", res->port_id);
17156 printf("function not implemented\n");
17159 printf("programming error: (%s)\n", strerror(-ret));
17163 #ifdef RTE_LIBRTE_I40E_PMD
17164 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17165 if (mapping[i].pctype != 0ULL) {
17168 printf("pctype: ");
17169 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17170 if (mapping[i].pctype & (1ULL << j)) {
17171 printf(first_pctype ?
17172 "%02d" : ",%02d", j);
17176 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17182 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17183 .f = cmd_pctype_mapping_get_parsed,
17185 .help_str = "show port <port_id> pctype mapping",
17187 (void *)&cmd_pctype_mapping_get_show,
17188 (void *)&cmd_pctype_mapping_get_port,
17189 (void *)&cmd_pctype_mapping_get_port_id,
17190 (void *)&cmd_pctype_mapping_get_pctype,
17191 (void *)&cmd_pctype_mapping_get_mapping,
17196 /* port config pctype mapping update */
17198 /* Common result structure for port config pctype mapping update */
17199 struct cmd_pctype_mapping_update_result {
17200 cmdline_fixed_string_t port;
17201 cmdline_fixed_string_t config;
17203 cmdline_fixed_string_t pctype;
17204 cmdline_fixed_string_t mapping;
17205 cmdline_fixed_string_t update;
17206 cmdline_fixed_string_t pctype_list;
17207 uint16_t flow_type;
17210 /* Common CLI fields for pctype mapping update*/
17211 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17212 TOKEN_STRING_INITIALIZER
17213 (struct cmd_pctype_mapping_update_result,
17215 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17216 TOKEN_STRING_INITIALIZER
17217 (struct cmd_pctype_mapping_update_result,
17219 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17220 TOKEN_NUM_INITIALIZER
17221 (struct cmd_pctype_mapping_update_result,
17223 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17224 TOKEN_STRING_INITIALIZER
17225 (struct cmd_pctype_mapping_update_result,
17227 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17228 TOKEN_STRING_INITIALIZER
17229 (struct cmd_pctype_mapping_update_result,
17230 mapping, "mapping");
17231 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17232 TOKEN_STRING_INITIALIZER
17233 (struct cmd_pctype_mapping_update_result,
17235 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17236 TOKEN_STRING_INITIALIZER
17237 (struct cmd_pctype_mapping_update_result,
17238 pctype_list, NULL);
17239 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17240 TOKEN_NUM_INITIALIZER
17241 (struct cmd_pctype_mapping_update_result,
17242 flow_type, UINT16);
17245 cmd_pctype_mapping_update_parsed(
17246 void *parsed_result,
17247 __attribute__((unused)) struct cmdline *cl,
17248 __attribute__((unused)) void *data)
17250 struct cmd_pctype_mapping_update_result *res = parsed_result;
17251 int ret = -ENOTSUP;
17252 #ifdef RTE_LIBRTE_I40E_PMD
17253 struct rte_pmd_i40e_flow_type_mapping mapping;
17255 unsigned int nb_item;
17256 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17259 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17262 #ifdef RTE_LIBRTE_I40E_PMD
17263 nb_item = parse_item_list(res->pctype_list, "pctypes",
17264 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17265 mapping.flow_type = res->flow_type;
17266 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17267 mapping.pctype |= (1ULL << pctype_list[i]);
17268 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17278 printf("invalid pctype or flow type\n");
17281 printf("invalid port_id %d\n", res->port_id);
17284 printf("function not implemented\n");
17287 printf("programming error: (%s)\n", strerror(-ret));
17291 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17292 .f = cmd_pctype_mapping_update_parsed,
17294 .help_str = "port config <port_id> pctype mapping update"
17295 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17297 (void *)&cmd_pctype_mapping_update_port,
17298 (void *)&cmd_pctype_mapping_update_config,
17299 (void *)&cmd_pctype_mapping_update_port_id,
17300 (void *)&cmd_pctype_mapping_update_pctype,
17301 (void *)&cmd_pctype_mapping_update_mapping,
17302 (void *)&cmd_pctype_mapping_update_update,
17303 (void *)&cmd_pctype_mapping_update_pc_type,
17304 (void *)&cmd_pctype_mapping_update_flow_type,
17309 /* ptype mapping get */
17311 /* Common result structure for ptype mapping get */
17312 struct cmd_ptype_mapping_get_result {
17313 cmdline_fixed_string_t ptype;
17314 cmdline_fixed_string_t mapping;
17315 cmdline_fixed_string_t get;
17317 uint8_t valid_only;
17320 /* Common CLI fields for ptype mapping get */
17321 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17322 TOKEN_STRING_INITIALIZER
17323 (struct cmd_ptype_mapping_get_result,
17325 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17326 TOKEN_STRING_INITIALIZER
17327 (struct cmd_ptype_mapping_get_result,
17328 mapping, "mapping");
17329 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17330 TOKEN_STRING_INITIALIZER
17331 (struct cmd_ptype_mapping_get_result,
17333 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17334 TOKEN_NUM_INITIALIZER
17335 (struct cmd_ptype_mapping_get_result,
17337 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17338 TOKEN_NUM_INITIALIZER
17339 (struct cmd_ptype_mapping_get_result,
17340 valid_only, UINT8);
17343 cmd_ptype_mapping_get_parsed(
17344 void *parsed_result,
17345 __attribute__((unused)) struct cmdline *cl,
17346 __attribute__((unused)) void *data)
17348 struct cmd_ptype_mapping_get_result *res = parsed_result;
17349 int ret = -ENOTSUP;
17350 #ifdef RTE_LIBRTE_I40E_PMD
17351 int max_ptype_num = 256;
17352 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17357 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17360 #ifdef RTE_LIBRTE_I40E_PMD
17361 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17372 printf("invalid port_id %d\n", res->port_id);
17375 printf("function not implemented\n");
17378 printf("programming error: (%s)\n", strerror(-ret));
17381 #ifdef RTE_LIBRTE_I40E_PMD
17383 for (i = 0; i < count; i++)
17384 printf("%3d\t0x%08x\n",
17385 mapping[i].hw_ptype, mapping[i].sw_ptype);
17390 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17391 .f = cmd_ptype_mapping_get_parsed,
17393 .help_str = "ptype mapping get <port_id> <valid_only>",
17395 (void *)&cmd_ptype_mapping_get_ptype,
17396 (void *)&cmd_ptype_mapping_get_mapping,
17397 (void *)&cmd_ptype_mapping_get_get,
17398 (void *)&cmd_ptype_mapping_get_port_id,
17399 (void *)&cmd_ptype_mapping_get_valid_only,
17404 /* ptype mapping replace */
17406 /* Common result structure for ptype mapping replace */
17407 struct cmd_ptype_mapping_replace_result {
17408 cmdline_fixed_string_t ptype;
17409 cmdline_fixed_string_t mapping;
17410 cmdline_fixed_string_t replace;
17417 /* Common CLI fields for ptype mapping replace */
17418 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17419 TOKEN_STRING_INITIALIZER
17420 (struct cmd_ptype_mapping_replace_result,
17422 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17423 TOKEN_STRING_INITIALIZER
17424 (struct cmd_ptype_mapping_replace_result,
17425 mapping, "mapping");
17426 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17427 TOKEN_STRING_INITIALIZER
17428 (struct cmd_ptype_mapping_replace_result,
17429 replace, "replace");
17430 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17431 TOKEN_NUM_INITIALIZER
17432 (struct cmd_ptype_mapping_replace_result,
17434 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17435 TOKEN_NUM_INITIALIZER
17436 (struct cmd_ptype_mapping_replace_result,
17438 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17439 TOKEN_NUM_INITIALIZER
17440 (struct cmd_ptype_mapping_replace_result,
17442 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17443 TOKEN_NUM_INITIALIZER
17444 (struct cmd_ptype_mapping_replace_result,
17448 cmd_ptype_mapping_replace_parsed(
17449 void *parsed_result,
17450 __attribute__((unused)) struct cmdline *cl,
17451 __attribute__((unused)) void *data)
17453 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17454 int ret = -ENOTSUP;
17456 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17459 #ifdef RTE_LIBRTE_I40E_PMD
17460 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17470 printf("invalid ptype 0x%8x or 0x%8x\n",
17471 res->target, res->pkt_type);
17474 printf("invalid port_id %d\n", res->port_id);
17477 printf("function not implemented\n");
17480 printf("programming error: (%s)\n", strerror(-ret));
17484 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17485 .f = cmd_ptype_mapping_replace_parsed,
17488 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17490 (void *)&cmd_ptype_mapping_replace_ptype,
17491 (void *)&cmd_ptype_mapping_replace_mapping,
17492 (void *)&cmd_ptype_mapping_replace_replace,
17493 (void *)&cmd_ptype_mapping_replace_port_id,
17494 (void *)&cmd_ptype_mapping_replace_target,
17495 (void *)&cmd_ptype_mapping_replace_mask,
17496 (void *)&cmd_ptype_mapping_replace_pkt_type,
17501 /* ptype mapping reset */
17503 /* Common result structure for ptype mapping reset */
17504 struct cmd_ptype_mapping_reset_result {
17505 cmdline_fixed_string_t ptype;
17506 cmdline_fixed_string_t mapping;
17507 cmdline_fixed_string_t reset;
17511 /* Common CLI fields for ptype mapping reset*/
17512 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17513 TOKEN_STRING_INITIALIZER
17514 (struct cmd_ptype_mapping_reset_result,
17516 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17517 TOKEN_STRING_INITIALIZER
17518 (struct cmd_ptype_mapping_reset_result,
17519 mapping, "mapping");
17520 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17521 TOKEN_STRING_INITIALIZER
17522 (struct cmd_ptype_mapping_reset_result,
17524 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17525 TOKEN_NUM_INITIALIZER
17526 (struct cmd_ptype_mapping_reset_result,
17530 cmd_ptype_mapping_reset_parsed(
17531 void *parsed_result,
17532 __attribute__((unused)) struct cmdline *cl,
17533 __attribute__((unused)) void *data)
17535 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17536 int ret = -ENOTSUP;
17538 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17541 #ifdef RTE_LIBRTE_I40E_PMD
17542 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17549 printf("invalid port_id %d\n", res->port_id);
17552 printf("function not implemented\n");
17555 printf("programming error: (%s)\n", strerror(-ret));
17559 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17560 .f = cmd_ptype_mapping_reset_parsed,
17562 .help_str = "ptype mapping reset <port_id>",
17564 (void *)&cmd_ptype_mapping_reset_ptype,
17565 (void *)&cmd_ptype_mapping_reset_mapping,
17566 (void *)&cmd_ptype_mapping_reset_reset,
17567 (void *)&cmd_ptype_mapping_reset_port_id,
17572 /* ptype mapping update */
17574 /* Common result structure for ptype mapping update */
17575 struct cmd_ptype_mapping_update_result {
17576 cmdline_fixed_string_t ptype;
17577 cmdline_fixed_string_t mapping;
17578 cmdline_fixed_string_t reset;
17584 /* Common CLI fields for ptype mapping update*/
17585 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17586 TOKEN_STRING_INITIALIZER
17587 (struct cmd_ptype_mapping_update_result,
17589 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17590 TOKEN_STRING_INITIALIZER
17591 (struct cmd_ptype_mapping_update_result,
17592 mapping, "mapping");
17593 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17594 TOKEN_STRING_INITIALIZER
17595 (struct cmd_ptype_mapping_update_result,
17597 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17598 TOKEN_NUM_INITIALIZER
17599 (struct cmd_ptype_mapping_update_result,
17601 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17602 TOKEN_NUM_INITIALIZER
17603 (struct cmd_ptype_mapping_update_result,
17605 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17606 TOKEN_NUM_INITIALIZER
17607 (struct cmd_ptype_mapping_update_result,
17611 cmd_ptype_mapping_update_parsed(
17612 void *parsed_result,
17613 __attribute__((unused)) struct cmdline *cl,
17614 __attribute__((unused)) void *data)
17616 struct cmd_ptype_mapping_update_result *res = parsed_result;
17617 int ret = -ENOTSUP;
17618 #ifdef RTE_LIBRTE_I40E_PMD
17619 struct rte_pmd_i40e_ptype_mapping mapping;
17621 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17624 #ifdef RTE_LIBRTE_I40E_PMD
17625 mapping.hw_ptype = res->hw_ptype;
17626 mapping.sw_ptype = res->sw_ptype;
17627 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17637 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17640 printf("invalid port_id %d\n", res->port_id);
17643 printf("function not implemented\n");
17646 printf("programming error: (%s)\n", strerror(-ret));
17650 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17651 .f = cmd_ptype_mapping_update_parsed,
17653 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17655 (void *)&cmd_ptype_mapping_update_ptype,
17656 (void *)&cmd_ptype_mapping_update_mapping,
17657 (void *)&cmd_ptype_mapping_update_update,
17658 (void *)&cmd_ptype_mapping_update_port_id,
17659 (void *)&cmd_ptype_mapping_update_hw_ptype,
17660 (void *)&cmd_ptype_mapping_update_sw_ptype,
17665 /* Common result structure for file commands */
17666 struct cmd_cmdfile_result {
17667 cmdline_fixed_string_t load;
17668 cmdline_fixed_string_t filename;
17671 /* Common CLI fields for file commands */
17672 cmdline_parse_token_string_t cmd_load_cmdfile =
17673 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17674 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17675 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17678 cmd_load_from_file_parsed(
17679 void *parsed_result,
17680 __attribute__((unused)) struct cmdline *cl,
17681 __attribute__((unused)) void *data)
17683 struct cmd_cmdfile_result *res = parsed_result;
17685 cmdline_read_from_file(res->filename);
17688 cmdline_parse_inst_t cmd_load_from_file = {
17689 .f = cmd_load_from_file_parsed,
17691 .help_str = "load <filename>",
17693 (void *)&cmd_load_cmdfile,
17694 (void *)&cmd_load_cmdfile_filename,
17699 /* Get Rx offloads capabilities */
17700 struct cmd_rx_offload_get_capa_result {
17701 cmdline_fixed_string_t show;
17702 cmdline_fixed_string_t port;
17704 cmdline_fixed_string_t rx_offload;
17705 cmdline_fixed_string_t capabilities;
17708 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17709 TOKEN_STRING_INITIALIZER
17710 (struct cmd_rx_offload_get_capa_result,
17712 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17713 TOKEN_STRING_INITIALIZER
17714 (struct cmd_rx_offload_get_capa_result,
17716 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17717 TOKEN_NUM_INITIALIZER
17718 (struct cmd_rx_offload_get_capa_result,
17720 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17721 TOKEN_STRING_INITIALIZER
17722 (struct cmd_rx_offload_get_capa_result,
17723 rx_offload, "rx_offload");
17724 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17725 TOKEN_STRING_INITIALIZER
17726 (struct cmd_rx_offload_get_capa_result,
17727 capabilities, "capabilities");
17730 print_rx_offloads(uint64_t offloads)
17732 uint64_t single_offload;
17740 begin = __builtin_ctzll(offloads);
17741 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17743 single_offload = 1 << begin;
17744 for (bit = begin; bit < end; bit++) {
17745 if (offloads & single_offload)
17747 rte_eth_dev_rx_offload_name(single_offload));
17748 single_offload <<= 1;
17753 cmd_rx_offload_get_capa_parsed(
17754 void *parsed_result,
17755 __attribute__((unused)) struct cmdline *cl,
17756 __attribute__((unused)) void *data)
17758 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17759 struct rte_eth_dev_info dev_info;
17760 portid_t port_id = res->port_id;
17761 uint64_t queue_offloads;
17762 uint64_t port_offloads;
17764 rte_eth_dev_info_get(port_id, &dev_info);
17765 queue_offloads = dev_info.rx_queue_offload_capa;
17766 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17768 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17769 printf(" Per Queue :");
17770 print_rx_offloads(queue_offloads);
17773 printf(" Per Port :");
17774 print_rx_offloads(port_offloads);
17778 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17779 .f = cmd_rx_offload_get_capa_parsed,
17781 .help_str = "show port <port_id> rx_offload capabilities",
17783 (void *)&cmd_rx_offload_get_capa_show,
17784 (void *)&cmd_rx_offload_get_capa_port,
17785 (void *)&cmd_rx_offload_get_capa_port_id,
17786 (void *)&cmd_rx_offload_get_capa_rx_offload,
17787 (void *)&cmd_rx_offload_get_capa_capabilities,
17792 /* Get Rx offloads configuration */
17793 struct cmd_rx_offload_get_configuration_result {
17794 cmdline_fixed_string_t show;
17795 cmdline_fixed_string_t port;
17797 cmdline_fixed_string_t rx_offload;
17798 cmdline_fixed_string_t configuration;
17801 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17802 TOKEN_STRING_INITIALIZER
17803 (struct cmd_rx_offload_get_configuration_result,
17805 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17806 TOKEN_STRING_INITIALIZER
17807 (struct cmd_rx_offload_get_configuration_result,
17809 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17810 TOKEN_NUM_INITIALIZER
17811 (struct cmd_rx_offload_get_configuration_result,
17813 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17814 TOKEN_STRING_INITIALIZER
17815 (struct cmd_rx_offload_get_configuration_result,
17816 rx_offload, "rx_offload");
17817 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17818 TOKEN_STRING_INITIALIZER
17819 (struct cmd_rx_offload_get_configuration_result,
17820 configuration, "configuration");
17823 cmd_rx_offload_get_configuration_parsed(
17824 void *parsed_result,
17825 __attribute__((unused)) struct cmdline *cl,
17826 __attribute__((unused)) void *data)
17828 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17829 struct rte_eth_dev_info dev_info;
17830 portid_t port_id = res->port_id;
17831 struct rte_port *port = &ports[port_id];
17832 uint64_t port_offloads;
17833 uint64_t queue_offloads;
17834 uint16_t nb_rx_queues;
17837 printf("Rx Offloading Configuration of port %d :\n", port_id);
17839 port_offloads = port->dev_conf.rxmode.offloads;
17841 print_rx_offloads(port_offloads);
17844 rte_eth_dev_info_get(port_id, &dev_info);
17845 nb_rx_queues = dev_info.nb_rx_queues;
17846 for (q = 0; q < nb_rx_queues; q++) {
17847 queue_offloads = port->rx_conf[q].offloads;
17848 printf(" Queue[%2d] :", q);
17849 print_rx_offloads(queue_offloads);
17855 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17856 .f = cmd_rx_offload_get_configuration_parsed,
17858 .help_str = "show port <port_id> rx_offload configuration",
17860 (void *)&cmd_rx_offload_get_configuration_show,
17861 (void *)&cmd_rx_offload_get_configuration_port,
17862 (void *)&cmd_rx_offload_get_configuration_port_id,
17863 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17864 (void *)&cmd_rx_offload_get_configuration_configuration,
17869 /* Enable/Disable a per port offloading */
17870 struct cmd_config_per_port_rx_offload_result {
17871 cmdline_fixed_string_t port;
17872 cmdline_fixed_string_t config;
17874 cmdline_fixed_string_t rx_offload;
17875 cmdline_fixed_string_t offload;
17876 cmdline_fixed_string_t on_off;
17879 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17880 TOKEN_STRING_INITIALIZER
17881 (struct cmd_config_per_port_rx_offload_result,
17883 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17884 TOKEN_STRING_INITIALIZER
17885 (struct cmd_config_per_port_rx_offload_result,
17887 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17888 TOKEN_NUM_INITIALIZER
17889 (struct cmd_config_per_port_rx_offload_result,
17891 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17892 TOKEN_STRING_INITIALIZER
17893 (struct cmd_config_per_port_rx_offload_result,
17894 rx_offload, "rx_offload");
17895 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17896 TOKEN_STRING_INITIALIZER
17897 (struct cmd_config_per_port_rx_offload_result,
17898 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17899 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17900 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17901 "crc_strip#scatter#timestamp#security#keep_crc");
17902 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17903 TOKEN_STRING_INITIALIZER
17904 (struct cmd_config_per_port_rx_offload_result,
17908 search_rx_offload(const char *name)
17910 uint64_t single_offload;
17911 const char *single_name;
17915 single_offload = 1;
17916 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17917 single_name = rte_eth_dev_rx_offload_name(single_offload);
17918 if (!strcasecmp(single_name, name)) {
17922 single_offload <<= 1;
17926 return single_offload;
17932 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17933 __attribute__((unused)) struct cmdline *cl,
17934 __attribute__((unused)) void *data)
17936 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17937 portid_t port_id = res->port_id;
17938 struct rte_eth_dev_info dev_info;
17939 struct rte_port *port = &ports[port_id];
17940 uint64_t single_offload;
17941 uint16_t nb_rx_queues;
17944 if (port->port_status != RTE_PORT_STOPPED) {
17945 printf("Error: Can't config offload when Port %d "
17946 "is not stopped\n", port_id);
17950 single_offload = search_rx_offload(res->offload);
17951 if (single_offload == 0) {
17952 printf("Unknown offload name: %s\n", res->offload);
17956 rte_eth_dev_info_get(port_id, &dev_info);
17957 nb_rx_queues = dev_info.nb_rx_queues;
17958 if (!strcmp(res->on_off, "on")) {
17959 port->dev_conf.rxmode.offloads |= single_offload;
17960 for (q = 0; q < nb_rx_queues; q++)
17961 port->rx_conf[q].offloads |= single_offload;
17963 port->dev_conf.rxmode.offloads &= ~single_offload;
17964 for (q = 0; q < nb_rx_queues; q++)
17965 port->rx_conf[q].offloads &= ~single_offload;
17968 cmd_reconfig_device_queue(port_id, 1, 1);
17971 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17972 .f = cmd_config_per_port_rx_offload_parsed,
17974 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17975 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17976 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17977 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17980 (void *)&cmd_config_per_port_rx_offload_result_port,
17981 (void *)&cmd_config_per_port_rx_offload_result_config,
17982 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17983 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17984 (void *)&cmd_config_per_port_rx_offload_result_offload,
17985 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17990 /* Enable/Disable a per queue offloading */
17991 struct cmd_config_per_queue_rx_offload_result {
17992 cmdline_fixed_string_t port;
17994 cmdline_fixed_string_t rxq;
17996 cmdline_fixed_string_t rx_offload;
17997 cmdline_fixed_string_t offload;
17998 cmdline_fixed_string_t on_off;
18001 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18002 TOKEN_STRING_INITIALIZER
18003 (struct cmd_config_per_queue_rx_offload_result,
18005 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18006 TOKEN_NUM_INITIALIZER
18007 (struct cmd_config_per_queue_rx_offload_result,
18009 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18010 TOKEN_STRING_INITIALIZER
18011 (struct cmd_config_per_queue_rx_offload_result,
18013 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18014 TOKEN_NUM_INITIALIZER
18015 (struct cmd_config_per_queue_rx_offload_result,
18017 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18018 TOKEN_STRING_INITIALIZER
18019 (struct cmd_config_per_queue_rx_offload_result,
18020 rx_offload, "rx_offload");
18021 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18022 TOKEN_STRING_INITIALIZER
18023 (struct cmd_config_per_queue_rx_offload_result,
18024 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18025 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18026 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18027 "crc_strip#scatter#timestamp#security#keep_crc");
18028 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18029 TOKEN_STRING_INITIALIZER
18030 (struct cmd_config_per_queue_rx_offload_result,
18034 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18035 __attribute__((unused)) struct cmdline *cl,
18036 __attribute__((unused)) void *data)
18038 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18039 struct rte_eth_dev_info dev_info;
18040 portid_t port_id = res->port_id;
18041 uint16_t queue_id = res->queue_id;
18042 struct rte_port *port = &ports[port_id];
18043 uint64_t single_offload;
18045 if (port->port_status != RTE_PORT_STOPPED) {
18046 printf("Error: Can't config offload when Port %d "
18047 "is not stopped\n", port_id);
18051 rte_eth_dev_info_get(port_id, &dev_info);
18052 if (queue_id >= dev_info.nb_rx_queues) {
18053 printf("Error: input queue_id should be 0 ... "
18054 "%d\n", dev_info.nb_rx_queues - 1);
18058 single_offload = search_rx_offload(res->offload);
18059 if (single_offload == 0) {
18060 printf("Unknown offload name: %s\n", res->offload);
18064 if (!strcmp(res->on_off, "on"))
18065 port->rx_conf[queue_id].offloads |= single_offload;
18067 port->rx_conf[queue_id].offloads &= ~single_offload;
18069 cmd_reconfig_device_queue(port_id, 1, 1);
18072 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18073 .f = cmd_config_per_queue_rx_offload_parsed,
18075 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18076 "vlan_strip|ipv4_cksum|"
18077 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18078 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18079 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18082 (void *)&cmd_config_per_queue_rx_offload_result_port,
18083 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18084 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18085 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18086 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18087 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18088 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18093 /* Get Tx offloads capabilities */
18094 struct cmd_tx_offload_get_capa_result {
18095 cmdline_fixed_string_t show;
18096 cmdline_fixed_string_t port;
18098 cmdline_fixed_string_t tx_offload;
18099 cmdline_fixed_string_t capabilities;
18102 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18103 TOKEN_STRING_INITIALIZER
18104 (struct cmd_tx_offload_get_capa_result,
18106 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18107 TOKEN_STRING_INITIALIZER
18108 (struct cmd_tx_offload_get_capa_result,
18110 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18111 TOKEN_NUM_INITIALIZER
18112 (struct cmd_tx_offload_get_capa_result,
18114 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18115 TOKEN_STRING_INITIALIZER
18116 (struct cmd_tx_offload_get_capa_result,
18117 tx_offload, "tx_offload");
18118 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18119 TOKEN_STRING_INITIALIZER
18120 (struct cmd_tx_offload_get_capa_result,
18121 capabilities, "capabilities");
18124 print_tx_offloads(uint64_t offloads)
18126 uint64_t single_offload;
18134 begin = __builtin_ctzll(offloads);
18135 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18137 single_offload = 1 << begin;
18138 for (bit = begin; bit < end; bit++) {
18139 if (offloads & single_offload)
18141 rte_eth_dev_tx_offload_name(single_offload));
18142 single_offload <<= 1;
18147 cmd_tx_offload_get_capa_parsed(
18148 void *parsed_result,
18149 __attribute__((unused)) struct cmdline *cl,
18150 __attribute__((unused)) void *data)
18152 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18153 struct rte_eth_dev_info dev_info;
18154 portid_t port_id = res->port_id;
18155 uint64_t queue_offloads;
18156 uint64_t port_offloads;
18158 rte_eth_dev_info_get(port_id, &dev_info);
18159 queue_offloads = dev_info.tx_queue_offload_capa;
18160 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18162 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18163 printf(" Per Queue :");
18164 print_tx_offloads(queue_offloads);
18167 printf(" Per Port :");
18168 print_tx_offloads(port_offloads);
18172 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18173 .f = cmd_tx_offload_get_capa_parsed,
18175 .help_str = "show port <port_id> tx_offload capabilities",
18177 (void *)&cmd_tx_offload_get_capa_show,
18178 (void *)&cmd_tx_offload_get_capa_port,
18179 (void *)&cmd_tx_offload_get_capa_port_id,
18180 (void *)&cmd_tx_offload_get_capa_tx_offload,
18181 (void *)&cmd_tx_offload_get_capa_capabilities,
18186 /* Get Tx offloads configuration */
18187 struct cmd_tx_offload_get_configuration_result {
18188 cmdline_fixed_string_t show;
18189 cmdline_fixed_string_t port;
18191 cmdline_fixed_string_t tx_offload;
18192 cmdline_fixed_string_t configuration;
18195 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18196 TOKEN_STRING_INITIALIZER
18197 (struct cmd_tx_offload_get_configuration_result,
18199 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18200 TOKEN_STRING_INITIALIZER
18201 (struct cmd_tx_offload_get_configuration_result,
18203 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18204 TOKEN_NUM_INITIALIZER
18205 (struct cmd_tx_offload_get_configuration_result,
18207 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18208 TOKEN_STRING_INITIALIZER
18209 (struct cmd_tx_offload_get_configuration_result,
18210 tx_offload, "tx_offload");
18211 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18212 TOKEN_STRING_INITIALIZER
18213 (struct cmd_tx_offload_get_configuration_result,
18214 configuration, "configuration");
18217 cmd_tx_offload_get_configuration_parsed(
18218 void *parsed_result,
18219 __attribute__((unused)) struct cmdline *cl,
18220 __attribute__((unused)) void *data)
18222 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18223 struct rte_eth_dev_info dev_info;
18224 portid_t port_id = res->port_id;
18225 struct rte_port *port = &ports[port_id];
18226 uint64_t port_offloads;
18227 uint64_t queue_offloads;
18228 uint16_t nb_tx_queues;
18231 printf("Tx Offloading Configuration of port %d :\n", port_id);
18233 port_offloads = port->dev_conf.txmode.offloads;
18235 print_tx_offloads(port_offloads);
18238 rte_eth_dev_info_get(port_id, &dev_info);
18239 nb_tx_queues = dev_info.nb_tx_queues;
18240 for (q = 0; q < nb_tx_queues; q++) {
18241 queue_offloads = port->tx_conf[q].offloads;
18242 printf(" Queue[%2d] :", q);
18243 print_tx_offloads(queue_offloads);
18249 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18250 .f = cmd_tx_offload_get_configuration_parsed,
18252 .help_str = "show port <port_id> tx_offload configuration",
18254 (void *)&cmd_tx_offload_get_configuration_show,
18255 (void *)&cmd_tx_offload_get_configuration_port,
18256 (void *)&cmd_tx_offload_get_configuration_port_id,
18257 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18258 (void *)&cmd_tx_offload_get_configuration_configuration,
18263 /* Enable/Disable a per port offloading */
18264 struct cmd_config_per_port_tx_offload_result {
18265 cmdline_fixed_string_t port;
18266 cmdline_fixed_string_t config;
18268 cmdline_fixed_string_t tx_offload;
18269 cmdline_fixed_string_t offload;
18270 cmdline_fixed_string_t on_off;
18273 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18274 TOKEN_STRING_INITIALIZER
18275 (struct cmd_config_per_port_tx_offload_result,
18277 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18278 TOKEN_STRING_INITIALIZER
18279 (struct cmd_config_per_port_tx_offload_result,
18281 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18282 TOKEN_NUM_INITIALIZER
18283 (struct cmd_config_per_port_tx_offload_result,
18285 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18286 TOKEN_STRING_INITIALIZER
18287 (struct cmd_config_per_port_tx_offload_result,
18288 tx_offload, "tx_offload");
18289 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18290 TOKEN_STRING_INITIALIZER
18291 (struct cmd_config_per_port_tx_offload_result,
18292 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18293 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18294 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18295 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18296 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18298 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18299 TOKEN_STRING_INITIALIZER
18300 (struct cmd_config_per_port_tx_offload_result,
18304 search_tx_offload(const char *name)
18306 uint64_t single_offload;
18307 const char *single_name;
18311 single_offload = 1;
18312 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18313 single_name = rte_eth_dev_tx_offload_name(single_offload);
18314 if (!strcasecmp(single_name, name)) {
18317 } else if (!strcasecmp(single_name, "UNKNOWN"))
18319 else if (single_name == NULL)
18321 single_offload <<= 1;
18325 return single_offload;
18331 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18332 __attribute__((unused)) struct cmdline *cl,
18333 __attribute__((unused)) void *data)
18335 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18336 portid_t port_id = res->port_id;
18337 struct rte_eth_dev_info dev_info;
18338 struct rte_port *port = &ports[port_id];
18339 uint64_t single_offload;
18340 uint16_t nb_tx_queues;
18343 if (port->port_status != RTE_PORT_STOPPED) {
18344 printf("Error: Can't config offload when Port %d "
18345 "is not stopped\n", port_id);
18349 single_offload = search_tx_offload(res->offload);
18350 if (single_offload == 0) {
18351 printf("Unknown offload name: %s\n", res->offload);
18355 rte_eth_dev_info_get(port_id, &dev_info);
18356 nb_tx_queues = dev_info.nb_tx_queues;
18357 if (!strcmp(res->on_off, "on")) {
18358 port->dev_conf.txmode.offloads |= single_offload;
18359 for (q = 0; q < nb_tx_queues; q++)
18360 port->tx_conf[q].offloads |= single_offload;
18362 port->dev_conf.txmode.offloads &= ~single_offload;
18363 for (q = 0; q < nb_tx_queues; q++)
18364 port->tx_conf[q].offloads &= ~single_offload;
18367 cmd_reconfig_device_queue(port_id, 1, 1);
18370 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18371 .f = cmd_config_per_port_tx_offload_parsed,
18373 .help_str = "port config <port_id> tx_offload "
18374 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18375 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18376 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18377 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18378 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18379 "match_metadata on|off",
18381 (void *)&cmd_config_per_port_tx_offload_result_port,
18382 (void *)&cmd_config_per_port_tx_offload_result_config,
18383 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18384 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18385 (void *)&cmd_config_per_port_tx_offload_result_offload,
18386 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18391 /* Enable/Disable a per queue offloading */
18392 struct cmd_config_per_queue_tx_offload_result {
18393 cmdline_fixed_string_t port;
18395 cmdline_fixed_string_t txq;
18397 cmdline_fixed_string_t tx_offload;
18398 cmdline_fixed_string_t offload;
18399 cmdline_fixed_string_t on_off;
18402 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18403 TOKEN_STRING_INITIALIZER
18404 (struct cmd_config_per_queue_tx_offload_result,
18406 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18407 TOKEN_NUM_INITIALIZER
18408 (struct cmd_config_per_queue_tx_offload_result,
18410 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18411 TOKEN_STRING_INITIALIZER
18412 (struct cmd_config_per_queue_tx_offload_result,
18414 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18415 TOKEN_NUM_INITIALIZER
18416 (struct cmd_config_per_queue_tx_offload_result,
18418 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18419 TOKEN_STRING_INITIALIZER
18420 (struct cmd_config_per_queue_tx_offload_result,
18421 tx_offload, "tx_offload");
18422 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18423 TOKEN_STRING_INITIALIZER
18424 (struct cmd_config_per_queue_tx_offload_result,
18425 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18426 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18427 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18428 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18429 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18430 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18431 TOKEN_STRING_INITIALIZER
18432 (struct cmd_config_per_queue_tx_offload_result,
18436 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18437 __attribute__((unused)) struct cmdline *cl,
18438 __attribute__((unused)) void *data)
18440 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18441 struct rte_eth_dev_info dev_info;
18442 portid_t port_id = res->port_id;
18443 uint16_t queue_id = res->queue_id;
18444 struct rte_port *port = &ports[port_id];
18445 uint64_t single_offload;
18447 if (port->port_status != RTE_PORT_STOPPED) {
18448 printf("Error: Can't config offload when Port %d "
18449 "is not stopped\n", port_id);
18453 rte_eth_dev_info_get(port_id, &dev_info);
18454 if (queue_id >= dev_info.nb_tx_queues) {
18455 printf("Error: input queue_id should be 0 ... "
18456 "%d\n", dev_info.nb_tx_queues - 1);
18460 single_offload = search_tx_offload(res->offload);
18461 if (single_offload == 0) {
18462 printf("Unknown offload name: %s\n", res->offload);
18466 if (!strcmp(res->on_off, "on"))
18467 port->tx_conf[queue_id].offloads |= single_offload;
18469 port->tx_conf[queue_id].offloads &= ~single_offload;
18471 cmd_reconfig_device_queue(port_id, 1, 1);
18474 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18475 .f = cmd_config_per_queue_tx_offload_parsed,
18477 .help_str = "port <port_id> txq <queue_id> tx_offload "
18478 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18479 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18480 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18481 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18482 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18485 (void *)&cmd_config_per_queue_tx_offload_result_port,
18486 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18487 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18488 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18489 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18490 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18491 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18496 /* *** configure tx_metadata for specific port *** */
18497 struct cmd_config_tx_metadata_specific_result {
18498 cmdline_fixed_string_t port;
18499 cmdline_fixed_string_t keyword;
18501 cmdline_fixed_string_t item;
18506 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18507 __attribute__((unused)) struct cmdline *cl,
18508 __attribute__((unused)) void *data)
18510 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18512 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18514 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18515 /* Add/remove callback to insert valid metadata in every Tx packet. */
18516 if (ports[res->port_id].tx_metadata)
18517 add_tx_md_callback(res->port_id);
18519 remove_tx_md_callback(res->port_id);
18522 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18523 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18525 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18526 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18527 keyword, "config");
18528 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18529 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18531 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18532 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18533 item, "tx_metadata");
18534 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18535 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18538 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18539 .f = cmd_config_tx_metadata_specific_parsed,
18541 .help_str = "port config <port_id> tx_metadata <value>",
18543 (void *)&cmd_config_tx_metadata_specific_port,
18544 (void *)&cmd_config_tx_metadata_specific_keyword,
18545 (void *)&cmd_config_tx_metadata_specific_id,
18546 (void *)&cmd_config_tx_metadata_specific_item,
18547 (void *)&cmd_config_tx_metadata_specific_value,
18552 /* *** display tx_metadata per port configuration *** */
18553 struct cmd_show_tx_metadata_result {
18554 cmdline_fixed_string_t cmd_show;
18555 cmdline_fixed_string_t cmd_port;
18556 cmdline_fixed_string_t cmd_keyword;
18561 cmd_show_tx_metadata_parsed(void *parsed_result,
18562 __attribute__((unused)) struct cmdline *cl,
18563 __attribute__((unused)) void *data)
18565 struct cmd_show_tx_metadata_result *res = parsed_result;
18567 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18568 printf("invalid port id %u\n", res->cmd_pid);
18571 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18572 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18573 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18577 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18578 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18580 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18581 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18583 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18584 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18586 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18587 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18588 cmd_keyword, "tx_metadata");
18590 cmdline_parse_inst_t cmd_show_tx_metadata = {
18591 .f = cmd_show_tx_metadata_parsed,
18593 .help_str = "show port <port_id> tx_metadata",
18595 (void *)&cmd_show_tx_metadata_show,
18596 (void *)&cmd_show_tx_metadata_port,
18597 (void *)&cmd_show_tx_metadata_pid,
18598 (void *)&cmd_show_tx_metadata_keyword,
18603 /* ******************************************************************************** */
18605 /* list of instructions */
18606 cmdline_parse_ctx_t main_ctx[] = {
18607 (cmdline_parse_inst_t *)&cmd_help_brief,
18608 (cmdline_parse_inst_t *)&cmd_help_long,
18609 (cmdline_parse_inst_t *)&cmd_quit,
18610 (cmdline_parse_inst_t *)&cmd_load_from_file,
18611 (cmdline_parse_inst_t *)&cmd_showport,
18612 (cmdline_parse_inst_t *)&cmd_showqueue,
18613 (cmdline_parse_inst_t *)&cmd_showportall,
18614 (cmdline_parse_inst_t *)&cmd_showcfg,
18615 (cmdline_parse_inst_t *)&cmd_showfwdall,
18616 (cmdline_parse_inst_t *)&cmd_start,
18617 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18618 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18619 (cmdline_parse_inst_t *)&cmd_set_link_up,
18620 (cmdline_parse_inst_t *)&cmd_set_link_down,
18621 (cmdline_parse_inst_t *)&cmd_reset,
18622 (cmdline_parse_inst_t *)&cmd_set_numbers,
18623 (cmdline_parse_inst_t *)&cmd_set_log,
18624 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18625 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18626 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18627 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18628 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18629 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18630 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18631 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18632 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18633 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18634 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18635 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18636 (cmdline_parse_inst_t *)&cmd_set_link_check,
18637 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18638 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18639 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18640 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18641 #ifdef RTE_LIBRTE_PMD_BOND
18642 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18643 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18644 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18645 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18646 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18647 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18648 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18649 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18650 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18651 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18652 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18654 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18655 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18656 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18657 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18658 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18659 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18660 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18661 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18662 (cmdline_parse_inst_t *)&cmd_csum_set,
18663 (cmdline_parse_inst_t *)&cmd_csum_show,
18664 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18665 (cmdline_parse_inst_t *)&cmd_tso_set,
18666 (cmdline_parse_inst_t *)&cmd_tso_show,
18667 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18668 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18669 (cmdline_parse_inst_t *)&cmd_gro_enable,
18670 (cmdline_parse_inst_t *)&cmd_gro_flush,
18671 (cmdline_parse_inst_t *)&cmd_gro_show,
18672 (cmdline_parse_inst_t *)&cmd_gso_enable,
18673 (cmdline_parse_inst_t *)&cmd_gso_size,
18674 (cmdline_parse_inst_t *)&cmd_gso_show,
18675 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18676 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18677 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18678 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18679 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18680 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18681 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18682 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18683 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18684 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18685 (cmdline_parse_inst_t *)&cmd_config_dcb,
18686 (cmdline_parse_inst_t *)&cmd_read_reg,
18687 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18688 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18689 (cmdline_parse_inst_t *)&cmd_write_reg,
18690 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18691 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18692 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18693 (cmdline_parse_inst_t *)&cmd_stop,
18694 (cmdline_parse_inst_t *)&cmd_mac_addr,
18695 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18696 (cmdline_parse_inst_t *)&cmd_set_qmap,
18697 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18698 (cmdline_parse_inst_t *)&cmd_operate_port,
18699 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18700 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18701 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18702 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18703 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18704 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18705 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18706 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18707 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18708 (cmdline_parse_inst_t *)&cmd_config_mtu,
18709 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18710 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18711 (cmdline_parse_inst_t *)&cmd_config_rss,
18712 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18713 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18714 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18715 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18716 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18717 (cmdline_parse_inst_t *)&cmd_showport_reta,
18718 (cmdline_parse_inst_t *)&cmd_config_burst,
18719 (cmdline_parse_inst_t *)&cmd_config_thresh,
18720 (cmdline_parse_inst_t *)&cmd_config_threshold,
18721 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18722 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18723 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18724 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18725 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18726 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18727 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18728 (cmdline_parse_inst_t *)&cmd_global_config,
18729 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18730 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18731 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18732 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18733 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18734 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18735 (cmdline_parse_inst_t *)&cmd_dump,
18736 (cmdline_parse_inst_t *)&cmd_dump_one,
18737 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18738 (cmdline_parse_inst_t *)&cmd_syn_filter,
18739 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18740 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18741 (cmdline_parse_inst_t *)&cmd_flex_filter,
18742 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18743 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18744 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18745 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18746 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18747 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18748 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18749 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18750 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18751 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18752 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18753 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18754 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18755 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18756 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18757 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18758 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18759 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18760 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18761 (cmdline_parse_inst_t *)&cmd_flow,
18762 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18763 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18764 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18765 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18766 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18767 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18768 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18769 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18770 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18771 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18772 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18773 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18774 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18775 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18776 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18777 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18778 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18779 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18780 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18781 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18782 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18783 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18784 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18785 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18786 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18787 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18788 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18789 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18790 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18791 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18792 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18793 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18794 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18795 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18796 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18797 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18798 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18799 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18800 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18801 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18802 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18803 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18804 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18805 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18806 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18807 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18808 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18809 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18810 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18811 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18812 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18814 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18815 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18816 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18817 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18818 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18819 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18820 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18821 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18822 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18823 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18824 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18825 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18826 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18827 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18828 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18829 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18830 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18831 (cmdline_parse_inst_t *)&cmd_ddp_add,
18832 (cmdline_parse_inst_t *)&cmd_ddp_del,
18833 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18834 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18835 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18836 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18837 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18838 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18839 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18840 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18841 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18842 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18844 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18845 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18846 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18847 (cmdline_parse_inst_t *)&cmd_queue_region,
18848 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18849 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18850 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18851 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18852 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18853 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18854 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18855 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18856 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18857 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18858 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18859 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18860 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18861 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18862 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18863 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18864 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18865 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18866 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18867 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18868 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18869 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18870 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18871 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18872 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18873 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18874 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18875 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18876 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18877 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18878 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18879 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18880 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18881 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18882 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18883 #ifdef RTE_LIBRTE_BPF
18884 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18885 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18887 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18888 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18892 /* read cmdline commands from file */
18894 cmdline_read_from_file(const char *filename)
18896 struct cmdline *cl;
18898 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18900 printf("Failed to create file based cmdline context: %s\n",
18905 cmdline_interact(cl);
18910 printf("Read CLI commands from %s\n", filename);
18913 /* prompt function, called from main on MASTER lcore */
18917 /* initialize non-constant commands */
18918 cmd_set_fwd_mode_init();
18919 cmd_set_fwd_retry_mode_init();
18921 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18922 if (testpmd_cl == NULL)
18924 cmdline_interact(testpmd_cl);
18925 cmdline_stdin_exit(testpmd_cl);
18931 if (testpmd_cl != NULL)
18932 cmdline_quit(testpmd_cl);
18936 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18938 if (id == (portid_t)RTE_PORT_ALL) {
18941 RTE_ETH_FOREACH_DEV(pid) {
18942 /* check if need_reconfig has been set to 1 */
18943 if (ports[pid].need_reconfig == 0)
18944 ports[pid].need_reconfig = dev;
18945 /* check if need_reconfig_queues has been set to 1 */
18946 if (ports[pid].need_reconfig_queues == 0)
18947 ports[pid].need_reconfig_queues = queue;
18949 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18950 /* check if need_reconfig has been set to 1 */
18951 if (ports[id].need_reconfig == 0)
18952 ports[id].need_reconfig = dev;
18953 /* check if need_reconfig_queues has been set to 1 */
18954 if (ports[id].need_reconfig_queues == 0)
18955 ports[id].need_reconfig_queues = queue;