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_PMD_SOFTNIC
73 #include <rte_eth_softnic.h>
75 #ifdef RTE_LIBRTE_BNXT_PMD
76 #include <rte_pmd_bnxt.h>
79 #include "cmdline_mtr.h"
80 #include "cmdline_tm.h"
83 static struct cmdline *testpmd_cl;
85 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
87 /* *** Help command with introduction. *** */
88 struct cmd_help_brief_result {
89 cmdline_fixed_string_t help;
92 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
94 __attribute__((unused)) void *data)
99 "Help is available for the following sections:\n\n"
100 " help control : Start and stop forwarding.\n"
101 " help display : Displaying port, stats and config "
103 " help config : Configuration information.\n"
104 " help ports : Configuring ports.\n"
105 " help registers : Reading and setting port registers.\n"
106 " help filters : Filters configuration help.\n"
107 " help all : All of the above sections.\n\n"
112 cmdline_parse_token_string_t cmd_help_brief_help =
113 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
115 cmdline_parse_inst_t cmd_help_brief = {
116 .f = cmd_help_brief_parsed,
118 .help_str = "help: Show help",
120 (void *)&cmd_help_brief_help,
125 /* *** Help command with help sections. *** */
126 struct cmd_help_long_result {
127 cmdline_fixed_string_t help;
128 cmdline_fixed_string_t section;
131 static void cmd_help_long_parsed(void *parsed_result,
133 __attribute__((unused)) void *data)
136 struct cmd_help_long_result *res = parsed_result;
138 if (!strcmp(res->section, "all"))
141 if (show_all || !strcmp(res->section, "control")) {
146 "Control forwarding:\n"
147 "-------------------\n\n"
150 " Start packet forwarding with current configuration.\n\n"
153 " Start packet forwarding with current config"
154 " after sending one burst of packets.\n\n"
157 " Stop packet forwarding, and display accumulated"
161 " Quit to prompt.\n\n"
165 if (show_all || !strcmp(res->section, "display")) {
173 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
174 " Display information for port_id, or all.\n\n"
176 "show port X rss reta (size) (mask0,mask1,...)\n"
177 " Display the rss redirection table entry indicated"
178 " by masks on port X. size is used to indicate the"
179 " hardware supported reta size\n\n"
181 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
182 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
183 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
184 " Display the RSS hash functions and RSS hash key"
187 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
188 " Clear information for port_id, or all.\n\n"
190 "show (rxq|txq) info (port_id) (queue_id)\n"
191 " Display information for configured RX/TX queue.\n\n"
193 "show config (rxtx|cores|fwd|txpkts)\n"
194 " Display the given configuration.\n\n"
196 "read rxd (port_id) (queue_id) (rxd_id)\n"
197 " Display an RX descriptor of a port RX queue.\n\n"
199 "read txd (port_id) (queue_id) (txd_id)\n"
200 " Display a TX descriptor of a port TX queue.\n\n"
202 "ddp get list (port_id)\n"
203 " Get ddp profile info list\n\n"
205 "ddp get info (profile_path)\n"
206 " Get ddp profile information.\n\n"
208 "show vf stats (port_id) (vf_id)\n"
209 " Display a VF's statistics.\n\n"
211 "clear vf stats (port_id) (vf_id)\n"
212 " Reset a VF's statistics.\n\n"
214 "show port (port_id) pctype mapping\n"
215 " Get flow ptype to pctype mapping on a port\n\n"
217 "show port meter stats (port_id) (meter_id) (clear)\n"
218 " Get meter stats on a port\n\n"
219 "show port tm cap (port_id)\n"
220 " Display the port TM capability.\n\n"
222 "show port tm level cap (port_id) (level_id)\n"
223 " Display the port TM hierarchical level capability.\n\n"
225 "show port tm node cap (port_id) (node_id)\n"
226 " Display the port TM node capability.\n\n"
228 "show port tm node type (port_id) (node_id)\n"
229 " Display the port TM node type.\n\n"
231 "show port tm node stats (port_id) (node_id) (clear)\n"
232 " Display the port TM node stats.\n\n"
237 if (show_all || !strcmp(res->section, "config")) {
243 "Configuration changes only become active when"
244 " forwarding is started/restarted.\n\n"
247 " Reset forwarding to the default configuration.\n\n"
249 "set verbose (level)\n"
250 " Set the debug verbosity level X.\n\n"
252 "set log global|(type) (level)\n"
253 " Set the log level.\n\n"
256 " Set number of ports.\n\n"
259 " Set number of cores.\n\n"
261 "set coremask (mask)\n"
262 " Set the forwarding cores hexadecimal mask.\n\n"
264 "set portmask (mask)\n"
265 " Set the forwarding ports hexadecimal mask.\n\n"
268 " Set number of packets per burst.\n\n"
270 "set burst tx delay (microseconds) retry (num)\n"
271 " Set the transmit delay time and number of retries,"
272 " effective when retry is enabled.\n\n"
274 "set txpkts (x[,y]*)\n"
275 " Set the length of each segment of TXONLY"
276 " and optionally CSUM packets.\n\n"
278 "set txsplit (off|on|rand)\n"
279 " Set the split policy for the TX packets."
280 " Right now only applicable for CSUM and TXONLY"
283 "set corelist (x[,y]*)\n"
284 " Set the list of forwarding cores.\n\n"
286 "set portlist (x[,y]*)\n"
287 " Set the list of forwarding ports.\n\n"
289 "set tx loopback (port_id) (on|off)\n"
290 " Enable or disable tx loopback.\n\n"
292 "set all queues drop (port_id) (on|off)\n"
293 " Set drop enable bit for all queues.\n\n"
295 "set vf split drop (port_id) (vf_id) (on|off)\n"
296 " Set split drop enable bit for a VF from the PF.\n\n"
298 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
299 " Set MAC antispoof for a VF from the PF.\n\n"
301 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
302 " Enable MACsec offload.\n\n"
304 "set macsec offload (port_id) off\n"
305 " Disable MACsec offload.\n\n"
307 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
308 " Configure MACsec secure connection (SC).\n\n"
310 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
311 " Configure MACsec secure association (SA).\n\n"
313 "set vf broadcast (port_id) (vf_id) (on|off)\n"
314 " Set VF broadcast for a VF from the PF.\n\n"
316 "vlan set strip (on|off) (port_id)\n"
317 " Set the VLAN strip on a port.\n\n"
319 "vlan set stripq (on|off) (port_id,queue_id)\n"
320 " Set the VLAN strip for a queue on a port.\n\n"
322 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
323 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
325 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
326 " Set VLAN insert for a VF from the PF.\n\n"
328 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
329 " Set VLAN antispoof for a VF from the PF.\n\n"
331 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
332 " Set VLAN tag for a VF from the PF.\n\n"
334 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
335 " Set a VF's max bandwidth(Mbps).\n\n"
337 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
338 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
340 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
341 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
343 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
344 " Set some TCs' strict link priority mode on a physical port.\n\n"
346 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
347 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
349 "vlan set filter (on|off) (port_id)\n"
350 " Set the VLAN filter on a port.\n\n"
352 "vlan set qinq (on|off) (port_id)\n"
353 " Set the VLAN QinQ (extended queue in queue)"
356 "vlan set (inner|outer) tpid (value) (port_id)\n"
357 " Set the VLAN TPID for Packet Filtering on"
360 "rx_vlan add (vlan_id|all) (port_id)\n"
361 " Add a vlan_id, or all identifiers, to the set"
362 " of VLAN identifiers filtered by port_id.\n\n"
364 "rx_vlan rm (vlan_id|all) (port_id)\n"
365 " Remove a vlan_id, or all identifiers, from the set"
366 " of VLAN identifiers filtered by port_id.\n\n"
368 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
369 " Add a vlan_id, to the set of VLAN identifiers"
370 "filtered for VF(s) from port_id.\n\n"
372 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
373 " Remove a vlan_id, to the set of VLAN identifiers"
374 "filtered for VF(s) from port_id.\n\n"
376 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
377 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
378 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
379 " add a tunnel filter of a port.\n\n"
381 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
382 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
383 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
384 " remove a tunnel filter of a port.\n\n"
386 "rx_vxlan_port add (udp_port) (port_id)\n"
387 " Add an UDP port for VXLAN packet filter on a port\n\n"
389 "rx_vxlan_port rm (udp_port) (port_id)\n"
390 " Remove an UDP port for VXLAN packet filter on a port\n\n"
392 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
393 " Set hardware insertion of VLAN IDs (single or double VLAN "
394 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
396 "tx_vlan set pvid port_id vlan_id (on|off)\n"
397 " Set port based TX VLAN insertion.\n\n"
399 "tx_vlan reset (port_id)\n"
400 " Disable hardware insertion of a VLAN header in"
401 " packets sent on a port.\n\n"
403 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
404 " Select hardware or software calculation of the"
405 " checksum when transmitting a packet using the"
406 " csum forward engine.\n"
407 " ip|udp|tcp|sctp always concern the inner layer.\n"
408 " outer-ip concerns the outer IP layer in"
409 " case the packet is recognized as a tunnel packet by"
410 " the forward engine (vxlan, gre and ipip are supported)\n"
411 " Please check the NIC datasheet for HW limits.\n\n"
413 "csum parse-tunnel (on|off) (tx_port_id)\n"
414 " If disabled, treat tunnel packets as non-tunneled"
415 " packets (treat inner headers as payload). The port\n"
416 " argument is the port used for TX in csum forward"
419 "csum show (port_id)\n"
420 " Display tx checksum offload configuration\n\n"
422 "tso set (segsize) (portid)\n"
423 " Enable TCP Segmentation Offload in csum forward"
425 " Please check the NIC datasheet for HW limits.\n\n"
428 " Display the status of TCP Segmentation Offload.\n\n"
430 "set port (port_id) gro on|off\n"
431 " Enable or disable Generic Receive Offload in"
432 " csum forwarding engine.\n\n"
434 "show port (port_id) gro\n"
435 " Display GRO configuration.\n\n"
437 "set gro flush (cycles)\n"
438 " Set the cycle to flush GROed packets from"
439 " reassembly tables.\n\n"
441 "set port (port_id) gso (on|off)"
442 " Enable or disable Generic Segmentation Offload in"
443 " csum forwarding engine.\n\n"
445 "set gso segsz (length)\n"
446 " Set max packet length for output GSO segments,"
447 " including packet header and payload.\n\n"
449 "show port (port_id) gso\n"
450 " Show GSO configuration.\n\n"
453 " Set packet forwarding mode.\n\n"
455 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
456 " Add a MAC address on port_id.\n\n"
458 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
459 " Remove a MAC address from port_id.\n\n"
461 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
462 " Set the default MAC address for port_id.\n\n"
464 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
465 " Add a MAC address for a VF on the port.\n\n"
467 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
468 " Set the MAC address for a VF from the PF.\n\n"
470 "set eth-peer (port_id) (peer_addr)\n"
471 " set the peer address for certain port.\n\n"
473 "set port (port_id) uta (mac_address|all) (on|off)\n"
474 " Add/Remove a or all unicast hash filter(s)"
477 "set promisc (port_id|all) (on|off)\n"
478 " Set the promiscuous mode on port_id, or all.\n\n"
480 "set allmulti (port_id|all) (on|off)\n"
481 " Set the allmulti mode on port_id, or all.\n\n"
483 "set vf promisc (port_id) (vf_id) (on|off)\n"
484 " Set unicast promiscuous mode for a VF from the PF.\n\n"
486 "set vf allmulti (port_id) (vf_id) (on|off)\n"
487 " Set multicast promiscuous mode for a VF from the PF.\n\n"
489 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
490 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
491 " (on|off) autoneg (on|off) (port_id)\n"
492 "set flow_ctrl rx (on|off) (portid)\n"
493 "set flow_ctrl tx (on|off) (portid)\n"
494 "set flow_ctrl high_water (high_water) (portid)\n"
495 "set flow_ctrl low_water (low_water) (portid)\n"
496 "set flow_ctrl pause_time (pause_time) (portid)\n"
497 "set flow_ctrl send_xon (send_xon) (portid)\n"
498 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
499 "set flow_ctrl autoneg (on|off) (port_id)\n"
500 " Set the link flow control parameter on a port.\n\n"
502 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
503 " (low_water) (pause_time) (priority) (port_id)\n"
504 " Set the priority flow control parameter on a"
507 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
508 " Set statistics mapping (qmapping 0..15) for RX/TX"
510 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
511 " on port 0 to mapping 5.\n\n"
513 "set xstats-hide-zero on|off\n"
514 " Set the option to hide the zero values"
515 " for xstats display.\n"
517 "set port (port_id) vf (vf_id) rx|tx on|off\n"
518 " Enable/Disable a VF receive/tranmit from a port\n\n"
520 "set port (port_id) vf (vf_id) (mac_addr)"
521 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
522 " Add/Remove unicast or multicast MAC addr filter"
525 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
527 " AUPE:accepts untagged VLAN;"
528 "ROPE:accept unicast hash\n\n"
529 " BAM:accepts broadcast packets;"
530 "MPE:accepts all multicast packets\n\n"
531 " Enable/Disable a VF receive mode of a port\n\n"
533 "set port (port_id) queue (queue_id) rate (rate_num)\n"
534 " Set rate limit for a queue of a port\n\n"
536 "set port (port_id) vf (vf_id) rate (rate_num) "
537 "queue_mask (queue_mask_value)\n"
538 " Set rate limit for queues in VF of a port\n\n"
540 "set port (port_id) mirror-rule (rule_id)"
541 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
542 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
543 " Set pool or vlan type mirror rule on a port.\n"
544 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
545 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
548 "set port (port_id) mirror-rule (rule_id)"
549 " (uplink-mirror|downlink-mirror) dst-pool"
550 " (pool_id) (on|off)\n"
551 " Set uplink or downlink type mirror rule on a port.\n"
552 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
553 " 0 on' enable mirror income traffic to pool 0.\n\n"
555 "reset port (port_id) mirror-rule (rule_id)\n"
556 " Reset a mirror rule.\n\n"
558 "set flush_rx (on|off)\n"
559 " Flush (default) or don't flush RX streams before"
560 " forwarding. Mainly used with PCAP drivers.\n\n"
562 "set bypass mode (normal|bypass|isolate) (port_id)\n"
563 " Set the bypass mode for the lowest port on bypass enabled"
566 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
567 "mode (normal|bypass|isolate) (port_id)\n"
568 " Set the event required to initiate specified bypass mode for"
569 " the lowest port on a bypass enabled NIC where:\n"
570 " timeout = enable bypass after watchdog timeout.\n"
571 " os_on = enable bypass when OS/board is powered on.\n"
572 " os_off = enable bypass when OS/board is powered off.\n"
573 " power_on = enable bypass when power supply is turned on.\n"
574 " power_off = enable bypass when power supply is turned off."
577 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
578 " Set the bypass watchdog timeout to 'n' seconds"
579 " where 0 = instant.\n\n"
581 "show bypass config (port_id)\n"
582 " Show the bypass configuration for a bypass enabled NIC"
583 " using the lowest port on the NIC.\n\n"
585 #ifdef RTE_LIBRTE_PMD_BOND
586 "create bonded device (mode) (socket)\n"
587 " Create a new bonded device with specific bonding mode and socket.\n\n"
589 "add bonding slave (slave_id) (port_id)\n"
590 " Add a slave device to a bonded device.\n\n"
592 "remove bonding slave (slave_id) (port_id)\n"
593 " Remove a slave device from a bonded device.\n\n"
595 "set bonding mode (value) (port_id)\n"
596 " Set the bonding mode on a bonded device.\n\n"
598 "set bonding primary (slave_id) (port_id)\n"
599 " Set the primary slave for a bonded device.\n\n"
601 "show bonding config (port_id)\n"
602 " Show the bonding config for port_id.\n\n"
604 "set bonding mac_addr (port_id) (address)\n"
605 " Set the MAC address of a bonded device.\n\n"
607 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
608 " Set Aggregation mode for IEEE802.3AD (mode 4)"
610 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
611 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
613 "set bonding mon_period (port_id) (value)\n"
614 " Set the bonding link status monitoring polling period in ms.\n\n"
616 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
617 " Enable/disable dedicated queues for LACP control traffic.\n\n"
620 "set link-up port (port_id)\n"
621 " Set link up for a port.\n\n"
623 "set link-down port (port_id)\n"
624 " Set link down for a port.\n\n"
626 "E-tag set insertion on port-tag-id (value)"
627 " port (port_id) vf (vf_id)\n"
628 " Enable E-tag insertion for a VF on a port\n\n"
630 "E-tag set insertion off port (port_id) vf (vf_id)\n"
631 " Disable E-tag insertion for a VF on a port\n\n"
633 "E-tag set stripping (on|off) port (port_id)\n"
634 " Enable/disable E-tag stripping on a port\n\n"
636 "E-tag set forwarding (on|off) port (port_id)\n"
637 " Enable/disable E-tag based forwarding"
640 "E-tag set filter add e-tag-id (value) dst-pool"
641 " (pool_id) port (port_id)\n"
642 " Add an E-tag forwarding filter on a port\n\n"
644 "E-tag set filter del e-tag-id (value) port (port_id)\n"
645 " Delete an E-tag forwarding filter on a port\n\n"
647 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
648 "set port tm hierarchy default (port_id)\n"
649 " Set default traffic Management hierarchy on a port\n\n"
652 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
653 " Load a profile package on a port\n\n"
655 "ddp del (port_id) (backup_profile_path)\n"
656 " Delete a profile package from a port\n\n"
658 "ptype mapping get (port_id) (valid_only)\n"
659 " Get ptype mapping on a port\n\n"
661 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
662 " Replace target with the pkt_type in ptype mapping\n\n"
664 "ptype mapping reset (port_id)\n"
665 " Reset ptype mapping on a port\n\n"
667 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
668 " Update a ptype mapping item on a port\n\n"
670 "set port (port_id) queue-region region_id (value) "
671 "queue_start_index (value) queue_num (value)\n"
672 " Set a queue region on a port\n\n"
674 "set port (port_id) queue-region region_id (value) "
676 " Set a flowtype region index on a port\n\n"
678 "set port (port_id) queue-region UP (value) region_id (value)\n"
679 " Set the mapping of User Priority to "
680 "queue region on a port\n\n"
682 "set port (port_id) queue-region flush (on|off)\n"
683 " flush all queue region related configuration\n\n"
685 "show port meter cap (port_id)\n"
686 " Show port meter capability information\n\n"
688 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
689 " meter profile add - srtcm rfc 2697\n\n"
691 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
692 " meter profile add - trtcm rfc 2698\n\n"
694 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
695 " meter profile add - trtcm rfc 4115\n\n"
697 "del port meter profile (port_id) (profile_id)\n"
698 " meter profile delete\n\n"
700 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
701 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
702 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
703 "(dscp_tbl_entry63)]\n"
706 "enable port meter (port_id) (mtr_id)\n"
709 "disable port meter (port_id) (mtr_id)\n"
712 "del port meter (port_id) (mtr_id)\n"
715 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
716 " meter update meter profile\n\n"
718 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
719 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
720 " update meter dscp table entries\n\n"
722 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
723 "(action0) [(action1) (action2)]\n"
724 " meter update policer action\n\n"
726 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
727 " meter update stats\n\n"
729 "show port (port_id) queue-region\n"
730 " show all queue region related configuration info\n\n"
732 "add port tm node shaper profile (port_id) (shaper_profile_id)"
733 " (tb_rate) (tb_size) (packet_length_adjust)\n"
734 " Add port tm node private shaper profile.\n\n"
736 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
737 " Delete port tm node private shaper profile.\n\n"
739 "add port tm node shared shaper (port_id) (shared_shaper_id)"
740 " (shaper_profile_id)\n"
741 " Add/update port tm node shared shaper.\n\n"
743 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
744 " Delete port tm node shared shaper.\n\n"
746 "set port tm node shaper profile (port_id) (node_id)"
747 " (shaper_profile_id)\n"
748 " Set port tm node shaper profile.\n\n"
750 "add port tm node wred profile (port_id) (wred_profile_id)"
751 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
752 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
753 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
754 " Add port tm node wred profile.\n\n"
756 "del port tm node wred profile (port_id) (wred_profile_id)\n"
757 " Delete port tm node wred profile.\n\n"
759 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
760 " (priority) (weight) (level_id) (shaper_profile_id)"
761 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
762 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
763 " Add port tm nonleaf node.\n\n"
765 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
766 " (priority) (weight) (level_id) (shaper_profile_id)"
767 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
768 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
769 " Add port tm leaf node.\n\n"
771 "del port tm node (port_id) (node_id)\n"
772 " Delete port tm node.\n\n"
774 "set port tm node parent (port_id) (node_id) (parent_node_id)"
775 " (priority) (weight)\n"
776 " Set port tm node parent.\n\n"
778 "suspend port tm node (port_id) (node_id)"
779 " Suspend tm node.\n\n"
781 "resume port tm node (port_id) (node_id)"
782 " Resume tm node.\n\n"
784 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
785 " Commit tm hierarchy.\n\n"
787 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
788 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
789 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
790 " Configure the VXLAN encapsulation for flows.\n\n"
792 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
793 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
794 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
795 " eth-dst (eth-dst)\n"
796 " Configure the VXLAN encapsulation for flows.\n\n"
798 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
799 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
801 " Configure the NVGRE encapsulation for flows.\n\n"
803 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
804 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
805 " eth-src (eth-src) eth-dst (eth-dst)\n"
806 " Configure the NVGRE encapsulation for flows.\n\n"
808 , list_pkt_forwarding_modes()
812 if (show_all || !strcmp(res->section, "ports")) {
818 "----------------\n\n"
820 "port start (port_id|all)\n"
821 " Start all ports or port_id.\n\n"
823 "port stop (port_id|all)\n"
824 " Stop all ports or port_id.\n\n"
826 "port close (port_id|all)\n"
827 " Close all ports or port_id.\n\n"
829 "port attach (ident)\n"
830 " Attach physical or virtual dev by pci address or virtual device name\n\n"
832 "port detach (port_id)\n"
833 " Detach physical or virtual dev by port_id\n\n"
835 "port config (port_id|all)"
836 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
837 " duplex (half|full|auto)\n"
838 " Set speed and duplex for all ports or port_id\n\n"
840 "port config (port_id|all) loopback (mode)\n"
841 " Set loopback mode for all ports or port_id\n\n"
843 "port config all (rxq|txq|rxd|txd) (value)\n"
844 " Set number for rxq/txq/rxd/txd.\n\n"
846 "port config all max-pkt-len (value)\n"
847 " Set the max packet length.\n\n"
849 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
850 "hw-vlan-strip|hw-vlan-extend|drop-en)"
852 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
855 "port config all rss (all|default|ip|tcp|udp|sctp|"
856 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
857 " Set the RSS mode.\n\n"
859 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
860 " Set the RSS redirection table.\n\n"
862 "port config (port_id) dcb vt (on|off) (traffic_class)"
864 " Set the DCB mode.\n\n"
866 "port config all burst (value)\n"
867 " Set the number of packets per burst.\n\n"
869 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
871 " Set the ring prefetch/host/writeback threshold"
872 " for tx/rx queue.\n\n"
874 "port config all (txfreet|txrst|rxfreet) (value)\n"
875 " Set free threshold for rx/tx, or set"
876 " tx rs bit threshold.\n\n"
877 "port config mtu X value\n"
878 " Set the MTU of port X to a given value\n\n"
880 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
881 " Set a rx/tx queue's ring size configuration, the new"
882 " value will take effect after command that (re-)start the port"
883 " or command that setup the specific queue\n\n"
885 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
886 " Start/stop a rx/tx queue of port X. Only take effect"
887 " when port X is started\n\n"
889 "port (port_id) (rxq|txq) (queue_id) setup\n"
890 " Setup a rx/tx queue of port X.\n\n"
892 "port config (port_id|all) l2-tunnel E-tag ether-type"
894 " Set the value of E-tag ether-type.\n\n"
896 "port config (port_id|all) l2-tunnel E-tag"
897 " (enable|disable)\n"
898 " Enable/disable the E-tag support.\n\n"
900 "port config (port_id) pctype mapping reset\n"
901 " Reset flow type to pctype mapping on a port\n\n"
903 "port config (port_id) pctype mapping update"
904 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
905 " Update a flow type to pctype mapping item on a port\n\n"
907 "port config (port_id) pctype (pctype_id) hash_inset|"
908 "fdir_inset|fdir_flx_inset get|set|clear field\n"
910 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
912 "port config (port_id) pctype (pctype_id) hash_inset|"
913 "fdir_inset|fdir_flx_inset clear all"
914 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
916 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
917 " Add/remove UDP tunnel port for tunneling offload\n\n"
921 if (show_all || !strcmp(res->section, "registers")) {
929 "read reg (port_id) (address)\n"
930 " Display value of a port register.\n\n"
932 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
933 " Display a port register bit field.\n\n"
935 "read regbit (port_id) (address) (bit_x)\n"
936 " Display a single port register bit.\n\n"
938 "write reg (port_id) (address) (value)\n"
939 " Set value of a port register.\n\n"
941 "write regfield (port_id) (address) (bit_x) (bit_y)"
943 " Set bit field of a port register.\n\n"
945 "write regbit (port_id) (address) (bit_x) (value)\n"
946 " Set single bit value of a port register.\n\n"
949 if (show_all || !strcmp(res->section, "filters")) {
957 "ethertype_filter (port_id) (add|del)"
958 " (mac_addr|mac_ignr) (mac_address) ethertype"
959 " (ether_type) (drop|fwd) queue (queue_id)\n"
960 " Add/Del an ethertype filter.\n\n"
962 "2tuple_filter (port_id) (add|del)"
963 " dst_port (dst_port_value) protocol (protocol_value)"
964 " mask (mask_value) tcp_flags (tcp_flags_value)"
965 " priority (prio_value) queue (queue_id)\n"
966 " Add/Del a 2tuple filter.\n\n"
968 "5tuple_filter (port_id) (add|del)"
969 " dst_ip (dst_address) src_ip (src_address)"
970 " dst_port (dst_port_value) src_port (src_port_value)"
971 " protocol (protocol_value)"
972 " mask (mask_value) tcp_flags (tcp_flags_value)"
973 " priority (prio_value) queue (queue_id)\n"
974 " Add/Del a 5tuple filter.\n\n"
976 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
977 " Add/Del syn filter.\n\n"
979 "flex_filter (port_id) (add|del) len (len_value)"
980 " bytes (bytes_value) mask (mask_value)"
981 " priority (prio_value) queue (queue_id)\n"
982 " Add/Del a flex filter.\n\n"
984 "flow_director_filter (port_id) mode IP (add|del|update)"
985 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
986 " src (src_ip_address) dst (dst_ip_address)"
987 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
988 " vlan (vlan_value) flexbytes (flexbytes_value)"
989 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
990 " fd_id (fd_id_value)\n"
991 " Add/Del an IP type flow director filter.\n\n"
993 "flow_director_filter (port_id) mode IP (add|del|update)"
994 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
995 " src (src_ip_address) (src_port)"
996 " dst (dst_ip_address) (dst_port)"
997 " tos (tos_value) ttl (ttl_value)"
998 " vlan (vlan_value) flexbytes (flexbytes_value)"
999 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1000 " fd_id (fd_id_value)\n"
1001 " Add/Del an UDP/TCP type flow director filter.\n\n"
1003 "flow_director_filter (port_id) mode IP (add|del|update)"
1004 " flow (ipv4-sctp|ipv6-sctp)"
1005 " src (src_ip_address) (src_port)"
1006 " dst (dst_ip_address) (dst_port)"
1007 " tag (verification_tag) "
1008 " tos (tos_value) ttl (ttl_value)"
1009 " vlan (vlan_value)"
1010 " flexbytes (flexbytes_value) (drop|fwd)"
1011 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1012 " Add/Del a SCTP type flow director filter.\n\n"
1014 "flow_director_filter (port_id) mode IP (add|del|update)"
1015 " flow l2_payload ether (ethertype)"
1016 " flexbytes (flexbytes_value) (drop|fwd)"
1017 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1018 " Add/Del a l2 payload type flow director filter.\n\n"
1020 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1021 " mac (mac_address) vlan (vlan_value)"
1022 " flexbytes (flexbytes_value) (drop|fwd)"
1023 " queue (queue_id) fd_id (fd_id_value)\n"
1024 " Add/Del a MAC-VLAN flow director filter.\n\n"
1026 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1027 " mac (mac_address) vlan (vlan_value)"
1028 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1029 " flexbytes (flexbytes_value) (drop|fwd)"
1030 " queue (queue_id) fd_id (fd_id_value)\n"
1031 " Add/Del a Tunnel flow director filter.\n\n"
1033 "flow_director_filter (port_id) mode raw (add|del|update)"
1034 " flow (flow_id) (drop|fwd) queue (queue_id)"
1035 " fd_id (fd_id_value) packet (packet file name)\n"
1036 " Add/Del a raw type flow director filter.\n\n"
1038 "flush_flow_director (port_id)\n"
1039 " Flush all flow director entries of a device.\n\n"
1041 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1042 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1043 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1044 " Set flow director IP mask.\n\n"
1046 "flow_director_mask (port_id) mode MAC-VLAN"
1047 " vlan (vlan_value)\n"
1048 " Set flow director MAC-VLAN mask.\n\n"
1050 "flow_director_mask (port_id) mode Tunnel"
1051 " vlan (vlan_value) mac (mac_value)"
1052 " tunnel-type (tunnel_type_value)"
1053 " tunnel-id (tunnel_id_value)\n"
1054 " Set flow director Tunnel mask.\n\n"
1056 "flow_director_flex_mask (port_id)"
1057 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1058 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1060 " Configure mask of flex payload.\n\n"
1062 "flow_director_flex_payload (port_id)"
1063 " (raw|l2|l3|l4) (config)\n"
1064 " Configure flex payload selection.\n\n"
1066 "get_sym_hash_ena_per_port (port_id)\n"
1067 " get symmetric hash enable configuration per port.\n\n"
1069 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1070 " set symmetric hash enable configuration per port"
1071 " to enable or disable.\n\n"
1073 "get_hash_global_config (port_id)\n"
1074 " Get the global configurations of hash filters.\n\n"
1076 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1077 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1078 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1079 " (enable|disable)\n"
1080 " Set the global configurations of hash filters.\n\n"
1082 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1083 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1084 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1085 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1086 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1087 "ipv6-next-header|udp-src-port|udp-dst-port|"
1088 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1089 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1090 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1091 "fld-8th|none) (select|add)\n"
1092 " Set the input set for hash.\n\n"
1094 "set_fdir_input_set (port_id) "
1095 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1096 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1097 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1098 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1099 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1100 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1101 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1103 " Set the input set for FDir.\n\n"
1105 "flow validate {port_id}"
1106 " [group {group_id}] [priority {level}]"
1107 " [ingress] [egress]"
1108 " pattern {item} [/ {item} [...]] / end"
1109 " actions {action} [/ {action} [...]] / end\n"
1110 " Check whether a flow rule can be created.\n\n"
1112 "flow create {port_id}"
1113 " [group {group_id}] [priority {level}]"
1114 " [ingress] [egress]"
1115 " pattern {item} [/ {item} [...]] / end"
1116 " actions {action} [/ {action} [...]] / end\n"
1117 " Create a flow rule.\n\n"
1119 "flow destroy {port_id} rule {rule_id} [...]\n"
1120 " Destroy specific flow rules.\n\n"
1122 "flow flush {port_id}\n"
1123 " Destroy all flow rules.\n\n"
1125 "flow query {port_id} {rule_id} {action}\n"
1126 " Query an existing flow rule.\n\n"
1128 "flow list {port_id} [group {group_id}] [...]\n"
1129 " List existing flow rules sorted by priority,"
1130 " filtered by group identifiers.\n\n"
1132 "flow isolate {port_id} {boolean}\n"
1133 " Restrict ingress traffic to the defined"
1139 cmdline_parse_token_string_t cmd_help_long_help =
1140 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1142 cmdline_parse_token_string_t cmd_help_long_section =
1143 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1144 "all#control#display#config#"
1145 "ports#registers#filters");
1147 cmdline_parse_inst_t cmd_help_long = {
1148 .f = cmd_help_long_parsed,
1150 .help_str = "help all|control|display|config|ports|register|filters: "
1153 (void *)&cmd_help_long_help,
1154 (void *)&cmd_help_long_section,
1160 /* *** start/stop/close all ports *** */
1161 struct cmd_operate_port_result {
1162 cmdline_fixed_string_t keyword;
1163 cmdline_fixed_string_t name;
1164 cmdline_fixed_string_t value;
1167 static void cmd_operate_port_parsed(void *parsed_result,
1168 __attribute__((unused)) struct cmdline *cl,
1169 __attribute__((unused)) void *data)
1171 struct cmd_operate_port_result *res = parsed_result;
1173 if (!strcmp(res->name, "start"))
1174 start_port(RTE_PORT_ALL);
1175 else if (!strcmp(res->name, "stop"))
1176 stop_port(RTE_PORT_ALL);
1177 else if (!strcmp(res->name, "close"))
1178 close_port(RTE_PORT_ALL);
1179 else if (!strcmp(res->name, "reset"))
1180 reset_port(RTE_PORT_ALL);
1182 printf("Unknown parameter\n");
1185 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1186 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1188 cmdline_parse_token_string_t cmd_operate_port_all_port =
1189 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1190 "start#stop#close#reset");
1191 cmdline_parse_token_string_t cmd_operate_port_all_all =
1192 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1194 cmdline_parse_inst_t cmd_operate_port = {
1195 .f = cmd_operate_port_parsed,
1197 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1199 (void *)&cmd_operate_port_all_cmd,
1200 (void *)&cmd_operate_port_all_port,
1201 (void *)&cmd_operate_port_all_all,
1206 /* *** start/stop/close specific port *** */
1207 struct cmd_operate_specific_port_result {
1208 cmdline_fixed_string_t keyword;
1209 cmdline_fixed_string_t name;
1213 static void cmd_operate_specific_port_parsed(void *parsed_result,
1214 __attribute__((unused)) struct cmdline *cl,
1215 __attribute__((unused)) void *data)
1217 struct cmd_operate_specific_port_result *res = parsed_result;
1219 if (!strcmp(res->name, "start"))
1220 start_port(res->value);
1221 else if (!strcmp(res->name, "stop"))
1222 stop_port(res->value);
1223 else if (!strcmp(res->name, "close"))
1224 close_port(res->value);
1225 else if (!strcmp(res->name, "reset"))
1226 reset_port(res->value);
1228 printf("Unknown parameter\n");
1231 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1232 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1234 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1235 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1236 name, "start#stop#close#reset");
1237 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1238 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1241 cmdline_parse_inst_t cmd_operate_specific_port = {
1242 .f = cmd_operate_specific_port_parsed,
1244 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1246 (void *)&cmd_operate_specific_port_cmd,
1247 (void *)&cmd_operate_specific_port_port,
1248 (void *)&cmd_operate_specific_port_id,
1253 /* *** attach a specified port *** */
1254 struct cmd_operate_attach_port_result {
1255 cmdline_fixed_string_t port;
1256 cmdline_fixed_string_t keyword;
1257 cmdline_fixed_string_t identifier;
1260 static void cmd_operate_attach_port_parsed(void *parsed_result,
1261 __attribute__((unused)) struct cmdline *cl,
1262 __attribute__((unused)) void *data)
1264 struct cmd_operate_attach_port_result *res = parsed_result;
1266 if (!strcmp(res->keyword, "attach"))
1267 attach_port(res->identifier);
1269 printf("Unknown parameter\n");
1272 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1273 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1275 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1278 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1282 cmdline_parse_inst_t cmd_operate_attach_port = {
1283 .f = cmd_operate_attach_port_parsed,
1285 .help_str = "port attach <identifier>: "
1286 "(identifier: pci address or virtual dev name)",
1288 (void *)&cmd_operate_attach_port_port,
1289 (void *)&cmd_operate_attach_port_keyword,
1290 (void *)&cmd_operate_attach_port_identifier,
1295 /* *** detach a specified port *** */
1296 struct cmd_operate_detach_port_result {
1297 cmdline_fixed_string_t port;
1298 cmdline_fixed_string_t keyword;
1302 static void cmd_operate_detach_port_parsed(void *parsed_result,
1303 __attribute__((unused)) struct cmdline *cl,
1304 __attribute__((unused)) void *data)
1306 struct cmd_operate_detach_port_result *res = parsed_result;
1308 if (!strcmp(res->keyword, "detach"))
1309 detach_port(res->port_id);
1311 printf("Unknown parameter\n");
1314 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1315 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1317 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1318 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1320 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1321 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1324 cmdline_parse_inst_t cmd_operate_detach_port = {
1325 .f = cmd_operate_detach_port_parsed,
1327 .help_str = "port detach <port_id>",
1329 (void *)&cmd_operate_detach_port_port,
1330 (void *)&cmd_operate_detach_port_keyword,
1331 (void *)&cmd_operate_detach_port_port_id,
1336 /* *** configure speed for all ports *** */
1337 struct cmd_config_speed_all {
1338 cmdline_fixed_string_t port;
1339 cmdline_fixed_string_t keyword;
1340 cmdline_fixed_string_t all;
1341 cmdline_fixed_string_t item1;
1342 cmdline_fixed_string_t item2;
1343 cmdline_fixed_string_t value1;
1344 cmdline_fixed_string_t value2;
1348 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1353 if (!strcmp(duplexstr, "half")) {
1354 duplex = ETH_LINK_HALF_DUPLEX;
1355 } else if (!strcmp(duplexstr, "full")) {
1356 duplex = ETH_LINK_FULL_DUPLEX;
1357 } else if (!strcmp(duplexstr, "auto")) {
1358 duplex = ETH_LINK_FULL_DUPLEX;
1360 printf("Unknown duplex parameter\n");
1364 if (!strcmp(speedstr, "10")) {
1365 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1366 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1367 } else if (!strcmp(speedstr, "100")) {
1368 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1369 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1371 if (duplex != ETH_LINK_FULL_DUPLEX) {
1372 printf("Invalid speed/duplex parameters\n");
1375 if (!strcmp(speedstr, "1000")) {
1376 *speed = ETH_LINK_SPEED_1G;
1377 } else if (!strcmp(speedstr, "10000")) {
1378 *speed = ETH_LINK_SPEED_10G;
1379 } else if (!strcmp(speedstr, "25000")) {
1380 *speed = ETH_LINK_SPEED_25G;
1381 } else if (!strcmp(speedstr, "40000")) {
1382 *speed = ETH_LINK_SPEED_40G;
1383 } else if (!strcmp(speedstr, "50000")) {
1384 *speed = ETH_LINK_SPEED_50G;
1385 } else if (!strcmp(speedstr, "100000")) {
1386 *speed = ETH_LINK_SPEED_100G;
1387 } else if (!strcmp(speedstr, "auto")) {
1388 *speed = ETH_LINK_SPEED_AUTONEG;
1390 printf("Unknown speed parameter\n");
1399 cmd_config_speed_all_parsed(void *parsed_result,
1400 __attribute__((unused)) struct cmdline *cl,
1401 __attribute__((unused)) void *data)
1403 struct cmd_config_speed_all *res = parsed_result;
1404 uint32_t link_speed;
1407 if (!all_ports_stopped()) {
1408 printf("Please stop all ports first\n");
1412 if (parse_and_check_speed_duplex(res->value1, res->value2,
1416 RTE_ETH_FOREACH_DEV(pid) {
1417 ports[pid].dev_conf.link_speeds = link_speed;
1420 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1423 cmdline_parse_token_string_t cmd_config_speed_all_port =
1424 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1425 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1426 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1428 cmdline_parse_token_string_t cmd_config_speed_all_all =
1429 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1430 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1431 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1432 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1433 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1434 "10#100#1000#10000#25000#40000#50000#100000#auto");
1435 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1436 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1437 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1438 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1441 cmdline_parse_inst_t cmd_config_speed_all = {
1442 .f = cmd_config_speed_all_parsed,
1444 .help_str = "port config all speed "
1445 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1448 (void *)&cmd_config_speed_all_port,
1449 (void *)&cmd_config_speed_all_keyword,
1450 (void *)&cmd_config_speed_all_all,
1451 (void *)&cmd_config_speed_all_item1,
1452 (void *)&cmd_config_speed_all_value1,
1453 (void *)&cmd_config_speed_all_item2,
1454 (void *)&cmd_config_speed_all_value2,
1459 /* *** configure speed for specific port *** */
1460 struct cmd_config_speed_specific {
1461 cmdline_fixed_string_t port;
1462 cmdline_fixed_string_t keyword;
1464 cmdline_fixed_string_t item1;
1465 cmdline_fixed_string_t item2;
1466 cmdline_fixed_string_t value1;
1467 cmdline_fixed_string_t value2;
1471 cmd_config_speed_specific_parsed(void *parsed_result,
1472 __attribute__((unused)) struct cmdline *cl,
1473 __attribute__((unused)) void *data)
1475 struct cmd_config_speed_specific *res = parsed_result;
1476 uint32_t link_speed;
1478 if (!all_ports_stopped()) {
1479 printf("Please stop all ports first\n");
1483 if (port_id_is_invalid(res->id, ENABLED_WARN))
1486 if (parse_and_check_speed_duplex(res->value1, res->value2,
1490 ports[res->id].dev_conf.link_speeds = link_speed;
1492 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1496 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1497 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1499 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1500 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1502 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1503 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1504 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1505 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1507 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1508 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1509 "10#100#1000#10000#25000#40000#50000#100000#auto");
1510 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1511 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1513 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1514 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1517 cmdline_parse_inst_t cmd_config_speed_specific = {
1518 .f = cmd_config_speed_specific_parsed,
1520 .help_str = "port config <port_id> speed "
1521 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1524 (void *)&cmd_config_speed_specific_port,
1525 (void *)&cmd_config_speed_specific_keyword,
1526 (void *)&cmd_config_speed_specific_id,
1527 (void *)&cmd_config_speed_specific_item1,
1528 (void *)&cmd_config_speed_specific_value1,
1529 (void *)&cmd_config_speed_specific_item2,
1530 (void *)&cmd_config_speed_specific_value2,
1535 /* *** configure loopback for all ports *** */
1536 struct cmd_config_loopback_all {
1537 cmdline_fixed_string_t port;
1538 cmdline_fixed_string_t keyword;
1539 cmdline_fixed_string_t all;
1540 cmdline_fixed_string_t item;
1545 cmd_config_loopback_all_parsed(void *parsed_result,
1546 __attribute__((unused)) struct cmdline *cl,
1547 __attribute__((unused)) void *data)
1549 struct cmd_config_loopback_all *res = parsed_result;
1552 if (!all_ports_stopped()) {
1553 printf("Please stop all ports first\n");
1557 RTE_ETH_FOREACH_DEV(pid) {
1558 ports[pid].dev_conf.lpbk_mode = res->mode;
1561 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1564 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1565 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1566 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1569 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1571 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1572 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1574 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1575 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1577 cmdline_parse_inst_t cmd_config_loopback_all = {
1578 .f = cmd_config_loopback_all_parsed,
1580 .help_str = "port config all loopback <mode>",
1582 (void *)&cmd_config_loopback_all_port,
1583 (void *)&cmd_config_loopback_all_keyword,
1584 (void *)&cmd_config_loopback_all_all,
1585 (void *)&cmd_config_loopback_all_item,
1586 (void *)&cmd_config_loopback_all_mode,
1591 /* *** configure loopback for specific port *** */
1592 struct cmd_config_loopback_specific {
1593 cmdline_fixed_string_t port;
1594 cmdline_fixed_string_t keyword;
1596 cmdline_fixed_string_t item;
1601 cmd_config_loopback_specific_parsed(void *parsed_result,
1602 __attribute__((unused)) struct cmdline *cl,
1603 __attribute__((unused)) void *data)
1605 struct cmd_config_loopback_specific *res = parsed_result;
1607 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1610 if (!port_is_stopped(res->port_id)) {
1611 printf("Please stop port %u first\n", res->port_id);
1615 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1617 cmd_reconfig_device_queue(res->port_id, 1, 1);
1621 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1622 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1624 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1625 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1627 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1628 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1630 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1633 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1634 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1637 cmdline_parse_inst_t cmd_config_loopback_specific = {
1638 .f = cmd_config_loopback_specific_parsed,
1640 .help_str = "port config <port_id> loopback <mode>",
1642 (void *)&cmd_config_loopback_specific_port,
1643 (void *)&cmd_config_loopback_specific_keyword,
1644 (void *)&cmd_config_loopback_specific_id,
1645 (void *)&cmd_config_loopback_specific_item,
1646 (void *)&cmd_config_loopback_specific_mode,
1651 /* *** configure txq/rxq, txd/rxd *** */
1652 struct cmd_config_rx_tx {
1653 cmdline_fixed_string_t port;
1654 cmdline_fixed_string_t keyword;
1655 cmdline_fixed_string_t all;
1656 cmdline_fixed_string_t name;
1661 cmd_config_rx_tx_parsed(void *parsed_result,
1662 __attribute__((unused)) struct cmdline *cl,
1663 __attribute__((unused)) void *data)
1665 struct cmd_config_rx_tx *res = parsed_result;
1667 if (!all_ports_stopped()) {
1668 printf("Please stop all ports first\n");
1671 if (!strcmp(res->name, "rxq")) {
1672 if (!res->value && !nb_txq) {
1673 printf("Warning: Either rx or tx queues should be non zero\n");
1676 if (check_nb_rxq(res->value) != 0)
1678 nb_rxq = res->value;
1680 else if (!strcmp(res->name, "txq")) {
1681 if (!res->value && !nb_rxq) {
1682 printf("Warning: Either rx or tx queues should be non zero\n");
1685 if (check_nb_txq(res->value) != 0)
1687 nb_txq = res->value;
1689 else if (!strcmp(res->name, "rxd")) {
1690 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1691 printf("rxd %d invalid - must be > 0 && <= %d\n",
1692 res->value, RTE_TEST_RX_DESC_MAX);
1695 nb_rxd = res->value;
1696 } else if (!strcmp(res->name, "txd")) {
1697 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1698 printf("txd %d invalid - must be > 0 && <= %d\n",
1699 res->value, RTE_TEST_TX_DESC_MAX);
1702 nb_txd = res->value;
1704 printf("Unknown parameter\n");
1712 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1715 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1717 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1719 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1721 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1724 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1725 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1727 cmdline_parse_inst_t cmd_config_rx_tx = {
1728 .f = cmd_config_rx_tx_parsed,
1730 .help_str = "port config all rxq|txq|rxd|txd <value>",
1732 (void *)&cmd_config_rx_tx_port,
1733 (void *)&cmd_config_rx_tx_keyword,
1734 (void *)&cmd_config_rx_tx_all,
1735 (void *)&cmd_config_rx_tx_name,
1736 (void *)&cmd_config_rx_tx_value,
1741 /* *** config max packet length *** */
1742 struct cmd_config_max_pkt_len_result {
1743 cmdline_fixed_string_t port;
1744 cmdline_fixed_string_t keyword;
1745 cmdline_fixed_string_t all;
1746 cmdline_fixed_string_t name;
1751 cmd_config_max_pkt_len_parsed(void *parsed_result,
1752 __attribute__((unused)) struct cmdline *cl,
1753 __attribute__((unused)) void *data)
1755 struct cmd_config_max_pkt_len_result *res = parsed_result;
1758 if (!all_ports_stopped()) {
1759 printf("Please stop all ports first\n");
1763 RTE_ETH_FOREACH_DEV(pid) {
1764 struct rte_port *port = &ports[pid];
1765 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1767 if (!strcmp(res->name, "max-pkt-len")) {
1768 if (res->value < ETHER_MIN_LEN) {
1769 printf("max-pkt-len can not be less than %d\n",
1773 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1776 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1777 if (res->value > ETHER_MAX_LEN)
1778 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1780 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1781 port->dev_conf.rxmode.offloads = rx_offloads;
1783 printf("Unknown parameter\n");
1790 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1793 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1796 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1799 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1802 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1803 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1805 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1806 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1809 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1810 .f = cmd_config_max_pkt_len_parsed,
1812 .help_str = "port config all max-pkt-len <value>",
1814 (void *)&cmd_config_max_pkt_len_port,
1815 (void *)&cmd_config_max_pkt_len_keyword,
1816 (void *)&cmd_config_max_pkt_len_all,
1817 (void *)&cmd_config_max_pkt_len_name,
1818 (void *)&cmd_config_max_pkt_len_value,
1823 /* *** configure port MTU *** */
1824 struct cmd_config_mtu_result {
1825 cmdline_fixed_string_t port;
1826 cmdline_fixed_string_t keyword;
1827 cmdline_fixed_string_t mtu;
1833 cmd_config_mtu_parsed(void *parsed_result,
1834 __attribute__((unused)) struct cmdline *cl,
1835 __attribute__((unused)) void *data)
1837 struct cmd_config_mtu_result *res = parsed_result;
1839 if (res->value < ETHER_MIN_LEN) {
1840 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1843 port_mtu_set(res->port_id, res->value);
1846 cmdline_parse_token_string_t cmd_config_mtu_port =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1849 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1852 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1853 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1855 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1856 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1857 cmdline_parse_token_num_t cmd_config_mtu_value =
1858 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1860 cmdline_parse_inst_t cmd_config_mtu = {
1861 .f = cmd_config_mtu_parsed,
1863 .help_str = "port config mtu <port_id> <value>",
1865 (void *)&cmd_config_mtu_port,
1866 (void *)&cmd_config_mtu_keyword,
1867 (void *)&cmd_config_mtu_mtu,
1868 (void *)&cmd_config_mtu_port_id,
1869 (void *)&cmd_config_mtu_value,
1874 /* *** configure rx mode *** */
1875 struct cmd_config_rx_mode_flag {
1876 cmdline_fixed_string_t port;
1877 cmdline_fixed_string_t keyword;
1878 cmdline_fixed_string_t all;
1879 cmdline_fixed_string_t name;
1880 cmdline_fixed_string_t value;
1884 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1885 __attribute__((unused)) struct cmdline *cl,
1886 __attribute__((unused)) void *data)
1888 struct cmd_config_rx_mode_flag *res = parsed_result;
1891 if (!all_ports_stopped()) {
1892 printf("Please stop all ports first\n");
1896 RTE_ETH_FOREACH_DEV(pid) {
1897 struct rte_port *port;
1898 uint64_t rx_offloads;
1901 rx_offloads = port->dev_conf.rxmode.offloads;
1902 if (!strcmp(res->name, "crc-strip")) {
1903 if (!strcmp(res->value, "on"))
1904 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1905 else if (!strcmp(res->value, "off"))
1906 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1908 printf("Unknown parameter\n");
1911 } else if (!strcmp(res->name, "scatter")) {
1912 if (!strcmp(res->value, "on")) {
1913 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1914 } else if (!strcmp(res->value, "off")) {
1915 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1917 printf("Unknown parameter\n");
1920 } else if (!strcmp(res->name, "rx-cksum")) {
1921 if (!strcmp(res->value, "on"))
1922 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1923 else if (!strcmp(res->value, "off"))
1924 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1926 printf("Unknown parameter\n");
1929 } else if (!strcmp(res->name, "rx-timestamp")) {
1930 if (!strcmp(res->value, "on"))
1931 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1932 else if (!strcmp(res->value, "off"))
1933 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1935 printf("Unknown parameter\n");
1938 } else if (!strcmp(res->name, "hw-vlan")) {
1939 if (!strcmp(res->value, "on")) {
1940 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1941 DEV_RX_OFFLOAD_VLAN_STRIP);
1942 } else if (!strcmp(res->value, "off")) {
1943 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1944 DEV_RX_OFFLOAD_VLAN_STRIP);
1946 printf("Unknown parameter\n");
1949 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1950 if (!strcmp(res->value, "on"))
1951 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1952 else if (!strcmp(res->value, "off"))
1953 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1955 printf("Unknown parameter\n");
1958 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1959 if (!strcmp(res->value, "on"))
1960 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1961 else if (!strcmp(res->value, "off"))
1962 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1964 printf("Unknown parameter\n");
1967 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1968 if (!strcmp(res->value, "on"))
1969 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1970 else if (!strcmp(res->value, "off"))
1971 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1973 printf("Unknown parameter\n");
1976 } else if (!strcmp(res->name, "drop-en")) {
1977 if (!strcmp(res->value, "on"))
1979 else if (!strcmp(res->value, "off"))
1982 printf("Unknown parameter\n");
1986 printf("Unknown parameter\n");
1989 port->dev_conf.rxmode.offloads = rx_offloads;
1994 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1997 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1998 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1999 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2002 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2003 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2004 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2005 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2006 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2007 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2008 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2009 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2012 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2013 .f = cmd_config_rx_mode_flag_parsed,
2015 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2016 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2018 (void *)&cmd_config_rx_mode_flag_port,
2019 (void *)&cmd_config_rx_mode_flag_keyword,
2020 (void *)&cmd_config_rx_mode_flag_all,
2021 (void *)&cmd_config_rx_mode_flag_name,
2022 (void *)&cmd_config_rx_mode_flag_value,
2027 /* *** configure rss *** */
2028 struct cmd_config_rss {
2029 cmdline_fixed_string_t port;
2030 cmdline_fixed_string_t keyword;
2031 cmdline_fixed_string_t all;
2032 cmdline_fixed_string_t name;
2033 cmdline_fixed_string_t value;
2037 cmd_config_rss_parsed(void *parsed_result,
2038 __attribute__((unused)) struct cmdline *cl,
2039 __attribute__((unused)) void *data)
2041 struct cmd_config_rss *res = parsed_result;
2042 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2043 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2044 int use_default = 0;
2045 int all_updated = 1;
2049 if (!strcmp(res->value, "all"))
2050 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2051 ETH_RSS_UDP | ETH_RSS_SCTP |
2053 else if (!strcmp(res->value, "ip"))
2054 rss_conf.rss_hf = ETH_RSS_IP;
2055 else if (!strcmp(res->value, "udp"))
2056 rss_conf.rss_hf = ETH_RSS_UDP;
2057 else if (!strcmp(res->value, "tcp"))
2058 rss_conf.rss_hf = ETH_RSS_TCP;
2059 else if (!strcmp(res->value, "sctp"))
2060 rss_conf.rss_hf = ETH_RSS_SCTP;
2061 else if (!strcmp(res->value, "ether"))
2062 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2063 else if (!strcmp(res->value, "port"))
2064 rss_conf.rss_hf = ETH_RSS_PORT;
2065 else if (!strcmp(res->value, "vxlan"))
2066 rss_conf.rss_hf = ETH_RSS_VXLAN;
2067 else if (!strcmp(res->value, "geneve"))
2068 rss_conf.rss_hf = ETH_RSS_GENEVE;
2069 else if (!strcmp(res->value, "nvgre"))
2070 rss_conf.rss_hf = ETH_RSS_NVGRE;
2071 else if (!strcmp(res->value, "none"))
2072 rss_conf.rss_hf = 0;
2073 else if (!strcmp(res->value, "default"))
2075 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2076 atoi(res->value) < 64)
2077 rss_conf.rss_hf = 1ULL << atoi(res->value);
2079 printf("Unknown parameter\n");
2082 rss_conf.rss_key = NULL;
2083 /* Update global configuration for RSS types. */
2084 RTE_ETH_FOREACH_DEV(i) {
2085 struct rte_eth_rss_conf local_rss_conf;
2087 rte_eth_dev_info_get(i, &dev_info);
2089 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2091 local_rss_conf = rss_conf;
2092 local_rss_conf.rss_hf = rss_conf.rss_hf &
2093 dev_info.flow_type_rss_offloads;
2094 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2095 printf("Port %u modified RSS hash function based on hardware support,"
2096 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2097 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2099 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2102 printf("Configuration of RSS hash at ethernet port %d "
2103 "failed with error (%d): %s.\n",
2104 i, -diag, strerror(-diag));
2107 if (all_updated && !use_default)
2108 rss_hf = rss_conf.rss_hf;
2111 cmdline_parse_token_string_t cmd_config_rss_port =
2112 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2113 cmdline_parse_token_string_t cmd_config_rss_keyword =
2114 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2115 cmdline_parse_token_string_t cmd_config_rss_all =
2116 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2117 cmdline_parse_token_string_t cmd_config_rss_name =
2118 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2119 cmdline_parse_token_string_t cmd_config_rss_value =
2120 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2122 cmdline_parse_inst_t cmd_config_rss = {
2123 .f = cmd_config_rss_parsed,
2125 .help_str = "port config all rss "
2126 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2128 (void *)&cmd_config_rss_port,
2129 (void *)&cmd_config_rss_keyword,
2130 (void *)&cmd_config_rss_all,
2131 (void *)&cmd_config_rss_name,
2132 (void *)&cmd_config_rss_value,
2137 /* *** configure rss hash key *** */
2138 struct cmd_config_rss_hash_key {
2139 cmdline_fixed_string_t port;
2140 cmdline_fixed_string_t config;
2142 cmdline_fixed_string_t rss_hash_key;
2143 cmdline_fixed_string_t rss_type;
2144 cmdline_fixed_string_t key;
2148 hexa_digit_to_value(char hexa_digit)
2150 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2151 return (uint8_t) (hexa_digit - '0');
2152 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2153 return (uint8_t) ((hexa_digit - 'a') + 10);
2154 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2155 return (uint8_t) ((hexa_digit - 'A') + 10);
2156 /* Invalid hexa digit */
2161 parse_and_check_key_hexa_digit(char *key, int idx)
2165 hexa_v = hexa_digit_to_value(key[idx]);
2167 printf("invalid key: character %c at position %d is not a "
2168 "valid hexa digit\n", key[idx], idx);
2173 cmd_config_rss_hash_key_parsed(void *parsed_result,
2174 __attribute__((unused)) struct cmdline *cl,
2175 __attribute__((unused)) void *data)
2177 struct cmd_config_rss_hash_key *res = parsed_result;
2178 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2182 struct rte_eth_dev_info dev_info;
2183 uint8_t hash_key_size;
2186 memset(&dev_info, 0, sizeof(dev_info));
2187 rte_eth_dev_info_get(res->port_id, &dev_info);
2188 if (dev_info.hash_key_size > 0 &&
2189 dev_info.hash_key_size <= sizeof(hash_key))
2190 hash_key_size = dev_info.hash_key_size;
2192 printf("dev_info did not provide a valid hash key size\n");
2195 /* Check the length of the RSS hash key */
2196 key_len = strlen(res->key);
2197 if (key_len != (hash_key_size * 2)) {
2198 printf("key length: %d invalid - key must be a string of %d"
2199 " hexa-decimal numbers\n",
2200 (int) key_len, hash_key_size * 2);
2203 /* Translate RSS hash key into binary representation */
2204 for (i = 0; i < hash_key_size; i++) {
2205 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2208 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2211 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2213 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2217 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2218 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2219 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2220 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2222 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2223 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2224 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2225 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2226 rss_hash_key, "rss-hash-key");
2227 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2228 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2229 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2230 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2231 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2232 "ipv6-tcp-ex#ipv6-udp-ex");
2233 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2234 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2236 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2237 .f = cmd_config_rss_hash_key_parsed,
2239 .help_str = "port config <port_id> rss-hash-key "
2240 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2241 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2242 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2243 "<string of hex digits (variable length, NIC dependent)>",
2245 (void *)&cmd_config_rss_hash_key_port,
2246 (void *)&cmd_config_rss_hash_key_config,
2247 (void *)&cmd_config_rss_hash_key_port_id,
2248 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2249 (void *)&cmd_config_rss_hash_key_rss_type,
2250 (void *)&cmd_config_rss_hash_key_value,
2255 /* *** configure port rxq/txq ring size *** */
2256 struct cmd_config_rxtx_ring_size {
2257 cmdline_fixed_string_t port;
2258 cmdline_fixed_string_t config;
2260 cmdline_fixed_string_t rxtxq;
2262 cmdline_fixed_string_t rsize;
2267 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2268 __attribute__((unused)) struct cmdline *cl,
2269 __attribute__((unused)) void *data)
2271 struct cmd_config_rxtx_ring_size *res = parsed_result;
2272 struct rte_port *port;
2275 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2278 if (res->portid == (portid_t)RTE_PORT_ALL) {
2279 printf("Invalid port id\n");
2283 port = &ports[res->portid];
2285 if (!strcmp(res->rxtxq, "rxq"))
2287 else if (!strcmp(res->rxtxq, "txq"))
2290 printf("Unknown parameter\n");
2294 if (isrx && rx_queue_id_is_invalid(res->qid))
2296 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2299 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2300 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2306 port->nb_rx_desc[res->qid] = res->size;
2308 port->nb_tx_desc[res->qid] = res->size;
2310 cmd_reconfig_device_queue(res->portid, 0, 1);
2313 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2316 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2317 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2319 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2320 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2322 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2323 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2325 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2326 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2328 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2329 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2330 rsize, "ring_size");
2331 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2332 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2335 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2336 .f = cmd_config_rxtx_ring_size_parsed,
2338 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2340 (void *)&cmd_config_rxtx_ring_size_port,
2341 (void *)&cmd_config_rxtx_ring_size_config,
2342 (void *)&cmd_config_rxtx_ring_size_portid,
2343 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2344 (void *)&cmd_config_rxtx_ring_size_qid,
2345 (void *)&cmd_config_rxtx_ring_size_rsize,
2346 (void *)&cmd_config_rxtx_ring_size_size,
2351 /* *** configure port rxq/txq start/stop *** */
2352 struct cmd_config_rxtx_queue {
2353 cmdline_fixed_string_t port;
2355 cmdline_fixed_string_t rxtxq;
2357 cmdline_fixed_string_t opname;
2361 cmd_config_rxtx_queue_parsed(void *parsed_result,
2362 __attribute__((unused)) struct cmdline *cl,
2363 __attribute__((unused)) void *data)
2365 struct cmd_config_rxtx_queue *res = parsed_result;
2370 if (test_done == 0) {
2371 printf("Please stop forwarding first\n");
2375 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2378 if (port_is_started(res->portid) != 1) {
2379 printf("Please start port %u first\n", res->portid);
2383 if (!strcmp(res->rxtxq, "rxq"))
2385 else if (!strcmp(res->rxtxq, "txq"))
2388 printf("Unknown parameter\n");
2392 if (isrx && rx_queue_id_is_invalid(res->qid))
2394 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2397 if (!strcmp(res->opname, "start"))
2399 else if (!strcmp(res->opname, "stop"))
2402 printf("Unknown parameter\n");
2406 if (isstart && isrx)
2407 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2408 else if (!isstart && isrx)
2409 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2410 else if (isstart && !isrx)
2411 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2413 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2415 if (ret == -ENOTSUP)
2416 printf("Function not supported in PMD driver\n");
2419 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2420 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2421 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2422 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2423 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2424 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2425 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2426 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2427 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2428 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2431 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2432 .f = cmd_config_rxtx_queue_parsed,
2434 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2436 (void *)&cmd_config_rxtx_queue_port,
2437 (void *)&cmd_config_rxtx_queue_portid,
2438 (void *)&cmd_config_rxtx_queue_rxtxq,
2439 (void *)&cmd_config_rxtx_queue_qid,
2440 (void *)&cmd_config_rxtx_queue_opname,
2445 /* *** configure port rxq/txq setup *** */
2446 struct cmd_setup_rxtx_queue {
2447 cmdline_fixed_string_t port;
2449 cmdline_fixed_string_t rxtxq;
2451 cmdline_fixed_string_t setup;
2454 /* Common CLI fields for queue setup */
2455 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2456 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2457 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2458 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2459 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2460 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2461 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2462 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2463 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2464 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2467 cmd_setup_rxtx_queue_parsed(
2468 void *parsed_result,
2469 __attribute__((unused)) struct cmdline *cl,
2470 __attribute__((unused)) void *data)
2472 struct cmd_setup_rxtx_queue *res = parsed_result;
2473 struct rte_port *port;
2474 struct rte_mempool *mp;
2475 unsigned int socket_id;
2479 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2482 if (res->portid == (portid_t)RTE_PORT_ALL) {
2483 printf("Invalid port id\n");
2487 if (!strcmp(res->rxtxq, "rxq"))
2489 else if (!strcmp(res->rxtxq, "txq"))
2492 printf("Unknown parameter\n");
2496 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2497 printf("Invalid rx queue\n");
2499 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2500 printf("Invalid tx queue\n");
2504 port = &ports[res->portid];
2506 socket_id = rxring_numa[res->portid];
2507 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2508 socket_id = port->socket_id;
2510 mp = mbuf_pool_find(socket_id);
2512 printf("Failed to setup RX queue: "
2513 "No mempool allocation"
2514 " on the socket %d\n",
2515 rxring_numa[res->portid]);
2518 ret = rte_eth_rx_queue_setup(res->portid,
2520 port->nb_rx_desc[res->qid],
2522 &port->rx_conf[res->qid],
2525 printf("Failed to setup RX queue\n");
2527 socket_id = txring_numa[res->portid];
2528 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2529 socket_id = port->socket_id;
2531 ret = rte_eth_tx_queue_setup(res->portid,
2533 port->nb_tx_desc[res->qid],
2535 &port->tx_conf[res->qid]);
2537 printf("Failed to setup TX queue\n");
2541 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2542 .f = cmd_setup_rxtx_queue_parsed,
2544 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2546 (void *)&cmd_setup_rxtx_queue_port,
2547 (void *)&cmd_setup_rxtx_queue_portid,
2548 (void *)&cmd_setup_rxtx_queue_rxtxq,
2549 (void *)&cmd_setup_rxtx_queue_qid,
2550 (void *)&cmd_setup_rxtx_queue_setup,
2556 /* *** Configure RSS RETA *** */
2557 struct cmd_config_rss_reta {
2558 cmdline_fixed_string_t port;
2559 cmdline_fixed_string_t keyword;
2561 cmdline_fixed_string_t name;
2562 cmdline_fixed_string_t list_name;
2563 cmdline_fixed_string_t list_of_items;
2567 parse_reta_config(const char *str,
2568 struct rte_eth_rss_reta_entry64 *reta_conf,
2569 uint16_t nb_entries)
2573 uint16_t hash_index, idx, shift;
2576 const char *p, *p0 = str;
2583 unsigned long int_fld[_NUM_FLD];
2584 char *str_fld[_NUM_FLD];
2586 while ((p = strchr(p0,'(')) != NULL) {
2588 if((p0 = strchr(p,')')) == NULL)
2592 if(size >= sizeof(s))
2595 snprintf(s, sizeof(s), "%.*s", size, p);
2596 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2598 for (i = 0; i < _NUM_FLD; i++) {
2600 int_fld[i] = strtoul(str_fld[i], &end, 0);
2601 if (errno != 0 || end == str_fld[i] ||
2606 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2607 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2609 if (hash_index >= nb_entries) {
2610 printf("Invalid RETA hash index=%d\n", hash_index);
2614 idx = hash_index / RTE_RETA_GROUP_SIZE;
2615 shift = hash_index % RTE_RETA_GROUP_SIZE;
2616 reta_conf[idx].mask |= (1ULL << shift);
2617 reta_conf[idx].reta[shift] = nb_queue;
2624 cmd_set_rss_reta_parsed(void *parsed_result,
2625 __attribute__((unused)) struct cmdline *cl,
2626 __attribute__((unused)) void *data)
2629 struct rte_eth_dev_info dev_info;
2630 struct rte_eth_rss_reta_entry64 reta_conf[8];
2631 struct cmd_config_rss_reta *res = parsed_result;
2633 memset(&dev_info, 0, sizeof(dev_info));
2634 rte_eth_dev_info_get(res->port_id, &dev_info);
2635 if (dev_info.reta_size == 0) {
2636 printf("Redirection table size is 0 which is "
2637 "invalid for RSS\n");
2640 printf("The reta size of port %d is %u\n",
2641 res->port_id, dev_info.reta_size);
2642 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2643 printf("Currently do not support more than %u entries of "
2644 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2648 memset(reta_conf, 0, sizeof(reta_conf));
2649 if (!strcmp(res->list_name, "reta")) {
2650 if (parse_reta_config(res->list_of_items, reta_conf,
2651 dev_info.reta_size)) {
2652 printf("Invalid RSS Redirection Table "
2653 "config entered\n");
2656 ret = rte_eth_dev_rss_reta_update(res->port_id,
2657 reta_conf, dev_info.reta_size);
2659 printf("Bad redirection table parameter, "
2660 "return code = %d \n", ret);
2664 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2665 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2666 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2667 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2668 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2669 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2670 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2671 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2672 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2673 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2674 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2675 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2677 cmdline_parse_inst_t cmd_config_rss_reta = {
2678 .f = cmd_set_rss_reta_parsed,
2680 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2682 (void *)&cmd_config_rss_reta_port,
2683 (void *)&cmd_config_rss_reta_keyword,
2684 (void *)&cmd_config_rss_reta_port_id,
2685 (void *)&cmd_config_rss_reta_name,
2686 (void *)&cmd_config_rss_reta_list_name,
2687 (void *)&cmd_config_rss_reta_list_of_items,
2692 /* *** SHOW PORT RETA INFO *** */
2693 struct cmd_showport_reta {
2694 cmdline_fixed_string_t show;
2695 cmdline_fixed_string_t port;
2697 cmdline_fixed_string_t rss;
2698 cmdline_fixed_string_t reta;
2700 cmdline_fixed_string_t list_of_items;
2704 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2705 uint16_t nb_entries,
2709 const char *p, *p0 = str;
2714 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2715 RTE_RETA_GROUP_SIZE;
2718 p = strchr(p0, '(');
2722 p0 = strchr(p, ')');
2726 if (size >= sizeof(s)) {
2727 printf("The string size exceeds the internal buffer size\n");
2730 snprintf(s, sizeof(s), "%.*s", size, p);
2731 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2732 if (ret <= 0 || ret != num) {
2733 printf("The bits of masks do not match the number of "
2734 "reta entries: %u\n", num);
2737 for (i = 0; i < ret; i++)
2738 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2744 cmd_showport_reta_parsed(void *parsed_result,
2745 __attribute__((unused)) struct cmdline *cl,
2746 __attribute__((unused)) void *data)
2748 struct cmd_showport_reta *res = parsed_result;
2749 struct rte_eth_rss_reta_entry64 reta_conf[8];
2750 struct rte_eth_dev_info dev_info;
2751 uint16_t max_reta_size;
2753 memset(&dev_info, 0, sizeof(dev_info));
2754 rte_eth_dev_info_get(res->port_id, &dev_info);
2755 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2756 if (res->size == 0 || res->size > max_reta_size) {
2757 printf("Invalid redirection table size: %u (1-%u)\n",
2758 res->size, max_reta_size);
2762 memset(reta_conf, 0, sizeof(reta_conf));
2763 if (showport_parse_reta_config(reta_conf, res->size,
2764 res->list_of_items) < 0) {
2765 printf("Invalid string: %s for reta masks\n",
2766 res->list_of_items);
2769 port_rss_reta_info(res->port_id, reta_conf, res->size);
2772 cmdline_parse_token_string_t cmd_showport_reta_show =
2773 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2774 cmdline_parse_token_string_t cmd_showport_reta_port =
2775 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2776 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2777 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2778 cmdline_parse_token_string_t cmd_showport_reta_rss =
2779 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2780 cmdline_parse_token_string_t cmd_showport_reta_reta =
2781 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2782 cmdline_parse_token_num_t cmd_showport_reta_size =
2783 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2784 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2785 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2786 list_of_items, NULL);
2788 cmdline_parse_inst_t cmd_showport_reta = {
2789 .f = cmd_showport_reta_parsed,
2791 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2793 (void *)&cmd_showport_reta_show,
2794 (void *)&cmd_showport_reta_port,
2795 (void *)&cmd_showport_reta_port_id,
2796 (void *)&cmd_showport_reta_rss,
2797 (void *)&cmd_showport_reta_reta,
2798 (void *)&cmd_showport_reta_size,
2799 (void *)&cmd_showport_reta_list_of_items,
2804 /* *** Show RSS hash configuration *** */
2805 struct cmd_showport_rss_hash {
2806 cmdline_fixed_string_t show;
2807 cmdline_fixed_string_t port;
2809 cmdline_fixed_string_t rss_hash;
2810 cmdline_fixed_string_t rss_type;
2811 cmdline_fixed_string_t key; /* optional argument */
2814 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2815 __attribute__((unused)) struct cmdline *cl,
2818 struct cmd_showport_rss_hash *res = parsed_result;
2820 port_rss_hash_conf_show(res->port_id, res->rss_type,
2821 show_rss_key != NULL);
2824 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2825 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2826 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2827 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2828 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2829 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2830 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2831 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2833 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2834 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2835 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2836 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2837 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2838 "ipv6-tcp-ex#ipv6-udp-ex");
2839 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2840 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2842 cmdline_parse_inst_t cmd_showport_rss_hash = {
2843 .f = cmd_showport_rss_hash_parsed,
2845 .help_str = "show port <port_id> rss-hash "
2846 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2847 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2848 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2850 (void *)&cmd_showport_rss_hash_show,
2851 (void *)&cmd_showport_rss_hash_port,
2852 (void *)&cmd_showport_rss_hash_port_id,
2853 (void *)&cmd_showport_rss_hash_rss_hash,
2854 (void *)&cmd_showport_rss_hash_rss_hash_info,
2859 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2860 .f = cmd_showport_rss_hash_parsed,
2862 .help_str = "show port <port_id> rss-hash "
2863 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2864 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2865 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2867 (void *)&cmd_showport_rss_hash_show,
2868 (void *)&cmd_showport_rss_hash_port,
2869 (void *)&cmd_showport_rss_hash_port_id,
2870 (void *)&cmd_showport_rss_hash_rss_hash,
2871 (void *)&cmd_showport_rss_hash_rss_hash_info,
2872 (void *)&cmd_showport_rss_hash_rss_key,
2877 /* *** Configure DCB *** */
2878 struct cmd_config_dcb {
2879 cmdline_fixed_string_t port;
2880 cmdline_fixed_string_t config;
2882 cmdline_fixed_string_t dcb;
2883 cmdline_fixed_string_t vt;
2884 cmdline_fixed_string_t vt_en;
2886 cmdline_fixed_string_t pfc;
2887 cmdline_fixed_string_t pfc_en;
2891 cmd_config_dcb_parsed(void *parsed_result,
2892 __attribute__((unused)) struct cmdline *cl,
2893 __attribute__((unused)) void *data)
2895 struct cmd_config_dcb *res = parsed_result;
2896 portid_t port_id = res->port_id;
2897 struct rte_port *port;
2901 port = &ports[port_id];
2902 /** Check if the port is not started **/
2903 if (port->port_status != RTE_PORT_STOPPED) {
2904 printf("Please stop port %d first\n", port_id);
2908 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2909 printf("The invalid number of traffic class,"
2910 " only 4 or 8 allowed.\n");
2914 if (nb_fwd_lcores < res->num_tcs) {
2915 printf("nb_cores shouldn't be less than number of TCs.\n");
2918 if (!strncmp(res->pfc_en, "on", 2))
2923 /* DCB in VT mode */
2924 if (!strncmp(res->vt_en, "on", 2))
2925 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2926 (enum rte_eth_nb_tcs)res->num_tcs,
2929 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2930 (enum rte_eth_nb_tcs)res->num_tcs,
2935 printf("Cannot initialize network ports.\n");
2939 cmd_reconfig_device_queue(port_id, 1, 1);
2942 cmdline_parse_token_string_t cmd_config_dcb_port =
2943 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2944 cmdline_parse_token_string_t cmd_config_dcb_config =
2945 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2946 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2947 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2948 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2949 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2950 cmdline_parse_token_string_t cmd_config_dcb_vt =
2951 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2952 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2953 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2954 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2955 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2956 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2957 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2958 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2959 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2961 cmdline_parse_inst_t cmd_config_dcb = {
2962 .f = cmd_config_dcb_parsed,
2964 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2966 (void *)&cmd_config_dcb_port,
2967 (void *)&cmd_config_dcb_config,
2968 (void *)&cmd_config_dcb_port_id,
2969 (void *)&cmd_config_dcb_dcb,
2970 (void *)&cmd_config_dcb_vt,
2971 (void *)&cmd_config_dcb_vt_en,
2972 (void *)&cmd_config_dcb_num_tcs,
2973 (void *)&cmd_config_dcb_pfc,
2974 (void *)&cmd_config_dcb_pfc_en,
2979 /* *** configure number of packets per burst *** */
2980 struct cmd_config_burst {
2981 cmdline_fixed_string_t port;
2982 cmdline_fixed_string_t keyword;
2983 cmdline_fixed_string_t all;
2984 cmdline_fixed_string_t name;
2989 cmd_config_burst_parsed(void *parsed_result,
2990 __attribute__((unused)) struct cmdline *cl,
2991 __attribute__((unused)) void *data)
2993 struct cmd_config_burst *res = parsed_result;
2994 struct rte_eth_dev_info dev_info;
2995 uint16_t rec_nb_pkts;
2997 if (!all_ports_stopped()) {
2998 printf("Please stop all ports first\n");
3002 if (!strcmp(res->name, "burst")) {
3003 if (res->value == 0) {
3004 /* If user gives a value of zero, query the PMD for
3005 * its recommended Rx burst size. Testpmd uses a single
3006 * size for all ports, so assume all ports are the same
3007 * NIC model and use the values from Port 0.
3009 rte_eth_dev_info_get(0, &dev_info);
3010 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3012 if (rec_nb_pkts == 0) {
3013 printf("PMD does not recommend a burst size.\n"
3014 "User provided value must be between"
3015 " 1 and %d\n", MAX_PKT_BURST);
3017 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3018 printf("PMD recommended burst size of %d"
3019 " exceeds maximum value of %d\n",
3020 rec_nb_pkts, MAX_PKT_BURST);
3023 printf("Using PMD-provided burst value of %d\n",
3025 nb_pkt_per_burst = rec_nb_pkts;
3026 } else if (res->value > MAX_PKT_BURST) {
3027 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3030 nb_pkt_per_burst = res->value;
3032 printf("Unknown parameter\n");
3038 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3041 cmdline_parse_token_string_t cmd_config_burst_port =
3042 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3043 cmdline_parse_token_string_t cmd_config_burst_keyword =
3044 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3045 cmdline_parse_token_string_t cmd_config_burst_all =
3046 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3047 cmdline_parse_token_string_t cmd_config_burst_name =
3048 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3049 cmdline_parse_token_num_t cmd_config_burst_value =
3050 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3052 cmdline_parse_inst_t cmd_config_burst = {
3053 .f = cmd_config_burst_parsed,
3055 .help_str = "port config all burst <value>",
3057 (void *)&cmd_config_burst_port,
3058 (void *)&cmd_config_burst_keyword,
3059 (void *)&cmd_config_burst_all,
3060 (void *)&cmd_config_burst_name,
3061 (void *)&cmd_config_burst_value,
3066 /* *** configure rx/tx queues *** */
3067 struct cmd_config_thresh {
3068 cmdline_fixed_string_t port;
3069 cmdline_fixed_string_t keyword;
3070 cmdline_fixed_string_t all;
3071 cmdline_fixed_string_t name;
3076 cmd_config_thresh_parsed(void *parsed_result,
3077 __attribute__((unused)) struct cmdline *cl,
3078 __attribute__((unused)) void *data)
3080 struct cmd_config_thresh *res = parsed_result;
3082 if (!all_ports_stopped()) {
3083 printf("Please stop all ports first\n");
3087 if (!strcmp(res->name, "txpt"))
3088 tx_pthresh = res->value;
3089 else if(!strcmp(res->name, "txht"))
3090 tx_hthresh = res->value;
3091 else if(!strcmp(res->name, "txwt"))
3092 tx_wthresh = res->value;
3093 else if(!strcmp(res->name, "rxpt"))
3094 rx_pthresh = res->value;
3095 else if(!strcmp(res->name, "rxht"))
3096 rx_hthresh = res->value;
3097 else if(!strcmp(res->name, "rxwt"))
3098 rx_wthresh = res->value;
3100 printf("Unknown parameter\n");
3106 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3109 cmdline_parse_token_string_t cmd_config_thresh_port =
3110 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3111 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3112 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3113 cmdline_parse_token_string_t cmd_config_thresh_all =
3114 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3115 cmdline_parse_token_string_t cmd_config_thresh_name =
3116 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3117 "txpt#txht#txwt#rxpt#rxht#rxwt");
3118 cmdline_parse_token_num_t cmd_config_thresh_value =
3119 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3121 cmdline_parse_inst_t cmd_config_thresh = {
3122 .f = cmd_config_thresh_parsed,
3124 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3126 (void *)&cmd_config_thresh_port,
3127 (void *)&cmd_config_thresh_keyword,
3128 (void *)&cmd_config_thresh_all,
3129 (void *)&cmd_config_thresh_name,
3130 (void *)&cmd_config_thresh_value,
3135 /* *** configure free/rs threshold *** */
3136 struct cmd_config_threshold {
3137 cmdline_fixed_string_t port;
3138 cmdline_fixed_string_t keyword;
3139 cmdline_fixed_string_t all;
3140 cmdline_fixed_string_t name;
3145 cmd_config_threshold_parsed(void *parsed_result,
3146 __attribute__((unused)) struct cmdline *cl,
3147 __attribute__((unused)) void *data)
3149 struct cmd_config_threshold *res = parsed_result;
3151 if (!all_ports_stopped()) {
3152 printf("Please stop all ports first\n");
3156 if (!strcmp(res->name, "txfreet"))
3157 tx_free_thresh = res->value;
3158 else if (!strcmp(res->name, "txrst"))
3159 tx_rs_thresh = res->value;
3160 else if (!strcmp(res->name, "rxfreet"))
3161 rx_free_thresh = res->value;
3163 printf("Unknown parameter\n");
3169 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3172 cmdline_parse_token_string_t cmd_config_threshold_port =
3173 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3174 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3175 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3177 cmdline_parse_token_string_t cmd_config_threshold_all =
3178 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3179 cmdline_parse_token_string_t cmd_config_threshold_name =
3180 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3181 "txfreet#txrst#rxfreet");
3182 cmdline_parse_token_num_t cmd_config_threshold_value =
3183 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3185 cmdline_parse_inst_t cmd_config_threshold = {
3186 .f = cmd_config_threshold_parsed,
3188 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3190 (void *)&cmd_config_threshold_port,
3191 (void *)&cmd_config_threshold_keyword,
3192 (void *)&cmd_config_threshold_all,
3193 (void *)&cmd_config_threshold_name,
3194 (void *)&cmd_config_threshold_value,
3200 struct cmd_stop_result {
3201 cmdline_fixed_string_t stop;
3204 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3205 __attribute__((unused)) struct cmdline *cl,
3206 __attribute__((unused)) void *data)
3208 stop_packet_forwarding();
3211 cmdline_parse_token_string_t cmd_stop_stop =
3212 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3214 cmdline_parse_inst_t cmd_stop = {
3215 .f = cmd_stop_parsed,
3217 .help_str = "stop: Stop packet forwarding",
3219 (void *)&cmd_stop_stop,
3224 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3227 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3228 unsigned int *parsed_items, int check_unique_values)
3230 unsigned int nb_item;
3238 * First parse all items in the list and store their value.
3243 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3245 if ((c >= '0') && (c <= '9')) {
3246 value = (unsigned int) (value * 10 + (c - '0'));
3251 printf("character %c is not a decimal digit\n", c);
3255 printf("No valid value before comma\n");
3258 if (nb_item < max_items) {
3259 parsed_items[nb_item] = value;
3265 if (nb_item >= max_items) {
3266 printf("Number of %s = %u > %u (maximum items)\n",
3267 item_name, nb_item + 1, max_items);
3270 parsed_items[nb_item++] = value;
3271 if (! check_unique_values)
3275 * Then, check that all values in the list are differents.
3276 * No optimization here...
3278 for (i = 0; i < nb_item; i++) {
3279 for (j = i + 1; j < nb_item; j++) {
3280 if (parsed_items[j] == parsed_items[i]) {
3281 printf("duplicated %s %u at index %u and %u\n",
3282 item_name, parsed_items[i], i, j);
3290 struct cmd_set_list_result {
3291 cmdline_fixed_string_t cmd_keyword;
3292 cmdline_fixed_string_t list_name;
3293 cmdline_fixed_string_t list_of_items;
3296 static void cmd_set_list_parsed(void *parsed_result,
3297 __attribute__((unused)) struct cmdline *cl,
3298 __attribute__((unused)) void *data)
3300 struct cmd_set_list_result *res;
3302 unsigned int lcorelist[RTE_MAX_LCORE];
3303 unsigned int portlist[RTE_MAX_ETHPORTS];
3305 unsigned int nb_item;
3307 if (test_done == 0) {
3308 printf("Please stop forwarding first\n");
3312 res = parsed_result;
3313 if (!strcmp(res->list_name, "corelist")) {
3314 nb_item = parse_item_list(res->list_of_items, "core",
3316 parsed_items.lcorelist, 1);
3318 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3323 if (!strcmp(res->list_name, "portlist")) {
3324 nb_item = parse_item_list(res->list_of_items, "port",
3326 parsed_items.portlist, 1);
3328 set_fwd_ports_list(parsed_items.portlist, nb_item);
3334 cmdline_parse_token_string_t cmd_set_list_keyword =
3335 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3337 cmdline_parse_token_string_t cmd_set_list_name =
3338 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3339 "corelist#portlist");
3340 cmdline_parse_token_string_t cmd_set_list_of_items =
3341 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3344 cmdline_parse_inst_t cmd_set_fwd_list = {
3345 .f = cmd_set_list_parsed,
3347 .help_str = "set corelist|portlist <list0[,list1]*>",
3349 (void *)&cmd_set_list_keyword,
3350 (void *)&cmd_set_list_name,
3351 (void *)&cmd_set_list_of_items,
3356 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3358 struct cmd_setmask_result {
3359 cmdline_fixed_string_t set;
3360 cmdline_fixed_string_t mask;
3364 static void cmd_set_mask_parsed(void *parsed_result,
3365 __attribute__((unused)) struct cmdline *cl,
3366 __attribute__((unused)) void *data)
3368 struct cmd_setmask_result *res = parsed_result;
3370 if (test_done == 0) {
3371 printf("Please stop forwarding first\n");
3374 if (!strcmp(res->mask, "coremask")) {
3375 set_fwd_lcores_mask(res->hexavalue);
3377 } else if (!strcmp(res->mask, "portmask")) {
3378 set_fwd_ports_mask(res->hexavalue);
3383 cmdline_parse_token_string_t cmd_setmask_set =
3384 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3385 cmdline_parse_token_string_t cmd_setmask_mask =
3386 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3387 "coremask#portmask");
3388 cmdline_parse_token_num_t cmd_setmask_value =
3389 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3391 cmdline_parse_inst_t cmd_set_fwd_mask = {
3392 .f = cmd_set_mask_parsed,
3394 .help_str = "set coremask|portmask <hexadecimal value>",
3396 (void *)&cmd_setmask_set,
3397 (void *)&cmd_setmask_mask,
3398 (void *)&cmd_setmask_value,
3404 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3406 struct cmd_set_result {
3407 cmdline_fixed_string_t set;
3408 cmdline_fixed_string_t what;
3412 static void cmd_set_parsed(void *parsed_result,
3413 __attribute__((unused)) struct cmdline *cl,
3414 __attribute__((unused)) void *data)
3416 struct cmd_set_result *res = parsed_result;
3417 if (!strcmp(res->what, "nbport")) {
3418 set_fwd_ports_number(res->value);
3420 } else if (!strcmp(res->what, "nbcore")) {
3421 set_fwd_lcores_number(res->value);
3423 } else if (!strcmp(res->what, "burst"))
3424 set_nb_pkt_per_burst(res->value);
3425 else if (!strcmp(res->what, "verbose"))
3426 set_verbose_level(res->value);
3429 cmdline_parse_token_string_t cmd_set_set =
3430 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3431 cmdline_parse_token_string_t cmd_set_what =
3432 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3433 "nbport#nbcore#burst#verbose");
3434 cmdline_parse_token_num_t cmd_set_value =
3435 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3437 cmdline_parse_inst_t cmd_set_numbers = {
3438 .f = cmd_set_parsed,
3440 .help_str = "set nbport|nbcore|burst|verbose <value>",
3442 (void *)&cmd_set_set,
3443 (void *)&cmd_set_what,
3444 (void *)&cmd_set_value,
3449 /* *** SET LOG LEVEL CONFIGURATION *** */
3451 struct cmd_set_log_result {
3452 cmdline_fixed_string_t set;
3453 cmdline_fixed_string_t log;
3454 cmdline_fixed_string_t type;
3459 cmd_set_log_parsed(void *parsed_result,
3460 __attribute__((unused)) struct cmdline *cl,
3461 __attribute__((unused)) void *data)
3463 struct cmd_set_log_result *res;
3466 res = parsed_result;
3467 if (!strcmp(res->type, "global"))
3468 rte_log_set_global_level(res->level);
3470 ret = rte_log_set_level_regexp(res->type, res->level);
3472 printf("Unable to set log level\n");
3476 cmdline_parse_token_string_t cmd_set_log_set =
3477 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3478 cmdline_parse_token_string_t cmd_set_log_log =
3479 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3480 cmdline_parse_token_string_t cmd_set_log_type =
3481 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3482 cmdline_parse_token_num_t cmd_set_log_level =
3483 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3485 cmdline_parse_inst_t cmd_set_log = {
3486 .f = cmd_set_log_parsed,
3488 .help_str = "set log global|<type> <level>",
3490 (void *)&cmd_set_log_set,
3491 (void *)&cmd_set_log_log,
3492 (void *)&cmd_set_log_type,
3493 (void *)&cmd_set_log_level,
3498 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3500 struct cmd_set_txpkts_result {
3501 cmdline_fixed_string_t cmd_keyword;
3502 cmdline_fixed_string_t txpkts;
3503 cmdline_fixed_string_t seg_lengths;
3507 cmd_set_txpkts_parsed(void *parsed_result,
3508 __attribute__((unused)) struct cmdline *cl,
3509 __attribute__((unused)) void *data)
3511 struct cmd_set_txpkts_result *res;
3512 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3513 unsigned int nb_segs;
3515 res = parsed_result;
3516 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3517 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3519 set_tx_pkt_segments(seg_lengths, nb_segs);
3522 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3523 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3524 cmd_keyword, "set");
3525 cmdline_parse_token_string_t cmd_set_txpkts_name =
3526 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3528 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3529 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3532 cmdline_parse_inst_t cmd_set_txpkts = {
3533 .f = cmd_set_txpkts_parsed,
3535 .help_str = "set txpkts <len0[,len1]*>",
3537 (void *)&cmd_set_txpkts_keyword,
3538 (void *)&cmd_set_txpkts_name,
3539 (void *)&cmd_set_txpkts_lengths,
3544 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3546 struct cmd_set_txsplit_result {
3547 cmdline_fixed_string_t cmd_keyword;
3548 cmdline_fixed_string_t txsplit;
3549 cmdline_fixed_string_t mode;
3553 cmd_set_txsplit_parsed(void *parsed_result,
3554 __attribute__((unused)) struct cmdline *cl,
3555 __attribute__((unused)) void *data)
3557 struct cmd_set_txsplit_result *res;
3559 res = parsed_result;
3560 set_tx_pkt_split(res->mode);
3563 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3564 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3565 cmd_keyword, "set");
3566 cmdline_parse_token_string_t cmd_set_txsplit_name =
3567 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3568 txsplit, "txsplit");
3569 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3570 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3573 cmdline_parse_inst_t cmd_set_txsplit = {
3574 .f = cmd_set_txsplit_parsed,
3576 .help_str = "set txsplit on|off|rand",
3578 (void *)&cmd_set_txsplit_keyword,
3579 (void *)&cmd_set_txsplit_name,
3580 (void *)&cmd_set_txsplit_mode,
3585 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3586 struct cmd_rx_vlan_filter_all_result {
3587 cmdline_fixed_string_t rx_vlan;
3588 cmdline_fixed_string_t what;
3589 cmdline_fixed_string_t all;
3594 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3595 __attribute__((unused)) struct cmdline *cl,
3596 __attribute__((unused)) void *data)
3598 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3600 if (!strcmp(res->what, "add"))
3601 rx_vlan_all_filter_set(res->port_id, 1);
3603 rx_vlan_all_filter_set(res->port_id, 0);
3606 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3607 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3608 rx_vlan, "rx_vlan");
3609 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3610 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3612 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3613 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3615 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3616 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3619 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3620 .f = cmd_rx_vlan_filter_all_parsed,
3622 .help_str = "rx_vlan add|rm all <port_id>: "
3623 "Add/Remove all identifiers to/from the set of VLAN "
3624 "identifiers filtered by a port",
3626 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3627 (void *)&cmd_rx_vlan_filter_all_what,
3628 (void *)&cmd_rx_vlan_filter_all_all,
3629 (void *)&cmd_rx_vlan_filter_all_portid,
3634 /* *** VLAN OFFLOAD SET ON A PORT *** */
3635 struct cmd_vlan_offload_result {
3636 cmdline_fixed_string_t vlan;
3637 cmdline_fixed_string_t set;
3638 cmdline_fixed_string_t vlan_type;
3639 cmdline_fixed_string_t what;
3640 cmdline_fixed_string_t on;
3641 cmdline_fixed_string_t port_id;
3645 cmd_vlan_offload_parsed(void *parsed_result,
3646 __attribute__((unused)) struct cmdline *cl,
3647 __attribute__((unused)) void *data)
3650 struct cmd_vlan_offload_result *res = parsed_result;
3653 portid_t port_id = 0;
3657 len = strnlen(str, STR_TOKEN_SIZE);
3659 /* Get port_id first */
3667 tmp = strtoul(str, NULL, 0);
3668 /* If port_id greater that what portid_t can represent, return */
3669 if(tmp >= RTE_MAX_ETHPORTS)
3671 port_id = (portid_t)tmp;
3673 if (!strcmp(res->on, "on"))
3678 if (!strcmp(res->what, "strip"))
3679 rx_vlan_strip_set(port_id, on);
3680 else if(!strcmp(res->what, "stripq")){
3681 uint16_t queue_id = 0;
3683 /* No queue_id, return */
3685 printf("must specify (port,queue_id)\n");
3688 tmp = strtoul(str + i + 1, NULL, 0);
3689 /* If queue_id greater that what 16-bits can represent, return */
3693 queue_id = (uint16_t)tmp;
3694 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3696 else if (!strcmp(res->what, "filter"))
3697 rx_vlan_filter_set(port_id, on);
3699 vlan_extend_set(port_id, on);
3704 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3705 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3707 cmdline_parse_token_string_t cmd_vlan_offload_set =
3708 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3710 cmdline_parse_token_string_t cmd_vlan_offload_what =
3711 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3712 what, "strip#filter#qinq#stripq");
3713 cmdline_parse_token_string_t cmd_vlan_offload_on =
3714 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3716 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3717 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3720 cmdline_parse_inst_t cmd_vlan_offload = {
3721 .f = cmd_vlan_offload_parsed,
3723 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3724 "<port_id[,queue_id]>: "
3725 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3727 (void *)&cmd_vlan_offload_vlan,
3728 (void *)&cmd_vlan_offload_set,
3729 (void *)&cmd_vlan_offload_what,
3730 (void *)&cmd_vlan_offload_on,
3731 (void *)&cmd_vlan_offload_portid,
3736 /* *** VLAN TPID SET ON A PORT *** */
3737 struct cmd_vlan_tpid_result {
3738 cmdline_fixed_string_t vlan;
3739 cmdline_fixed_string_t set;
3740 cmdline_fixed_string_t vlan_type;
3741 cmdline_fixed_string_t what;
3747 cmd_vlan_tpid_parsed(void *parsed_result,
3748 __attribute__((unused)) struct cmdline *cl,
3749 __attribute__((unused)) void *data)
3751 struct cmd_vlan_tpid_result *res = parsed_result;
3752 enum rte_vlan_type vlan_type;
3754 if (!strcmp(res->vlan_type, "inner"))
3755 vlan_type = ETH_VLAN_TYPE_INNER;
3756 else if (!strcmp(res->vlan_type, "outer"))
3757 vlan_type = ETH_VLAN_TYPE_OUTER;
3759 printf("Unknown vlan type\n");
3762 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3765 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3766 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3768 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3769 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3771 cmdline_parse_token_string_t cmd_vlan_type =
3772 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3773 vlan_type, "inner#outer");
3774 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3775 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3777 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3778 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3780 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3781 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3784 cmdline_parse_inst_t cmd_vlan_tpid = {
3785 .f = cmd_vlan_tpid_parsed,
3787 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3788 "Set the VLAN Ether type",
3790 (void *)&cmd_vlan_tpid_vlan,
3791 (void *)&cmd_vlan_tpid_set,
3792 (void *)&cmd_vlan_type,
3793 (void *)&cmd_vlan_tpid_what,
3794 (void *)&cmd_vlan_tpid_tpid,
3795 (void *)&cmd_vlan_tpid_portid,
3800 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3801 struct cmd_rx_vlan_filter_result {
3802 cmdline_fixed_string_t rx_vlan;
3803 cmdline_fixed_string_t what;
3809 cmd_rx_vlan_filter_parsed(void *parsed_result,
3810 __attribute__((unused)) struct cmdline *cl,
3811 __attribute__((unused)) void *data)
3813 struct cmd_rx_vlan_filter_result *res = parsed_result;
3815 if (!strcmp(res->what, "add"))
3816 rx_vft_set(res->port_id, res->vlan_id, 1);
3818 rx_vft_set(res->port_id, res->vlan_id, 0);
3821 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3822 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3823 rx_vlan, "rx_vlan");
3824 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3825 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3827 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3828 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3830 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3831 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3834 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3835 .f = cmd_rx_vlan_filter_parsed,
3837 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3838 "Add/Remove a VLAN identifier to/from the set of VLAN "
3839 "identifiers filtered by a port",
3841 (void *)&cmd_rx_vlan_filter_rx_vlan,
3842 (void *)&cmd_rx_vlan_filter_what,
3843 (void *)&cmd_rx_vlan_filter_vlanid,
3844 (void *)&cmd_rx_vlan_filter_portid,
3849 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3850 struct cmd_tx_vlan_set_result {
3851 cmdline_fixed_string_t tx_vlan;
3852 cmdline_fixed_string_t set;
3858 cmd_tx_vlan_set_parsed(void *parsed_result,
3859 __attribute__((unused)) struct cmdline *cl,
3860 __attribute__((unused)) void *data)
3862 struct cmd_tx_vlan_set_result *res = parsed_result;
3864 if (!port_is_stopped(res->port_id)) {
3865 printf("Please stop port %d first\n", res->port_id);
3869 tx_vlan_set(res->port_id, res->vlan_id);
3871 cmd_reconfig_device_queue(res->port_id, 1, 1);
3874 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3875 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3876 tx_vlan, "tx_vlan");
3877 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3878 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3880 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3881 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3883 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3884 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3887 cmdline_parse_inst_t cmd_tx_vlan_set = {
3888 .f = cmd_tx_vlan_set_parsed,
3890 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3891 "Enable hardware insertion of a single VLAN header "
3892 "with a given TAG Identifier in packets sent on a port",
3894 (void *)&cmd_tx_vlan_set_tx_vlan,
3895 (void *)&cmd_tx_vlan_set_set,
3896 (void *)&cmd_tx_vlan_set_portid,
3897 (void *)&cmd_tx_vlan_set_vlanid,
3902 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3903 struct cmd_tx_vlan_set_qinq_result {
3904 cmdline_fixed_string_t tx_vlan;
3905 cmdline_fixed_string_t set;
3908 uint16_t vlan_id_outer;
3912 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3913 __attribute__((unused)) struct cmdline *cl,
3914 __attribute__((unused)) void *data)
3916 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3918 if (!port_is_stopped(res->port_id)) {
3919 printf("Please stop port %d first\n", res->port_id);
3923 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3925 cmd_reconfig_device_queue(res->port_id, 1, 1);
3928 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3929 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3930 tx_vlan, "tx_vlan");
3931 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3932 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3934 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3935 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3937 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3938 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3940 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3941 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3942 vlan_id_outer, UINT16);
3944 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3945 .f = cmd_tx_vlan_set_qinq_parsed,
3947 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3948 "Enable hardware insertion of double VLAN header "
3949 "with given TAG Identifiers in packets sent on a port",
3951 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3952 (void *)&cmd_tx_vlan_set_qinq_set,
3953 (void *)&cmd_tx_vlan_set_qinq_portid,
3954 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3955 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3960 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3961 struct cmd_tx_vlan_set_pvid_result {
3962 cmdline_fixed_string_t tx_vlan;
3963 cmdline_fixed_string_t set;
3964 cmdline_fixed_string_t pvid;
3967 cmdline_fixed_string_t mode;
3971 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3972 __attribute__((unused)) struct cmdline *cl,
3973 __attribute__((unused)) void *data)
3975 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3977 if (strcmp(res->mode, "on") == 0)
3978 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3980 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3983 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3984 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3985 tx_vlan, "tx_vlan");
3986 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3987 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3989 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3990 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3992 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3993 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3995 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3996 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3998 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3999 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4002 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4003 .f = cmd_tx_vlan_set_pvid_parsed,
4005 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4007 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4008 (void *)&cmd_tx_vlan_set_pvid_set,
4009 (void *)&cmd_tx_vlan_set_pvid_pvid,
4010 (void *)&cmd_tx_vlan_set_pvid_port_id,
4011 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4012 (void *)&cmd_tx_vlan_set_pvid_mode,
4017 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4018 struct cmd_tx_vlan_reset_result {
4019 cmdline_fixed_string_t tx_vlan;
4020 cmdline_fixed_string_t reset;
4025 cmd_tx_vlan_reset_parsed(void *parsed_result,
4026 __attribute__((unused)) struct cmdline *cl,
4027 __attribute__((unused)) void *data)
4029 struct cmd_tx_vlan_reset_result *res = parsed_result;
4031 if (!port_is_stopped(res->port_id)) {
4032 printf("Please stop port %d first\n", res->port_id);
4036 tx_vlan_reset(res->port_id);
4038 cmd_reconfig_device_queue(res->port_id, 1, 1);
4041 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4042 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4043 tx_vlan, "tx_vlan");
4044 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4045 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4047 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4048 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4051 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4052 .f = cmd_tx_vlan_reset_parsed,
4054 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4055 "VLAN header in packets sent on a port",
4057 (void *)&cmd_tx_vlan_reset_tx_vlan,
4058 (void *)&cmd_tx_vlan_reset_reset,
4059 (void *)&cmd_tx_vlan_reset_portid,
4065 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4066 struct cmd_csum_result {
4067 cmdline_fixed_string_t csum;
4068 cmdline_fixed_string_t mode;
4069 cmdline_fixed_string_t proto;
4070 cmdline_fixed_string_t hwsw;
4075 csum_show(int port_id)
4077 struct rte_eth_dev_info dev_info;
4078 uint64_t tx_offloads;
4080 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4081 printf("Parse tunnel is %s\n",
4082 (ports[port_id].parse_tunnel) ? "on" : "off");
4083 printf("IP checksum offload is %s\n",
4084 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4085 printf("UDP checksum offload is %s\n",
4086 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4087 printf("TCP checksum offload is %s\n",
4088 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4089 printf("SCTP checksum offload is %s\n",
4090 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4091 printf("Outer-Ip checksum offload is %s\n",
4092 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4094 /* display warnings if configuration is not supported by the NIC */
4095 rte_eth_dev_info_get(port_id, &dev_info);
4096 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4097 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4098 printf("Warning: hardware IP checksum enabled but not "
4099 "supported by port %d\n", port_id);
4101 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4102 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4103 printf("Warning: hardware UDP checksum enabled but not "
4104 "supported by port %d\n", port_id);
4106 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4107 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4108 printf("Warning: hardware TCP checksum enabled but not "
4109 "supported by port %d\n", port_id);
4111 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4112 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4113 printf("Warning: hardware SCTP checksum enabled but not "
4114 "supported by port %d\n", port_id);
4116 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4117 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4118 printf("Warning: hardware outer IP checksum enabled but not "
4119 "supported by port %d\n", port_id);
4124 cmd_csum_parsed(void *parsed_result,
4125 __attribute__((unused)) struct cmdline *cl,
4126 __attribute__((unused)) void *data)
4128 struct cmd_csum_result *res = parsed_result;
4130 uint64_t csum_offloads = 0;
4131 struct rte_eth_dev_info dev_info;
4133 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4134 printf("invalid port %d\n", res->port_id);
4137 if (!port_is_stopped(res->port_id)) {
4138 printf("Please stop port %d first\n", res->port_id);
4142 rte_eth_dev_info_get(res->port_id, &dev_info);
4143 if (!strcmp(res->mode, "set")) {
4145 if (!strcmp(res->hwsw, "hw"))
4148 if (!strcmp(res->proto, "ip")) {
4149 if (hw == 0 || (dev_info.tx_offload_capa &
4150 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4151 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4153 printf("IP checksum offload is not supported "
4154 "by port %u\n", res->port_id);
4156 } else if (!strcmp(res->proto, "udp")) {
4157 if (hw == 0 || (dev_info.tx_offload_capa &
4158 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4159 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4161 printf("UDP checksum offload is not supported "
4162 "by port %u\n", res->port_id);
4164 } else if (!strcmp(res->proto, "tcp")) {
4165 if (hw == 0 || (dev_info.tx_offload_capa &
4166 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4167 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4169 printf("TCP checksum offload is not supported "
4170 "by port %u\n", res->port_id);
4172 } else if (!strcmp(res->proto, "sctp")) {
4173 if (hw == 0 || (dev_info.tx_offload_capa &
4174 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4175 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4177 printf("SCTP checksum offload is not supported "
4178 "by port %u\n", res->port_id);
4180 } else if (!strcmp(res->proto, "outer-ip")) {
4181 if (hw == 0 || (dev_info.tx_offload_capa &
4182 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4184 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4186 printf("Outer IP checksum offload is not "
4187 "supported by port %u\n", res->port_id);
4192 ports[res->port_id].dev_conf.txmode.offloads |=
4195 ports[res->port_id].dev_conf.txmode.offloads &=
4199 csum_show(res->port_id);
4201 cmd_reconfig_device_queue(res->port_id, 1, 1);
4204 cmdline_parse_token_string_t cmd_csum_csum =
4205 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4207 cmdline_parse_token_string_t cmd_csum_mode =
4208 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4210 cmdline_parse_token_string_t cmd_csum_proto =
4211 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4212 proto, "ip#tcp#udp#sctp#outer-ip");
4213 cmdline_parse_token_string_t cmd_csum_hwsw =
4214 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4216 cmdline_parse_token_num_t cmd_csum_portid =
4217 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4220 cmdline_parse_inst_t cmd_csum_set = {
4221 .f = cmd_csum_parsed,
4223 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4224 "Enable/Disable hardware calculation of L3/L4 checksum when "
4225 "using csum forward engine",
4227 (void *)&cmd_csum_csum,
4228 (void *)&cmd_csum_mode,
4229 (void *)&cmd_csum_proto,
4230 (void *)&cmd_csum_hwsw,
4231 (void *)&cmd_csum_portid,
4236 cmdline_parse_token_string_t cmd_csum_mode_show =
4237 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4240 cmdline_parse_inst_t cmd_csum_show = {
4241 .f = cmd_csum_parsed,
4243 .help_str = "csum show <port_id>: Show checksum offload configuration",
4245 (void *)&cmd_csum_csum,
4246 (void *)&cmd_csum_mode_show,
4247 (void *)&cmd_csum_portid,
4252 /* Enable/disable tunnel parsing */
4253 struct cmd_csum_tunnel_result {
4254 cmdline_fixed_string_t csum;
4255 cmdline_fixed_string_t parse;
4256 cmdline_fixed_string_t onoff;
4261 cmd_csum_tunnel_parsed(void *parsed_result,
4262 __attribute__((unused)) struct cmdline *cl,
4263 __attribute__((unused)) void *data)
4265 struct cmd_csum_tunnel_result *res = parsed_result;
4267 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4270 if (!strcmp(res->onoff, "on"))
4271 ports[res->port_id].parse_tunnel = 1;
4273 ports[res->port_id].parse_tunnel = 0;
4275 csum_show(res->port_id);
4278 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4279 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4281 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4282 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4283 parse, "parse_tunnel");
4284 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4285 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4287 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4288 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4291 cmdline_parse_inst_t cmd_csum_tunnel = {
4292 .f = cmd_csum_tunnel_parsed,
4294 .help_str = "csum parse_tunnel on|off <port_id>: "
4295 "Enable/Disable parsing of tunnels for csum engine",
4297 (void *)&cmd_csum_tunnel_csum,
4298 (void *)&cmd_csum_tunnel_parse,
4299 (void *)&cmd_csum_tunnel_onoff,
4300 (void *)&cmd_csum_tunnel_portid,
4305 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4306 struct cmd_tso_set_result {
4307 cmdline_fixed_string_t tso;
4308 cmdline_fixed_string_t mode;
4314 cmd_tso_set_parsed(void *parsed_result,
4315 __attribute__((unused)) struct cmdline *cl,
4316 __attribute__((unused)) void *data)
4318 struct cmd_tso_set_result *res = parsed_result;
4319 struct rte_eth_dev_info dev_info;
4321 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4323 if (!port_is_stopped(res->port_id)) {
4324 printf("Please stop port %d first\n", res->port_id);
4328 if (!strcmp(res->mode, "set"))
4329 ports[res->port_id].tso_segsz = res->tso_segsz;
4331 rte_eth_dev_info_get(res->port_id, &dev_info);
4332 if ((ports[res->port_id].tso_segsz != 0) &&
4333 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4334 printf("Error: TSO is not supported by port %d\n",
4339 if (ports[res->port_id].tso_segsz == 0) {
4340 ports[res->port_id].dev_conf.txmode.offloads &=
4341 ~DEV_TX_OFFLOAD_TCP_TSO;
4342 printf("TSO for non-tunneled packets is disabled\n");
4344 ports[res->port_id].dev_conf.txmode.offloads |=
4345 DEV_TX_OFFLOAD_TCP_TSO;
4346 printf("TSO segment size for non-tunneled packets is %d\n",
4347 ports[res->port_id].tso_segsz);
4350 /* display warnings if configuration is not supported by the NIC */
4351 rte_eth_dev_info_get(res->port_id, &dev_info);
4352 if ((ports[res->port_id].tso_segsz != 0) &&
4353 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4354 printf("Warning: TSO enabled but not "
4355 "supported by port %d\n", res->port_id);
4358 cmd_reconfig_device_queue(res->port_id, 1, 1);
4361 cmdline_parse_token_string_t cmd_tso_set_tso =
4362 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4364 cmdline_parse_token_string_t cmd_tso_set_mode =
4365 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4367 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4368 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4370 cmdline_parse_token_num_t cmd_tso_set_portid =
4371 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4374 cmdline_parse_inst_t cmd_tso_set = {
4375 .f = cmd_tso_set_parsed,
4377 .help_str = "tso set <tso_segsz> <port_id>: "
4378 "Set TSO segment size of non-tunneled packets for csum engine "
4381 (void *)&cmd_tso_set_tso,
4382 (void *)&cmd_tso_set_mode,
4383 (void *)&cmd_tso_set_tso_segsz,
4384 (void *)&cmd_tso_set_portid,
4389 cmdline_parse_token_string_t cmd_tso_show_mode =
4390 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4394 cmdline_parse_inst_t cmd_tso_show = {
4395 .f = cmd_tso_set_parsed,
4397 .help_str = "tso show <port_id>: "
4398 "Show TSO segment size of non-tunneled packets for csum engine",
4400 (void *)&cmd_tso_set_tso,
4401 (void *)&cmd_tso_show_mode,
4402 (void *)&cmd_tso_set_portid,
4407 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4408 struct cmd_tunnel_tso_set_result {
4409 cmdline_fixed_string_t tso;
4410 cmdline_fixed_string_t mode;
4415 static struct rte_eth_dev_info
4416 check_tunnel_tso_nic_support(portid_t port_id)
4418 struct rte_eth_dev_info dev_info;
4420 rte_eth_dev_info_get(port_id, &dev_info);
4421 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4422 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4423 "not enabled for port %d\n", port_id);
4424 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4425 printf("Warning: GRE TUNNEL TSO not supported therefore "
4426 "not enabled for port %d\n", port_id);
4427 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4428 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4429 "not enabled for port %d\n", port_id);
4430 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4431 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4432 "not enabled for port %d\n", port_id);
4433 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4434 printf("Warning: IP TUNNEL TSO not supported therefore "
4435 "not enabled for port %d\n", port_id);
4436 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4437 printf("Warning: UDP TUNNEL TSO not supported therefore "
4438 "not enabled for port %d\n", port_id);
4443 cmd_tunnel_tso_set_parsed(void *parsed_result,
4444 __attribute__((unused)) struct cmdline *cl,
4445 __attribute__((unused)) void *data)
4447 struct cmd_tunnel_tso_set_result *res = parsed_result;
4448 struct rte_eth_dev_info dev_info;
4450 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4452 if (!port_is_stopped(res->port_id)) {
4453 printf("Please stop port %d first\n", res->port_id);
4457 if (!strcmp(res->mode, "set"))
4458 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4460 dev_info = check_tunnel_tso_nic_support(res->port_id);
4461 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4462 ports[res->port_id].dev_conf.txmode.offloads &=
4463 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4464 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4465 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4466 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4467 DEV_TX_OFFLOAD_IP_TNL_TSO |
4468 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4469 printf("TSO for tunneled packets is disabled\n");
4471 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4472 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4473 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4474 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4475 DEV_TX_OFFLOAD_IP_TNL_TSO |
4476 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4478 ports[res->port_id].dev_conf.txmode.offloads |=
4479 (tso_offloads & dev_info.tx_offload_capa);
4480 printf("TSO segment size for tunneled packets is %d\n",
4481 ports[res->port_id].tunnel_tso_segsz);
4483 /* Below conditions are needed to make it work:
4484 * (1) tunnel TSO is supported by the NIC;
4485 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4487 * (3) for tunneled pkts with outer L3 of IPv4,
4488 * "csum set outer-ip" must be set to hw, because after tso,
4489 * total_len of outer IP header is changed, and the checksum
4490 * of outer IP header calculated by sw should be wrong; that
4491 * is not necessary for IPv6 tunneled pkts because there's no
4492 * checksum in IP header anymore.
4495 if (!ports[res->port_id].parse_tunnel)
4496 printf("Warning: csum parse_tunnel must be set "
4497 "so that tunneled packets are recognized\n");
4498 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4499 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4500 printf("Warning: csum set outer-ip must be set to hw "
4501 "if outer L3 is IPv4; not necessary for IPv6\n");
4504 cmd_reconfig_device_queue(res->port_id, 1, 1);
4507 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4508 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4510 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4511 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4513 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4514 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4516 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4517 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4520 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4521 .f = cmd_tunnel_tso_set_parsed,
4523 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4524 "Set TSO segment size of tunneled packets for csum engine "
4527 (void *)&cmd_tunnel_tso_set_tso,
4528 (void *)&cmd_tunnel_tso_set_mode,
4529 (void *)&cmd_tunnel_tso_set_tso_segsz,
4530 (void *)&cmd_tunnel_tso_set_portid,
4535 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4536 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4540 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4541 .f = cmd_tunnel_tso_set_parsed,
4543 .help_str = "tunnel_tso show <port_id> "
4544 "Show TSO segment size of tunneled packets for csum engine",
4546 (void *)&cmd_tunnel_tso_set_tso,
4547 (void *)&cmd_tunnel_tso_show_mode,
4548 (void *)&cmd_tunnel_tso_set_portid,
4553 /* *** SET GRO FOR A PORT *** */
4554 struct cmd_gro_enable_result {
4555 cmdline_fixed_string_t cmd_set;
4556 cmdline_fixed_string_t cmd_port;
4557 cmdline_fixed_string_t cmd_keyword;
4558 cmdline_fixed_string_t cmd_onoff;
4563 cmd_gro_enable_parsed(void *parsed_result,
4564 __attribute__((unused)) struct cmdline *cl,
4565 __attribute__((unused)) void *data)
4567 struct cmd_gro_enable_result *res;
4569 res = parsed_result;
4570 if (!strcmp(res->cmd_keyword, "gro"))
4571 setup_gro(res->cmd_onoff, res->cmd_pid);
4574 cmdline_parse_token_string_t cmd_gro_enable_set =
4575 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4577 cmdline_parse_token_string_t cmd_gro_enable_port =
4578 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4579 cmd_keyword, "port");
4580 cmdline_parse_token_num_t cmd_gro_enable_pid =
4581 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4583 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4584 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4585 cmd_keyword, "gro");
4586 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4587 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4588 cmd_onoff, "on#off");
4590 cmdline_parse_inst_t cmd_gro_enable = {
4591 .f = cmd_gro_enable_parsed,
4593 .help_str = "set port <port_id> gro on|off",
4595 (void *)&cmd_gro_enable_set,
4596 (void *)&cmd_gro_enable_port,
4597 (void *)&cmd_gro_enable_pid,
4598 (void *)&cmd_gro_enable_keyword,
4599 (void *)&cmd_gro_enable_onoff,
4604 /* *** DISPLAY GRO CONFIGURATION *** */
4605 struct cmd_gro_show_result {
4606 cmdline_fixed_string_t cmd_show;
4607 cmdline_fixed_string_t cmd_port;
4608 cmdline_fixed_string_t cmd_keyword;
4613 cmd_gro_show_parsed(void *parsed_result,
4614 __attribute__((unused)) struct cmdline *cl,
4615 __attribute__((unused)) void *data)
4617 struct cmd_gro_show_result *res;
4619 res = parsed_result;
4620 if (!strcmp(res->cmd_keyword, "gro"))
4621 show_gro(res->cmd_pid);
4624 cmdline_parse_token_string_t cmd_gro_show_show =
4625 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4627 cmdline_parse_token_string_t cmd_gro_show_port =
4628 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4630 cmdline_parse_token_num_t cmd_gro_show_pid =
4631 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4633 cmdline_parse_token_string_t cmd_gro_show_keyword =
4634 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4635 cmd_keyword, "gro");
4637 cmdline_parse_inst_t cmd_gro_show = {
4638 .f = cmd_gro_show_parsed,
4640 .help_str = "show port <port_id> gro",
4642 (void *)&cmd_gro_show_show,
4643 (void *)&cmd_gro_show_port,
4644 (void *)&cmd_gro_show_pid,
4645 (void *)&cmd_gro_show_keyword,
4650 /* *** SET FLUSH CYCLES FOR GRO *** */
4651 struct cmd_gro_flush_result {
4652 cmdline_fixed_string_t cmd_set;
4653 cmdline_fixed_string_t cmd_keyword;
4654 cmdline_fixed_string_t cmd_flush;
4659 cmd_gro_flush_parsed(void *parsed_result,
4660 __attribute__((unused)) struct cmdline *cl,
4661 __attribute__((unused)) void *data)
4663 struct cmd_gro_flush_result *res;
4665 res = parsed_result;
4666 if ((!strcmp(res->cmd_keyword, "gro")) &&
4667 (!strcmp(res->cmd_flush, "flush")))
4668 setup_gro_flush_cycles(res->cmd_cycles);
4671 cmdline_parse_token_string_t cmd_gro_flush_set =
4672 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4674 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4675 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4676 cmd_keyword, "gro");
4677 cmdline_parse_token_string_t cmd_gro_flush_flush =
4678 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4679 cmd_flush, "flush");
4680 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4681 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4684 cmdline_parse_inst_t cmd_gro_flush = {
4685 .f = cmd_gro_flush_parsed,
4687 .help_str = "set gro flush <cycles>",
4689 (void *)&cmd_gro_flush_set,
4690 (void *)&cmd_gro_flush_keyword,
4691 (void *)&cmd_gro_flush_flush,
4692 (void *)&cmd_gro_flush_cycles,
4697 /* *** ENABLE/DISABLE GSO *** */
4698 struct cmd_gso_enable_result {
4699 cmdline_fixed_string_t cmd_set;
4700 cmdline_fixed_string_t cmd_port;
4701 cmdline_fixed_string_t cmd_keyword;
4702 cmdline_fixed_string_t cmd_mode;
4707 cmd_gso_enable_parsed(void *parsed_result,
4708 __attribute__((unused)) struct cmdline *cl,
4709 __attribute__((unused)) void *data)
4711 struct cmd_gso_enable_result *res;
4713 res = parsed_result;
4714 if (!strcmp(res->cmd_keyword, "gso"))
4715 setup_gso(res->cmd_mode, res->cmd_pid);
4718 cmdline_parse_token_string_t cmd_gso_enable_set =
4719 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4721 cmdline_parse_token_string_t cmd_gso_enable_port =
4722 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4724 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4725 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4726 cmd_keyword, "gso");
4727 cmdline_parse_token_string_t cmd_gso_enable_mode =
4728 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4729 cmd_mode, "on#off");
4730 cmdline_parse_token_num_t cmd_gso_enable_pid =
4731 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4734 cmdline_parse_inst_t cmd_gso_enable = {
4735 .f = cmd_gso_enable_parsed,
4737 .help_str = "set port <port_id> gso on|off",
4739 (void *)&cmd_gso_enable_set,
4740 (void *)&cmd_gso_enable_port,
4741 (void *)&cmd_gso_enable_pid,
4742 (void *)&cmd_gso_enable_keyword,
4743 (void *)&cmd_gso_enable_mode,
4748 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4749 struct cmd_gso_size_result {
4750 cmdline_fixed_string_t cmd_set;
4751 cmdline_fixed_string_t cmd_keyword;
4752 cmdline_fixed_string_t cmd_segsz;
4757 cmd_gso_size_parsed(void *parsed_result,
4758 __attribute__((unused)) struct cmdline *cl,
4759 __attribute__((unused)) void *data)
4761 struct cmd_gso_size_result *res = parsed_result;
4763 if (test_done == 0) {
4764 printf("Before setting GSO segsz, please first"
4765 " stop fowarding\n");
4769 if (!strcmp(res->cmd_keyword, "gso") &&
4770 !strcmp(res->cmd_segsz, "segsz")) {
4771 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4772 printf("gso_size should be larger than %zu."
4773 " Please input a legal value\n",
4774 RTE_GSO_SEG_SIZE_MIN);
4776 gso_max_segment_size = res->cmd_size;
4780 cmdline_parse_token_string_t cmd_gso_size_set =
4781 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4783 cmdline_parse_token_string_t cmd_gso_size_keyword =
4784 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4785 cmd_keyword, "gso");
4786 cmdline_parse_token_string_t cmd_gso_size_segsz =
4787 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4788 cmd_segsz, "segsz");
4789 cmdline_parse_token_num_t cmd_gso_size_size =
4790 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4793 cmdline_parse_inst_t cmd_gso_size = {
4794 .f = cmd_gso_size_parsed,
4796 .help_str = "set gso segsz <length>",
4798 (void *)&cmd_gso_size_set,
4799 (void *)&cmd_gso_size_keyword,
4800 (void *)&cmd_gso_size_segsz,
4801 (void *)&cmd_gso_size_size,
4806 /* *** SHOW GSO CONFIGURATION *** */
4807 struct cmd_gso_show_result {
4808 cmdline_fixed_string_t cmd_show;
4809 cmdline_fixed_string_t cmd_port;
4810 cmdline_fixed_string_t cmd_keyword;
4815 cmd_gso_show_parsed(void *parsed_result,
4816 __attribute__((unused)) struct cmdline *cl,
4817 __attribute__((unused)) void *data)
4819 struct cmd_gso_show_result *res = parsed_result;
4821 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4822 printf("invalid port id %u\n", res->cmd_pid);
4825 if (!strcmp(res->cmd_keyword, "gso")) {
4826 if (gso_ports[res->cmd_pid].enable) {
4827 printf("Max GSO'd packet size: %uB\n"
4828 "Supported GSO types: TCP/IPv4, "
4829 "UDP/IPv4, VxLAN with inner "
4830 "TCP/IPv4 packet, GRE with inner "
4831 "TCP/IPv4 packet\n",
4832 gso_max_segment_size);
4834 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4838 cmdline_parse_token_string_t cmd_gso_show_show =
4839 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4841 cmdline_parse_token_string_t cmd_gso_show_port =
4842 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4844 cmdline_parse_token_string_t cmd_gso_show_keyword =
4845 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4846 cmd_keyword, "gso");
4847 cmdline_parse_token_num_t cmd_gso_show_pid =
4848 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4851 cmdline_parse_inst_t cmd_gso_show = {
4852 .f = cmd_gso_show_parsed,
4854 .help_str = "show port <port_id> gso",
4856 (void *)&cmd_gso_show_show,
4857 (void *)&cmd_gso_show_port,
4858 (void *)&cmd_gso_show_pid,
4859 (void *)&cmd_gso_show_keyword,
4864 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4865 struct cmd_set_flush_rx {
4866 cmdline_fixed_string_t set;
4867 cmdline_fixed_string_t flush_rx;
4868 cmdline_fixed_string_t mode;
4872 cmd_set_flush_rx_parsed(void *parsed_result,
4873 __attribute__((unused)) struct cmdline *cl,
4874 __attribute__((unused)) void *data)
4876 struct cmd_set_flush_rx *res = parsed_result;
4877 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4880 cmdline_parse_token_string_t cmd_setflushrx_set =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4883 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4884 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4885 flush_rx, "flush_rx");
4886 cmdline_parse_token_string_t cmd_setflushrx_mode =
4887 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4891 cmdline_parse_inst_t cmd_set_flush_rx = {
4892 .f = cmd_set_flush_rx_parsed,
4893 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4896 (void *)&cmd_setflushrx_set,
4897 (void *)&cmd_setflushrx_flush_rx,
4898 (void *)&cmd_setflushrx_mode,
4903 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4904 struct cmd_set_link_check {
4905 cmdline_fixed_string_t set;
4906 cmdline_fixed_string_t link_check;
4907 cmdline_fixed_string_t mode;
4911 cmd_set_link_check_parsed(void *parsed_result,
4912 __attribute__((unused)) struct cmdline *cl,
4913 __attribute__((unused)) void *data)
4915 struct cmd_set_link_check *res = parsed_result;
4916 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4919 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4920 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4922 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4923 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4924 link_check, "link_check");
4925 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4926 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4930 cmdline_parse_inst_t cmd_set_link_check = {
4931 .f = cmd_set_link_check_parsed,
4932 .help_str = "set link_check on|off: Enable/Disable link status check "
4933 "when starting/stopping a port",
4936 (void *)&cmd_setlinkcheck_set,
4937 (void *)&cmd_setlinkcheck_link_check,
4938 (void *)&cmd_setlinkcheck_mode,
4943 /* *** SET NIC BYPASS MODE *** */
4944 struct cmd_set_bypass_mode_result {
4945 cmdline_fixed_string_t set;
4946 cmdline_fixed_string_t bypass;
4947 cmdline_fixed_string_t mode;
4948 cmdline_fixed_string_t value;
4953 cmd_set_bypass_mode_parsed(void *parsed_result,
4954 __attribute__((unused)) struct cmdline *cl,
4955 __attribute__((unused)) void *data)
4957 struct cmd_set_bypass_mode_result *res = parsed_result;
4958 portid_t port_id = res->port_id;
4959 int32_t rc = -EINVAL;
4961 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4962 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4964 if (!strcmp(res->value, "bypass"))
4965 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4966 else if (!strcmp(res->value, "isolate"))
4967 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4969 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4971 /* Set the bypass mode for the relevant port. */
4972 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4975 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4978 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4979 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4981 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4984 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4987 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4988 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4989 value, "normal#bypass#isolate");
4990 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4991 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4994 cmdline_parse_inst_t cmd_set_bypass_mode = {
4995 .f = cmd_set_bypass_mode_parsed,
4996 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4997 "Set the NIC bypass mode for port_id",
5000 (void *)&cmd_setbypass_mode_set,
5001 (void *)&cmd_setbypass_mode_bypass,
5002 (void *)&cmd_setbypass_mode_mode,
5003 (void *)&cmd_setbypass_mode_value,
5004 (void *)&cmd_setbypass_mode_port,
5009 /* *** SET NIC BYPASS EVENT *** */
5010 struct cmd_set_bypass_event_result {
5011 cmdline_fixed_string_t set;
5012 cmdline_fixed_string_t bypass;
5013 cmdline_fixed_string_t event;
5014 cmdline_fixed_string_t event_value;
5015 cmdline_fixed_string_t mode;
5016 cmdline_fixed_string_t mode_value;
5021 cmd_set_bypass_event_parsed(void *parsed_result,
5022 __attribute__((unused)) struct cmdline *cl,
5023 __attribute__((unused)) void *data)
5025 int32_t rc = -EINVAL;
5026 struct cmd_set_bypass_event_result *res = parsed_result;
5027 portid_t port_id = res->port_id;
5029 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5030 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5031 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5033 if (!strcmp(res->event_value, "timeout"))
5034 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5035 else if (!strcmp(res->event_value, "os_on"))
5036 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5037 else if (!strcmp(res->event_value, "os_off"))
5038 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5039 else if (!strcmp(res->event_value, "power_on"))
5040 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5041 else if (!strcmp(res->event_value, "power_off"))
5042 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5044 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5046 if (!strcmp(res->mode_value, "bypass"))
5047 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5048 else if (!strcmp(res->mode_value, "isolate"))
5049 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5051 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5053 /* Set the watchdog timeout. */
5054 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5057 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5058 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5062 printf("Failed to set timeout value %u "
5063 "for port %d, errto code: %d.\n",
5064 bypass_timeout, port_id, rc);
5068 /* Set the bypass event to transition to bypass mode. */
5069 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5074 printf("\t Failed to set bypass event for port = %d.\n",
5078 cmdline_parse_token_string_t cmd_setbypass_event_set =
5079 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5081 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5082 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5084 cmdline_parse_token_string_t cmd_setbypass_event_event =
5085 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5087 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5088 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5089 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5090 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5091 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5093 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5094 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5095 mode_value, "normal#bypass#isolate");
5096 cmdline_parse_token_num_t cmd_setbypass_event_port =
5097 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5100 cmdline_parse_inst_t cmd_set_bypass_event = {
5101 .f = cmd_set_bypass_event_parsed,
5102 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5103 "power_off mode normal|bypass|isolate <port_id>: "
5104 "Set the NIC bypass event mode for port_id",
5107 (void *)&cmd_setbypass_event_set,
5108 (void *)&cmd_setbypass_event_bypass,
5109 (void *)&cmd_setbypass_event_event,
5110 (void *)&cmd_setbypass_event_event_value,
5111 (void *)&cmd_setbypass_event_mode,
5112 (void *)&cmd_setbypass_event_mode_value,
5113 (void *)&cmd_setbypass_event_port,
5119 /* *** SET NIC BYPASS TIMEOUT *** */
5120 struct cmd_set_bypass_timeout_result {
5121 cmdline_fixed_string_t set;
5122 cmdline_fixed_string_t bypass;
5123 cmdline_fixed_string_t timeout;
5124 cmdline_fixed_string_t value;
5128 cmd_set_bypass_timeout_parsed(void *parsed_result,
5129 __attribute__((unused)) struct cmdline *cl,
5130 __attribute__((unused)) void *data)
5132 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5134 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5135 if (!strcmp(res->value, "1.5"))
5136 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5137 else if (!strcmp(res->value, "2"))
5138 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5139 else if (!strcmp(res->value, "3"))
5140 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5141 else if (!strcmp(res->value, "4"))
5142 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5143 else if (!strcmp(res->value, "8"))
5144 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5145 else if (!strcmp(res->value, "16"))
5146 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5147 else if (!strcmp(res->value, "32"))
5148 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5150 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5154 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5155 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5157 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5158 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5160 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5161 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5162 timeout, "timeout");
5163 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5164 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5165 value, "0#1.5#2#3#4#8#16#32");
5167 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5168 .f = cmd_set_bypass_timeout_parsed,
5169 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5170 "Set the NIC bypass watchdog timeout in seconds",
5173 (void *)&cmd_setbypass_timeout_set,
5174 (void *)&cmd_setbypass_timeout_bypass,
5175 (void *)&cmd_setbypass_timeout_timeout,
5176 (void *)&cmd_setbypass_timeout_value,
5181 /* *** SHOW NIC BYPASS MODE *** */
5182 struct cmd_show_bypass_config_result {
5183 cmdline_fixed_string_t show;
5184 cmdline_fixed_string_t bypass;
5185 cmdline_fixed_string_t config;
5190 cmd_show_bypass_config_parsed(void *parsed_result,
5191 __attribute__((unused)) struct cmdline *cl,
5192 __attribute__((unused)) void *data)
5194 struct cmd_show_bypass_config_result *res = parsed_result;
5195 portid_t port_id = res->port_id;
5197 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5198 uint32_t event_mode;
5199 uint32_t bypass_mode;
5200 uint32_t timeout = bypass_timeout;
5203 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5204 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5205 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5206 {"UNKNOWN", "normal", "bypass", "isolate"};
5207 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5214 int num_events = (sizeof events) / (sizeof events[0]);
5216 /* Display the bypass mode.*/
5217 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5218 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5222 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5223 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5225 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5228 /* Display the bypass timeout.*/
5229 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5230 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5232 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5234 /* Display the bypass events and associated modes. */
5235 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5237 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5238 printf("\tFailed to get bypass mode for event = %s\n",
5241 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5242 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5244 printf("\tbypass event: %-16s = %s\n", events[i],
5250 printf("\tFailed to get bypass configuration for port = %d\n",
5254 cmdline_parse_token_string_t cmd_showbypass_config_show =
5255 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5257 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5258 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5260 cmdline_parse_token_string_t cmd_showbypass_config_config =
5261 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5263 cmdline_parse_token_num_t cmd_showbypass_config_port =
5264 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5267 cmdline_parse_inst_t cmd_show_bypass_config = {
5268 .f = cmd_show_bypass_config_parsed,
5269 .help_str = "show bypass config <port_id>: "
5270 "Show the NIC bypass config for port_id",
5273 (void *)&cmd_showbypass_config_show,
5274 (void *)&cmd_showbypass_config_bypass,
5275 (void *)&cmd_showbypass_config_config,
5276 (void *)&cmd_showbypass_config_port,
5281 #ifdef RTE_LIBRTE_PMD_BOND
5282 /* *** SET BONDING MODE *** */
5283 struct cmd_set_bonding_mode_result {
5284 cmdline_fixed_string_t set;
5285 cmdline_fixed_string_t bonding;
5286 cmdline_fixed_string_t mode;
5291 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5292 __attribute__((unused)) struct cmdline *cl,
5293 __attribute__((unused)) void *data)
5295 struct cmd_set_bonding_mode_result *res = parsed_result;
5296 portid_t port_id = res->port_id;
5298 /* Set the bonding mode for the relevant port. */
5299 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5300 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5303 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5304 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5306 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5307 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5308 bonding, "bonding");
5309 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5310 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5312 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5313 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5315 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5316 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5319 cmdline_parse_inst_t cmd_set_bonding_mode = {
5320 .f = cmd_set_bonding_mode_parsed,
5321 .help_str = "set bonding mode <mode_value> <port_id>: "
5322 "Set the bonding mode for port_id",
5325 (void *) &cmd_setbonding_mode_set,
5326 (void *) &cmd_setbonding_mode_bonding,
5327 (void *) &cmd_setbonding_mode_mode,
5328 (void *) &cmd_setbonding_mode_value,
5329 (void *) &cmd_setbonding_mode_port,
5334 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5335 struct cmd_set_bonding_lacp_dedicated_queues_result {
5336 cmdline_fixed_string_t set;
5337 cmdline_fixed_string_t bonding;
5338 cmdline_fixed_string_t lacp;
5339 cmdline_fixed_string_t dedicated_queues;
5341 cmdline_fixed_string_t mode;
5344 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5345 __attribute__((unused)) struct cmdline *cl,
5346 __attribute__((unused)) void *data)
5348 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5349 portid_t port_id = res->port_id;
5350 struct rte_port *port;
5352 port = &ports[port_id];
5354 /** Check if the port is not started **/
5355 if (port->port_status != RTE_PORT_STOPPED) {
5356 printf("Please stop port %d first\n", port_id);
5360 if (!strcmp(res->mode, "enable")) {
5361 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5362 printf("Dedicate queues for LACP control packets"
5365 printf("Enabling dedicate queues for LACP control "
5366 "packets on port %d failed\n", port_id);
5367 } else if (!strcmp(res->mode, "disable")) {
5368 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5369 printf("Dedicated queues for LACP control packets "
5372 printf("Disabling dedicated queues for LACP control "
5373 "traffic on port %d failed\n", port_id);
5377 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5378 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5380 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5381 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5382 bonding, "bonding");
5383 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5384 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5386 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5387 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5388 dedicated_queues, "dedicated_queues");
5389 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5390 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5392 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5393 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5394 mode, "enable#disable");
5396 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5397 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5398 .help_str = "set bonding lacp dedicated_queues <port_id> "
5400 "Enable/disable dedicated queues for LACP control traffic for port_id",
5403 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5404 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5405 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5406 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5407 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5408 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5413 /* *** SET BALANCE XMIT POLICY *** */
5414 struct cmd_set_bonding_balance_xmit_policy_result {
5415 cmdline_fixed_string_t set;
5416 cmdline_fixed_string_t bonding;
5417 cmdline_fixed_string_t balance_xmit_policy;
5419 cmdline_fixed_string_t policy;
5422 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5423 __attribute__((unused)) struct cmdline *cl,
5424 __attribute__((unused)) void *data)
5426 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5427 portid_t port_id = res->port_id;
5430 if (!strcmp(res->policy, "l2")) {
5431 policy = BALANCE_XMIT_POLICY_LAYER2;
5432 } else if (!strcmp(res->policy, "l23")) {
5433 policy = BALANCE_XMIT_POLICY_LAYER23;
5434 } else if (!strcmp(res->policy, "l34")) {
5435 policy = BALANCE_XMIT_POLICY_LAYER34;
5437 printf("\t Invalid xmit policy selection");
5441 /* Set the bonding mode for the relevant port. */
5442 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5443 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5448 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5449 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5451 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5452 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5453 bonding, "bonding");
5454 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5455 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5456 balance_xmit_policy, "balance_xmit_policy");
5457 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5458 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5460 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5461 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5462 policy, "l2#l23#l34");
5464 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5465 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5466 .help_str = "set bonding balance_xmit_policy <port_id> "
5468 "Set the bonding balance_xmit_policy for port_id",
5471 (void *)&cmd_setbonding_balance_xmit_policy_set,
5472 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5473 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5474 (void *)&cmd_setbonding_balance_xmit_policy_port,
5475 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5480 /* *** SHOW NIC BONDING CONFIGURATION *** */
5481 struct cmd_show_bonding_config_result {
5482 cmdline_fixed_string_t show;
5483 cmdline_fixed_string_t bonding;
5484 cmdline_fixed_string_t config;
5488 static void cmd_show_bonding_config_parsed(void *parsed_result,
5489 __attribute__((unused)) struct cmdline *cl,
5490 __attribute__((unused)) void *data)
5492 struct cmd_show_bonding_config_result *res = parsed_result;
5493 int bonding_mode, agg_mode;
5494 portid_t slaves[RTE_MAX_ETHPORTS];
5495 int num_slaves, num_active_slaves;
5498 portid_t port_id = res->port_id;
5500 /* Display the bonding mode.*/
5501 bonding_mode = rte_eth_bond_mode_get(port_id);
5502 if (bonding_mode < 0) {
5503 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5506 printf("\tBonding mode: %d\n", bonding_mode);
5508 if (bonding_mode == BONDING_MODE_BALANCE) {
5509 int balance_xmit_policy;
5511 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5512 if (balance_xmit_policy < 0) {
5513 printf("\tFailed to get balance xmit policy for port = %d\n",
5517 printf("\tBalance Xmit Policy: ");
5519 switch (balance_xmit_policy) {
5520 case BALANCE_XMIT_POLICY_LAYER2:
5521 printf("BALANCE_XMIT_POLICY_LAYER2");
5523 case BALANCE_XMIT_POLICY_LAYER23:
5524 printf("BALANCE_XMIT_POLICY_LAYER23");
5526 case BALANCE_XMIT_POLICY_LAYER34:
5527 printf("BALANCE_XMIT_POLICY_LAYER34");
5534 if (bonding_mode == BONDING_MODE_8023AD) {
5535 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5536 printf("\tIEEE802.3AD Aggregator Mode: ");
5539 printf("bandwidth");
5551 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5553 if (num_slaves < 0) {
5554 printf("\tFailed to get slave list for port = %d\n", port_id);
5557 if (num_slaves > 0) {
5558 printf("\tSlaves (%d): [", num_slaves);
5559 for (i = 0; i < num_slaves - 1; i++)
5560 printf("%d ", slaves[i]);
5562 printf("%d]\n", slaves[num_slaves - 1]);
5564 printf("\tSlaves: []\n");
5568 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5571 if (num_active_slaves < 0) {
5572 printf("\tFailed to get active slave list for port = %d\n", port_id);
5575 if (num_active_slaves > 0) {
5576 printf("\tActive Slaves (%d): [", num_active_slaves);
5577 for (i = 0; i < num_active_slaves - 1; i++)
5578 printf("%d ", slaves[i]);
5580 printf("%d]\n", slaves[num_active_slaves - 1]);
5583 printf("\tActive Slaves: []\n");
5587 primary_id = rte_eth_bond_primary_get(port_id);
5588 if (primary_id < 0) {
5589 printf("\tFailed to get primary slave for port = %d\n", port_id);
5592 printf("\tPrimary: [%d]\n", primary_id);
5596 cmdline_parse_token_string_t cmd_showbonding_config_show =
5597 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5599 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5600 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5601 bonding, "bonding");
5602 cmdline_parse_token_string_t cmd_showbonding_config_config =
5603 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5605 cmdline_parse_token_num_t cmd_showbonding_config_port =
5606 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5609 cmdline_parse_inst_t cmd_show_bonding_config = {
5610 .f = cmd_show_bonding_config_parsed,
5611 .help_str = "show bonding config <port_id>: "
5612 "Show the bonding config for port_id",
5615 (void *)&cmd_showbonding_config_show,
5616 (void *)&cmd_showbonding_config_bonding,
5617 (void *)&cmd_showbonding_config_config,
5618 (void *)&cmd_showbonding_config_port,
5623 /* *** SET BONDING PRIMARY *** */
5624 struct cmd_set_bonding_primary_result {
5625 cmdline_fixed_string_t set;
5626 cmdline_fixed_string_t bonding;
5627 cmdline_fixed_string_t primary;
5632 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5633 __attribute__((unused)) struct cmdline *cl,
5634 __attribute__((unused)) void *data)
5636 struct cmd_set_bonding_primary_result *res = parsed_result;
5637 portid_t master_port_id = res->port_id;
5638 portid_t slave_port_id = res->slave_id;
5640 /* Set the primary slave for a bonded device. */
5641 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5642 printf("\t Failed to set primary slave for port = %d.\n",
5649 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5650 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5652 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5653 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5654 bonding, "bonding");
5655 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5656 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5657 primary, "primary");
5658 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5659 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5661 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5662 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5665 cmdline_parse_inst_t cmd_set_bonding_primary = {
5666 .f = cmd_set_bonding_primary_parsed,
5667 .help_str = "set bonding primary <slave_id> <port_id>: "
5668 "Set the primary slave for port_id",
5671 (void *)&cmd_setbonding_primary_set,
5672 (void *)&cmd_setbonding_primary_bonding,
5673 (void *)&cmd_setbonding_primary_primary,
5674 (void *)&cmd_setbonding_primary_slave,
5675 (void *)&cmd_setbonding_primary_port,
5680 /* *** ADD SLAVE *** */
5681 struct cmd_add_bonding_slave_result {
5682 cmdline_fixed_string_t add;
5683 cmdline_fixed_string_t bonding;
5684 cmdline_fixed_string_t slave;
5689 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5690 __attribute__((unused)) struct cmdline *cl,
5691 __attribute__((unused)) void *data)
5693 struct cmd_add_bonding_slave_result *res = parsed_result;
5694 portid_t master_port_id = res->port_id;
5695 portid_t slave_port_id = res->slave_id;
5697 /* add the slave for a bonded device. */
5698 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5699 printf("\t Failed to add slave %d to master port = %d.\n",
5700 slave_port_id, master_port_id);
5704 set_port_slave_flag(slave_port_id);
5707 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5708 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5710 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5711 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5712 bonding, "bonding");
5713 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5714 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5716 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5717 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5719 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5720 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5723 cmdline_parse_inst_t cmd_add_bonding_slave = {
5724 .f = cmd_add_bonding_slave_parsed,
5725 .help_str = "add bonding slave <slave_id> <port_id>: "
5726 "Add a slave device to a bonded device",
5729 (void *)&cmd_addbonding_slave_add,
5730 (void *)&cmd_addbonding_slave_bonding,
5731 (void *)&cmd_addbonding_slave_slave,
5732 (void *)&cmd_addbonding_slave_slaveid,
5733 (void *)&cmd_addbonding_slave_port,
5738 /* *** REMOVE SLAVE *** */
5739 struct cmd_remove_bonding_slave_result {
5740 cmdline_fixed_string_t remove;
5741 cmdline_fixed_string_t bonding;
5742 cmdline_fixed_string_t slave;
5747 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5748 __attribute__((unused)) struct cmdline *cl,
5749 __attribute__((unused)) void *data)
5751 struct cmd_remove_bonding_slave_result *res = parsed_result;
5752 portid_t master_port_id = res->port_id;
5753 portid_t slave_port_id = res->slave_id;
5755 /* remove the slave from a bonded device. */
5756 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5757 printf("\t Failed to remove slave %d from master port = %d.\n",
5758 slave_port_id, master_port_id);
5762 clear_port_slave_flag(slave_port_id);
5765 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5766 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5768 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5769 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5770 bonding, "bonding");
5771 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5772 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5774 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5775 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5777 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5778 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5781 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5782 .f = cmd_remove_bonding_slave_parsed,
5783 .help_str = "remove bonding slave <slave_id> <port_id>: "
5784 "Remove a slave device from a bonded device",
5787 (void *)&cmd_removebonding_slave_remove,
5788 (void *)&cmd_removebonding_slave_bonding,
5789 (void *)&cmd_removebonding_slave_slave,
5790 (void *)&cmd_removebonding_slave_slaveid,
5791 (void *)&cmd_removebonding_slave_port,
5796 /* *** CREATE BONDED DEVICE *** */
5797 struct cmd_create_bonded_device_result {
5798 cmdline_fixed_string_t create;
5799 cmdline_fixed_string_t bonded;
5800 cmdline_fixed_string_t device;
5805 static int bond_dev_num = 0;
5807 static void cmd_create_bonded_device_parsed(void *parsed_result,
5808 __attribute__((unused)) struct cmdline *cl,
5809 __attribute__((unused)) void *data)
5811 struct cmd_create_bonded_device_result *res = parsed_result;
5812 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5815 if (test_done == 0) {
5816 printf("Please stop forwarding first\n");
5820 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5823 /* Create a new bonded device. */
5824 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5826 printf("\t Failed to create bonded device.\n");
5829 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5832 /* Update number of ports */
5833 nb_ports = rte_eth_dev_count_avail();
5834 reconfig(port_id, res->socket);
5835 rte_eth_promiscuous_enable(port_id);
5840 cmdline_parse_token_string_t cmd_createbonded_device_create =
5841 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5843 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5844 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5846 cmdline_parse_token_string_t cmd_createbonded_device_device =
5847 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5849 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5850 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5852 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5853 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5856 cmdline_parse_inst_t cmd_create_bonded_device = {
5857 .f = cmd_create_bonded_device_parsed,
5858 .help_str = "create bonded device <mode> <socket>: "
5859 "Create a new bonded device with specific bonding mode and socket",
5862 (void *)&cmd_createbonded_device_create,
5863 (void *)&cmd_createbonded_device_bonded,
5864 (void *)&cmd_createbonded_device_device,
5865 (void *)&cmd_createbonded_device_mode,
5866 (void *)&cmd_createbonded_device_socket,
5871 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5872 struct cmd_set_bond_mac_addr_result {
5873 cmdline_fixed_string_t set;
5874 cmdline_fixed_string_t bonding;
5875 cmdline_fixed_string_t mac_addr;
5877 struct ether_addr address;
5880 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5881 __attribute__((unused)) struct cmdline *cl,
5882 __attribute__((unused)) void *data)
5884 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5887 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5890 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5892 /* check the return value and print it if is < 0 */
5894 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5897 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5898 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5899 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5900 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5902 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5903 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5905 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5906 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5908 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5909 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5911 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5912 .f = cmd_set_bond_mac_addr_parsed,
5914 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5916 (void *)&cmd_set_bond_mac_addr_set,
5917 (void *)&cmd_set_bond_mac_addr_bonding,
5918 (void *)&cmd_set_bond_mac_addr_mac,
5919 (void *)&cmd_set_bond_mac_addr_portnum,
5920 (void *)&cmd_set_bond_mac_addr_addr,
5926 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5927 struct cmd_set_bond_mon_period_result {
5928 cmdline_fixed_string_t set;
5929 cmdline_fixed_string_t bonding;
5930 cmdline_fixed_string_t mon_period;
5935 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5936 __attribute__((unused)) struct cmdline *cl,
5937 __attribute__((unused)) void *data)
5939 struct cmd_set_bond_mon_period_result *res = parsed_result;
5942 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5944 /* check the return value and print it if is < 0 */
5946 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5949 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5950 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5952 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5953 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5954 bonding, "bonding");
5955 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5956 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5957 mon_period, "mon_period");
5958 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5959 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5961 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5962 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5965 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5966 .f = cmd_set_bond_mon_period_parsed,
5968 .help_str = "set bonding mon_period <port_id> <period_ms>",
5970 (void *)&cmd_set_bond_mon_period_set,
5971 (void *)&cmd_set_bond_mon_period_bonding,
5972 (void *)&cmd_set_bond_mon_period_mon_period,
5973 (void *)&cmd_set_bond_mon_period_portnum,
5974 (void *)&cmd_set_bond_mon_period_period_ms,
5981 struct cmd_set_bonding_agg_mode_policy_result {
5982 cmdline_fixed_string_t set;
5983 cmdline_fixed_string_t bonding;
5984 cmdline_fixed_string_t agg_mode;
5986 cmdline_fixed_string_t policy;
5991 cmd_set_bonding_agg_mode(void *parsed_result,
5992 __attribute__((unused)) struct cmdline *cl,
5993 __attribute__((unused)) void *data)
5995 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5996 uint8_t policy = AGG_BANDWIDTH;
5998 if (!strcmp(res->policy, "bandwidth"))
5999 policy = AGG_BANDWIDTH;
6000 else if (!strcmp(res->policy, "stable"))
6001 policy = AGG_STABLE;
6002 else if (!strcmp(res->policy, "count"))
6005 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6009 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6010 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6012 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6013 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6014 bonding, "bonding");
6016 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6017 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6018 agg_mode, "agg_mode");
6020 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6021 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6024 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6025 TOKEN_STRING_INITIALIZER(
6026 struct cmd_set_bonding_balance_xmit_policy_result,
6027 policy, "stable#bandwidth#count");
6029 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6030 .f = cmd_set_bonding_agg_mode,
6032 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6034 (void *)&cmd_set_bonding_agg_mode_set,
6035 (void *)&cmd_set_bonding_agg_mode_bonding,
6036 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6037 (void *)&cmd_set_bonding_agg_mode_portnum,
6038 (void *)&cmd_set_bonding_agg_mode_policy_string,
6044 #endif /* RTE_LIBRTE_PMD_BOND */
6046 /* *** SET FORWARDING MODE *** */
6047 struct cmd_set_fwd_mode_result {
6048 cmdline_fixed_string_t set;
6049 cmdline_fixed_string_t fwd;
6050 cmdline_fixed_string_t mode;
6053 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6054 __attribute__((unused)) struct cmdline *cl,
6055 __attribute__((unused)) void *data)
6057 struct cmd_set_fwd_mode_result *res = parsed_result;
6060 set_pkt_forwarding_mode(res->mode);
6063 cmdline_parse_token_string_t cmd_setfwd_set =
6064 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6065 cmdline_parse_token_string_t cmd_setfwd_fwd =
6066 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6067 cmdline_parse_token_string_t cmd_setfwd_mode =
6068 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6069 "" /* defined at init */);
6071 cmdline_parse_inst_t cmd_set_fwd_mode = {
6072 .f = cmd_set_fwd_mode_parsed,
6074 .help_str = NULL, /* defined at init */
6076 (void *)&cmd_setfwd_set,
6077 (void *)&cmd_setfwd_fwd,
6078 (void *)&cmd_setfwd_mode,
6083 static void cmd_set_fwd_mode_init(void)
6086 static char token[128];
6087 static char help[256];
6088 cmdline_parse_token_string_t *token_struct;
6090 modes = list_pkt_forwarding_modes();
6091 snprintf(help, sizeof(help), "set fwd %s: "
6092 "Set packet forwarding mode", modes);
6093 cmd_set_fwd_mode.help_str = help;
6095 /* string token separator is # */
6096 for (c = token; *modes != '\0'; modes++)
6101 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6102 token_struct->string_data.str = token;
6105 /* *** SET RETRY FORWARDING MODE *** */
6106 struct cmd_set_fwd_retry_mode_result {
6107 cmdline_fixed_string_t set;
6108 cmdline_fixed_string_t fwd;
6109 cmdline_fixed_string_t mode;
6110 cmdline_fixed_string_t retry;
6113 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6114 __attribute__((unused)) struct cmdline *cl,
6115 __attribute__((unused)) void *data)
6117 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6120 set_pkt_forwarding_mode(res->mode);
6123 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6124 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6126 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6127 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6129 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6130 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6132 "" /* defined at init */);
6133 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6134 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6137 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6138 .f = cmd_set_fwd_retry_mode_parsed,
6140 .help_str = NULL, /* defined at init */
6142 (void *)&cmd_setfwd_retry_set,
6143 (void *)&cmd_setfwd_retry_fwd,
6144 (void *)&cmd_setfwd_retry_mode,
6145 (void *)&cmd_setfwd_retry_retry,
6150 static void cmd_set_fwd_retry_mode_init(void)
6153 static char token[128];
6154 static char help[256];
6155 cmdline_parse_token_string_t *token_struct;
6157 modes = list_pkt_forwarding_retry_modes();
6158 snprintf(help, sizeof(help), "set fwd %s retry: "
6159 "Set packet forwarding mode with retry", modes);
6160 cmd_set_fwd_retry_mode.help_str = help;
6162 /* string token separator is # */
6163 for (c = token; *modes != '\0'; modes++)
6168 token_struct = (cmdline_parse_token_string_t *)
6169 cmd_set_fwd_retry_mode.tokens[2];
6170 token_struct->string_data.str = token;
6173 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6174 struct cmd_set_burst_tx_retry_result {
6175 cmdline_fixed_string_t set;
6176 cmdline_fixed_string_t burst;
6177 cmdline_fixed_string_t tx;
6178 cmdline_fixed_string_t delay;
6180 cmdline_fixed_string_t retry;
6184 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6185 __attribute__((unused)) struct cmdline *cl,
6186 __attribute__((unused)) void *data)
6188 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6190 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6191 && !strcmp(res->tx, "tx")) {
6192 if (!strcmp(res->delay, "delay"))
6193 burst_tx_delay_time = res->time;
6194 if (!strcmp(res->retry, "retry"))
6195 burst_tx_retry_num = res->retry_num;
6200 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6201 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6202 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6203 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6205 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6206 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6207 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6208 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6209 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6210 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6211 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6212 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6213 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6214 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6216 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6217 .f = cmd_set_burst_tx_retry_parsed,
6218 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6220 (void *)&cmd_set_burst_tx_retry_set,
6221 (void *)&cmd_set_burst_tx_retry_burst,
6222 (void *)&cmd_set_burst_tx_retry_tx,
6223 (void *)&cmd_set_burst_tx_retry_delay,
6224 (void *)&cmd_set_burst_tx_retry_time,
6225 (void *)&cmd_set_burst_tx_retry_retry,
6226 (void *)&cmd_set_burst_tx_retry_retry_num,
6231 /* *** SET PROMISC MODE *** */
6232 struct cmd_set_promisc_mode_result {
6233 cmdline_fixed_string_t set;
6234 cmdline_fixed_string_t promisc;
6235 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6236 uint16_t port_num; /* valid if "allports" argument == 0 */
6237 cmdline_fixed_string_t mode;
6240 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6241 __attribute__((unused)) struct cmdline *cl,
6244 struct cmd_set_promisc_mode_result *res = parsed_result;
6248 if (!strcmp(res->mode, "on"))
6255 RTE_ETH_FOREACH_DEV(i) {
6257 rte_eth_promiscuous_enable(i);
6259 rte_eth_promiscuous_disable(i);
6264 rte_eth_promiscuous_enable(res->port_num);
6266 rte_eth_promiscuous_disable(res->port_num);
6270 cmdline_parse_token_string_t cmd_setpromisc_set =
6271 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6272 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6273 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6275 cmdline_parse_token_string_t cmd_setpromisc_portall =
6276 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6278 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6279 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6281 cmdline_parse_token_string_t cmd_setpromisc_mode =
6282 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6285 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6286 .f = cmd_set_promisc_mode_parsed,
6288 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6290 (void *)&cmd_setpromisc_set,
6291 (void *)&cmd_setpromisc_promisc,
6292 (void *)&cmd_setpromisc_portall,
6293 (void *)&cmd_setpromisc_mode,
6298 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6299 .f = cmd_set_promisc_mode_parsed,
6301 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6303 (void *)&cmd_setpromisc_set,
6304 (void *)&cmd_setpromisc_promisc,
6305 (void *)&cmd_setpromisc_portnum,
6306 (void *)&cmd_setpromisc_mode,
6311 /* *** SET ALLMULTI MODE *** */
6312 struct cmd_set_allmulti_mode_result {
6313 cmdline_fixed_string_t set;
6314 cmdline_fixed_string_t allmulti;
6315 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6316 uint16_t port_num; /* valid if "allports" argument == 0 */
6317 cmdline_fixed_string_t mode;
6320 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6321 __attribute__((unused)) struct cmdline *cl,
6324 struct cmd_set_allmulti_mode_result *res = parsed_result;
6328 if (!strcmp(res->mode, "on"))
6335 RTE_ETH_FOREACH_DEV(i) {
6337 rte_eth_allmulticast_enable(i);
6339 rte_eth_allmulticast_disable(i);
6344 rte_eth_allmulticast_enable(res->port_num);
6346 rte_eth_allmulticast_disable(res->port_num);
6350 cmdline_parse_token_string_t cmd_setallmulti_set =
6351 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6352 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6353 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6355 cmdline_parse_token_string_t cmd_setallmulti_portall =
6356 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6358 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6359 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6361 cmdline_parse_token_string_t cmd_setallmulti_mode =
6362 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6365 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6366 .f = cmd_set_allmulti_mode_parsed,
6368 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6370 (void *)&cmd_setallmulti_set,
6371 (void *)&cmd_setallmulti_allmulti,
6372 (void *)&cmd_setallmulti_portall,
6373 (void *)&cmd_setallmulti_mode,
6378 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6379 .f = cmd_set_allmulti_mode_parsed,
6381 .help_str = "set allmulti <port_id> on|off: "
6382 "Set allmulti mode on port_id",
6384 (void *)&cmd_setallmulti_set,
6385 (void *)&cmd_setallmulti_allmulti,
6386 (void *)&cmd_setallmulti_portnum,
6387 (void *)&cmd_setallmulti_mode,
6392 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6393 struct cmd_link_flow_ctrl_set_result {
6394 cmdline_fixed_string_t set;
6395 cmdline_fixed_string_t flow_ctrl;
6396 cmdline_fixed_string_t rx;
6397 cmdline_fixed_string_t rx_lfc_mode;
6398 cmdline_fixed_string_t tx;
6399 cmdline_fixed_string_t tx_lfc_mode;
6400 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6401 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6402 cmdline_fixed_string_t autoneg_str;
6403 cmdline_fixed_string_t autoneg;
6404 cmdline_fixed_string_t hw_str;
6405 uint32_t high_water;
6406 cmdline_fixed_string_t lw_str;
6408 cmdline_fixed_string_t pt_str;
6409 uint16_t pause_time;
6410 cmdline_fixed_string_t xon_str;
6415 cmdline_parse_token_string_t cmd_lfc_set_set =
6416 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6418 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6419 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6420 flow_ctrl, "flow_ctrl");
6421 cmdline_parse_token_string_t cmd_lfc_set_rx =
6422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6424 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6426 rx_lfc_mode, "on#off");
6427 cmdline_parse_token_string_t cmd_lfc_set_tx =
6428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6430 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6432 tx_lfc_mode, "on#off");
6433 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6434 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6435 hw_str, "high_water");
6436 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6437 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6438 high_water, UINT32);
6439 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6440 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6441 lw_str, "low_water");
6442 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6443 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6445 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6446 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6447 pt_str, "pause_time");
6448 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6449 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6450 pause_time, UINT16);
6451 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6452 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6453 xon_str, "send_xon");
6454 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6455 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6457 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6458 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6459 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6460 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6461 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6462 mac_ctrl_frame_fwd_mode, "on#off");
6463 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6464 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6465 autoneg_str, "autoneg");
6466 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6467 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6469 cmdline_parse_token_num_t cmd_lfc_set_portid =
6470 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6473 /* forward declaration */
6475 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6478 cmdline_parse_inst_t cmd_link_flow_control_set = {
6479 .f = cmd_link_flow_ctrl_set_parsed,
6481 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6482 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6483 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6485 (void *)&cmd_lfc_set_set,
6486 (void *)&cmd_lfc_set_flow_ctrl,
6487 (void *)&cmd_lfc_set_rx,
6488 (void *)&cmd_lfc_set_rx_mode,
6489 (void *)&cmd_lfc_set_tx,
6490 (void *)&cmd_lfc_set_tx_mode,
6491 (void *)&cmd_lfc_set_high_water,
6492 (void *)&cmd_lfc_set_low_water,
6493 (void *)&cmd_lfc_set_pause_time,
6494 (void *)&cmd_lfc_set_send_xon,
6495 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6496 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6497 (void *)&cmd_lfc_set_autoneg_str,
6498 (void *)&cmd_lfc_set_autoneg,
6499 (void *)&cmd_lfc_set_portid,
6504 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6505 .f = cmd_link_flow_ctrl_set_parsed,
6506 .data = (void *)&cmd_link_flow_control_set_rx,
6507 .help_str = "set flow_ctrl rx on|off <port_id>: "
6508 "Change rx flow control parameter",
6510 (void *)&cmd_lfc_set_set,
6511 (void *)&cmd_lfc_set_flow_ctrl,
6512 (void *)&cmd_lfc_set_rx,
6513 (void *)&cmd_lfc_set_rx_mode,
6514 (void *)&cmd_lfc_set_portid,
6519 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6520 .f = cmd_link_flow_ctrl_set_parsed,
6521 .data = (void *)&cmd_link_flow_control_set_tx,
6522 .help_str = "set flow_ctrl tx on|off <port_id>: "
6523 "Change tx flow control parameter",
6525 (void *)&cmd_lfc_set_set,
6526 (void *)&cmd_lfc_set_flow_ctrl,
6527 (void *)&cmd_lfc_set_tx,
6528 (void *)&cmd_lfc_set_tx_mode,
6529 (void *)&cmd_lfc_set_portid,
6534 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6535 .f = cmd_link_flow_ctrl_set_parsed,
6536 .data = (void *)&cmd_link_flow_control_set_hw,
6537 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6538 "Change high water flow control parameter",
6540 (void *)&cmd_lfc_set_set,
6541 (void *)&cmd_lfc_set_flow_ctrl,
6542 (void *)&cmd_lfc_set_high_water_str,
6543 (void *)&cmd_lfc_set_high_water,
6544 (void *)&cmd_lfc_set_portid,
6549 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6550 .f = cmd_link_flow_ctrl_set_parsed,
6551 .data = (void *)&cmd_link_flow_control_set_lw,
6552 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6553 "Change low water flow control parameter",
6555 (void *)&cmd_lfc_set_set,
6556 (void *)&cmd_lfc_set_flow_ctrl,
6557 (void *)&cmd_lfc_set_low_water_str,
6558 (void *)&cmd_lfc_set_low_water,
6559 (void *)&cmd_lfc_set_portid,
6564 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6565 .f = cmd_link_flow_ctrl_set_parsed,
6566 .data = (void *)&cmd_link_flow_control_set_pt,
6567 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6568 "Change pause time flow control parameter",
6570 (void *)&cmd_lfc_set_set,
6571 (void *)&cmd_lfc_set_flow_ctrl,
6572 (void *)&cmd_lfc_set_pause_time_str,
6573 (void *)&cmd_lfc_set_pause_time,
6574 (void *)&cmd_lfc_set_portid,
6579 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6580 .f = cmd_link_flow_ctrl_set_parsed,
6581 .data = (void *)&cmd_link_flow_control_set_xon,
6582 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6583 "Change send_xon flow control parameter",
6585 (void *)&cmd_lfc_set_set,
6586 (void *)&cmd_lfc_set_flow_ctrl,
6587 (void *)&cmd_lfc_set_send_xon_str,
6588 (void *)&cmd_lfc_set_send_xon,
6589 (void *)&cmd_lfc_set_portid,
6594 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6595 .f = cmd_link_flow_ctrl_set_parsed,
6596 .data = (void *)&cmd_link_flow_control_set_macfwd,
6597 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6598 "Change mac ctrl fwd flow control parameter",
6600 (void *)&cmd_lfc_set_set,
6601 (void *)&cmd_lfc_set_flow_ctrl,
6602 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6603 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6604 (void *)&cmd_lfc_set_portid,
6609 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6610 .f = cmd_link_flow_ctrl_set_parsed,
6611 .data = (void *)&cmd_link_flow_control_set_autoneg,
6612 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6613 "Change autoneg flow control parameter",
6615 (void *)&cmd_lfc_set_set,
6616 (void *)&cmd_lfc_set_flow_ctrl,
6617 (void *)&cmd_lfc_set_autoneg_str,
6618 (void *)&cmd_lfc_set_autoneg,
6619 (void *)&cmd_lfc_set_portid,
6625 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6626 __attribute__((unused)) struct cmdline *cl,
6629 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6630 cmdline_parse_inst_t *cmd = data;
6631 struct rte_eth_fc_conf fc_conf;
6637 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6638 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6639 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6640 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6642 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6643 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6646 /* Partial command line, retrieve current configuration */
6648 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6650 printf("cannot get current flow ctrl parameters, return"
6651 "code = %d\n", ret);
6655 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6656 (fc_conf.mode == RTE_FC_FULL))
6658 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6659 (fc_conf.mode == RTE_FC_FULL))
6663 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6664 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6666 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6667 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6669 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6671 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6672 fc_conf.high_water = res->high_water;
6674 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6675 fc_conf.low_water = res->low_water;
6677 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6678 fc_conf.pause_time = res->pause_time;
6680 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6681 fc_conf.send_xon = res->send_xon;
6683 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6684 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6685 fc_conf.mac_ctrl_frame_fwd = 1;
6687 fc_conf.mac_ctrl_frame_fwd = 0;
6690 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6691 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6693 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6695 printf("bad flow contrl parameter, return code = %d \n", ret);
6698 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6699 struct cmd_priority_flow_ctrl_set_result {
6700 cmdline_fixed_string_t set;
6701 cmdline_fixed_string_t pfc_ctrl;
6702 cmdline_fixed_string_t rx;
6703 cmdline_fixed_string_t rx_pfc_mode;
6704 cmdline_fixed_string_t tx;
6705 cmdline_fixed_string_t tx_pfc_mode;
6706 uint32_t high_water;
6708 uint16_t pause_time;
6714 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6715 __attribute__((unused)) struct cmdline *cl,
6716 __attribute__((unused)) void *data)
6718 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6719 struct rte_eth_pfc_conf pfc_conf;
6720 int rx_fc_enable, tx_fc_enable;
6724 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6725 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6726 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6727 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6729 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6730 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6733 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6734 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6735 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6736 pfc_conf.fc.high_water = res->high_water;
6737 pfc_conf.fc.low_water = res->low_water;
6738 pfc_conf.fc.pause_time = res->pause_time;
6739 pfc_conf.priority = res->priority;
6741 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6743 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6746 cmdline_parse_token_string_t cmd_pfc_set_set =
6747 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6749 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6750 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6751 pfc_ctrl, "pfc_ctrl");
6752 cmdline_parse_token_string_t cmd_pfc_set_rx =
6753 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6755 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6756 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6757 rx_pfc_mode, "on#off");
6758 cmdline_parse_token_string_t cmd_pfc_set_tx =
6759 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6761 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6762 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6763 tx_pfc_mode, "on#off");
6764 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6765 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6766 high_water, UINT32);
6767 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6768 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6770 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6771 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6772 pause_time, UINT16);
6773 cmdline_parse_token_num_t cmd_pfc_set_priority =
6774 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6776 cmdline_parse_token_num_t cmd_pfc_set_portid =
6777 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6780 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6781 .f = cmd_priority_flow_ctrl_set_parsed,
6783 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6784 "<pause_time> <priority> <port_id>: "
6785 "Configure the Ethernet priority flow control",
6787 (void *)&cmd_pfc_set_set,
6788 (void *)&cmd_pfc_set_flow_ctrl,
6789 (void *)&cmd_pfc_set_rx,
6790 (void *)&cmd_pfc_set_rx_mode,
6791 (void *)&cmd_pfc_set_tx,
6792 (void *)&cmd_pfc_set_tx_mode,
6793 (void *)&cmd_pfc_set_high_water,
6794 (void *)&cmd_pfc_set_low_water,
6795 (void *)&cmd_pfc_set_pause_time,
6796 (void *)&cmd_pfc_set_priority,
6797 (void *)&cmd_pfc_set_portid,
6802 /* *** RESET CONFIGURATION *** */
6803 struct cmd_reset_result {
6804 cmdline_fixed_string_t reset;
6805 cmdline_fixed_string_t def;
6808 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6810 __attribute__((unused)) void *data)
6812 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6813 set_def_fwd_config();
6816 cmdline_parse_token_string_t cmd_reset_set =
6817 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6818 cmdline_parse_token_string_t cmd_reset_def =
6819 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6822 cmdline_parse_inst_t cmd_reset = {
6823 .f = cmd_reset_parsed,
6825 .help_str = "set default: Reset default forwarding configuration",
6827 (void *)&cmd_reset_set,
6828 (void *)&cmd_reset_def,
6833 /* *** START FORWARDING *** */
6834 struct cmd_start_result {
6835 cmdline_fixed_string_t start;
6838 cmdline_parse_token_string_t cmd_start_start =
6839 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6841 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6842 __attribute__((unused)) struct cmdline *cl,
6843 __attribute__((unused)) void *data)
6845 start_packet_forwarding(0);
6848 cmdline_parse_inst_t cmd_start = {
6849 .f = cmd_start_parsed,
6851 .help_str = "start: Start packet forwarding",
6853 (void *)&cmd_start_start,
6858 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6859 struct cmd_start_tx_first_result {
6860 cmdline_fixed_string_t start;
6861 cmdline_fixed_string_t tx_first;
6865 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6866 __attribute__((unused)) struct cmdline *cl,
6867 __attribute__((unused)) void *data)
6869 start_packet_forwarding(1);
6872 cmdline_parse_token_string_t cmd_start_tx_first_start =
6873 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6875 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6876 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6877 tx_first, "tx_first");
6879 cmdline_parse_inst_t cmd_start_tx_first = {
6880 .f = cmd_start_tx_first_parsed,
6882 .help_str = "start tx_first: Start packet forwarding, "
6883 "after sending 1 burst of packets",
6885 (void *)&cmd_start_tx_first_start,
6886 (void *)&cmd_start_tx_first_tx_first,
6891 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6892 struct cmd_start_tx_first_n_result {
6893 cmdline_fixed_string_t start;
6894 cmdline_fixed_string_t tx_first;
6899 cmd_start_tx_first_n_parsed(void *parsed_result,
6900 __attribute__((unused)) struct cmdline *cl,
6901 __attribute__((unused)) void *data)
6903 struct cmd_start_tx_first_n_result *res = parsed_result;
6905 start_packet_forwarding(res->tx_num);
6908 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6909 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6911 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6912 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6913 tx_first, "tx_first");
6914 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6915 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6918 cmdline_parse_inst_t cmd_start_tx_first_n = {
6919 .f = cmd_start_tx_first_n_parsed,
6921 .help_str = "start tx_first <num>: "
6922 "packet forwarding, after sending <num> bursts of packets",
6924 (void *)&cmd_start_tx_first_n_start,
6925 (void *)&cmd_start_tx_first_n_tx_first,
6926 (void *)&cmd_start_tx_first_n_tx_num,
6931 /* *** SET LINK UP *** */
6932 struct cmd_set_link_up_result {
6933 cmdline_fixed_string_t set;
6934 cmdline_fixed_string_t link_up;
6935 cmdline_fixed_string_t port;
6939 cmdline_parse_token_string_t cmd_set_link_up_set =
6940 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6941 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6942 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6944 cmdline_parse_token_string_t cmd_set_link_up_port =
6945 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6946 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6947 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6949 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6950 __attribute__((unused)) struct cmdline *cl,
6951 __attribute__((unused)) void *data)
6953 struct cmd_set_link_up_result *res = parsed_result;
6954 dev_set_link_up(res->port_id);
6957 cmdline_parse_inst_t cmd_set_link_up = {
6958 .f = cmd_set_link_up_parsed,
6960 .help_str = "set link-up port <port id>",
6962 (void *)&cmd_set_link_up_set,
6963 (void *)&cmd_set_link_up_link_up,
6964 (void *)&cmd_set_link_up_port,
6965 (void *)&cmd_set_link_up_port_id,
6970 /* *** SET LINK DOWN *** */
6971 struct cmd_set_link_down_result {
6972 cmdline_fixed_string_t set;
6973 cmdline_fixed_string_t link_down;
6974 cmdline_fixed_string_t port;
6978 cmdline_parse_token_string_t cmd_set_link_down_set =
6979 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6980 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6981 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6983 cmdline_parse_token_string_t cmd_set_link_down_port =
6984 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6985 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6986 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6988 static void cmd_set_link_down_parsed(
6989 __attribute__((unused)) void *parsed_result,
6990 __attribute__((unused)) struct cmdline *cl,
6991 __attribute__((unused)) void *data)
6993 struct cmd_set_link_down_result *res = parsed_result;
6994 dev_set_link_down(res->port_id);
6997 cmdline_parse_inst_t cmd_set_link_down = {
6998 .f = cmd_set_link_down_parsed,
7000 .help_str = "set link-down port <port id>",
7002 (void *)&cmd_set_link_down_set,
7003 (void *)&cmd_set_link_down_link_down,
7004 (void *)&cmd_set_link_down_port,
7005 (void *)&cmd_set_link_down_port_id,
7010 /* *** SHOW CFG *** */
7011 struct cmd_showcfg_result {
7012 cmdline_fixed_string_t show;
7013 cmdline_fixed_string_t cfg;
7014 cmdline_fixed_string_t what;
7017 static void cmd_showcfg_parsed(void *parsed_result,
7018 __attribute__((unused)) struct cmdline *cl,
7019 __attribute__((unused)) void *data)
7021 struct cmd_showcfg_result *res = parsed_result;
7022 if (!strcmp(res->what, "rxtx"))
7023 rxtx_config_display();
7024 else if (!strcmp(res->what, "cores"))
7025 fwd_lcores_config_display();
7026 else if (!strcmp(res->what, "fwd"))
7027 pkt_fwd_config_display(&cur_fwd_config);
7028 else if (!strcmp(res->what, "txpkts"))
7029 show_tx_pkt_segments();
7032 cmdline_parse_token_string_t cmd_showcfg_show =
7033 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7034 cmdline_parse_token_string_t cmd_showcfg_port =
7035 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7036 cmdline_parse_token_string_t cmd_showcfg_what =
7037 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7038 "rxtx#cores#fwd#txpkts");
7040 cmdline_parse_inst_t cmd_showcfg = {
7041 .f = cmd_showcfg_parsed,
7043 .help_str = "show config rxtx|cores|fwd|txpkts",
7045 (void *)&cmd_showcfg_show,
7046 (void *)&cmd_showcfg_port,
7047 (void *)&cmd_showcfg_what,
7052 /* *** SHOW ALL PORT INFO *** */
7053 struct cmd_showportall_result {
7054 cmdline_fixed_string_t show;
7055 cmdline_fixed_string_t port;
7056 cmdline_fixed_string_t what;
7057 cmdline_fixed_string_t all;
7060 static void cmd_showportall_parsed(void *parsed_result,
7061 __attribute__((unused)) struct cmdline *cl,
7062 __attribute__((unused)) void *data)
7066 struct cmd_showportall_result *res = parsed_result;
7067 if (!strcmp(res->show, "clear")) {
7068 if (!strcmp(res->what, "stats"))
7069 RTE_ETH_FOREACH_DEV(i)
7071 else if (!strcmp(res->what, "xstats"))
7072 RTE_ETH_FOREACH_DEV(i)
7073 nic_xstats_clear(i);
7074 } else if (!strcmp(res->what, "info"))
7075 RTE_ETH_FOREACH_DEV(i)
7076 port_infos_display(i);
7077 else if (!strcmp(res->what, "stats"))
7078 RTE_ETH_FOREACH_DEV(i)
7079 nic_stats_display(i);
7080 else if (!strcmp(res->what, "xstats"))
7081 RTE_ETH_FOREACH_DEV(i)
7082 nic_xstats_display(i);
7083 else if (!strcmp(res->what, "fdir"))
7084 RTE_ETH_FOREACH_DEV(i)
7086 else if (!strcmp(res->what, "stat_qmap"))
7087 RTE_ETH_FOREACH_DEV(i)
7088 nic_stats_mapping_display(i);
7089 else if (!strcmp(res->what, "dcb_tc"))
7090 RTE_ETH_FOREACH_DEV(i)
7091 port_dcb_info_display(i);
7092 else if (!strcmp(res->what, "cap"))
7093 RTE_ETH_FOREACH_DEV(i)
7094 port_offload_cap_display(i);
7097 cmdline_parse_token_string_t cmd_showportall_show =
7098 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7100 cmdline_parse_token_string_t cmd_showportall_port =
7101 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7102 cmdline_parse_token_string_t cmd_showportall_what =
7103 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7104 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7105 cmdline_parse_token_string_t cmd_showportall_all =
7106 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7107 cmdline_parse_inst_t cmd_showportall = {
7108 .f = cmd_showportall_parsed,
7110 .help_str = "show|clear port "
7111 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7113 (void *)&cmd_showportall_show,
7114 (void *)&cmd_showportall_port,
7115 (void *)&cmd_showportall_what,
7116 (void *)&cmd_showportall_all,
7121 /* *** SHOW PORT INFO *** */
7122 struct cmd_showport_result {
7123 cmdline_fixed_string_t show;
7124 cmdline_fixed_string_t port;
7125 cmdline_fixed_string_t what;
7129 static void cmd_showport_parsed(void *parsed_result,
7130 __attribute__((unused)) struct cmdline *cl,
7131 __attribute__((unused)) void *data)
7133 struct cmd_showport_result *res = parsed_result;
7134 if (!strcmp(res->show, "clear")) {
7135 if (!strcmp(res->what, "stats"))
7136 nic_stats_clear(res->portnum);
7137 else if (!strcmp(res->what, "xstats"))
7138 nic_xstats_clear(res->portnum);
7139 } else if (!strcmp(res->what, "info"))
7140 port_infos_display(res->portnum);
7141 else if (!strcmp(res->what, "stats"))
7142 nic_stats_display(res->portnum);
7143 else if (!strcmp(res->what, "xstats"))
7144 nic_xstats_display(res->portnum);
7145 else if (!strcmp(res->what, "fdir"))
7146 fdir_get_infos(res->portnum);
7147 else if (!strcmp(res->what, "stat_qmap"))
7148 nic_stats_mapping_display(res->portnum);
7149 else if (!strcmp(res->what, "dcb_tc"))
7150 port_dcb_info_display(res->portnum);
7151 else if (!strcmp(res->what, "cap"))
7152 port_offload_cap_display(res->portnum);
7155 cmdline_parse_token_string_t cmd_showport_show =
7156 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7158 cmdline_parse_token_string_t cmd_showport_port =
7159 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7160 cmdline_parse_token_string_t cmd_showport_what =
7161 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7162 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7163 cmdline_parse_token_num_t cmd_showport_portnum =
7164 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7166 cmdline_parse_inst_t cmd_showport = {
7167 .f = cmd_showport_parsed,
7169 .help_str = "show|clear port "
7170 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7173 (void *)&cmd_showport_show,
7174 (void *)&cmd_showport_port,
7175 (void *)&cmd_showport_what,
7176 (void *)&cmd_showport_portnum,
7181 /* *** SHOW QUEUE INFO *** */
7182 struct cmd_showqueue_result {
7183 cmdline_fixed_string_t show;
7184 cmdline_fixed_string_t type;
7185 cmdline_fixed_string_t what;
7191 cmd_showqueue_parsed(void *parsed_result,
7192 __attribute__((unused)) struct cmdline *cl,
7193 __attribute__((unused)) void *data)
7195 struct cmd_showqueue_result *res = parsed_result;
7197 if (!strcmp(res->type, "rxq"))
7198 rx_queue_infos_display(res->portnum, res->queuenum);
7199 else if (!strcmp(res->type, "txq"))
7200 tx_queue_infos_display(res->portnum, res->queuenum);
7203 cmdline_parse_token_string_t cmd_showqueue_show =
7204 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7205 cmdline_parse_token_string_t cmd_showqueue_type =
7206 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7207 cmdline_parse_token_string_t cmd_showqueue_what =
7208 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7209 cmdline_parse_token_num_t cmd_showqueue_portnum =
7210 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7211 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7212 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7214 cmdline_parse_inst_t cmd_showqueue = {
7215 .f = cmd_showqueue_parsed,
7217 .help_str = "show rxq|txq info <port_id> <queue_id>",
7219 (void *)&cmd_showqueue_show,
7220 (void *)&cmd_showqueue_type,
7221 (void *)&cmd_showqueue_what,
7222 (void *)&cmd_showqueue_portnum,
7223 (void *)&cmd_showqueue_queuenum,
7228 /* *** READ PORT REGISTER *** */
7229 struct cmd_read_reg_result {
7230 cmdline_fixed_string_t read;
7231 cmdline_fixed_string_t reg;
7237 cmd_read_reg_parsed(void *parsed_result,
7238 __attribute__((unused)) struct cmdline *cl,
7239 __attribute__((unused)) void *data)
7241 struct cmd_read_reg_result *res = parsed_result;
7242 port_reg_display(res->port_id, res->reg_off);
7245 cmdline_parse_token_string_t cmd_read_reg_read =
7246 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7247 cmdline_parse_token_string_t cmd_read_reg_reg =
7248 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7249 cmdline_parse_token_num_t cmd_read_reg_port_id =
7250 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7251 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7252 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7254 cmdline_parse_inst_t cmd_read_reg = {
7255 .f = cmd_read_reg_parsed,
7257 .help_str = "read reg <port_id> <reg_off>",
7259 (void *)&cmd_read_reg_read,
7260 (void *)&cmd_read_reg_reg,
7261 (void *)&cmd_read_reg_port_id,
7262 (void *)&cmd_read_reg_reg_off,
7267 /* *** READ PORT REGISTER BIT FIELD *** */
7268 struct cmd_read_reg_bit_field_result {
7269 cmdline_fixed_string_t read;
7270 cmdline_fixed_string_t regfield;
7278 cmd_read_reg_bit_field_parsed(void *parsed_result,
7279 __attribute__((unused)) struct cmdline *cl,
7280 __attribute__((unused)) void *data)
7282 struct cmd_read_reg_bit_field_result *res = parsed_result;
7283 port_reg_bit_field_display(res->port_id, res->reg_off,
7284 res->bit1_pos, res->bit2_pos);
7287 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7288 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7290 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7291 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7292 regfield, "regfield");
7293 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7294 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7296 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7297 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7299 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7300 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7302 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7303 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7306 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7307 .f = cmd_read_reg_bit_field_parsed,
7309 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7310 "Read register bit field between bit_x and bit_y included",
7312 (void *)&cmd_read_reg_bit_field_read,
7313 (void *)&cmd_read_reg_bit_field_regfield,
7314 (void *)&cmd_read_reg_bit_field_port_id,
7315 (void *)&cmd_read_reg_bit_field_reg_off,
7316 (void *)&cmd_read_reg_bit_field_bit1_pos,
7317 (void *)&cmd_read_reg_bit_field_bit2_pos,
7322 /* *** READ PORT REGISTER BIT *** */
7323 struct cmd_read_reg_bit_result {
7324 cmdline_fixed_string_t read;
7325 cmdline_fixed_string_t regbit;
7332 cmd_read_reg_bit_parsed(void *parsed_result,
7333 __attribute__((unused)) struct cmdline *cl,
7334 __attribute__((unused)) void *data)
7336 struct cmd_read_reg_bit_result *res = parsed_result;
7337 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7340 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7341 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7342 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7343 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7345 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7346 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7347 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7348 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7349 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7350 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7352 cmdline_parse_inst_t cmd_read_reg_bit = {
7353 .f = cmd_read_reg_bit_parsed,
7355 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7357 (void *)&cmd_read_reg_bit_read,
7358 (void *)&cmd_read_reg_bit_regbit,
7359 (void *)&cmd_read_reg_bit_port_id,
7360 (void *)&cmd_read_reg_bit_reg_off,
7361 (void *)&cmd_read_reg_bit_bit_pos,
7366 /* *** WRITE PORT REGISTER *** */
7367 struct cmd_write_reg_result {
7368 cmdline_fixed_string_t write;
7369 cmdline_fixed_string_t reg;
7376 cmd_write_reg_parsed(void *parsed_result,
7377 __attribute__((unused)) struct cmdline *cl,
7378 __attribute__((unused)) void *data)
7380 struct cmd_write_reg_result *res = parsed_result;
7381 port_reg_set(res->port_id, res->reg_off, res->value);
7384 cmdline_parse_token_string_t cmd_write_reg_write =
7385 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7386 cmdline_parse_token_string_t cmd_write_reg_reg =
7387 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7388 cmdline_parse_token_num_t cmd_write_reg_port_id =
7389 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7390 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7391 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7392 cmdline_parse_token_num_t cmd_write_reg_value =
7393 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7395 cmdline_parse_inst_t cmd_write_reg = {
7396 .f = cmd_write_reg_parsed,
7398 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7400 (void *)&cmd_write_reg_write,
7401 (void *)&cmd_write_reg_reg,
7402 (void *)&cmd_write_reg_port_id,
7403 (void *)&cmd_write_reg_reg_off,
7404 (void *)&cmd_write_reg_value,
7409 /* *** WRITE PORT REGISTER BIT FIELD *** */
7410 struct cmd_write_reg_bit_field_result {
7411 cmdline_fixed_string_t write;
7412 cmdline_fixed_string_t regfield;
7421 cmd_write_reg_bit_field_parsed(void *parsed_result,
7422 __attribute__((unused)) struct cmdline *cl,
7423 __attribute__((unused)) void *data)
7425 struct cmd_write_reg_bit_field_result *res = parsed_result;
7426 port_reg_bit_field_set(res->port_id, res->reg_off,
7427 res->bit1_pos, res->bit2_pos, res->value);
7430 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7431 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7433 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7434 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7435 regfield, "regfield");
7436 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7437 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7439 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7440 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7442 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7443 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7445 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7446 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7448 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7449 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7452 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7453 .f = cmd_write_reg_bit_field_parsed,
7455 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7457 "Set register bit field between bit_x and bit_y included",
7459 (void *)&cmd_write_reg_bit_field_write,
7460 (void *)&cmd_write_reg_bit_field_regfield,
7461 (void *)&cmd_write_reg_bit_field_port_id,
7462 (void *)&cmd_write_reg_bit_field_reg_off,
7463 (void *)&cmd_write_reg_bit_field_bit1_pos,
7464 (void *)&cmd_write_reg_bit_field_bit2_pos,
7465 (void *)&cmd_write_reg_bit_field_value,
7470 /* *** WRITE PORT REGISTER BIT *** */
7471 struct cmd_write_reg_bit_result {
7472 cmdline_fixed_string_t write;
7473 cmdline_fixed_string_t regbit;
7481 cmd_write_reg_bit_parsed(void *parsed_result,
7482 __attribute__((unused)) struct cmdline *cl,
7483 __attribute__((unused)) void *data)
7485 struct cmd_write_reg_bit_result *res = parsed_result;
7486 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7489 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7490 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7492 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7493 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7495 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7496 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7497 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7498 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7499 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7500 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7501 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7502 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7504 cmdline_parse_inst_t cmd_write_reg_bit = {
7505 .f = cmd_write_reg_bit_parsed,
7507 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7510 (void *)&cmd_write_reg_bit_write,
7511 (void *)&cmd_write_reg_bit_regbit,
7512 (void *)&cmd_write_reg_bit_port_id,
7513 (void *)&cmd_write_reg_bit_reg_off,
7514 (void *)&cmd_write_reg_bit_bit_pos,
7515 (void *)&cmd_write_reg_bit_value,
7520 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7521 struct cmd_read_rxd_txd_result {
7522 cmdline_fixed_string_t read;
7523 cmdline_fixed_string_t rxd_txd;
7530 cmd_read_rxd_txd_parsed(void *parsed_result,
7531 __attribute__((unused)) struct cmdline *cl,
7532 __attribute__((unused)) void *data)
7534 struct cmd_read_rxd_txd_result *res = parsed_result;
7536 if (!strcmp(res->rxd_txd, "rxd"))
7537 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7538 else if (!strcmp(res->rxd_txd, "txd"))
7539 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7542 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7543 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7544 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7545 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7547 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7548 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7549 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7550 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7551 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7552 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7554 cmdline_parse_inst_t cmd_read_rxd_txd = {
7555 .f = cmd_read_rxd_txd_parsed,
7557 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7559 (void *)&cmd_read_rxd_txd_read,
7560 (void *)&cmd_read_rxd_txd_rxd_txd,
7561 (void *)&cmd_read_rxd_txd_port_id,
7562 (void *)&cmd_read_rxd_txd_queue_id,
7563 (void *)&cmd_read_rxd_txd_desc_id,
7569 struct cmd_quit_result {
7570 cmdline_fixed_string_t quit;
7573 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7575 __attribute__((unused)) void *data)
7581 cmdline_parse_token_string_t cmd_quit_quit =
7582 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7584 cmdline_parse_inst_t cmd_quit = {
7585 .f = cmd_quit_parsed,
7587 .help_str = "quit: Exit application",
7589 (void *)&cmd_quit_quit,
7594 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7595 struct cmd_mac_addr_result {
7596 cmdline_fixed_string_t mac_addr_cmd;
7597 cmdline_fixed_string_t what;
7599 struct ether_addr address;
7602 static void cmd_mac_addr_parsed(void *parsed_result,
7603 __attribute__((unused)) struct cmdline *cl,
7604 __attribute__((unused)) void *data)
7606 struct cmd_mac_addr_result *res = parsed_result;
7609 if (strcmp(res->what, "add") == 0)
7610 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7611 else if (strcmp(res->what, "set") == 0)
7612 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7615 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7617 /* check the return value and print it if is < 0 */
7619 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7623 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7624 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7626 cmdline_parse_token_string_t cmd_mac_addr_what =
7627 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7629 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7630 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7632 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7633 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7635 cmdline_parse_inst_t cmd_mac_addr = {
7636 .f = cmd_mac_addr_parsed,
7638 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7639 "Add/Remove/Set MAC address on port_id",
7641 (void *)&cmd_mac_addr_cmd,
7642 (void *)&cmd_mac_addr_what,
7643 (void *)&cmd_mac_addr_portnum,
7644 (void *)&cmd_mac_addr_addr,
7649 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7650 struct cmd_eth_peer_result {
7651 cmdline_fixed_string_t set;
7652 cmdline_fixed_string_t eth_peer;
7654 cmdline_fixed_string_t peer_addr;
7657 static void cmd_set_eth_peer_parsed(void *parsed_result,
7658 __attribute__((unused)) struct cmdline *cl,
7659 __attribute__((unused)) void *data)
7661 struct cmd_eth_peer_result *res = parsed_result;
7663 if (test_done == 0) {
7664 printf("Please stop forwarding first\n");
7667 if (!strcmp(res->eth_peer, "eth-peer")) {
7668 set_fwd_eth_peer(res->port_id, res->peer_addr);
7672 cmdline_parse_token_string_t cmd_eth_peer_set =
7673 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7674 cmdline_parse_token_string_t cmd_eth_peer =
7675 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7676 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7677 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7678 cmdline_parse_token_string_t cmd_eth_peer_addr =
7679 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7681 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7682 .f = cmd_set_eth_peer_parsed,
7684 .help_str = "set eth-peer <port_id> <peer_mac>",
7686 (void *)&cmd_eth_peer_set,
7687 (void *)&cmd_eth_peer,
7688 (void *)&cmd_eth_peer_port_id,
7689 (void *)&cmd_eth_peer_addr,
7694 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7695 struct cmd_set_qmap_result {
7696 cmdline_fixed_string_t set;
7697 cmdline_fixed_string_t qmap;
7698 cmdline_fixed_string_t what;
7705 cmd_set_qmap_parsed(void *parsed_result,
7706 __attribute__((unused)) struct cmdline *cl,
7707 __attribute__((unused)) void *data)
7709 struct cmd_set_qmap_result *res = parsed_result;
7710 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7712 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7715 cmdline_parse_token_string_t cmd_setqmap_set =
7716 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7718 cmdline_parse_token_string_t cmd_setqmap_qmap =
7719 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7721 cmdline_parse_token_string_t cmd_setqmap_what =
7722 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7724 cmdline_parse_token_num_t cmd_setqmap_portid =
7725 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7727 cmdline_parse_token_num_t cmd_setqmap_queueid =
7728 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7730 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7731 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7734 cmdline_parse_inst_t cmd_set_qmap = {
7735 .f = cmd_set_qmap_parsed,
7737 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7738 "Set statistics mapping value on tx|rx queue_id of port_id",
7740 (void *)&cmd_setqmap_set,
7741 (void *)&cmd_setqmap_qmap,
7742 (void *)&cmd_setqmap_what,
7743 (void *)&cmd_setqmap_portid,
7744 (void *)&cmd_setqmap_queueid,
7745 (void *)&cmd_setqmap_mapvalue,
7750 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7751 struct cmd_set_xstats_hide_zero_result {
7752 cmdline_fixed_string_t keyword;
7753 cmdline_fixed_string_t name;
7754 cmdline_fixed_string_t on_off;
7758 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7759 __attribute__((unused)) struct cmdline *cl,
7760 __attribute__((unused)) void *data)
7762 struct cmd_set_xstats_hide_zero_result *res;
7763 uint16_t on_off = 0;
7765 res = parsed_result;
7766 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7767 set_xstats_hide_zero(on_off);
7770 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7771 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7773 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7774 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7775 name, "xstats-hide-zero");
7776 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7777 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7780 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7781 .f = cmd_set_xstats_hide_zero_parsed,
7783 .help_str = "set xstats-hide-zero on|off",
7785 (void *)&cmd_set_xstats_hide_zero_keyword,
7786 (void *)&cmd_set_xstats_hide_zero_name,
7787 (void *)&cmd_set_xstats_hide_zero_on_off,
7792 /* *** CONFIGURE UNICAST HASH TABLE *** */
7793 struct cmd_set_uc_hash_table {
7794 cmdline_fixed_string_t set;
7795 cmdline_fixed_string_t port;
7797 cmdline_fixed_string_t what;
7798 struct ether_addr address;
7799 cmdline_fixed_string_t mode;
7803 cmd_set_uc_hash_parsed(void *parsed_result,
7804 __attribute__((unused)) struct cmdline *cl,
7805 __attribute__((unused)) void *data)
7808 struct cmd_set_uc_hash_table *res = parsed_result;
7810 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7812 if (strcmp(res->what, "uta") == 0)
7813 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7814 &res->address,(uint8_t)is_on);
7816 printf("bad unicast hash table parameter, return code = %d \n", ret);
7820 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7821 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7823 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7824 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7826 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7827 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7829 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7830 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7832 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7833 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7835 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7836 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7839 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7840 .f = cmd_set_uc_hash_parsed,
7842 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7844 (void *)&cmd_set_uc_hash_set,
7845 (void *)&cmd_set_uc_hash_port,
7846 (void *)&cmd_set_uc_hash_portid,
7847 (void *)&cmd_set_uc_hash_what,
7848 (void *)&cmd_set_uc_hash_mac,
7849 (void *)&cmd_set_uc_hash_mode,
7854 struct cmd_set_uc_all_hash_table {
7855 cmdline_fixed_string_t set;
7856 cmdline_fixed_string_t port;
7858 cmdline_fixed_string_t what;
7859 cmdline_fixed_string_t value;
7860 cmdline_fixed_string_t mode;
7864 cmd_set_uc_all_hash_parsed(void *parsed_result,
7865 __attribute__((unused)) struct cmdline *cl,
7866 __attribute__((unused)) void *data)
7869 struct cmd_set_uc_all_hash_table *res = parsed_result;
7871 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7873 if ((strcmp(res->what, "uta") == 0) &&
7874 (strcmp(res->value, "all") == 0))
7875 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7877 printf("bad unicast hash table parameter,"
7878 "return code = %d \n", ret);
7881 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7882 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7884 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7885 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7887 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7888 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7890 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7891 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7893 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7894 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7896 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7897 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7900 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7901 .f = cmd_set_uc_all_hash_parsed,
7903 .help_str = "set port <port_id> uta all on|off",
7905 (void *)&cmd_set_uc_all_hash_set,
7906 (void *)&cmd_set_uc_all_hash_port,
7907 (void *)&cmd_set_uc_all_hash_portid,
7908 (void *)&cmd_set_uc_all_hash_what,
7909 (void *)&cmd_set_uc_all_hash_value,
7910 (void *)&cmd_set_uc_all_hash_mode,
7915 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7916 struct cmd_set_vf_macvlan_filter {
7917 cmdline_fixed_string_t set;
7918 cmdline_fixed_string_t port;
7920 cmdline_fixed_string_t vf;
7922 struct ether_addr address;
7923 cmdline_fixed_string_t filter_type;
7924 cmdline_fixed_string_t mode;
7928 cmd_set_vf_macvlan_parsed(void *parsed_result,
7929 __attribute__((unused)) struct cmdline *cl,
7930 __attribute__((unused)) void *data)
7933 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7934 struct rte_eth_mac_filter filter;
7936 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7938 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7940 /* set VF MAC filter */
7944 filter.dst_id = res->vf_id;
7946 if (!strcmp(res->filter_type, "exact-mac"))
7947 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7948 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7949 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7950 else if (!strcmp(res->filter_type, "hashmac"))
7951 filter.filter_type = RTE_MAC_HASH_MATCH;
7952 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7953 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7955 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7958 ret = rte_eth_dev_filter_ctrl(res->port_id,
7959 RTE_ETH_FILTER_MACVLAN,
7963 ret = rte_eth_dev_filter_ctrl(res->port_id,
7964 RTE_ETH_FILTER_MACVLAN,
7965 RTE_ETH_FILTER_DELETE,
7969 printf("bad set MAC hash parameter, return code = %d\n", ret);
7973 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7974 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7976 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7977 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7979 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7980 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7982 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7983 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7985 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7986 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7988 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7989 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7991 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7992 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7993 filter_type, "exact-mac#exact-mac-vlan"
7994 "#hashmac#hashmac-vlan");
7995 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7996 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7999 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8000 .f = cmd_set_vf_macvlan_parsed,
8002 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8003 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8004 "Exact match rule: exact match of MAC or MAC and VLAN; "
8005 "hash match rule: hash match of MAC and exact match of VLAN",
8007 (void *)&cmd_set_vf_macvlan_set,
8008 (void *)&cmd_set_vf_macvlan_port,
8009 (void *)&cmd_set_vf_macvlan_portid,
8010 (void *)&cmd_set_vf_macvlan_vf,
8011 (void *)&cmd_set_vf_macvlan_vf_id,
8012 (void *)&cmd_set_vf_macvlan_mac,
8013 (void *)&cmd_set_vf_macvlan_filter_type,
8014 (void *)&cmd_set_vf_macvlan_mode,
8019 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8020 struct cmd_set_vf_traffic {
8021 cmdline_fixed_string_t set;
8022 cmdline_fixed_string_t port;
8024 cmdline_fixed_string_t vf;
8026 cmdline_fixed_string_t what;
8027 cmdline_fixed_string_t mode;
8031 cmd_set_vf_traffic_parsed(void *parsed_result,
8032 __attribute__((unused)) struct cmdline *cl,
8033 __attribute__((unused)) void *data)
8035 struct cmd_set_vf_traffic *res = parsed_result;
8036 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8037 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8039 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8042 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8043 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8045 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8046 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8048 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8049 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8051 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8052 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8054 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8055 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8057 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8058 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8060 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8061 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8064 cmdline_parse_inst_t cmd_set_vf_traffic = {
8065 .f = cmd_set_vf_traffic_parsed,
8067 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8069 (void *)&cmd_setvf_traffic_set,
8070 (void *)&cmd_setvf_traffic_port,
8071 (void *)&cmd_setvf_traffic_portid,
8072 (void *)&cmd_setvf_traffic_vf,
8073 (void *)&cmd_setvf_traffic_vfid,
8074 (void *)&cmd_setvf_traffic_what,
8075 (void *)&cmd_setvf_traffic_mode,
8080 /* *** CONFIGURE VF RECEIVE MODE *** */
8081 struct cmd_set_vf_rxmode {
8082 cmdline_fixed_string_t set;
8083 cmdline_fixed_string_t port;
8085 cmdline_fixed_string_t vf;
8087 cmdline_fixed_string_t what;
8088 cmdline_fixed_string_t mode;
8089 cmdline_fixed_string_t on;
8093 cmd_set_vf_rxmode_parsed(void *parsed_result,
8094 __attribute__((unused)) struct cmdline *cl,
8095 __attribute__((unused)) void *data)
8098 uint16_t rx_mode = 0;
8099 struct cmd_set_vf_rxmode *res = parsed_result;
8101 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8102 if (!strcmp(res->what,"rxmode")) {
8103 if (!strcmp(res->mode, "AUPE"))
8104 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8105 else if (!strcmp(res->mode, "ROPE"))
8106 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8107 else if (!strcmp(res->mode, "BAM"))
8108 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8109 else if (!strncmp(res->mode, "MPE",3))
8110 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8113 RTE_SET_USED(is_on);
8115 #ifdef RTE_LIBRTE_IXGBE_PMD
8116 if (ret == -ENOTSUP)
8117 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8118 rx_mode, (uint8_t)is_on);
8120 #ifdef RTE_LIBRTE_BNXT_PMD
8121 if (ret == -ENOTSUP)
8122 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8123 rx_mode, (uint8_t)is_on);
8126 printf("bad VF receive mode parameter, return code = %d \n",
8130 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8131 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8133 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8134 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8136 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8137 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8139 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8140 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8142 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8143 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8145 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8146 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8148 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8149 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8150 mode, "AUPE#ROPE#BAM#MPE");
8151 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8152 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8155 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8156 .f = cmd_set_vf_rxmode_parsed,
8158 .help_str = "set port <port_id> vf <vf_id> rxmode "
8159 "AUPE|ROPE|BAM|MPE on|off",
8161 (void *)&cmd_set_vf_rxmode_set,
8162 (void *)&cmd_set_vf_rxmode_port,
8163 (void *)&cmd_set_vf_rxmode_portid,
8164 (void *)&cmd_set_vf_rxmode_vf,
8165 (void *)&cmd_set_vf_rxmode_vfid,
8166 (void *)&cmd_set_vf_rxmode_what,
8167 (void *)&cmd_set_vf_rxmode_mode,
8168 (void *)&cmd_set_vf_rxmode_on,
8173 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8174 struct cmd_vf_mac_addr_result {
8175 cmdline_fixed_string_t mac_addr_cmd;
8176 cmdline_fixed_string_t what;
8177 cmdline_fixed_string_t port;
8179 cmdline_fixed_string_t vf;
8181 struct ether_addr address;
8184 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8185 __attribute__((unused)) struct cmdline *cl,
8186 __attribute__((unused)) void *data)
8188 struct cmd_vf_mac_addr_result *res = parsed_result;
8191 if (strcmp(res->what, "add") != 0)
8194 #ifdef RTE_LIBRTE_I40E_PMD
8195 if (ret == -ENOTSUP)
8196 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8199 #ifdef RTE_LIBRTE_BNXT_PMD
8200 if (ret == -ENOTSUP)
8201 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8206 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8210 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8211 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8212 mac_addr_cmd,"mac_addr");
8213 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8214 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8216 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8217 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8219 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8220 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8222 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8223 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8225 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8226 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8228 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8229 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8232 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8233 .f = cmd_vf_mac_addr_parsed,
8235 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8236 "Add MAC address filtering for a VF on port_id",
8238 (void *)&cmd_vf_mac_addr_cmd,
8239 (void *)&cmd_vf_mac_addr_what,
8240 (void *)&cmd_vf_mac_addr_port,
8241 (void *)&cmd_vf_mac_addr_portnum,
8242 (void *)&cmd_vf_mac_addr_vf,
8243 (void *)&cmd_vf_mac_addr_vfnum,
8244 (void *)&cmd_vf_mac_addr_addr,
8249 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8250 struct cmd_vf_rx_vlan_filter {
8251 cmdline_fixed_string_t rx_vlan;
8252 cmdline_fixed_string_t what;
8254 cmdline_fixed_string_t port;
8256 cmdline_fixed_string_t vf;
8261 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8262 __attribute__((unused)) struct cmdline *cl,
8263 __attribute__((unused)) void *data)
8265 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8268 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8270 #ifdef RTE_LIBRTE_IXGBE_PMD
8271 if (ret == -ENOTSUP)
8272 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8273 res->vlan_id, res->vf_mask, is_add);
8275 #ifdef RTE_LIBRTE_I40E_PMD
8276 if (ret == -ENOTSUP)
8277 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8278 res->vlan_id, res->vf_mask, is_add);
8280 #ifdef RTE_LIBRTE_BNXT_PMD
8281 if (ret == -ENOTSUP)
8282 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8283 res->vlan_id, res->vf_mask, is_add);
8290 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8291 res->vlan_id, res->vf_mask);
8294 printf("invalid port_id %d\n", res->port_id);
8297 printf("function not implemented or supported\n");
8300 printf("programming error: (%s)\n", strerror(-ret));
8304 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8305 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8306 rx_vlan, "rx_vlan");
8307 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8308 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8310 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8311 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8313 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8314 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8316 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8317 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8319 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8320 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8322 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8323 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8326 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8327 .f = cmd_vf_rx_vlan_filter_parsed,
8329 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8330 "(vf_mask = hexadecimal VF mask)",
8332 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8333 (void *)&cmd_vf_rx_vlan_filter_what,
8334 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8335 (void *)&cmd_vf_rx_vlan_filter_port,
8336 (void *)&cmd_vf_rx_vlan_filter_portid,
8337 (void *)&cmd_vf_rx_vlan_filter_vf,
8338 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8343 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8344 struct cmd_queue_rate_limit_result {
8345 cmdline_fixed_string_t set;
8346 cmdline_fixed_string_t port;
8348 cmdline_fixed_string_t queue;
8350 cmdline_fixed_string_t rate;
8354 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8355 __attribute__((unused)) struct cmdline *cl,
8356 __attribute__((unused)) void *data)
8358 struct cmd_queue_rate_limit_result *res = parsed_result;
8361 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8362 && (strcmp(res->queue, "queue") == 0)
8363 && (strcmp(res->rate, "rate") == 0))
8364 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8367 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8371 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8372 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8374 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8375 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8377 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8378 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8380 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8381 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8383 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8384 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8386 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8387 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8389 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8390 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8393 cmdline_parse_inst_t cmd_queue_rate_limit = {
8394 .f = cmd_queue_rate_limit_parsed,
8396 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8397 "Set rate limit for a queue on port_id",
8399 (void *)&cmd_queue_rate_limit_set,
8400 (void *)&cmd_queue_rate_limit_port,
8401 (void *)&cmd_queue_rate_limit_portnum,
8402 (void *)&cmd_queue_rate_limit_queue,
8403 (void *)&cmd_queue_rate_limit_queuenum,
8404 (void *)&cmd_queue_rate_limit_rate,
8405 (void *)&cmd_queue_rate_limit_ratenum,
8410 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8411 struct cmd_vf_rate_limit_result {
8412 cmdline_fixed_string_t set;
8413 cmdline_fixed_string_t port;
8415 cmdline_fixed_string_t vf;
8417 cmdline_fixed_string_t rate;
8419 cmdline_fixed_string_t q_msk;
8423 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8424 __attribute__((unused)) struct cmdline *cl,
8425 __attribute__((unused)) void *data)
8427 struct cmd_vf_rate_limit_result *res = parsed_result;
8430 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8431 && (strcmp(res->vf, "vf") == 0)
8432 && (strcmp(res->rate, "rate") == 0)
8433 && (strcmp(res->q_msk, "queue_mask") == 0))
8434 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8435 res->rate_num, res->q_msk_val);
8437 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8441 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8442 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8444 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8445 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8447 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8448 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8450 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8451 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8453 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8454 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8456 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8457 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8459 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8460 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8462 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8463 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8464 q_msk, "queue_mask");
8465 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8466 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8469 cmdline_parse_inst_t cmd_vf_rate_limit = {
8470 .f = cmd_vf_rate_limit_parsed,
8472 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8473 "queue_mask <queue_mask_value>: "
8474 "Set rate limit for queues of VF on port_id",
8476 (void *)&cmd_vf_rate_limit_set,
8477 (void *)&cmd_vf_rate_limit_port,
8478 (void *)&cmd_vf_rate_limit_portnum,
8479 (void *)&cmd_vf_rate_limit_vf,
8480 (void *)&cmd_vf_rate_limit_vfnum,
8481 (void *)&cmd_vf_rate_limit_rate,
8482 (void *)&cmd_vf_rate_limit_ratenum,
8483 (void *)&cmd_vf_rate_limit_q_msk,
8484 (void *)&cmd_vf_rate_limit_q_msk_val,
8489 /* *** ADD TUNNEL FILTER OF A PORT *** */
8490 struct cmd_tunnel_filter_result {
8491 cmdline_fixed_string_t cmd;
8492 cmdline_fixed_string_t what;
8494 struct ether_addr outer_mac;
8495 struct ether_addr inner_mac;
8496 cmdline_ipaddr_t ip_value;
8497 uint16_t inner_vlan;
8498 cmdline_fixed_string_t tunnel_type;
8499 cmdline_fixed_string_t filter_type;
8505 cmd_tunnel_filter_parsed(void *parsed_result,
8506 __attribute__((unused)) struct cmdline *cl,
8507 __attribute__((unused)) void *data)
8509 struct cmd_tunnel_filter_result *res = parsed_result;
8510 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8513 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8515 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8516 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8517 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8519 if (res->ip_value.family == AF_INET) {
8520 tunnel_filter_conf.ip_addr.ipv4_addr =
8521 res->ip_value.addr.ipv4.s_addr;
8522 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8524 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8525 &(res->ip_value.addr.ipv6),
8526 sizeof(struct in6_addr));
8527 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8530 if (!strcmp(res->filter_type, "imac-ivlan"))
8531 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8532 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8533 tunnel_filter_conf.filter_type =
8534 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8535 else if (!strcmp(res->filter_type, "imac-tenid"))
8536 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8537 else if (!strcmp(res->filter_type, "imac"))
8538 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8539 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8540 tunnel_filter_conf.filter_type =
8541 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8542 else if (!strcmp(res->filter_type, "oip"))
8543 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8544 else if (!strcmp(res->filter_type, "iip"))
8545 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8547 printf("The filter type is not supported");
8551 if (!strcmp(res->tunnel_type, "vxlan"))
8552 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8553 else if (!strcmp(res->tunnel_type, "nvgre"))
8554 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8555 else if (!strcmp(res->tunnel_type, "ipingre"))
8556 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8558 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8562 tunnel_filter_conf.tenant_id = res->tenant_id;
8563 tunnel_filter_conf.queue_id = res->queue_num;
8564 if (!strcmp(res->what, "add"))
8565 ret = rte_eth_dev_filter_ctrl(res->port_id,
8566 RTE_ETH_FILTER_TUNNEL,
8568 &tunnel_filter_conf);
8570 ret = rte_eth_dev_filter_ctrl(res->port_id,
8571 RTE_ETH_FILTER_TUNNEL,
8572 RTE_ETH_FILTER_DELETE,
8573 &tunnel_filter_conf);
8575 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8579 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8580 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8581 cmd, "tunnel_filter");
8582 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8583 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8585 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8586 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8588 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8589 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8591 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8592 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8594 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8595 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8596 inner_vlan, UINT16);
8597 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8598 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8600 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8601 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8602 tunnel_type, "vxlan#nvgre#ipingre");
8604 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8605 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8606 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8607 "imac#omac-imac-tenid");
8608 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8609 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8611 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8612 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8615 cmdline_parse_inst_t cmd_tunnel_filter = {
8616 .f = cmd_tunnel_filter_parsed,
8618 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8619 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8620 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8621 "<queue_id>: Add/Rm tunnel filter of a port",
8623 (void *)&cmd_tunnel_filter_cmd,
8624 (void *)&cmd_tunnel_filter_what,
8625 (void *)&cmd_tunnel_filter_port_id,
8626 (void *)&cmd_tunnel_filter_outer_mac,
8627 (void *)&cmd_tunnel_filter_inner_mac,
8628 (void *)&cmd_tunnel_filter_ip_value,
8629 (void *)&cmd_tunnel_filter_innner_vlan,
8630 (void *)&cmd_tunnel_filter_tunnel_type,
8631 (void *)&cmd_tunnel_filter_filter_type,
8632 (void *)&cmd_tunnel_filter_tenant_id,
8633 (void *)&cmd_tunnel_filter_queue_num,
8638 /* *** CONFIGURE TUNNEL UDP PORT *** */
8639 struct cmd_tunnel_udp_config {
8640 cmdline_fixed_string_t cmd;
8641 cmdline_fixed_string_t what;
8647 cmd_tunnel_udp_config_parsed(void *parsed_result,
8648 __attribute__((unused)) struct cmdline *cl,
8649 __attribute__((unused)) void *data)
8651 struct cmd_tunnel_udp_config *res = parsed_result;
8652 struct rte_eth_udp_tunnel tunnel_udp;
8655 tunnel_udp.udp_port = res->udp_port;
8657 if (!strcmp(res->cmd, "rx_vxlan_port"))
8658 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8660 if (!strcmp(res->what, "add"))
8661 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8664 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8668 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8671 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8672 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8673 cmd, "rx_vxlan_port");
8674 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8675 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8677 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8678 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8680 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8681 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8684 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8685 .f = cmd_tunnel_udp_config_parsed,
8687 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8688 "Add/Remove a tunneling UDP port filter",
8690 (void *)&cmd_tunnel_udp_config_cmd,
8691 (void *)&cmd_tunnel_udp_config_what,
8692 (void *)&cmd_tunnel_udp_config_udp_port,
8693 (void *)&cmd_tunnel_udp_config_port_id,
8698 struct cmd_config_tunnel_udp_port {
8699 cmdline_fixed_string_t port;
8700 cmdline_fixed_string_t config;
8702 cmdline_fixed_string_t udp_tunnel_port;
8703 cmdline_fixed_string_t action;
8704 cmdline_fixed_string_t tunnel_type;
8709 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8710 __attribute__((unused)) struct cmdline *cl,
8711 __attribute__((unused)) void *data)
8713 struct cmd_config_tunnel_udp_port *res = parsed_result;
8714 struct rte_eth_udp_tunnel tunnel_udp;
8717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8720 tunnel_udp.udp_port = res->udp_port;
8722 if (!strcmp(res->tunnel_type, "vxlan")) {
8723 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8724 } else if (!strcmp(res->tunnel_type, "geneve")) {
8725 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8727 printf("Invalid tunnel type\n");
8731 if (!strcmp(res->action, "add"))
8732 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8735 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8739 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8742 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8743 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8745 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8746 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8748 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8749 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8751 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8752 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8755 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8756 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8758 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8759 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8761 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8762 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8765 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8766 .f = cmd_cfg_tunnel_udp_port_parsed,
8768 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8770 (void *)&cmd_config_tunnel_udp_port_port,
8771 (void *)&cmd_config_tunnel_udp_port_config,
8772 (void *)&cmd_config_tunnel_udp_port_port_id,
8773 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8774 (void *)&cmd_config_tunnel_udp_port_action,
8775 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8776 (void *)&cmd_config_tunnel_udp_port_value,
8781 /* *** GLOBAL CONFIG *** */
8782 struct cmd_global_config_result {
8783 cmdline_fixed_string_t cmd;
8785 cmdline_fixed_string_t cfg_type;
8790 cmd_global_config_parsed(void *parsed_result,
8791 __attribute__((unused)) struct cmdline *cl,
8792 __attribute__((unused)) void *data)
8794 struct cmd_global_config_result *res = parsed_result;
8795 struct rte_eth_global_cfg conf;
8798 memset(&conf, 0, sizeof(conf));
8799 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8800 conf.cfg.gre_key_len = res->len;
8801 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8802 RTE_ETH_FILTER_SET, &conf);
8804 printf("Global config error\n");
8807 cmdline_parse_token_string_t cmd_global_config_cmd =
8808 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8810 cmdline_parse_token_num_t cmd_global_config_port_id =
8811 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8813 cmdline_parse_token_string_t cmd_global_config_type =
8814 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8815 cfg_type, "gre-key-len");
8816 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8817 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8820 cmdline_parse_inst_t cmd_global_config = {
8821 .f = cmd_global_config_parsed,
8822 .data = (void *)NULL,
8823 .help_str = "global_config <port_id> gre-key-len <key_len>",
8825 (void *)&cmd_global_config_cmd,
8826 (void *)&cmd_global_config_port_id,
8827 (void *)&cmd_global_config_type,
8828 (void *)&cmd_global_config_gre_key_len,
8833 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8834 struct cmd_set_mirror_mask_result {
8835 cmdline_fixed_string_t set;
8836 cmdline_fixed_string_t port;
8838 cmdline_fixed_string_t mirror;
8840 cmdline_fixed_string_t what;
8841 cmdline_fixed_string_t value;
8842 cmdline_fixed_string_t dstpool;
8844 cmdline_fixed_string_t on;
8847 cmdline_parse_token_string_t cmd_mirror_mask_set =
8848 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8850 cmdline_parse_token_string_t cmd_mirror_mask_port =
8851 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8853 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8854 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8856 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8857 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8858 mirror, "mirror-rule");
8859 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8860 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8862 cmdline_parse_token_string_t cmd_mirror_mask_what =
8863 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8864 what, "pool-mirror-up#pool-mirror-down"
8866 cmdline_parse_token_string_t cmd_mirror_mask_value =
8867 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8869 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8870 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8871 dstpool, "dst-pool");
8872 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8873 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8875 cmdline_parse_token_string_t cmd_mirror_mask_on =
8876 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8880 cmd_set_mirror_mask_parsed(void *parsed_result,
8881 __attribute__((unused)) struct cmdline *cl,
8882 __attribute__((unused)) void *data)
8885 struct cmd_set_mirror_mask_result *res = parsed_result;
8886 struct rte_eth_mirror_conf mr_conf;
8888 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8890 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8892 mr_conf.dst_pool = res->dstpool_id;
8894 if (!strcmp(res->what, "pool-mirror-up")) {
8895 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8896 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8897 } else if (!strcmp(res->what, "pool-mirror-down")) {
8898 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8899 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8900 } else if (!strcmp(res->what, "vlan-mirror")) {
8901 mr_conf.rule_type = ETH_MIRROR_VLAN;
8902 nb_item = parse_item_list(res->value, "vlan",
8903 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8907 for (i = 0; i < nb_item; i++) {
8908 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8909 printf("Invalid vlan_id: must be < 4096\n");
8913 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8914 mr_conf.vlan.vlan_mask |= 1ULL << i;
8918 if (!strcmp(res->on, "on"))
8919 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8922 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8925 printf("mirror rule add error: (%s)\n", strerror(-ret));
8928 cmdline_parse_inst_t cmd_set_mirror_mask = {
8929 .f = cmd_set_mirror_mask_parsed,
8931 .help_str = "set port <port_id> mirror-rule <rule_id> "
8932 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8933 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8935 (void *)&cmd_mirror_mask_set,
8936 (void *)&cmd_mirror_mask_port,
8937 (void *)&cmd_mirror_mask_portid,
8938 (void *)&cmd_mirror_mask_mirror,
8939 (void *)&cmd_mirror_mask_ruleid,
8940 (void *)&cmd_mirror_mask_what,
8941 (void *)&cmd_mirror_mask_value,
8942 (void *)&cmd_mirror_mask_dstpool,
8943 (void *)&cmd_mirror_mask_poolid,
8944 (void *)&cmd_mirror_mask_on,
8949 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8950 struct cmd_set_mirror_link_result {
8951 cmdline_fixed_string_t set;
8952 cmdline_fixed_string_t port;
8954 cmdline_fixed_string_t mirror;
8956 cmdline_fixed_string_t what;
8957 cmdline_fixed_string_t dstpool;
8959 cmdline_fixed_string_t on;
8962 cmdline_parse_token_string_t cmd_mirror_link_set =
8963 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8965 cmdline_parse_token_string_t cmd_mirror_link_port =
8966 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8968 cmdline_parse_token_num_t cmd_mirror_link_portid =
8969 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8971 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8972 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8973 mirror, "mirror-rule");
8974 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8975 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8977 cmdline_parse_token_string_t cmd_mirror_link_what =
8978 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8979 what, "uplink-mirror#downlink-mirror");
8980 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8981 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8982 dstpool, "dst-pool");
8983 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8984 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8986 cmdline_parse_token_string_t cmd_mirror_link_on =
8987 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8991 cmd_set_mirror_link_parsed(void *parsed_result,
8992 __attribute__((unused)) struct cmdline *cl,
8993 __attribute__((unused)) void *data)
8996 struct cmd_set_mirror_link_result *res = parsed_result;
8997 struct rte_eth_mirror_conf mr_conf;
8999 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9000 if (!strcmp(res->what, "uplink-mirror"))
9001 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9003 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9005 mr_conf.dst_pool = res->dstpool_id;
9007 if (!strcmp(res->on, "on"))
9008 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9011 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9014 /* check the return value and print it if is < 0 */
9016 printf("mirror rule add error: (%s)\n", strerror(-ret));
9020 cmdline_parse_inst_t cmd_set_mirror_link = {
9021 .f = cmd_set_mirror_link_parsed,
9023 .help_str = "set port <port_id> mirror-rule <rule_id> "
9024 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9026 (void *)&cmd_mirror_link_set,
9027 (void *)&cmd_mirror_link_port,
9028 (void *)&cmd_mirror_link_portid,
9029 (void *)&cmd_mirror_link_mirror,
9030 (void *)&cmd_mirror_link_ruleid,
9031 (void *)&cmd_mirror_link_what,
9032 (void *)&cmd_mirror_link_dstpool,
9033 (void *)&cmd_mirror_link_poolid,
9034 (void *)&cmd_mirror_link_on,
9039 /* *** RESET VM MIRROR RULE *** */
9040 struct cmd_rm_mirror_rule_result {
9041 cmdline_fixed_string_t reset;
9042 cmdline_fixed_string_t port;
9044 cmdline_fixed_string_t mirror;
9048 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9049 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9051 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9052 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9054 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9055 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9057 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9058 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9059 mirror, "mirror-rule");
9060 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9061 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9065 cmd_reset_mirror_rule_parsed(void *parsed_result,
9066 __attribute__((unused)) struct cmdline *cl,
9067 __attribute__((unused)) void *data)
9070 struct cmd_set_mirror_link_result *res = parsed_result;
9072 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9074 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9077 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9078 .f = cmd_reset_mirror_rule_parsed,
9080 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9082 (void *)&cmd_rm_mirror_rule_reset,
9083 (void *)&cmd_rm_mirror_rule_port,
9084 (void *)&cmd_rm_mirror_rule_portid,
9085 (void *)&cmd_rm_mirror_rule_mirror,
9086 (void *)&cmd_rm_mirror_rule_ruleid,
9091 /* ******************************************************************************** */
9093 struct cmd_dump_result {
9094 cmdline_fixed_string_t dump;
9098 dump_struct_sizes(void)
9100 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9101 DUMP_SIZE(struct rte_mbuf);
9102 DUMP_SIZE(struct rte_mempool);
9103 DUMP_SIZE(struct rte_ring);
9107 static void cmd_dump_parsed(void *parsed_result,
9108 __attribute__((unused)) struct cmdline *cl,
9109 __attribute__((unused)) void *data)
9111 struct cmd_dump_result *res = parsed_result;
9113 if (!strcmp(res->dump, "dump_physmem"))
9114 rte_dump_physmem_layout(stdout);
9115 else if (!strcmp(res->dump, "dump_memzone"))
9116 rte_memzone_dump(stdout);
9117 else if (!strcmp(res->dump, "dump_struct_sizes"))
9118 dump_struct_sizes();
9119 else if (!strcmp(res->dump, "dump_ring"))
9120 rte_ring_list_dump(stdout);
9121 else if (!strcmp(res->dump, "dump_mempool"))
9122 rte_mempool_list_dump(stdout);
9123 else if (!strcmp(res->dump, "dump_devargs"))
9124 rte_devargs_dump(stdout);
9125 else if (!strcmp(res->dump, "dump_log_types"))
9126 rte_log_dump(stdout);
9129 cmdline_parse_token_string_t cmd_dump_dump =
9130 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9133 "dump_struct_sizes#"
9139 cmdline_parse_inst_t cmd_dump = {
9140 .f = cmd_dump_parsed, /* function to call */
9141 .data = NULL, /* 2nd arg of func */
9142 .help_str = "Dump status",
9143 .tokens = { /* token list, NULL terminated */
9144 (void *)&cmd_dump_dump,
9149 /* ******************************************************************************** */
9151 struct cmd_dump_one_result {
9152 cmdline_fixed_string_t dump;
9153 cmdline_fixed_string_t name;
9156 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9157 __attribute__((unused)) void *data)
9159 struct cmd_dump_one_result *res = parsed_result;
9161 if (!strcmp(res->dump, "dump_ring")) {
9163 r = rte_ring_lookup(res->name);
9165 cmdline_printf(cl, "Cannot find ring\n");
9168 rte_ring_dump(stdout, r);
9169 } else if (!strcmp(res->dump, "dump_mempool")) {
9170 struct rte_mempool *mp;
9171 mp = rte_mempool_lookup(res->name);
9173 cmdline_printf(cl, "Cannot find mempool\n");
9176 rte_mempool_dump(stdout, mp);
9180 cmdline_parse_token_string_t cmd_dump_one_dump =
9181 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9182 "dump_ring#dump_mempool");
9184 cmdline_parse_token_string_t cmd_dump_one_name =
9185 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9187 cmdline_parse_inst_t cmd_dump_one = {
9188 .f = cmd_dump_one_parsed, /* function to call */
9189 .data = NULL, /* 2nd arg of func */
9190 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9191 .tokens = { /* token list, NULL terminated */
9192 (void *)&cmd_dump_one_dump,
9193 (void *)&cmd_dump_one_name,
9198 /* *** Add/Del syn filter *** */
9199 struct cmd_syn_filter_result {
9200 cmdline_fixed_string_t filter;
9202 cmdline_fixed_string_t ops;
9203 cmdline_fixed_string_t priority;
9204 cmdline_fixed_string_t high;
9205 cmdline_fixed_string_t queue;
9210 cmd_syn_filter_parsed(void *parsed_result,
9211 __attribute__((unused)) struct cmdline *cl,
9212 __attribute__((unused)) void *data)
9214 struct cmd_syn_filter_result *res = parsed_result;
9215 struct rte_eth_syn_filter syn_filter;
9218 ret = rte_eth_dev_filter_supported(res->port_id,
9219 RTE_ETH_FILTER_SYN);
9221 printf("syn filter is not supported on port %u.\n",
9226 memset(&syn_filter, 0, sizeof(syn_filter));
9228 if (!strcmp(res->ops, "add")) {
9229 if (!strcmp(res->high, "high"))
9230 syn_filter.hig_pri = 1;
9232 syn_filter.hig_pri = 0;
9234 syn_filter.queue = res->queue_id;
9235 ret = rte_eth_dev_filter_ctrl(res->port_id,
9240 ret = rte_eth_dev_filter_ctrl(res->port_id,
9242 RTE_ETH_FILTER_DELETE,
9246 printf("syn filter programming error: (%s)\n",
9250 cmdline_parse_token_string_t cmd_syn_filter_filter =
9251 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9252 filter, "syn_filter");
9253 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9254 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9256 cmdline_parse_token_string_t cmd_syn_filter_ops =
9257 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9259 cmdline_parse_token_string_t cmd_syn_filter_priority =
9260 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9261 priority, "priority");
9262 cmdline_parse_token_string_t cmd_syn_filter_high =
9263 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9265 cmdline_parse_token_string_t cmd_syn_filter_queue =
9266 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9268 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9269 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9272 cmdline_parse_inst_t cmd_syn_filter = {
9273 .f = cmd_syn_filter_parsed,
9275 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9276 "<queue_id>: Add/Delete syn filter",
9278 (void *)&cmd_syn_filter_filter,
9279 (void *)&cmd_syn_filter_port_id,
9280 (void *)&cmd_syn_filter_ops,
9281 (void *)&cmd_syn_filter_priority,
9282 (void *)&cmd_syn_filter_high,
9283 (void *)&cmd_syn_filter_queue,
9284 (void *)&cmd_syn_filter_queue_id,
9289 /* *** queue region set *** */
9290 struct cmd_queue_region_result {
9291 cmdline_fixed_string_t set;
9292 cmdline_fixed_string_t port;
9294 cmdline_fixed_string_t cmd;
9295 cmdline_fixed_string_t region;
9297 cmdline_fixed_string_t queue_start_index;
9299 cmdline_fixed_string_t queue_num;
9300 uint8_t queue_num_value;
9304 cmd_queue_region_parsed(void *parsed_result,
9305 __attribute__((unused)) struct cmdline *cl,
9306 __attribute__((unused)) void *data)
9308 struct cmd_queue_region_result *res = parsed_result;
9310 #ifdef RTE_LIBRTE_I40E_PMD
9311 struct rte_pmd_i40e_queue_region_conf region_conf;
9312 enum rte_pmd_i40e_queue_region_op op_type;
9315 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9318 #ifdef RTE_LIBRTE_I40E_PMD
9319 memset(®ion_conf, 0, sizeof(region_conf));
9320 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9321 region_conf.region_id = res->region_id;
9322 region_conf.queue_num = res->queue_num_value;
9323 region_conf.queue_start_index = res->queue_id;
9325 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9326 op_type, ®ion_conf);
9333 printf("function not implemented or supported\n");
9336 printf("queue region config error: (%s)\n", strerror(-ret));
9340 cmdline_parse_token_string_t cmd_queue_region_set =
9341 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9343 cmdline_parse_token_string_t cmd_queue_region_port =
9344 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9345 cmdline_parse_token_num_t cmd_queue_region_port_id =
9346 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9348 cmdline_parse_token_string_t cmd_queue_region_cmd =
9349 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9350 cmd, "queue-region");
9351 cmdline_parse_token_string_t cmd_queue_region_id =
9352 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9353 region, "region_id");
9354 cmdline_parse_token_num_t cmd_queue_region_index =
9355 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9357 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9358 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9359 queue_start_index, "queue_start_index");
9360 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9361 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9363 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9364 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9365 queue_num, "queue_num");
9366 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9367 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9368 queue_num_value, UINT8);
9370 cmdline_parse_inst_t cmd_queue_region = {
9371 .f = cmd_queue_region_parsed,
9373 .help_str = "set port <port_id> queue-region region_id <value> "
9374 "queue_start_index <value> queue_num <value>: Set a queue region",
9376 (void *)&cmd_queue_region_set,
9377 (void *)&cmd_queue_region_port,
9378 (void *)&cmd_queue_region_port_id,
9379 (void *)&cmd_queue_region_cmd,
9380 (void *)&cmd_queue_region_id,
9381 (void *)&cmd_queue_region_index,
9382 (void *)&cmd_queue_region_queue_start_index,
9383 (void *)&cmd_queue_region_queue_id,
9384 (void *)&cmd_queue_region_queue_num,
9385 (void *)&cmd_queue_region_queue_num_value,
9390 /* *** queue region and flowtype set *** */
9391 struct cmd_region_flowtype_result {
9392 cmdline_fixed_string_t set;
9393 cmdline_fixed_string_t port;
9395 cmdline_fixed_string_t cmd;
9396 cmdline_fixed_string_t region;
9398 cmdline_fixed_string_t flowtype;
9399 uint8_t flowtype_id;
9403 cmd_region_flowtype_parsed(void *parsed_result,
9404 __attribute__((unused)) struct cmdline *cl,
9405 __attribute__((unused)) void *data)
9407 struct cmd_region_flowtype_result *res = parsed_result;
9409 #ifdef RTE_LIBRTE_I40E_PMD
9410 struct rte_pmd_i40e_queue_region_conf region_conf;
9411 enum rte_pmd_i40e_queue_region_op op_type;
9414 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9417 #ifdef RTE_LIBRTE_I40E_PMD
9418 memset(®ion_conf, 0, sizeof(region_conf));
9420 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9421 region_conf.region_id = res->region_id;
9422 region_conf.hw_flowtype = res->flowtype_id;
9424 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9425 op_type, ®ion_conf);
9432 printf("function not implemented or supported\n");
9435 printf("region flowtype config error: (%s)\n", strerror(-ret));
9439 cmdline_parse_token_string_t cmd_region_flowtype_set =
9440 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9442 cmdline_parse_token_string_t cmd_region_flowtype_port =
9443 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9445 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9446 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9448 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9449 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9450 cmd, "queue-region");
9451 cmdline_parse_token_string_t cmd_region_flowtype_index =
9452 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9453 region, "region_id");
9454 cmdline_parse_token_num_t cmd_region_flowtype_id =
9455 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9457 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9458 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9459 flowtype, "flowtype");
9460 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9461 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9462 flowtype_id, UINT8);
9463 cmdline_parse_inst_t cmd_region_flowtype = {
9464 .f = cmd_region_flowtype_parsed,
9466 .help_str = "set port <port_id> queue-region region_id <value> "
9467 "flowtype <value>: Set a flowtype region index",
9469 (void *)&cmd_region_flowtype_set,
9470 (void *)&cmd_region_flowtype_port,
9471 (void *)&cmd_region_flowtype_port_index,
9472 (void *)&cmd_region_flowtype_cmd,
9473 (void *)&cmd_region_flowtype_index,
9474 (void *)&cmd_region_flowtype_id,
9475 (void *)&cmd_region_flowtype_flow_index,
9476 (void *)&cmd_region_flowtype_flow_id,
9481 /* *** User Priority (UP) to queue region (region_id) set *** */
9482 struct cmd_user_priority_region_result {
9483 cmdline_fixed_string_t set;
9484 cmdline_fixed_string_t port;
9486 cmdline_fixed_string_t cmd;
9487 cmdline_fixed_string_t user_priority;
9488 uint8_t user_priority_id;
9489 cmdline_fixed_string_t region;
9494 cmd_user_priority_region_parsed(void *parsed_result,
9495 __attribute__((unused)) struct cmdline *cl,
9496 __attribute__((unused)) void *data)
9498 struct cmd_user_priority_region_result *res = parsed_result;
9500 #ifdef RTE_LIBRTE_I40E_PMD
9501 struct rte_pmd_i40e_queue_region_conf region_conf;
9502 enum rte_pmd_i40e_queue_region_op op_type;
9505 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9508 #ifdef RTE_LIBRTE_I40E_PMD
9509 memset(®ion_conf, 0, sizeof(region_conf));
9510 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9511 region_conf.user_priority = res->user_priority_id;
9512 region_conf.region_id = res->region_id;
9514 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9515 op_type, ®ion_conf);
9522 printf("function not implemented or supported\n");
9525 printf("user_priority region config error: (%s)\n",
9530 cmdline_parse_token_string_t cmd_user_priority_region_set =
9531 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9533 cmdline_parse_token_string_t cmd_user_priority_region_port =
9534 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9536 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9537 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9539 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9540 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9541 cmd, "queue-region");
9542 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9543 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9544 user_priority, "UP");
9545 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9546 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9547 user_priority_id, UINT8);
9548 cmdline_parse_token_string_t cmd_user_priority_region_region =
9549 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9550 region, "region_id");
9551 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9552 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9555 cmdline_parse_inst_t cmd_user_priority_region = {
9556 .f = cmd_user_priority_region_parsed,
9558 .help_str = "set port <port_id> queue-region UP <value> "
9559 "region_id <value>: Set the mapping of User Priority (UP) "
9560 "to queue region (region_id) ",
9562 (void *)&cmd_user_priority_region_set,
9563 (void *)&cmd_user_priority_region_port,
9564 (void *)&cmd_user_priority_region_port_index,
9565 (void *)&cmd_user_priority_region_cmd,
9566 (void *)&cmd_user_priority_region_UP,
9567 (void *)&cmd_user_priority_region_UP_id,
9568 (void *)&cmd_user_priority_region_region,
9569 (void *)&cmd_user_priority_region_region_id,
9574 /* *** flush all queue region related configuration *** */
9575 struct cmd_flush_queue_region_result {
9576 cmdline_fixed_string_t set;
9577 cmdline_fixed_string_t port;
9579 cmdline_fixed_string_t cmd;
9580 cmdline_fixed_string_t flush;
9581 cmdline_fixed_string_t what;
9585 cmd_flush_queue_region_parsed(void *parsed_result,
9586 __attribute__((unused)) struct cmdline *cl,
9587 __attribute__((unused)) void *data)
9589 struct cmd_flush_queue_region_result *res = parsed_result;
9591 #ifdef RTE_LIBRTE_I40E_PMD
9592 struct rte_pmd_i40e_queue_region_conf region_conf;
9593 enum rte_pmd_i40e_queue_region_op op_type;
9596 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9599 #ifdef RTE_LIBRTE_I40E_PMD
9600 memset(®ion_conf, 0, sizeof(region_conf));
9602 if (strcmp(res->what, "on") == 0)
9603 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9605 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9607 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9608 op_type, ®ion_conf);
9615 printf("function not implemented or supported\n");
9618 printf("queue region config flush error: (%s)\n",
9623 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9624 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9626 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9627 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9629 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9630 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9632 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9633 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9634 cmd, "queue-region");
9635 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9636 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9638 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9639 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9642 cmdline_parse_inst_t cmd_flush_queue_region = {
9643 .f = cmd_flush_queue_region_parsed,
9645 .help_str = "set port <port_id> queue-region flush on|off"
9646 ": flush all queue region related configuration",
9648 (void *)&cmd_flush_queue_region_set,
9649 (void *)&cmd_flush_queue_region_port,
9650 (void *)&cmd_flush_queue_region_port_index,
9651 (void *)&cmd_flush_queue_region_cmd,
9652 (void *)&cmd_flush_queue_region_flush,
9653 (void *)&cmd_flush_queue_region_what,
9658 /* *** get all queue region related configuration info *** */
9659 struct cmd_show_queue_region_info {
9660 cmdline_fixed_string_t show;
9661 cmdline_fixed_string_t port;
9663 cmdline_fixed_string_t cmd;
9667 cmd_show_queue_region_info_parsed(void *parsed_result,
9668 __attribute__((unused)) struct cmdline *cl,
9669 __attribute__((unused)) void *data)
9671 struct cmd_show_queue_region_info *res = parsed_result;
9673 #ifdef RTE_LIBRTE_I40E_PMD
9674 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9675 enum rte_pmd_i40e_queue_region_op op_type;
9678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9681 #ifdef RTE_LIBRTE_I40E_PMD
9682 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9684 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9686 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9687 op_type, &rte_pmd_regions);
9689 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9696 printf("function not implemented or supported\n");
9699 printf("queue region config info show error: (%s)\n",
9704 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9705 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9707 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9708 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9710 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9711 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9713 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9714 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9715 cmd, "queue-region");
9717 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9718 .f = cmd_show_queue_region_info_parsed,
9720 .help_str = "show port <port_id> queue-region"
9721 ": show all queue region related configuration info",
9723 (void *)&cmd_show_queue_region_info_get,
9724 (void *)&cmd_show_queue_region_info_port,
9725 (void *)&cmd_show_queue_region_info_port_index,
9726 (void *)&cmd_show_queue_region_info_cmd,
9731 /* *** ADD/REMOVE A 2tuple FILTER *** */
9732 struct cmd_2tuple_filter_result {
9733 cmdline_fixed_string_t filter;
9735 cmdline_fixed_string_t ops;
9736 cmdline_fixed_string_t dst_port;
9737 uint16_t dst_port_value;
9738 cmdline_fixed_string_t protocol;
9739 uint8_t protocol_value;
9740 cmdline_fixed_string_t mask;
9742 cmdline_fixed_string_t tcp_flags;
9743 uint8_t tcp_flags_value;
9744 cmdline_fixed_string_t priority;
9745 uint8_t priority_value;
9746 cmdline_fixed_string_t queue;
9751 cmd_2tuple_filter_parsed(void *parsed_result,
9752 __attribute__((unused)) struct cmdline *cl,
9753 __attribute__((unused)) void *data)
9755 struct rte_eth_ntuple_filter filter;
9756 struct cmd_2tuple_filter_result *res = parsed_result;
9759 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9761 printf("ntuple filter is not supported on port %u.\n",
9766 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9768 filter.flags = RTE_2TUPLE_FLAGS;
9769 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9770 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9771 filter.proto = res->protocol_value;
9772 filter.priority = res->priority_value;
9773 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9774 printf("nonzero tcp_flags is only meaningful"
9775 " when protocol is TCP.\n");
9778 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9779 printf("invalid TCP flags.\n");
9783 if (res->tcp_flags_value != 0) {
9784 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9785 filter.tcp_flags = res->tcp_flags_value;
9788 /* need convert to big endian. */
9789 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9790 filter.queue = res->queue_id;
9792 if (!strcmp(res->ops, "add"))
9793 ret = rte_eth_dev_filter_ctrl(res->port_id,
9794 RTE_ETH_FILTER_NTUPLE,
9798 ret = rte_eth_dev_filter_ctrl(res->port_id,
9799 RTE_ETH_FILTER_NTUPLE,
9800 RTE_ETH_FILTER_DELETE,
9803 printf("2tuple filter programming error: (%s)\n",
9808 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9809 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9810 filter, "2tuple_filter");
9811 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9812 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9814 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9815 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9817 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9818 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9819 dst_port, "dst_port");
9820 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9821 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9822 dst_port_value, UINT16);
9823 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9824 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9825 protocol, "protocol");
9826 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9827 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9828 protocol_value, UINT8);
9829 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9830 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9832 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9833 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9835 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9836 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9837 tcp_flags, "tcp_flags");
9838 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9839 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9840 tcp_flags_value, UINT8);
9841 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9842 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9843 priority, "priority");
9844 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9845 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9846 priority_value, UINT8);
9847 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9848 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9850 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9851 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9854 cmdline_parse_inst_t cmd_2tuple_filter = {
9855 .f = cmd_2tuple_filter_parsed,
9857 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9858 "<value> mask <value> tcp_flags <value> priority <value> queue "
9859 "<queue_id>: Add a 2tuple filter",
9861 (void *)&cmd_2tuple_filter_filter,
9862 (void *)&cmd_2tuple_filter_port_id,
9863 (void *)&cmd_2tuple_filter_ops,
9864 (void *)&cmd_2tuple_filter_dst_port,
9865 (void *)&cmd_2tuple_filter_dst_port_value,
9866 (void *)&cmd_2tuple_filter_protocol,
9867 (void *)&cmd_2tuple_filter_protocol_value,
9868 (void *)&cmd_2tuple_filter_mask,
9869 (void *)&cmd_2tuple_filter_mask_value,
9870 (void *)&cmd_2tuple_filter_tcp_flags,
9871 (void *)&cmd_2tuple_filter_tcp_flags_value,
9872 (void *)&cmd_2tuple_filter_priority,
9873 (void *)&cmd_2tuple_filter_priority_value,
9874 (void *)&cmd_2tuple_filter_queue,
9875 (void *)&cmd_2tuple_filter_queue_id,
9880 /* *** ADD/REMOVE A 5tuple FILTER *** */
9881 struct cmd_5tuple_filter_result {
9882 cmdline_fixed_string_t filter;
9884 cmdline_fixed_string_t ops;
9885 cmdline_fixed_string_t dst_ip;
9886 cmdline_ipaddr_t dst_ip_value;
9887 cmdline_fixed_string_t src_ip;
9888 cmdline_ipaddr_t src_ip_value;
9889 cmdline_fixed_string_t dst_port;
9890 uint16_t dst_port_value;
9891 cmdline_fixed_string_t src_port;
9892 uint16_t src_port_value;
9893 cmdline_fixed_string_t protocol;
9894 uint8_t protocol_value;
9895 cmdline_fixed_string_t mask;
9897 cmdline_fixed_string_t tcp_flags;
9898 uint8_t tcp_flags_value;
9899 cmdline_fixed_string_t priority;
9900 uint8_t priority_value;
9901 cmdline_fixed_string_t queue;
9906 cmd_5tuple_filter_parsed(void *parsed_result,
9907 __attribute__((unused)) struct cmdline *cl,
9908 __attribute__((unused)) void *data)
9910 struct rte_eth_ntuple_filter filter;
9911 struct cmd_5tuple_filter_result *res = parsed_result;
9914 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9916 printf("ntuple filter is not supported on port %u.\n",
9921 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9923 filter.flags = RTE_5TUPLE_FLAGS;
9924 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9925 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9926 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9927 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9928 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9929 filter.proto = res->protocol_value;
9930 filter.priority = res->priority_value;
9931 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9932 printf("nonzero tcp_flags is only meaningful"
9933 " when protocol is TCP.\n");
9936 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9937 printf("invalid TCP flags.\n");
9941 if (res->tcp_flags_value != 0) {
9942 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9943 filter.tcp_flags = res->tcp_flags_value;
9946 if (res->dst_ip_value.family == AF_INET)
9947 /* no need to convert, already big endian. */
9948 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9950 if (filter.dst_ip_mask == 0) {
9951 printf("can not support ipv6 involved compare.\n");
9957 if (res->src_ip_value.family == AF_INET)
9958 /* no need to convert, already big endian. */
9959 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9961 if (filter.src_ip_mask == 0) {
9962 printf("can not support ipv6 involved compare.\n");
9967 /* need convert to big endian. */
9968 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9969 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9970 filter.queue = res->queue_id;
9972 if (!strcmp(res->ops, "add"))
9973 ret = rte_eth_dev_filter_ctrl(res->port_id,
9974 RTE_ETH_FILTER_NTUPLE,
9978 ret = rte_eth_dev_filter_ctrl(res->port_id,
9979 RTE_ETH_FILTER_NTUPLE,
9980 RTE_ETH_FILTER_DELETE,
9983 printf("5tuple filter programming error: (%s)\n",
9987 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9988 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9989 filter, "5tuple_filter");
9990 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9991 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9993 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9994 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9996 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9997 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9999 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10000 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10002 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10003 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10005 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10006 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10008 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10009 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10010 dst_port, "dst_port");
10011 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10012 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10013 dst_port_value, UINT16);
10014 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10015 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10016 src_port, "src_port");
10017 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10018 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10019 src_port_value, UINT16);
10020 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10021 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10022 protocol, "protocol");
10023 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10024 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10025 protocol_value, UINT8);
10026 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10027 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10029 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10030 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10032 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10033 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10034 tcp_flags, "tcp_flags");
10035 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10036 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10037 tcp_flags_value, UINT8);
10038 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10039 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10040 priority, "priority");
10041 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10042 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10043 priority_value, UINT8);
10044 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10045 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10047 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10048 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10051 cmdline_parse_inst_t cmd_5tuple_filter = {
10052 .f = cmd_5tuple_filter_parsed,
10054 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10055 "src_ip <value> dst_port <value> src_port <value> "
10056 "protocol <value> mask <value> tcp_flags <value> "
10057 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10059 (void *)&cmd_5tuple_filter_filter,
10060 (void *)&cmd_5tuple_filter_port_id,
10061 (void *)&cmd_5tuple_filter_ops,
10062 (void *)&cmd_5tuple_filter_dst_ip,
10063 (void *)&cmd_5tuple_filter_dst_ip_value,
10064 (void *)&cmd_5tuple_filter_src_ip,
10065 (void *)&cmd_5tuple_filter_src_ip_value,
10066 (void *)&cmd_5tuple_filter_dst_port,
10067 (void *)&cmd_5tuple_filter_dst_port_value,
10068 (void *)&cmd_5tuple_filter_src_port,
10069 (void *)&cmd_5tuple_filter_src_port_value,
10070 (void *)&cmd_5tuple_filter_protocol,
10071 (void *)&cmd_5tuple_filter_protocol_value,
10072 (void *)&cmd_5tuple_filter_mask,
10073 (void *)&cmd_5tuple_filter_mask_value,
10074 (void *)&cmd_5tuple_filter_tcp_flags,
10075 (void *)&cmd_5tuple_filter_tcp_flags_value,
10076 (void *)&cmd_5tuple_filter_priority,
10077 (void *)&cmd_5tuple_filter_priority_value,
10078 (void *)&cmd_5tuple_filter_queue,
10079 (void *)&cmd_5tuple_filter_queue_id,
10084 /* *** ADD/REMOVE A flex FILTER *** */
10085 struct cmd_flex_filter_result {
10086 cmdline_fixed_string_t filter;
10087 cmdline_fixed_string_t ops;
10089 cmdline_fixed_string_t len;
10091 cmdline_fixed_string_t bytes;
10092 cmdline_fixed_string_t bytes_value;
10093 cmdline_fixed_string_t mask;
10094 cmdline_fixed_string_t mask_value;
10095 cmdline_fixed_string_t priority;
10096 uint8_t priority_value;
10097 cmdline_fixed_string_t queue;
10101 static int xdigit2val(unsigned char c)
10106 else if (isupper(c))
10107 val = c - 'A' + 10;
10109 val = c - 'a' + 10;
10114 cmd_flex_filter_parsed(void *parsed_result,
10115 __attribute__((unused)) struct cmdline *cl,
10116 __attribute__((unused)) void *data)
10119 struct rte_eth_flex_filter filter;
10120 struct cmd_flex_filter_result *res = parsed_result;
10121 char *bytes_ptr, *mask_ptr;
10122 uint16_t len, i, j = 0;
10127 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10128 printf("the len exceed the max length 128\n");
10131 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10132 filter.len = res->len_value;
10133 filter.priority = res->priority_value;
10134 filter.queue = res->queue_id;
10135 bytes_ptr = res->bytes_value;
10136 mask_ptr = res->mask_value;
10138 /* translate bytes string to array. */
10139 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10140 (bytes_ptr[1] == 'X')))
10142 len = strnlen(bytes_ptr, res->len_value * 2);
10143 if (len == 0 || (len % 8 != 0)) {
10144 printf("please check len and bytes input\n");
10147 for (i = 0; i < len; i++) {
10149 if (isxdigit(c) == 0) {
10150 /* invalid characters. */
10151 printf("invalid input\n");
10154 val = xdigit2val(c);
10157 filter.bytes[j] = byte;
10158 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10165 /* translate mask string to uint8_t array. */
10166 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10167 (mask_ptr[1] == 'X')))
10169 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10171 printf("invalid input\n");
10176 for (i = 0; i < len; i++) {
10178 if (isxdigit(c) == 0) {
10179 /* invalid characters. */
10180 printf("invalid input\n");
10183 val = xdigit2val(c);
10186 filter.mask[j] = byte;
10187 printf("mask[%d]:%02x ", j, filter.mask[j]);
10195 if (!strcmp(res->ops, "add"))
10196 ret = rte_eth_dev_filter_ctrl(res->port_id,
10197 RTE_ETH_FILTER_FLEXIBLE,
10198 RTE_ETH_FILTER_ADD,
10201 ret = rte_eth_dev_filter_ctrl(res->port_id,
10202 RTE_ETH_FILTER_FLEXIBLE,
10203 RTE_ETH_FILTER_DELETE,
10207 printf("flex filter setting error: (%s)\n", strerror(-ret));
10210 cmdline_parse_token_string_t cmd_flex_filter_filter =
10211 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10212 filter, "flex_filter");
10213 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10214 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10216 cmdline_parse_token_string_t cmd_flex_filter_ops =
10217 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10219 cmdline_parse_token_string_t cmd_flex_filter_len =
10220 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10222 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10223 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10225 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10226 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10228 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10229 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10230 bytes_value, NULL);
10231 cmdline_parse_token_string_t cmd_flex_filter_mask =
10232 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10234 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10235 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10237 cmdline_parse_token_string_t cmd_flex_filter_priority =
10238 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10239 priority, "priority");
10240 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10241 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10242 priority_value, UINT8);
10243 cmdline_parse_token_string_t cmd_flex_filter_queue =
10244 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10246 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10247 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10249 cmdline_parse_inst_t cmd_flex_filter = {
10250 .f = cmd_flex_filter_parsed,
10252 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10253 "<value> mask <value> priority <value> queue <queue_id>: "
10254 "Add/Del a flex filter",
10256 (void *)&cmd_flex_filter_filter,
10257 (void *)&cmd_flex_filter_port_id,
10258 (void *)&cmd_flex_filter_ops,
10259 (void *)&cmd_flex_filter_len,
10260 (void *)&cmd_flex_filter_len_value,
10261 (void *)&cmd_flex_filter_bytes,
10262 (void *)&cmd_flex_filter_bytes_value,
10263 (void *)&cmd_flex_filter_mask,
10264 (void *)&cmd_flex_filter_mask_value,
10265 (void *)&cmd_flex_filter_priority,
10266 (void *)&cmd_flex_filter_priority_value,
10267 (void *)&cmd_flex_filter_queue,
10268 (void *)&cmd_flex_filter_queue_id,
10273 /* *** Filters Control *** */
10275 /* *** deal with ethertype filter *** */
10276 struct cmd_ethertype_filter_result {
10277 cmdline_fixed_string_t filter;
10279 cmdline_fixed_string_t ops;
10280 cmdline_fixed_string_t mac;
10281 struct ether_addr mac_addr;
10282 cmdline_fixed_string_t ethertype;
10283 uint16_t ethertype_value;
10284 cmdline_fixed_string_t drop;
10285 cmdline_fixed_string_t queue;
10289 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10290 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10291 filter, "ethertype_filter");
10292 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10293 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10295 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10296 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10298 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10299 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10300 mac, "mac_addr#mac_ignr");
10301 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10302 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10304 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10305 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10306 ethertype, "ethertype");
10307 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10308 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10309 ethertype_value, UINT16);
10310 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10311 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10313 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10314 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10316 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10317 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10321 cmd_ethertype_filter_parsed(void *parsed_result,
10322 __attribute__((unused)) struct cmdline *cl,
10323 __attribute__((unused)) void *data)
10325 struct cmd_ethertype_filter_result *res = parsed_result;
10326 struct rte_eth_ethertype_filter filter;
10329 ret = rte_eth_dev_filter_supported(res->port_id,
10330 RTE_ETH_FILTER_ETHERTYPE);
10332 printf("ethertype filter is not supported on port %u.\n",
10337 memset(&filter, 0, sizeof(filter));
10338 if (!strcmp(res->mac, "mac_addr")) {
10339 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10340 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10341 sizeof(struct ether_addr));
10343 if (!strcmp(res->drop, "drop"))
10344 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10345 filter.ether_type = res->ethertype_value;
10346 filter.queue = res->queue_id;
10348 if (!strcmp(res->ops, "add"))
10349 ret = rte_eth_dev_filter_ctrl(res->port_id,
10350 RTE_ETH_FILTER_ETHERTYPE,
10351 RTE_ETH_FILTER_ADD,
10354 ret = rte_eth_dev_filter_ctrl(res->port_id,
10355 RTE_ETH_FILTER_ETHERTYPE,
10356 RTE_ETH_FILTER_DELETE,
10359 printf("ethertype filter programming error: (%s)\n",
10363 cmdline_parse_inst_t cmd_ethertype_filter = {
10364 .f = cmd_ethertype_filter_parsed,
10366 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10367 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10368 "Add or delete an ethertype filter entry",
10370 (void *)&cmd_ethertype_filter_filter,
10371 (void *)&cmd_ethertype_filter_port_id,
10372 (void *)&cmd_ethertype_filter_ops,
10373 (void *)&cmd_ethertype_filter_mac,
10374 (void *)&cmd_ethertype_filter_mac_addr,
10375 (void *)&cmd_ethertype_filter_ethertype,
10376 (void *)&cmd_ethertype_filter_ethertype_value,
10377 (void *)&cmd_ethertype_filter_drop,
10378 (void *)&cmd_ethertype_filter_queue,
10379 (void *)&cmd_ethertype_filter_queue_id,
10384 /* *** deal with flow director filter *** */
10385 struct cmd_flow_director_result {
10386 cmdline_fixed_string_t flow_director_filter;
10388 cmdline_fixed_string_t mode;
10389 cmdline_fixed_string_t mode_value;
10390 cmdline_fixed_string_t ops;
10391 cmdline_fixed_string_t flow;
10392 cmdline_fixed_string_t flow_type;
10393 cmdline_fixed_string_t ether;
10394 uint16_t ether_type;
10395 cmdline_fixed_string_t src;
10396 cmdline_ipaddr_t ip_src;
10398 cmdline_fixed_string_t dst;
10399 cmdline_ipaddr_t ip_dst;
10401 cmdline_fixed_string_t verify_tag;
10402 uint32_t verify_tag_value;
10403 cmdline_fixed_string_t tos;
10405 cmdline_fixed_string_t proto;
10406 uint8_t proto_value;
10407 cmdline_fixed_string_t ttl;
10409 cmdline_fixed_string_t vlan;
10410 uint16_t vlan_value;
10411 cmdline_fixed_string_t flexbytes;
10412 cmdline_fixed_string_t flexbytes_value;
10413 cmdline_fixed_string_t pf_vf;
10414 cmdline_fixed_string_t drop;
10415 cmdline_fixed_string_t queue;
10417 cmdline_fixed_string_t fd_id;
10418 uint32_t fd_id_value;
10419 cmdline_fixed_string_t mac;
10420 struct ether_addr mac_addr;
10421 cmdline_fixed_string_t tunnel;
10422 cmdline_fixed_string_t tunnel_type;
10423 cmdline_fixed_string_t tunnel_id;
10424 uint32_t tunnel_id_value;
10425 cmdline_fixed_string_t packet;
10430 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10433 const char *p, *p0 = q_arg;
10435 unsigned long int_fld;
10436 char *str_fld[max_num];
10441 p = strchr(p0, '(');
10445 p0 = strchr(p, ')');
10450 if (size >= sizeof(s))
10453 snprintf(s, sizeof(s), "%.*s", size, p);
10454 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10455 if (ret < 0 || ret > max_num)
10457 for (i = 0; i < ret; i++) {
10459 int_fld = strtoul(str_fld[i], &end, 0);
10460 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10462 flexbytes[i] = (uint8_t)int_fld;
10468 str2flowtype(char *string)
10471 static const struct {
10474 } flowtype_str[] = {
10475 {"raw", RTE_ETH_FLOW_RAW},
10476 {"ipv4", RTE_ETH_FLOW_IPV4},
10477 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10478 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10479 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10480 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10481 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10482 {"ipv6", RTE_ETH_FLOW_IPV6},
10483 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10484 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10485 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10486 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10487 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10488 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10491 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10492 if (!strcmp(flowtype_str[i].str, string))
10493 return flowtype_str[i].type;
10496 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10497 return (uint16_t)atoi(string);
10499 return RTE_ETH_FLOW_UNKNOWN;
10502 static enum rte_eth_fdir_tunnel_type
10503 str2fdir_tunneltype(char *string)
10507 static const struct {
10509 enum rte_eth_fdir_tunnel_type type;
10510 } tunneltype_str[] = {
10511 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10512 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10515 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10516 if (!strcmp(tunneltype_str[i].str, string))
10517 return tunneltype_str[i].type;
10519 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10522 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10524 if ((ip_addr).family == AF_INET) \
10525 (ip) = (ip_addr).addr.ipv4.s_addr; \
10527 printf("invalid parameter.\n"); \
10532 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10534 if ((ip_addr).family == AF_INET6) \
10535 rte_memcpy(&(ip), \
10536 &((ip_addr).addr.ipv6), \
10537 sizeof(struct in6_addr)); \
10539 printf("invalid parameter.\n"); \
10545 cmd_flow_director_filter_parsed(void *parsed_result,
10546 __attribute__((unused)) struct cmdline *cl,
10547 __attribute__((unused)) void *data)
10549 struct cmd_flow_director_result *res = parsed_result;
10550 struct rte_eth_fdir_filter entry;
10551 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10553 unsigned long vf_id;
10556 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10558 printf("flow director is not supported on port %u.\n",
10562 memset(flexbytes, 0, sizeof(flexbytes));
10563 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10565 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10566 if (strcmp(res->mode_value, "MAC-VLAN")) {
10567 printf("Please set mode to MAC-VLAN.\n");
10570 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10571 if (strcmp(res->mode_value, "Tunnel")) {
10572 printf("Please set mode to Tunnel.\n");
10576 if (!strcmp(res->mode_value, "raw")) {
10577 #ifdef RTE_LIBRTE_I40E_PMD
10578 struct rte_pmd_i40e_flow_type_mapping
10579 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10580 struct rte_pmd_i40e_pkt_template_conf conf;
10581 uint16_t flow_type = str2flowtype(res->flow_type);
10582 uint16_t i, port = res->port_id;
10585 memset(&conf, 0, sizeof(conf));
10587 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10588 printf("Invalid flow type specified.\n");
10591 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10595 if (mapping[flow_type].pctype == 0ULL) {
10596 printf("Invalid flow type specified.\n");
10599 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10600 if (mapping[flow_type].pctype & (1ULL << i)) {
10601 conf.input.pctype = i;
10606 conf.input.packet = open_file(res->filepath,
10607 &conf.input.length);
10608 if (!conf.input.packet)
10610 if (!strcmp(res->drop, "drop"))
10611 conf.action.behavior =
10612 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10614 conf.action.behavior =
10615 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10616 conf.action.report_status =
10617 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10618 conf.action.rx_queue = res->queue_id;
10619 conf.soft_id = res->fd_id_value;
10620 add = strcmp(res->ops, "del") ? 1 : 0;
10621 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10625 printf("flow director config error: (%s)\n",
10627 close_file(conf.input.packet);
10630 } else if (strcmp(res->mode_value, "IP")) {
10631 printf("Please set mode to IP or raw.\n");
10634 entry.input.flow_type = str2flowtype(res->flow_type);
10637 ret = parse_flexbytes(res->flexbytes_value,
10639 RTE_ETH_FDIR_MAX_FLEXLEN);
10641 printf("error: Cannot parse flexbytes input.\n");
10645 switch (entry.input.flow_type) {
10646 case RTE_ETH_FLOW_FRAG_IPV4:
10647 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10648 entry.input.flow.ip4_flow.proto = res->proto_value;
10650 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10651 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10652 IPV4_ADDR_TO_UINT(res->ip_dst,
10653 entry.input.flow.ip4_flow.dst_ip);
10654 IPV4_ADDR_TO_UINT(res->ip_src,
10655 entry.input.flow.ip4_flow.src_ip);
10656 entry.input.flow.ip4_flow.tos = res->tos_value;
10657 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10658 /* need convert to big endian. */
10659 entry.input.flow.udp4_flow.dst_port =
10660 rte_cpu_to_be_16(res->port_dst);
10661 entry.input.flow.udp4_flow.src_port =
10662 rte_cpu_to_be_16(res->port_src);
10664 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10665 IPV4_ADDR_TO_UINT(res->ip_dst,
10666 entry.input.flow.sctp4_flow.ip.dst_ip);
10667 IPV4_ADDR_TO_UINT(res->ip_src,
10668 entry.input.flow.sctp4_flow.ip.src_ip);
10669 entry.input.flow.ip4_flow.tos = res->tos_value;
10670 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10671 /* need convert to big endian. */
10672 entry.input.flow.sctp4_flow.dst_port =
10673 rte_cpu_to_be_16(res->port_dst);
10674 entry.input.flow.sctp4_flow.src_port =
10675 rte_cpu_to_be_16(res->port_src);
10676 entry.input.flow.sctp4_flow.verify_tag =
10677 rte_cpu_to_be_32(res->verify_tag_value);
10679 case RTE_ETH_FLOW_FRAG_IPV6:
10680 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10681 entry.input.flow.ipv6_flow.proto = res->proto_value;
10683 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10684 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10685 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10686 entry.input.flow.ipv6_flow.dst_ip);
10687 IPV6_ADDR_TO_ARRAY(res->ip_src,
10688 entry.input.flow.ipv6_flow.src_ip);
10689 entry.input.flow.ipv6_flow.tc = res->tos_value;
10690 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10691 /* need convert to big endian. */
10692 entry.input.flow.udp6_flow.dst_port =
10693 rte_cpu_to_be_16(res->port_dst);
10694 entry.input.flow.udp6_flow.src_port =
10695 rte_cpu_to_be_16(res->port_src);
10697 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10698 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10699 entry.input.flow.sctp6_flow.ip.dst_ip);
10700 IPV6_ADDR_TO_ARRAY(res->ip_src,
10701 entry.input.flow.sctp6_flow.ip.src_ip);
10702 entry.input.flow.ipv6_flow.tc = res->tos_value;
10703 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10704 /* need convert to big endian. */
10705 entry.input.flow.sctp6_flow.dst_port =
10706 rte_cpu_to_be_16(res->port_dst);
10707 entry.input.flow.sctp6_flow.src_port =
10708 rte_cpu_to_be_16(res->port_src);
10709 entry.input.flow.sctp6_flow.verify_tag =
10710 rte_cpu_to_be_32(res->verify_tag_value);
10712 case RTE_ETH_FLOW_L2_PAYLOAD:
10713 entry.input.flow.l2_flow.ether_type =
10714 rte_cpu_to_be_16(res->ether_type);
10720 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10721 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10723 sizeof(struct ether_addr));
10725 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10726 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10728 sizeof(struct ether_addr));
10729 entry.input.flow.tunnel_flow.tunnel_type =
10730 str2fdir_tunneltype(res->tunnel_type);
10731 entry.input.flow.tunnel_flow.tunnel_id =
10732 rte_cpu_to_be_32(res->tunnel_id_value);
10735 rte_memcpy(entry.input.flow_ext.flexbytes,
10737 RTE_ETH_FDIR_MAX_FLEXLEN);
10739 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10741 entry.action.flex_off = 0; /*use 0 by default */
10742 if (!strcmp(res->drop, "drop"))
10743 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10745 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10747 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10748 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10749 if (!strcmp(res->pf_vf, "pf"))
10750 entry.input.flow_ext.is_vf = 0;
10751 else if (!strncmp(res->pf_vf, "vf", 2)) {
10752 struct rte_eth_dev_info dev_info;
10754 memset(&dev_info, 0, sizeof(dev_info));
10755 rte_eth_dev_info_get(res->port_id, &dev_info);
10757 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10758 if (errno != 0 || *end != '\0' ||
10759 vf_id >= dev_info.max_vfs) {
10760 printf("invalid parameter %s.\n", res->pf_vf);
10763 entry.input.flow_ext.is_vf = 1;
10764 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10766 printf("invalid parameter %s.\n", res->pf_vf);
10771 /* set to report FD ID by default */
10772 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10773 entry.action.rx_queue = res->queue_id;
10774 entry.soft_id = res->fd_id_value;
10775 if (!strcmp(res->ops, "add"))
10776 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10777 RTE_ETH_FILTER_ADD, &entry);
10778 else if (!strcmp(res->ops, "del"))
10779 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10780 RTE_ETH_FILTER_DELETE, &entry);
10782 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10783 RTE_ETH_FILTER_UPDATE, &entry);
10785 printf("flow director programming error: (%s)\n",
10789 cmdline_parse_token_string_t cmd_flow_director_filter =
10790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10791 flow_director_filter, "flow_director_filter");
10792 cmdline_parse_token_num_t cmd_flow_director_port_id =
10793 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10795 cmdline_parse_token_string_t cmd_flow_director_ops =
10796 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10797 ops, "add#del#update");
10798 cmdline_parse_token_string_t cmd_flow_director_flow =
10799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10801 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10802 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10804 cmdline_parse_token_string_t cmd_flow_director_ether =
10805 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10807 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10808 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10809 ether_type, UINT16);
10810 cmdline_parse_token_string_t cmd_flow_director_src =
10811 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10813 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10814 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10816 cmdline_parse_token_num_t cmd_flow_director_port_src =
10817 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10819 cmdline_parse_token_string_t cmd_flow_director_dst =
10820 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10822 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10823 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10825 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10826 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10828 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10829 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10830 verify_tag, "verify_tag");
10831 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10832 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10833 verify_tag_value, UINT32);
10834 cmdline_parse_token_string_t cmd_flow_director_tos =
10835 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10837 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10838 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10840 cmdline_parse_token_string_t cmd_flow_director_proto =
10841 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10843 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10844 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10845 proto_value, UINT8);
10846 cmdline_parse_token_string_t cmd_flow_director_ttl =
10847 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10849 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10850 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10852 cmdline_parse_token_string_t cmd_flow_director_vlan =
10853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10855 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10856 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10857 vlan_value, UINT16);
10858 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10860 flexbytes, "flexbytes");
10861 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10863 flexbytes_value, NULL);
10864 cmdline_parse_token_string_t cmd_flow_director_drop =
10865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10867 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10870 cmdline_parse_token_string_t cmd_flow_director_queue =
10871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10873 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10874 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10876 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10877 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10879 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10880 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10881 fd_id_value, UINT32);
10883 cmdline_parse_token_string_t cmd_flow_director_mode =
10884 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10886 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10887 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10889 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10890 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10891 mode_value, "MAC-VLAN");
10892 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10893 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10894 mode_value, "Tunnel");
10895 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10896 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10897 mode_value, "raw");
10898 cmdline_parse_token_string_t cmd_flow_director_mac =
10899 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10901 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10902 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10904 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10905 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10907 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10908 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10909 tunnel_type, "NVGRE#VxLAN");
10910 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10911 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10912 tunnel_id, "tunnel-id");
10913 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10914 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10915 tunnel_id_value, UINT32);
10916 cmdline_parse_token_string_t cmd_flow_director_packet =
10917 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10919 cmdline_parse_token_string_t cmd_flow_director_filepath =
10920 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10923 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10924 .f = cmd_flow_director_filter_parsed,
10926 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10927 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10928 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10929 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10930 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10931 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10932 "fd_id <fd_id_value>: "
10933 "Add or delete an ip flow director entry on NIC",
10935 (void *)&cmd_flow_director_filter,
10936 (void *)&cmd_flow_director_port_id,
10937 (void *)&cmd_flow_director_mode,
10938 (void *)&cmd_flow_director_mode_ip,
10939 (void *)&cmd_flow_director_ops,
10940 (void *)&cmd_flow_director_flow,
10941 (void *)&cmd_flow_director_flow_type,
10942 (void *)&cmd_flow_director_src,
10943 (void *)&cmd_flow_director_ip_src,
10944 (void *)&cmd_flow_director_dst,
10945 (void *)&cmd_flow_director_ip_dst,
10946 (void *)&cmd_flow_director_tos,
10947 (void *)&cmd_flow_director_tos_value,
10948 (void *)&cmd_flow_director_proto,
10949 (void *)&cmd_flow_director_proto_value,
10950 (void *)&cmd_flow_director_ttl,
10951 (void *)&cmd_flow_director_ttl_value,
10952 (void *)&cmd_flow_director_vlan,
10953 (void *)&cmd_flow_director_vlan_value,
10954 (void *)&cmd_flow_director_flexbytes,
10955 (void *)&cmd_flow_director_flexbytes_value,
10956 (void *)&cmd_flow_director_drop,
10957 (void *)&cmd_flow_director_pf_vf,
10958 (void *)&cmd_flow_director_queue,
10959 (void *)&cmd_flow_director_queue_id,
10960 (void *)&cmd_flow_director_fd_id,
10961 (void *)&cmd_flow_director_fd_id_value,
10966 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10967 .f = cmd_flow_director_filter_parsed,
10969 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10970 "director entry on NIC",
10972 (void *)&cmd_flow_director_filter,
10973 (void *)&cmd_flow_director_port_id,
10974 (void *)&cmd_flow_director_mode,
10975 (void *)&cmd_flow_director_mode_ip,
10976 (void *)&cmd_flow_director_ops,
10977 (void *)&cmd_flow_director_flow,
10978 (void *)&cmd_flow_director_flow_type,
10979 (void *)&cmd_flow_director_src,
10980 (void *)&cmd_flow_director_ip_src,
10981 (void *)&cmd_flow_director_port_src,
10982 (void *)&cmd_flow_director_dst,
10983 (void *)&cmd_flow_director_ip_dst,
10984 (void *)&cmd_flow_director_port_dst,
10985 (void *)&cmd_flow_director_tos,
10986 (void *)&cmd_flow_director_tos_value,
10987 (void *)&cmd_flow_director_ttl,
10988 (void *)&cmd_flow_director_ttl_value,
10989 (void *)&cmd_flow_director_vlan,
10990 (void *)&cmd_flow_director_vlan_value,
10991 (void *)&cmd_flow_director_flexbytes,
10992 (void *)&cmd_flow_director_flexbytes_value,
10993 (void *)&cmd_flow_director_drop,
10994 (void *)&cmd_flow_director_pf_vf,
10995 (void *)&cmd_flow_director_queue,
10996 (void *)&cmd_flow_director_queue_id,
10997 (void *)&cmd_flow_director_fd_id,
10998 (void *)&cmd_flow_director_fd_id_value,
11003 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11004 .f = cmd_flow_director_filter_parsed,
11006 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11007 "director entry on NIC",
11009 (void *)&cmd_flow_director_filter,
11010 (void *)&cmd_flow_director_port_id,
11011 (void *)&cmd_flow_director_mode,
11012 (void *)&cmd_flow_director_mode_ip,
11013 (void *)&cmd_flow_director_ops,
11014 (void *)&cmd_flow_director_flow,
11015 (void *)&cmd_flow_director_flow_type,
11016 (void *)&cmd_flow_director_src,
11017 (void *)&cmd_flow_director_ip_src,
11018 (void *)&cmd_flow_director_port_src,
11019 (void *)&cmd_flow_director_dst,
11020 (void *)&cmd_flow_director_ip_dst,
11021 (void *)&cmd_flow_director_port_dst,
11022 (void *)&cmd_flow_director_verify_tag,
11023 (void *)&cmd_flow_director_verify_tag_value,
11024 (void *)&cmd_flow_director_tos,
11025 (void *)&cmd_flow_director_tos_value,
11026 (void *)&cmd_flow_director_ttl,
11027 (void *)&cmd_flow_director_ttl_value,
11028 (void *)&cmd_flow_director_vlan,
11029 (void *)&cmd_flow_director_vlan_value,
11030 (void *)&cmd_flow_director_flexbytes,
11031 (void *)&cmd_flow_director_flexbytes_value,
11032 (void *)&cmd_flow_director_drop,
11033 (void *)&cmd_flow_director_pf_vf,
11034 (void *)&cmd_flow_director_queue,
11035 (void *)&cmd_flow_director_queue_id,
11036 (void *)&cmd_flow_director_fd_id,
11037 (void *)&cmd_flow_director_fd_id_value,
11042 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11043 .f = cmd_flow_director_filter_parsed,
11045 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11046 "director entry on NIC",
11048 (void *)&cmd_flow_director_filter,
11049 (void *)&cmd_flow_director_port_id,
11050 (void *)&cmd_flow_director_mode,
11051 (void *)&cmd_flow_director_mode_ip,
11052 (void *)&cmd_flow_director_ops,
11053 (void *)&cmd_flow_director_flow,
11054 (void *)&cmd_flow_director_flow_type,
11055 (void *)&cmd_flow_director_ether,
11056 (void *)&cmd_flow_director_ether_type,
11057 (void *)&cmd_flow_director_flexbytes,
11058 (void *)&cmd_flow_director_flexbytes_value,
11059 (void *)&cmd_flow_director_drop,
11060 (void *)&cmd_flow_director_pf_vf,
11061 (void *)&cmd_flow_director_queue,
11062 (void *)&cmd_flow_director_queue_id,
11063 (void *)&cmd_flow_director_fd_id,
11064 (void *)&cmd_flow_director_fd_id_value,
11069 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11070 .f = cmd_flow_director_filter_parsed,
11072 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11073 "director entry on NIC",
11075 (void *)&cmd_flow_director_filter,
11076 (void *)&cmd_flow_director_port_id,
11077 (void *)&cmd_flow_director_mode,
11078 (void *)&cmd_flow_director_mode_mac_vlan,
11079 (void *)&cmd_flow_director_ops,
11080 (void *)&cmd_flow_director_mac,
11081 (void *)&cmd_flow_director_mac_addr,
11082 (void *)&cmd_flow_director_vlan,
11083 (void *)&cmd_flow_director_vlan_value,
11084 (void *)&cmd_flow_director_flexbytes,
11085 (void *)&cmd_flow_director_flexbytes_value,
11086 (void *)&cmd_flow_director_drop,
11087 (void *)&cmd_flow_director_queue,
11088 (void *)&cmd_flow_director_queue_id,
11089 (void *)&cmd_flow_director_fd_id,
11090 (void *)&cmd_flow_director_fd_id_value,
11095 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11096 .f = cmd_flow_director_filter_parsed,
11098 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11099 "director entry on NIC",
11101 (void *)&cmd_flow_director_filter,
11102 (void *)&cmd_flow_director_port_id,
11103 (void *)&cmd_flow_director_mode,
11104 (void *)&cmd_flow_director_mode_tunnel,
11105 (void *)&cmd_flow_director_ops,
11106 (void *)&cmd_flow_director_mac,
11107 (void *)&cmd_flow_director_mac_addr,
11108 (void *)&cmd_flow_director_vlan,
11109 (void *)&cmd_flow_director_vlan_value,
11110 (void *)&cmd_flow_director_tunnel,
11111 (void *)&cmd_flow_director_tunnel_type,
11112 (void *)&cmd_flow_director_tunnel_id,
11113 (void *)&cmd_flow_director_tunnel_id_value,
11114 (void *)&cmd_flow_director_flexbytes,
11115 (void *)&cmd_flow_director_flexbytes_value,
11116 (void *)&cmd_flow_director_drop,
11117 (void *)&cmd_flow_director_queue,
11118 (void *)&cmd_flow_director_queue_id,
11119 (void *)&cmd_flow_director_fd_id,
11120 (void *)&cmd_flow_director_fd_id_value,
11125 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11126 .f = cmd_flow_director_filter_parsed,
11128 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11129 "director entry on NIC",
11131 (void *)&cmd_flow_director_filter,
11132 (void *)&cmd_flow_director_port_id,
11133 (void *)&cmd_flow_director_mode,
11134 (void *)&cmd_flow_director_mode_raw,
11135 (void *)&cmd_flow_director_ops,
11136 (void *)&cmd_flow_director_flow,
11137 (void *)&cmd_flow_director_flow_type,
11138 (void *)&cmd_flow_director_drop,
11139 (void *)&cmd_flow_director_queue,
11140 (void *)&cmd_flow_director_queue_id,
11141 (void *)&cmd_flow_director_fd_id,
11142 (void *)&cmd_flow_director_fd_id_value,
11143 (void *)&cmd_flow_director_packet,
11144 (void *)&cmd_flow_director_filepath,
11149 struct cmd_flush_flow_director_result {
11150 cmdline_fixed_string_t flush_flow_director;
11154 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11155 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11156 flush_flow_director, "flush_flow_director");
11157 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11158 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11162 cmd_flush_flow_director_parsed(void *parsed_result,
11163 __attribute__((unused)) struct cmdline *cl,
11164 __attribute__((unused)) void *data)
11166 struct cmd_flow_director_result *res = parsed_result;
11169 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11171 printf("flow director is not supported on port %u.\n",
11176 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11177 RTE_ETH_FILTER_FLUSH, NULL);
11179 printf("flow director table flushing error: (%s)\n",
11183 cmdline_parse_inst_t cmd_flush_flow_director = {
11184 .f = cmd_flush_flow_director_parsed,
11186 .help_str = "flush_flow_director <port_id>: "
11187 "Flush all flow director entries of a device on NIC",
11189 (void *)&cmd_flush_flow_director_flush,
11190 (void *)&cmd_flush_flow_director_port_id,
11195 /* *** deal with flow director mask *** */
11196 struct cmd_flow_director_mask_result {
11197 cmdline_fixed_string_t flow_director_mask;
11199 cmdline_fixed_string_t mode;
11200 cmdline_fixed_string_t mode_value;
11201 cmdline_fixed_string_t vlan;
11202 uint16_t vlan_mask;
11203 cmdline_fixed_string_t src_mask;
11204 cmdline_ipaddr_t ipv4_src;
11205 cmdline_ipaddr_t ipv6_src;
11207 cmdline_fixed_string_t dst_mask;
11208 cmdline_ipaddr_t ipv4_dst;
11209 cmdline_ipaddr_t ipv6_dst;
11211 cmdline_fixed_string_t mac;
11212 uint8_t mac_addr_byte_mask;
11213 cmdline_fixed_string_t tunnel_id;
11214 uint32_t tunnel_id_mask;
11215 cmdline_fixed_string_t tunnel_type;
11216 uint8_t tunnel_type_mask;
11220 cmd_flow_director_mask_parsed(void *parsed_result,
11221 __attribute__((unused)) struct cmdline *cl,
11222 __attribute__((unused)) void *data)
11224 struct cmd_flow_director_mask_result *res = parsed_result;
11225 struct rte_eth_fdir_masks *mask;
11226 struct rte_port *port;
11228 port = &ports[res->port_id];
11229 /** Check if the port is not started **/
11230 if (port->port_status != RTE_PORT_STOPPED) {
11231 printf("Please stop port %d first\n", res->port_id);
11235 mask = &port->dev_conf.fdir_conf.mask;
11237 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11238 if (strcmp(res->mode_value, "MAC-VLAN")) {
11239 printf("Please set mode to MAC-VLAN.\n");
11243 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11244 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11245 if (strcmp(res->mode_value, "Tunnel")) {
11246 printf("Please set mode to Tunnel.\n");
11250 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11251 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11252 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11253 mask->tunnel_type_mask = res->tunnel_type_mask;
11255 if (strcmp(res->mode_value, "IP")) {
11256 printf("Please set mode to IP.\n");
11260 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11261 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11262 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11263 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11264 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11265 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11266 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11269 cmd_reconfig_device_queue(res->port_id, 1, 1);
11272 cmdline_parse_token_string_t cmd_flow_director_mask =
11273 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11274 flow_director_mask, "flow_director_mask");
11275 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11276 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11278 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11279 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11281 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11282 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11283 vlan_mask, UINT16);
11284 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11286 src_mask, "src_mask");
11287 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11288 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11290 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11291 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11293 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11294 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11296 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11298 dst_mask, "dst_mask");
11299 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11300 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11302 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11303 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11305 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11306 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11309 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11312 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11313 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11315 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11316 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11317 mode_value, "MAC-VLAN");
11318 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11320 mode_value, "Tunnel");
11321 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11324 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11325 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11326 mac_addr_byte_mask, UINT8);
11327 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11329 tunnel_type, "tunnel-type");
11330 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11331 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11332 tunnel_type_mask, UINT8);
11333 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11335 tunnel_id, "tunnel-id");
11336 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11337 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11338 tunnel_id_mask, UINT32);
11340 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11341 .f = cmd_flow_director_mask_parsed,
11343 .help_str = "flow_director_mask ... : "
11344 "Set IP mode flow director's mask on NIC",
11346 (void *)&cmd_flow_director_mask,
11347 (void *)&cmd_flow_director_mask_port_id,
11348 (void *)&cmd_flow_director_mask_mode,
11349 (void *)&cmd_flow_director_mask_mode_ip,
11350 (void *)&cmd_flow_director_mask_vlan,
11351 (void *)&cmd_flow_director_mask_vlan_value,
11352 (void *)&cmd_flow_director_mask_src,
11353 (void *)&cmd_flow_director_mask_ipv4_src,
11354 (void *)&cmd_flow_director_mask_ipv6_src,
11355 (void *)&cmd_flow_director_mask_port_src,
11356 (void *)&cmd_flow_director_mask_dst,
11357 (void *)&cmd_flow_director_mask_ipv4_dst,
11358 (void *)&cmd_flow_director_mask_ipv6_dst,
11359 (void *)&cmd_flow_director_mask_port_dst,
11364 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11365 .f = cmd_flow_director_mask_parsed,
11367 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11368 "flow director's mask on NIC",
11370 (void *)&cmd_flow_director_mask,
11371 (void *)&cmd_flow_director_mask_port_id,
11372 (void *)&cmd_flow_director_mask_mode,
11373 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11374 (void *)&cmd_flow_director_mask_vlan,
11375 (void *)&cmd_flow_director_mask_vlan_value,
11380 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11381 .f = cmd_flow_director_mask_parsed,
11383 .help_str = "flow_director_mask ... : Set tunnel mode "
11384 "flow director's mask on NIC",
11386 (void *)&cmd_flow_director_mask,
11387 (void *)&cmd_flow_director_mask_port_id,
11388 (void *)&cmd_flow_director_mask_mode,
11389 (void *)&cmd_flow_director_mask_mode_tunnel,
11390 (void *)&cmd_flow_director_mask_vlan,
11391 (void *)&cmd_flow_director_mask_vlan_value,
11392 (void *)&cmd_flow_director_mask_mac,
11393 (void *)&cmd_flow_director_mask_mac_value,
11394 (void *)&cmd_flow_director_mask_tunnel_type,
11395 (void *)&cmd_flow_director_mask_tunnel_type_value,
11396 (void *)&cmd_flow_director_mask_tunnel_id,
11397 (void *)&cmd_flow_director_mask_tunnel_id_value,
11402 /* *** deal with flow director mask on flexible payload *** */
11403 struct cmd_flow_director_flex_mask_result {
11404 cmdline_fixed_string_t flow_director_flexmask;
11406 cmdline_fixed_string_t flow;
11407 cmdline_fixed_string_t flow_type;
11408 cmdline_fixed_string_t mask;
11412 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11413 __attribute__((unused)) struct cmdline *cl,
11414 __attribute__((unused)) void *data)
11416 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11417 struct rte_eth_fdir_info fdir_info;
11418 struct rte_eth_fdir_flex_mask flex_mask;
11419 struct rte_port *port;
11420 uint64_t flow_type_mask;
11424 port = &ports[res->port_id];
11425 /** Check if the port is not started **/
11426 if (port->port_status != RTE_PORT_STOPPED) {
11427 printf("Please stop port %d first\n", res->port_id);
11431 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11432 ret = parse_flexbytes(res->mask,
11434 RTE_ETH_FDIR_MAX_FLEXLEN);
11436 printf("error: Cannot parse mask input.\n");
11440 memset(&fdir_info, 0, sizeof(fdir_info));
11441 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11442 RTE_ETH_FILTER_INFO, &fdir_info);
11444 printf("Cannot get FDir filter info\n");
11448 if (!strcmp(res->flow_type, "none")) {
11449 /* means don't specify the flow type */
11450 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11451 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11452 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11453 0, sizeof(struct rte_eth_fdir_flex_mask));
11454 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11455 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11457 sizeof(struct rte_eth_fdir_flex_mask));
11458 cmd_reconfig_device_queue(res->port_id, 1, 1);
11461 flow_type_mask = fdir_info.flow_types_mask[0];
11462 if (!strcmp(res->flow_type, "all")) {
11463 if (!flow_type_mask) {
11464 printf("No flow type supported\n");
11467 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11468 if (flow_type_mask & (1ULL << i)) {
11469 flex_mask.flow_type = i;
11470 fdir_set_flex_mask(res->port_id, &flex_mask);
11473 cmd_reconfig_device_queue(res->port_id, 1, 1);
11476 flex_mask.flow_type = str2flowtype(res->flow_type);
11477 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11478 printf("Flow type %s not supported on port %d\n",
11479 res->flow_type, res->port_id);
11482 fdir_set_flex_mask(res->port_id, &flex_mask);
11483 cmd_reconfig_device_queue(res->port_id, 1, 1);
11486 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11487 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11488 flow_director_flexmask,
11489 "flow_director_flex_mask");
11490 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11491 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11493 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11494 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11496 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11497 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11498 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11499 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11500 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11501 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11504 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11505 .f = cmd_flow_director_flex_mask_parsed,
11507 .help_str = "flow_director_flex_mask ... : "
11508 "Set flow director's flex mask on NIC",
11510 (void *)&cmd_flow_director_flexmask,
11511 (void *)&cmd_flow_director_flexmask_port_id,
11512 (void *)&cmd_flow_director_flexmask_flow,
11513 (void *)&cmd_flow_director_flexmask_flow_type,
11514 (void *)&cmd_flow_director_flexmask_mask,
11519 /* *** deal with flow director flexible payload configuration *** */
11520 struct cmd_flow_director_flexpayload_result {
11521 cmdline_fixed_string_t flow_director_flexpayload;
11523 cmdline_fixed_string_t payload_layer;
11524 cmdline_fixed_string_t payload_cfg;
11528 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11531 const char *p, *p0 = q_arg;
11533 unsigned long int_fld;
11534 char *str_fld[max_num];
11539 p = strchr(p0, '(');
11543 p0 = strchr(p, ')');
11548 if (size >= sizeof(s))
11551 snprintf(s, sizeof(s), "%.*s", size, p);
11552 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11553 if (ret < 0 || ret > max_num)
11555 for (i = 0; i < ret; i++) {
11557 int_fld = strtoul(str_fld[i], &end, 0);
11558 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11560 offsets[i] = (uint16_t)int_fld;
11566 cmd_flow_director_flxpld_parsed(void *parsed_result,
11567 __attribute__((unused)) struct cmdline *cl,
11568 __attribute__((unused)) void *data)
11570 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11571 struct rte_eth_flex_payload_cfg flex_cfg;
11572 struct rte_port *port;
11575 port = &ports[res->port_id];
11576 /** Check if the port is not started **/
11577 if (port->port_status != RTE_PORT_STOPPED) {
11578 printf("Please stop port %d first\n", res->port_id);
11582 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11584 if (!strcmp(res->payload_layer, "raw"))
11585 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11586 else if (!strcmp(res->payload_layer, "l2"))
11587 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11588 else if (!strcmp(res->payload_layer, "l3"))
11589 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11590 else if (!strcmp(res->payload_layer, "l4"))
11591 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11593 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11594 RTE_ETH_FDIR_MAX_FLEXLEN);
11596 printf("error: Cannot parse flex payload input.\n");
11600 fdir_set_flex_payload(res->port_id, &flex_cfg);
11601 cmd_reconfig_device_queue(res->port_id, 1, 1);
11604 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11605 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11606 flow_director_flexpayload,
11607 "flow_director_flex_payload");
11608 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11609 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11611 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11612 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11613 payload_layer, "raw#l2#l3#l4");
11614 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11615 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11616 payload_cfg, NULL);
11618 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11619 .f = cmd_flow_director_flxpld_parsed,
11621 .help_str = "flow_director_flexpayload ... : "
11622 "Set flow director's flex payload on NIC",
11624 (void *)&cmd_flow_director_flexpayload,
11625 (void *)&cmd_flow_director_flexpayload_port_id,
11626 (void *)&cmd_flow_director_flexpayload_payload_layer,
11627 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11632 /* Generic flow interface command. */
11633 extern cmdline_parse_inst_t cmd_flow;
11635 /* *** Classification Filters Control *** */
11636 /* *** Get symmetric hash enable per port *** */
11637 struct cmd_get_sym_hash_ena_per_port_result {
11638 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11643 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11644 __rte_unused struct cmdline *cl,
11645 __rte_unused void *data)
11647 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11648 struct rte_eth_hash_filter_info info;
11651 if (rte_eth_dev_filter_supported(res->port_id,
11652 RTE_ETH_FILTER_HASH) < 0) {
11653 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11658 memset(&info, 0, sizeof(info));
11659 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11660 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11661 RTE_ETH_FILTER_GET, &info);
11664 printf("Cannot get symmetric hash enable per port "
11665 "on port %u\n", res->port_id);
11669 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11670 "enabled" : "disabled", res->port_id);
11673 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11674 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11675 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11676 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11677 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11680 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11681 .f = cmd_get_sym_hash_per_port_parsed,
11683 .help_str = "get_sym_hash_ena_per_port <port_id>",
11685 (void *)&cmd_get_sym_hash_ena_per_port_all,
11686 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11691 /* *** Set symmetric hash enable per port *** */
11692 struct cmd_set_sym_hash_ena_per_port_result {
11693 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11694 cmdline_fixed_string_t enable;
11699 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11700 __rte_unused struct cmdline *cl,
11701 __rte_unused void *data)
11703 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11704 struct rte_eth_hash_filter_info info;
11707 if (rte_eth_dev_filter_supported(res->port_id,
11708 RTE_ETH_FILTER_HASH) < 0) {
11709 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11714 memset(&info, 0, sizeof(info));
11715 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11716 if (!strcmp(res->enable, "enable"))
11717 info.info.enable = 1;
11718 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11719 RTE_ETH_FILTER_SET, &info);
11721 printf("Cannot set symmetric hash enable per port on "
11722 "port %u\n", res->port_id);
11725 printf("Symmetric hash has been set to %s on port %u\n",
11726 res->enable, res->port_id);
11729 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11730 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11731 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11732 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11733 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11735 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11736 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11737 enable, "enable#disable");
11739 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11740 .f = cmd_set_sym_hash_per_port_parsed,
11742 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11744 (void *)&cmd_set_sym_hash_ena_per_port_all,
11745 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11746 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11751 /* Get global config of hash function */
11752 struct cmd_get_hash_global_config_result {
11753 cmdline_fixed_string_t get_hash_global_config;
11758 flowtype_to_str(uint16_t ftype)
11764 } ftype_table[] = {
11765 {"ipv4", RTE_ETH_FLOW_IPV4},
11766 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11767 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11768 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11769 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11770 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11771 {"ipv6", RTE_ETH_FLOW_IPV6},
11772 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11773 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11774 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11775 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11776 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11777 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11778 {"port", RTE_ETH_FLOW_PORT},
11779 {"vxlan", RTE_ETH_FLOW_VXLAN},
11780 {"geneve", RTE_ETH_FLOW_GENEVE},
11781 {"nvgre", RTE_ETH_FLOW_NVGRE},
11784 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11785 if (ftype_table[i].ftype == ftype)
11786 return ftype_table[i].str;
11793 cmd_get_hash_global_config_parsed(void *parsed_result,
11794 __rte_unused struct cmdline *cl,
11795 __rte_unused void *data)
11797 struct cmd_get_hash_global_config_result *res = parsed_result;
11798 struct rte_eth_hash_filter_info info;
11799 uint32_t idx, offset;
11804 if (rte_eth_dev_filter_supported(res->port_id,
11805 RTE_ETH_FILTER_HASH) < 0) {
11806 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11811 memset(&info, 0, sizeof(info));
11812 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11813 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11814 RTE_ETH_FILTER_GET, &info);
11816 printf("Cannot get hash global configurations by port %d\n",
11821 switch (info.info.global_conf.hash_func) {
11822 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11823 printf("Hash function is Toeplitz\n");
11825 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11826 printf("Hash function is Simple XOR\n");
11829 printf("Unknown hash function\n");
11833 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11834 idx = i / UINT64_BIT;
11835 offset = i % UINT64_BIT;
11836 if (!(info.info.global_conf.valid_bit_mask[idx] &
11839 str = flowtype_to_str(i);
11842 printf("Symmetric hash is %s globally for flow type %s "
11844 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11845 (1ULL << offset)) ? "enabled" : "disabled"), str,
11850 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11851 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11852 get_hash_global_config, "get_hash_global_config");
11853 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11854 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11857 cmdline_parse_inst_t cmd_get_hash_global_config = {
11858 .f = cmd_get_hash_global_config_parsed,
11860 .help_str = "get_hash_global_config <port_id>",
11862 (void *)&cmd_get_hash_global_config_all,
11863 (void *)&cmd_get_hash_global_config_port_id,
11868 /* Set global config of hash function */
11869 struct cmd_set_hash_global_config_result {
11870 cmdline_fixed_string_t set_hash_global_config;
11872 cmdline_fixed_string_t hash_func;
11873 cmdline_fixed_string_t flow_type;
11874 cmdline_fixed_string_t enable;
11878 cmd_set_hash_global_config_parsed(void *parsed_result,
11879 __rte_unused struct cmdline *cl,
11880 __rte_unused void *data)
11882 struct cmd_set_hash_global_config_result *res = parsed_result;
11883 struct rte_eth_hash_filter_info info;
11884 uint32_t ftype, idx, offset;
11887 if (rte_eth_dev_filter_supported(res->port_id,
11888 RTE_ETH_FILTER_HASH) < 0) {
11889 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11893 memset(&info, 0, sizeof(info));
11894 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11895 if (!strcmp(res->hash_func, "toeplitz"))
11896 info.info.global_conf.hash_func =
11897 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11898 else if (!strcmp(res->hash_func, "simple_xor"))
11899 info.info.global_conf.hash_func =
11900 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11901 else if (!strcmp(res->hash_func, "default"))
11902 info.info.global_conf.hash_func =
11903 RTE_ETH_HASH_FUNCTION_DEFAULT;
11905 ftype = str2flowtype(res->flow_type);
11906 idx = ftype / UINT64_BIT;
11907 offset = ftype % UINT64_BIT;
11908 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11909 if (!strcmp(res->enable, "enable"))
11910 info.info.global_conf.sym_hash_enable_mask[idx] |=
11912 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11913 RTE_ETH_FILTER_SET, &info);
11915 printf("Cannot set global hash configurations by port %d\n",
11918 printf("Global hash configurations have been set "
11919 "succcessfully by port %d\n", res->port_id);
11922 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11923 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11924 set_hash_global_config, "set_hash_global_config");
11925 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11926 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11928 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11929 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11930 hash_func, "toeplitz#simple_xor#default");
11931 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11932 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11934 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11935 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11936 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11937 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11938 enable, "enable#disable");
11940 cmdline_parse_inst_t cmd_set_hash_global_config = {
11941 .f = cmd_set_hash_global_config_parsed,
11943 .help_str = "set_hash_global_config <port_id> "
11944 "toeplitz|simple_xor|default "
11945 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11946 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11947 "l2_payload enable|disable",
11949 (void *)&cmd_set_hash_global_config_all,
11950 (void *)&cmd_set_hash_global_config_port_id,
11951 (void *)&cmd_set_hash_global_config_hash_func,
11952 (void *)&cmd_set_hash_global_config_flow_type,
11953 (void *)&cmd_set_hash_global_config_enable,
11958 /* Set hash input set */
11959 struct cmd_set_hash_input_set_result {
11960 cmdline_fixed_string_t set_hash_input_set;
11962 cmdline_fixed_string_t flow_type;
11963 cmdline_fixed_string_t inset_field;
11964 cmdline_fixed_string_t select;
11967 static enum rte_eth_input_set_field
11968 str2inset(char *string)
11972 static const struct {
11974 enum rte_eth_input_set_field inset;
11975 } inset_table[] = {
11976 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11977 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11978 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11979 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11980 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11981 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11982 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11983 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11984 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11985 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11986 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11987 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11988 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11989 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11990 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11991 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11992 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11993 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11994 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11995 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11996 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11997 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11998 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11999 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12000 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12001 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12002 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12003 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12004 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12005 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12006 {"none", RTE_ETH_INPUT_SET_NONE},
12009 for (i = 0; i < RTE_DIM(inset_table); i++) {
12010 if (!strcmp(string, inset_table[i].str))
12011 return inset_table[i].inset;
12014 return RTE_ETH_INPUT_SET_UNKNOWN;
12018 cmd_set_hash_input_set_parsed(void *parsed_result,
12019 __rte_unused struct cmdline *cl,
12020 __rte_unused void *data)
12022 struct cmd_set_hash_input_set_result *res = parsed_result;
12023 struct rte_eth_hash_filter_info info;
12025 memset(&info, 0, sizeof(info));
12026 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12027 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12028 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12029 info.info.input_set_conf.inset_size = 1;
12030 if (!strcmp(res->select, "select"))
12031 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12032 else if (!strcmp(res->select, "add"))
12033 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12034 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12035 RTE_ETH_FILTER_SET, &info);
12038 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12039 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12040 set_hash_input_set, "set_hash_input_set");
12041 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12042 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12044 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12045 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12047 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12048 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12050 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12051 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12052 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12053 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12054 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12056 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12057 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12058 select, "select#add");
12060 cmdline_parse_inst_t cmd_set_hash_input_set = {
12061 .f = cmd_set_hash_input_set_parsed,
12063 .help_str = "set_hash_input_set <port_id> "
12064 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12065 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12066 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12067 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12068 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12069 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12070 "fld-7th|fld-8th|none select|add",
12072 (void *)&cmd_set_hash_input_set_cmd,
12073 (void *)&cmd_set_hash_input_set_port_id,
12074 (void *)&cmd_set_hash_input_set_flow_type,
12075 (void *)&cmd_set_hash_input_set_field,
12076 (void *)&cmd_set_hash_input_set_select,
12081 /* Set flow director input set */
12082 struct cmd_set_fdir_input_set_result {
12083 cmdline_fixed_string_t set_fdir_input_set;
12085 cmdline_fixed_string_t flow_type;
12086 cmdline_fixed_string_t inset_field;
12087 cmdline_fixed_string_t select;
12091 cmd_set_fdir_input_set_parsed(void *parsed_result,
12092 __rte_unused struct cmdline *cl,
12093 __rte_unused void *data)
12095 struct cmd_set_fdir_input_set_result *res = parsed_result;
12096 struct rte_eth_fdir_filter_info info;
12098 memset(&info, 0, sizeof(info));
12099 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12100 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12101 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12102 info.info.input_set_conf.inset_size = 1;
12103 if (!strcmp(res->select, "select"))
12104 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12105 else if (!strcmp(res->select, "add"))
12106 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12107 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12108 RTE_ETH_FILTER_SET, &info);
12111 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12112 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12113 set_fdir_input_set, "set_fdir_input_set");
12114 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12115 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12117 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12118 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12120 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12121 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12122 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12123 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12125 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12126 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12127 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12128 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12129 "sctp-veri-tag#none");
12130 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12131 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12132 select, "select#add");
12134 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12135 .f = cmd_set_fdir_input_set_parsed,
12137 .help_str = "set_fdir_input_set <port_id> "
12138 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12139 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12140 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12141 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12142 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12143 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12144 "sctp-veri-tag|none select|add",
12146 (void *)&cmd_set_fdir_input_set_cmd,
12147 (void *)&cmd_set_fdir_input_set_port_id,
12148 (void *)&cmd_set_fdir_input_set_flow_type,
12149 (void *)&cmd_set_fdir_input_set_field,
12150 (void *)&cmd_set_fdir_input_set_select,
12155 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12156 struct cmd_mcast_addr_result {
12157 cmdline_fixed_string_t mcast_addr_cmd;
12158 cmdline_fixed_string_t what;
12160 struct ether_addr mc_addr;
12163 static void cmd_mcast_addr_parsed(void *parsed_result,
12164 __attribute__((unused)) struct cmdline *cl,
12165 __attribute__((unused)) void *data)
12167 struct cmd_mcast_addr_result *res = parsed_result;
12169 if (!is_multicast_ether_addr(&res->mc_addr)) {
12170 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12171 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12172 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12173 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12176 if (strcmp(res->what, "add") == 0)
12177 mcast_addr_add(res->port_num, &res->mc_addr);
12179 mcast_addr_remove(res->port_num, &res->mc_addr);
12182 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12183 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12184 mcast_addr_cmd, "mcast_addr");
12185 cmdline_parse_token_string_t cmd_mcast_addr_what =
12186 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12188 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12189 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12190 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12191 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12193 cmdline_parse_inst_t cmd_mcast_addr = {
12194 .f = cmd_mcast_addr_parsed,
12196 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12197 "Add/Remove multicast MAC address on port_id",
12199 (void *)&cmd_mcast_addr_cmd,
12200 (void *)&cmd_mcast_addr_what,
12201 (void *)&cmd_mcast_addr_portnum,
12202 (void *)&cmd_mcast_addr_addr,
12207 /* l2 tunnel config
12208 * only support E-tag now.
12211 /* Ether type config */
12212 struct cmd_config_l2_tunnel_eth_type_result {
12213 cmdline_fixed_string_t port;
12214 cmdline_fixed_string_t config;
12215 cmdline_fixed_string_t all;
12217 cmdline_fixed_string_t l2_tunnel;
12218 cmdline_fixed_string_t l2_tunnel_type;
12219 cmdline_fixed_string_t eth_type;
12220 uint16_t eth_type_val;
12223 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12224 TOKEN_STRING_INITIALIZER
12225 (struct cmd_config_l2_tunnel_eth_type_result,
12227 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12228 TOKEN_STRING_INITIALIZER
12229 (struct cmd_config_l2_tunnel_eth_type_result,
12231 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12232 TOKEN_STRING_INITIALIZER
12233 (struct cmd_config_l2_tunnel_eth_type_result,
12235 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12236 TOKEN_NUM_INITIALIZER
12237 (struct cmd_config_l2_tunnel_eth_type_result,
12239 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12240 TOKEN_STRING_INITIALIZER
12241 (struct cmd_config_l2_tunnel_eth_type_result,
12242 l2_tunnel, "l2-tunnel");
12243 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12244 TOKEN_STRING_INITIALIZER
12245 (struct cmd_config_l2_tunnel_eth_type_result,
12246 l2_tunnel_type, "E-tag");
12247 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12248 TOKEN_STRING_INITIALIZER
12249 (struct cmd_config_l2_tunnel_eth_type_result,
12250 eth_type, "ether-type");
12251 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12252 TOKEN_NUM_INITIALIZER
12253 (struct cmd_config_l2_tunnel_eth_type_result,
12254 eth_type_val, UINT16);
12256 static enum rte_eth_tunnel_type
12257 str2fdir_l2_tunnel_type(char *string)
12261 static const struct {
12263 enum rte_eth_tunnel_type type;
12264 } l2_tunnel_type_str[] = {
12265 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12268 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12269 if (!strcmp(l2_tunnel_type_str[i].str, string))
12270 return l2_tunnel_type_str[i].type;
12272 return RTE_TUNNEL_TYPE_NONE;
12275 /* ether type config for all ports */
12277 cmd_config_l2_tunnel_eth_type_all_parsed
12278 (void *parsed_result,
12279 __attribute__((unused)) struct cmdline *cl,
12280 __attribute__((unused)) void *data)
12282 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12283 struct rte_eth_l2_tunnel_conf entry;
12286 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12287 entry.ether_type = res->eth_type_val;
12289 RTE_ETH_FOREACH_DEV(pid) {
12290 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12294 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12295 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12297 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12299 (void *)&cmd_config_l2_tunnel_eth_type_port,
12300 (void *)&cmd_config_l2_tunnel_eth_type_config,
12301 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12302 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12303 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12304 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12305 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12310 /* ether type config for a specific port */
12312 cmd_config_l2_tunnel_eth_type_specific_parsed(
12313 void *parsed_result,
12314 __attribute__((unused)) struct cmdline *cl,
12315 __attribute__((unused)) void *data)
12317 struct cmd_config_l2_tunnel_eth_type_result *res =
12319 struct rte_eth_l2_tunnel_conf entry;
12321 if (port_id_is_invalid(res->id, ENABLED_WARN))
12324 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12325 entry.ether_type = res->eth_type_val;
12327 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12330 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12331 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12333 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12335 (void *)&cmd_config_l2_tunnel_eth_type_port,
12336 (void *)&cmd_config_l2_tunnel_eth_type_config,
12337 (void *)&cmd_config_l2_tunnel_eth_type_id,
12338 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12339 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12340 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12341 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12346 /* Enable/disable l2 tunnel */
12347 struct cmd_config_l2_tunnel_en_dis_result {
12348 cmdline_fixed_string_t port;
12349 cmdline_fixed_string_t config;
12350 cmdline_fixed_string_t all;
12352 cmdline_fixed_string_t l2_tunnel;
12353 cmdline_fixed_string_t l2_tunnel_type;
12354 cmdline_fixed_string_t en_dis;
12357 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12358 TOKEN_STRING_INITIALIZER
12359 (struct cmd_config_l2_tunnel_en_dis_result,
12361 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12362 TOKEN_STRING_INITIALIZER
12363 (struct cmd_config_l2_tunnel_en_dis_result,
12365 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12366 TOKEN_STRING_INITIALIZER
12367 (struct cmd_config_l2_tunnel_en_dis_result,
12369 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12370 TOKEN_NUM_INITIALIZER
12371 (struct cmd_config_l2_tunnel_en_dis_result,
12373 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_config_l2_tunnel_en_dis_result,
12376 l2_tunnel, "l2-tunnel");
12377 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_config_l2_tunnel_en_dis_result,
12380 l2_tunnel_type, "E-tag");
12381 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12382 TOKEN_STRING_INITIALIZER
12383 (struct cmd_config_l2_tunnel_en_dis_result,
12384 en_dis, "enable#disable");
12386 /* enable/disable l2 tunnel for all ports */
12388 cmd_config_l2_tunnel_en_dis_all_parsed(
12389 void *parsed_result,
12390 __attribute__((unused)) struct cmdline *cl,
12391 __attribute__((unused)) void *data)
12393 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12394 struct rte_eth_l2_tunnel_conf entry;
12398 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12400 if (!strcmp("enable", res->en_dis))
12405 RTE_ETH_FOREACH_DEV(pid) {
12406 rte_eth_dev_l2_tunnel_offload_set(pid,
12408 ETH_L2_TUNNEL_ENABLE_MASK,
12413 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12414 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12416 .help_str = "port config all l2-tunnel E-tag enable|disable",
12418 (void *)&cmd_config_l2_tunnel_en_dis_port,
12419 (void *)&cmd_config_l2_tunnel_en_dis_config,
12420 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12421 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12422 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12423 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12428 /* enable/disable l2 tunnel for a port */
12430 cmd_config_l2_tunnel_en_dis_specific_parsed(
12431 void *parsed_result,
12432 __attribute__((unused)) struct cmdline *cl,
12433 __attribute__((unused)) void *data)
12435 struct cmd_config_l2_tunnel_en_dis_result *res =
12437 struct rte_eth_l2_tunnel_conf entry;
12439 if (port_id_is_invalid(res->id, ENABLED_WARN))
12442 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12444 if (!strcmp("enable", res->en_dis))
12445 rte_eth_dev_l2_tunnel_offload_set(res->id,
12447 ETH_L2_TUNNEL_ENABLE_MASK,
12450 rte_eth_dev_l2_tunnel_offload_set(res->id,
12452 ETH_L2_TUNNEL_ENABLE_MASK,
12456 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12457 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12459 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12461 (void *)&cmd_config_l2_tunnel_en_dis_port,
12462 (void *)&cmd_config_l2_tunnel_en_dis_config,
12463 (void *)&cmd_config_l2_tunnel_en_dis_id,
12464 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12465 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12466 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12471 /* E-tag configuration */
12473 /* Common result structure for all E-tag configuration */
12474 struct cmd_config_e_tag_result {
12475 cmdline_fixed_string_t e_tag;
12476 cmdline_fixed_string_t set;
12477 cmdline_fixed_string_t insertion;
12478 cmdline_fixed_string_t stripping;
12479 cmdline_fixed_string_t forwarding;
12480 cmdline_fixed_string_t filter;
12481 cmdline_fixed_string_t add;
12482 cmdline_fixed_string_t del;
12483 cmdline_fixed_string_t on;
12484 cmdline_fixed_string_t off;
12485 cmdline_fixed_string_t on_off;
12486 cmdline_fixed_string_t port_tag_id;
12487 uint32_t port_tag_id_val;
12488 cmdline_fixed_string_t e_tag_id;
12489 uint16_t e_tag_id_val;
12490 cmdline_fixed_string_t dst_pool;
12491 uint8_t dst_pool_val;
12492 cmdline_fixed_string_t port;
12494 cmdline_fixed_string_t vf;
12498 /* Common CLI fields for all E-tag configuration */
12499 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12500 TOKEN_STRING_INITIALIZER
12501 (struct cmd_config_e_tag_result,
12503 cmdline_parse_token_string_t cmd_config_e_tag_set =
12504 TOKEN_STRING_INITIALIZER
12505 (struct cmd_config_e_tag_result,
12507 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12508 TOKEN_STRING_INITIALIZER
12509 (struct cmd_config_e_tag_result,
12510 insertion, "insertion");
12511 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12512 TOKEN_STRING_INITIALIZER
12513 (struct cmd_config_e_tag_result,
12514 stripping, "stripping");
12515 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12516 TOKEN_STRING_INITIALIZER
12517 (struct cmd_config_e_tag_result,
12518 forwarding, "forwarding");
12519 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12520 TOKEN_STRING_INITIALIZER
12521 (struct cmd_config_e_tag_result,
12523 cmdline_parse_token_string_t cmd_config_e_tag_add =
12524 TOKEN_STRING_INITIALIZER
12525 (struct cmd_config_e_tag_result,
12527 cmdline_parse_token_string_t cmd_config_e_tag_del =
12528 TOKEN_STRING_INITIALIZER
12529 (struct cmd_config_e_tag_result,
12531 cmdline_parse_token_string_t cmd_config_e_tag_on =
12532 TOKEN_STRING_INITIALIZER
12533 (struct cmd_config_e_tag_result,
12535 cmdline_parse_token_string_t cmd_config_e_tag_off =
12536 TOKEN_STRING_INITIALIZER
12537 (struct cmd_config_e_tag_result,
12539 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12540 TOKEN_STRING_INITIALIZER
12541 (struct cmd_config_e_tag_result,
12543 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12544 TOKEN_STRING_INITIALIZER
12545 (struct cmd_config_e_tag_result,
12546 port_tag_id, "port-tag-id");
12547 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12548 TOKEN_NUM_INITIALIZER
12549 (struct cmd_config_e_tag_result,
12550 port_tag_id_val, UINT32);
12551 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12552 TOKEN_STRING_INITIALIZER
12553 (struct cmd_config_e_tag_result,
12554 e_tag_id, "e-tag-id");
12555 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12556 TOKEN_NUM_INITIALIZER
12557 (struct cmd_config_e_tag_result,
12558 e_tag_id_val, UINT16);
12559 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12560 TOKEN_STRING_INITIALIZER
12561 (struct cmd_config_e_tag_result,
12562 dst_pool, "dst-pool");
12563 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12564 TOKEN_NUM_INITIALIZER
12565 (struct cmd_config_e_tag_result,
12566 dst_pool_val, UINT8);
12567 cmdline_parse_token_string_t cmd_config_e_tag_port =
12568 TOKEN_STRING_INITIALIZER
12569 (struct cmd_config_e_tag_result,
12571 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12572 TOKEN_NUM_INITIALIZER
12573 (struct cmd_config_e_tag_result,
12575 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12576 TOKEN_STRING_INITIALIZER
12577 (struct cmd_config_e_tag_result,
12579 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12580 TOKEN_NUM_INITIALIZER
12581 (struct cmd_config_e_tag_result,
12584 /* E-tag insertion configuration */
12586 cmd_config_e_tag_insertion_en_parsed(
12587 void *parsed_result,
12588 __attribute__((unused)) struct cmdline *cl,
12589 __attribute__((unused)) void *data)
12591 struct cmd_config_e_tag_result *res =
12593 struct rte_eth_l2_tunnel_conf entry;
12595 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12598 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12599 entry.tunnel_id = res->port_tag_id_val;
12600 entry.vf_id = res->vf_id;
12601 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12603 ETH_L2_TUNNEL_INSERTION_MASK,
12608 cmd_config_e_tag_insertion_dis_parsed(
12609 void *parsed_result,
12610 __attribute__((unused)) struct cmdline *cl,
12611 __attribute__((unused)) void *data)
12613 struct cmd_config_e_tag_result *res =
12615 struct rte_eth_l2_tunnel_conf entry;
12617 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12620 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12621 entry.vf_id = res->vf_id;
12623 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12625 ETH_L2_TUNNEL_INSERTION_MASK,
12629 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12630 .f = cmd_config_e_tag_insertion_en_parsed,
12632 .help_str = "E-tag ... : E-tag insertion enable",
12634 (void *)&cmd_config_e_tag_e_tag,
12635 (void *)&cmd_config_e_tag_set,
12636 (void *)&cmd_config_e_tag_insertion,
12637 (void *)&cmd_config_e_tag_on,
12638 (void *)&cmd_config_e_tag_port_tag_id,
12639 (void *)&cmd_config_e_tag_port_tag_id_val,
12640 (void *)&cmd_config_e_tag_port,
12641 (void *)&cmd_config_e_tag_port_id,
12642 (void *)&cmd_config_e_tag_vf,
12643 (void *)&cmd_config_e_tag_vf_id,
12648 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12649 .f = cmd_config_e_tag_insertion_dis_parsed,
12651 .help_str = "E-tag ... : E-tag insertion disable",
12653 (void *)&cmd_config_e_tag_e_tag,
12654 (void *)&cmd_config_e_tag_set,
12655 (void *)&cmd_config_e_tag_insertion,
12656 (void *)&cmd_config_e_tag_off,
12657 (void *)&cmd_config_e_tag_port,
12658 (void *)&cmd_config_e_tag_port_id,
12659 (void *)&cmd_config_e_tag_vf,
12660 (void *)&cmd_config_e_tag_vf_id,
12665 /* E-tag stripping configuration */
12667 cmd_config_e_tag_stripping_parsed(
12668 void *parsed_result,
12669 __attribute__((unused)) struct cmdline *cl,
12670 __attribute__((unused)) void *data)
12672 struct cmd_config_e_tag_result *res =
12674 struct rte_eth_l2_tunnel_conf entry;
12676 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12679 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12681 if (!strcmp(res->on_off, "on"))
12682 rte_eth_dev_l2_tunnel_offload_set
12685 ETH_L2_TUNNEL_STRIPPING_MASK,
12688 rte_eth_dev_l2_tunnel_offload_set
12691 ETH_L2_TUNNEL_STRIPPING_MASK,
12695 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12696 .f = cmd_config_e_tag_stripping_parsed,
12698 .help_str = "E-tag ... : E-tag stripping enable/disable",
12700 (void *)&cmd_config_e_tag_e_tag,
12701 (void *)&cmd_config_e_tag_set,
12702 (void *)&cmd_config_e_tag_stripping,
12703 (void *)&cmd_config_e_tag_on_off,
12704 (void *)&cmd_config_e_tag_port,
12705 (void *)&cmd_config_e_tag_port_id,
12710 /* E-tag forwarding configuration */
12712 cmd_config_e_tag_forwarding_parsed(
12713 void *parsed_result,
12714 __attribute__((unused)) struct cmdline *cl,
12715 __attribute__((unused)) void *data)
12717 struct cmd_config_e_tag_result *res = parsed_result;
12718 struct rte_eth_l2_tunnel_conf entry;
12720 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12723 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12725 if (!strcmp(res->on_off, "on"))
12726 rte_eth_dev_l2_tunnel_offload_set
12729 ETH_L2_TUNNEL_FORWARDING_MASK,
12732 rte_eth_dev_l2_tunnel_offload_set
12735 ETH_L2_TUNNEL_FORWARDING_MASK,
12739 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12740 .f = cmd_config_e_tag_forwarding_parsed,
12742 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12744 (void *)&cmd_config_e_tag_e_tag,
12745 (void *)&cmd_config_e_tag_set,
12746 (void *)&cmd_config_e_tag_forwarding,
12747 (void *)&cmd_config_e_tag_on_off,
12748 (void *)&cmd_config_e_tag_port,
12749 (void *)&cmd_config_e_tag_port_id,
12754 /* E-tag filter configuration */
12756 cmd_config_e_tag_filter_add_parsed(
12757 void *parsed_result,
12758 __attribute__((unused)) struct cmdline *cl,
12759 __attribute__((unused)) void *data)
12761 struct cmd_config_e_tag_result *res = parsed_result;
12762 struct rte_eth_l2_tunnel_conf entry;
12765 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12768 if (res->e_tag_id_val > 0x3fff) {
12769 printf("e-tag-id must be equal or less than 0x3fff.\n");
12773 ret = rte_eth_dev_filter_supported(res->port_id,
12774 RTE_ETH_FILTER_L2_TUNNEL);
12776 printf("E-tag filter is not supported on port %u.\n",
12781 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12782 entry.tunnel_id = res->e_tag_id_val;
12783 entry.pool = res->dst_pool_val;
12785 ret = rte_eth_dev_filter_ctrl(res->port_id,
12786 RTE_ETH_FILTER_L2_TUNNEL,
12787 RTE_ETH_FILTER_ADD,
12790 printf("E-tag filter programming error: (%s)\n",
12794 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12795 .f = cmd_config_e_tag_filter_add_parsed,
12797 .help_str = "E-tag ... : E-tag filter add",
12799 (void *)&cmd_config_e_tag_e_tag,
12800 (void *)&cmd_config_e_tag_set,
12801 (void *)&cmd_config_e_tag_filter,
12802 (void *)&cmd_config_e_tag_add,
12803 (void *)&cmd_config_e_tag_e_tag_id,
12804 (void *)&cmd_config_e_tag_e_tag_id_val,
12805 (void *)&cmd_config_e_tag_dst_pool,
12806 (void *)&cmd_config_e_tag_dst_pool_val,
12807 (void *)&cmd_config_e_tag_port,
12808 (void *)&cmd_config_e_tag_port_id,
12814 cmd_config_e_tag_filter_del_parsed(
12815 void *parsed_result,
12816 __attribute__((unused)) struct cmdline *cl,
12817 __attribute__((unused)) void *data)
12819 struct cmd_config_e_tag_result *res = parsed_result;
12820 struct rte_eth_l2_tunnel_conf entry;
12823 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12826 if (res->e_tag_id_val > 0x3fff) {
12827 printf("e-tag-id must be less than 0x3fff.\n");
12831 ret = rte_eth_dev_filter_supported(res->port_id,
12832 RTE_ETH_FILTER_L2_TUNNEL);
12834 printf("E-tag filter is not supported on port %u.\n",
12839 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12840 entry.tunnel_id = res->e_tag_id_val;
12842 ret = rte_eth_dev_filter_ctrl(res->port_id,
12843 RTE_ETH_FILTER_L2_TUNNEL,
12844 RTE_ETH_FILTER_DELETE,
12847 printf("E-tag filter programming error: (%s)\n",
12851 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12852 .f = cmd_config_e_tag_filter_del_parsed,
12854 .help_str = "E-tag ... : E-tag filter delete",
12856 (void *)&cmd_config_e_tag_e_tag,
12857 (void *)&cmd_config_e_tag_set,
12858 (void *)&cmd_config_e_tag_filter,
12859 (void *)&cmd_config_e_tag_del,
12860 (void *)&cmd_config_e_tag_e_tag_id,
12861 (void *)&cmd_config_e_tag_e_tag_id_val,
12862 (void *)&cmd_config_e_tag_port,
12863 (void *)&cmd_config_e_tag_port_id,
12868 /* vf vlan anti spoof configuration */
12870 /* Common result structure for vf vlan anti spoof */
12871 struct cmd_vf_vlan_anti_spoof_result {
12872 cmdline_fixed_string_t set;
12873 cmdline_fixed_string_t vf;
12874 cmdline_fixed_string_t vlan;
12875 cmdline_fixed_string_t antispoof;
12878 cmdline_fixed_string_t on_off;
12881 /* Common CLI fields for vf vlan anti spoof enable disable */
12882 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12883 TOKEN_STRING_INITIALIZER
12884 (struct cmd_vf_vlan_anti_spoof_result,
12886 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12887 TOKEN_STRING_INITIALIZER
12888 (struct cmd_vf_vlan_anti_spoof_result,
12890 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12891 TOKEN_STRING_INITIALIZER
12892 (struct cmd_vf_vlan_anti_spoof_result,
12894 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12895 TOKEN_STRING_INITIALIZER
12896 (struct cmd_vf_vlan_anti_spoof_result,
12897 antispoof, "antispoof");
12898 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12899 TOKEN_NUM_INITIALIZER
12900 (struct cmd_vf_vlan_anti_spoof_result,
12902 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12903 TOKEN_NUM_INITIALIZER
12904 (struct cmd_vf_vlan_anti_spoof_result,
12906 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12907 TOKEN_STRING_INITIALIZER
12908 (struct cmd_vf_vlan_anti_spoof_result,
12912 cmd_set_vf_vlan_anti_spoof_parsed(
12913 void *parsed_result,
12914 __attribute__((unused)) struct cmdline *cl,
12915 __attribute__((unused)) void *data)
12917 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12918 int ret = -ENOTSUP;
12920 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12922 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12925 #ifdef RTE_LIBRTE_IXGBE_PMD
12926 if (ret == -ENOTSUP)
12927 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12928 res->vf_id, is_on);
12930 #ifdef RTE_LIBRTE_I40E_PMD
12931 if (ret == -ENOTSUP)
12932 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12933 res->vf_id, is_on);
12935 #ifdef RTE_LIBRTE_BNXT_PMD
12936 if (ret == -ENOTSUP)
12937 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12938 res->vf_id, is_on);
12945 printf("invalid vf_id %d\n", res->vf_id);
12948 printf("invalid port_id %d\n", res->port_id);
12951 printf("function not implemented\n");
12954 printf("programming error: (%s)\n", strerror(-ret));
12958 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12959 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12961 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12963 (void *)&cmd_vf_vlan_anti_spoof_set,
12964 (void *)&cmd_vf_vlan_anti_spoof_vf,
12965 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12966 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12967 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12968 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12969 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12974 /* vf mac anti spoof configuration */
12976 /* Common result structure for vf mac anti spoof */
12977 struct cmd_vf_mac_anti_spoof_result {
12978 cmdline_fixed_string_t set;
12979 cmdline_fixed_string_t vf;
12980 cmdline_fixed_string_t mac;
12981 cmdline_fixed_string_t antispoof;
12984 cmdline_fixed_string_t on_off;
12987 /* Common CLI fields for vf mac anti spoof enable disable */
12988 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12989 TOKEN_STRING_INITIALIZER
12990 (struct cmd_vf_mac_anti_spoof_result,
12992 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12993 TOKEN_STRING_INITIALIZER
12994 (struct cmd_vf_mac_anti_spoof_result,
12996 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12997 TOKEN_STRING_INITIALIZER
12998 (struct cmd_vf_mac_anti_spoof_result,
13000 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13001 TOKEN_STRING_INITIALIZER
13002 (struct cmd_vf_mac_anti_spoof_result,
13003 antispoof, "antispoof");
13004 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13005 TOKEN_NUM_INITIALIZER
13006 (struct cmd_vf_mac_anti_spoof_result,
13008 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13009 TOKEN_NUM_INITIALIZER
13010 (struct cmd_vf_mac_anti_spoof_result,
13012 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13013 TOKEN_STRING_INITIALIZER
13014 (struct cmd_vf_mac_anti_spoof_result,
13018 cmd_set_vf_mac_anti_spoof_parsed(
13019 void *parsed_result,
13020 __attribute__((unused)) struct cmdline *cl,
13021 __attribute__((unused)) void *data)
13023 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13024 int ret = -ENOTSUP;
13026 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13031 #ifdef RTE_LIBRTE_IXGBE_PMD
13032 if (ret == -ENOTSUP)
13033 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13034 res->vf_id, is_on);
13036 #ifdef RTE_LIBRTE_I40E_PMD
13037 if (ret == -ENOTSUP)
13038 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13039 res->vf_id, is_on);
13041 #ifdef RTE_LIBRTE_BNXT_PMD
13042 if (ret == -ENOTSUP)
13043 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13044 res->vf_id, is_on);
13051 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13054 printf("invalid port_id %d\n", res->port_id);
13057 printf("function not implemented\n");
13060 printf("programming error: (%s)\n", strerror(-ret));
13064 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13065 .f = cmd_set_vf_mac_anti_spoof_parsed,
13067 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13069 (void *)&cmd_vf_mac_anti_spoof_set,
13070 (void *)&cmd_vf_mac_anti_spoof_vf,
13071 (void *)&cmd_vf_mac_anti_spoof_mac,
13072 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13073 (void *)&cmd_vf_mac_anti_spoof_port_id,
13074 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13075 (void *)&cmd_vf_mac_anti_spoof_on_off,
13080 /* vf vlan strip queue configuration */
13082 /* Common result structure for vf mac anti spoof */
13083 struct cmd_vf_vlan_stripq_result {
13084 cmdline_fixed_string_t set;
13085 cmdline_fixed_string_t vf;
13086 cmdline_fixed_string_t vlan;
13087 cmdline_fixed_string_t stripq;
13090 cmdline_fixed_string_t on_off;
13093 /* Common CLI fields for vf vlan strip enable disable */
13094 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13095 TOKEN_STRING_INITIALIZER
13096 (struct cmd_vf_vlan_stripq_result,
13098 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13099 TOKEN_STRING_INITIALIZER
13100 (struct cmd_vf_vlan_stripq_result,
13102 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13103 TOKEN_STRING_INITIALIZER
13104 (struct cmd_vf_vlan_stripq_result,
13106 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13107 TOKEN_STRING_INITIALIZER
13108 (struct cmd_vf_vlan_stripq_result,
13110 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13111 TOKEN_NUM_INITIALIZER
13112 (struct cmd_vf_vlan_stripq_result,
13114 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13115 TOKEN_NUM_INITIALIZER
13116 (struct cmd_vf_vlan_stripq_result,
13118 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13119 TOKEN_STRING_INITIALIZER
13120 (struct cmd_vf_vlan_stripq_result,
13124 cmd_set_vf_vlan_stripq_parsed(
13125 void *parsed_result,
13126 __attribute__((unused)) struct cmdline *cl,
13127 __attribute__((unused)) void *data)
13129 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13130 int ret = -ENOTSUP;
13132 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13134 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13137 #ifdef RTE_LIBRTE_IXGBE_PMD
13138 if (ret == -ENOTSUP)
13139 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13140 res->vf_id, is_on);
13142 #ifdef RTE_LIBRTE_I40E_PMD
13143 if (ret == -ENOTSUP)
13144 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13145 res->vf_id, is_on);
13147 #ifdef RTE_LIBRTE_BNXT_PMD
13148 if (ret == -ENOTSUP)
13149 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13150 res->vf_id, is_on);
13157 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13160 printf("invalid port_id %d\n", res->port_id);
13163 printf("function not implemented\n");
13166 printf("programming error: (%s)\n", strerror(-ret));
13170 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13171 .f = cmd_set_vf_vlan_stripq_parsed,
13173 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13175 (void *)&cmd_vf_vlan_stripq_set,
13176 (void *)&cmd_vf_vlan_stripq_vf,
13177 (void *)&cmd_vf_vlan_stripq_vlan,
13178 (void *)&cmd_vf_vlan_stripq_stripq,
13179 (void *)&cmd_vf_vlan_stripq_port_id,
13180 (void *)&cmd_vf_vlan_stripq_vf_id,
13181 (void *)&cmd_vf_vlan_stripq_on_off,
13186 /* vf vlan insert configuration */
13188 /* Common result structure for vf vlan insert */
13189 struct cmd_vf_vlan_insert_result {
13190 cmdline_fixed_string_t set;
13191 cmdline_fixed_string_t vf;
13192 cmdline_fixed_string_t vlan;
13193 cmdline_fixed_string_t insert;
13199 /* Common CLI fields for vf vlan insert enable disable */
13200 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13201 TOKEN_STRING_INITIALIZER
13202 (struct cmd_vf_vlan_insert_result,
13204 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13205 TOKEN_STRING_INITIALIZER
13206 (struct cmd_vf_vlan_insert_result,
13208 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13209 TOKEN_STRING_INITIALIZER
13210 (struct cmd_vf_vlan_insert_result,
13212 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13213 TOKEN_STRING_INITIALIZER
13214 (struct cmd_vf_vlan_insert_result,
13216 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13217 TOKEN_NUM_INITIALIZER
13218 (struct cmd_vf_vlan_insert_result,
13220 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13221 TOKEN_NUM_INITIALIZER
13222 (struct cmd_vf_vlan_insert_result,
13224 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13225 TOKEN_NUM_INITIALIZER
13226 (struct cmd_vf_vlan_insert_result,
13230 cmd_set_vf_vlan_insert_parsed(
13231 void *parsed_result,
13232 __attribute__((unused)) struct cmdline *cl,
13233 __attribute__((unused)) void *data)
13235 struct cmd_vf_vlan_insert_result *res = parsed_result;
13236 int ret = -ENOTSUP;
13238 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13241 #ifdef RTE_LIBRTE_IXGBE_PMD
13242 if (ret == -ENOTSUP)
13243 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13246 #ifdef RTE_LIBRTE_I40E_PMD
13247 if (ret == -ENOTSUP)
13248 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13251 #ifdef RTE_LIBRTE_BNXT_PMD
13252 if (ret == -ENOTSUP)
13253 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13261 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13264 printf("invalid port_id %d\n", res->port_id);
13267 printf("function not implemented\n");
13270 printf("programming error: (%s)\n", strerror(-ret));
13274 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13275 .f = cmd_set_vf_vlan_insert_parsed,
13277 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13279 (void *)&cmd_vf_vlan_insert_set,
13280 (void *)&cmd_vf_vlan_insert_vf,
13281 (void *)&cmd_vf_vlan_insert_vlan,
13282 (void *)&cmd_vf_vlan_insert_insert,
13283 (void *)&cmd_vf_vlan_insert_port_id,
13284 (void *)&cmd_vf_vlan_insert_vf_id,
13285 (void *)&cmd_vf_vlan_insert_vlan_id,
13290 /* tx loopback configuration */
13292 /* Common result structure for tx loopback */
13293 struct cmd_tx_loopback_result {
13294 cmdline_fixed_string_t set;
13295 cmdline_fixed_string_t tx;
13296 cmdline_fixed_string_t loopback;
13298 cmdline_fixed_string_t on_off;
13301 /* Common CLI fields for tx loopback enable disable */
13302 cmdline_parse_token_string_t cmd_tx_loopback_set =
13303 TOKEN_STRING_INITIALIZER
13304 (struct cmd_tx_loopback_result,
13306 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13307 TOKEN_STRING_INITIALIZER
13308 (struct cmd_tx_loopback_result,
13310 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13311 TOKEN_STRING_INITIALIZER
13312 (struct cmd_tx_loopback_result,
13313 loopback, "loopback");
13314 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13315 TOKEN_NUM_INITIALIZER
13316 (struct cmd_tx_loopback_result,
13318 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13319 TOKEN_STRING_INITIALIZER
13320 (struct cmd_tx_loopback_result,
13324 cmd_set_tx_loopback_parsed(
13325 void *parsed_result,
13326 __attribute__((unused)) struct cmdline *cl,
13327 __attribute__((unused)) void *data)
13329 struct cmd_tx_loopback_result *res = parsed_result;
13330 int ret = -ENOTSUP;
13332 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13334 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13337 #ifdef RTE_LIBRTE_IXGBE_PMD
13338 if (ret == -ENOTSUP)
13339 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13341 #ifdef RTE_LIBRTE_I40E_PMD
13342 if (ret == -ENOTSUP)
13343 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13345 #ifdef RTE_LIBRTE_BNXT_PMD
13346 if (ret == -ENOTSUP)
13347 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13349 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13350 if (ret == -ENOTSUP)
13351 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13358 printf("invalid is_on %d\n", is_on);
13361 printf("invalid port_id %d\n", res->port_id);
13364 printf("function not implemented\n");
13367 printf("programming error: (%s)\n", strerror(-ret));
13371 cmdline_parse_inst_t cmd_set_tx_loopback = {
13372 .f = cmd_set_tx_loopback_parsed,
13374 .help_str = "set tx loopback <port_id> on|off",
13376 (void *)&cmd_tx_loopback_set,
13377 (void *)&cmd_tx_loopback_tx,
13378 (void *)&cmd_tx_loopback_loopback,
13379 (void *)&cmd_tx_loopback_port_id,
13380 (void *)&cmd_tx_loopback_on_off,
13385 /* all queues drop enable configuration */
13387 /* Common result structure for all queues drop enable */
13388 struct cmd_all_queues_drop_en_result {
13389 cmdline_fixed_string_t set;
13390 cmdline_fixed_string_t all;
13391 cmdline_fixed_string_t queues;
13392 cmdline_fixed_string_t drop;
13394 cmdline_fixed_string_t on_off;
13397 /* Common CLI fields for tx loopback enable disable */
13398 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13399 TOKEN_STRING_INITIALIZER
13400 (struct cmd_all_queues_drop_en_result,
13402 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13403 TOKEN_STRING_INITIALIZER
13404 (struct cmd_all_queues_drop_en_result,
13406 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13407 TOKEN_STRING_INITIALIZER
13408 (struct cmd_all_queues_drop_en_result,
13410 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13411 TOKEN_STRING_INITIALIZER
13412 (struct cmd_all_queues_drop_en_result,
13414 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13415 TOKEN_NUM_INITIALIZER
13416 (struct cmd_all_queues_drop_en_result,
13418 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13419 TOKEN_STRING_INITIALIZER
13420 (struct cmd_all_queues_drop_en_result,
13424 cmd_set_all_queues_drop_en_parsed(
13425 void *parsed_result,
13426 __attribute__((unused)) struct cmdline *cl,
13427 __attribute__((unused)) void *data)
13429 struct cmd_all_queues_drop_en_result *res = parsed_result;
13430 int ret = -ENOTSUP;
13431 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13433 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13436 #ifdef RTE_LIBRTE_IXGBE_PMD
13437 if (ret == -ENOTSUP)
13438 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13440 #ifdef RTE_LIBRTE_BNXT_PMD
13441 if (ret == -ENOTSUP)
13442 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13448 printf("invalid is_on %d\n", is_on);
13451 printf("invalid port_id %d\n", res->port_id);
13454 printf("function not implemented\n");
13457 printf("programming error: (%s)\n", strerror(-ret));
13461 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13462 .f = cmd_set_all_queues_drop_en_parsed,
13464 .help_str = "set all queues drop <port_id> on|off",
13466 (void *)&cmd_all_queues_drop_en_set,
13467 (void *)&cmd_all_queues_drop_en_all,
13468 (void *)&cmd_all_queues_drop_en_queues,
13469 (void *)&cmd_all_queues_drop_en_drop,
13470 (void *)&cmd_all_queues_drop_en_port_id,
13471 (void *)&cmd_all_queues_drop_en_on_off,
13476 /* vf split drop enable configuration */
13478 /* Common result structure for vf split drop enable */
13479 struct cmd_vf_split_drop_en_result {
13480 cmdline_fixed_string_t set;
13481 cmdline_fixed_string_t vf;
13482 cmdline_fixed_string_t split;
13483 cmdline_fixed_string_t drop;
13486 cmdline_fixed_string_t on_off;
13489 /* Common CLI fields for vf split drop enable disable */
13490 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13491 TOKEN_STRING_INITIALIZER
13492 (struct cmd_vf_split_drop_en_result,
13494 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13495 TOKEN_STRING_INITIALIZER
13496 (struct cmd_vf_split_drop_en_result,
13498 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13499 TOKEN_STRING_INITIALIZER
13500 (struct cmd_vf_split_drop_en_result,
13502 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13503 TOKEN_STRING_INITIALIZER
13504 (struct cmd_vf_split_drop_en_result,
13506 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13507 TOKEN_NUM_INITIALIZER
13508 (struct cmd_vf_split_drop_en_result,
13510 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13511 TOKEN_NUM_INITIALIZER
13512 (struct cmd_vf_split_drop_en_result,
13514 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13515 TOKEN_STRING_INITIALIZER
13516 (struct cmd_vf_split_drop_en_result,
13520 cmd_set_vf_split_drop_en_parsed(
13521 void *parsed_result,
13522 __attribute__((unused)) struct cmdline *cl,
13523 __attribute__((unused)) void *data)
13525 struct cmd_vf_split_drop_en_result *res = parsed_result;
13526 int ret = -ENOTSUP;
13527 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13529 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13532 #ifdef RTE_LIBRTE_IXGBE_PMD
13533 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13540 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13543 printf("invalid port_id %d\n", res->port_id);
13546 printf("not supported on port %d\n", res->port_id);
13549 printf("programming error: (%s)\n", strerror(-ret));
13553 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13554 .f = cmd_set_vf_split_drop_en_parsed,
13556 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13558 (void *)&cmd_vf_split_drop_en_set,
13559 (void *)&cmd_vf_split_drop_en_vf,
13560 (void *)&cmd_vf_split_drop_en_split,
13561 (void *)&cmd_vf_split_drop_en_drop,
13562 (void *)&cmd_vf_split_drop_en_port_id,
13563 (void *)&cmd_vf_split_drop_en_vf_id,
13564 (void *)&cmd_vf_split_drop_en_on_off,
13569 /* vf mac address configuration */
13571 /* Common result structure for vf mac address */
13572 struct cmd_set_vf_mac_addr_result {
13573 cmdline_fixed_string_t set;
13574 cmdline_fixed_string_t vf;
13575 cmdline_fixed_string_t mac;
13576 cmdline_fixed_string_t addr;
13579 struct ether_addr mac_addr;
13583 /* Common CLI fields for vf split drop enable disable */
13584 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13585 TOKEN_STRING_INITIALIZER
13586 (struct cmd_set_vf_mac_addr_result,
13588 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13589 TOKEN_STRING_INITIALIZER
13590 (struct cmd_set_vf_mac_addr_result,
13592 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13593 TOKEN_STRING_INITIALIZER
13594 (struct cmd_set_vf_mac_addr_result,
13596 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13597 TOKEN_STRING_INITIALIZER
13598 (struct cmd_set_vf_mac_addr_result,
13600 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13601 TOKEN_NUM_INITIALIZER
13602 (struct cmd_set_vf_mac_addr_result,
13604 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13605 TOKEN_NUM_INITIALIZER
13606 (struct cmd_set_vf_mac_addr_result,
13608 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13609 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13613 cmd_set_vf_mac_addr_parsed(
13614 void *parsed_result,
13615 __attribute__((unused)) struct cmdline *cl,
13616 __attribute__((unused)) void *data)
13618 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13619 int ret = -ENOTSUP;
13621 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13624 #ifdef RTE_LIBRTE_IXGBE_PMD
13625 if (ret == -ENOTSUP)
13626 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13629 #ifdef RTE_LIBRTE_I40E_PMD
13630 if (ret == -ENOTSUP)
13631 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13634 #ifdef RTE_LIBRTE_BNXT_PMD
13635 if (ret == -ENOTSUP)
13636 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13644 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13647 printf("invalid port_id %d\n", res->port_id);
13650 printf("function not implemented\n");
13653 printf("programming error: (%s)\n", strerror(-ret));
13657 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13658 .f = cmd_set_vf_mac_addr_parsed,
13660 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13662 (void *)&cmd_set_vf_mac_addr_set,
13663 (void *)&cmd_set_vf_mac_addr_vf,
13664 (void *)&cmd_set_vf_mac_addr_mac,
13665 (void *)&cmd_set_vf_mac_addr_addr,
13666 (void *)&cmd_set_vf_mac_addr_port_id,
13667 (void *)&cmd_set_vf_mac_addr_vf_id,
13668 (void *)&cmd_set_vf_mac_addr_mac_addr,
13673 /* MACsec configuration */
13675 /* Common result structure for MACsec offload enable */
13676 struct cmd_macsec_offload_on_result {
13677 cmdline_fixed_string_t set;
13678 cmdline_fixed_string_t macsec;
13679 cmdline_fixed_string_t offload;
13681 cmdline_fixed_string_t on;
13682 cmdline_fixed_string_t encrypt;
13683 cmdline_fixed_string_t en_on_off;
13684 cmdline_fixed_string_t replay_protect;
13685 cmdline_fixed_string_t rp_on_off;
13688 /* Common CLI fields for MACsec offload disable */
13689 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13690 TOKEN_STRING_INITIALIZER
13691 (struct cmd_macsec_offload_on_result,
13693 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13694 TOKEN_STRING_INITIALIZER
13695 (struct cmd_macsec_offload_on_result,
13697 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13698 TOKEN_STRING_INITIALIZER
13699 (struct cmd_macsec_offload_on_result,
13700 offload, "offload");
13701 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13702 TOKEN_NUM_INITIALIZER
13703 (struct cmd_macsec_offload_on_result,
13705 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13706 TOKEN_STRING_INITIALIZER
13707 (struct cmd_macsec_offload_on_result,
13709 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13710 TOKEN_STRING_INITIALIZER
13711 (struct cmd_macsec_offload_on_result,
13712 encrypt, "encrypt");
13713 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13714 TOKEN_STRING_INITIALIZER
13715 (struct cmd_macsec_offload_on_result,
13716 en_on_off, "on#off");
13717 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13718 TOKEN_STRING_INITIALIZER
13719 (struct cmd_macsec_offload_on_result,
13720 replay_protect, "replay-protect");
13721 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13722 TOKEN_STRING_INITIALIZER
13723 (struct cmd_macsec_offload_on_result,
13724 rp_on_off, "on#off");
13727 cmd_set_macsec_offload_on_parsed(
13728 void *parsed_result,
13729 __attribute__((unused)) struct cmdline *cl,
13730 __attribute__((unused)) void *data)
13732 struct cmd_macsec_offload_on_result *res = parsed_result;
13733 int ret = -ENOTSUP;
13734 portid_t port_id = res->port_id;
13735 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13736 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13737 struct rte_eth_dev_info dev_info;
13739 if (port_id_is_invalid(port_id, ENABLED_WARN))
13741 if (!port_is_stopped(port_id)) {
13742 printf("Please stop port %d first\n", port_id);
13746 rte_eth_dev_info_get(port_id, &dev_info);
13747 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13748 #ifdef RTE_LIBRTE_IXGBE_PMD
13749 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13757 ports[port_id].dev_conf.txmode.offloads |=
13758 DEV_TX_OFFLOAD_MACSEC_INSERT;
13759 cmd_reconfig_device_queue(port_id, 1, 1);
13762 printf("invalid port_id %d\n", port_id);
13765 printf("not supported on port %d\n", port_id);
13768 printf("programming error: (%s)\n", strerror(-ret));
13772 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13773 .f = cmd_set_macsec_offload_on_parsed,
13775 .help_str = "set macsec offload <port_id> on "
13776 "encrypt on|off replay-protect on|off",
13778 (void *)&cmd_macsec_offload_on_set,
13779 (void *)&cmd_macsec_offload_on_macsec,
13780 (void *)&cmd_macsec_offload_on_offload,
13781 (void *)&cmd_macsec_offload_on_port_id,
13782 (void *)&cmd_macsec_offload_on_on,
13783 (void *)&cmd_macsec_offload_on_encrypt,
13784 (void *)&cmd_macsec_offload_on_en_on_off,
13785 (void *)&cmd_macsec_offload_on_replay_protect,
13786 (void *)&cmd_macsec_offload_on_rp_on_off,
13791 /* Common result structure for MACsec offload disable */
13792 struct cmd_macsec_offload_off_result {
13793 cmdline_fixed_string_t set;
13794 cmdline_fixed_string_t macsec;
13795 cmdline_fixed_string_t offload;
13797 cmdline_fixed_string_t off;
13800 /* Common CLI fields for MACsec offload disable */
13801 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13802 TOKEN_STRING_INITIALIZER
13803 (struct cmd_macsec_offload_off_result,
13805 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13806 TOKEN_STRING_INITIALIZER
13807 (struct cmd_macsec_offload_off_result,
13809 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13810 TOKEN_STRING_INITIALIZER
13811 (struct cmd_macsec_offload_off_result,
13812 offload, "offload");
13813 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13814 TOKEN_NUM_INITIALIZER
13815 (struct cmd_macsec_offload_off_result,
13817 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13818 TOKEN_STRING_INITIALIZER
13819 (struct cmd_macsec_offload_off_result,
13823 cmd_set_macsec_offload_off_parsed(
13824 void *parsed_result,
13825 __attribute__((unused)) struct cmdline *cl,
13826 __attribute__((unused)) void *data)
13828 struct cmd_macsec_offload_off_result *res = parsed_result;
13829 int ret = -ENOTSUP;
13830 struct rte_eth_dev_info dev_info;
13831 portid_t port_id = res->port_id;
13833 if (port_id_is_invalid(port_id, ENABLED_WARN))
13835 if (!port_is_stopped(port_id)) {
13836 printf("Please stop port %d first\n", port_id);
13840 rte_eth_dev_info_get(port_id, &dev_info);
13841 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13842 #ifdef RTE_LIBRTE_IXGBE_PMD
13843 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13848 ports[port_id].dev_conf.txmode.offloads &=
13849 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13850 cmd_reconfig_device_queue(port_id, 1, 1);
13853 printf("invalid port_id %d\n", port_id);
13856 printf("not supported on port %d\n", port_id);
13859 printf("programming error: (%s)\n", strerror(-ret));
13863 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13864 .f = cmd_set_macsec_offload_off_parsed,
13866 .help_str = "set macsec offload <port_id> off",
13868 (void *)&cmd_macsec_offload_off_set,
13869 (void *)&cmd_macsec_offload_off_macsec,
13870 (void *)&cmd_macsec_offload_off_offload,
13871 (void *)&cmd_macsec_offload_off_port_id,
13872 (void *)&cmd_macsec_offload_off_off,
13877 /* Common result structure for MACsec secure connection configure */
13878 struct cmd_macsec_sc_result {
13879 cmdline_fixed_string_t set;
13880 cmdline_fixed_string_t macsec;
13881 cmdline_fixed_string_t sc;
13882 cmdline_fixed_string_t tx_rx;
13884 struct ether_addr mac;
13888 /* Common CLI fields for MACsec secure connection configure */
13889 cmdline_parse_token_string_t cmd_macsec_sc_set =
13890 TOKEN_STRING_INITIALIZER
13891 (struct cmd_macsec_sc_result,
13893 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13894 TOKEN_STRING_INITIALIZER
13895 (struct cmd_macsec_sc_result,
13897 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13898 TOKEN_STRING_INITIALIZER
13899 (struct cmd_macsec_sc_result,
13901 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13902 TOKEN_STRING_INITIALIZER
13903 (struct cmd_macsec_sc_result,
13905 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13906 TOKEN_NUM_INITIALIZER
13907 (struct cmd_macsec_sc_result,
13909 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13910 TOKEN_ETHERADDR_INITIALIZER
13911 (struct cmd_macsec_sc_result,
13913 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13914 TOKEN_NUM_INITIALIZER
13915 (struct cmd_macsec_sc_result,
13919 cmd_set_macsec_sc_parsed(
13920 void *parsed_result,
13921 __attribute__((unused)) struct cmdline *cl,
13922 __attribute__((unused)) void *data)
13924 struct cmd_macsec_sc_result *res = parsed_result;
13925 int ret = -ENOTSUP;
13926 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13928 #ifdef RTE_LIBRTE_IXGBE_PMD
13930 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13931 res->mac.addr_bytes) :
13932 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13933 res->mac.addr_bytes, res->pi);
13935 RTE_SET_USED(is_tx);
13941 printf("invalid port_id %d\n", res->port_id);
13944 printf("not supported on port %d\n", res->port_id);
13947 printf("programming error: (%s)\n", strerror(-ret));
13951 cmdline_parse_inst_t cmd_set_macsec_sc = {
13952 .f = cmd_set_macsec_sc_parsed,
13954 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13956 (void *)&cmd_macsec_sc_set,
13957 (void *)&cmd_macsec_sc_macsec,
13958 (void *)&cmd_macsec_sc_sc,
13959 (void *)&cmd_macsec_sc_tx_rx,
13960 (void *)&cmd_macsec_sc_port_id,
13961 (void *)&cmd_macsec_sc_mac,
13962 (void *)&cmd_macsec_sc_pi,
13967 /* Common result structure for MACsec secure connection configure */
13968 struct cmd_macsec_sa_result {
13969 cmdline_fixed_string_t set;
13970 cmdline_fixed_string_t macsec;
13971 cmdline_fixed_string_t sa;
13972 cmdline_fixed_string_t tx_rx;
13977 cmdline_fixed_string_t key;
13980 /* Common CLI fields for MACsec secure connection configure */
13981 cmdline_parse_token_string_t cmd_macsec_sa_set =
13982 TOKEN_STRING_INITIALIZER
13983 (struct cmd_macsec_sa_result,
13985 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13986 TOKEN_STRING_INITIALIZER
13987 (struct cmd_macsec_sa_result,
13989 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13990 TOKEN_STRING_INITIALIZER
13991 (struct cmd_macsec_sa_result,
13993 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13994 TOKEN_STRING_INITIALIZER
13995 (struct cmd_macsec_sa_result,
13997 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13998 TOKEN_NUM_INITIALIZER
13999 (struct cmd_macsec_sa_result,
14001 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14002 TOKEN_NUM_INITIALIZER
14003 (struct cmd_macsec_sa_result,
14005 cmdline_parse_token_num_t cmd_macsec_sa_an =
14006 TOKEN_NUM_INITIALIZER
14007 (struct cmd_macsec_sa_result,
14009 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14010 TOKEN_NUM_INITIALIZER
14011 (struct cmd_macsec_sa_result,
14013 cmdline_parse_token_string_t cmd_macsec_sa_key =
14014 TOKEN_STRING_INITIALIZER
14015 (struct cmd_macsec_sa_result,
14019 cmd_set_macsec_sa_parsed(
14020 void *parsed_result,
14021 __attribute__((unused)) struct cmdline *cl,
14022 __attribute__((unused)) void *data)
14024 struct cmd_macsec_sa_result *res = parsed_result;
14025 int ret = -ENOTSUP;
14026 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14027 uint8_t key[16] = { 0 };
14033 key_len = strlen(res->key) / 2;
14037 for (i = 0; i < key_len; i++) {
14038 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14041 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14044 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14047 #ifdef RTE_LIBRTE_IXGBE_PMD
14049 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14050 res->idx, res->an, res->pn, key) :
14051 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14052 res->idx, res->an, res->pn, key);
14054 RTE_SET_USED(is_tx);
14061 printf("invalid idx %d or an %d\n", res->idx, res->an);
14064 printf("invalid port_id %d\n", res->port_id);
14067 printf("not supported on port %d\n", res->port_id);
14070 printf("programming error: (%s)\n", strerror(-ret));
14074 cmdline_parse_inst_t cmd_set_macsec_sa = {
14075 .f = cmd_set_macsec_sa_parsed,
14077 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14079 (void *)&cmd_macsec_sa_set,
14080 (void *)&cmd_macsec_sa_macsec,
14081 (void *)&cmd_macsec_sa_sa,
14082 (void *)&cmd_macsec_sa_tx_rx,
14083 (void *)&cmd_macsec_sa_port_id,
14084 (void *)&cmd_macsec_sa_idx,
14085 (void *)&cmd_macsec_sa_an,
14086 (void *)&cmd_macsec_sa_pn,
14087 (void *)&cmd_macsec_sa_key,
14092 /* VF unicast promiscuous mode configuration */
14094 /* Common result structure for VF unicast promiscuous mode */
14095 struct cmd_vf_promisc_result {
14096 cmdline_fixed_string_t set;
14097 cmdline_fixed_string_t vf;
14098 cmdline_fixed_string_t promisc;
14101 cmdline_fixed_string_t on_off;
14104 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14105 cmdline_parse_token_string_t cmd_vf_promisc_set =
14106 TOKEN_STRING_INITIALIZER
14107 (struct cmd_vf_promisc_result,
14109 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14110 TOKEN_STRING_INITIALIZER
14111 (struct cmd_vf_promisc_result,
14113 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14114 TOKEN_STRING_INITIALIZER
14115 (struct cmd_vf_promisc_result,
14116 promisc, "promisc");
14117 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14118 TOKEN_NUM_INITIALIZER
14119 (struct cmd_vf_promisc_result,
14121 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14122 TOKEN_NUM_INITIALIZER
14123 (struct cmd_vf_promisc_result,
14125 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14126 TOKEN_STRING_INITIALIZER
14127 (struct cmd_vf_promisc_result,
14131 cmd_set_vf_promisc_parsed(
14132 void *parsed_result,
14133 __attribute__((unused)) struct cmdline *cl,
14134 __attribute__((unused)) void *data)
14136 struct cmd_vf_promisc_result *res = parsed_result;
14137 int ret = -ENOTSUP;
14139 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14141 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14144 #ifdef RTE_LIBRTE_I40E_PMD
14145 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14146 res->vf_id, is_on);
14153 printf("invalid vf_id %d\n", res->vf_id);
14156 printf("invalid port_id %d\n", res->port_id);
14159 printf("function not implemented\n");
14162 printf("programming error: (%s)\n", strerror(-ret));
14166 cmdline_parse_inst_t cmd_set_vf_promisc = {
14167 .f = cmd_set_vf_promisc_parsed,
14169 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14170 "Set unicast promiscuous mode for a VF from the PF",
14172 (void *)&cmd_vf_promisc_set,
14173 (void *)&cmd_vf_promisc_vf,
14174 (void *)&cmd_vf_promisc_promisc,
14175 (void *)&cmd_vf_promisc_port_id,
14176 (void *)&cmd_vf_promisc_vf_id,
14177 (void *)&cmd_vf_promisc_on_off,
14182 /* VF multicast promiscuous mode configuration */
14184 /* Common result structure for VF multicast promiscuous mode */
14185 struct cmd_vf_allmulti_result {
14186 cmdline_fixed_string_t set;
14187 cmdline_fixed_string_t vf;
14188 cmdline_fixed_string_t allmulti;
14191 cmdline_fixed_string_t on_off;
14194 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14195 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14196 TOKEN_STRING_INITIALIZER
14197 (struct cmd_vf_allmulti_result,
14199 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14200 TOKEN_STRING_INITIALIZER
14201 (struct cmd_vf_allmulti_result,
14203 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14204 TOKEN_STRING_INITIALIZER
14205 (struct cmd_vf_allmulti_result,
14206 allmulti, "allmulti");
14207 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14208 TOKEN_NUM_INITIALIZER
14209 (struct cmd_vf_allmulti_result,
14211 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14212 TOKEN_NUM_INITIALIZER
14213 (struct cmd_vf_allmulti_result,
14215 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14216 TOKEN_STRING_INITIALIZER
14217 (struct cmd_vf_allmulti_result,
14221 cmd_set_vf_allmulti_parsed(
14222 void *parsed_result,
14223 __attribute__((unused)) struct cmdline *cl,
14224 __attribute__((unused)) void *data)
14226 struct cmd_vf_allmulti_result *res = parsed_result;
14227 int ret = -ENOTSUP;
14229 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14231 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14234 #ifdef RTE_LIBRTE_I40E_PMD
14235 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14236 res->vf_id, is_on);
14243 printf("invalid vf_id %d\n", res->vf_id);
14246 printf("invalid port_id %d\n", res->port_id);
14249 printf("function not implemented\n");
14252 printf("programming error: (%s)\n", strerror(-ret));
14256 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14257 .f = cmd_set_vf_allmulti_parsed,
14259 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14260 "Set multicast promiscuous mode for a VF from the PF",
14262 (void *)&cmd_vf_allmulti_set,
14263 (void *)&cmd_vf_allmulti_vf,
14264 (void *)&cmd_vf_allmulti_allmulti,
14265 (void *)&cmd_vf_allmulti_port_id,
14266 (void *)&cmd_vf_allmulti_vf_id,
14267 (void *)&cmd_vf_allmulti_on_off,
14272 /* vf broadcast mode configuration */
14274 /* Common result structure for vf broadcast */
14275 struct cmd_set_vf_broadcast_result {
14276 cmdline_fixed_string_t set;
14277 cmdline_fixed_string_t vf;
14278 cmdline_fixed_string_t broadcast;
14281 cmdline_fixed_string_t on_off;
14284 /* Common CLI fields for vf broadcast enable disable */
14285 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14286 TOKEN_STRING_INITIALIZER
14287 (struct cmd_set_vf_broadcast_result,
14289 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14290 TOKEN_STRING_INITIALIZER
14291 (struct cmd_set_vf_broadcast_result,
14293 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14294 TOKEN_STRING_INITIALIZER
14295 (struct cmd_set_vf_broadcast_result,
14296 broadcast, "broadcast");
14297 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14298 TOKEN_NUM_INITIALIZER
14299 (struct cmd_set_vf_broadcast_result,
14301 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14302 TOKEN_NUM_INITIALIZER
14303 (struct cmd_set_vf_broadcast_result,
14305 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14306 TOKEN_STRING_INITIALIZER
14307 (struct cmd_set_vf_broadcast_result,
14311 cmd_set_vf_broadcast_parsed(
14312 void *parsed_result,
14313 __attribute__((unused)) struct cmdline *cl,
14314 __attribute__((unused)) void *data)
14316 struct cmd_set_vf_broadcast_result *res = parsed_result;
14317 int ret = -ENOTSUP;
14319 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14321 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14324 #ifdef RTE_LIBRTE_I40E_PMD
14325 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14326 res->vf_id, is_on);
14333 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14336 printf("invalid port_id %d\n", res->port_id);
14339 printf("function not implemented\n");
14342 printf("programming error: (%s)\n", strerror(-ret));
14346 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14347 .f = cmd_set_vf_broadcast_parsed,
14349 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14351 (void *)&cmd_set_vf_broadcast_set,
14352 (void *)&cmd_set_vf_broadcast_vf,
14353 (void *)&cmd_set_vf_broadcast_broadcast,
14354 (void *)&cmd_set_vf_broadcast_port_id,
14355 (void *)&cmd_set_vf_broadcast_vf_id,
14356 (void *)&cmd_set_vf_broadcast_on_off,
14361 /* vf vlan tag configuration */
14363 /* Common result structure for vf vlan tag */
14364 struct cmd_set_vf_vlan_tag_result {
14365 cmdline_fixed_string_t set;
14366 cmdline_fixed_string_t vf;
14367 cmdline_fixed_string_t vlan;
14368 cmdline_fixed_string_t tag;
14371 cmdline_fixed_string_t on_off;
14374 /* Common CLI fields for vf vlan tag enable disable */
14375 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14376 TOKEN_STRING_INITIALIZER
14377 (struct cmd_set_vf_vlan_tag_result,
14379 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14380 TOKEN_STRING_INITIALIZER
14381 (struct cmd_set_vf_vlan_tag_result,
14383 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14384 TOKEN_STRING_INITIALIZER
14385 (struct cmd_set_vf_vlan_tag_result,
14387 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14388 TOKEN_STRING_INITIALIZER
14389 (struct cmd_set_vf_vlan_tag_result,
14391 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14392 TOKEN_NUM_INITIALIZER
14393 (struct cmd_set_vf_vlan_tag_result,
14395 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14396 TOKEN_NUM_INITIALIZER
14397 (struct cmd_set_vf_vlan_tag_result,
14399 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14400 TOKEN_STRING_INITIALIZER
14401 (struct cmd_set_vf_vlan_tag_result,
14405 cmd_set_vf_vlan_tag_parsed(
14406 void *parsed_result,
14407 __attribute__((unused)) struct cmdline *cl,
14408 __attribute__((unused)) void *data)
14410 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14411 int ret = -ENOTSUP;
14413 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14415 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14418 #ifdef RTE_LIBRTE_I40E_PMD
14419 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14420 res->vf_id, is_on);
14427 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14430 printf("invalid port_id %d\n", res->port_id);
14433 printf("function not implemented\n");
14436 printf("programming error: (%s)\n", strerror(-ret));
14440 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14441 .f = cmd_set_vf_vlan_tag_parsed,
14443 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14445 (void *)&cmd_set_vf_vlan_tag_set,
14446 (void *)&cmd_set_vf_vlan_tag_vf,
14447 (void *)&cmd_set_vf_vlan_tag_vlan,
14448 (void *)&cmd_set_vf_vlan_tag_tag,
14449 (void *)&cmd_set_vf_vlan_tag_port_id,
14450 (void *)&cmd_set_vf_vlan_tag_vf_id,
14451 (void *)&cmd_set_vf_vlan_tag_on_off,
14456 /* Common definition of VF and TC TX bandwidth configuration */
14457 struct cmd_vf_tc_bw_result {
14458 cmdline_fixed_string_t set;
14459 cmdline_fixed_string_t vf;
14460 cmdline_fixed_string_t tc;
14461 cmdline_fixed_string_t tx;
14462 cmdline_fixed_string_t min_bw;
14463 cmdline_fixed_string_t max_bw;
14464 cmdline_fixed_string_t strict_link_prio;
14469 cmdline_fixed_string_t bw_list;
14473 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14474 TOKEN_STRING_INITIALIZER
14475 (struct cmd_vf_tc_bw_result,
14477 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14478 TOKEN_STRING_INITIALIZER
14479 (struct cmd_vf_tc_bw_result,
14481 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14482 TOKEN_STRING_INITIALIZER
14483 (struct cmd_vf_tc_bw_result,
14485 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14486 TOKEN_STRING_INITIALIZER
14487 (struct cmd_vf_tc_bw_result,
14489 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14490 TOKEN_STRING_INITIALIZER
14491 (struct cmd_vf_tc_bw_result,
14492 strict_link_prio, "strict-link-priority");
14493 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14494 TOKEN_STRING_INITIALIZER
14495 (struct cmd_vf_tc_bw_result,
14496 min_bw, "min-bandwidth");
14497 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14498 TOKEN_STRING_INITIALIZER
14499 (struct cmd_vf_tc_bw_result,
14500 max_bw, "max-bandwidth");
14501 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14502 TOKEN_NUM_INITIALIZER
14503 (struct cmd_vf_tc_bw_result,
14505 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14506 TOKEN_NUM_INITIALIZER
14507 (struct cmd_vf_tc_bw_result,
14509 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14510 TOKEN_NUM_INITIALIZER
14511 (struct cmd_vf_tc_bw_result,
14513 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14514 TOKEN_NUM_INITIALIZER
14515 (struct cmd_vf_tc_bw_result,
14517 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14518 TOKEN_STRING_INITIALIZER
14519 (struct cmd_vf_tc_bw_result,
14521 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14522 TOKEN_NUM_INITIALIZER
14523 (struct cmd_vf_tc_bw_result,
14526 /* VF max bandwidth setting */
14528 cmd_vf_max_bw_parsed(
14529 void *parsed_result,
14530 __attribute__((unused)) struct cmdline *cl,
14531 __attribute__((unused)) void *data)
14533 struct cmd_vf_tc_bw_result *res = parsed_result;
14534 int ret = -ENOTSUP;
14536 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14539 #ifdef RTE_LIBRTE_I40E_PMD
14540 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14541 res->vf_id, res->bw);
14548 printf("invalid vf_id %d or bandwidth %d\n",
14549 res->vf_id, res->bw);
14552 printf("invalid port_id %d\n", res->port_id);
14555 printf("function not implemented\n");
14558 printf("programming error: (%s)\n", strerror(-ret));
14562 cmdline_parse_inst_t cmd_vf_max_bw = {
14563 .f = cmd_vf_max_bw_parsed,
14565 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14567 (void *)&cmd_vf_tc_bw_set,
14568 (void *)&cmd_vf_tc_bw_vf,
14569 (void *)&cmd_vf_tc_bw_tx,
14570 (void *)&cmd_vf_tc_bw_max_bw,
14571 (void *)&cmd_vf_tc_bw_port_id,
14572 (void *)&cmd_vf_tc_bw_vf_id,
14573 (void *)&cmd_vf_tc_bw_bw,
14579 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14584 const char *p, *p0 = str;
14591 p = strchr(p0, '(');
14593 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14597 p0 = strchr(p, ')');
14599 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14603 if (size >= sizeof(s)) {
14604 printf("The string size exceeds the internal buffer size\n");
14607 snprintf(s, sizeof(s), "%.*s", size, p);
14608 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14610 printf("Failed to get the bandwidth list. ");
14614 for (i = 0; i < ret; i++)
14615 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14620 /* TC min bandwidth setting */
14622 cmd_vf_tc_min_bw_parsed(
14623 void *parsed_result,
14624 __attribute__((unused)) struct cmdline *cl,
14625 __attribute__((unused)) void *data)
14627 struct cmd_vf_tc_bw_result *res = parsed_result;
14630 int ret = -ENOTSUP;
14632 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14635 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14639 #ifdef RTE_LIBRTE_I40E_PMD
14640 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14648 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14651 printf("invalid port_id %d\n", res->port_id);
14654 printf("function not implemented\n");
14657 printf("programming error: (%s)\n", strerror(-ret));
14661 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14662 .f = cmd_vf_tc_min_bw_parsed,
14664 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14665 " <bw1, bw2, ...>",
14667 (void *)&cmd_vf_tc_bw_set,
14668 (void *)&cmd_vf_tc_bw_vf,
14669 (void *)&cmd_vf_tc_bw_tc,
14670 (void *)&cmd_vf_tc_bw_tx,
14671 (void *)&cmd_vf_tc_bw_min_bw,
14672 (void *)&cmd_vf_tc_bw_port_id,
14673 (void *)&cmd_vf_tc_bw_vf_id,
14674 (void *)&cmd_vf_tc_bw_bw_list,
14680 cmd_tc_min_bw_parsed(
14681 void *parsed_result,
14682 __attribute__((unused)) struct cmdline *cl,
14683 __attribute__((unused)) void *data)
14685 struct cmd_vf_tc_bw_result *res = parsed_result;
14686 struct rte_port *port;
14689 int ret = -ENOTSUP;
14691 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14694 port = &ports[res->port_id];
14695 /** Check if the port is not started **/
14696 if (port->port_status != RTE_PORT_STOPPED) {
14697 printf("Please stop port %d first\n", res->port_id);
14701 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14705 #ifdef RTE_LIBRTE_IXGBE_PMD
14706 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14713 printf("invalid bandwidth\n");
14716 printf("invalid port_id %d\n", res->port_id);
14719 printf("function not implemented\n");
14722 printf("programming error: (%s)\n", strerror(-ret));
14726 cmdline_parse_inst_t cmd_tc_min_bw = {
14727 .f = cmd_tc_min_bw_parsed,
14729 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14731 (void *)&cmd_vf_tc_bw_set,
14732 (void *)&cmd_vf_tc_bw_tc,
14733 (void *)&cmd_vf_tc_bw_tx,
14734 (void *)&cmd_vf_tc_bw_min_bw,
14735 (void *)&cmd_vf_tc_bw_port_id,
14736 (void *)&cmd_vf_tc_bw_bw_list,
14741 /* TC max bandwidth setting */
14743 cmd_vf_tc_max_bw_parsed(
14744 void *parsed_result,
14745 __attribute__((unused)) struct cmdline *cl,
14746 __attribute__((unused)) void *data)
14748 struct cmd_vf_tc_bw_result *res = parsed_result;
14749 int ret = -ENOTSUP;
14751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14754 #ifdef RTE_LIBRTE_I40E_PMD
14755 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14756 res->tc_no, res->bw);
14763 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14764 res->vf_id, res->tc_no, res->bw);
14767 printf("invalid port_id %d\n", res->port_id);
14770 printf("function not implemented\n");
14773 printf("programming error: (%s)\n", strerror(-ret));
14777 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14778 .f = cmd_vf_tc_max_bw_parsed,
14780 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14783 (void *)&cmd_vf_tc_bw_set,
14784 (void *)&cmd_vf_tc_bw_vf,
14785 (void *)&cmd_vf_tc_bw_tc,
14786 (void *)&cmd_vf_tc_bw_tx,
14787 (void *)&cmd_vf_tc_bw_max_bw,
14788 (void *)&cmd_vf_tc_bw_port_id,
14789 (void *)&cmd_vf_tc_bw_vf_id,
14790 (void *)&cmd_vf_tc_bw_tc_no,
14791 (void *)&cmd_vf_tc_bw_bw,
14797 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14799 /* *** Set Port default Traffic Management Hierarchy *** */
14800 struct cmd_set_port_tm_hierarchy_default_result {
14801 cmdline_fixed_string_t set;
14802 cmdline_fixed_string_t port;
14803 cmdline_fixed_string_t tm;
14804 cmdline_fixed_string_t hierarchy;
14805 cmdline_fixed_string_t def;
14809 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14810 TOKEN_STRING_INITIALIZER(
14811 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14812 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14813 TOKEN_STRING_INITIALIZER(
14814 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14815 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14816 TOKEN_STRING_INITIALIZER(
14817 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14818 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14819 TOKEN_STRING_INITIALIZER(
14820 struct cmd_set_port_tm_hierarchy_default_result,
14821 hierarchy, "hierarchy");
14822 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14823 TOKEN_STRING_INITIALIZER(
14824 struct cmd_set_port_tm_hierarchy_default_result,
14826 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14827 TOKEN_NUM_INITIALIZER(
14828 struct cmd_set_port_tm_hierarchy_default_result,
14831 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14832 __attribute__((unused)) struct cmdline *cl,
14833 __attribute__((unused)) void *data)
14835 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14836 struct rte_port *p;
14837 portid_t port_id = res->port_id;
14839 if (port_id_is_invalid(port_id, ENABLED_WARN))
14842 p = &ports[port_id];
14844 /* Forward mode: tm */
14845 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
14846 printf(" softnicfwd mode not enabled(error)\n");
14850 /* Set the default tm hierarchy */
14851 p->softport.default_tm_hierarchy_enable = 1;
14854 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14855 .f = cmd_set_port_tm_hierarchy_default_parsed,
14857 .help_str = "set port tm hierarchy default <port_id>",
14859 (void *)&cmd_set_port_tm_hierarchy_default_set,
14860 (void *)&cmd_set_port_tm_hierarchy_default_port,
14861 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14862 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14863 (void *)&cmd_set_port_tm_hierarchy_default_default,
14864 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14870 /** Set VXLAN encapsulation details */
14871 struct cmd_set_vxlan_result {
14872 cmdline_fixed_string_t set;
14873 cmdline_fixed_string_t vxlan;
14874 cmdline_fixed_string_t pos_token;
14875 cmdline_fixed_string_t ip_version;
14876 uint32_t vlan_present:1;
14880 cmdline_ipaddr_t ip_src;
14881 cmdline_ipaddr_t ip_dst;
14883 struct ether_addr eth_src;
14884 struct ether_addr eth_dst;
14887 cmdline_parse_token_string_t cmd_set_vxlan_set =
14888 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
14889 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
14890 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
14891 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
14892 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14893 "vxlan-with-vlan");
14894 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
14895 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14897 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
14898 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
14900 cmdline_parse_token_string_t cmd_set_vxlan_vni =
14901 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14903 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
14904 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
14905 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
14906 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14908 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
14909 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
14910 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
14911 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14913 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
14914 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
14915 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
14916 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14918 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
14919 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
14920 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
14921 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14923 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
14924 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
14925 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
14926 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14928 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
14929 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
14930 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
14931 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14933 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
14934 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
14935 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
14936 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14938 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
14939 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
14941 static void cmd_set_vxlan_parsed(void *parsed_result,
14942 __attribute__((unused)) struct cmdline *cl,
14943 __attribute__((unused)) void *data)
14945 struct cmd_set_vxlan_result *res = parsed_result;
14950 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
14953 if (strcmp(res->vxlan, "vxlan") == 0)
14954 vxlan_encap_conf.select_vlan = 0;
14955 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
14956 vxlan_encap_conf.select_vlan = 1;
14957 if (strcmp(res->ip_version, "ipv4") == 0)
14958 vxlan_encap_conf.select_ipv4 = 1;
14959 else if (strcmp(res->ip_version, "ipv6") == 0)
14960 vxlan_encap_conf.select_ipv4 = 0;
14963 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
14964 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
14965 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
14966 if (vxlan_encap_conf.select_ipv4) {
14967 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
14968 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
14970 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
14971 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
14973 if (vxlan_encap_conf.select_vlan)
14974 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14975 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
14977 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14981 cmdline_parse_inst_t cmd_set_vxlan = {
14982 .f = cmd_set_vxlan_parsed,
14984 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
14985 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
14986 " eth-src <eth-src> eth-dst <eth-dst>",
14988 (void *)&cmd_set_vxlan_set,
14989 (void *)&cmd_set_vxlan_vxlan,
14990 (void *)&cmd_set_vxlan_ip_version,
14991 (void *)&cmd_set_vxlan_ip_version_value,
14992 (void *)&cmd_set_vxlan_vni,
14993 (void *)&cmd_set_vxlan_vni_value,
14994 (void *)&cmd_set_vxlan_udp_src,
14995 (void *)&cmd_set_vxlan_udp_src_value,
14996 (void *)&cmd_set_vxlan_udp_dst,
14997 (void *)&cmd_set_vxlan_udp_dst_value,
14998 (void *)&cmd_set_vxlan_ip_src,
14999 (void *)&cmd_set_vxlan_ip_src_value,
15000 (void *)&cmd_set_vxlan_ip_dst,
15001 (void *)&cmd_set_vxlan_ip_dst_value,
15002 (void *)&cmd_set_vxlan_eth_src,
15003 (void *)&cmd_set_vxlan_eth_src_value,
15004 (void *)&cmd_set_vxlan_eth_dst,
15005 (void *)&cmd_set_vxlan_eth_dst_value,
15010 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15011 .f = cmd_set_vxlan_parsed,
15013 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15014 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15015 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15018 (void *)&cmd_set_vxlan_set,
15019 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15020 (void *)&cmd_set_vxlan_ip_version,
15021 (void *)&cmd_set_vxlan_ip_version_value,
15022 (void *)&cmd_set_vxlan_vni,
15023 (void *)&cmd_set_vxlan_vni_value,
15024 (void *)&cmd_set_vxlan_udp_src,
15025 (void *)&cmd_set_vxlan_udp_src_value,
15026 (void *)&cmd_set_vxlan_udp_dst,
15027 (void *)&cmd_set_vxlan_udp_dst_value,
15028 (void *)&cmd_set_vxlan_ip_src,
15029 (void *)&cmd_set_vxlan_ip_src_value,
15030 (void *)&cmd_set_vxlan_ip_dst,
15031 (void *)&cmd_set_vxlan_ip_dst_value,
15032 (void *)&cmd_set_vxlan_vlan,
15033 (void *)&cmd_set_vxlan_vlan_value,
15034 (void *)&cmd_set_vxlan_eth_src,
15035 (void *)&cmd_set_vxlan_eth_src_value,
15036 (void *)&cmd_set_vxlan_eth_dst,
15037 (void *)&cmd_set_vxlan_eth_dst_value,
15042 /** Set NVGRE encapsulation details */
15043 struct cmd_set_nvgre_result {
15044 cmdline_fixed_string_t set;
15045 cmdline_fixed_string_t nvgre;
15046 cmdline_fixed_string_t pos_token;
15047 cmdline_fixed_string_t ip_version;
15049 cmdline_ipaddr_t ip_src;
15050 cmdline_ipaddr_t ip_dst;
15052 struct ether_addr eth_src;
15053 struct ether_addr eth_dst;
15056 cmdline_parse_token_string_t cmd_set_nvgre_set =
15057 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15058 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15059 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15060 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15061 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15062 "nvgre-with-vlan");
15063 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15064 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15066 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15067 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15069 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15070 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15072 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15073 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15074 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15075 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15077 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15078 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15079 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15080 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15082 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15083 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15084 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15085 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15087 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15088 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15089 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15090 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15092 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15093 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15094 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15095 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15097 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15098 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15100 static void cmd_set_nvgre_parsed(void *parsed_result,
15101 __attribute__((unused)) struct cmdline *cl,
15102 __attribute__((unused)) void *data)
15104 struct cmd_set_nvgre_result *res = parsed_result;
15106 uint32_t nvgre_tni;
15109 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15112 if (strcmp(res->nvgre, "nvgre") == 0)
15113 nvgre_encap_conf.select_vlan = 0;
15114 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15115 nvgre_encap_conf.select_vlan = 1;
15116 if (strcmp(res->ip_version, "ipv4") == 0)
15117 nvgre_encap_conf.select_ipv4 = 1;
15118 else if (strcmp(res->ip_version, "ipv6") == 0)
15119 nvgre_encap_conf.select_ipv4 = 0;
15122 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15123 if (nvgre_encap_conf.select_ipv4) {
15124 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15125 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15127 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15128 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15130 if (nvgre_encap_conf.select_vlan)
15131 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15132 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15134 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15138 cmdline_parse_inst_t cmd_set_nvgre = {
15139 .f = cmd_set_nvgre_parsed,
15141 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15142 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15143 " eth-dst <eth-dst>",
15145 (void *)&cmd_set_nvgre_set,
15146 (void *)&cmd_set_nvgre_nvgre,
15147 (void *)&cmd_set_nvgre_ip_version,
15148 (void *)&cmd_set_nvgre_ip_version_value,
15149 (void *)&cmd_set_nvgre_tni,
15150 (void *)&cmd_set_nvgre_tni_value,
15151 (void *)&cmd_set_nvgre_ip_src,
15152 (void *)&cmd_set_nvgre_ip_src_value,
15153 (void *)&cmd_set_nvgre_ip_dst,
15154 (void *)&cmd_set_nvgre_ip_dst_value,
15155 (void *)&cmd_set_nvgre_eth_src,
15156 (void *)&cmd_set_nvgre_eth_src_value,
15157 (void *)&cmd_set_nvgre_eth_dst,
15158 (void *)&cmd_set_nvgre_eth_dst_value,
15163 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15164 .f = cmd_set_nvgre_parsed,
15166 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15167 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15168 " eth-src <eth-src> eth-dst <eth-dst>",
15170 (void *)&cmd_set_nvgre_set,
15171 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15172 (void *)&cmd_set_nvgre_ip_version,
15173 (void *)&cmd_set_nvgre_ip_version_value,
15174 (void *)&cmd_set_nvgre_tni,
15175 (void *)&cmd_set_nvgre_tni_value,
15176 (void *)&cmd_set_nvgre_ip_src,
15177 (void *)&cmd_set_nvgre_ip_src_value,
15178 (void *)&cmd_set_nvgre_ip_dst,
15179 (void *)&cmd_set_nvgre_ip_dst_value,
15180 (void *)&cmd_set_nvgre_vlan,
15181 (void *)&cmd_set_nvgre_vlan_value,
15182 (void *)&cmd_set_nvgre_eth_src,
15183 (void *)&cmd_set_nvgre_eth_src_value,
15184 (void *)&cmd_set_nvgre_eth_dst,
15185 (void *)&cmd_set_nvgre_eth_dst_value,
15190 /* Strict link priority scheduling mode setting */
15192 cmd_strict_link_prio_parsed(
15193 void *parsed_result,
15194 __attribute__((unused)) struct cmdline *cl,
15195 __attribute__((unused)) void *data)
15197 struct cmd_vf_tc_bw_result *res = parsed_result;
15198 int ret = -ENOTSUP;
15200 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15203 #ifdef RTE_LIBRTE_I40E_PMD
15204 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15211 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15214 printf("invalid port_id %d\n", res->port_id);
15217 printf("function not implemented\n");
15220 printf("programming error: (%s)\n", strerror(-ret));
15224 cmdline_parse_inst_t cmd_strict_link_prio = {
15225 .f = cmd_strict_link_prio_parsed,
15227 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
15229 (void *)&cmd_vf_tc_bw_set,
15230 (void *)&cmd_vf_tc_bw_tx,
15231 (void *)&cmd_vf_tc_bw_strict_link_prio,
15232 (void *)&cmd_vf_tc_bw_port_id,
15233 (void *)&cmd_vf_tc_bw_tc_map,
15238 /* Load dynamic device personalization*/
15239 struct cmd_ddp_add_result {
15240 cmdline_fixed_string_t ddp;
15241 cmdline_fixed_string_t add;
15246 cmdline_parse_token_string_t cmd_ddp_add_ddp =
15247 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
15248 cmdline_parse_token_string_t cmd_ddp_add_add =
15249 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
15250 cmdline_parse_token_num_t cmd_ddp_add_port_id =
15251 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
15252 cmdline_parse_token_string_t cmd_ddp_add_filepath =
15253 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
15256 cmd_ddp_add_parsed(
15257 void *parsed_result,
15258 __attribute__((unused)) struct cmdline *cl,
15259 __attribute__((unused)) void *data)
15261 struct cmd_ddp_add_result *res = parsed_result;
15267 int ret = -ENOTSUP;
15269 if (!all_ports_stopped()) {
15270 printf("Please stop all ports first\n");
15274 filepath = strdup(res->filepath);
15275 if (filepath == NULL) {
15276 printf("Failed to allocate memory\n");
15279 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
15281 buff = open_file(file_fld[0], &size);
15283 free((void *)filepath);
15287 #ifdef RTE_LIBRTE_I40E_PMD
15288 if (ret == -ENOTSUP)
15289 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15291 RTE_PMD_I40E_PKG_OP_WR_ADD);
15294 if (ret == -EEXIST)
15295 printf("Profile has already existed.\n");
15297 printf("Failed to load profile.\n");
15298 else if (file_num == 2)
15299 save_file(file_fld[1], buff, size);
15302 free((void *)filepath);
15305 cmdline_parse_inst_t cmd_ddp_add = {
15306 .f = cmd_ddp_add_parsed,
15308 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
15310 (void *)&cmd_ddp_add_ddp,
15311 (void *)&cmd_ddp_add_add,
15312 (void *)&cmd_ddp_add_port_id,
15313 (void *)&cmd_ddp_add_filepath,
15318 /* Delete dynamic device personalization*/
15319 struct cmd_ddp_del_result {
15320 cmdline_fixed_string_t ddp;
15321 cmdline_fixed_string_t del;
15326 cmdline_parse_token_string_t cmd_ddp_del_ddp =
15327 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
15328 cmdline_parse_token_string_t cmd_ddp_del_del =
15329 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
15330 cmdline_parse_token_num_t cmd_ddp_del_port_id =
15331 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
15332 cmdline_parse_token_string_t cmd_ddp_del_filepath =
15333 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
15336 cmd_ddp_del_parsed(
15337 void *parsed_result,
15338 __attribute__((unused)) struct cmdline *cl,
15339 __attribute__((unused)) void *data)
15341 struct cmd_ddp_del_result *res = parsed_result;
15344 int ret = -ENOTSUP;
15346 if (!all_ports_stopped()) {
15347 printf("Please stop all ports first\n");
15351 buff = open_file(res->filepath, &size);
15355 #ifdef RTE_LIBRTE_I40E_PMD
15356 if (ret == -ENOTSUP)
15357 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15359 RTE_PMD_I40E_PKG_OP_WR_DEL);
15362 if (ret == -EACCES)
15363 printf("Profile does not exist.\n");
15365 printf("Failed to delete profile.\n");
15370 cmdline_parse_inst_t cmd_ddp_del = {
15371 .f = cmd_ddp_del_parsed,
15373 .help_str = "ddp del <port_id> <backup_profile_path>",
15375 (void *)&cmd_ddp_del_ddp,
15376 (void *)&cmd_ddp_del_del,
15377 (void *)&cmd_ddp_del_port_id,
15378 (void *)&cmd_ddp_del_filepath,
15383 /* Get dynamic device personalization profile info */
15384 struct cmd_ddp_info_result {
15385 cmdline_fixed_string_t ddp;
15386 cmdline_fixed_string_t get;
15387 cmdline_fixed_string_t info;
15391 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15392 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15393 cmdline_parse_token_string_t cmd_ddp_info_get =
15394 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15395 cmdline_parse_token_string_t cmd_ddp_info_info =
15396 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15397 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15398 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15401 cmd_ddp_info_parsed(
15402 void *parsed_result,
15403 __attribute__((unused)) struct cmdline *cl,
15404 __attribute__((unused)) void *data)
15406 struct cmd_ddp_info_result *res = parsed_result;
15409 int ret = -ENOTSUP;
15410 #ifdef RTE_LIBRTE_I40E_PMD
15413 uint32_t buff_size = 0;
15414 struct rte_pmd_i40e_profile_info info;
15415 uint32_t dev_num = 0;
15416 struct rte_pmd_i40e_ddp_device_id *devs;
15417 uint32_t proto_num = 0;
15418 struct rte_pmd_i40e_proto_info *proto = NULL;
15419 uint32_t pctype_num = 0;
15420 struct rte_pmd_i40e_ptype_info *pctype;
15421 uint32_t ptype_num = 0;
15422 struct rte_pmd_i40e_ptype_info *ptype;
15427 pkg = open_file(res->filepath, &pkg_size);
15431 #ifdef RTE_LIBRTE_I40E_PMD
15432 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15433 (uint8_t *)&info, sizeof(info),
15434 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15436 printf("Global Track id: 0x%x\n", info.track_id);
15437 printf("Global Version: %d.%d.%d.%d\n",
15438 info.version.major,
15439 info.version.minor,
15440 info.version.update,
15441 info.version.draft);
15442 printf("Global Package name: %s\n\n", info.name);
15445 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15446 (uint8_t *)&info, sizeof(info),
15447 RTE_PMD_I40E_PKG_INFO_HEADER);
15449 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15450 printf("i40e Profile Version: %d.%d.%d.%d\n",
15451 info.version.major,
15452 info.version.minor,
15453 info.version.update,
15454 info.version.draft);
15455 printf("i40e Profile name: %s\n\n", info.name);
15458 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15459 (uint8_t *)&buff_size, sizeof(buff_size),
15460 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15461 if (!ret && buff_size) {
15462 buff = (uint8_t *)malloc(buff_size);
15464 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15466 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15468 printf("Package Notes:\n%s\n\n", buff);
15473 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15474 (uint8_t *)&dev_num, sizeof(dev_num),
15475 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15476 if (!ret && dev_num) {
15477 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15478 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15480 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15481 (uint8_t *)devs, buff_size,
15482 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15484 printf("List of supported devices:\n");
15485 for (i = 0; i < dev_num; i++) {
15486 printf(" %04X:%04X %04X:%04X\n",
15487 devs[i].vendor_dev_id >> 16,
15488 devs[i].vendor_dev_id & 0xFFFF,
15489 devs[i].sub_vendor_dev_id >> 16,
15490 devs[i].sub_vendor_dev_id & 0xFFFF);
15498 /* get information about protocols and packet types */
15499 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15500 (uint8_t *)&proto_num, sizeof(proto_num),
15501 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15502 if (ret || !proto_num)
15503 goto no_print_return;
15505 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15506 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15508 goto no_print_return;
15510 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15512 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15514 printf("List of used protocols:\n");
15515 for (i = 0; i < proto_num; i++)
15516 printf(" %2u: %s\n", proto[i].proto_id,
15520 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15521 (uint8_t *)&pctype_num, sizeof(pctype_num),
15522 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15523 if (ret || !pctype_num)
15524 goto no_print_pctypes;
15526 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15527 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15529 goto no_print_pctypes;
15531 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15533 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15536 goto no_print_pctypes;
15539 printf("List of defined packet classification types:\n");
15540 for (i = 0; i < pctype_num; i++) {
15541 printf(" %2u:", pctype[i].ptype_id);
15542 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15543 proto_id = pctype[i].protocols[j];
15544 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15545 for (n = 0; n < proto_num; n++) {
15546 if (proto[n].proto_id == proto_id) {
15547 printf(" %s", proto[n].name);
15560 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15562 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15563 if (ret || !ptype_num)
15564 goto no_print_return;
15566 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15567 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15569 goto no_print_return;
15571 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15573 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15576 goto no_print_return;
15578 printf("List of defined packet types:\n");
15579 for (i = 0; i < ptype_num; i++) {
15580 printf(" %2u:", ptype[i].ptype_id);
15581 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15582 proto_id = ptype[i].protocols[j];
15583 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15584 for (n = 0; n < proto_num; n++) {
15585 if (proto[n].proto_id == proto_id) {
15586 printf(" %s", proto[n].name);
15602 if (ret == -ENOTSUP)
15603 printf("Function not supported in PMD driver\n");
15607 cmdline_parse_inst_t cmd_ddp_get_info = {
15608 .f = cmd_ddp_info_parsed,
15610 .help_str = "ddp get info <profile_path>",
15612 (void *)&cmd_ddp_info_ddp,
15613 (void *)&cmd_ddp_info_get,
15614 (void *)&cmd_ddp_info_info,
15615 (void *)&cmd_ddp_info_filepath,
15620 /* Get dynamic device personalization profile info list*/
15621 #define PROFILE_INFO_SIZE 48
15622 #define MAX_PROFILE_NUM 16
15624 struct cmd_ddp_get_list_result {
15625 cmdline_fixed_string_t ddp;
15626 cmdline_fixed_string_t get;
15627 cmdline_fixed_string_t list;
15631 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15632 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15633 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15634 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15635 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15636 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15637 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15638 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15641 cmd_ddp_get_list_parsed(
15642 __attribute__((unused)) void *parsed_result,
15643 __attribute__((unused)) struct cmdline *cl,
15644 __attribute__((unused)) void *data)
15646 #ifdef RTE_LIBRTE_I40E_PMD
15647 struct cmd_ddp_get_list_result *res = parsed_result;
15648 struct rte_pmd_i40e_profile_list *p_list;
15649 struct rte_pmd_i40e_profile_info *p_info;
15654 int ret = -ENOTSUP;
15656 #ifdef RTE_LIBRTE_I40E_PMD
15657 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15658 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15660 printf("%s: Failed to malloc buffer\n", __func__);
15662 if (ret == -ENOTSUP)
15663 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15664 (uint8_t *)p_list, size);
15667 p_num = p_list->p_count;
15668 printf("Profile number is: %d\n\n", p_num);
15670 for (i = 0; i < p_num; i++) {
15671 p_info = &p_list->p_info[i];
15672 printf("Profile %d:\n", i);
15673 printf("Track id: 0x%x\n", p_info->track_id);
15674 printf("Version: %d.%d.%d.%d\n",
15675 p_info->version.major,
15676 p_info->version.minor,
15677 p_info->version.update,
15678 p_info->version.draft);
15679 printf("Profile name: %s\n\n", p_info->name);
15687 printf("Failed to get ddp list\n");
15690 cmdline_parse_inst_t cmd_ddp_get_list = {
15691 .f = cmd_ddp_get_list_parsed,
15693 .help_str = "ddp get list <port_id>",
15695 (void *)&cmd_ddp_get_list_ddp,
15696 (void *)&cmd_ddp_get_list_get,
15697 (void *)&cmd_ddp_get_list_list,
15698 (void *)&cmd_ddp_get_list_port_id,
15703 /* Configure input set */
15704 struct cmd_cfg_input_set_result {
15705 cmdline_fixed_string_t port;
15706 cmdline_fixed_string_t cfg;
15708 cmdline_fixed_string_t pctype;
15710 cmdline_fixed_string_t inset_type;
15711 cmdline_fixed_string_t opt;
15712 cmdline_fixed_string_t field;
15717 cmd_cfg_input_set_parsed(
15718 __attribute__((unused)) void *parsed_result,
15719 __attribute__((unused)) struct cmdline *cl,
15720 __attribute__((unused)) void *data)
15722 #ifdef RTE_LIBRTE_I40E_PMD
15723 struct cmd_cfg_input_set_result *res = parsed_result;
15724 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15725 struct rte_pmd_i40e_inset inset;
15727 int ret = -ENOTSUP;
15729 if (!all_ports_stopped()) {
15730 printf("Please stop all ports first\n");
15734 #ifdef RTE_LIBRTE_I40E_PMD
15735 if (!strcmp(res->inset_type, "hash_inset"))
15736 inset_type = INSET_HASH;
15737 else if (!strcmp(res->inset_type, "fdir_inset"))
15738 inset_type = INSET_FDIR;
15739 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15740 inset_type = INSET_FDIR_FLX;
15741 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15742 &inset, inset_type);
15744 printf("Failed to get input set.\n");
15748 if (!strcmp(res->opt, "get")) {
15749 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15752 printf("Field index %d is enabled.\n", res->field_idx);
15754 printf("Field index %d is disabled.\n", res->field_idx);
15756 } else if (!strcmp(res->opt, "set"))
15757 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15759 else if (!strcmp(res->opt, "clear"))
15760 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15763 printf("Failed to configure input set field.\n");
15767 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15768 &inset, inset_type);
15770 printf("Failed to set input set.\n");
15775 if (ret == -ENOTSUP)
15776 printf("Function not supported\n");
15779 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15780 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15782 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15783 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15785 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15786 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15788 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15789 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15791 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15792 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15794 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15795 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15797 "hash_inset#fdir_inset#fdir_flx_inset");
15798 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15799 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15800 opt, "get#set#clear");
15801 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15802 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15804 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15805 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15808 cmdline_parse_inst_t cmd_cfg_input_set = {
15809 .f = cmd_cfg_input_set_parsed,
15811 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15812 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15814 (void *)&cmd_cfg_input_set_port,
15815 (void *)&cmd_cfg_input_set_cfg,
15816 (void *)&cmd_cfg_input_set_port_id,
15817 (void *)&cmd_cfg_input_set_pctype,
15818 (void *)&cmd_cfg_input_set_pctype_id,
15819 (void *)&cmd_cfg_input_set_inset_type,
15820 (void *)&cmd_cfg_input_set_opt,
15821 (void *)&cmd_cfg_input_set_field,
15822 (void *)&cmd_cfg_input_set_field_idx,
15827 /* Clear input set */
15828 struct cmd_clear_input_set_result {
15829 cmdline_fixed_string_t port;
15830 cmdline_fixed_string_t cfg;
15832 cmdline_fixed_string_t pctype;
15834 cmdline_fixed_string_t inset_type;
15835 cmdline_fixed_string_t clear;
15836 cmdline_fixed_string_t all;
15840 cmd_clear_input_set_parsed(
15841 __attribute__((unused)) void *parsed_result,
15842 __attribute__((unused)) struct cmdline *cl,
15843 __attribute__((unused)) void *data)
15845 #ifdef RTE_LIBRTE_I40E_PMD
15846 struct cmd_clear_input_set_result *res = parsed_result;
15847 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15848 struct rte_pmd_i40e_inset inset;
15850 int ret = -ENOTSUP;
15852 if (!all_ports_stopped()) {
15853 printf("Please stop all ports first\n");
15857 #ifdef RTE_LIBRTE_I40E_PMD
15858 if (!strcmp(res->inset_type, "hash_inset"))
15859 inset_type = INSET_HASH;
15860 else if (!strcmp(res->inset_type, "fdir_inset"))
15861 inset_type = INSET_FDIR;
15862 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15863 inset_type = INSET_FDIR_FLX;
15865 memset(&inset, 0, sizeof(inset));
15867 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15868 &inset, inset_type);
15870 printf("Failed to clear input set.\n");
15876 if (ret == -ENOTSUP)
15877 printf("Function not supported\n");
15880 cmdline_parse_token_string_t cmd_clear_input_set_port =
15881 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15883 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15884 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15886 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15887 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15889 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15890 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15892 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15893 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15895 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15896 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15898 "hash_inset#fdir_inset#fdir_flx_inset");
15899 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15900 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15902 cmdline_parse_token_string_t cmd_clear_input_set_all =
15903 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15906 cmdline_parse_inst_t cmd_clear_input_set = {
15907 .f = cmd_clear_input_set_parsed,
15909 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15910 "fdir_inset|fdir_flx_inset clear all",
15912 (void *)&cmd_clear_input_set_port,
15913 (void *)&cmd_clear_input_set_cfg,
15914 (void *)&cmd_clear_input_set_port_id,
15915 (void *)&cmd_clear_input_set_pctype,
15916 (void *)&cmd_clear_input_set_pctype_id,
15917 (void *)&cmd_clear_input_set_inset_type,
15918 (void *)&cmd_clear_input_set_clear,
15919 (void *)&cmd_clear_input_set_all,
15924 /* show vf stats */
15926 /* Common result structure for show vf stats */
15927 struct cmd_show_vf_stats_result {
15928 cmdline_fixed_string_t show;
15929 cmdline_fixed_string_t vf;
15930 cmdline_fixed_string_t stats;
15935 /* Common CLI fields show vf stats*/
15936 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15937 TOKEN_STRING_INITIALIZER
15938 (struct cmd_show_vf_stats_result,
15940 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15941 TOKEN_STRING_INITIALIZER
15942 (struct cmd_show_vf_stats_result,
15944 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15945 TOKEN_STRING_INITIALIZER
15946 (struct cmd_show_vf_stats_result,
15948 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15949 TOKEN_NUM_INITIALIZER
15950 (struct cmd_show_vf_stats_result,
15952 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15953 TOKEN_NUM_INITIALIZER
15954 (struct cmd_show_vf_stats_result,
15958 cmd_show_vf_stats_parsed(
15959 void *parsed_result,
15960 __attribute__((unused)) struct cmdline *cl,
15961 __attribute__((unused)) void *data)
15963 struct cmd_show_vf_stats_result *res = parsed_result;
15964 struct rte_eth_stats stats;
15965 int ret = -ENOTSUP;
15966 static const char *nic_stats_border = "########################";
15968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15971 memset(&stats, 0, sizeof(stats));
15973 #ifdef RTE_LIBRTE_I40E_PMD
15974 if (ret == -ENOTSUP)
15975 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15979 #ifdef RTE_LIBRTE_BNXT_PMD
15980 if (ret == -ENOTSUP)
15981 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15990 printf("invalid vf_id %d\n", res->vf_id);
15993 printf("invalid port_id %d\n", res->port_id);
15996 printf("function not implemented\n");
15999 printf("programming error: (%s)\n", strerror(-ret));
16002 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16003 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16005 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16007 stats.ipackets, stats.imissed, stats.ibytes);
16008 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16009 printf(" RX-nombuf: %-10"PRIu64"\n",
16011 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16013 stats.opackets, stats.oerrors, stats.obytes);
16015 printf(" %s############################%s\n",
16016 nic_stats_border, nic_stats_border);
16019 cmdline_parse_inst_t cmd_show_vf_stats = {
16020 .f = cmd_show_vf_stats_parsed,
16022 .help_str = "show vf stats <port_id> <vf_id>",
16024 (void *)&cmd_show_vf_stats_show,
16025 (void *)&cmd_show_vf_stats_vf,
16026 (void *)&cmd_show_vf_stats_stats,
16027 (void *)&cmd_show_vf_stats_port_id,
16028 (void *)&cmd_show_vf_stats_vf_id,
16033 /* clear vf stats */
16035 /* Common result structure for clear vf stats */
16036 struct cmd_clear_vf_stats_result {
16037 cmdline_fixed_string_t clear;
16038 cmdline_fixed_string_t vf;
16039 cmdline_fixed_string_t stats;
16044 /* Common CLI fields clear vf stats*/
16045 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16046 TOKEN_STRING_INITIALIZER
16047 (struct cmd_clear_vf_stats_result,
16049 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16050 TOKEN_STRING_INITIALIZER
16051 (struct cmd_clear_vf_stats_result,
16053 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16054 TOKEN_STRING_INITIALIZER
16055 (struct cmd_clear_vf_stats_result,
16057 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16058 TOKEN_NUM_INITIALIZER
16059 (struct cmd_clear_vf_stats_result,
16061 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16062 TOKEN_NUM_INITIALIZER
16063 (struct cmd_clear_vf_stats_result,
16067 cmd_clear_vf_stats_parsed(
16068 void *parsed_result,
16069 __attribute__((unused)) struct cmdline *cl,
16070 __attribute__((unused)) void *data)
16072 struct cmd_clear_vf_stats_result *res = parsed_result;
16073 int ret = -ENOTSUP;
16075 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16078 #ifdef RTE_LIBRTE_I40E_PMD
16079 if (ret == -ENOTSUP)
16080 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16083 #ifdef RTE_LIBRTE_BNXT_PMD
16084 if (ret == -ENOTSUP)
16085 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16093 printf("invalid vf_id %d\n", res->vf_id);
16096 printf("invalid port_id %d\n", res->port_id);
16099 printf("function not implemented\n");
16102 printf("programming error: (%s)\n", strerror(-ret));
16106 cmdline_parse_inst_t cmd_clear_vf_stats = {
16107 .f = cmd_clear_vf_stats_parsed,
16109 .help_str = "clear vf stats <port_id> <vf_id>",
16111 (void *)&cmd_clear_vf_stats_clear,
16112 (void *)&cmd_clear_vf_stats_vf,
16113 (void *)&cmd_clear_vf_stats_stats,
16114 (void *)&cmd_clear_vf_stats_port_id,
16115 (void *)&cmd_clear_vf_stats_vf_id,
16120 /* port config pctype mapping reset */
16122 /* Common result structure for port config pctype mapping reset */
16123 struct cmd_pctype_mapping_reset_result {
16124 cmdline_fixed_string_t port;
16125 cmdline_fixed_string_t config;
16127 cmdline_fixed_string_t pctype;
16128 cmdline_fixed_string_t mapping;
16129 cmdline_fixed_string_t reset;
16132 /* Common CLI fields for port config pctype mapping reset*/
16133 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16134 TOKEN_STRING_INITIALIZER
16135 (struct cmd_pctype_mapping_reset_result,
16137 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16138 TOKEN_STRING_INITIALIZER
16139 (struct cmd_pctype_mapping_reset_result,
16141 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16142 TOKEN_NUM_INITIALIZER
16143 (struct cmd_pctype_mapping_reset_result,
16145 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16146 TOKEN_STRING_INITIALIZER
16147 (struct cmd_pctype_mapping_reset_result,
16149 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16150 TOKEN_STRING_INITIALIZER
16151 (struct cmd_pctype_mapping_reset_result,
16152 mapping, "mapping");
16153 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16154 TOKEN_STRING_INITIALIZER
16155 (struct cmd_pctype_mapping_reset_result,
16159 cmd_pctype_mapping_reset_parsed(
16160 void *parsed_result,
16161 __attribute__((unused)) struct cmdline *cl,
16162 __attribute__((unused)) void *data)
16164 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16165 int ret = -ENOTSUP;
16167 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16170 #ifdef RTE_LIBRTE_I40E_PMD
16171 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16178 printf("invalid port_id %d\n", res->port_id);
16181 printf("function not implemented\n");
16184 printf("programming error: (%s)\n", strerror(-ret));
16188 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16189 .f = cmd_pctype_mapping_reset_parsed,
16191 .help_str = "port config <port_id> pctype mapping reset",
16193 (void *)&cmd_pctype_mapping_reset_port,
16194 (void *)&cmd_pctype_mapping_reset_config,
16195 (void *)&cmd_pctype_mapping_reset_port_id,
16196 (void *)&cmd_pctype_mapping_reset_pctype,
16197 (void *)&cmd_pctype_mapping_reset_mapping,
16198 (void *)&cmd_pctype_mapping_reset_reset,
16203 /* show port pctype mapping */
16205 /* Common result structure for show port pctype mapping */
16206 struct cmd_pctype_mapping_get_result {
16207 cmdline_fixed_string_t show;
16208 cmdline_fixed_string_t port;
16210 cmdline_fixed_string_t pctype;
16211 cmdline_fixed_string_t mapping;
16214 /* Common CLI fields for pctype mapping get */
16215 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
16216 TOKEN_STRING_INITIALIZER
16217 (struct cmd_pctype_mapping_get_result,
16219 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16220 TOKEN_STRING_INITIALIZER
16221 (struct cmd_pctype_mapping_get_result,
16223 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
16224 TOKEN_NUM_INITIALIZER
16225 (struct cmd_pctype_mapping_get_result,
16227 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
16228 TOKEN_STRING_INITIALIZER
16229 (struct cmd_pctype_mapping_get_result,
16231 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
16232 TOKEN_STRING_INITIALIZER
16233 (struct cmd_pctype_mapping_get_result,
16234 mapping, "mapping");
16237 cmd_pctype_mapping_get_parsed(
16238 void *parsed_result,
16239 __attribute__((unused)) struct cmdline *cl,
16240 __attribute__((unused)) void *data)
16242 struct cmd_pctype_mapping_get_result *res = parsed_result;
16243 int ret = -ENOTSUP;
16244 #ifdef RTE_LIBRTE_I40E_PMD
16245 struct rte_pmd_i40e_flow_type_mapping
16246 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
16247 int i, j, first_pctype;
16250 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16253 #ifdef RTE_LIBRTE_I40E_PMD
16254 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
16261 printf("invalid port_id %d\n", res->port_id);
16264 printf("function not implemented\n");
16267 printf("programming error: (%s)\n", strerror(-ret));
16271 #ifdef RTE_LIBRTE_I40E_PMD
16272 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
16273 if (mapping[i].pctype != 0ULL) {
16276 printf("pctype: ");
16277 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
16278 if (mapping[i].pctype & (1ULL << j)) {
16279 printf(first_pctype ?
16280 "%02d" : ",%02d", j);
16284 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
16290 cmdline_parse_inst_t cmd_pctype_mapping_get = {
16291 .f = cmd_pctype_mapping_get_parsed,
16293 .help_str = "show port <port_id> pctype mapping",
16295 (void *)&cmd_pctype_mapping_get_show,
16296 (void *)&cmd_pctype_mapping_get_port,
16297 (void *)&cmd_pctype_mapping_get_port_id,
16298 (void *)&cmd_pctype_mapping_get_pctype,
16299 (void *)&cmd_pctype_mapping_get_mapping,
16304 /* port config pctype mapping update */
16306 /* Common result structure for port config pctype mapping update */
16307 struct cmd_pctype_mapping_update_result {
16308 cmdline_fixed_string_t port;
16309 cmdline_fixed_string_t config;
16311 cmdline_fixed_string_t pctype;
16312 cmdline_fixed_string_t mapping;
16313 cmdline_fixed_string_t update;
16314 cmdline_fixed_string_t pctype_list;
16315 uint16_t flow_type;
16318 /* Common CLI fields for pctype mapping update*/
16319 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
16320 TOKEN_STRING_INITIALIZER
16321 (struct cmd_pctype_mapping_update_result,
16323 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
16324 TOKEN_STRING_INITIALIZER
16325 (struct cmd_pctype_mapping_update_result,
16327 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
16328 TOKEN_NUM_INITIALIZER
16329 (struct cmd_pctype_mapping_update_result,
16331 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
16332 TOKEN_STRING_INITIALIZER
16333 (struct cmd_pctype_mapping_update_result,
16335 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
16336 TOKEN_STRING_INITIALIZER
16337 (struct cmd_pctype_mapping_update_result,
16338 mapping, "mapping");
16339 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
16340 TOKEN_STRING_INITIALIZER
16341 (struct cmd_pctype_mapping_update_result,
16343 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16344 TOKEN_STRING_INITIALIZER
16345 (struct cmd_pctype_mapping_update_result,
16346 pctype_list, NULL);
16347 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16348 TOKEN_NUM_INITIALIZER
16349 (struct cmd_pctype_mapping_update_result,
16350 flow_type, UINT16);
16353 cmd_pctype_mapping_update_parsed(
16354 void *parsed_result,
16355 __attribute__((unused)) struct cmdline *cl,
16356 __attribute__((unused)) void *data)
16358 struct cmd_pctype_mapping_update_result *res = parsed_result;
16359 int ret = -ENOTSUP;
16360 #ifdef RTE_LIBRTE_I40E_PMD
16361 struct rte_pmd_i40e_flow_type_mapping mapping;
16363 unsigned int nb_item;
16364 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16367 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16370 #ifdef RTE_LIBRTE_I40E_PMD
16371 nb_item = parse_item_list(res->pctype_list, "pctypes",
16372 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16373 mapping.flow_type = res->flow_type;
16374 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16375 mapping.pctype |= (1ULL << pctype_list[i]);
16376 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16386 printf("invalid pctype or flow type\n");
16389 printf("invalid port_id %d\n", res->port_id);
16392 printf("function not implemented\n");
16395 printf("programming error: (%s)\n", strerror(-ret));
16399 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16400 .f = cmd_pctype_mapping_update_parsed,
16402 .help_str = "port config <port_id> pctype mapping update"
16403 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16405 (void *)&cmd_pctype_mapping_update_port,
16406 (void *)&cmd_pctype_mapping_update_config,
16407 (void *)&cmd_pctype_mapping_update_port_id,
16408 (void *)&cmd_pctype_mapping_update_pctype,
16409 (void *)&cmd_pctype_mapping_update_mapping,
16410 (void *)&cmd_pctype_mapping_update_update,
16411 (void *)&cmd_pctype_mapping_update_pc_type,
16412 (void *)&cmd_pctype_mapping_update_flow_type,
16417 /* ptype mapping get */
16419 /* Common result structure for ptype mapping get */
16420 struct cmd_ptype_mapping_get_result {
16421 cmdline_fixed_string_t ptype;
16422 cmdline_fixed_string_t mapping;
16423 cmdline_fixed_string_t get;
16425 uint8_t valid_only;
16428 /* Common CLI fields for ptype mapping get */
16429 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16430 TOKEN_STRING_INITIALIZER
16431 (struct cmd_ptype_mapping_get_result,
16433 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16434 TOKEN_STRING_INITIALIZER
16435 (struct cmd_ptype_mapping_get_result,
16436 mapping, "mapping");
16437 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16438 TOKEN_STRING_INITIALIZER
16439 (struct cmd_ptype_mapping_get_result,
16441 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16442 TOKEN_NUM_INITIALIZER
16443 (struct cmd_ptype_mapping_get_result,
16445 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16446 TOKEN_NUM_INITIALIZER
16447 (struct cmd_ptype_mapping_get_result,
16448 valid_only, UINT8);
16451 cmd_ptype_mapping_get_parsed(
16452 void *parsed_result,
16453 __attribute__((unused)) struct cmdline *cl,
16454 __attribute__((unused)) void *data)
16456 struct cmd_ptype_mapping_get_result *res = parsed_result;
16457 int ret = -ENOTSUP;
16458 #ifdef RTE_LIBRTE_I40E_PMD
16459 int max_ptype_num = 256;
16460 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16465 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16468 #ifdef RTE_LIBRTE_I40E_PMD
16469 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16480 printf("invalid port_id %d\n", res->port_id);
16483 printf("function not implemented\n");
16486 printf("programming error: (%s)\n", strerror(-ret));
16489 #ifdef RTE_LIBRTE_I40E_PMD
16491 for (i = 0; i < count; i++)
16492 printf("%3d\t0x%08x\n",
16493 mapping[i].hw_ptype, mapping[i].sw_ptype);
16498 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16499 .f = cmd_ptype_mapping_get_parsed,
16501 .help_str = "ptype mapping get <port_id> <valid_only>",
16503 (void *)&cmd_ptype_mapping_get_ptype,
16504 (void *)&cmd_ptype_mapping_get_mapping,
16505 (void *)&cmd_ptype_mapping_get_get,
16506 (void *)&cmd_ptype_mapping_get_port_id,
16507 (void *)&cmd_ptype_mapping_get_valid_only,
16512 /* ptype mapping replace */
16514 /* Common result structure for ptype mapping replace */
16515 struct cmd_ptype_mapping_replace_result {
16516 cmdline_fixed_string_t ptype;
16517 cmdline_fixed_string_t mapping;
16518 cmdline_fixed_string_t replace;
16525 /* Common CLI fields for ptype mapping replace */
16526 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16527 TOKEN_STRING_INITIALIZER
16528 (struct cmd_ptype_mapping_replace_result,
16530 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16531 TOKEN_STRING_INITIALIZER
16532 (struct cmd_ptype_mapping_replace_result,
16533 mapping, "mapping");
16534 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16535 TOKEN_STRING_INITIALIZER
16536 (struct cmd_ptype_mapping_replace_result,
16537 replace, "replace");
16538 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16539 TOKEN_NUM_INITIALIZER
16540 (struct cmd_ptype_mapping_replace_result,
16542 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16543 TOKEN_NUM_INITIALIZER
16544 (struct cmd_ptype_mapping_replace_result,
16546 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16547 TOKEN_NUM_INITIALIZER
16548 (struct cmd_ptype_mapping_replace_result,
16550 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16551 TOKEN_NUM_INITIALIZER
16552 (struct cmd_ptype_mapping_replace_result,
16556 cmd_ptype_mapping_replace_parsed(
16557 void *parsed_result,
16558 __attribute__((unused)) struct cmdline *cl,
16559 __attribute__((unused)) void *data)
16561 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16562 int ret = -ENOTSUP;
16564 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16567 #ifdef RTE_LIBRTE_I40E_PMD
16568 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16578 printf("invalid ptype 0x%8x or 0x%8x\n",
16579 res->target, res->pkt_type);
16582 printf("invalid port_id %d\n", res->port_id);
16585 printf("function not implemented\n");
16588 printf("programming error: (%s)\n", strerror(-ret));
16592 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16593 .f = cmd_ptype_mapping_replace_parsed,
16596 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16598 (void *)&cmd_ptype_mapping_replace_ptype,
16599 (void *)&cmd_ptype_mapping_replace_mapping,
16600 (void *)&cmd_ptype_mapping_replace_replace,
16601 (void *)&cmd_ptype_mapping_replace_port_id,
16602 (void *)&cmd_ptype_mapping_replace_target,
16603 (void *)&cmd_ptype_mapping_replace_mask,
16604 (void *)&cmd_ptype_mapping_replace_pkt_type,
16609 /* ptype mapping reset */
16611 /* Common result structure for ptype mapping reset */
16612 struct cmd_ptype_mapping_reset_result {
16613 cmdline_fixed_string_t ptype;
16614 cmdline_fixed_string_t mapping;
16615 cmdline_fixed_string_t reset;
16619 /* Common CLI fields for ptype mapping reset*/
16620 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16621 TOKEN_STRING_INITIALIZER
16622 (struct cmd_ptype_mapping_reset_result,
16624 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16625 TOKEN_STRING_INITIALIZER
16626 (struct cmd_ptype_mapping_reset_result,
16627 mapping, "mapping");
16628 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16629 TOKEN_STRING_INITIALIZER
16630 (struct cmd_ptype_mapping_reset_result,
16632 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16633 TOKEN_NUM_INITIALIZER
16634 (struct cmd_ptype_mapping_reset_result,
16638 cmd_ptype_mapping_reset_parsed(
16639 void *parsed_result,
16640 __attribute__((unused)) struct cmdline *cl,
16641 __attribute__((unused)) void *data)
16643 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16644 int ret = -ENOTSUP;
16646 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16649 #ifdef RTE_LIBRTE_I40E_PMD
16650 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16657 printf("invalid port_id %d\n", res->port_id);
16660 printf("function not implemented\n");
16663 printf("programming error: (%s)\n", strerror(-ret));
16667 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16668 .f = cmd_ptype_mapping_reset_parsed,
16670 .help_str = "ptype mapping reset <port_id>",
16672 (void *)&cmd_ptype_mapping_reset_ptype,
16673 (void *)&cmd_ptype_mapping_reset_mapping,
16674 (void *)&cmd_ptype_mapping_reset_reset,
16675 (void *)&cmd_ptype_mapping_reset_port_id,
16680 /* ptype mapping update */
16682 /* Common result structure for ptype mapping update */
16683 struct cmd_ptype_mapping_update_result {
16684 cmdline_fixed_string_t ptype;
16685 cmdline_fixed_string_t mapping;
16686 cmdline_fixed_string_t reset;
16692 /* Common CLI fields for ptype mapping update*/
16693 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16694 TOKEN_STRING_INITIALIZER
16695 (struct cmd_ptype_mapping_update_result,
16697 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16698 TOKEN_STRING_INITIALIZER
16699 (struct cmd_ptype_mapping_update_result,
16700 mapping, "mapping");
16701 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16702 TOKEN_STRING_INITIALIZER
16703 (struct cmd_ptype_mapping_update_result,
16705 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16706 TOKEN_NUM_INITIALIZER
16707 (struct cmd_ptype_mapping_update_result,
16709 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16710 TOKEN_NUM_INITIALIZER
16711 (struct cmd_ptype_mapping_update_result,
16713 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16714 TOKEN_NUM_INITIALIZER
16715 (struct cmd_ptype_mapping_update_result,
16719 cmd_ptype_mapping_update_parsed(
16720 void *parsed_result,
16721 __attribute__((unused)) struct cmdline *cl,
16722 __attribute__((unused)) void *data)
16724 struct cmd_ptype_mapping_update_result *res = parsed_result;
16725 int ret = -ENOTSUP;
16726 #ifdef RTE_LIBRTE_I40E_PMD
16727 struct rte_pmd_i40e_ptype_mapping mapping;
16729 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16732 #ifdef RTE_LIBRTE_I40E_PMD
16733 mapping.hw_ptype = res->hw_ptype;
16734 mapping.sw_ptype = res->sw_ptype;
16735 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16745 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16748 printf("invalid port_id %d\n", res->port_id);
16751 printf("function not implemented\n");
16754 printf("programming error: (%s)\n", strerror(-ret));
16758 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16759 .f = cmd_ptype_mapping_update_parsed,
16761 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16763 (void *)&cmd_ptype_mapping_update_ptype,
16764 (void *)&cmd_ptype_mapping_update_mapping,
16765 (void *)&cmd_ptype_mapping_update_update,
16766 (void *)&cmd_ptype_mapping_update_port_id,
16767 (void *)&cmd_ptype_mapping_update_hw_ptype,
16768 (void *)&cmd_ptype_mapping_update_sw_ptype,
16773 /* Common result structure for file commands */
16774 struct cmd_cmdfile_result {
16775 cmdline_fixed_string_t load;
16776 cmdline_fixed_string_t filename;
16779 /* Common CLI fields for file commands */
16780 cmdline_parse_token_string_t cmd_load_cmdfile =
16781 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16782 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16783 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16786 cmd_load_from_file_parsed(
16787 void *parsed_result,
16788 __attribute__((unused)) struct cmdline *cl,
16789 __attribute__((unused)) void *data)
16791 struct cmd_cmdfile_result *res = parsed_result;
16793 cmdline_read_from_file(res->filename);
16796 cmdline_parse_inst_t cmd_load_from_file = {
16797 .f = cmd_load_from_file_parsed,
16799 .help_str = "load <filename>",
16801 (void *)&cmd_load_cmdfile,
16802 (void *)&cmd_load_cmdfile_filename,
16807 /* Get Rx offloads capabilities */
16808 struct cmd_rx_offload_get_capa_result {
16809 cmdline_fixed_string_t show;
16810 cmdline_fixed_string_t port;
16812 cmdline_fixed_string_t rx_offload;
16813 cmdline_fixed_string_t capabilities;
16816 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16817 TOKEN_STRING_INITIALIZER
16818 (struct cmd_rx_offload_get_capa_result,
16820 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16821 TOKEN_STRING_INITIALIZER
16822 (struct cmd_rx_offload_get_capa_result,
16824 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16825 TOKEN_NUM_INITIALIZER
16826 (struct cmd_rx_offload_get_capa_result,
16828 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16829 TOKEN_STRING_INITIALIZER
16830 (struct cmd_rx_offload_get_capa_result,
16831 rx_offload, "rx_offload");
16832 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16833 TOKEN_STRING_INITIALIZER
16834 (struct cmd_rx_offload_get_capa_result,
16835 capabilities, "capabilities");
16838 print_rx_offloads(uint64_t offloads)
16840 uint64_t single_offload;
16848 begin = __builtin_ctzll(offloads);
16849 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16851 single_offload = 1 << begin;
16852 for (bit = begin; bit < end; bit++) {
16853 if (offloads & single_offload)
16855 rte_eth_dev_rx_offload_name(single_offload));
16856 single_offload <<= 1;
16861 cmd_rx_offload_get_capa_parsed(
16862 void *parsed_result,
16863 __attribute__((unused)) struct cmdline *cl,
16864 __attribute__((unused)) void *data)
16866 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16867 struct rte_eth_dev_info dev_info;
16868 portid_t port_id = res->port_id;
16869 uint64_t queue_offloads;
16870 uint64_t port_offloads;
16872 rte_eth_dev_info_get(port_id, &dev_info);
16873 queue_offloads = dev_info.rx_queue_offload_capa;
16874 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16876 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16877 printf(" Per Queue :");
16878 print_rx_offloads(queue_offloads);
16881 printf(" Per Port :");
16882 print_rx_offloads(port_offloads);
16886 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16887 .f = cmd_rx_offload_get_capa_parsed,
16889 .help_str = "show port <port_id> rx_offload capabilities",
16891 (void *)&cmd_rx_offload_get_capa_show,
16892 (void *)&cmd_rx_offload_get_capa_port,
16893 (void *)&cmd_rx_offload_get_capa_port_id,
16894 (void *)&cmd_rx_offload_get_capa_rx_offload,
16895 (void *)&cmd_rx_offload_get_capa_capabilities,
16900 /* Get Rx offloads configuration */
16901 struct cmd_rx_offload_get_configuration_result {
16902 cmdline_fixed_string_t show;
16903 cmdline_fixed_string_t port;
16905 cmdline_fixed_string_t rx_offload;
16906 cmdline_fixed_string_t configuration;
16909 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16910 TOKEN_STRING_INITIALIZER
16911 (struct cmd_rx_offload_get_configuration_result,
16913 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16914 TOKEN_STRING_INITIALIZER
16915 (struct cmd_rx_offload_get_configuration_result,
16917 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16918 TOKEN_NUM_INITIALIZER
16919 (struct cmd_rx_offload_get_configuration_result,
16921 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16922 TOKEN_STRING_INITIALIZER
16923 (struct cmd_rx_offload_get_configuration_result,
16924 rx_offload, "rx_offload");
16925 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16926 TOKEN_STRING_INITIALIZER
16927 (struct cmd_rx_offload_get_configuration_result,
16928 configuration, "configuration");
16931 cmd_rx_offload_get_configuration_parsed(
16932 void *parsed_result,
16933 __attribute__((unused)) struct cmdline *cl,
16934 __attribute__((unused)) void *data)
16936 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16937 struct rte_eth_dev_info dev_info;
16938 portid_t port_id = res->port_id;
16939 struct rte_port *port = &ports[port_id];
16940 uint64_t port_offloads;
16941 uint64_t queue_offloads;
16942 uint16_t nb_rx_queues;
16945 printf("Rx Offloading Configuration of port %d :\n", port_id);
16947 port_offloads = port->dev_conf.rxmode.offloads;
16949 print_rx_offloads(port_offloads);
16952 rte_eth_dev_info_get(port_id, &dev_info);
16953 nb_rx_queues = dev_info.nb_rx_queues;
16954 for (q = 0; q < nb_rx_queues; q++) {
16955 queue_offloads = port->rx_conf[q].offloads;
16956 printf(" Queue[%2d] :", q);
16957 print_rx_offloads(queue_offloads);
16963 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16964 .f = cmd_rx_offload_get_configuration_parsed,
16966 .help_str = "show port <port_id> rx_offload configuration",
16968 (void *)&cmd_rx_offload_get_configuration_show,
16969 (void *)&cmd_rx_offload_get_configuration_port,
16970 (void *)&cmd_rx_offload_get_configuration_port_id,
16971 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16972 (void *)&cmd_rx_offload_get_configuration_configuration,
16977 /* Enable/Disable a per port offloading */
16978 struct cmd_config_per_port_rx_offload_result {
16979 cmdline_fixed_string_t port;
16980 cmdline_fixed_string_t config;
16982 cmdline_fixed_string_t rx_offload;
16983 cmdline_fixed_string_t offload;
16984 cmdline_fixed_string_t on_off;
16987 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16988 TOKEN_STRING_INITIALIZER
16989 (struct cmd_config_per_port_rx_offload_result,
16991 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16992 TOKEN_STRING_INITIALIZER
16993 (struct cmd_config_per_port_rx_offload_result,
16995 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16996 TOKEN_NUM_INITIALIZER
16997 (struct cmd_config_per_port_rx_offload_result,
16999 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17000 TOKEN_STRING_INITIALIZER
17001 (struct cmd_config_per_port_rx_offload_result,
17002 rx_offload, "rx_offload");
17003 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17004 TOKEN_STRING_INITIALIZER
17005 (struct cmd_config_per_port_rx_offload_result,
17006 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17007 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17008 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17009 "crc_strip#scatter#timestamp#security");
17010 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17011 TOKEN_STRING_INITIALIZER
17012 (struct cmd_config_per_port_rx_offload_result,
17016 search_rx_offload(const char *name)
17018 uint64_t single_offload;
17019 const char *single_name;
17023 single_offload = 1;
17024 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17025 single_name = rte_eth_dev_rx_offload_name(single_offload);
17026 if (!strcasecmp(single_name, name)) {
17029 } else if (!strcasecmp(single_name, "UNKNOWN"))
17031 else if (single_name == NULL)
17033 single_offload <<= 1;
17037 return single_offload;
17043 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17044 __attribute__((unused)) struct cmdline *cl,
17045 __attribute__((unused)) void *data)
17047 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17048 portid_t port_id = res->port_id;
17049 struct rte_eth_dev_info dev_info;
17050 struct rte_port *port = &ports[port_id];
17051 uint64_t single_offload;
17052 uint16_t nb_rx_queues;
17055 if (port->port_status != RTE_PORT_STOPPED) {
17056 printf("Error: Can't config offload when Port %d "
17057 "is not stopped\n", port_id);
17061 single_offload = search_rx_offload(res->offload);
17062 if (single_offload == 0) {
17063 printf("Unknown offload name: %s\n", res->offload);
17067 rte_eth_dev_info_get(port_id, &dev_info);
17068 nb_rx_queues = dev_info.nb_rx_queues;
17069 if (!strcmp(res->on_off, "on")) {
17070 port->dev_conf.rxmode.offloads |= single_offload;
17071 for (q = 0; q < nb_rx_queues; q++)
17072 port->rx_conf[q].offloads |= single_offload;
17074 port->dev_conf.rxmode.offloads &= ~single_offload;
17075 for (q = 0; q < nb_rx_queues; q++)
17076 port->rx_conf[q].offloads &= ~single_offload;
17079 cmd_reconfig_device_queue(port_id, 1, 1);
17082 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17083 .f = cmd_config_per_port_rx_offload_parsed,
17085 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17086 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17087 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17088 "jumbo_frame|crc_strip|scatter|timestamp|security "
17091 (void *)&cmd_config_per_port_rx_offload_result_port,
17092 (void *)&cmd_config_per_port_rx_offload_result_config,
17093 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17094 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17095 (void *)&cmd_config_per_port_rx_offload_result_offload,
17096 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17101 /* Enable/Disable a per queue offloading */
17102 struct cmd_config_per_queue_rx_offload_result {
17103 cmdline_fixed_string_t port;
17105 cmdline_fixed_string_t rxq;
17107 cmdline_fixed_string_t rx_offload;
17108 cmdline_fixed_string_t offload;
17109 cmdline_fixed_string_t on_off;
17112 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17113 TOKEN_STRING_INITIALIZER
17114 (struct cmd_config_per_queue_rx_offload_result,
17116 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17117 TOKEN_NUM_INITIALIZER
17118 (struct cmd_config_per_queue_rx_offload_result,
17120 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17121 TOKEN_STRING_INITIALIZER
17122 (struct cmd_config_per_queue_rx_offload_result,
17124 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17125 TOKEN_NUM_INITIALIZER
17126 (struct cmd_config_per_queue_rx_offload_result,
17128 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17129 TOKEN_STRING_INITIALIZER
17130 (struct cmd_config_per_queue_rx_offload_result,
17131 rx_offload, "rx_offload");
17132 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17133 TOKEN_STRING_INITIALIZER
17134 (struct cmd_config_per_queue_rx_offload_result,
17135 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17136 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17137 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17138 "crc_strip#scatter#timestamp#security");
17139 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17140 TOKEN_STRING_INITIALIZER
17141 (struct cmd_config_per_queue_rx_offload_result,
17145 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17146 __attribute__((unused)) struct cmdline *cl,
17147 __attribute__((unused)) void *data)
17149 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17150 struct rte_eth_dev_info dev_info;
17151 portid_t port_id = res->port_id;
17152 uint16_t queue_id = res->queue_id;
17153 struct rte_port *port = &ports[port_id];
17154 uint64_t single_offload;
17156 if (port->port_status != RTE_PORT_STOPPED) {
17157 printf("Error: Can't config offload when Port %d "
17158 "is not stopped\n", port_id);
17162 rte_eth_dev_info_get(port_id, &dev_info);
17163 if (queue_id >= dev_info.nb_rx_queues) {
17164 printf("Error: input queue_id should be 0 ... "
17165 "%d\n", dev_info.nb_rx_queues - 1);
17169 single_offload = search_rx_offload(res->offload);
17170 if (single_offload == 0) {
17171 printf("Unknown offload name: %s\n", res->offload);
17175 if (!strcmp(res->on_off, "on"))
17176 port->rx_conf[queue_id].offloads |= single_offload;
17178 port->rx_conf[queue_id].offloads &= ~single_offload;
17180 cmd_reconfig_device_queue(port_id, 1, 1);
17183 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17184 .f = cmd_config_per_queue_rx_offload_parsed,
17186 .help_str = "port <port_id> rxq <queue_id> rx_offload "
17187 "vlan_strip|ipv4_cksum|"
17188 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17189 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17190 "jumbo_frame|crc_strip|scatter|timestamp|security "
17193 (void *)&cmd_config_per_queue_rx_offload_result_port,
17194 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
17195 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
17196 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
17197 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
17198 (void *)&cmd_config_per_queue_rx_offload_result_offload,
17199 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
17204 /* Get Tx offloads capabilities */
17205 struct cmd_tx_offload_get_capa_result {
17206 cmdline_fixed_string_t show;
17207 cmdline_fixed_string_t port;
17209 cmdline_fixed_string_t tx_offload;
17210 cmdline_fixed_string_t capabilities;
17213 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17214 TOKEN_STRING_INITIALIZER
17215 (struct cmd_tx_offload_get_capa_result,
17217 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17218 TOKEN_STRING_INITIALIZER
17219 (struct cmd_tx_offload_get_capa_result,
17221 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
17222 TOKEN_NUM_INITIALIZER
17223 (struct cmd_tx_offload_get_capa_result,
17225 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
17226 TOKEN_STRING_INITIALIZER
17227 (struct cmd_tx_offload_get_capa_result,
17228 tx_offload, "tx_offload");
17229 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
17230 TOKEN_STRING_INITIALIZER
17231 (struct cmd_tx_offload_get_capa_result,
17232 capabilities, "capabilities");
17235 print_tx_offloads(uint64_t offloads)
17237 uint64_t single_offload;
17245 begin = __builtin_ctzll(offloads);
17246 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17248 single_offload = 1 << begin;
17249 for (bit = begin; bit < end; bit++) {
17250 if (offloads & single_offload)
17252 rte_eth_dev_tx_offload_name(single_offload));
17253 single_offload <<= 1;
17258 cmd_tx_offload_get_capa_parsed(
17259 void *parsed_result,
17260 __attribute__((unused)) struct cmdline *cl,
17261 __attribute__((unused)) void *data)
17263 struct cmd_tx_offload_get_capa_result *res = parsed_result;
17264 struct rte_eth_dev_info dev_info;
17265 portid_t port_id = res->port_id;
17266 uint64_t queue_offloads;
17267 uint64_t port_offloads;
17269 rte_eth_dev_info_get(port_id, &dev_info);
17270 queue_offloads = dev_info.tx_queue_offload_capa;
17271 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
17273 printf("Tx Offloading Capabilities of port %d :\n", port_id);
17274 printf(" Per Queue :");
17275 print_tx_offloads(queue_offloads);
17278 printf(" Per Port :");
17279 print_tx_offloads(port_offloads);
17283 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
17284 .f = cmd_tx_offload_get_capa_parsed,
17286 .help_str = "show port <port_id> tx_offload capabilities",
17288 (void *)&cmd_tx_offload_get_capa_show,
17289 (void *)&cmd_tx_offload_get_capa_port,
17290 (void *)&cmd_tx_offload_get_capa_port_id,
17291 (void *)&cmd_tx_offload_get_capa_tx_offload,
17292 (void *)&cmd_tx_offload_get_capa_capabilities,
17297 /* Get Tx offloads configuration */
17298 struct cmd_tx_offload_get_configuration_result {
17299 cmdline_fixed_string_t show;
17300 cmdline_fixed_string_t port;
17302 cmdline_fixed_string_t tx_offload;
17303 cmdline_fixed_string_t configuration;
17306 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
17307 TOKEN_STRING_INITIALIZER
17308 (struct cmd_tx_offload_get_configuration_result,
17310 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
17311 TOKEN_STRING_INITIALIZER
17312 (struct cmd_tx_offload_get_configuration_result,
17314 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
17315 TOKEN_NUM_INITIALIZER
17316 (struct cmd_tx_offload_get_configuration_result,
17318 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
17319 TOKEN_STRING_INITIALIZER
17320 (struct cmd_tx_offload_get_configuration_result,
17321 tx_offload, "tx_offload");
17322 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
17323 TOKEN_STRING_INITIALIZER
17324 (struct cmd_tx_offload_get_configuration_result,
17325 configuration, "configuration");
17328 cmd_tx_offload_get_configuration_parsed(
17329 void *parsed_result,
17330 __attribute__((unused)) struct cmdline *cl,
17331 __attribute__((unused)) void *data)
17333 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
17334 struct rte_eth_dev_info dev_info;
17335 portid_t port_id = res->port_id;
17336 struct rte_port *port = &ports[port_id];
17337 uint64_t port_offloads;
17338 uint64_t queue_offloads;
17339 uint16_t nb_tx_queues;
17342 printf("Tx Offloading Configuration of port %d :\n", port_id);
17344 port_offloads = port->dev_conf.txmode.offloads;
17346 print_tx_offloads(port_offloads);
17349 rte_eth_dev_info_get(port_id, &dev_info);
17350 nb_tx_queues = dev_info.nb_tx_queues;
17351 for (q = 0; q < nb_tx_queues; q++) {
17352 queue_offloads = port->tx_conf[q].offloads;
17353 printf(" Queue[%2d] :", q);
17354 print_tx_offloads(queue_offloads);
17360 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17361 .f = cmd_tx_offload_get_configuration_parsed,
17363 .help_str = "show port <port_id> tx_offload configuration",
17365 (void *)&cmd_tx_offload_get_configuration_show,
17366 (void *)&cmd_tx_offload_get_configuration_port,
17367 (void *)&cmd_tx_offload_get_configuration_port_id,
17368 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17369 (void *)&cmd_tx_offload_get_configuration_configuration,
17374 /* Enable/Disable a per port offloading */
17375 struct cmd_config_per_port_tx_offload_result {
17376 cmdline_fixed_string_t port;
17377 cmdline_fixed_string_t config;
17379 cmdline_fixed_string_t tx_offload;
17380 cmdline_fixed_string_t offload;
17381 cmdline_fixed_string_t on_off;
17384 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17385 TOKEN_STRING_INITIALIZER
17386 (struct cmd_config_per_port_tx_offload_result,
17388 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17389 TOKEN_STRING_INITIALIZER
17390 (struct cmd_config_per_port_tx_offload_result,
17392 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17393 TOKEN_NUM_INITIALIZER
17394 (struct cmd_config_per_port_tx_offload_result,
17396 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17397 TOKEN_STRING_INITIALIZER
17398 (struct cmd_config_per_port_tx_offload_result,
17399 tx_offload, "tx_offload");
17400 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17401 TOKEN_STRING_INITIALIZER
17402 (struct cmd_config_per_port_tx_offload_result,
17403 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17404 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17405 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17406 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17407 "mt_lockfree#multi_segs#fast_free#security");
17408 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17409 TOKEN_STRING_INITIALIZER
17410 (struct cmd_config_per_port_tx_offload_result,
17414 search_tx_offload(const char *name)
17416 uint64_t single_offload;
17417 const char *single_name;
17421 single_offload = 1;
17422 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17423 single_name = rte_eth_dev_tx_offload_name(single_offload);
17424 if (!strcasecmp(single_name, name)) {
17427 } else if (!strcasecmp(single_name, "UNKNOWN"))
17429 else if (single_name == NULL)
17431 single_offload <<= 1;
17435 return single_offload;
17441 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17442 __attribute__((unused)) struct cmdline *cl,
17443 __attribute__((unused)) void *data)
17445 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17446 portid_t port_id = res->port_id;
17447 struct rte_eth_dev_info dev_info;
17448 struct rte_port *port = &ports[port_id];
17449 uint64_t single_offload;
17450 uint16_t nb_tx_queues;
17453 if (port->port_status != RTE_PORT_STOPPED) {
17454 printf("Error: Can't config offload when Port %d "
17455 "is not stopped\n", port_id);
17459 single_offload = search_tx_offload(res->offload);
17460 if (single_offload == 0) {
17461 printf("Unknown offload name: %s\n", res->offload);
17465 rte_eth_dev_info_get(port_id, &dev_info);
17466 nb_tx_queues = dev_info.nb_tx_queues;
17467 if (!strcmp(res->on_off, "on")) {
17468 port->dev_conf.txmode.offloads |= single_offload;
17469 for (q = 0; q < nb_tx_queues; q++)
17470 port->tx_conf[q].offloads |= single_offload;
17472 port->dev_conf.txmode.offloads &= ~single_offload;
17473 for (q = 0; q < nb_tx_queues; q++)
17474 port->tx_conf[q].offloads &= ~single_offload;
17477 cmd_reconfig_device_queue(port_id, 1, 1);
17480 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17481 .f = cmd_config_per_port_tx_offload_parsed,
17483 .help_str = "port config <port_id> tx_offload "
17484 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17485 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17486 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17487 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17488 "mt_lockfree|multi_segs|fast_free|security "
17491 (void *)&cmd_config_per_port_tx_offload_result_port,
17492 (void *)&cmd_config_per_port_tx_offload_result_config,
17493 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17494 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17495 (void *)&cmd_config_per_port_tx_offload_result_offload,
17496 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17501 /* Enable/Disable a per queue offloading */
17502 struct cmd_config_per_queue_tx_offload_result {
17503 cmdline_fixed_string_t port;
17505 cmdline_fixed_string_t txq;
17507 cmdline_fixed_string_t tx_offload;
17508 cmdline_fixed_string_t offload;
17509 cmdline_fixed_string_t on_off;
17512 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17513 TOKEN_STRING_INITIALIZER
17514 (struct cmd_config_per_queue_tx_offload_result,
17516 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17517 TOKEN_NUM_INITIALIZER
17518 (struct cmd_config_per_queue_tx_offload_result,
17520 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17521 TOKEN_STRING_INITIALIZER
17522 (struct cmd_config_per_queue_tx_offload_result,
17524 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17525 TOKEN_NUM_INITIALIZER
17526 (struct cmd_config_per_queue_tx_offload_result,
17528 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17529 TOKEN_STRING_INITIALIZER
17530 (struct cmd_config_per_queue_tx_offload_result,
17531 tx_offload, "tx_offload");
17532 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17533 TOKEN_STRING_INITIALIZER
17534 (struct cmd_config_per_queue_tx_offload_result,
17535 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17536 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17537 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17538 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17539 "mt_lockfree#multi_segs#fast_free#security");
17540 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17541 TOKEN_STRING_INITIALIZER
17542 (struct cmd_config_per_queue_tx_offload_result,
17546 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17547 __attribute__((unused)) struct cmdline *cl,
17548 __attribute__((unused)) void *data)
17550 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17551 struct rte_eth_dev_info dev_info;
17552 portid_t port_id = res->port_id;
17553 uint16_t queue_id = res->queue_id;
17554 struct rte_port *port = &ports[port_id];
17555 uint64_t single_offload;
17557 if (port->port_status != RTE_PORT_STOPPED) {
17558 printf("Error: Can't config offload when Port %d "
17559 "is not stopped\n", port_id);
17563 rte_eth_dev_info_get(port_id, &dev_info);
17564 if (queue_id >= dev_info.nb_tx_queues) {
17565 printf("Error: input queue_id should be 0 ... "
17566 "%d\n", dev_info.nb_tx_queues - 1);
17570 single_offload = search_tx_offload(res->offload);
17571 if (single_offload == 0) {
17572 printf("Unknown offload name: %s\n", res->offload);
17576 if (!strcmp(res->on_off, "on"))
17577 port->tx_conf[queue_id].offloads |= single_offload;
17579 port->tx_conf[queue_id].offloads &= ~single_offload;
17581 cmd_reconfig_device_queue(port_id, 1, 1);
17584 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17585 .f = cmd_config_per_queue_tx_offload_parsed,
17587 .help_str = "port <port_id> txq <queue_id> tx_offload "
17588 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17589 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17590 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17591 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17592 "mt_lockfree|multi_segs|fast_free|security "
17595 (void *)&cmd_config_per_queue_tx_offload_result_port,
17596 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17597 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17598 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17599 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17600 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17601 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17606 /* ******************************************************************************** */
17608 /* list of instructions */
17609 cmdline_parse_ctx_t main_ctx[] = {
17610 (cmdline_parse_inst_t *)&cmd_help_brief,
17611 (cmdline_parse_inst_t *)&cmd_help_long,
17612 (cmdline_parse_inst_t *)&cmd_quit,
17613 (cmdline_parse_inst_t *)&cmd_load_from_file,
17614 (cmdline_parse_inst_t *)&cmd_showport,
17615 (cmdline_parse_inst_t *)&cmd_showqueue,
17616 (cmdline_parse_inst_t *)&cmd_showportall,
17617 (cmdline_parse_inst_t *)&cmd_showcfg,
17618 (cmdline_parse_inst_t *)&cmd_start,
17619 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17620 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17621 (cmdline_parse_inst_t *)&cmd_set_link_up,
17622 (cmdline_parse_inst_t *)&cmd_set_link_down,
17623 (cmdline_parse_inst_t *)&cmd_reset,
17624 (cmdline_parse_inst_t *)&cmd_set_numbers,
17625 (cmdline_parse_inst_t *)&cmd_set_log,
17626 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17627 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17628 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17629 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17630 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17631 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17632 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17633 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17634 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17635 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17636 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17637 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17638 (cmdline_parse_inst_t *)&cmd_set_link_check,
17639 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17640 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17641 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17642 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17643 #ifdef RTE_LIBRTE_PMD_BOND
17644 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17645 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17646 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17647 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17648 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17649 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17650 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17651 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17652 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17653 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17654 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17656 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17657 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17658 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17659 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17660 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17661 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17662 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17663 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17664 (cmdline_parse_inst_t *)&cmd_csum_set,
17665 (cmdline_parse_inst_t *)&cmd_csum_show,
17666 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17667 (cmdline_parse_inst_t *)&cmd_tso_set,
17668 (cmdline_parse_inst_t *)&cmd_tso_show,
17669 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17670 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17671 (cmdline_parse_inst_t *)&cmd_gro_enable,
17672 (cmdline_parse_inst_t *)&cmd_gro_flush,
17673 (cmdline_parse_inst_t *)&cmd_gro_show,
17674 (cmdline_parse_inst_t *)&cmd_gso_enable,
17675 (cmdline_parse_inst_t *)&cmd_gso_size,
17676 (cmdline_parse_inst_t *)&cmd_gso_show,
17677 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17678 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17679 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17680 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17681 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17682 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17683 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17684 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17685 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17686 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17687 (cmdline_parse_inst_t *)&cmd_config_dcb,
17688 (cmdline_parse_inst_t *)&cmd_read_reg,
17689 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17690 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17691 (cmdline_parse_inst_t *)&cmd_write_reg,
17692 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17693 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17694 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17695 (cmdline_parse_inst_t *)&cmd_stop,
17696 (cmdline_parse_inst_t *)&cmd_mac_addr,
17697 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17698 (cmdline_parse_inst_t *)&cmd_set_qmap,
17699 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17700 (cmdline_parse_inst_t *)&cmd_operate_port,
17701 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17702 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17703 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17704 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17705 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17706 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17707 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17708 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17709 (cmdline_parse_inst_t *)&cmd_config_mtu,
17710 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17711 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17712 (cmdline_parse_inst_t *)&cmd_config_rss,
17713 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17714 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17715 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17716 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17717 (cmdline_parse_inst_t *)&cmd_showport_reta,
17718 (cmdline_parse_inst_t *)&cmd_config_burst,
17719 (cmdline_parse_inst_t *)&cmd_config_thresh,
17720 (cmdline_parse_inst_t *)&cmd_config_threshold,
17721 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17722 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17723 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17724 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
17725 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17726 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
17727 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17728 (cmdline_parse_inst_t *)&cmd_global_config,
17729 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17730 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17731 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17732 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17733 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17734 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17735 (cmdline_parse_inst_t *)&cmd_dump,
17736 (cmdline_parse_inst_t *)&cmd_dump_one,
17737 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
17738 (cmdline_parse_inst_t *)&cmd_syn_filter,
17739 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
17740 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
17741 (cmdline_parse_inst_t *)&cmd_flex_filter,
17742 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
17743 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
17744 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
17745 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
17746 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
17747 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
17748 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17749 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
17750 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17751 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17752 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17753 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
17754 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17755 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
17756 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
17757 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
17758 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
17759 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
17760 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
17761 (cmdline_parse_inst_t *)&cmd_flow,
17762 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17763 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17764 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17765 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17766 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17767 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17768 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17769 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17770 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17771 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17772 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17773 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17774 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17775 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17776 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
17777 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
17778 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
17779 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
17780 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
17781 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
17782 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
17783 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
17784 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
17785 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
17786 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17787 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17788 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17789 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17790 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17791 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17792 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17793 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17794 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17795 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17796 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17797 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17798 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17799 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17800 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17801 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17802 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17803 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17804 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17805 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17806 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17807 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17808 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17809 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17810 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17811 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
17812 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
17814 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17815 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17816 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17817 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17818 (cmdline_parse_inst_t *)&cmd_ddp_add,
17819 (cmdline_parse_inst_t *)&cmd_ddp_del,
17820 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17821 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17822 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17823 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17824 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17825 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17826 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17827 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17828 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17829 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17831 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17832 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17833 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17834 (cmdline_parse_inst_t *)&cmd_queue_region,
17835 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17836 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17837 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17838 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17839 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17840 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17841 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17842 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17843 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17844 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17845 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17846 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17847 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17848 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17849 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17850 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17851 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17852 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17853 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17854 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17855 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17856 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17857 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17858 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17859 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17860 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17861 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17862 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17863 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17864 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17865 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17866 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17867 #ifdef RTE_LIBRTE_BPF
17868 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17869 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17874 /* read cmdline commands from file */
17876 cmdline_read_from_file(const char *filename)
17878 struct cmdline *cl;
17880 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17882 printf("Failed to create file based cmdline context: %s\n",
17887 cmdline_interact(cl);
17892 printf("Read CLI commands from %s\n", filename);
17895 /* prompt function, called from main on MASTER lcore */
17901 /* initialize non-constant commands */
17902 cmd_set_fwd_mode_init();
17903 cmd_set_fwd_retry_mode_init();
17905 #if defined RTE_LIBRTE_PMD_SOFTNIC
17906 portid_t softnic_portid, pid;
17907 uint8_t softnic_enable = 0;
17909 if (strcmp(cur_fwd_eng->fwd_mode_name, "softnic") == 0) {
17910 RTE_ETH_FOREACH_DEV(pid) {
17911 struct rte_port *port = &ports[pid];
17912 const char *driver = port->dev_info.driver_name;
17914 if (strcmp(driver, "net_softnic") == 0) {
17915 softnic_portid = pid;
17916 softnic_enable = 1;
17923 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17924 if (testpmd_cl == NULL)
17928 status = cmdline_poll(testpmd_cl);
17930 rte_panic("CLI poll error (%" PRId32 ")\n", status);
17931 else if (status == RDLINE_EXITED) {
17932 cmdline_stdin_exit(testpmd_cl);
17936 #if defined RTE_LIBRTE_PMD_SOFTNIC
17938 if ((softnic_enable == 1) &&
17939 (strcmp(cur_fwd_eng->fwd_mode_name, "softnic") == 0))
17940 rte_pmd_softnic_manage(softnic_portid);
17948 if (testpmd_cl != NULL)
17949 cmdline_quit(testpmd_cl);
17953 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17955 if (id == (portid_t)RTE_PORT_ALL) {
17958 RTE_ETH_FOREACH_DEV(pid) {
17959 /* check if need_reconfig has been set to 1 */
17960 if (ports[pid].need_reconfig == 0)
17961 ports[pid].need_reconfig = dev;
17962 /* check if need_reconfig_queues has been set to 1 */
17963 if (ports[pid].need_reconfig_queues == 0)
17964 ports[pid].need_reconfig_queues = queue;
17966 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17967 /* check if need_reconfig has been set to 1 */
17968 if (ports[id].need_reconfig == 0)
17969 ports[id].need_reconfig = dev;
17970 /* check if need_reconfig_queues has been set to 1 */
17971 if (ports[id].need_reconfig_queues == 0)
17972 ports[id].need_reconfig_queues = queue;