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 , list_pkt_forwarding_modes()
791 if (show_all || !strcmp(res->section, "ports")) {
797 "----------------\n\n"
799 "port start (port_id|all)\n"
800 " Start all ports or port_id.\n\n"
802 "port stop (port_id|all)\n"
803 " Stop all ports or port_id.\n\n"
805 "port close (port_id|all)\n"
806 " Close all ports or port_id.\n\n"
808 "port attach (ident)\n"
809 " Attach physical or virtual dev by pci address or virtual device name\n\n"
811 "port detach (port_id)\n"
812 " Detach physical or virtual dev by port_id\n\n"
814 "port config (port_id|all)"
815 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
816 " duplex (half|full|auto)\n"
817 " Set speed and duplex for all ports or port_id\n\n"
819 "port config (port_id|all) loopback (mode)\n"
820 " Set loopback mode for all ports or port_id\n\n"
822 "port config all (rxq|txq|rxd|txd) (value)\n"
823 " Set number for rxq/txq/rxd/txd.\n\n"
825 "port config all max-pkt-len (value)\n"
826 " Set the max packet length.\n\n"
828 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
829 "hw-vlan-strip|hw-vlan-extend|drop-en)"
831 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
834 "port config all rss (all|default|ip|tcp|udp|sctp|"
835 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
836 " Set the RSS mode.\n\n"
838 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
839 " Set the RSS redirection table.\n\n"
841 "port config (port_id) dcb vt (on|off) (traffic_class)"
843 " Set the DCB mode.\n\n"
845 "port config all burst (value)\n"
846 " Set the number of packets per burst.\n\n"
848 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
850 " Set the ring prefetch/host/writeback threshold"
851 " for tx/rx queue.\n\n"
853 "port config all (txfreet|txrst|rxfreet) (value)\n"
854 " Set free threshold for rx/tx, or set"
855 " tx rs bit threshold.\n\n"
856 "port config mtu X value\n"
857 " Set the MTU of port X to a given value\n\n"
859 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
860 " Set a rx/tx queue's ring size configuration, the new"
861 " value will take effect after command that (re-)start the port"
862 " or command that setup the specific queue\n\n"
864 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
865 " Start/stop a rx/tx queue of port X. Only take effect"
866 " when port X is started\n\n"
868 "port (port_id) (rxq|txq) (queue_id) setup\n"
869 " Setup a rx/tx queue of port X.\n\n"
871 "port config (port_id|all) l2-tunnel E-tag ether-type"
873 " Set the value of E-tag ether-type.\n\n"
875 "port config (port_id|all) l2-tunnel E-tag"
876 " (enable|disable)\n"
877 " Enable/disable the E-tag support.\n\n"
879 "port config (port_id) pctype mapping reset\n"
880 " Reset flow type to pctype mapping on a port\n\n"
882 "port config (port_id) pctype mapping update"
883 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
884 " Update a flow type to pctype mapping item on a port\n\n"
886 "port config (port_id) pctype (pctype_id) hash_inset|"
887 "fdir_inset|fdir_flx_inset get|set|clear field\n"
889 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
891 "port config (port_id) pctype (pctype_id) hash_inset|"
892 "fdir_inset|fdir_flx_inset clear all"
893 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
895 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
896 " Add/remove UDP tunnel port for tunneling offload\n\n"
900 if (show_all || !strcmp(res->section, "registers")) {
908 "read reg (port_id) (address)\n"
909 " Display value of a port register.\n\n"
911 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
912 " Display a port register bit field.\n\n"
914 "read regbit (port_id) (address) (bit_x)\n"
915 " Display a single port register bit.\n\n"
917 "write reg (port_id) (address) (value)\n"
918 " Set value of a port register.\n\n"
920 "write regfield (port_id) (address) (bit_x) (bit_y)"
922 " Set bit field of a port register.\n\n"
924 "write regbit (port_id) (address) (bit_x) (value)\n"
925 " Set single bit value of a port register.\n\n"
928 if (show_all || !strcmp(res->section, "filters")) {
936 "ethertype_filter (port_id) (add|del)"
937 " (mac_addr|mac_ignr) (mac_address) ethertype"
938 " (ether_type) (drop|fwd) queue (queue_id)\n"
939 " Add/Del an ethertype filter.\n\n"
941 "2tuple_filter (port_id) (add|del)"
942 " dst_port (dst_port_value) protocol (protocol_value)"
943 " mask (mask_value) tcp_flags (tcp_flags_value)"
944 " priority (prio_value) queue (queue_id)\n"
945 " Add/Del a 2tuple filter.\n\n"
947 "5tuple_filter (port_id) (add|del)"
948 " dst_ip (dst_address) src_ip (src_address)"
949 " dst_port (dst_port_value) src_port (src_port_value)"
950 " protocol (protocol_value)"
951 " mask (mask_value) tcp_flags (tcp_flags_value)"
952 " priority (prio_value) queue (queue_id)\n"
953 " Add/Del a 5tuple filter.\n\n"
955 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
956 " Add/Del syn filter.\n\n"
958 "flex_filter (port_id) (add|del) len (len_value)"
959 " bytes (bytes_value) mask (mask_value)"
960 " priority (prio_value) queue (queue_id)\n"
961 " Add/Del a flex filter.\n\n"
963 "flow_director_filter (port_id) mode IP (add|del|update)"
964 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
965 " src (src_ip_address) dst (dst_ip_address)"
966 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
967 " vlan (vlan_value) flexbytes (flexbytes_value)"
968 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
969 " fd_id (fd_id_value)\n"
970 " Add/Del an IP type flow director filter.\n\n"
972 "flow_director_filter (port_id) mode IP (add|del|update)"
973 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
974 " src (src_ip_address) (src_port)"
975 " dst (dst_ip_address) (dst_port)"
976 " tos (tos_value) ttl (ttl_value)"
977 " vlan (vlan_value) flexbytes (flexbytes_value)"
978 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
979 " fd_id (fd_id_value)\n"
980 " Add/Del an UDP/TCP type flow director filter.\n\n"
982 "flow_director_filter (port_id) mode IP (add|del|update)"
983 " flow (ipv4-sctp|ipv6-sctp)"
984 " src (src_ip_address) (src_port)"
985 " dst (dst_ip_address) (dst_port)"
986 " tag (verification_tag) "
987 " tos (tos_value) ttl (ttl_value)"
989 " flexbytes (flexbytes_value) (drop|fwd)"
990 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
991 " Add/Del a SCTP type flow director filter.\n\n"
993 "flow_director_filter (port_id) mode IP (add|del|update)"
994 " flow l2_payload ether (ethertype)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a l2 payload type flow director filter.\n\n"
999 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1000 " mac (mac_address) vlan (vlan_value)"
1001 " flexbytes (flexbytes_value) (drop|fwd)"
1002 " queue (queue_id) fd_id (fd_id_value)\n"
1003 " Add/Del a MAC-VLAN flow director filter.\n\n"
1005 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1006 " mac (mac_address) vlan (vlan_value)"
1007 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a Tunnel flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode raw (add|del|update)"
1013 " flow (flow_id) (drop|fwd) queue (queue_id)"
1014 " fd_id (fd_id_value) packet (packet file name)\n"
1015 " Add/Del a raw type flow director filter.\n\n"
1017 "flush_flow_director (port_id)\n"
1018 " Flush all flow director entries of a device.\n\n"
1020 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1021 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1022 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1023 " Set flow director IP mask.\n\n"
1025 "flow_director_mask (port_id) mode MAC-VLAN"
1026 " vlan (vlan_value)\n"
1027 " Set flow director MAC-VLAN mask.\n\n"
1029 "flow_director_mask (port_id) mode Tunnel"
1030 " vlan (vlan_value) mac (mac_value)"
1031 " tunnel-type (tunnel_type_value)"
1032 " tunnel-id (tunnel_id_value)\n"
1033 " Set flow director Tunnel mask.\n\n"
1035 "flow_director_flex_mask (port_id)"
1036 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1037 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1039 " Configure mask of flex payload.\n\n"
1041 "flow_director_flex_payload (port_id)"
1042 " (raw|l2|l3|l4) (config)\n"
1043 " Configure flex payload selection.\n\n"
1045 "get_sym_hash_ena_per_port (port_id)\n"
1046 " get symmetric hash enable configuration per port.\n\n"
1048 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1049 " set symmetric hash enable configuration per port"
1050 " to enable or disable.\n\n"
1052 "get_hash_global_config (port_id)\n"
1053 " Get the global configurations of hash filters.\n\n"
1055 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1056 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1058 " (enable|disable)\n"
1059 " Set the global configurations of hash filters.\n\n"
1061 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1062 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1063 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1064 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1065 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1066 "ipv6-next-header|udp-src-port|udp-dst-port|"
1067 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1068 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1069 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1070 "fld-8th|none) (select|add)\n"
1071 " Set the input set for hash.\n\n"
1073 "set_fdir_input_set (port_id) "
1074 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1075 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1076 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1077 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1078 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1079 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1080 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1082 " Set the input set for FDir.\n\n"
1084 "flow validate {port_id}"
1085 " [group {group_id}] [priority {level}]"
1086 " [ingress] [egress]"
1087 " pattern {item} [/ {item} [...]] / end"
1088 " actions {action} [/ {action} [...]] / end\n"
1089 " Check whether a flow rule can be created.\n\n"
1091 "flow create {port_id}"
1092 " [group {group_id}] [priority {level}]"
1093 " [ingress] [egress]"
1094 " pattern {item} [/ {item} [...]] / end"
1095 " actions {action} [/ {action} [...]] / end\n"
1096 " Create a flow rule.\n\n"
1098 "flow destroy {port_id} rule {rule_id} [...]\n"
1099 " Destroy specific flow rules.\n\n"
1101 "flow flush {port_id}\n"
1102 " Destroy all flow rules.\n\n"
1104 "flow query {port_id} {rule_id} {action}\n"
1105 " Query an existing flow rule.\n\n"
1107 "flow list {port_id} [group {group_id}] [...]\n"
1108 " List existing flow rules sorted by priority,"
1109 " filtered by group identifiers.\n\n"
1111 "flow isolate {port_id} {boolean}\n"
1112 " Restrict ingress traffic to the defined"
1118 cmdline_parse_token_string_t cmd_help_long_help =
1119 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1121 cmdline_parse_token_string_t cmd_help_long_section =
1122 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1123 "all#control#display#config#"
1124 "ports#registers#filters");
1126 cmdline_parse_inst_t cmd_help_long = {
1127 .f = cmd_help_long_parsed,
1129 .help_str = "help all|control|display|config|ports|register|filters: "
1132 (void *)&cmd_help_long_help,
1133 (void *)&cmd_help_long_section,
1139 /* *** start/stop/close all ports *** */
1140 struct cmd_operate_port_result {
1141 cmdline_fixed_string_t keyword;
1142 cmdline_fixed_string_t name;
1143 cmdline_fixed_string_t value;
1146 static void cmd_operate_port_parsed(void *parsed_result,
1147 __attribute__((unused)) struct cmdline *cl,
1148 __attribute__((unused)) void *data)
1150 struct cmd_operate_port_result *res = parsed_result;
1152 if (!strcmp(res->name, "start"))
1153 start_port(RTE_PORT_ALL);
1154 else if (!strcmp(res->name, "stop"))
1155 stop_port(RTE_PORT_ALL);
1156 else if (!strcmp(res->name, "close"))
1157 close_port(RTE_PORT_ALL);
1158 else if (!strcmp(res->name, "reset"))
1159 reset_port(RTE_PORT_ALL);
1161 printf("Unknown parameter\n");
1164 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1165 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1167 cmdline_parse_token_string_t cmd_operate_port_all_port =
1168 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1169 "start#stop#close#reset");
1170 cmdline_parse_token_string_t cmd_operate_port_all_all =
1171 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1173 cmdline_parse_inst_t cmd_operate_port = {
1174 .f = cmd_operate_port_parsed,
1176 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1178 (void *)&cmd_operate_port_all_cmd,
1179 (void *)&cmd_operate_port_all_port,
1180 (void *)&cmd_operate_port_all_all,
1185 /* *** start/stop/close specific port *** */
1186 struct cmd_operate_specific_port_result {
1187 cmdline_fixed_string_t keyword;
1188 cmdline_fixed_string_t name;
1192 static void cmd_operate_specific_port_parsed(void *parsed_result,
1193 __attribute__((unused)) struct cmdline *cl,
1194 __attribute__((unused)) void *data)
1196 struct cmd_operate_specific_port_result *res = parsed_result;
1198 if (!strcmp(res->name, "start"))
1199 start_port(res->value);
1200 else if (!strcmp(res->name, "stop"))
1201 stop_port(res->value);
1202 else if (!strcmp(res->name, "close"))
1203 close_port(res->value);
1204 else if (!strcmp(res->name, "reset"))
1205 reset_port(res->value);
1207 printf("Unknown parameter\n");
1210 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1211 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1213 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1214 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1215 name, "start#stop#close#reset");
1216 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1217 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1220 cmdline_parse_inst_t cmd_operate_specific_port = {
1221 .f = cmd_operate_specific_port_parsed,
1223 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1225 (void *)&cmd_operate_specific_port_cmd,
1226 (void *)&cmd_operate_specific_port_port,
1227 (void *)&cmd_operate_specific_port_id,
1232 /* *** attach a specified port *** */
1233 struct cmd_operate_attach_port_result {
1234 cmdline_fixed_string_t port;
1235 cmdline_fixed_string_t keyword;
1236 cmdline_fixed_string_t identifier;
1239 static void cmd_operate_attach_port_parsed(void *parsed_result,
1240 __attribute__((unused)) struct cmdline *cl,
1241 __attribute__((unused)) void *data)
1243 struct cmd_operate_attach_port_result *res = parsed_result;
1245 if (!strcmp(res->keyword, "attach"))
1246 attach_port(res->identifier);
1248 printf("Unknown parameter\n");
1251 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1252 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1254 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1255 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1257 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1258 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1261 cmdline_parse_inst_t cmd_operate_attach_port = {
1262 .f = cmd_operate_attach_port_parsed,
1264 .help_str = "port attach <identifier>: "
1265 "(identifier: pci address or virtual dev name)",
1267 (void *)&cmd_operate_attach_port_port,
1268 (void *)&cmd_operate_attach_port_keyword,
1269 (void *)&cmd_operate_attach_port_identifier,
1274 /* *** detach a specified port *** */
1275 struct cmd_operate_detach_port_result {
1276 cmdline_fixed_string_t port;
1277 cmdline_fixed_string_t keyword;
1281 static void cmd_operate_detach_port_parsed(void *parsed_result,
1282 __attribute__((unused)) struct cmdline *cl,
1283 __attribute__((unused)) void *data)
1285 struct cmd_operate_detach_port_result *res = parsed_result;
1287 if (!strcmp(res->keyword, "detach"))
1288 detach_port(res->port_id);
1290 printf("Unknown parameter\n");
1293 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1294 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1296 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1297 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1299 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1300 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1303 cmdline_parse_inst_t cmd_operate_detach_port = {
1304 .f = cmd_operate_detach_port_parsed,
1306 .help_str = "port detach <port_id>",
1308 (void *)&cmd_operate_detach_port_port,
1309 (void *)&cmd_operate_detach_port_keyword,
1310 (void *)&cmd_operate_detach_port_port_id,
1315 /* *** configure speed for all ports *** */
1316 struct cmd_config_speed_all {
1317 cmdline_fixed_string_t port;
1318 cmdline_fixed_string_t keyword;
1319 cmdline_fixed_string_t all;
1320 cmdline_fixed_string_t item1;
1321 cmdline_fixed_string_t item2;
1322 cmdline_fixed_string_t value1;
1323 cmdline_fixed_string_t value2;
1327 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1332 if (!strcmp(duplexstr, "half")) {
1333 duplex = ETH_LINK_HALF_DUPLEX;
1334 } else if (!strcmp(duplexstr, "full")) {
1335 duplex = ETH_LINK_FULL_DUPLEX;
1336 } else if (!strcmp(duplexstr, "auto")) {
1337 duplex = ETH_LINK_FULL_DUPLEX;
1339 printf("Unknown duplex parameter\n");
1343 if (!strcmp(speedstr, "10")) {
1344 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1345 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1346 } else if (!strcmp(speedstr, "100")) {
1347 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1348 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1350 if (duplex != ETH_LINK_FULL_DUPLEX) {
1351 printf("Invalid speed/duplex parameters\n");
1354 if (!strcmp(speedstr, "1000")) {
1355 *speed = ETH_LINK_SPEED_1G;
1356 } else if (!strcmp(speedstr, "10000")) {
1357 *speed = ETH_LINK_SPEED_10G;
1358 } else if (!strcmp(speedstr, "25000")) {
1359 *speed = ETH_LINK_SPEED_25G;
1360 } else if (!strcmp(speedstr, "40000")) {
1361 *speed = ETH_LINK_SPEED_40G;
1362 } else if (!strcmp(speedstr, "50000")) {
1363 *speed = ETH_LINK_SPEED_50G;
1364 } else if (!strcmp(speedstr, "100000")) {
1365 *speed = ETH_LINK_SPEED_100G;
1366 } else if (!strcmp(speedstr, "auto")) {
1367 *speed = ETH_LINK_SPEED_AUTONEG;
1369 printf("Unknown speed parameter\n");
1378 cmd_config_speed_all_parsed(void *parsed_result,
1379 __attribute__((unused)) struct cmdline *cl,
1380 __attribute__((unused)) void *data)
1382 struct cmd_config_speed_all *res = parsed_result;
1383 uint32_t link_speed;
1386 if (!all_ports_stopped()) {
1387 printf("Please stop all ports first\n");
1391 if (parse_and_check_speed_duplex(res->value1, res->value2,
1395 RTE_ETH_FOREACH_DEV(pid) {
1396 ports[pid].dev_conf.link_speeds = link_speed;
1399 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1402 cmdline_parse_token_string_t cmd_config_speed_all_port =
1403 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1404 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1407 cmdline_parse_token_string_t cmd_config_speed_all_all =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1409 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1410 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1411 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1412 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1413 "10#100#1000#10000#25000#40000#50000#100000#auto");
1414 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1415 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1416 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1420 cmdline_parse_inst_t cmd_config_speed_all = {
1421 .f = cmd_config_speed_all_parsed,
1423 .help_str = "port config all speed "
1424 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1427 (void *)&cmd_config_speed_all_port,
1428 (void *)&cmd_config_speed_all_keyword,
1429 (void *)&cmd_config_speed_all_all,
1430 (void *)&cmd_config_speed_all_item1,
1431 (void *)&cmd_config_speed_all_value1,
1432 (void *)&cmd_config_speed_all_item2,
1433 (void *)&cmd_config_speed_all_value2,
1438 /* *** configure speed for specific port *** */
1439 struct cmd_config_speed_specific {
1440 cmdline_fixed_string_t port;
1441 cmdline_fixed_string_t keyword;
1443 cmdline_fixed_string_t item1;
1444 cmdline_fixed_string_t item2;
1445 cmdline_fixed_string_t value1;
1446 cmdline_fixed_string_t value2;
1450 cmd_config_speed_specific_parsed(void *parsed_result,
1451 __attribute__((unused)) struct cmdline *cl,
1452 __attribute__((unused)) void *data)
1454 struct cmd_config_speed_specific *res = parsed_result;
1455 uint32_t link_speed;
1457 if (!all_ports_stopped()) {
1458 printf("Please stop all ports first\n");
1462 if (port_id_is_invalid(res->id, ENABLED_WARN))
1465 if (parse_and_check_speed_duplex(res->value1, res->value2,
1469 ports[res->id].dev_conf.link_speeds = link_speed;
1471 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1475 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1476 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1478 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1479 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1481 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1482 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1483 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1484 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1486 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1487 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1488 "10#100#1000#10000#25000#40000#50000#100000#auto");
1489 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1492 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1496 cmdline_parse_inst_t cmd_config_speed_specific = {
1497 .f = cmd_config_speed_specific_parsed,
1499 .help_str = "port config <port_id> speed "
1500 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1503 (void *)&cmd_config_speed_specific_port,
1504 (void *)&cmd_config_speed_specific_keyword,
1505 (void *)&cmd_config_speed_specific_id,
1506 (void *)&cmd_config_speed_specific_item1,
1507 (void *)&cmd_config_speed_specific_value1,
1508 (void *)&cmd_config_speed_specific_item2,
1509 (void *)&cmd_config_speed_specific_value2,
1514 /* *** configure loopback for all ports *** */
1515 struct cmd_config_loopback_all {
1516 cmdline_fixed_string_t port;
1517 cmdline_fixed_string_t keyword;
1518 cmdline_fixed_string_t all;
1519 cmdline_fixed_string_t item;
1524 cmd_config_loopback_all_parsed(void *parsed_result,
1525 __attribute__((unused)) struct cmdline *cl,
1526 __attribute__((unused)) void *data)
1528 struct cmd_config_loopback_all *res = parsed_result;
1531 if (!all_ports_stopped()) {
1532 printf("Please stop all ports first\n");
1536 RTE_ETH_FOREACH_DEV(pid) {
1537 ports[pid].dev_conf.lpbk_mode = res->mode;
1540 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1543 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1544 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1545 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1546 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1548 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1549 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1550 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1551 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1553 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1554 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1556 cmdline_parse_inst_t cmd_config_loopback_all = {
1557 .f = cmd_config_loopback_all_parsed,
1559 .help_str = "port config all loopback <mode>",
1561 (void *)&cmd_config_loopback_all_port,
1562 (void *)&cmd_config_loopback_all_keyword,
1563 (void *)&cmd_config_loopback_all_all,
1564 (void *)&cmd_config_loopback_all_item,
1565 (void *)&cmd_config_loopback_all_mode,
1570 /* *** configure loopback for specific port *** */
1571 struct cmd_config_loopback_specific {
1572 cmdline_fixed_string_t port;
1573 cmdline_fixed_string_t keyword;
1575 cmdline_fixed_string_t item;
1580 cmd_config_loopback_specific_parsed(void *parsed_result,
1581 __attribute__((unused)) struct cmdline *cl,
1582 __attribute__((unused)) void *data)
1584 struct cmd_config_loopback_specific *res = parsed_result;
1586 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1589 if (!port_is_stopped(res->port_id)) {
1590 printf("Please stop port %u first\n", res->port_id);
1594 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1596 cmd_reconfig_device_queue(res->port_id, 1, 1);
1600 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1601 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1603 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1604 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1606 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1607 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1609 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1610 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1612 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1613 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1616 cmdline_parse_inst_t cmd_config_loopback_specific = {
1617 .f = cmd_config_loopback_specific_parsed,
1619 .help_str = "port config <port_id> loopback <mode>",
1621 (void *)&cmd_config_loopback_specific_port,
1622 (void *)&cmd_config_loopback_specific_keyword,
1623 (void *)&cmd_config_loopback_specific_id,
1624 (void *)&cmd_config_loopback_specific_item,
1625 (void *)&cmd_config_loopback_specific_mode,
1630 /* *** configure txq/rxq, txd/rxd *** */
1631 struct cmd_config_rx_tx {
1632 cmdline_fixed_string_t port;
1633 cmdline_fixed_string_t keyword;
1634 cmdline_fixed_string_t all;
1635 cmdline_fixed_string_t name;
1640 cmd_config_rx_tx_parsed(void *parsed_result,
1641 __attribute__((unused)) struct cmdline *cl,
1642 __attribute__((unused)) void *data)
1644 struct cmd_config_rx_tx *res = parsed_result;
1646 if (!all_ports_stopped()) {
1647 printf("Please stop all ports first\n");
1650 if (!strcmp(res->name, "rxq")) {
1651 if (!res->value && !nb_txq) {
1652 printf("Warning: Either rx or tx queues should be non zero\n");
1655 if (check_nb_rxq(res->value) != 0)
1657 nb_rxq = res->value;
1659 else if (!strcmp(res->name, "txq")) {
1660 if (!res->value && !nb_rxq) {
1661 printf("Warning: Either rx or tx queues should be non zero\n");
1664 if (check_nb_txq(res->value) != 0)
1666 nb_txq = res->value;
1668 else if (!strcmp(res->name, "rxd")) {
1669 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1670 printf("rxd %d invalid - must be > 0 && <= %d\n",
1671 res->value, RTE_TEST_RX_DESC_MAX);
1674 nb_rxd = res->value;
1675 } else if (!strcmp(res->name, "txd")) {
1676 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1677 printf("txd %d invalid - must be > 0 && <= %d\n",
1678 res->value, RTE_TEST_TX_DESC_MAX);
1681 nb_txd = res->value;
1683 printf("Unknown parameter\n");
1691 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1694 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1695 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1696 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1697 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1698 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1699 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1700 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1701 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1703 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1704 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1706 cmdline_parse_inst_t cmd_config_rx_tx = {
1707 .f = cmd_config_rx_tx_parsed,
1709 .help_str = "port config all rxq|txq|rxd|txd <value>",
1711 (void *)&cmd_config_rx_tx_port,
1712 (void *)&cmd_config_rx_tx_keyword,
1713 (void *)&cmd_config_rx_tx_all,
1714 (void *)&cmd_config_rx_tx_name,
1715 (void *)&cmd_config_rx_tx_value,
1720 /* *** config max packet length *** */
1721 struct cmd_config_max_pkt_len_result {
1722 cmdline_fixed_string_t port;
1723 cmdline_fixed_string_t keyword;
1724 cmdline_fixed_string_t all;
1725 cmdline_fixed_string_t name;
1730 cmd_config_max_pkt_len_parsed(void *parsed_result,
1731 __attribute__((unused)) struct cmdline *cl,
1732 __attribute__((unused)) void *data)
1734 struct cmd_config_max_pkt_len_result *res = parsed_result;
1737 if (!all_ports_stopped()) {
1738 printf("Please stop all ports first\n");
1742 RTE_ETH_FOREACH_DEV(pid) {
1743 struct rte_port *port = &ports[pid];
1744 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1746 if (!strcmp(res->name, "max-pkt-len")) {
1747 if (res->value < ETHER_MIN_LEN) {
1748 printf("max-pkt-len can not be less than %d\n",
1752 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1755 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1756 if (res->value > ETHER_MAX_LEN)
1757 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1759 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1760 port->dev_conf.rxmode.offloads = rx_offloads;
1762 printf("Unknown parameter\n");
1769 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1772 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1773 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1775 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1778 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1779 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1781 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1784 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1785 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1788 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1789 .f = cmd_config_max_pkt_len_parsed,
1791 .help_str = "port config all max-pkt-len <value>",
1793 (void *)&cmd_config_max_pkt_len_port,
1794 (void *)&cmd_config_max_pkt_len_keyword,
1795 (void *)&cmd_config_max_pkt_len_all,
1796 (void *)&cmd_config_max_pkt_len_name,
1797 (void *)&cmd_config_max_pkt_len_value,
1802 /* *** configure port MTU *** */
1803 struct cmd_config_mtu_result {
1804 cmdline_fixed_string_t port;
1805 cmdline_fixed_string_t keyword;
1806 cmdline_fixed_string_t mtu;
1812 cmd_config_mtu_parsed(void *parsed_result,
1813 __attribute__((unused)) struct cmdline *cl,
1814 __attribute__((unused)) void *data)
1816 struct cmd_config_mtu_result *res = parsed_result;
1818 if (res->value < ETHER_MIN_LEN) {
1819 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1822 port_mtu_set(res->port_id, res->value);
1825 cmdline_parse_token_string_t cmd_config_mtu_port =
1826 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1828 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1829 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1831 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1834 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1835 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1836 cmdline_parse_token_num_t cmd_config_mtu_value =
1837 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1839 cmdline_parse_inst_t cmd_config_mtu = {
1840 .f = cmd_config_mtu_parsed,
1842 .help_str = "port config mtu <port_id> <value>",
1844 (void *)&cmd_config_mtu_port,
1845 (void *)&cmd_config_mtu_keyword,
1846 (void *)&cmd_config_mtu_mtu,
1847 (void *)&cmd_config_mtu_port_id,
1848 (void *)&cmd_config_mtu_value,
1853 /* *** configure rx mode *** */
1854 struct cmd_config_rx_mode_flag {
1855 cmdline_fixed_string_t port;
1856 cmdline_fixed_string_t keyword;
1857 cmdline_fixed_string_t all;
1858 cmdline_fixed_string_t name;
1859 cmdline_fixed_string_t value;
1863 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1864 __attribute__((unused)) struct cmdline *cl,
1865 __attribute__((unused)) void *data)
1867 struct cmd_config_rx_mode_flag *res = parsed_result;
1870 if (!all_ports_stopped()) {
1871 printf("Please stop all ports first\n");
1875 RTE_ETH_FOREACH_DEV(pid) {
1876 struct rte_port *port;
1877 uint64_t rx_offloads;
1880 rx_offloads = port->dev_conf.rxmode.offloads;
1881 if (!strcmp(res->name, "crc-strip")) {
1882 if (!strcmp(res->value, "on"))
1883 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1884 else if (!strcmp(res->value, "off"))
1885 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1887 printf("Unknown parameter\n");
1890 } else if (!strcmp(res->name, "scatter")) {
1891 if (!strcmp(res->value, "on")) {
1892 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1893 } else if (!strcmp(res->value, "off")) {
1894 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1896 printf("Unknown parameter\n");
1899 } else if (!strcmp(res->name, "rx-cksum")) {
1900 if (!strcmp(res->value, "on"))
1901 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1902 else if (!strcmp(res->value, "off"))
1903 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1905 printf("Unknown parameter\n");
1908 } else if (!strcmp(res->name, "rx-timestamp")) {
1909 if (!strcmp(res->value, "on"))
1910 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1911 else if (!strcmp(res->value, "off"))
1912 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1914 printf("Unknown parameter\n");
1917 } else if (!strcmp(res->name, "hw-vlan")) {
1918 if (!strcmp(res->value, "on")) {
1919 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1920 DEV_RX_OFFLOAD_VLAN_STRIP);
1921 } else if (!strcmp(res->value, "off")) {
1922 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1923 DEV_RX_OFFLOAD_VLAN_STRIP);
1925 printf("Unknown parameter\n");
1928 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1929 if (!strcmp(res->value, "on"))
1930 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1931 else if (!strcmp(res->value, "off"))
1932 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1934 printf("Unknown parameter\n");
1937 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1938 if (!strcmp(res->value, "on"))
1939 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1940 else if (!strcmp(res->value, "off"))
1941 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1943 printf("Unknown parameter\n");
1946 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1947 if (!strcmp(res->value, "on"))
1948 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1949 else if (!strcmp(res->value, "off"))
1950 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1952 printf("Unknown parameter\n");
1955 } else if (!strcmp(res->name, "drop-en")) {
1956 if (!strcmp(res->value, "on"))
1958 else if (!strcmp(res->value, "off"))
1961 printf("Unknown parameter\n");
1965 printf("Unknown parameter\n");
1968 port->dev_conf.rxmode.offloads = rx_offloads;
1973 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1976 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1977 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1978 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1979 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1981 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1982 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1983 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1984 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1985 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1986 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1987 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1988 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1991 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1992 .f = cmd_config_rx_mode_flag_parsed,
1994 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1995 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1997 (void *)&cmd_config_rx_mode_flag_port,
1998 (void *)&cmd_config_rx_mode_flag_keyword,
1999 (void *)&cmd_config_rx_mode_flag_all,
2000 (void *)&cmd_config_rx_mode_flag_name,
2001 (void *)&cmd_config_rx_mode_flag_value,
2006 /* *** configure rss *** */
2007 struct cmd_config_rss {
2008 cmdline_fixed_string_t port;
2009 cmdline_fixed_string_t keyword;
2010 cmdline_fixed_string_t all;
2011 cmdline_fixed_string_t name;
2012 cmdline_fixed_string_t value;
2016 cmd_config_rss_parsed(void *parsed_result,
2017 __attribute__((unused)) struct cmdline *cl,
2018 __attribute__((unused)) void *data)
2020 struct cmd_config_rss *res = parsed_result;
2021 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2022 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2023 int use_default = 0;
2024 int all_updated = 1;
2028 if (!strcmp(res->value, "all"))
2029 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2030 ETH_RSS_UDP | ETH_RSS_SCTP |
2032 else if (!strcmp(res->value, "ip"))
2033 rss_conf.rss_hf = ETH_RSS_IP;
2034 else if (!strcmp(res->value, "udp"))
2035 rss_conf.rss_hf = ETH_RSS_UDP;
2036 else if (!strcmp(res->value, "tcp"))
2037 rss_conf.rss_hf = ETH_RSS_TCP;
2038 else if (!strcmp(res->value, "sctp"))
2039 rss_conf.rss_hf = ETH_RSS_SCTP;
2040 else if (!strcmp(res->value, "ether"))
2041 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2042 else if (!strcmp(res->value, "port"))
2043 rss_conf.rss_hf = ETH_RSS_PORT;
2044 else if (!strcmp(res->value, "vxlan"))
2045 rss_conf.rss_hf = ETH_RSS_VXLAN;
2046 else if (!strcmp(res->value, "geneve"))
2047 rss_conf.rss_hf = ETH_RSS_GENEVE;
2048 else if (!strcmp(res->value, "nvgre"))
2049 rss_conf.rss_hf = ETH_RSS_NVGRE;
2050 else if (!strcmp(res->value, "none"))
2051 rss_conf.rss_hf = 0;
2052 else if (!strcmp(res->value, "default"))
2054 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2055 atoi(res->value) < 64)
2056 rss_conf.rss_hf = 1ULL << atoi(res->value);
2058 printf("Unknown parameter\n");
2061 rss_conf.rss_key = NULL;
2062 /* Update global configuration for RSS types. */
2063 RTE_ETH_FOREACH_DEV(i) {
2064 struct rte_eth_rss_conf local_rss_conf;
2066 rte_eth_dev_info_get(i, &dev_info);
2068 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2070 local_rss_conf = rss_conf;
2071 local_rss_conf.rss_hf = rss_conf.rss_hf &
2072 dev_info.flow_type_rss_offloads;
2073 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2074 printf("Port %u modified RSS hash function based on hardware support,"
2075 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2076 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2078 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2081 printf("Configuration of RSS hash at ethernet port %d "
2082 "failed with error (%d): %s.\n",
2083 i, -diag, strerror(-diag));
2086 if (all_updated && !use_default)
2087 rss_hf = rss_conf.rss_hf;
2090 cmdline_parse_token_string_t cmd_config_rss_port =
2091 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2092 cmdline_parse_token_string_t cmd_config_rss_keyword =
2093 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2094 cmdline_parse_token_string_t cmd_config_rss_all =
2095 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2096 cmdline_parse_token_string_t cmd_config_rss_name =
2097 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2098 cmdline_parse_token_string_t cmd_config_rss_value =
2099 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2101 cmdline_parse_inst_t cmd_config_rss = {
2102 .f = cmd_config_rss_parsed,
2104 .help_str = "port config all rss "
2105 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2107 (void *)&cmd_config_rss_port,
2108 (void *)&cmd_config_rss_keyword,
2109 (void *)&cmd_config_rss_all,
2110 (void *)&cmd_config_rss_name,
2111 (void *)&cmd_config_rss_value,
2116 /* *** configure rss hash key *** */
2117 struct cmd_config_rss_hash_key {
2118 cmdline_fixed_string_t port;
2119 cmdline_fixed_string_t config;
2121 cmdline_fixed_string_t rss_hash_key;
2122 cmdline_fixed_string_t rss_type;
2123 cmdline_fixed_string_t key;
2127 hexa_digit_to_value(char hexa_digit)
2129 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2130 return (uint8_t) (hexa_digit - '0');
2131 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2132 return (uint8_t) ((hexa_digit - 'a') + 10);
2133 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2134 return (uint8_t) ((hexa_digit - 'A') + 10);
2135 /* Invalid hexa digit */
2140 parse_and_check_key_hexa_digit(char *key, int idx)
2144 hexa_v = hexa_digit_to_value(key[idx]);
2146 printf("invalid key: character %c at position %d is not a "
2147 "valid hexa digit\n", key[idx], idx);
2152 cmd_config_rss_hash_key_parsed(void *parsed_result,
2153 __attribute__((unused)) struct cmdline *cl,
2154 __attribute__((unused)) void *data)
2156 struct cmd_config_rss_hash_key *res = parsed_result;
2157 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2161 struct rte_eth_dev_info dev_info;
2162 uint8_t hash_key_size;
2165 memset(&dev_info, 0, sizeof(dev_info));
2166 rte_eth_dev_info_get(res->port_id, &dev_info);
2167 if (dev_info.hash_key_size > 0 &&
2168 dev_info.hash_key_size <= sizeof(hash_key))
2169 hash_key_size = dev_info.hash_key_size;
2171 printf("dev_info did not provide a valid hash key size\n");
2174 /* Check the length of the RSS hash key */
2175 key_len = strlen(res->key);
2176 if (key_len != (hash_key_size * 2)) {
2177 printf("key length: %d invalid - key must be a string of %d"
2178 " hexa-decimal numbers\n",
2179 (int) key_len, hash_key_size * 2);
2182 /* Translate RSS hash key into binary representation */
2183 for (i = 0; i < hash_key_size; i++) {
2184 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2187 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2190 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2192 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2196 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2197 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2198 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2199 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2201 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2202 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2203 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2204 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2205 rss_hash_key, "rss-hash-key");
2206 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2207 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2208 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2209 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2210 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2211 "ipv6-tcp-ex#ipv6-udp-ex");
2212 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2213 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2215 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2216 .f = cmd_config_rss_hash_key_parsed,
2218 .help_str = "port config <port_id> rss-hash-key "
2219 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2220 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2221 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2222 "<string of hex digits (variable length, NIC dependent)>",
2224 (void *)&cmd_config_rss_hash_key_port,
2225 (void *)&cmd_config_rss_hash_key_config,
2226 (void *)&cmd_config_rss_hash_key_port_id,
2227 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2228 (void *)&cmd_config_rss_hash_key_rss_type,
2229 (void *)&cmd_config_rss_hash_key_value,
2234 /* *** configure port rxq/txq ring size *** */
2235 struct cmd_config_rxtx_ring_size {
2236 cmdline_fixed_string_t port;
2237 cmdline_fixed_string_t config;
2239 cmdline_fixed_string_t rxtxq;
2241 cmdline_fixed_string_t rsize;
2246 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2247 __attribute__((unused)) struct cmdline *cl,
2248 __attribute__((unused)) void *data)
2250 struct cmd_config_rxtx_ring_size *res = parsed_result;
2251 struct rte_port *port;
2254 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2257 if (res->portid == (portid_t)RTE_PORT_ALL) {
2258 printf("Invalid port id\n");
2262 port = &ports[res->portid];
2264 if (!strcmp(res->rxtxq, "rxq"))
2266 else if (!strcmp(res->rxtxq, "txq"))
2269 printf("Unknown parameter\n");
2273 if (isrx && rx_queue_id_is_invalid(res->qid))
2275 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2278 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2279 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2285 port->nb_rx_desc[res->qid] = res->size;
2287 port->nb_tx_desc[res->qid] = res->size;
2289 cmd_reconfig_device_queue(res->portid, 0, 1);
2292 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2293 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2295 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2296 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2298 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2299 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2301 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2302 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2304 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2305 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2307 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2309 rsize, "ring_size");
2310 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2311 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2314 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2315 .f = cmd_config_rxtx_ring_size_parsed,
2317 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2319 (void *)&cmd_config_rxtx_ring_size_port,
2320 (void *)&cmd_config_rxtx_ring_size_config,
2321 (void *)&cmd_config_rxtx_ring_size_portid,
2322 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2323 (void *)&cmd_config_rxtx_ring_size_qid,
2324 (void *)&cmd_config_rxtx_ring_size_rsize,
2325 (void *)&cmd_config_rxtx_ring_size_size,
2330 /* *** configure port rxq/txq start/stop *** */
2331 struct cmd_config_rxtx_queue {
2332 cmdline_fixed_string_t port;
2334 cmdline_fixed_string_t rxtxq;
2336 cmdline_fixed_string_t opname;
2340 cmd_config_rxtx_queue_parsed(void *parsed_result,
2341 __attribute__((unused)) struct cmdline *cl,
2342 __attribute__((unused)) void *data)
2344 struct cmd_config_rxtx_queue *res = parsed_result;
2349 if (test_done == 0) {
2350 printf("Please stop forwarding first\n");
2354 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2357 if (port_is_started(res->portid) != 1) {
2358 printf("Please start port %u first\n", res->portid);
2362 if (!strcmp(res->rxtxq, "rxq"))
2364 else if (!strcmp(res->rxtxq, "txq"))
2367 printf("Unknown parameter\n");
2371 if (isrx && rx_queue_id_is_invalid(res->qid))
2373 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2376 if (!strcmp(res->opname, "start"))
2378 else if (!strcmp(res->opname, "stop"))
2381 printf("Unknown parameter\n");
2385 if (isstart && isrx)
2386 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2387 else if (!isstart && isrx)
2388 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2389 else if (isstart && !isrx)
2390 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2392 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2394 if (ret == -ENOTSUP)
2395 printf("Function not supported in PMD driver\n");
2398 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2399 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2400 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2401 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2402 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2403 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2404 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2405 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2406 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2407 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2410 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2411 .f = cmd_config_rxtx_queue_parsed,
2413 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2415 (void *)&cmd_config_rxtx_queue_port,
2416 (void *)&cmd_config_rxtx_queue_portid,
2417 (void *)&cmd_config_rxtx_queue_rxtxq,
2418 (void *)&cmd_config_rxtx_queue_qid,
2419 (void *)&cmd_config_rxtx_queue_opname,
2424 /* *** configure port rxq/txq setup *** */
2425 struct cmd_setup_rxtx_queue {
2426 cmdline_fixed_string_t port;
2428 cmdline_fixed_string_t rxtxq;
2430 cmdline_fixed_string_t setup;
2433 /* Common CLI fields for queue setup */
2434 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2435 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2436 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2437 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2438 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2439 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2440 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2441 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2442 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2443 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2446 cmd_setup_rxtx_queue_parsed(
2447 void *parsed_result,
2448 __attribute__((unused)) struct cmdline *cl,
2449 __attribute__((unused)) void *data)
2451 struct cmd_setup_rxtx_queue *res = parsed_result;
2452 struct rte_port *port;
2453 struct rte_mempool *mp;
2454 unsigned int socket_id;
2458 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2461 if (res->portid == (portid_t)RTE_PORT_ALL) {
2462 printf("Invalid port id\n");
2466 if (!strcmp(res->rxtxq, "rxq"))
2468 else if (!strcmp(res->rxtxq, "txq"))
2471 printf("Unknown parameter\n");
2475 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2476 printf("Invalid rx queue\n");
2478 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2479 printf("Invalid tx queue\n");
2483 port = &ports[res->portid];
2485 socket_id = rxring_numa[res->portid];
2486 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2487 socket_id = port->socket_id;
2489 mp = mbuf_pool_find(socket_id);
2491 printf("Failed to setup RX queue: "
2492 "No mempool allocation"
2493 " on the socket %d\n",
2494 rxring_numa[res->portid]);
2497 ret = rte_eth_rx_queue_setup(res->portid,
2499 port->nb_rx_desc[res->qid],
2501 &port->rx_conf[res->qid],
2504 printf("Failed to setup RX queue\n");
2506 socket_id = txring_numa[res->portid];
2507 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2508 socket_id = port->socket_id;
2510 ret = rte_eth_tx_queue_setup(res->portid,
2512 port->nb_tx_desc[res->qid],
2514 &port->tx_conf[res->qid]);
2516 printf("Failed to setup TX queue\n");
2520 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2521 .f = cmd_setup_rxtx_queue_parsed,
2523 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2525 (void *)&cmd_setup_rxtx_queue_port,
2526 (void *)&cmd_setup_rxtx_queue_portid,
2527 (void *)&cmd_setup_rxtx_queue_rxtxq,
2528 (void *)&cmd_setup_rxtx_queue_qid,
2529 (void *)&cmd_setup_rxtx_queue_setup,
2535 /* *** Configure RSS RETA *** */
2536 struct cmd_config_rss_reta {
2537 cmdline_fixed_string_t port;
2538 cmdline_fixed_string_t keyword;
2540 cmdline_fixed_string_t name;
2541 cmdline_fixed_string_t list_name;
2542 cmdline_fixed_string_t list_of_items;
2546 parse_reta_config(const char *str,
2547 struct rte_eth_rss_reta_entry64 *reta_conf,
2548 uint16_t nb_entries)
2552 uint16_t hash_index, idx, shift;
2555 const char *p, *p0 = str;
2562 unsigned long int_fld[_NUM_FLD];
2563 char *str_fld[_NUM_FLD];
2565 while ((p = strchr(p0,'(')) != NULL) {
2567 if((p0 = strchr(p,')')) == NULL)
2571 if(size >= sizeof(s))
2574 snprintf(s, sizeof(s), "%.*s", size, p);
2575 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2577 for (i = 0; i < _NUM_FLD; i++) {
2579 int_fld[i] = strtoul(str_fld[i], &end, 0);
2580 if (errno != 0 || end == str_fld[i] ||
2585 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2586 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2588 if (hash_index >= nb_entries) {
2589 printf("Invalid RETA hash index=%d\n", hash_index);
2593 idx = hash_index / RTE_RETA_GROUP_SIZE;
2594 shift = hash_index % RTE_RETA_GROUP_SIZE;
2595 reta_conf[idx].mask |= (1ULL << shift);
2596 reta_conf[idx].reta[shift] = nb_queue;
2603 cmd_set_rss_reta_parsed(void *parsed_result,
2604 __attribute__((unused)) struct cmdline *cl,
2605 __attribute__((unused)) void *data)
2608 struct rte_eth_dev_info dev_info;
2609 struct rte_eth_rss_reta_entry64 reta_conf[8];
2610 struct cmd_config_rss_reta *res = parsed_result;
2612 memset(&dev_info, 0, sizeof(dev_info));
2613 rte_eth_dev_info_get(res->port_id, &dev_info);
2614 if (dev_info.reta_size == 0) {
2615 printf("Redirection table size is 0 which is "
2616 "invalid for RSS\n");
2619 printf("The reta size of port %d is %u\n",
2620 res->port_id, dev_info.reta_size);
2621 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2622 printf("Currently do not support more than %u entries of "
2623 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2627 memset(reta_conf, 0, sizeof(reta_conf));
2628 if (!strcmp(res->list_name, "reta")) {
2629 if (parse_reta_config(res->list_of_items, reta_conf,
2630 dev_info.reta_size)) {
2631 printf("Invalid RSS Redirection Table "
2632 "config entered\n");
2635 ret = rte_eth_dev_rss_reta_update(res->port_id,
2636 reta_conf, dev_info.reta_size);
2638 printf("Bad redirection table parameter, "
2639 "return code = %d \n", ret);
2643 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2644 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2645 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2646 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2647 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2648 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2649 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2650 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2651 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2652 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2653 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2654 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2656 cmdline_parse_inst_t cmd_config_rss_reta = {
2657 .f = cmd_set_rss_reta_parsed,
2659 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2661 (void *)&cmd_config_rss_reta_port,
2662 (void *)&cmd_config_rss_reta_keyword,
2663 (void *)&cmd_config_rss_reta_port_id,
2664 (void *)&cmd_config_rss_reta_name,
2665 (void *)&cmd_config_rss_reta_list_name,
2666 (void *)&cmd_config_rss_reta_list_of_items,
2671 /* *** SHOW PORT RETA INFO *** */
2672 struct cmd_showport_reta {
2673 cmdline_fixed_string_t show;
2674 cmdline_fixed_string_t port;
2676 cmdline_fixed_string_t rss;
2677 cmdline_fixed_string_t reta;
2679 cmdline_fixed_string_t list_of_items;
2683 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2684 uint16_t nb_entries,
2688 const char *p, *p0 = str;
2693 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2694 RTE_RETA_GROUP_SIZE;
2697 p = strchr(p0, '(');
2701 p0 = strchr(p, ')');
2705 if (size >= sizeof(s)) {
2706 printf("The string size exceeds the internal buffer size\n");
2709 snprintf(s, sizeof(s), "%.*s", size, p);
2710 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2711 if (ret <= 0 || ret != num) {
2712 printf("The bits of masks do not match the number of "
2713 "reta entries: %u\n", num);
2716 for (i = 0; i < ret; i++)
2717 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2723 cmd_showport_reta_parsed(void *parsed_result,
2724 __attribute__((unused)) struct cmdline *cl,
2725 __attribute__((unused)) void *data)
2727 struct cmd_showport_reta *res = parsed_result;
2728 struct rte_eth_rss_reta_entry64 reta_conf[8];
2729 struct rte_eth_dev_info dev_info;
2730 uint16_t max_reta_size;
2732 memset(&dev_info, 0, sizeof(dev_info));
2733 rte_eth_dev_info_get(res->port_id, &dev_info);
2734 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2735 if (res->size == 0 || res->size > max_reta_size) {
2736 printf("Invalid redirection table size: %u (1-%u)\n",
2737 res->size, max_reta_size);
2741 memset(reta_conf, 0, sizeof(reta_conf));
2742 if (showport_parse_reta_config(reta_conf, res->size,
2743 res->list_of_items) < 0) {
2744 printf("Invalid string: %s for reta masks\n",
2745 res->list_of_items);
2748 port_rss_reta_info(res->port_id, reta_conf, res->size);
2751 cmdline_parse_token_string_t cmd_showport_reta_show =
2752 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2753 cmdline_parse_token_string_t cmd_showport_reta_port =
2754 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2755 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2756 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2757 cmdline_parse_token_string_t cmd_showport_reta_rss =
2758 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2759 cmdline_parse_token_string_t cmd_showport_reta_reta =
2760 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2761 cmdline_parse_token_num_t cmd_showport_reta_size =
2762 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2763 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2764 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2765 list_of_items, NULL);
2767 cmdline_parse_inst_t cmd_showport_reta = {
2768 .f = cmd_showport_reta_parsed,
2770 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2772 (void *)&cmd_showport_reta_show,
2773 (void *)&cmd_showport_reta_port,
2774 (void *)&cmd_showport_reta_port_id,
2775 (void *)&cmd_showport_reta_rss,
2776 (void *)&cmd_showport_reta_reta,
2777 (void *)&cmd_showport_reta_size,
2778 (void *)&cmd_showport_reta_list_of_items,
2783 /* *** Show RSS hash configuration *** */
2784 struct cmd_showport_rss_hash {
2785 cmdline_fixed_string_t show;
2786 cmdline_fixed_string_t port;
2788 cmdline_fixed_string_t rss_hash;
2789 cmdline_fixed_string_t rss_type;
2790 cmdline_fixed_string_t key; /* optional argument */
2793 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2794 __attribute__((unused)) struct cmdline *cl,
2797 struct cmd_showport_rss_hash *res = parsed_result;
2799 port_rss_hash_conf_show(res->port_id, res->rss_type,
2800 show_rss_key != NULL);
2803 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2804 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2805 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2806 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2807 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2808 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2809 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2810 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2812 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2813 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2814 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2815 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2816 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2817 "ipv6-tcp-ex#ipv6-udp-ex");
2818 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2819 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2821 cmdline_parse_inst_t cmd_showport_rss_hash = {
2822 .f = cmd_showport_rss_hash_parsed,
2824 .help_str = "show port <port_id> rss-hash "
2825 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2826 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2827 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2829 (void *)&cmd_showport_rss_hash_show,
2830 (void *)&cmd_showport_rss_hash_port,
2831 (void *)&cmd_showport_rss_hash_port_id,
2832 (void *)&cmd_showport_rss_hash_rss_hash,
2833 (void *)&cmd_showport_rss_hash_rss_hash_info,
2838 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2839 .f = cmd_showport_rss_hash_parsed,
2841 .help_str = "show port <port_id> rss-hash "
2842 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2843 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2844 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2846 (void *)&cmd_showport_rss_hash_show,
2847 (void *)&cmd_showport_rss_hash_port,
2848 (void *)&cmd_showport_rss_hash_port_id,
2849 (void *)&cmd_showport_rss_hash_rss_hash,
2850 (void *)&cmd_showport_rss_hash_rss_hash_info,
2851 (void *)&cmd_showport_rss_hash_rss_key,
2856 /* *** Configure DCB *** */
2857 struct cmd_config_dcb {
2858 cmdline_fixed_string_t port;
2859 cmdline_fixed_string_t config;
2861 cmdline_fixed_string_t dcb;
2862 cmdline_fixed_string_t vt;
2863 cmdline_fixed_string_t vt_en;
2865 cmdline_fixed_string_t pfc;
2866 cmdline_fixed_string_t pfc_en;
2870 cmd_config_dcb_parsed(void *parsed_result,
2871 __attribute__((unused)) struct cmdline *cl,
2872 __attribute__((unused)) void *data)
2874 struct cmd_config_dcb *res = parsed_result;
2875 portid_t port_id = res->port_id;
2876 struct rte_port *port;
2880 port = &ports[port_id];
2881 /** Check if the port is not started **/
2882 if (port->port_status != RTE_PORT_STOPPED) {
2883 printf("Please stop port %d first\n", port_id);
2887 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2888 printf("The invalid number of traffic class,"
2889 " only 4 or 8 allowed.\n");
2893 if (nb_fwd_lcores < res->num_tcs) {
2894 printf("nb_cores shouldn't be less than number of TCs.\n");
2897 if (!strncmp(res->pfc_en, "on", 2))
2902 /* DCB in VT mode */
2903 if (!strncmp(res->vt_en, "on", 2))
2904 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2905 (enum rte_eth_nb_tcs)res->num_tcs,
2908 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2909 (enum rte_eth_nb_tcs)res->num_tcs,
2914 printf("Cannot initialize network ports.\n");
2918 cmd_reconfig_device_queue(port_id, 1, 1);
2921 cmdline_parse_token_string_t cmd_config_dcb_port =
2922 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2923 cmdline_parse_token_string_t cmd_config_dcb_config =
2924 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2925 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2926 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2927 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2928 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2929 cmdline_parse_token_string_t cmd_config_dcb_vt =
2930 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2931 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2932 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2933 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2934 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2935 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2936 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2937 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2938 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2940 cmdline_parse_inst_t cmd_config_dcb = {
2941 .f = cmd_config_dcb_parsed,
2943 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2945 (void *)&cmd_config_dcb_port,
2946 (void *)&cmd_config_dcb_config,
2947 (void *)&cmd_config_dcb_port_id,
2948 (void *)&cmd_config_dcb_dcb,
2949 (void *)&cmd_config_dcb_vt,
2950 (void *)&cmd_config_dcb_vt_en,
2951 (void *)&cmd_config_dcb_num_tcs,
2952 (void *)&cmd_config_dcb_pfc,
2953 (void *)&cmd_config_dcb_pfc_en,
2958 /* *** configure number of packets per burst *** */
2959 struct cmd_config_burst {
2960 cmdline_fixed_string_t port;
2961 cmdline_fixed_string_t keyword;
2962 cmdline_fixed_string_t all;
2963 cmdline_fixed_string_t name;
2968 cmd_config_burst_parsed(void *parsed_result,
2969 __attribute__((unused)) struct cmdline *cl,
2970 __attribute__((unused)) void *data)
2972 struct cmd_config_burst *res = parsed_result;
2973 struct rte_eth_dev_info dev_info;
2974 uint16_t rec_nb_pkts;
2976 if (!all_ports_stopped()) {
2977 printf("Please stop all ports first\n");
2981 if (!strcmp(res->name, "burst")) {
2982 if (res->value == 0) {
2983 /* If user gives a value of zero, query the PMD for
2984 * its recommended Rx burst size. Testpmd uses a single
2985 * size for all ports, so assume all ports are the same
2986 * NIC model and use the values from Port 0.
2988 rte_eth_dev_info_get(0, &dev_info);
2989 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2991 if (rec_nb_pkts == 0) {
2992 printf("PMD does not recommend a burst size.\n"
2993 "User provided value must be between"
2994 " 1 and %d\n", MAX_PKT_BURST);
2996 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2997 printf("PMD recommended burst size of %d"
2998 " exceeds maximum value of %d\n",
2999 rec_nb_pkts, MAX_PKT_BURST);
3002 printf("Using PMD-provided burst value of %d\n",
3004 nb_pkt_per_burst = rec_nb_pkts;
3005 } else if (res->value > MAX_PKT_BURST) {
3006 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3009 nb_pkt_per_burst = res->value;
3011 printf("Unknown parameter\n");
3017 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3020 cmdline_parse_token_string_t cmd_config_burst_port =
3021 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3022 cmdline_parse_token_string_t cmd_config_burst_keyword =
3023 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3024 cmdline_parse_token_string_t cmd_config_burst_all =
3025 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3026 cmdline_parse_token_string_t cmd_config_burst_name =
3027 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3028 cmdline_parse_token_num_t cmd_config_burst_value =
3029 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3031 cmdline_parse_inst_t cmd_config_burst = {
3032 .f = cmd_config_burst_parsed,
3034 .help_str = "port config all burst <value>",
3036 (void *)&cmd_config_burst_port,
3037 (void *)&cmd_config_burst_keyword,
3038 (void *)&cmd_config_burst_all,
3039 (void *)&cmd_config_burst_name,
3040 (void *)&cmd_config_burst_value,
3045 /* *** configure rx/tx queues *** */
3046 struct cmd_config_thresh {
3047 cmdline_fixed_string_t port;
3048 cmdline_fixed_string_t keyword;
3049 cmdline_fixed_string_t all;
3050 cmdline_fixed_string_t name;
3055 cmd_config_thresh_parsed(void *parsed_result,
3056 __attribute__((unused)) struct cmdline *cl,
3057 __attribute__((unused)) void *data)
3059 struct cmd_config_thresh *res = parsed_result;
3061 if (!all_ports_stopped()) {
3062 printf("Please stop all ports first\n");
3066 if (!strcmp(res->name, "txpt"))
3067 tx_pthresh = res->value;
3068 else if(!strcmp(res->name, "txht"))
3069 tx_hthresh = res->value;
3070 else if(!strcmp(res->name, "txwt"))
3071 tx_wthresh = res->value;
3072 else if(!strcmp(res->name, "rxpt"))
3073 rx_pthresh = res->value;
3074 else if(!strcmp(res->name, "rxht"))
3075 rx_hthresh = res->value;
3076 else if(!strcmp(res->name, "rxwt"))
3077 rx_wthresh = res->value;
3079 printf("Unknown parameter\n");
3085 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3088 cmdline_parse_token_string_t cmd_config_thresh_port =
3089 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3090 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3091 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3092 cmdline_parse_token_string_t cmd_config_thresh_all =
3093 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3094 cmdline_parse_token_string_t cmd_config_thresh_name =
3095 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3096 "txpt#txht#txwt#rxpt#rxht#rxwt");
3097 cmdline_parse_token_num_t cmd_config_thresh_value =
3098 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3100 cmdline_parse_inst_t cmd_config_thresh = {
3101 .f = cmd_config_thresh_parsed,
3103 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3105 (void *)&cmd_config_thresh_port,
3106 (void *)&cmd_config_thresh_keyword,
3107 (void *)&cmd_config_thresh_all,
3108 (void *)&cmd_config_thresh_name,
3109 (void *)&cmd_config_thresh_value,
3114 /* *** configure free/rs threshold *** */
3115 struct cmd_config_threshold {
3116 cmdline_fixed_string_t port;
3117 cmdline_fixed_string_t keyword;
3118 cmdline_fixed_string_t all;
3119 cmdline_fixed_string_t name;
3124 cmd_config_threshold_parsed(void *parsed_result,
3125 __attribute__((unused)) struct cmdline *cl,
3126 __attribute__((unused)) void *data)
3128 struct cmd_config_threshold *res = parsed_result;
3130 if (!all_ports_stopped()) {
3131 printf("Please stop all ports first\n");
3135 if (!strcmp(res->name, "txfreet"))
3136 tx_free_thresh = res->value;
3137 else if (!strcmp(res->name, "txrst"))
3138 tx_rs_thresh = res->value;
3139 else if (!strcmp(res->name, "rxfreet"))
3140 rx_free_thresh = res->value;
3142 printf("Unknown parameter\n");
3148 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3151 cmdline_parse_token_string_t cmd_config_threshold_port =
3152 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3153 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3154 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3156 cmdline_parse_token_string_t cmd_config_threshold_all =
3157 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3158 cmdline_parse_token_string_t cmd_config_threshold_name =
3159 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3160 "txfreet#txrst#rxfreet");
3161 cmdline_parse_token_num_t cmd_config_threshold_value =
3162 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3164 cmdline_parse_inst_t cmd_config_threshold = {
3165 .f = cmd_config_threshold_parsed,
3167 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3169 (void *)&cmd_config_threshold_port,
3170 (void *)&cmd_config_threshold_keyword,
3171 (void *)&cmd_config_threshold_all,
3172 (void *)&cmd_config_threshold_name,
3173 (void *)&cmd_config_threshold_value,
3179 struct cmd_stop_result {
3180 cmdline_fixed_string_t stop;
3183 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3184 __attribute__((unused)) struct cmdline *cl,
3185 __attribute__((unused)) void *data)
3187 stop_packet_forwarding();
3190 cmdline_parse_token_string_t cmd_stop_stop =
3191 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3193 cmdline_parse_inst_t cmd_stop = {
3194 .f = cmd_stop_parsed,
3196 .help_str = "stop: Stop packet forwarding",
3198 (void *)&cmd_stop_stop,
3203 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3206 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3207 unsigned int *parsed_items, int check_unique_values)
3209 unsigned int nb_item;
3217 * First parse all items in the list and store their value.
3222 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3224 if ((c >= '0') && (c <= '9')) {
3225 value = (unsigned int) (value * 10 + (c - '0'));
3230 printf("character %c is not a decimal digit\n", c);
3234 printf("No valid value before comma\n");
3237 if (nb_item < max_items) {
3238 parsed_items[nb_item] = value;
3244 if (nb_item >= max_items) {
3245 printf("Number of %s = %u > %u (maximum items)\n",
3246 item_name, nb_item + 1, max_items);
3249 parsed_items[nb_item++] = value;
3250 if (! check_unique_values)
3254 * Then, check that all values in the list are differents.
3255 * No optimization here...
3257 for (i = 0; i < nb_item; i++) {
3258 for (j = i + 1; j < nb_item; j++) {
3259 if (parsed_items[j] == parsed_items[i]) {
3260 printf("duplicated %s %u at index %u and %u\n",
3261 item_name, parsed_items[i], i, j);
3269 struct cmd_set_list_result {
3270 cmdline_fixed_string_t cmd_keyword;
3271 cmdline_fixed_string_t list_name;
3272 cmdline_fixed_string_t list_of_items;
3275 static void cmd_set_list_parsed(void *parsed_result,
3276 __attribute__((unused)) struct cmdline *cl,
3277 __attribute__((unused)) void *data)
3279 struct cmd_set_list_result *res;
3281 unsigned int lcorelist[RTE_MAX_LCORE];
3282 unsigned int portlist[RTE_MAX_ETHPORTS];
3284 unsigned int nb_item;
3286 if (test_done == 0) {
3287 printf("Please stop forwarding first\n");
3291 res = parsed_result;
3292 if (!strcmp(res->list_name, "corelist")) {
3293 nb_item = parse_item_list(res->list_of_items, "core",
3295 parsed_items.lcorelist, 1);
3297 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3302 if (!strcmp(res->list_name, "portlist")) {
3303 nb_item = parse_item_list(res->list_of_items, "port",
3305 parsed_items.portlist, 1);
3307 set_fwd_ports_list(parsed_items.portlist, nb_item);
3313 cmdline_parse_token_string_t cmd_set_list_keyword =
3314 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3316 cmdline_parse_token_string_t cmd_set_list_name =
3317 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3318 "corelist#portlist");
3319 cmdline_parse_token_string_t cmd_set_list_of_items =
3320 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3323 cmdline_parse_inst_t cmd_set_fwd_list = {
3324 .f = cmd_set_list_parsed,
3326 .help_str = "set corelist|portlist <list0[,list1]*>",
3328 (void *)&cmd_set_list_keyword,
3329 (void *)&cmd_set_list_name,
3330 (void *)&cmd_set_list_of_items,
3335 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3337 struct cmd_setmask_result {
3338 cmdline_fixed_string_t set;
3339 cmdline_fixed_string_t mask;
3343 static void cmd_set_mask_parsed(void *parsed_result,
3344 __attribute__((unused)) struct cmdline *cl,
3345 __attribute__((unused)) void *data)
3347 struct cmd_setmask_result *res = parsed_result;
3349 if (test_done == 0) {
3350 printf("Please stop forwarding first\n");
3353 if (!strcmp(res->mask, "coremask")) {
3354 set_fwd_lcores_mask(res->hexavalue);
3356 } else if (!strcmp(res->mask, "portmask")) {
3357 set_fwd_ports_mask(res->hexavalue);
3362 cmdline_parse_token_string_t cmd_setmask_set =
3363 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3364 cmdline_parse_token_string_t cmd_setmask_mask =
3365 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3366 "coremask#portmask");
3367 cmdline_parse_token_num_t cmd_setmask_value =
3368 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3370 cmdline_parse_inst_t cmd_set_fwd_mask = {
3371 .f = cmd_set_mask_parsed,
3373 .help_str = "set coremask|portmask <hexadecimal value>",
3375 (void *)&cmd_setmask_set,
3376 (void *)&cmd_setmask_mask,
3377 (void *)&cmd_setmask_value,
3383 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3385 struct cmd_set_result {
3386 cmdline_fixed_string_t set;
3387 cmdline_fixed_string_t what;
3391 static void cmd_set_parsed(void *parsed_result,
3392 __attribute__((unused)) struct cmdline *cl,
3393 __attribute__((unused)) void *data)
3395 struct cmd_set_result *res = parsed_result;
3396 if (!strcmp(res->what, "nbport")) {
3397 set_fwd_ports_number(res->value);
3399 } else if (!strcmp(res->what, "nbcore")) {
3400 set_fwd_lcores_number(res->value);
3402 } else if (!strcmp(res->what, "burst"))
3403 set_nb_pkt_per_burst(res->value);
3404 else if (!strcmp(res->what, "verbose"))
3405 set_verbose_level(res->value);
3408 cmdline_parse_token_string_t cmd_set_set =
3409 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3410 cmdline_parse_token_string_t cmd_set_what =
3411 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3412 "nbport#nbcore#burst#verbose");
3413 cmdline_parse_token_num_t cmd_set_value =
3414 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3416 cmdline_parse_inst_t cmd_set_numbers = {
3417 .f = cmd_set_parsed,
3419 .help_str = "set nbport|nbcore|burst|verbose <value>",
3421 (void *)&cmd_set_set,
3422 (void *)&cmd_set_what,
3423 (void *)&cmd_set_value,
3428 /* *** SET LOG LEVEL CONFIGURATION *** */
3430 struct cmd_set_log_result {
3431 cmdline_fixed_string_t set;
3432 cmdline_fixed_string_t log;
3433 cmdline_fixed_string_t type;
3438 cmd_set_log_parsed(void *parsed_result,
3439 __attribute__((unused)) struct cmdline *cl,
3440 __attribute__((unused)) void *data)
3442 struct cmd_set_log_result *res;
3445 res = parsed_result;
3446 if (!strcmp(res->type, "global"))
3447 rte_log_set_global_level(res->level);
3449 ret = rte_log_set_level_regexp(res->type, res->level);
3451 printf("Unable to set log level\n");
3455 cmdline_parse_token_string_t cmd_set_log_set =
3456 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3457 cmdline_parse_token_string_t cmd_set_log_log =
3458 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3459 cmdline_parse_token_string_t cmd_set_log_type =
3460 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3461 cmdline_parse_token_num_t cmd_set_log_level =
3462 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3464 cmdline_parse_inst_t cmd_set_log = {
3465 .f = cmd_set_log_parsed,
3467 .help_str = "set log global|<type> <level>",
3469 (void *)&cmd_set_log_set,
3470 (void *)&cmd_set_log_log,
3471 (void *)&cmd_set_log_type,
3472 (void *)&cmd_set_log_level,
3477 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3479 struct cmd_set_txpkts_result {
3480 cmdline_fixed_string_t cmd_keyword;
3481 cmdline_fixed_string_t txpkts;
3482 cmdline_fixed_string_t seg_lengths;
3486 cmd_set_txpkts_parsed(void *parsed_result,
3487 __attribute__((unused)) struct cmdline *cl,
3488 __attribute__((unused)) void *data)
3490 struct cmd_set_txpkts_result *res;
3491 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3492 unsigned int nb_segs;
3494 res = parsed_result;
3495 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3496 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3498 set_tx_pkt_segments(seg_lengths, nb_segs);
3501 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3502 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3503 cmd_keyword, "set");
3504 cmdline_parse_token_string_t cmd_set_txpkts_name =
3505 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3507 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3508 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3511 cmdline_parse_inst_t cmd_set_txpkts = {
3512 .f = cmd_set_txpkts_parsed,
3514 .help_str = "set txpkts <len0[,len1]*>",
3516 (void *)&cmd_set_txpkts_keyword,
3517 (void *)&cmd_set_txpkts_name,
3518 (void *)&cmd_set_txpkts_lengths,
3523 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3525 struct cmd_set_txsplit_result {
3526 cmdline_fixed_string_t cmd_keyword;
3527 cmdline_fixed_string_t txsplit;
3528 cmdline_fixed_string_t mode;
3532 cmd_set_txsplit_parsed(void *parsed_result,
3533 __attribute__((unused)) struct cmdline *cl,
3534 __attribute__((unused)) void *data)
3536 struct cmd_set_txsplit_result *res;
3538 res = parsed_result;
3539 set_tx_pkt_split(res->mode);
3542 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3543 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3544 cmd_keyword, "set");
3545 cmdline_parse_token_string_t cmd_set_txsplit_name =
3546 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3547 txsplit, "txsplit");
3548 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3549 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3552 cmdline_parse_inst_t cmd_set_txsplit = {
3553 .f = cmd_set_txsplit_parsed,
3555 .help_str = "set txsplit on|off|rand",
3557 (void *)&cmd_set_txsplit_keyword,
3558 (void *)&cmd_set_txsplit_name,
3559 (void *)&cmd_set_txsplit_mode,
3564 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3565 struct cmd_rx_vlan_filter_all_result {
3566 cmdline_fixed_string_t rx_vlan;
3567 cmdline_fixed_string_t what;
3568 cmdline_fixed_string_t all;
3573 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3574 __attribute__((unused)) struct cmdline *cl,
3575 __attribute__((unused)) void *data)
3577 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3579 if (!strcmp(res->what, "add"))
3580 rx_vlan_all_filter_set(res->port_id, 1);
3582 rx_vlan_all_filter_set(res->port_id, 0);
3585 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3586 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3587 rx_vlan, "rx_vlan");
3588 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3589 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3591 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3592 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3594 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3595 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3598 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3599 .f = cmd_rx_vlan_filter_all_parsed,
3601 .help_str = "rx_vlan add|rm all <port_id>: "
3602 "Add/Remove all identifiers to/from the set of VLAN "
3603 "identifiers filtered by a port",
3605 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3606 (void *)&cmd_rx_vlan_filter_all_what,
3607 (void *)&cmd_rx_vlan_filter_all_all,
3608 (void *)&cmd_rx_vlan_filter_all_portid,
3613 /* *** VLAN OFFLOAD SET ON A PORT *** */
3614 struct cmd_vlan_offload_result {
3615 cmdline_fixed_string_t vlan;
3616 cmdline_fixed_string_t set;
3617 cmdline_fixed_string_t vlan_type;
3618 cmdline_fixed_string_t what;
3619 cmdline_fixed_string_t on;
3620 cmdline_fixed_string_t port_id;
3624 cmd_vlan_offload_parsed(void *parsed_result,
3625 __attribute__((unused)) struct cmdline *cl,
3626 __attribute__((unused)) void *data)
3629 struct cmd_vlan_offload_result *res = parsed_result;
3632 portid_t port_id = 0;
3636 len = strnlen(str, STR_TOKEN_SIZE);
3638 /* Get port_id first */
3646 tmp = strtoul(str, NULL, 0);
3647 /* If port_id greater that what portid_t can represent, return */
3648 if(tmp >= RTE_MAX_ETHPORTS)
3650 port_id = (portid_t)tmp;
3652 if (!strcmp(res->on, "on"))
3657 if (!strcmp(res->what, "strip"))
3658 rx_vlan_strip_set(port_id, on);
3659 else if(!strcmp(res->what, "stripq")){
3660 uint16_t queue_id = 0;
3662 /* No queue_id, return */
3664 printf("must specify (port,queue_id)\n");
3667 tmp = strtoul(str + i + 1, NULL, 0);
3668 /* If queue_id greater that what 16-bits can represent, return */
3672 queue_id = (uint16_t)tmp;
3673 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3675 else if (!strcmp(res->what, "filter"))
3676 rx_vlan_filter_set(port_id, on);
3678 vlan_extend_set(port_id, on);
3683 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3684 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3686 cmdline_parse_token_string_t cmd_vlan_offload_set =
3687 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3689 cmdline_parse_token_string_t cmd_vlan_offload_what =
3690 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3691 what, "strip#filter#qinq#stripq");
3692 cmdline_parse_token_string_t cmd_vlan_offload_on =
3693 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3695 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3696 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3699 cmdline_parse_inst_t cmd_vlan_offload = {
3700 .f = cmd_vlan_offload_parsed,
3702 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3703 "<port_id[,queue_id]>: "
3704 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3706 (void *)&cmd_vlan_offload_vlan,
3707 (void *)&cmd_vlan_offload_set,
3708 (void *)&cmd_vlan_offload_what,
3709 (void *)&cmd_vlan_offload_on,
3710 (void *)&cmd_vlan_offload_portid,
3715 /* *** VLAN TPID SET ON A PORT *** */
3716 struct cmd_vlan_tpid_result {
3717 cmdline_fixed_string_t vlan;
3718 cmdline_fixed_string_t set;
3719 cmdline_fixed_string_t vlan_type;
3720 cmdline_fixed_string_t what;
3726 cmd_vlan_tpid_parsed(void *parsed_result,
3727 __attribute__((unused)) struct cmdline *cl,
3728 __attribute__((unused)) void *data)
3730 struct cmd_vlan_tpid_result *res = parsed_result;
3731 enum rte_vlan_type vlan_type;
3733 if (!strcmp(res->vlan_type, "inner"))
3734 vlan_type = ETH_VLAN_TYPE_INNER;
3735 else if (!strcmp(res->vlan_type, "outer"))
3736 vlan_type = ETH_VLAN_TYPE_OUTER;
3738 printf("Unknown vlan type\n");
3741 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3744 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3745 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3747 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3748 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3750 cmdline_parse_token_string_t cmd_vlan_type =
3751 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3752 vlan_type, "inner#outer");
3753 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3754 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3756 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3757 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3759 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3760 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3763 cmdline_parse_inst_t cmd_vlan_tpid = {
3764 .f = cmd_vlan_tpid_parsed,
3766 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3767 "Set the VLAN Ether type",
3769 (void *)&cmd_vlan_tpid_vlan,
3770 (void *)&cmd_vlan_tpid_set,
3771 (void *)&cmd_vlan_type,
3772 (void *)&cmd_vlan_tpid_what,
3773 (void *)&cmd_vlan_tpid_tpid,
3774 (void *)&cmd_vlan_tpid_portid,
3779 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3780 struct cmd_rx_vlan_filter_result {
3781 cmdline_fixed_string_t rx_vlan;
3782 cmdline_fixed_string_t what;
3788 cmd_rx_vlan_filter_parsed(void *parsed_result,
3789 __attribute__((unused)) struct cmdline *cl,
3790 __attribute__((unused)) void *data)
3792 struct cmd_rx_vlan_filter_result *res = parsed_result;
3794 if (!strcmp(res->what, "add"))
3795 rx_vft_set(res->port_id, res->vlan_id, 1);
3797 rx_vft_set(res->port_id, res->vlan_id, 0);
3800 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3801 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3802 rx_vlan, "rx_vlan");
3803 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3804 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3806 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3807 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3809 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3810 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3813 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3814 .f = cmd_rx_vlan_filter_parsed,
3816 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3817 "Add/Remove a VLAN identifier to/from the set of VLAN "
3818 "identifiers filtered by a port",
3820 (void *)&cmd_rx_vlan_filter_rx_vlan,
3821 (void *)&cmd_rx_vlan_filter_what,
3822 (void *)&cmd_rx_vlan_filter_vlanid,
3823 (void *)&cmd_rx_vlan_filter_portid,
3828 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3829 struct cmd_tx_vlan_set_result {
3830 cmdline_fixed_string_t tx_vlan;
3831 cmdline_fixed_string_t set;
3837 cmd_tx_vlan_set_parsed(void *parsed_result,
3838 __attribute__((unused)) struct cmdline *cl,
3839 __attribute__((unused)) void *data)
3841 struct cmd_tx_vlan_set_result *res = parsed_result;
3843 if (!port_is_stopped(res->port_id)) {
3844 printf("Please stop port %d first\n", res->port_id);
3848 tx_vlan_set(res->port_id, res->vlan_id);
3850 cmd_reconfig_device_queue(res->port_id, 1, 1);
3853 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3854 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3855 tx_vlan, "tx_vlan");
3856 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3857 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3859 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3860 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3862 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3863 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3866 cmdline_parse_inst_t cmd_tx_vlan_set = {
3867 .f = cmd_tx_vlan_set_parsed,
3869 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3870 "Enable hardware insertion of a single VLAN header "
3871 "with a given TAG Identifier in packets sent on a port",
3873 (void *)&cmd_tx_vlan_set_tx_vlan,
3874 (void *)&cmd_tx_vlan_set_set,
3875 (void *)&cmd_tx_vlan_set_portid,
3876 (void *)&cmd_tx_vlan_set_vlanid,
3881 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3882 struct cmd_tx_vlan_set_qinq_result {
3883 cmdline_fixed_string_t tx_vlan;
3884 cmdline_fixed_string_t set;
3887 uint16_t vlan_id_outer;
3891 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3892 __attribute__((unused)) struct cmdline *cl,
3893 __attribute__((unused)) void *data)
3895 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3897 if (!port_is_stopped(res->port_id)) {
3898 printf("Please stop port %d first\n", res->port_id);
3902 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3904 cmd_reconfig_device_queue(res->port_id, 1, 1);
3907 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3908 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3909 tx_vlan, "tx_vlan");
3910 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3911 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3913 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3914 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3916 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3917 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3919 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3920 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3921 vlan_id_outer, UINT16);
3923 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3924 .f = cmd_tx_vlan_set_qinq_parsed,
3926 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3927 "Enable hardware insertion of double VLAN header "
3928 "with given TAG Identifiers in packets sent on a port",
3930 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3931 (void *)&cmd_tx_vlan_set_qinq_set,
3932 (void *)&cmd_tx_vlan_set_qinq_portid,
3933 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3934 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3939 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3940 struct cmd_tx_vlan_set_pvid_result {
3941 cmdline_fixed_string_t tx_vlan;
3942 cmdline_fixed_string_t set;
3943 cmdline_fixed_string_t pvid;
3946 cmdline_fixed_string_t mode;
3950 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3951 __attribute__((unused)) struct cmdline *cl,
3952 __attribute__((unused)) void *data)
3954 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3956 if (strcmp(res->mode, "on") == 0)
3957 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3959 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3962 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3963 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3964 tx_vlan, "tx_vlan");
3965 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3966 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3968 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3969 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3971 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3972 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3974 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3975 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3977 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3978 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3981 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3982 .f = cmd_tx_vlan_set_pvid_parsed,
3984 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3986 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3987 (void *)&cmd_tx_vlan_set_pvid_set,
3988 (void *)&cmd_tx_vlan_set_pvid_pvid,
3989 (void *)&cmd_tx_vlan_set_pvid_port_id,
3990 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3991 (void *)&cmd_tx_vlan_set_pvid_mode,
3996 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3997 struct cmd_tx_vlan_reset_result {
3998 cmdline_fixed_string_t tx_vlan;
3999 cmdline_fixed_string_t reset;
4004 cmd_tx_vlan_reset_parsed(void *parsed_result,
4005 __attribute__((unused)) struct cmdline *cl,
4006 __attribute__((unused)) void *data)
4008 struct cmd_tx_vlan_reset_result *res = parsed_result;
4010 if (!port_is_stopped(res->port_id)) {
4011 printf("Please stop port %d first\n", res->port_id);
4015 tx_vlan_reset(res->port_id);
4017 cmd_reconfig_device_queue(res->port_id, 1, 1);
4020 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4021 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4022 tx_vlan, "tx_vlan");
4023 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4024 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4026 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4027 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4030 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4031 .f = cmd_tx_vlan_reset_parsed,
4033 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4034 "VLAN header in packets sent on a port",
4036 (void *)&cmd_tx_vlan_reset_tx_vlan,
4037 (void *)&cmd_tx_vlan_reset_reset,
4038 (void *)&cmd_tx_vlan_reset_portid,
4044 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4045 struct cmd_csum_result {
4046 cmdline_fixed_string_t csum;
4047 cmdline_fixed_string_t mode;
4048 cmdline_fixed_string_t proto;
4049 cmdline_fixed_string_t hwsw;
4054 csum_show(int port_id)
4056 struct rte_eth_dev_info dev_info;
4057 uint64_t tx_offloads;
4059 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4060 printf("Parse tunnel is %s\n",
4061 (ports[port_id].parse_tunnel) ? "on" : "off");
4062 printf("IP checksum offload is %s\n",
4063 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4064 printf("UDP checksum offload is %s\n",
4065 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4066 printf("TCP checksum offload is %s\n",
4067 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4068 printf("SCTP checksum offload is %s\n",
4069 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4070 printf("Outer-Ip checksum offload is %s\n",
4071 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4073 /* display warnings if configuration is not supported by the NIC */
4074 rte_eth_dev_info_get(port_id, &dev_info);
4075 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4076 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4077 printf("Warning: hardware IP checksum enabled but not "
4078 "supported by port %d\n", port_id);
4080 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4081 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4082 printf("Warning: hardware UDP checksum enabled but not "
4083 "supported by port %d\n", port_id);
4085 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4086 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4087 printf("Warning: hardware TCP checksum enabled but not "
4088 "supported by port %d\n", port_id);
4090 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4091 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4092 printf("Warning: hardware SCTP checksum enabled but not "
4093 "supported by port %d\n", port_id);
4095 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4096 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4097 printf("Warning: hardware outer IP checksum enabled but not "
4098 "supported by port %d\n", port_id);
4103 cmd_csum_parsed(void *parsed_result,
4104 __attribute__((unused)) struct cmdline *cl,
4105 __attribute__((unused)) void *data)
4107 struct cmd_csum_result *res = parsed_result;
4109 uint64_t csum_offloads = 0;
4110 struct rte_eth_dev_info dev_info;
4112 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4113 printf("invalid port %d\n", res->port_id);
4116 if (!port_is_stopped(res->port_id)) {
4117 printf("Please stop port %d first\n", res->port_id);
4121 rte_eth_dev_info_get(res->port_id, &dev_info);
4122 if (!strcmp(res->mode, "set")) {
4124 if (!strcmp(res->hwsw, "hw"))
4127 if (!strcmp(res->proto, "ip")) {
4128 if (hw == 0 || (dev_info.tx_offload_capa &
4129 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4130 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4132 printf("IP checksum offload is not supported "
4133 "by port %u\n", res->port_id);
4135 } else if (!strcmp(res->proto, "udp")) {
4136 if (hw == 0 || (dev_info.tx_offload_capa &
4137 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4138 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4140 printf("UDP checksum offload is not supported "
4141 "by port %u\n", res->port_id);
4143 } else if (!strcmp(res->proto, "tcp")) {
4144 if (hw == 0 || (dev_info.tx_offload_capa &
4145 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4146 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4148 printf("TCP checksum offload is not supported "
4149 "by port %u\n", res->port_id);
4151 } else if (!strcmp(res->proto, "sctp")) {
4152 if (hw == 0 || (dev_info.tx_offload_capa &
4153 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4154 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4156 printf("SCTP checksum offload is not supported "
4157 "by port %u\n", res->port_id);
4159 } else if (!strcmp(res->proto, "outer-ip")) {
4160 if (hw == 0 || (dev_info.tx_offload_capa &
4161 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4163 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4165 printf("Outer IP checksum offload is not "
4166 "supported by port %u\n", res->port_id);
4171 ports[res->port_id].dev_conf.txmode.offloads |=
4174 ports[res->port_id].dev_conf.txmode.offloads &=
4178 csum_show(res->port_id);
4180 cmd_reconfig_device_queue(res->port_id, 1, 1);
4183 cmdline_parse_token_string_t cmd_csum_csum =
4184 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4186 cmdline_parse_token_string_t cmd_csum_mode =
4187 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4189 cmdline_parse_token_string_t cmd_csum_proto =
4190 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4191 proto, "ip#tcp#udp#sctp#outer-ip");
4192 cmdline_parse_token_string_t cmd_csum_hwsw =
4193 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4195 cmdline_parse_token_num_t cmd_csum_portid =
4196 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4199 cmdline_parse_inst_t cmd_csum_set = {
4200 .f = cmd_csum_parsed,
4202 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4203 "Enable/Disable hardware calculation of L3/L4 checksum when "
4204 "using csum forward engine",
4206 (void *)&cmd_csum_csum,
4207 (void *)&cmd_csum_mode,
4208 (void *)&cmd_csum_proto,
4209 (void *)&cmd_csum_hwsw,
4210 (void *)&cmd_csum_portid,
4215 cmdline_parse_token_string_t cmd_csum_mode_show =
4216 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4219 cmdline_parse_inst_t cmd_csum_show = {
4220 .f = cmd_csum_parsed,
4222 .help_str = "csum show <port_id>: Show checksum offload configuration",
4224 (void *)&cmd_csum_csum,
4225 (void *)&cmd_csum_mode_show,
4226 (void *)&cmd_csum_portid,
4231 /* Enable/disable tunnel parsing */
4232 struct cmd_csum_tunnel_result {
4233 cmdline_fixed_string_t csum;
4234 cmdline_fixed_string_t parse;
4235 cmdline_fixed_string_t onoff;
4240 cmd_csum_tunnel_parsed(void *parsed_result,
4241 __attribute__((unused)) struct cmdline *cl,
4242 __attribute__((unused)) void *data)
4244 struct cmd_csum_tunnel_result *res = parsed_result;
4246 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4249 if (!strcmp(res->onoff, "on"))
4250 ports[res->port_id].parse_tunnel = 1;
4252 ports[res->port_id].parse_tunnel = 0;
4254 csum_show(res->port_id);
4257 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4258 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4260 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4261 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4262 parse, "parse_tunnel");
4263 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4264 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4266 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4267 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4270 cmdline_parse_inst_t cmd_csum_tunnel = {
4271 .f = cmd_csum_tunnel_parsed,
4273 .help_str = "csum parse_tunnel on|off <port_id>: "
4274 "Enable/Disable parsing of tunnels for csum engine",
4276 (void *)&cmd_csum_tunnel_csum,
4277 (void *)&cmd_csum_tunnel_parse,
4278 (void *)&cmd_csum_tunnel_onoff,
4279 (void *)&cmd_csum_tunnel_portid,
4284 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4285 struct cmd_tso_set_result {
4286 cmdline_fixed_string_t tso;
4287 cmdline_fixed_string_t mode;
4293 cmd_tso_set_parsed(void *parsed_result,
4294 __attribute__((unused)) struct cmdline *cl,
4295 __attribute__((unused)) void *data)
4297 struct cmd_tso_set_result *res = parsed_result;
4298 struct rte_eth_dev_info dev_info;
4300 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4302 if (!port_is_stopped(res->port_id)) {
4303 printf("Please stop port %d first\n", res->port_id);
4307 if (!strcmp(res->mode, "set"))
4308 ports[res->port_id].tso_segsz = res->tso_segsz;
4310 rte_eth_dev_info_get(res->port_id, &dev_info);
4311 if ((ports[res->port_id].tso_segsz != 0) &&
4312 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4313 printf("Error: TSO is not supported by port %d\n",
4318 if (ports[res->port_id].tso_segsz == 0) {
4319 ports[res->port_id].dev_conf.txmode.offloads &=
4320 ~DEV_TX_OFFLOAD_TCP_TSO;
4321 printf("TSO for non-tunneled packets is disabled\n");
4323 ports[res->port_id].dev_conf.txmode.offloads |=
4324 DEV_TX_OFFLOAD_TCP_TSO;
4325 printf("TSO segment size for non-tunneled packets is %d\n",
4326 ports[res->port_id].tso_segsz);
4329 /* display warnings if configuration is not supported by the NIC */
4330 rte_eth_dev_info_get(res->port_id, &dev_info);
4331 if ((ports[res->port_id].tso_segsz != 0) &&
4332 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4333 printf("Warning: TSO enabled but not "
4334 "supported by port %d\n", res->port_id);
4337 cmd_reconfig_device_queue(res->port_id, 1, 1);
4340 cmdline_parse_token_string_t cmd_tso_set_tso =
4341 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4343 cmdline_parse_token_string_t cmd_tso_set_mode =
4344 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4346 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4347 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4349 cmdline_parse_token_num_t cmd_tso_set_portid =
4350 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4353 cmdline_parse_inst_t cmd_tso_set = {
4354 .f = cmd_tso_set_parsed,
4356 .help_str = "tso set <tso_segsz> <port_id>: "
4357 "Set TSO segment size of non-tunneled packets for csum engine "
4360 (void *)&cmd_tso_set_tso,
4361 (void *)&cmd_tso_set_mode,
4362 (void *)&cmd_tso_set_tso_segsz,
4363 (void *)&cmd_tso_set_portid,
4368 cmdline_parse_token_string_t cmd_tso_show_mode =
4369 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4373 cmdline_parse_inst_t cmd_tso_show = {
4374 .f = cmd_tso_set_parsed,
4376 .help_str = "tso show <port_id>: "
4377 "Show TSO segment size of non-tunneled packets for csum engine",
4379 (void *)&cmd_tso_set_tso,
4380 (void *)&cmd_tso_show_mode,
4381 (void *)&cmd_tso_set_portid,
4386 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4387 struct cmd_tunnel_tso_set_result {
4388 cmdline_fixed_string_t tso;
4389 cmdline_fixed_string_t mode;
4394 static struct rte_eth_dev_info
4395 check_tunnel_tso_nic_support(portid_t port_id)
4397 struct rte_eth_dev_info dev_info;
4399 rte_eth_dev_info_get(port_id, &dev_info);
4400 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4401 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4402 "not enabled for port %d\n", port_id);
4403 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4404 printf("Warning: GRE TUNNEL TSO not supported therefore "
4405 "not enabled for port %d\n", port_id);
4406 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4407 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4408 "not enabled for port %d\n", port_id);
4409 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4410 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4411 "not enabled for port %d\n", port_id);
4412 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4413 printf("Warning: IP TUNNEL TSO not supported therefore "
4414 "not enabled for port %d\n", port_id);
4415 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4416 printf("Warning: UDP TUNNEL TSO not supported therefore "
4417 "not enabled for port %d\n", port_id);
4422 cmd_tunnel_tso_set_parsed(void *parsed_result,
4423 __attribute__((unused)) struct cmdline *cl,
4424 __attribute__((unused)) void *data)
4426 struct cmd_tunnel_tso_set_result *res = parsed_result;
4427 struct rte_eth_dev_info dev_info;
4429 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4431 if (!port_is_stopped(res->port_id)) {
4432 printf("Please stop port %d first\n", res->port_id);
4436 if (!strcmp(res->mode, "set"))
4437 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4439 dev_info = check_tunnel_tso_nic_support(res->port_id);
4440 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4441 ports[res->port_id].dev_conf.txmode.offloads &=
4442 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4443 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4444 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4445 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4446 DEV_TX_OFFLOAD_IP_TNL_TSO |
4447 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4448 printf("TSO for tunneled packets is disabled\n");
4450 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4451 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4452 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4453 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4454 DEV_TX_OFFLOAD_IP_TNL_TSO |
4455 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4457 ports[res->port_id].dev_conf.txmode.offloads |=
4458 (tso_offloads & dev_info.tx_offload_capa);
4459 printf("TSO segment size for tunneled packets is %d\n",
4460 ports[res->port_id].tunnel_tso_segsz);
4462 /* Below conditions are needed to make it work:
4463 * (1) tunnel TSO is supported by the NIC;
4464 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4466 * (3) for tunneled pkts with outer L3 of IPv4,
4467 * "csum set outer-ip" must be set to hw, because after tso,
4468 * total_len of outer IP header is changed, and the checksum
4469 * of outer IP header calculated by sw should be wrong; that
4470 * is not necessary for IPv6 tunneled pkts because there's no
4471 * checksum in IP header anymore.
4474 if (!ports[res->port_id].parse_tunnel)
4475 printf("Warning: csum parse_tunnel must be set "
4476 "so that tunneled packets are recognized\n");
4477 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4478 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4479 printf("Warning: csum set outer-ip must be set to hw "
4480 "if outer L3 is IPv4; not necessary for IPv6\n");
4483 cmd_reconfig_device_queue(res->port_id, 1, 1);
4486 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4487 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4489 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4490 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4492 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4493 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4495 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4496 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4499 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4500 .f = cmd_tunnel_tso_set_parsed,
4502 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4503 "Set TSO segment size of tunneled packets for csum engine "
4506 (void *)&cmd_tunnel_tso_set_tso,
4507 (void *)&cmd_tunnel_tso_set_mode,
4508 (void *)&cmd_tunnel_tso_set_tso_segsz,
4509 (void *)&cmd_tunnel_tso_set_portid,
4514 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4515 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4519 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4520 .f = cmd_tunnel_tso_set_parsed,
4522 .help_str = "tunnel_tso show <port_id> "
4523 "Show TSO segment size of tunneled packets for csum engine",
4525 (void *)&cmd_tunnel_tso_set_tso,
4526 (void *)&cmd_tunnel_tso_show_mode,
4527 (void *)&cmd_tunnel_tso_set_portid,
4532 /* *** SET GRO FOR A PORT *** */
4533 struct cmd_gro_enable_result {
4534 cmdline_fixed_string_t cmd_set;
4535 cmdline_fixed_string_t cmd_port;
4536 cmdline_fixed_string_t cmd_keyword;
4537 cmdline_fixed_string_t cmd_onoff;
4542 cmd_gro_enable_parsed(void *parsed_result,
4543 __attribute__((unused)) struct cmdline *cl,
4544 __attribute__((unused)) void *data)
4546 struct cmd_gro_enable_result *res;
4548 res = parsed_result;
4549 if (!strcmp(res->cmd_keyword, "gro"))
4550 setup_gro(res->cmd_onoff, res->cmd_pid);
4553 cmdline_parse_token_string_t cmd_gro_enable_set =
4554 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4556 cmdline_parse_token_string_t cmd_gro_enable_port =
4557 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4558 cmd_keyword, "port");
4559 cmdline_parse_token_num_t cmd_gro_enable_pid =
4560 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4562 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4563 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4564 cmd_keyword, "gro");
4565 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4566 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4567 cmd_onoff, "on#off");
4569 cmdline_parse_inst_t cmd_gro_enable = {
4570 .f = cmd_gro_enable_parsed,
4572 .help_str = "set port <port_id> gro on|off",
4574 (void *)&cmd_gro_enable_set,
4575 (void *)&cmd_gro_enable_port,
4576 (void *)&cmd_gro_enable_pid,
4577 (void *)&cmd_gro_enable_keyword,
4578 (void *)&cmd_gro_enable_onoff,
4583 /* *** DISPLAY GRO CONFIGURATION *** */
4584 struct cmd_gro_show_result {
4585 cmdline_fixed_string_t cmd_show;
4586 cmdline_fixed_string_t cmd_port;
4587 cmdline_fixed_string_t cmd_keyword;
4592 cmd_gro_show_parsed(void *parsed_result,
4593 __attribute__((unused)) struct cmdline *cl,
4594 __attribute__((unused)) void *data)
4596 struct cmd_gro_show_result *res;
4598 res = parsed_result;
4599 if (!strcmp(res->cmd_keyword, "gro"))
4600 show_gro(res->cmd_pid);
4603 cmdline_parse_token_string_t cmd_gro_show_show =
4604 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4606 cmdline_parse_token_string_t cmd_gro_show_port =
4607 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4609 cmdline_parse_token_num_t cmd_gro_show_pid =
4610 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4612 cmdline_parse_token_string_t cmd_gro_show_keyword =
4613 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4614 cmd_keyword, "gro");
4616 cmdline_parse_inst_t cmd_gro_show = {
4617 .f = cmd_gro_show_parsed,
4619 .help_str = "show port <port_id> gro",
4621 (void *)&cmd_gro_show_show,
4622 (void *)&cmd_gro_show_port,
4623 (void *)&cmd_gro_show_pid,
4624 (void *)&cmd_gro_show_keyword,
4629 /* *** SET FLUSH CYCLES FOR GRO *** */
4630 struct cmd_gro_flush_result {
4631 cmdline_fixed_string_t cmd_set;
4632 cmdline_fixed_string_t cmd_keyword;
4633 cmdline_fixed_string_t cmd_flush;
4638 cmd_gro_flush_parsed(void *parsed_result,
4639 __attribute__((unused)) struct cmdline *cl,
4640 __attribute__((unused)) void *data)
4642 struct cmd_gro_flush_result *res;
4644 res = parsed_result;
4645 if ((!strcmp(res->cmd_keyword, "gro")) &&
4646 (!strcmp(res->cmd_flush, "flush")))
4647 setup_gro_flush_cycles(res->cmd_cycles);
4650 cmdline_parse_token_string_t cmd_gro_flush_set =
4651 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4653 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4654 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4655 cmd_keyword, "gro");
4656 cmdline_parse_token_string_t cmd_gro_flush_flush =
4657 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4658 cmd_flush, "flush");
4659 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4660 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4663 cmdline_parse_inst_t cmd_gro_flush = {
4664 .f = cmd_gro_flush_parsed,
4666 .help_str = "set gro flush <cycles>",
4668 (void *)&cmd_gro_flush_set,
4669 (void *)&cmd_gro_flush_keyword,
4670 (void *)&cmd_gro_flush_flush,
4671 (void *)&cmd_gro_flush_cycles,
4676 /* *** ENABLE/DISABLE GSO *** */
4677 struct cmd_gso_enable_result {
4678 cmdline_fixed_string_t cmd_set;
4679 cmdline_fixed_string_t cmd_port;
4680 cmdline_fixed_string_t cmd_keyword;
4681 cmdline_fixed_string_t cmd_mode;
4686 cmd_gso_enable_parsed(void *parsed_result,
4687 __attribute__((unused)) struct cmdline *cl,
4688 __attribute__((unused)) void *data)
4690 struct cmd_gso_enable_result *res;
4692 res = parsed_result;
4693 if (!strcmp(res->cmd_keyword, "gso"))
4694 setup_gso(res->cmd_mode, res->cmd_pid);
4697 cmdline_parse_token_string_t cmd_gso_enable_set =
4698 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4700 cmdline_parse_token_string_t cmd_gso_enable_port =
4701 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4703 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4704 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4705 cmd_keyword, "gso");
4706 cmdline_parse_token_string_t cmd_gso_enable_mode =
4707 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4708 cmd_mode, "on#off");
4709 cmdline_parse_token_num_t cmd_gso_enable_pid =
4710 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4713 cmdline_parse_inst_t cmd_gso_enable = {
4714 .f = cmd_gso_enable_parsed,
4716 .help_str = "set port <port_id> gso on|off",
4718 (void *)&cmd_gso_enable_set,
4719 (void *)&cmd_gso_enable_port,
4720 (void *)&cmd_gso_enable_pid,
4721 (void *)&cmd_gso_enable_keyword,
4722 (void *)&cmd_gso_enable_mode,
4727 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4728 struct cmd_gso_size_result {
4729 cmdline_fixed_string_t cmd_set;
4730 cmdline_fixed_string_t cmd_keyword;
4731 cmdline_fixed_string_t cmd_segsz;
4736 cmd_gso_size_parsed(void *parsed_result,
4737 __attribute__((unused)) struct cmdline *cl,
4738 __attribute__((unused)) void *data)
4740 struct cmd_gso_size_result *res = parsed_result;
4742 if (test_done == 0) {
4743 printf("Before setting GSO segsz, please first"
4744 " stop fowarding\n");
4748 if (!strcmp(res->cmd_keyword, "gso") &&
4749 !strcmp(res->cmd_segsz, "segsz")) {
4750 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4751 printf("gso_size should be larger than %zu."
4752 " Please input a legal value\n",
4753 RTE_GSO_SEG_SIZE_MIN);
4755 gso_max_segment_size = res->cmd_size;
4759 cmdline_parse_token_string_t cmd_gso_size_set =
4760 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4762 cmdline_parse_token_string_t cmd_gso_size_keyword =
4763 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4764 cmd_keyword, "gso");
4765 cmdline_parse_token_string_t cmd_gso_size_segsz =
4766 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4767 cmd_segsz, "segsz");
4768 cmdline_parse_token_num_t cmd_gso_size_size =
4769 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4772 cmdline_parse_inst_t cmd_gso_size = {
4773 .f = cmd_gso_size_parsed,
4775 .help_str = "set gso segsz <length>",
4777 (void *)&cmd_gso_size_set,
4778 (void *)&cmd_gso_size_keyword,
4779 (void *)&cmd_gso_size_segsz,
4780 (void *)&cmd_gso_size_size,
4785 /* *** SHOW GSO CONFIGURATION *** */
4786 struct cmd_gso_show_result {
4787 cmdline_fixed_string_t cmd_show;
4788 cmdline_fixed_string_t cmd_port;
4789 cmdline_fixed_string_t cmd_keyword;
4794 cmd_gso_show_parsed(void *parsed_result,
4795 __attribute__((unused)) struct cmdline *cl,
4796 __attribute__((unused)) void *data)
4798 struct cmd_gso_show_result *res = parsed_result;
4800 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4801 printf("invalid port id %u\n", res->cmd_pid);
4804 if (!strcmp(res->cmd_keyword, "gso")) {
4805 if (gso_ports[res->cmd_pid].enable) {
4806 printf("Max GSO'd packet size: %uB\n"
4807 "Supported GSO types: TCP/IPv4, "
4808 "UDP/IPv4, VxLAN with inner "
4809 "TCP/IPv4 packet, GRE with inner "
4810 "TCP/IPv4 packet\n",
4811 gso_max_segment_size);
4813 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4817 cmdline_parse_token_string_t cmd_gso_show_show =
4818 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4820 cmdline_parse_token_string_t cmd_gso_show_port =
4821 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4823 cmdline_parse_token_string_t cmd_gso_show_keyword =
4824 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4825 cmd_keyword, "gso");
4826 cmdline_parse_token_num_t cmd_gso_show_pid =
4827 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4830 cmdline_parse_inst_t cmd_gso_show = {
4831 .f = cmd_gso_show_parsed,
4833 .help_str = "show port <port_id> gso",
4835 (void *)&cmd_gso_show_show,
4836 (void *)&cmd_gso_show_port,
4837 (void *)&cmd_gso_show_pid,
4838 (void *)&cmd_gso_show_keyword,
4843 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4844 struct cmd_set_flush_rx {
4845 cmdline_fixed_string_t set;
4846 cmdline_fixed_string_t flush_rx;
4847 cmdline_fixed_string_t mode;
4851 cmd_set_flush_rx_parsed(void *parsed_result,
4852 __attribute__((unused)) struct cmdline *cl,
4853 __attribute__((unused)) void *data)
4855 struct cmd_set_flush_rx *res = parsed_result;
4856 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4859 cmdline_parse_token_string_t cmd_setflushrx_set =
4860 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4862 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4863 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4864 flush_rx, "flush_rx");
4865 cmdline_parse_token_string_t cmd_setflushrx_mode =
4866 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4870 cmdline_parse_inst_t cmd_set_flush_rx = {
4871 .f = cmd_set_flush_rx_parsed,
4872 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4875 (void *)&cmd_setflushrx_set,
4876 (void *)&cmd_setflushrx_flush_rx,
4877 (void *)&cmd_setflushrx_mode,
4882 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4883 struct cmd_set_link_check {
4884 cmdline_fixed_string_t set;
4885 cmdline_fixed_string_t link_check;
4886 cmdline_fixed_string_t mode;
4890 cmd_set_link_check_parsed(void *parsed_result,
4891 __attribute__((unused)) struct cmdline *cl,
4892 __attribute__((unused)) void *data)
4894 struct cmd_set_link_check *res = parsed_result;
4895 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4898 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4899 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4901 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4902 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4903 link_check, "link_check");
4904 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4905 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4909 cmdline_parse_inst_t cmd_set_link_check = {
4910 .f = cmd_set_link_check_parsed,
4911 .help_str = "set link_check on|off: Enable/Disable link status check "
4912 "when starting/stopping a port",
4915 (void *)&cmd_setlinkcheck_set,
4916 (void *)&cmd_setlinkcheck_link_check,
4917 (void *)&cmd_setlinkcheck_mode,
4922 /* *** SET NIC BYPASS MODE *** */
4923 struct cmd_set_bypass_mode_result {
4924 cmdline_fixed_string_t set;
4925 cmdline_fixed_string_t bypass;
4926 cmdline_fixed_string_t mode;
4927 cmdline_fixed_string_t value;
4932 cmd_set_bypass_mode_parsed(void *parsed_result,
4933 __attribute__((unused)) struct cmdline *cl,
4934 __attribute__((unused)) void *data)
4936 struct cmd_set_bypass_mode_result *res = parsed_result;
4937 portid_t port_id = res->port_id;
4938 int32_t rc = -EINVAL;
4940 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4941 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4943 if (!strcmp(res->value, "bypass"))
4944 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4945 else if (!strcmp(res->value, "isolate"))
4946 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4948 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4950 /* Set the bypass mode for the relevant port. */
4951 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4954 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4957 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4958 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4960 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4961 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4963 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4964 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4966 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4967 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4968 value, "normal#bypass#isolate");
4969 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4970 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4973 cmdline_parse_inst_t cmd_set_bypass_mode = {
4974 .f = cmd_set_bypass_mode_parsed,
4975 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4976 "Set the NIC bypass mode for port_id",
4979 (void *)&cmd_setbypass_mode_set,
4980 (void *)&cmd_setbypass_mode_bypass,
4981 (void *)&cmd_setbypass_mode_mode,
4982 (void *)&cmd_setbypass_mode_value,
4983 (void *)&cmd_setbypass_mode_port,
4988 /* *** SET NIC BYPASS EVENT *** */
4989 struct cmd_set_bypass_event_result {
4990 cmdline_fixed_string_t set;
4991 cmdline_fixed_string_t bypass;
4992 cmdline_fixed_string_t event;
4993 cmdline_fixed_string_t event_value;
4994 cmdline_fixed_string_t mode;
4995 cmdline_fixed_string_t mode_value;
5000 cmd_set_bypass_event_parsed(void *parsed_result,
5001 __attribute__((unused)) struct cmdline *cl,
5002 __attribute__((unused)) void *data)
5004 int32_t rc = -EINVAL;
5005 struct cmd_set_bypass_event_result *res = parsed_result;
5006 portid_t port_id = res->port_id;
5008 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5009 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5010 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5012 if (!strcmp(res->event_value, "timeout"))
5013 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5014 else if (!strcmp(res->event_value, "os_on"))
5015 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5016 else if (!strcmp(res->event_value, "os_off"))
5017 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5018 else if (!strcmp(res->event_value, "power_on"))
5019 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5020 else if (!strcmp(res->event_value, "power_off"))
5021 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5023 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5025 if (!strcmp(res->mode_value, "bypass"))
5026 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5027 else if (!strcmp(res->mode_value, "isolate"))
5028 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5030 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5032 /* Set the watchdog timeout. */
5033 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5036 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5037 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5041 printf("Failed to set timeout value %u "
5042 "for port %d, errto code: %d.\n",
5043 bypass_timeout, port_id, rc);
5047 /* Set the bypass event to transition to bypass mode. */
5048 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5053 printf("\t Failed to set bypass event for port = %d.\n",
5057 cmdline_parse_token_string_t cmd_setbypass_event_set =
5058 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5060 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5061 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5063 cmdline_parse_token_string_t cmd_setbypass_event_event =
5064 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5066 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5067 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5068 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5069 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5070 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5072 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5073 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5074 mode_value, "normal#bypass#isolate");
5075 cmdline_parse_token_num_t cmd_setbypass_event_port =
5076 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5079 cmdline_parse_inst_t cmd_set_bypass_event = {
5080 .f = cmd_set_bypass_event_parsed,
5081 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5082 "power_off mode normal|bypass|isolate <port_id>: "
5083 "Set the NIC bypass event mode for port_id",
5086 (void *)&cmd_setbypass_event_set,
5087 (void *)&cmd_setbypass_event_bypass,
5088 (void *)&cmd_setbypass_event_event,
5089 (void *)&cmd_setbypass_event_event_value,
5090 (void *)&cmd_setbypass_event_mode,
5091 (void *)&cmd_setbypass_event_mode_value,
5092 (void *)&cmd_setbypass_event_port,
5098 /* *** SET NIC BYPASS TIMEOUT *** */
5099 struct cmd_set_bypass_timeout_result {
5100 cmdline_fixed_string_t set;
5101 cmdline_fixed_string_t bypass;
5102 cmdline_fixed_string_t timeout;
5103 cmdline_fixed_string_t value;
5107 cmd_set_bypass_timeout_parsed(void *parsed_result,
5108 __attribute__((unused)) struct cmdline *cl,
5109 __attribute__((unused)) void *data)
5111 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5113 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5114 if (!strcmp(res->value, "1.5"))
5115 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5116 else if (!strcmp(res->value, "2"))
5117 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5118 else if (!strcmp(res->value, "3"))
5119 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5120 else if (!strcmp(res->value, "4"))
5121 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5122 else if (!strcmp(res->value, "8"))
5123 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5124 else if (!strcmp(res->value, "16"))
5125 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5126 else if (!strcmp(res->value, "32"))
5127 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5129 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5133 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5134 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5136 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5137 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5139 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5140 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5141 timeout, "timeout");
5142 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5143 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5144 value, "0#1.5#2#3#4#8#16#32");
5146 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5147 .f = cmd_set_bypass_timeout_parsed,
5148 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5149 "Set the NIC bypass watchdog timeout in seconds",
5152 (void *)&cmd_setbypass_timeout_set,
5153 (void *)&cmd_setbypass_timeout_bypass,
5154 (void *)&cmd_setbypass_timeout_timeout,
5155 (void *)&cmd_setbypass_timeout_value,
5160 /* *** SHOW NIC BYPASS MODE *** */
5161 struct cmd_show_bypass_config_result {
5162 cmdline_fixed_string_t show;
5163 cmdline_fixed_string_t bypass;
5164 cmdline_fixed_string_t config;
5169 cmd_show_bypass_config_parsed(void *parsed_result,
5170 __attribute__((unused)) struct cmdline *cl,
5171 __attribute__((unused)) void *data)
5173 struct cmd_show_bypass_config_result *res = parsed_result;
5174 portid_t port_id = res->port_id;
5176 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5177 uint32_t event_mode;
5178 uint32_t bypass_mode;
5179 uint32_t timeout = bypass_timeout;
5182 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5183 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5184 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5185 {"UNKNOWN", "normal", "bypass", "isolate"};
5186 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5193 int num_events = (sizeof events) / (sizeof events[0]);
5195 /* Display the bypass mode.*/
5196 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5197 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5201 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5202 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5204 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5207 /* Display the bypass timeout.*/
5208 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5209 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5211 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5213 /* Display the bypass events and associated modes. */
5214 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5216 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5217 printf("\tFailed to get bypass mode for event = %s\n",
5220 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5221 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5223 printf("\tbypass event: %-16s = %s\n", events[i],
5229 printf("\tFailed to get bypass configuration for port = %d\n",
5233 cmdline_parse_token_string_t cmd_showbypass_config_show =
5234 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5236 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5237 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5239 cmdline_parse_token_string_t cmd_showbypass_config_config =
5240 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5242 cmdline_parse_token_num_t cmd_showbypass_config_port =
5243 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5246 cmdline_parse_inst_t cmd_show_bypass_config = {
5247 .f = cmd_show_bypass_config_parsed,
5248 .help_str = "show bypass config <port_id>: "
5249 "Show the NIC bypass config for port_id",
5252 (void *)&cmd_showbypass_config_show,
5253 (void *)&cmd_showbypass_config_bypass,
5254 (void *)&cmd_showbypass_config_config,
5255 (void *)&cmd_showbypass_config_port,
5260 #ifdef RTE_LIBRTE_PMD_BOND
5261 /* *** SET BONDING MODE *** */
5262 struct cmd_set_bonding_mode_result {
5263 cmdline_fixed_string_t set;
5264 cmdline_fixed_string_t bonding;
5265 cmdline_fixed_string_t mode;
5270 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5271 __attribute__((unused)) struct cmdline *cl,
5272 __attribute__((unused)) void *data)
5274 struct cmd_set_bonding_mode_result *res = parsed_result;
5275 portid_t port_id = res->port_id;
5277 /* Set the bonding mode for the relevant port. */
5278 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5279 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5282 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5283 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5285 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5287 bonding, "bonding");
5288 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5289 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5291 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5292 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5294 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5295 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5298 cmdline_parse_inst_t cmd_set_bonding_mode = {
5299 .f = cmd_set_bonding_mode_parsed,
5300 .help_str = "set bonding mode <mode_value> <port_id>: "
5301 "Set the bonding mode for port_id",
5304 (void *) &cmd_setbonding_mode_set,
5305 (void *) &cmd_setbonding_mode_bonding,
5306 (void *) &cmd_setbonding_mode_mode,
5307 (void *) &cmd_setbonding_mode_value,
5308 (void *) &cmd_setbonding_mode_port,
5313 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5314 struct cmd_set_bonding_lacp_dedicated_queues_result {
5315 cmdline_fixed_string_t set;
5316 cmdline_fixed_string_t bonding;
5317 cmdline_fixed_string_t lacp;
5318 cmdline_fixed_string_t dedicated_queues;
5320 cmdline_fixed_string_t mode;
5323 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5324 __attribute__((unused)) struct cmdline *cl,
5325 __attribute__((unused)) void *data)
5327 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5328 portid_t port_id = res->port_id;
5329 struct rte_port *port;
5331 port = &ports[port_id];
5333 /** Check if the port is not started **/
5334 if (port->port_status != RTE_PORT_STOPPED) {
5335 printf("Please stop port %d first\n", port_id);
5339 if (!strcmp(res->mode, "enable")) {
5340 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5341 printf("Dedicate queues for LACP control packets"
5344 printf("Enabling dedicate queues for LACP control "
5345 "packets on port %d failed\n", port_id);
5346 } else if (!strcmp(res->mode, "disable")) {
5347 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5348 printf("Dedicated queues for LACP control packets "
5351 printf("Disabling dedicated queues for LACP control "
5352 "traffic on port %d failed\n", port_id);
5356 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5357 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5359 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5360 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5361 bonding, "bonding");
5362 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5363 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5365 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5366 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5367 dedicated_queues, "dedicated_queues");
5368 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5369 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5371 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5372 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5373 mode, "enable#disable");
5375 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5376 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5377 .help_str = "set bonding lacp dedicated_queues <port_id> "
5379 "Enable/disable dedicated queues for LACP control traffic for port_id",
5382 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5383 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5384 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5385 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5386 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5387 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5392 /* *** SET BALANCE XMIT POLICY *** */
5393 struct cmd_set_bonding_balance_xmit_policy_result {
5394 cmdline_fixed_string_t set;
5395 cmdline_fixed_string_t bonding;
5396 cmdline_fixed_string_t balance_xmit_policy;
5398 cmdline_fixed_string_t policy;
5401 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5402 __attribute__((unused)) struct cmdline *cl,
5403 __attribute__((unused)) void *data)
5405 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5406 portid_t port_id = res->port_id;
5409 if (!strcmp(res->policy, "l2")) {
5410 policy = BALANCE_XMIT_POLICY_LAYER2;
5411 } else if (!strcmp(res->policy, "l23")) {
5412 policy = BALANCE_XMIT_POLICY_LAYER23;
5413 } else if (!strcmp(res->policy, "l34")) {
5414 policy = BALANCE_XMIT_POLICY_LAYER34;
5416 printf("\t Invalid xmit policy selection");
5420 /* Set the bonding mode for the relevant port. */
5421 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5422 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5427 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5428 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5430 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5431 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5432 bonding, "bonding");
5433 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5434 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5435 balance_xmit_policy, "balance_xmit_policy");
5436 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5437 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5439 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5441 policy, "l2#l23#l34");
5443 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5444 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5445 .help_str = "set bonding balance_xmit_policy <port_id> "
5447 "Set the bonding balance_xmit_policy for port_id",
5450 (void *)&cmd_setbonding_balance_xmit_policy_set,
5451 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5452 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5453 (void *)&cmd_setbonding_balance_xmit_policy_port,
5454 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5459 /* *** SHOW NIC BONDING CONFIGURATION *** */
5460 struct cmd_show_bonding_config_result {
5461 cmdline_fixed_string_t show;
5462 cmdline_fixed_string_t bonding;
5463 cmdline_fixed_string_t config;
5467 static void cmd_show_bonding_config_parsed(void *parsed_result,
5468 __attribute__((unused)) struct cmdline *cl,
5469 __attribute__((unused)) void *data)
5471 struct cmd_show_bonding_config_result *res = parsed_result;
5472 int bonding_mode, agg_mode;
5473 portid_t slaves[RTE_MAX_ETHPORTS];
5474 int num_slaves, num_active_slaves;
5477 portid_t port_id = res->port_id;
5479 /* Display the bonding mode.*/
5480 bonding_mode = rte_eth_bond_mode_get(port_id);
5481 if (bonding_mode < 0) {
5482 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5485 printf("\tBonding mode: %d\n", bonding_mode);
5487 if (bonding_mode == BONDING_MODE_BALANCE) {
5488 int balance_xmit_policy;
5490 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5491 if (balance_xmit_policy < 0) {
5492 printf("\tFailed to get balance xmit policy for port = %d\n",
5496 printf("\tBalance Xmit Policy: ");
5498 switch (balance_xmit_policy) {
5499 case BALANCE_XMIT_POLICY_LAYER2:
5500 printf("BALANCE_XMIT_POLICY_LAYER2");
5502 case BALANCE_XMIT_POLICY_LAYER23:
5503 printf("BALANCE_XMIT_POLICY_LAYER23");
5505 case BALANCE_XMIT_POLICY_LAYER34:
5506 printf("BALANCE_XMIT_POLICY_LAYER34");
5513 if (bonding_mode == BONDING_MODE_8023AD) {
5514 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5515 printf("\tIEEE802.3AD Aggregator Mode: ");
5518 printf("bandwidth");
5530 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5532 if (num_slaves < 0) {
5533 printf("\tFailed to get slave list for port = %d\n", port_id);
5536 if (num_slaves > 0) {
5537 printf("\tSlaves (%d): [", num_slaves);
5538 for (i = 0; i < num_slaves - 1; i++)
5539 printf("%d ", slaves[i]);
5541 printf("%d]\n", slaves[num_slaves - 1]);
5543 printf("\tSlaves: []\n");
5547 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5550 if (num_active_slaves < 0) {
5551 printf("\tFailed to get active slave list for port = %d\n", port_id);
5554 if (num_active_slaves > 0) {
5555 printf("\tActive Slaves (%d): [", num_active_slaves);
5556 for (i = 0; i < num_active_slaves - 1; i++)
5557 printf("%d ", slaves[i]);
5559 printf("%d]\n", slaves[num_active_slaves - 1]);
5562 printf("\tActive Slaves: []\n");
5566 primary_id = rte_eth_bond_primary_get(port_id);
5567 if (primary_id < 0) {
5568 printf("\tFailed to get primary slave for port = %d\n", port_id);
5571 printf("\tPrimary: [%d]\n", primary_id);
5575 cmdline_parse_token_string_t cmd_showbonding_config_show =
5576 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5578 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5579 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5580 bonding, "bonding");
5581 cmdline_parse_token_string_t cmd_showbonding_config_config =
5582 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5584 cmdline_parse_token_num_t cmd_showbonding_config_port =
5585 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5588 cmdline_parse_inst_t cmd_show_bonding_config = {
5589 .f = cmd_show_bonding_config_parsed,
5590 .help_str = "show bonding config <port_id>: "
5591 "Show the bonding config for port_id",
5594 (void *)&cmd_showbonding_config_show,
5595 (void *)&cmd_showbonding_config_bonding,
5596 (void *)&cmd_showbonding_config_config,
5597 (void *)&cmd_showbonding_config_port,
5602 /* *** SET BONDING PRIMARY *** */
5603 struct cmd_set_bonding_primary_result {
5604 cmdline_fixed_string_t set;
5605 cmdline_fixed_string_t bonding;
5606 cmdline_fixed_string_t primary;
5611 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5612 __attribute__((unused)) struct cmdline *cl,
5613 __attribute__((unused)) void *data)
5615 struct cmd_set_bonding_primary_result *res = parsed_result;
5616 portid_t master_port_id = res->port_id;
5617 portid_t slave_port_id = res->slave_id;
5619 /* Set the primary slave for a bonded device. */
5620 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5621 printf("\t Failed to set primary slave for port = %d.\n",
5628 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5631 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5632 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5633 bonding, "bonding");
5634 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5635 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5636 primary, "primary");
5637 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5638 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5640 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5641 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5644 cmdline_parse_inst_t cmd_set_bonding_primary = {
5645 .f = cmd_set_bonding_primary_parsed,
5646 .help_str = "set bonding primary <slave_id> <port_id>: "
5647 "Set the primary slave for port_id",
5650 (void *)&cmd_setbonding_primary_set,
5651 (void *)&cmd_setbonding_primary_bonding,
5652 (void *)&cmd_setbonding_primary_primary,
5653 (void *)&cmd_setbonding_primary_slave,
5654 (void *)&cmd_setbonding_primary_port,
5659 /* *** ADD SLAVE *** */
5660 struct cmd_add_bonding_slave_result {
5661 cmdline_fixed_string_t add;
5662 cmdline_fixed_string_t bonding;
5663 cmdline_fixed_string_t slave;
5668 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5669 __attribute__((unused)) struct cmdline *cl,
5670 __attribute__((unused)) void *data)
5672 struct cmd_add_bonding_slave_result *res = parsed_result;
5673 portid_t master_port_id = res->port_id;
5674 portid_t slave_port_id = res->slave_id;
5676 /* add the slave for a bonded device. */
5677 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5678 printf("\t Failed to add slave %d to master port = %d.\n",
5679 slave_port_id, master_port_id);
5683 set_port_slave_flag(slave_port_id);
5686 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5687 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5689 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5690 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5691 bonding, "bonding");
5692 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5693 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5695 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5696 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5698 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5699 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5702 cmdline_parse_inst_t cmd_add_bonding_slave = {
5703 .f = cmd_add_bonding_slave_parsed,
5704 .help_str = "add bonding slave <slave_id> <port_id>: "
5705 "Add a slave device to a bonded device",
5708 (void *)&cmd_addbonding_slave_add,
5709 (void *)&cmd_addbonding_slave_bonding,
5710 (void *)&cmd_addbonding_slave_slave,
5711 (void *)&cmd_addbonding_slave_slaveid,
5712 (void *)&cmd_addbonding_slave_port,
5717 /* *** REMOVE SLAVE *** */
5718 struct cmd_remove_bonding_slave_result {
5719 cmdline_fixed_string_t remove;
5720 cmdline_fixed_string_t bonding;
5721 cmdline_fixed_string_t slave;
5726 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5727 __attribute__((unused)) struct cmdline *cl,
5728 __attribute__((unused)) void *data)
5730 struct cmd_remove_bonding_slave_result *res = parsed_result;
5731 portid_t master_port_id = res->port_id;
5732 portid_t slave_port_id = res->slave_id;
5734 /* remove the slave from a bonded device. */
5735 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5736 printf("\t Failed to remove slave %d from master port = %d.\n",
5737 slave_port_id, master_port_id);
5741 clear_port_slave_flag(slave_port_id);
5744 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5745 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5747 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5748 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5749 bonding, "bonding");
5750 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5751 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5753 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5754 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5756 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5757 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5760 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5761 .f = cmd_remove_bonding_slave_parsed,
5762 .help_str = "remove bonding slave <slave_id> <port_id>: "
5763 "Remove a slave device from a bonded device",
5766 (void *)&cmd_removebonding_slave_remove,
5767 (void *)&cmd_removebonding_slave_bonding,
5768 (void *)&cmd_removebonding_slave_slave,
5769 (void *)&cmd_removebonding_slave_slaveid,
5770 (void *)&cmd_removebonding_slave_port,
5775 /* *** CREATE BONDED DEVICE *** */
5776 struct cmd_create_bonded_device_result {
5777 cmdline_fixed_string_t create;
5778 cmdline_fixed_string_t bonded;
5779 cmdline_fixed_string_t device;
5784 static int bond_dev_num = 0;
5786 static void cmd_create_bonded_device_parsed(void *parsed_result,
5787 __attribute__((unused)) struct cmdline *cl,
5788 __attribute__((unused)) void *data)
5790 struct cmd_create_bonded_device_result *res = parsed_result;
5791 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5794 if (test_done == 0) {
5795 printf("Please stop forwarding first\n");
5799 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5802 /* Create a new bonded device. */
5803 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5805 printf("\t Failed to create bonded device.\n");
5808 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5811 /* Update number of ports */
5812 nb_ports = rte_eth_dev_count_avail();
5813 reconfig(port_id, res->socket);
5814 rte_eth_promiscuous_enable(port_id);
5819 cmdline_parse_token_string_t cmd_createbonded_device_create =
5820 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5822 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5823 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5825 cmdline_parse_token_string_t cmd_createbonded_device_device =
5826 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5828 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5829 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5831 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5832 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5835 cmdline_parse_inst_t cmd_create_bonded_device = {
5836 .f = cmd_create_bonded_device_parsed,
5837 .help_str = "create bonded device <mode> <socket>: "
5838 "Create a new bonded device with specific bonding mode and socket",
5841 (void *)&cmd_createbonded_device_create,
5842 (void *)&cmd_createbonded_device_bonded,
5843 (void *)&cmd_createbonded_device_device,
5844 (void *)&cmd_createbonded_device_mode,
5845 (void *)&cmd_createbonded_device_socket,
5850 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5851 struct cmd_set_bond_mac_addr_result {
5852 cmdline_fixed_string_t set;
5853 cmdline_fixed_string_t bonding;
5854 cmdline_fixed_string_t mac_addr;
5856 struct ether_addr address;
5859 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5860 __attribute__((unused)) struct cmdline *cl,
5861 __attribute__((unused)) void *data)
5863 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5866 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5869 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5871 /* check the return value and print it if is < 0 */
5873 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5876 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5877 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5878 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5879 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5881 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5882 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5884 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5885 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5887 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5888 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5890 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5891 .f = cmd_set_bond_mac_addr_parsed,
5893 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5895 (void *)&cmd_set_bond_mac_addr_set,
5896 (void *)&cmd_set_bond_mac_addr_bonding,
5897 (void *)&cmd_set_bond_mac_addr_mac,
5898 (void *)&cmd_set_bond_mac_addr_portnum,
5899 (void *)&cmd_set_bond_mac_addr_addr,
5905 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5906 struct cmd_set_bond_mon_period_result {
5907 cmdline_fixed_string_t set;
5908 cmdline_fixed_string_t bonding;
5909 cmdline_fixed_string_t mon_period;
5914 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5915 __attribute__((unused)) struct cmdline *cl,
5916 __attribute__((unused)) void *data)
5918 struct cmd_set_bond_mon_period_result *res = parsed_result;
5921 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5923 /* check the return value and print it if is < 0 */
5925 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5928 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5929 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5931 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5932 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5933 bonding, "bonding");
5934 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5935 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5936 mon_period, "mon_period");
5937 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5938 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5940 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5941 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5944 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5945 .f = cmd_set_bond_mon_period_parsed,
5947 .help_str = "set bonding mon_period <port_id> <period_ms>",
5949 (void *)&cmd_set_bond_mon_period_set,
5950 (void *)&cmd_set_bond_mon_period_bonding,
5951 (void *)&cmd_set_bond_mon_period_mon_period,
5952 (void *)&cmd_set_bond_mon_period_portnum,
5953 (void *)&cmd_set_bond_mon_period_period_ms,
5960 struct cmd_set_bonding_agg_mode_policy_result {
5961 cmdline_fixed_string_t set;
5962 cmdline_fixed_string_t bonding;
5963 cmdline_fixed_string_t agg_mode;
5965 cmdline_fixed_string_t policy;
5970 cmd_set_bonding_agg_mode(void *parsed_result,
5971 __attribute__((unused)) struct cmdline *cl,
5972 __attribute__((unused)) void *data)
5974 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5975 uint8_t policy = AGG_BANDWIDTH;
5977 if (!strcmp(res->policy, "bandwidth"))
5978 policy = AGG_BANDWIDTH;
5979 else if (!strcmp(res->policy, "stable"))
5980 policy = AGG_STABLE;
5981 else if (!strcmp(res->policy, "count"))
5984 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5988 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5989 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5991 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5992 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5993 bonding, "bonding");
5995 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5996 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5997 agg_mode, "agg_mode");
5999 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6000 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6003 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6004 TOKEN_STRING_INITIALIZER(
6005 struct cmd_set_bonding_balance_xmit_policy_result,
6006 policy, "stable#bandwidth#count");
6008 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6009 .f = cmd_set_bonding_agg_mode,
6011 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6013 (void *)&cmd_set_bonding_agg_mode_set,
6014 (void *)&cmd_set_bonding_agg_mode_bonding,
6015 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6016 (void *)&cmd_set_bonding_agg_mode_portnum,
6017 (void *)&cmd_set_bonding_agg_mode_policy_string,
6023 #endif /* RTE_LIBRTE_PMD_BOND */
6025 /* *** SET FORWARDING MODE *** */
6026 struct cmd_set_fwd_mode_result {
6027 cmdline_fixed_string_t set;
6028 cmdline_fixed_string_t fwd;
6029 cmdline_fixed_string_t mode;
6032 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6033 __attribute__((unused)) struct cmdline *cl,
6034 __attribute__((unused)) void *data)
6036 struct cmd_set_fwd_mode_result *res = parsed_result;
6039 set_pkt_forwarding_mode(res->mode);
6042 cmdline_parse_token_string_t cmd_setfwd_set =
6043 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6044 cmdline_parse_token_string_t cmd_setfwd_fwd =
6045 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6046 cmdline_parse_token_string_t cmd_setfwd_mode =
6047 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6048 "" /* defined at init */);
6050 cmdline_parse_inst_t cmd_set_fwd_mode = {
6051 .f = cmd_set_fwd_mode_parsed,
6053 .help_str = NULL, /* defined at init */
6055 (void *)&cmd_setfwd_set,
6056 (void *)&cmd_setfwd_fwd,
6057 (void *)&cmd_setfwd_mode,
6062 static void cmd_set_fwd_mode_init(void)
6065 static char token[128];
6066 static char help[256];
6067 cmdline_parse_token_string_t *token_struct;
6069 modes = list_pkt_forwarding_modes();
6070 snprintf(help, sizeof(help), "set fwd %s: "
6071 "Set packet forwarding mode", modes);
6072 cmd_set_fwd_mode.help_str = help;
6074 /* string token separator is # */
6075 for (c = token; *modes != '\0'; modes++)
6080 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6081 token_struct->string_data.str = token;
6084 /* *** SET RETRY FORWARDING MODE *** */
6085 struct cmd_set_fwd_retry_mode_result {
6086 cmdline_fixed_string_t set;
6087 cmdline_fixed_string_t fwd;
6088 cmdline_fixed_string_t mode;
6089 cmdline_fixed_string_t retry;
6092 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6093 __attribute__((unused)) struct cmdline *cl,
6094 __attribute__((unused)) void *data)
6096 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6099 set_pkt_forwarding_mode(res->mode);
6102 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6103 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6105 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6106 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6108 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6109 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6111 "" /* defined at init */);
6112 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6113 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6116 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6117 .f = cmd_set_fwd_retry_mode_parsed,
6119 .help_str = NULL, /* defined at init */
6121 (void *)&cmd_setfwd_retry_set,
6122 (void *)&cmd_setfwd_retry_fwd,
6123 (void *)&cmd_setfwd_retry_mode,
6124 (void *)&cmd_setfwd_retry_retry,
6129 static void cmd_set_fwd_retry_mode_init(void)
6132 static char token[128];
6133 static char help[256];
6134 cmdline_parse_token_string_t *token_struct;
6136 modes = list_pkt_forwarding_retry_modes();
6137 snprintf(help, sizeof(help), "set fwd %s retry: "
6138 "Set packet forwarding mode with retry", modes);
6139 cmd_set_fwd_retry_mode.help_str = help;
6141 /* string token separator is # */
6142 for (c = token; *modes != '\0'; modes++)
6147 token_struct = (cmdline_parse_token_string_t *)
6148 cmd_set_fwd_retry_mode.tokens[2];
6149 token_struct->string_data.str = token;
6152 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6153 struct cmd_set_burst_tx_retry_result {
6154 cmdline_fixed_string_t set;
6155 cmdline_fixed_string_t burst;
6156 cmdline_fixed_string_t tx;
6157 cmdline_fixed_string_t delay;
6159 cmdline_fixed_string_t retry;
6163 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6164 __attribute__((unused)) struct cmdline *cl,
6165 __attribute__((unused)) void *data)
6167 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6169 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6170 && !strcmp(res->tx, "tx")) {
6171 if (!strcmp(res->delay, "delay"))
6172 burst_tx_delay_time = res->time;
6173 if (!strcmp(res->retry, "retry"))
6174 burst_tx_retry_num = res->retry_num;
6179 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6180 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6181 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6182 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6184 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6185 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6186 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6187 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6188 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6189 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6190 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6191 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6192 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6193 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6195 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6196 .f = cmd_set_burst_tx_retry_parsed,
6197 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6199 (void *)&cmd_set_burst_tx_retry_set,
6200 (void *)&cmd_set_burst_tx_retry_burst,
6201 (void *)&cmd_set_burst_tx_retry_tx,
6202 (void *)&cmd_set_burst_tx_retry_delay,
6203 (void *)&cmd_set_burst_tx_retry_time,
6204 (void *)&cmd_set_burst_tx_retry_retry,
6205 (void *)&cmd_set_burst_tx_retry_retry_num,
6210 /* *** SET PROMISC MODE *** */
6211 struct cmd_set_promisc_mode_result {
6212 cmdline_fixed_string_t set;
6213 cmdline_fixed_string_t promisc;
6214 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6215 uint16_t port_num; /* valid if "allports" argument == 0 */
6216 cmdline_fixed_string_t mode;
6219 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6220 __attribute__((unused)) struct cmdline *cl,
6223 struct cmd_set_promisc_mode_result *res = parsed_result;
6227 if (!strcmp(res->mode, "on"))
6234 RTE_ETH_FOREACH_DEV(i) {
6236 rte_eth_promiscuous_enable(i);
6238 rte_eth_promiscuous_disable(i);
6243 rte_eth_promiscuous_enable(res->port_num);
6245 rte_eth_promiscuous_disable(res->port_num);
6249 cmdline_parse_token_string_t cmd_setpromisc_set =
6250 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6251 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6252 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6254 cmdline_parse_token_string_t cmd_setpromisc_portall =
6255 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6257 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6258 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6260 cmdline_parse_token_string_t cmd_setpromisc_mode =
6261 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6264 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6265 .f = cmd_set_promisc_mode_parsed,
6267 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6269 (void *)&cmd_setpromisc_set,
6270 (void *)&cmd_setpromisc_promisc,
6271 (void *)&cmd_setpromisc_portall,
6272 (void *)&cmd_setpromisc_mode,
6277 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6278 .f = cmd_set_promisc_mode_parsed,
6280 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6282 (void *)&cmd_setpromisc_set,
6283 (void *)&cmd_setpromisc_promisc,
6284 (void *)&cmd_setpromisc_portnum,
6285 (void *)&cmd_setpromisc_mode,
6290 /* *** SET ALLMULTI MODE *** */
6291 struct cmd_set_allmulti_mode_result {
6292 cmdline_fixed_string_t set;
6293 cmdline_fixed_string_t allmulti;
6294 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6295 uint16_t port_num; /* valid if "allports" argument == 0 */
6296 cmdline_fixed_string_t mode;
6299 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6300 __attribute__((unused)) struct cmdline *cl,
6303 struct cmd_set_allmulti_mode_result *res = parsed_result;
6307 if (!strcmp(res->mode, "on"))
6314 RTE_ETH_FOREACH_DEV(i) {
6316 rte_eth_allmulticast_enable(i);
6318 rte_eth_allmulticast_disable(i);
6323 rte_eth_allmulticast_enable(res->port_num);
6325 rte_eth_allmulticast_disable(res->port_num);
6329 cmdline_parse_token_string_t cmd_setallmulti_set =
6330 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6331 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6332 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6334 cmdline_parse_token_string_t cmd_setallmulti_portall =
6335 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6337 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6338 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6340 cmdline_parse_token_string_t cmd_setallmulti_mode =
6341 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6344 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6345 .f = cmd_set_allmulti_mode_parsed,
6347 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6349 (void *)&cmd_setallmulti_set,
6350 (void *)&cmd_setallmulti_allmulti,
6351 (void *)&cmd_setallmulti_portall,
6352 (void *)&cmd_setallmulti_mode,
6357 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6358 .f = cmd_set_allmulti_mode_parsed,
6360 .help_str = "set allmulti <port_id> on|off: "
6361 "Set allmulti mode on port_id",
6363 (void *)&cmd_setallmulti_set,
6364 (void *)&cmd_setallmulti_allmulti,
6365 (void *)&cmd_setallmulti_portnum,
6366 (void *)&cmd_setallmulti_mode,
6371 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6372 struct cmd_link_flow_ctrl_set_result {
6373 cmdline_fixed_string_t set;
6374 cmdline_fixed_string_t flow_ctrl;
6375 cmdline_fixed_string_t rx;
6376 cmdline_fixed_string_t rx_lfc_mode;
6377 cmdline_fixed_string_t tx;
6378 cmdline_fixed_string_t tx_lfc_mode;
6379 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6380 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6381 cmdline_fixed_string_t autoneg_str;
6382 cmdline_fixed_string_t autoneg;
6383 cmdline_fixed_string_t hw_str;
6384 uint32_t high_water;
6385 cmdline_fixed_string_t lw_str;
6387 cmdline_fixed_string_t pt_str;
6388 uint16_t pause_time;
6389 cmdline_fixed_string_t xon_str;
6394 cmdline_parse_token_string_t cmd_lfc_set_set =
6395 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6397 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6398 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6399 flow_ctrl, "flow_ctrl");
6400 cmdline_parse_token_string_t cmd_lfc_set_rx =
6401 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6403 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6404 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6405 rx_lfc_mode, "on#off");
6406 cmdline_parse_token_string_t cmd_lfc_set_tx =
6407 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6409 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6410 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6411 tx_lfc_mode, "on#off");
6412 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6413 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6414 hw_str, "high_water");
6415 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6416 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6417 high_water, UINT32);
6418 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6419 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6420 lw_str, "low_water");
6421 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6422 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6424 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6426 pt_str, "pause_time");
6427 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6428 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6429 pause_time, UINT16);
6430 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6432 xon_str, "send_xon");
6433 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6434 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6436 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6437 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6438 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6439 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6440 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6441 mac_ctrl_frame_fwd_mode, "on#off");
6442 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6443 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6444 autoneg_str, "autoneg");
6445 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6446 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6448 cmdline_parse_token_num_t cmd_lfc_set_portid =
6449 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6452 /* forward declaration */
6454 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6457 cmdline_parse_inst_t cmd_link_flow_control_set = {
6458 .f = cmd_link_flow_ctrl_set_parsed,
6460 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6461 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6462 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6464 (void *)&cmd_lfc_set_set,
6465 (void *)&cmd_lfc_set_flow_ctrl,
6466 (void *)&cmd_lfc_set_rx,
6467 (void *)&cmd_lfc_set_rx_mode,
6468 (void *)&cmd_lfc_set_tx,
6469 (void *)&cmd_lfc_set_tx_mode,
6470 (void *)&cmd_lfc_set_high_water,
6471 (void *)&cmd_lfc_set_low_water,
6472 (void *)&cmd_lfc_set_pause_time,
6473 (void *)&cmd_lfc_set_send_xon,
6474 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6475 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6476 (void *)&cmd_lfc_set_autoneg_str,
6477 (void *)&cmd_lfc_set_autoneg,
6478 (void *)&cmd_lfc_set_portid,
6483 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6484 .f = cmd_link_flow_ctrl_set_parsed,
6485 .data = (void *)&cmd_link_flow_control_set_rx,
6486 .help_str = "set flow_ctrl rx on|off <port_id>: "
6487 "Change rx flow control parameter",
6489 (void *)&cmd_lfc_set_set,
6490 (void *)&cmd_lfc_set_flow_ctrl,
6491 (void *)&cmd_lfc_set_rx,
6492 (void *)&cmd_lfc_set_rx_mode,
6493 (void *)&cmd_lfc_set_portid,
6498 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6499 .f = cmd_link_flow_ctrl_set_parsed,
6500 .data = (void *)&cmd_link_flow_control_set_tx,
6501 .help_str = "set flow_ctrl tx on|off <port_id>: "
6502 "Change tx flow control parameter",
6504 (void *)&cmd_lfc_set_set,
6505 (void *)&cmd_lfc_set_flow_ctrl,
6506 (void *)&cmd_lfc_set_tx,
6507 (void *)&cmd_lfc_set_tx_mode,
6508 (void *)&cmd_lfc_set_portid,
6513 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6514 .f = cmd_link_flow_ctrl_set_parsed,
6515 .data = (void *)&cmd_link_flow_control_set_hw,
6516 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6517 "Change high water flow control parameter",
6519 (void *)&cmd_lfc_set_set,
6520 (void *)&cmd_lfc_set_flow_ctrl,
6521 (void *)&cmd_lfc_set_high_water_str,
6522 (void *)&cmd_lfc_set_high_water,
6523 (void *)&cmd_lfc_set_portid,
6528 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6529 .f = cmd_link_flow_ctrl_set_parsed,
6530 .data = (void *)&cmd_link_flow_control_set_lw,
6531 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6532 "Change low water flow control parameter",
6534 (void *)&cmd_lfc_set_set,
6535 (void *)&cmd_lfc_set_flow_ctrl,
6536 (void *)&cmd_lfc_set_low_water_str,
6537 (void *)&cmd_lfc_set_low_water,
6538 (void *)&cmd_lfc_set_portid,
6543 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6544 .f = cmd_link_flow_ctrl_set_parsed,
6545 .data = (void *)&cmd_link_flow_control_set_pt,
6546 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6547 "Change pause time flow control parameter",
6549 (void *)&cmd_lfc_set_set,
6550 (void *)&cmd_lfc_set_flow_ctrl,
6551 (void *)&cmd_lfc_set_pause_time_str,
6552 (void *)&cmd_lfc_set_pause_time,
6553 (void *)&cmd_lfc_set_portid,
6558 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6559 .f = cmd_link_flow_ctrl_set_parsed,
6560 .data = (void *)&cmd_link_flow_control_set_xon,
6561 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6562 "Change send_xon flow control parameter",
6564 (void *)&cmd_lfc_set_set,
6565 (void *)&cmd_lfc_set_flow_ctrl,
6566 (void *)&cmd_lfc_set_send_xon_str,
6567 (void *)&cmd_lfc_set_send_xon,
6568 (void *)&cmd_lfc_set_portid,
6573 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6574 .f = cmd_link_flow_ctrl_set_parsed,
6575 .data = (void *)&cmd_link_flow_control_set_macfwd,
6576 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6577 "Change mac ctrl fwd flow control parameter",
6579 (void *)&cmd_lfc_set_set,
6580 (void *)&cmd_lfc_set_flow_ctrl,
6581 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6582 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6583 (void *)&cmd_lfc_set_portid,
6588 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6589 .f = cmd_link_flow_ctrl_set_parsed,
6590 .data = (void *)&cmd_link_flow_control_set_autoneg,
6591 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6592 "Change autoneg flow control parameter",
6594 (void *)&cmd_lfc_set_set,
6595 (void *)&cmd_lfc_set_flow_ctrl,
6596 (void *)&cmd_lfc_set_autoneg_str,
6597 (void *)&cmd_lfc_set_autoneg,
6598 (void *)&cmd_lfc_set_portid,
6604 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6605 __attribute__((unused)) struct cmdline *cl,
6608 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6609 cmdline_parse_inst_t *cmd = data;
6610 struct rte_eth_fc_conf fc_conf;
6616 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6617 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6618 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6619 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6621 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6622 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6625 /* Partial command line, retrieve current configuration */
6627 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6629 printf("cannot get current flow ctrl parameters, return"
6630 "code = %d\n", ret);
6634 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6635 (fc_conf.mode == RTE_FC_FULL))
6637 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6638 (fc_conf.mode == RTE_FC_FULL))
6642 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6643 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6645 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6646 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6648 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6650 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6651 fc_conf.high_water = res->high_water;
6653 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6654 fc_conf.low_water = res->low_water;
6656 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6657 fc_conf.pause_time = res->pause_time;
6659 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6660 fc_conf.send_xon = res->send_xon;
6662 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6663 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6664 fc_conf.mac_ctrl_frame_fwd = 1;
6666 fc_conf.mac_ctrl_frame_fwd = 0;
6669 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6670 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6672 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6674 printf("bad flow contrl parameter, return code = %d \n", ret);
6677 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6678 struct cmd_priority_flow_ctrl_set_result {
6679 cmdline_fixed_string_t set;
6680 cmdline_fixed_string_t pfc_ctrl;
6681 cmdline_fixed_string_t rx;
6682 cmdline_fixed_string_t rx_pfc_mode;
6683 cmdline_fixed_string_t tx;
6684 cmdline_fixed_string_t tx_pfc_mode;
6685 uint32_t high_water;
6687 uint16_t pause_time;
6693 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6694 __attribute__((unused)) struct cmdline *cl,
6695 __attribute__((unused)) void *data)
6697 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6698 struct rte_eth_pfc_conf pfc_conf;
6699 int rx_fc_enable, tx_fc_enable;
6703 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6704 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6705 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6706 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6708 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6709 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6712 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6713 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6714 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6715 pfc_conf.fc.high_water = res->high_water;
6716 pfc_conf.fc.low_water = res->low_water;
6717 pfc_conf.fc.pause_time = res->pause_time;
6718 pfc_conf.priority = res->priority;
6720 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6722 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6725 cmdline_parse_token_string_t cmd_pfc_set_set =
6726 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6728 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6729 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6730 pfc_ctrl, "pfc_ctrl");
6731 cmdline_parse_token_string_t cmd_pfc_set_rx =
6732 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6734 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6735 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6736 rx_pfc_mode, "on#off");
6737 cmdline_parse_token_string_t cmd_pfc_set_tx =
6738 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6740 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6741 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6742 tx_pfc_mode, "on#off");
6743 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6744 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6745 high_water, UINT32);
6746 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6747 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6749 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6750 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6751 pause_time, UINT16);
6752 cmdline_parse_token_num_t cmd_pfc_set_priority =
6753 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6755 cmdline_parse_token_num_t cmd_pfc_set_portid =
6756 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6759 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6760 .f = cmd_priority_flow_ctrl_set_parsed,
6762 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6763 "<pause_time> <priority> <port_id>: "
6764 "Configure the Ethernet priority flow control",
6766 (void *)&cmd_pfc_set_set,
6767 (void *)&cmd_pfc_set_flow_ctrl,
6768 (void *)&cmd_pfc_set_rx,
6769 (void *)&cmd_pfc_set_rx_mode,
6770 (void *)&cmd_pfc_set_tx,
6771 (void *)&cmd_pfc_set_tx_mode,
6772 (void *)&cmd_pfc_set_high_water,
6773 (void *)&cmd_pfc_set_low_water,
6774 (void *)&cmd_pfc_set_pause_time,
6775 (void *)&cmd_pfc_set_priority,
6776 (void *)&cmd_pfc_set_portid,
6781 /* *** RESET CONFIGURATION *** */
6782 struct cmd_reset_result {
6783 cmdline_fixed_string_t reset;
6784 cmdline_fixed_string_t def;
6787 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6789 __attribute__((unused)) void *data)
6791 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6792 set_def_fwd_config();
6795 cmdline_parse_token_string_t cmd_reset_set =
6796 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6797 cmdline_parse_token_string_t cmd_reset_def =
6798 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6801 cmdline_parse_inst_t cmd_reset = {
6802 .f = cmd_reset_parsed,
6804 .help_str = "set default: Reset default forwarding configuration",
6806 (void *)&cmd_reset_set,
6807 (void *)&cmd_reset_def,
6812 /* *** START FORWARDING *** */
6813 struct cmd_start_result {
6814 cmdline_fixed_string_t start;
6817 cmdline_parse_token_string_t cmd_start_start =
6818 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6820 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6821 __attribute__((unused)) struct cmdline *cl,
6822 __attribute__((unused)) void *data)
6824 start_packet_forwarding(0);
6827 cmdline_parse_inst_t cmd_start = {
6828 .f = cmd_start_parsed,
6830 .help_str = "start: Start packet forwarding",
6832 (void *)&cmd_start_start,
6837 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6838 struct cmd_start_tx_first_result {
6839 cmdline_fixed_string_t start;
6840 cmdline_fixed_string_t tx_first;
6844 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6845 __attribute__((unused)) struct cmdline *cl,
6846 __attribute__((unused)) void *data)
6848 start_packet_forwarding(1);
6851 cmdline_parse_token_string_t cmd_start_tx_first_start =
6852 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6854 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6855 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6856 tx_first, "tx_first");
6858 cmdline_parse_inst_t cmd_start_tx_first = {
6859 .f = cmd_start_tx_first_parsed,
6861 .help_str = "start tx_first: Start packet forwarding, "
6862 "after sending 1 burst of packets",
6864 (void *)&cmd_start_tx_first_start,
6865 (void *)&cmd_start_tx_first_tx_first,
6870 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6871 struct cmd_start_tx_first_n_result {
6872 cmdline_fixed_string_t start;
6873 cmdline_fixed_string_t tx_first;
6878 cmd_start_tx_first_n_parsed(void *parsed_result,
6879 __attribute__((unused)) struct cmdline *cl,
6880 __attribute__((unused)) void *data)
6882 struct cmd_start_tx_first_n_result *res = parsed_result;
6884 start_packet_forwarding(res->tx_num);
6887 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6888 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6890 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6891 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6892 tx_first, "tx_first");
6893 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6894 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6897 cmdline_parse_inst_t cmd_start_tx_first_n = {
6898 .f = cmd_start_tx_first_n_parsed,
6900 .help_str = "start tx_first <num>: "
6901 "packet forwarding, after sending <num> bursts of packets",
6903 (void *)&cmd_start_tx_first_n_start,
6904 (void *)&cmd_start_tx_first_n_tx_first,
6905 (void *)&cmd_start_tx_first_n_tx_num,
6910 /* *** SET LINK UP *** */
6911 struct cmd_set_link_up_result {
6912 cmdline_fixed_string_t set;
6913 cmdline_fixed_string_t link_up;
6914 cmdline_fixed_string_t port;
6918 cmdline_parse_token_string_t cmd_set_link_up_set =
6919 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6920 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6921 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6923 cmdline_parse_token_string_t cmd_set_link_up_port =
6924 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6925 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6926 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6928 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6929 __attribute__((unused)) struct cmdline *cl,
6930 __attribute__((unused)) void *data)
6932 struct cmd_set_link_up_result *res = parsed_result;
6933 dev_set_link_up(res->port_id);
6936 cmdline_parse_inst_t cmd_set_link_up = {
6937 .f = cmd_set_link_up_parsed,
6939 .help_str = "set link-up port <port id>",
6941 (void *)&cmd_set_link_up_set,
6942 (void *)&cmd_set_link_up_link_up,
6943 (void *)&cmd_set_link_up_port,
6944 (void *)&cmd_set_link_up_port_id,
6949 /* *** SET LINK DOWN *** */
6950 struct cmd_set_link_down_result {
6951 cmdline_fixed_string_t set;
6952 cmdline_fixed_string_t link_down;
6953 cmdline_fixed_string_t port;
6957 cmdline_parse_token_string_t cmd_set_link_down_set =
6958 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6959 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6960 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6962 cmdline_parse_token_string_t cmd_set_link_down_port =
6963 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6964 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6965 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6967 static void cmd_set_link_down_parsed(
6968 __attribute__((unused)) void *parsed_result,
6969 __attribute__((unused)) struct cmdline *cl,
6970 __attribute__((unused)) void *data)
6972 struct cmd_set_link_down_result *res = parsed_result;
6973 dev_set_link_down(res->port_id);
6976 cmdline_parse_inst_t cmd_set_link_down = {
6977 .f = cmd_set_link_down_parsed,
6979 .help_str = "set link-down port <port id>",
6981 (void *)&cmd_set_link_down_set,
6982 (void *)&cmd_set_link_down_link_down,
6983 (void *)&cmd_set_link_down_port,
6984 (void *)&cmd_set_link_down_port_id,
6989 /* *** SHOW CFG *** */
6990 struct cmd_showcfg_result {
6991 cmdline_fixed_string_t show;
6992 cmdline_fixed_string_t cfg;
6993 cmdline_fixed_string_t what;
6996 static void cmd_showcfg_parsed(void *parsed_result,
6997 __attribute__((unused)) struct cmdline *cl,
6998 __attribute__((unused)) void *data)
7000 struct cmd_showcfg_result *res = parsed_result;
7001 if (!strcmp(res->what, "rxtx"))
7002 rxtx_config_display();
7003 else if (!strcmp(res->what, "cores"))
7004 fwd_lcores_config_display();
7005 else if (!strcmp(res->what, "fwd"))
7006 pkt_fwd_config_display(&cur_fwd_config);
7007 else if (!strcmp(res->what, "txpkts"))
7008 show_tx_pkt_segments();
7011 cmdline_parse_token_string_t cmd_showcfg_show =
7012 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7013 cmdline_parse_token_string_t cmd_showcfg_port =
7014 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7015 cmdline_parse_token_string_t cmd_showcfg_what =
7016 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7017 "rxtx#cores#fwd#txpkts");
7019 cmdline_parse_inst_t cmd_showcfg = {
7020 .f = cmd_showcfg_parsed,
7022 .help_str = "show config rxtx|cores|fwd|txpkts",
7024 (void *)&cmd_showcfg_show,
7025 (void *)&cmd_showcfg_port,
7026 (void *)&cmd_showcfg_what,
7031 /* *** SHOW ALL PORT INFO *** */
7032 struct cmd_showportall_result {
7033 cmdline_fixed_string_t show;
7034 cmdline_fixed_string_t port;
7035 cmdline_fixed_string_t what;
7036 cmdline_fixed_string_t all;
7039 static void cmd_showportall_parsed(void *parsed_result,
7040 __attribute__((unused)) struct cmdline *cl,
7041 __attribute__((unused)) void *data)
7045 struct cmd_showportall_result *res = parsed_result;
7046 if (!strcmp(res->show, "clear")) {
7047 if (!strcmp(res->what, "stats"))
7048 RTE_ETH_FOREACH_DEV(i)
7050 else if (!strcmp(res->what, "xstats"))
7051 RTE_ETH_FOREACH_DEV(i)
7052 nic_xstats_clear(i);
7053 } else if (!strcmp(res->what, "info"))
7054 RTE_ETH_FOREACH_DEV(i)
7055 port_infos_display(i);
7056 else if (!strcmp(res->what, "stats"))
7057 RTE_ETH_FOREACH_DEV(i)
7058 nic_stats_display(i);
7059 else if (!strcmp(res->what, "xstats"))
7060 RTE_ETH_FOREACH_DEV(i)
7061 nic_xstats_display(i);
7062 else if (!strcmp(res->what, "fdir"))
7063 RTE_ETH_FOREACH_DEV(i)
7065 else if (!strcmp(res->what, "stat_qmap"))
7066 RTE_ETH_FOREACH_DEV(i)
7067 nic_stats_mapping_display(i);
7068 else if (!strcmp(res->what, "dcb_tc"))
7069 RTE_ETH_FOREACH_DEV(i)
7070 port_dcb_info_display(i);
7071 else if (!strcmp(res->what, "cap"))
7072 RTE_ETH_FOREACH_DEV(i)
7073 port_offload_cap_display(i);
7076 cmdline_parse_token_string_t cmd_showportall_show =
7077 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7079 cmdline_parse_token_string_t cmd_showportall_port =
7080 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7081 cmdline_parse_token_string_t cmd_showportall_what =
7082 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7083 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7084 cmdline_parse_token_string_t cmd_showportall_all =
7085 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7086 cmdline_parse_inst_t cmd_showportall = {
7087 .f = cmd_showportall_parsed,
7089 .help_str = "show|clear port "
7090 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7092 (void *)&cmd_showportall_show,
7093 (void *)&cmd_showportall_port,
7094 (void *)&cmd_showportall_what,
7095 (void *)&cmd_showportall_all,
7100 /* *** SHOW PORT INFO *** */
7101 struct cmd_showport_result {
7102 cmdline_fixed_string_t show;
7103 cmdline_fixed_string_t port;
7104 cmdline_fixed_string_t what;
7108 static void cmd_showport_parsed(void *parsed_result,
7109 __attribute__((unused)) struct cmdline *cl,
7110 __attribute__((unused)) void *data)
7112 struct cmd_showport_result *res = parsed_result;
7113 if (!strcmp(res->show, "clear")) {
7114 if (!strcmp(res->what, "stats"))
7115 nic_stats_clear(res->portnum);
7116 else if (!strcmp(res->what, "xstats"))
7117 nic_xstats_clear(res->portnum);
7118 } else if (!strcmp(res->what, "info"))
7119 port_infos_display(res->portnum);
7120 else if (!strcmp(res->what, "stats"))
7121 nic_stats_display(res->portnum);
7122 else if (!strcmp(res->what, "xstats"))
7123 nic_xstats_display(res->portnum);
7124 else if (!strcmp(res->what, "fdir"))
7125 fdir_get_infos(res->portnum);
7126 else if (!strcmp(res->what, "stat_qmap"))
7127 nic_stats_mapping_display(res->portnum);
7128 else if (!strcmp(res->what, "dcb_tc"))
7129 port_dcb_info_display(res->portnum);
7130 else if (!strcmp(res->what, "cap"))
7131 port_offload_cap_display(res->portnum);
7134 cmdline_parse_token_string_t cmd_showport_show =
7135 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7137 cmdline_parse_token_string_t cmd_showport_port =
7138 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7139 cmdline_parse_token_string_t cmd_showport_what =
7140 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7141 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7142 cmdline_parse_token_num_t cmd_showport_portnum =
7143 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7145 cmdline_parse_inst_t cmd_showport = {
7146 .f = cmd_showport_parsed,
7148 .help_str = "show|clear port "
7149 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7152 (void *)&cmd_showport_show,
7153 (void *)&cmd_showport_port,
7154 (void *)&cmd_showport_what,
7155 (void *)&cmd_showport_portnum,
7160 /* *** SHOW QUEUE INFO *** */
7161 struct cmd_showqueue_result {
7162 cmdline_fixed_string_t show;
7163 cmdline_fixed_string_t type;
7164 cmdline_fixed_string_t what;
7170 cmd_showqueue_parsed(void *parsed_result,
7171 __attribute__((unused)) struct cmdline *cl,
7172 __attribute__((unused)) void *data)
7174 struct cmd_showqueue_result *res = parsed_result;
7176 if (!strcmp(res->type, "rxq"))
7177 rx_queue_infos_display(res->portnum, res->queuenum);
7178 else if (!strcmp(res->type, "txq"))
7179 tx_queue_infos_display(res->portnum, res->queuenum);
7182 cmdline_parse_token_string_t cmd_showqueue_show =
7183 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7184 cmdline_parse_token_string_t cmd_showqueue_type =
7185 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7186 cmdline_parse_token_string_t cmd_showqueue_what =
7187 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7188 cmdline_parse_token_num_t cmd_showqueue_portnum =
7189 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7190 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7191 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7193 cmdline_parse_inst_t cmd_showqueue = {
7194 .f = cmd_showqueue_parsed,
7196 .help_str = "show rxq|txq info <port_id> <queue_id>",
7198 (void *)&cmd_showqueue_show,
7199 (void *)&cmd_showqueue_type,
7200 (void *)&cmd_showqueue_what,
7201 (void *)&cmd_showqueue_portnum,
7202 (void *)&cmd_showqueue_queuenum,
7207 /* *** READ PORT REGISTER *** */
7208 struct cmd_read_reg_result {
7209 cmdline_fixed_string_t read;
7210 cmdline_fixed_string_t reg;
7216 cmd_read_reg_parsed(void *parsed_result,
7217 __attribute__((unused)) struct cmdline *cl,
7218 __attribute__((unused)) void *data)
7220 struct cmd_read_reg_result *res = parsed_result;
7221 port_reg_display(res->port_id, res->reg_off);
7224 cmdline_parse_token_string_t cmd_read_reg_read =
7225 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7226 cmdline_parse_token_string_t cmd_read_reg_reg =
7227 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7228 cmdline_parse_token_num_t cmd_read_reg_port_id =
7229 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7230 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7231 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7233 cmdline_parse_inst_t cmd_read_reg = {
7234 .f = cmd_read_reg_parsed,
7236 .help_str = "read reg <port_id> <reg_off>",
7238 (void *)&cmd_read_reg_read,
7239 (void *)&cmd_read_reg_reg,
7240 (void *)&cmd_read_reg_port_id,
7241 (void *)&cmd_read_reg_reg_off,
7246 /* *** READ PORT REGISTER BIT FIELD *** */
7247 struct cmd_read_reg_bit_field_result {
7248 cmdline_fixed_string_t read;
7249 cmdline_fixed_string_t regfield;
7257 cmd_read_reg_bit_field_parsed(void *parsed_result,
7258 __attribute__((unused)) struct cmdline *cl,
7259 __attribute__((unused)) void *data)
7261 struct cmd_read_reg_bit_field_result *res = parsed_result;
7262 port_reg_bit_field_display(res->port_id, res->reg_off,
7263 res->bit1_pos, res->bit2_pos);
7266 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7267 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7269 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7270 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7271 regfield, "regfield");
7272 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7273 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7275 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7276 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7278 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7279 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7281 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7282 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7285 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7286 .f = cmd_read_reg_bit_field_parsed,
7288 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7289 "Read register bit field between bit_x and bit_y included",
7291 (void *)&cmd_read_reg_bit_field_read,
7292 (void *)&cmd_read_reg_bit_field_regfield,
7293 (void *)&cmd_read_reg_bit_field_port_id,
7294 (void *)&cmd_read_reg_bit_field_reg_off,
7295 (void *)&cmd_read_reg_bit_field_bit1_pos,
7296 (void *)&cmd_read_reg_bit_field_bit2_pos,
7301 /* *** READ PORT REGISTER BIT *** */
7302 struct cmd_read_reg_bit_result {
7303 cmdline_fixed_string_t read;
7304 cmdline_fixed_string_t regbit;
7311 cmd_read_reg_bit_parsed(void *parsed_result,
7312 __attribute__((unused)) struct cmdline *cl,
7313 __attribute__((unused)) void *data)
7315 struct cmd_read_reg_bit_result *res = parsed_result;
7316 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7319 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7320 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7321 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7322 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7324 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7325 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7326 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7327 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7328 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7329 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7331 cmdline_parse_inst_t cmd_read_reg_bit = {
7332 .f = cmd_read_reg_bit_parsed,
7334 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7336 (void *)&cmd_read_reg_bit_read,
7337 (void *)&cmd_read_reg_bit_regbit,
7338 (void *)&cmd_read_reg_bit_port_id,
7339 (void *)&cmd_read_reg_bit_reg_off,
7340 (void *)&cmd_read_reg_bit_bit_pos,
7345 /* *** WRITE PORT REGISTER *** */
7346 struct cmd_write_reg_result {
7347 cmdline_fixed_string_t write;
7348 cmdline_fixed_string_t reg;
7355 cmd_write_reg_parsed(void *parsed_result,
7356 __attribute__((unused)) struct cmdline *cl,
7357 __attribute__((unused)) void *data)
7359 struct cmd_write_reg_result *res = parsed_result;
7360 port_reg_set(res->port_id, res->reg_off, res->value);
7363 cmdline_parse_token_string_t cmd_write_reg_write =
7364 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7365 cmdline_parse_token_string_t cmd_write_reg_reg =
7366 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7367 cmdline_parse_token_num_t cmd_write_reg_port_id =
7368 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7369 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7370 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7371 cmdline_parse_token_num_t cmd_write_reg_value =
7372 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7374 cmdline_parse_inst_t cmd_write_reg = {
7375 .f = cmd_write_reg_parsed,
7377 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7379 (void *)&cmd_write_reg_write,
7380 (void *)&cmd_write_reg_reg,
7381 (void *)&cmd_write_reg_port_id,
7382 (void *)&cmd_write_reg_reg_off,
7383 (void *)&cmd_write_reg_value,
7388 /* *** WRITE PORT REGISTER BIT FIELD *** */
7389 struct cmd_write_reg_bit_field_result {
7390 cmdline_fixed_string_t write;
7391 cmdline_fixed_string_t regfield;
7400 cmd_write_reg_bit_field_parsed(void *parsed_result,
7401 __attribute__((unused)) struct cmdline *cl,
7402 __attribute__((unused)) void *data)
7404 struct cmd_write_reg_bit_field_result *res = parsed_result;
7405 port_reg_bit_field_set(res->port_id, res->reg_off,
7406 res->bit1_pos, res->bit2_pos, res->value);
7409 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7410 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7412 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7413 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7414 regfield, "regfield");
7415 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7416 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7418 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7419 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7421 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7422 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7424 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7425 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7427 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7428 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7431 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7432 .f = cmd_write_reg_bit_field_parsed,
7434 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7436 "Set register bit field between bit_x and bit_y included",
7438 (void *)&cmd_write_reg_bit_field_write,
7439 (void *)&cmd_write_reg_bit_field_regfield,
7440 (void *)&cmd_write_reg_bit_field_port_id,
7441 (void *)&cmd_write_reg_bit_field_reg_off,
7442 (void *)&cmd_write_reg_bit_field_bit1_pos,
7443 (void *)&cmd_write_reg_bit_field_bit2_pos,
7444 (void *)&cmd_write_reg_bit_field_value,
7449 /* *** WRITE PORT REGISTER BIT *** */
7450 struct cmd_write_reg_bit_result {
7451 cmdline_fixed_string_t write;
7452 cmdline_fixed_string_t regbit;
7460 cmd_write_reg_bit_parsed(void *parsed_result,
7461 __attribute__((unused)) struct cmdline *cl,
7462 __attribute__((unused)) void *data)
7464 struct cmd_write_reg_bit_result *res = parsed_result;
7465 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7468 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7469 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7471 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7472 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7474 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7475 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7476 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7477 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7478 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7479 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7480 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7481 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7483 cmdline_parse_inst_t cmd_write_reg_bit = {
7484 .f = cmd_write_reg_bit_parsed,
7486 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7489 (void *)&cmd_write_reg_bit_write,
7490 (void *)&cmd_write_reg_bit_regbit,
7491 (void *)&cmd_write_reg_bit_port_id,
7492 (void *)&cmd_write_reg_bit_reg_off,
7493 (void *)&cmd_write_reg_bit_bit_pos,
7494 (void *)&cmd_write_reg_bit_value,
7499 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7500 struct cmd_read_rxd_txd_result {
7501 cmdline_fixed_string_t read;
7502 cmdline_fixed_string_t rxd_txd;
7509 cmd_read_rxd_txd_parsed(void *parsed_result,
7510 __attribute__((unused)) struct cmdline *cl,
7511 __attribute__((unused)) void *data)
7513 struct cmd_read_rxd_txd_result *res = parsed_result;
7515 if (!strcmp(res->rxd_txd, "rxd"))
7516 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7517 else if (!strcmp(res->rxd_txd, "txd"))
7518 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7521 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7522 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7523 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7524 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7526 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7527 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7528 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7529 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7530 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7531 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7533 cmdline_parse_inst_t cmd_read_rxd_txd = {
7534 .f = cmd_read_rxd_txd_parsed,
7536 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7538 (void *)&cmd_read_rxd_txd_read,
7539 (void *)&cmd_read_rxd_txd_rxd_txd,
7540 (void *)&cmd_read_rxd_txd_port_id,
7541 (void *)&cmd_read_rxd_txd_queue_id,
7542 (void *)&cmd_read_rxd_txd_desc_id,
7548 struct cmd_quit_result {
7549 cmdline_fixed_string_t quit;
7552 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7554 __attribute__((unused)) void *data)
7560 cmdline_parse_token_string_t cmd_quit_quit =
7561 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7563 cmdline_parse_inst_t cmd_quit = {
7564 .f = cmd_quit_parsed,
7566 .help_str = "quit: Exit application",
7568 (void *)&cmd_quit_quit,
7573 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7574 struct cmd_mac_addr_result {
7575 cmdline_fixed_string_t mac_addr_cmd;
7576 cmdline_fixed_string_t what;
7578 struct ether_addr address;
7581 static void cmd_mac_addr_parsed(void *parsed_result,
7582 __attribute__((unused)) struct cmdline *cl,
7583 __attribute__((unused)) void *data)
7585 struct cmd_mac_addr_result *res = parsed_result;
7588 if (strcmp(res->what, "add") == 0)
7589 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7590 else if (strcmp(res->what, "set") == 0)
7591 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7594 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7596 /* check the return value and print it if is < 0 */
7598 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7602 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7603 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7605 cmdline_parse_token_string_t cmd_mac_addr_what =
7606 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7608 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7609 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7611 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7612 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7614 cmdline_parse_inst_t cmd_mac_addr = {
7615 .f = cmd_mac_addr_parsed,
7617 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7618 "Add/Remove/Set MAC address on port_id",
7620 (void *)&cmd_mac_addr_cmd,
7621 (void *)&cmd_mac_addr_what,
7622 (void *)&cmd_mac_addr_portnum,
7623 (void *)&cmd_mac_addr_addr,
7628 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7629 struct cmd_eth_peer_result {
7630 cmdline_fixed_string_t set;
7631 cmdline_fixed_string_t eth_peer;
7633 cmdline_fixed_string_t peer_addr;
7636 static void cmd_set_eth_peer_parsed(void *parsed_result,
7637 __attribute__((unused)) struct cmdline *cl,
7638 __attribute__((unused)) void *data)
7640 struct cmd_eth_peer_result *res = parsed_result;
7642 if (test_done == 0) {
7643 printf("Please stop forwarding first\n");
7646 if (!strcmp(res->eth_peer, "eth-peer")) {
7647 set_fwd_eth_peer(res->port_id, res->peer_addr);
7651 cmdline_parse_token_string_t cmd_eth_peer_set =
7652 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7653 cmdline_parse_token_string_t cmd_eth_peer =
7654 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7655 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7656 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7657 cmdline_parse_token_string_t cmd_eth_peer_addr =
7658 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7660 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7661 .f = cmd_set_eth_peer_parsed,
7663 .help_str = "set eth-peer <port_id> <peer_mac>",
7665 (void *)&cmd_eth_peer_set,
7666 (void *)&cmd_eth_peer,
7667 (void *)&cmd_eth_peer_port_id,
7668 (void *)&cmd_eth_peer_addr,
7673 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7674 struct cmd_set_qmap_result {
7675 cmdline_fixed_string_t set;
7676 cmdline_fixed_string_t qmap;
7677 cmdline_fixed_string_t what;
7684 cmd_set_qmap_parsed(void *parsed_result,
7685 __attribute__((unused)) struct cmdline *cl,
7686 __attribute__((unused)) void *data)
7688 struct cmd_set_qmap_result *res = parsed_result;
7689 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7691 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7694 cmdline_parse_token_string_t cmd_setqmap_set =
7695 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7697 cmdline_parse_token_string_t cmd_setqmap_qmap =
7698 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7700 cmdline_parse_token_string_t cmd_setqmap_what =
7701 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7703 cmdline_parse_token_num_t cmd_setqmap_portid =
7704 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7706 cmdline_parse_token_num_t cmd_setqmap_queueid =
7707 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7709 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7710 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7713 cmdline_parse_inst_t cmd_set_qmap = {
7714 .f = cmd_set_qmap_parsed,
7716 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7717 "Set statistics mapping value on tx|rx queue_id of port_id",
7719 (void *)&cmd_setqmap_set,
7720 (void *)&cmd_setqmap_qmap,
7721 (void *)&cmd_setqmap_what,
7722 (void *)&cmd_setqmap_portid,
7723 (void *)&cmd_setqmap_queueid,
7724 (void *)&cmd_setqmap_mapvalue,
7729 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7730 struct cmd_set_xstats_hide_zero_result {
7731 cmdline_fixed_string_t keyword;
7732 cmdline_fixed_string_t name;
7733 cmdline_fixed_string_t on_off;
7737 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7738 __attribute__((unused)) struct cmdline *cl,
7739 __attribute__((unused)) void *data)
7741 struct cmd_set_xstats_hide_zero_result *res;
7742 uint16_t on_off = 0;
7744 res = parsed_result;
7745 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7746 set_xstats_hide_zero(on_off);
7749 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7750 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7752 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7753 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7754 name, "xstats-hide-zero");
7755 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7756 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7759 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7760 .f = cmd_set_xstats_hide_zero_parsed,
7762 .help_str = "set xstats-hide-zero on|off",
7764 (void *)&cmd_set_xstats_hide_zero_keyword,
7765 (void *)&cmd_set_xstats_hide_zero_name,
7766 (void *)&cmd_set_xstats_hide_zero_on_off,
7771 /* *** CONFIGURE UNICAST HASH TABLE *** */
7772 struct cmd_set_uc_hash_table {
7773 cmdline_fixed_string_t set;
7774 cmdline_fixed_string_t port;
7776 cmdline_fixed_string_t what;
7777 struct ether_addr address;
7778 cmdline_fixed_string_t mode;
7782 cmd_set_uc_hash_parsed(void *parsed_result,
7783 __attribute__((unused)) struct cmdline *cl,
7784 __attribute__((unused)) void *data)
7787 struct cmd_set_uc_hash_table *res = parsed_result;
7789 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7791 if (strcmp(res->what, "uta") == 0)
7792 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7793 &res->address,(uint8_t)is_on);
7795 printf("bad unicast hash table parameter, return code = %d \n", ret);
7799 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7800 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7802 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7803 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7805 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7806 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7808 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7809 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7811 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7812 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7814 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7815 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7818 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7819 .f = cmd_set_uc_hash_parsed,
7821 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7823 (void *)&cmd_set_uc_hash_set,
7824 (void *)&cmd_set_uc_hash_port,
7825 (void *)&cmd_set_uc_hash_portid,
7826 (void *)&cmd_set_uc_hash_what,
7827 (void *)&cmd_set_uc_hash_mac,
7828 (void *)&cmd_set_uc_hash_mode,
7833 struct cmd_set_uc_all_hash_table {
7834 cmdline_fixed_string_t set;
7835 cmdline_fixed_string_t port;
7837 cmdline_fixed_string_t what;
7838 cmdline_fixed_string_t value;
7839 cmdline_fixed_string_t mode;
7843 cmd_set_uc_all_hash_parsed(void *parsed_result,
7844 __attribute__((unused)) struct cmdline *cl,
7845 __attribute__((unused)) void *data)
7848 struct cmd_set_uc_all_hash_table *res = parsed_result;
7850 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7852 if ((strcmp(res->what, "uta") == 0) &&
7853 (strcmp(res->value, "all") == 0))
7854 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7856 printf("bad unicast hash table parameter,"
7857 "return code = %d \n", ret);
7860 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7861 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7863 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7864 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7866 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7867 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7869 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7870 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7872 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7873 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7875 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7876 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7879 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7880 .f = cmd_set_uc_all_hash_parsed,
7882 .help_str = "set port <port_id> uta all on|off",
7884 (void *)&cmd_set_uc_all_hash_set,
7885 (void *)&cmd_set_uc_all_hash_port,
7886 (void *)&cmd_set_uc_all_hash_portid,
7887 (void *)&cmd_set_uc_all_hash_what,
7888 (void *)&cmd_set_uc_all_hash_value,
7889 (void *)&cmd_set_uc_all_hash_mode,
7894 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7895 struct cmd_set_vf_macvlan_filter {
7896 cmdline_fixed_string_t set;
7897 cmdline_fixed_string_t port;
7899 cmdline_fixed_string_t vf;
7901 struct ether_addr address;
7902 cmdline_fixed_string_t filter_type;
7903 cmdline_fixed_string_t mode;
7907 cmd_set_vf_macvlan_parsed(void *parsed_result,
7908 __attribute__((unused)) struct cmdline *cl,
7909 __attribute__((unused)) void *data)
7912 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7913 struct rte_eth_mac_filter filter;
7915 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7917 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7919 /* set VF MAC filter */
7923 filter.dst_id = res->vf_id;
7925 if (!strcmp(res->filter_type, "exact-mac"))
7926 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7927 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7928 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7929 else if (!strcmp(res->filter_type, "hashmac"))
7930 filter.filter_type = RTE_MAC_HASH_MATCH;
7931 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7932 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7934 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7937 ret = rte_eth_dev_filter_ctrl(res->port_id,
7938 RTE_ETH_FILTER_MACVLAN,
7942 ret = rte_eth_dev_filter_ctrl(res->port_id,
7943 RTE_ETH_FILTER_MACVLAN,
7944 RTE_ETH_FILTER_DELETE,
7948 printf("bad set MAC hash parameter, return code = %d\n", ret);
7952 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7953 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7955 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7956 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7958 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7959 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7961 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7962 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7964 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7965 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7967 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7968 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7970 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7971 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7972 filter_type, "exact-mac#exact-mac-vlan"
7973 "#hashmac#hashmac-vlan");
7974 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7975 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7978 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7979 .f = cmd_set_vf_macvlan_parsed,
7981 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7982 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7983 "Exact match rule: exact match of MAC or MAC and VLAN; "
7984 "hash match rule: hash match of MAC and exact match of VLAN",
7986 (void *)&cmd_set_vf_macvlan_set,
7987 (void *)&cmd_set_vf_macvlan_port,
7988 (void *)&cmd_set_vf_macvlan_portid,
7989 (void *)&cmd_set_vf_macvlan_vf,
7990 (void *)&cmd_set_vf_macvlan_vf_id,
7991 (void *)&cmd_set_vf_macvlan_mac,
7992 (void *)&cmd_set_vf_macvlan_filter_type,
7993 (void *)&cmd_set_vf_macvlan_mode,
7998 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7999 struct cmd_set_vf_traffic {
8000 cmdline_fixed_string_t set;
8001 cmdline_fixed_string_t port;
8003 cmdline_fixed_string_t vf;
8005 cmdline_fixed_string_t what;
8006 cmdline_fixed_string_t mode;
8010 cmd_set_vf_traffic_parsed(void *parsed_result,
8011 __attribute__((unused)) struct cmdline *cl,
8012 __attribute__((unused)) void *data)
8014 struct cmd_set_vf_traffic *res = parsed_result;
8015 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8016 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8018 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8021 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8022 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8024 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8025 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8027 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8028 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8030 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8031 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8033 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8034 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8036 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8037 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8039 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8040 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8043 cmdline_parse_inst_t cmd_set_vf_traffic = {
8044 .f = cmd_set_vf_traffic_parsed,
8046 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8048 (void *)&cmd_setvf_traffic_set,
8049 (void *)&cmd_setvf_traffic_port,
8050 (void *)&cmd_setvf_traffic_portid,
8051 (void *)&cmd_setvf_traffic_vf,
8052 (void *)&cmd_setvf_traffic_vfid,
8053 (void *)&cmd_setvf_traffic_what,
8054 (void *)&cmd_setvf_traffic_mode,
8059 /* *** CONFIGURE VF RECEIVE MODE *** */
8060 struct cmd_set_vf_rxmode {
8061 cmdline_fixed_string_t set;
8062 cmdline_fixed_string_t port;
8064 cmdline_fixed_string_t vf;
8066 cmdline_fixed_string_t what;
8067 cmdline_fixed_string_t mode;
8068 cmdline_fixed_string_t on;
8072 cmd_set_vf_rxmode_parsed(void *parsed_result,
8073 __attribute__((unused)) struct cmdline *cl,
8074 __attribute__((unused)) void *data)
8077 uint16_t rx_mode = 0;
8078 struct cmd_set_vf_rxmode *res = parsed_result;
8080 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8081 if (!strcmp(res->what,"rxmode")) {
8082 if (!strcmp(res->mode, "AUPE"))
8083 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8084 else if (!strcmp(res->mode, "ROPE"))
8085 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8086 else if (!strcmp(res->mode, "BAM"))
8087 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8088 else if (!strncmp(res->mode, "MPE",3))
8089 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8092 RTE_SET_USED(is_on);
8094 #ifdef RTE_LIBRTE_IXGBE_PMD
8095 if (ret == -ENOTSUP)
8096 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8097 rx_mode, (uint8_t)is_on);
8099 #ifdef RTE_LIBRTE_BNXT_PMD
8100 if (ret == -ENOTSUP)
8101 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8102 rx_mode, (uint8_t)is_on);
8105 printf("bad VF receive mode parameter, return code = %d \n",
8109 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8110 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8112 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8113 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8115 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8116 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8118 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8119 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8121 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8122 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8124 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8125 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8127 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8128 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8129 mode, "AUPE#ROPE#BAM#MPE");
8130 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8131 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8134 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8135 .f = cmd_set_vf_rxmode_parsed,
8137 .help_str = "set port <port_id> vf <vf_id> rxmode "
8138 "AUPE|ROPE|BAM|MPE on|off",
8140 (void *)&cmd_set_vf_rxmode_set,
8141 (void *)&cmd_set_vf_rxmode_port,
8142 (void *)&cmd_set_vf_rxmode_portid,
8143 (void *)&cmd_set_vf_rxmode_vf,
8144 (void *)&cmd_set_vf_rxmode_vfid,
8145 (void *)&cmd_set_vf_rxmode_what,
8146 (void *)&cmd_set_vf_rxmode_mode,
8147 (void *)&cmd_set_vf_rxmode_on,
8152 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8153 struct cmd_vf_mac_addr_result {
8154 cmdline_fixed_string_t mac_addr_cmd;
8155 cmdline_fixed_string_t what;
8156 cmdline_fixed_string_t port;
8158 cmdline_fixed_string_t vf;
8160 struct ether_addr address;
8163 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8164 __attribute__((unused)) struct cmdline *cl,
8165 __attribute__((unused)) void *data)
8167 struct cmd_vf_mac_addr_result *res = parsed_result;
8170 if (strcmp(res->what, "add") != 0)
8173 #ifdef RTE_LIBRTE_I40E_PMD
8174 if (ret == -ENOTSUP)
8175 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8178 #ifdef RTE_LIBRTE_BNXT_PMD
8179 if (ret == -ENOTSUP)
8180 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8185 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8189 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8190 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8191 mac_addr_cmd,"mac_addr");
8192 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8193 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8195 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8196 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8198 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8199 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8201 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8202 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8204 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8205 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8207 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8208 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8211 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8212 .f = cmd_vf_mac_addr_parsed,
8214 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8215 "Add MAC address filtering for a VF on port_id",
8217 (void *)&cmd_vf_mac_addr_cmd,
8218 (void *)&cmd_vf_mac_addr_what,
8219 (void *)&cmd_vf_mac_addr_port,
8220 (void *)&cmd_vf_mac_addr_portnum,
8221 (void *)&cmd_vf_mac_addr_vf,
8222 (void *)&cmd_vf_mac_addr_vfnum,
8223 (void *)&cmd_vf_mac_addr_addr,
8228 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8229 struct cmd_vf_rx_vlan_filter {
8230 cmdline_fixed_string_t rx_vlan;
8231 cmdline_fixed_string_t what;
8233 cmdline_fixed_string_t port;
8235 cmdline_fixed_string_t vf;
8240 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8241 __attribute__((unused)) struct cmdline *cl,
8242 __attribute__((unused)) void *data)
8244 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8247 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8249 #ifdef RTE_LIBRTE_IXGBE_PMD
8250 if (ret == -ENOTSUP)
8251 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8252 res->vlan_id, res->vf_mask, is_add);
8254 #ifdef RTE_LIBRTE_I40E_PMD
8255 if (ret == -ENOTSUP)
8256 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8257 res->vlan_id, res->vf_mask, is_add);
8259 #ifdef RTE_LIBRTE_BNXT_PMD
8260 if (ret == -ENOTSUP)
8261 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8262 res->vlan_id, res->vf_mask, is_add);
8269 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8270 res->vlan_id, res->vf_mask);
8273 printf("invalid port_id %d\n", res->port_id);
8276 printf("function not implemented or supported\n");
8279 printf("programming error: (%s)\n", strerror(-ret));
8283 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8284 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8285 rx_vlan, "rx_vlan");
8286 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8287 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8289 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8290 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8292 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8293 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8295 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8296 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8298 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8299 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8301 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8302 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8305 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8306 .f = cmd_vf_rx_vlan_filter_parsed,
8308 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8309 "(vf_mask = hexadecimal VF mask)",
8311 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8312 (void *)&cmd_vf_rx_vlan_filter_what,
8313 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8314 (void *)&cmd_vf_rx_vlan_filter_port,
8315 (void *)&cmd_vf_rx_vlan_filter_portid,
8316 (void *)&cmd_vf_rx_vlan_filter_vf,
8317 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8322 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8323 struct cmd_queue_rate_limit_result {
8324 cmdline_fixed_string_t set;
8325 cmdline_fixed_string_t port;
8327 cmdline_fixed_string_t queue;
8329 cmdline_fixed_string_t rate;
8333 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8334 __attribute__((unused)) struct cmdline *cl,
8335 __attribute__((unused)) void *data)
8337 struct cmd_queue_rate_limit_result *res = parsed_result;
8340 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8341 && (strcmp(res->queue, "queue") == 0)
8342 && (strcmp(res->rate, "rate") == 0))
8343 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8346 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8350 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8351 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8353 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8354 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8356 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8357 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8359 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8360 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8362 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8363 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8365 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8366 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8368 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8369 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8372 cmdline_parse_inst_t cmd_queue_rate_limit = {
8373 .f = cmd_queue_rate_limit_parsed,
8375 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8376 "Set rate limit for a queue on port_id",
8378 (void *)&cmd_queue_rate_limit_set,
8379 (void *)&cmd_queue_rate_limit_port,
8380 (void *)&cmd_queue_rate_limit_portnum,
8381 (void *)&cmd_queue_rate_limit_queue,
8382 (void *)&cmd_queue_rate_limit_queuenum,
8383 (void *)&cmd_queue_rate_limit_rate,
8384 (void *)&cmd_queue_rate_limit_ratenum,
8389 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8390 struct cmd_vf_rate_limit_result {
8391 cmdline_fixed_string_t set;
8392 cmdline_fixed_string_t port;
8394 cmdline_fixed_string_t vf;
8396 cmdline_fixed_string_t rate;
8398 cmdline_fixed_string_t q_msk;
8402 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8403 __attribute__((unused)) struct cmdline *cl,
8404 __attribute__((unused)) void *data)
8406 struct cmd_vf_rate_limit_result *res = parsed_result;
8409 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8410 && (strcmp(res->vf, "vf") == 0)
8411 && (strcmp(res->rate, "rate") == 0)
8412 && (strcmp(res->q_msk, "queue_mask") == 0))
8413 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8414 res->rate_num, res->q_msk_val);
8416 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8420 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8421 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8423 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8424 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8426 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8427 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8429 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8430 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8432 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8433 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8435 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8436 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8438 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8439 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8441 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8442 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8443 q_msk, "queue_mask");
8444 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8445 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8448 cmdline_parse_inst_t cmd_vf_rate_limit = {
8449 .f = cmd_vf_rate_limit_parsed,
8451 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8452 "queue_mask <queue_mask_value>: "
8453 "Set rate limit for queues of VF on port_id",
8455 (void *)&cmd_vf_rate_limit_set,
8456 (void *)&cmd_vf_rate_limit_port,
8457 (void *)&cmd_vf_rate_limit_portnum,
8458 (void *)&cmd_vf_rate_limit_vf,
8459 (void *)&cmd_vf_rate_limit_vfnum,
8460 (void *)&cmd_vf_rate_limit_rate,
8461 (void *)&cmd_vf_rate_limit_ratenum,
8462 (void *)&cmd_vf_rate_limit_q_msk,
8463 (void *)&cmd_vf_rate_limit_q_msk_val,
8468 /* *** ADD TUNNEL FILTER OF A PORT *** */
8469 struct cmd_tunnel_filter_result {
8470 cmdline_fixed_string_t cmd;
8471 cmdline_fixed_string_t what;
8473 struct ether_addr outer_mac;
8474 struct ether_addr inner_mac;
8475 cmdline_ipaddr_t ip_value;
8476 uint16_t inner_vlan;
8477 cmdline_fixed_string_t tunnel_type;
8478 cmdline_fixed_string_t filter_type;
8484 cmd_tunnel_filter_parsed(void *parsed_result,
8485 __attribute__((unused)) struct cmdline *cl,
8486 __attribute__((unused)) void *data)
8488 struct cmd_tunnel_filter_result *res = parsed_result;
8489 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8492 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8494 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8495 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8496 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8498 if (res->ip_value.family == AF_INET) {
8499 tunnel_filter_conf.ip_addr.ipv4_addr =
8500 res->ip_value.addr.ipv4.s_addr;
8501 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8503 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8504 &(res->ip_value.addr.ipv6),
8505 sizeof(struct in6_addr));
8506 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8509 if (!strcmp(res->filter_type, "imac-ivlan"))
8510 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8511 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8512 tunnel_filter_conf.filter_type =
8513 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8514 else if (!strcmp(res->filter_type, "imac-tenid"))
8515 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8516 else if (!strcmp(res->filter_type, "imac"))
8517 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8518 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8519 tunnel_filter_conf.filter_type =
8520 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8521 else if (!strcmp(res->filter_type, "oip"))
8522 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8523 else if (!strcmp(res->filter_type, "iip"))
8524 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8526 printf("The filter type is not supported");
8530 if (!strcmp(res->tunnel_type, "vxlan"))
8531 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8532 else if (!strcmp(res->tunnel_type, "nvgre"))
8533 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8534 else if (!strcmp(res->tunnel_type, "ipingre"))
8535 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8537 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8541 tunnel_filter_conf.tenant_id = res->tenant_id;
8542 tunnel_filter_conf.queue_id = res->queue_num;
8543 if (!strcmp(res->what, "add"))
8544 ret = rte_eth_dev_filter_ctrl(res->port_id,
8545 RTE_ETH_FILTER_TUNNEL,
8547 &tunnel_filter_conf);
8549 ret = rte_eth_dev_filter_ctrl(res->port_id,
8550 RTE_ETH_FILTER_TUNNEL,
8551 RTE_ETH_FILTER_DELETE,
8552 &tunnel_filter_conf);
8554 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8558 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8559 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8560 cmd, "tunnel_filter");
8561 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8562 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8564 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8565 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8567 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8568 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8570 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8571 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8573 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8574 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8575 inner_vlan, UINT16);
8576 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8577 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8579 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8580 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8581 tunnel_type, "vxlan#nvgre#ipingre");
8583 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8584 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8585 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8586 "imac#omac-imac-tenid");
8587 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8588 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8590 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8591 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8594 cmdline_parse_inst_t cmd_tunnel_filter = {
8595 .f = cmd_tunnel_filter_parsed,
8597 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8598 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8599 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8600 "<queue_id>: Add/Rm tunnel filter of a port",
8602 (void *)&cmd_tunnel_filter_cmd,
8603 (void *)&cmd_tunnel_filter_what,
8604 (void *)&cmd_tunnel_filter_port_id,
8605 (void *)&cmd_tunnel_filter_outer_mac,
8606 (void *)&cmd_tunnel_filter_inner_mac,
8607 (void *)&cmd_tunnel_filter_ip_value,
8608 (void *)&cmd_tunnel_filter_innner_vlan,
8609 (void *)&cmd_tunnel_filter_tunnel_type,
8610 (void *)&cmd_tunnel_filter_filter_type,
8611 (void *)&cmd_tunnel_filter_tenant_id,
8612 (void *)&cmd_tunnel_filter_queue_num,
8617 /* *** CONFIGURE TUNNEL UDP PORT *** */
8618 struct cmd_tunnel_udp_config {
8619 cmdline_fixed_string_t cmd;
8620 cmdline_fixed_string_t what;
8626 cmd_tunnel_udp_config_parsed(void *parsed_result,
8627 __attribute__((unused)) struct cmdline *cl,
8628 __attribute__((unused)) void *data)
8630 struct cmd_tunnel_udp_config *res = parsed_result;
8631 struct rte_eth_udp_tunnel tunnel_udp;
8634 tunnel_udp.udp_port = res->udp_port;
8636 if (!strcmp(res->cmd, "rx_vxlan_port"))
8637 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8639 if (!strcmp(res->what, "add"))
8640 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8643 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8647 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8650 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8651 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8652 cmd, "rx_vxlan_port");
8653 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8654 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8656 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8657 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8659 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8660 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8663 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8664 .f = cmd_tunnel_udp_config_parsed,
8666 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8667 "Add/Remove a tunneling UDP port filter",
8669 (void *)&cmd_tunnel_udp_config_cmd,
8670 (void *)&cmd_tunnel_udp_config_what,
8671 (void *)&cmd_tunnel_udp_config_udp_port,
8672 (void *)&cmd_tunnel_udp_config_port_id,
8677 struct cmd_config_tunnel_udp_port {
8678 cmdline_fixed_string_t port;
8679 cmdline_fixed_string_t config;
8681 cmdline_fixed_string_t udp_tunnel_port;
8682 cmdline_fixed_string_t action;
8683 cmdline_fixed_string_t tunnel_type;
8688 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8689 __attribute__((unused)) struct cmdline *cl,
8690 __attribute__((unused)) void *data)
8692 struct cmd_config_tunnel_udp_port *res = parsed_result;
8693 struct rte_eth_udp_tunnel tunnel_udp;
8696 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8699 tunnel_udp.udp_port = res->udp_port;
8701 if (!strcmp(res->tunnel_type, "vxlan")) {
8702 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8703 } else if (!strcmp(res->tunnel_type, "geneve")) {
8704 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8706 printf("Invalid tunnel type\n");
8710 if (!strcmp(res->action, "add"))
8711 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8714 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8718 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8721 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8722 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8724 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8725 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8727 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8728 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8730 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8731 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8734 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8735 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8737 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8738 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8740 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8741 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8744 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8745 .f = cmd_cfg_tunnel_udp_port_parsed,
8747 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8749 (void *)&cmd_config_tunnel_udp_port_port,
8750 (void *)&cmd_config_tunnel_udp_port_config,
8751 (void *)&cmd_config_tunnel_udp_port_port_id,
8752 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8753 (void *)&cmd_config_tunnel_udp_port_action,
8754 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8755 (void *)&cmd_config_tunnel_udp_port_value,
8760 /* *** GLOBAL CONFIG *** */
8761 struct cmd_global_config_result {
8762 cmdline_fixed_string_t cmd;
8764 cmdline_fixed_string_t cfg_type;
8769 cmd_global_config_parsed(void *parsed_result,
8770 __attribute__((unused)) struct cmdline *cl,
8771 __attribute__((unused)) void *data)
8773 struct cmd_global_config_result *res = parsed_result;
8774 struct rte_eth_global_cfg conf;
8777 memset(&conf, 0, sizeof(conf));
8778 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8779 conf.cfg.gre_key_len = res->len;
8780 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8781 RTE_ETH_FILTER_SET, &conf);
8783 printf("Global config error\n");
8786 cmdline_parse_token_string_t cmd_global_config_cmd =
8787 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8789 cmdline_parse_token_num_t cmd_global_config_port_id =
8790 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8792 cmdline_parse_token_string_t cmd_global_config_type =
8793 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8794 cfg_type, "gre-key-len");
8795 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8796 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8799 cmdline_parse_inst_t cmd_global_config = {
8800 .f = cmd_global_config_parsed,
8801 .data = (void *)NULL,
8802 .help_str = "global_config <port_id> gre-key-len <key_len>",
8804 (void *)&cmd_global_config_cmd,
8805 (void *)&cmd_global_config_port_id,
8806 (void *)&cmd_global_config_type,
8807 (void *)&cmd_global_config_gre_key_len,
8812 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8813 struct cmd_set_mirror_mask_result {
8814 cmdline_fixed_string_t set;
8815 cmdline_fixed_string_t port;
8817 cmdline_fixed_string_t mirror;
8819 cmdline_fixed_string_t what;
8820 cmdline_fixed_string_t value;
8821 cmdline_fixed_string_t dstpool;
8823 cmdline_fixed_string_t on;
8826 cmdline_parse_token_string_t cmd_mirror_mask_set =
8827 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8829 cmdline_parse_token_string_t cmd_mirror_mask_port =
8830 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8832 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8833 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8835 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8836 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8837 mirror, "mirror-rule");
8838 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8839 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8841 cmdline_parse_token_string_t cmd_mirror_mask_what =
8842 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8843 what, "pool-mirror-up#pool-mirror-down"
8845 cmdline_parse_token_string_t cmd_mirror_mask_value =
8846 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8848 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8849 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8850 dstpool, "dst-pool");
8851 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8852 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8854 cmdline_parse_token_string_t cmd_mirror_mask_on =
8855 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8859 cmd_set_mirror_mask_parsed(void *parsed_result,
8860 __attribute__((unused)) struct cmdline *cl,
8861 __attribute__((unused)) void *data)
8864 struct cmd_set_mirror_mask_result *res = parsed_result;
8865 struct rte_eth_mirror_conf mr_conf;
8867 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8869 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8871 mr_conf.dst_pool = res->dstpool_id;
8873 if (!strcmp(res->what, "pool-mirror-up")) {
8874 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8875 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8876 } else if (!strcmp(res->what, "pool-mirror-down")) {
8877 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8878 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8879 } else if (!strcmp(res->what, "vlan-mirror")) {
8880 mr_conf.rule_type = ETH_MIRROR_VLAN;
8881 nb_item = parse_item_list(res->value, "vlan",
8882 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8886 for (i = 0; i < nb_item; i++) {
8887 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8888 printf("Invalid vlan_id: must be < 4096\n");
8892 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8893 mr_conf.vlan.vlan_mask |= 1ULL << i;
8897 if (!strcmp(res->on, "on"))
8898 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8901 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8904 printf("mirror rule add error: (%s)\n", strerror(-ret));
8907 cmdline_parse_inst_t cmd_set_mirror_mask = {
8908 .f = cmd_set_mirror_mask_parsed,
8910 .help_str = "set port <port_id> mirror-rule <rule_id> "
8911 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8912 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8914 (void *)&cmd_mirror_mask_set,
8915 (void *)&cmd_mirror_mask_port,
8916 (void *)&cmd_mirror_mask_portid,
8917 (void *)&cmd_mirror_mask_mirror,
8918 (void *)&cmd_mirror_mask_ruleid,
8919 (void *)&cmd_mirror_mask_what,
8920 (void *)&cmd_mirror_mask_value,
8921 (void *)&cmd_mirror_mask_dstpool,
8922 (void *)&cmd_mirror_mask_poolid,
8923 (void *)&cmd_mirror_mask_on,
8928 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8929 struct cmd_set_mirror_link_result {
8930 cmdline_fixed_string_t set;
8931 cmdline_fixed_string_t port;
8933 cmdline_fixed_string_t mirror;
8935 cmdline_fixed_string_t what;
8936 cmdline_fixed_string_t dstpool;
8938 cmdline_fixed_string_t on;
8941 cmdline_parse_token_string_t cmd_mirror_link_set =
8942 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8944 cmdline_parse_token_string_t cmd_mirror_link_port =
8945 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8947 cmdline_parse_token_num_t cmd_mirror_link_portid =
8948 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8950 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8951 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8952 mirror, "mirror-rule");
8953 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8954 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8956 cmdline_parse_token_string_t cmd_mirror_link_what =
8957 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8958 what, "uplink-mirror#downlink-mirror");
8959 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8960 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8961 dstpool, "dst-pool");
8962 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8963 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8965 cmdline_parse_token_string_t cmd_mirror_link_on =
8966 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8970 cmd_set_mirror_link_parsed(void *parsed_result,
8971 __attribute__((unused)) struct cmdline *cl,
8972 __attribute__((unused)) void *data)
8975 struct cmd_set_mirror_link_result *res = parsed_result;
8976 struct rte_eth_mirror_conf mr_conf;
8978 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8979 if (!strcmp(res->what, "uplink-mirror"))
8980 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8982 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8984 mr_conf.dst_pool = res->dstpool_id;
8986 if (!strcmp(res->on, "on"))
8987 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8990 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8993 /* check the return value and print it if is < 0 */
8995 printf("mirror rule add error: (%s)\n", strerror(-ret));
8999 cmdline_parse_inst_t cmd_set_mirror_link = {
9000 .f = cmd_set_mirror_link_parsed,
9002 .help_str = "set port <port_id> mirror-rule <rule_id> "
9003 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9005 (void *)&cmd_mirror_link_set,
9006 (void *)&cmd_mirror_link_port,
9007 (void *)&cmd_mirror_link_portid,
9008 (void *)&cmd_mirror_link_mirror,
9009 (void *)&cmd_mirror_link_ruleid,
9010 (void *)&cmd_mirror_link_what,
9011 (void *)&cmd_mirror_link_dstpool,
9012 (void *)&cmd_mirror_link_poolid,
9013 (void *)&cmd_mirror_link_on,
9018 /* *** RESET VM MIRROR RULE *** */
9019 struct cmd_rm_mirror_rule_result {
9020 cmdline_fixed_string_t reset;
9021 cmdline_fixed_string_t port;
9023 cmdline_fixed_string_t mirror;
9027 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9028 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9030 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9031 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9033 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9034 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9036 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9037 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9038 mirror, "mirror-rule");
9039 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9040 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9044 cmd_reset_mirror_rule_parsed(void *parsed_result,
9045 __attribute__((unused)) struct cmdline *cl,
9046 __attribute__((unused)) void *data)
9049 struct cmd_set_mirror_link_result *res = parsed_result;
9051 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9053 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9056 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9057 .f = cmd_reset_mirror_rule_parsed,
9059 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9061 (void *)&cmd_rm_mirror_rule_reset,
9062 (void *)&cmd_rm_mirror_rule_port,
9063 (void *)&cmd_rm_mirror_rule_portid,
9064 (void *)&cmd_rm_mirror_rule_mirror,
9065 (void *)&cmd_rm_mirror_rule_ruleid,
9070 /* ******************************************************************************** */
9072 struct cmd_dump_result {
9073 cmdline_fixed_string_t dump;
9077 dump_struct_sizes(void)
9079 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9080 DUMP_SIZE(struct rte_mbuf);
9081 DUMP_SIZE(struct rte_mempool);
9082 DUMP_SIZE(struct rte_ring);
9086 static void cmd_dump_parsed(void *parsed_result,
9087 __attribute__((unused)) struct cmdline *cl,
9088 __attribute__((unused)) void *data)
9090 struct cmd_dump_result *res = parsed_result;
9092 if (!strcmp(res->dump, "dump_physmem"))
9093 rte_dump_physmem_layout(stdout);
9094 else if (!strcmp(res->dump, "dump_memzone"))
9095 rte_memzone_dump(stdout);
9096 else if (!strcmp(res->dump, "dump_struct_sizes"))
9097 dump_struct_sizes();
9098 else if (!strcmp(res->dump, "dump_ring"))
9099 rte_ring_list_dump(stdout);
9100 else if (!strcmp(res->dump, "dump_mempool"))
9101 rte_mempool_list_dump(stdout);
9102 else if (!strcmp(res->dump, "dump_devargs"))
9103 rte_devargs_dump(stdout);
9104 else if (!strcmp(res->dump, "dump_log_types"))
9105 rte_log_dump(stdout);
9108 cmdline_parse_token_string_t cmd_dump_dump =
9109 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9112 "dump_struct_sizes#"
9118 cmdline_parse_inst_t cmd_dump = {
9119 .f = cmd_dump_parsed, /* function to call */
9120 .data = NULL, /* 2nd arg of func */
9121 .help_str = "Dump status",
9122 .tokens = { /* token list, NULL terminated */
9123 (void *)&cmd_dump_dump,
9128 /* ******************************************************************************** */
9130 struct cmd_dump_one_result {
9131 cmdline_fixed_string_t dump;
9132 cmdline_fixed_string_t name;
9135 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9136 __attribute__((unused)) void *data)
9138 struct cmd_dump_one_result *res = parsed_result;
9140 if (!strcmp(res->dump, "dump_ring")) {
9142 r = rte_ring_lookup(res->name);
9144 cmdline_printf(cl, "Cannot find ring\n");
9147 rte_ring_dump(stdout, r);
9148 } else if (!strcmp(res->dump, "dump_mempool")) {
9149 struct rte_mempool *mp;
9150 mp = rte_mempool_lookup(res->name);
9152 cmdline_printf(cl, "Cannot find mempool\n");
9155 rte_mempool_dump(stdout, mp);
9159 cmdline_parse_token_string_t cmd_dump_one_dump =
9160 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9161 "dump_ring#dump_mempool");
9163 cmdline_parse_token_string_t cmd_dump_one_name =
9164 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9166 cmdline_parse_inst_t cmd_dump_one = {
9167 .f = cmd_dump_one_parsed, /* function to call */
9168 .data = NULL, /* 2nd arg of func */
9169 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9170 .tokens = { /* token list, NULL terminated */
9171 (void *)&cmd_dump_one_dump,
9172 (void *)&cmd_dump_one_name,
9177 /* *** Add/Del syn filter *** */
9178 struct cmd_syn_filter_result {
9179 cmdline_fixed_string_t filter;
9181 cmdline_fixed_string_t ops;
9182 cmdline_fixed_string_t priority;
9183 cmdline_fixed_string_t high;
9184 cmdline_fixed_string_t queue;
9189 cmd_syn_filter_parsed(void *parsed_result,
9190 __attribute__((unused)) struct cmdline *cl,
9191 __attribute__((unused)) void *data)
9193 struct cmd_syn_filter_result *res = parsed_result;
9194 struct rte_eth_syn_filter syn_filter;
9197 ret = rte_eth_dev_filter_supported(res->port_id,
9198 RTE_ETH_FILTER_SYN);
9200 printf("syn filter is not supported on port %u.\n",
9205 memset(&syn_filter, 0, sizeof(syn_filter));
9207 if (!strcmp(res->ops, "add")) {
9208 if (!strcmp(res->high, "high"))
9209 syn_filter.hig_pri = 1;
9211 syn_filter.hig_pri = 0;
9213 syn_filter.queue = res->queue_id;
9214 ret = rte_eth_dev_filter_ctrl(res->port_id,
9219 ret = rte_eth_dev_filter_ctrl(res->port_id,
9221 RTE_ETH_FILTER_DELETE,
9225 printf("syn filter programming error: (%s)\n",
9229 cmdline_parse_token_string_t cmd_syn_filter_filter =
9230 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9231 filter, "syn_filter");
9232 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9233 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9235 cmdline_parse_token_string_t cmd_syn_filter_ops =
9236 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9238 cmdline_parse_token_string_t cmd_syn_filter_priority =
9239 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9240 priority, "priority");
9241 cmdline_parse_token_string_t cmd_syn_filter_high =
9242 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9244 cmdline_parse_token_string_t cmd_syn_filter_queue =
9245 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9247 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9248 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9251 cmdline_parse_inst_t cmd_syn_filter = {
9252 .f = cmd_syn_filter_parsed,
9254 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9255 "<queue_id>: Add/Delete syn filter",
9257 (void *)&cmd_syn_filter_filter,
9258 (void *)&cmd_syn_filter_port_id,
9259 (void *)&cmd_syn_filter_ops,
9260 (void *)&cmd_syn_filter_priority,
9261 (void *)&cmd_syn_filter_high,
9262 (void *)&cmd_syn_filter_queue,
9263 (void *)&cmd_syn_filter_queue_id,
9268 /* *** queue region set *** */
9269 struct cmd_queue_region_result {
9270 cmdline_fixed_string_t set;
9271 cmdline_fixed_string_t port;
9273 cmdline_fixed_string_t cmd;
9274 cmdline_fixed_string_t region;
9276 cmdline_fixed_string_t queue_start_index;
9278 cmdline_fixed_string_t queue_num;
9279 uint8_t queue_num_value;
9283 cmd_queue_region_parsed(void *parsed_result,
9284 __attribute__((unused)) struct cmdline *cl,
9285 __attribute__((unused)) void *data)
9287 struct cmd_queue_region_result *res = parsed_result;
9289 #ifdef RTE_LIBRTE_I40E_PMD
9290 struct rte_pmd_i40e_queue_region_conf region_conf;
9291 enum rte_pmd_i40e_queue_region_op op_type;
9294 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9297 #ifdef RTE_LIBRTE_I40E_PMD
9298 memset(®ion_conf, 0, sizeof(region_conf));
9299 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9300 region_conf.region_id = res->region_id;
9301 region_conf.queue_num = res->queue_num_value;
9302 region_conf.queue_start_index = res->queue_id;
9304 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9305 op_type, ®ion_conf);
9312 printf("function not implemented or supported\n");
9315 printf("queue region config error: (%s)\n", strerror(-ret));
9319 cmdline_parse_token_string_t cmd_queue_region_set =
9320 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9322 cmdline_parse_token_string_t cmd_queue_region_port =
9323 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9324 cmdline_parse_token_num_t cmd_queue_region_port_id =
9325 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9327 cmdline_parse_token_string_t cmd_queue_region_cmd =
9328 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9329 cmd, "queue-region");
9330 cmdline_parse_token_string_t cmd_queue_region_id =
9331 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9332 region, "region_id");
9333 cmdline_parse_token_num_t cmd_queue_region_index =
9334 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9336 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9337 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9338 queue_start_index, "queue_start_index");
9339 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9340 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9342 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9343 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9344 queue_num, "queue_num");
9345 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9346 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9347 queue_num_value, UINT8);
9349 cmdline_parse_inst_t cmd_queue_region = {
9350 .f = cmd_queue_region_parsed,
9352 .help_str = "set port <port_id> queue-region region_id <value> "
9353 "queue_start_index <value> queue_num <value>: Set a queue region",
9355 (void *)&cmd_queue_region_set,
9356 (void *)&cmd_queue_region_port,
9357 (void *)&cmd_queue_region_port_id,
9358 (void *)&cmd_queue_region_cmd,
9359 (void *)&cmd_queue_region_id,
9360 (void *)&cmd_queue_region_index,
9361 (void *)&cmd_queue_region_queue_start_index,
9362 (void *)&cmd_queue_region_queue_id,
9363 (void *)&cmd_queue_region_queue_num,
9364 (void *)&cmd_queue_region_queue_num_value,
9369 /* *** queue region and flowtype set *** */
9370 struct cmd_region_flowtype_result {
9371 cmdline_fixed_string_t set;
9372 cmdline_fixed_string_t port;
9374 cmdline_fixed_string_t cmd;
9375 cmdline_fixed_string_t region;
9377 cmdline_fixed_string_t flowtype;
9378 uint8_t flowtype_id;
9382 cmd_region_flowtype_parsed(void *parsed_result,
9383 __attribute__((unused)) struct cmdline *cl,
9384 __attribute__((unused)) void *data)
9386 struct cmd_region_flowtype_result *res = parsed_result;
9388 #ifdef RTE_LIBRTE_I40E_PMD
9389 struct rte_pmd_i40e_queue_region_conf region_conf;
9390 enum rte_pmd_i40e_queue_region_op op_type;
9393 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9396 #ifdef RTE_LIBRTE_I40E_PMD
9397 memset(®ion_conf, 0, sizeof(region_conf));
9399 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9400 region_conf.region_id = res->region_id;
9401 region_conf.hw_flowtype = res->flowtype_id;
9403 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9404 op_type, ®ion_conf);
9411 printf("function not implemented or supported\n");
9414 printf("region flowtype config error: (%s)\n", strerror(-ret));
9418 cmdline_parse_token_string_t cmd_region_flowtype_set =
9419 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9421 cmdline_parse_token_string_t cmd_region_flowtype_port =
9422 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9424 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9425 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9427 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9428 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9429 cmd, "queue-region");
9430 cmdline_parse_token_string_t cmd_region_flowtype_index =
9431 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9432 region, "region_id");
9433 cmdline_parse_token_num_t cmd_region_flowtype_id =
9434 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9436 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9437 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9438 flowtype, "flowtype");
9439 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9440 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9441 flowtype_id, UINT8);
9442 cmdline_parse_inst_t cmd_region_flowtype = {
9443 .f = cmd_region_flowtype_parsed,
9445 .help_str = "set port <port_id> queue-region region_id <value> "
9446 "flowtype <value>: Set a flowtype region index",
9448 (void *)&cmd_region_flowtype_set,
9449 (void *)&cmd_region_flowtype_port,
9450 (void *)&cmd_region_flowtype_port_index,
9451 (void *)&cmd_region_flowtype_cmd,
9452 (void *)&cmd_region_flowtype_index,
9453 (void *)&cmd_region_flowtype_id,
9454 (void *)&cmd_region_flowtype_flow_index,
9455 (void *)&cmd_region_flowtype_flow_id,
9460 /* *** User Priority (UP) to queue region (region_id) set *** */
9461 struct cmd_user_priority_region_result {
9462 cmdline_fixed_string_t set;
9463 cmdline_fixed_string_t port;
9465 cmdline_fixed_string_t cmd;
9466 cmdline_fixed_string_t user_priority;
9467 uint8_t user_priority_id;
9468 cmdline_fixed_string_t region;
9473 cmd_user_priority_region_parsed(void *parsed_result,
9474 __attribute__((unused)) struct cmdline *cl,
9475 __attribute__((unused)) void *data)
9477 struct cmd_user_priority_region_result *res = parsed_result;
9479 #ifdef RTE_LIBRTE_I40E_PMD
9480 struct rte_pmd_i40e_queue_region_conf region_conf;
9481 enum rte_pmd_i40e_queue_region_op op_type;
9484 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9487 #ifdef RTE_LIBRTE_I40E_PMD
9488 memset(®ion_conf, 0, sizeof(region_conf));
9489 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9490 region_conf.user_priority = res->user_priority_id;
9491 region_conf.region_id = res->region_id;
9493 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9494 op_type, ®ion_conf);
9501 printf("function not implemented or supported\n");
9504 printf("user_priority region config error: (%s)\n",
9509 cmdline_parse_token_string_t cmd_user_priority_region_set =
9510 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9512 cmdline_parse_token_string_t cmd_user_priority_region_port =
9513 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9515 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9516 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9518 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9519 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9520 cmd, "queue-region");
9521 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9522 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9523 user_priority, "UP");
9524 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9525 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9526 user_priority_id, UINT8);
9527 cmdline_parse_token_string_t cmd_user_priority_region_region =
9528 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9529 region, "region_id");
9530 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9531 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9534 cmdline_parse_inst_t cmd_user_priority_region = {
9535 .f = cmd_user_priority_region_parsed,
9537 .help_str = "set port <port_id> queue-region UP <value> "
9538 "region_id <value>: Set the mapping of User Priority (UP) "
9539 "to queue region (region_id) ",
9541 (void *)&cmd_user_priority_region_set,
9542 (void *)&cmd_user_priority_region_port,
9543 (void *)&cmd_user_priority_region_port_index,
9544 (void *)&cmd_user_priority_region_cmd,
9545 (void *)&cmd_user_priority_region_UP,
9546 (void *)&cmd_user_priority_region_UP_id,
9547 (void *)&cmd_user_priority_region_region,
9548 (void *)&cmd_user_priority_region_region_id,
9553 /* *** flush all queue region related configuration *** */
9554 struct cmd_flush_queue_region_result {
9555 cmdline_fixed_string_t set;
9556 cmdline_fixed_string_t port;
9558 cmdline_fixed_string_t cmd;
9559 cmdline_fixed_string_t flush;
9560 cmdline_fixed_string_t what;
9564 cmd_flush_queue_region_parsed(void *parsed_result,
9565 __attribute__((unused)) struct cmdline *cl,
9566 __attribute__((unused)) void *data)
9568 struct cmd_flush_queue_region_result *res = parsed_result;
9570 #ifdef RTE_LIBRTE_I40E_PMD
9571 struct rte_pmd_i40e_queue_region_conf region_conf;
9572 enum rte_pmd_i40e_queue_region_op op_type;
9575 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9578 #ifdef RTE_LIBRTE_I40E_PMD
9579 memset(®ion_conf, 0, sizeof(region_conf));
9581 if (strcmp(res->what, "on") == 0)
9582 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9584 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9586 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9587 op_type, ®ion_conf);
9594 printf("function not implemented or supported\n");
9597 printf("queue region config flush error: (%s)\n",
9602 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9603 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9605 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9606 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9608 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9609 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9611 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9612 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9613 cmd, "queue-region");
9614 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9615 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9617 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9618 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9621 cmdline_parse_inst_t cmd_flush_queue_region = {
9622 .f = cmd_flush_queue_region_parsed,
9624 .help_str = "set port <port_id> queue-region flush on|off"
9625 ": flush all queue region related configuration",
9627 (void *)&cmd_flush_queue_region_set,
9628 (void *)&cmd_flush_queue_region_port,
9629 (void *)&cmd_flush_queue_region_port_index,
9630 (void *)&cmd_flush_queue_region_cmd,
9631 (void *)&cmd_flush_queue_region_flush,
9632 (void *)&cmd_flush_queue_region_what,
9637 /* *** get all queue region related configuration info *** */
9638 struct cmd_show_queue_region_info {
9639 cmdline_fixed_string_t show;
9640 cmdline_fixed_string_t port;
9642 cmdline_fixed_string_t cmd;
9646 cmd_show_queue_region_info_parsed(void *parsed_result,
9647 __attribute__((unused)) struct cmdline *cl,
9648 __attribute__((unused)) void *data)
9650 struct cmd_show_queue_region_info *res = parsed_result;
9652 #ifdef RTE_LIBRTE_I40E_PMD
9653 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9654 enum rte_pmd_i40e_queue_region_op op_type;
9657 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9660 #ifdef RTE_LIBRTE_I40E_PMD
9661 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9663 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9665 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9666 op_type, &rte_pmd_regions);
9668 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9675 printf("function not implemented or supported\n");
9678 printf("queue region config info show error: (%s)\n",
9683 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9684 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9686 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9687 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9689 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9690 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9692 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9693 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9694 cmd, "queue-region");
9696 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9697 .f = cmd_show_queue_region_info_parsed,
9699 .help_str = "show port <port_id> queue-region"
9700 ": show all queue region related configuration info",
9702 (void *)&cmd_show_queue_region_info_get,
9703 (void *)&cmd_show_queue_region_info_port,
9704 (void *)&cmd_show_queue_region_info_port_index,
9705 (void *)&cmd_show_queue_region_info_cmd,
9710 /* *** ADD/REMOVE A 2tuple FILTER *** */
9711 struct cmd_2tuple_filter_result {
9712 cmdline_fixed_string_t filter;
9714 cmdline_fixed_string_t ops;
9715 cmdline_fixed_string_t dst_port;
9716 uint16_t dst_port_value;
9717 cmdline_fixed_string_t protocol;
9718 uint8_t protocol_value;
9719 cmdline_fixed_string_t mask;
9721 cmdline_fixed_string_t tcp_flags;
9722 uint8_t tcp_flags_value;
9723 cmdline_fixed_string_t priority;
9724 uint8_t priority_value;
9725 cmdline_fixed_string_t queue;
9730 cmd_2tuple_filter_parsed(void *parsed_result,
9731 __attribute__((unused)) struct cmdline *cl,
9732 __attribute__((unused)) void *data)
9734 struct rte_eth_ntuple_filter filter;
9735 struct cmd_2tuple_filter_result *res = parsed_result;
9738 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9740 printf("ntuple filter is not supported on port %u.\n",
9745 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9747 filter.flags = RTE_2TUPLE_FLAGS;
9748 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9749 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9750 filter.proto = res->protocol_value;
9751 filter.priority = res->priority_value;
9752 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9753 printf("nonzero tcp_flags is only meaningful"
9754 " when protocol is TCP.\n");
9757 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9758 printf("invalid TCP flags.\n");
9762 if (res->tcp_flags_value != 0) {
9763 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9764 filter.tcp_flags = res->tcp_flags_value;
9767 /* need convert to big endian. */
9768 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9769 filter.queue = res->queue_id;
9771 if (!strcmp(res->ops, "add"))
9772 ret = rte_eth_dev_filter_ctrl(res->port_id,
9773 RTE_ETH_FILTER_NTUPLE,
9777 ret = rte_eth_dev_filter_ctrl(res->port_id,
9778 RTE_ETH_FILTER_NTUPLE,
9779 RTE_ETH_FILTER_DELETE,
9782 printf("2tuple filter programming error: (%s)\n",
9787 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9788 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9789 filter, "2tuple_filter");
9790 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9791 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9793 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9794 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9796 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9797 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9798 dst_port, "dst_port");
9799 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9800 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9801 dst_port_value, UINT16);
9802 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9803 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9804 protocol, "protocol");
9805 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9806 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9807 protocol_value, UINT8);
9808 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9809 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9811 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9812 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9814 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9815 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9816 tcp_flags, "tcp_flags");
9817 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9818 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9819 tcp_flags_value, UINT8);
9820 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9821 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9822 priority, "priority");
9823 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9824 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9825 priority_value, UINT8);
9826 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9827 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9829 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9830 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9833 cmdline_parse_inst_t cmd_2tuple_filter = {
9834 .f = cmd_2tuple_filter_parsed,
9836 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9837 "<value> mask <value> tcp_flags <value> priority <value> queue "
9838 "<queue_id>: Add a 2tuple filter",
9840 (void *)&cmd_2tuple_filter_filter,
9841 (void *)&cmd_2tuple_filter_port_id,
9842 (void *)&cmd_2tuple_filter_ops,
9843 (void *)&cmd_2tuple_filter_dst_port,
9844 (void *)&cmd_2tuple_filter_dst_port_value,
9845 (void *)&cmd_2tuple_filter_protocol,
9846 (void *)&cmd_2tuple_filter_protocol_value,
9847 (void *)&cmd_2tuple_filter_mask,
9848 (void *)&cmd_2tuple_filter_mask_value,
9849 (void *)&cmd_2tuple_filter_tcp_flags,
9850 (void *)&cmd_2tuple_filter_tcp_flags_value,
9851 (void *)&cmd_2tuple_filter_priority,
9852 (void *)&cmd_2tuple_filter_priority_value,
9853 (void *)&cmd_2tuple_filter_queue,
9854 (void *)&cmd_2tuple_filter_queue_id,
9859 /* *** ADD/REMOVE A 5tuple FILTER *** */
9860 struct cmd_5tuple_filter_result {
9861 cmdline_fixed_string_t filter;
9863 cmdline_fixed_string_t ops;
9864 cmdline_fixed_string_t dst_ip;
9865 cmdline_ipaddr_t dst_ip_value;
9866 cmdline_fixed_string_t src_ip;
9867 cmdline_ipaddr_t src_ip_value;
9868 cmdline_fixed_string_t dst_port;
9869 uint16_t dst_port_value;
9870 cmdline_fixed_string_t src_port;
9871 uint16_t src_port_value;
9872 cmdline_fixed_string_t protocol;
9873 uint8_t protocol_value;
9874 cmdline_fixed_string_t mask;
9876 cmdline_fixed_string_t tcp_flags;
9877 uint8_t tcp_flags_value;
9878 cmdline_fixed_string_t priority;
9879 uint8_t priority_value;
9880 cmdline_fixed_string_t queue;
9885 cmd_5tuple_filter_parsed(void *parsed_result,
9886 __attribute__((unused)) struct cmdline *cl,
9887 __attribute__((unused)) void *data)
9889 struct rte_eth_ntuple_filter filter;
9890 struct cmd_5tuple_filter_result *res = parsed_result;
9893 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9895 printf("ntuple filter is not supported on port %u.\n",
9900 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9902 filter.flags = RTE_5TUPLE_FLAGS;
9903 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9904 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9905 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9906 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9907 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9908 filter.proto = res->protocol_value;
9909 filter.priority = res->priority_value;
9910 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9911 printf("nonzero tcp_flags is only meaningful"
9912 " when protocol is TCP.\n");
9915 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9916 printf("invalid TCP flags.\n");
9920 if (res->tcp_flags_value != 0) {
9921 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9922 filter.tcp_flags = res->tcp_flags_value;
9925 if (res->dst_ip_value.family == AF_INET)
9926 /* no need to convert, already big endian. */
9927 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9929 if (filter.dst_ip_mask == 0) {
9930 printf("can not support ipv6 involved compare.\n");
9936 if (res->src_ip_value.family == AF_INET)
9937 /* no need to convert, already big endian. */
9938 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9940 if (filter.src_ip_mask == 0) {
9941 printf("can not support ipv6 involved compare.\n");
9946 /* need convert to big endian. */
9947 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9948 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9949 filter.queue = res->queue_id;
9951 if (!strcmp(res->ops, "add"))
9952 ret = rte_eth_dev_filter_ctrl(res->port_id,
9953 RTE_ETH_FILTER_NTUPLE,
9957 ret = rte_eth_dev_filter_ctrl(res->port_id,
9958 RTE_ETH_FILTER_NTUPLE,
9959 RTE_ETH_FILTER_DELETE,
9962 printf("5tuple filter programming error: (%s)\n",
9966 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9967 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9968 filter, "5tuple_filter");
9969 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9970 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9972 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9973 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9975 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9976 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9978 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9979 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9981 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9982 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9984 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9985 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9987 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9988 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9989 dst_port, "dst_port");
9990 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9991 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9992 dst_port_value, UINT16);
9993 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9994 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9995 src_port, "src_port");
9996 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9997 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9998 src_port_value, UINT16);
9999 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10000 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10001 protocol, "protocol");
10002 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10003 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10004 protocol_value, UINT8);
10005 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10006 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10008 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10009 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10011 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10012 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10013 tcp_flags, "tcp_flags");
10014 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10015 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10016 tcp_flags_value, UINT8);
10017 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10018 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10019 priority, "priority");
10020 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10021 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10022 priority_value, UINT8);
10023 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10024 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10026 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10027 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10030 cmdline_parse_inst_t cmd_5tuple_filter = {
10031 .f = cmd_5tuple_filter_parsed,
10033 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10034 "src_ip <value> dst_port <value> src_port <value> "
10035 "protocol <value> mask <value> tcp_flags <value> "
10036 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10038 (void *)&cmd_5tuple_filter_filter,
10039 (void *)&cmd_5tuple_filter_port_id,
10040 (void *)&cmd_5tuple_filter_ops,
10041 (void *)&cmd_5tuple_filter_dst_ip,
10042 (void *)&cmd_5tuple_filter_dst_ip_value,
10043 (void *)&cmd_5tuple_filter_src_ip,
10044 (void *)&cmd_5tuple_filter_src_ip_value,
10045 (void *)&cmd_5tuple_filter_dst_port,
10046 (void *)&cmd_5tuple_filter_dst_port_value,
10047 (void *)&cmd_5tuple_filter_src_port,
10048 (void *)&cmd_5tuple_filter_src_port_value,
10049 (void *)&cmd_5tuple_filter_protocol,
10050 (void *)&cmd_5tuple_filter_protocol_value,
10051 (void *)&cmd_5tuple_filter_mask,
10052 (void *)&cmd_5tuple_filter_mask_value,
10053 (void *)&cmd_5tuple_filter_tcp_flags,
10054 (void *)&cmd_5tuple_filter_tcp_flags_value,
10055 (void *)&cmd_5tuple_filter_priority,
10056 (void *)&cmd_5tuple_filter_priority_value,
10057 (void *)&cmd_5tuple_filter_queue,
10058 (void *)&cmd_5tuple_filter_queue_id,
10063 /* *** ADD/REMOVE A flex FILTER *** */
10064 struct cmd_flex_filter_result {
10065 cmdline_fixed_string_t filter;
10066 cmdline_fixed_string_t ops;
10068 cmdline_fixed_string_t len;
10070 cmdline_fixed_string_t bytes;
10071 cmdline_fixed_string_t bytes_value;
10072 cmdline_fixed_string_t mask;
10073 cmdline_fixed_string_t mask_value;
10074 cmdline_fixed_string_t priority;
10075 uint8_t priority_value;
10076 cmdline_fixed_string_t queue;
10080 static int xdigit2val(unsigned char c)
10085 else if (isupper(c))
10086 val = c - 'A' + 10;
10088 val = c - 'a' + 10;
10093 cmd_flex_filter_parsed(void *parsed_result,
10094 __attribute__((unused)) struct cmdline *cl,
10095 __attribute__((unused)) void *data)
10098 struct rte_eth_flex_filter filter;
10099 struct cmd_flex_filter_result *res = parsed_result;
10100 char *bytes_ptr, *mask_ptr;
10101 uint16_t len, i, j = 0;
10106 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10107 printf("the len exceed the max length 128\n");
10110 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10111 filter.len = res->len_value;
10112 filter.priority = res->priority_value;
10113 filter.queue = res->queue_id;
10114 bytes_ptr = res->bytes_value;
10115 mask_ptr = res->mask_value;
10117 /* translate bytes string to array. */
10118 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10119 (bytes_ptr[1] == 'X')))
10121 len = strnlen(bytes_ptr, res->len_value * 2);
10122 if (len == 0 || (len % 8 != 0)) {
10123 printf("please check len and bytes input\n");
10126 for (i = 0; i < len; i++) {
10128 if (isxdigit(c) == 0) {
10129 /* invalid characters. */
10130 printf("invalid input\n");
10133 val = xdigit2val(c);
10136 filter.bytes[j] = byte;
10137 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10144 /* translate mask string to uint8_t array. */
10145 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10146 (mask_ptr[1] == 'X')))
10148 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10150 printf("invalid input\n");
10155 for (i = 0; i < len; i++) {
10157 if (isxdigit(c) == 0) {
10158 /* invalid characters. */
10159 printf("invalid input\n");
10162 val = xdigit2val(c);
10165 filter.mask[j] = byte;
10166 printf("mask[%d]:%02x ", j, filter.mask[j]);
10174 if (!strcmp(res->ops, "add"))
10175 ret = rte_eth_dev_filter_ctrl(res->port_id,
10176 RTE_ETH_FILTER_FLEXIBLE,
10177 RTE_ETH_FILTER_ADD,
10180 ret = rte_eth_dev_filter_ctrl(res->port_id,
10181 RTE_ETH_FILTER_FLEXIBLE,
10182 RTE_ETH_FILTER_DELETE,
10186 printf("flex filter setting error: (%s)\n", strerror(-ret));
10189 cmdline_parse_token_string_t cmd_flex_filter_filter =
10190 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10191 filter, "flex_filter");
10192 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10193 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10195 cmdline_parse_token_string_t cmd_flex_filter_ops =
10196 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10198 cmdline_parse_token_string_t cmd_flex_filter_len =
10199 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10201 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10202 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10204 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10205 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10207 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10208 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10209 bytes_value, NULL);
10210 cmdline_parse_token_string_t cmd_flex_filter_mask =
10211 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10213 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10214 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10216 cmdline_parse_token_string_t cmd_flex_filter_priority =
10217 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10218 priority, "priority");
10219 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10220 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10221 priority_value, UINT8);
10222 cmdline_parse_token_string_t cmd_flex_filter_queue =
10223 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10225 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10226 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10228 cmdline_parse_inst_t cmd_flex_filter = {
10229 .f = cmd_flex_filter_parsed,
10231 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10232 "<value> mask <value> priority <value> queue <queue_id>: "
10233 "Add/Del a flex filter",
10235 (void *)&cmd_flex_filter_filter,
10236 (void *)&cmd_flex_filter_port_id,
10237 (void *)&cmd_flex_filter_ops,
10238 (void *)&cmd_flex_filter_len,
10239 (void *)&cmd_flex_filter_len_value,
10240 (void *)&cmd_flex_filter_bytes,
10241 (void *)&cmd_flex_filter_bytes_value,
10242 (void *)&cmd_flex_filter_mask,
10243 (void *)&cmd_flex_filter_mask_value,
10244 (void *)&cmd_flex_filter_priority,
10245 (void *)&cmd_flex_filter_priority_value,
10246 (void *)&cmd_flex_filter_queue,
10247 (void *)&cmd_flex_filter_queue_id,
10252 /* *** Filters Control *** */
10254 /* *** deal with ethertype filter *** */
10255 struct cmd_ethertype_filter_result {
10256 cmdline_fixed_string_t filter;
10258 cmdline_fixed_string_t ops;
10259 cmdline_fixed_string_t mac;
10260 struct ether_addr mac_addr;
10261 cmdline_fixed_string_t ethertype;
10262 uint16_t ethertype_value;
10263 cmdline_fixed_string_t drop;
10264 cmdline_fixed_string_t queue;
10268 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10269 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10270 filter, "ethertype_filter");
10271 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10272 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10274 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10275 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10277 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10278 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10279 mac, "mac_addr#mac_ignr");
10280 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10281 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10283 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10284 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10285 ethertype, "ethertype");
10286 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10287 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10288 ethertype_value, UINT16);
10289 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10290 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10292 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10293 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10295 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10296 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10300 cmd_ethertype_filter_parsed(void *parsed_result,
10301 __attribute__((unused)) struct cmdline *cl,
10302 __attribute__((unused)) void *data)
10304 struct cmd_ethertype_filter_result *res = parsed_result;
10305 struct rte_eth_ethertype_filter filter;
10308 ret = rte_eth_dev_filter_supported(res->port_id,
10309 RTE_ETH_FILTER_ETHERTYPE);
10311 printf("ethertype filter is not supported on port %u.\n",
10316 memset(&filter, 0, sizeof(filter));
10317 if (!strcmp(res->mac, "mac_addr")) {
10318 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10319 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10320 sizeof(struct ether_addr));
10322 if (!strcmp(res->drop, "drop"))
10323 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10324 filter.ether_type = res->ethertype_value;
10325 filter.queue = res->queue_id;
10327 if (!strcmp(res->ops, "add"))
10328 ret = rte_eth_dev_filter_ctrl(res->port_id,
10329 RTE_ETH_FILTER_ETHERTYPE,
10330 RTE_ETH_FILTER_ADD,
10333 ret = rte_eth_dev_filter_ctrl(res->port_id,
10334 RTE_ETH_FILTER_ETHERTYPE,
10335 RTE_ETH_FILTER_DELETE,
10338 printf("ethertype filter programming error: (%s)\n",
10342 cmdline_parse_inst_t cmd_ethertype_filter = {
10343 .f = cmd_ethertype_filter_parsed,
10345 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10346 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10347 "Add or delete an ethertype filter entry",
10349 (void *)&cmd_ethertype_filter_filter,
10350 (void *)&cmd_ethertype_filter_port_id,
10351 (void *)&cmd_ethertype_filter_ops,
10352 (void *)&cmd_ethertype_filter_mac,
10353 (void *)&cmd_ethertype_filter_mac_addr,
10354 (void *)&cmd_ethertype_filter_ethertype,
10355 (void *)&cmd_ethertype_filter_ethertype_value,
10356 (void *)&cmd_ethertype_filter_drop,
10357 (void *)&cmd_ethertype_filter_queue,
10358 (void *)&cmd_ethertype_filter_queue_id,
10363 /* *** deal with flow director filter *** */
10364 struct cmd_flow_director_result {
10365 cmdline_fixed_string_t flow_director_filter;
10367 cmdline_fixed_string_t mode;
10368 cmdline_fixed_string_t mode_value;
10369 cmdline_fixed_string_t ops;
10370 cmdline_fixed_string_t flow;
10371 cmdline_fixed_string_t flow_type;
10372 cmdline_fixed_string_t ether;
10373 uint16_t ether_type;
10374 cmdline_fixed_string_t src;
10375 cmdline_ipaddr_t ip_src;
10377 cmdline_fixed_string_t dst;
10378 cmdline_ipaddr_t ip_dst;
10380 cmdline_fixed_string_t verify_tag;
10381 uint32_t verify_tag_value;
10382 cmdline_fixed_string_t tos;
10384 cmdline_fixed_string_t proto;
10385 uint8_t proto_value;
10386 cmdline_fixed_string_t ttl;
10388 cmdline_fixed_string_t vlan;
10389 uint16_t vlan_value;
10390 cmdline_fixed_string_t flexbytes;
10391 cmdline_fixed_string_t flexbytes_value;
10392 cmdline_fixed_string_t pf_vf;
10393 cmdline_fixed_string_t drop;
10394 cmdline_fixed_string_t queue;
10396 cmdline_fixed_string_t fd_id;
10397 uint32_t fd_id_value;
10398 cmdline_fixed_string_t mac;
10399 struct ether_addr mac_addr;
10400 cmdline_fixed_string_t tunnel;
10401 cmdline_fixed_string_t tunnel_type;
10402 cmdline_fixed_string_t tunnel_id;
10403 uint32_t tunnel_id_value;
10404 cmdline_fixed_string_t packet;
10409 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10412 const char *p, *p0 = q_arg;
10414 unsigned long int_fld;
10415 char *str_fld[max_num];
10420 p = strchr(p0, '(');
10424 p0 = strchr(p, ')');
10429 if (size >= sizeof(s))
10432 snprintf(s, sizeof(s), "%.*s", size, p);
10433 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10434 if (ret < 0 || ret > max_num)
10436 for (i = 0; i < ret; i++) {
10438 int_fld = strtoul(str_fld[i], &end, 0);
10439 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10441 flexbytes[i] = (uint8_t)int_fld;
10447 str2flowtype(char *string)
10450 static const struct {
10453 } flowtype_str[] = {
10454 {"raw", RTE_ETH_FLOW_RAW},
10455 {"ipv4", RTE_ETH_FLOW_IPV4},
10456 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10457 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10458 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10459 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10460 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10461 {"ipv6", RTE_ETH_FLOW_IPV6},
10462 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10463 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10464 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10465 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10466 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10467 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10470 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10471 if (!strcmp(flowtype_str[i].str, string))
10472 return flowtype_str[i].type;
10475 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10476 return (uint16_t)atoi(string);
10478 return RTE_ETH_FLOW_UNKNOWN;
10481 static enum rte_eth_fdir_tunnel_type
10482 str2fdir_tunneltype(char *string)
10486 static const struct {
10488 enum rte_eth_fdir_tunnel_type type;
10489 } tunneltype_str[] = {
10490 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10491 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10494 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10495 if (!strcmp(tunneltype_str[i].str, string))
10496 return tunneltype_str[i].type;
10498 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10501 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10503 if ((ip_addr).family == AF_INET) \
10504 (ip) = (ip_addr).addr.ipv4.s_addr; \
10506 printf("invalid parameter.\n"); \
10511 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10513 if ((ip_addr).family == AF_INET6) \
10514 rte_memcpy(&(ip), \
10515 &((ip_addr).addr.ipv6), \
10516 sizeof(struct in6_addr)); \
10518 printf("invalid parameter.\n"); \
10524 cmd_flow_director_filter_parsed(void *parsed_result,
10525 __attribute__((unused)) struct cmdline *cl,
10526 __attribute__((unused)) void *data)
10528 struct cmd_flow_director_result *res = parsed_result;
10529 struct rte_eth_fdir_filter entry;
10530 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10532 unsigned long vf_id;
10535 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10537 printf("flow director is not supported on port %u.\n",
10541 memset(flexbytes, 0, sizeof(flexbytes));
10542 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10544 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10545 if (strcmp(res->mode_value, "MAC-VLAN")) {
10546 printf("Please set mode to MAC-VLAN.\n");
10549 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10550 if (strcmp(res->mode_value, "Tunnel")) {
10551 printf("Please set mode to Tunnel.\n");
10555 if (!strcmp(res->mode_value, "raw")) {
10556 #ifdef RTE_LIBRTE_I40E_PMD
10557 struct rte_pmd_i40e_flow_type_mapping
10558 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10559 struct rte_pmd_i40e_pkt_template_conf conf;
10560 uint16_t flow_type = str2flowtype(res->flow_type);
10561 uint16_t i, port = res->port_id;
10564 memset(&conf, 0, sizeof(conf));
10566 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10567 printf("Invalid flow type specified.\n");
10570 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10574 if (mapping[flow_type].pctype == 0ULL) {
10575 printf("Invalid flow type specified.\n");
10578 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10579 if (mapping[flow_type].pctype & (1ULL << i)) {
10580 conf.input.pctype = i;
10585 conf.input.packet = open_file(res->filepath,
10586 &conf.input.length);
10587 if (!conf.input.packet)
10589 if (!strcmp(res->drop, "drop"))
10590 conf.action.behavior =
10591 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10593 conf.action.behavior =
10594 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10595 conf.action.report_status =
10596 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10597 conf.action.rx_queue = res->queue_id;
10598 conf.soft_id = res->fd_id_value;
10599 add = strcmp(res->ops, "del") ? 1 : 0;
10600 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10604 printf("flow director config error: (%s)\n",
10606 close_file(conf.input.packet);
10609 } else if (strcmp(res->mode_value, "IP")) {
10610 printf("Please set mode to IP or raw.\n");
10613 entry.input.flow_type = str2flowtype(res->flow_type);
10616 ret = parse_flexbytes(res->flexbytes_value,
10618 RTE_ETH_FDIR_MAX_FLEXLEN);
10620 printf("error: Cannot parse flexbytes input.\n");
10624 switch (entry.input.flow_type) {
10625 case RTE_ETH_FLOW_FRAG_IPV4:
10626 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10627 entry.input.flow.ip4_flow.proto = res->proto_value;
10629 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10630 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10631 IPV4_ADDR_TO_UINT(res->ip_dst,
10632 entry.input.flow.ip4_flow.dst_ip);
10633 IPV4_ADDR_TO_UINT(res->ip_src,
10634 entry.input.flow.ip4_flow.src_ip);
10635 entry.input.flow.ip4_flow.tos = res->tos_value;
10636 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10637 /* need convert to big endian. */
10638 entry.input.flow.udp4_flow.dst_port =
10639 rte_cpu_to_be_16(res->port_dst);
10640 entry.input.flow.udp4_flow.src_port =
10641 rte_cpu_to_be_16(res->port_src);
10643 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10644 IPV4_ADDR_TO_UINT(res->ip_dst,
10645 entry.input.flow.sctp4_flow.ip.dst_ip);
10646 IPV4_ADDR_TO_UINT(res->ip_src,
10647 entry.input.flow.sctp4_flow.ip.src_ip);
10648 entry.input.flow.ip4_flow.tos = res->tos_value;
10649 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10650 /* need convert to big endian. */
10651 entry.input.flow.sctp4_flow.dst_port =
10652 rte_cpu_to_be_16(res->port_dst);
10653 entry.input.flow.sctp4_flow.src_port =
10654 rte_cpu_to_be_16(res->port_src);
10655 entry.input.flow.sctp4_flow.verify_tag =
10656 rte_cpu_to_be_32(res->verify_tag_value);
10658 case RTE_ETH_FLOW_FRAG_IPV6:
10659 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10660 entry.input.flow.ipv6_flow.proto = res->proto_value;
10662 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10663 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10664 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10665 entry.input.flow.ipv6_flow.dst_ip);
10666 IPV6_ADDR_TO_ARRAY(res->ip_src,
10667 entry.input.flow.ipv6_flow.src_ip);
10668 entry.input.flow.ipv6_flow.tc = res->tos_value;
10669 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10670 /* need convert to big endian. */
10671 entry.input.flow.udp6_flow.dst_port =
10672 rte_cpu_to_be_16(res->port_dst);
10673 entry.input.flow.udp6_flow.src_port =
10674 rte_cpu_to_be_16(res->port_src);
10676 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10677 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10678 entry.input.flow.sctp6_flow.ip.dst_ip);
10679 IPV6_ADDR_TO_ARRAY(res->ip_src,
10680 entry.input.flow.sctp6_flow.ip.src_ip);
10681 entry.input.flow.ipv6_flow.tc = res->tos_value;
10682 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10683 /* need convert to big endian. */
10684 entry.input.flow.sctp6_flow.dst_port =
10685 rte_cpu_to_be_16(res->port_dst);
10686 entry.input.flow.sctp6_flow.src_port =
10687 rte_cpu_to_be_16(res->port_src);
10688 entry.input.flow.sctp6_flow.verify_tag =
10689 rte_cpu_to_be_32(res->verify_tag_value);
10691 case RTE_ETH_FLOW_L2_PAYLOAD:
10692 entry.input.flow.l2_flow.ether_type =
10693 rte_cpu_to_be_16(res->ether_type);
10699 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10700 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10702 sizeof(struct ether_addr));
10704 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10705 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10707 sizeof(struct ether_addr));
10708 entry.input.flow.tunnel_flow.tunnel_type =
10709 str2fdir_tunneltype(res->tunnel_type);
10710 entry.input.flow.tunnel_flow.tunnel_id =
10711 rte_cpu_to_be_32(res->tunnel_id_value);
10714 rte_memcpy(entry.input.flow_ext.flexbytes,
10716 RTE_ETH_FDIR_MAX_FLEXLEN);
10718 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10720 entry.action.flex_off = 0; /*use 0 by default */
10721 if (!strcmp(res->drop, "drop"))
10722 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10724 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10726 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10727 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10728 if (!strcmp(res->pf_vf, "pf"))
10729 entry.input.flow_ext.is_vf = 0;
10730 else if (!strncmp(res->pf_vf, "vf", 2)) {
10731 struct rte_eth_dev_info dev_info;
10733 memset(&dev_info, 0, sizeof(dev_info));
10734 rte_eth_dev_info_get(res->port_id, &dev_info);
10736 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10737 if (errno != 0 || *end != '\0' ||
10738 vf_id >= dev_info.max_vfs) {
10739 printf("invalid parameter %s.\n", res->pf_vf);
10742 entry.input.flow_ext.is_vf = 1;
10743 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10745 printf("invalid parameter %s.\n", res->pf_vf);
10750 /* set to report FD ID by default */
10751 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10752 entry.action.rx_queue = res->queue_id;
10753 entry.soft_id = res->fd_id_value;
10754 if (!strcmp(res->ops, "add"))
10755 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10756 RTE_ETH_FILTER_ADD, &entry);
10757 else if (!strcmp(res->ops, "del"))
10758 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10759 RTE_ETH_FILTER_DELETE, &entry);
10761 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10762 RTE_ETH_FILTER_UPDATE, &entry);
10764 printf("flow director programming error: (%s)\n",
10768 cmdline_parse_token_string_t cmd_flow_director_filter =
10769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10770 flow_director_filter, "flow_director_filter");
10771 cmdline_parse_token_num_t cmd_flow_director_port_id =
10772 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10774 cmdline_parse_token_string_t cmd_flow_director_ops =
10775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10776 ops, "add#del#update");
10777 cmdline_parse_token_string_t cmd_flow_director_flow =
10778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10780 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10781 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10783 cmdline_parse_token_string_t cmd_flow_director_ether =
10784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10786 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10787 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10788 ether_type, UINT16);
10789 cmdline_parse_token_string_t cmd_flow_director_src =
10790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10792 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10793 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10795 cmdline_parse_token_num_t cmd_flow_director_port_src =
10796 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10798 cmdline_parse_token_string_t cmd_flow_director_dst =
10799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10801 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10802 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10804 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10805 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10807 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10808 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10809 verify_tag, "verify_tag");
10810 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10811 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10812 verify_tag_value, UINT32);
10813 cmdline_parse_token_string_t cmd_flow_director_tos =
10814 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10816 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10817 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10819 cmdline_parse_token_string_t cmd_flow_director_proto =
10820 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10822 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10823 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10824 proto_value, UINT8);
10825 cmdline_parse_token_string_t cmd_flow_director_ttl =
10826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10828 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10829 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10831 cmdline_parse_token_string_t cmd_flow_director_vlan =
10832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10834 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10835 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10836 vlan_value, UINT16);
10837 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10838 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10839 flexbytes, "flexbytes");
10840 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10841 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10842 flexbytes_value, NULL);
10843 cmdline_parse_token_string_t cmd_flow_director_drop =
10844 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10846 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10847 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10849 cmdline_parse_token_string_t cmd_flow_director_queue =
10850 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10852 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10853 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10855 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10858 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10859 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10860 fd_id_value, UINT32);
10862 cmdline_parse_token_string_t cmd_flow_director_mode =
10863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10865 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10866 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10868 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10870 mode_value, "MAC-VLAN");
10871 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10873 mode_value, "Tunnel");
10874 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10876 mode_value, "raw");
10877 cmdline_parse_token_string_t cmd_flow_director_mac =
10878 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10880 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10881 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10883 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10884 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10886 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10887 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10888 tunnel_type, "NVGRE#VxLAN");
10889 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10890 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10891 tunnel_id, "tunnel-id");
10892 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10893 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10894 tunnel_id_value, UINT32);
10895 cmdline_parse_token_string_t cmd_flow_director_packet =
10896 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10898 cmdline_parse_token_string_t cmd_flow_director_filepath =
10899 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10902 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10903 .f = cmd_flow_director_filter_parsed,
10905 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10906 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10907 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10908 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10909 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10910 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10911 "fd_id <fd_id_value>: "
10912 "Add or delete an ip flow director entry on NIC",
10914 (void *)&cmd_flow_director_filter,
10915 (void *)&cmd_flow_director_port_id,
10916 (void *)&cmd_flow_director_mode,
10917 (void *)&cmd_flow_director_mode_ip,
10918 (void *)&cmd_flow_director_ops,
10919 (void *)&cmd_flow_director_flow,
10920 (void *)&cmd_flow_director_flow_type,
10921 (void *)&cmd_flow_director_src,
10922 (void *)&cmd_flow_director_ip_src,
10923 (void *)&cmd_flow_director_dst,
10924 (void *)&cmd_flow_director_ip_dst,
10925 (void *)&cmd_flow_director_tos,
10926 (void *)&cmd_flow_director_tos_value,
10927 (void *)&cmd_flow_director_proto,
10928 (void *)&cmd_flow_director_proto_value,
10929 (void *)&cmd_flow_director_ttl,
10930 (void *)&cmd_flow_director_ttl_value,
10931 (void *)&cmd_flow_director_vlan,
10932 (void *)&cmd_flow_director_vlan_value,
10933 (void *)&cmd_flow_director_flexbytes,
10934 (void *)&cmd_flow_director_flexbytes_value,
10935 (void *)&cmd_flow_director_drop,
10936 (void *)&cmd_flow_director_pf_vf,
10937 (void *)&cmd_flow_director_queue,
10938 (void *)&cmd_flow_director_queue_id,
10939 (void *)&cmd_flow_director_fd_id,
10940 (void *)&cmd_flow_director_fd_id_value,
10945 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10946 .f = cmd_flow_director_filter_parsed,
10948 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10949 "director entry on NIC",
10951 (void *)&cmd_flow_director_filter,
10952 (void *)&cmd_flow_director_port_id,
10953 (void *)&cmd_flow_director_mode,
10954 (void *)&cmd_flow_director_mode_ip,
10955 (void *)&cmd_flow_director_ops,
10956 (void *)&cmd_flow_director_flow,
10957 (void *)&cmd_flow_director_flow_type,
10958 (void *)&cmd_flow_director_src,
10959 (void *)&cmd_flow_director_ip_src,
10960 (void *)&cmd_flow_director_port_src,
10961 (void *)&cmd_flow_director_dst,
10962 (void *)&cmd_flow_director_ip_dst,
10963 (void *)&cmd_flow_director_port_dst,
10964 (void *)&cmd_flow_director_tos,
10965 (void *)&cmd_flow_director_tos_value,
10966 (void *)&cmd_flow_director_ttl,
10967 (void *)&cmd_flow_director_ttl_value,
10968 (void *)&cmd_flow_director_vlan,
10969 (void *)&cmd_flow_director_vlan_value,
10970 (void *)&cmd_flow_director_flexbytes,
10971 (void *)&cmd_flow_director_flexbytes_value,
10972 (void *)&cmd_flow_director_drop,
10973 (void *)&cmd_flow_director_pf_vf,
10974 (void *)&cmd_flow_director_queue,
10975 (void *)&cmd_flow_director_queue_id,
10976 (void *)&cmd_flow_director_fd_id,
10977 (void *)&cmd_flow_director_fd_id_value,
10982 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10983 .f = cmd_flow_director_filter_parsed,
10985 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10986 "director entry on NIC",
10988 (void *)&cmd_flow_director_filter,
10989 (void *)&cmd_flow_director_port_id,
10990 (void *)&cmd_flow_director_mode,
10991 (void *)&cmd_flow_director_mode_ip,
10992 (void *)&cmd_flow_director_ops,
10993 (void *)&cmd_flow_director_flow,
10994 (void *)&cmd_flow_director_flow_type,
10995 (void *)&cmd_flow_director_src,
10996 (void *)&cmd_flow_director_ip_src,
10997 (void *)&cmd_flow_director_port_src,
10998 (void *)&cmd_flow_director_dst,
10999 (void *)&cmd_flow_director_ip_dst,
11000 (void *)&cmd_flow_director_port_dst,
11001 (void *)&cmd_flow_director_verify_tag,
11002 (void *)&cmd_flow_director_verify_tag_value,
11003 (void *)&cmd_flow_director_tos,
11004 (void *)&cmd_flow_director_tos_value,
11005 (void *)&cmd_flow_director_ttl,
11006 (void *)&cmd_flow_director_ttl_value,
11007 (void *)&cmd_flow_director_vlan,
11008 (void *)&cmd_flow_director_vlan_value,
11009 (void *)&cmd_flow_director_flexbytes,
11010 (void *)&cmd_flow_director_flexbytes_value,
11011 (void *)&cmd_flow_director_drop,
11012 (void *)&cmd_flow_director_pf_vf,
11013 (void *)&cmd_flow_director_queue,
11014 (void *)&cmd_flow_director_queue_id,
11015 (void *)&cmd_flow_director_fd_id,
11016 (void *)&cmd_flow_director_fd_id_value,
11021 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11022 .f = cmd_flow_director_filter_parsed,
11024 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11025 "director entry on NIC",
11027 (void *)&cmd_flow_director_filter,
11028 (void *)&cmd_flow_director_port_id,
11029 (void *)&cmd_flow_director_mode,
11030 (void *)&cmd_flow_director_mode_ip,
11031 (void *)&cmd_flow_director_ops,
11032 (void *)&cmd_flow_director_flow,
11033 (void *)&cmd_flow_director_flow_type,
11034 (void *)&cmd_flow_director_ether,
11035 (void *)&cmd_flow_director_ether_type,
11036 (void *)&cmd_flow_director_flexbytes,
11037 (void *)&cmd_flow_director_flexbytes_value,
11038 (void *)&cmd_flow_director_drop,
11039 (void *)&cmd_flow_director_pf_vf,
11040 (void *)&cmd_flow_director_queue,
11041 (void *)&cmd_flow_director_queue_id,
11042 (void *)&cmd_flow_director_fd_id,
11043 (void *)&cmd_flow_director_fd_id_value,
11048 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11049 .f = cmd_flow_director_filter_parsed,
11051 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11052 "director entry on NIC",
11054 (void *)&cmd_flow_director_filter,
11055 (void *)&cmd_flow_director_port_id,
11056 (void *)&cmd_flow_director_mode,
11057 (void *)&cmd_flow_director_mode_mac_vlan,
11058 (void *)&cmd_flow_director_ops,
11059 (void *)&cmd_flow_director_mac,
11060 (void *)&cmd_flow_director_mac_addr,
11061 (void *)&cmd_flow_director_vlan,
11062 (void *)&cmd_flow_director_vlan_value,
11063 (void *)&cmd_flow_director_flexbytes,
11064 (void *)&cmd_flow_director_flexbytes_value,
11065 (void *)&cmd_flow_director_drop,
11066 (void *)&cmd_flow_director_queue,
11067 (void *)&cmd_flow_director_queue_id,
11068 (void *)&cmd_flow_director_fd_id,
11069 (void *)&cmd_flow_director_fd_id_value,
11074 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11075 .f = cmd_flow_director_filter_parsed,
11077 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11078 "director entry on NIC",
11080 (void *)&cmd_flow_director_filter,
11081 (void *)&cmd_flow_director_port_id,
11082 (void *)&cmd_flow_director_mode,
11083 (void *)&cmd_flow_director_mode_tunnel,
11084 (void *)&cmd_flow_director_ops,
11085 (void *)&cmd_flow_director_mac,
11086 (void *)&cmd_flow_director_mac_addr,
11087 (void *)&cmd_flow_director_vlan,
11088 (void *)&cmd_flow_director_vlan_value,
11089 (void *)&cmd_flow_director_tunnel,
11090 (void *)&cmd_flow_director_tunnel_type,
11091 (void *)&cmd_flow_director_tunnel_id,
11092 (void *)&cmd_flow_director_tunnel_id_value,
11093 (void *)&cmd_flow_director_flexbytes,
11094 (void *)&cmd_flow_director_flexbytes_value,
11095 (void *)&cmd_flow_director_drop,
11096 (void *)&cmd_flow_director_queue,
11097 (void *)&cmd_flow_director_queue_id,
11098 (void *)&cmd_flow_director_fd_id,
11099 (void *)&cmd_flow_director_fd_id_value,
11104 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11105 .f = cmd_flow_director_filter_parsed,
11107 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11108 "director entry on NIC",
11110 (void *)&cmd_flow_director_filter,
11111 (void *)&cmd_flow_director_port_id,
11112 (void *)&cmd_flow_director_mode,
11113 (void *)&cmd_flow_director_mode_raw,
11114 (void *)&cmd_flow_director_ops,
11115 (void *)&cmd_flow_director_flow,
11116 (void *)&cmd_flow_director_flow_type,
11117 (void *)&cmd_flow_director_drop,
11118 (void *)&cmd_flow_director_queue,
11119 (void *)&cmd_flow_director_queue_id,
11120 (void *)&cmd_flow_director_fd_id,
11121 (void *)&cmd_flow_director_fd_id_value,
11122 (void *)&cmd_flow_director_packet,
11123 (void *)&cmd_flow_director_filepath,
11128 struct cmd_flush_flow_director_result {
11129 cmdline_fixed_string_t flush_flow_director;
11133 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11134 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11135 flush_flow_director, "flush_flow_director");
11136 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11137 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11141 cmd_flush_flow_director_parsed(void *parsed_result,
11142 __attribute__((unused)) struct cmdline *cl,
11143 __attribute__((unused)) void *data)
11145 struct cmd_flow_director_result *res = parsed_result;
11148 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11150 printf("flow director is not supported on port %u.\n",
11155 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11156 RTE_ETH_FILTER_FLUSH, NULL);
11158 printf("flow director table flushing error: (%s)\n",
11162 cmdline_parse_inst_t cmd_flush_flow_director = {
11163 .f = cmd_flush_flow_director_parsed,
11165 .help_str = "flush_flow_director <port_id>: "
11166 "Flush all flow director entries of a device on NIC",
11168 (void *)&cmd_flush_flow_director_flush,
11169 (void *)&cmd_flush_flow_director_port_id,
11174 /* *** deal with flow director mask *** */
11175 struct cmd_flow_director_mask_result {
11176 cmdline_fixed_string_t flow_director_mask;
11178 cmdline_fixed_string_t mode;
11179 cmdline_fixed_string_t mode_value;
11180 cmdline_fixed_string_t vlan;
11181 uint16_t vlan_mask;
11182 cmdline_fixed_string_t src_mask;
11183 cmdline_ipaddr_t ipv4_src;
11184 cmdline_ipaddr_t ipv6_src;
11186 cmdline_fixed_string_t dst_mask;
11187 cmdline_ipaddr_t ipv4_dst;
11188 cmdline_ipaddr_t ipv6_dst;
11190 cmdline_fixed_string_t mac;
11191 uint8_t mac_addr_byte_mask;
11192 cmdline_fixed_string_t tunnel_id;
11193 uint32_t tunnel_id_mask;
11194 cmdline_fixed_string_t tunnel_type;
11195 uint8_t tunnel_type_mask;
11199 cmd_flow_director_mask_parsed(void *parsed_result,
11200 __attribute__((unused)) struct cmdline *cl,
11201 __attribute__((unused)) void *data)
11203 struct cmd_flow_director_mask_result *res = parsed_result;
11204 struct rte_eth_fdir_masks *mask;
11205 struct rte_port *port;
11207 port = &ports[res->port_id];
11208 /** Check if the port is not started **/
11209 if (port->port_status != RTE_PORT_STOPPED) {
11210 printf("Please stop port %d first\n", res->port_id);
11214 mask = &port->dev_conf.fdir_conf.mask;
11216 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11217 if (strcmp(res->mode_value, "MAC-VLAN")) {
11218 printf("Please set mode to MAC-VLAN.\n");
11222 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11223 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11224 if (strcmp(res->mode_value, "Tunnel")) {
11225 printf("Please set mode to Tunnel.\n");
11229 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11230 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11231 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11232 mask->tunnel_type_mask = res->tunnel_type_mask;
11234 if (strcmp(res->mode_value, "IP")) {
11235 printf("Please set mode to IP.\n");
11239 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11240 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11241 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11242 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11243 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11244 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11245 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11248 cmd_reconfig_device_queue(res->port_id, 1, 1);
11251 cmdline_parse_token_string_t cmd_flow_director_mask =
11252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11253 flow_director_mask, "flow_director_mask");
11254 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11255 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11257 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11260 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11261 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11262 vlan_mask, UINT16);
11263 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11265 src_mask, "src_mask");
11266 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11267 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11269 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11270 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11272 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11273 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11275 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11277 dst_mask, "dst_mask");
11278 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11279 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11281 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11282 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11284 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11285 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11288 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11291 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11294 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11296 mode_value, "MAC-VLAN");
11297 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11299 mode_value, "Tunnel");
11300 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11301 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11303 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11304 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11305 mac_addr_byte_mask, UINT8);
11306 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11307 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11308 tunnel_type, "tunnel-type");
11309 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11310 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11311 tunnel_type_mask, UINT8);
11312 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11313 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11314 tunnel_id, "tunnel-id");
11315 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11316 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11317 tunnel_id_mask, UINT32);
11319 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11320 .f = cmd_flow_director_mask_parsed,
11322 .help_str = "flow_director_mask ... : "
11323 "Set IP mode flow director's mask on NIC",
11325 (void *)&cmd_flow_director_mask,
11326 (void *)&cmd_flow_director_mask_port_id,
11327 (void *)&cmd_flow_director_mask_mode,
11328 (void *)&cmd_flow_director_mask_mode_ip,
11329 (void *)&cmd_flow_director_mask_vlan,
11330 (void *)&cmd_flow_director_mask_vlan_value,
11331 (void *)&cmd_flow_director_mask_src,
11332 (void *)&cmd_flow_director_mask_ipv4_src,
11333 (void *)&cmd_flow_director_mask_ipv6_src,
11334 (void *)&cmd_flow_director_mask_port_src,
11335 (void *)&cmd_flow_director_mask_dst,
11336 (void *)&cmd_flow_director_mask_ipv4_dst,
11337 (void *)&cmd_flow_director_mask_ipv6_dst,
11338 (void *)&cmd_flow_director_mask_port_dst,
11343 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11344 .f = cmd_flow_director_mask_parsed,
11346 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11347 "flow director's mask on NIC",
11349 (void *)&cmd_flow_director_mask,
11350 (void *)&cmd_flow_director_mask_port_id,
11351 (void *)&cmd_flow_director_mask_mode,
11352 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11353 (void *)&cmd_flow_director_mask_vlan,
11354 (void *)&cmd_flow_director_mask_vlan_value,
11359 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11360 .f = cmd_flow_director_mask_parsed,
11362 .help_str = "flow_director_mask ... : Set tunnel mode "
11363 "flow director's mask on NIC",
11365 (void *)&cmd_flow_director_mask,
11366 (void *)&cmd_flow_director_mask_port_id,
11367 (void *)&cmd_flow_director_mask_mode,
11368 (void *)&cmd_flow_director_mask_mode_tunnel,
11369 (void *)&cmd_flow_director_mask_vlan,
11370 (void *)&cmd_flow_director_mask_vlan_value,
11371 (void *)&cmd_flow_director_mask_mac,
11372 (void *)&cmd_flow_director_mask_mac_value,
11373 (void *)&cmd_flow_director_mask_tunnel_type,
11374 (void *)&cmd_flow_director_mask_tunnel_type_value,
11375 (void *)&cmd_flow_director_mask_tunnel_id,
11376 (void *)&cmd_flow_director_mask_tunnel_id_value,
11381 /* *** deal with flow director mask on flexible payload *** */
11382 struct cmd_flow_director_flex_mask_result {
11383 cmdline_fixed_string_t flow_director_flexmask;
11385 cmdline_fixed_string_t flow;
11386 cmdline_fixed_string_t flow_type;
11387 cmdline_fixed_string_t mask;
11391 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11392 __attribute__((unused)) struct cmdline *cl,
11393 __attribute__((unused)) void *data)
11395 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11396 struct rte_eth_fdir_info fdir_info;
11397 struct rte_eth_fdir_flex_mask flex_mask;
11398 struct rte_port *port;
11399 uint64_t flow_type_mask;
11403 port = &ports[res->port_id];
11404 /** Check if the port is not started **/
11405 if (port->port_status != RTE_PORT_STOPPED) {
11406 printf("Please stop port %d first\n", res->port_id);
11410 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11411 ret = parse_flexbytes(res->mask,
11413 RTE_ETH_FDIR_MAX_FLEXLEN);
11415 printf("error: Cannot parse mask input.\n");
11419 memset(&fdir_info, 0, sizeof(fdir_info));
11420 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11421 RTE_ETH_FILTER_INFO, &fdir_info);
11423 printf("Cannot get FDir filter info\n");
11427 if (!strcmp(res->flow_type, "none")) {
11428 /* means don't specify the flow type */
11429 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11430 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11431 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11432 0, sizeof(struct rte_eth_fdir_flex_mask));
11433 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11434 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11436 sizeof(struct rte_eth_fdir_flex_mask));
11437 cmd_reconfig_device_queue(res->port_id, 1, 1);
11440 flow_type_mask = fdir_info.flow_types_mask[0];
11441 if (!strcmp(res->flow_type, "all")) {
11442 if (!flow_type_mask) {
11443 printf("No flow type supported\n");
11446 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11447 if (flow_type_mask & (1ULL << i)) {
11448 flex_mask.flow_type = i;
11449 fdir_set_flex_mask(res->port_id, &flex_mask);
11452 cmd_reconfig_device_queue(res->port_id, 1, 1);
11455 flex_mask.flow_type = str2flowtype(res->flow_type);
11456 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11457 printf("Flow type %s not supported on port %d\n",
11458 res->flow_type, res->port_id);
11461 fdir_set_flex_mask(res->port_id, &flex_mask);
11462 cmd_reconfig_device_queue(res->port_id, 1, 1);
11465 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11466 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11467 flow_director_flexmask,
11468 "flow_director_flex_mask");
11469 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11470 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11472 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11475 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11476 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11477 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11478 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11479 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11480 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11483 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11484 .f = cmd_flow_director_flex_mask_parsed,
11486 .help_str = "flow_director_flex_mask ... : "
11487 "Set flow director's flex mask on NIC",
11489 (void *)&cmd_flow_director_flexmask,
11490 (void *)&cmd_flow_director_flexmask_port_id,
11491 (void *)&cmd_flow_director_flexmask_flow,
11492 (void *)&cmd_flow_director_flexmask_flow_type,
11493 (void *)&cmd_flow_director_flexmask_mask,
11498 /* *** deal with flow director flexible payload configuration *** */
11499 struct cmd_flow_director_flexpayload_result {
11500 cmdline_fixed_string_t flow_director_flexpayload;
11502 cmdline_fixed_string_t payload_layer;
11503 cmdline_fixed_string_t payload_cfg;
11507 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11510 const char *p, *p0 = q_arg;
11512 unsigned long int_fld;
11513 char *str_fld[max_num];
11518 p = strchr(p0, '(');
11522 p0 = strchr(p, ')');
11527 if (size >= sizeof(s))
11530 snprintf(s, sizeof(s), "%.*s", size, p);
11531 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11532 if (ret < 0 || ret > max_num)
11534 for (i = 0; i < ret; i++) {
11536 int_fld = strtoul(str_fld[i], &end, 0);
11537 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11539 offsets[i] = (uint16_t)int_fld;
11545 cmd_flow_director_flxpld_parsed(void *parsed_result,
11546 __attribute__((unused)) struct cmdline *cl,
11547 __attribute__((unused)) void *data)
11549 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11550 struct rte_eth_flex_payload_cfg flex_cfg;
11551 struct rte_port *port;
11554 port = &ports[res->port_id];
11555 /** Check if the port is not started **/
11556 if (port->port_status != RTE_PORT_STOPPED) {
11557 printf("Please stop port %d first\n", res->port_id);
11561 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11563 if (!strcmp(res->payload_layer, "raw"))
11564 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11565 else if (!strcmp(res->payload_layer, "l2"))
11566 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11567 else if (!strcmp(res->payload_layer, "l3"))
11568 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11569 else if (!strcmp(res->payload_layer, "l4"))
11570 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11572 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11573 RTE_ETH_FDIR_MAX_FLEXLEN);
11575 printf("error: Cannot parse flex payload input.\n");
11579 fdir_set_flex_payload(res->port_id, &flex_cfg);
11580 cmd_reconfig_device_queue(res->port_id, 1, 1);
11583 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11585 flow_director_flexpayload,
11586 "flow_director_flex_payload");
11587 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11588 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11590 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11592 payload_layer, "raw#l2#l3#l4");
11593 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11595 payload_cfg, NULL);
11597 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11598 .f = cmd_flow_director_flxpld_parsed,
11600 .help_str = "flow_director_flexpayload ... : "
11601 "Set flow director's flex payload on NIC",
11603 (void *)&cmd_flow_director_flexpayload,
11604 (void *)&cmd_flow_director_flexpayload_port_id,
11605 (void *)&cmd_flow_director_flexpayload_payload_layer,
11606 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11611 /* Generic flow interface command. */
11612 extern cmdline_parse_inst_t cmd_flow;
11614 /* *** Classification Filters Control *** */
11615 /* *** Get symmetric hash enable per port *** */
11616 struct cmd_get_sym_hash_ena_per_port_result {
11617 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11622 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11623 __rte_unused struct cmdline *cl,
11624 __rte_unused void *data)
11626 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11627 struct rte_eth_hash_filter_info info;
11630 if (rte_eth_dev_filter_supported(res->port_id,
11631 RTE_ETH_FILTER_HASH) < 0) {
11632 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11637 memset(&info, 0, sizeof(info));
11638 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11639 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11640 RTE_ETH_FILTER_GET, &info);
11643 printf("Cannot get symmetric hash enable per port "
11644 "on port %u\n", res->port_id);
11648 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11649 "enabled" : "disabled", res->port_id);
11652 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11653 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11654 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11655 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11656 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11659 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11660 .f = cmd_get_sym_hash_per_port_parsed,
11662 .help_str = "get_sym_hash_ena_per_port <port_id>",
11664 (void *)&cmd_get_sym_hash_ena_per_port_all,
11665 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11670 /* *** Set symmetric hash enable per port *** */
11671 struct cmd_set_sym_hash_ena_per_port_result {
11672 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11673 cmdline_fixed_string_t enable;
11678 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11679 __rte_unused struct cmdline *cl,
11680 __rte_unused void *data)
11682 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11683 struct rte_eth_hash_filter_info info;
11686 if (rte_eth_dev_filter_supported(res->port_id,
11687 RTE_ETH_FILTER_HASH) < 0) {
11688 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11693 memset(&info, 0, sizeof(info));
11694 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11695 if (!strcmp(res->enable, "enable"))
11696 info.info.enable = 1;
11697 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11698 RTE_ETH_FILTER_SET, &info);
11700 printf("Cannot set symmetric hash enable per port on "
11701 "port %u\n", res->port_id);
11704 printf("Symmetric hash has been set to %s on port %u\n",
11705 res->enable, res->port_id);
11708 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11709 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11710 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11711 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11712 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11714 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11715 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11716 enable, "enable#disable");
11718 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11719 .f = cmd_set_sym_hash_per_port_parsed,
11721 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11723 (void *)&cmd_set_sym_hash_ena_per_port_all,
11724 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11725 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11730 /* Get global config of hash function */
11731 struct cmd_get_hash_global_config_result {
11732 cmdline_fixed_string_t get_hash_global_config;
11737 flowtype_to_str(uint16_t ftype)
11743 } ftype_table[] = {
11744 {"ipv4", RTE_ETH_FLOW_IPV4},
11745 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11746 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11747 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11748 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11749 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11750 {"ipv6", RTE_ETH_FLOW_IPV6},
11751 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11752 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11753 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11754 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11755 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11756 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11757 {"port", RTE_ETH_FLOW_PORT},
11758 {"vxlan", RTE_ETH_FLOW_VXLAN},
11759 {"geneve", RTE_ETH_FLOW_GENEVE},
11760 {"nvgre", RTE_ETH_FLOW_NVGRE},
11763 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11764 if (ftype_table[i].ftype == ftype)
11765 return ftype_table[i].str;
11772 cmd_get_hash_global_config_parsed(void *parsed_result,
11773 __rte_unused struct cmdline *cl,
11774 __rte_unused void *data)
11776 struct cmd_get_hash_global_config_result *res = parsed_result;
11777 struct rte_eth_hash_filter_info info;
11778 uint32_t idx, offset;
11783 if (rte_eth_dev_filter_supported(res->port_id,
11784 RTE_ETH_FILTER_HASH) < 0) {
11785 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11790 memset(&info, 0, sizeof(info));
11791 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11792 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11793 RTE_ETH_FILTER_GET, &info);
11795 printf("Cannot get hash global configurations by port %d\n",
11800 switch (info.info.global_conf.hash_func) {
11801 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11802 printf("Hash function is Toeplitz\n");
11804 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11805 printf("Hash function is Simple XOR\n");
11808 printf("Unknown hash function\n");
11812 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11813 idx = i / UINT64_BIT;
11814 offset = i % UINT64_BIT;
11815 if (!(info.info.global_conf.valid_bit_mask[idx] &
11818 str = flowtype_to_str(i);
11821 printf("Symmetric hash is %s globally for flow type %s "
11823 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11824 (1ULL << offset)) ? "enabled" : "disabled"), str,
11829 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11830 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11831 get_hash_global_config, "get_hash_global_config");
11832 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11833 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11836 cmdline_parse_inst_t cmd_get_hash_global_config = {
11837 .f = cmd_get_hash_global_config_parsed,
11839 .help_str = "get_hash_global_config <port_id>",
11841 (void *)&cmd_get_hash_global_config_all,
11842 (void *)&cmd_get_hash_global_config_port_id,
11847 /* Set global config of hash function */
11848 struct cmd_set_hash_global_config_result {
11849 cmdline_fixed_string_t set_hash_global_config;
11851 cmdline_fixed_string_t hash_func;
11852 cmdline_fixed_string_t flow_type;
11853 cmdline_fixed_string_t enable;
11857 cmd_set_hash_global_config_parsed(void *parsed_result,
11858 __rte_unused struct cmdline *cl,
11859 __rte_unused void *data)
11861 struct cmd_set_hash_global_config_result *res = parsed_result;
11862 struct rte_eth_hash_filter_info info;
11863 uint32_t ftype, idx, offset;
11866 if (rte_eth_dev_filter_supported(res->port_id,
11867 RTE_ETH_FILTER_HASH) < 0) {
11868 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11872 memset(&info, 0, sizeof(info));
11873 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11874 if (!strcmp(res->hash_func, "toeplitz"))
11875 info.info.global_conf.hash_func =
11876 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11877 else if (!strcmp(res->hash_func, "simple_xor"))
11878 info.info.global_conf.hash_func =
11879 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11880 else if (!strcmp(res->hash_func, "default"))
11881 info.info.global_conf.hash_func =
11882 RTE_ETH_HASH_FUNCTION_DEFAULT;
11884 ftype = str2flowtype(res->flow_type);
11885 idx = ftype / UINT64_BIT;
11886 offset = ftype % UINT64_BIT;
11887 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11888 if (!strcmp(res->enable, "enable"))
11889 info.info.global_conf.sym_hash_enable_mask[idx] |=
11891 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11892 RTE_ETH_FILTER_SET, &info);
11894 printf("Cannot set global hash configurations by port %d\n",
11897 printf("Global hash configurations have been set "
11898 "succcessfully by port %d\n", res->port_id);
11901 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11902 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11903 set_hash_global_config, "set_hash_global_config");
11904 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11905 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11907 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11908 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11909 hash_func, "toeplitz#simple_xor#default");
11910 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11911 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11913 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11914 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11915 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11916 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11917 enable, "enable#disable");
11919 cmdline_parse_inst_t cmd_set_hash_global_config = {
11920 .f = cmd_set_hash_global_config_parsed,
11922 .help_str = "set_hash_global_config <port_id> "
11923 "toeplitz|simple_xor|default "
11924 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11925 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11926 "l2_payload enable|disable",
11928 (void *)&cmd_set_hash_global_config_all,
11929 (void *)&cmd_set_hash_global_config_port_id,
11930 (void *)&cmd_set_hash_global_config_hash_func,
11931 (void *)&cmd_set_hash_global_config_flow_type,
11932 (void *)&cmd_set_hash_global_config_enable,
11937 /* Set hash input set */
11938 struct cmd_set_hash_input_set_result {
11939 cmdline_fixed_string_t set_hash_input_set;
11941 cmdline_fixed_string_t flow_type;
11942 cmdline_fixed_string_t inset_field;
11943 cmdline_fixed_string_t select;
11946 static enum rte_eth_input_set_field
11947 str2inset(char *string)
11951 static const struct {
11953 enum rte_eth_input_set_field inset;
11954 } inset_table[] = {
11955 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11956 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11957 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11958 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11959 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11960 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11961 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11962 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11963 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11964 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11965 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11966 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11967 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11968 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11969 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11970 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11971 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11972 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11973 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11974 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11975 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11976 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11977 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11978 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11979 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11980 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11981 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11982 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11983 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11984 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11985 {"none", RTE_ETH_INPUT_SET_NONE},
11988 for (i = 0; i < RTE_DIM(inset_table); i++) {
11989 if (!strcmp(string, inset_table[i].str))
11990 return inset_table[i].inset;
11993 return RTE_ETH_INPUT_SET_UNKNOWN;
11997 cmd_set_hash_input_set_parsed(void *parsed_result,
11998 __rte_unused struct cmdline *cl,
11999 __rte_unused void *data)
12001 struct cmd_set_hash_input_set_result *res = parsed_result;
12002 struct rte_eth_hash_filter_info info;
12004 memset(&info, 0, sizeof(info));
12005 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12006 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12007 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12008 info.info.input_set_conf.inset_size = 1;
12009 if (!strcmp(res->select, "select"))
12010 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12011 else if (!strcmp(res->select, "add"))
12012 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12013 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12014 RTE_ETH_FILTER_SET, &info);
12017 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12018 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12019 set_hash_input_set, "set_hash_input_set");
12020 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12021 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12023 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12024 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12026 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12027 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12029 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12030 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12031 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12032 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12033 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12035 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12036 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12037 select, "select#add");
12039 cmdline_parse_inst_t cmd_set_hash_input_set = {
12040 .f = cmd_set_hash_input_set_parsed,
12042 .help_str = "set_hash_input_set <port_id> "
12043 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12044 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12045 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12046 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12047 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12048 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12049 "fld-7th|fld-8th|none select|add",
12051 (void *)&cmd_set_hash_input_set_cmd,
12052 (void *)&cmd_set_hash_input_set_port_id,
12053 (void *)&cmd_set_hash_input_set_flow_type,
12054 (void *)&cmd_set_hash_input_set_field,
12055 (void *)&cmd_set_hash_input_set_select,
12060 /* Set flow director input set */
12061 struct cmd_set_fdir_input_set_result {
12062 cmdline_fixed_string_t set_fdir_input_set;
12064 cmdline_fixed_string_t flow_type;
12065 cmdline_fixed_string_t inset_field;
12066 cmdline_fixed_string_t select;
12070 cmd_set_fdir_input_set_parsed(void *parsed_result,
12071 __rte_unused struct cmdline *cl,
12072 __rte_unused void *data)
12074 struct cmd_set_fdir_input_set_result *res = parsed_result;
12075 struct rte_eth_fdir_filter_info info;
12077 memset(&info, 0, sizeof(info));
12078 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12079 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12080 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12081 info.info.input_set_conf.inset_size = 1;
12082 if (!strcmp(res->select, "select"))
12083 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12084 else if (!strcmp(res->select, "add"))
12085 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12086 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12087 RTE_ETH_FILTER_SET, &info);
12090 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12091 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12092 set_fdir_input_set, "set_fdir_input_set");
12093 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12094 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12096 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12097 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12099 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12100 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12101 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12102 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12104 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12105 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12106 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12107 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12108 "sctp-veri-tag#none");
12109 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12110 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12111 select, "select#add");
12113 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12114 .f = cmd_set_fdir_input_set_parsed,
12116 .help_str = "set_fdir_input_set <port_id> "
12117 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12118 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12119 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12120 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12121 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12122 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12123 "sctp-veri-tag|none select|add",
12125 (void *)&cmd_set_fdir_input_set_cmd,
12126 (void *)&cmd_set_fdir_input_set_port_id,
12127 (void *)&cmd_set_fdir_input_set_flow_type,
12128 (void *)&cmd_set_fdir_input_set_field,
12129 (void *)&cmd_set_fdir_input_set_select,
12134 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12135 struct cmd_mcast_addr_result {
12136 cmdline_fixed_string_t mcast_addr_cmd;
12137 cmdline_fixed_string_t what;
12139 struct ether_addr mc_addr;
12142 static void cmd_mcast_addr_parsed(void *parsed_result,
12143 __attribute__((unused)) struct cmdline *cl,
12144 __attribute__((unused)) void *data)
12146 struct cmd_mcast_addr_result *res = parsed_result;
12148 if (!is_multicast_ether_addr(&res->mc_addr)) {
12149 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12150 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12151 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12152 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12155 if (strcmp(res->what, "add") == 0)
12156 mcast_addr_add(res->port_num, &res->mc_addr);
12158 mcast_addr_remove(res->port_num, &res->mc_addr);
12161 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12162 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12163 mcast_addr_cmd, "mcast_addr");
12164 cmdline_parse_token_string_t cmd_mcast_addr_what =
12165 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12167 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12168 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12169 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12170 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12172 cmdline_parse_inst_t cmd_mcast_addr = {
12173 .f = cmd_mcast_addr_parsed,
12175 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12176 "Add/Remove multicast MAC address on port_id",
12178 (void *)&cmd_mcast_addr_cmd,
12179 (void *)&cmd_mcast_addr_what,
12180 (void *)&cmd_mcast_addr_portnum,
12181 (void *)&cmd_mcast_addr_addr,
12186 /* l2 tunnel config
12187 * only support E-tag now.
12190 /* Ether type config */
12191 struct cmd_config_l2_tunnel_eth_type_result {
12192 cmdline_fixed_string_t port;
12193 cmdline_fixed_string_t config;
12194 cmdline_fixed_string_t all;
12196 cmdline_fixed_string_t l2_tunnel;
12197 cmdline_fixed_string_t l2_tunnel_type;
12198 cmdline_fixed_string_t eth_type;
12199 uint16_t eth_type_val;
12202 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12203 TOKEN_STRING_INITIALIZER
12204 (struct cmd_config_l2_tunnel_eth_type_result,
12206 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12207 TOKEN_STRING_INITIALIZER
12208 (struct cmd_config_l2_tunnel_eth_type_result,
12210 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12211 TOKEN_STRING_INITIALIZER
12212 (struct cmd_config_l2_tunnel_eth_type_result,
12214 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12215 TOKEN_NUM_INITIALIZER
12216 (struct cmd_config_l2_tunnel_eth_type_result,
12218 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12219 TOKEN_STRING_INITIALIZER
12220 (struct cmd_config_l2_tunnel_eth_type_result,
12221 l2_tunnel, "l2-tunnel");
12222 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12223 TOKEN_STRING_INITIALIZER
12224 (struct cmd_config_l2_tunnel_eth_type_result,
12225 l2_tunnel_type, "E-tag");
12226 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12227 TOKEN_STRING_INITIALIZER
12228 (struct cmd_config_l2_tunnel_eth_type_result,
12229 eth_type, "ether-type");
12230 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12231 TOKEN_NUM_INITIALIZER
12232 (struct cmd_config_l2_tunnel_eth_type_result,
12233 eth_type_val, UINT16);
12235 static enum rte_eth_tunnel_type
12236 str2fdir_l2_tunnel_type(char *string)
12240 static const struct {
12242 enum rte_eth_tunnel_type type;
12243 } l2_tunnel_type_str[] = {
12244 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12247 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12248 if (!strcmp(l2_tunnel_type_str[i].str, string))
12249 return l2_tunnel_type_str[i].type;
12251 return RTE_TUNNEL_TYPE_NONE;
12254 /* ether type config for all ports */
12256 cmd_config_l2_tunnel_eth_type_all_parsed
12257 (void *parsed_result,
12258 __attribute__((unused)) struct cmdline *cl,
12259 __attribute__((unused)) void *data)
12261 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12262 struct rte_eth_l2_tunnel_conf entry;
12265 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12266 entry.ether_type = res->eth_type_val;
12268 RTE_ETH_FOREACH_DEV(pid) {
12269 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12273 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12274 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12276 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12278 (void *)&cmd_config_l2_tunnel_eth_type_port,
12279 (void *)&cmd_config_l2_tunnel_eth_type_config,
12280 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12281 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12282 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12283 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12284 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12289 /* ether type config for a specific port */
12291 cmd_config_l2_tunnel_eth_type_specific_parsed(
12292 void *parsed_result,
12293 __attribute__((unused)) struct cmdline *cl,
12294 __attribute__((unused)) void *data)
12296 struct cmd_config_l2_tunnel_eth_type_result *res =
12298 struct rte_eth_l2_tunnel_conf entry;
12300 if (port_id_is_invalid(res->id, ENABLED_WARN))
12303 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12304 entry.ether_type = res->eth_type_val;
12306 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12309 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12310 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12312 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12314 (void *)&cmd_config_l2_tunnel_eth_type_port,
12315 (void *)&cmd_config_l2_tunnel_eth_type_config,
12316 (void *)&cmd_config_l2_tunnel_eth_type_id,
12317 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12318 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12319 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12320 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12325 /* Enable/disable l2 tunnel */
12326 struct cmd_config_l2_tunnel_en_dis_result {
12327 cmdline_fixed_string_t port;
12328 cmdline_fixed_string_t config;
12329 cmdline_fixed_string_t all;
12331 cmdline_fixed_string_t l2_tunnel;
12332 cmdline_fixed_string_t l2_tunnel_type;
12333 cmdline_fixed_string_t en_dis;
12336 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12337 TOKEN_STRING_INITIALIZER
12338 (struct cmd_config_l2_tunnel_en_dis_result,
12340 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12341 TOKEN_STRING_INITIALIZER
12342 (struct cmd_config_l2_tunnel_en_dis_result,
12344 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12345 TOKEN_STRING_INITIALIZER
12346 (struct cmd_config_l2_tunnel_en_dis_result,
12348 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12349 TOKEN_NUM_INITIALIZER
12350 (struct cmd_config_l2_tunnel_en_dis_result,
12352 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12353 TOKEN_STRING_INITIALIZER
12354 (struct cmd_config_l2_tunnel_en_dis_result,
12355 l2_tunnel, "l2-tunnel");
12356 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12357 TOKEN_STRING_INITIALIZER
12358 (struct cmd_config_l2_tunnel_en_dis_result,
12359 l2_tunnel_type, "E-tag");
12360 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12361 TOKEN_STRING_INITIALIZER
12362 (struct cmd_config_l2_tunnel_en_dis_result,
12363 en_dis, "enable#disable");
12365 /* enable/disable l2 tunnel for all ports */
12367 cmd_config_l2_tunnel_en_dis_all_parsed(
12368 void *parsed_result,
12369 __attribute__((unused)) struct cmdline *cl,
12370 __attribute__((unused)) void *data)
12372 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12373 struct rte_eth_l2_tunnel_conf entry;
12377 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12379 if (!strcmp("enable", res->en_dis))
12384 RTE_ETH_FOREACH_DEV(pid) {
12385 rte_eth_dev_l2_tunnel_offload_set(pid,
12387 ETH_L2_TUNNEL_ENABLE_MASK,
12392 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12393 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12395 .help_str = "port config all l2-tunnel E-tag enable|disable",
12397 (void *)&cmd_config_l2_tunnel_en_dis_port,
12398 (void *)&cmd_config_l2_tunnel_en_dis_config,
12399 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12400 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12401 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12402 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12407 /* enable/disable l2 tunnel for a port */
12409 cmd_config_l2_tunnel_en_dis_specific_parsed(
12410 void *parsed_result,
12411 __attribute__((unused)) struct cmdline *cl,
12412 __attribute__((unused)) void *data)
12414 struct cmd_config_l2_tunnel_en_dis_result *res =
12416 struct rte_eth_l2_tunnel_conf entry;
12418 if (port_id_is_invalid(res->id, ENABLED_WARN))
12421 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12423 if (!strcmp("enable", res->en_dis))
12424 rte_eth_dev_l2_tunnel_offload_set(res->id,
12426 ETH_L2_TUNNEL_ENABLE_MASK,
12429 rte_eth_dev_l2_tunnel_offload_set(res->id,
12431 ETH_L2_TUNNEL_ENABLE_MASK,
12435 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12436 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12438 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12440 (void *)&cmd_config_l2_tunnel_en_dis_port,
12441 (void *)&cmd_config_l2_tunnel_en_dis_config,
12442 (void *)&cmd_config_l2_tunnel_en_dis_id,
12443 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12444 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12445 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12450 /* E-tag configuration */
12452 /* Common result structure for all E-tag configuration */
12453 struct cmd_config_e_tag_result {
12454 cmdline_fixed_string_t e_tag;
12455 cmdline_fixed_string_t set;
12456 cmdline_fixed_string_t insertion;
12457 cmdline_fixed_string_t stripping;
12458 cmdline_fixed_string_t forwarding;
12459 cmdline_fixed_string_t filter;
12460 cmdline_fixed_string_t add;
12461 cmdline_fixed_string_t del;
12462 cmdline_fixed_string_t on;
12463 cmdline_fixed_string_t off;
12464 cmdline_fixed_string_t on_off;
12465 cmdline_fixed_string_t port_tag_id;
12466 uint32_t port_tag_id_val;
12467 cmdline_fixed_string_t e_tag_id;
12468 uint16_t e_tag_id_val;
12469 cmdline_fixed_string_t dst_pool;
12470 uint8_t dst_pool_val;
12471 cmdline_fixed_string_t port;
12473 cmdline_fixed_string_t vf;
12477 /* Common CLI fields for all E-tag configuration */
12478 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12479 TOKEN_STRING_INITIALIZER
12480 (struct cmd_config_e_tag_result,
12482 cmdline_parse_token_string_t cmd_config_e_tag_set =
12483 TOKEN_STRING_INITIALIZER
12484 (struct cmd_config_e_tag_result,
12486 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12487 TOKEN_STRING_INITIALIZER
12488 (struct cmd_config_e_tag_result,
12489 insertion, "insertion");
12490 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12491 TOKEN_STRING_INITIALIZER
12492 (struct cmd_config_e_tag_result,
12493 stripping, "stripping");
12494 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12495 TOKEN_STRING_INITIALIZER
12496 (struct cmd_config_e_tag_result,
12497 forwarding, "forwarding");
12498 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12499 TOKEN_STRING_INITIALIZER
12500 (struct cmd_config_e_tag_result,
12502 cmdline_parse_token_string_t cmd_config_e_tag_add =
12503 TOKEN_STRING_INITIALIZER
12504 (struct cmd_config_e_tag_result,
12506 cmdline_parse_token_string_t cmd_config_e_tag_del =
12507 TOKEN_STRING_INITIALIZER
12508 (struct cmd_config_e_tag_result,
12510 cmdline_parse_token_string_t cmd_config_e_tag_on =
12511 TOKEN_STRING_INITIALIZER
12512 (struct cmd_config_e_tag_result,
12514 cmdline_parse_token_string_t cmd_config_e_tag_off =
12515 TOKEN_STRING_INITIALIZER
12516 (struct cmd_config_e_tag_result,
12518 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12519 TOKEN_STRING_INITIALIZER
12520 (struct cmd_config_e_tag_result,
12522 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12523 TOKEN_STRING_INITIALIZER
12524 (struct cmd_config_e_tag_result,
12525 port_tag_id, "port-tag-id");
12526 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12527 TOKEN_NUM_INITIALIZER
12528 (struct cmd_config_e_tag_result,
12529 port_tag_id_val, UINT32);
12530 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12531 TOKEN_STRING_INITIALIZER
12532 (struct cmd_config_e_tag_result,
12533 e_tag_id, "e-tag-id");
12534 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12535 TOKEN_NUM_INITIALIZER
12536 (struct cmd_config_e_tag_result,
12537 e_tag_id_val, UINT16);
12538 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12539 TOKEN_STRING_INITIALIZER
12540 (struct cmd_config_e_tag_result,
12541 dst_pool, "dst-pool");
12542 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12543 TOKEN_NUM_INITIALIZER
12544 (struct cmd_config_e_tag_result,
12545 dst_pool_val, UINT8);
12546 cmdline_parse_token_string_t cmd_config_e_tag_port =
12547 TOKEN_STRING_INITIALIZER
12548 (struct cmd_config_e_tag_result,
12550 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12551 TOKEN_NUM_INITIALIZER
12552 (struct cmd_config_e_tag_result,
12554 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12555 TOKEN_STRING_INITIALIZER
12556 (struct cmd_config_e_tag_result,
12558 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12559 TOKEN_NUM_INITIALIZER
12560 (struct cmd_config_e_tag_result,
12563 /* E-tag insertion configuration */
12565 cmd_config_e_tag_insertion_en_parsed(
12566 void *parsed_result,
12567 __attribute__((unused)) struct cmdline *cl,
12568 __attribute__((unused)) void *data)
12570 struct cmd_config_e_tag_result *res =
12572 struct rte_eth_l2_tunnel_conf entry;
12574 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12577 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12578 entry.tunnel_id = res->port_tag_id_val;
12579 entry.vf_id = res->vf_id;
12580 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12582 ETH_L2_TUNNEL_INSERTION_MASK,
12587 cmd_config_e_tag_insertion_dis_parsed(
12588 void *parsed_result,
12589 __attribute__((unused)) struct cmdline *cl,
12590 __attribute__((unused)) void *data)
12592 struct cmd_config_e_tag_result *res =
12594 struct rte_eth_l2_tunnel_conf entry;
12596 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12599 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12600 entry.vf_id = res->vf_id;
12602 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12604 ETH_L2_TUNNEL_INSERTION_MASK,
12608 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12609 .f = cmd_config_e_tag_insertion_en_parsed,
12611 .help_str = "E-tag ... : E-tag insertion enable",
12613 (void *)&cmd_config_e_tag_e_tag,
12614 (void *)&cmd_config_e_tag_set,
12615 (void *)&cmd_config_e_tag_insertion,
12616 (void *)&cmd_config_e_tag_on,
12617 (void *)&cmd_config_e_tag_port_tag_id,
12618 (void *)&cmd_config_e_tag_port_tag_id_val,
12619 (void *)&cmd_config_e_tag_port,
12620 (void *)&cmd_config_e_tag_port_id,
12621 (void *)&cmd_config_e_tag_vf,
12622 (void *)&cmd_config_e_tag_vf_id,
12627 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12628 .f = cmd_config_e_tag_insertion_dis_parsed,
12630 .help_str = "E-tag ... : E-tag insertion disable",
12632 (void *)&cmd_config_e_tag_e_tag,
12633 (void *)&cmd_config_e_tag_set,
12634 (void *)&cmd_config_e_tag_insertion,
12635 (void *)&cmd_config_e_tag_off,
12636 (void *)&cmd_config_e_tag_port,
12637 (void *)&cmd_config_e_tag_port_id,
12638 (void *)&cmd_config_e_tag_vf,
12639 (void *)&cmd_config_e_tag_vf_id,
12644 /* E-tag stripping configuration */
12646 cmd_config_e_tag_stripping_parsed(
12647 void *parsed_result,
12648 __attribute__((unused)) struct cmdline *cl,
12649 __attribute__((unused)) void *data)
12651 struct cmd_config_e_tag_result *res =
12653 struct rte_eth_l2_tunnel_conf entry;
12655 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12658 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12660 if (!strcmp(res->on_off, "on"))
12661 rte_eth_dev_l2_tunnel_offload_set
12664 ETH_L2_TUNNEL_STRIPPING_MASK,
12667 rte_eth_dev_l2_tunnel_offload_set
12670 ETH_L2_TUNNEL_STRIPPING_MASK,
12674 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12675 .f = cmd_config_e_tag_stripping_parsed,
12677 .help_str = "E-tag ... : E-tag stripping enable/disable",
12679 (void *)&cmd_config_e_tag_e_tag,
12680 (void *)&cmd_config_e_tag_set,
12681 (void *)&cmd_config_e_tag_stripping,
12682 (void *)&cmd_config_e_tag_on_off,
12683 (void *)&cmd_config_e_tag_port,
12684 (void *)&cmd_config_e_tag_port_id,
12689 /* E-tag forwarding configuration */
12691 cmd_config_e_tag_forwarding_parsed(
12692 void *parsed_result,
12693 __attribute__((unused)) struct cmdline *cl,
12694 __attribute__((unused)) void *data)
12696 struct cmd_config_e_tag_result *res = parsed_result;
12697 struct rte_eth_l2_tunnel_conf entry;
12699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12702 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12704 if (!strcmp(res->on_off, "on"))
12705 rte_eth_dev_l2_tunnel_offload_set
12708 ETH_L2_TUNNEL_FORWARDING_MASK,
12711 rte_eth_dev_l2_tunnel_offload_set
12714 ETH_L2_TUNNEL_FORWARDING_MASK,
12718 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12719 .f = cmd_config_e_tag_forwarding_parsed,
12721 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12723 (void *)&cmd_config_e_tag_e_tag,
12724 (void *)&cmd_config_e_tag_set,
12725 (void *)&cmd_config_e_tag_forwarding,
12726 (void *)&cmd_config_e_tag_on_off,
12727 (void *)&cmd_config_e_tag_port,
12728 (void *)&cmd_config_e_tag_port_id,
12733 /* E-tag filter configuration */
12735 cmd_config_e_tag_filter_add_parsed(
12736 void *parsed_result,
12737 __attribute__((unused)) struct cmdline *cl,
12738 __attribute__((unused)) void *data)
12740 struct cmd_config_e_tag_result *res = parsed_result;
12741 struct rte_eth_l2_tunnel_conf entry;
12744 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12747 if (res->e_tag_id_val > 0x3fff) {
12748 printf("e-tag-id must be equal or less than 0x3fff.\n");
12752 ret = rte_eth_dev_filter_supported(res->port_id,
12753 RTE_ETH_FILTER_L2_TUNNEL);
12755 printf("E-tag filter is not supported on port %u.\n",
12760 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12761 entry.tunnel_id = res->e_tag_id_val;
12762 entry.pool = res->dst_pool_val;
12764 ret = rte_eth_dev_filter_ctrl(res->port_id,
12765 RTE_ETH_FILTER_L2_TUNNEL,
12766 RTE_ETH_FILTER_ADD,
12769 printf("E-tag filter programming error: (%s)\n",
12773 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12774 .f = cmd_config_e_tag_filter_add_parsed,
12776 .help_str = "E-tag ... : E-tag filter add",
12778 (void *)&cmd_config_e_tag_e_tag,
12779 (void *)&cmd_config_e_tag_set,
12780 (void *)&cmd_config_e_tag_filter,
12781 (void *)&cmd_config_e_tag_add,
12782 (void *)&cmd_config_e_tag_e_tag_id,
12783 (void *)&cmd_config_e_tag_e_tag_id_val,
12784 (void *)&cmd_config_e_tag_dst_pool,
12785 (void *)&cmd_config_e_tag_dst_pool_val,
12786 (void *)&cmd_config_e_tag_port,
12787 (void *)&cmd_config_e_tag_port_id,
12793 cmd_config_e_tag_filter_del_parsed(
12794 void *parsed_result,
12795 __attribute__((unused)) struct cmdline *cl,
12796 __attribute__((unused)) void *data)
12798 struct cmd_config_e_tag_result *res = parsed_result;
12799 struct rte_eth_l2_tunnel_conf entry;
12802 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12805 if (res->e_tag_id_val > 0x3fff) {
12806 printf("e-tag-id must be less than 0x3fff.\n");
12810 ret = rte_eth_dev_filter_supported(res->port_id,
12811 RTE_ETH_FILTER_L2_TUNNEL);
12813 printf("E-tag filter is not supported on port %u.\n",
12818 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12819 entry.tunnel_id = res->e_tag_id_val;
12821 ret = rte_eth_dev_filter_ctrl(res->port_id,
12822 RTE_ETH_FILTER_L2_TUNNEL,
12823 RTE_ETH_FILTER_DELETE,
12826 printf("E-tag filter programming error: (%s)\n",
12830 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12831 .f = cmd_config_e_tag_filter_del_parsed,
12833 .help_str = "E-tag ... : E-tag filter delete",
12835 (void *)&cmd_config_e_tag_e_tag,
12836 (void *)&cmd_config_e_tag_set,
12837 (void *)&cmd_config_e_tag_filter,
12838 (void *)&cmd_config_e_tag_del,
12839 (void *)&cmd_config_e_tag_e_tag_id,
12840 (void *)&cmd_config_e_tag_e_tag_id_val,
12841 (void *)&cmd_config_e_tag_port,
12842 (void *)&cmd_config_e_tag_port_id,
12847 /* vf vlan anti spoof configuration */
12849 /* Common result structure for vf vlan anti spoof */
12850 struct cmd_vf_vlan_anti_spoof_result {
12851 cmdline_fixed_string_t set;
12852 cmdline_fixed_string_t vf;
12853 cmdline_fixed_string_t vlan;
12854 cmdline_fixed_string_t antispoof;
12857 cmdline_fixed_string_t on_off;
12860 /* Common CLI fields for vf vlan anti spoof enable disable */
12861 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12862 TOKEN_STRING_INITIALIZER
12863 (struct cmd_vf_vlan_anti_spoof_result,
12865 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12866 TOKEN_STRING_INITIALIZER
12867 (struct cmd_vf_vlan_anti_spoof_result,
12869 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12870 TOKEN_STRING_INITIALIZER
12871 (struct cmd_vf_vlan_anti_spoof_result,
12873 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12874 TOKEN_STRING_INITIALIZER
12875 (struct cmd_vf_vlan_anti_spoof_result,
12876 antispoof, "antispoof");
12877 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12878 TOKEN_NUM_INITIALIZER
12879 (struct cmd_vf_vlan_anti_spoof_result,
12881 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12882 TOKEN_NUM_INITIALIZER
12883 (struct cmd_vf_vlan_anti_spoof_result,
12885 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12886 TOKEN_STRING_INITIALIZER
12887 (struct cmd_vf_vlan_anti_spoof_result,
12891 cmd_set_vf_vlan_anti_spoof_parsed(
12892 void *parsed_result,
12893 __attribute__((unused)) struct cmdline *cl,
12894 __attribute__((unused)) void *data)
12896 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12897 int ret = -ENOTSUP;
12899 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12901 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12904 #ifdef RTE_LIBRTE_IXGBE_PMD
12905 if (ret == -ENOTSUP)
12906 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12907 res->vf_id, is_on);
12909 #ifdef RTE_LIBRTE_I40E_PMD
12910 if (ret == -ENOTSUP)
12911 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12912 res->vf_id, is_on);
12914 #ifdef RTE_LIBRTE_BNXT_PMD
12915 if (ret == -ENOTSUP)
12916 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12917 res->vf_id, is_on);
12924 printf("invalid vf_id %d\n", res->vf_id);
12927 printf("invalid port_id %d\n", res->port_id);
12930 printf("function not implemented\n");
12933 printf("programming error: (%s)\n", strerror(-ret));
12937 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12938 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12940 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12942 (void *)&cmd_vf_vlan_anti_spoof_set,
12943 (void *)&cmd_vf_vlan_anti_spoof_vf,
12944 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12945 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12946 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12947 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12948 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12953 /* vf mac anti spoof configuration */
12955 /* Common result structure for vf mac anti spoof */
12956 struct cmd_vf_mac_anti_spoof_result {
12957 cmdline_fixed_string_t set;
12958 cmdline_fixed_string_t vf;
12959 cmdline_fixed_string_t mac;
12960 cmdline_fixed_string_t antispoof;
12963 cmdline_fixed_string_t on_off;
12966 /* Common CLI fields for vf mac anti spoof enable disable */
12967 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12968 TOKEN_STRING_INITIALIZER
12969 (struct cmd_vf_mac_anti_spoof_result,
12971 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12972 TOKEN_STRING_INITIALIZER
12973 (struct cmd_vf_mac_anti_spoof_result,
12975 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12976 TOKEN_STRING_INITIALIZER
12977 (struct cmd_vf_mac_anti_spoof_result,
12979 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12980 TOKEN_STRING_INITIALIZER
12981 (struct cmd_vf_mac_anti_spoof_result,
12982 antispoof, "antispoof");
12983 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12984 TOKEN_NUM_INITIALIZER
12985 (struct cmd_vf_mac_anti_spoof_result,
12987 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12988 TOKEN_NUM_INITIALIZER
12989 (struct cmd_vf_mac_anti_spoof_result,
12991 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12992 TOKEN_STRING_INITIALIZER
12993 (struct cmd_vf_mac_anti_spoof_result,
12997 cmd_set_vf_mac_anti_spoof_parsed(
12998 void *parsed_result,
12999 __attribute__((unused)) struct cmdline *cl,
13000 __attribute__((unused)) void *data)
13002 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13003 int ret = -ENOTSUP;
13005 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13007 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13010 #ifdef RTE_LIBRTE_IXGBE_PMD
13011 if (ret == -ENOTSUP)
13012 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13013 res->vf_id, is_on);
13015 #ifdef RTE_LIBRTE_I40E_PMD
13016 if (ret == -ENOTSUP)
13017 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13018 res->vf_id, is_on);
13020 #ifdef RTE_LIBRTE_BNXT_PMD
13021 if (ret == -ENOTSUP)
13022 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13023 res->vf_id, is_on);
13030 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13033 printf("invalid port_id %d\n", res->port_id);
13036 printf("function not implemented\n");
13039 printf("programming error: (%s)\n", strerror(-ret));
13043 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13044 .f = cmd_set_vf_mac_anti_spoof_parsed,
13046 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13048 (void *)&cmd_vf_mac_anti_spoof_set,
13049 (void *)&cmd_vf_mac_anti_spoof_vf,
13050 (void *)&cmd_vf_mac_anti_spoof_mac,
13051 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13052 (void *)&cmd_vf_mac_anti_spoof_port_id,
13053 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13054 (void *)&cmd_vf_mac_anti_spoof_on_off,
13059 /* vf vlan strip queue configuration */
13061 /* Common result structure for vf mac anti spoof */
13062 struct cmd_vf_vlan_stripq_result {
13063 cmdline_fixed_string_t set;
13064 cmdline_fixed_string_t vf;
13065 cmdline_fixed_string_t vlan;
13066 cmdline_fixed_string_t stripq;
13069 cmdline_fixed_string_t on_off;
13072 /* Common CLI fields for vf vlan strip enable disable */
13073 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13074 TOKEN_STRING_INITIALIZER
13075 (struct cmd_vf_vlan_stripq_result,
13077 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13078 TOKEN_STRING_INITIALIZER
13079 (struct cmd_vf_vlan_stripq_result,
13081 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13082 TOKEN_STRING_INITIALIZER
13083 (struct cmd_vf_vlan_stripq_result,
13085 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13086 TOKEN_STRING_INITIALIZER
13087 (struct cmd_vf_vlan_stripq_result,
13089 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13090 TOKEN_NUM_INITIALIZER
13091 (struct cmd_vf_vlan_stripq_result,
13093 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13094 TOKEN_NUM_INITIALIZER
13095 (struct cmd_vf_vlan_stripq_result,
13097 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13098 TOKEN_STRING_INITIALIZER
13099 (struct cmd_vf_vlan_stripq_result,
13103 cmd_set_vf_vlan_stripq_parsed(
13104 void *parsed_result,
13105 __attribute__((unused)) struct cmdline *cl,
13106 __attribute__((unused)) void *data)
13108 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13109 int ret = -ENOTSUP;
13111 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13113 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13116 #ifdef RTE_LIBRTE_IXGBE_PMD
13117 if (ret == -ENOTSUP)
13118 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13119 res->vf_id, is_on);
13121 #ifdef RTE_LIBRTE_I40E_PMD
13122 if (ret == -ENOTSUP)
13123 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13124 res->vf_id, is_on);
13126 #ifdef RTE_LIBRTE_BNXT_PMD
13127 if (ret == -ENOTSUP)
13128 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13129 res->vf_id, is_on);
13136 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13139 printf("invalid port_id %d\n", res->port_id);
13142 printf("function not implemented\n");
13145 printf("programming error: (%s)\n", strerror(-ret));
13149 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13150 .f = cmd_set_vf_vlan_stripq_parsed,
13152 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13154 (void *)&cmd_vf_vlan_stripq_set,
13155 (void *)&cmd_vf_vlan_stripq_vf,
13156 (void *)&cmd_vf_vlan_stripq_vlan,
13157 (void *)&cmd_vf_vlan_stripq_stripq,
13158 (void *)&cmd_vf_vlan_stripq_port_id,
13159 (void *)&cmd_vf_vlan_stripq_vf_id,
13160 (void *)&cmd_vf_vlan_stripq_on_off,
13165 /* vf vlan insert configuration */
13167 /* Common result structure for vf vlan insert */
13168 struct cmd_vf_vlan_insert_result {
13169 cmdline_fixed_string_t set;
13170 cmdline_fixed_string_t vf;
13171 cmdline_fixed_string_t vlan;
13172 cmdline_fixed_string_t insert;
13178 /* Common CLI fields for vf vlan insert enable disable */
13179 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13180 TOKEN_STRING_INITIALIZER
13181 (struct cmd_vf_vlan_insert_result,
13183 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13184 TOKEN_STRING_INITIALIZER
13185 (struct cmd_vf_vlan_insert_result,
13187 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13188 TOKEN_STRING_INITIALIZER
13189 (struct cmd_vf_vlan_insert_result,
13191 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13192 TOKEN_STRING_INITIALIZER
13193 (struct cmd_vf_vlan_insert_result,
13195 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13196 TOKEN_NUM_INITIALIZER
13197 (struct cmd_vf_vlan_insert_result,
13199 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13200 TOKEN_NUM_INITIALIZER
13201 (struct cmd_vf_vlan_insert_result,
13203 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13204 TOKEN_NUM_INITIALIZER
13205 (struct cmd_vf_vlan_insert_result,
13209 cmd_set_vf_vlan_insert_parsed(
13210 void *parsed_result,
13211 __attribute__((unused)) struct cmdline *cl,
13212 __attribute__((unused)) void *data)
13214 struct cmd_vf_vlan_insert_result *res = parsed_result;
13215 int ret = -ENOTSUP;
13217 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13220 #ifdef RTE_LIBRTE_IXGBE_PMD
13221 if (ret == -ENOTSUP)
13222 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13225 #ifdef RTE_LIBRTE_I40E_PMD
13226 if (ret == -ENOTSUP)
13227 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13230 #ifdef RTE_LIBRTE_BNXT_PMD
13231 if (ret == -ENOTSUP)
13232 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13240 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13243 printf("invalid port_id %d\n", res->port_id);
13246 printf("function not implemented\n");
13249 printf("programming error: (%s)\n", strerror(-ret));
13253 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13254 .f = cmd_set_vf_vlan_insert_parsed,
13256 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13258 (void *)&cmd_vf_vlan_insert_set,
13259 (void *)&cmd_vf_vlan_insert_vf,
13260 (void *)&cmd_vf_vlan_insert_vlan,
13261 (void *)&cmd_vf_vlan_insert_insert,
13262 (void *)&cmd_vf_vlan_insert_port_id,
13263 (void *)&cmd_vf_vlan_insert_vf_id,
13264 (void *)&cmd_vf_vlan_insert_vlan_id,
13269 /* tx loopback configuration */
13271 /* Common result structure for tx loopback */
13272 struct cmd_tx_loopback_result {
13273 cmdline_fixed_string_t set;
13274 cmdline_fixed_string_t tx;
13275 cmdline_fixed_string_t loopback;
13277 cmdline_fixed_string_t on_off;
13280 /* Common CLI fields for tx loopback enable disable */
13281 cmdline_parse_token_string_t cmd_tx_loopback_set =
13282 TOKEN_STRING_INITIALIZER
13283 (struct cmd_tx_loopback_result,
13285 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13286 TOKEN_STRING_INITIALIZER
13287 (struct cmd_tx_loopback_result,
13289 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13290 TOKEN_STRING_INITIALIZER
13291 (struct cmd_tx_loopback_result,
13292 loopback, "loopback");
13293 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13294 TOKEN_NUM_INITIALIZER
13295 (struct cmd_tx_loopback_result,
13297 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13298 TOKEN_STRING_INITIALIZER
13299 (struct cmd_tx_loopback_result,
13303 cmd_set_tx_loopback_parsed(
13304 void *parsed_result,
13305 __attribute__((unused)) struct cmdline *cl,
13306 __attribute__((unused)) void *data)
13308 struct cmd_tx_loopback_result *res = parsed_result;
13309 int ret = -ENOTSUP;
13311 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13313 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13316 #ifdef RTE_LIBRTE_IXGBE_PMD
13317 if (ret == -ENOTSUP)
13318 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13320 #ifdef RTE_LIBRTE_I40E_PMD
13321 if (ret == -ENOTSUP)
13322 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13324 #ifdef RTE_LIBRTE_BNXT_PMD
13325 if (ret == -ENOTSUP)
13326 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13328 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13329 if (ret == -ENOTSUP)
13330 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13337 printf("invalid is_on %d\n", is_on);
13340 printf("invalid port_id %d\n", res->port_id);
13343 printf("function not implemented\n");
13346 printf("programming error: (%s)\n", strerror(-ret));
13350 cmdline_parse_inst_t cmd_set_tx_loopback = {
13351 .f = cmd_set_tx_loopback_parsed,
13353 .help_str = "set tx loopback <port_id> on|off",
13355 (void *)&cmd_tx_loopback_set,
13356 (void *)&cmd_tx_loopback_tx,
13357 (void *)&cmd_tx_loopback_loopback,
13358 (void *)&cmd_tx_loopback_port_id,
13359 (void *)&cmd_tx_loopback_on_off,
13364 /* all queues drop enable configuration */
13366 /* Common result structure for all queues drop enable */
13367 struct cmd_all_queues_drop_en_result {
13368 cmdline_fixed_string_t set;
13369 cmdline_fixed_string_t all;
13370 cmdline_fixed_string_t queues;
13371 cmdline_fixed_string_t drop;
13373 cmdline_fixed_string_t on_off;
13376 /* Common CLI fields for tx loopback enable disable */
13377 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13378 TOKEN_STRING_INITIALIZER
13379 (struct cmd_all_queues_drop_en_result,
13381 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13382 TOKEN_STRING_INITIALIZER
13383 (struct cmd_all_queues_drop_en_result,
13385 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13386 TOKEN_STRING_INITIALIZER
13387 (struct cmd_all_queues_drop_en_result,
13389 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13390 TOKEN_STRING_INITIALIZER
13391 (struct cmd_all_queues_drop_en_result,
13393 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13394 TOKEN_NUM_INITIALIZER
13395 (struct cmd_all_queues_drop_en_result,
13397 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13398 TOKEN_STRING_INITIALIZER
13399 (struct cmd_all_queues_drop_en_result,
13403 cmd_set_all_queues_drop_en_parsed(
13404 void *parsed_result,
13405 __attribute__((unused)) struct cmdline *cl,
13406 __attribute__((unused)) void *data)
13408 struct cmd_all_queues_drop_en_result *res = parsed_result;
13409 int ret = -ENOTSUP;
13410 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13412 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13415 #ifdef RTE_LIBRTE_IXGBE_PMD
13416 if (ret == -ENOTSUP)
13417 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13419 #ifdef RTE_LIBRTE_BNXT_PMD
13420 if (ret == -ENOTSUP)
13421 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13427 printf("invalid is_on %d\n", is_on);
13430 printf("invalid port_id %d\n", res->port_id);
13433 printf("function not implemented\n");
13436 printf("programming error: (%s)\n", strerror(-ret));
13440 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13441 .f = cmd_set_all_queues_drop_en_parsed,
13443 .help_str = "set all queues drop <port_id> on|off",
13445 (void *)&cmd_all_queues_drop_en_set,
13446 (void *)&cmd_all_queues_drop_en_all,
13447 (void *)&cmd_all_queues_drop_en_queues,
13448 (void *)&cmd_all_queues_drop_en_drop,
13449 (void *)&cmd_all_queues_drop_en_port_id,
13450 (void *)&cmd_all_queues_drop_en_on_off,
13455 /* vf split drop enable configuration */
13457 /* Common result structure for vf split drop enable */
13458 struct cmd_vf_split_drop_en_result {
13459 cmdline_fixed_string_t set;
13460 cmdline_fixed_string_t vf;
13461 cmdline_fixed_string_t split;
13462 cmdline_fixed_string_t drop;
13465 cmdline_fixed_string_t on_off;
13468 /* Common CLI fields for vf split drop enable disable */
13469 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13470 TOKEN_STRING_INITIALIZER
13471 (struct cmd_vf_split_drop_en_result,
13473 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13474 TOKEN_STRING_INITIALIZER
13475 (struct cmd_vf_split_drop_en_result,
13477 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13478 TOKEN_STRING_INITIALIZER
13479 (struct cmd_vf_split_drop_en_result,
13481 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13482 TOKEN_STRING_INITIALIZER
13483 (struct cmd_vf_split_drop_en_result,
13485 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13486 TOKEN_NUM_INITIALIZER
13487 (struct cmd_vf_split_drop_en_result,
13489 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13490 TOKEN_NUM_INITIALIZER
13491 (struct cmd_vf_split_drop_en_result,
13493 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13494 TOKEN_STRING_INITIALIZER
13495 (struct cmd_vf_split_drop_en_result,
13499 cmd_set_vf_split_drop_en_parsed(
13500 void *parsed_result,
13501 __attribute__((unused)) struct cmdline *cl,
13502 __attribute__((unused)) void *data)
13504 struct cmd_vf_split_drop_en_result *res = parsed_result;
13505 int ret = -ENOTSUP;
13506 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13508 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13511 #ifdef RTE_LIBRTE_IXGBE_PMD
13512 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13519 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13522 printf("invalid port_id %d\n", res->port_id);
13525 printf("not supported on port %d\n", res->port_id);
13528 printf("programming error: (%s)\n", strerror(-ret));
13532 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13533 .f = cmd_set_vf_split_drop_en_parsed,
13535 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13537 (void *)&cmd_vf_split_drop_en_set,
13538 (void *)&cmd_vf_split_drop_en_vf,
13539 (void *)&cmd_vf_split_drop_en_split,
13540 (void *)&cmd_vf_split_drop_en_drop,
13541 (void *)&cmd_vf_split_drop_en_port_id,
13542 (void *)&cmd_vf_split_drop_en_vf_id,
13543 (void *)&cmd_vf_split_drop_en_on_off,
13548 /* vf mac address configuration */
13550 /* Common result structure for vf mac address */
13551 struct cmd_set_vf_mac_addr_result {
13552 cmdline_fixed_string_t set;
13553 cmdline_fixed_string_t vf;
13554 cmdline_fixed_string_t mac;
13555 cmdline_fixed_string_t addr;
13558 struct ether_addr mac_addr;
13562 /* Common CLI fields for vf split drop enable disable */
13563 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13564 TOKEN_STRING_INITIALIZER
13565 (struct cmd_set_vf_mac_addr_result,
13567 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13568 TOKEN_STRING_INITIALIZER
13569 (struct cmd_set_vf_mac_addr_result,
13571 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13572 TOKEN_STRING_INITIALIZER
13573 (struct cmd_set_vf_mac_addr_result,
13575 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13576 TOKEN_STRING_INITIALIZER
13577 (struct cmd_set_vf_mac_addr_result,
13579 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13580 TOKEN_NUM_INITIALIZER
13581 (struct cmd_set_vf_mac_addr_result,
13583 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13584 TOKEN_NUM_INITIALIZER
13585 (struct cmd_set_vf_mac_addr_result,
13587 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13588 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13592 cmd_set_vf_mac_addr_parsed(
13593 void *parsed_result,
13594 __attribute__((unused)) struct cmdline *cl,
13595 __attribute__((unused)) void *data)
13597 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13598 int ret = -ENOTSUP;
13600 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13603 #ifdef RTE_LIBRTE_IXGBE_PMD
13604 if (ret == -ENOTSUP)
13605 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13608 #ifdef RTE_LIBRTE_I40E_PMD
13609 if (ret == -ENOTSUP)
13610 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13613 #ifdef RTE_LIBRTE_BNXT_PMD
13614 if (ret == -ENOTSUP)
13615 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13623 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13626 printf("invalid port_id %d\n", res->port_id);
13629 printf("function not implemented\n");
13632 printf("programming error: (%s)\n", strerror(-ret));
13636 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13637 .f = cmd_set_vf_mac_addr_parsed,
13639 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13641 (void *)&cmd_set_vf_mac_addr_set,
13642 (void *)&cmd_set_vf_mac_addr_vf,
13643 (void *)&cmd_set_vf_mac_addr_mac,
13644 (void *)&cmd_set_vf_mac_addr_addr,
13645 (void *)&cmd_set_vf_mac_addr_port_id,
13646 (void *)&cmd_set_vf_mac_addr_vf_id,
13647 (void *)&cmd_set_vf_mac_addr_mac_addr,
13652 /* MACsec configuration */
13654 /* Common result structure for MACsec offload enable */
13655 struct cmd_macsec_offload_on_result {
13656 cmdline_fixed_string_t set;
13657 cmdline_fixed_string_t macsec;
13658 cmdline_fixed_string_t offload;
13660 cmdline_fixed_string_t on;
13661 cmdline_fixed_string_t encrypt;
13662 cmdline_fixed_string_t en_on_off;
13663 cmdline_fixed_string_t replay_protect;
13664 cmdline_fixed_string_t rp_on_off;
13667 /* Common CLI fields for MACsec offload disable */
13668 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13669 TOKEN_STRING_INITIALIZER
13670 (struct cmd_macsec_offload_on_result,
13672 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13673 TOKEN_STRING_INITIALIZER
13674 (struct cmd_macsec_offload_on_result,
13676 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13677 TOKEN_STRING_INITIALIZER
13678 (struct cmd_macsec_offload_on_result,
13679 offload, "offload");
13680 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13681 TOKEN_NUM_INITIALIZER
13682 (struct cmd_macsec_offload_on_result,
13684 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13685 TOKEN_STRING_INITIALIZER
13686 (struct cmd_macsec_offload_on_result,
13688 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13689 TOKEN_STRING_INITIALIZER
13690 (struct cmd_macsec_offload_on_result,
13691 encrypt, "encrypt");
13692 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13693 TOKEN_STRING_INITIALIZER
13694 (struct cmd_macsec_offload_on_result,
13695 en_on_off, "on#off");
13696 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13697 TOKEN_STRING_INITIALIZER
13698 (struct cmd_macsec_offload_on_result,
13699 replay_protect, "replay-protect");
13700 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13701 TOKEN_STRING_INITIALIZER
13702 (struct cmd_macsec_offload_on_result,
13703 rp_on_off, "on#off");
13706 cmd_set_macsec_offload_on_parsed(
13707 void *parsed_result,
13708 __attribute__((unused)) struct cmdline *cl,
13709 __attribute__((unused)) void *data)
13711 struct cmd_macsec_offload_on_result *res = parsed_result;
13712 int ret = -ENOTSUP;
13713 portid_t port_id = res->port_id;
13714 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13715 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13716 struct rte_eth_dev_info dev_info;
13718 if (port_id_is_invalid(port_id, ENABLED_WARN))
13720 if (!port_is_stopped(port_id)) {
13721 printf("Please stop port %d first\n", port_id);
13725 rte_eth_dev_info_get(port_id, &dev_info);
13726 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13727 #ifdef RTE_LIBRTE_IXGBE_PMD
13728 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13736 ports[port_id].dev_conf.txmode.offloads |=
13737 DEV_TX_OFFLOAD_MACSEC_INSERT;
13738 cmd_reconfig_device_queue(port_id, 1, 1);
13741 printf("invalid port_id %d\n", port_id);
13744 printf("not supported on port %d\n", port_id);
13747 printf("programming error: (%s)\n", strerror(-ret));
13751 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13752 .f = cmd_set_macsec_offload_on_parsed,
13754 .help_str = "set macsec offload <port_id> on "
13755 "encrypt on|off replay-protect on|off",
13757 (void *)&cmd_macsec_offload_on_set,
13758 (void *)&cmd_macsec_offload_on_macsec,
13759 (void *)&cmd_macsec_offload_on_offload,
13760 (void *)&cmd_macsec_offload_on_port_id,
13761 (void *)&cmd_macsec_offload_on_on,
13762 (void *)&cmd_macsec_offload_on_encrypt,
13763 (void *)&cmd_macsec_offload_on_en_on_off,
13764 (void *)&cmd_macsec_offload_on_replay_protect,
13765 (void *)&cmd_macsec_offload_on_rp_on_off,
13770 /* Common result structure for MACsec offload disable */
13771 struct cmd_macsec_offload_off_result {
13772 cmdline_fixed_string_t set;
13773 cmdline_fixed_string_t macsec;
13774 cmdline_fixed_string_t offload;
13776 cmdline_fixed_string_t off;
13779 /* Common CLI fields for MACsec offload disable */
13780 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13781 TOKEN_STRING_INITIALIZER
13782 (struct cmd_macsec_offload_off_result,
13784 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13785 TOKEN_STRING_INITIALIZER
13786 (struct cmd_macsec_offload_off_result,
13788 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13789 TOKEN_STRING_INITIALIZER
13790 (struct cmd_macsec_offload_off_result,
13791 offload, "offload");
13792 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13793 TOKEN_NUM_INITIALIZER
13794 (struct cmd_macsec_offload_off_result,
13796 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13797 TOKEN_STRING_INITIALIZER
13798 (struct cmd_macsec_offload_off_result,
13802 cmd_set_macsec_offload_off_parsed(
13803 void *parsed_result,
13804 __attribute__((unused)) struct cmdline *cl,
13805 __attribute__((unused)) void *data)
13807 struct cmd_macsec_offload_off_result *res = parsed_result;
13808 int ret = -ENOTSUP;
13809 struct rte_eth_dev_info dev_info;
13810 portid_t port_id = res->port_id;
13812 if (port_id_is_invalid(port_id, ENABLED_WARN))
13814 if (!port_is_stopped(port_id)) {
13815 printf("Please stop port %d first\n", port_id);
13819 rte_eth_dev_info_get(port_id, &dev_info);
13820 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13821 #ifdef RTE_LIBRTE_IXGBE_PMD
13822 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13827 ports[port_id].dev_conf.txmode.offloads &=
13828 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13829 cmd_reconfig_device_queue(port_id, 1, 1);
13832 printf("invalid port_id %d\n", port_id);
13835 printf("not supported on port %d\n", port_id);
13838 printf("programming error: (%s)\n", strerror(-ret));
13842 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13843 .f = cmd_set_macsec_offload_off_parsed,
13845 .help_str = "set macsec offload <port_id> off",
13847 (void *)&cmd_macsec_offload_off_set,
13848 (void *)&cmd_macsec_offload_off_macsec,
13849 (void *)&cmd_macsec_offload_off_offload,
13850 (void *)&cmd_macsec_offload_off_port_id,
13851 (void *)&cmd_macsec_offload_off_off,
13856 /* Common result structure for MACsec secure connection configure */
13857 struct cmd_macsec_sc_result {
13858 cmdline_fixed_string_t set;
13859 cmdline_fixed_string_t macsec;
13860 cmdline_fixed_string_t sc;
13861 cmdline_fixed_string_t tx_rx;
13863 struct ether_addr mac;
13867 /* Common CLI fields for MACsec secure connection configure */
13868 cmdline_parse_token_string_t cmd_macsec_sc_set =
13869 TOKEN_STRING_INITIALIZER
13870 (struct cmd_macsec_sc_result,
13872 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13873 TOKEN_STRING_INITIALIZER
13874 (struct cmd_macsec_sc_result,
13876 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13877 TOKEN_STRING_INITIALIZER
13878 (struct cmd_macsec_sc_result,
13880 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13881 TOKEN_STRING_INITIALIZER
13882 (struct cmd_macsec_sc_result,
13884 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13885 TOKEN_NUM_INITIALIZER
13886 (struct cmd_macsec_sc_result,
13888 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13889 TOKEN_ETHERADDR_INITIALIZER
13890 (struct cmd_macsec_sc_result,
13892 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13893 TOKEN_NUM_INITIALIZER
13894 (struct cmd_macsec_sc_result,
13898 cmd_set_macsec_sc_parsed(
13899 void *parsed_result,
13900 __attribute__((unused)) struct cmdline *cl,
13901 __attribute__((unused)) void *data)
13903 struct cmd_macsec_sc_result *res = parsed_result;
13904 int ret = -ENOTSUP;
13905 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13907 #ifdef RTE_LIBRTE_IXGBE_PMD
13909 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13910 res->mac.addr_bytes) :
13911 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13912 res->mac.addr_bytes, res->pi);
13914 RTE_SET_USED(is_tx);
13920 printf("invalid port_id %d\n", res->port_id);
13923 printf("not supported on port %d\n", res->port_id);
13926 printf("programming error: (%s)\n", strerror(-ret));
13930 cmdline_parse_inst_t cmd_set_macsec_sc = {
13931 .f = cmd_set_macsec_sc_parsed,
13933 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13935 (void *)&cmd_macsec_sc_set,
13936 (void *)&cmd_macsec_sc_macsec,
13937 (void *)&cmd_macsec_sc_sc,
13938 (void *)&cmd_macsec_sc_tx_rx,
13939 (void *)&cmd_macsec_sc_port_id,
13940 (void *)&cmd_macsec_sc_mac,
13941 (void *)&cmd_macsec_sc_pi,
13946 /* Common result structure for MACsec secure connection configure */
13947 struct cmd_macsec_sa_result {
13948 cmdline_fixed_string_t set;
13949 cmdline_fixed_string_t macsec;
13950 cmdline_fixed_string_t sa;
13951 cmdline_fixed_string_t tx_rx;
13956 cmdline_fixed_string_t key;
13959 /* Common CLI fields for MACsec secure connection configure */
13960 cmdline_parse_token_string_t cmd_macsec_sa_set =
13961 TOKEN_STRING_INITIALIZER
13962 (struct cmd_macsec_sa_result,
13964 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_macsec_sa_result,
13968 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13969 TOKEN_STRING_INITIALIZER
13970 (struct cmd_macsec_sa_result,
13972 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13973 TOKEN_STRING_INITIALIZER
13974 (struct cmd_macsec_sa_result,
13976 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13977 TOKEN_NUM_INITIALIZER
13978 (struct cmd_macsec_sa_result,
13980 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13981 TOKEN_NUM_INITIALIZER
13982 (struct cmd_macsec_sa_result,
13984 cmdline_parse_token_num_t cmd_macsec_sa_an =
13985 TOKEN_NUM_INITIALIZER
13986 (struct cmd_macsec_sa_result,
13988 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13989 TOKEN_NUM_INITIALIZER
13990 (struct cmd_macsec_sa_result,
13992 cmdline_parse_token_string_t cmd_macsec_sa_key =
13993 TOKEN_STRING_INITIALIZER
13994 (struct cmd_macsec_sa_result,
13998 cmd_set_macsec_sa_parsed(
13999 void *parsed_result,
14000 __attribute__((unused)) struct cmdline *cl,
14001 __attribute__((unused)) void *data)
14003 struct cmd_macsec_sa_result *res = parsed_result;
14004 int ret = -ENOTSUP;
14005 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14006 uint8_t key[16] = { 0 };
14012 key_len = strlen(res->key) / 2;
14016 for (i = 0; i < key_len; i++) {
14017 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14020 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14023 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14026 #ifdef RTE_LIBRTE_IXGBE_PMD
14028 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14029 res->idx, res->an, res->pn, key) :
14030 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14031 res->idx, res->an, res->pn, key);
14033 RTE_SET_USED(is_tx);
14040 printf("invalid idx %d or an %d\n", res->idx, res->an);
14043 printf("invalid port_id %d\n", res->port_id);
14046 printf("not supported on port %d\n", res->port_id);
14049 printf("programming error: (%s)\n", strerror(-ret));
14053 cmdline_parse_inst_t cmd_set_macsec_sa = {
14054 .f = cmd_set_macsec_sa_parsed,
14056 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14058 (void *)&cmd_macsec_sa_set,
14059 (void *)&cmd_macsec_sa_macsec,
14060 (void *)&cmd_macsec_sa_sa,
14061 (void *)&cmd_macsec_sa_tx_rx,
14062 (void *)&cmd_macsec_sa_port_id,
14063 (void *)&cmd_macsec_sa_idx,
14064 (void *)&cmd_macsec_sa_an,
14065 (void *)&cmd_macsec_sa_pn,
14066 (void *)&cmd_macsec_sa_key,
14071 /* VF unicast promiscuous mode configuration */
14073 /* Common result structure for VF unicast promiscuous mode */
14074 struct cmd_vf_promisc_result {
14075 cmdline_fixed_string_t set;
14076 cmdline_fixed_string_t vf;
14077 cmdline_fixed_string_t promisc;
14080 cmdline_fixed_string_t on_off;
14083 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14084 cmdline_parse_token_string_t cmd_vf_promisc_set =
14085 TOKEN_STRING_INITIALIZER
14086 (struct cmd_vf_promisc_result,
14088 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14089 TOKEN_STRING_INITIALIZER
14090 (struct cmd_vf_promisc_result,
14092 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14093 TOKEN_STRING_INITIALIZER
14094 (struct cmd_vf_promisc_result,
14095 promisc, "promisc");
14096 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14097 TOKEN_NUM_INITIALIZER
14098 (struct cmd_vf_promisc_result,
14100 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14101 TOKEN_NUM_INITIALIZER
14102 (struct cmd_vf_promisc_result,
14104 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14105 TOKEN_STRING_INITIALIZER
14106 (struct cmd_vf_promisc_result,
14110 cmd_set_vf_promisc_parsed(
14111 void *parsed_result,
14112 __attribute__((unused)) struct cmdline *cl,
14113 __attribute__((unused)) void *data)
14115 struct cmd_vf_promisc_result *res = parsed_result;
14116 int ret = -ENOTSUP;
14118 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14120 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14123 #ifdef RTE_LIBRTE_I40E_PMD
14124 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14125 res->vf_id, is_on);
14132 printf("invalid vf_id %d\n", res->vf_id);
14135 printf("invalid port_id %d\n", res->port_id);
14138 printf("function not implemented\n");
14141 printf("programming error: (%s)\n", strerror(-ret));
14145 cmdline_parse_inst_t cmd_set_vf_promisc = {
14146 .f = cmd_set_vf_promisc_parsed,
14148 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14149 "Set unicast promiscuous mode for a VF from the PF",
14151 (void *)&cmd_vf_promisc_set,
14152 (void *)&cmd_vf_promisc_vf,
14153 (void *)&cmd_vf_promisc_promisc,
14154 (void *)&cmd_vf_promisc_port_id,
14155 (void *)&cmd_vf_promisc_vf_id,
14156 (void *)&cmd_vf_promisc_on_off,
14161 /* VF multicast promiscuous mode configuration */
14163 /* Common result structure for VF multicast promiscuous mode */
14164 struct cmd_vf_allmulti_result {
14165 cmdline_fixed_string_t set;
14166 cmdline_fixed_string_t vf;
14167 cmdline_fixed_string_t allmulti;
14170 cmdline_fixed_string_t on_off;
14173 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14174 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14175 TOKEN_STRING_INITIALIZER
14176 (struct cmd_vf_allmulti_result,
14178 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14179 TOKEN_STRING_INITIALIZER
14180 (struct cmd_vf_allmulti_result,
14182 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14183 TOKEN_STRING_INITIALIZER
14184 (struct cmd_vf_allmulti_result,
14185 allmulti, "allmulti");
14186 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14187 TOKEN_NUM_INITIALIZER
14188 (struct cmd_vf_allmulti_result,
14190 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14191 TOKEN_NUM_INITIALIZER
14192 (struct cmd_vf_allmulti_result,
14194 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14195 TOKEN_STRING_INITIALIZER
14196 (struct cmd_vf_allmulti_result,
14200 cmd_set_vf_allmulti_parsed(
14201 void *parsed_result,
14202 __attribute__((unused)) struct cmdline *cl,
14203 __attribute__((unused)) void *data)
14205 struct cmd_vf_allmulti_result *res = parsed_result;
14206 int ret = -ENOTSUP;
14208 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14210 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14213 #ifdef RTE_LIBRTE_I40E_PMD
14214 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14215 res->vf_id, is_on);
14222 printf("invalid vf_id %d\n", res->vf_id);
14225 printf("invalid port_id %d\n", res->port_id);
14228 printf("function not implemented\n");
14231 printf("programming error: (%s)\n", strerror(-ret));
14235 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14236 .f = cmd_set_vf_allmulti_parsed,
14238 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14239 "Set multicast promiscuous mode for a VF from the PF",
14241 (void *)&cmd_vf_allmulti_set,
14242 (void *)&cmd_vf_allmulti_vf,
14243 (void *)&cmd_vf_allmulti_allmulti,
14244 (void *)&cmd_vf_allmulti_port_id,
14245 (void *)&cmd_vf_allmulti_vf_id,
14246 (void *)&cmd_vf_allmulti_on_off,
14251 /* vf broadcast mode configuration */
14253 /* Common result structure for vf broadcast */
14254 struct cmd_set_vf_broadcast_result {
14255 cmdline_fixed_string_t set;
14256 cmdline_fixed_string_t vf;
14257 cmdline_fixed_string_t broadcast;
14260 cmdline_fixed_string_t on_off;
14263 /* Common CLI fields for vf broadcast enable disable */
14264 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14265 TOKEN_STRING_INITIALIZER
14266 (struct cmd_set_vf_broadcast_result,
14268 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14269 TOKEN_STRING_INITIALIZER
14270 (struct cmd_set_vf_broadcast_result,
14272 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14273 TOKEN_STRING_INITIALIZER
14274 (struct cmd_set_vf_broadcast_result,
14275 broadcast, "broadcast");
14276 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14277 TOKEN_NUM_INITIALIZER
14278 (struct cmd_set_vf_broadcast_result,
14280 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14281 TOKEN_NUM_INITIALIZER
14282 (struct cmd_set_vf_broadcast_result,
14284 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14285 TOKEN_STRING_INITIALIZER
14286 (struct cmd_set_vf_broadcast_result,
14290 cmd_set_vf_broadcast_parsed(
14291 void *parsed_result,
14292 __attribute__((unused)) struct cmdline *cl,
14293 __attribute__((unused)) void *data)
14295 struct cmd_set_vf_broadcast_result *res = parsed_result;
14296 int ret = -ENOTSUP;
14298 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14300 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14303 #ifdef RTE_LIBRTE_I40E_PMD
14304 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14305 res->vf_id, is_on);
14312 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14315 printf("invalid port_id %d\n", res->port_id);
14318 printf("function not implemented\n");
14321 printf("programming error: (%s)\n", strerror(-ret));
14325 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14326 .f = cmd_set_vf_broadcast_parsed,
14328 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14330 (void *)&cmd_set_vf_broadcast_set,
14331 (void *)&cmd_set_vf_broadcast_vf,
14332 (void *)&cmd_set_vf_broadcast_broadcast,
14333 (void *)&cmd_set_vf_broadcast_port_id,
14334 (void *)&cmd_set_vf_broadcast_vf_id,
14335 (void *)&cmd_set_vf_broadcast_on_off,
14340 /* vf vlan tag configuration */
14342 /* Common result structure for vf vlan tag */
14343 struct cmd_set_vf_vlan_tag_result {
14344 cmdline_fixed_string_t set;
14345 cmdline_fixed_string_t vf;
14346 cmdline_fixed_string_t vlan;
14347 cmdline_fixed_string_t tag;
14350 cmdline_fixed_string_t on_off;
14353 /* Common CLI fields for vf vlan tag enable disable */
14354 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14355 TOKEN_STRING_INITIALIZER
14356 (struct cmd_set_vf_vlan_tag_result,
14358 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14359 TOKEN_STRING_INITIALIZER
14360 (struct cmd_set_vf_vlan_tag_result,
14362 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14363 TOKEN_STRING_INITIALIZER
14364 (struct cmd_set_vf_vlan_tag_result,
14366 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14367 TOKEN_STRING_INITIALIZER
14368 (struct cmd_set_vf_vlan_tag_result,
14370 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14371 TOKEN_NUM_INITIALIZER
14372 (struct cmd_set_vf_vlan_tag_result,
14374 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14375 TOKEN_NUM_INITIALIZER
14376 (struct cmd_set_vf_vlan_tag_result,
14378 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14379 TOKEN_STRING_INITIALIZER
14380 (struct cmd_set_vf_vlan_tag_result,
14384 cmd_set_vf_vlan_tag_parsed(
14385 void *parsed_result,
14386 __attribute__((unused)) struct cmdline *cl,
14387 __attribute__((unused)) void *data)
14389 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14390 int ret = -ENOTSUP;
14392 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14397 #ifdef RTE_LIBRTE_I40E_PMD
14398 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14399 res->vf_id, is_on);
14406 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14409 printf("invalid port_id %d\n", res->port_id);
14412 printf("function not implemented\n");
14415 printf("programming error: (%s)\n", strerror(-ret));
14419 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14420 .f = cmd_set_vf_vlan_tag_parsed,
14422 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14424 (void *)&cmd_set_vf_vlan_tag_set,
14425 (void *)&cmd_set_vf_vlan_tag_vf,
14426 (void *)&cmd_set_vf_vlan_tag_vlan,
14427 (void *)&cmd_set_vf_vlan_tag_tag,
14428 (void *)&cmd_set_vf_vlan_tag_port_id,
14429 (void *)&cmd_set_vf_vlan_tag_vf_id,
14430 (void *)&cmd_set_vf_vlan_tag_on_off,
14435 /* Common definition of VF and TC TX bandwidth configuration */
14436 struct cmd_vf_tc_bw_result {
14437 cmdline_fixed_string_t set;
14438 cmdline_fixed_string_t vf;
14439 cmdline_fixed_string_t tc;
14440 cmdline_fixed_string_t tx;
14441 cmdline_fixed_string_t min_bw;
14442 cmdline_fixed_string_t max_bw;
14443 cmdline_fixed_string_t strict_link_prio;
14448 cmdline_fixed_string_t bw_list;
14452 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14453 TOKEN_STRING_INITIALIZER
14454 (struct cmd_vf_tc_bw_result,
14456 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14457 TOKEN_STRING_INITIALIZER
14458 (struct cmd_vf_tc_bw_result,
14460 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14461 TOKEN_STRING_INITIALIZER
14462 (struct cmd_vf_tc_bw_result,
14464 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14465 TOKEN_STRING_INITIALIZER
14466 (struct cmd_vf_tc_bw_result,
14468 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14469 TOKEN_STRING_INITIALIZER
14470 (struct cmd_vf_tc_bw_result,
14471 strict_link_prio, "strict-link-priority");
14472 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14473 TOKEN_STRING_INITIALIZER
14474 (struct cmd_vf_tc_bw_result,
14475 min_bw, "min-bandwidth");
14476 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14477 TOKEN_STRING_INITIALIZER
14478 (struct cmd_vf_tc_bw_result,
14479 max_bw, "max-bandwidth");
14480 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14481 TOKEN_NUM_INITIALIZER
14482 (struct cmd_vf_tc_bw_result,
14484 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14485 TOKEN_NUM_INITIALIZER
14486 (struct cmd_vf_tc_bw_result,
14488 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14489 TOKEN_NUM_INITIALIZER
14490 (struct cmd_vf_tc_bw_result,
14492 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14493 TOKEN_NUM_INITIALIZER
14494 (struct cmd_vf_tc_bw_result,
14496 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14497 TOKEN_STRING_INITIALIZER
14498 (struct cmd_vf_tc_bw_result,
14500 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14501 TOKEN_NUM_INITIALIZER
14502 (struct cmd_vf_tc_bw_result,
14505 /* VF max bandwidth setting */
14507 cmd_vf_max_bw_parsed(
14508 void *parsed_result,
14509 __attribute__((unused)) struct cmdline *cl,
14510 __attribute__((unused)) void *data)
14512 struct cmd_vf_tc_bw_result *res = parsed_result;
14513 int ret = -ENOTSUP;
14515 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14518 #ifdef RTE_LIBRTE_I40E_PMD
14519 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14520 res->vf_id, res->bw);
14527 printf("invalid vf_id %d or bandwidth %d\n",
14528 res->vf_id, res->bw);
14531 printf("invalid port_id %d\n", res->port_id);
14534 printf("function not implemented\n");
14537 printf("programming error: (%s)\n", strerror(-ret));
14541 cmdline_parse_inst_t cmd_vf_max_bw = {
14542 .f = cmd_vf_max_bw_parsed,
14544 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14546 (void *)&cmd_vf_tc_bw_set,
14547 (void *)&cmd_vf_tc_bw_vf,
14548 (void *)&cmd_vf_tc_bw_tx,
14549 (void *)&cmd_vf_tc_bw_max_bw,
14550 (void *)&cmd_vf_tc_bw_port_id,
14551 (void *)&cmd_vf_tc_bw_vf_id,
14552 (void *)&cmd_vf_tc_bw_bw,
14558 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14563 const char *p, *p0 = str;
14570 p = strchr(p0, '(');
14572 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14576 p0 = strchr(p, ')');
14578 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14582 if (size >= sizeof(s)) {
14583 printf("The string size exceeds the internal buffer size\n");
14586 snprintf(s, sizeof(s), "%.*s", size, p);
14587 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14589 printf("Failed to get the bandwidth list. ");
14593 for (i = 0; i < ret; i++)
14594 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14599 /* TC min bandwidth setting */
14601 cmd_vf_tc_min_bw_parsed(
14602 void *parsed_result,
14603 __attribute__((unused)) struct cmdline *cl,
14604 __attribute__((unused)) void *data)
14606 struct cmd_vf_tc_bw_result *res = parsed_result;
14609 int ret = -ENOTSUP;
14611 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14614 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14618 #ifdef RTE_LIBRTE_I40E_PMD
14619 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14627 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14630 printf("invalid port_id %d\n", res->port_id);
14633 printf("function not implemented\n");
14636 printf("programming error: (%s)\n", strerror(-ret));
14640 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14641 .f = cmd_vf_tc_min_bw_parsed,
14643 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14644 " <bw1, bw2, ...>",
14646 (void *)&cmd_vf_tc_bw_set,
14647 (void *)&cmd_vf_tc_bw_vf,
14648 (void *)&cmd_vf_tc_bw_tc,
14649 (void *)&cmd_vf_tc_bw_tx,
14650 (void *)&cmd_vf_tc_bw_min_bw,
14651 (void *)&cmd_vf_tc_bw_port_id,
14652 (void *)&cmd_vf_tc_bw_vf_id,
14653 (void *)&cmd_vf_tc_bw_bw_list,
14659 cmd_tc_min_bw_parsed(
14660 void *parsed_result,
14661 __attribute__((unused)) struct cmdline *cl,
14662 __attribute__((unused)) void *data)
14664 struct cmd_vf_tc_bw_result *res = parsed_result;
14665 struct rte_port *port;
14668 int ret = -ENOTSUP;
14670 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14673 port = &ports[res->port_id];
14674 /** Check if the port is not started **/
14675 if (port->port_status != RTE_PORT_STOPPED) {
14676 printf("Please stop port %d first\n", res->port_id);
14680 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14684 #ifdef RTE_LIBRTE_IXGBE_PMD
14685 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14692 printf("invalid bandwidth\n");
14695 printf("invalid port_id %d\n", res->port_id);
14698 printf("function not implemented\n");
14701 printf("programming error: (%s)\n", strerror(-ret));
14705 cmdline_parse_inst_t cmd_tc_min_bw = {
14706 .f = cmd_tc_min_bw_parsed,
14708 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14710 (void *)&cmd_vf_tc_bw_set,
14711 (void *)&cmd_vf_tc_bw_tc,
14712 (void *)&cmd_vf_tc_bw_tx,
14713 (void *)&cmd_vf_tc_bw_min_bw,
14714 (void *)&cmd_vf_tc_bw_port_id,
14715 (void *)&cmd_vf_tc_bw_bw_list,
14720 /* TC max bandwidth setting */
14722 cmd_vf_tc_max_bw_parsed(
14723 void *parsed_result,
14724 __attribute__((unused)) struct cmdline *cl,
14725 __attribute__((unused)) void *data)
14727 struct cmd_vf_tc_bw_result *res = parsed_result;
14728 int ret = -ENOTSUP;
14730 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14733 #ifdef RTE_LIBRTE_I40E_PMD
14734 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14735 res->tc_no, res->bw);
14742 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14743 res->vf_id, res->tc_no, res->bw);
14746 printf("invalid port_id %d\n", res->port_id);
14749 printf("function not implemented\n");
14752 printf("programming error: (%s)\n", strerror(-ret));
14756 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14757 .f = cmd_vf_tc_max_bw_parsed,
14759 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14762 (void *)&cmd_vf_tc_bw_set,
14763 (void *)&cmd_vf_tc_bw_vf,
14764 (void *)&cmd_vf_tc_bw_tc,
14765 (void *)&cmd_vf_tc_bw_tx,
14766 (void *)&cmd_vf_tc_bw_max_bw,
14767 (void *)&cmd_vf_tc_bw_port_id,
14768 (void *)&cmd_vf_tc_bw_vf_id,
14769 (void *)&cmd_vf_tc_bw_tc_no,
14770 (void *)&cmd_vf_tc_bw_bw,
14776 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14778 /* *** Set Port default Traffic Management Hierarchy *** */
14779 struct cmd_set_port_tm_hierarchy_default_result {
14780 cmdline_fixed_string_t set;
14781 cmdline_fixed_string_t port;
14782 cmdline_fixed_string_t tm;
14783 cmdline_fixed_string_t hierarchy;
14784 cmdline_fixed_string_t def;
14788 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14789 TOKEN_STRING_INITIALIZER(
14790 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14791 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14792 TOKEN_STRING_INITIALIZER(
14793 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14794 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14795 TOKEN_STRING_INITIALIZER(
14796 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14797 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14798 TOKEN_STRING_INITIALIZER(
14799 struct cmd_set_port_tm_hierarchy_default_result,
14800 hierarchy, "hierarchy");
14801 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14802 TOKEN_STRING_INITIALIZER(
14803 struct cmd_set_port_tm_hierarchy_default_result,
14805 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14806 TOKEN_NUM_INITIALIZER(
14807 struct cmd_set_port_tm_hierarchy_default_result,
14810 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14811 __attribute__((unused)) struct cmdline *cl,
14812 __attribute__((unused)) void *data)
14814 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14815 struct rte_port *p;
14816 portid_t port_id = res->port_id;
14818 if (port_id_is_invalid(port_id, ENABLED_WARN))
14821 p = &ports[port_id];
14823 /* Forward mode: tm */
14824 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
14825 printf(" softnicfwd mode not enabled(error)\n");
14829 /* Set the default tm hierarchy */
14830 p->softport.default_tm_hierarchy_enable = 1;
14833 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14834 .f = cmd_set_port_tm_hierarchy_default_parsed,
14836 .help_str = "set port tm hierarchy default <port_id>",
14838 (void *)&cmd_set_port_tm_hierarchy_default_set,
14839 (void *)&cmd_set_port_tm_hierarchy_default_port,
14840 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14841 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14842 (void *)&cmd_set_port_tm_hierarchy_default_default,
14843 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14849 /* Strict link priority scheduling mode setting */
14851 cmd_strict_link_prio_parsed(
14852 void *parsed_result,
14853 __attribute__((unused)) struct cmdline *cl,
14854 __attribute__((unused)) void *data)
14856 struct cmd_vf_tc_bw_result *res = parsed_result;
14857 int ret = -ENOTSUP;
14859 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14862 #ifdef RTE_LIBRTE_I40E_PMD
14863 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14870 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14873 printf("invalid port_id %d\n", res->port_id);
14876 printf("function not implemented\n");
14879 printf("programming error: (%s)\n", strerror(-ret));
14883 cmdline_parse_inst_t cmd_strict_link_prio = {
14884 .f = cmd_strict_link_prio_parsed,
14886 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14888 (void *)&cmd_vf_tc_bw_set,
14889 (void *)&cmd_vf_tc_bw_tx,
14890 (void *)&cmd_vf_tc_bw_strict_link_prio,
14891 (void *)&cmd_vf_tc_bw_port_id,
14892 (void *)&cmd_vf_tc_bw_tc_map,
14897 /* Load dynamic device personalization*/
14898 struct cmd_ddp_add_result {
14899 cmdline_fixed_string_t ddp;
14900 cmdline_fixed_string_t add;
14905 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14906 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14907 cmdline_parse_token_string_t cmd_ddp_add_add =
14908 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14909 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14910 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14911 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14912 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14915 cmd_ddp_add_parsed(
14916 void *parsed_result,
14917 __attribute__((unused)) struct cmdline *cl,
14918 __attribute__((unused)) void *data)
14920 struct cmd_ddp_add_result *res = parsed_result;
14926 int ret = -ENOTSUP;
14928 if (!all_ports_stopped()) {
14929 printf("Please stop all ports first\n");
14933 filepath = strdup(res->filepath);
14934 if (filepath == NULL) {
14935 printf("Failed to allocate memory\n");
14938 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14940 buff = open_file(file_fld[0], &size);
14942 free((void *)filepath);
14946 #ifdef RTE_LIBRTE_I40E_PMD
14947 if (ret == -ENOTSUP)
14948 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14950 RTE_PMD_I40E_PKG_OP_WR_ADD);
14953 if (ret == -EEXIST)
14954 printf("Profile has already existed.\n");
14956 printf("Failed to load profile.\n");
14957 else if (file_num == 2)
14958 save_file(file_fld[1], buff, size);
14961 free((void *)filepath);
14964 cmdline_parse_inst_t cmd_ddp_add = {
14965 .f = cmd_ddp_add_parsed,
14967 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14969 (void *)&cmd_ddp_add_ddp,
14970 (void *)&cmd_ddp_add_add,
14971 (void *)&cmd_ddp_add_port_id,
14972 (void *)&cmd_ddp_add_filepath,
14977 /* Delete dynamic device personalization*/
14978 struct cmd_ddp_del_result {
14979 cmdline_fixed_string_t ddp;
14980 cmdline_fixed_string_t del;
14985 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14986 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14987 cmdline_parse_token_string_t cmd_ddp_del_del =
14988 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14989 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14990 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14991 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14992 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14995 cmd_ddp_del_parsed(
14996 void *parsed_result,
14997 __attribute__((unused)) struct cmdline *cl,
14998 __attribute__((unused)) void *data)
15000 struct cmd_ddp_del_result *res = parsed_result;
15003 int ret = -ENOTSUP;
15005 if (!all_ports_stopped()) {
15006 printf("Please stop all ports first\n");
15010 buff = open_file(res->filepath, &size);
15014 #ifdef RTE_LIBRTE_I40E_PMD
15015 if (ret == -ENOTSUP)
15016 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15018 RTE_PMD_I40E_PKG_OP_WR_DEL);
15021 if (ret == -EACCES)
15022 printf("Profile does not exist.\n");
15024 printf("Failed to delete profile.\n");
15029 cmdline_parse_inst_t cmd_ddp_del = {
15030 .f = cmd_ddp_del_parsed,
15032 .help_str = "ddp del <port_id> <backup_profile_path>",
15034 (void *)&cmd_ddp_del_ddp,
15035 (void *)&cmd_ddp_del_del,
15036 (void *)&cmd_ddp_del_port_id,
15037 (void *)&cmd_ddp_del_filepath,
15042 /* Get dynamic device personalization profile info */
15043 struct cmd_ddp_info_result {
15044 cmdline_fixed_string_t ddp;
15045 cmdline_fixed_string_t get;
15046 cmdline_fixed_string_t info;
15050 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15051 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15052 cmdline_parse_token_string_t cmd_ddp_info_get =
15053 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15054 cmdline_parse_token_string_t cmd_ddp_info_info =
15055 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15056 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15057 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15060 cmd_ddp_info_parsed(
15061 void *parsed_result,
15062 __attribute__((unused)) struct cmdline *cl,
15063 __attribute__((unused)) void *data)
15065 struct cmd_ddp_info_result *res = parsed_result;
15068 int ret = -ENOTSUP;
15069 #ifdef RTE_LIBRTE_I40E_PMD
15072 uint32_t buff_size = 0;
15073 struct rte_pmd_i40e_profile_info info;
15074 uint32_t dev_num = 0;
15075 struct rte_pmd_i40e_ddp_device_id *devs;
15076 uint32_t proto_num = 0;
15077 struct rte_pmd_i40e_proto_info *proto = NULL;
15078 uint32_t pctype_num = 0;
15079 struct rte_pmd_i40e_ptype_info *pctype;
15080 uint32_t ptype_num = 0;
15081 struct rte_pmd_i40e_ptype_info *ptype;
15086 pkg = open_file(res->filepath, &pkg_size);
15090 #ifdef RTE_LIBRTE_I40E_PMD
15091 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15092 (uint8_t *)&info, sizeof(info),
15093 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15095 printf("Global Track id: 0x%x\n", info.track_id);
15096 printf("Global Version: %d.%d.%d.%d\n",
15097 info.version.major,
15098 info.version.minor,
15099 info.version.update,
15100 info.version.draft);
15101 printf("Global Package name: %s\n\n", info.name);
15104 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15105 (uint8_t *)&info, sizeof(info),
15106 RTE_PMD_I40E_PKG_INFO_HEADER);
15108 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15109 printf("i40e Profile Version: %d.%d.%d.%d\n",
15110 info.version.major,
15111 info.version.minor,
15112 info.version.update,
15113 info.version.draft);
15114 printf("i40e Profile name: %s\n\n", info.name);
15117 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15118 (uint8_t *)&buff_size, sizeof(buff_size),
15119 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15120 if (!ret && buff_size) {
15121 buff = (uint8_t *)malloc(buff_size);
15123 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15125 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15127 printf("Package Notes:\n%s\n\n", buff);
15132 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15133 (uint8_t *)&dev_num, sizeof(dev_num),
15134 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15135 if (!ret && dev_num) {
15136 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15137 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15139 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15140 (uint8_t *)devs, buff_size,
15141 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15143 printf("List of supported devices:\n");
15144 for (i = 0; i < dev_num; i++) {
15145 printf(" %04X:%04X %04X:%04X\n",
15146 devs[i].vendor_dev_id >> 16,
15147 devs[i].vendor_dev_id & 0xFFFF,
15148 devs[i].sub_vendor_dev_id >> 16,
15149 devs[i].sub_vendor_dev_id & 0xFFFF);
15157 /* get information about protocols and packet types */
15158 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15159 (uint8_t *)&proto_num, sizeof(proto_num),
15160 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15161 if (ret || !proto_num)
15162 goto no_print_return;
15164 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15165 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15167 goto no_print_return;
15169 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15171 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15173 printf("List of used protocols:\n");
15174 for (i = 0; i < proto_num; i++)
15175 printf(" %2u: %s\n", proto[i].proto_id,
15179 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15180 (uint8_t *)&pctype_num, sizeof(pctype_num),
15181 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15182 if (ret || !pctype_num)
15183 goto no_print_pctypes;
15185 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15186 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15188 goto no_print_pctypes;
15190 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15192 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15195 goto no_print_pctypes;
15198 printf("List of defined packet classification types:\n");
15199 for (i = 0; i < pctype_num; i++) {
15200 printf(" %2u:", pctype[i].ptype_id);
15201 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15202 proto_id = pctype[i].protocols[j];
15203 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15204 for (n = 0; n < proto_num; n++) {
15205 if (proto[n].proto_id == proto_id) {
15206 printf(" %s", proto[n].name);
15219 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15221 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15222 if (ret || !ptype_num)
15223 goto no_print_return;
15225 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15226 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15228 goto no_print_return;
15230 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15232 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15235 goto no_print_return;
15237 printf("List of defined packet types:\n");
15238 for (i = 0; i < ptype_num; i++) {
15239 printf(" %2u:", ptype[i].ptype_id);
15240 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15241 proto_id = ptype[i].protocols[j];
15242 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15243 for (n = 0; n < proto_num; n++) {
15244 if (proto[n].proto_id == proto_id) {
15245 printf(" %s", proto[n].name);
15261 if (ret == -ENOTSUP)
15262 printf("Function not supported in PMD driver\n");
15266 cmdline_parse_inst_t cmd_ddp_get_info = {
15267 .f = cmd_ddp_info_parsed,
15269 .help_str = "ddp get info <profile_path>",
15271 (void *)&cmd_ddp_info_ddp,
15272 (void *)&cmd_ddp_info_get,
15273 (void *)&cmd_ddp_info_info,
15274 (void *)&cmd_ddp_info_filepath,
15279 /* Get dynamic device personalization profile info list*/
15280 #define PROFILE_INFO_SIZE 48
15281 #define MAX_PROFILE_NUM 16
15283 struct cmd_ddp_get_list_result {
15284 cmdline_fixed_string_t ddp;
15285 cmdline_fixed_string_t get;
15286 cmdline_fixed_string_t list;
15290 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15291 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15292 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15293 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15294 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15295 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15296 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15297 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15300 cmd_ddp_get_list_parsed(
15301 __attribute__((unused)) void *parsed_result,
15302 __attribute__((unused)) struct cmdline *cl,
15303 __attribute__((unused)) void *data)
15305 #ifdef RTE_LIBRTE_I40E_PMD
15306 struct cmd_ddp_get_list_result *res = parsed_result;
15307 struct rte_pmd_i40e_profile_list *p_list;
15308 struct rte_pmd_i40e_profile_info *p_info;
15313 int ret = -ENOTSUP;
15315 #ifdef RTE_LIBRTE_I40E_PMD
15316 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15317 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15319 printf("%s: Failed to malloc buffer\n", __func__);
15321 if (ret == -ENOTSUP)
15322 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15323 (uint8_t *)p_list, size);
15326 p_num = p_list->p_count;
15327 printf("Profile number is: %d\n\n", p_num);
15329 for (i = 0; i < p_num; i++) {
15330 p_info = &p_list->p_info[i];
15331 printf("Profile %d:\n", i);
15332 printf("Track id: 0x%x\n", p_info->track_id);
15333 printf("Version: %d.%d.%d.%d\n",
15334 p_info->version.major,
15335 p_info->version.minor,
15336 p_info->version.update,
15337 p_info->version.draft);
15338 printf("Profile name: %s\n\n", p_info->name);
15346 printf("Failed to get ddp list\n");
15349 cmdline_parse_inst_t cmd_ddp_get_list = {
15350 .f = cmd_ddp_get_list_parsed,
15352 .help_str = "ddp get list <port_id>",
15354 (void *)&cmd_ddp_get_list_ddp,
15355 (void *)&cmd_ddp_get_list_get,
15356 (void *)&cmd_ddp_get_list_list,
15357 (void *)&cmd_ddp_get_list_port_id,
15362 /* Configure input set */
15363 struct cmd_cfg_input_set_result {
15364 cmdline_fixed_string_t port;
15365 cmdline_fixed_string_t cfg;
15367 cmdline_fixed_string_t pctype;
15369 cmdline_fixed_string_t inset_type;
15370 cmdline_fixed_string_t opt;
15371 cmdline_fixed_string_t field;
15376 cmd_cfg_input_set_parsed(
15377 __attribute__((unused)) void *parsed_result,
15378 __attribute__((unused)) struct cmdline *cl,
15379 __attribute__((unused)) void *data)
15381 #ifdef RTE_LIBRTE_I40E_PMD
15382 struct cmd_cfg_input_set_result *res = parsed_result;
15383 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15384 struct rte_pmd_i40e_inset inset;
15386 int ret = -ENOTSUP;
15388 if (!all_ports_stopped()) {
15389 printf("Please stop all ports first\n");
15393 #ifdef RTE_LIBRTE_I40E_PMD
15394 if (!strcmp(res->inset_type, "hash_inset"))
15395 inset_type = INSET_HASH;
15396 else if (!strcmp(res->inset_type, "fdir_inset"))
15397 inset_type = INSET_FDIR;
15398 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15399 inset_type = INSET_FDIR_FLX;
15400 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15401 &inset, inset_type);
15403 printf("Failed to get input set.\n");
15407 if (!strcmp(res->opt, "get")) {
15408 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15411 printf("Field index %d is enabled.\n", res->field_idx);
15413 printf("Field index %d is disabled.\n", res->field_idx);
15415 } else if (!strcmp(res->opt, "set"))
15416 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15418 else if (!strcmp(res->opt, "clear"))
15419 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15422 printf("Failed to configure input set field.\n");
15426 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15427 &inset, inset_type);
15429 printf("Failed to set input set.\n");
15434 if (ret == -ENOTSUP)
15435 printf("Function not supported\n");
15438 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15439 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15441 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15442 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15444 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15445 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15447 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15448 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15450 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15451 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15453 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15454 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15456 "hash_inset#fdir_inset#fdir_flx_inset");
15457 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15458 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15459 opt, "get#set#clear");
15460 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15461 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15463 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15464 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15467 cmdline_parse_inst_t cmd_cfg_input_set = {
15468 .f = cmd_cfg_input_set_parsed,
15470 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15471 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15473 (void *)&cmd_cfg_input_set_port,
15474 (void *)&cmd_cfg_input_set_cfg,
15475 (void *)&cmd_cfg_input_set_port_id,
15476 (void *)&cmd_cfg_input_set_pctype,
15477 (void *)&cmd_cfg_input_set_pctype_id,
15478 (void *)&cmd_cfg_input_set_inset_type,
15479 (void *)&cmd_cfg_input_set_opt,
15480 (void *)&cmd_cfg_input_set_field,
15481 (void *)&cmd_cfg_input_set_field_idx,
15486 /* Clear input set */
15487 struct cmd_clear_input_set_result {
15488 cmdline_fixed_string_t port;
15489 cmdline_fixed_string_t cfg;
15491 cmdline_fixed_string_t pctype;
15493 cmdline_fixed_string_t inset_type;
15494 cmdline_fixed_string_t clear;
15495 cmdline_fixed_string_t all;
15499 cmd_clear_input_set_parsed(
15500 __attribute__((unused)) void *parsed_result,
15501 __attribute__((unused)) struct cmdline *cl,
15502 __attribute__((unused)) void *data)
15504 #ifdef RTE_LIBRTE_I40E_PMD
15505 struct cmd_clear_input_set_result *res = parsed_result;
15506 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15507 struct rte_pmd_i40e_inset inset;
15509 int ret = -ENOTSUP;
15511 if (!all_ports_stopped()) {
15512 printf("Please stop all ports first\n");
15516 #ifdef RTE_LIBRTE_I40E_PMD
15517 if (!strcmp(res->inset_type, "hash_inset"))
15518 inset_type = INSET_HASH;
15519 else if (!strcmp(res->inset_type, "fdir_inset"))
15520 inset_type = INSET_FDIR;
15521 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15522 inset_type = INSET_FDIR_FLX;
15524 memset(&inset, 0, sizeof(inset));
15526 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15527 &inset, inset_type);
15529 printf("Failed to clear input set.\n");
15535 if (ret == -ENOTSUP)
15536 printf("Function not supported\n");
15539 cmdline_parse_token_string_t cmd_clear_input_set_port =
15540 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15542 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15543 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15545 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15546 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15548 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15549 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15551 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15552 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15554 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15555 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15557 "hash_inset#fdir_inset#fdir_flx_inset");
15558 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15559 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15561 cmdline_parse_token_string_t cmd_clear_input_set_all =
15562 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15565 cmdline_parse_inst_t cmd_clear_input_set = {
15566 .f = cmd_clear_input_set_parsed,
15568 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15569 "fdir_inset|fdir_flx_inset clear all",
15571 (void *)&cmd_clear_input_set_port,
15572 (void *)&cmd_clear_input_set_cfg,
15573 (void *)&cmd_clear_input_set_port_id,
15574 (void *)&cmd_clear_input_set_pctype,
15575 (void *)&cmd_clear_input_set_pctype_id,
15576 (void *)&cmd_clear_input_set_inset_type,
15577 (void *)&cmd_clear_input_set_clear,
15578 (void *)&cmd_clear_input_set_all,
15583 /* show vf stats */
15585 /* Common result structure for show vf stats */
15586 struct cmd_show_vf_stats_result {
15587 cmdline_fixed_string_t show;
15588 cmdline_fixed_string_t vf;
15589 cmdline_fixed_string_t stats;
15594 /* Common CLI fields show vf stats*/
15595 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15596 TOKEN_STRING_INITIALIZER
15597 (struct cmd_show_vf_stats_result,
15599 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15600 TOKEN_STRING_INITIALIZER
15601 (struct cmd_show_vf_stats_result,
15603 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15604 TOKEN_STRING_INITIALIZER
15605 (struct cmd_show_vf_stats_result,
15607 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15608 TOKEN_NUM_INITIALIZER
15609 (struct cmd_show_vf_stats_result,
15611 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15612 TOKEN_NUM_INITIALIZER
15613 (struct cmd_show_vf_stats_result,
15617 cmd_show_vf_stats_parsed(
15618 void *parsed_result,
15619 __attribute__((unused)) struct cmdline *cl,
15620 __attribute__((unused)) void *data)
15622 struct cmd_show_vf_stats_result *res = parsed_result;
15623 struct rte_eth_stats stats;
15624 int ret = -ENOTSUP;
15625 static const char *nic_stats_border = "########################";
15627 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15630 memset(&stats, 0, sizeof(stats));
15632 #ifdef RTE_LIBRTE_I40E_PMD
15633 if (ret == -ENOTSUP)
15634 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15638 #ifdef RTE_LIBRTE_BNXT_PMD
15639 if (ret == -ENOTSUP)
15640 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15649 printf("invalid vf_id %d\n", res->vf_id);
15652 printf("invalid port_id %d\n", res->port_id);
15655 printf("function not implemented\n");
15658 printf("programming error: (%s)\n", strerror(-ret));
15661 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15662 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15664 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15666 stats.ipackets, stats.imissed, stats.ibytes);
15667 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15668 printf(" RX-nombuf: %-10"PRIu64"\n",
15670 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15672 stats.opackets, stats.oerrors, stats.obytes);
15674 printf(" %s############################%s\n",
15675 nic_stats_border, nic_stats_border);
15678 cmdline_parse_inst_t cmd_show_vf_stats = {
15679 .f = cmd_show_vf_stats_parsed,
15681 .help_str = "show vf stats <port_id> <vf_id>",
15683 (void *)&cmd_show_vf_stats_show,
15684 (void *)&cmd_show_vf_stats_vf,
15685 (void *)&cmd_show_vf_stats_stats,
15686 (void *)&cmd_show_vf_stats_port_id,
15687 (void *)&cmd_show_vf_stats_vf_id,
15692 /* clear vf stats */
15694 /* Common result structure for clear vf stats */
15695 struct cmd_clear_vf_stats_result {
15696 cmdline_fixed_string_t clear;
15697 cmdline_fixed_string_t vf;
15698 cmdline_fixed_string_t stats;
15703 /* Common CLI fields clear vf stats*/
15704 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15705 TOKEN_STRING_INITIALIZER
15706 (struct cmd_clear_vf_stats_result,
15708 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15709 TOKEN_STRING_INITIALIZER
15710 (struct cmd_clear_vf_stats_result,
15712 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15713 TOKEN_STRING_INITIALIZER
15714 (struct cmd_clear_vf_stats_result,
15716 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15717 TOKEN_NUM_INITIALIZER
15718 (struct cmd_clear_vf_stats_result,
15720 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15721 TOKEN_NUM_INITIALIZER
15722 (struct cmd_clear_vf_stats_result,
15726 cmd_clear_vf_stats_parsed(
15727 void *parsed_result,
15728 __attribute__((unused)) struct cmdline *cl,
15729 __attribute__((unused)) void *data)
15731 struct cmd_clear_vf_stats_result *res = parsed_result;
15732 int ret = -ENOTSUP;
15734 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15737 #ifdef RTE_LIBRTE_I40E_PMD
15738 if (ret == -ENOTSUP)
15739 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15742 #ifdef RTE_LIBRTE_BNXT_PMD
15743 if (ret == -ENOTSUP)
15744 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15752 printf("invalid vf_id %d\n", res->vf_id);
15755 printf("invalid port_id %d\n", res->port_id);
15758 printf("function not implemented\n");
15761 printf("programming error: (%s)\n", strerror(-ret));
15765 cmdline_parse_inst_t cmd_clear_vf_stats = {
15766 .f = cmd_clear_vf_stats_parsed,
15768 .help_str = "clear vf stats <port_id> <vf_id>",
15770 (void *)&cmd_clear_vf_stats_clear,
15771 (void *)&cmd_clear_vf_stats_vf,
15772 (void *)&cmd_clear_vf_stats_stats,
15773 (void *)&cmd_clear_vf_stats_port_id,
15774 (void *)&cmd_clear_vf_stats_vf_id,
15779 /* port config pctype mapping reset */
15781 /* Common result structure for port config pctype mapping reset */
15782 struct cmd_pctype_mapping_reset_result {
15783 cmdline_fixed_string_t port;
15784 cmdline_fixed_string_t config;
15786 cmdline_fixed_string_t pctype;
15787 cmdline_fixed_string_t mapping;
15788 cmdline_fixed_string_t reset;
15791 /* Common CLI fields for port config pctype mapping reset*/
15792 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15793 TOKEN_STRING_INITIALIZER
15794 (struct cmd_pctype_mapping_reset_result,
15796 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15797 TOKEN_STRING_INITIALIZER
15798 (struct cmd_pctype_mapping_reset_result,
15800 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15801 TOKEN_NUM_INITIALIZER
15802 (struct cmd_pctype_mapping_reset_result,
15804 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15805 TOKEN_STRING_INITIALIZER
15806 (struct cmd_pctype_mapping_reset_result,
15808 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15809 TOKEN_STRING_INITIALIZER
15810 (struct cmd_pctype_mapping_reset_result,
15811 mapping, "mapping");
15812 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15813 TOKEN_STRING_INITIALIZER
15814 (struct cmd_pctype_mapping_reset_result,
15818 cmd_pctype_mapping_reset_parsed(
15819 void *parsed_result,
15820 __attribute__((unused)) struct cmdline *cl,
15821 __attribute__((unused)) void *data)
15823 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15824 int ret = -ENOTSUP;
15826 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15829 #ifdef RTE_LIBRTE_I40E_PMD
15830 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15837 printf("invalid port_id %d\n", res->port_id);
15840 printf("function not implemented\n");
15843 printf("programming error: (%s)\n", strerror(-ret));
15847 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15848 .f = cmd_pctype_mapping_reset_parsed,
15850 .help_str = "port config <port_id> pctype mapping reset",
15852 (void *)&cmd_pctype_mapping_reset_port,
15853 (void *)&cmd_pctype_mapping_reset_config,
15854 (void *)&cmd_pctype_mapping_reset_port_id,
15855 (void *)&cmd_pctype_mapping_reset_pctype,
15856 (void *)&cmd_pctype_mapping_reset_mapping,
15857 (void *)&cmd_pctype_mapping_reset_reset,
15862 /* show port pctype mapping */
15864 /* Common result structure for show port pctype mapping */
15865 struct cmd_pctype_mapping_get_result {
15866 cmdline_fixed_string_t show;
15867 cmdline_fixed_string_t port;
15869 cmdline_fixed_string_t pctype;
15870 cmdline_fixed_string_t mapping;
15873 /* Common CLI fields for pctype mapping get */
15874 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15875 TOKEN_STRING_INITIALIZER
15876 (struct cmd_pctype_mapping_get_result,
15878 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15879 TOKEN_STRING_INITIALIZER
15880 (struct cmd_pctype_mapping_get_result,
15882 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15883 TOKEN_NUM_INITIALIZER
15884 (struct cmd_pctype_mapping_get_result,
15886 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15887 TOKEN_STRING_INITIALIZER
15888 (struct cmd_pctype_mapping_get_result,
15890 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15891 TOKEN_STRING_INITIALIZER
15892 (struct cmd_pctype_mapping_get_result,
15893 mapping, "mapping");
15896 cmd_pctype_mapping_get_parsed(
15897 void *parsed_result,
15898 __attribute__((unused)) struct cmdline *cl,
15899 __attribute__((unused)) void *data)
15901 struct cmd_pctype_mapping_get_result *res = parsed_result;
15902 int ret = -ENOTSUP;
15903 #ifdef RTE_LIBRTE_I40E_PMD
15904 struct rte_pmd_i40e_flow_type_mapping
15905 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15906 int i, j, first_pctype;
15909 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15912 #ifdef RTE_LIBRTE_I40E_PMD
15913 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15920 printf("invalid port_id %d\n", res->port_id);
15923 printf("function not implemented\n");
15926 printf("programming error: (%s)\n", strerror(-ret));
15930 #ifdef RTE_LIBRTE_I40E_PMD
15931 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15932 if (mapping[i].pctype != 0ULL) {
15935 printf("pctype: ");
15936 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15937 if (mapping[i].pctype & (1ULL << j)) {
15938 printf(first_pctype ?
15939 "%02d" : ",%02d", j);
15943 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15949 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15950 .f = cmd_pctype_mapping_get_parsed,
15952 .help_str = "show port <port_id> pctype mapping",
15954 (void *)&cmd_pctype_mapping_get_show,
15955 (void *)&cmd_pctype_mapping_get_port,
15956 (void *)&cmd_pctype_mapping_get_port_id,
15957 (void *)&cmd_pctype_mapping_get_pctype,
15958 (void *)&cmd_pctype_mapping_get_mapping,
15963 /* port config pctype mapping update */
15965 /* Common result structure for port config pctype mapping update */
15966 struct cmd_pctype_mapping_update_result {
15967 cmdline_fixed_string_t port;
15968 cmdline_fixed_string_t config;
15970 cmdline_fixed_string_t pctype;
15971 cmdline_fixed_string_t mapping;
15972 cmdline_fixed_string_t update;
15973 cmdline_fixed_string_t pctype_list;
15974 uint16_t flow_type;
15977 /* Common CLI fields for pctype mapping update*/
15978 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15979 TOKEN_STRING_INITIALIZER
15980 (struct cmd_pctype_mapping_update_result,
15982 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15983 TOKEN_STRING_INITIALIZER
15984 (struct cmd_pctype_mapping_update_result,
15986 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15987 TOKEN_NUM_INITIALIZER
15988 (struct cmd_pctype_mapping_update_result,
15990 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15991 TOKEN_STRING_INITIALIZER
15992 (struct cmd_pctype_mapping_update_result,
15994 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15995 TOKEN_STRING_INITIALIZER
15996 (struct cmd_pctype_mapping_update_result,
15997 mapping, "mapping");
15998 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15999 TOKEN_STRING_INITIALIZER
16000 (struct cmd_pctype_mapping_update_result,
16002 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16003 TOKEN_STRING_INITIALIZER
16004 (struct cmd_pctype_mapping_update_result,
16005 pctype_list, NULL);
16006 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16007 TOKEN_NUM_INITIALIZER
16008 (struct cmd_pctype_mapping_update_result,
16009 flow_type, UINT16);
16012 cmd_pctype_mapping_update_parsed(
16013 void *parsed_result,
16014 __attribute__((unused)) struct cmdline *cl,
16015 __attribute__((unused)) void *data)
16017 struct cmd_pctype_mapping_update_result *res = parsed_result;
16018 int ret = -ENOTSUP;
16019 #ifdef RTE_LIBRTE_I40E_PMD
16020 struct rte_pmd_i40e_flow_type_mapping mapping;
16022 unsigned int nb_item;
16023 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16026 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16029 #ifdef RTE_LIBRTE_I40E_PMD
16030 nb_item = parse_item_list(res->pctype_list, "pctypes",
16031 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16032 mapping.flow_type = res->flow_type;
16033 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16034 mapping.pctype |= (1ULL << pctype_list[i]);
16035 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16045 printf("invalid pctype or flow type\n");
16048 printf("invalid port_id %d\n", res->port_id);
16051 printf("function not implemented\n");
16054 printf("programming error: (%s)\n", strerror(-ret));
16058 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16059 .f = cmd_pctype_mapping_update_parsed,
16061 .help_str = "port config <port_id> pctype mapping update"
16062 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16064 (void *)&cmd_pctype_mapping_update_port,
16065 (void *)&cmd_pctype_mapping_update_config,
16066 (void *)&cmd_pctype_mapping_update_port_id,
16067 (void *)&cmd_pctype_mapping_update_pctype,
16068 (void *)&cmd_pctype_mapping_update_mapping,
16069 (void *)&cmd_pctype_mapping_update_update,
16070 (void *)&cmd_pctype_mapping_update_pc_type,
16071 (void *)&cmd_pctype_mapping_update_flow_type,
16076 /* ptype mapping get */
16078 /* Common result structure for ptype mapping get */
16079 struct cmd_ptype_mapping_get_result {
16080 cmdline_fixed_string_t ptype;
16081 cmdline_fixed_string_t mapping;
16082 cmdline_fixed_string_t get;
16084 uint8_t valid_only;
16087 /* Common CLI fields for ptype mapping get */
16088 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16089 TOKEN_STRING_INITIALIZER
16090 (struct cmd_ptype_mapping_get_result,
16092 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16093 TOKEN_STRING_INITIALIZER
16094 (struct cmd_ptype_mapping_get_result,
16095 mapping, "mapping");
16096 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16097 TOKEN_STRING_INITIALIZER
16098 (struct cmd_ptype_mapping_get_result,
16100 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16101 TOKEN_NUM_INITIALIZER
16102 (struct cmd_ptype_mapping_get_result,
16104 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16105 TOKEN_NUM_INITIALIZER
16106 (struct cmd_ptype_mapping_get_result,
16107 valid_only, UINT8);
16110 cmd_ptype_mapping_get_parsed(
16111 void *parsed_result,
16112 __attribute__((unused)) struct cmdline *cl,
16113 __attribute__((unused)) void *data)
16115 struct cmd_ptype_mapping_get_result *res = parsed_result;
16116 int ret = -ENOTSUP;
16117 #ifdef RTE_LIBRTE_I40E_PMD
16118 int max_ptype_num = 256;
16119 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16124 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16127 #ifdef RTE_LIBRTE_I40E_PMD
16128 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16139 printf("invalid port_id %d\n", res->port_id);
16142 printf("function not implemented\n");
16145 printf("programming error: (%s)\n", strerror(-ret));
16148 #ifdef RTE_LIBRTE_I40E_PMD
16150 for (i = 0; i < count; i++)
16151 printf("%3d\t0x%08x\n",
16152 mapping[i].hw_ptype, mapping[i].sw_ptype);
16157 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16158 .f = cmd_ptype_mapping_get_parsed,
16160 .help_str = "ptype mapping get <port_id> <valid_only>",
16162 (void *)&cmd_ptype_mapping_get_ptype,
16163 (void *)&cmd_ptype_mapping_get_mapping,
16164 (void *)&cmd_ptype_mapping_get_get,
16165 (void *)&cmd_ptype_mapping_get_port_id,
16166 (void *)&cmd_ptype_mapping_get_valid_only,
16171 /* ptype mapping replace */
16173 /* Common result structure for ptype mapping replace */
16174 struct cmd_ptype_mapping_replace_result {
16175 cmdline_fixed_string_t ptype;
16176 cmdline_fixed_string_t mapping;
16177 cmdline_fixed_string_t replace;
16184 /* Common CLI fields for ptype mapping replace */
16185 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16186 TOKEN_STRING_INITIALIZER
16187 (struct cmd_ptype_mapping_replace_result,
16189 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16190 TOKEN_STRING_INITIALIZER
16191 (struct cmd_ptype_mapping_replace_result,
16192 mapping, "mapping");
16193 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16194 TOKEN_STRING_INITIALIZER
16195 (struct cmd_ptype_mapping_replace_result,
16196 replace, "replace");
16197 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16198 TOKEN_NUM_INITIALIZER
16199 (struct cmd_ptype_mapping_replace_result,
16201 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16202 TOKEN_NUM_INITIALIZER
16203 (struct cmd_ptype_mapping_replace_result,
16205 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16206 TOKEN_NUM_INITIALIZER
16207 (struct cmd_ptype_mapping_replace_result,
16209 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16210 TOKEN_NUM_INITIALIZER
16211 (struct cmd_ptype_mapping_replace_result,
16215 cmd_ptype_mapping_replace_parsed(
16216 void *parsed_result,
16217 __attribute__((unused)) struct cmdline *cl,
16218 __attribute__((unused)) void *data)
16220 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16221 int ret = -ENOTSUP;
16223 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16226 #ifdef RTE_LIBRTE_I40E_PMD
16227 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16237 printf("invalid ptype 0x%8x or 0x%8x\n",
16238 res->target, res->pkt_type);
16241 printf("invalid port_id %d\n", res->port_id);
16244 printf("function not implemented\n");
16247 printf("programming error: (%s)\n", strerror(-ret));
16251 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16252 .f = cmd_ptype_mapping_replace_parsed,
16255 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16257 (void *)&cmd_ptype_mapping_replace_ptype,
16258 (void *)&cmd_ptype_mapping_replace_mapping,
16259 (void *)&cmd_ptype_mapping_replace_replace,
16260 (void *)&cmd_ptype_mapping_replace_port_id,
16261 (void *)&cmd_ptype_mapping_replace_target,
16262 (void *)&cmd_ptype_mapping_replace_mask,
16263 (void *)&cmd_ptype_mapping_replace_pkt_type,
16268 /* ptype mapping reset */
16270 /* Common result structure for ptype mapping reset */
16271 struct cmd_ptype_mapping_reset_result {
16272 cmdline_fixed_string_t ptype;
16273 cmdline_fixed_string_t mapping;
16274 cmdline_fixed_string_t reset;
16278 /* Common CLI fields for ptype mapping reset*/
16279 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16280 TOKEN_STRING_INITIALIZER
16281 (struct cmd_ptype_mapping_reset_result,
16283 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16284 TOKEN_STRING_INITIALIZER
16285 (struct cmd_ptype_mapping_reset_result,
16286 mapping, "mapping");
16287 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16288 TOKEN_STRING_INITIALIZER
16289 (struct cmd_ptype_mapping_reset_result,
16291 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16292 TOKEN_NUM_INITIALIZER
16293 (struct cmd_ptype_mapping_reset_result,
16297 cmd_ptype_mapping_reset_parsed(
16298 void *parsed_result,
16299 __attribute__((unused)) struct cmdline *cl,
16300 __attribute__((unused)) void *data)
16302 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16303 int ret = -ENOTSUP;
16305 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16308 #ifdef RTE_LIBRTE_I40E_PMD
16309 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16316 printf("invalid port_id %d\n", res->port_id);
16319 printf("function not implemented\n");
16322 printf("programming error: (%s)\n", strerror(-ret));
16326 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16327 .f = cmd_ptype_mapping_reset_parsed,
16329 .help_str = "ptype mapping reset <port_id>",
16331 (void *)&cmd_ptype_mapping_reset_ptype,
16332 (void *)&cmd_ptype_mapping_reset_mapping,
16333 (void *)&cmd_ptype_mapping_reset_reset,
16334 (void *)&cmd_ptype_mapping_reset_port_id,
16339 /* ptype mapping update */
16341 /* Common result structure for ptype mapping update */
16342 struct cmd_ptype_mapping_update_result {
16343 cmdline_fixed_string_t ptype;
16344 cmdline_fixed_string_t mapping;
16345 cmdline_fixed_string_t reset;
16351 /* Common CLI fields for ptype mapping update*/
16352 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16353 TOKEN_STRING_INITIALIZER
16354 (struct cmd_ptype_mapping_update_result,
16356 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16357 TOKEN_STRING_INITIALIZER
16358 (struct cmd_ptype_mapping_update_result,
16359 mapping, "mapping");
16360 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16361 TOKEN_STRING_INITIALIZER
16362 (struct cmd_ptype_mapping_update_result,
16364 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16365 TOKEN_NUM_INITIALIZER
16366 (struct cmd_ptype_mapping_update_result,
16368 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16369 TOKEN_NUM_INITIALIZER
16370 (struct cmd_ptype_mapping_update_result,
16372 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16373 TOKEN_NUM_INITIALIZER
16374 (struct cmd_ptype_mapping_update_result,
16378 cmd_ptype_mapping_update_parsed(
16379 void *parsed_result,
16380 __attribute__((unused)) struct cmdline *cl,
16381 __attribute__((unused)) void *data)
16383 struct cmd_ptype_mapping_update_result *res = parsed_result;
16384 int ret = -ENOTSUP;
16385 #ifdef RTE_LIBRTE_I40E_PMD
16386 struct rte_pmd_i40e_ptype_mapping mapping;
16388 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16391 #ifdef RTE_LIBRTE_I40E_PMD
16392 mapping.hw_ptype = res->hw_ptype;
16393 mapping.sw_ptype = res->sw_ptype;
16394 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16404 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16407 printf("invalid port_id %d\n", res->port_id);
16410 printf("function not implemented\n");
16413 printf("programming error: (%s)\n", strerror(-ret));
16417 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16418 .f = cmd_ptype_mapping_update_parsed,
16420 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16422 (void *)&cmd_ptype_mapping_update_ptype,
16423 (void *)&cmd_ptype_mapping_update_mapping,
16424 (void *)&cmd_ptype_mapping_update_update,
16425 (void *)&cmd_ptype_mapping_update_port_id,
16426 (void *)&cmd_ptype_mapping_update_hw_ptype,
16427 (void *)&cmd_ptype_mapping_update_sw_ptype,
16432 /* Common result structure for file commands */
16433 struct cmd_cmdfile_result {
16434 cmdline_fixed_string_t load;
16435 cmdline_fixed_string_t filename;
16438 /* Common CLI fields for file commands */
16439 cmdline_parse_token_string_t cmd_load_cmdfile =
16440 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16441 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16442 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16445 cmd_load_from_file_parsed(
16446 void *parsed_result,
16447 __attribute__((unused)) struct cmdline *cl,
16448 __attribute__((unused)) void *data)
16450 struct cmd_cmdfile_result *res = parsed_result;
16452 cmdline_read_from_file(res->filename);
16455 cmdline_parse_inst_t cmd_load_from_file = {
16456 .f = cmd_load_from_file_parsed,
16458 .help_str = "load <filename>",
16460 (void *)&cmd_load_cmdfile,
16461 (void *)&cmd_load_cmdfile_filename,
16466 /* Get Rx offloads capabilities */
16467 struct cmd_rx_offload_get_capa_result {
16468 cmdline_fixed_string_t show;
16469 cmdline_fixed_string_t port;
16471 cmdline_fixed_string_t rx_offload;
16472 cmdline_fixed_string_t capabilities;
16475 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16476 TOKEN_STRING_INITIALIZER
16477 (struct cmd_rx_offload_get_capa_result,
16479 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16480 TOKEN_STRING_INITIALIZER
16481 (struct cmd_rx_offload_get_capa_result,
16483 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16484 TOKEN_NUM_INITIALIZER
16485 (struct cmd_rx_offload_get_capa_result,
16487 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16488 TOKEN_STRING_INITIALIZER
16489 (struct cmd_rx_offload_get_capa_result,
16490 rx_offload, "rx_offload");
16491 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16492 TOKEN_STRING_INITIALIZER
16493 (struct cmd_rx_offload_get_capa_result,
16494 capabilities, "capabilities");
16497 print_rx_offloads(uint64_t offloads)
16499 uint64_t single_offload;
16507 begin = __builtin_ctzll(offloads);
16508 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16510 single_offload = 1 << begin;
16511 for (bit = begin; bit < end; bit++) {
16512 if (offloads & single_offload)
16514 rte_eth_dev_rx_offload_name(single_offload));
16515 single_offload <<= 1;
16520 cmd_rx_offload_get_capa_parsed(
16521 void *parsed_result,
16522 __attribute__((unused)) struct cmdline *cl,
16523 __attribute__((unused)) void *data)
16525 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16526 struct rte_eth_dev_info dev_info;
16527 portid_t port_id = res->port_id;
16528 uint64_t queue_offloads;
16529 uint64_t port_offloads;
16531 rte_eth_dev_info_get(port_id, &dev_info);
16532 queue_offloads = dev_info.rx_queue_offload_capa;
16533 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16535 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16536 printf(" Per Queue :");
16537 print_rx_offloads(queue_offloads);
16540 printf(" Per Port :");
16541 print_rx_offloads(port_offloads);
16545 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16546 .f = cmd_rx_offload_get_capa_parsed,
16548 .help_str = "show port <port_id> rx_offload capabilities",
16550 (void *)&cmd_rx_offload_get_capa_show,
16551 (void *)&cmd_rx_offload_get_capa_port,
16552 (void *)&cmd_rx_offload_get_capa_port_id,
16553 (void *)&cmd_rx_offload_get_capa_rx_offload,
16554 (void *)&cmd_rx_offload_get_capa_capabilities,
16559 /* Get Rx offloads configuration */
16560 struct cmd_rx_offload_get_configuration_result {
16561 cmdline_fixed_string_t show;
16562 cmdline_fixed_string_t port;
16564 cmdline_fixed_string_t rx_offload;
16565 cmdline_fixed_string_t configuration;
16568 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16569 TOKEN_STRING_INITIALIZER
16570 (struct cmd_rx_offload_get_configuration_result,
16572 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16573 TOKEN_STRING_INITIALIZER
16574 (struct cmd_rx_offload_get_configuration_result,
16576 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16577 TOKEN_NUM_INITIALIZER
16578 (struct cmd_rx_offload_get_configuration_result,
16580 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16581 TOKEN_STRING_INITIALIZER
16582 (struct cmd_rx_offload_get_configuration_result,
16583 rx_offload, "rx_offload");
16584 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16585 TOKEN_STRING_INITIALIZER
16586 (struct cmd_rx_offload_get_configuration_result,
16587 configuration, "configuration");
16590 cmd_rx_offload_get_configuration_parsed(
16591 void *parsed_result,
16592 __attribute__((unused)) struct cmdline *cl,
16593 __attribute__((unused)) void *data)
16595 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16596 struct rte_eth_dev_info dev_info;
16597 portid_t port_id = res->port_id;
16598 struct rte_port *port = &ports[port_id];
16599 uint64_t port_offloads;
16600 uint64_t queue_offloads;
16601 uint16_t nb_rx_queues;
16604 printf("Rx Offloading Configuration of port %d :\n", port_id);
16606 port_offloads = port->dev_conf.rxmode.offloads;
16608 print_rx_offloads(port_offloads);
16611 rte_eth_dev_info_get(port_id, &dev_info);
16612 nb_rx_queues = dev_info.nb_rx_queues;
16613 for (q = 0; q < nb_rx_queues; q++) {
16614 queue_offloads = port->rx_conf[q].offloads;
16615 printf(" Queue[%2d] :", q);
16616 print_rx_offloads(queue_offloads);
16622 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16623 .f = cmd_rx_offload_get_configuration_parsed,
16625 .help_str = "show port <port_id> rx_offload configuration",
16627 (void *)&cmd_rx_offload_get_configuration_show,
16628 (void *)&cmd_rx_offload_get_configuration_port,
16629 (void *)&cmd_rx_offload_get_configuration_port_id,
16630 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16631 (void *)&cmd_rx_offload_get_configuration_configuration,
16636 /* Enable/Disable a per port offloading */
16637 struct cmd_config_per_port_rx_offload_result {
16638 cmdline_fixed_string_t port;
16639 cmdline_fixed_string_t config;
16641 cmdline_fixed_string_t rx_offload;
16642 cmdline_fixed_string_t offload;
16643 cmdline_fixed_string_t on_off;
16646 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16647 TOKEN_STRING_INITIALIZER
16648 (struct cmd_config_per_port_rx_offload_result,
16650 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16651 TOKEN_STRING_INITIALIZER
16652 (struct cmd_config_per_port_rx_offload_result,
16654 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16655 TOKEN_NUM_INITIALIZER
16656 (struct cmd_config_per_port_rx_offload_result,
16658 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16659 TOKEN_STRING_INITIALIZER
16660 (struct cmd_config_per_port_rx_offload_result,
16661 rx_offload, "rx_offload");
16662 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16663 TOKEN_STRING_INITIALIZER
16664 (struct cmd_config_per_port_rx_offload_result,
16665 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16666 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16667 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16668 "crc_strip#scatter#timestamp#security");
16669 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16670 TOKEN_STRING_INITIALIZER
16671 (struct cmd_config_per_port_rx_offload_result,
16675 search_rx_offload(const char *name)
16677 uint64_t single_offload;
16678 const char *single_name;
16682 single_offload = 1;
16683 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16684 single_name = rte_eth_dev_rx_offload_name(single_offload);
16685 if (!strcasecmp(single_name, name)) {
16688 } else if (!strcasecmp(single_name, "UNKNOWN"))
16690 else if (single_name == NULL)
16692 single_offload <<= 1;
16696 return single_offload;
16702 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16703 __attribute__((unused)) struct cmdline *cl,
16704 __attribute__((unused)) void *data)
16706 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16707 portid_t port_id = res->port_id;
16708 struct rte_eth_dev_info dev_info;
16709 struct rte_port *port = &ports[port_id];
16710 uint64_t single_offload;
16711 uint16_t nb_rx_queues;
16714 if (port->port_status != RTE_PORT_STOPPED) {
16715 printf("Error: Can't config offload when Port %d "
16716 "is not stopped\n", port_id);
16720 single_offload = search_rx_offload(res->offload);
16721 if (single_offload == 0) {
16722 printf("Unknown offload name: %s\n", res->offload);
16726 rte_eth_dev_info_get(port_id, &dev_info);
16727 nb_rx_queues = dev_info.nb_rx_queues;
16728 if (!strcmp(res->on_off, "on")) {
16729 port->dev_conf.rxmode.offloads |= single_offload;
16730 for (q = 0; q < nb_rx_queues; q++)
16731 port->rx_conf[q].offloads |= single_offload;
16733 port->dev_conf.rxmode.offloads &= ~single_offload;
16734 for (q = 0; q < nb_rx_queues; q++)
16735 port->rx_conf[q].offloads &= ~single_offload;
16738 cmd_reconfig_device_queue(port_id, 1, 1);
16741 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16742 .f = cmd_config_per_port_rx_offload_parsed,
16744 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16745 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16746 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16747 "jumbo_frame|crc_strip|scatter|timestamp|security "
16750 (void *)&cmd_config_per_port_rx_offload_result_port,
16751 (void *)&cmd_config_per_port_rx_offload_result_config,
16752 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16753 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16754 (void *)&cmd_config_per_port_rx_offload_result_offload,
16755 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16760 /* Enable/Disable a per queue offloading */
16761 struct cmd_config_per_queue_rx_offload_result {
16762 cmdline_fixed_string_t port;
16764 cmdline_fixed_string_t rxq;
16766 cmdline_fixed_string_t rx_offload;
16767 cmdline_fixed_string_t offload;
16768 cmdline_fixed_string_t on_off;
16771 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16772 TOKEN_STRING_INITIALIZER
16773 (struct cmd_config_per_queue_rx_offload_result,
16775 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16776 TOKEN_NUM_INITIALIZER
16777 (struct cmd_config_per_queue_rx_offload_result,
16779 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16780 TOKEN_STRING_INITIALIZER
16781 (struct cmd_config_per_queue_rx_offload_result,
16783 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16784 TOKEN_NUM_INITIALIZER
16785 (struct cmd_config_per_queue_rx_offload_result,
16787 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16788 TOKEN_STRING_INITIALIZER
16789 (struct cmd_config_per_queue_rx_offload_result,
16790 rx_offload, "rx_offload");
16791 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16792 TOKEN_STRING_INITIALIZER
16793 (struct cmd_config_per_queue_rx_offload_result,
16794 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16795 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16796 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16797 "crc_strip#scatter#timestamp#security");
16798 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16799 TOKEN_STRING_INITIALIZER
16800 (struct cmd_config_per_queue_rx_offload_result,
16804 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16805 __attribute__((unused)) struct cmdline *cl,
16806 __attribute__((unused)) void *data)
16808 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16809 struct rte_eth_dev_info dev_info;
16810 portid_t port_id = res->port_id;
16811 uint16_t queue_id = res->queue_id;
16812 struct rte_port *port = &ports[port_id];
16813 uint64_t single_offload;
16815 if (port->port_status != RTE_PORT_STOPPED) {
16816 printf("Error: Can't config offload when Port %d "
16817 "is not stopped\n", port_id);
16821 rte_eth_dev_info_get(port_id, &dev_info);
16822 if (queue_id >= dev_info.nb_rx_queues) {
16823 printf("Error: input queue_id should be 0 ... "
16824 "%d\n", dev_info.nb_rx_queues - 1);
16828 single_offload = search_rx_offload(res->offload);
16829 if (single_offload == 0) {
16830 printf("Unknown offload name: %s\n", res->offload);
16834 if (!strcmp(res->on_off, "on"))
16835 port->rx_conf[queue_id].offloads |= single_offload;
16837 port->rx_conf[queue_id].offloads &= ~single_offload;
16839 cmd_reconfig_device_queue(port_id, 1, 1);
16842 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16843 .f = cmd_config_per_queue_rx_offload_parsed,
16845 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16846 "vlan_strip|ipv4_cksum|"
16847 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16848 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16849 "jumbo_frame|crc_strip|scatter|timestamp|security "
16852 (void *)&cmd_config_per_queue_rx_offload_result_port,
16853 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16854 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16855 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16856 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16857 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16858 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16863 /* Get Tx offloads capabilities */
16864 struct cmd_tx_offload_get_capa_result {
16865 cmdline_fixed_string_t show;
16866 cmdline_fixed_string_t port;
16868 cmdline_fixed_string_t tx_offload;
16869 cmdline_fixed_string_t capabilities;
16872 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16873 TOKEN_STRING_INITIALIZER
16874 (struct cmd_tx_offload_get_capa_result,
16876 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16877 TOKEN_STRING_INITIALIZER
16878 (struct cmd_tx_offload_get_capa_result,
16880 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16881 TOKEN_NUM_INITIALIZER
16882 (struct cmd_tx_offload_get_capa_result,
16884 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16885 TOKEN_STRING_INITIALIZER
16886 (struct cmd_tx_offload_get_capa_result,
16887 tx_offload, "tx_offload");
16888 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16889 TOKEN_STRING_INITIALIZER
16890 (struct cmd_tx_offload_get_capa_result,
16891 capabilities, "capabilities");
16894 print_tx_offloads(uint64_t offloads)
16896 uint64_t single_offload;
16904 begin = __builtin_ctzll(offloads);
16905 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16907 single_offload = 1 << begin;
16908 for (bit = begin; bit < end; bit++) {
16909 if (offloads & single_offload)
16911 rte_eth_dev_tx_offload_name(single_offload));
16912 single_offload <<= 1;
16917 cmd_tx_offload_get_capa_parsed(
16918 void *parsed_result,
16919 __attribute__((unused)) struct cmdline *cl,
16920 __attribute__((unused)) void *data)
16922 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16923 struct rte_eth_dev_info dev_info;
16924 portid_t port_id = res->port_id;
16925 uint64_t queue_offloads;
16926 uint64_t port_offloads;
16928 rte_eth_dev_info_get(port_id, &dev_info);
16929 queue_offloads = dev_info.tx_queue_offload_capa;
16930 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16932 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16933 printf(" Per Queue :");
16934 print_tx_offloads(queue_offloads);
16937 printf(" Per Port :");
16938 print_tx_offloads(port_offloads);
16942 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16943 .f = cmd_tx_offload_get_capa_parsed,
16945 .help_str = "show port <port_id> tx_offload capabilities",
16947 (void *)&cmd_tx_offload_get_capa_show,
16948 (void *)&cmd_tx_offload_get_capa_port,
16949 (void *)&cmd_tx_offload_get_capa_port_id,
16950 (void *)&cmd_tx_offload_get_capa_tx_offload,
16951 (void *)&cmd_tx_offload_get_capa_capabilities,
16956 /* Get Tx offloads configuration */
16957 struct cmd_tx_offload_get_configuration_result {
16958 cmdline_fixed_string_t show;
16959 cmdline_fixed_string_t port;
16961 cmdline_fixed_string_t tx_offload;
16962 cmdline_fixed_string_t configuration;
16965 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16966 TOKEN_STRING_INITIALIZER
16967 (struct cmd_tx_offload_get_configuration_result,
16969 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16970 TOKEN_STRING_INITIALIZER
16971 (struct cmd_tx_offload_get_configuration_result,
16973 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16974 TOKEN_NUM_INITIALIZER
16975 (struct cmd_tx_offload_get_configuration_result,
16977 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16978 TOKEN_STRING_INITIALIZER
16979 (struct cmd_tx_offload_get_configuration_result,
16980 tx_offload, "tx_offload");
16981 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16982 TOKEN_STRING_INITIALIZER
16983 (struct cmd_tx_offload_get_configuration_result,
16984 configuration, "configuration");
16987 cmd_tx_offload_get_configuration_parsed(
16988 void *parsed_result,
16989 __attribute__((unused)) struct cmdline *cl,
16990 __attribute__((unused)) void *data)
16992 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16993 struct rte_eth_dev_info dev_info;
16994 portid_t port_id = res->port_id;
16995 struct rte_port *port = &ports[port_id];
16996 uint64_t port_offloads;
16997 uint64_t queue_offloads;
16998 uint16_t nb_tx_queues;
17001 printf("Tx Offloading Configuration of port %d :\n", port_id);
17003 port_offloads = port->dev_conf.txmode.offloads;
17005 print_tx_offloads(port_offloads);
17008 rte_eth_dev_info_get(port_id, &dev_info);
17009 nb_tx_queues = dev_info.nb_tx_queues;
17010 for (q = 0; q < nb_tx_queues; q++) {
17011 queue_offloads = port->tx_conf[q].offloads;
17012 printf(" Queue[%2d] :", q);
17013 print_tx_offloads(queue_offloads);
17019 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17020 .f = cmd_tx_offload_get_configuration_parsed,
17022 .help_str = "show port <port_id> tx_offload configuration",
17024 (void *)&cmd_tx_offload_get_configuration_show,
17025 (void *)&cmd_tx_offload_get_configuration_port,
17026 (void *)&cmd_tx_offload_get_configuration_port_id,
17027 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17028 (void *)&cmd_tx_offload_get_configuration_configuration,
17033 /* Enable/Disable a per port offloading */
17034 struct cmd_config_per_port_tx_offload_result {
17035 cmdline_fixed_string_t port;
17036 cmdline_fixed_string_t config;
17038 cmdline_fixed_string_t tx_offload;
17039 cmdline_fixed_string_t offload;
17040 cmdline_fixed_string_t on_off;
17043 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17044 TOKEN_STRING_INITIALIZER
17045 (struct cmd_config_per_port_tx_offload_result,
17047 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17048 TOKEN_STRING_INITIALIZER
17049 (struct cmd_config_per_port_tx_offload_result,
17051 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17052 TOKEN_NUM_INITIALIZER
17053 (struct cmd_config_per_port_tx_offload_result,
17055 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17056 TOKEN_STRING_INITIALIZER
17057 (struct cmd_config_per_port_tx_offload_result,
17058 tx_offload, "tx_offload");
17059 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17060 TOKEN_STRING_INITIALIZER
17061 (struct cmd_config_per_port_tx_offload_result,
17062 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17063 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17064 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17065 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17066 "mt_lockfree#multi_segs#fast_free#security");
17067 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17068 TOKEN_STRING_INITIALIZER
17069 (struct cmd_config_per_port_tx_offload_result,
17073 search_tx_offload(const char *name)
17075 uint64_t single_offload;
17076 const char *single_name;
17080 single_offload = 1;
17081 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17082 single_name = rte_eth_dev_tx_offload_name(single_offload);
17083 if (!strcasecmp(single_name, name)) {
17086 } else if (!strcasecmp(single_name, "UNKNOWN"))
17088 else if (single_name == NULL)
17090 single_offload <<= 1;
17094 return single_offload;
17100 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17101 __attribute__((unused)) struct cmdline *cl,
17102 __attribute__((unused)) void *data)
17104 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17105 portid_t port_id = res->port_id;
17106 struct rte_eth_dev_info dev_info;
17107 struct rte_port *port = &ports[port_id];
17108 uint64_t single_offload;
17109 uint16_t nb_tx_queues;
17112 if (port->port_status != RTE_PORT_STOPPED) {
17113 printf("Error: Can't config offload when Port %d "
17114 "is not stopped\n", port_id);
17118 single_offload = search_tx_offload(res->offload);
17119 if (single_offload == 0) {
17120 printf("Unknown offload name: %s\n", res->offload);
17124 rte_eth_dev_info_get(port_id, &dev_info);
17125 nb_tx_queues = dev_info.nb_tx_queues;
17126 if (!strcmp(res->on_off, "on")) {
17127 port->dev_conf.txmode.offloads |= single_offload;
17128 for (q = 0; q < nb_tx_queues; q++)
17129 port->tx_conf[q].offloads |= single_offload;
17131 port->dev_conf.txmode.offloads &= ~single_offload;
17132 for (q = 0; q < nb_tx_queues; q++)
17133 port->tx_conf[q].offloads &= ~single_offload;
17136 cmd_reconfig_device_queue(port_id, 1, 1);
17139 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17140 .f = cmd_config_per_port_tx_offload_parsed,
17142 .help_str = "port config <port_id> tx_offload "
17143 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17144 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17145 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17146 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17147 "mt_lockfree|multi_segs|fast_free|security "
17150 (void *)&cmd_config_per_port_tx_offload_result_port,
17151 (void *)&cmd_config_per_port_tx_offload_result_config,
17152 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17153 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17154 (void *)&cmd_config_per_port_tx_offload_result_offload,
17155 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17160 /* Enable/Disable a per queue offloading */
17161 struct cmd_config_per_queue_tx_offload_result {
17162 cmdline_fixed_string_t port;
17164 cmdline_fixed_string_t txq;
17166 cmdline_fixed_string_t tx_offload;
17167 cmdline_fixed_string_t offload;
17168 cmdline_fixed_string_t on_off;
17171 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17172 TOKEN_STRING_INITIALIZER
17173 (struct cmd_config_per_queue_tx_offload_result,
17175 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17176 TOKEN_NUM_INITIALIZER
17177 (struct cmd_config_per_queue_tx_offload_result,
17179 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17180 TOKEN_STRING_INITIALIZER
17181 (struct cmd_config_per_queue_tx_offload_result,
17183 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17184 TOKEN_NUM_INITIALIZER
17185 (struct cmd_config_per_queue_tx_offload_result,
17187 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17188 TOKEN_STRING_INITIALIZER
17189 (struct cmd_config_per_queue_tx_offload_result,
17190 tx_offload, "tx_offload");
17191 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17192 TOKEN_STRING_INITIALIZER
17193 (struct cmd_config_per_queue_tx_offload_result,
17194 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17195 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17196 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17197 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17198 "mt_lockfree#multi_segs#fast_free#security");
17199 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17200 TOKEN_STRING_INITIALIZER
17201 (struct cmd_config_per_queue_tx_offload_result,
17205 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17206 __attribute__((unused)) struct cmdline *cl,
17207 __attribute__((unused)) void *data)
17209 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17210 struct rte_eth_dev_info dev_info;
17211 portid_t port_id = res->port_id;
17212 uint16_t queue_id = res->queue_id;
17213 struct rte_port *port = &ports[port_id];
17214 uint64_t single_offload;
17216 if (port->port_status != RTE_PORT_STOPPED) {
17217 printf("Error: Can't config offload when Port %d "
17218 "is not stopped\n", port_id);
17222 rte_eth_dev_info_get(port_id, &dev_info);
17223 if (queue_id >= dev_info.nb_tx_queues) {
17224 printf("Error: input queue_id should be 0 ... "
17225 "%d\n", dev_info.nb_tx_queues - 1);
17229 single_offload = search_tx_offload(res->offload);
17230 if (single_offload == 0) {
17231 printf("Unknown offload name: %s\n", res->offload);
17235 if (!strcmp(res->on_off, "on"))
17236 port->tx_conf[queue_id].offloads |= single_offload;
17238 port->tx_conf[queue_id].offloads &= ~single_offload;
17240 cmd_reconfig_device_queue(port_id, 1, 1);
17243 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17244 .f = cmd_config_per_queue_tx_offload_parsed,
17246 .help_str = "port <port_id> txq <queue_id> tx_offload "
17247 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17248 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17249 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17250 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17251 "mt_lockfree|multi_segs|fast_free|security "
17254 (void *)&cmd_config_per_queue_tx_offload_result_port,
17255 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17256 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17257 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17258 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17259 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17260 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17265 /* ******************************************************************************** */
17267 /* list of instructions */
17268 cmdline_parse_ctx_t main_ctx[] = {
17269 (cmdline_parse_inst_t *)&cmd_help_brief,
17270 (cmdline_parse_inst_t *)&cmd_help_long,
17271 (cmdline_parse_inst_t *)&cmd_quit,
17272 (cmdline_parse_inst_t *)&cmd_load_from_file,
17273 (cmdline_parse_inst_t *)&cmd_showport,
17274 (cmdline_parse_inst_t *)&cmd_showqueue,
17275 (cmdline_parse_inst_t *)&cmd_showportall,
17276 (cmdline_parse_inst_t *)&cmd_showcfg,
17277 (cmdline_parse_inst_t *)&cmd_start,
17278 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17279 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17280 (cmdline_parse_inst_t *)&cmd_set_link_up,
17281 (cmdline_parse_inst_t *)&cmd_set_link_down,
17282 (cmdline_parse_inst_t *)&cmd_reset,
17283 (cmdline_parse_inst_t *)&cmd_set_numbers,
17284 (cmdline_parse_inst_t *)&cmd_set_log,
17285 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17286 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17287 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17288 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17289 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17290 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17291 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17292 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17293 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17294 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17295 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17296 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17297 (cmdline_parse_inst_t *)&cmd_set_link_check,
17298 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17299 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17300 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17301 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17302 #ifdef RTE_LIBRTE_PMD_BOND
17303 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17304 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17305 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17306 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17307 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17308 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17309 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17310 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17311 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17312 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17313 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17315 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17316 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17317 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17318 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17319 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17320 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17321 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17322 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17323 (cmdline_parse_inst_t *)&cmd_csum_set,
17324 (cmdline_parse_inst_t *)&cmd_csum_show,
17325 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17326 (cmdline_parse_inst_t *)&cmd_tso_set,
17327 (cmdline_parse_inst_t *)&cmd_tso_show,
17328 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17329 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17330 (cmdline_parse_inst_t *)&cmd_gro_enable,
17331 (cmdline_parse_inst_t *)&cmd_gro_flush,
17332 (cmdline_parse_inst_t *)&cmd_gro_show,
17333 (cmdline_parse_inst_t *)&cmd_gso_enable,
17334 (cmdline_parse_inst_t *)&cmd_gso_size,
17335 (cmdline_parse_inst_t *)&cmd_gso_show,
17336 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17337 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17338 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17339 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17340 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17341 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17342 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17343 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17344 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17345 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17346 (cmdline_parse_inst_t *)&cmd_config_dcb,
17347 (cmdline_parse_inst_t *)&cmd_read_reg,
17348 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17349 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17350 (cmdline_parse_inst_t *)&cmd_write_reg,
17351 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17352 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17353 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17354 (cmdline_parse_inst_t *)&cmd_stop,
17355 (cmdline_parse_inst_t *)&cmd_mac_addr,
17356 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17357 (cmdline_parse_inst_t *)&cmd_set_qmap,
17358 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17359 (cmdline_parse_inst_t *)&cmd_operate_port,
17360 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17361 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17362 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17363 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17364 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17365 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17366 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17367 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17368 (cmdline_parse_inst_t *)&cmd_config_mtu,
17369 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17370 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17371 (cmdline_parse_inst_t *)&cmd_config_rss,
17372 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17373 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17374 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17375 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17376 (cmdline_parse_inst_t *)&cmd_showport_reta,
17377 (cmdline_parse_inst_t *)&cmd_config_burst,
17378 (cmdline_parse_inst_t *)&cmd_config_thresh,
17379 (cmdline_parse_inst_t *)&cmd_config_threshold,
17380 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17381 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17382 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17383 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
17384 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17385 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
17386 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17387 (cmdline_parse_inst_t *)&cmd_global_config,
17388 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17389 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17390 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17391 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17392 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17393 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17394 (cmdline_parse_inst_t *)&cmd_dump,
17395 (cmdline_parse_inst_t *)&cmd_dump_one,
17396 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
17397 (cmdline_parse_inst_t *)&cmd_syn_filter,
17398 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
17399 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
17400 (cmdline_parse_inst_t *)&cmd_flex_filter,
17401 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
17402 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
17403 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
17404 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
17405 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
17406 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
17407 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17408 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
17409 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17410 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17411 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17412 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
17413 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17414 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
17415 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
17416 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
17417 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
17418 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
17419 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
17420 (cmdline_parse_inst_t *)&cmd_flow,
17421 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17422 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17423 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17424 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17425 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17426 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17427 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17428 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17429 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17430 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17431 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17432 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17433 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17434 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17435 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
17436 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
17437 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
17438 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
17439 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
17440 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
17441 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
17442 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
17443 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
17444 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
17445 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17446 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17447 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17448 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17449 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17450 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17451 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17452 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17453 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17454 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17455 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17456 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17457 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17458 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17459 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17460 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17461 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17462 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17463 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17464 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17465 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17466 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17467 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17468 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17469 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17470 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
17471 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
17473 (cmdline_parse_inst_t *)&cmd_ddp_add,
17474 (cmdline_parse_inst_t *)&cmd_ddp_del,
17475 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17476 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17477 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17478 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17479 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17480 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17481 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17482 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17483 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17484 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17486 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17487 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17488 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17489 (cmdline_parse_inst_t *)&cmd_queue_region,
17490 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17491 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17492 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17493 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17494 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17495 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17496 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17497 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17498 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17499 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17500 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17501 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17502 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17503 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17504 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17505 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17506 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17507 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17508 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17509 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17510 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17511 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17512 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17513 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17514 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17515 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17516 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17517 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17518 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17519 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17520 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17521 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17522 #ifdef RTE_LIBRTE_BPF
17523 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17524 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17529 /* read cmdline commands from file */
17531 cmdline_read_from_file(const char *filename)
17533 struct cmdline *cl;
17535 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17537 printf("Failed to create file based cmdline context: %s\n",
17542 cmdline_interact(cl);
17547 printf("Read CLI commands from %s\n", filename);
17550 /* prompt function, called from main on MASTER lcore */
17556 /* initialize non-constant commands */
17557 cmd_set_fwd_mode_init();
17558 cmd_set_fwd_retry_mode_init();
17560 #if defined RTE_LIBRTE_PMD_SOFTNIC
17561 portid_t softnic_portid, pid;
17562 uint8_t softnic_enable = 0;
17564 if (strcmp(cur_fwd_eng->fwd_mode_name, "softnic") == 0) {
17565 RTE_ETH_FOREACH_DEV(pid) {
17566 struct rte_port *port = &ports[pid];
17567 const char *driver = port->dev_info.driver_name;
17569 if (strcmp(driver, "net_softnic") == 0) {
17570 softnic_portid = pid;
17571 softnic_enable = 1;
17578 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17579 if (testpmd_cl == NULL)
17583 status = cmdline_poll(testpmd_cl);
17585 rte_panic("CLI poll error (%" PRId32 ")\n", status);
17586 else if (status == RDLINE_EXITED) {
17587 cmdline_stdin_exit(testpmd_cl);
17591 #if defined RTE_LIBRTE_PMD_SOFTNIC
17593 if ((softnic_enable == 1) &&
17594 (strcmp(cur_fwd_eng->fwd_mode_name, "softnic") == 0))
17595 rte_pmd_softnic_manage(softnic_portid);
17603 if (testpmd_cl != NULL)
17604 cmdline_quit(testpmd_cl);
17608 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17610 if (id == (portid_t)RTE_PORT_ALL) {
17613 RTE_ETH_FOREACH_DEV(pid) {
17614 /* check if need_reconfig has been set to 1 */
17615 if (ports[pid].need_reconfig == 0)
17616 ports[pid].need_reconfig = dev;
17617 /* check if need_reconfig_queues has been set to 1 */
17618 if (ports[pid].need_reconfig_queues == 0)
17619 ports[pid].need_reconfig_queues = queue;
17621 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17622 /* check if need_reconfig has been set to 1 */
17623 if (ports[id].need_reconfig == 0)
17624 ports[id].need_reconfig = dev;
17625 /* check if need_reconfig_queues has been set to 1 */
17626 if (ports[id].need_reconfig_queues == 0)
17627 ports[id].need_reconfig_queues = queue;