1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
16 #include <net/socket.h>
18 #include <sys/socket.h>
21 #include <netinet/in.h>
23 #include <sys/queue.h>
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
47 #include <rte_eth_ctrl.h>
51 #include <cmdline_rdline.h>
52 #include <cmdline_parse.h>
53 #include <cmdline_parse_num.h>
54 #include <cmdline_parse_string.h>
55 #include <cmdline_parse_ipaddr.h>
56 #include <cmdline_parse_etheraddr.h>
57 #include <cmdline_socket.h>
59 #ifdef RTE_LIBRTE_PMD_BOND
60 #include <rte_eth_bond.h>
61 #include <rte_eth_bond_8023ad.h>
63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
64 #include <rte_pmd_dpaa.h>
66 #ifdef RTE_LIBRTE_IXGBE_PMD
67 #include <rte_pmd_ixgbe.h>
69 #ifdef RTE_LIBRTE_I40E_PMD
70 #include <rte_pmd_i40e.h>
72 #ifdef RTE_LIBRTE_PMD_SOFTNIC
73 #include <rte_eth_softnic.h>
75 #ifdef RTE_LIBRTE_BNXT_PMD
76 #include <rte_pmd_bnxt.h>
79 #include "cmdline_mtr.h"
80 #include "cmdline_tm.h"
83 static struct cmdline *testpmd_cl;
85 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
87 /* *** Help command with introduction. *** */
88 struct cmd_help_brief_result {
89 cmdline_fixed_string_t help;
92 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
94 __attribute__((unused)) void *data)
99 "Help is available for the following sections:\n\n"
100 " help control : Start and stop forwarding.\n"
101 " help display : Displaying port, stats and config "
103 " help config : Configuration information.\n"
104 " help ports : Configuring ports.\n"
105 " help registers : Reading and setting port registers.\n"
106 " help filters : Filters configuration help.\n"
107 " help all : All of the above sections.\n\n"
112 cmdline_parse_token_string_t cmd_help_brief_help =
113 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
115 cmdline_parse_inst_t cmd_help_brief = {
116 .f = cmd_help_brief_parsed,
118 .help_str = "help: Show help",
120 (void *)&cmd_help_brief_help,
125 /* *** Help command with help sections. *** */
126 struct cmd_help_long_result {
127 cmdline_fixed_string_t help;
128 cmdline_fixed_string_t section;
131 static void cmd_help_long_parsed(void *parsed_result,
133 __attribute__((unused)) void *data)
136 struct cmd_help_long_result *res = parsed_result;
138 if (!strcmp(res->section, "all"))
141 if (show_all || !strcmp(res->section, "control")) {
146 "Control forwarding:\n"
147 "-------------------\n\n"
150 " Start packet forwarding with current configuration.\n\n"
153 " Start packet forwarding with current config"
154 " after sending one burst of packets.\n\n"
157 " Stop packet forwarding, and display accumulated"
161 " Quit to prompt.\n\n"
165 if (show_all || !strcmp(res->section, "display")) {
173 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
174 " Display information for port_id, or all.\n\n"
176 "show port X rss reta (size) (mask0,mask1,...)\n"
177 " Display the rss redirection table entry indicated"
178 " by masks on port X. size is used to indicate the"
179 " hardware supported reta size\n\n"
181 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
182 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
183 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
184 " Display the RSS hash functions and RSS hash key"
187 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
188 " Clear information for port_id, or all.\n\n"
190 "show (rxq|txq) info (port_id) (queue_id)\n"
191 " Display information for configured RX/TX queue.\n\n"
193 "show config (rxtx|cores|fwd|txpkts)\n"
194 " Display the given configuration.\n\n"
196 "read rxd (port_id) (queue_id) (rxd_id)\n"
197 " Display an RX descriptor of a port RX queue.\n\n"
199 "read txd (port_id) (queue_id) (txd_id)\n"
200 " Display a TX descriptor of a port TX queue.\n\n"
202 "ddp get list (port_id)\n"
203 " Get ddp profile info list\n\n"
205 "ddp get info (profile_path)\n"
206 " Get ddp profile information.\n\n"
208 "show vf stats (port_id) (vf_id)\n"
209 " Display a VF's statistics.\n\n"
211 "clear vf stats (port_id) (vf_id)\n"
212 " Reset a VF's statistics.\n\n"
214 "show port (port_id) pctype mapping\n"
215 " Get flow ptype to pctype mapping on a port\n\n"
217 "show port meter stats (port_id) (meter_id) (clear)\n"
218 " Get meter stats on a port\n\n"
219 "show port tm cap (port_id)\n"
220 " Display the port TM capability.\n\n"
222 "show port tm level cap (port_id) (level_id)\n"
223 " Display the port TM hierarchical level capability.\n\n"
225 "show port tm node cap (port_id) (node_id)\n"
226 " Display the port TM node capability.\n\n"
228 "show port tm node type (port_id) (node_id)\n"
229 " Display the port TM node type.\n\n"
231 "show port tm node stats (port_id) (node_id) (clear)\n"
232 " Display the port TM node stats.\n\n"
237 if (show_all || !strcmp(res->section, "config")) {
243 "Configuration changes only become active when"
244 " forwarding is started/restarted.\n\n"
247 " Reset forwarding to the default configuration.\n\n"
249 "set verbose (level)\n"
250 " Set the debug verbosity level X.\n\n"
252 "set log global|(type) (level)\n"
253 " Set the log level.\n\n"
256 " Set number of ports.\n\n"
259 " Set number of cores.\n\n"
261 "set coremask (mask)\n"
262 " Set the forwarding cores hexadecimal mask.\n\n"
264 "set portmask (mask)\n"
265 " Set the forwarding ports hexadecimal mask.\n\n"
268 " Set number of packets per burst.\n\n"
270 "set burst tx delay (microseconds) retry (num)\n"
271 " Set the transmit delay time and number of retries,"
272 " effective when retry is enabled.\n\n"
274 "set txpkts (x[,y]*)\n"
275 " Set the length of each segment of TXONLY"
276 " and optionally CSUM packets.\n\n"
278 "set txsplit (off|on|rand)\n"
279 " Set the split policy for the TX packets."
280 " Right now only applicable for CSUM and TXONLY"
283 "set corelist (x[,y]*)\n"
284 " Set the list of forwarding cores.\n\n"
286 "set portlist (x[,y]*)\n"
287 " Set the list of forwarding ports.\n\n"
289 "set tx loopback (port_id) (on|off)\n"
290 " Enable or disable tx loopback.\n\n"
292 "set all queues drop (port_id) (on|off)\n"
293 " Set drop enable bit for all queues.\n\n"
295 "set vf split drop (port_id) (vf_id) (on|off)\n"
296 " Set split drop enable bit for a VF from the PF.\n\n"
298 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
299 " Set MAC antispoof for a VF from the PF.\n\n"
301 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
302 " Enable MACsec offload.\n\n"
304 "set macsec offload (port_id) off\n"
305 " Disable MACsec offload.\n\n"
307 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
308 " Configure MACsec secure connection (SC).\n\n"
310 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
311 " Configure MACsec secure association (SA).\n\n"
313 "set vf broadcast (port_id) (vf_id) (on|off)\n"
314 " Set VF broadcast for a VF from the PF.\n\n"
316 "vlan set strip (on|off) (port_id)\n"
317 " Set the VLAN strip on a port.\n\n"
319 "vlan set stripq (on|off) (port_id,queue_id)\n"
320 " Set the VLAN strip for a queue on a port.\n\n"
322 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
323 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
325 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
326 " Set VLAN insert for a VF from the PF.\n\n"
328 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
329 " Set VLAN antispoof for a VF from the PF.\n\n"
331 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
332 " Set VLAN tag for a VF from the PF.\n\n"
334 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
335 " Set a VF's max bandwidth(Mbps).\n\n"
337 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
338 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
340 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
341 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
343 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
344 " Set some TCs' strict link priority mode on a physical port.\n\n"
346 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
347 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
349 "vlan set filter (on|off) (port_id)\n"
350 " Set the VLAN filter on a port.\n\n"
352 "vlan set qinq (on|off) (port_id)\n"
353 " Set the VLAN QinQ (extended queue in queue)"
356 "vlan set (inner|outer) tpid (value) (port_id)\n"
357 " Set the VLAN TPID for Packet Filtering on"
360 "rx_vlan add (vlan_id|all) (port_id)\n"
361 " Add a vlan_id, or all identifiers, to the set"
362 " of VLAN identifiers filtered by port_id.\n\n"
364 "rx_vlan rm (vlan_id|all) (port_id)\n"
365 " Remove a vlan_id, or all identifiers, from the set"
366 " of VLAN identifiers filtered by port_id.\n\n"
368 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
369 " Add a vlan_id, to the set of VLAN identifiers"
370 "filtered for VF(s) from port_id.\n\n"
372 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
373 " Remove a vlan_id, to the set of VLAN identifiers"
374 "filtered for VF(s) from port_id.\n\n"
376 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
377 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
378 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
379 " add a tunnel filter of a port.\n\n"
381 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
382 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
383 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
384 " remove a tunnel filter of a port.\n\n"
386 "rx_vxlan_port add (udp_port) (port_id)\n"
387 " Add an UDP port for VXLAN packet filter on a port\n\n"
389 "rx_vxlan_port rm (udp_port) (port_id)\n"
390 " Remove an UDP port for VXLAN packet filter on a port\n\n"
392 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
393 " Set hardware insertion of VLAN IDs (single or double VLAN "
394 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
396 "tx_vlan set pvid port_id vlan_id (on|off)\n"
397 " Set port based TX VLAN insertion.\n\n"
399 "tx_vlan reset (port_id)\n"
400 " Disable hardware insertion of a VLAN header in"
401 " packets sent on a port.\n\n"
403 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
404 " Select hardware or software calculation of the"
405 " checksum when transmitting a packet using the"
406 " csum forward engine.\n"
407 " ip|udp|tcp|sctp always concern the inner layer.\n"
408 " outer-ip concerns the outer IP layer in"
409 " case the packet is recognized as a tunnel packet by"
410 " the forward engine (vxlan, gre and ipip are supported)\n"
411 " Please check the NIC datasheet for HW limits.\n\n"
413 "csum parse-tunnel (on|off) (tx_port_id)\n"
414 " If disabled, treat tunnel packets as non-tunneled"
415 " packets (treat inner headers as payload). The port\n"
416 " argument is the port used for TX in csum forward"
419 "csum show (port_id)\n"
420 " Display tx checksum offload configuration\n\n"
422 "tso set (segsize) (portid)\n"
423 " Enable TCP Segmentation Offload in csum forward"
425 " Please check the NIC datasheet for HW limits.\n\n"
428 " Display the status of TCP Segmentation Offload.\n\n"
430 "set port (port_id) gro on|off\n"
431 " Enable or disable Generic Receive Offload in"
432 " csum forwarding engine.\n\n"
434 "show port (port_id) gro\n"
435 " Display GRO configuration.\n\n"
437 "set gro flush (cycles)\n"
438 " Set the cycle to flush GROed packets from"
439 " reassembly tables.\n\n"
441 "set port (port_id) gso (on|off)"
442 " Enable or disable Generic Segmentation Offload in"
443 " csum forwarding engine.\n\n"
445 "set gso segsz (length)\n"
446 " Set max packet length for output GSO segments,"
447 " including packet header and payload.\n\n"
449 "show port (port_id) gso\n"
450 " Show GSO configuration.\n\n"
453 " Set packet forwarding mode.\n\n"
455 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
456 " Add a MAC address on port_id.\n\n"
458 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
459 " Remove a MAC address from port_id.\n\n"
461 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
462 " Set the default MAC address for port_id.\n\n"
464 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
465 " Add a MAC address for a VF on the port.\n\n"
467 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
468 " Set the MAC address for a VF from the PF.\n\n"
470 "set eth-peer (port_id) (peer_addr)\n"
471 " set the peer address for certain port.\n\n"
473 "set port (port_id) uta (mac_address|all) (on|off)\n"
474 " Add/Remove a or all unicast hash filter(s)"
477 "set promisc (port_id|all) (on|off)\n"
478 " Set the promiscuous mode on port_id, or all.\n\n"
480 "set allmulti (port_id|all) (on|off)\n"
481 " Set the allmulti mode on port_id, or all.\n\n"
483 "set vf promisc (port_id) (vf_id) (on|off)\n"
484 " Set unicast promiscuous mode for a VF from the PF.\n\n"
486 "set vf allmulti (port_id) (vf_id) (on|off)\n"
487 " Set multicast promiscuous mode for a VF from the PF.\n\n"
489 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
490 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
491 " (on|off) autoneg (on|off) (port_id)\n"
492 "set flow_ctrl rx (on|off) (portid)\n"
493 "set flow_ctrl tx (on|off) (portid)\n"
494 "set flow_ctrl high_water (high_water) (portid)\n"
495 "set flow_ctrl low_water (low_water) (portid)\n"
496 "set flow_ctrl pause_time (pause_time) (portid)\n"
497 "set flow_ctrl send_xon (send_xon) (portid)\n"
498 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
499 "set flow_ctrl autoneg (on|off) (port_id)\n"
500 " Set the link flow control parameter on a port.\n\n"
502 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
503 " (low_water) (pause_time) (priority) (port_id)\n"
504 " Set the priority flow control parameter on a"
507 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
508 " Set statistics mapping (qmapping 0..15) for RX/TX"
510 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
511 " on port 0 to mapping 5.\n\n"
513 "set xstats-hide-zero on|off\n"
514 " Set the option to hide the zero values"
515 " for xstats display.\n"
517 "set port (port_id) vf (vf_id) rx|tx on|off\n"
518 " Enable/Disable a VF receive/tranmit from a port\n\n"
520 "set port (port_id) vf (vf_id) (mac_addr)"
521 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
522 " Add/Remove unicast or multicast MAC addr filter"
525 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
527 " AUPE:accepts untagged VLAN;"
528 "ROPE:accept unicast hash\n\n"
529 " BAM:accepts broadcast packets;"
530 "MPE:accepts all multicast packets\n\n"
531 " Enable/Disable a VF receive mode of a port\n\n"
533 "set port (port_id) queue (queue_id) rate (rate_num)\n"
534 " Set rate limit for a queue of a port\n\n"
536 "set port (port_id) vf (vf_id) rate (rate_num) "
537 "queue_mask (queue_mask_value)\n"
538 " Set rate limit for queues in VF of a port\n\n"
540 "set port (port_id) mirror-rule (rule_id)"
541 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
542 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
543 " Set pool or vlan type mirror rule on a port.\n"
544 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
545 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
548 "set port (port_id) mirror-rule (rule_id)"
549 " (uplink-mirror|downlink-mirror) dst-pool"
550 " (pool_id) (on|off)\n"
551 " Set uplink or downlink type mirror rule on a port.\n"
552 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
553 " 0 on' enable mirror income traffic to pool 0.\n\n"
555 "reset port (port_id) mirror-rule (rule_id)\n"
556 " Reset a mirror rule.\n\n"
558 "set flush_rx (on|off)\n"
559 " Flush (default) or don't flush RX streams before"
560 " forwarding. Mainly used with PCAP drivers.\n\n"
562 "set bypass mode (normal|bypass|isolate) (port_id)\n"
563 " Set the bypass mode for the lowest port on bypass enabled"
566 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
567 "mode (normal|bypass|isolate) (port_id)\n"
568 " Set the event required to initiate specified bypass mode for"
569 " the lowest port on a bypass enabled NIC where:\n"
570 " timeout = enable bypass after watchdog timeout.\n"
571 " os_on = enable bypass when OS/board is powered on.\n"
572 " os_off = enable bypass when OS/board is powered off.\n"
573 " power_on = enable bypass when power supply is turned on.\n"
574 " power_off = enable bypass when power supply is turned off."
577 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
578 " Set the bypass watchdog timeout to 'n' seconds"
579 " where 0 = instant.\n\n"
581 "show bypass config (port_id)\n"
582 " Show the bypass configuration for a bypass enabled NIC"
583 " using the lowest port on the NIC.\n\n"
585 #ifdef RTE_LIBRTE_PMD_BOND
586 "create bonded device (mode) (socket)\n"
587 " Create a new bonded device with specific bonding mode and socket.\n\n"
589 "add bonding slave (slave_id) (port_id)\n"
590 " Add a slave device to a bonded device.\n\n"
592 "remove bonding slave (slave_id) (port_id)\n"
593 " Remove a slave device from a bonded device.\n\n"
595 "set bonding mode (value) (port_id)\n"
596 " Set the bonding mode on a bonded device.\n\n"
598 "set bonding primary (slave_id) (port_id)\n"
599 " Set the primary slave for a bonded device.\n\n"
601 "show bonding config (port_id)\n"
602 " Show the bonding config for port_id.\n\n"
604 "set bonding mac_addr (port_id) (address)\n"
605 " Set the MAC address of a bonded device.\n\n"
607 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
608 " Set Aggregation mode for IEEE802.3AD (mode 4)"
610 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
611 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
613 "set bonding mon_period (port_id) (value)\n"
614 " Set the bonding link status monitoring polling period in ms.\n\n"
616 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
617 " Enable/disable dedicated queues for LACP control traffic.\n\n"
620 "set link-up port (port_id)\n"
621 " Set link up for a port.\n\n"
623 "set link-down port (port_id)\n"
624 " Set link down for a port.\n\n"
626 "E-tag set insertion on port-tag-id (value)"
627 " port (port_id) vf (vf_id)\n"
628 " Enable E-tag insertion for a VF on a port\n\n"
630 "E-tag set insertion off port (port_id) vf (vf_id)\n"
631 " Disable E-tag insertion for a VF on a port\n\n"
633 "E-tag set stripping (on|off) port (port_id)\n"
634 " Enable/disable E-tag stripping on a port\n\n"
636 "E-tag set forwarding (on|off) port (port_id)\n"
637 " Enable/disable E-tag based forwarding"
640 "E-tag set filter add e-tag-id (value) dst-pool"
641 " (pool_id) port (port_id)\n"
642 " Add an E-tag forwarding filter on a port\n\n"
644 "E-tag set filter del e-tag-id (value) port (port_id)\n"
645 " Delete an E-tag forwarding filter on a port\n\n"
647 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
648 "set port tm hierarchy default (port_id)\n"
649 " Set default traffic Management hierarchy on a port\n\n"
652 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
653 " Load a profile package on a port\n\n"
655 "ddp del (port_id) (backup_profile_path)\n"
656 " Delete a profile package from a port\n\n"
658 "ptype mapping get (port_id) (valid_only)\n"
659 " Get ptype mapping on a port\n\n"
661 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
662 " Replace target with the pkt_type in ptype mapping\n\n"
664 "ptype mapping reset (port_id)\n"
665 " Reset ptype mapping on a port\n\n"
667 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
668 " Update a ptype mapping item on a port\n\n"
670 "set port (port_id) queue-region region_id (value) "
671 "queue_start_index (value) queue_num (value)\n"
672 " Set a queue region on a port\n\n"
674 "set port (port_id) queue-region region_id (value) "
676 " Set a flowtype region index on a port\n\n"
678 "set port (port_id) queue-region UP (value) region_id (value)\n"
679 " Set the mapping of User Priority to "
680 "queue region on a port\n\n"
682 "set port (port_id) queue-region flush (on|off)\n"
683 " flush all queue region related configuration\n\n"
685 "show port meter cap (port_id)\n"
686 " Show port meter capability information\n\n"
688 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
689 " meter profile add - srtcm rfc 2697\n\n"
691 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
692 " meter profile add - trtcm rfc 2698\n\n"
694 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
695 " meter profile add - trtcm rfc 4115\n\n"
697 "del port meter profile (port_id) (profile_id)\n"
698 " meter profile delete\n\n"
700 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
701 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
702 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
703 "(dscp_tbl_entry63)]\n"
706 "enable port meter (port_id) (mtr_id)\n"
709 "disable port meter (port_id) (mtr_id)\n"
712 "del port meter (port_id) (mtr_id)\n"
715 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
716 " meter update meter profile\n\n"
718 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
719 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
720 " update meter dscp table entries\n\n"
722 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
723 "(action0) [(action1) (action2)]\n"
724 " meter update policer action\n\n"
726 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
727 " meter update stats\n\n"
729 "show port (port_id) queue-region\n"
730 " show all queue region related configuration info\n\n"
732 "add port tm node shaper profile (port_id) (shaper_profile_id)"
733 " (tb_rate) (tb_size) (packet_length_adjust)\n"
734 " Add port tm node private shaper profile.\n\n"
736 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
737 " Delete port tm node private shaper profile.\n\n"
739 "add port tm node shared shaper (port_id) (shared_shaper_id)"
740 " (shaper_profile_id)\n"
741 " Add/update port tm node shared shaper.\n\n"
743 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
744 " Delete port tm node shared shaper.\n\n"
746 "set port tm node shaper profile (port_id) (node_id)"
747 " (shaper_profile_id)\n"
748 " Set port tm node shaper profile.\n\n"
750 "add port tm node wred profile (port_id) (wred_profile_id)"
751 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
752 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
753 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
754 " Add port tm node wred profile.\n\n"
756 "del port tm node wred profile (port_id) (wred_profile_id)\n"
757 " Delete port tm node wred profile.\n\n"
759 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
760 " (priority) (weight) (level_id) (shaper_profile_id)"
761 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
762 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
763 " Add port tm nonleaf node.\n\n"
765 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
766 " (priority) (weight) (level_id) (shaper_profile_id)"
767 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
768 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
769 " Add port tm leaf node.\n\n"
771 "del port tm node (port_id) (node_id)\n"
772 " Delete port tm node.\n\n"
774 "set port tm node parent (port_id) (node_id) (parent_node_id)"
775 " (priority) (weight)\n"
776 " Set port tm node parent.\n\n"
778 "suspend port tm node (port_id) (node_id)"
779 " Suspend tm node.\n\n"
781 "resume port tm node (port_id) (node_id)"
782 " Resume tm node.\n\n"
784 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
785 " Commit tm hierarchy.\n\n"
787 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
788 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
789 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
790 " Configure the VXLAN encapsulation for flows.\n\n"
792 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
793 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
794 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
795 " eth-dst (eth-dst)\n"
796 " Configure the VXLAN encapsulation for flows.\n\n"
798 , list_pkt_forwarding_modes()
802 if (show_all || !strcmp(res->section, "ports")) {
808 "----------------\n\n"
810 "port start (port_id|all)\n"
811 " Start all ports or port_id.\n\n"
813 "port stop (port_id|all)\n"
814 " Stop all ports or port_id.\n\n"
816 "port close (port_id|all)\n"
817 " Close all ports or port_id.\n\n"
819 "port attach (ident)\n"
820 " Attach physical or virtual dev by pci address or virtual device name\n\n"
822 "port detach (port_id)\n"
823 " Detach physical or virtual dev by port_id\n\n"
825 "port config (port_id|all)"
826 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
827 " duplex (half|full|auto)\n"
828 " Set speed and duplex for all ports or port_id\n\n"
830 "port config (port_id|all) loopback (mode)\n"
831 " Set loopback mode for all ports or port_id\n\n"
833 "port config all (rxq|txq|rxd|txd) (value)\n"
834 " Set number for rxq/txq/rxd/txd.\n\n"
836 "port config all max-pkt-len (value)\n"
837 " Set the max packet length.\n\n"
839 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
840 "hw-vlan-strip|hw-vlan-extend|drop-en)"
842 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
845 "port config all rss (all|default|ip|tcp|udp|sctp|"
846 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
847 " Set the RSS mode.\n\n"
849 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
850 " Set the RSS redirection table.\n\n"
852 "port config (port_id) dcb vt (on|off) (traffic_class)"
854 " Set the DCB mode.\n\n"
856 "port config all burst (value)\n"
857 " Set the number of packets per burst.\n\n"
859 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
861 " Set the ring prefetch/host/writeback threshold"
862 " for tx/rx queue.\n\n"
864 "port config all (txfreet|txrst|rxfreet) (value)\n"
865 " Set free threshold for rx/tx, or set"
866 " tx rs bit threshold.\n\n"
867 "port config mtu X value\n"
868 " Set the MTU of port X to a given value\n\n"
870 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
871 " Set a rx/tx queue's ring size configuration, the new"
872 " value will take effect after command that (re-)start the port"
873 " or command that setup the specific queue\n\n"
875 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
876 " Start/stop a rx/tx queue of port X. Only take effect"
877 " when port X is started\n\n"
879 "port (port_id) (rxq|txq) (queue_id) setup\n"
880 " Setup a rx/tx queue of port X.\n\n"
882 "port config (port_id|all) l2-tunnel E-tag ether-type"
884 " Set the value of E-tag ether-type.\n\n"
886 "port config (port_id|all) l2-tunnel E-tag"
887 " (enable|disable)\n"
888 " Enable/disable the E-tag support.\n\n"
890 "port config (port_id) pctype mapping reset\n"
891 " Reset flow type to pctype mapping on a port\n\n"
893 "port config (port_id) pctype mapping update"
894 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
895 " Update a flow type to pctype mapping item on a port\n\n"
897 "port config (port_id) pctype (pctype_id) hash_inset|"
898 "fdir_inset|fdir_flx_inset get|set|clear field\n"
900 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
902 "port config (port_id) pctype (pctype_id) hash_inset|"
903 "fdir_inset|fdir_flx_inset clear all"
904 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
906 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
907 " Add/remove UDP tunnel port for tunneling offload\n\n"
911 if (show_all || !strcmp(res->section, "registers")) {
919 "read reg (port_id) (address)\n"
920 " Display value of a port register.\n\n"
922 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
923 " Display a port register bit field.\n\n"
925 "read regbit (port_id) (address) (bit_x)\n"
926 " Display a single port register bit.\n\n"
928 "write reg (port_id) (address) (value)\n"
929 " Set value of a port register.\n\n"
931 "write regfield (port_id) (address) (bit_x) (bit_y)"
933 " Set bit field of a port register.\n\n"
935 "write regbit (port_id) (address) (bit_x) (value)\n"
936 " Set single bit value of a port register.\n\n"
939 if (show_all || !strcmp(res->section, "filters")) {
947 "ethertype_filter (port_id) (add|del)"
948 " (mac_addr|mac_ignr) (mac_address) ethertype"
949 " (ether_type) (drop|fwd) queue (queue_id)\n"
950 " Add/Del an ethertype filter.\n\n"
952 "2tuple_filter (port_id) (add|del)"
953 " dst_port (dst_port_value) protocol (protocol_value)"
954 " mask (mask_value) tcp_flags (tcp_flags_value)"
955 " priority (prio_value) queue (queue_id)\n"
956 " Add/Del a 2tuple filter.\n\n"
958 "5tuple_filter (port_id) (add|del)"
959 " dst_ip (dst_address) src_ip (src_address)"
960 " dst_port (dst_port_value) src_port (src_port_value)"
961 " protocol (protocol_value)"
962 " mask (mask_value) tcp_flags (tcp_flags_value)"
963 " priority (prio_value) queue (queue_id)\n"
964 " Add/Del a 5tuple filter.\n\n"
966 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
967 " Add/Del syn filter.\n\n"
969 "flex_filter (port_id) (add|del) len (len_value)"
970 " bytes (bytes_value) mask (mask_value)"
971 " priority (prio_value) queue (queue_id)\n"
972 " Add/Del a flex filter.\n\n"
974 "flow_director_filter (port_id) mode IP (add|del|update)"
975 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
976 " src (src_ip_address) dst (dst_ip_address)"
977 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
978 " vlan (vlan_value) flexbytes (flexbytes_value)"
979 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
980 " fd_id (fd_id_value)\n"
981 " Add/Del an IP type flow director filter.\n\n"
983 "flow_director_filter (port_id) mode IP (add|del|update)"
984 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
985 " src (src_ip_address) (src_port)"
986 " dst (dst_ip_address) (dst_port)"
987 " tos (tos_value) ttl (ttl_value)"
988 " vlan (vlan_value) flexbytes (flexbytes_value)"
989 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
990 " fd_id (fd_id_value)\n"
991 " Add/Del an UDP/TCP type flow director filter.\n\n"
993 "flow_director_filter (port_id) mode IP (add|del|update)"
994 " flow (ipv4-sctp|ipv6-sctp)"
995 " src (src_ip_address) (src_port)"
996 " dst (dst_ip_address) (dst_port)"
997 " tag (verification_tag) "
998 " tos (tos_value) ttl (ttl_value)"
1000 " flexbytes (flexbytes_value) (drop|fwd)"
1001 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1002 " Add/Del a SCTP type flow director filter.\n\n"
1004 "flow_director_filter (port_id) mode IP (add|del|update)"
1005 " flow l2_payload ether (ethertype)"
1006 " flexbytes (flexbytes_value) (drop|fwd)"
1007 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1008 " Add/Del a l2 payload type flow director filter.\n\n"
1010 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1011 " mac (mac_address) vlan (vlan_value)"
1012 " flexbytes (flexbytes_value) (drop|fwd)"
1013 " queue (queue_id) fd_id (fd_id_value)\n"
1014 " Add/Del a MAC-VLAN flow director filter.\n\n"
1016 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1017 " mac (mac_address) vlan (vlan_value)"
1018 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1019 " flexbytes (flexbytes_value) (drop|fwd)"
1020 " queue (queue_id) fd_id (fd_id_value)\n"
1021 " Add/Del a Tunnel flow director filter.\n\n"
1023 "flow_director_filter (port_id) mode raw (add|del|update)"
1024 " flow (flow_id) (drop|fwd) queue (queue_id)"
1025 " fd_id (fd_id_value) packet (packet file name)\n"
1026 " Add/Del a raw type flow director filter.\n\n"
1028 "flush_flow_director (port_id)\n"
1029 " Flush all flow director entries of a device.\n\n"
1031 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1032 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1033 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1034 " Set flow director IP mask.\n\n"
1036 "flow_director_mask (port_id) mode MAC-VLAN"
1037 " vlan (vlan_value)\n"
1038 " Set flow director MAC-VLAN mask.\n\n"
1040 "flow_director_mask (port_id) mode Tunnel"
1041 " vlan (vlan_value) mac (mac_value)"
1042 " tunnel-type (tunnel_type_value)"
1043 " tunnel-id (tunnel_id_value)\n"
1044 " Set flow director Tunnel mask.\n\n"
1046 "flow_director_flex_mask (port_id)"
1047 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1048 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1050 " Configure mask of flex payload.\n\n"
1052 "flow_director_flex_payload (port_id)"
1053 " (raw|l2|l3|l4) (config)\n"
1054 " Configure flex payload selection.\n\n"
1056 "get_sym_hash_ena_per_port (port_id)\n"
1057 " get symmetric hash enable configuration per port.\n\n"
1059 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1060 " set symmetric hash enable configuration per port"
1061 " to enable or disable.\n\n"
1063 "get_hash_global_config (port_id)\n"
1064 " Get the global configurations of hash filters.\n\n"
1066 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1067 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1068 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1069 " (enable|disable)\n"
1070 " Set the global configurations of hash filters.\n\n"
1072 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1073 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1074 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1075 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1076 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1077 "ipv6-next-header|udp-src-port|udp-dst-port|"
1078 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1079 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1080 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1081 "fld-8th|none) (select|add)\n"
1082 " Set the input set for hash.\n\n"
1084 "set_fdir_input_set (port_id) "
1085 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1086 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1087 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1088 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1089 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1090 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1091 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1093 " Set the input set for FDir.\n\n"
1095 "flow validate {port_id}"
1096 " [group {group_id}] [priority {level}]"
1097 " [ingress] [egress]"
1098 " pattern {item} [/ {item} [...]] / end"
1099 " actions {action} [/ {action} [...]] / end\n"
1100 " Check whether a flow rule can be created.\n\n"
1102 "flow create {port_id}"
1103 " [group {group_id}] [priority {level}]"
1104 " [ingress] [egress]"
1105 " pattern {item} [/ {item} [...]] / end"
1106 " actions {action} [/ {action} [...]] / end\n"
1107 " Create a flow rule.\n\n"
1109 "flow destroy {port_id} rule {rule_id} [...]\n"
1110 " Destroy specific flow rules.\n\n"
1112 "flow flush {port_id}\n"
1113 " Destroy all flow rules.\n\n"
1115 "flow query {port_id} {rule_id} {action}\n"
1116 " Query an existing flow rule.\n\n"
1118 "flow list {port_id} [group {group_id}] [...]\n"
1119 " List existing flow rules sorted by priority,"
1120 " filtered by group identifiers.\n\n"
1122 "flow isolate {port_id} {boolean}\n"
1123 " Restrict ingress traffic to the defined"
1129 cmdline_parse_token_string_t cmd_help_long_help =
1130 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1132 cmdline_parse_token_string_t cmd_help_long_section =
1133 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1134 "all#control#display#config#"
1135 "ports#registers#filters");
1137 cmdline_parse_inst_t cmd_help_long = {
1138 .f = cmd_help_long_parsed,
1140 .help_str = "help all|control|display|config|ports|register|filters: "
1143 (void *)&cmd_help_long_help,
1144 (void *)&cmd_help_long_section,
1150 /* *** start/stop/close all ports *** */
1151 struct cmd_operate_port_result {
1152 cmdline_fixed_string_t keyword;
1153 cmdline_fixed_string_t name;
1154 cmdline_fixed_string_t value;
1157 static void cmd_operate_port_parsed(void *parsed_result,
1158 __attribute__((unused)) struct cmdline *cl,
1159 __attribute__((unused)) void *data)
1161 struct cmd_operate_port_result *res = parsed_result;
1163 if (!strcmp(res->name, "start"))
1164 start_port(RTE_PORT_ALL);
1165 else if (!strcmp(res->name, "stop"))
1166 stop_port(RTE_PORT_ALL);
1167 else if (!strcmp(res->name, "close"))
1168 close_port(RTE_PORT_ALL);
1169 else if (!strcmp(res->name, "reset"))
1170 reset_port(RTE_PORT_ALL);
1172 printf("Unknown parameter\n");
1175 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1176 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1178 cmdline_parse_token_string_t cmd_operate_port_all_port =
1179 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1180 "start#stop#close#reset");
1181 cmdline_parse_token_string_t cmd_operate_port_all_all =
1182 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1184 cmdline_parse_inst_t cmd_operate_port = {
1185 .f = cmd_operate_port_parsed,
1187 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1189 (void *)&cmd_operate_port_all_cmd,
1190 (void *)&cmd_operate_port_all_port,
1191 (void *)&cmd_operate_port_all_all,
1196 /* *** start/stop/close specific port *** */
1197 struct cmd_operate_specific_port_result {
1198 cmdline_fixed_string_t keyword;
1199 cmdline_fixed_string_t name;
1203 static void cmd_operate_specific_port_parsed(void *parsed_result,
1204 __attribute__((unused)) struct cmdline *cl,
1205 __attribute__((unused)) void *data)
1207 struct cmd_operate_specific_port_result *res = parsed_result;
1209 if (!strcmp(res->name, "start"))
1210 start_port(res->value);
1211 else if (!strcmp(res->name, "stop"))
1212 stop_port(res->value);
1213 else if (!strcmp(res->name, "close"))
1214 close_port(res->value);
1215 else if (!strcmp(res->name, "reset"))
1216 reset_port(res->value);
1218 printf("Unknown parameter\n");
1221 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1222 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1224 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1225 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1226 name, "start#stop#close#reset");
1227 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1228 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1231 cmdline_parse_inst_t cmd_operate_specific_port = {
1232 .f = cmd_operate_specific_port_parsed,
1234 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1236 (void *)&cmd_operate_specific_port_cmd,
1237 (void *)&cmd_operate_specific_port_port,
1238 (void *)&cmd_operate_specific_port_id,
1243 /* *** attach a specified port *** */
1244 struct cmd_operate_attach_port_result {
1245 cmdline_fixed_string_t port;
1246 cmdline_fixed_string_t keyword;
1247 cmdline_fixed_string_t identifier;
1250 static void cmd_operate_attach_port_parsed(void *parsed_result,
1251 __attribute__((unused)) struct cmdline *cl,
1252 __attribute__((unused)) void *data)
1254 struct cmd_operate_attach_port_result *res = parsed_result;
1256 if (!strcmp(res->keyword, "attach"))
1257 attach_port(res->identifier);
1259 printf("Unknown parameter\n");
1262 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1263 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1265 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1266 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1268 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1269 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1272 cmdline_parse_inst_t cmd_operate_attach_port = {
1273 .f = cmd_operate_attach_port_parsed,
1275 .help_str = "port attach <identifier>: "
1276 "(identifier: pci address or virtual dev name)",
1278 (void *)&cmd_operate_attach_port_port,
1279 (void *)&cmd_operate_attach_port_keyword,
1280 (void *)&cmd_operate_attach_port_identifier,
1285 /* *** detach a specified port *** */
1286 struct cmd_operate_detach_port_result {
1287 cmdline_fixed_string_t port;
1288 cmdline_fixed_string_t keyword;
1292 static void cmd_operate_detach_port_parsed(void *parsed_result,
1293 __attribute__((unused)) struct cmdline *cl,
1294 __attribute__((unused)) void *data)
1296 struct cmd_operate_detach_port_result *res = parsed_result;
1298 if (!strcmp(res->keyword, "detach"))
1299 detach_port(res->port_id);
1301 printf("Unknown parameter\n");
1304 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1305 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1307 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1308 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1310 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1311 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1314 cmdline_parse_inst_t cmd_operate_detach_port = {
1315 .f = cmd_operate_detach_port_parsed,
1317 .help_str = "port detach <port_id>",
1319 (void *)&cmd_operate_detach_port_port,
1320 (void *)&cmd_operate_detach_port_keyword,
1321 (void *)&cmd_operate_detach_port_port_id,
1326 /* *** configure speed for all ports *** */
1327 struct cmd_config_speed_all {
1328 cmdline_fixed_string_t port;
1329 cmdline_fixed_string_t keyword;
1330 cmdline_fixed_string_t all;
1331 cmdline_fixed_string_t item1;
1332 cmdline_fixed_string_t item2;
1333 cmdline_fixed_string_t value1;
1334 cmdline_fixed_string_t value2;
1338 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1343 if (!strcmp(duplexstr, "half")) {
1344 duplex = ETH_LINK_HALF_DUPLEX;
1345 } else if (!strcmp(duplexstr, "full")) {
1346 duplex = ETH_LINK_FULL_DUPLEX;
1347 } else if (!strcmp(duplexstr, "auto")) {
1348 duplex = ETH_LINK_FULL_DUPLEX;
1350 printf("Unknown duplex parameter\n");
1354 if (!strcmp(speedstr, "10")) {
1355 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1356 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1357 } else if (!strcmp(speedstr, "100")) {
1358 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1359 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1361 if (duplex != ETH_LINK_FULL_DUPLEX) {
1362 printf("Invalid speed/duplex parameters\n");
1365 if (!strcmp(speedstr, "1000")) {
1366 *speed = ETH_LINK_SPEED_1G;
1367 } else if (!strcmp(speedstr, "10000")) {
1368 *speed = ETH_LINK_SPEED_10G;
1369 } else if (!strcmp(speedstr, "25000")) {
1370 *speed = ETH_LINK_SPEED_25G;
1371 } else if (!strcmp(speedstr, "40000")) {
1372 *speed = ETH_LINK_SPEED_40G;
1373 } else if (!strcmp(speedstr, "50000")) {
1374 *speed = ETH_LINK_SPEED_50G;
1375 } else if (!strcmp(speedstr, "100000")) {
1376 *speed = ETH_LINK_SPEED_100G;
1377 } else if (!strcmp(speedstr, "auto")) {
1378 *speed = ETH_LINK_SPEED_AUTONEG;
1380 printf("Unknown speed parameter\n");
1389 cmd_config_speed_all_parsed(void *parsed_result,
1390 __attribute__((unused)) struct cmdline *cl,
1391 __attribute__((unused)) void *data)
1393 struct cmd_config_speed_all *res = parsed_result;
1394 uint32_t link_speed;
1397 if (!all_ports_stopped()) {
1398 printf("Please stop all ports first\n");
1402 if (parse_and_check_speed_duplex(res->value1, res->value2,
1406 RTE_ETH_FOREACH_DEV(pid) {
1407 ports[pid].dev_conf.link_speeds = link_speed;
1410 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1413 cmdline_parse_token_string_t cmd_config_speed_all_port =
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1415 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1416 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1418 cmdline_parse_token_string_t cmd_config_speed_all_all =
1419 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1420 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1421 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1422 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1424 "10#100#1000#10000#25000#40000#50000#100000#auto");
1425 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1426 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1427 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1428 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1431 cmdline_parse_inst_t cmd_config_speed_all = {
1432 .f = cmd_config_speed_all_parsed,
1434 .help_str = "port config all speed "
1435 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1438 (void *)&cmd_config_speed_all_port,
1439 (void *)&cmd_config_speed_all_keyword,
1440 (void *)&cmd_config_speed_all_all,
1441 (void *)&cmd_config_speed_all_item1,
1442 (void *)&cmd_config_speed_all_value1,
1443 (void *)&cmd_config_speed_all_item2,
1444 (void *)&cmd_config_speed_all_value2,
1449 /* *** configure speed for specific port *** */
1450 struct cmd_config_speed_specific {
1451 cmdline_fixed_string_t port;
1452 cmdline_fixed_string_t keyword;
1454 cmdline_fixed_string_t item1;
1455 cmdline_fixed_string_t item2;
1456 cmdline_fixed_string_t value1;
1457 cmdline_fixed_string_t value2;
1461 cmd_config_speed_specific_parsed(void *parsed_result,
1462 __attribute__((unused)) struct cmdline *cl,
1463 __attribute__((unused)) void *data)
1465 struct cmd_config_speed_specific *res = parsed_result;
1466 uint32_t link_speed;
1468 if (!all_ports_stopped()) {
1469 printf("Please stop all ports first\n");
1473 if (port_id_is_invalid(res->id, ENABLED_WARN))
1476 if (parse_and_check_speed_duplex(res->value1, res->value2,
1480 ports[res->id].dev_conf.link_speeds = link_speed;
1482 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1486 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1487 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1489 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1492 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1493 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1494 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1495 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1497 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1499 "10#100#1000#10000#25000#40000#50000#100000#auto");
1500 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1501 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1503 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1504 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1507 cmdline_parse_inst_t cmd_config_speed_specific = {
1508 .f = cmd_config_speed_specific_parsed,
1510 .help_str = "port config <port_id> speed "
1511 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1514 (void *)&cmd_config_speed_specific_port,
1515 (void *)&cmd_config_speed_specific_keyword,
1516 (void *)&cmd_config_speed_specific_id,
1517 (void *)&cmd_config_speed_specific_item1,
1518 (void *)&cmd_config_speed_specific_value1,
1519 (void *)&cmd_config_speed_specific_item2,
1520 (void *)&cmd_config_speed_specific_value2,
1525 /* *** configure loopback for all ports *** */
1526 struct cmd_config_loopback_all {
1527 cmdline_fixed_string_t port;
1528 cmdline_fixed_string_t keyword;
1529 cmdline_fixed_string_t all;
1530 cmdline_fixed_string_t item;
1535 cmd_config_loopback_all_parsed(void *parsed_result,
1536 __attribute__((unused)) struct cmdline *cl,
1537 __attribute__((unused)) void *data)
1539 struct cmd_config_loopback_all *res = parsed_result;
1542 if (!all_ports_stopped()) {
1543 printf("Please stop all ports first\n");
1547 RTE_ETH_FOREACH_DEV(pid) {
1548 ports[pid].dev_conf.lpbk_mode = res->mode;
1551 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1554 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1555 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1556 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1557 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1559 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1561 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1564 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1565 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1567 cmdline_parse_inst_t cmd_config_loopback_all = {
1568 .f = cmd_config_loopback_all_parsed,
1570 .help_str = "port config all loopback <mode>",
1572 (void *)&cmd_config_loopback_all_port,
1573 (void *)&cmd_config_loopback_all_keyword,
1574 (void *)&cmd_config_loopback_all_all,
1575 (void *)&cmd_config_loopback_all_item,
1576 (void *)&cmd_config_loopback_all_mode,
1581 /* *** configure loopback for specific port *** */
1582 struct cmd_config_loopback_specific {
1583 cmdline_fixed_string_t port;
1584 cmdline_fixed_string_t keyword;
1586 cmdline_fixed_string_t item;
1591 cmd_config_loopback_specific_parsed(void *parsed_result,
1592 __attribute__((unused)) struct cmdline *cl,
1593 __attribute__((unused)) void *data)
1595 struct cmd_config_loopback_specific *res = parsed_result;
1597 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1600 if (!port_is_stopped(res->port_id)) {
1601 printf("Please stop port %u first\n", res->port_id);
1605 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1607 cmd_reconfig_device_queue(res->port_id, 1, 1);
1611 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1612 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1614 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1615 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1617 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1618 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1620 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1621 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1623 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1624 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1627 cmdline_parse_inst_t cmd_config_loopback_specific = {
1628 .f = cmd_config_loopback_specific_parsed,
1630 .help_str = "port config <port_id> loopback <mode>",
1632 (void *)&cmd_config_loopback_specific_port,
1633 (void *)&cmd_config_loopback_specific_keyword,
1634 (void *)&cmd_config_loopback_specific_id,
1635 (void *)&cmd_config_loopback_specific_item,
1636 (void *)&cmd_config_loopback_specific_mode,
1641 /* *** configure txq/rxq, txd/rxd *** */
1642 struct cmd_config_rx_tx {
1643 cmdline_fixed_string_t port;
1644 cmdline_fixed_string_t keyword;
1645 cmdline_fixed_string_t all;
1646 cmdline_fixed_string_t name;
1651 cmd_config_rx_tx_parsed(void *parsed_result,
1652 __attribute__((unused)) struct cmdline *cl,
1653 __attribute__((unused)) void *data)
1655 struct cmd_config_rx_tx *res = parsed_result;
1657 if (!all_ports_stopped()) {
1658 printf("Please stop all ports first\n");
1661 if (!strcmp(res->name, "rxq")) {
1662 if (!res->value && !nb_txq) {
1663 printf("Warning: Either rx or tx queues should be non zero\n");
1666 if (check_nb_rxq(res->value) != 0)
1668 nb_rxq = res->value;
1670 else if (!strcmp(res->name, "txq")) {
1671 if (!res->value && !nb_rxq) {
1672 printf("Warning: Either rx or tx queues should be non zero\n");
1675 if (check_nb_txq(res->value) != 0)
1677 nb_txq = res->value;
1679 else if (!strcmp(res->name, "rxd")) {
1680 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1681 printf("rxd %d invalid - must be > 0 && <= %d\n",
1682 res->value, RTE_TEST_RX_DESC_MAX);
1685 nb_rxd = res->value;
1686 } else if (!strcmp(res->name, "txd")) {
1687 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1688 printf("txd %d invalid - must be > 0 && <= %d\n",
1689 res->value, RTE_TEST_TX_DESC_MAX);
1692 nb_txd = res->value;
1694 printf("Unknown parameter\n");
1702 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1705 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1706 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1707 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1708 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1709 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1711 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1714 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1715 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1717 cmdline_parse_inst_t cmd_config_rx_tx = {
1718 .f = cmd_config_rx_tx_parsed,
1720 .help_str = "port config all rxq|txq|rxd|txd <value>",
1722 (void *)&cmd_config_rx_tx_port,
1723 (void *)&cmd_config_rx_tx_keyword,
1724 (void *)&cmd_config_rx_tx_all,
1725 (void *)&cmd_config_rx_tx_name,
1726 (void *)&cmd_config_rx_tx_value,
1731 /* *** config max packet length *** */
1732 struct cmd_config_max_pkt_len_result {
1733 cmdline_fixed_string_t port;
1734 cmdline_fixed_string_t keyword;
1735 cmdline_fixed_string_t all;
1736 cmdline_fixed_string_t name;
1741 cmd_config_max_pkt_len_parsed(void *parsed_result,
1742 __attribute__((unused)) struct cmdline *cl,
1743 __attribute__((unused)) void *data)
1745 struct cmd_config_max_pkt_len_result *res = parsed_result;
1748 if (!all_ports_stopped()) {
1749 printf("Please stop all ports first\n");
1753 RTE_ETH_FOREACH_DEV(pid) {
1754 struct rte_port *port = &ports[pid];
1755 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1757 if (!strcmp(res->name, "max-pkt-len")) {
1758 if (res->value < ETHER_MIN_LEN) {
1759 printf("max-pkt-len can not be less than %d\n",
1763 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1766 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1767 if (res->value > ETHER_MAX_LEN)
1768 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1770 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1771 port->dev_conf.rxmode.offloads = rx_offloads;
1773 printf("Unknown parameter\n");
1780 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1783 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1784 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1786 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1787 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1789 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1790 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1792 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1793 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1795 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1796 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1799 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1800 .f = cmd_config_max_pkt_len_parsed,
1802 .help_str = "port config all max-pkt-len <value>",
1804 (void *)&cmd_config_max_pkt_len_port,
1805 (void *)&cmd_config_max_pkt_len_keyword,
1806 (void *)&cmd_config_max_pkt_len_all,
1807 (void *)&cmd_config_max_pkt_len_name,
1808 (void *)&cmd_config_max_pkt_len_value,
1813 /* *** configure port MTU *** */
1814 struct cmd_config_mtu_result {
1815 cmdline_fixed_string_t port;
1816 cmdline_fixed_string_t keyword;
1817 cmdline_fixed_string_t mtu;
1823 cmd_config_mtu_parsed(void *parsed_result,
1824 __attribute__((unused)) struct cmdline *cl,
1825 __attribute__((unused)) void *data)
1827 struct cmd_config_mtu_result *res = parsed_result;
1829 if (res->value < ETHER_MIN_LEN) {
1830 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1833 port_mtu_set(res->port_id, res->value);
1836 cmdline_parse_token_string_t cmd_config_mtu_port =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1839 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1840 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1842 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1843 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1845 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1846 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1847 cmdline_parse_token_num_t cmd_config_mtu_value =
1848 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1850 cmdline_parse_inst_t cmd_config_mtu = {
1851 .f = cmd_config_mtu_parsed,
1853 .help_str = "port config mtu <port_id> <value>",
1855 (void *)&cmd_config_mtu_port,
1856 (void *)&cmd_config_mtu_keyword,
1857 (void *)&cmd_config_mtu_mtu,
1858 (void *)&cmd_config_mtu_port_id,
1859 (void *)&cmd_config_mtu_value,
1864 /* *** configure rx mode *** */
1865 struct cmd_config_rx_mode_flag {
1866 cmdline_fixed_string_t port;
1867 cmdline_fixed_string_t keyword;
1868 cmdline_fixed_string_t all;
1869 cmdline_fixed_string_t name;
1870 cmdline_fixed_string_t value;
1874 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1875 __attribute__((unused)) struct cmdline *cl,
1876 __attribute__((unused)) void *data)
1878 struct cmd_config_rx_mode_flag *res = parsed_result;
1881 if (!all_ports_stopped()) {
1882 printf("Please stop all ports first\n");
1886 RTE_ETH_FOREACH_DEV(pid) {
1887 struct rte_port *port;
1888 uint64_t rx_offloads;
1891 rx_offloads = port->dev_conf.rxmode.offloads;
1892 if (!strcmp(res->name, "crc-strip")) {
1893 if (!strcmp(res->value, "on"))
1894 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1895 else if (!strcmp(res->value, "off"))
1896 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1898 printf("Unknown parameter\n");
1901 } else if (!strcmp(res->name, "scatter")) {
1902 if (!strcmp(res->value, "on")) {
1903 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1904 } else if (!strcmp(res->value, "off")) {
1905 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1907 printf("Unknown parameter\n");
1910 } else if (!strcmp(res->name, "rx-cksum")) {
1911 if (!strcmp(res->value, "on"))
1912 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1913 else if (!strcmp(res->value, "off"))
1914 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1916 printf("Unknown parameter\n");
1919 } else if (!strcmp(res->name, "rx-timestamp")) {
1920 if (!strcmp(res->value, "on"))
1921 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1922 else if (!strcmp(res->value, "off"))
1923 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1925 printf("Unknown parameter\n");
1928 } else if (!strcmp(res->name, "hw-vlan")) {
1929 if (!strcmp(res->value, "on")) {
1930 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1931 DEV_RX_OFFLOAD_VLAN_STRIP);
1932 } else if (!strcmp(res->value, "off")) {
1933 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1934 DEV_RX_OFFLOAD_VLAN_STRIP);
1936 printf("Unknown parameter\n");
1939 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1940 if (!strcmp(res->value, "on"))
1941 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1942 else if (!strcmp(res->value, "off"))
1943 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1945 printf("Unknown parameter\n");
1948 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1949 if (!strcmp(res->value, "on"))
1950 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1951 else if (!strcmp(res->value, "off"))
1952 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1954 printf("Unknown parameter\n");
1957 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1958 if (!strcmp(res->value, "on"))
1959 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1960 else if (!strcmp(res->value, "off"))
1961 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1963 printf("Unknown parameter\n");
1966 } else if (!strcmp(res->name, "drop-en")) {
1967 if (!strcmp(res->value, "on"))
1969 else if (!strcmp(res->value, "off"))
1972 printf("Unknown parameter\n");
1976 printf("Unknown parameter\n");
1979 port->dev_conf.rxmode.offloads = rx_offloads;
1984 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1987 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1988 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1989 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1990 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1992 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1993 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1994 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1995 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1996 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1997 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1998 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1999 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2002 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2003 .f = cmd_config_rx_mode_flag_parsed,
2005 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2006 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2008 (void *)&cmd_config_rx_mode_flag_port,
2009 (void *)&cmd_config_rx_mode_flag_keyword,
2010 (void *)&cmd_config_rx_mode_flag_all,
2011 (void *)&cmd_config_rx_mode_flag_name,
2012 (void *)&cmd_config_rx_mode_flag_value,
2017 /* *** configure rss *** */
2018 struct cmd_config_rss {
2019 cmdline_fixed_string_t port;
2020 cmdline_fixed_string_t keyword;
2021 cmdline_fixed_string_t all;
2022 cmdline_fixed_string_t name;
2023 cmdline_fixed_string_t value;
2027 cmd_config_rss_parsed(void *parsed_result,
2028 __attribute__((unused)) struct cmdline *cl,
2029 __attribute__((unused)) void *data)
2031 struct cmd_config_rss *res = parsed_result;
2032 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2033 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2034 int use_default = 0;
2035 int all_updated = 1;
2039 if (!strcmp(res->value, "all"))
2040 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2041 ETH_RSS_UDP | ETH_RSS_SCTP |
2043 else if (!strcmp(res->value, "ip"))
2044 rss_conf.rss_hf = ETH_RSS_IP;
2045 else if (!strcmp(res->value, "udp"))
2046 rss_conf.rss_hf = ETH_RSS_UDP;
2047 else if (!strcmp(res->value, "tcp"))
2048 rss_conf.rss_hf = ETH_RSS_TCP;
2049 else if (!strcmp(res->value, "sctp"))
2050 rss_conf.rss_hf = ETH_RSS_SCTP;
2051 else if (!strcmp(res->value, "ether"))
2052 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2053 else if (!strcmp(res->value, "port"))
2054 rss_conf.rss_hf = ETH_RSS_PORT;
2055 else if (!strcmp(res->value, "vxlan"))
2056 rss_conf.rss_hf = ETH_RSS_VXLAN;
2057 else if (!strcmp(res->value, "geneve"))
2058 rss_conf.rss_hf = ETH_RSS_GENEVE;
2059 else if (!strcmp(res->value, "nvgre"))
2060 rss_conf.rss_hf = ETH_RSS_NVGRE;
2061 else if (!strcmp(res->value, "none"))
2062 rss_conf.rss_hf = 0;
2063 else if (!strcmp(res->value, "default"))
2065 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2066 atoi(res->value) < 64)
2067 rss_conf.rss_hf = 1ULL << atoi(res->value);
2069 printf("Unknown parameter\n");
2072 rss_conf.rss_key = NULL;
2073 /* Update global configuration for RSS types. */
2074 RTE_ETH_FOREACH_DEV(i) {
2075 struct rte_eth_rss_conf local_rss_conf;
2077 rte_eth_dev_info_get(i, &dev_info);
2079 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2081 local_rss_conf = rss_conf;
2082 local_rss_conf.rss_hf = rss_conf.rss_hf &
2083 dev_info.flow_type_rss_offloads;
2084 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2085 printf("Port %u modified RSS hash function based on hardware support,"
2086 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2087 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2089 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2092 printf("Configuration of RSS hash at ethernet port %d "
2093 "failed with error (%d): %s.\n",
2094 i, -diag, strerror(-diag));
2097 if (all_updated && !use_default)
2098 rss_hf = rss_conf.rss_hf;
2101 cmdline_parse_token_string_t cmd_config_rss_port =
2102 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2103 cmdline_parse_token_string_t cmd_config_rss_keyword =
2104 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2105 cmdline_parse_token_string_t cmd_config_rss_all =
2106 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2107 cmdline_parse_token_string_t cmd_config_rss_name =
2108 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2109 cmdline_parse_token_string_t cmd_config_rss_value =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2112 cmdline_parse_inst_t cmd_config_rss = {
2113 .f = cmd_config_rss_parsed,
2115 .help_str = "port config all rss "
2116 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2118 (void *)&cmd_config_rss_port,
2119 (void *)&cmd_config_rss_keyword,
2120 (void *)&cmd_config_rss_all,
2121 (void *)&cmd_config_rss_name,
2122 (void *)&cmd_config_rss_value,
2127 /* *** configure rss hash key *** */
2128 struct cmd_config_rss_hash_key {
2129 cmdline_fixed_string_t port;
2130 cmdline_fixed_string_t config;
2132 cmdline_fixed_string_t rss_hash_key;
2133 cmdline_fixed_string_t rss_type;
2134 cmdline_fixed_string_t key;
2138 hexa_digit_to_value(char hexa_digit)
2140 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2141 return (uint8_t) (hexa_digit - '0');
2142 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2143 return (uint8_t) ((hexa_digit - 'a') + 10);
2144 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2145 return (uint8_t) ((hexa_digit - 'A') + 10);
2146 /* Invalid hexa digit */
2151 parse_and_check_key_hexa_digit(char *key, int idx)
2155 hexa_v = hexa_digit_to_value(key[idx]);
2157 printf("invalid key: character %c at position %d is not a "
2158 "valid hexa digit\n", key[idx], idx);
2163 cmd_config_rss_hash_key_parsed(void *parsed_result,
2164 __attribute__((unused)) struct cmdline *cl,
2165 __attribute__((unused)) void *data)
2167 struct cmd_config_rss_hash_key *res = parsed_result;
2168 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2172 struct rte_eth_dev_info dev_info;
2173 uint8_t hash_key_size;
2176 memset(&dev_info, 0, sizeof(dev_info));
2177 rte_eth_dev_info_get(res->port_id, &dev_info);
2178 if (dev_info.hash_key_size > 0 &&
2179 dev_info.hash_key_size <= sizeof(hash_key))
2180 hash_key_size = dev_info.hash_key_size;
2182 printf("dev_info did not provide a valid hash key size\n");
2185 /* Check the length of the RSS hash key */
2186 key_len = strlen(res->key);
2187 if (key_len != (hash_key_size * 2)) {
2188 printf("key length: %d invalid - key must be a string of %d"
2189 " hexa-decimal numbers\n",
2190 (int) key_len, hash_key_size * 2);
2193 /* Translate RSS hash key into binary representation */
2194 for (i = 0; i < hash_key_size; i++) {
2195 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2198 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2201 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2203 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2207 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2208 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2209 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2210 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2212 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2213 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2214 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2215 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2216 rss_hash_key, "rss-hash-key");
2217 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2218 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2219 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2220 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2221 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2222 "ipv6-tcp-ex#ipv6-udp-ex");
2223 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2224 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2226 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2227 .f = cmd_config_rss_hash_key_parsed,
2229 .help_str = "port config <port_id> rss-hash-key "
2230 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2231 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2232 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2233 "<string of hex digits (variable length, NIC dependent)>",
2235 (void *)&cmd_config_rss_hash_key_port,
2236 (void *)&cmd_config_rss_hash_key_config,
2237 (void *)&cmd_config_rss_hash_key_port_id,
2238 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2239 (void *)&cmd_config_rss_hash_key_rss_type,
2240 (void *)&cmd_config_rss_hash_key_value,
2245 /* *** configure port rxq/txq ring size *** */
2246 struct cmd_config_rxtx_ring_size {
2247 cmdline_fixed_string_t port;
2248 cmdline_fixed_string_t config;
2250 cmdline_fixed_string_t rxtxq;
2252 cmdline_fixed_string_t rsize;
2257 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2258 __attribute__((unused)) struct cmdline *cl,
2259 __attribute__((unused)) void *data)
2261 struct cmd_config_rxtx_ring_size *res = parsed_result;
2262 struct rte_port *port;
2265 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2268 if (res->portid == (portid_t)RTE_PORT_ALL) {
2269 printf("Invalid port id\n");
2273 port = &ports[res->portid];
2275 if (!strcmp(res->rxtxq, "rxq"))
2277 else if (!strcmp(res->rxtxq, "txq"))
2280 printf("Unknown parameter\n");
2284 if (isrx && rx_queue_id_is_invalid(res->qid))
2286 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2289 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2290 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2296 port->nb_rx_desc[res->qid] = res->size;
2298 port->nb_tx_desc[res->qid] = res->size;
2300 cmd_reconfig_device_queue(res->portid, 0, 1);
2303 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2304 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2306 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2307 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2309 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2310 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2312 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2313 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2315 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2316 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2318 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2319 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2320 rsize, "ring_size");
2321 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2322 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2325 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2326 .f = cmd_config_rxtx_ring_size_parsed,
2328 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2330 (void *)&cmd_config_rxtx_ring_size_port,
2331 (void *)&cmd_config_rxtx_ring_size_config,
2332 (void *)&cmd_config_rxtx_ring_size_portid,
2333 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2334 (void *)&cmd_config_rxtx_ring_size_qid,
2335 (void *)&cmd_config_rxtx_ring_size_rsize,
2336 (void *)&cmd_config_rxtx_ring_size_size,
2341 /* *** configure port rxq/txq start/stop *** */
2342 struct cmd_config_rxtx_queue {
2343 cmdline_fixed_string_t port;
2345 cmdline_fixed_string_t rxtxq;
2347 cmdline_fixed_string_t opname;
2351 cmd_config_rxtx_queue_parsed(void *parsed_result,
2352 __attribute__((unused)) struct cmdline *cl,
2353 __attribute__((unused)) void *data)
2355 struct cmd_config_rxtx_queue *res = parsed_result;
2360 if (test_done == 0) {
2361 printf("Please stop forwarding first\n");
2365 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2368 if (port_is_started(res->portid) != 1) {
2369 printf("Please start port %u first\n", res->portid);
2373 if (!strcmp(res->rxtxq, "rxq"))
2375 else if (!strcmp(res->rxtxq, "txq"))
2378 printf("Unknown parameter\n");
2382 if (isrx && rx_queue_id_is_invalid(res->qid))
2384 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2387 if (!strcmp(res->opname, "start"))
2389 else if (!strcmp(res->opname, "stop"))
2392 printf("Unknown parameter\n");
2396 if (isstart && isrx)
2397 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2398 else if (!isstart && isrx)
2399 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2400 else if (isstart && !isrx)
2401 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2403 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2405 if (ret == -ENOTSUP)
2406 printf("Function not supported in PMD driver\n");
2409 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2410 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2411 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2412 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2413 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2414 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2415 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2416 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2417 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2418 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2421 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2422 .f = cmd_config_rxtx_queue_parsed,
2424 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2426 (void *)&cmd_config_rxtx_queue_port,
2427 (void *)&cmd_config_rxtx_queue_portid,
2428 (void *)&cmd_config_rxtx_queue_rxtxq,
2429 (void *)&cmd_config_rxtx_queue_qid,
2430 (void *)&cmd_config_rxtx_queue_opname,
2435 /* *** configure port rxq/txq setup *** */
2436 struct cmd_setup_rxtx_queue {
2437 cmdline_fixed_string_t port;
2439 cmdline_fixed_string_t rxtxq;
2441 cmdline_fixed_string_t setup;
2444 /* Common CLI fields for queue setup */
2445 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2446 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2447 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2448 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2449 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2450 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2451 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2452 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2453 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2454 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2457 cmd_setup_rxtx_queue_parsed(
2458 void *parsed_result,
2459 __attribute__((unused)) struct cmdline *cl,
2460 __attribute__((unused)) void *data)
2462 struct cmd_setup_rxtx_queue *res = parsed_result;
2463 struct rte_port *port;
2464 struct rte_mempool *mp;
2465 unsigned int socket_id;
2469 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2472 if (res->portid == (portid_t)RTE_PORT_ALL) {
2473 printf("Invalid port id\n");
2477 if (!strcmp(res->rxtxq, "rxq"))
2479 else if (!strcmp(res->rxtxq, "txq"))
2482 printf("Unknown parameter\n");
2486 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2487 printf("Invalid rx queue\n");
2489 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2490 printf("Invalid tx queue\n");
2494 port = &ports[res->portid];
2496 socket_id = rxring_numa[res->portid];
2497 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2498 socket_id = port->socket_id;
2500 mp = mbuf_pool_find(socket_id);
2502 printf("Failed to setup RX queue: "
2503 "No mempool allocation"
2504 " on the socket %d\n",
2505 rxring_numa[res->portid]);
2508 ret = rte_eth_rx_queue_setup(res->portid,
2510 port->nb_rx_desc[res->qid],
2512 &port->rx_conf[res->qid],
2515 printf("Failed to setup RX queue\n");
2517 socket_id = txring_numa[res->portid];
2518 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2519 socket_id = port->socket_id;
2521 ret = rte_eth_tx_queue_setup(res->portid,
2523 port->nb_tx_desc[res->qid],
2525 &port->tx_conf[res->qid]);
2527 printf("Failed to setup TX queue\n");
2531 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2532 .f = cmd_setup_rxtx_queue_parsed,
2534 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2536 (void *)&cmd_setup_rxtx_queue_port,
2537 (void *)&cmd_setup_rxtx_queue_portid,
2538 (void *)&cmd_setup_rxtx_queue_rxtxq,
2539 (void *)&cmd_setup_rxtx_queue_qid,
2540 (void *)&cmd_setup_rxtx_queue_setup,
2546 /* *** Configure RSS RETA *** */
2547 struct cmd_config_rss_reta {
2548 cmdline_fixed_string_t port;
2549 cmdline_fixed_string_t keyword;
2551 cmdline_fixed_string_t name;
2552 cmdline_fixed_string_t list_name;
2553 cmdline_fixed_string_t list_of_items;
2557 parse_reta_config(const char *str,
2558 struct rte_eth_rss_reta_entry64 *reta_conf,
2559 uint16_t nb_entries)
2563 uint16_t hash_index, idx, shift;
2566 const char *p, *p0 = str;
2573 unsigned long int_fld[_NUM_FLD];
2574 char *str_fld[_NUM_FLD];
2576 while ((p = strchr(p0,'(')) != NULL) {
2578 if((p0 = strchr(p,')')) == NULL)
2582 if(size >= sizeof(s))
2585 snprintf(s, sizeof(s), "%.*s", size, p);
2586 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2588 for (i = 0; i < _NUM_FLD; i++) {
2590 int_fld[i] = strtoul(str_fld[i], &end, 0);
2591 if (errno != 0 || end == str_fld[i] ||
2596 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2597 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2599 if (hash_index >= nb_entries) {
2600 printf("Invalid RETA hash index=%d\n", hash_index);
2604 idx = hash_index / RTE_RETA_GROUP_SIZE;
2605 shift = hash_index % RTE_RETA_GROUP_SIZE;
2606 reta_conf[idx].mask |= (1ULL << shift);
2607 reta_conf[idx].reta[shift] = nb_queue;
2614 cmd_set_rss_reta_parsed(void *parsed_result,
2615 __attribute__((unused)) struct cmdline *cl,
2616 __attribute__((unused)) void *data)
2619 struct rte_eth_dev_info dev_info;
2620 struct rte_eth_rss_reta_entry64 reta_conf[8];
2621 struct cmd_config_rss_reta *res = parsed_result;
2623 memset(&dev_info, 0, sizeof(dev_info));
2624 rte_eth_dev_info_get(res->port_id, &dev_info);
2625 if (dev_info.reta_size == 0) {
2626 printf("Redirection table size is 0 which is "
2627 "invalid for RSS\n");
2630 printf("The reta size of port %d is %u\n",
2631 res->port_id, dev_info.reta_size);
2632 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2633 printf("Currently do not support more than %u entries of "
2634 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2638 memset(reta_conf, 0, sizeof(reta_conf));
2639 if (!strcmp(res->list_name, "reta")) {
2640 if (parse_reta_config(res->list_of_items, reta_conf,
2641 dev_info.reta_size)) {
2642 printf("Invalid RSS Redirection Table "
2643 "config entered\n");
2646 ret = rte_eth_dev_rss_reta_update(res->port_id,
2647 reta_conf, dev_info.reta_size);
2649 printf("Bad redirection table parameter, "
2650 "return code = %d \n", ret);
2654 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2655 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2656 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2657 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2658 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2659 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2660 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2661 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2662 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2663 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2664 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2665 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2667 cmdline_parse_inst_t cmd_config_rss_reta = {
2668 .f = cmd_set_rss_reta_parsed,
2670 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2672 (void *)&cmd_config_rss_reta_port,
2673 (void *)&cmd_config_rss_reta_keyword,
2674 (void *)&cmd_config_rss_reta_port_id,
2675 (void *)&cmd_config_rss_reta_name,
2676 (void *)&cmd_config_rss_reta_list_name,
2677 (void *)&cmd_config_rss_reta_list_of_items,
2682 /* *** SHOW PORT RETA INFO *** */
2683 struct cmd_showport_reta {
2684 cmdline_fixed_string_t show;
2685 cmdline_fixed_string_t port;
2687 cmdline_fixed_string_t rss;
2688 cmdline_fixed_string_t reta;
2690 cmdline_fixed_string_t list_of_items;
2694 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2695 uint16_t nb_entries,
2699 const char *p, *p0 = str;
2704 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2705 RTE_RETA_GROUP_SIZE;
2708 p = strchr(p0, '(');
2712 p0 = strchr(p, ')');
2716 if (size >= sizeof(s)) {
2717 printf("The string size exceeds the internal buffer size\n");
2720 snprintf(s, sizeof(s), "%.*s", size, p);
2721 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2722 if (ret <= 0 || ret != num) {
2723 printf("The bits of masks do not match the number of "
2724 "reta entries: %u\n", num);
2727 for (i = 0; i < ret; i++)
2728 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2734 cmd_showport_reta_parsed(void *parsed_result,
2735 __attribute__((unused)) struct cmdline *cl,
2736 __attribute__((unused)) void *data)
2738 struct cmd_showport_reta *res = parsed_result;
2739 struct rte_eth_rss_reta_entry64 reta_conf[8];
2740 struct rte_eth_dev_info dev_info;
2741 uint16_t max_reta_size;
2743 memset(&dev_info, 0, sizeof(dev_info));
2744 rte_eth_dev_info_get(res->port_id, &dev_info);
2745 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2746 if (res->size == 0 || res->size > max_reta_size) {
2747 printf("Invalid redirection table size: %u (1-%u)\n",
2748 res->size, max_reta_size);
2752 memset(reta_conf, 0, sizeof(reta_conf));
2753 if (showport_parse_reta_config(reta_conf, res->size,
2754 res->list_of_items) < 0) {
2755 printf("Invalid string: %s for reta masks\n",
2756 res->list_of_items);
2759 port_rss_reta_info(res->port_id, reta_conf, res->size);
2762 cmdline_parse_token_string_t cmd_showport_reta_show =
2763 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2764 cmdline_parse_token_string_t cmd_showport_reta_port =
2765 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2766 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2767 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2768 cmdline_parse_token_string_t cmd_showport_reta_rss =
2769 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2770 cmdline_parse_token_string_t cmd_showport_reta_reta =
2771 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2772 cmdline_parse_token_num_t cmd_showport_reta_size =
2773 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2774 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2775 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2776 list_of_items, NULL);
2778 cmdline_parse_inst_t cmd_showport_reta = {
2779 .f = cmd_showport_reta_parsed,
2781 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2783 (void *)&cmd_showport_reta_show,
2784 (void *)&cmd_showport_reta_port,
2785 (void *)&cmd_showport_reta_port_id,
2786 (void *)&cmd_showport_reta_rss,
2787 (void *)&cmd_showport_reta_reta,
2788 (void *)&cmd_showport_reta_size,
2789 (void *)&cmd_showport_reta_list_of_items,
2794 /* *** Show RSS hash configuration *** */
2795 struct cmd_showport_rss_hash {
2796 cmdline_fixed_string_t show;
2797 cmdline_fixed_string_t port;
2799 cmdline_fixed_string_t rss_hash;
2800 cmdline_fixed_string_t rss_type;
2801 cmdline_fixed_string_t key; /* optional argument */
2804 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2805 __attribute__((unused)) struct cmdline *cl,
2808 struct cmd_showport_rss_hash *res = parsed_result;
2810 port_rss_hash_conf_show(res->port_id, res->rss_type,
2811 show_rss_key != NULL);
2814 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2815 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2816 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2817 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2818 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2819 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2820 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2821 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2823 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2824 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2825 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2826 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2827 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2828 "ipv6-tcp-ex#ipv6-udp-ex");
2829 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2830 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2832 cmdline_parse_inst_t cmd_showport_rss_hash = {
2833 .f = cmd_showport_rss_hash_parsed,
2835 .help_str = "show port <port_id> rss-hash "
2836 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2837 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2838 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2840 (void *)&cmd_showport_rss_hash_show,
2841 (void *)&cmd_showport_rss_hash_port,
2842 (void *)&cmd_showport_rss_hash_port_id,
2843 (void *)&cmd_showport_rss_hash_rss_hash,
2844 (void *)&cmd_showport_rss_hash_rss_hash_info,
2849 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2850 .f = cmd_showport_rss_hash_parsed,
2852 .help_str = "show port <port_id> rss-hash "
2853 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2854 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2855 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2857 (void *)&cmd_showport_rss_hash_show,
2858 (void *)&cmd_showport_rss_hash_port,
2859 (void *)&cmd_showport_rss_hash_port_id,
2860 (void *)&cmd_showport_rss_hash_rss_hash,
2861 (void *)&cmd_showport_rss_hash_rss_hash_info,
2862 (void *)&cmd_showport_rss_hash_rss_key,
2867 /* *** Configure DCB *** */
2868 struct cmd_config_dcb {
2869 cmdline_fixed_string_t port;
2870 cmdline_fixed_string_t config;
2872 cmdline_fixed_string_t dcb;
2873 cmdline_fixed_string_t vt;
2874 cmdline_fixed_string_t vt_en;
2876 cmdline_fixed_string_t pfc;
2877 cmdline_fixed_string_t pfc_en;
2881 cmd_config_dcb_parsed(void *parsed_result,
2882 __attribute__((unused)) struct cmdline *cl,
2883 __attribute__((unused)) void *data)
2885 struct cmd_config_dcb *res = parsed_result;
2886 portid_t port_id = res->port_id;
2887 struct rte_port *port;
2891 port = &ports[port_id];
2892 /** Check if the port is not started **/
2893 if (port->port_status != RTE_PORT_STOPPED) {
2894 printf("Please stop port %d first\n", port_id);
2898 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2899 printf("The invalid number of traffic class,"
2900 " only 4 or 8 allowed.\n");
2904 if (nb_fwd_lcores < res->num_tcs) {
2905 printf("nb_cores shouldn't be less than number of TCs.\n");
2908 if (!strncmp(res->pfc_en, "on", 2))
2913 /* DCB in VT mode */
2914 if (!strncmp(res->vt_en, "on", 2))
2915 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2916 (enum rte_eth_nb_tcs)res->num_tcs,
2919 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2920 (enum rte_eth_nb_tcs)res->num_tcs,
2925 printf("Cannot initialize network ports.\n");
2929 cmd_reconfig_device_queue(port_id, 1, 1);
2932 cmdline_parse_token_string_t cmd_config_dcb_port =
2933 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2934 cmdline_parse_token_string_t cmd_config_dcb_config =
2935 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2936 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2937 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2938 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2939 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2940 cmdline_parse_token_string_t cmd_config_dcb_vt =
2941 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2942 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2943 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2944 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2945 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2946 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2947 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2948 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2949 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2951 cmdline_parse_inst_t cmd_config_dcb = {
2952 .f = cmd_config_dcb_parsed,
2954 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2956 (void *)&cmd_config_dcb_port,
2957 (void *)&cmd_config_dcb_config,
2958 (void *)&cmd_config_dcb_port_id,
2959 (void *)&cmd_config_dcb_dcb,
2960 (void *)&cmd_config_dcb_vt,
2961 (void *)&cmd_config_dcb_vt_en,
2962 (void *)&cmd_config_dcb_num_tcs,
2963 (void *)&cmd_config_dcb_pfc,
2964 (void *)&cmd_config_dcb_pfc_en,
2969 /* *** configure number of packets per burst *** */
2970 struct cmd_config_burst {
2971 cmdline_fixed_string_t port;
2972 cmdline_fixed_string_t keyword;
2973 cmdline_fixed_string_t all;
2974 cmdline_fixed_string_t name;
2979 cmd_config_burst_parsed(void *parsed_result,
2980 __attribute__((unused)) struct cmdline *cl,
2981 __attribute__((unused)) void *data)
2983 struct cmd_config_burst *res = parsed_result;
2984 struct rte_eth_dev_info dev_info;
2985 uint16_t rec_nb_pkts;
2987 if (!all_ports_stopped()) {
2988 printf("Please stop all ports first\n");
2992 if (!strcmp(res->name, "burst")) {
2993 if (res->value == 0) {
2994 /* If user gives a value of zero, query the PMD for
2995 * its recommended Rx burst size. Testpmd uses a single
2996 * size for all ports, so assume all ports are the same
2997 * NIC model and use the values from Port 0.
2999 rte_eth_dev_info_get(0, &dev_info);
3000 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3002 if (rec_nb_pkts == 0) {
3003 printf("PMD does not recommend a burst size.\n"
3004 "User provided value must be between"
3005 " 1 and %d\n", MAX_PKT_BURST);
3007 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3008 printf("PMD recommended burst size of %d"
3009 " exceeds maximum value of %d\n",
3010 rec_nb_pkts, MAX_PKT_BURST);
3013 printf("Using PMD-provided burst value of %d\n",
3015 nb_pkt_per_burst = rec_nb_pkts;
3016 } else if (res->value > MAX_PKT_BURST) {
3017 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3020 nb_pkt_per_burst = res->value;
3022 printf("Unknown parameter\n");
3028 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3031 cmdline_parse_token_string_t cmd_config_burst_port =
3032 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3033 cmdline_parse_token_string_t cmd_config_burst_keyword =
3034 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3035 cmdline_parse_token_string_t cmd_config_burst_all =
3036 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3037 cmdline_parse_token_string_t cmd_config_burst_name =
3038 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3039 cmdline_parse_token_num_t cmd_config_burst_value =
3040 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3042 cmdline_parse_inst_t cmd_config_burst = {
3043 .f = cmd_config_burst_parsed,
3045 .help_str = "port config all burst <value>",
3047 (void *)&cmd_config_burst_port,
3048 (void *)&cmd_config_burst_keyword,
3049 (void *)&cmd_config_burst_all,
3050 (void *)&cmd_config_burst_name,
3051 (void *)&cmd_config_burst_value,
3056 /* *** configure rx/tx queues *** */
3057 struct cmd_config_thresh {
3058 cmdline_fixed_string_t port;
3059 cmdline_fixed_string_t keyword;
3060 cmdline_fixed_string_t all;
3061 cmdline_fixed_string_t name;
3066 cmd_config_thresh_parsed(void *parsed_result,
3067 __attribute__((unused)) struct cmdline *cl,
3068 __attribute__((unused)) void *data)
3070 struct cmd_config_thresh *res = parsed_result;
3072 if (!all_ports_stopped()) {
3073 printf("Please stop all ports first\n");
3077 if (!strcmp(res->name, "txpt"))
3078 tx_pthresh = res->value;
3079 else if(!strcmp(res->name, "txht"))
3080 tx_hthresh = res->value;
3081 else if(!strcmp(res->name, "txwt"))
3082 tx_wthresh = res->value;
3083 else if(!strcmp(res->name, "rxpt"))
3084 rx_pthresh = res->value;
3085 else if(!strcmp(res->name, "rxht"))
3086 rx_hthresh = res->value;
3087 else if(!strcmp(res->name, "rxwt"))
3088 rx_wthresh = res->value;
3090 printf("Unknown parameter\n");
3096 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3099 cmdline_parse_token_string_t cmd_config_thresh_port =
3100 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3101 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3102 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3103 cmdline_parse_token_string_t cmd_config_thresh_all =
3104 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3105 cmdline_parse_token_string_t cmd_config_thresh_name =
3106 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3107 "txpt#txht#txwt#rxpt#rxht#rxwt");
3108 cmdline_parse_token_num_t cmd_config_thresh_value =
3109 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3111 cmdline_parse_inst_t cmd_config_thresh = {
3112 .f = cmd_config_thresh_parsed,
3114 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3116 (void *)&cmd_config_thresh_port,
3117 (void *)&cmd_config_thresh_keyword,
3118 (void *)&cmd_config_thresh_all,
3119 (void *)&cmd_config_thresh_name,
3120 (void *)&cmd_config_thresh_value,
3125 /* *** configure free/rs threshold *** */
3126 struct cmd_config_threshold {
3127 cmdline_fixed_string_t port;
3128 cmdline_fixed_string_t keyword;
3129 cmdline_fixed_string_t all;
3130 cmdline_fixed_string_t name;
3135 cmd_config_threshold_parsed(void *parsed_result,
3136 __attribute__((unused)) struct cmdline *cl,
3137 __attribute__((unused)) void *data)
3139 struct cmd_config_threshold *res = parsed_result;
3141 if (!all_ports_stopped()) {
3142 printf("Please stop all ports first\n");
3146 if (!strcmp(res->name, "txfreet"))
3147 tx_free_thresh = res->value;
3148 else if (!strcmp(res->name, "txrst"))
3149 tx_rs_thresh = res->value;
3150 else if (!strcmp(res->name, "rxfreet"))
3151 rx_free_thresh = res->value;
3153 printf("Unknown parameter\n");
3159 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3162 cmdline_parse_token_string_t cmd_config_threshold_port =
3163 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3164 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3165 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3167 cmdline_parse_token_string_t cmd_config_threshold_all =
3168 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3169 cmdline_parse_token_string_t cmd_config_threshold_name =
3170 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3171 "txfreet#txrst#rxfreet");
3172 cmdline_parse_token_num_t cmd_config_threshold_value =
3173 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3175 cmdline_parse_inst_t cmd_config_threshold = {
3176 .f = cmd_config_threshold_parsed,
3178 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3180 (void *)&cmd_config_threshold_port,
3181 (void *)&cmd_config_threshold_keyword,
3182 (void *)&cmd_config_threshold_all,
3183 (void *)&cmd_config_threshold_name,
3184 (void *)&cmd_config_threshold_value,
3190 struct cmd_stop_result {
3191 cmdline_fixed_string_t stop;
3194 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3195 __attribute__((unused)) struct cmdline *cl,
3196 __attribute__((unused)) void *data)
3198 stop_packet_forwarding();
3201 cmdline_parse_token_string_t cmd_stop_stop =
3202 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3204 cmdline_parse_inst_t cmd_stop = {
3205 .f = cmd_stop_parsed,
3207 .help_str = "stop: Stop packet forwarding",
3209 (void *)&cmd_stop_stop,
3214 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3217 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3218 unsigned int *parsed_items, int check_unique_values)
3220 unsigned int nb_item;
3228 * First parse all items in the list and store their value.
3233 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3235 if ((c >= '0') && (c <= '9')) {
3236 value = (unsigned int) (value * 10 + (c - '0'));
3241 printf("character %c is not a decimal digit\n", c);
3245 printf("No valid value before comma\n");
3248 if (nb_item < max_items) {
3249 parsed_items[nb_item] = value;
3255 if (nb_item >= max_items) {
3256 printf("Number of %s = %u > %u (maximum items)\n",
3257 item_name, nb_item + 1, max_items);
3260 parsed_items[nb_item++] = value;
3261 if (! check_unique_values)
3265 * Then, check that all values in the list are differents.
3266 * No optimization here...
3268 for (i = 0; i < nb_item; i++) {
3269 for (j = i + 1; j < nb_item; j++) {
3270 if (parsed_items[j] == parsed_items[i]) {
3271 printf("duplicated %s %u at index %u and %u\n",
3272 item_name, parsed_items[i], i, j);
3280 struct cmd_set_list_result {
3281 cmdline_fixed_string_t cmd_keyword;
3282 cmdline_fixed_string_t list_name;
3283 cmdline_fixed_string_t list_of_items;
3286 static void cmd_set_list_parsed(void *parsed_result,
3287 __attribute__((unused)) struct cmdline *cl,
3288 __attribute__((unused)) void *data)
3290 struct cmd_set_list_result *res;
3292 unsigned int lcorelist[RTE_MAX_LCORE];
3293 unsigned int portlist[RTE_MAX_ETHPORTS];
3295 unsigned int nb_item;
3297 if (test_done == 0) {
3298 printf("Please stop forwarding first\n");
3302 res = parsed_result;
3303 if (!strcmp(res->list_name, "corelist")) {
3304 nb_item = parse_item_list(res->list_of_items, "core",
3306 parsed_items.lcorelist, 1);
3308 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3313 if (!strcmp(res->list_name, "portlist")) {
3314 nb_item = parse_item_list(res->list_of_items, "port",
3316 parsed_items.portlist, 1);
3318 set_fwd_ports_list(parsed_items.portlist, nb_item);
3324 cmdline_parse_token_string_t cmd_set_list_keyword =
3325 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3327 cmdline_parse_token_string_t cmd_set_list_name =
3328 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3329 "corelist#portlist");
3330 cmdline_parse_token_string_t cmd_set_list_of_items =
3331 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3334 cmdline_parse_inst_t cmd_set_fwd_list = {
3335 .f = cmd_set_list_parsed,
3337 .help_str = "set corelist|portlist <list0[,list1]*>",
3339 (void *)&cmd_set_list_keyword,
3340 (void *)&cmd_set_list_name,
3341 (void *)&cmd_set_list_of_items,
3346 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3348 struct cmd_setmask_result {
3349 cmdline_fixed_string_t set;
3350 cmdline_fixed_string_t mask;
3354 static void cmd_set_mask_parsed(void *parsed_result,
3355 __attribute__((unused)) struct cmdline *cl,
3356 __attribute__((unused)) void *data)
3358 struct cmd_setmask_result *res = parsed_result;
3360 if (test_done == 0) {
3361 printf("Please stop forwarding first\n");
3364 if (!strcmp(res->mask, "coremask")) {
3365 set_fwd_lcores_mask(res->hexavalue);
3367 } else if (!strcmp(res->mask, "portmask")) {
3368 set_fwd_ports_mask(res->hexavalue);
3373 cmdline_parse_token_string_t cmd_setmask_set =
3374 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3375 cmdline_parse_token_string_t cmd_setmask_mask =
3376 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3377 "coremask#portmask");
3378 cmdline_parse_token_num_t cmd_setmask_value =
3379 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3381 cmdline_parse_inst_t cmd_set_fwd_mask = {
3382 .f = cmd_set_mask_parsed,
3384 .help_str = "set coremask|portmask <hexadecimal value>",
3386 (void *)&cmd_setmask_set,
3387 (void *)&cmd_setmask_mask,
3388 (void *)&cmd_setmask_value,
3394 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3396 struct cmd_set_result {
3397 cmdline_fixed_string_t set;
3398 cmdline_fixed_string_t what;
3402 static void cmd_set_parsed(void *parsed_result,
3403 __attribute__((unused)) struct cmdline *cl,
3404 __attribute__((unused)) void *data)
3406 struct cmd_set_result *res = parsed_result;
3407 if (!strcmp(res->what, "nbport")) {
3408 set_fwd_ports_number(res->value);
3410 } else if (!strcmp(res->what, "nbcore")) {
3411 set_fwd_lcores_number(res->value);
3413 } else if (!strcmp(res->what, "burst"))
3414 set_nb_pkt_per_burst(res->value);
3415 else if (!strcmp(res->what, "verbose"))
3416 set_verbose_level(res->value);
3419 cmdline_parse_token_string_t cmd_set_set =
3420 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3421 cmdline_parse_token_string_t cmd_set_what =
3422 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3423 "nbport#nbcore#burst#verbose");
3424 cmdline_parse_token_num_t cmd_set_value =
3425 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3427 cmdline_parse_inst_t cmd_set_numbers = {
3428 .f = cmd_set_parsed,
3430 .help_str = "set nbport|nbcore|burst|verbose <value>",
3432 (void *)&cmd_set_set,
3433 (void *)&cmd_set_what,
3434 (void *)&cmd_set_value,
3439 /* *** SET LOG LEVEL CONFIGURATION *** */
3441 struct cmd_set_log_result {
3442 cmdline_fixed_string_t set;
3443 cmdline_fixed_string_t log;
3444 cmdline_fixed_string_t type;
3449 cmd_set_log_parsed(void *parsed_result,
3450 __attribute__((unused)) struct cmdline *cl,
3451 __attribute__((unused)) void *data)
3453 struct cmd_set_log_result *res;
3456 res = parsed_result;
3457 if (!strcmp(res->type, "global"))
3458 rte_log_set_global_level(res->level);
3460 ret = rte_log_set_level_regexp(res->type, res->level);
3462 printf("Unable to set log level\n");
3466 cmdline_parse_token_string_t cmd_set_log_set =
3467 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3468 cmdline_parse_token_string_t cmd_set_log_log =
3469 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3470 cmdline_parse_token_string_t cmd_set_log_type =
3471 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3472 cmdline_parse_token_num_t cmd_set_log_level =
3473 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3475 cmdline_parse_inst_t cmd_set_log = {
3476 .f = cmd_set_log_parsed,
3478 .help_str = "set log global|<type> <level>",
3480 (void *)&cmd_set_log_set,
3481 (void *)&cmd_set_log_log,
3482 (void *)&cmd_set_log_type,
3483 (void *)&cmd_set_log_level,
3488 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3490 struct cmd_set_txpkts_result {
3491 cmdline_fixed_string_t cmd_keyword;
3492 cmdline_fixed_string_t txpkts;
3493 cmdline_fixed_string_t seg_lengths;
3497 cmd_set_txpkts_parsed(void *parsed_result,
3498 __attribute__((unused)) struct cmdline *cl,
3499 __attribute__((unused)) void *data)
3501 struct cmd_set_txpkts_result *res;
3502 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3503 unsigned int nb_segs;
3505 res = parsed_result;
3506 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3507 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3509 set_tx_pkt_segments(seg_lengths, nb_segs);
3512 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3513 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3514 cmd_keyword, "set");
3515 cmdline_parse_token_string_t cmd_set_txpkts_name =
3516 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3518 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3519 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3522 cmdline_parse_inst_t cmd_set_txpkts = {
3523 .f = cmd_set_txpkts_parsed,
3525 .help_str = "set txpkts <len0[,len1]*>",
3527 (void *)&cmd_set_txpkts_keyword,
3528 (void *)&cmd_set_txpkts_name,
3529 (void *)&cmd_set_txpkts_lengths,
3534 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3536 struct cmd_set_txsplit_result {
3537 cmdline_fixed_string_t cmd_keyword;
3538 cmdline_fixed_string_t txsplit;
3539 cmdline_fixed_string_t mode;
3543 cmd_set_txsplit_parsed(void *parsed_result,
3544 __attribute__((unused)) struct cmdline *cl,
3545 __attribute__((unused)) void *data)
3547 struct cmd_set_txsplit_result *res;
3549 res = parsed_result;
3550 set_tx_pkt_split(res->mode);
3553 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3554 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3555 cmd_keyword, "set");
3556 cmdline_parse_token_string_t cmd_set_txsplit_name =
3557 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3558 txsplit, "txsplit");
3559 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3560 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3563 cmdline_parse_inst_t cmd_set_txsplit = {
3564 .f = cmd_set_txsplit_parsed,
3566 .help_str = "set txsplit on|off|rand",
3568 (void *)&cmd_set_txsplit_keyword,
3569 (void *)&cmd_set_txsplit_name,
3570 (void *)&cmd_set_txsplit_mode,
3575 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3576 struct cmd_rx_vlan_filter_all_result {
3577 cmdline_fixed_string_t rx_vlan;
3578 cmdline_fixed_string_t what;
3579 cmdline_fixed_string_t all;
3584 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3585 __attribute__((unused)) struct cmdline *cl,
3586 __attribute__((unused)) void *data)
3588 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3590 if (!strcmp(res->what, "add"))
3591 rx_vlan_all_filter_set(res->port_id, 1);
3593 rx_vlan_all_filter_set(res->port_id, 0);
3596 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3597 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3598 rx_vlan, "rx_vlan");
3599 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3600 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3602 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3603 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3605 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3606 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3609 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3610 .f = cmd_rx_vlan_filter_all_parsed,
3612 .help_str = "rx_vlan add|rm all <port_id>: "
3613 "Add/Remove all identifiers to/from the set of VLAN "
3614 "identifiers filtered by a port",
3616 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3617 (void *)&cmd_rx_vlan_filter_all_what,
3618 (void *)&cmd_rx_vlan_filter_all_all,
3619 (void *)&cmd_rx_vlan_filter_all_portid,
3624 /* *** VLAN OFFLOAD SET ON A PORT *** */
3625 struct cmd_vlan_offload_result {
3626 cmdline_fixed_string_t vlan;
3627 cmdline_fixed_string_t set;
3628 cmdline_fixed_string_t vlan_type;
3629 cmdline_fixed_string_t what;
3630 cmdline_fixed_string_t on;
3631 cmdline_fixed_string_t port_id;
3635 cmd_vlan_offload_parsed(void *parsed_result,
3636 __attribute__((unused)) struct cmdline *cl,
3637 __attribute__((unused)) void *data)
3640 struct cmd_vlan_offload_result *res = parsed_result;
3643 portid_t port_id = 0;
3647 len = strnlen(str, STR_TOKEN_SIZE);
3649 /* Get port_id first */
3657 tmp = strtoul(str, NULL, 0);
3658 /* If port_id greater that what portid_t can represent, return */
3659 if(tmp >= RTE_MAX_ETHPORTS)
3661 port_id = (portid_t)tmp;
3663 if (!strcmp(res->on, "on"))
3668 if (!strcmp(res->what, "strip"))
3669 rx_vlan_strip_set(port_id, on);
3670 else if(!strcmp(res->what, "stripq")){
3671 uint16_t queue_id = 0;
3673 /* No queue_id, return */
3675 printf("must specify (port,queue_id)\n");
3678 tmp = strtoul(str + i + 1, NULL, 0);
3679 /* If queue_id greater that what 16-bits can represent, return */
3683 queue_id = (uint16_t)tmp;
3684 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3686 else if (!strcmp(res->what, "filter"))
3687 rx_vlan_filter_set(port_id, on);
3689 vlan_extend_set(port_id, on);
3694 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3695 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3697 cmdline_parse_token_string_t cmd_vlan_offload_set =
3698 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3700 cmdline_parse_token_string_t cmd_vlan_offload_what =
3701 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3702 what, "strip#filter#qinq#stripq");
3703 cmdline_parse_token_string_t cmd_vlan_offload_on =
3704 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3706 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3707 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3710 cmdline_parse_inst_t cmd_vlan_offload = {
3711 .f = cmd_vlan_offload_parsed,
3713 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3714 "<port_id[,queue_id]>: "
3715 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3717 (void *)&cmd_vlan_offload_vlan,
3718 (void *)&cmd_vlan_offload_set,
3719 (void *)&cmd_vlan_offload_what,
3720 (void *)&cmd_vlan_offload_on,
3721 (void *)&cmd_vlan_offload_portid,
3726 /* *** VLAN TPID SET ON A PORT *** */
3727 struct cmd_vlan_tpid_result {
3728 cmdline_fixed_string_t vlan;
3729 cmdline_fixed_string_t set;
3730 cmdline_fixed_string_t vlan_type;
3731 cmdline_fixed_string_t what;
3737 cmd_vlan_tpid_parsed(void *parsed_result,
3738 __attribute__((unused)) struct cmdline *cl,
3739 __attribute__((unused)) void *data)
3741 struct cmd_vlan_tpid_result *res = parsed_result;
3742 enum rte_vlan_type vlan_type;
3744 if (!strcmp(res->vlan_type, "inner"))
3745 vlan_type = ETH_VLAN_TYPE_INNER;
3746 else if (!strcmp(res->vlan_type, "outer"))
3747 vlan_type = ETH_VLAN_TYPE_OUTER;
3749 printf("Unknown vlan type\n");
3752 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3755 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3756 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3758 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3759 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3761 cmdline_parse_token_string_t cmd_vlan_type =
3762 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3763 vlan_type, "inner#outer");
3764 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3765 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3767 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3768 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3770 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3771 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3774 cmdline_parse_inst_t cmd_vlan_tpid = {
3775 .f = cmd_vlan_tpid_parsed,
3777 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3778 "Set the VLAN Ether type",
3780 (void *)&cmd_vlan_tpid_vlan,
3781 (void *)&cmd_vlan_tpid_set,
3782 (void *)&cmd_vlan_type,
3783 (void *)&cmd_vlan_tpid_what,
3784 (void *)&cmd_vlan_tpid_tpid,
3785 (void *)&cmd_vlan_tpid_portid,
3790 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3791 struct cmd_rx_vlan_filter_result {
3792 cmdline_fixed_string_t rx_vlan;
3793 cmdline_fixed_string_t what;
3799 cmd_rx_vlan_filter_parsed(void *parsed_result,
3800 __attribute__((unused)) struct cmdline *cl,
3801 __attribute__((unused)) void *data)
3803 struct cmd_rx_vlan_filter_result *res = parsed_result;
3805 if (!strcmp(res->what, "add"))
3806 rx_vft_set(res->port_id, res->vlan_id, 1);
3808 rx_vft_set(res->port_id, res->vlan_id, 0);
3811 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3812 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3813 rx_vlan, "rx_vlan");
3814 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3815 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3817 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3818 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3820 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3821 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3824 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3825 .f = cmd_rx_vlan_filter_parsed,
3827 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3828 "Add/Remove a VLAN identifier to/from the set of VLAN "
3829 "identifiers filtered by a port",
3831 (void *)&cmd_rx_vlan_filter_rx_vlan,
3832 (void *)&cmd_rx_vlan_filter_what,
3833 (void *)&cmd_rx_vlan_filter_vlanid,
3834 (void *)&cmd_rx_vlan_filter_portid,
3839 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3840 struct cmd_tx_vlan_set_result {
3841 cmdline_fixed_string_t tx_vlan;
3842 cmdline_fixed_string_t set;
3848 cmd_tx_vlan_set_parsed(void *parsed_result,
3849 __attribute__((unused)) struct cmdline *cl,
3850 __attribute__((unused)) void *data)
3852 struct cmd_tx_vlan_set_result *res = parsed_result;
3854 if (!port_is_stopped(res->port_id)) {
3855 printf("Please stop port %d first\n", res->port_id);
3859 tx_vlan_set(res->port_id, res->vlan_id);
3861 cmd_reconfig_device_queue(res->port_id, 1, 1);
3864 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3865 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3866 tx_vlan, "tx_vlan");
3867 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3868 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3870 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3871 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3873 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3874 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3877 cmdline_parse_inst_t cmd_tx_vlan_set = {
3878 .f = cmd_tx_vlan_set_parsed,
3880 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3881 "Enable hardware insertion of a single VLAN header "
3882 "with a given TAG Identifier in packets sent on a port",
3884 (void *)&cmd_tx_vlan_set_tx_vlan,
3885 (void *)&cmd_tx_vlan_set_set,
3886 (void *)&cmd_tx_vlan_set_portid,
3887 (void *)&cmd_tx_vlan_set_vlanid,
3892 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3893 struct cmd_tx_vlan_set_qinq_result {
3894 cmdline_fixed_string_t tx_vlan;
3895 cmdline_fixed_string_t set;
3898 uint16_t vlan_id_outer;
3902 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3903 __attribute__((unused)) struct cmdline *cl,
3904 __attribute__((unused)) void *data)
3906 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3908 if (!port_is_stopped(res->port_id)) {
3909 printf("Please stop port %d first\n", res->port_id);
3913 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3915 cmd_reconfig_device_queue(res->port_id, 1, 1);
3918 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3919 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3920 tx_vlan, "tx_vlan");
3921 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3922 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3924 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3925 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3927 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3928 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3930 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3931 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3932 vlan_id_outer, UINT16);
3934 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3935 .f = cmd_tx_vlan_set_qinq_parsed,
3937 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3938 "Enable hardware insertion of double VLAN header "
3939 "with given TAG Identifiers in packets sent on a port",
3941 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3942 (void *)&cmd_tx_vlan_set_qinq_set,
3943 (void *)&cmd_tx_vlan_set_qinq_portid,
3944 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3945 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3950 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3951 struct cmd_tx_vlan_set_pvid_result {
3952 cmdline_fixed_string_t tx_vlan;
3953 cmdline_fixed_string_t set;
3954 cmdline_fixed_string_t pvid;
3957 cmdline_fixed_string_t mode;
3961 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3962 __attribute__((unused)) struct cmdline *cl,
3963 __attribute__((unused)) void *data)
3965 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3967 if (strcmp(res->mode, "on") == 0)
3968 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3970 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3973 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3974 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3975 tx_vlan, "tx_vlan");
3976 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3977 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3979 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3980 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3982 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3983 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3985 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3986 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3988 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3989 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3992 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3993 .f = cmd_tx_vlan_set_pvid_parsed,
3995 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3997 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3998 (void *)&cmd_tx_vlan_set_pvid_set,
3999 (void *)&cmd_tx_vlan_set_pvid_pvid,
4000 (void *)&cmd_tx_vlan_set_pvid_port_id,
4001 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4002 (void *)&cmd_tx_vlan_set_pvid_mode,
4007 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4008 struct cmd_tx_vlan_reset_result {
4009 cmdline_fixed_string_t tx_vlan;
4010 cmdline_fixed_string_t reset;
4015 cmd_tx_vlan_reset_parsed(void *parsed_result,
4016 __attribute__((unused)) struct cmdline *cl,
4017 __attribute__((unused)) void *data)
4019 struct cmd_tx_vlan_reset_result *res = parsed_result;
4021 if (!port_is_stopped(res->port_id)) {
4022 printf("Please stop port %d first\n", res->port_id);
4026 tx_vlan_reset(res->port_id);
4028 cmd_reconfig_device_queue(res->port_id, 1, 1);
4031 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4032 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4033 tx_vlan, "tx_vlan");
4034 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4035 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4037 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4038 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4041 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4042 .f = cmd_tx_vlan_reset_parsed,
4044 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4045 "VLAN header in packets sent on a port",
4047 (void *)&cmd_tx_vlan_reset_tx_vlan,
4048 (void *)&cmd_tx_vlan_reset_reset,
4049 (void *)&cmd_tx_vlan_reset_portid,
4055 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4056 struct cmd_csum_result {
4057 cmdline_fixed_string_t csum;
4058 cmdline_fixed_string_t mode;
4059 cmdline_fixed_string_t proto;
4060 cmdline_fixed_string_t hwsw;
4065 csum_show(int port_id)
4067 struct rte_eth_dev_info dev_info;
4068 uint64_t tx_offloads;
4070 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4071 printf("Parse tunnel is %s\n",
4072 (ports[port_id].parse_tunnel) ? "on" : "off");
4073 printf("IP checksum offload is %s\n",
4074 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4075 printf("UDP checksum offload is %s\n",
4076 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4077 printf("TCP checksum offload is %s\n",
4078 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4079 printf("SCTP checksum offload is %s\n",
4080 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4081 printf("Outer-Ip checksum offload is %s\n",
4082 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4084 /* display warnings if configuration is not supported by the NIC */
4085 rte_eth_dev_info_get(port_id, &dev_info);
4086 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4087 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4088 printf("Warning: hardware IP checksum enabled but not "
4089 "supported by port %d\n", port_id);
4091 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4092 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4093 printf("Warning: hardware UDP checksum enabled but not "
4094 "supported by port %d\n", port_id);
4096 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4097 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4098 printf("Warning: hardware TCP checksum enabled but not "
4099 "supported by port %d\n", port_id);
4101 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4102 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4103 printf("Warning: hardware SCTP checksum enabled but not "
4104 "supported by port %d\n", port_id);
4106 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4107 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4108 printf("Warning: hardware outer IP checksum enabled but not "
4109 "supported by port %d\n", port_id);
4114 cmd_csum_parsed(void *parsed_result,
4115 __attribute__((unused)) struct cmdline *cl,
4116 __attribute__((unused)) void *data)
4118 struct cmd_csum_result *res = parsed_result;
4120 uint64_t csum_offloads = 0;
4121 struct rte_eth_dev_info dev_info;
4123 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4124 printf("invalid port %d\n", res->port_id);
4127 if (!port_is_stopped(res->port_id)) {
4128 printf("Please stop port %d first\n", res->port_id);
4132 rte_eth_dev_info_get(res->port_id, &dev_info);
4133 if (!strcmp(res->mode, "set")) {
4135 if (!strcmp(res->hwsw, "hw"))
4138 if (!strcmp(res->proto, "ip")) {
4139 if (hw == 0 || (dev_info.tx_offload_capa &
4140 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4141 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4143 printf("IP checksum offload is not supported "
4144 "by port %u\n", res->port_id);
4146 } else if (!strcmp(res->proto, "udp")) {
4147 if (hw == 0 || (dev_info.tx_offload_capa &
4148 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4149 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4151 printf("UDP checksum offload is not supported "
4152 "by port %u\n", res->port_id);
4154 } else if (!strcmp(res->proto, "tcp")) {
4155 if (hw == 0 || (dev_info.tx_offload_capa &
4156 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4157 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4159 printf("TCP checksum offload is not supported "
4160 "by port %u\n", res->port_id);
4162 } else if (!strcmp(res->proto, "sctp")) {
4163 if (hw == 0 || (dev_info.tx_offload_capa &
4164 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4165 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4167 printf("SCTP checksum offload is not supported "
4168 "by port %u\n", res->port_id);
4170 } else if (!strcmp(res->proto, "outer-ip")) {
4171 if (hw == 0 || (dev_info.tx_offload_capa &
4172 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4174 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4176 printf("Outer IP checksum offload is not "
4177 "supported by port %u\n", res->port_id);
4182 ports[res->port_id].dev_conf.txmode.offloads |=
4185 ports[res->port_id].dev_conf.txmode.offloads &=
4189 csum_show(res->port_id);
4191 cmd_reconfig_device_queue(res->port_id, 1, 1);
4194 cmdline_parse_token_string_t cmd_csum_csum =
4195 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4197 cmdline_parse_token_string_t cmd_csum_mode =
4198 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4200 cmdline_parse_token_string_t cmd_csum_proto =
4201 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4202 proto, "ip#tcp#udp#sctp#outer-ip");
4203 cmdline_parse_token_string_t cmd_csum_hwsw =
4204 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4206 cmdline_parse_token_num_t cmd_csum_portid =
4207 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4210 cmdline_parse_inst_t cmd_csum_set = {
4211 .f = cmd_csum_parsed,
4213 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4214 "Enable/Disable hardware calculation of L3/L4 checksum when "
4215 "using csum forward engine",
4217 (void *)&cmd_csum_csum,
4218 (void *)&cmd_csum_mode,
4219 (void *)&cmd_csum_proto,
4220 (void *)&cmd_csum_hwsw,
4221 (void *)&cmd_csum_portid,
4226 cmdline_parse_token_string_t cmd_csum_mode_show =
4227 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4230 cmdline_parse_inst_t cmd_csum_show = {
4231 .f = cmd_csum_parsed,
4233 .help_str = "csum show <port_id>: Show checksum offload configuration",
4235 (void *)&cmd_csum_csum,
4236 (void *)&cmd_csum_mode_show,
4237 (void *)&cmd_csum_portid,
4242 /* Enable/disable tunnel parsing */
4243 struct cmd_csum_tunnel_result {
4244 cmdline_fixed_string_t csum;
4245 cmdline_fixed_string_t parse;
4246 cmdline_fixed_string_t onoff;
4251 cmd_csum_tunnel_parsed(void *parsed_result,
4252 __attribute__((unused)) struct cmdline *cl,
4253 __attribute__((unused)) void *data)
4255 struct cmd_csum_tunnel_result *res = parsed_result;
4257 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4260 if (!strcmp(res->onoff, "on"))
4261 ports[res->port_id].parse_tunnel = 1;
4263 ports[res->port_id].parse_tunnel = 0;
4265 csum_show(res->port_id);
4268 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4269 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4271 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4272 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4273 parse, "parse_tunnel");
4274 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4275 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4277 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4278 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4281 cmdline_parse_inst_t cmd_csum_tunnel = {
4282 .f = cmd_csum_tunnel_parsed,
4284 .help_str = "csum parse_tunnel on|off <port_id>: "
4285 "Enable/Disable parsing of tunnels for csum engine",
4287 (void *)&cmd_csum_tunnel_csum,
4288 (void *)&cmd_csum_tunnel_parse,
4289 (void *)&cmd_csum_tunnel_onoff,
4290 (void *)&cmd_csum_tunnel_portid,
4295 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4296 struct cmd_tso_set_result {
4297 cmdline_fixed_string_t tso;
4298 cmdline_fixed_string_t mode;
4304 cmd_tso_set_parsed(void *parsed_result,
4305 __attribute__((unused)) struct cmdline *cl,
4306 __attribute__((unused)) void *data)
4308 struct cmd_tso_set_result *res = parsed_result;
4309 struct rte_eth_dev_info dev_info;
4311 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4313 if (!port_is_stopped(res->port_id)) {
4314 printf("Please stop port %d first\n", res->port_id);
4318 if (!strcmp(res->mode, "set"))
4319 ports[res->port_id].tso_segsz = res->tso_segsz;
4321 rte_eth_dev_info_get(res->port_id, &dev_info);
4322 if ((ports[res->port_id].tso_segsz != 0) &&
4323 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4324 printf("Error: TSO is not supported by port %d\n",
4329 if (ports[res->port_id].tso_segsz == 0) {
4330 ports[res->port_id].dev_conf.txmode.offloads &=
4331 ~DEV_TX_OFFLOAD_TCP_TSO;
4332 printf("TSO for non-tunneled packets is disabled\n");
4334 ports[res->port_id].dev_conf.txmode.offloads |=
4335 DEV_TX_OFFLOAD_TCP_TSO;
4336 printf("TSO segment size for non-tunneled packets is %d\n",
4337 ports[res->port_id].tso_segsz);
4340 /* display warnings if configuration is not supported by the NIC */
4341 rte_eth_dev_info_get(res->port_id, &dev_info);
4342 if ((ports[res->port_id].tso_segsz != 0) &&
4343 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4344 printf("Warning: TSO enabled but not "
4345 "supported by port %d\n", res->port_id);
4348 cmd_reconfig_device_queue(res->port_id, 1, 1);
4351 cmdline_parse_token_string_t cmd_tso_set_tso =
4352 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4354 cmdline_parse_token_string_t cmd_tso_set_mode =
4355 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4357 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4358 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4360 cmdline_parse_token_num_t cmd_tso_set_portid =
4361 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4364 cmdline_parse_inst_t cmd_tso_set = {
4365 .f = cmd_tso_set_parsed,
4367 .help_str = "tso set <tso_segsz> <port_id>: "
4368 "Set TSO segment size of non-tunneled packets for csum engine "
4371 (void *)&cmd_tso_set_tso,
4372 (void *)&cmd_tso_set_mode,
4373 (void *)&cmd_tso_set_tso_segsz,
4374 (void *)&cmd_tso_set_portid,
4379 cmdline_parse_token_string_t cmd_tso_show_mode =
4380 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4384 cmdline_parse_inst_t cmd_tso_show = {
4385 .f = cmd_tso_set_parsed,
4387 .help_str = "tso show <port_id>: "
4388 "Show TSO segment size of non-tunneled packets for csum engine",
4390 (void *)&cmd_tso_set_tso,
4391 (void *)&cmd_tso_show_mode,
4392 (void *)&cmd_tso_set_portid,
4397 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4398 struct cmd_tunnel_tso_set_result {
4399 cmdline_fixed_string_t tso;
4400 cmdline_fixed_string_t mode;
4405 static struct rte_eth_dev_info
4406 check_tunnel_tso_nic_support(portid_t port_id)
4408 struct rte_eth_dev_info dev_info;
4410 rte_eth_dev_info_get(port_id, &dev_info);
4411 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4412 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4413 "not enabled for port %d\n", port_id);
4414 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4415 printf("Warning: GRE TUNNEL TSO not supported therefore "
4416 "not enabled for port %d\n", port_id);
4417 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4418 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4419 "not enabled for port %d\n", port_id);
4420 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4421 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4422 "not enabled for port %d\n", port_id);
4423 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4424 printf("Warning: IP TUNNEL TSO not supported therefore "
4425 "not enabled for port %d\n", port_id);
4426 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4427 printf("Warning: UDP TUNNEL TSO not supported therefore "
4428 "not enabled for port %d\n", port_id);
4433 cmd_tunnel_tso_set_parsed(void *parsed_result,
4434 __attribute__((unused)) struct cmdline *cl,
4435 __attribute__((unused)) void *data)
4437 struct cmd_tunnel_tso_set_result *res = parsed_result;
4438 struct rte_eth_dev_info dev_info;
4440 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4442 if (!port_is_stopped(res->port_id)) {
4443 printf("Please stop port %d first\n", res->port_id);
4447 if (!strcmp(res->mode, "set"))
4448 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4450 dev_info = check_tunnel_tso_nic_support(res->port_id);
4451 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4452 ports[res->port_id].dev_conf.txmode.offloads &=
4453 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4454 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4455 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4456 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4457 DEV_TX_OFFLOAD_IP_TNL_TSO |
4458 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4459 printf("TSO for tunneled packets is disabled\n");
4461 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4462 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4463 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4464 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4465 DEV_TX_OFFLOAD_IP_TNL_TSO |
4466 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4468 ports[res->port_id].dev_conf.txmode.offloads |=
4469 (tso_offloads & dev_info.tx_offload_capa);
4470 printf("TSO segment size for tunneled packets is %d\n",
4471 ports[res->port_id].tunnel_tso_segsz);
4473 /* Below conditions are needed to make it work:
4474 * (1) tunnel TSO is supported by the NIC;
4475 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4477 * (3) for tunneled pkts with outer L3 of IPv4,
4478 * "csum set outer-ip" must be set to hw, because after tso,
4479 * total_len of outer IP header is changed, and the checksum
4480 * of outer IP header calculated by sw should be wrong; that
4481 * is not necessary for IPv6 tunneled pkts because there's no
4482 * checksum in IP header anymore.
4485 if (!ports[res->port_id].parse_tunnel)
4486 printf("Warning: csum parse_tunnel must be set "
4487 "so that tunneled packets are recognized\n");
4488 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4489 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4490 printf("Warning: csum set outer-ip must be set to hw "
4491 "if outer L3 is IPv4; not necessary for IPv6\n");
4494 cmd_reconfig_device_queue(res->port_id, 1, 1);
4497 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4498 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4500 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4501 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4503 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4504 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4506 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4507 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4510 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4511 .f = cmd_tunnel_tso_set_parsed,
4513 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4514 "Set TSO segment size of tunneled packets for csum engine "
4517 (void *)&cmd_tunnel_tso_set_tso,
4518 (void *)&cmd_tunnel_tso_set_mode,
4519 (void *)&cmd_tunnel_tso_set_tso_segsz,
4520 (void *)&cmd_tunnel_tso_set_portid,
4525 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4526 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4530 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4531 .f = cmd_tunnel_tso_set_parsed,
4533 .help_str = "tunnel_tso show <port_id> "
4534 "Show TSO segment size of tunneled packets for csum engine",
4536 (void *)&cmd_tunnel_tso_set_tso,
4537 (void *)&cmd_tunnel_tso_show_mode,
4538 (void *)&cmd_tunnel_tso_set_portid,
4543 /* *** SET GRO FOR A PORT *** */
4544 struct cmd_gro_enable_result {
4545 cmdline_fixed_string_t cmd_set;
4546 cmdline_fixed_string_t cmd_port;
4547 cmdline_fixed_string_t cmd_keyword;
4548 cmdline_fixed_string_t cmd_onoff;
4553 cmd_gro_enable_parsed(void *parsed_result,
4554 __attribute__((unused)) struct cmdline *cl,
4555 __attribute__((unused)) void *data)
4557 struct cmd_gro_enable_result *res;
4559 res = parsed_result;
4560 if (!strcmp(res->cmd_keyword, "gro"))
4561 setup_gro(res->cmd_onoff, res->cmd_pid);
4564 cmdline_parse_token_string_t cmd_gro_enable_set =
4565 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4567 cmdline_parse_token_string_t cmd_gro_enable_port =
4568 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4569 cmd_keyword, "port");
4570 cmdline_parse_token_num_t cmd_gro_enable_pid =
4571 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4573 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4574 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4575 cmd_keyword, "gro");
4576 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4577 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4578 cmd_onoff, "on#off");
4580 cmdline_parse_inst_t cmd_gro_enable = {
4581 .f = cmd_gro_enable_parsed,
4583 .help_str = "set port <port_id> gro on|off",
4585 (void *)&cmd_gro_enable_set,
4586 (void *)&cmd_gro_enable_port,
4587 (void *)&cmd_gro_enable_pid,
4588 (void *)&cmd_gro_enable_keyword,
4589 (void *)&cmd_gro_enable_onoff,
4594 /* *** DISPLAY GRO CONFIGURATION *** */
4595 struct cmd_gro_show_result {
4596 cmdline_fixed_string_t cmd_show;
4597 cmdline_fixed_string_t cmd_port;
4598 cmdline_fixed_string_t cmd_keyword;
4603 cmd_gro_show_parsed(void *parsed_result,
4604 __attribute__((unused)) struct cmdline *cl,
4605 __attribute__((unused)) void *data)
4607 struct cmd_gro_show_result *res;
4609 res = parsed_result;
4610 if (!strcmp(res->cmd_keyword, "gro"))
4611 show_gro(res->cmd_pid);
4614 cmdline_parse_token_string_t cmd_gro_show_show =
4615 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4617 cmdline_parse_token_string_t cmd_gro_show_port =
4618 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4620 cmdline_parse_token_num_t cmd_gro_show_pid =
4621 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4623 cmdline_parse_token_string_t cmd_gro_show_keyword =
4624 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4625 cmd_keyword, "gro");
4627 cmdline_parse_inst_t cmd_gro_show = {
4628 .f = cmd_gro_show_parsed,
4630 .help_str = "show port <port_id> gro",
4632 (void *)&cmd_gro_show_show,
4633 (void *)&cmd_gro_show_port,
4634 (void *)&cmd_gro_show_pid,
4635 (void *)&cmd_gro_show_keyword,
4640 /* *** SET FLUSH CYCLES FOR GRO *** */
4641 struct cmd_gro_flush_result {
4642 cmdline_fixed_string_t cmd_set;
4643 cmdline_fixed_string_t cmd_keyword;
4644 cmdline_fixed_string_t cmd_flush;
4649 cmd_gro_flush_parsed(void *parsed_result,
4650 __attribute__((unused)) struct cmdline *cl,
4651 __attribute__((unused)) void *data)
4653 struct cmd_gro_flush_result *res;
4655 res = parsed_result;
4656 if ((!strcmp(res->cmd_keyword, "gro")) &&
4657 (!strcmp(res->cmd_flush, "flush")))
4658 setup_gro_flush_cycles(res->cmd_cycles);
4661 cmdline_parse_token_string_t cmd_gro_flush_set =
4662 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4664 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4665 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4666 cmd_keyword, "gro");
4667 cmdline_parse_token_string_t cmd_gro_flush_flush =
4668 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4669 cmd_flush, "flush");
4670 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4671 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4674 cmdline_parse_inst_t cmd_gro_flush = {
4675 .f = cmd_gro_flush_parsed,
4677 .help_str = "set gro flush <cycles>",
4679 (void *)&cmd_gro_flush_set,
4680 (void *)&cmd_gro_flush_keyword,
4681 (void *)&cmd_gro_flush_flush,
4682 (void *)&cmd_gro_flush_cycles,
4687 /* *** ENABLE/DISABLE GSO *** */
4688 struct cmd_gso_enable_result {
4689 cmdline_fixed_string_t cmd_set;
4690 cmdline_fixed_string_t cmd_port;
4691 cmdline_fixed_string_t cmd_keyword;
4692 cmdline_fixed_string_t cmd_mode;
4697 cmd_gso_enable_parsed(void *parsed_result,
4698 __attribute__((unused)) struct cmdline *cl,
4699 __attribute__((unused)) void *data)
4701 struct cmd_gso_enable_result *res;
4703 res = parsed_result;
4704 if (!strcmp(res->cmd_keyword, "gso"))
4705 setup_gso(res->cmd_mode, res->cmd_pid);
4708 cmdline_parse_token_string_t cmd_gso_enable_set =
4709 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4711 cmdline_parse_token_string_t cmd_gso_enable_port =
4712 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4714 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4715 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4716 cmd_keyword, "gso");
4717 cmdline_parse_token_string_t cmd_gso_enable_mode =
4718 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4719 cmd_mode, "on#off");
4720 cmdline_parse_token_num_t cmd_gso_enable_pid =
4721 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4724 cmdline_parse_inst_t cmd_gso_enable = {
4725 .f = cmd_gso_enable_parsed,
4727 .help_str = "set port <port_id> gso on|off",
4729 (void *)&cmd_gso_enable_set,
4730 (void *)&cmd_gso_enable_port,
4731 (void *)&cmd_gso_enable_pid,
4732 (void *)&cmd_gso_enable_keyword,
4733 (void *)&cmd_gso_enable_mode,
4738 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4739 struct cmd_gso_size_result {
4740 cmdline_fixed_string_t cmd_set;
4741 cmdline_fixed_string_t cmd_keyword;
4742 cmdline_fixed_string_t cmd_segsz;
4747 cmd_gso_size_parsed(void *parsed_result,
4748 __attribute__((unused)) struct cmdline *cl,
4749 __attribute__((unused)) void *data)
4751 struct cmd_gso_size_result *res = parsed_result;
4753 if (test_done == 0) {
4754 printf("Before setting GSO segsz, please first"
4755 " stop fowarding\n");
4759 if (!strcmp(res->cmd_keyword, "gso") &&
4760 !strcmp(res->cmd_segsz, "segsz")) {
4761 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4762 printf("gso_size should be larger than %zu."
4763 " Please input a legal value\n",
4764 RTE_GSO_SEG_SIZE_MIN);
4766 gso_max_segment_size = res->cmd_size;
4770 cmdline_parse_token_string_t cmd_gso_size_set =
4771 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4773 cmdline_parse_token_string_t cmd_gso_size_keyword =
4774 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4775 cmd_keyword, "gso");
4776 cmdline_parse_token_string_t cmd_gso_size_segsz =
4777 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4778 cmd_segsz, "segsz");
4779 cmdline_parse_token_num_t cmd_gso_size_size =
4780 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4783 cmdline_parse_inst_t cmd_gso_size = {
4784 .f = cmd_gso_size_parsed,
4786 .help_str = "set gso segsz <length>",
4788 (void *)&cmd_gso_size_set,
4789 (void *)&cmd_gso_size_keyword,
4790 (void *)&cmd_gso_size_segsz,
4791 (void *)&cmd_gso_size_size,
4796 /* *** SHOW GSO CONFIGURATION *** */
4797 struct cmd_gso_show_result {
4798 cmdline_fixed_string_t cmd_show;
4799 cmdline_fixed_string_t cmd_port;
4800 cmdline_fixed_string_t cmd_keyword;
4805 cmd_gso_show_parsed(void *parsed_result,
4806 __attribute__((unused)) struct cmdline *cl,
4807 __attribute__((unused)) void *data)
4809 struct cmd_gso_show_result *res = parsed_result;
4811 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4812 printf("invalid port id %u\n", res->cmd_pid);
4815 if (!strcmp(res->cmd_keyword, "gso")) {
4816 if (gso_ports[res->cmd_pid].enable) {
4817 printf("Max GSO'd packet size: %uB\n"
4818 "Supported GSO types: TCP/IPv4, "
4819 "UDP/IPv4, VxLAN with inner "
4820 "TCP/IPv4 packet, GRE with inner "
4821 "TCP/IPv4 packet\n",
4822 gso_max_segment_size);
4824 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4828 cmdline_parse_token_string_t cmd_gso_show_show =
4829 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4831 cmdline_parse_token_string_t cmd_gso_show_port =
4832 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4834 cmdline_parse_token_string_t cmd_gso_show_keyword =
4835 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4836 cmd_keyword, "gso");
4837 cmdline_parse_token_num_t cmd_gso_show_pid =
4838 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4841 cmdline_parse_inst_t cmd_gso_show = {
4842 .f = cmd_gso_show_parsed,
4844 .help_str = "show port <port_id> gso",
4846 (void *)&cmd_gso_show_show,
4847 (void *)&cmd_gso_show_port,
4848 (void *)&cmd_gso_show_pid,
4849 (void *)&cmd_gso_show_keyword,
4854 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4855 struct cmd_set_flush_rx {
4856 cmdline_fixed_string_t set;
4857 cmdline_fixed_string_t flush_rx;
4858 cmdline_fixed_string_t mode;
4862 cmd_set_flush_rx_parsed(void *parsed_result,
4863 __attribute__((unused)) struct cmdline *cl,
4864 __attribute__((unused)) void *data)
4866 struct cmd_set_flush_rx *res = parsed_result;
4867 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4870 cmdline_parse_token_string_t cmd_setflushrx_set =
4871 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4873 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4874 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4875 flush_rx, "flush_rx");
4876 cmdline_parse_token_string_t cmd_setflushrx_mode =
4877 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4881 cmdline_parse_inst_t cmd_set_flush_rx = {
4882 .f = cmd_set_flush_rx_parsed,
4883 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4886 (void *)&cmd_setflushrx_set,
4887 (void *)&cmd_setflushrx_flush_rx,
4888 (void *)&cmd_setflushrx_mode,
4893 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4894 struct cmd_set_link_check {
4895 cmdline_fixed_string_t set;
4896 cmdline_fixed_string_t link_check;
4897 cmdline_fixed_string_t mode;
4901 cmd_set_link_check_parsed(void *parsed_result,
4902 __attribute__((unused)) struct cmdline *cl,
4903 __attribute__((unused)) void *data)
4905 struct cmd_set_link_check *res = parsed_result;
4906 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4909 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4910 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4912 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4913 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4914 link_check, "link_check");
4915 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4916 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4920 cmdline_parse_inst_t cmd_set_link_check = {
4921 .f = cmd_set_link_check_parsed,
4922 .help_str = "set link_check on|off: Enable/Disable link status check "
4923 "when starting/stopping a port",
4926 (void *)&cmd_setlinkcheck_set,
4927 (void *)&cmd_setlinkcheck_link_check,
4928 (void *)&cmd_setlinkcheck_mode,
4933 /* *** SET NIC BYPASS MODE *** */
4934 struct cmd_set_bypass_mode_result {
4935 cmdline_fixed_string_t set;
4936 cmdline_fixed_string_t bypass;
4937 cmdline_fixed_string_t mode;
4938 cmdline_fixed_string_t value;
4943 cmd_set_bypass_mode_parsed(void *parsed_result,
4944 __attribute__((unused)) struct cmdline *cl,
4945 __attribute__((unused)) void *data)
4947 struct cmd_set_bypass_mode_result *res = parsed_result;
4948 portid_t port_id = res->port_id;
4949 int32_t rc = -EINVAL;
4951 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4952 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4954 if (!strcmp(res->value, "bypass"))
4955 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4956 else if (!strcmp(res->value, "isolate"))
4957 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4959 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4961 /* Set the bypass mode for the relevant port. */
4962 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4965 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4968 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4969 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4971 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4972 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4974 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4975 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4977 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4978 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4979 value, "normal#bypass#isolate");
4980 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4981 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4984 cmdline_parse_inst_t cmd_set_bypass_mode = {
4985 .f = cmd_set_bypass_mode_parsed,
4986 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4987 "Set the NIC bypass mode for port_id",
4990 (void *)&cmd_setbypass_mode_set,
4991 (void *)&cmd_setbypass_mode_bypass,
4992 (void *)&cmd_setbypass_mode_mode,
4993 (void *)&cmd_setbypass_mode_value,
4994 (void *)&cmd_setbypass_mode_port,
4999 /* *** SET NIC BYPASS EVENT *** */
5000 struct cmd_set_bypass_event_result {
5001 cmdline_fixed_string_t set;
5002 cmdline_fixed_string_t bypass;
5003 cmdline_fixed_string_t event;
5004 cmdline_fixed_string_t event_value;
5005 cmdline_fixed_string_t mode;
5006 cmdline_fixed_string_t mode_value;
5011 cmd_set_bypass_event_parsed(void *parsed_result,
5012 __attribute__((unused)) struct cmdline *cl,
5013 __attribute__((unused)) void *data)
5015 int32_t rc = -EINVAL;
5016 struct cmd_set_bypass_event_result *res = parsed_result;
5017 portid_t port_id = res->port_id;
5019 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5020 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5021 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5023 if (!strcmp(res->event_value, "timeout"))
5024 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5025 else if (!strcmp(res->event_value, "os_on"))
5026 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5027 else if (!strcmp(res->event_value, "os_off"))
5028 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5029 else if (!strcmp(res->event_value, "power_on"))
5030 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5031 else if (!strcmp(res->event_value, "power_off"))
5032 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5034 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5036 if (!strcmp(res->mode_value, "bypass"))
5037 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5038 else if (!strcmp(res->mode_value, "isolate"))
5039 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5041 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5043 /* Set the watchdog timeout. */
5044 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5047 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5048 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5052 printf("Failed to set timeout value %u "
5053 "for port %d, errto code: %d.\n",
5054 bypass_timeout, port_id, rc);
5058 /* Set the bypass event to transition to bypass mode. */
5059 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5064 printf("\t Failed to set bypass event for port = %d.\n",
5068 cmdline_parse_token_string_t cmd_setbypass_event_set =
5069 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5071 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5072 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5074 cmdline_parse_token_string_t cmd_setbypass_event_event =
5075 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5077 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5078 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5079 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5080 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5081 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5083 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5084 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5085 mode_value, "normal#bypass#isolate");
5086 cmdline_parse_token_num_t cmd_setbypass_event_port =
5087 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5090 cmdline_parse_inst_t cmd_set_bypass_event = {
5091 .f = cmd_set_bypass_event_parsed,
5092 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5093 "power_off mode normal|bypass|isolate <port_id>: "
5094 "Set the NIC bypass event mode for port_id",
5097 (void *)&cmd_setbypass_event_set,
5098 (void *)&cmd_setbypass_event_bypass,
5099 (void *)&cmd_setbypass_event_event,
5100 (void *)&cmd_setbypass_event_event_value,
5101 (void *)&cmd_setbypass_event_mode,
5102 (void *)&cmd_setbypass_event_mode_value,
5103 (void *)&cmd_setbypass_event_port,
5109 /* *** SET NIC BYPASS TIMEOUT *** */
5110 struct cmd_set_bypass_timeout_result {
5111 cmdline_fixed_string_t set;
5112 cmdline_fixed_string_t bypass;
5113 cmdline_fixed_string_t timeout;
5114 cmdline_fixed_string_t value;
5118 cmd_set_bypass_timeout_parsed(void *parsed_result,
5119 __attribute__((unused)) struct cmdline *cl,
5120 __attribute__((unused)) void *data)
5122 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5124 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5125 if (!strcmp(res->value, "1.5"))
5126 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5127 else if (!strcmp(res->value, "2"))
5128 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5129 else if (!strcmp(res->value, "3"))
5130 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5131 else if (!strcmp(res->value, "4"))
5132 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5133 else if (!strcmp(res->value, "8"))
5134 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5135 else if (!strcmp(res->value, "16"))
5136 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5137 else if (!strcmp(res->value, "32"))
5138 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5140 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5144 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5145 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5147 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5148 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5150 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5151 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5152 timeout, "timeout");
5153 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5154 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5155 value, "0#1.5#2#3#4#8#16#32");
5157 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5158 .f = cmd_set_bypass_timeout_parsed,
5159 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5160 "Set the NIC bypass watchdog timeout in seconds",
5163 (void *)&cmd_setbypass_timeout_set,
5164 (void *)&cmd_setbypass_timeout_bypass,
5165 (void *)&cmd_setbypass_timeout_timeout,
5166 (void *)&cmd_setbypass_timeout_value,
5171 /* *** SHOW NIC BYPASS MODE *** */
5172 struct cmd_show_bypass_config_result {
5173 cmdline_fixed_string_t show;
5174 cmdline_fixed_string_t bypass;
5175 cmdline_fixed_string_t config;
5180 cmd_show_bypass_config_parsed(void *parsed_result,
5181 __attribute__((unused)) struct cmdline *cl,
5182 __attribute__((unused)) void *data)
5184 struct cmd_show_bypass_config_result *res = parsed_result;
5185 portid_t port_id = res->port_id;
5187 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5188 uint32_t event_mode;
5189 uint32_t bypass_mode;
5190 uint32_t timeout = bypass_timeout;
5193 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5194 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5195 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5196 {"UNKNOWN", "normal", "bypass", "isolate"};
5197 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5204 int num_events = (sizeof events) / (sizeof events[0]);
5206 /* Display the bypass mode.*/
5207 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5208 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5212 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5213 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5215 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5218 /* Display the bypass timeout.*/
5219 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5220 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5222 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5224 /* Display the bypass events and associated modes. */
5225 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5227 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5228 printf("\tFailed to get bypass mode for event = %s\n",
5231 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5232 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5234 printf("\tbypass event: %-16s = %s\n", events[i],
5240 printf("\tFailed to get bypass configuration for port = %d\n",
5244 cmdline_parse_token_string_t cmd_showbypass_config_show =
5245 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5247 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5248 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5250 cmdline_parse_token_string_t cmd_showbypass_config_config =
5251 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5253 cmdline_parse_token_num_t cmd_showbypass_config_port =
5254 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5257 cmdline_parse_inst_t cmd_show_bypass_config = {
5258 .f = cmd_show_bypass_config_parsed,
5259 .help_str = "show bypass config <port_id>: "
5260 "Show the NIC bypass config for port_id",
5263 (void *)&cmd_showbypass_config_show,
5264 (void *)&cmd_showbypass_config_bypass,
5265 (void *)&cmd_showbypass_config_config,
5266 (void *)&cmd_showbypass_config_port,
5271 #ifdef RTE_LIBRTE_PMD_BOND
5272 /* *** SET BONDING MODE *** */
5273 struct cmd_set_bonding_mode_result {
5274 cmdline_fixed_string_t set;
5275 cmdline_fixed_string_t bonding;
5276 cmdline_fixed_string_t mode;
5281 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5282 __attribute__((unused)) struct cmdline *cl,
5283 __attribute__((unused)) void *data)
5285 struct cmd_set_bonding_mode_result *res = parsed_result;
5286 portid_t port_id = res->port_id;
5288 /* Set the bonding mode for the relevant port. */
5289 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5290 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5293 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5294 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5296 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5297 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5298 bonding, "bonding");
5299 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5300 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5302 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5303 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5305 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5306 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5309 cmdline_parse_inst_t cmd_set_bonding_mode = {
5310 .f = cmd_set_bonding_mode_parsed,
5311 .help_str = "set bonding mode <mode_value> <port_id>: "
5312 "Set the bonding mode for port_id",
5315 (void *) &cmd_setbonding_mode_set,
5316 (void *) &cmd_setbonding_mode_bonding,
5317 (void *) &cmd_setbonding_mode_mode,
5318 (void *) &cmd_setbonding_mode_value,
5319 (void *) &cmd_setbonding_mode_port,
5324 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5325 struct cmd_set_bonding_lacp_dedicated_queues_result {
5326 cmdline_fixed_string_t set;
5327 cmdline_fixed_string_t bonding;
5328 cmdline_fixed_string_t lacp;
5329 cmdline_fixed_string_t dedicated_queues;
5331 cmdline_fixed_string_t mode;
5334 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5335 __attribute__((unused)) struct cmdline *cl,
5336 __attribute__((unused)) void *data)
5338 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5339 portid_t port_id = res->port_id;
5340 struct rte_port *port;
5342 port = &ports[port_id];
5344 /** Check if the port is not started **/
5345 if (port->port_status != RTE_PORT_STOPPED) {
5346 printf("Please stop port %d first\n", port_id);
5350 if (!strcmp(res->mode, "enable")) {
5351 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5352 printf("Dedicate queues for LACP control packets"
5355 printf("Enabling dedicate queues for LACP control "
5356 "packets on port %d failed\n", port_id);
5357 } else if (!strcmp(res->mode, "disable")) {
5358 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5359 printf("Dedicated queues for LACP control packets "
5362 printf("Disabling dedicated queues for LACP control "
5363 "traffic on port %d failed\n", port_id);
5367 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5368 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5370 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5371 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5372 bonding, "bonding");
5373 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5374 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5376 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5377 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5378 dedicated_queues, "dedicated_queues");
5379 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5380 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5382 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5383 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5384 mode, "enable#disable");
5386 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5387 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5388 .help_str = "set bonding lacp dedicated_queues <port_id> "
5390 "Enable/disable dedicated queues for LACP control traffic for port_id",
5393 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5394 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5395 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5396 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5397 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5398 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5403 /* *** SET BALANCE XMIT POLICY *** */
5404 struct cmd_set_bonding_balance_xmit_policy_result {
5405 cmdline_fixed_string_t set;
5406 cmdline_fixed_string_t bonding;
5407 cmdline_fixed_string_t balance_xmit_policy;
5409 cmdline_fixed_string_t policy;
5412 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5413 __attribute__((unused)) struct cmdline *cl,
5414 __attribute__((unused)) void *data)
5416 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5417 portid_t port_id = res->port_id;
5420 if (!strcmp(res->policy, "l2")) {
5421 policy = BALANCE_XMIT_POLICY_LAYER2;
5422 } else if (!strcmp(res->policy, "l23")) {
5423 policy = BALANCE_XMIT_POLICY_LAYER23;
5424 } else if (!strcmp(res->policy, "l34")) {
5425 policy = BALANCE_XMIT_POLICY_LAYER34;
5427 printf("\t Invalid xmit policy selection");
5431 /* Set the bonding mode for the relevant port. */
5432 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5433 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5438 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5439 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5441 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5442 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5443 bonding, "bonding");
5444 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5445 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5446 balance_xmit_policy, "balance_xmit_policy");
5447 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5448 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5450 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5451 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5452 policy, "l2#l23#l34");
5454 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5455 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5456 .help_str = "set bonding balance_xmit_policy <port_id> "
5458 "Set the bonding balance_xmit_policy for port_id",
5461 (void *)&cmd_setbonding_balance_xmit_policy_set,
5462 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5463 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5464 (void *)&cmd_setbonding_balance_xmit_policy_port,
5465 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5470 /* *** SHOW NIC BONDING CONFIGURATION *** */
5471 struct cmd_show_bonding_config_result {
5472 cmdline_fixed_string_t show;
5473 cmdline_fixed_string_t bonding;
5474 cmdline_fixed_string_t config;
5478 static void cmd_show_bonding_config_parsed(void *parsed_result,
5479 __attribute__((unused)) struct cmdline *cl,
5480 __attribute__((unused)) void *data)
5482 struct cmd_show_bonding_config_result *res = parsed_result;
5483 int bonding_mode, agg_mode;
5484 portid_t slaves[RTE_MAX_ETHPORTS];
5485 int num_slaves, num_active_slaves;
5488 portid_t port_id = res->port_id;
5490 /* Display the bonding mode.*/
5491 bonding_mode = rte_eth_bond_mode_get(port_id);
5492 if (bonding_mode < 0) {
5493 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5496 printf("\tBonding mode: %d\n", bonding_mode);
5498 if (bonding_mode == BONDING_MODE_BALANCE) {
5499 int balance_xmit_policy;
5501 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5502 if (balance_xmit_policy < 0) {
5503 printf("\tFailed to get balance xmit policy for port = %d\n",
5507 printf("\tBalance Xmit Policy: ");
5509 switch (balance_xmit_policy) {
5510 case BALANCE_XMIT_POLICY_LAYER2:
5511 printf("BALANCE_XMIT_POLICY_LAYER2");
5513 case BALANCE_XMIT_POLICY_LAYER23:
5514 printf("BALANCE_XMIT_POLICY_LAYER23");
5516 case BALANCE_XMIT_POLICY_LAYER34:
5517 printf("BALANCE_XMIT_POLICY_LAYER34");
5524 if (bonding_mode == BONDING_MODE_8023AD) {
5525 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5526 printf("\tIEEE802.3AD Aggregator Mode: ");
5529 printf("bandwidth");
5541 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5543 if (num_slaves < 0) {
5544 printf("\tFailed to get slave list for port = %d\n", port_id);
5547 if (num_slaves > 0) {
5548 printf("\tSlaves (%d): [", num_slaves);
5549 for (i = 0; i < num_slaves - 1; i++)
5550 printf("%d ", slaves[i]);
5552 printf("%d]\n", slaves[num_slaves - 1]);
5554 printf("\tSlaves: []\n");
5558 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5561 if (num_active_slaves < 0) {
5562 printf("\tFailed to get active slave list for port = %d\n", port_id);
5565 if (num_active_slaves > 0) {
5566 printf("\tActive Slaves (%d): [", num_active_slaves);
5567 for (i = 0; i < num_active_slaves - 1; i++)
5568 printf("%d ", slaves[i]);
5570 printf("%d]\n", slaves[num_active_slaves - 1]);
5573 printf("\tActive Slaves: []\n");
5577 primary_id = rte_eth_bond_primary_get(port_id);
5578 if (primary_id < 0) {
5579 printf("\tFailed to get primary slave for port = %d\n", port_id);
5582 printf("\tPrimary: [%d]\n", primary_id);
5586 cmdline_parse_token_string_t cmd_showbonding_config_show =
5587 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5589 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5590 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5591 bonding, "bonding");
5592 cmdline_parse_token_string_t cmd_showbonding_config_config =
5593 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5595 cmdline_parse_token_num_t cmd_showbonding_config_port =
5596 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5599 cmdline_parse_inst_t cmd_show_bonding_config = {
5600 .f = cmd_show_bonding_config_parsed,
5601 .help_str = "show bonding config <port_id>: "
5602 "Show the bonding config for port_id",
5605 (void *)&cmd_showbonding_config_show,
5606 (void *)&cmd_showbonding_config_bonding,
5607 (void *)&cmd_showbonding_config_config,
5608 (void *)&cmd_showbonding_config_port,
5613 /* *** SET BONDING PRIMARY *** */
5614 struct cmd_set_bonding_primary_result {
5615 cmdline_fixed_string_t set;
5616 cmdline_fixed_string_t bonding;
5617 cmdline_fixed_string_t primary;
5622 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5623 __attribute__((unused)) struct cmdline *cl,
5624 __attribute__((unused)) void *data)
5626 struct cmd_set_bonding_primary_result *res = parsed_result;
5627 portid_t master_port_id = res->port_id;
5628 portid_t slave_port_id = res->slave_id;
5630 /* Set the primary slave for a bonded device. */
5631 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5632 printf("\t Failed to set primary slave for port = %d.\n",
5639 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5640 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5642 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5643 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5644 bonding, "bonding");
5645 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5646 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5647 primary, "primary");
5648 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5649 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5651 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5652 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5655 cmdline_parse_inst_t cmd_set_bonding_primary = {
5656 .f = cmd_set_bonding_primary_parsed,
5657 .help_str = "set bonding primary <slave_id> <port_id>: "
5658 "Set the primary slave for port_id",
5661 (void *)&cmd_setbonding_primary_set,
5662 (void *)&cmd_setbonding_primary_bonding,
5663 (void *)&cmd_setbonding_primary_primary,
5664 (void *)&cmd_setbonding_primary_slave,
5665 (void *)&cmd_setbonding_primary_port,
5670 /* *** ADD SLAVE *** */
5671 struct cmd_add_bonding_slave_result {
5672 cmdline_fixed_string_t add;
5673 cmdline_fixed_string_t bonding;
5674 cmdline_fixed_string_t slave;
5679 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5680 __attribute__((unused)) struct cmdline *cl,
5681 __attribute__((unused)) void *data)
5683 struct cmd_add_bonding_slave_result *res = parsed_result;
5684 portid_t master_port_id = res->port_id;
5685 portid_t slave_port_id = res->slave_id;
5687 /* add the slave for a bonded device. */
5688 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5689 printf("\t Failed to add slave %d to master port = %d.\n",
5690 slave_port_id, master_port_id);
5694 set_port_slave_flag(slave_port_id);
5697 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5698 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5700 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5701 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5702 bonding, "bonding");
5703 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5704 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5706 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5707 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5709 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5710 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5713 cmdline_parse_inst_t cmd_add_bonding_slave = {
5714 .f = cmd_add_bonding_slave_parsed,
5715 .help_str = "add bonding slave <slave_id> <port_id>: "
5716 "Add a slave device to a bonded device",
5719 (void *)&cmd_addbonding_slave_add,
5720 (void *)&cmd_addbonding_slave_bonding,
5721 (void *)&cmd_addbonding_slave_slave,
5722 (void *)&cmd_addbonding_slave_slaveid,
5723 (void *)&cmd_addbonding_slave_port,
5728 /* *** REMOVE SLAVE *** */
5729 struct cmd_remove_bonding_slave_result {
5730 cmdline_fixed_string_t remove;
5731 cmdline_fixed_string_t bonding;
5732 cmdline_fixed_string_t slave;
5737 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5738 __attribute__((unused)) struct cmdline *cl,
5739 __attribute__((unused)) void *data)
5741 struct cmd_remove_bonding_slave_result *res = parsed_result;
5742 portid_t master_port_id = res->port_id;
5743 portid_t slave_port_id = res->slave_id;
5745 /* remove the slave from a bonded device. */
5746 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5747 printf("\t Failed to remove slave %d from master port = %d.\n",
5748 slave_port_id, master_port_id);
5752 clear_port_slave_flag(slave_port_id);
5755 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5756 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5758 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5759 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5760 bonding, "bonding");
5761 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5762 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5764 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5765 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5767 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5768 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5771 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5772 .f = cmd_remove_bonding_slave_parsed,
5773 .help_str = "remove bonding slave <slave_id> <port_id>: "
5774 "Remove a slave device from a bonded device",
5777 (void *)&cmd_removebonding_slave_remove,
5778 (void *)&cmd_removebonding_slave_bonding,
5779 (void *)&cmd_removebonding_slave_slave,
5780 (void *)&cmd_removebonding_slave_slaveid,
5781 (void *)&cmd_removebonding_slave_port,
5786 /* *** CREATE BONDED DEVICE *** */
5787 struct cmd_create_bonded_device_result {
5788 cmdline_fixed_string_t create;
5789 cmdline_fixed_string_t bonded;
5790 cmdline_fixed_string_t device;
5795 static int bond_dev_num = 0;
5797 static void cmd_create_bonded_device_parsed(void *parsed_result,
5798 __attribute__((unused)) struct cmdline *cl,
5799 __attribute__((unused)) void *data)
5801 struct cmd_create_bonded_device_result *res = parsed_result;
5802 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5805 if (test_done == 0) {
5806 printf("Please stop forwarding first\n");
5810 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5813 /* Create a new bonded device. */
5814 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5816 printf("\t Failed to create bonded device.\n");
5819 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5822 /* Update number of ports */
5823 nb_ports = rte_eth_dev_count_avail();
5824 reconfig(port_id, res->socket);
5825 rte_eth_promiscuous_enable(port_id);
5830 cmdline_parse_token_string_t cmd_createbonded_device_create =
5831 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5833 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5834 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5836 cmdline_parse_token_string_t cmd_createbonded_device_device =
5837 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5839 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5840 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5842 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5843 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5846 cmdline_parse_inst_t cmd_create_bonded_device = {
5847 .f = cmd_create_bonded_device_parsed,
5848 .help_str = "create bonded device <mode> <socket>: "
5849 "Create a new bonded device with specific bonding mode and socket",
5852 (void *)&cmd_createbonded_device_create,
5853 (void *)&cmd_createbonded_device_bonded,
5854 (void *)&cmd_createbonded_device_device,
5855 (void *)&cmd_createbonded_device_mode,
5856 (void *)&cmd_createbonded_device_socket,
5861 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5862 struct cmd_set_bond_mac_addr_result {
5863 cmdline_fixed_string_t set;
5864 cmdline_fixed_string_t bonding;
5865 cmdline_fixed_string_t mac_addr;
5867 struct ether_addr address;
5870 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5871 __attribute__((unused)) struct cmdline *cl,
5872 __attribute__((unused)) void *data)
5874 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5877 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5880 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5882 /* check the return value and print it if is < 0 */
5884 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5887 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5888 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5889 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5890 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5892 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5893 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5895 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5896 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5898 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5899 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5901 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5902 .f = cmd_set_bond_mac_addr_parsed,
5904 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5906 (void *)&cmd_set_bond_mac_addr_set,
5907 (void *)&cmd_set_bond_mac_addr_bonding,
5908 (void *)&cmd_set_bond_mac_addr_mac,
5909 (void *)&cmd_set_bond_mac_addr_portnum,
5910 (void *)&cmd_set_bond_mac_addr_addr,
5916 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5917 struct cmd_set_bond_mon_period_result {
5918 cmdline_fixed_string_t set;
5919 cmdline_fixed_string_t bonding;
5920 cmdline_fixed_string_t mon_period;
5925 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5926 __attribute__((unused)) struct cmdline *cl,
5927 __attribute__((unused)) void *data)
5929 struct cmd_set_bond_mon_period_result *res = parsed_result;
5932 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5934 /* check the return value and print it if is < 0 */
5936 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5939 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5940 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5942 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5943 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5944 bonding, "bonding");
5945 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5946 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5947 mon_period, "mon_period");
5948 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5949 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5951 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5952 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5955 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5956 .f = cmd_set_bond_mon_period_parsed,
5958 .help_str = "set bonding mon_period <port_id> <period_ms>",
5960 (void *)&cmd_set_bond_mon_period_set,
5961 (void *)&cmd_set_bond_mon_period_bonding,
5962 (void *)&cmd_set_bond_mon_period_mon_period,
5963 (void *)&cmd_set_bond_mon_period_portnum,
5964 (void *)&cmd_set_bond_mon_period_period_ms,
5971 struct cmd_set_bonding_agg_mode_policy_result {
5972 cmdline_fixed_string_t set;
5973 cmdline_fixed_string_t bonding;
5974 cmdline_fixed_string_t agg_mode;
5976 cmdline_fixed_string_t policy;
5981 cmd_set_bonding_agg_mode(void *parsed_result,
5982 __attribute__((unused)) struct cmdline *cl,
5983 __attribute__((unused)) void *data)
5985 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5986 uint8_t policy = AGG_BANDWIDTH;
5988 if (!strcmp(res->policy, "bandwidth"))
5989 policy = AGG_BANDWIDTH;
5990 else if (!strcmp(res->policy, "stable"))
5991 policy = AGG_STABLE;
5992 else if (!strcmp(res->policy, "count"))
5995 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5999 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6000 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6002 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6003 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6004 bonding, "bonding");
6006 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6007 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6008 agg_mode, "agg_mode");
6010 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6011 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6014 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6015 TOKEN_STRING_INITIALIZER(
6016 struct cmd_set_bonding_balance_xmit_policy_result,
6017 policy, "stable#bandwidth#count");
6019 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6020 .f = cmd_set_bonding_agg_mode,
6022 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6024 (void *)&cmd_set_bonding_agg_mode_set,
6025 (void *)&cmd_set_bonding_agg_mode_bonding,
6026 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6027 (void *)&cmd_set_bonding_agg_mode_portnum,
6028 (void *)&cmd_set_bonding_agg_mode_policy_string,
6034 #endif /* RTE_LIBRTE_PMD_BOND */
6036 /* *** SET FORWARDING MODE *** */
6037 struct cmd_set_fwd_mode_result {
6038 cmdline_fixed_string_t set;
6039 cmdline_fixed_string_t fwd;
6040 cmdline_fixed_string_t mode;
6043 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6044 __attribute__((unused)) struct cmdline *cl,
6045 __attribute__((unused)) void *data)
6047 struct cmd_set_fwd_mode_result *res = parsed_result;
6050 set_pkt_forwarding_mode(res->mode);
6053 cmdline_parse_token_string_t cmd_setfwd_set =
6054 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6055 cmdline_parse_token_string_t cmd_setfwd_fwd =
6056 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6057 cmdline_parse_token_string_t cmd_setfwd_mode =
6058 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6059 "" /* defined at init */);
6061 cmdline_parse_inst_t cmd_set_fwd_mode = {
6062 .f = cmd_set_fwd_mode_parsed,
6064 .help_str = NULL, /* defined at init */
6066 (void *)&cmd_setfwd_set,
6067 (void *)&cmd_setfwd_fwd,
6068 (void *)&cmd_setfwd_mode,
6073 static void cmd_set_fwd_mode_init(void)
6076 static char token[128];
6077 static char help[256];
6078 cmdline_parse_token_string_t *token_struct;
6080 modes = list_pkt_forwarding_modes();
6081 snprintf(help, sizeof(help), "set fwd %s: "
6082 "Set packet forwarding mode", modes);
6083 cmd_set_fwd_mode.help_str = help;
6085 /* string token separator is # */
6086 for (c = token; *modes != '\0'; modes++)
6091 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6092 token_struct->string_data.str = token;
6095 /* *** SET RETRY FORWARDING MODE *** */
6096 struct cmd_set_fwd_retry_mode_result {
6097 cmdline_fixed_string_t set;
6098 cmdline_fixed_string_t fwd;
6099 cmdline_fixed_string_t mode;
6100 cmdline_fixed_string_t retry;
6103 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6104 __attribute__((unused)) struct cmdline *cl,
6105 __attribute__((unused)) void *data)
6107 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6110 set_pkt_forwarding_mode(res->mode);
6113 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6114 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6116 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6117 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6119 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6120 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6122 "" /* defined at init */);
6123 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6124 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6127 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6128 .f = cmd_set_fwd_retry_mode_parsed,
6130 .help_str = NULL, /* defined at init */
6132 (void *)&cmd_setfwd_retry_set,
6133 (void *)&cmd_setfwd_retry_fwd,
6134 (void *)&cmd_setfwd_retry_mode,
6135 (void *)&cmd_setfwd_retry_retry,
6140 static void cmd_set_fwd_retry_mode_init(void)
6143 static char token[128];
6144 static char help[256];
6145 cmdline_parse_token_string_t *token_struct;
6147 modes = list_pkt_forwarding_retry_modes();
6148 snprintf(help, sizeof(help), "set fwd %s retry: "
6149 "Set packet forwarding mode with retry", modes);
6150 cmd_set_fwd_retry_mode.help_str = help;
6152 /* string token separator is # */
6153 for (c = token; *modes != '\0'; modes++)
6158 token_struct = (cmdline_parse_token_string_t *)
6159 cmd_set_fwd_retry_mode.tokens[2];
6160 token_struct->string_data.str = token;
6163 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6164 struct cmd_set_burst_tx_retry_result {
6165 cmdline_fixed_string_t set;
6166 cmdline_fixed_string_t burst;
6167 cmdline_fixed_string_t tx;
6168 cmdline_fixed_string_t delay;
6170 cmdline_fixed_string_t retry;
6174 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6175 __attribute__((unused)) struct cmdline *cl,
6176 __attribute__((unused)) void *data)
6178 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6180 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6181 && !strcmp(res->tx, "tx")) {
6182 if (!strcmp(res->delay, "delay"))
6183 burst_tx_delay_time = res->time;
6184 if (!strcmp(res->retry, "retry"))
6185 burst_tx_retry_num = res->retry_num;
6190 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6191 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6192 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6193 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6195 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6196 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6197 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6198 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6199 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6200 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6201 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6202 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6203 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6204 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6206 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6207 .f = cmd_set_burst_tx_retry_parsed,
6208 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6210 (void *)&cmd_set_burst_tx_retry_set,
6211 (void *)&cmd_set_burst_tx_retry_burst,
6212 (void *)&cmd_set_burst_tx_retry_tx,
6213 (void *)&cmd_set_burst_tx_retry_delay,
6214 (void *)&cmd_set_burst_tx_retry_time,
6215 (void *)&cmd_set_burst_tx_retry_retry,
6216 (void *)&cmd_set_burst_tx_retry_retry_num,
6221 /* *** SET PROMISC MODE *** */
6222 struct cmd_set_promisc_mode_result {
6223 cmdline_fixed_string_t set;
6224 cmdline_fixed_string_t promisc;
6225 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6226 uint16_t port_num; /* valid if "allports" argument == 0 */
6227 cmdline_fixed_string_t mode;
6230 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6231 __attribute__((unused)) struct cmdline *cl,
6234 struct cmd_set_promisc_mode_result *res = parsed_result;
6238 if (!strcmp(res->mode, "on"))
6245 RTE_ETH_FOREACH_DEV(i) {
6247 rte_eth_promiscuous_enable(i);
6249 rte_eth_promiscuous_disable(i);
6254 rte_eth_promiscuous_enable(res->port_num);
6256 rte_eth_promiscuous_disable(res->port_num);
6260 cmdline_parse_token_string_t cmd_setpromisc_set =
6261 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6262 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6263 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6265 cmdline_parse_token_string_t cmd_setpromisc_portall =
6266 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6268 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6269 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6271 cmdline_parse_token_string_t cmd_setpromisc_mode =
6272 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6275 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6276 .f = cmd_set_promisc_mode_parsed,
6278 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6280 (void *)&cmd_setpromisc_set,
6281 (void *)&cmd_setpromisc_promisc,
6282 (void *)&cmd_setpromisc_portall,
6283 (void *)&cmd_setpromisc_mode,
6288 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6289 .f = cmd_set_promisc_mode_parsed,
6291 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6293 (void *)&cmd_setpromisc_set,
6294 (void *)&cmd_setpromisc_promisc,
6295 (void *)&cmd_setpromisc_portnum,
6296 (void *)&cmd_setpromisc_mode,
6301 /* *** SET ALLMULTI MODE *** */
6302 struct cmd_set_allmulti_mode_result {
6303 cmdline_fixed_string_t set;
6304 cmdline_fixed_string_t allmulti;
6305 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6306 uint16_t port_num; /* valid if "allports" argument == 0 */
6307 cmdline_fixed_string_t mode;
6310 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6311 __attribute__((unused)) struct cmdline *cl,
6314 struct cmd_set_allmulti_mode_result *res = parsed_result;
6318 if (!strcmp(res->mode, "on"))
6325 RTE_ETH_FOREACH_DEV(i) {
6327 rte_eth_allmulticast_enable(i);
6329 rte_eth_allmulticast_disable(i);
6334 rte_eth_allmulticast_enable(res->port_num);
6336 rte_eth_allmulticast_disable(res->port_num);
6340 cmdline_parse_token_string_t cmd_setallmulti_set =
6341 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6342 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6343 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6345 cmdline_parse_token_string_t cmd_setallmulti_portall =
6346 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6348 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6349 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6351 cmdline_parse_token_string_t cmd_setallmulti_mode =
6352 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6355 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6356 .f = cmd_set_allmulti_mode_parsed,
6358 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6360 (void *)&cmd_setallmulti_set,
6361 (void *)&cmd_setallmulti_allmulti,
6362 (void *)&cmd_setallmulti_portall,
6363 (void *)&cmd_setallmulti_mode,
6368 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6369 .f = cmd_set_allmulti_mode_parsed,
6371 .help_str = "set allmulti <port_id> on|off: "
6372 "Set allmulti mode on port_id",
6374 (void *)&cmd_setallmulti_set,
6375 (void *)&cmd_setallmulti_allmulti,
6376 (void *)&cmd_setallmulti_portnum,
6377 (void *)&cmd_setallmulti_mode,
6382 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6383 struct cmd_link_flow_ctrl_set_result {
6384 cmdline_fixed_string_t set;
6385 cmdline_fixed_string_t flow_ctrl;
6386 cmdline_fixed_string_t rx;
6387 cmdline_fixed_string_t rx_lfc_mode;
6388 cmdline_fixed_string_t tx;
6389 cmdline_fixed_string_t tx_lfc_mode;
6390 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6391 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6392 cmdline_fixed_string_t autoneg_str;
6393 cmdline_fixed_string_t autoneg;
6394 cmdline_fixed_string_t hw_str;
6395 uint32_t high_water;
6396 cmdline_fixed_string_t lw_str;
6398 cmdline_fixed_string_t pt_str;
6399 uint16_t pause_time;
6400 cmdline_fixed_string_t xon_str;
6405 cmdline_parse_token_string_t cmd_lfc_set_set =
6406 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6408 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6409 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6410 flow_ctrl, "flow_ctrl");
6411 cmdline_parse_token_string_t cmd_lfc_set_rx =
6412 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6414 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6415 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6416 rx_lfc_mode, "on#off");
6417 cmdline_parse_token_string_t cmd_lfc_set_tx =
6418 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6420 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6421 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6422 tx_lfc_mode, "on#off");
6423 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6424 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6425 hw_str, "high_water");
6426 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6427 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6428 high_water, UINT32);
6429 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6430 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6431 lw_str, "low_water");
6432 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6433 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6435 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6436 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6437 pt_str, "pause_time");
6438 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6439 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6440 pause_time, UINT16);
6441 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6442 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6443 xon_str, "send_xon");
6444 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6445 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6447 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6448 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6449 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6450 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6451 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6452 mac_ctrl_frame_fwd_mode, "on#off");
6453 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6454 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6455 autoneg_str, "autoneg");
6456 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6457 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6459 cmdline_parse_token_num_t cmd_lfc_set_portid =
6460 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6463 /* forward declaration */
6465 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6468 cmdline_parse_inst_t cmd_link_flow_control_set = {
6469 .f = cmd_link_flow_ctrl_set_parsed,
6471 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6472 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6473 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6475 (void *)&cmd_lfc_set_set,
6476 (void *)&cmd_lfc_set_flow_ctrl,
6477 (void *)&cmd_lfc_set_rx,
6478 (void *)&cmd_lfc_set_rx_mode,
6479 (void *)&cmd_lfc_set_tx,
6480 (void *)&cmd_lfc_set_tx_mode,
6481 (void *)&cmd_lfc_set_high_water,
6482 (void *)&cmd_lfc_set_low_water,
6483 (void *)&cmd_lfc_set_pause_time,
6484 (void *)&cmd_lfc_set_send_xon,
6485 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6486 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6487 (void *)&cmd_lfc_set_autoneg_str,
6488 (void *)&cmd_lfc_set_autoneg,
6489 (void *)&cmd_lfc_set_portid,
6494 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6495 .f = cmd_link_flow_ctrl_set_parsed,
6496 .data = (void *)&cmd_link_flow_control_set_rx,
6497 .help_str = "set flow_ctrl rx on|off <port_id>: "
6498 "Change rx flow control parameter",
6500 (void *)&cmd_lfc_set_set,
6501 (void *)&cmd_lfc_set_flow_ctrl,
6502 (void *)&cmd_lfc_set_rx,
6503 (void *)&cmd_lfc_set_rx_mode,
6504 (void *)&cmd_lfc_set_portid,
6509 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6510 .f = cmd_link_flow_ctrl_set_parsed,
6511 .data = (void *)&cmd_link_flow_control_set_tx,
6512 .help_str = "set flow_ctrl tx on|off <port_id>: "
6513 "Change tx flow control parameter",
6515 (void *)&cmd_lfc_set_set,
6516 (void *)&cmd_lfc_set_flow_ctrl,
6517 (void *)&cmd_lfc_set_tx,
6518 (void *)&cmd_lfc_set_tx_mode,
6519 (void *)&cmd_lfc_set_portid,
6524 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6525 .f = cmd_link_flow_ctrl_set_parsed,
6526 .data = (void *)&cmd_link_flow_control_set_hw,
6527 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6528 "Change high water flow control parameter",
6530 (void *)&cmd_lfc_set_set,
6531 (void *)&cmd_lfc_set_flow_ctrl,
6532 (void *)&cmd_lfc_set_high_water_str,
6533 (void *)&cmd_lfc_set_high_water,
6534 (void *)&cmd_lfc_set_portid,
6539 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6540 .f = cmd_link_flow_ctrl_set_parsed,
6541 .data = (void *)&cmd_link_flow_control_set_lw,
6542 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6543 "Change low water flow control parameter",
6545 (void *)&cmd_lfc_set_set,
6546 (void *)&cmd_lfc_set_flow_ctrl,
6547 (void *)&cmd_lfc_set_low_water_str,
6548 (void *)&cmd_lfc_set_low_water,
6549 (void *)&cmd_lfc_set_portid,
6554 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6555 .f = cmd_link_flow_ctrl_set_parsed,
6556 .data = (void *)&cmd_link_flow_control_set_pt,
6557 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6558 "Change pause time flow control parameter",
6560 (void *)&cmd_lfc_set_set,
6561 (void *)&cmd_lfc_set_flow_ctrl,
6562 (void *)&cmd_lfc_set_pause_time_str,
6563 (void *)&cmd_lfc_set_pause_time,
6564 (void *)&cmd_lfc_set_portid,
6569 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6570 .f = cmd_link_flow_ctrl_set_parsed,
6571 .data = (void *)&cmd_link_flow_control_set_xon,
6572 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6573 "Change send_xon flow control parameter",
6575 (void *)&cmd_lfc_set_set,
6576 (void *)&cmd_lfc_set_flow_ctrl,
6577 (void *)&cmd_lfc_set_send_xon_str,
6578 (void *)&cmd_lfc_set_send_xon,
6579 (void *)&cmd_lfc_set_portid,
6584 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6585 .f = cmd_link_flow_ctrl_set_parsed,
6586 .data = (void *)&cmd_link_flow_control_set_macfwd,
6587 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6588 "Change mac ctrl fwd flow control parameter",
6590 (void *)&cmd_lfc_set_set,
6591 (void *)&cmd_lfc_set_flow_ctrl,
6592 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6593 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6594 (void *)&cmd_lfc_set_portid,
6599 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6600 .f = cmd_link_flow_ctrl_set_parsed,
6601 .data = (void *)&cmd_link_flow_control_set_autoneg,
6602 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6603 "Change autoneg flow control parameter",
6605 (void *)&cmd_lfc_set_set,
6606 (void *)&cmd_lfc_set_flow_ctrl,
6607 (void *)&cmd_lfc_set_autoneg_str,
6608 (void *)&cmd_lfc_set_autoneg,
6609 (void *)&cmd_lfc_set_portid,
6615 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6616 __attribute__((unused)) struct cmdline *cl,
6619 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6620 cmdline_parse_inst_t *cmd = data;
6621 struct rte_eth_fc_conf fc_conf;
6627 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6628 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6629 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6630 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6632 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6633 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6636 /* Partial command line, retrieve current configuration */
6638 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6640 printf("cannot get current flow ctrl parameters, return"
6641 "code = %d\n", ret);
6645 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6646 (fc_conf.mode == RTE_FC_FULL))
6648 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6649 (fc_conf.mode == RTE_FC_FULL))
6653 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6654 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6656 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6657 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6659 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6661 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6662 fc_conf.high_water = res->high_water;
6664 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6665 fc_conf.low_water = res->low_water;
6667 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6668 fc_conf.pause_time = res->pause_time;
6670 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6671 fc_conf.send_xon = res->send_xon;
6673 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6674 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6675 fc_conf.mac_ctrl_frame_fwd = 1;
6677 fc_conf.mac_ctrl_frame_fwd = 0;
6680 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6681 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6683 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6685 printf("bad flow contrl parameter, return code = %d \n", ret);
6688 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6689 struct cmd_priority_flow_ctrl_set_result {
6690 cmdline_fixed_string_t set;
6691 cmdline_fixed_string_t pfc_ctrl;
6692 cmdline_fixed_string_t rx;
6693 cmdline_fixed_string_t rx_pfc_mode;
6694 cmdline_fixed_string_t tx;
6695 cmdline_fixed_string_t tx_pfc_mode;
6696 uint32_t high_water;
6698 uint16_t pause_time;
6704 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6705 __attribute__((unused)) struct cmdline *cl,
6706 __attribute__((unused)) void *data)
6708 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6709 struct rte_eth_pfc_conf pfc_conf;
6710 int rx_fc_enable, tx_fc_enable;
6714 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6715 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6716 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6717 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6719 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6720 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6723 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6724 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6725 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6726 pfc_conf.fc.high_water = res->high_water;
6727 pfc_conf.fc.low_water = res->low_water;
6728 pfc_conf.fc.pause_time = res->pause_time;
6729 pfc_conf.priority = res->priority;
6731 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6733 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6736 cmdline_parse_token_string_t cmd_pfc_set_set =
6737 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6739 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6740 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6741 pfc_ctrl, "pfc_ctrl");
6742 cmdline_parse_token_string_t cmd_pfc_set_rx =
6743 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6745 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6746 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6747 rx_pfc_mode, "on#off");
6748 cmdline_parse_token_string_t cmd_pfc_set_tx =
6749 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6751 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6752 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6753 tx_pfc_mode, "on#off");
6754 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6755 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6756 high_water, UINT32);
6757 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6758 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6760 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6761 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6762 pause_time, UINT16);
6763 cmdline_parse_token_num_t cmd_pfc_set_priority =
6764 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6766 cmdline_parse_token_num_t cmd_pfc_set_portid =
6767 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6770 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6771 .f = cmd_priority_flow_ctrl_set_parsed,
6773 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6774 "<pause_time> <priority> <port_id>: "
6775 "Configure the Ethernet priority flow control",
6777 (void *)&cmd_pfc_set_set,
6778 (void *)&cmd_pfc_set_flow_ctrl,
6779 (void *)&cmd_pfc_set_rx,
6780 (void *)&cmd_pfc_set_rx_mode,
6781 (void *)&cmd_pfc_set_tx,
6782 (void *)&cmd_pfc_set_tx_mode,
6783 (void *)&cmd_pfc_set_high_water,
6784 (void *)&cmd_pfc_set_low_water,
6785 (void *)&cmd_pfc_set_pause_time,
6786 (void *)&cmd_pfc_set_priority,
6787 (void *)&cmd_pfc_set_portid,
6792 /* *** RESET CONFIGURATION *** */
6793 struct cmd_reset_result {
6794 cmdline_fixed_string_t reset;
6795 cmdline_fixed_string_t def;
6798 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6800 __attribute__((unused)) void *data)
6802 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6803 set_def_fwd_config();
6806 cmdline_parse_token_string_t cmd_reset_set =
6807 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6808 cmdline_parse_token_string_t cmd_reset_def =
6809 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6812 cmdline_parse_inst_t cmd_reset = {
6813 .f = cmd_reset_parsed,
6815 .help_str = "set default: Reset default forwarding configuration",
6817 (void *)&cmd_reset_set,
6818 (void *)&cmd_reset_def,
6823 /* *** START FORWARDING *** */
6824 struct cmd_start_result {
6825 cmdline_fixed_string_t start;
6828 cmdline_parse_token_string_t cmd_start_start =
6829 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6831 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6832 __attribute__((unused)) struct cmdline *cl,
6833 __attribute__((unused)) void *data)
6835 start_packet_forwarding(0);
6838 cmdline_parse_inst_t cmd_start = {
6839 .f = cmd_start_parsed,
6841 .help_str = "start: Start packet forwarding",
6843 (void *)&cmd_start_start,
6848 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6849 struct cmd_start_tx_first_result {
6850 cmdline_fixed_string_t start;
6851 cmdline_fixed_string_t tx_first;
6855 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6856 __attribute__((unused)) struct cmdline *cl,
6857 __attribute__((unused)) void *data)
6859 start_packet_forwarding(1);
6862 cmdline_parse_token_string_t cmd_start_tx_first_start =
6863 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6865 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6866 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6867 tx_first, "tx_first");
6869 cmdline_parse_inst_t cmd_start_tx_first = {
6870 .f = cmd_start_tx_first_parsed,
6872 .help_str = "start tx_first: Start packet forwarding, "
6873 "after sending 1 burst of packets",
6875 (void *)&cmd_start_tx_first_start,
6876 (void *)&cmd_start_tx_first_tx_first,
6881 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6882 struct cmd_start_tx_first_n_result {
6883 cmdline_fixed_string_t start;
6884 cmdline_fixed_string_t tx_first;
6889 cmd_start_tx_first_n_parsed(void *parsed_result,
6890 __attribute__((unused)) struct cmdline *cl,
6891 __attribute__((unused)) void *data)
6893 struct cmd_start_tx_first_n_result *res = parsed_result;
6895 start_packet_forwarding(res->tx_num);
6898 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6899 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6901 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6902 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6903 tx_first, "tx_first");
6904 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6905 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6908 cmdline_parse_inst_t cmd_start_tx_first_n = {
6909 .f = cmd_start_tx_first_n_parsed,
6911 .help_str = "start tx_first <num>: "
6912 "packet forwarding, after sending <num> bursts of packets",
6914 (void *)&cmd_start_tx_first_n_start,
6915 (void *)&cmd_start_tx_first_n_tx_first,
6916 (void *)&cmd_start_tx_first_n_tx_num,
6921 /* *** SET LINK UP *** */
6922 struct cmd_set_link_up_result {
6923 cmdline_fixed_string_t set;
6924 cmdline_fixed_string_t link_up;
6925 cmdline_fixed_string_t port;
6929 cmdline_parse_token_string_t cmd_set_link_up_set =
6930 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6931 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6932 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6934 cmdline_parse_token_string_t cmd_set_link_up_port =
6935 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6936 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6937 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6939 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6940 __attribute__((unused)) struct cmdline *cl,
6941 __attribute__((unused)) void *data)
6943 struct cmd_set_link_up_result *res = parsed_result;
6944 dev_set_link_up(res->port_id);
6947 cmdline_parse_inst_t cmd_set_link_up = {
6948 .f = cmd_set_link_up_parsed,
6950 .help_str = "set link-up port <port id>",
6952 (void *)&cmd_set_link_up_set,
6953 (void *)&cmd_set_link_up_link_up,
6954 (void *)&cmd_set_link_up_port,
6955 (void *)&cmd_set_link_up_port_id,
6960 /* *** SET LINK DOWN *** */
6961 struct cmd_set_link_down_result {
6962 cmdline_fixed_string_t set;
6963 cmdline_fixed_string_t link_down;
6964 cmdline_fixed_string_t port;
6968 cmdline_parse_token_string_t cmd_set_link_down_set =
6969 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6970 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6971 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6973 cmdline_parse_token_string_t cmd_set_link_down_port =
6974 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6975 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6976 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6978 static void cmd_set_link_down_parsed(
6979 __attribute__((unused)) void *parsed_result,
6980 __attribute__((unused)) struct cmdline *cl,
6981 __attribute__((unused)) void *data)
6983 struct cmd_set_link_down_result *res = parsed_result;
6984 dev_set_link_down(res->port_id);
6987 cmdline_parse_inst_t cmd_set_link_down = {
6988 .f = cmd_set_link_down_parsed,
6990 .help_str = "set link-down port <port id>",
6992 (void *)&cmd_set_link_down_set,
6993 (void *)&cmd_set_link_down_link_down,
6994 (void *)&cmd_set_link_down_port,
6995 (void *)&cmd_set_link_down_port_id,
7000 /* *** SHOW CFG *** */
7001 struct cmd_showcfg_result {
7002 cmdline_fixed_string_t show;
7003 cmdline_fixed_string_t cfg;
7004 cmdline_fixed_string_t what;
7007 static void cmd_showcfg_parsed(void *parsed_result,
7008 __attribute__((unused)) struct cmdline *cl,
7009 __attribute__((unused)) void *data)
7011 struct cmd_showcfg_result *res = parsed_result;
7012 if (!strcmp(res->what, "rxtx"))
7013 rxtx_config_display();
7014 else if (!strcmp(res->what, "cores"))
7015 fwd_lcores_config_display();
7016 else if (!strcmp(res->what, "fwd"))
7017 pkt_fwd_config_display(&cur_fwd_config);
7018 else if (!strcmp(res->what, "txpkts"))
7019 show_tx_pkt_segments();
7022 cmdline_parse_token_string_t cmd_showcfg_show =
7023 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7024 cmdline_parse_token_string_t cmd_showcfg_port =
7025 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7026 cmdline_parse_token_string_t cmd_showcfg_what =
7027 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7028 "rxtx#cores#fwd#txpkts");
7030 cmdline_parse_inst_t cmd_showcfg = {
7031 .f = cmd_showcfg_parsed,
7033 .help_str = "show config rxtx|cores|fwd|txpkts",
7035 (void *)&cmd_showcfg_show,
7036 (void *)&cmd_showcfg_port,
7037 (void *)&cmd_showcfg_what,
7042 /* *** SHOW ALL PORT INFO *** */
7043 struct cmd_showportall_result {
7044 cmdline_fixed_string_t show;
7045 cmdline_fixed_string_t port;
7046 cmdline_fixed_string_t what;
7047 cmdline_fixed_string_t all;
7050 static void cmd_showportall_parsed(void *parsed_result,
7051 __attribute__((unused)) struct cmdline *cl,
7052 __attribute__((unused)) void *data)
7056 struct cmd_showportall_result *res = parsed_result;
7057 if (!strcmp(res->show, "clear")) {
7058 if (!strcmp(res->what, "stats"))
7059 RTE_ETH_FOREACH_DEV(i)
7061 else if (!strcmp(res->what, "xstats"))
7062 RTE_ETH_FOREACH_DEV(i)
7063 nic_xstats_clear(i);
7064 } else if (!strcmp(res->what, "info"))
7065 RTE_ETH_FOREACH_DEV(i)
7066 port_infos_display(i);
7067 else if (!strcmp(res->what, "stats"))
7068 RTE_ETH_FOREACH_DEV(i)
7069 nic_stats_display(i);
7070 else if (!strcmp(res->what, "xstats"))
7071 RTE_ETH_FOREACH_DEV(i)
7072 nic_xstats_display(i);
7073 else if (!strcmp(res->what, "fdir"))
7074 RTE_ETH_FOREACH_DEV(i)
7076 else if (!strcmp(res->what, "stat_qmap"))
7077 RTE_ETH_FOREACH_DEV(i)
7078 nic_stats_mapping_display(i);
7079 else if (!strcmp(res->what, "dcb_tc"))
7080 RTE_ETH_FOREACH_DEV(i)
7081 port_dcb_info_display(i);
7082 else if (!strcmp(res->what, "cap"))
7083 RTE_ETH_FOREACH_DEV(i)
7084 port_offload_cap_display(i);
7087 cmdline_parse_token_string_t cmd_showportall_show =
7088 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7090 cmdline_parse_token_string_t cmd_showportall_port =
7091 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7092 cmdline_parse_token_string_t cmd_showportall_what =
7093 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7094 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7095 cmdline_parse_token_string_t cmd_showportall_all =
7096 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7097 cmdline_parse_inst_t cmd_showportall = {
7098 .f = cmd_showportall_parsed,
7100 .help_str = "show|clear port "
7101 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7103 (void *)&cmd_showportall_show,
7104 (void *)&cmd_showportall_port,
7105 (void *)&cmd_showportall_what,
7106 (void *)&cmd_showportall_all,
7111 /* *** SHOW PORT INFO *** */
7112 struct cmd_showport_result {
7113 cmdline_fixed_string_t show;
7114 cmdline_fixed_string_t port;
7115 cmdline_fixed_string_t what;
7119 static void cmd_showport_parsed(void *parsed_result,
7120 __attribute__((unused)) struct cmdline *cl,
7121 __attribute__((unused)) void *data)
7123 struct cmd_showport_result *res = parsed_result;
7124 if (!strcmp(res->show, "clear")) {
7125 if (!strcmp(res->what, "stats"))
7126 nic_stats_clear(res->portnum);
7127 else if (!strcmp(res->what, "xstats"))
7128 nic_xstats_clear(res->portnum);
7129 } else if (!strcmp(res->what, "info"))
7130 port_infos_display(res->portnum);
7131 else if (!strcmp(res->what, "stats"))
7132 nic_stats_display(res->portnum);
7133 else if (!strcmp(res->what, "xstats"))
7134 nic_xstats_display(res->portnum);
7135 else if (!strcmp(res->what, "fdir"))
7136 fdir_get_infos(res->portnum);
7137 else if (!strcmp(res->what, "stat_qmap"))
7138 nic_stats_mapping_display(res->portnum);
7139 else if (!strcmp(res->what, "dcb_tc"))
7140 port_dcb_info_display(res->portnum);
7141 else if (!strcmp(res->what, "cap"))
7142 port_offload_cap_display(res->portnum);
7145 cmdline_parse_token_string_t cmd_showport_show =
7146 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7148 cmdline_parse_token_string_t cmd_showport_port =
7149 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7150 cmdline_parse_token_string_t cmd_showport_what =
7151 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7152 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7153 cmdline_parse_token_num_t cmd_showport_portnum =
7154 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7156 cmdline_parse_inst_t cmd_showport = {
7157 .f = cmd_showport_parsed,
7159 .help_str = "show|clear port "
7160 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7163 (void *)&cmd_showport_show,
7164 (void *)&cmd_showport_port,
7165 (void *)&cmd_showport_what,
7166 (void *)&cmd_showport_portnum,
7171 /* *** SHOW QUEUE INFO *** */
7172 struct cmd_showqueue_result {
7173 cmdline_fixed_string_t show;
7174 cmdline_fixed_string_t type;
7175 cmdline_fixed_string_t what;
7181 cmd_showqueue_parsed(void *parsed_result,
7182 __attribute__((unused)) struct cmdline *cl,
7183 __attribute__((unused)) void *data)
7185 struct cmd_showqueue_result *res = parsed_result;
7187 if (!strcmp(res->type, "rxq"))
7188 rx_queue_infos_display(res->portnum, res->queuenum);
7189 else if (!strcmp(res->type, "txq"))
7190 tx_queue_infos_display(res->portnum, res->queuenum);
7193 cmdline_parse_token_string_t cmd_showqueue_show =
7194 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7195 cmdline_parse_token_string_t cmd_showqueue_type =
7196 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7197 cmdline_parse_token_string_t cmd_showqueue_what =
7198 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7199 cmdline_parse_token_num_t cmd_showqueue_portnum =
7200 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7201 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7202 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7204 cmdline_parse_inst_t cmd_showqueue = {
7205 .f = cmd_showqueue_parsed,
7207 .help_str = "show rxq|txq info <port_id> <queue_id>",
7209 (void *)&cmd_showqueue_show,
7210 (void *)&cmd_showqueue_type,
7211 (void *)&cmd_showqueue_what,
7212 (void *)&cmd_showqueue_portnum,
7213 (void *)&cmd_showqueue_queuenum,
7218 /* *** READ PORT REGISTER *** */
7219 struct cmd_read_reg_result {
7220 cmdline_fixed_string_t read;
7221 cmdline_fixed_string_t reg;
7227 cmd_read_reg_parsed(void *parsed_result,
7228 __attribute__((unused)) struct cmdline *cl,
7229 __attribute__((unused)) void *data)
7231 struct cmd_read_reg_result *res = parsed_result;
7232 port_reg_display(res->port_id, res->reg_off);
7235 cmdline_parse_token_string_t cmd_read_reg_read =
7236 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7237 cmdline_parse_token_string_t cmd_read_reg_reg =
7238 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7239 cmdline_parse_token_num_t cmd_read_reg_port_id =
7240 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7241 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7242 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7244 cmdline_parse_inst_t cmd_read_reg = {
7245 .f = cmd_read_reg_parsed,
7247 .help_str = "read reg <port_id> <reg_off>",
7249 (void *)&cmd_read_reg_read,
7250 (void *)&cmd_read_reg_reg,
7251 (void *)&cmd_read_reg_port_id,
7252 (void *)&cmd_read_reg_reg_off,
7257 /* *** READ PORT REGISTER BIT FIELD *** */
7258 struct cmd_read_reg_bit_field_result {
7259 cmdline_fixed_string_t read;
7260 cmdline_fixed_string_t regfield;
7268 cmd_read_reg_bit_field_parsed(void *parsed_result,
7269 __attribute__((unused)) struct cmdline *cl,
7270 __attribute__((unused)) void *data)
7272 struct cmd_read_reg_bit_field_result *res = parsed_result;
7273 port_reg_bit_field_display(res->port_id, res->reg_off,
7274 res->bit1_pos, res->bit2_pos);
7277 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7278 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7280 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7281 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7282 regfield, "regfield");
7283 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7284 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7286 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7287 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7289 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7290 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7292 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7293 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7296 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7297 .f = cmd_read_reg_bit_field_parsed,
7299 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7300 "Read register bit field between bit_x and bit_y included",
7302 (void *)&cmd_read_reg_bit_field_read,
7303 (void *)&cmd_read_reg_bit_field_regfield,
7304 (void *)&cmd_read_reg_bit_field_port_id,
7305 (void *)&cmd_read_reg_bit_field_reg_off,
7306 (void *)&cmd_read_reg_bit_field_bit1_pos,
7307 (void *)&cmd_read_reg_bit_field_bit2_pos,
7312 /* *** READ PORT REGISTER BIT *** */
7313 struct cmd_read_reg_bit_result {
7314 cmdline_fixed_string_t read;
7315 cmdline_fixed_string_t regbit;
7322 cmd_read_reg_bit_parsed(void *parsed_result,
7323 __attribute__((unused)) struct cmdline *cl,
7324 __attribute__((unused)) void *data)
7326 struct cmd_read_reg_bit_result *res = parsed_result;
7327 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7330 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7331 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7332 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7333 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7335 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7336 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7337 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7338 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7339 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7340 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7342 cmdline_parse_inst_t cmd_read_reg_bit = {
7343 .f = cmd_read_reg_bit_parsed,
7345 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7347 (void *)&cmd_read_reg_bit_read,
7348 (void *)&cmd_read_reg_bit_regbit,
7349 (void *)&cmd_read_reg_bit_port_id,
7350 (void *)&cmd_read_reg_bit_reg_off,
7351 (void *)&cmd_read_reg_bit_bit_pos,
7356 /* *** WRITE PORT REGISTER *** */
7357 struct cmd_write_reg_result {
7358 cmdline_fixed_string_t write;
7359 cmdline_fixed_string_t reg;
7366 cmd_write_reg_parsed(void *parsed_result,
7367 __attribute__((unused)) struct cmdline *cl,
7368 __attribute__((unused)) void *data)
7370 struct cmd_write_reg_result *res = parsed_result;
7371 port_reg_set(res->port_id, res->reg_off, res->value);
7374 cmdline_parse_token_string_t cmd_write_reg_write =
7375 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7376 cmdline_parse_token_string_t cmd_write_reg_reg =
7377 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7378 cmdline_parse_token_num_t cmd_write_reg_port_id =
7379 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7380 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7381 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7382 cmdline_parse_token_num_t cmd_write_reg_value =
7383 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7385 cmdline_parse_inst_t cmd_write_reg = {
7386 .f = cmd_write_reg_parsed,
7388 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7390 (void *)&cmd_write_reg_write,
7391 (void *)&cmd_write_reg_reg,
7392 (void *)&cmd_write_reg_port_id,
7393 (void *)&cmd_write_reg_reg_off,
7394 (void *)&cmd_write_reg_value,
7399 /* *** WRITE PORT REGISTER BIT FIELD *** */
7400 struct cmd_write_reg_bit_field_result {
7401 cmdline_fixed_string_t write;
7402 cmdline_fixed_string_t regfield;
7411 cmd_write_reg_bit_field_parsed(void *parsed_result,
7412 __attribute__((unused)) struct cmdline *cl,
7413 __attribute__((unused)) void *data)
7415 struct cmd_write_reg_bit_field_result *res = parsed_result;
7416 port_reg_bit_field_set(res->port_id, res->reg_off,
7417 res->bit1_pos, res->bit2_pos, res->value);
7420 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7421 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7423 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7424 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7425 regfield, "regfield");
7426 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7427 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7429 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7430 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7432 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7433 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7435 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7436 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7438 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7439 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7442 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7443 .f = cmd_write_reg_bit_field_parsed,
7445 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7447 "Set register bit field between bit_x and bit_y included",
7449 (void *)&cmd_write_reg_bit_field_write,
7450 (void *)&cmd_write_reg_bit_field_regfield,
7451 (void *)&cmd_write_reg_bit_field_port_id,
7452 (void *)&cmd_write_reg_bit_field_reg_off,
7453 (void *)&cmd_write_reg_bit_field_bit1_pos,
7454 (void *)&cmd_write_reg_bit_field_bit2_pos,
7455 (void *)&cmd_write_reg_bit_field_value,
7460 /* *** WRITE PORT REGISTER BIT *** */
7461 struct cmd_write_reg_bit_result {
7462 cmdline_fixed_string_t write;
7463 cmdline_fixed_string_t regbit;
7471 cmd_write_reg_bit_parsed(void *parsed_result,
7472 __attribute__((unused)) struct cmdline *cl,
7473 __attribute__((unused)) void *data)
7475 struct cmd_write_reg_bit_result *res = parsed_result;
7476 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7479 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7480 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7482 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7483 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7485 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7486 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7487 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7488 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7489 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7490 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7491 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7492 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7494 cmdline_parse_inst_t cmd_write_reg_bit = {
7495 .f = cmd_write_reg_bit_parsed,
7497 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7500 (void *)&cmd_write_reg_bit_write,
7501 (void *)&cmd_write_reg_bit_regbit,
7502 (void *)&cmd_write_reg_bit_port_id,
7503 (void *)&cmd_write_reg_bit_reg_off,
7504 (void *)&cmd_write_reg_bit_bit_pos,
7505 (void *)&cmd_write_reg_bit_value,
7510 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7511 struct cmd_read_rxd_txd_result {
7512 cmdline_fixed_string_t read;
7513 cmdline_fixed_string_t rxd_txd;
7520 cmd_read_rxd_txd_parsed(void *parsed_result,
7521 __attribute__((unused)) struct cmdline *cl,
7522 __attribute__((unused)) void *data)
7524 struct cmd_read_rxd_txd_result *res = parsed_result;
7526 if (!strcmp(res->rxd_txd, "rxd"))
7527 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7528 else if (!strcmp(res->rxd_txd, "txd"))
7529 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7532 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7533 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7534 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7535 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7537 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7538 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7539 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7540 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7541 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7542 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7544 cmdline_parse_inst_t cmd_read_rxd_txd = {
7545 .f = cmd_read_rxd_txd_parsed,
7547 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7549 (void *)&cmd_read_rxd_txd_read,
7550 (void *)&cmd_read_rxd_txd_rxd_txd,
7551 (void *)&cmd_read_rxd_txd_port_id,
7552 (void *)&cmd_read_rxd_txd_queue_id,
7553 (void *)&cmd_read_rxd_txd_desc_id,
7559 struct cmd_quit_result {
7560 cmdline_fixed_string_t quit;
7563 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7565 __attribute__((unused)) void *data)
7571 cmdline_parse_token_string_t cmd_quit_quit =
7572 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7574 cmdline_parse_inst_t cmd_quit = {
7575 .f = cmd_quit_parsed,
7577 .help_str = "quit: Exit application",
7579 (void *)&cmd_quit_quit,
7584 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7585 struct cmd_mac_addr_result {
7586 cmdline_fixed_string_t mac_addr_cmd;
7587 cmdline_fixed_string_t what;
7589 struct ether_addr address;
7592 static void cmd_mac_addr_parsed(void *parsed_result,
7593 __attribute__((unused)) struct cmdline *cl,
7594 __attribute__((unused)) void *data)
7596 struct cmd_mac_addr_result *res = parsed_result;
7599 if (strcmp(res->what, "add") == 0)
7600 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7601 else if (strcmp(res->what, "set") == 0)
7602 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7605 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7607 /* check the return value and print it if is < 0 */
7609 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7613 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7614 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7616 cmdline_parse_token_string_t cmd_mac_addr_what =
7617 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7619 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7620 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7622 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7623 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7625 cmdline_parse_inst_t cmd_mac_addr = {
7626 .f = cmd_mac_addr_parsed,
7628 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7629 "Add/Remove/Set MAC address on port_id",
7631 (void *)&cmd_mac_addr_cmd,
7632 (void *)&cmd_mac_addr_what,
7633 (void *)&cmd_mac_addr_portnum,
7634 (void *)&cmd_mac_addr_addr,
7639 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7640 struct cmd_eth_peer_result {
7641 cmdline_fixed_string_t set;
7642 cmdline_fixed_string_t eth_peer;
7644 cmdline_fixed_string_t peer_addr;
7647 static void cmd_set_eth_peer_parsed(void *parsed_result,
7648 __attribute__((unused)) struct cmdline *cl,
7649 __attribute__((unused)) void *data)
7651 struct cmd_eth_peer_result *res = parsed_result;
7653 if (test_done == 0) {
7654 printf("Please stop forwarding first\n");
7657 if (!strcmp(res->eth_peer, "eth-peer")) {
7658 set_fwd_eth_peer(res->port_id, res->peer_addr);
7662 cmdline_parse_token_string_t cmd_eth_peer_set =
7663 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7664 cmdline_parse_token_string_t cmd_eth_peer =
7665 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7666 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7667 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7668 cmdline_parse_token_string_t cmd_eth_peer_addr =
7669 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7671 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7672 .f = cmd_set_eth_peer_parsed,
7674 .help_str = "set eth-peer <port_id> <peer_mac>",
7676 (void *)&cmd_eth_peer_set,
7677 (void *)&cmd_eth_peer,
7678 (void *)&cmd_eth_peer_port_id,
7679 (void *)&cmd_eth_peer_addr,
7684 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7685 struct cmd_set_qmap_result {
7686 cmdline_fixed_string_t set;
7687 cmdline_fixed_string_t qmap;
7688 cmdline_fixed_string_t what;
7695 cmd_set_qmap_parsed(void *parsed_result,
7696 __attribute__((unused)) struct cmdline *cl,
7697 __attribute__((unused)) void *data)
7699 struct cmd_set_qmap_result *res = parsed_result;
7700 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7702 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7705 cmdline_parse_token_string_t cmd_setqmap_set =
7706 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7708 cmdline_parse_token_string_t cmd_setqmap_qmap =
7709 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7711 cmdline_parse_token_string_t cmd_setqmap_what =
7712 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7714 cmdline_parse_token_num_t cmd_setqmap_portid =
7715 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7717 cmdline_parse_token_num_t cmd_setqmap_queueid =
7718 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7720 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7721 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7724 cmdline_parse_inst_t cmd_set_qmap = {
7725 .f = cmd_set_qmap_parsed,
7727 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7728 "Set statistics mapping value on tx|rx queue_id of port_id",
7730 (void *)&cmd_setqmap_set,
7731 (void *)&cmd_setqmap_qmap,
7732 (void *)&cmd_setqmap_what,
7733 (void *)&cmd_setqmap_portid,
7734 (void *)&cmd_setqmap_queueid,
7735 (void *)&cmd_setqmap_mapvalue,
7740 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7741 struct cmd_set_xstats_hide_zero_result {
7742 cmdline_fixed_string_t keyword;
7743 cmdline_fixed_string_t name;
7744 cmdline_fixed_string_t on_off;
7748 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7749 __attribute__((unused)) struct cmdline *cl,
7750 __attribute__((unused)) void *data)
7752 struct cmd_set_xstats_hide_zero_result *res;
7753 uint16_t on_off = 0;
7755 res = parsed_result;
7756 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7757 set_xstats_hide_zero(on_off);
7760 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7761 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7763 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7764 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7765 name, "xstats-hide-zero");
7766 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7767 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7770 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7771 .f = cmd_set_xstats_hide_zero_parsed,
7773 .help_str = "set xstats-hide-zero on|off",
7775 (void *)&cmd_set_xstats_hide_zero_keyword,
7776 (void *)&cmd_set_xstats_hide_zero_name,
7777 (void *)&cmd_set_xstats_hide_zero_on_off,
7782 /* *** CONFIGURE UNICAST HASH TABLE *** */
7783 struct cmd_set_uc_hash_table {
7784 cmdline_fixed_string_t set;
7785 cmdline_fixed_string_t port;
7787 cmdline_fixed_string_t what;
7788 struct ether_addr address;
7789 cmdline_fixed_string_t mode;
7793 cmd_set_uc_hash_parsed(void *parsed_result,
7794 __attribute__((unused)) struct cmdline *cl,
7795 __attribute__((unused)) void *data)
7798 struct cmd_set_uc_hash_table *res = parsed_result;
7800 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7802 if (strcmp(res->what, "uta") == 0)
7803 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7804 &res->address,(uint8_t)is_on);
7806 printf("bad unicast hash table parameter, return code = %d \n", ret);
7810 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7811 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7813 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7814 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7816 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7817 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7819 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7820 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7822 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7823 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7825 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7826 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7829 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7830 .f = cmd_set_uc_hash_parsed,
7832 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7834 (void *)&cmd_set_uc_hash_set,
7835 (void *)&cmd_set_uc_hash_port,
7836 (void *)&cmd_set_uc_hash_portid,
7837 (void *)&cmd_set_uc_hash_what,
7838 (void *)&cmd_set_uc_hash_mac,
7839 (void *)&cmd_set_uc_hash_mode,
7844 struct cmd_set_uc_all_hash_table {
7845 cmdline_fixed_string_t set;
7846 cmdline_fixed_string_t port;
7848 cmdline_fixed_string_t what;
7849 cmdline_fixed_string_t value;
7850 cmdline_fixed_string_t mode;
7854 cmd_set_uc_all_hash_parsed(void *parsed_result,
7855 __attribute__((unused)) struct cmdline *cl,
7856 __attribute__((unused)) void *data)
7859 struct cmd_set_uc_all_hash_table *res = parsed_result;
7861 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7863 if ((strcmp(res->what, "uta") == 0) &&
7864 (strcmp(res->value, "all") == 0))
7865 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7867 printf("bad unicast hash table parameter,"
7868 "return code = %d \n", ret);
7871 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7872 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7874 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7875 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7877 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7878 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7880 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7881 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7883 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7884 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7886 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7887 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7890 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7891 .f = cmd_set_uc_all_hash_parsed,
7893 .help_str = "set port <port_id> uta all on|off",
7895 (void *)&cmd_set_uc_all_hash_set,
7896 (void *)&cmd_set_uc_all_hash_port,
7897 (void *)&cmd_set_uc_all_hash_portid,
7898 (void *)&cmd_set_uc_all_hash_what,
7899 (void *)&cmd_set_uc_all_hash_value,
7900 (void *)&cmd_set_uc_all_hash_mode,
7905 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7906 struct cmd_set_vf_macvlan_filter {
7907 cmdline_fixed_string_t set;
7908 cmdline_fixed_string_t port;
7910 cmdline_fixed_string_t vf;
7912 struct ether_addr address;
7913 cmdline_fixed_string_t filter_type;
7914 cmdline_fixed_string_t mode;
7918 cmd_set_vf_macvlan_parsed(void *parsed_result,
7919 __attribute__((unused)) struct cmdline *cl,
7920 __attribute__((unused)) void *data)
7923 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7924 struct rte_eth_mac_filter filter;
7926 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7928 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7930 /* set VF MAC filter */
7934 filter.dst_id = res->vf_id;
7936 if (!strcmp(res->filter_type, "exact-mac"))
7937 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7938 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7939 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7940 else if (!strcmp(res->filter_type, "hashmac"))
7941 filter.filter_type = RTE_MAC_HASH_MATCH;
7942 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7943 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7945 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7948 ret = rte_eth_dev_filter_ctrl(res->port_id,
7949 RTE_ETH_FILTER_MACVLAN,
7953 ret = rte_eth_dev_filter_ctrl(res->port_id,
7954 RTE_ETH_FILTER_MACVLAN,
7955 RTE_ETH_FILTER_DELETE,
7959 printf("bad set MAC hash parameter, return code = %d\n", ret);
7963 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7964 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7966 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7967 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7969 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7970 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7972 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7973 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7975 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7976 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7978 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7979 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7981 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7982 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7983 filter_type, "exact-mac#exact-mac-vlan"
7984 "#hashmac#hashmac-vlan");
7985 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7986 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7989 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7990 .f = cmd_set_vf_macvlan_parsed,
7992 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7993 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7994 "Exact match rule: exact match of MAC or MAC and VLAN; "
7995 "hash match rule: hash match of MAC and exact match of VLAN",
7997 (void *)&cmd_set_vf_macvlan_set,
7998 (void *)&cmd_set_vf_macvlan_port,
7999 (void *)&cmd_set_vf_macvlan_portid,
8000 (void *)&cmd_set_vf_macvlan_vf,
8001 (void *)&cmd_set_vf_macvlan_vf_id,
8002 (void *)&cmd_set_vf_macvlan_mac,
8003 (void *)&cmd_set_vf_macvlan_filter_type,
8004 (void *)&cmd_set_vf_macvlan_mode,
8009 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8010 struct cmd_set_vf_traffic {
8011 cmdline_fixed_string_t set;
8012 cmdline_fixed_string_t port;
8014 cmdline_fixed_string_t vf;
8016 cmdline_fixed_string_t what;
8017 cmdline_fixed_string_t mode;
8021 cmd_set_vf_traffic_parsed(void *parsed_result,
8022 __attribute__((unused)) struct cmdline *cl,
8023 __attribute__((unused)) void *data)
8025 struct cmd_set_vf_traffic *res = parsed_result;
8026 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8027 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8029 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8032 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8033 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8035 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8036 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8038 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8039 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8041 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8042 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8044 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8045 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8047 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8048 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8050 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8051 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8054 cmdline_parse_inst_t cmd_set_vf_traffic = {
8055 .f = cmd_set_vf_traffic_parsed,
8057 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8059 (void *)&cmd_setvf_traffic_set,
8060 (void *)&cmd_setvf_traffic_port,
8061 (void *)&cmd_setvf_traffic_portid,
8062 (void *)&cmd_setvf_traffic_vf,
8063 (void *)&cmd_setvf_traffic_vfid,
8064 (void *)&cmd_setvf_traffic_what,
8065 (void *)&cmd_setvf_traffic_mode,
8070 /* *** CONFIGURE VF RECEIVE MODE *** */
8071 struct cmd_set_vf_rxmode {
8072 cmdline_fixed_string_t set;
8073 cmdline_fixed_string_t port;
8075 cmdline_fixed_string_t vf;
8077 cmdline_fixed_string_t what;
8078 cmdline_fixed_string_t mode;
8079 cmdline_fixed_string_t on;
8083 cmd_set_vf_rxmode_parsed(void *parsed_result,
8084 __attribute__((unused)) struct cmdline *cl,
8085 __attribute__((unused)) void *data)
8088 uint16_t rx_mode = 0;
8089 struct cmd_set_vf_rxmode *res = parsed_result;
8091 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8092 if (!strcmp(res->what,"rxmode")) {
8093 if (!strcmp(res->mode, "AUPE"))
8094 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8095 else if (!strcmp(res->mode, "ROPE"))
8096 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8097 else if (!strcmp(res->mode, "BAM"))
8098 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8099 else if (!strncmp(res->mode, "MPE",3))
8100 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8103 RTE_SET_USED(is_on);
8105 #ifdef RTE_LIBRTE_IXGBE_PMD
8106 if (ret == -ENOTSUP)
8107 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8108 rx_mode, (uint8_t)is_on);
8110 #ifdef RTE_LIBRTE_BNXT_PMD
8111 if (ret == -ENOTSUP)
8112 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8113 rx_mode, (uint8_t)is_on);
8116 printf("bad VF receive mode parameter, return code = %d \n",
8120 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8121 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8123 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8124 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8126 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8127 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8129 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8130 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8132 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8133 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8135 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8136 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8138 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8139 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8140 mode, "AUPE#ROPE#BAM#MPE");
8141 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8142 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8145 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8146 .f = cmd_set_vf_rxmode_parsed,
8148 .help_str = "set port <port_id> vf <vf_id> rxmode "
8149 "AUPE|ROPE|BAM|MPE on|off",
8151 (void *)&cmd_set_vf_rxmode_set,
8152 (void *)&cmd_set_vf_rxmode_port,
8153 (void *)&cmd_set_vf_rxmode_portid,
8154 (void *)&cmd_set_vf_rxmode_vf,
8155 (void *)&cmd_set_vf_rxmode_vfid,
8156 (void *)&cmd_set_vf_rxmode_what,
8157 (void *)&cmd_set_vf_rxmode_mode,
8158 (void *)&cmd_set_vf_rxmode_on,
8163 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8164 struct cmd_vf_mac_addr_result {
8165 cmdline_fixed_string_t mac_addr_cmd;
8166 cmdline_fixed_string_t what;
8167 cmdline_fixed_string_t port;
8169 cmdline_fixed_string_t vf;
8171 struct ether_addr address;
8174 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8175 __attribute__((unused)) struct cmdline *cl,
8176 __attribute__((unused)) void *data)
8178 struct cmd_vf_mac_addr_result *res = parsed_result;
8181 if (strcmp(res->what, "add") != 0)
8184 #ifdef RTE_LIBRTE_I40E_PMD
8185 if (ret == -ENOTSUP)
8186 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8189 #ifdef RTE_LIBRTE_BNXT_PMD
8190 if (ret == -ENOTSUP)
8191 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8196 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8200 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8201 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8202 mac_addr_cmd,"mac_addr");
8203 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8204 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8206 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8207 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8209 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8210 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8212 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8213 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8215 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8216 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8218 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8219 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8222 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8223 .f = cmd_vf_mac_addr_parsed,
8225 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8226 "Add MAC address filtering for a VF on port_id",
8228 (void *)&cmd_vf_mac_addr_cmd,
8229 (void *)&cmd_vf_mac_addr_what,
8230 (void *)&cmd_vf_mac_addr_port,
8231 (void *)&cmd_vf_mac_addr_portnum,
8232 (void *)&cmd_vf_mac_addr_vf,
8233 (void *)&cmd_vf_mac_addr_vfnum,
8234 (void *)&cmd_vf_mac_addr_addr,
8239 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8240 struct cmd_vf_rx_vlan_filter {
8241 cmdline_fixed_string_t rx_vlan;
8242 cmdline_fixed_string_t what;
8244 cmdline_fixed_string_t port;
8246 cmdline_fixed_string_t vf;
8251 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8252 __attribute__((unused)) struct cmdline *cl,
8253 __attribute__((unused)) void *data)
8255 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8258 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8260 #ifdef RTE_LIBRTE_IXGBE_PMD
8261 if (ret == -ENOTSUP)
8262 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8263 res->vlan_id, res->vf_mask, is_add);
8265 #ifdef RTE_LIBRTE_I40E_PMD
8266 if (ret == -ENOTSUP)
8267 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8268 res->vlan_id, res->vf_mask, is_add);
8270 #ifdef RTE_LIBRTE_BNXT_PMD
8271 if (ret == -ENOTSUP)
8272 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8273 res->vlan_id, res->vf_mask, is_add);
8280 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8281 res->vlan_id, res->vf_mask);
8284 printf("invalid port_id %d\n", res->port_id);
8287 printf("function not implemented or supported\n");
8290 printf("programming error: (%s)\n", strerror(-ret));
8294 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8295 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8296 rx_vlan, "rx_vlan");
8297 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8298 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8300 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8301 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8303 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8304 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8306 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8307 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8309 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8310 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8312 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8313 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8316 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8317 .f = cmd_vf_rx_vlan_filter_parsed,
8319 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8320 "(vf_mask = hexadecimal VF mask)",
8322 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8323 (void *)&cmd_vf_rx_vlan_filter_what,
8324 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8325 (void *)&cmd_vf_rx_vlan_filter_port,
8326 (void *)&cmd_vf_rx_vlan_filter_portid,
8327 (void *)&cmd_vf_rx_vlan_filter_vf,
8328 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8333 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8334 struct cmd_queue_rate_limit_result {
8335 cmdline_fixed_string_t set;
8336 cmdline_fixed_string_t port;
8338 cmdline_fixed_string_t queue;
8340 cmdline_fixed_string_t rate;
8344 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8345 __attribute__((unused)) struct cmdline *cl,
8346 __attribute__((unused)) void *data)
8348 struct cmd_queue_rate_limit_result *res = parsed_result;
8351 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8352 && (strcmp(res->queue, "queue") == 0)
8353 && (strcmp(res->rate, "rate") == 0))
8354 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8357 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8361 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8362 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8364 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8365 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8367 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8368 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8370 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8371 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8373 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8374 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8376 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8377 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8379 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8380 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8383 cmdline_parse_inst_t cmd_queue_rate_limit = {
8384 .f = cmd_queue_rate_limit_parsed,
8386 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8387 "Set rate limit for a queue on port_id",
8389 (void *)&cmd_queue_rate_limit_set,
8390 (void *)&cmd_queue_rate_limit_port,
8391 (void *)&cmd_queue_rate_limit_portnum,
8392 (void *)&cmd_queue_rate_limit_queue,
8393 (void *)&cmd_queue_rate_limit_queuenum,
8394 (void *)&cmd_queue_rate_limit_rate,
8395 (void *)&cmd_queue_rate_limit_ratenum,
8400 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8401 struct cmd_vf_rate_limit_result {
8402 cmdline_fixed_string_t set;
8403 cmdline_fixed_string_t port;
8405 cmdline_fixed_string_t vf;
8407 cmdline_fixed_string_t rate;
8409 cmdline_fixed_string_t q_msk;
8413 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8414 __attribute__((unused)) struct cmdline *cl,
8415 __attribute__((unused)) void *data)
8417 struct cmd_vf_rate_limit_result *res = parsed_result;
8420 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8421 && (strcmp(res->vf, "vf") == 0)
8422 && (strcmp(res->rate, "rate") == 0)
8423 && (strcmp(res->q_msk, "queue_mask") == 0))
8424 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8425 res->rate_num, res->q_msk_val);
8427 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8431 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8432 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8434 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8435 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8437 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8438 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8440 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8441 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8443 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8444 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8446 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8447 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8449 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8450 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8452 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8453 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8454 q_msk, "queue_mask");
8455 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8456 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8459 cmdline_parse_inst_t cmd_vf_rate_limit = {
8460 .f = cmd_vf_rate_limit_parsed,
8462 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8463 "queue_mask <queue_mask_value>: "
8464 "Set rate limit for queues of VF on port_id",
8466 (void *)&cmd_vf_rate_limit_set,
8467 (void *)&cmd_vf_rate_limit_port,
8468 (void *)&cmd_vf_rate_limit_portnum,
8469 (void *)&cmd_vf_rate_limit_vf,
8470 (void *)&cmd_vf_rate_limit_vfnum,
8471 (void *)&cmd_vf_rate_limit_rate,
8472 (void *)&cmd_vf_rate_limit_ratenum,
8473 (void *)&cmd_vf_rate_limit_q_msk,
8474 (void *)&cmd_vf_rate_limit_q_msk_val,
8479 /* *** ADD TUNNEL FILTER OF A PORT *** */
8480 struct cmd_tunnel_filter_result {
8481 cmdline_fixed_string_t cmd;
8482 cmdline_fixed_string_t what;
8484 struct ether_addr outer_mac;
8485 struct ether_addr inner_mac;
8486 cmdline_ipaddr_t ip_value;
8487 uint16_t inner_vlan;
8488 cmdline_fixed_string_t tunnel_type;
8489 cmdline_fixed_string_t filter_type;
8495 cmd_tunnel_filter_parsed(void *parsed_result,
8496 __attribute__((unused)) struct cmdline *cl,
8497 __attribute__((unused)) void *data)
8499 struct cmd_tunnel_filter_result *res = parsed_result;
8500 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8503 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8505 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8506 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8507 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8509 if (res->ip_value.family == AF_INET) {
8510 tunnel_filter_conf.ip_addr.ipv4_addr =
8511 res->ip_value.addr.ipv4.s_addr;
8512 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8514 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8515 &(res->ip_value.addr.ipv6),
8516 sizeof(struct in6_addr));
8517 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8520 if (!strcmp(res->filter_type, "imac-ivlan"))
8521 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8522 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8523 tunnel_filter_conf.filter_type =
8524 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8525 else if (!strcmp(res->filter_type, "imac-tenid"))
8526 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8527 else if (!strcmp(res->filter_type, "imac"))
8528 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8529 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8530 tunnel_filter_conf.filter_type =
8531 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8532 else if (!strcmp(res->filter_type, "oip"))
8533 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8534 else if (!strcmp(res->filter_type, "iip"))
8535 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8537 printf("The filter type is not supported");
8541 if (!strcmp(res->tunnel_type, "vxlan"))
8542 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8543 else if (!strcmp(res->tunnel_type, "nvgre"))
8544 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8545 else if (!strcmp(res->tunnel_type, "ipingre"))
8546 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8548 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8552 tunnel_filter_conf.tenant_id = res->tenant_id;
8553 tunnel_filter_conf.queue_id = res->queue_num;
8554 if (!strcmp(res->what, "add"))
8555 ret = rte_eth_dev_filter_ctrl(res->port_id,
8556 RTE_ETH_FILTER_TUNNEL,
8558 &tunnel_filter_conf);
8560 ret = rte_eth_dev_filter_ctrl(res->port_id,
8561 RTE_ETH_FILTER_TUNNEL,
8562 RTE_ETH_FILTER_DELETE,
8563 &tunnel_filter_conf);
8565 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8569 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8570 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8571 cmd, "tunnel_filter");
8572 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8573 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8575 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8576 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8578 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8579 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8581 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8582 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8584 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8585 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8586 inner_vlan, UINT16);
8587 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8588 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8590 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8591 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8592 tunnel_type, "vxlan#nvgre#ipingre");
8594 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8595 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8596 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8597 "imac#omac-imac-tenid");
8598 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8599 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8601 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8602 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8605 cmdline_parse_inst_t cmd_tunnel_filter = {
8606 .f = cmd_tunnel_filter_parsed,
8608 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8609 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8610 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8611 "<queue_id>: Add/Rm tunnel filter of a port",
8613 (void *)&cmd_tunnel_filter_cmd,
8614 (void *)&cmd_tunnel_filter_what,
8615 (void *)&cmd_tunnel_filter_port_id,
8616 (void *)&cmd_tunnel_filter_outer_mac,
8617 (void *)&cmd_tunnel_filter_inner_mac,
8618 (void *)&cmd_tunnel_filter_ip_value,
8619 (void *)&cmd_tunnel_filter_innner_vlan,
8620 (void *)&cmd_tunnel_filter_tunnel_type,
8621 (void *)&cmd_tunnel_filter_filter_type,
8622 (void *)&cmd_tunnel_filter_tenant_id,
8623 (void *)&cmd_tunnel_filter_queue_num,
8628 /* *** CONFIGURE TUNNEL UDP PORT *** */
8629 struct cmd_tunnel_udp_config {
8630 cmdline_fixed_string_t cmd;
8631 cmdline_fixed_string_t what;
8637 cmd_tunnel_udp_config_parsed(void *parsed_result,
8638 __attribute__((unused)) struct cmdline *cl,
8639 __attribute__((unused)) void *data)
8641 struct cmd_tunnel_udp_config *res = parsed_result;
8642 struct rte_eth_udp_tunnel tunnel_udp;
8645 tunnel_udp.udp_port = res->udp_port;
8647 if (!strcmp(res->cmd, "rx_vxlan_port"))
8648 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8650 if (!strcmp(res->what, "add"))
8651 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8654 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8658 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8661 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8662 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8663 cmd, "rx_vxlan_port");
8664 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8665 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8667 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8668 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8670 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8671 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8674 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8675 .f = cmd_tunnel_udp_config_parsed,
8677 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8678 "Add/Remove a tunneling UDP port filter",
8680 (void *)&cmd_tunnel_udp_config_cmd,
8681 (void *)&cmd_tunnel_udp_config_what,
8682 (void *)&cmd_tunnel_udp_config_udp_port,
8683 (void *)&cmd_tunnel_udp_config_port_id,
8688 struct cmd_config_tunnel_udp_port {
8689 cmdline_fixed_string_t port;
8690 cmdline_fixed_string_t config;
8692 cmdline_fixed_string_t udp_tunnel_port;
8693 cmdline_fixed_string_t action;
8694 cmdline_fixed_string_t tunnel_type;
8699 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8700 __attribute__((unused)) struct cmdline *cl,
8701 __attribute__((unused)) void *data)
8703 struct cmd_config_tunnel_udp_port *res = parsed_result;
8704 struct rte_eth_udp_tunnel tunnel_udp;
8707 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8710 tunnel_udp.udp_port = res->udp_port;
8712 if (!strcmp(res->tunnel_type, "vxlan")) {
8713 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8714 } else if (!strcmp(res->tunnel_type, "geneve")) {
8715 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8717 printf("Invalid tunnel type\n");
8721 if (!strcmp(res->action, "add"))
8722 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8725 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8729 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8732 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8733 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8735 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8736 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8738 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8739 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8741 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8742 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8745 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8746 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8748 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8749 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8751 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8752 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8755 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8756 .f = cmd_cfg_tunnel_udp_port_parsed,
8758 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8760 (void *)&cmd_config_tunnel_udp_port_port,
8761 (void *)&cmd_config_tunnel_udp_port_config,
8762 (void *)&cmd_config_tunnel_udp_port_port_id,
8763 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8764 (void *)&cmd_config_tunnel_udp_port_action,
8765 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8766 (void *)&cmd_config_tunnel_udp_port_value,
8771 /* *** GLOBAL CONFIG *** */
8772 struct cmd_global_config_result {
8773 cmdline_fixed_string_t cmd;
8775 cmdline_fixed_string_t cfg_type;
8780 cmd_global_config_parsed(void *parsed_result,
8781 __attribute__((unused)) struct cmdline *cl,
8782 __attribute__((unused)) void *data)
8784 struct cmd_global_config_result *res = parsed_result;
8785 struct rte_eth_global_cfg conf;
8788 memset(&conf, 0, sizeof(conf));
8789 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8790 conf.cfg.gre_key_len = res->len;
8791 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8792 RTE_ETH_FILTER_SET, &conf);
8794 printf("Global config error\n");
8797 cmdline_parse_token_string_t cmd_global_config_cmd =
8798 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8800 cmdline_parse_token_num_t cmd_global_config_port_id =
8801 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8803 cmdline_parse_token_string_t cmd_global_config_type =
8804 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8805 cfg_type, "gre-key-len");
8806 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8807 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8810 cmdline_parse_inst_t cmd_global_config = {
8811 .f = cmd_global_config_parsed,
8812 .data = (void *)NULL,
8813 .help_str = "global_config <port_id> gre-key-len <key_len>",
8815 (void *)&cmd_global_config_cmd,
8816 (void *)&cmd_global_config_port_id,
8817 (void *)&cmd_global_config_type,
8818 (void *)&cmd_global_config_gre_key_len,
8823 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8824 struct cmd_set_mirror_mask_result {
8825 cmdline_fixed_string_t set;
8826 cmdline_fixed_string_t port;
8828 cmdline_fixed_string_t mirror;
8830 cmdline_fixed_string_t what;
8831 cmdline_fixed_string_t value;
8832 cmdline_fixed_string_t dstpool;
8834 cmdline_fixed_string_t on;
8837 cmdline_parse_token_string_t cmd_mirror_mask_set =
8838 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8840 cmdline_parse_token_string_t cmd_mirror_mask_port =
8841 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8843 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8844 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8846 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8847 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8848 mirror, "mirror-rule");
8849 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8850 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8852 cmdline_parse_token_string_t cmd_mirror_mask_what =
8853 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8854 what, "pool-mirror-up#pool-mirror-down"
8856 cmdline_parse_token_string_t cmd_mirror_mask_value =
8857 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8859 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8860 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8861 dstpool, "dst-pool");
8862 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8863 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8865 cmdline_parse_token_string_t cmd_mirror_mask_on =
8866 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8870 cmd_set_mirror_mask_parsed(void *parsed_result,
8871 __attribute__((unused)) struct cmdline *cl,
8872 __attribute__((unused)) void *data)
8875 struct cmd_set_mirror_mask_result *res = parsed_result;
8876 struct rte_eth_mirror_conf mr_conf;
8878 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8880 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8882 mr_conf.dst_pool = res->dstpool_id;
8884 if (!strcmp(res->what, "pool-mirror-up")) {
8885 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8886 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8887 } else if (!strcmp(res->what, "pool-mirror-down")) {
8888 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8889 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8890 } else if (!strcmp(res->what, "vlan-mirror")) {
8891 mr_conf.rule_type = ETH_MIRROR_VLAN;
8892 nb_item = parse_item_list(res->value, "vlan",
8893 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8897 for (i = 0; i < nb_item; i++) {
8898 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8899 printf("Invalid vlan_id: must be < 4096\n");
8903 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8904 mr_conf.vlan.vlan_mask |= 1ULL << i;
8908 if (!strcmp(res->on, "on"))
8909 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8912 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8915 printf("mirror rule add error: (%s)\n", strerror(-ret));
8918 cmdline_parse_inst_t cmd_set_mirror_mask = {
8919 .f = cmd_set_mirror_mask_parsed,
8921 .help_str = "set port <port_id> mirror-rule <rule_id> "
8922 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8923 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8925 (void *)&cmd_mirror_mask_set,
8926 (void *)&cmd_mirror_mask_port,
8927 (void *)&cmd_mirror_mask_portid,
8928 (void *)&cmd_mirror_mask_mirror,
8929 (void *)&cmd_mirror_mask_ruleid,
8930 (void *)&cmd_mirror_mask_what,
8931 (void *)&cmd_mirror_mask_value,
8932 (void *)&cmd_mirror_mask_dstpool,
8933 (void *)&cmd_mirror_mask_poolid,
8934 (void *)&cmd_mirror_mask_on,
8939 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8940 struct cmd_set_mirror_link_result {
8941 cmdline_fixed_string_t set;
8942 cmdline_fixed_string_t port;
8944 cmdline_fixed_string_t mirror;
8946 cmdline_fixed_string_t what;
8947 cmdline_fixed_string_t dstpool;
8949 cmdline_fixed_string_t on;
8952 cmdline_parse_token_string_t cmd_mirror_link_set =
8953 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8955 cmdline_parse_token_string_t cmd_mirror_link_port =
8956 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8958 cmdline_parse_token_num_t cmd_mirror_link_portid =
8959 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8961 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8962 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8963 mirror, "mirror-rule");
8964 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8965 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8967 cmdline_parse_token_string_t cmd_mirror_link_what =
8968 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8969 what, "uplink-mirror#downlink-mirror");
8970 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8971 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8972 dstpool, "dst-pool");
8973 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8974 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8976 cmdline_parse_token_string_t cmd_mirror_link_on =
8977 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8981 cmd_set_mirror_link_parsed(void *parsed_result,
8982 __attribute__((unused)) struct cmdline *cl,
8983 __attribute__((unused)) void *data)
8986 struct cmd_set_mirror_link_result *res = parsed_result;
8987 struct rte_eth_mirror_conf mr_conf;
8989 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8990 if (!strcmp(res->what, "uplink-mirror"))
8991 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8993 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8995 mr_conf.dst_pool = res->dstpool_id;
8997 if (!strcmp(res->on, "on"))
8998 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9001 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9004 /* check the return value and print it if is < 0 */
9006 printf("mirror rule add error: (%s)\n", strerror(-ret));
9010 cmdline_parse_inst_t cmd_set_mirror_link = {
9011 .f = cmd_set_mirror_link_parsed,
9013 .help_str = "set port <port_id> mirror-rule <rule_id> "
9014 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9016 (void *)&cmd_mirror_link_set,
9017 (void *)&cmd_mirror_link_port,
9018 (void *)&cmd_mirror_link_portid,
9019 (void *)&cmd_mirror_link_mirror,
9020 (void *)&cmd_mirror_link_ruleid,
9021 (void *)&cmd_mirror_link_what,
9022 (void *)&cmd_mirror_link_dstpool,
9023 (void *)&cmd_mirror_link_poolid,
9024 (void *)&cmd_mirror_link_on,
9029 /* *** RESET VM MIRROR RULE *** */
9030 struct cmd_rm_mirror_rule_result {
9031 cmdline_fixed_string_t reset;
9032 cmdline_fixed_string_t port;
9034 cmdline_fixed_string_t mirror;
9038 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9039 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9041 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9042 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9044 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9045 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9047 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9048 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9049 mirror, "mirror-rule");
9050 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9051 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9055 cmd_reset_mirror_rule_parsed(void *parsed_result,
9056 __attribute__((unused)) struct cmdline *cl,
9057 __attribute__((unused)) void *data)
9060 struct cmd_set_mirror_link_result *res = parsed_result;
9062 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9064 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9067 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9068 .f = cmd_reset_mirror_rule_parsed,
9070 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9072 (void *)&cmd_rm_mirror_rule_reset,
9073 (void *)&cmd_rm_mirror_rule_port,
9074 (void *)&cmd_rm_mirror_rule_portid,
9075 (void *)&cmd_rm_mirror_rule_mirror,
9076 (void *)&cmd_rm_mirror_rule_ruleid,
9081 /* ******************************************************************************** */
9083 struct cmd_dump_result {
9084 cmdline_fixed_string_t dump;
9088 dump_struct_sizes(void)
9090 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9091 DUMP_SIZE(struct rte_mbuf);
9092 DUMP_SIZE(struct rte_mempool);
9093 DUMP_SIZE(struct rte_ring);
9097 static void cmd_dump_parsed(void *parsed_result,
9098 __attribute__((unused)) struct cmdline *cl,
9099 __attribute__((unused)) void *data)
9101 struct cmd_dump_result *res = parsed_result;
9103 if (!strcmp(res->dump, "dump_physmem"))
9104 rte_dump_physmem_layout(stdout);
9105 else if (!strcmp(res->dump, "dump_memzone"))
9106 rte_memzone_dump(stdout);
9107 else if (!strcmp(res->dump, "dump_struct_sizes"))
9108 dump_struct_sizes();
9109 else if (!strcmp(res->dump, "dump_ring"))
9110 rte_ring_list_dump(stdout);
9111 else if (!strcmp(res->dump, "dump_mempool"))
9112 rte_mempool_list_dump(stdout);
9113 else if (!strcmp(res->dump, "dump_devargs"))
9114 rte_devargs_dump(stdout);
9115 else if (!strcmp(res->dump, "dump_log_types"))
9116 rte_log_dump(stdout);
9119 cmdline_parse_token_string_t cmd_dump_dump =
9120 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9123 "dump_struct_sizes#"
9129 cmdline_parse_inst_t cmd_dump = {
9130 .f = cmd_dump_parsed, /* function to call */
9131 .data = NULL, /* 2nd arg of func */
9132 .help_str = "Dump status",
9133 .tokens = { /* token list, NULL terminated */
9134 (void *)&cmd_dump_dump,
9139 /* ******************************************************************************** */
9141 struct cmd_dump_one_result {
9142 cmdline_fixed_string_t dump;
9143 cmdline_fixed_string_t name;
9146 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9147 __attribute__((unused)) void *data)
9149 struct cmd_dump_one_result *res = parsed_result;
9151 if (!strcmp(res->dump, "dump_ring")) {
9153 r = rte_ring_lookup(res->name);
9155 cmdline_printf(cl, "Cannot find ring\n");
9158 rte_ring_dump(stdout, r);
9159 } else if (!strcmp(res->dump, "dump_mempool")) {
9160 struct rte_mempool *mp;
9161 mp = rte_mempool_lookup(res->name);
9163 cmdline_printf(cl, "Cannot find mempool\n");
9166 rte_mempool_dump(stdout, mp);
9170 cmdline_parse_token_string_t cmd_dump_one_dump =
9171 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9172 "dump_ring#dump_mempool");
9174 cmdline_parse_token_string_t cmd_dump_one_name =
9175 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9177 cmdline_parse_inst_t cmd_dump_one = {
9178 .f = cmd_dump_one_parsed, /* function to call */
9179 .data = NULL, /* 2nd arg of func */
9180 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9181 .tokens = { /* token list, NULL terminated */
9182 (void *)&cmd_dump_one_dump,
9183 (void *)&cmd_dump_one_name,
9188 /* *** Add/Del syn filter *** */
9189 struct cmd_syn_filter_result {
9190 cmdline_fixed_string_t filter;
9192 cmdline_fixed_string_t ops;
9193 cmdline_fixed_string_t priority;
9194 cmdline_fixed_string_t high;
9195 cmdline_fixed_string_t queue;
9200 cmd_syn_filter_parsed(void *parsed_result,
9201 __attribute__((unused)) struct cmdline *cl,
9202 __attribute__((unused)) void *data)
9204 struct cmd_syn_filter_result *res = parsed_result;
9205 struct rte_eth_syn_filter syn_filter;
9208 ret = rte_eth_dev_filter_supported(res->port_id,
9209 RTE_ETH_FILTER_SYN);
9211 printf("syn filter is not supported on port %u.\n",
9216 memset(&syn_filter, 0, sizeof(syn_filter));
9218 if (!strcmp(res->ops, "add")) {
9219 if (!strcmp(res->high, "high"))
9220 syn_filter.hig_pri = 1;
9222 syn_filter.hig_pri = 0;
9224 syn_filter.queue = res->queue_id;
9225 ret = rte_eth_dev_filter_ctrl(res->port_id,
9230 ret = rte_eth_dev_filter_ctrl(res->port_id,
9232 RTE_ETH_FILTER_DELETE,
9236 printf("syn filter programming error: (%s)\n",
9240 cmdline_parse_token_string_t cmd_syn_filter_filter =
9241 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9242 filter, "syn_filter");
9243 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9244 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9246 cmdline_parse_token_string_t cmd_syn_filter_ops =
9247 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9249 cmdline_parse_token_string_t cmd_syn_filter_priority =
9250 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9251 priority, "priority");
9252 cmdline_parse_token_string_t cmd_syn_filter_high =
9253 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9255 cmdline_parse_token_string_t cmd_syn_filter_queue =
9256 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9258 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9259 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9262 cmdline_parse_inst_t cmd_syn_filter = {
9263 .f = cmd_syn_filter_parsed,
9265 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9266 "<queue_id>: Add/Delete syn filter",
9268 (void *)&cmd_syn_filter_filter,
9269 (void *)&cmd_syn_filter_port_id,
9270 (void *)&cmd_syn_filter_ops,
9271 (void *)&cmd_syn_filter_priority,
9272 (void *)&cmd_syn_filter_high,
9273 (void *)&cmd_syn_filter_queue,
9274 (void *)&cmd_syn_filter_queue_id,
9279 /* *** queue region set *** */
9280 struct cmd_queue_region_result {
9281 cmdline_fixed_string_t set;
9282 cmdline_fixed_string_t port;
9284 cmdline_fixed_string_t cmd;
9285 cmdline_fixed_string_t region;
9287 cmdline_fixed_string_t queue_start_index;
9289 cmdline_fixed_string_t queue_num;
9290 uint8_t queue_num_value;
9294 cmd_queue_region_parsed(void *parsed_result,
9295 __attribute__((unused)) struct cmdline *cl,
9296 __attribute__((unused)) void *data)
9298 struct cmd_queue_region_result *res = parsed_result;
9300 #ifdef RTE_LIBRTE_I40E_PMD
9301 struct rte_pmd_i40e_queue_region_conf region_conf;
9302 enum rte_pmd_i40e_queue_region_op op_type;
9305 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9308 #ifdef RTE_LIBRTE_I40E_PMD
9309 memset(®ion_conf, 0, sizeof(region_conf));
9310 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9311 region_conf.region_id = res->region_id;
9312 region_conf.queue_num = res->queue_num_value;
9313 region_conf.queue_start_index = res->queue_id;
9315 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9316 op_type, ®ion_conf);
9323 printf("function not implemented or supported\n");
9326 printf("queue region config error: (%s)\n", strerror(-ret));
9330 cmdline_parse_token_string_t cmd_queue_region_set =
9331 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9333 cmdline_parse_token_string_t cmd_queue_region_port =
9334 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9335 cmdline_parse_token_num_t cmd_queue_region_port_id =
9336 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9338 cmdline_parse_token_string_t cmd_queue_region_cmd =
9339 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9340 cmd, "queue-region");
9341 cmdline_parse_token_string_t cmd_queue_region_id =
9342 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9343 region, "region_id");
9344 cmdline_parse_token_num_t cmd_queue_region_index =
9345 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9347 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9348 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9349 queue_start_index, "queue_start_index");
9350 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9351 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9353 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9354 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9355 queue_num, "queue_num");
9356 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9357 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9358 queue_num_value, UINT8);
9360 cmdline_parse_inst_t cmd_queue_region = {
9361 .f = cmd_queue_region_parsed,
9363 .help_str = "set port <port_id> queue-region region_id <value> "
9364 "queue_start_index <value> queue_num <value>: Set a queue region",
9366 (void *)&cmd_queue_region_set,
9367 (void *)&cmd_queue_region_port,
9368 (void *)&cmd_queue_region_port_id,
9369 (void *)&cmd_queue_region_cmd,
9370 (void *)&cmd_queue_region_id,
9371 (void *)&cmd_queue_region_index,
9372 (void *)&cmd_queue_region_queue_start_index,
9373 (void *)&cmd_queue_region_queue_id,
9374 (void *)&cmd_queue_region_queue_num,
9375 (void *)&cmd_queue_region_queue_num_value,
9380 /* *** queue region and flowtype set *** */
9381 struct cmd_region_flowtype_result {
9382 cmdline_fixed_string_t set;
9383 cmdline_fixed_string_t port;
9385 cmdline_fixed_string_t cmd;
9386 cmdline_fixed_string_t region;
9388 cmdline_fixed_string_t flowtype;
9389 uint8_t flowtype_id;
9393 cmd_region_flowtype_parsed(void *parsed_result,
9394 __attribute__((unused)) struct cmdline *cl,
9395 __attribute__((unused)) void *data)
9397 struct cmd_region_flowtype_result *res = parsed_result;
9399 #ifdef RTE_LIBRTE_I40E_PMD
9400 struct rte_pmd_i40e_queue_region_conf region_conf;
9401 enum rte_pmd_i40e_queue_region_op op_type;
9404 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9407 #ifdef RTE_LIBRTE_I40E_PMD
9408 memset(®ion_conf, 0, sizeof(region_conf));
9410 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9411 region_conf.region_id = res->region_id;
9412 region_conf.hw_flowtype = res->flowtype_id;
9414 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9415 op_type, ®ion_conf);
9422 printf("function not implemented or supported\n");
9425 printf("region flowtype config error: (%s)\n", strerror(-ret));
9429 cmdline_parse_token_string_t cmd_region_flowtype_set =
9430 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9432 cmdline_parse_token_string_t cmd_region_flowtype_port =
9433 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9435 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9436 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9438 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9439 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9440 cmd, "queue-region");
9441 cmdline_parse_token_string_t cmd_region_flowtype_index =
9442 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9443 region, "region_id");
9444 cmdline_parse_token_num_t cmd_region_flowtype_id =
9445 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9447 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9448 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9449 flowtype, "flowtype");
9450 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9451 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9452 flowtype_id, UINT8);
9453 cmdline_parse_inst_t cmd_region_flowtype = {
9454 .f = cmd_region_flowtype_parsed,
9456 .help_str = "set port <port_id> queue-region region_id <value> "
9457 "flowtype <value>: Set a flowtype region index",
9459 (void *)&cmd_region_flowtype_set,
9460 (void *)&cmd_region_flowtype_port,
9461 (void *)&cmd_region_flowtype_port_index,
9462 (void *)&cmd_region_flowtype_cmd,
9463 (void *)&cmd_region_flowtype_index,
9464 (void *)&cmd_region_flowtype_id,
9465 (void *)&cmd_region_flowtype_flow_index,
9466 (void *)&cmd_region_flowtype_flow_id,
9471 /* *** User Priority (UP) to queue region (region_id) set *** */
9472 struct cmd_user_priority_region_result {
9473 cmdline_fixed_string_t set;
9474 cmdline_fixed_string_t port;
9476 cmdline_fixed_string_t cmd;
9477 cmdline_fixed_string_t user_priority;
9478 uint8_t user_priority_id;
9479 cmdline_fixed_string_t region;
9484 cmd_user_priority_region_parsed(void *parsed_result,
9485 __attribute__((unused)) struct cmdline *cl,
9486 __attribute__((unused)) void *data)
9488 struct cmd_user_priority_region_result *res = parsed_result;
9490 #ifdef RTE_LIBRTE_I40E_PMD
9491 struct rte_pmd_i40e_queue_region_conf region_conf;
9492 enum rte_pmd_i40e_queue_region_op op_type;
9495 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9498 #ifdef RTE_LIBRTE_I40E_PMD
9499 memset(®ion_conf, 0, sizeof(region_conf));
9500 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9501 region_conf.user_priority = res->user_priority_id;
9502 region_conf.region_id = res->region_id;
9504 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9505 op_type, ®ion_conf);
9512 printf("function not implemented or supported\n");
9515 printf("user_priority region config error: (%s)\n",
9520 cmdline_parse_token_string_t cmd_user_priority_region_set =
9521 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9523 cmdline_parse_token_string_t cmd_user_priority_region_port =
9524 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9526 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9527 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9529 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9530 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9531 cmd, "queue-region");
9532 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9533 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9534 user_priority, "UP");
9535 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9536 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9537 user_priority_id, UINT8);
9538 cmdline_parse_token_string_t cmd_user_priority_region_region =
9539 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9540 region, "region_id");
9541 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9542 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9545 cmdline_parse_inst_t cmd_user_priority_region = {
9546 .f = cmd_user_priority_region_parsed,
9548 .help_str = "set port <port_id> queue-region UP <value> "
9549 "region_id <value>: Set the mapping of User Priority (UP) "
9550 "to queue region (region_id) ",
9552 (void *)&cmd_user_priority_region_set,
9553 (void *)&cmd_user_priority_region_port,
9554 (void *)&cmd_user_priority_region_port_index,
9555 (void *)&cmd_user_priority_region_cmd,
9556 (void *)&cmd_user_priority_region_UP,
9557 (void *)&cmd_user_priority_region_UP_id,
9558 (void *)&cmd_user_priority_region_region,
9559 (void *)&cmd_user_priority_region_region_id,
9564 /* *** flush all queue region related configuration *** */
9565 struct cmd_flush_queue_region_result {
9566 cmdline_fixed_string_t set;
9567 cmdline_fixed_string_t port;
9569 cmdline_fixed_string_t cmd;
9570 cmdline_fixed_string_t flush;
9571 cmdline_fixed_string_t what;
9575 cmd_flush_queue_region_parsed(void *parsed_result,
9576 __attribute__((unused)) struct cmdline *cl,
9577 __attribute__((unused)) void *data)
9579 struct cmd_flush_queue_region_result *res = parsed_result;
9581 #ifdef RTE_LIBRTE_I40E_PMD
9582 struct rte_pmd_i40e_queue_region_conf region_conf;
9583 enum rte_pmd_i40e_queue_region_op op_type;
9586 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9589 #ifdef RTE_LIBRTE_I40E_PMD
9590 memset(®ion_conf, 0, sizeof(region_conf));
9592 if (strcmp(res->what, "on") == 0)
9593 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9595 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9597 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9598 op_type, ®ion_conf);
9605 printf("function not implemented or supported\n");
9608 printf("queue region config flush error: (%s)\n",
9613 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9614 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9616 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9617 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9619 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9620 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9622 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9623 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9624 cmd, "queue-region");
9625 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9626 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9628 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9629 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9632 cmdline_parse_inst_t cmd_flush_queue_region = {
9633 .f = cmd_flush_queue_region_parsed,
9635 .help_str = "set port <port_id> queue-region flush on|off"
9636 ": flush all queue region related configuration",
9638 (void *)&cmd_flush_queue_region_set,
9639 (void *)&cmd_flush_queue_region_port,
9640 (void *)&cmd_flush_queue_region_port_index,
9641 (void *)&cmd_flush_queue_region_cmd,
9642 (void *)&cmd_flush_queue_region_flush,
9643 (void *)&cmd_flush_queue_region_what,
9648 /* *** get all queue region related configuration info *** */
9649 struct cmd_show_queue_region_info {
9650 cmdline_fixed_string_t show;
9651 cmdline_fixed_string_t port;
9653 cmdline_fixed_string_t cmd;
9657 cmd_show_queue_region_info_parsed(void *parsed_result,
9658 __attribute__((unused)) struct cmdline *cl,
9659 __attribute__((unused)) void *data)
9661 struct cmd_show_queue_region_info *res = parsed_result;
9663 #ifdef RTE_LIBRTE_I40E_PMD
9664 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9665 enum rte_pmd_i40e_queue_region_op op_type;
9668 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9671 #ifdef RTE_LIBRTE_I40E_PMD
9672 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9674 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9676 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9677 op_type, &rte_pmd_regions);
9679 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9686 printf("function not implemented or supported\n");
9689 printf("queue region config info show error: (%s)\n",
9694 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9695 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9697 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9698 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9700 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9701 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9703 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9704 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9705 cmd, "queue-region");
9707 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9708 .f = cmd_show_queue_region_info_parsed,
9710 .help_str = "show port <port_id> queue-region"
9711 ": show all queue region related configuration info",
9713 (void *)&cmd_show_queue_region_info_get,
9714 (void *)&cmd_show_queue_region_info_port,
9715 (void *)&cmd_show_queue_region_info_port_index,
9716 (void *)&cmd_show_queue_region_info_cmd,
9721 /* *** ADD/REMOVE A 2tuple FILTER *** */
9722 struct cmd_2tuple_filter_result {
9723 cmdline_fixed_string_t filter;
9725 cmdline_fixed_string_t ops;
9726 cmdline_fixed_string_t dst_port;
9727 uint16_t dst_port_value;
9728 cmdline_fixed_string_t protocol;
9729 uint8_t protocol_value;
9730 cmdline_fixed_string_t mask;
9732 cmdline_fixed_string_t tcp_flags;
9733 uint8_t tcp_flags_value;
9734 cmdline_fixed_string_t priority;
9735 uint8_t priority_value;
9736 cmdline_fixed_string_t queue;
9741 cmd_2tuple_filter_parsed(void *parsed_result,
9742 __attribute__((unused)) struct cmdline *cl,
9743 __attribute__((unused)) void *data)
9745 struct rte_eth_ntuple_filter filter;
9746 struct cmd_2tuple_filter_result *res = parsed_result;
9749 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9751 printf("ntuple filter is not supported on port %u.\n",
9756 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9758 filter.flags = RTE_2TUPLE_FLAGS;
9759 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9760 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9761 filter.proto = res->protocol_value;
9762 filter.priority = res->priority_value;
9763 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9764 printf("nonzero tcp_flags is only meaningful"
9765 " when protocol is TCP.\n");
9768 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9769 printf("invalid TCP flags.\n");
9773 if (res->tcp_flags_value != 0) {
9774 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9775 filter.tcp_flags = res->tcp_flags_value;
9778 /* need convert to big endian. */
9779 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9780 filter.queue = res->queue_id;
9782 if (!strcmp(res->ops, "add"))
9783 ret = rte_eth_dev_filter_ctrl(res->port_id,
9784 RTE_ETH_FILTER_NTUPLE,
9788 ret = rte_eth_dev_filter_ctrl(res->port_id,
9789 RTE_ETH_FILTER_NTUPLE,
9790 RTE_ETH_FILTER_DELETE,
9793 printf("2tuple filter programming error: (%s)\n",
9798 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9799 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9800 filter, "2tuple_filter");
9801 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9802 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9804 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9805 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9807 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9808 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9809 dst_port, "dst_port");
9810 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9811 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9812 dst_port_value, UINT16);
9813 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9814 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9815 protocol, "protocol");
9816 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9817 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9818 protocol_value, UINT8);
9819 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9820 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9822 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9823 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9825 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9826 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9827 tcp_flags, "tcp_flags");
9828 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9829 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9830 tcp_flags_value, UINT8);
9831 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9832 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9833 priority, "priority");
9834 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9835 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9836 priority_value, UINT8);
9837 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9838 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9840 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9841 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9844 cmdline_parse_inst_t cmd_2tuple_filter = {
9845 .f = cmd_2tuple_filter_parsed,
9847 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9848 "<value> mask <value> tcp_flags <value> priority <value> queue "
9849 "<queue_id>: Add a 2tuple filter",
9851 (void *)&cmd_2tuple_filter_filter,
9852 (void *)&cmd_2tuple_filter_port_id,
9853 (void *)&cmd_2tuple_filter_ops,
9854 (void *)&cmd_2tuple_filter_dst_port,
9855 (void *)&cmd_2tuple_filter_dst_port_value,
9856 (void *)&cmd_2tuple_filter_protocol,
9857 (void *)&cmd_2tuple_filter_protocol_value,
9858 (void *)&cmd_2tuple_filter_mask,
9859 (void *)&cmd_2tuple_filter_mask_value,
9860 (void *)&cmd_2tuple_filter_tcp_flags,
9861 (void *)&cmd_2tuple_filter_tcp_flags_value,
9862 (void *)&cmd_2tuple_filter_priority,
9863 (void *)&cmd_2tuple_filter_priority_value,
9864 (void *)&cmd_2tuple_filter_queue,
9865 (void *)&cmd_2tuple_filter_queue_id,
9870 /* *** ADD/REMOVE A 5tuple FILTER *** */
9871 struct cmd_5tuple_filter_result {
9872 cmdline_fixed_string_t filter;
9874 cmdline_fixed_string_t ops;
9875 cmdline_fixed_string_t dst_ip;
9876 cmdline_ipaddr_t dst_ip_value;
9877 cmdline_fixed_string_t src_ip;
9878 cmdline_ipaddr_t src_ip_value;
9879 cmdline_fixed_string_t dst_port;
9880 uint16_t dst_port_value;
9881 cmdline_fixed_string_t src_port;
9882 uint16_t src_port_value;
9883 cmdline_fixed_string_t protocol;
9884 uint8_t protocol_value;
9885 cmdline_fixed_string_t mask;
9887 cmdline_fixed_string_t tcp_flags;
9888 uint8_t tcp_flags_value;
9889 cmdline_fixed_string_t priority;
9890 uint8_t priority_value;
9891 cmdline_fixed_string_t queue;
9896 cmd_5tuple_filter_parsed(void *parsed_result,
9897 __attribute__((unused)) struct cmdline *cl,
9898 __attribute__((unused)) void *data)
9900 struct rte_eth_ntuple_filter filter;
9901 struct cmd_5tuple_filter_result *res = parsed_result;
9904 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9906 printf("ntuple filter is not supported on port %u.\n",
9911 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9913 filter.flags = RTE_5TUPLE_FLAGS;
9914 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9915 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9916 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9917 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9918 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9919 filter.proto = res->protocol_value;
9920 filter.priority = res->priority_value;
9921 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9922 printf("nonzero tcp_flags is only meaningful"
9923 " when protocol is TCP.\n");
9926 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9927 printf("invalid TCP flags.\n");
9931 if (res->tcp_flags_value != 0) {
9932 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9933 filter.tcp_flags = res->tcp_flags_value;
9936 if (res->dst_ip_value.family == AF_INET)
9937 /* no need to convert, already big endian. */
9938 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9940 if (filter.dst_ip_mask == 0) {
9941 printf("can not support ipv6 involved compare.\n");
9947 if (res->src_ip_value.family == AF_INET)
9948 /* no need to convert, already big endian. */
9949 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9951 if (filter.src_ip_mask == 0) {
9952 printf("can not support ipv6 involved compare.\n");
9957 /* need convert to big endian. */
9958 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9959 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9960 filter.queue = res->queue_id;
9962 if (!strcmp(res->ops, "add"))
9963 ret = rte_eth_dev_filter_ctrl(res->port_id,
9964 RTE_ETH_FILTER_NTUPLE,
9968 ret = rte_eth_dev_filter_ctrl(res->port_id,
9969 RTE_ETH_FILTER_NTUPLE,
9970 RTE_ETH_FILTER_DELETE,
9973 printf("5tuple filter programming error: (%s)\n",
9977 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9978 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9979 filter, "5tuple_filter");
9980 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9981 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9983 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9984 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9986 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9987 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9989 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9990 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9992 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9993 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9995 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9996 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9998 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9999 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10000 dst_port, "dst_port");
10001 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10002 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10003 dst_port_value, UINT16);
10004 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10005 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10006 src_port, "src_port");
10007 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10008 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10009 src_port_value, UINT16);
10010 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10011 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10012 protocol, "protocol");
10013 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10014 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10015 protocol_value, UINT8);
10016 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10017 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10019 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10020 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10022 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10023 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10024 tcp_flags, "tcp_flags");
10025 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10026 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10027 tcp_flags_value, UINT8);
10028 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10029 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10030 priority, "priority");
10031 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10032 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10033 priority_value, UINT8);
10034 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10035 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10037 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10038 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10041 cmdline_parse_inst_t cmd_5tuple_filter = {
10042 .f = cmd_5tuple_filter_parsed,
10044 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10045 "src_ip <value> dst_port <value> src_port <value> "
10046 "protocol <value> mask <value> tcp_flags <value> "
10047 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10049 (void *)&cmd_5tuple_filter_filter,
10050 (void *)&cmd_5tuple_filter_port_id,
10051 (void *)&cmd_5tuple_filter_ops,
10052 (void *)&cmd_5tuple_filter_dst_ip,
10053 (void *)&cmd_5tuple_filter_dst_ip_value,
10054 (void *)&cmd_5tuple_filter_src_ip,
10055 (void *)&cmd_5tuple_filter_src_ip_value,
10056 (void *)&cmd_5tuple_filter_dst_port,
10057 (void *)&cmd_5tuple_filter_dst_port_value,
10058 (void *)&cmd_5tuple_filter_src_port,
10059 (void *)&cmd_5tuple_filter_src_port_value,
10060 (void *)&cmd_5tuple_filter_protocol,
10061 (void *)&cmd_5tuple_filter_protocol_value,
10062 (void *)&cmd_5tuple_filter_mask,
10063 (void *)&cmd_5tuple_filter_mask_value,
10064 (void *)&cmd_5tuple_filter_tcp_flags,
10065 (void *)&cmd_5tuple_filter_tcp_flags_value,
10066 (void *)&cmd_5tuple_filter_priority,
10067 (void *)&cmd_5tuple_filter_priority_value,
10068 (void *)&cmd_5tuple_filter_queue,
10069 (void *)&cmd_5tuple_filter_queue_id,
10074 /* *** ADD/REMOVE A flex FILTER *** */
10075 struct cmd_flex_filter_result {
10076 cmdline_fixed_string_t filter;
10077 cmdline_fixed_string_t ops;
10079 cmdline_fixed_string_t len;
10081 cmdline_fixed_string_t bytes;
10082 cmdline_fixed_string_t bytes_value;
10083 cmdline_fixed_string_t mask;
10084 cmdline_fixed_string_t mask_value;
10085 cmdline_fixed_string_t priority;
10086 uint8_t priority_value;
10087 cmdline_fixed_string_t queue;
10091 static int xdigit2val(unsigned char c)
10096 else if (isupper(c))
10097 val = c - 'A' + 10;
10099 val = c - 'a' + 10;
10104 cmd_flex_filter_parsed(void *parsed_result,
10105 __attribute__((unused)) struct cmdline *cl,
10106 __attribute__((unused)) void *data)
10109 struct rte_eth_flex_filter filter;
10110 struct cmd_flex_filter_result *res = parsed_result;
10111 char *bytes_ptr, *mask_ptr;
10112 uint16_t len, i, j = 0;
10117 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10118 printf("the len exceed the max length 128\n");
10121 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10122 filter.len = res->len_value;
10123 filter.priority = res->priority_value;
10124 filter.queue = res->queue_id;
10125 bytes_ptr = res->bytes_value;
10126 mask_ptr = res->mask_value;
10128 /* translate bytes string to array. */
10129 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10130 (bytes_ptr[1] == 'X')))
10132 len = strnlen(bytes_ptr, res->len_value * 2);
10133 if (len == 0 || (len % 8 != 0)) {
10134 printf("please check len and bytes input\n");
10137 for (i = 0; i < len; i++) {
10139 if (isxdigit(c) == 0) {
10140 /* invalid characters. */
10141 printf("invalid input\n");
10144 val = xdigit2val(c);
10147 filter.bytes[j] = byte;
10148 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10155 /* translate mask string to uint8_t array. */
10156 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10157 (mask_ptr[1] == 'X')))
10159 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10161 printf("invalid input\n");
10166 for (i = 0; i < len; i++) {
10168 if (isxdigit(c) == 0) {
10169 /* invalid characters. */
10170 printf("invalid input\n");
10173 val = xdigit2val(c);
10176 filter.mask[j] = byte;
10177 printf("mask[%d]:%02x ", j, filter.mask[j]);
10185 if (!strcmp(res->ops, "add"))
10186 ret = rte_eth_dev_filter_ctrl(res->port_id,
10187 RTE_ETH_FILTER_FLEXIBLE,
10188 RTE_ETH_FILTER_ADD,
10191 ret = rte_eth_dev_filter_ctrl(res->port_id,
10192 RTE_ETH_FILTER_FLEXIBLE,
10193 RTE_ETH_FILTER_DELETE,
10197 printf("flex filter setting error: (%s)\n", strerror(-ret));
10200 cmdline_parse_token_string_t cmd_flex_filter_filter =
10201 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10202 filter, "flex_filter");
10203 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10204 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10206 cmdline_parse_token_string_t cmd_flex_filter_ops =
10207 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10209 cmdline_parse_token_string_t cmd_flex_filter_len =
10210 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10212 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10213 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10215 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10216 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10218 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10219 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10220 bytes_value, NULL);
10221 cmdline_parse_token_string_t cmd_flex_filter_mask =
10222 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10224 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10225 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10227 cmdline_parse_token_string_t cmd_flex_filter_priority =
10228 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10229 priority, "priority");
10230 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10231 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10232 priority_value, UINT8);
10233 cmdline_parse_token_string_t cmd_flex_filter_queue =
10234 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10236 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10237 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10239 cmdline_parse_inst_t cmd_flex_filter = {
10240 .f = cmd_flex_filter_parsed,
10242 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10243 "<value> mask <value> priority <value> queue <queue_id>: "
10244 "Add/Del a flex filter",
10246 (void *)&cmd_flex_filter_filter,
10247 (void *)&cmd_flex_filter_port_id,
10248 (void *)&cmd_flex_filter_ops,
10249 (void *)&cmd_flex_filter_len,
10250 (void *)&cmd_flex_filter_len_value,
10251 (void *)&cmd_flex_filter_bytes,
10252 (void *)&cmd_flex_filter_bytes_value,
10253 (void *)&cmd_flex_filter_mask,
10254 (void *)&cmd_flex_filter_mask_value,
10255 (void *)&cmd_flex_filter_priority,
10256 (void *)&cmd_flex_filter_priority_value,
10257 (void *)&cmd_flex_filter_queue,
10258 (void *)&cmd_flex_filter_queue_id,
10263 /* *** Filters Control *** */
10265 /* *** deal with ethertype filter *** */
10266 struct cmd_ethertype_filter_result {
10267 cmdline_fixed_string_t filter;
10269 cmdline_fixed_string_t ops;
10270 cmdline_fixed_string_t mac;
10271 struct ether_addr mac_addr;
10272 cmdline_fixed_string_t ethertype;
10273 uint16_t ethertype_value;
10274 cmdline_fixed_string_t drop;
10275 cmdline_fixed_string_t queue;
10279 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10280 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10281 filter, "ethertype_filter");
10282 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10283 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10285 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10286 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10288 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10289 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10290 mac, "mac_addr#mac_ignr");
10291 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10292 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10294 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10295 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10296 ethertype, "ethertype");
10297 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10298 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10299 ethertype_value, UINT16);
10300 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10301 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10303 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10304 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10306 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10307 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10311 cmd_ethertype_filter_parsed(void *parsed_result,
10312 __attribute__((unused)) struct cmdline *cl,
10313 __attribute__((unused)) void *data)
10315 struct cmd_ethertype_filter_result *res = parsed_result;
10316 struct rte_eth_ethertype_filter filter;
10319 ret = rte_eth_dev_filter_supported(res->port_id,
10320 RTE_ETH_FILTER_ETHERTYPE);
10322 printf("ethertype filter is not supported on port %u.\n",
10327 memset(&filter, 0, sizeof(filter));
10328 if (!strcmp(res->mac, "mac_addr")) {
10329 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10330 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10331 sizeof(struct ether_addr));
10333 if (!strcmp(res->drop, "drop"))
10334 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10335 filter.ether_type = res->ethertype_value;
10336 filter.queue = res->queue_id;
10338 if (!strcmp(res->ops, "add"))
10339 ret = rte_eth_dev_filter_ctrl(res->port_id,
10340 RTE_ETH_FILTER_ETHERTYPE,
10341 RTE_ETH_FILTER_ADD,
10344 ret = rte_eth_dev_filter_ctrl(res->port_id,
10345 RTE_ETH_FILTER_ETHERTYPE,
10346 RTE_ETH_FILTER_DELETE,
10349 printf("ethertype filter programming error: (%s)\n",
10353 cmdline_parse_inst_t cmd_ethertype_filter = {
10354 .f = cmd_ethertype_filter_parsed,
10356 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10357 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10358 "Add or delete an ethertype filter entry",
10360 (void *)&cmd_ethertype_filter_filter,
10361 (void *)&cmd_ethertype_filter_port_id,
10362 (void *)&cmd_ethertype_filter_ops,
10363 (void *)&cmd_ethertype_filter_mac,
10364 (void *)&cmd_ethertype_filter_mac_addr,
10365 (void *)&cmd_ethertype_filter_ethertype,
10366 (void *)&cmd_ethertype_filter_ethertype_value,
10367 (void *)&cmd_ethertype_filter_drop,
10368 (void *)&cmd_ethertype_filter_queue,
10369 (void *)&cmd_ethertype_filter_queue_id,
10374 /* *** deal with flow director filter *** */
10375 struct cmd_flow_director_result {
10376 cmdline_fixed_string_t flow_director_filter;
10378 cmdline_fixed_string_t mode;
10379 cmdline_fixed_string_t mode_value;
10380 cmdline_fixed_string_t ops;
10381 cmdline_fixed_string_t flow;
10382 cmdline_fixed_string_t flow_type;
10383 cmdline_fixed_string_t ether;
10384 uint16_t ether_type;
10385 cmdline_fixed_string_t src;
10386 cmdline_ipaddr_t ip_src;
10388 cmdline_fixed_string_t dst;
10389 cmdline_ipaddr_t ip_dst;
10391 cmdline_fixed_string_t verify_tag;
10392 uint32_t verify_tag_value;
10393 cmdline_fixed_string_t tos;
10395 cmdline_fixed_string_t proto;
10396 uint8_t proto_value;
10397 cmdline_fixed_string_t ttl;
10399 cmdline_fixed_string_t vlan;
10400 uint16_t vlan_value;
10401 cmdline_fixed_string_t flexbytes;
10402 cmdline_fixed_string_t flexbytes_value;
10403 cmdline_fixed_string_t pf_vf;
10404 cmdline_fixed_string_t drop;
10405 cmdline_fixed_string_t queue;
10407 cmdline_fixed_string_t fd_id;
10408 uint32_t fd_id_value;
10409 cmdline_fixed_string_t mac;
10410 struct ether_addr mac_addr;
10411 cmdline_fixed_string_t tunnel;
10412 cmdline_fixed_string_t tunnel_type;
10413 cmdline_fixed_string_t tunnel_id;
10414 uint32_t tunnel_id_value;
10415 cmdline_fixed_string_t packet;
10420 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10423 const char *p, *p0 = q_arg;
10425 unsigned long int_fld;
10426 char *str_fld[max_num];
10431 p = strchr(p0, '(');
10435 p0 = strchr(p, ')');
10440 if (size >= sizeof(s))
10443 snprintf(s, sizeof(s), "%.*s", size, p);
10444 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10445 if (ret < 0 || ret > max_num)
10447 for (i = 0; i < ret; i++) {
10449 int_fld = strtoul(str_fld[i], &end, 0);
10450 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10452 flexbytes[i] = (uint8_t)int_fld;
10458 str2flowtype(char *string)
10461 static const struct {
10464 } flowtype_str[] = {
10465 {"raw", RTE_ETH_FLOW_RAW},
10466 {"ipv4", RTE_ETH_FLOW_IPV4},
10467 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10468 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10469 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10470 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10471 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10472 {"ipv6", RTE_ETH_FLOW_IPV6},
10473 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10474 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10475 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10476 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10477 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10478 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10481 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10482 if (!strcmp(flowtype_str[i].str, string))
10483 return flowtype_str[i].type;
10486 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10487 return (uint16_t)atoi(string);
10489 return RTE_ETH_FLOW_UNKNOWN;
10492 static enum rte_eth_fdir_tunnel_type
10493 str2fdir_tunneltype(char *string)
10497 static const struct {
10499 enum rte_eth_fdir_tunnel_type type;
10500 } tunneltype_str[] = {
10501 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10502 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10505 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10506 if (!strcmp(tunneltype_str[i].str, string))
10507 return tunneltype_str[i].type;
10509 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10512 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10514 if ((ip_addr).family == AF_INET) \
10515 (ip) = (ip_addr).addr.ipv4.s_addr; \
10517 printf("invalid parameter.\n"); \
10522 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10524 if ((ip_addr).family == AF_INET6) \
10525 rte_memcpy(&(ip), \
10526 &((ip_addr).addr.ipv6), \
10527 sizeof(struct in6_addr)); \
10529 printf("invalid parameter.\n"); \
10535 cmd_flow_director_filter_parsed(void *parsed_result,
10536 __attribute__((unused)) struct cmdline *cl,
10537 __attribute__((unused)) void *data)
10539 struct cmd_flow_director_result *res = parsed_result;
10540 struct rte_eth_fdir_filter entry;
10541 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10543 unsigned long vf_id;
10546 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10548 printf("flow director is not supported on port %u.\n",
10552 memset(flexbytes, 0, sizeof(flexbytes));
10553 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10555 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10556 if (strcmp(res->mode_value, "MAC-VLAN")) {
10557 printf("Please set mode to MAC-VLAN.\n");
10560 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10561 if (strcmp(res->mode_value, "Tunnel")) {
10562 printf("Please set mode to Tunnel.\n");
10566 if (!strcmp(res->mode_value, "raw")) {
10567 #ifdef RTE_LIBRTE_I40E_PMD
10568 struct rte_pmd_i40e_flow_type_mapping
10569 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10570 struct rte_pmd_i40e_pkt_template_conf conf;
10571 uint16_t flow_type = str2flowtype(res->flow_type);
10572 uint16_t i, port = res->port_id;
10575 memset(&conf, 0, sizeof(conf));
10577 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10578 printf("Invalid flow type specified.\n");
10581 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10585 if (mapping[flow_type].pctype == 0ULL) {
10586 printf("Invalid flow type specified.\n");
10589 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10590 if (mapping[flow_type].pctype & (1ULL << i)) {
10591 conf.input.pctype = i;
10596 conf.input.packet = open_file(res->filepath,
10597 &conf.input.length);
10598 if (!conf.input.packet)
10600 if (!strcmp(res->drop, "drop"))
10601 conf.action.behavior =
10602 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10604 conf.action.behavior =
10605 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10606 conf.action.report_status =
10607 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10608 conf.action.rx_queue = res->queue_id;
10609 conf.soft_id = res->fd_id_value;
10610 add = strcmp(res->ops, "del") ? 1 : 0;
10611 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10615 printf("flow director config error: (%s)\n",
10617 close_file(conf.input.packet);
10620 } else if (strcmp(res->mode_value, "IP")) {
10621 printf("Please set mode to IP or raw.\n");
10624 entry.input.flow_type = str2flowtype(res->flow_type);
10627 ret = parse_flexbytes(res->flexbytes_value,
10629 RTE_ETH_FDIR_MAX_FLEXLEN);
10631 printf("error: Cannot parse flexbytes input.\n");
10635 switch (entry.input.flow_type) {
10636 case RTE_ETH_FLOW_FRAG_IPV4:
10637 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10638 entry.input.flow.ip4_flow.proto = res->proto_value;
10640 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10641 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10642 IPV4_ADDR_TO_UINT(res->ip_dst,
10643 entry.input.flow.ip4_flow.dst_ip);
10644 IPV4_ADDR_TO_UINT(res->ip_src,
10645 entry.input.flow.ip4_flow.src_ip);
10646 entry.input.flow.ip4_flow.tos = res->tos_value;
10647 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10648 /* need convert to big endian. */
10649 entry.input.flow.udp4_flow.dst_port =
10650 rte_cpu_to_be_16(res->port_dst);
10651 entry.input.flow.udp4_flow.src_port =
10652 rte_cpu_to_be_16(res->port_src);
10654 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10655 IPV4_ADDR_TO_UINT(res->ip_dst,
10656 entry.input.flow.sctp4_flow.ip.dst_ip);
10657 IPV4_ADDR_TO_UINT(res->ip_src,
10658 entry.input.flow.sctp4_flow.ip.src_ip);
10659 entry.input.flow.ip4_flow.tos = res->tos_value;
10660 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10661 /* need convert to big endian. */
10662 entry.input.flow.sctp4_flow.dst_port =
10663 rte_cpu_to_be_16(res->port_dst);
10664 entry.input.flow.sctp4_flow.src_port =
10665 rte_cpu_to_be_16(res->port_src);
10666 entry.input.flow.sctp4_flow.verify_tag =
10667 rte_cpu_to_be_32(res->verify_tag_value);
10669 case RTE_ETH_FLOW_FRAG_IPV6:
10670 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10671 entry.input.flow.ipv6_flow.proto = res->proto_value;
10673 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10674 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10675 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10676 entry.input.flow.ipv6_flow.dst_ip);
10677 IPV6_ADDR_TO_ARRAY(res->ip_src,
10678 entry.input.flow.ipv6_flow.src_ip);
10679 entry.input.flow.ipv6_flow.tc = res->tos_value;
10680 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10681 /* need convert to big endian. */
10682 entry.input.flow.udp6_flow.dst_port =
10683 rte_cpu_to_be_16(res->port_dst);
10684 entry.input.flow.udp6_flow.src_port =
10685 rte_cpu_to_be_16(res->port_src);
10687 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10688 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10689 entry.input.flow.sctp6_flow.ip.dst_ip);
10690 IPV6_ADDR_TO_ARRAY(res->ip_src,
10691 entry.input.flow.sctp6_flow.ip.src_ip);
10692 entry.input.flow.ipv6_flow.tc = res->tos_value;
10693 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10694 /* need convert to big endian. */
10695 entry.input.flow.sctp6_flow.dst_port =
10696 rte_cpu_to_be_16(res->port_dst);
10697 entry.input.flow.sctp6_flow.src_port =
10698 rte_cpu_to_be_16(res->port_src);
10699 entry.input.flow.sctp6_flow.verify_tag =
10700 rte_cpu_to_be_32(res->verify_tag_value);
10702 case RTE_ETH_FLOW_L2_PAYLOAD:
10703 entry.input.flow.l2_flow.ether_type =
10704 rte_cpu_to_be_16(res->ether_type);
10710 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10711 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10713 sizeof(struct ether_addr));
10715 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10716 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10718 sizeof(struct ether_addr));
10719 entry.input.flow.tunnel_flow.tunnel_type =
10720 str2fdir_tunneltype(res->tunnel_type);
10721 entry.input.flow.tunnel_flow.tunnel_id =
10722 rte_cpu_to_be_32(res->tunnel_id_value);
10725 rte_memcpy(entry.input.flow_ext.flexbytes,
10727 RTE_ETH_FDIR_MAX_FLEXLEN);
10729 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10731 entry.action.flex_off = 0; /*use 0 by default */
10732 if (!strcmp(res->drop, "drop"))
10733 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10735 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10737 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10738 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10739 if (!strcmp(res->pf_vf, "pf"))
10740 entry.input.flow_ext.is_vf = 0;
10741 else if (!strncmp(res->pf_vf, "vf", 2)) {
10742 struct rte_eth_dev_info dev_info;
10744 memset(&dev_info, 0, sizeof(dev_info));
10745 rte_eth_dev_info_get(res->port_id, &dev_info);
10747 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10748 if (errno != 0 || *end != '\0' ||
10749 vf_id >= dev_info.max_vfs) {
10750 printf("invalid parameter %s.\n", res->pf_vf);
10753 entry.input.flow_ext.is_vf = 1;
10754 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10756 printf("invalid parameter %s.\n", res->pf_vf);
10761 /* set to report FD ID by default */
10762 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10763 entry.action.rx_queue = res->queue_id;
10764 entry.soft_id = res->fd_id_value;
10765 if (!strcmp(res->ops, "add"))
10766 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10767 RTE_ETH_FILTER_ADD, &entry);
10768 else if (!strcmp(res->ops, "del"))
10769 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10770 RTE_ETH_FILTER_DELETE, &entry);
10772 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10773 RTE_ETH_FILTER_UPDATE, &entry);
10775 printf("flow director programming error: (%s)\n",
10779 cmdline_parse_token_string_t cmd_flow_director_filter =
10780 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10781 flow_director_filter, "flow_director_filter");
10782 cmdline_parse_token_num_t cmd_flow_director_port_id =
10783 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10785 cmdline_parse_token_string_t cmd_flow_director_ops =
10786 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10787 ops, "add#del#update");
10788 cmdline_parse_token_string_t cmd_flow_director_flow =
10789 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10791 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10792 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10794 cmdline_parse_token_string_t cmd_flow_director_ether =
10795 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10797 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10798 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10799 ether_type, UINT16);
10800 cmdline_parse_token_string_t cmd_flow_director_src =
10801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10803 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10804 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10806 cmdline_parse_token_num_t cmd_flow_director_port_src =
10807 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10809 cmdline_parse_token_string_t cmd_flow_director_dst =
10810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10812 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10813 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10815 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10816 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10818 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10820 verify_tag, "verify_tag");
10821 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10822 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10823 verify_tag_value, UINT32);
10824 cmdline_parse_token_string_t cmd_flow_director_tos =
10825 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10827 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10828 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10830 cmdline_parse_token_string_t cmd_flow_director_proto =
10831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10833 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10834 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10835 proto_value, UINT8);
10836 cmdline_parse_token_string_t cmd_flow_director_ttl =
10837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10839 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10840 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10842 cmdline_parse_token_string_t cmd_flow_director_vlan =
10843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10845 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10846 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10847 vlan_value, UINT16);
10848 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10849 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10850 flexbytes, "flexbytes");
10851 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10853 flexbytes_value, NULL);
10854 cmdline_parse_token_string_t cmd_flow_director_drop =
10855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10857 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10860 cmdline_parse_token_string_t cmd_flow_director_queue =
10861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10863 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10864 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10866 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10869 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10870 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10871 fd_id_value, UINT32);
10873 cmdline_parse_token_string_t cmd_flow_director_mode =
10874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10876 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10877 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10879 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10881 mode_value, "MAC-VLAN");
10882 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10883 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10884 mode_value, "Tunnel");
10885 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10887 mode_value, "raw");
10888 cmdline_parse_token_string_t cmd_flow_director_mac =
10889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10891 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10892 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10894 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10897 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10899 tunnel_type, "NVGRE#VxLAN");
10900 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10902 tunnel_id, "tunnel-id");
10903 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10904 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10905 tunnel_id_value, UINT32);
10906 cmdline_parse_token_string_t cmd_flow_director_packet =
10907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10909 cmdline_parse_token_string_t cmd_flow_director_filepath =
10910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10913 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10914 .f = cmd_flow_director_filter_parsed,
10916 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10917 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10918 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10919 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10920 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10921 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10922 "fd_id <fd_id_value>: "
10923 "Add or delete an ip flow director entry on NIC",
10925 (void *)&cmd_flow_director_filter,
10926 (void *)&cmd_flow_director_port_id,
10927 (void *)&cmd_flow_director_mode,
10928 (void *)&cmd_flow_director_mode_ip,
10929 (void *)&cmd_flow_director_ops,
10930 (void *)&cmd_flow_director_flow,
10931 (void *)&cmd_flow_director_flow_type,
10932 (void *)&cmd_flow_director_src,
10933 (void *)&cmd_flow_director_ip_src,
10934 (void *)&cmd_flow_director_dst,
10935 (void *)&cmd_flow_director_ip_dst,
10936 (void *)&cmd_flow_director_tos,
10937 (void *)&cmd_flow_director_tos_value,
10938 (void *)&cmd_flow_director_proto,
10939 (void *)&cmd_flow_director_proto_value,
10940 (void *)&cmd_flow_director_ttl,
10941 (void *)&cmd_flow_director_ttl_value,
10942 (void *)&cmd_flow_director_vlan,
10943 (void *)&cmd_flow_director_vlan_value,
10944 (void *)&cmd_flow_director_flexbytes,
10945 (void *)&cmd_flow_director_flexbytes_value,
10946 (void *)&cmd_flow_director_drop,
10947 (void *)&cmd_flow_director_pf_vf,
10948 (void *)&cmd_flow_director_queue,
10949 (void *)&cmd_flow_director_queue_id,
10950 (void *)&cmd_flow_director_fd_id,
10951 (void *)&cmd_flow_director_fd_id_value,
10956 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10957 .f = cmd_flow_director_filter_parsed,
10959 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10960 "director entry on NIC",
10962 (void *)&cmd_flow_director_filter,
10963 (void *)&cmd_flow_director_port_id,
10964 (void *)&cmd_flow_director_mode,
10965 (void *)&cmd_flow_director_mode_ip,
10966 (void *)&cmd_flow_director_ops,
10967 (void *)&cmd_flow_director_flow,
10968 (void *)&cmd_flow_director_flow_type,
10969 (void *)&cmd_flow_director_src,
10970 (void *)&cmd_flow_director_ip_src,
10971 (void *)&cmd_flow_director_port_src,
10972 (void *)&cmd_flow_director_dst,
10973 (void *)&cmd_flow_director_ip_dst,
10974 (void *)&cmd_flow_director_port_dst,
10975 (void *)&cmd_flow_director_tos,
10976 (void *)&cmd_flow_director_tos_value,
10977 (void *)&cmd_flow_director_ttl,
10978 (void *)&cmd_flow_director_ttl_value,
10979 (void *)&cmd_flow_director_vlan,
10980 (void *)&cmd_flow_director_vlan_value,
10981 (void *)&cmd_flow_director_flexbytes,
10982 (void *)&cmd_flow_director_flexbytes_value,
10983 (void *)&cmd_flow_director_drop,
10984 (void *)&cmd_flow_director_pf_vf,
10985 (void *)&cmd_flow_director_queue,
10986 (void *)&cmd_flow_director_queue_id,
10987 (void *)&cmd_flow_director_fd_id,
10988 (void *)&cmd_flow_director_fd_id_value,
10993 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10994 .f = cmd_flow_director_filter_parsed,
10996 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10997 "director entry on NIC",
10999 (void *)&cmd_flow_director_filter,
11000 (void *)&cmd_flow_director_port_id,
11001 (void *)&cmd_flow_director_mode,
11002 (void *)&cmd_flow_director_mode_ip,
11003 (void *)&cmd_flow_director_ops,
11004 (void *)&cmd_flow_director_flow,
11005 (void *)&cmd_flow_director_flow_type,
11006 (void *)&cmd_flow_director_src,
11007 (void *)&cmd_flow_director_ip_src,
11008 (void *)&cmd_flow_director_port_src,
11009 (void *)&cmd_flow_director_dst,
11010 (void *)&cmd_flow_director_ip_dst,
11011 (void *)&cmd_flow_director_port_dst,
11012 (void *)&cmd_flow_director_verify_tag,
11013 (void *)&cmd_flow_director_verify_tag_value,
11014 (void *)&cmd_flow_director_tos,
11015 (void *)&cmd_flow_director_tos_value,
11016 (void *)&cmd_flow_director_ttl,
11017 (void *)&cmd_flow_director_ttl_value,
11018 (void *)&cmd_flow_director_vlan,
11019 (void *)&cmd_flow_director_vlan_value,
11020 (void *)&cmd_flow_director_flexbytes,
11021 (void *)&cmd_flow_director_flexbytes_value,
11022 (void *)&cmd_flow_director_drop,
11023 (void *)&cmd_flow_director_pf_vf,
11024 (void *)&cmd_flow_director_queue,
11025 (void *)&cmd_flow_director_queue_id,
11026 (void *)&cmd_flow_director_fd_id,
11027 (void *)&cmd_flow_director_fd_id_value,
11032 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11033 .f = cmd_flow_director_filter_parsed,
11035 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11036 "director entry on NIC",
11038 (void *)&cmd_flow_director_filter,
11039 (void *)&cmd_flow_director_port_id,
11040 (void *)&cmd_flow_director_mode,
11041 (void *)&cmd_flow_director_mode_ip,
11042 (void *)&cmd_flow_director_ops,
11043 (void *)&cmd_flow_director_flow,
11044 (void *)&cmd_flow_director_flow_type,
11045 (void *)&cmd_flow_director_ether,
11046 (void *)&cmd_flow_director_ether_type,
11047 (void *)&cmd_flow_director_flexbytes,
11048 (void *)&cmd_flow_director_flexbytes_value,
11049 (void *)&cmd_flow_director_drop,
11050 (void *)&cmd_flow_director_pf_vf,
11051 (void *)&cmd_flow_director_queue,
11052 (void *)&cmd_flow_director_queue_id,
11053 (void *)&cmd_flow_director_fd_id,
11054 (void *)&cmd_flow_director_fd_id_value,
11059 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11060 .f = cmd_flow_director_filter_parsed,
11062 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11063 "director entry on NIC",
11065 (void *)&cmd_flow_director_filter,
11066 (void *)&cmd_flow_director_port_id,
11067 (void *)&cmd_flow_director_mode,
11068 (void *)&cmd_flow_director_mode_mac_vlan,
11069 (void *)&cmd_flow_director_ops,
11070 (void *)&cmd_flow_director_mac,
11071 (void *)&cmd_flow_director_mac_addr,
11072 (void *)&cmd_flow_director_vlan,
11073 (void *)&cmd_flow_director_vlan_value,
11074 (void *)&cmd_flow_director_flexbytes,
11075 (void *)&cmd_flow_director_flexbytes_value,
11076 (void *)&cmd_flow_director_drop,
11077 (void *)&cmd_flow_director_queue,
11078 (void *)&cmd_flow_director_queue_id,
11079 (void *)&cmd_flow_director_fd_id,
11080 (void *)&cmd_flow_director_fd_id_value,
11085 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11086 .f = cmd_flow_director_filter_parsed,
11088 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11089 "director entry on NIC",
11091 (void *)&cmd_flow_director_filter,
11092 (void *)&cmd_flow_director_port_id,
11093 (void *)&cmd_flow_director_mode,
11094 (void *)&cmd_flow_director_mode_tunnel,
11095 (void *)&cmd_flow_director_ops,
11096 (void *)&cmd_flow_director_mac,
11097 (void *)&cmd_flow_director_mac_addr,
11098 (void *)&cmd_flow_director_vlan,
11099 (void *)&cmd_flow_director_vlan_value,
11100 (void *)&cmd_flow_director_tunnel,
11101 (void *)&cmd_flow_director_tunnel_type,
11102 (void *)&cmd_flow_director_tunnel_id,
11103 (void *)&cmd_flow_director_tunnel_id_value,
11104 (void *)&cmd_flow_director_flexbytes,
11105 (void *)&cmd_flow_director_flexbytes_value,
11106 (void *)&cmd_flow_director_drop,
11107 (void *)&cmd_flow_director_queue,
11108 (void *)&cmd_flow_director_queue_id,
11109 (void *)&cmd_flow_director_fd_id,
11110 (void *)&cmd_flow_director_fd_id_value,
11115 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11116 .f = cmd_flow_director_filter_parsed,
11118 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11119 "director entry on NIC",
11121 (void *)&cmd_flow_director_filter,
11122 (void *)&cmd_flow_director_port_id,
11123 (void *)&cmd_flow_director_mode,
11124 (void *)&cmd_flow_director_mode_raw,
11125 (void *)&cmd_flow_director_ops,
11126 (void *)&cmd_flow_director_flow,
11127 (void *)&cmd_flow_director_flow_type,
11128 (void *)&cmd_flow_director_drop,
11129 (void *)&cmd_flow_director_queue,
11130 (void *)&cmd_flow_director_queue_id,
11131 (void *)&cmd_flow_director_fd_id,
11132 (void *)&cmd_flow_director_fd_id_value,
11133 (void *)&cmd_flow_director_packet,
11134 (void *)&cmd_flow_director_filepath,
11139 struct cmd_flush_flow_director_result {
11140 cmdline_fixed_string_t flush_flow_director;
11144 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11145 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11146 flush_flow_director, "flush_flow_director");
11147 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11148 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11152 cmd_flush_flow_director_parsed(void *parsed_result,
11153 __attribute__((unused)) struct cmdline *cl,
11154 __attribute__((unused)) void *data)
11156 struct cmd_flow_director_result *res = parsed_result;
11159 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11161 printf("flow director is not supported on port %u.\n",
11166 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11167 RTE_ETH_FILTER_FLUSH, NULL);
11169 printf("flow director table flushing error: (%s)\n",
11173 cmdline_parse_inst_t cmd_flush_flow_director = {
11174 .f = cmd_flush_flow_director_parsed,
11176 .help_str = "flush_flow_director <port_id>: "
11177 "Flush all flow director entries of a device on NIC",
11179 (void *)&cmd_flush_flow_director_flush,
11180 (void *)&cmd_flush_flow_director_port_id,
11185 /* *** deal with flow director mask *** */
11186 struct cmd_flow_director_mask_result {
11187 cmdline_fixed_string_t flow_director_mask;
11189 cmdline_fixed_string_t mode;
11190 cmdline_fixed_string_t mode_value;
11191 cmdline_fixed_string_t vlan;
11192 uint16_t vlan_mask;
11193 cmdline_fixed_string_t src_mask;
11194 cmdline_ipaddr_t ipv4_src;
11195 cmdline_ipaddr_t ipv6_src;
11197 cmdline_fixed_string_t dst_mask;
11198 cmdline_ipaddr_t ipv4_dst;
11199 cmdline_ipaddr_t ipv6_dst;
11201 cmdline_fixed_string_t mac;
11202 uint8_t mac_addr_byte_mask;
11203 cmdline_fixed_string_t tunnel_id;
11204 uint32_t tunnel_id_mask;
11205 cmdline_fixed_string_t tunnel_type;
11206 uint8_t tunnel_type_mask;
11210 cmd_flow_director_mask_parsed(void *parsed_result,
11211 __attribute__((unused)) struct cmdline *cl,
11212 __attribute__((unused)) void *data)
11214 struct cmd_flow_director_mask_result *res = parsed_result;
11215 struct rte_eth_fdir_masks *mask;
11216 struct rte_port *port;
11218 port = &ports[res->port_id];
11219 /** Check if the port is not started **/
11220 if (port->port_status != RTE_PORT_STOPPED) {
11221 printf("Please stop port %d first\n", res->port_id);
11225 mask = &port->dev_conf.fdir_conf.mask;
11227 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11228 if (strcmp(res->mode_value, "MAC-VLAN")) {
11229 printf("Please set mode to MAC-VLAN.\n");
11233 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11234 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11235 if (strcmp(res->mode_value, "Tunnel")) {
11236 printf("Please set mode to Tunnel.\n");
11240 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11241 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11242 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11243 mask->tunnel_type_mask = res->tunnel_type_mask;
11245 if (strcmp(res->mode_value, "IP")) {
11246 printf("Please set mode to IP.\n");
11250 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11251 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11252 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11253 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11254 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11255 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11256 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11259 cmd_reconfig_device_queue(res->port_id, 1, 1);
11262 cmdline_parse_token_string_t cmd_flow_director_mask =
11263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11264 flow_director_mask, "flow_director_mask");
11265 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11266 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11268 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11271 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11272 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11273 vlan_mask, UINT16);
11274 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11275 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11276 src_mask, "src_mask");
11277 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11278 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11280 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11281 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11283 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11284 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11286 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11287 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11288 dst_mask, "dst_mask");
11289 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11290 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11292 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11293 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11295 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11296 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11299 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11300 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11302 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11305 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11306 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11307 mode_value, "MAC-VLAN");
11308 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11310 mode_value, "Tunnel");
11311 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11312 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11314 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11315 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11316 mac_addr_byte_mask, UINT8);
11317 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11318 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11319 tunnel_type, "tunnel-type");
11320 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11321 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11322 tunnel_type_mask, UINT8);
11323 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11324 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11325 tunnel_id, "tunnel-id");
11326 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11327 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11328 tunnel_id_mask, UINT32);
11330 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11331 .f = cmd_flow_director_mask_parsed,
11333 .help_str = "flow_director_mask ... : "
11334 "Set IP mode flow director's mask on NIC",
11336 (void *)&cmd_flow_director_mask,
11337 (void *)&cmd_flow_director_mask_port_id,
11338 (void *)&cmd_flow_director_mask_mode,
11339 (void *)&cmd_flow_director_mask_mode_ip,
11340 (void *)&cmd_flow_director_mask_vlan,
11341 (void *)&cmd_flow_director_mask_vlan_value,
11342 (void *)&cmd_flow_director_mask_src,
11343 (void *)&cmd_flow_director_mask_ipv4_src,
11344 (void *)&cmd_flow_director_mask_ipv6_src,
11345 (void *)&cmd_flow_director_mask_port_src,
11346 (void *)&cmd_flow_director_mask_dst,
11347 (void *)&cmd_flow_director_mask_ipv4_dst,
11348 (void *)&cmd_flow_director_mask_ipv6_dst,
11349 (void *)&cmd_flow_director_mask_port_dst,
11354 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11355 .f = cmd_flow_director_mask_parsed,
11357 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11358 "flow director's mask on NIC",
11360 (void *)&cmd_flow_director_mask,
11361 (void *)&cmd_flow_director_mask_port_id,
11362 (void *)&cmd_flow_director_mask_mode,
11363 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11364 (void *)&cmd_flow_director_mask_vlan,
11365 (void *)&cmd_flow_director_mask_vlan_value,
11370 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11371 .f = cmd_flow_director_mask_parsed,
11373 .help_str = "flow_director_mask ... : Set tunnel mode "
11374 "flow director's mask on NIC",
11376 (void *)&cmd_flow_director_mask,
11377 (void *)&cmd_flow_director_mask_port_id,
11378 (void *)&cmd_flow_director_mask_mode,
11379 (void *)&cmd_flow_director_mask_mode_tunnel,
11380 (void *)&cmd_flow_director_mask_vlan,
11381 (void *)&cmd_flow_director_mask_vlan_value,
11382 (void *)&cmd_flow_director_mask_mac,
11383 (void *)&cmd_flow_director_mask_mac_value,
11384 (void *)&cmd_flow_director_mask_tunnel_type,
11385 (void *)&cmd_flow_director_mask_tunnel_type_value,
11386 (void *)&cmd_flow_director_mask_tunnel_id,
11387 (void *)&cmd_flow_director_mask_tunnel_id_value,
11392 /* *** deal with flow director mask on flexible payload *** */
11393 struct cmd_flow_director_flex_mask_result {
11394 cmdline_fixed_string_t flow_director_flexmask;
11396 cmdline_fixed_string_t flow;
11397 cmdline_fixed_string_t flow_type;
11398 cmdline_fixed_string_t mask;
11402 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11403 __attribute__((unused)) struct cmdline *cl,
11404 __attribute__((unused)) void *data)
11406 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11407 struct rte_eth_fdir_info fdir_info;
11408 struct rte_eth_fdir_flex_mask flex_mask;
11409 struct rte_port *port;
11410 uint64_t flow_type_mask;
11414 port = &ports[res->port_id];
11415 /** Check if the port is not started **/
11416 if (port->port_status != RTE_PORT_STOPPED) {
11417 printf("Please stop port %d first\n", res->port_id);
11421 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11422 ret = parse_flexbytes(res->mask,
11424 RTE_ETH_FDIR_MAX_FLEXLEN);
11426 printf("error: Cannot parse mask input.\n");
11430 memset(&fdir_info, 0, sizeof(fdir_info));
11431 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11432 RTE_ETH_FILTER_INFO, &fdir_info);
11434 printf("Cannot get FDir filter info\n");
11438 if (!strcmp(res->flow_type, "none")) {
11439 /* means don't specify the flow type */
11440 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11441 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11442 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11443 0, sizeof(struct rte_eth_fdir_flex_mask));
11444 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11445 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11447 sizeof(struct rte_eth_fdir_flex_mask));
11448 cmd_reconfig_device_queue(res->port_id, 1, 1);
11451 flow_type_mask = fdir_info.flow_types_mask[0];
11452 if (!strcmp(res->flow_type, "all")) {
11453 if (!flow_type_mask) {
11454 printf("No flow type supported\n");
11457 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11458 if (flow_type_mask & (1ULL << i)) {
11459 flex_mask.flow_type = i;
11460 fdir_set_flex_mask(res->port_id, &flex_mask);
11463 cmd_reconfig_device_queue(res->port_id, 1, 1);
11466 flex_mask.flow_type = str2flowtype(res->flow_type);
11467 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11468 printf("Flow type %s not supported on port %d\n",
11469 res->flow_type, res->port_id);
11472 fdir_set_flex_mask(res->port_id, &flex_mask);
11473 cmd_reconfig_device_queue(res->port_id, 1, 1);
11476 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11477 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11478 flow_director_flexmask,
11479 "flow_director_flex_mask");
11480 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11481 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11483 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11484 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11486 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11487 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11488 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11489 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11490 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11491 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11494 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11495 .f = cmd_flow_director_flex_mask_parsed,
11497 .help_str = "flow_director_flex_mask ... : "
11498 "Set flow director's flex mask on NIC",
11500 (void *)&cmd_flow_director_flexmask,
11501 (void *)&cmd_flow_director_flexmask_port_id,
11502 (void *)&cmd_flow_director_flexmask_flow,
11503 (void *)&cmd_flow_director_flexmask_flow_type,
11504 (void *)&cmd_flow_director_flexmask_mask,
11509 /* *** deal with flow director flexible payload configuration *** */
11510 struct cmd_flow_director_flexpayload_result {
11511 cmdline_fixed_string_t flow_director_flexpayload;
11513 cmdline_fixed_string_t payload_layer;
11514 cmdline_fixed_string_t payload_cfg;
11518 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11521 const char *p, *p0 = q_arg;
11523 unsigned long int_fld;
11524 char *str_fld[max_num];
11529 p = strchr(p0, '(');
11533 p0 = strchr(p, ')');
11538 if (size >= sizeof(s))
11541 snprintf(s, sizeof(s), "%.*s", size, p);
11542 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11543 if (ret < 0 || ret > max_num)
11545 for (i = 0; i < ret; i++) {
11547 int_fld = strtoul(str_fld[i], &end, 0);
11548 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11550 offsets[i] = (uint16_t)int_fld;
11556 cmd_flow_director_flxpld_parsed(void *parsed_result,
11557 __attribute__((unused)) struct cmdline *cl,
11558 __attribute__((unused)) void *data)
11560 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11561 struct rte_eth_flex_payload_cfg flex_cfg;
11562 struct rte_port *port;
11565 port = &ports[res->port_id];
11566 /** Check if the port is not started **/
11567 if (port->port_status != RTE_PORT_STOPPED) {
11568 printf("Please stop port %d first\n", res->port_id);
11572 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11574 if (!strcmp(res->payload_layer, "raw"))
11575 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11576 else if (!strcmp(res->payload_layer, "l2"))
11577 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11578 else if (!strcmp(res->payload_layer, "l3"))
11579 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11580 else if (!strcmp(res->payload_layer, "l4"))
11581 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11583 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11584 RTE_ETH_FDIR_MAX_FLEXLEN);
11586 printf("error: Cannot parse flex payload input.\n");
11590 fdir_set_flex_payload(res->port_id, &flex_cfg);
11591 cmd_reconfig_device_queue(res->port_id, 1, 1);
11594 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11595 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11596 flow_director_flexpayload,
11597 "flow_director_flex_payload");
11598 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11599 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11601 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11603 payload_layer, "raw#l2#l3#l4");
11604 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11605 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11606 payload_cfg, NULL);
11608 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11609 .f = cmd_flow_director_flxpld_parsed,
11611 .help_str = "flow_director_flexpayload ... : "
11612 "Set flow director's flex payload on NIC",
11614 (void *)&cmd_flow_director_flexpayload,
11615 (void *)&cmd_flow_director_flexpayload_port_id,
11616 (void *)&cmd_flow_director_flexpayload_payload_layer,
11617 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11622 /* Generic flow interface command. */
11623 extern cmdline_parse_inst_t cmd_flow;
11625 /* *** Classification Filters Control *** */
11626 /* *** Get symmetric hash enable per port *** */
11627 struct cmd_get_sym_hash_ena_per_port_result {
11628 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11633 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11634 __rte_unused struct cmdline *cl,
11635 __rte_unused void *data)
11637 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11638 struct rte_eth_hash_filter_info info;
11641 if (rte_eth_dev_filter_supported(res->port_id,
11642 RTE_ETH_FILTER_HASH) < 0) {
11643 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11648 memset(&info, 0, sizeof(info));
11649 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11650 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11651 RTE_ETH_FILTER_GET, &info);
11654 printf("Cannot get symmetric hash enable per port "
11655 "on port %u\n", res->port_id);
11659 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11660 "enabled" : "disabled", res->port_id);
11663 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11664 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11665 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11666 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11667 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11670 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11671 .f = cmd_get_sym_hash_per_port_parsed,
11673 .help_str = "get_sym_hash_ena_per_port <port_id>",
11675 (void *)&cmd_get_sym_hash_ena_per_port_all,
11676 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11681 /* *** Set symmetric hash enable per port *** */
11682 struct cmd_set_sym_hash_ena_per_port_result {
11683 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11684 cmdline_fixed_string_t enable;
11689 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11690 __rte_unused struct cmdline *cl,
11691 __rte_unused void *data)
11693 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11694 struct rte_eth_hash_filter_info info;
11697 if (rte_eth_dev_filter_supported(res->port_id,
11698 RTE_ETH_FILTER_HASH) < 0) {
11699 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11704 memset(&info, 0, sizeof(info));
11705 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11706 if (!strcmp(res->enable, "enable"))
11707 info.info.enable = 1;
11708 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11709 RTE_ETH_FILTER_SET, &info);
11711 printf("Cannot set symmetric hash enable per port on "
11712 "port %u\n", res->port_id);
11715 printf("Symmetric hash has been set to %s on port %u\n",
11716 res->enable, res->port_id);
11719 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11720 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11721 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11722 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11723 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11725 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11726 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11727 enable, "enable#disable");
11729 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11730 .f = cmd_set_sym_hash_per_port_parsed,
11732 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11734 (void *)&cmd_set_sym_hash_ena_per_port_all,
11735 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11736 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11741 /* Get global config of hash function */
11742 struct cmd_get_hash_global_config_result {
11743 cmdline_fixed_string_t get_hash_global_config;
11748 flowtype_to_str(uint16_t ftype)
11754 } ftype_table[] = {
11755 {"ipv4", RTE_ETH_FLOW_IPV4},
11756 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11757 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11758 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11759 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11760 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11761 {"ipv6", RTE_ETH_FLOW_IPV6},
11762 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11763 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11764 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11765 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11766 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11767 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11768 {"port", RTE_ETH_FLOW_PORT},
11769 {"vxlan", RTE_ETH_FLOW_VXLAN},
11770 {"geneve", RTE_ETH_FLOW_GENEVE},
11771 {"nvgre", RTE_ETH_FLOW_NVGRE},
11774 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11775 if (ftype_table[i].ftype == ftype)
11776 return ftype_table[i].str;
11783 cmd_get_hash_global_config_parsed(void *parsed_result,
11784 __rte_unused struct cmdline *cl,
11785 __rte_unused void *data)
11787 struct cmd_get_hash_global_config_result *res = parsed_result;
11788 struct rte_eth_hash_filter_info info;
11789 uint32_t idx, offset;
11794 if (rte_eth_dev_filter_supported(res->port_id,
11795 RTE_ETH_FILTER_HASH) < 0) {
11796 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11801 memset(&info, 0, sizeof(info));
11802 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11803 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11804 RTE_ETH_FILTER_GET, &info);
11806 printf("Cannot get hash global configurations by port %d\n",
11811 switch (info.info.global_conf.hash_func) {
11812 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11813 printf("Hash function is Toeplitz\n");
11815 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11816 printf("Hash function is Simple XOR\n");
11819 printf("Unknown hash function\n");
11823 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11824 idx = i / UINT64_BIT;
11825 offset = i % UINT64_BIT;
11826 if (!(info.info.global_conf.valid_bit_mask[idx] &
11829 str = flowtype_to_str(i);
11832 printf("Symmetric hash is %s globally for flow type %s "
11834 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11835 (1ULL << offset)) ? "enabled" : "disabled"), str,
11840 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11841 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11842 get_hash_global_config, "get_hash_global_config");
11843 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11844 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11847 cmdline_parse_inst_t cmd_get_hash_global_config = {
11848 .f = cmd_get_hash_global_config_parsed,
11850 .help_str = "get_hash_global_config <port_id>",
11852 (void *)&cmd_get_hash_global_config_all,
11853 (void *)&cmd_get_hash_global_config_port_id,
11858 /* Set global config of hash function */
11859 struct cmd_set_hash_global_config_result {
11860 cmdline_fixed_string_t set_hash_global_config;
11862 cmdline_fixed_string_t hash_func;
11863 cmdline_fixed_string_t flow_type;
11864 cmdline_fixed_string_t enable;
11868 cmd_set_hash_global_config_parsed(void *parsed_result,
11869 __rte_unused struct cmdline *cl,
11870 __rte_unused void *data)
11872 struct cmd_set_hash_global_config_result *res = parsed_result;
11873 struct rte_eth_hash_filter_info info;
11874 uint32_t ftype, idx, offset;
11877 if (rte_eth_dev_filter_supported(res->port_id,
11878 RTE_ETH_FILTER_HASH) < 0) {
11879 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11883 memset(&info, 0, sizeof(info));
11884 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11885 if (!strcmp(res->hash_func, "toeplitz"))
11886 info.info.global_conf.hash_func =
11887 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11888 else if (!strcmp(res->hash_func, "simple_xor"))
11889 info.info.global_conf.hash_func =
11890 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11891 else if (!strcmp(res->hash_func, "default"))
11892 info.info.global_conf.hash_func =
11893 RTE_ETH_HASH_FUNCTION_DEFAULT;
11895 ftype = str2flowtype(res->flow_type);
11896 idx = ftype / UINT64_BIT;
11897 offset = ftype % UINT64_BIT;
11898 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11899 if (!strcmp(res->enable, "enable"))
11900 info.info.global_conf.sym_hash_enable_mask[idx] |=
11902 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11903 RTE_ETH_FILTER_SET, &info);
11905 printf("Cannot set global hash configurations by port %d\n",
11908 printf("Global hash configurations have been set "
11909 "succcessfully by port %d\n", res->port_id);
11912 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11913 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11914 set_hash_global_config, "set_hash_global_config");
11915 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11916 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11918 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11919 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11920 hash_func, "toeplitz#simple_xor#default");
11921 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11922 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11924 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11925 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11926 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11927 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11928 enable, "enable#disable");
11930 cmdline_parse_inst_t cmd_set_hash_global_config = {
11931 .f = cmd_set_hash_global_config_parsed,
11933 .help_str = "set_hash_global_config <port_id> "
11934 "toeplitz|simple_xor|default "
11935 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11936 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11937 "l2_payload enable|disable",
11939 (void *)&cmd_set_hash_global_config_all,
11940 (void *)&cmd_set_hash_global_config_port_id,
11941 (void *)&cmd_set_hash_global_config_hash_func,
11942 (void *)&cmd_set_hash_global_config_flow_type,
11943 (void *)&cmd_set_hash_global_config_enable,
11948 /* Set hash input set */
11949 struct cmd_set_hash_input_set_result {
11950 cmdline_fixed_string_t set_hash_input_set;
11952 cmdline_fixed_string_t flow_type;
11953 cmdline_fixed_string_t inset_field;
11954 cmdline_fixed_string_t select;
11957 static enum rte_eth_input_set_field
11958 str2inset(char *string)
11962 static const struct {
11964 enum rte_eth_input_set_field inset;
11965 } inset_table[] = {
11966 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11967 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11968 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11969 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11970 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11971 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11972 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11973 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11974 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11975 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11976 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11977 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11978 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11979 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11980 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11981 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11982 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11983 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11984 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11985 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11986 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11987 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11988 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11989 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11990 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11991 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11992 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11993 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11994 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11995 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11996 {"none", RTE_ETH_INPUT_SET_NONE},
11999 for (i = 0; i < RTE_DIM(inset_table); i++) {
12000 if (!strcmp(string, inset_table[i].str))
12001 return inset_table[i].inset;
12004 return RTE_ETH_INPUT_SET_UNKNOWN;
12008 cmd_set_hash_input_set_parsed(void *parsed_result,
12009 __rte_unused struct cmdline *cl,
12010 __rte_unused void *data)
12012 struct cmd_set_hash_input_set_result *res = parsed_result;
12013 struct rte_eth_hash_filter_info info;
12015 memset(&info, 0, sizeof(info));
12016 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12017 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12018 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12019 info.info.input_set_conf.inset_size = 1;
12020 if (!strcmp(res->select, "select"))
12021 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12022 else if (!strcmp(res->select, "add"))
12023 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12024 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12025 RTE_ETH_FILTER_SET, &info);
12028 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12029 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12030 set_hash_input_set, "set_hash_input_set");
12031 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12032 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12034 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12035 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12037 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12038 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12040 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12041 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12042 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12043 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12044 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12046 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12047 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12048 select, "select#add");
12050 cmdline_parse_inst_t cmd_set_hash_input_set = {
12051 .f = cmd_set_hash_input_set_parsed,
12053 .help_str = "set_hash_input_set <port_id> "
12054 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12055 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12056 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12057 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12058 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12059 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12060 "fld-7th|fld-8th|none select|add",
12062 (void *)&cmd_set_hash_input_set_cmd,
12063 (void *)&cmd_set_hash_input_set_port_id,
12064 (void *)&cmd_set_hash_input_set_flow_type,
12065 (void *)&cmd_set_hash_input_set_field,
12066 (void *)&cmd_set_hash_input_set_select,
12071 /* Set flow director input set */
12072 struct cmd_set_fdir_input_set_result {
12073 cmdline_fixed_string_t set_fdir_input_set;
12075 cmdline_fixed_string_t flow_type;
12076 cmdline_fixed_string_t inset_field;
12077 cmdline_fixed_string_t select;
12081 cmd_set_fdir_input_set_parsed(void *parsed_result,
12082 __rte_unused struct cmdline *cl,
12083 __rte_unused void *data)
12085 struct cmd_set_fdir_input_set_result *res = parsed_result;
12086 struct rte_eth_fdir_filter_info info;
12088 memset(&info, 0, sizeof(info));
12089 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12090 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12091 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12092 info.info.input_set_conf.inset_size = 1;
12093 if (!strcmp(res->select, "select"))
12094 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12095 else if (!strcmp(res->select, "add"))
12096 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12097 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12098 RTE_ETH_FILTER_SET, &info);
12101 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12102 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12103 set_fdir_input_set, "set_fdir_input_set");
12104 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12105 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12107 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12108 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12110 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12111 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12112 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12113 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12115 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12116 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12117 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12118 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12119 "sctp-veri-tag#none");
12120 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12121 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12122 select, "select#add");
12124 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12125 .f = cmd_set_fdir_input_set_parsed,
12127 .help_str = "set_fdir_input_set <port_id> "
12128 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12129 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12130 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12131 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12132 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12133 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12134 "sctp-veri-tag|none select|add",
12136 (void *)&cmd_set_fdir_input_set_cmd,
12137 (void *)&cmd_set_fdir_input_set_port_id,
12138 (void *)&cmd_set_fdir_input_set_flow_type,
12139 (void *)&cmd_set_fdir_input_set_field,
12140 (void *)&cmd_set_fdir_input_set_select,
12145 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12146 struct cmd_mcast_addr_result {
12147 cmdline_fixed_string_t mcast_addr_cmd;
12148 cmdline_fixed_string_t what;
12150 struct ether_addr mc_addr;
12153 static void cmd_mcast_addr_parsed(void *parsed_result,
12154 __attribute__((unused)) struct cmdline *cl,
12155 __attribute__((unused)) void *data)
12157 struct cmd_mcast_addr_result *res = parsed_result;
12159 if (!is_multicast_ether_addr(&res->mc_addr)) {
12160 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12161 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12162 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12163 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12166 if (strcmp(res->what, "add") == 0)
12167 mcast_addr_add(res->port_num, &res->mc_addr);
12169 mcast_addr_remove(res->port_num, &res->mc_addr);
12172 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12173 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12174 mcast_addr_cmd, "mcast_addr");
12175 cmdline_parse_token_string_t cmd_mcast_addr_what =
12176 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12178 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12179 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12180 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12181 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12183 cmdline_parse_inst_t cmd_mcast_addr = {
12184 .f = cmd_mcast_addr_parsed,
12186 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12187 "Add/Remove multicast MAC address on port_id",
12189 (void *)&cmd_mcast_addr_cmd,
12190 (void *)&cmd_mcast_addr_what,
12191 (void *)&cmd_mcast_addr_portnum,
12192 (void *)&cmd_mcast_addr_addr,
12197 /* l2 tunnel config
12198 * only support E-tag now.
12201 /* Ether type config */
12202 struct cmd_config_l2_tunnel_eth_type_result {
12203 cmdline_fixed_string_t port;
12204 cmdline_fixed_string_t config;
12205 cmdline_fixed_string_t all;
12207 cmdline_fixed_string_t l2_tunnel;
12208 cmdline_fixed_string_t l2_tunnel_type;
12209 cmdline_fixed_string_t eth_type;
12210 uint16_t eth_type_val;
12213 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12214 TOKEN_STRING_INITIALIZER
12215 (struct cmd_config_l2_tunnel_eth_type_result,
12217 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12218 TOKEN_STRING_INITIALIZER
12219 (struct cmd_config_l2_tunnel_eth_type_result,
12221 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12222 TOKEN_STRING_INITIALIZER
12223 (struct cmd_config_l2_tunnel_eth_type_result,
12225 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12226 TOKEN_NUM_INITIALIZER
12227 (struct cmd_config_l2_tunnel_eth_type_result,
12229 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12230 TOKEN_STRING_INITIALIZER
12231 (struct cmd_config_l2_tunnel_eth_type_result,
12232 l2_tunnel, "l2-tunnel");
12233 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12234 TOKEN_STRING_INITIALIZER
12235 (struct cmd_config_l2_tunnel_eth_type_result,
12236 l2_tunnel_type, "E-tag");
12237 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12238 TOKEN_STRING_INITIALIZER
12239 (struct cmd_config_l2_tunnel_eth_type_result,
12240 eth_type, "ether-type");
12241 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12242 TOKEN_NUM_INITIALIZER
12243 (struct cmd_config_l2_tunnel_eth_type_result,
12244 eth_type_val, UINT16);
12246 static enum rte_eth_tunnel_type
12247 str2fdir_l2_tunnel_type(char *string)
12251 static const struct {
12253 enum rte_eth_tunnel_type type;
12254 } l2_tunnel_type_str[] = {
12255 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12258 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12259 if (!strcmp(l2_tunnel_type_str[i].str, string))
12260 return l2_tunnel_type_str[i].type;
12262 return RTE_TUNNEL_TYPE_NONE;
12265 /* ether type config for all ports */
12267 cmd_config_l2_tunnel_eth_type_all_parsed
12268 (void *parsed_result,
12269 __attribute__((unused)) struct cmdline *cl,
12270 __attribute__((unused)) void *data)
12272 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12273 struct rte_eth_l2_tunnel_conf entry;
12276 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12277 entry.ether_type = res->eth_type_val;
12279 RTE_ETH_FOREACH_DEV(pid) {
12280 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12284 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12285 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12287 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12289 (void *)&cmd_config_l2_tunnel_eth_type_port,
12290 (void *)&cmd_config_l2_tunnel_eth_type_config,
12291 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12292 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12293 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12294 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12295 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12300 /* ether type config for a specific port */
12302 cmd_config_l2_tunnel_eth_type_specific_parsed(
12303 void *parsed_result,
12304 __attribute__((unused)) struct cmdline *cl,
12305 __attribute__((unused)) void *data)
12307 struct cmd_config_l2_tunnel_eth_type_result *res =
12309 struct rte_eth_l2_tunnel_conf entry;
12311 if (port_id_is_invalid(res->id, ENABLED_WARN))
12314 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12315 entry.ether_type = res->eth_type_val;
12317 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12320 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12321 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12323 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12325 (void *)&cmd_config_l2_tunnel_eth_type_port,
12326 (void *)&cmd_config_l2_tunnel_eth_type_config,
12327 (void *)&cmd_config_l2_tunnel_eth_type_id,
12328 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12329 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12330 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12331 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12336 /* Enable/disable l2 tunnel */
12337 struct cmd_config_l2_tunnel_en_dis_result {
12338 cmdline_fixed_string_t port;
12339 cmdline_fixed_string_t config;
12340 cmdline_fixed_string_t all;
12342 cmdline_fixed_string_t l2_tunnel;
12343 cmdline_fixed_string_t l2_tunnel_type;
12344 cmdline_fixed_string_t en_dis;
12347 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12348 TOKEN_STRING_INITIALIZER
12349 (struct cmd_config_l2_tunnel_en_dis_result,
12351 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12352 TOKEN_STRING_INITIALIZER
12353 (struct cmd_config_l2_tunnel_en_dis_result,
12355 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12356 TOKEN_STRING_INITIALIZER
12357 (struct cmd_config_l2_tunnel_en_dis_result,
12359 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12360 TOKEN_NUM_INITIALIZER
12361 (struct cmd_config_l2_tunnel_en_dis_result,
12363 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12364 TOKEN_STRING_INITIALIZER
12365 (struct cmd_config_l2_tunnel_en_dis_result,
12366 l2_tunnel, "l2-tunnel");
12367 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12368 TOKEN_STRING_INITIALIZER
12369 (struct cmd_config_l2_tunnel_en_dis_result,
12370 l2_tunnel_type, "E-tag");
12371 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12372 TOKEN_STRING_INITIALIZER
12373 (struct cmd_config_l2_tunnel_en_dis_result,
12374 en_dis, "enable#disable");
12376 /* enable/disable l2 tunnel for all ports */
12378 cmd_config_l2_tunnel_en_dis_all_parsed(
12379 void *parsed_result,
12380 __attribute__((unused)) struct cmdline *cl,
12381 __attribute__((unused)) void *data)
12383 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12384 struct rte_eth_l2_tunnel_conf entry;
12388 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12390 if (!strcmp("enable", res->en_dis))
12395 RTE_ETH_FOREACH_DEV(pid) {
12396 rte_eth_dev_l2_tunnel_offload_set(pid,
12398 ETH_L2_TUNNEL_ENABLE_MASK,
12403 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12404 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12406 .help_str = "port config all l2-tunnel E-tag enable|disable",
12408 (void *)&cmd_config_l2_tunnel_en_dis_port,
12409 (void *)&cmd_config_l2_tunnel_en_dis_config,
12410 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12411 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12412 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12413 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12418 /* enable/disable l2 tunnel for a port */
12420 cmd_config_l2_tunnel_en_dis_specific_parsed(
12421 void *parsed_result,
12422 __attribute__((unused)) struct cmdline *cl,
12423 __attribute__((unused)) void *data)
12425 struct cmd_config_l2_tunnel_en_dis_result *res =
12427 struct rte_eth_l2_tunnel_conf entry;
12429 if (port_id_is_invalid(res->id, ENABLED_WARN))
12432 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12434 if (!strcmp("enable", res->en_dis))
12435 rte_eth_dev_l2_tunnel_offload_set(res->id,
12437 ETH_L2_TUNNEL_ENABLE_MASK,
12440 rte_eth_dev_l2_tunnel_offload_set(res->id,
12442 ETH_L2_TUNNEL_ENABLE_MASK,
12446 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12447 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12449 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12451 (void *)&cmd_config_l2_tunnel_en_dis_port,
12452 (void *)&cmd_config_l2_tunnel_en_dis_config,
12453 (void *)&cmd_config_l2_tunnel_en_dis_id,
12454 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12455 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12456 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12461 /* E-tag configuration */
12463 /* Common result structure for all E-tag configuration */
12464 struct cmd_config_e_tag_result {
12465 cmdline_fixed_string_t e_tag;
12466 cmdline_fixed_string_t set;
12467 cmdline_fixed_string_t insertion;
12468 cmdline_fixed_string_t stripping;
12469 cmdline_fixed_string_t forwarding;
12470 cmdline_fixed_string_t filter;
12471 cmdline_fixed_string_t add;
12472 cmdline_fixed_string_t del;
12473 cmdline_fixed_string_t on;
12474 cmdline_fixed_string_t off;
12475 cmdline_fixed_string_t on_off;
12476 cmdline_fixed_string_t port_tag_id;
12477 uint32_t port_tag_id_val;
12478 cmdline_fixed_string_t e_tag_id;
12479 uint16_t e_tag_id_val;
12480 cmdline_fixed_string_t dst_pool;
12481 uint8_t dst_pool_val;
12482 cmdline_fixed_string_t port;
12484 cmdline_fixed_string_t vf;
12488 /* Common CLI fields for all E-tag configuration */
12489 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12490 TOKEN_STRING_INITIALIZER
12491 (struct cmd_config_e_tag_result,
12493 cmdline_parse_token_string_t cmd_config_e_tag_set =
12494 TOKEN_STRING_INITIALIZER
12495 (struct cmd_config_e_tag_result,
12497 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12498 TOKEN_STRING_INITIALIZER
12499 (struct cmd_config_e_tag_result,
12500 insertion, "insertion");
12501 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12502 TOKEN_STRING_INITIALIZER
12503 (struct cmd_config_e_tag_result,
12504 stripping, "stripping");
12505 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12506 TOKEN_STRING_INITIALIZER
12507 (struct cmd_config_e_tag_result,
12508 forwarding, "forwarding");
12509 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12510 TOKEN_STRING_INITIALIZER
12511 (struct cmd_config_e_tag_result,
12513 cmdline_parse_token_string_t cmd_config_e_tag_add =
12514 TOKEN_STRING_INITIALIZER
12515 (struct cmd_config_e_tag_result,
12517 cmdline_parse_token_string_t cmd_config_e_tag_del =
12518 TOKEN_STRING_INITIALIZER
12519 (struct cmd_config_e_tag_result,
12521 cmdline_parse_token_string_t cmd_config_e_tag_on =
12522 TOKEN_STRING_INITIALIZER
12523 (struct cmd_config_e_tag_result,
12525 cmdline_parse_token_string_t cmd_config_e_tag_off =
12526 TOKEN_STRING_INITIALIZER
12527 (struct cmd_config_e_tag_result,
12529 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12530 TOKEN_STRING_INITIALIZER
12531 (struct cmd_config_e_tag_result,
12533 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12534 TOKEN_STRING_INITIALIZER
12535 (struct cmd_config_e_tag_result,
12536 port_tag_id, "port-tag-id");
12537 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12538 TOKEN_NUM_INITIALIZER
12539 (struct cmd_config_e_tag_result,
12540 port_tag_id_val, UINT32);
12541 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12542 TOKEN_STRING_INITIALIZER
12543 (struct cmd_config_e_tag_result,
12544 e_tag_id, "e-tag-id");
12545 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12546 TOKEN_NUM_INITIALIZER
12547 (struct cmd_config_e_tag_result,
12548 e_tag_id_val, UINT16);
12549 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12550 TOKEN_STRING_INITIALIZER
12551 (struct cmd_config_e_tag_result,
12552 dst_pool, "dst-pool");
12553 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12554 TOKEN_NUM_INITIALIZER
12555 (struct cmd_config_e_tag_result,
12556 dst_pool_val, UINT8);
12557 cmdline_parse_token_string_t cmd_config_e_tag_port =
12558 TOKEN_STRING_INITIALIZER
12559 (struct cmd_config_e_tag_result,
12561 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12562 TOKEN_NUM_INITIALIZER
12563 (struct cmd_config_e_tag_result,
12565 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12566 TOKEN_STRING_INITIALIZER
12567 (struct cmd_config_e_tag_result,
12569 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12570 TOKEN_NUM_INITIALIZER
12571 (struct cmd_config_e_tag_result,
12574 /* E-tag insertion configuration */
12576 cmd_config_e_tag_insertion_en_parsed(
12577 void *parsed_result,
12578 __attribute__((unused)) struct cmdline *cl,
12579 __attribute__((unused)) void *data)
12581 struct cmd_config_e_tag_result *res =
12583 struct rte_eth_l2_tunnel_conf entry;
12585 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12588 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12589 entry.tunnel_id = res->port_tag_id_val;
12590 entry.vf_id = res->vf_id;
12591 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12593 ETH_L2_TUNNEL_INSERTION_MASK,
12598 cmd_config_e_tag_insertion_dis_parsed(
12599 void *parsed_result,
12600 __attribute__((unused)) struct cmdline *cl,
12601 __attribute__((unused)) void *data)
12603 struct cmd_config_e_tag_result *res =
12605 struct rte_eth_l2_tunnel_conf entry;
12607 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12610 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12611 entry.vf_id = res->vf_id;
12613 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12615 ETH_L2_TUNNEL_INSERTION_MASK,
12619 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12620 .f = cmd_config_e_tag_insertion_en_parsed,
12622 .help_str = "E-tag ... : E-tag insertion enable",
12624 (void *)&cmd_config_e_tag_e_tag,
12625 (void *)&cmd_config_e_tag_set,
12626 (void *)&cmd_config_e_tag_insertion,
12627 (void *)&cmd_config_e_tag_on,
12628 (void *)&cmd_config_e_tag_port_tag_id,
12629 (void *)&cmd_config_e_tag_port_tag_id_val,
12630 (void *)&cmd_config_e_tag_port,
12631 (void *)&cmd_config_e_tag_port_id,
12632 (void *)&cmd_config_e_tag_vf,
12633 (void *)&cmd_config_e_tag_vf_id,
12638 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12639 .f = cmd_config_e_tag_insertion_dis_parsed,
12641 .help_str = "E-tag ... : E-tag insertion disable",
12643 (void *)&cmd_config_e_tag_e_tag,
12644 (void *)&cmd_config_e_tag_set,
12645 (void *)&cmd_config_e_tag_insertion,
12646 (void *)&cmd_config_e_tag_off,
12647 (void *)&cmd_config_e_tag_port,
12648 (void *)&cmd_config_e_tag_port_id,
12649 (void *)&cmd_config_e_tag_vf,
12650 (void *)&cmd_config_e_tag_vf_id,
12655 /* E-tag stripping configuration */
12657 cmd_config_e_tag_stripping_parsed(
12658 void *parsed_result,
12659 __attribute__((unused)) struct cmdline *cl,
12660 __attribute__((unused)) void *data)
12662 struct cmd_config_e_tag_result *res =
12664 struct rte_eth_l2_tunnel_conf entry;
12666 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12669 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12671 if (!strcmp(res->on_off, "on"))
12672 rte_eth_dev_l2_tunnel_offload_set
12675 ETH_L2_TUNNEL_STRIPPING_MASK,
12678 rte_eth_dev_l2_tunnel_offload_set
12681 ETH_L2_TUNNEL_STRIPPING_MASK,
12685 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12686 .f = cmd_config_e_tag_stripping_parsed,
12688 .help_str = "E-tag ... : E-tag stripping enable/disable",
12690 (void *)&cmd_config_e_tag_e_tag,
12691 (void *)&cmd_config_e_tag_set,
12692 (void *)&cmd_config_e_tag_stripping,
12693 (void *)&cmd_config_e_tag_on_off,
12694 (void *)&cmd_config_e_tag_port,
12695 (void *)&cmd_config_e_tag_port_id,
12700 /* E-tag forwarding configuration */
12702 cmd_config_e_tag_forwarding_parsed(
12703 void *parsed_result,
12704 __attribute__((unused)) struct cmdline *cl,
12705 __attribute__((unused)) void *data)
12707 struct cmd_config_e_tag_result *res = parsed_result;
12708 struct rte_eth_l2_tunnel_conf entry;
12710 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12713 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12715 if (!strcmp(res->on_off, "on"))
12716 rte_eth_dev_l2_tunnel_offload_set
12719 ETH_L2_TUNNEL_FORWARDING_MASK,
12722 rte_eth_dev_l2_tunnel_offload_set
12725 ETH_L2_TUNNEL_FORWARDING_MASK,
12729 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12730 .f = cmd_config_e_tag_forwarding_parsed,
12732 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12734 (void *)&cmd_config_e_tag_e_tag,
12735 (void *)&cmd_config_e_tag_set,
12736 (void *)&cmd_config_e_tag_forwarding,
12737 (void *)&cmd_config_e_tag_on_off,
12738 (void *)&cmd_config_e_tag_port,
12739 (void *)&cmd_config_e_tag_port_id,
12744 /* E-tag filter configuration */
12746 cmd_config_e_tag_filter_add_parsed(
12747 void *parsed_result,
12748 __attribute__((unused)) struct cmdline *cl,
12749 __attribute__((unused)) void *data)
12751 struct cmd_config_e_tag_result *res = parsed_result;
12752 struct rte_eth_l2_tunnel_conf entry;
12755 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12758 if (res->e_tag_id_val > 0x3fff) {
12759 printf("e-tag-id must be equal or less than 0x3fff.\n");
12763 ret = rte_eth_dev_filter_supported(res->port_id,
12764 RTE_ETH_FILTER_L2_TUNNEL);
12766 printf("E-tag filter is not supported on port %u.\n",
12771 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12772 entry.tunnel_id = res->e_tag_id_val;
12773 entry.pool = res->dst_pool_val;
12775 ret = rte_eth_dev_filter_ctrl(res->port_id,
12776 RTE_ETH_FILTER_L2_TUNNEL,
12777 RTE_ETH_FILTER_ADD,
12780 printf("E-tag filter programming error: (%s)\n",
12784 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12785 .f = cmd_config_e_tag_filter_add_parsed,
12787 .help_str = "E-tag ... : E-tag filter add",
12789 (void *)&cmd_config_e_tag_e_tag,
12790 (void *)&cmd_config_e_tag_set,
12791 (void *)&cmd_config_e_tag_filter,
12792 (void *)&cmd_config_e_tag_add,
12793 (void *)&cmd_config_e_tag_e_tag_id,
12794 (void *)&cmd_config_e_tag_e_tag_id_val,
12795 (void *)&cmd_config_e_tag_dst_pool,
12796 (void *)&cmd_config_e_tag_dst_pool_val,
12797 (void *)&cmd_config_e_tag_port,
12798 (void *)&cmd_config_e_tag_port_id,
12804 cmd_config_e_tag_filter_del_parsed(
12805 void *parsed_result,
12806 __attribute__((unused)) struct cmdline *cl,
12807 __attribute__((unused)) void *data)
12809 struct cmd_config_e_tag_result *res = parsed_result;
12810 struct rte_eth_l2_tunnel_conf entry;
12813 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12816 if (res->e_tag_id_val > 0x3fff) {
12817 printf("e-tag-id must be less than 0x3fff.\n");
12821 ret = rte_eth_dev_filter_supported(res->port_id,
12822 RTE_ETH_FILTER_L2_TUNNEL);
12824 printf("E-tag filter is not supported on port %u.\n",
12829 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12830 entry.tunnel_id = res->e_tag_id_val;
12832 ret = rte_eth_dev_filter_ctrl(res->port_id,
12833 RTE_ETH_FILTER_L2_TUNNEL,
12834 RTE_ETH_FILTER_DELETE,
12837 printf("E-tag filter programming error: (%s)\n",
12841 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12842 .f = cmd_config_e_tag_filter_del_parsed,
12844 .help_str = "E-tag ... : E-tag filter delete",
12846 (void *)&cmd_config_e_tag_e_tag,
12847 (void *)&cmd_config_e_tag_set,
12848 (void *)&cmd_config_e_tag_filter,
12849 (void *)&cmd_config_e_tag_del,
12850 (void *)&cmd_config_e_tag_e_tag_id,
12851 (void *)&cmd_config_e_tag_e_tag_id_val,
12852 (void *)&cmd_config_e_tag_port,
12853 (void *)&cmd_config_e_tag_port_id,
12858 /* vf vlan anti spoof configuration */
12860 /* Common result structure for vf vlan anti spoof */
12861 struct cmd_vf_vlan_anti_spoof_result {
12862 cmdline_fixed_string_t set;
12863 cmdline_fixed_string_t vf;
12864 cmdline_fixed_string_t vlan;
12865 cmdline_fixed_string_t antispoof;
12868 cmdline_fixed_string_t on_off;
12871 /* Common CLI fields for vf vlan anti spoof enable disable */
12872 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12873 TOKEN_STRING_INITIALIZER
12874 (struct cmd_vf_vlan_anti_spoof_result,
12876 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12877 TOKEN_STRING_INITIALIZER
12878 (struct cmd_vf_vlan_anti_spoof_result,
12880 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12881 TOKEN_STRING_INITIALIZER
12882 (struct cmd_vf_vlan_anti_spoof_result,
12884 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12885 TOKEN_STRING_INITIALIZER
12886 (struct cmd_vf_vlan_anti_spoof_result,
12887 antispoof, "antispoof");
12888 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12889 TOKEN_NUM_INITIALIZER
12890 (struct cmd_vf_vlan_anti_spoof_result,
12892 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12893 TOKEN_NUM_INITIALIZER
12894 (struct cmd_vf_vlan_anti_spoof_result,
12896 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12897 TOKEN_STRING_INITIALIZER
12898 (struct cmd_vf_vlan_anti_spoof_result,
12902 cmd_set_vf_vlan_anti_spoof_parsed(
12903 void *parsed_result,
12904 __attribute__((unused)) struct cmdline *cl,
12905 __attribute__((unused)) void *data)
12907 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12908 int ret = -ENOTSUP;
12910 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12912 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12915 #ifdef RTE_LIBRTE_IXGBE_PMD
12916 if (ret == -ENOTSUP)
12917 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12918 res->vf_id, is_on);
12920 #ifdef RTE_LIBRTE_I40E_PMD
12921 if (ret == -ENOTSUP)
12922 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12923 res->vf_id, is_on);
12925 #ifdef RTE_LIBRTE_BNXT_PMD
12926 if (ret == -ENOTSUP)
12927 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12928 res->vf_id, is_on);
12935 printf("invalid vf_id %d\n", res->vf_id);
12938 printf("invalid port_id %d\n", res->port_id);
12941 printf("function not implemented\n");
12944 printf("programming error: (%s)\n", strerror(-ret));
12948 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12949 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12951 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12953 (void *)&cmd_vf_vlan_anti_spoof_set,
12954 (void *)&cmd_vf_vlan_anti_spoof_vf,
12955 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12956 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12957 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12958 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12959 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12964 /* vf mac anti spoof configuration */
12966 /* Common result structure for vf mac anti spoof */
12967 struct cmd_vf_mac_anti_spoof_result {
12968 cmdline_fixed_string_t set;
12969 cmdline_fixed_string_t vf;
12970 cmdline_fixed_string_t mac;
12971 cmdline_fixed_string_t antispoof;
12974 cmdline_fixed_string_t on_off;
12977 /* Common CLI fields for vf mac anti spoof enable disable */
12978 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12979 TOKEN_STRING_INITIALIZER
12980 (struct cmd_vf_mac_anti_spoof_result,
12982 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12983 TOKEN_STRING_INITIALIZER
12984 (struct cmd_vf_mac_anti_spoof_result,
12986 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12987 TOKEN_STRING_INITIALIZER
12988 (struct cmd_vf_mac_anti_spoof_result,
12990 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12991 TOKEN_STRING_INITIALIZER
12992 (struct cmd_vf_mac_anti_spoof_result,
12993 antispoof, "antispoof");
12994 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12995 TOKEN_NUM_INITIALIZER
12996 (struct cmd_vf_mac_anti_spoof_result,
12998 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12999 TOKEN_NUM_INITIALIZER
13000 (struct cmd_vf_mac_anti_spoof_result,
13002 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13003 TOKEN_STRING_INITIALIZER
13004 (struct cmd_vf_mac_anti_spoof_result,
13008 cmd_set_vf_mac_anti_spoof_parsed(
13009 void *parsed_result,
13010 __attribute__((unused)) struct cmdline *cl,
13011 __attribute__((unused)) void *data)
13013 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13014 int ret = -ENOTSUP;
13016 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13018 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13021 #ifdef RTE_LIBRTE_IXGBE_PMD
13022 if (ret == -ENOTSUP)
13023 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13024 res->vf_id, is_on);
13026 #ifdef RTE_LIBRTE_I40E_PMD
13027 if (ret == -ENOTSUP)
13028 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13029 res->vf_id, is_on);
13031 #ifdef RTE_LIBRTE_BNXT_PMD
13032 if (ret == -ENOTSUP)
13033 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13034 res->vf_id, is_on);
13041 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13044 printf("invalid port_id %d\n", res->port_id);
13047 printf("function not implemented\n");
13050 printf("programming error: (%s)\n", strerror(-ret));
13054 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13055 .f = cmd_set_vf_mac_anti_spoof_parsed,
13057 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13059 (void *)&cmd_vf_mac_anti_spoof_set,
13060 (void *)&cmd_vf_mac_anti_spoof_vf,
13061 (void *)&cmd_vf_mac_anti_spoof_mac,
13062 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13063 (void *)&cmd_vf_mac_anti_spoof_port_id,
13064 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13065 (void *)&cmd_vf_mac_anti_spoof_on_off,
13070 /* vf vlan strip queue configuration */
13072 /* Common result structure for vf mac anti spoof */
13073 struct cmd_vf_vlan_stripq_result {
13074 cmdline_fixed_string_t set;
13075 cmdline_fixed_string_t vf;
13076 cmdline_fixed_string_t vlan;
13077 cmdline_fixed_string_t stripq;
13080 cmdline_fixed_string_t on_off;
13083 /* Common CLI fields for vf vlan strip enable disable */
13084 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13085 TOKEN_STRING_INITIALIZER
13086 (struct cmd_vf_vlan_stripq_result,
13088 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13089 TOKEN_STRING_INITIALIZER
13090 (struct cmd_vf_vlan_stripq_result,
13092 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13093 TOKEN_STRING_INITIALIZER
13094 (struct cmd_vf_vlan_stripq_result,
13096 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13097 TOKEN_STRING_INITIALIZER
13098 (struct cmd_vf_vlan_stripq_result,
13100 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13101 TOKEN_NUM_INITIALIZER
13102 (struct cmd_vf_vlan_stripq_result,
13104 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13105 TOKEN_NUM_INITIALIZER
13106 (struct cmd_vf_vlan_stripq_result,
13108 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13109 TOKEN_STRING_INITIALIZER
13110 (struct cmd_vf_vlan_stripq_result,
13114 cmd_set_vf_vlan_stripq_parsed(
13115 void *parsed_result,
13116 __attribute__((unused)) struct cmdline *cl,
13117 __attribute__((unused)) void *data)
13119 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13120 int ret = -ENOTSUP;
13122 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13124 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13127 #ifdef RTE_LIBRTE_IXGBE_PMD
13128 if (ret == -ENOTSUP)
13129 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13130 res->vf_id, is_on);
13132 #ifdef RTE_LIBRTE_I40E_PMD
13133 if (ret == -ENOTSUP)
13134 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13135 res->vf_id, is_on);
13137 #ifdef RTE_LIBRTE_BNXT_PMD
13138 if (ret == -ENOTSUP)
13139 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13140 res->vf_id, is_on);
13147 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13150 printf("invalid port_id %d\n", res->port_id);
13153 printf("function not implemented\n");
13156 printf("programming error: (%s)\n", strerror(-ret));
13160 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13161 .f = cmd_set_vf_vlan_stripq_parsed,
13163 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13165 (void *)&cmd_vf_vlan_stripq_set,
13166 (void *)&cmd_vf_vlan_stripq_vf,
13167 (void *)&cmd_vf_vlan_stripq_vlan,
13168 (void *)&cmd_vf_vlan_stripq_stripq,
13169 (void *)&cmd_vf_vlan_stripq_port_id,
13170 (void *)&cmd_vf_vlan_stripq_vf_id,
13171 (void *)&cmd_vf_vlan_stripq_on_off,
13176 /* vf vlan insert configuration */
13178 /* Common result structure for vf vlan insert */
13179 struct cmd_vf_vlan_insert_result {
13180 cmdline_fixed_string_t set;
13181 cmdline_fixed_string_t vf;
13182 cmdline_fixed_string_t vlan;
13183 cmdline_fixed_string_t insert;
13189 /* Common CLI fields for vf vlan insert enable disable */
13190 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13191 TOKEN_STRING_INITIALIZER
13192 (struct cmd_vf_vlan_insert_result,
13194 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13195 TOKEN_STRING_INITIALIZER
13196 (struct cmd_vf_vlan_insert_result,
13198 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13199 TOKEN_STRING_INITIALIZER
13200 (struct cmd_vf_vlan_insert_result,
13202 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13203 TOKEN_STRING_INITIALIZER
13204 (struct cmd_vf_vlan_insert_result,
13206 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13207 TOKEN_NUM_INITIALIZER
13208 (struct cmd_vf_vlan_insert_result,
13210 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13211 TOKEN_NUM_INITIALIZER
13212 (struct cmd_vf_vlan_insert_result,
13214 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13215 TOKEN_NUM_INITIALIZER
13216 (struct cmd_vf_vlan_insert_result,
13220 cmd_set_vf_vlan_insert_parsed(
13221 void *parsed_result,
13222 __attribute__((unused)) struct cmdline *cl,
13223 __attribute__((unused)) void *data)
13225 struct cmd_vf_vlan_insert_result *res = parsed_result;
13226 int ret = -ENOTSUP;
13228 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13231 #ifdef RTE_LIBRTE_IXGBE_PMD
13232 if (ret == -ENOTSUP)
13233 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13236 #ifdef RTE_LIBRTE_I40E_PMD
13237 if (ret == -ENOTSUP)
13238 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13241 #ifdef RTE_LIBRTE_BNXT_PMD
13242 if (ret == -ENOTSUP)
13243 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13251 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13254 printf("invalid port_id %d\n", res->port_id);
13257 printf("function not implemented\n");
13260 printf("programming error: (%s)\n", strerror(-ret));
13264 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13265 .f = cmd_set_vf_vlan_insert_parsed,
13267 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13269 (void *)&cmd_vf_vlan_insert_set,
13270 (void *)&cmd_vf_vlan_insert_vf,
13271 (void *)&cmd_vf_vlan_insert_vlan,
13272 (void *)&cmd_vf_vlan_insert_insert,
13273 (void *)&cmd_vf_vlan_insert_port_id,
13274 (void *)&cmd_vf_vlan_insert_vf_id,
13275 (void *)&cmd_vf_vlan_insert_vlan_id,
13280 /* tx loopback configuration */
13282 /* Common result structure for tx loopback */
13283 struct cmd_tx_loopback_result {
13284 cmdline_fixed_string_t set;
13285 cmdline_fixed_string_t tx;
13286 cmdline_fixed_string_t loopback;
13288 cmdline_fixed_string_t on_off;
13291 /* Common CLI fields for tx loopback enable disable */
13292 cmdline_parse_token_string_t cmd_tx_loopback_set =
13293 TOKEN_STRING_INITIALIZER
13294 (struct cmd_tx_loopback_result,
13296 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13297 TOKEN_STRING_INITIALIZER
13298 (struct cmd_tx_loopback_result,
13300 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13301 TOKEN_STRING_INITIALIZER
13302 (struct cmd_tx_loopback_result,
13303 loopback, "loopback");
13304 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13305 TOKEN_NUM_INITIALIZER
13306 (struct cmd_tx_loopback_result,
13308 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13309 TOKEN_STRING_INITIALIZER
13310 (struct cmd_tx_loopback_result,
13314 cmd_set_tx_loopback_parsed(
13315 void *parsed_result,
13316 __attribute__((unused)) struct cmdline *cl,
13317 __attribute__((unused)) void *data)
13319 struct cmd_tx_loopback_result *res = parsed_result;
13320 int ret = -ENOTSUP;
13322 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13324 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13327 #ifdef RTE_LIBRTE_IXGBE_PMD
13328 if (ret == -ENOTSUP)
13329 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13331 #ifdef RTE_LIBRTE_I40E_PMD
13332 if (ret == -ENOTSUP)
13333 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13335 #ifdef RTE_LIBRTE_BNXT_PMD
13336 if (ret == -ENOTSUP)
13337 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13339 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13340 if (ret == -ENOTSUP)
13341 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13348 printf("invalid is_on %d\n", is_on);
13351 printf("invalid port_id %d\n", res->port_id);
13354 printf("function not implemented\n");
13357 printf("programming error: (%s)\n", strerror(-ret));
13361 cmdline_parse_inst_t cmd_set_tx_loopback = {
13362 .f = cmd_set_tx_loopback_parsed,
13364 .help_str = "set tx loopback <port_id> on|off",
13366 (void *)&cmd_tx_loopback_set,
13367 (void *)&cmd_tx_loopback_tx,
13368 (void *)&cmd_tx_loopback_loopback,
13369 (void *)&cmd_tx_loopback_port_id,
13370 (void *)&cmd_tx_loopback_on_off,
13375 /* all queues drop enable configuration */
13377 /* Common result structure for all queues drop enable */
13378 struct cmd_all_queues_drop_en_result {
13379 cmdline_fixed_string_t set;
13380 cmdline_fixed_string_t all;
13381 cmdline_fixed_string_t queues;
13382 cmdline_fixed_string_t drop;
13384 cmdline_fixed_string_t on_off;
13387 /* Common CLI fields for tx loopback enable disable */
13388 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13389 TOKEN_STRING_INITIALIZER
13390 (struct cmd_all_queues_drop_en_result,
13392 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13393 TOKEN_STRING_INITIALIZER
13394 (struct cmd_all_queues_drop_en_result,
13396 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13397 TOKEN_STRING_INITIALIZER
13398 (struct cmd_all_queues_drop_en_result,
13400 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13401 TOKEN_STRING_INITIALIZER
13402 (struct cmd_all_queues_drop_en_result,
13404 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13405 TOKEN_NUM_INITIALIZER
13406 (struct cmd_all_queues_drop_en_result,
13408 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13409 TOKEN_STRING_INITIALIZER
13410 (struct cmd_all_queues_drop_en_result,
13414 cmd_set_all_queues_drop_en_parsed(
13415 void *parsed_result,
13416 __attribute__((unused)) struct cmdline *cl,
13417 __attribute__((unused)) void *data)
13419 struct cmd_all_queues_drop_en_result *res = parsed_result;
13420 int ret = -ENOTSUP;
13421 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13423 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13426 #ifdef RTE_LIBRTE_IXGBE_PMD
13427 if (ret == -ENOTSUP)
13428 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13430 #ifdef RTE_LIBRTE_BNXT_PMD
13431 if (ret == -ENOTSUP)
13432 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13438 printf("invalid is_on %d\n", is_on);
13441 printf("invalid port_id %d\n", res->port_id);
13444 printf("function not implemented\n");
13447 printf("programming error: (%s)\n", strerror(-ret));
13451 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13452 .f = cmd_set_all_queues_drop_en_parsed,
13454 .help_str = "set all queues drop <port_id> on|off",
13456 (void *)&cmd_all_queues_drop_en_set,
13457 (void *)&cmd_all_queues_drop_en_all,
13458 (void *)&cmd_all_queues_drop_en_queues,
13459 (void *)&cmd_all_queues_drop_en_drop,
13460 (void *)&cmd_all_queues_drop_en_port_id,
13461 (void *)&cmd_all_queues_drop_en_on_off,
13466 /* vf split drop enable configuration */
13468 /* Common result structure for vf split drop enable */
13469 struct cmd_vf_split_drop_en_result {
13470 cmdline_fixed_string_t set;
13471 cmdline_fixed_string_t vf;
13472 cmdline_fixed_string_t split;
13473 cmdline_fixed_string_t drop;
13476 cmdline_fixed_string_t on_off;
13479 /* Common CLI fields for vf split drop enable disable */
13480 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13481 TOKEN_STRING_INITIALIZER
13482 (struct cmd_vf_split_drop_en_result,
13484 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13485 TOKEN_STRING_INITIALIZER
13486 (struct cmd_vf_split_drop_en_result,
13488 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13489 TOKEN_STRING_INITIALIZER
13490 (struct cmd_vf_split_drop_en_result,
13492 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13493 TOKEN_STRING_INITIALIZER
13494 (struct cmd_vf_split_drop_en_result,
13496 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13497 TOKEN_NUM_INITIALIZER
13498 (struct cmd_vf_split_drop_en_result,
13500 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13501 TOKEN_NUM_INITIALIZER
13502 (struct cmd_vf_split_drop_en_result,
13504 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13505 TOKEN_STRING_INITIALIZER
13506 (struct cmd_vf_split_drop_en_result,
13510 cmd_set_vf_split_drop_en_parsed(
13511 void *parsed_result,
13512 __attribute__((unused)) struct cmdline *cl,
13513 __attribute__((unused)) void *data)
13515 struct cmd_vf_split_drop_en_result *res = parsed_result;
13516 int ret = -ENOTSUP;
13517 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13519 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13522 #ifdef RTE_LIBRTE_IXGBE_PMD
13523 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13530 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13533 printf("invalid port_id %d\n", res->port_id);
13536 printf("not supported on port %d\n", res->port_id);
13539 printf("programming error: (%s)\n", strerror(-ret));
13543 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13544 .f = cmd_set_vf_split_drop_en_parsed,
13546 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13548 (void *)&cmd_vf_split_drop_en_set,
13549 (void *)&cmd_vf_split_drop_en_vf,
13550 (void *)&cmd_vf_split_drop_en_split,
13551 (void *)&cmd_vf_split_drop_en_drop,
13552 (void *)&cmd_vf_split_drop_en_port_id,
13553 (void *)&cmd_vf_split_drop_en_vf_id,
13554 (void *)&cmd_vf_split_drop_en_on_off,
13559 /* vf mac address configuration */
13561 /* Common result structure for vf mac address */
13562 struct cmd_set_vf_mac_addr_result {
13563 cmdline_fixed_string_t set;
13564 cmdline_fixed_string_t vf;
13565 cmdline_fixed_string_t mac;
13566 cmdline_fixed_string_t addr;
13569 struct ether_addr mac_addr;
13573 /* Common CLI fields for vf split drop enable disable */
13574 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13575 TOKEN_STRING_INITIALIZER
13576 (struct cmd_set_vf_mac_addr_result,
13578 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13579 TOKEN_STRING_INITIALIZER
13580 (struct cmd_set_vf_mac_addr_result,
13582 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13583 TOKEN_STRING_INITIALIZER
13584 (struct cmd_set_vf_mac_addr_result,
13586 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13587 TOKEN_STRING_INITIALIZER
13588 (struct cmd_set_vf_mac_addr_result,
13590 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13591 TOKEN_NUM_INITIALIZER
13592 (struct cmd_set_vf_mac_addr_result,
13594 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13595 TOKEN_NUM_INITIALIZER
13596 (struct cmd_set_vf_mac_addr_result,
13598 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13599 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13603 cmd_set_vf_mac_addr_parsed(
13604 void *parsed_result,
13605 __attribute__((unused)) struct cmdline *cl,
13606 __attribute__((unused)) void *data)
13608 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13609 int ret = -ENOTSUP;
13611 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13614 #ifdef RTE_LIBRTE_IXGBE_PMD
13615 if (ret == -ENOTSUP)
13616 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13619 #ifdef RTE_LIBRTE_I40E_PMD
13620 if (ret == -ENOTSUP)
13621 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13624 #ifdef RTE_LIBRTE_BNXT_PMD
13625 if (ret == -ENOTSUP)
13626 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13634 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13637 printf("invalid port_id %d\n", res->port_id);
13640 printf("function not implemented\n");
13643 printf("programming error: (%s)\n", strerror(-ret));
13647 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13648 .f = cmd_set_vf_mac_addr_parsed,
13650 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13652 (void *)&cmd_set_vf_mac_addr_set,
13653 (void *)&cmd_set_vf_mac_addr_vf,
13654 (void *)&cmd_set_vf_mac_addr_mac,
13655 (void *)&cmd_set_vf_mac_addr_addr,
13656 (void *)&cmd_set_vf_mac_addr_port_id,
13657 (void *)&cmd_set_vf_mac_addr_vf_id,
13658 (void *)&cmd_set_vf_mac_addr_mac_addr,
13663 /* MACsec configuration */
13665 /* Common result structure for MACsec offload enable */
13666 struct cmd_macsec_offload_on_result {
13667 cmdline_fixed_string_t set;
13668 cmdline_fixed_string_t macsec;
13669 cmdline_fixed_string_t offload;
13671 cmdline_fixed_string_t on;
13672 cmdline_fixed_string_t encrypt;
13673 cmdline_fixed_string_t en_on_off;
13674 cmdline_fixed_string_t replay_protect;
13675 cmdline_fixed_string_t rp_on_off;
13678 /* Common CLI fields for MACsec offload disable */
13679 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13680 TOKEN_STRING_INITIALIZER
13681 (struct cmd_macsec_offload_on_result,
13683 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13684 TOKEN_STRING_INITIALIZER
13685 (struct cmd_macsec_offload_on_result,
13687 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13688 TOKEN_STRING_INITIALIZER
13689 (struct cmd_macsec_offload_on_result,
13690 offload, "offload");
13691 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13692 TOKEN_NUM_INITIALIZER
13693 (struct cmd_macsec_offload_on_result,
13695 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13696 TOKEN_STRING_INITIALIZER
13697 (struct cmd_macsec_offload_on_result,
13699 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13700 TOKEN_STRING_INITIALIZER
13701 (struct cmd_macsec_offload_on_result,
13702 encrypt, "encrypt");
13703 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13704 TOKEN_STRING_INITIALIZER
13705 (struct cmd_macsec_offload_on_result,
13706 en_on_off, "on#off");
13707 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13708 TOKEN_STRING_INITIALIZER
13709 (struct cmd_macsec_offload_on_result,
13710 replay_protect, "replay-protect");
13711 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13712 TOKEN_STRING_INITIALIZER
13713 (struct cmd_macsec_offload_on_result,
13714 rp_on_off, "on#off");
13717 cmd_set_macsec_offload_on_parsed(
13718 void *parsed_result,
13719 __attribute__((unused)) struct cmdline *cl,
13720 __attribute__((unused)) void *data)
13722 struct cmd_macsec_offload_on_result *res = parsed_result;
13723 int ret = -ENOTSUP;
13724 portid_t port_id = res->port_id;
13725 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13726 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13727 struct rte_eth_dev_info dev_info;
13729 if (port_id_is_invalid(port_id, ENABLED_WARN))
13731 if (!port_is_stopped(port_id)) {
13732 printf("Please stop port %d first\n", port_id);
13736 rte_eth_dev_info_get(port_id, &dev_info);
13737 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13738 #ifdef RTE_LIBRTE_IXGBE_PMD
13739 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13747 ports[port_id].dev_conf.txmode.offloads |=
13748 DEV_TX_OFFLOAD_MACSEC_INSERT;
13749 cmd_reconfig_device_queue(port_id, 1, 1);
13752 printf("invalid port_id %d\n", port_id);
13755 printf("not supported on port %d\n", port_id);
13758 printf("programming error: (%s)\n", strerror(-ret));
13762 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13763 .f = cmd_set_macsec_offload_on_parsed,
13765 .help_str = "set macsec offload <port_id> on "
13766 "encrypt on|off replay-protect on|off",
13768 (void *)&cmd_macsec_offload_on_set,
13769 (void *)&cmd_macsec_offload_on_macsec,
13770 (void *)&cmd_macsec_offload_on_offload,
13771 (void *)&cmd_macsec_offload_on_port_id,
13772 (void *)&cmd_macsec_offload_on_on,
13773 (void *)&cmd_macsec_offload_on_encrypt,
13774 (void *)&cmd_macsec_offload_on_en_on_off,
13775 (void *)&cmd_macsec_offload_on_replay_protect,
13776 (void *)&cmd_macsec_offload_on_rp_on_off,
13781 /* Common result structure for MACsec offload disable */
13782 struct cmd_macsec_offload_off_result {
13783 cmdline_fixed_string_t set;
13784 cmdline_fixed_string_t macsec;
13785 cmdline_fixed_string_t offload;
13787 cmdline_fixed_string_t off;
13790 /* Common CLI fields for MACsec offload disable */
13791 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13792 TOKEN_STRING_INITIALIZER
13793 (struct cmd_macsec_offload_off_result,
13795 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13796 TOKEN_STRING_INITIALIZER
13797 (struct cmd_macsec_offload_off_result,
13799 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13800 TOKEN_STRING_INITIALIZER
13801 (struct cmd_macsec_offload_off_result,
13802 offload, "offload");
13803 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13804 TOKEN_NUM_INITIALIZER
13805 (struct cmd_macsec_offload_off_result,
13807 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13808 TOKEN_STRING_INITIALIZER
13809 (struct cmd_macsec_offload_off_result,
13813 cmd_set_macsec_offload_off_parsed(
13814 void *parsed_result,
13815 __attribute__((unused)) struct cmdline *cl,
13816 __attribute__((unused)) void *data)
13818 struct cmd_macsec_offload_off_result *res = parsed_result;
13819 int ret = -ENOTSUP;
13820 struct rte_eth_dev_info dev_info;
13821 portid_t port_id = res->port_id;
13823 if (port_id_is_invalid(port_id, ENABLED_WARN))
13825 if (!port_is_stopped(port_id)) {
13826 printf("Please stop port %d first\n", port_id);
13830 rte_eth_dev_info_get(port_id, &dev_info);
13831 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13832 #ifdef RTE_LIBRTE_IXGBE_PMD
13833 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13838 ports[port_id].dev_conf.txmode.offloads &=
13839 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13840 cmd_reconfig_device_queue(port_id, 1, 1);
13843 printf("invalid port_id %d\n", port_id);
13846 printf("not supported on port %d\n", port_id);
13849 printf("programming error: (%s)\n", strerror(-ret));
13853 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13854 .f = cmd_set_macsec_offload_off_parsed,
13856 .help_str = "set macsec offload <port_id> off",
13858 (void *)&cmd_macsec_offload_off_set,
13859 (void *)&cmd_macsec_offload_off_macsec,
13860 (void *)&cmd_macsec_offload_off_offload,
13861 (void *)&cmd_macsec_offload_off_port_id,
13862 (void *)&cmd_macsec_offload_off_off,
13867 /* Common result structure for MACsec secure connection configure */
13868 struct cmd_macsec_sc_result {
13869 cmdline_fixed_string_t set;
13870 cmdline_fixed_string_t macsec;
13871 cmdline_fixed_string_t sc;
13872 cmdline_fixed_string_t tx_rx;
13874 struct ether_addr mac;
13878 /* Common CLI fields for MACsec secure connection configure */
13879 cmdline_parse_token_string_t cmd_macsec_sc_set =
13880 TOKEN_STRING_INITIALIZER
13881 (struct cmd_macsec_sc_result,
13883 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13884 TOKEN_STRING_INITIALIZER
13885 (struct cmd_macsec_sc_result,
13887 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13888 TOKEN_STRING_INITIALIZER
13889 (struct cmd_macsec_sc_result,
13891 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13892 TOKEN_STRING_INITIALIZER
13893 (struct cmd_macsec_sc_result,
13895 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13896 TOKEN_NUM_INITIALIZER
13897 (struct cmd_macsec_sc_result,
13899 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13900 TOKEN_ETHERADDR_INITIALIZER
13901 (struct cmd_macsec_sc_result,
13903 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13904 TOKEN_NUM_INITIALIZER
13905 (struct cmd_macsec_sc_result,
13909 cmd_set_macsec_sc_parsed(
13910 void *parsed_result,
13911 __attribute__((unused)) struct cmdline *cl,
13912 __attribute__((unused)) void *data)
13914 struct cmd_macsec_sc_result *res = parsed_result;
13915 int ret = -ENOTSUP;
13916 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13918 #ifdef RTE_LIBRTE_IXGBE_PMD
13920 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13921 res->mac.addr_bytes) :
13922 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13923 res->mac.addr_bytes, res->pi);
13925 RTE_SET_USED(is_tx);
13931 printf("invalid port_id %d\n", res->port_id);
13934 printf("not supported on port %d\n", res->port_id);
13937 printf("programming error: (%s)\n", strerror(-ret));
13941 cmdline_parse_inst_t cmd_set_macsec_sc = {
13942 .f = cmd_set_macsec_sc_parsed,
13944 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13946 (void *)&cmd_macsec_sc_set,
13947 (void *)&cmd_macsec_sc_macsec,
13948 (void *)&cmd_macsec_sc_sc,
13949 (void *)&cmd_macsec_sc_tx_rx,
13950 (void *)&cmd_macsec_sc_port_id,
13951 (void *)&cmd_macsec_sc_mac,
13952 (void *)&cmd_macsec_sc_pi,
13957 /* Common result structure for MACsec secure connection configure */
13958 struct cmd_macsec_sa_result {
13959 cmdline_fixed_string_t set;
13960 cmdline_fixed_string_t macsec;
13961 cmdline_fixed_string_t sa;
13962 cmdline_fixed_string_t tx_rx;
13967 cmdline_fixed_string_t key;
13970 /* Common CLI fields for MACsec secure connection configure */
13971 cmdline_parse_token_string_t cmd_macsec_sa_set =
13972 TOKEN_STRING_INITIALIZER
13973 (struct cmd_macsec_sa_result,
13975 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13976 TOKEN_STRING_INITIALIZER
13977 (struct cmd_macsec_sa_result,
13979 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13980 TOKEN_STRING_INITIALIZER
13981 (struct cmd_macsec_sa_result,
13983 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13984 TOKEN_STRING_INITIALIZER
13985 (struct cmd_macsec_sa_result,
13987 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13988 TOKEN_NUM_INITIALIZER
13989 (struct cmd_macsec_sa_result,
13991 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13992 TOKEN_NUM_INITIALIZER
13993 (struct cmd_macsec_sa_result,
13995 cmdline_parse_token_num_t cmd_macsec_sa_an =
13996 TOKEN_NUM_INITIALIZER
13997 (struct cmd_macsec_sa_result,
13999 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14000 TOKEN_NUM_INITIALIZER
14001 (struct cmd_macsec_sa_result,
14003 cmdline_parse_token_string_t cmd_macsec_sa_key =
14004 TOKEN_STRING_INITIALIZER
14005 (struct cmd_macsec_sa_result,
14009 cmd_set_macsec_sa_parsed(
14010 void *parsed_result,
14011 __attribute__((unused)) struct cmdline *cl,
14012 __attribute__((unused)) void *data)
14014 struct cmd_macsec_sa_result *res = parsed_result;
14015 int ret = -ENOTSUP;
14016 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14017 uint8_t key[16] = { 0 };
14023 key_len = strlen(res->key) / 2;
14027 for (i = 0; i < key_len; i++) {
14028 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14031 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14034 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14037 #ifdef RTE_LIBRTE_IXGBE_PMD
14039 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14040 res->idx, res->an, res->pn, key) :
14041 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14042 res->idx, res->an, res->pn, key);
14044 RTE_SET_USED(is_tx);
14051 printf("invalid idx %d or an %d\n", res->idx, res->an);
14054 printf("invalid port_id %d\n", res->port_id);
14057 printf("not supported on port %d\n", res->port_id);
14060 printf("programming error: (%s)\n", strerror(-ret));
14064 cmdline_parse_inst_t cmd_set_macsec_sa = {
14065 .f = cmd_set_macsec_sa_parsed,
14067 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14069 (void *)&cmd_macsec_sa_set,
14070 (void *)&cmd_macsec_sa_macsec,
14071 (void *)&cmd_macsec_sa_sa,
14072 (void *)&cmd_macsec_sa_tx_rx,
14073 (void *)&cmd_macsec_sa_port_id,
14074 (void *)&cmd_macsec_sa_idx,
14075 (void *)&cmd_macsec_sa_an,
14076 (void *)&cmd_macsec_sa_pn,
14077 (void *)&cmd_macsec_sa_key,
14082 /* VF unicast promiscuous mode configuration */
14084 /* Common result structure for VF unicast promiscuous mode */
14085 struct cmd_vf_promisc_result {
14086 cmdline_fixed_string_t set;
14087 cmdline_fixed_string_t vf;
14088 cmdline_fixed_string_t promisc;
14091 cmdline_fixed_string_t on_off;
14094 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14095 cmdline_parse_token_string_t cmd_vf_promisc_set =
14096 TOKEN_STRING_INITIALIZER
14097 (struct cmd_vf_promisc_result,
14099 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14100 TOKEN_STRING_INITIALIZER
14101 (struct cmd_vf_promisc_result,
14103 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14104 TOKEN_STRING_INITIALIZER
14105 (struct cmd_vf_promisc_result,
14106 promisc, "promisc");
14107 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14108 TOKEN_NUM_INITIALIZER
14109 (struct cmd_vf_promisc_result,
14111 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14112 TOKEN_NUM_INITIALIZER
14113 (struct cmd_vf_promisc_result,
14115 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14116 TOKEN_STRING_INITIALIZER
14117 (struct cmd_vf_promisc_result,
14121 cmd_set_vf_promisc_parsed(
14122 void *parsed_result,
14123 __attribute__((unused)) struct cmdline *cl,
14124 __attribute__((unused)) void *data)
14126 struct cmd_vf_promisc_result *res = parsed_result;
14127 int ret = -ENOTSUP;
14129 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14131 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14134 #ifdef RTE_LIBRTE_I40E_PMD
14135 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14136 res->vf_id, is_on);
14143 printf("invalid vf_id %d\n", res->vf_id);
14146 printf("invalid port_id %d\n", res->port_id);
14149 printf("function not implemented\n");
14152 printf("programming error: (%s)\n", strerror(-ret));
14156 cmdline_parse_inst_t cmd_set_vf_promisc = {
14157 .f = cmd_set_vf_promisc_parsed,
14159 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14160 "Set unicast promiscuous mode for a VF from the PF",
14162 (void *)&cmd_vf_promisc_set,
14163 (void *)&cmd_vf_promisc_vf,
14164 (void *)&cmd_vf_promisc_promisc,
14165 (void *)&cmd_vf_promisc_port_id,
14166 (void *)&cmd_vf_promisc_vf_id,
14167 (void *)&cmd_vf_promisc_on_off,
14172 /* VF multicast promiscuous mode configuration */
14174 /* Common result structure for VF multicast promiscuous mode */
14175 struct cmd_vf_allmulti_result {
14176 cmdline_fixed_string_t set;
14177 cmdline_fixed_string_t vf;
14178 cmdline_fixed_string_t allmulti;
14181 cmdline_fixed_string_t on_off;
14184 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14185 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14186 TOKEN_STRING_INITIALIZER
14187 (struct cmd_vf_allmulti_result,
14189 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14190 TOKEN_STRING_INITIALIZER
14191 (struct cmd_vf_allmulti_result,
14193 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14194 TOKEN_STRING_INITIALIZER
14195 (struct cmd_vf_allmulti_result,
14196 allmulti, "allmulti");
14197 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14198 TOKEN_NUM_INITIALIZER
14199 (struct cmd_vf_allmulti_result,
14201 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14202 TOKEN_NUM_INITIALIZER
14203 (struct cmd_vf_allmulti_result,
14205 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14206 TOKEN_STRING_INITIALIZER
14207 (struct cmd_vf_allmulti_result,
14211 cmd_set_vf_allmulti_parsed(
14212 void *parsed_result,
14213 __attribute__((unused)) struct cmdline *cl,
14214 __attribute__((unused)) void *data)
14216 struct cmd_vf_allmulti_result *res = parsed_result;
14217 int ret = -ENOTSUP;
14219 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14221 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14224 #ifdef RTE_LIBRTE_I40E_PMD
14225 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14226 res->vf_id, is_on);
14233 printf("invalid vf_id %d\n", res->vf_id);
14236 printf("invalid port_id %d\n", res->port_id);
14239 printf("function not implemented\n");
14242 printf("programming error: (%s)\n", strerror(-ret));
14246 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14247 .f = cmd_set_vf_allmulti_parsed,
14249 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14250 "Set multicast promiscuous mode for a VF from the PF",
14252 (void *)&cmd_vf_allmulti_set,
14253 (void *)&cmd_vf_allmulti_vf,
14254 (void *)&cmd_vf_allmulti_allmulti,
14255 (void *)&cmd_vf_allmulti_port_id,
14256 (void *)&cmd_vf_allmulti_vf_id,
14257 (void *)&cmd_vf_allmulti_on_off,
14262 /* vf broadcast mode configuration */
14264 /* Common result structure for vf broadcast */
14265 struct cmd_set_vf_broadcast_result {
14266 cmdline_fixed_string_t set;
14267 cmdline_fixed_string_t vf;
14268 cmdline_fixed_string_t broadcast;
14271 cmdline_fixed_string_t on_off;
14274 /* Common CLI fields for vf broadcast enable disable */
14275 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14276 TOKEN_STRING_INITIALIZER
14277 (struct cmd_set_vf_broadcast_result,
14279 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14280 TOKEN_STRING_INITIALIZER
14281 (struct cmd_set_vf_broadcast_result,
14283 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14284 TOKEN_STRING_INITIALIZER
14285 (struct cmd_set_vf_broadcast_result,
14286 broadcast, "broadcast");
14287 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14288 TOKEN_NUM_INITIALIZER
14289 (struct cmd_set_vf_broadcast_result,
14291 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14292 TOKEN_NUM_INITIALIZER
14293 (struct cmd_set_vf_broadcast_result,
14295 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14296 TOKEN_STRING_INITIALIZER
14297 (struct cmd_set_vf_broadcast_result,
14301 cmd_set_vf_broadcast_parsed(
14302 void *parsed_result,
14303 __attribute__((unused)) struct cmdline *cl,
14304 __attribute__((unused)) void *data)
14306 struct cmd_set_vf_broadcast_result *res = parsed_result;
14307 int ret = -ENOTSUP;
14309 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14311 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14314 #ifdef RTE_LIBRTE_I40E_PMD
14315 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14316 res->vf_id, is_on);
14323 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14326 printf("invalid port_id %d\n", res->port_id);
14329 printf("function not implemented\n");
14332 printf("programming error: (%s)\n", strerror(-ret));
14336 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14337 .f = cmd_set_vf_broadcast_parsed,
14339 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14341 (void *)&cmd_set_vf_broadcast_set,
14342 (void *)&cmd_set_vf_broadcast_vf,
14343 (void *)&cmd_set_vf_broadcast_broadcast,
14344 (void *)&cmd_set_vf_broadcast_port_id,
14345 (void *)&cmd_set_vf_broadcast_vf_id,
14346 (void *)&cmd_set_vf_broadcast_on_off,
14351 /* vf vlan tag configuration */
14353 /* Common result structure for vf vlan tag */
14354 struct cmd_set_vf_vlan_tag_result {
14355 cmdline_fixed_string_t set;
14356 cmdline_fixed_string_t vf;
14357 cmdline_fixed_string_t vlan;
14358 cmdline_fixed_string_t tag;
14361 cmdline_fixed_string_t on_off;
14364 /* Common CLI fields for vf vlan tag enable disable */
14365 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14366 TOKEN_STRING_INITIALIZER
14367 (struct cmd_set_vf_vlan_tag_result,
14369 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14370 TOKEN_STRING_INITIALIZER
14371 (struct cmd_set_vf_vlan_tag_result,
14373 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14374 TOKEN_STRING_INITIALIZER
14375 (struct cmd_set_vf_vlan_tag_result,
14377 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14378 TOKEN_STRING_INITIALIZER
14379 (struct cmd_set_vf_vlan_tag_result,
14381 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14382 TOKEN_NUM_INITIALIZER
14383 (struct cmd_set_vf_vlan_tag_result,
14385 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14386 TOKEN_NUM_INITIALIZER
14387 (struct cmd_set_vf_vlan_tag_result,
14389 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14390 TOKEN_STRING_INITIALIZER
14391 (struct cmd_set_vf_vlan_tag_result,
14395 cmd_set_vf_vlan_tag_parsed(
14396 void *parsed_result,
14397 __attribute__((unused)) struct cmdline *cl,
14398 __attribute__((unused)) void *data)
14400 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14401 int ret = -ENOTSUP;
14403 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14405 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14408 #ifdef RTE_LIBRTE_I40E_PMD
14409 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14410 res->vf_id, is_on);
14417 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14420 printf("invalid port_id %d\n", res->port_id);
14423 printf("function not implemented\n");
14426 printf("programming error: (%s)\n", strerror(-ret));
14430 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14431 .f = cmd_set_vf_vlan_tag_parsed,
14433 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14435 (void *)&cmd_set_vf_vlan_tag_set,
14436 (void *)&cmd_set_vf_vlan_tag_vf,
14437 (void *)&cmd_set_vf_vlan_tag_vlan,
14438 (void *)&cmd_set_vf_vlan_tag_tag,
14439 (void *)&cmd_set_vf_vlan_tag_port_id,
14440 (void *)&cmd_set_vf_vlan_tag_vf_id,
14441 (void *)&cmd_set_vf_vlan_tag_on_off,
14446 /* Common definition of VF and TC TX bandwidth configuration */
14447 struct cmd_vf_tc_bw_result {
14448 cmdline_fixed_string_t set;
14449 cmdline_fixed_string_t vf;
14450 cmdline_fixed_string_t tc;
14451 cmdline_fixed_string_t tx;
14452 cmdline_fixed_string_t min_bw;
14453 cmdline_fixed_string_t max_bw;
14454 cmdline_fixed_string_t strict_link_prio;
14459 cmdline_fixed_string_t bw_list;
14463 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14464 TOKEN_STRING_INITIALIZER
14465 (struct cmd_vf_tc_bw_result,
14467 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14468 TOKEN_STRING_INITIALIZER
14469 (struct cmd_vf_tc_bw_result,
14471 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14472 TOKEN_STRING_INITIALIZER
14473 (struct cmd_vf_tc_bw_result,
14475 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14476 TOKEN_STRING_INITIALIZER
14477 (struct cmd_vf_tc_bw_result,
14479 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14480 TOKEN_STRING_INITIALIZER
14481 (struct cmd_vf_tc_bw_result,
14482 strict_link_prio, "strict-link-priority");
14483 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14484 TOKEN_STRING_INITIALIZER
14485 (struct cmd_vf_tc_bw_result,
14486 min_bw, "min-bandwidth");
14487 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14488 TOKEN_STRING_INITIALIZER
14489 (struct cmd_vf_tc_bw_result,
14490 max_bw, "max-bandwidth");
14491 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14492 TOKEN_NUM_INITIALIZER
14493 (struct cmd_vf_tc_bw_result,
14495 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14496 TOKEN_NUM_INITIALIZER
14497 (struct cmd_vf_tc_bw_result,
14499 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14500 TOKEN_NUM_INITIALIZER
14501 (struct cmd_vf_tc_bw_result,
14503 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14504 TOKEN_NUM_INITIALIZER
14505 (struct cmd_vf_tc_bw_result,
14507 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14508 TOKEN_STRING_INITIALIZER
14509 (struct cmd_vf_tc_bw_result,
14511 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14512 TOKEN_NUM_INITIALIZER
14513 (struct cmd_vf_tc_bw_result,
14516 /* VF max bandwidth setting */
14518 cmd_vf_max_bw_parsed(
14519 void *parsed_result,
14520 __attribute__((unused)) struct cmdline *cl,
14521 __attribute__((unused)) void *data)
14523 struct cmd_vf_tc_bw_result *res = parsed_result;
14524 int ret = -ENOTSUP;
14526 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14529 #ifdef RTE_LIBRTE_I40E_PMD
14530 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14531 res->vf_id, res->bw);
14538 printf("invalid vf_id %d or bandwidth %d\n",
14539 res->vf_id, res->bw);
14542 printf("invalid port_id %d\n", res->port_id);
14545 printf("function not implemented\n");
14548 printf("programming error: (%s)\n", strerror(-ret));
14552 cmdline_parse_inst_t cmd_vf_max_bw = {
14553 .f = cmd_vf_max_bw_parsed,
14555 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14557 (void *)&cmd_vf_tc_bw_set,
14558 (void *)&cmd_vf_tc_bw_vf,
14559 (void *)&cmd_vf_tc_bw_tx,
14560 (void *)&cmd_vf_tc_bw_max_bw,
14561 (void *)&cmd_vf_tc_bw_port_id,
14562 (void *)&cmd_vf_tc_bw_vf_id,
14563 (void *)&cmd_vf_tc_bw_bw,
14569 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14574 const char *p, *p0 = str;
14581 p = strchr(p0, '(');
14583 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14587 p0 = strchr(p, ')');
14589 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14593 if (size >= sizeof(s)) {
14594 printf("The string size exceeds the internal buffer size\n");
14597 snprintf(s, sizeof(s), "%.*s", size, p);
14598 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14600 printf("Failed to get the bandwidth list. ");
14604 for (i = 0; i < ret; i++)
14605 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14610 /* TC min bandwidth setting */
14612 cmd_vf_tc_min_bw_parsed(
14613 void *parsed_result,
14614 __attribute__((unused)) struct cmdline *cl,
14615 __attribute__((unused)) void *data)
14617 struct cmd_vf_tc_bw_result *res = parsed_result;
14620 int ret = -ENOTSUP;
14622 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14625 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14629 #ifdef RTE_LIBRTE_I40E_PMD
14630 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14638 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14641 printf("invalid port_id %d\n", res->port_id);
14644 printf("function not implemented\n");
14647 printf("programming error: (%s)\n", strerror(-ret));
14651 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14652 .f = cmd_vf_tc_min_bw_parsed,
14654 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14655 " <bw1, bw2, ...>",
14657 (void *)&cmd_vf_tc_bw_set,
14658 (void *)&cmd_vf_tc_bw_vf,
14659 (void *)&cmd_vf_tc_bw_tc,
14660 (void *)&cmd_vf_tc_bw_tx,
14661 (void *)&cmd_vf_tc_bw_min_bw,
14662 (void *)&cmd_vf_tc_bw_port_id,
14663 (void *)&cmd_vf_tc_bw_vf_id,
14664 (void *)&cmd_vf_tc_bw_bw_list,
14670 cmd_tc_min_bw_parsed(
14671 void *parsed_result,
14672 __attribute__((unused)) struct cmdline *cl,
14673 __attribute__((unused)) void *data)
14675 struct cmd_vf_tc_bw_result *res = parsed_result;
14676 struct rte_port *port;
14679 int ret = -ENOTSUP;
14681 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14684 port = &ports[res->port_id];
14685 /** Check if the port is not started **/
14686 if (port->port_status != RTE_PORT_STOPPED) {
14687 printf("Please stop port %d first\n", res->port_id);
14691 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14695 #ifdef RTE_LIBRTE_IXGBE_PMD
14696 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14703 printf("invalid bandwidth\n");
14706 printf("invalid port_id %d\n", res->port_id);
14709 printf("function not implemented\n");
14712 printf("programming error: (%s)\n", strerror(-ret));
14716 cmdline_parse_inst_t cmd_tc_min_bw = {
14717 .f = cmd_tc_min_bw_parsed,
14719 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14721 (void *)&cmd_vf_tc_bw_set,
14722 (void *)&cmd_vf_tc_bw_tc,
14723 (void *)&cmd_vf_tc_bw_tx,
14724 (void *)&cmd_vf_tc_bw_min_bw,
14725 (void *)&cmd_vf_tc_bw_port_id,
14726 (void *)&cmd_vf_tc_bw_bw_list,
14731 /* TC max bandwidth setting */
14733 cmd_vf_tc_max_bw_parsed(
14734 void *parsed_result,
14735 __attribute__((unused)) struct cmdline *cl,
14736 __attribute__((unused)) void *data)
14738 struct cmd_vf_tc_bw_result *res = parsed_result;
14739 int ret = -ENOTSUP;
14741 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14744 #ifdef RTE_LIBRTE_I40E_PMD
14745 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14746 res->tc_no, res->bw);
14753 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14754 res->vf_id, res->tc_no, res->bw);
14757 printf("invalid port_id %d\n", res->port_id);
14760 printf("function not implemented\n");
14763 printf("programming error: (%s)\n", strerror(-ret));
14767 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14768 .f = cmd_vf_tc_max_bw_parsed,
14770 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14773 (void *)&cmd_vf_tc_bw_set,
14774 (void *)&cmd_vf_tc_bw_vf,
14775 (void *)&cmd_vf_tc_bw_tc,
14776 (void *)&cmd_vf_tc_bw_tx,
14777 (void *)&cmd_vf_tc_bw_max_bw,
14778 (void *)&cmd_vf_tc_bw_port_id,
14779 (void *)&cmd_vf_tc_bw_vf_id,
14780 (void *)&cmd_vf_tc_bw_tc_no,
14781 (void *)&cmd_vf_tc_bw_bw,
14787 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14789 /* *** Set Port default Traffic Management Hierarchy *** */
14790 struct cmd_set_port_tm_hierarchy_default_result {
14791 cmdline_fixed_string_t set;
14792 cmdline_fixed_string_t port;
14793 cmdline_fixed_string_t tm;
14794 cmdline_fixed_string_t hierarchy;
14795 cmdline_fixed_string_t def;
14799 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14800 TOKEN_STRING_INITIALIZER(
14801 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14802 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14803 TOKEN_STRING_INITIALIZER(
14804 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14805 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14806 TOKEN_STRING_INITIALIZER(
14807 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14808 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14809 TOKEN_STRING_INITIALIZER(
14810 struct cmd_set_port_tm_hierarchy_default_result,
14811 hierarchy, "hierarchy");
14812 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14813 TOKEN_STRING_INITIALIZER(
14814 struct cmd_set_port_tm_hierarchy_default_result,
14816 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14817 TOKEN_NUM_INITIALIZER(
14818 struct cmd_set_port_tm_hierarchy_default_result,
14821 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14822 __attribute__((unused)) struct cmdline *cl,
14823 __attribute__((unused)) void *data)
14825 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14826 struct rte_port *p;
14827 portid_t port_id = res->port_id;
14829 if (port_id_is_invalid(port_id, ENABLED_WARN))
14832 p = &ports[port_id];
14834 /* Forward mode: tm */
14835 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
14836 printf(" softnicfwd mode not enabled(error)\n");
14840 /* Set the default tm hierarchy */
14841 p->softport.default_tm_hierarchy_enable = 1;
14844 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14845 .f = cmd_set_port_tm_hierarchy_default_parsed,
14847 .help_str = "set port tm hierarchy default <port_id>",
14849 (void *)&cmd_set_port_tm_hierarchy_default_set,
14850 (void *)&cmd_set_port_tm_hierarchy_default_port,
14851 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14852 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14853 (void *)&cmd_set_port_tm_hierarchy_default_default,
14854 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14860 /** Set VXLAN encapsulation details */
14861 struct cmd_set_vxlan_result {
14862 cmdline_fixed_string_t set;
14863 cmdline_fixed_string_t vxlan;
14864 cmdline_fixed_string_t pos_token;
14865 cmdline_fixed_string_t ip_version;
14866 uint32_t vlan_present:1;
14870 cmdline_ipaddr_t ip_src;
14871 cmdline_ipaddr_t ip_dst;
14873 struct ether_addr eth_src;
14874 struct ether_addr eth_dst;
14877 cmdline_parse_token_string_t cmd_set_vxlan_set =
14878 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
14879 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
14880 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
14881 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
14882 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14883 "vxlan-with-vlan");
14884 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
14885 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14887 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
14888 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
14890 cmdline_parse_token_string_t cmd_set_vxlan_vni =
14891 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14893 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
14894 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
14895 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
14896 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14898 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
14899 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
14900 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
14901 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14903 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
14904 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
14905 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
14906 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14908 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
14909 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
14910 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
14911 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14913 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
14914 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
14915 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
14916 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14918 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
14919 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
14920 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
14921 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14923 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
14924 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
14925 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
14926 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14928 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
14929 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
14931 static void cmd_set_vxlan_parsed(void *parsed_result,
14932 __attribute__((unused)) struct cmdline *cl,
14933 __attribute__((unused)) void *data)
14935 struct cmd_set_vxlan_result *res = parsed_result;
14940 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
14943 if (strcmp(res->vxlan, "vxlan") == 0)
14944 vxlan_encap_conf.select_vlan = 0;
14945 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
14946 vxlan_encap_conf.select_vlan = 1;
14947 if (strcmp(res->ip_version, "ipv4") == 0)
14948 vxlan_encap_conf.select_ipv4 = 1;
14949 else if (strcmp(res->ip_version, "ipv6") == 0)
14950 vxlan_encap_conf.select_ipv4 = 0;
14953 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
14954 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
14955 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
14956 if (vxlan_encap_conf.select_ipv4) {
14957 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
14958 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
14960 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
14961 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
14963 if (vxlan_encap_conf.select_vlan)
14964 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14965 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
14967 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14971 cmdline_parse_inst_t cmd_set_vxlan = {
14972 .f = cmd_set_vxlan_parsed,
14974 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
14975 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
14976 " eth-src <eth-src> eth-dst <eth-dst>",
14978 (void *)&cmd_set_vxlan_set,
14979 (void *)&cmd_set_vxlan_vxlan,
14980 (void *)&cmd_set_vxlan_ip_version,
14981 (void *)&cmd_set_vxlan_ip_version_value,
14982 (void *)&cmd_set_vxlan_vni,
14983 (void *)&cmd_set_vxlan_vni_value,
14984 (void *)&cmd_set_vxlan_udp_src,
14985 (void *)&cmd_set_vxlan_udp_src_value,
14986 (void *)&cmd_set_vxlan_udp_dst,
14987 (void *)&cmd_set_vxlan_udp_dst_value,
14988 (void *)&cmd_set_vxlan_ip_src,
14989 (void *)&cmd_set_vxlan_ip_src_value,
14990 (void *)&cmd_set_vxlan_ip_dst,
14991 (void *)&cmd_set_vxlan_ip_dst_value,
14992 (void *)&cmd_set_vxlan_eth_src,
14993 (void *)&cmd_set_vxlan_eth_src_value,
14994 (void *)&cmd_set_vxlan_eth_dst,
14995 (void *)&cmd_set_vxlan_eth_dst_value,
15000 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15001 .f = cmd_set_vxlan_parsed,
15003 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15004 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15005 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15008 (void *)&cmd_set_vxlan_set,
15009 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15010 (void *)&cmd_set_vxlan_ip_version,
15011 (void *)&cmd_set_vxlan_ip_version_value,
15012 (void *)&cmd_set_vxlan_vni,
15013 (void *)&cmd_set_vxlan_vni_value,
15014 (void *)&cmd_set_vxlan_udp_src,
15015 (void *)&cmd_set_vxlan_udp_src_value,
15016 (void *)&cmd_set_vxlan_udp_dst,
15017 (void *)&cmd_set_vxlan_udp_dst_value,
15018 (void *)&cmd_set_vxlan_ip_src,
15019 (void *)&cmd_set_vxlan_ip_src_value,
15020 (void *)&cmd_set_vxlan_ip_dst,
15021 (void *)&cmd_set_vxlan_ip_dst_value,
15022 (void *)&cmd_set_vxlan_vlan,
15023 (void *)&cmd_set_vxlan_vlan_value,
15024 (void *)&cmd_set_vxlan_eth_src,
15025 (void *)&cmd_set_vxlan_eth_src_value,
15026 (void *)&cmd_set_vxlan_eth_dst,
15027 (void *)&cmd_set_vxlan_eth_dst_value,
15032 /* Strict link priority scheduling mode setting */
15034 cmd_strict_link_prio_parsed(
15035 void *parsed_result,
15036 __attribute__((unused)) struct cmdline *cl,
15037 __attribute__((unused)) void *data)
15039 struct cmd_vf_tc_bw_result *res = parsed_result;
15040 int ret = -ENOTSUP;
15042 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15045 #ifdef RTE_LIBRTE_I40E_PMD
15046 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15053 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15056 printf("invalid port_id %d\n", res->port_id);
15059 printf("function not implemented\n");
15062 printf("programming error: (%s)\n", strerror(-ret));
15066 cmdline_parse_inst_t cmd_strict_link_prio = {
15067 .f = cmd_strict_link_prio_parsed,
15069 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
15071 (void *)&cmd_vf_tc_bw_set,
15072 (void *)&cmd_vf_tc_bw_tx,
15073 (void *)&cmd_vf_tc_bw_strict_link_prio,
15074 (void *)&cmd_vf_tc_bw_port_id,
15075 (void *)&cmd_vf_tc_bw_tc_map,
15080 /* Load dynamic device personalization*/
15081 struct cmd_ddp_add_result {
15082 cmdline_fixed_string_t ddp;
15083 cmdline_fixed_string_t add;
15088 cmdline_parse_token_string_t cmd_ddp_add_ddp =
15089 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
15090 cmdline_parse_token_string_t cmd_ddp_add_add =
15091 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
15092 cmdline_parse_token_num_t cmd_ddp_add_port_id =
15093 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
15094 cmdline_parse_token_string_t cmd_ddp_add_filepath =
15095 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
15098 cmd_ddp_add_parsed(
15099 void *parsed_result,
15100 __attribute__((unused)) struct cmdline *cl,
15101 __attribute__((unused)) void *data)
15103 struct cmd_ddp_add_result *res = parsed_result;
15109 int ret = -ENOTSUP;
15111 if (!all_ports_stopped()) {
15112 printf("Please stop all ports first\n");
15116 filepath = strdup(res->filepath);
15117 if (filepath == NULL) {
15118 printf("Failed to allocate memory\n");
15121 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
15123 buff = open_file(file_fld[0], &size);
15125 free((void *)filepath);
15129 #ifdef RTE_LIBRTE_I40E_PMD
15130 if (ret == -ENOTSUP)
15131 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15133 RTE_PMD_I40E_PKG_OP_WR_ADD);
15136 if (ret == -EEXIST)
15137 printf("Profile has already existed.\n");
15139 printf("Failed to load profile.\n");
15140 else if (file_num == 2)
15141 save_file(file_fld[1], buff, size);
15144 free((void *)filepath);
15147 cmdline_parse_inst_t cmd_ddp_add = {
15148 .f = cmd_ddp_add_parsed,
15150 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
15152 (void *)&cmd_ddp_add_ddp,
15153 (void *)&cmd_ddp_add_add,
15154 (void *)&cmd_ddp_add_port_id,
15155 (void *)&cmd_ddp_add_filepath,
15160 /* Delete dynamic device personalization*/
15161 struct cmd_ddp_del_result {
15162 cmdline_fixed_string_t ddp;
15163 cmdline_fixed_string_t del;
15168 cmdline_parse_token_string_t cmd_ddp_del_ddp =
15169 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
15170 cmdline_parse_token_string_t cmd_ddp_del_del =
15171 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
15172 cmdline_parse_token_num_t cmd_ddp_del_port_id =
15173 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
15174 cmdline_parse_token_string_t cmd_ddp_del_filepath =
15175 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
15178 cmd_ddp_del_parsed(
15179 void *parsed_result,
15180 __attribute__((unused)) struct cmdline *cl,
15181 __attribute__((unused)) void *data)
15183 struct cmd_ddp_del_result *res = parsed_result;
15186 int ret = -ENOTSUP;
15188 if (!all_ports_stopped()) {
15189 printf("Please stop all ports first\n");
15193 buff = open_file(res->filepath, &size);
15197 #ifdef RTE_LIBRTE_I40E_PMD
15198 if (ret == -ENOTSUP)
15199 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15201 RTE_PMD_I40E_PKG_OP_WR_DEL);
15204 if (ret == -EACCES)
15205 printf("Profile does not exist.\n");
15207 printf("Failed to delete profile.\n");
15212 cmdline_parse_inst_t cmd_ddp_del = {
15213 .f = cmd_ddp_del_parsed,
15215 .help_str = "ddp del <port_id> <backup_profile_path>",
15217 (void *)&cmd_ddp_del_ddp,
15218 (void *)&cmd_ddp_del_del,
15219 (void *)&cmd_ddp_del_port_id,
15220 (void *)&cmd_ddp_del_filepath,
15225 /* Get dynamic device personalization profile info */
15226 struct cmd_ddp_info_result {
15227 cmdline_fixed_string_t ddp;
15228 cmdline_fixed_string_t get;
15229 cmdline_fixed_string_t info;
15233 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15234 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15235 cmdline_parse_token_string_t cmd_ddp_info_get =
15236 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15237 cmdline_parse_token_string_t cmd_ddp_info_info =
15238 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15239 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15240 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15243 cmd_ddp_info_parsed(
15244 void *parsed_result,
15245 __attribute__((unused)) struct cmdline *cl,
15246 __attribute__((unused)) void *data)
15248 struct cmd_ddp_info_result *res = parsed_result;
15251 int ret = -ENOTSUP;
15252 #ifdef RTE_LIBRTE_I40E_PMD
15255 uint32_t buff_size = 0;
15256 struct rte_pmd_i40e_profile_info info;
15257 uint32_t dev_num = 0;
15258 struct rte_pmd_i40e_ddp_device_id *devs;
15259 uint32_t proto_num = 0;
15260 struct rte_pmd_i40e_proto_info *proto = NULL;
15261 uint32_t pctype_num = 0;
15262 struct rte_pmd_i40e_ptype_info *pctype;
15263 uint32_t ptype_num = 0;
15264 struct rte_pmd_i40e_ptype_info *ptype;
15269 pkg = open_file(res->filepath, &pkg_size);
15273 #ifdef RTE_LIBRTE_I40E_PMD
15274 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15275 (uint8_t *)&info, sizeof(info),
15276 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15278 printf("Global Track id: 0x%x\n", info.track_id);
15279 printf("Global Version: %d.%d.%d.%d\n",
15280 info.version.major,
15281 info.version.minor,
15282 info.version.update,
15283 info.version.draft);
15284 printf("Global Package name: %s\n\n", info.name);
15287 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15288 (uint8_t *)&info, sizeof(info),
15289 RTE_PMD_I40E_PKG_INFO_HEADER);
15291 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15292 printf("i40e Profile Version: %d.%d.%d.%d\n",
15293 info.version.major,
15294 info.version.minor,
15295 info.version.update,
15296 info.version.draft);
15297 printf("i40e Profile name: %s\n\n", info.name);
15300 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15301 (uint8_t *)&buff_size, sizeof(buff_size),
15302 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15303 if (!ret && buff_size) {
15304 buff = (uint8_t *)malloc(buff_size);
15306 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15308 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15310 printf("Package Notes:\n%s\n\n", buff);
15315 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15316 (uint8_t *)&dev_num, sizeof(dev_num),
15317 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15318 if (!ret && dev_num) {
15319 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15320 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15322 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15323 (uint8_t *)devs, buff_size,
15324 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15326 printf("List of supported devices:\n");
15327 for (i = 0; i < dev_num; i++) {
15328 printf(" %04X:%04X %04X:%04X\n",
15329 devs[i].vendor_dev_id >> 16,
15330 devs[i].vendor_dev_id & 0xFFFF,
15331 devs[i].sub_vendor_dev_id >> 16,
15332 devs[i].sub_vendor_dev_id & 0xFFFF);
15340 /* get information about protocols and packet types */
15341 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15342 (uint8_t *)&proto_num, sizeof(proto_num),
15343 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15344 if (ret || !proto_num)
15345 goto no_print_return;
15347 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15348 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15350 goto no_print_return;
15352 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15354 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15356 printf("List of used protocols:\n");
15357 for (i = 0; i < proto_num; i++)
15358 printf(" %2u: %s\n", proto[i].proto_id,
15362 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15363 (uint8_t *)&pctype_num, sizeof(pctype_num),
15364 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15365 if (ret || !pctype_num)
15366 goto no_print_pctypes;
15368 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15369 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15371 goto no_print_pctypes;
15373 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15375 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15378 goto no_print_pctypes;
15381 printf("List of defined packet classification types:\n");
15382 for (i = 0; i < pctype_num; i++) {
15383 printf(" %2u:", pctype[i].ptype_id);
15384 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15385 proto_id = pctype[i].protocols[j];
15386 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15387 for (n = 0; n < proto_num; n++) {
15388 if (proto[n].proto_id == proto_id) {
15389 printf(" %s", proto[n].name);
15402 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15404 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15405 if (ret || !ptype_num)
15406 goto no_print_return;
15408 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15409 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15411 goto no_print_return;
15413 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15415 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15418 goto no_print_return;
15420 printf("List of defined packet types:\n");
15421 for (i = 0; i < ptype_num; i++) {
15422 printf(" %2u:", ptype[i].ptype_id);
15423 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15424 proto_id = ptype[i].protocols[j];
15425 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15426 for (n = 0; n < proto_num; n++) {
15427 if (proto[n].proto_id == proto_id) {
15428 printf(" %s", proto[n].name);
15444 if (ret == -ENOTSUP)
15445 printf("Function not supported in PMD driver\n");
15449 cmdline_parse_inst_t cmd_ddp_get_info = {
15450 .f = cmd_ddp_info_parsed,
15452 .help_str = "ddp get info <profile_path>",
15454 (void *)&cmd_ddp_info_ddp,
15455 (void *)&cmd_ddp_info_get,
15456 (void *)&cmd_ddp_info_info,
15457 (void *)&cmd_ddp_info_filepath,
15462 /* Get dynamic device personalization profile info list*/
15463 #define PROFILE_INFO_SIZE 48
15464 #define MAX_PROFILE_NUM 16
15466 struct cmd_ddp_get_list_result {
15467 cmdline_fixed_string_t ddp;
15468 cmdline_fixed_string_t get;
15469 cmdline_fixed_string_t list;
15473 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15474 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15475 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15476 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15477 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15478 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15479 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15480 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15483 cmd_ddp_get_list_parsed(
15484 __attribute__((unused)) void *parsed_result,
15485 __attribute__((unused)) struct cmdline *cl,
15486 __attribute__((unused)) void *data)
15488 #ifdef RTE_LIBRTE_I40E_PMD
15489 struct cmd_ddp_get_list_result *res = parsed_result;
15490 struct rte_pmd_i40e_profile_list *p_list;
15491 struct rte_pmd_i40e_profile_info *p_info;
15496 int ret = -ENOTSUP;
15498 #ifdef RTE_LIBRTE_I40E_PMD
15499 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15500 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15502 printf("%s: Failed to malloc buffer\n", __func__);
15504 if (ret == -ENOTSUP)
15505 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15506 (uint8_t *)p_list, size);
15509 p_num = p_list->p_count;
15510 printf("Profile number is: %d\n\n", p_num);
15512 for (i = 0; i < p_num; i++) {
15513 p_info = &p_list->p_info[i];
15514 printf("Profile %d:\n", i);
15515 printf("Track id: 0x%x\n", p_info->track_id);
15516 printf("Version: %d.%d.%d.%d\n",
15517 p_info->version.major,
15518 p_info->version.minor,
15519 p_info->version.update,
15520 p_info->version.draft);
15521 printf("Profile name: %s\n\n", p_info->name);
15529 printf("Failed to get ddp list\n");
15532 cmdline_parse_inst_t cmd_ddp_get_list = {
15533 .f = cmd_ddp_get_list_parsed,
15535 .help_str = "ddp get list <port_id>",
15537 (void *)&cmd_ddp_get_list_ddp,
15538 (void *)&cmd_ddp_get_list_get,
15539 (void *)&cmd_ddp_get_list_list,
15540 (void *)&cmd_ddp_get_list_port_id,
15545 /* Configure input set */
15546 struct cmd_cfg_input_set_result {
15547 cmdline_fixed_string_t port;
15548 cmdline_fixed_string_t cfg;
15550 cmdline_fixed_string_t pctype;
15552 cmdline_fixed_string_t inset_type;
15553 cmdline_fixed_string_t opt;
15554 cmdline_fixed_string_t field;
15559 cmd_cfg_input_set_parsed(
15560 __attribute__((unused)) void *parsed_result,
15561 __attribute__((unused)) struct cmdline *cl,
15562 __attribute__((unused)) void *data)
15564 #ifdef RTE_LIBRTE_I40E_PMD
15565 struct cmd_cfg_input_set_result *res = parsed_result;
15566 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15567 struct rte_pmd_i40e_inset inset;
15569 int ret = -ENOTSUP;
15571 if (!all_ports_stopped()) {
15572 printf("Please stop all ports first\n");
15576 #ifdef RTE_LIBRTE_I40E_PMD
15577 if (!strcmp(res->inset_type, "hash_inset"))
15578 inset_type = INSET_HASH;
15579 else if (!strcmp(res->inset_type, "fdir_inset"))
15580 inset_type = INSET_FDIR;
15581 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15582 inset_type = INSET_FDIR_FLX;
15583 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15584 &inset, inset_type);
15586 printf("Failed to get input set.\n");
15590 if (!strcmp(res->opt, "get")) {
15591 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15594 printf("Field index %d is enabled.\n", res->field_idx);
15596 printf("Field index %d is disabled.\n", res->field_idx);
15598 } else if (!strcmp(res->opt, "set"))
15599 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15601 else if (!strcmp(res->opt, "clear"))
15602 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15605 printf("Failed to configure input set field.\n");
15609 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15610 &inset, inset_type);
15612 printf("Failed to set input set.\n");
15617 if (ret == -ENOTSUP)
15618 printf("Function not supported\n");
15621 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15622 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15624 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15625 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15627 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15628 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15630 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15631 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15633 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15634 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15636 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15637 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15639 "hash_inset#fdir_inset#fdir_flx_inset");
15640 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15641 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15642 opt, "get#set#clear");
15643 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15644 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15646 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15647 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15650 cmdline_parse_inst_t cmd_cfg_input_set = {
15651 .f = cmd_cfg_input_set_parsed,
15653 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15654 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15656 (void *)&cmd_cfg_input_set_port,
15657 (void *)&cmd_cfg_input_set_cfg,
15658 (void *)&cmd_cfg_input_set_port_id,
15659 (void *)&cmd_cfg_input_set_pctype,
15660 (void *)&cmd_cfg_input_set_pctype_id,
15661 (void *)&cmd_cfg_input_set_inset_type,
15662 (void *)&cmd_cfg_input_set_opt,
15663 (void *)&cmd_cfg_input_set_field,
15664 (void *)&cmd_cfg_input_set_field_idx,
15669 /* Clear input set */
15670 struct cmd_clear_input_set_result {
15671 cmdline_fixed_string_t port;
15672 cmdline_fixed_string_t cfg;
15674 cmdline_fixed_string_t pctype;
15676 cmdline_fixed_string_t inset_type;
15677 cmdline_fixed_string_t clear;
15678 cmdline_fixed_string_t all;
15682 cmd_clear_input_set_parsed(
15683 __attribute__((unused)) void *parsed_result,
15684 __attribute__((unused)) struct cmdline *cl,
15685 __attribute__((unused)) void *data)
15687 #ifdef RTE_LIBRTE_I40E_PMD
15688 struct cmd_clear_input_set_result *res = parsed_result;
15689 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15690 struct rte_pmd_i40e_inset inset;
15692 int ret = -ENOTSUP;
15694 if (!all_ports_stopped()) {
15695 printf("Please stop all ports first\n");
15699 #ifdef RTE_LIBRTE_I40E_PMD
15700 if (!strcmp(res->inset_type, "hash_inset"))
15701 inset_type = INSET_HASH;
15702 else if (!strcmp(res->inset_type, "fdir_inset"))
15703 inset_type = INSET_FDIR;
15704 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15705 inset_type = INSET_FDIR_FLX;
15707 memset(&inset, 0, sizeof(inset));
15709 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15710 &inset, inset_type);
15712 printf("Failed to clear input set.\n");
15718 if (ret == -ENOTSUP)
15719 printf("Function not supported\n");
15722 cmdline_parse_token_string_t cmd_clear_input_set_port =
15723 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15725 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15726 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15728 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15729 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15731 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15732 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15734 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15735 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15737 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15738 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15740 "hash_inset#fdir_inset#fdir_flx_inset");
15741 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15742 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15744 cmdline_parse_token_string_t cmd_clear_input_set_all =
15745 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15748 cmdline_parse_inst_t cmd_clear_input_set = {
15749 .f = cmd_clear_input_set_parsed,
15751 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15752 "fdir_inset|fdir_flx_inset clear all",
15754 (void *)&cmd_clear_input_set_port,
15755 (void *)&cmd_clear_input_set_cfg,
15756 (void *)&cmd_clear_input_set_port_id,
15757 (void *)&cmd_clear_input_set_pctype,
15758 (void *)&cmd_clear_input_set_pctype_id,
15759 (void *)&cmd_clear_input_set_inset_type,
15760 (void *)&cmd_clear_input_set_clear,
15761 (void *)&cmd_clear_input_set_all,
15766 /* show vf stats */
15768 /* Common result structure for show vf stats */
15769 struct cmd_show_vf_stats_result {
15770 cmdline_fixed_string_t show;
15771 cmdline_fixed_string_t vf;
15772 cmdline_fixed_string_t stats;
15777 /* Common CLI fields show vf stats*/
15778 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15779 TOKEN_STRING_INITIALIZER
15780 (struct cmd_show_vf_stats_result,
15782 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15783 TOKEN_STRING_INITIALIZER
15784 (struct cmd_show_vf_stats_result,
15786 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15787 TOKEN_STRING_INITIALIZER
15788 (struct cmd_show_vf_stats_result,
15790 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15791 TOKEN_NUM_INITIALIZER
15792 (struct cmd_show_vf_stats_result,
15794 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15795 TOKEN_NUM_INITIALIZER
15796 (struct cmd_show_vf_stats_result,
15800 cmd_show_vf_stats_parsed(
15801 void *parsed_result,
15802 __attribute__((unused)) struct cmdline *cl,
15803 __attribute__((unused)) void *data)
15805 struct cmd_show_vf_stats_result *res = parsed_result;
15806 struct rte_eth_stats stats;
15807 int ret = -ENOTSUP;
15808 static const char *nic_stats_border = "########################";
15810 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15813 memset(&stats, 0, sizeof(stats));
15815 #ifdef RTE_LIBRTE_I40E_PMD
15816 if (ret == -ENOTSUP)
15817 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15821 #ifdef RTE_LIBRTE_BNXT_PMD
15822 if (ret == -ENOTSUP)
15823 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15832 printf("invalid vf_id %d\n", res->vf_id);
15835 printf("invalid port_id %d\n", res->port_id);
15838 printf("function not implemented\n");
15841 printf("programming error: (%s)\n", strerror(-ret));
15844 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15845 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15847 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15849 stats.ipackets, stats.imissed, stats.ibytes);
15850 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15851 printf(" RX-nombuf: %-10"PRIu64"\n",
15853 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15855 stats.opackets, stats.oerrors, stats.obytes);
15857 printf(" %s############################%s\n",
15858 nic_stats_border, nic_stats_border);
15861 cmdline_parse_inst_t cmd_show_vf_stats = {
15862 .f = cmd_show_vf_stats_parsed,
15864 .help_str = "show vf stats <port_id> <vf_id>",
15866 (void *)&cmd_show_vf_stats_show,
15867 (void *)&cmd_show_vf_stats_vf,
15868 (void *)&cmd_show_vf_stats_stats,
15869 (void *)&cmd_show_vf_stats_port_id,
15870 (void *)&cmd_show_vf_stats_vf_id,
15875 /* clear vf stats */
15877 /* Common result structure for clear vf stats */
15878 struct cmd_clear_vf_stats_result {
15879 cmdline_fixed_string_t clear;
15880 cmdline_fixed_string_t vf;
15881 cmdline_fixed_string_t stats;
15886 /* Common CLI fields clear vf stats*/
15887 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15888 TOKEN_STRING_INITIALIZER
15889 (struct cmd_clear_vf_stats_result,
15891 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15892 TOKEN_STRING_INITIALIZER
15893 (struct cmd_clear_vf_stats_result,
15895 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15896 TOKEN_STRING_INITIALIZER
15897 (struct cmd_clear_vf_stats_result,
15899 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15900 TOKEN_NUM_INITIALIZER
15901 (struct cmd_clear_vf_stats_result,
15903 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15904 TOKEN_NUM_INITIALIZER
15905 (struct cmd_clear_vf_stats_result,
15909 cmd_clear_vf_stats_parsed(
15910 void *parsed_result,
15911 __attribute__((unused)) struct cmdline *cl,
15912 __attribute__((unused)) void *data)
15914 struct cmd_clear_vf_stats_result *res = parsed_result;
15915 int ret = -ENOTSUP;
15917 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15920 #ifdef RTE_LIBRTE_I40E_PMD
15921 if (ret == -ENOTSUP)
15922 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15925 #ifdef RTE_LIBRTE_BNXT_PMD
15926 if (ret == -ENOTSUP)
15927 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15935 printf("invalid vf_id %d\n", res->vf_id);
15938 printf("invalid port_id %d\n", res->port_id);
15941 printf("function not implemented\n");
15944 printf("programming error: (%s)\n", strerror(-ret));
15948 cmdline_parse_inst_t cmd_clear_vf_stats = {
15949 .f = cmd_clear_vf_stats_parsed,
15951 .help_str = "clear vf stats <port_id> <vf_id>",
15953 (void *)&cmd_clear_vf_stats_clear,
15954 (void *)&cmd_clear_vf_stats_vf,
15955 (void *)&cmd_clear_vf_stats_stats,
15956 (void *)&cmd_clear_vf_stats_port_id,
15957 (void *)&cmd_clear_vf_stats_vf_id,
15962 /* port config pctype mapping reset */
15964 /* Common result structure for port config pctype mapping reset */
15965 struct cmd_pctype_mapping_reset_result {
15966 cmdline_fixed_string_t port;
15967 cmdline_fixed_string_t config;
15969 cmdline_fixed_string_t pctype;
15970 cmdline_fixed_string_t mapping;
15971 cmdline_fixed_string_t reset;
15974 /* Common CLI fields for port config pctype mapping reset*/
15975 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15976 TOKEN_STRING_INITIALIZER
15977 (struct cmd_pctype_mapping_reset_result,
15979 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15980 TOKEN_STRING_INITIALIZER
15981 (struct cmd_pctype_mapping_reset_result,
15983 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15984 TOKEN_NUM_INITIALIZER
15985 (struct cmd_pctype_mapping_reset_result,
15987 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15988 TOKEN_STRING_INITIALIZER
15989 (struct cmd_pctype_mapping_reset_result,
15991 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15992 TOKEN_STRING_INITIALIZER
15993 (struct cmd_pctype_mapping_reset_result,
15994 mapping, "mapping");
15995 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15996 TOKEN_STRING_INITIALIZER
15997 (struct cmd_pctype_mapping_reset_result,
16001 cmd_pctype_mapping_reset_parsed(
16002 void *parsed_result,
16003 __attribute__((unused)) struct cmdline *cl,
16004 __attribute__((unused)) void *data)
16006 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16007 int ret = -ENOTSUP;
16009 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16012 #ifdef RTE_LIBRTE_I40E_PMD
16013 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16020 printf("invalid port_id %d\n", res->port_id);
16023 printf("function not implemented\n");
16026 printf("programming error: (%s)\n", strerror(-ret));
16030 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16031 .f = cmd_pctype_mapping_reset_parsed,
16033 .help_str = "port config <port_id> pctype mapping reset",
16035 (void *)&cmd_pctype_mapping_reset_port,
16036 (void *)&cmd_pctype_mapping_reset_config,
16037 (void *)&cmd_pctype_mapping_reset_port_id,
16038 (void *)&cmd_pctype_mapping_reset_pctype,
16039 (void *)&cmd_pctype_mapping_reset_mapping,
16040 (void *)&cmd_pctype_mapping_reset_reset,
16045 /* show port pctype mapping */
16047 /* Common result structure for show port pctype mapping */
16048 struct cmd_pctype_mapping_get_result {
16049 cmdline_fixed_string_t show;
16050 cmdline_fixed_string_t port;
16052 cmdline_fixed_string_t pctype;
16053 cmdline_fixed_string_t mapping;
16056 /* Common CLI fields for pctype mapping get */
16057 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
16058 TOKEN_STRING_INITIALIZER
16059 (struct cmd_pctype_mapping_get_result,
16061 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16062 TOKEN_STRING_INITIALIZER
16063 (struct cmd_pctype_mapping_get_result,
16065 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
16066 TOKEN_NUM_INITIALIZER
16067 (struct cmd_pctype_mapping_get_result,
16069 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
16070 TOKEN_STRING_INITIALIZER
16071 (struct cmd_pctype_mapping_get_result,
16073 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
16074 TOKEN_STRING_INITIALIZER
16075 (struct cmd_pctype_mapping_get_result,
16076 mapping, "mapping");
16079 cmd_pctype_mapping_get_parsed(
16080 void *parsed_result,
16081 __attribute__((unused)) struct cmdline *cl,
16082 __attribute__((unused)) void *data)
16084 struct cmd_pctype_mapping_get_result *res = parsed_result;
16085 int ret = -ENOTSUP;
16086 #ifdef RTE_LIBRTE_I40E_PMD
16087 struct rte_pmd_i40e_flow_type_mapping
16088 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
16089 int i, j, first_pctype;
16092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16095 #ifdef RTE_LIBRTE_I40E_PMD
16096 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
16103 printf("invalid port_id %d\n", res->port_id);
16106 printf("function not implemented\n");
16109 printf("programming error: (%s)\n", strerror(-ret));
16113 #ifdef RTE_LIBRTE_I40E_PMD
16114 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
16115 if (mapping[i].pctype != 0ULL) {
16118 printf("pctype: ");
16119 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
16120 if (mapping[i].pctype & (1ULL << j)) {
16121 printf(first_pctype ?
16122 "%02d" : ",%02d", j);
16126 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
16132 cmdline_parse_inst_t cmd_pctype_mapping_get = {
16133 .f = cmd_pctype_mapping_get_parsed,
16135 .help_str = "show port <port_id> pctype mapping",
16137 (void *)&cmd_pctype_mapping_get_show,
16138 (void *)&cmd_pctype_mapping_get_port,
16139 (void *)&cmd_pctype_mapping_get_port_id,
16140 (void *)&cmd_pctype_mapping_get_pctype,
16141 (void *)&cmd_pctype_mapping_get_mapping,
16146 /* port config pctype mapping update */
16148 /* Common result structure for port config pctype mapping update */
16149 struct cmd_pctype_mapping_update_result {
16150 cmdline_fixed_string_t port;
16151 cmdline_fixed_string_t config;
16153 cmdline_fixed_string_t pctype;
16154 cmdline_fixed_string_t mapping;
16155 cmdline_fixed_string_t update;
16156 cmdline_fixed_string_t pctype_list;
16157 uint16_t flow_type;
16160 /* Common CLI fields for pctype mapping update*/
16161 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
16162 TOKEN_STRING_INITIALIZER
16163 (struct cmd_pctype_mapping_update_result,
16165 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
16166 TOKEN_STRING_INITIALIZER
16167 (struct cmd_pctype_mapping_update_result,
16169 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
16170 TOKEN_NUM_INITIALIZER
16171 (struct cmd_pctype_mapping_update_result,
16173 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
16174 TOKEN_STRING_INITIALIZER
16175 (struct cmd_pctype_mapping_update_result,
16177 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
16178 TOKEN_STRING_INITIALIZER
16179 (struct cmd_pctype_mapping_update_result,
16180 mapping, "mapping");
16181 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
16182 TOKEN_STRING_INITIALIZER
16183 (struct cmd_pctype_mapping_update_result,
16185 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16186 TOKEN_STRING_INITIALIZER
16187 (struct cmd_pctype_mapping_update_result,
16188 pctype_list, NULL);
16189 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16190 TOKEN_NUM_INITIALIZER
16191 (struct cmd_pctype_mapping_update_result,
16192 flow_type, UINT16);
16195 cmd_pctype_mapping_update_parsed(
16196 void *parsed_result,
16197 __attribute__((unused)) struct cmdline *cl,
16198 __attribute__((unused)) void *data)
16200 struct cmd_pctype_mapping_update_result *res = parsed_result;
16201 int ret = -ENOTSUP;
16202 #ifdef RTE_LIBRTE_I40E_PMD
16203 struct rte_pmd_i40e_flow_type_mapping mapping;
16205 unsigned int nb_item;
16206 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16209 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16212 #ifdef RTE_LIBRTE_I40E_PMD
16213 nb_item = parse_item_list(res->pctype_list, "pctypes",
16214 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16215 mapping.flow_type = res->flow_type;
16216 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16217 mapping.pctype |= (1ULL << pctype_list[i]);
16218 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16228 printf("invalid pctype or flow type\n");
16231 printf("invalid port_id %d\n", res->port_id);
16234 printf("function not implemented\n");
16237 printf("programming error: (%s)\n", strerror(-ret));
16241 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16242 .f = cmd_pctype_mapping_update_parsed,
16244 .help_str = "port config <port_id> pctype mapping update"
16245 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16247 (void *)&cmd_pctype_mapping_update_port,
16248 (void *)&cmd_pctype_mapping_update_config,
16249 (void *)&cmd_pctype_mapping_update_port_id,
16250 (void *)&cmd_pctype_mapping_update_pctype,
16251 (void *)&cmd_pctype_mapping_update_mapping,
16252 (void *)&cmd_pctype_mapping_update_update,
16253 (void *)&cmd_pctype_mapping_update_pc_type,
16254 (void *)&cmd_pctype_mapping_update_flow_type,
16259 /* ptype mapping get */
16261 /* Common result structure for ptype mapping get */
16262 struct cmd_ptype_mapping_get_result {
16263 cmdline_fixed_string_t ptype;
16264 cmdline_fixed_string_t mapping;
16265 cmdline_fixed_string_t get;
16267 uint8_t valid_only;
16270 /* Common CLI fields for ptype mapping get */
16271 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16272 TOKEN_STRING_INITIALIZER
16273 (struct cmd_ptype_mapping_get_result,
16275 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16276 TOKEN_STRING_INITIALIZER
16277 (struct cmd_ptype_mapping_get_result,
16278 mapping, "mapping");
16279 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16280 TOKEN_STRING_INITIALIZER
16281 (struct cmd_ptype_mapping_get_result,
16283 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16284 TOKEN_NUM_INITIALIZER
16285 (struct cmd_ptype_mapping_get_result,
16287 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16288 TOKEN_NUM_INITIALIZER
16289 (struct cmd_ptype_mapping_get_result,
16290 valid_only, UINT8);
16293 cmd_ptype_mapping_get_parsed(
16294 void *parsed_result,
16295 __attribute__((unused)) struct cmdline *cl,
16296 __attribute__((unused)) void *data)
16298 struct cmd_ptype_mapping_get_result *res = parsed_result;
16299 int ret = -ENOTSUP;
16300 #ifdef RTE_LIBRTE_I40E_PMD
16301 int max_ptype_num = 256;
16302 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16307 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16310 #ifdef RTE_LIBRTE_I40E_PMD
16311 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16322 printf("invalid port_id %d\n", res->port_id);
16325 printf("function not implemented\n");
16328 printf("programming error: (%s)\n", strerror(-ret));
16331 #ifdef RTE_LIBRTE_I40E_PMD
16333 for (i = 0; i < count; i++)
16334 printf("%3d\t0x%08x\n",
16335 mapping[i].hw_ptype, mapping[i].sw_ptype);
16340 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16341 .f = cmd_ptype_mapping_get_parsed,
16343 .help_str = "ptype mapping get <port_id> <valid_only>",
16345 (void *)&cmd_ptype_mapping_get_ptype,
16346 (void *)&cmd_ptype_mapping_get_mapping,
16347 (void *)&cmd_ptype_mapping_get_get,
16348 (void *)&cmd_ptype_mapping_get_port_id,
16349 (void *)&cmd_ptype_mapping_get_valid_only,
16354 /* ptype mapping replace */
16356 /* Common result structure for ptype mapping replace */
16357 struct cmd_ptype_mapping_replace_result {
16358 cmdline_fixed_string_t ptype;
16359 cmdline_fixed_string_t mapping;
16360 cmdline_fixed_string_t replace;
16367 /* Common CLI fields for ptype mapping replace */
16368 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16369 TOKEN_STRING_INITIALIZER
16370 (struct cmd_ptype_mapping_replace_result,
16372 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16373 TOKEN_STRING_INITIALIZER
16374 (struct cmd_ptype_mapping_replace_result,
16375 mapping, "mapping");
16376 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16377 TOKEN_STRING_INITIALIZER
16378 (struct cmd_ptype_mapping_replace_result,
16379 replace, "replace");
16380 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16381 TOKEN_NUM_INITIALIZER
16382 (struct cmd_ptype_mapping_replace_result,
16384 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16385 TOKEN_NUM_INITIALIZER
16386 (struct cmd_ptype_mapping_replace_result,
16388 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16389 TOKEN_NUM_INITIALIZER
16390 (struct cmd_ptype_mapping_replace_result,
16392 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16393 TOKEN_NUM_INITIALIZER
16394 (struct cmd_ptype_mapping_replace_result,
16398 cmd_ptype_mapping_replace_parsed(
16399 void *parsed_result,
16400 __attribute__((unused)) struct cmdline *cl,
16401 __attribute__((unused)) void *data)
16403 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16404 int ret = -ENOTSUP;
16406 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16409 #ifdef RTE_LIBRTE_I40E_PMD
16410 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16420 printf("invalid ptype 0x%8x or 0x%8x\n",
16421 res->target, res->pkt_type);
16424 printf("invalid port_id %d\n", res->port_id);
16427 printf("function not implemented\n");
16430 printf("programming error: (%s)\n", strerror(-ret));
16434 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16435 .f = cmd_ptype_mapping_replace_parsed,
16438 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16440 (void *)&cmd_ptype_mapping_replace_ptype,
16441 (void *)&cmd_ptype_mapping_replace_mapping,
16442 (void *)&cmd_ptype_mapping_replace_replace,
16443 (void *)&cmd_ptype_mapping_replace_port_id,
16444 (void *)&cmd_ptype_mapping_replace_target,
16445 (void *)&cmd_ptype_mapping_replace_mask,
16446 (void *)&cmd_ptype_mapping_replace_pkt_type,
16451 /* ptype mapping reset */
16453 /* Common result structure for ptype mapping reset */
16454 struct cmd_ptype_mapping_reset_result {
16455 cmdline_fixed_string_t ptype;
16456 cmdline_fixed_string_t mapping;
16457 cmdline_fixed_string_t reset;
16461 /* Common CLI fields for ptype mapping reset*/
16462 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16463 TOKEN_STRING_INITIALIZER
16464 (struct cmd_ptype_mapping_reset_result,
16466 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16467 TOKEN_STRING_INITIALIZER
16468 (struct cmd_ptype_mapping_reset_result,
16469 mapping, "mapping");
16470 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16471 TOKEN_STRING_INITIALIZER
16472 (struct cmd_ptype_mapping_reset_result,
16474 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16475 TOKEN_NUM_INITIALIZER
16476 (struct cmd_ptype_mapping_reset_result,
16480 cmd_ptype_mapping_reset_parsed(
16481 void *parsed_result,
16482 __attribute__((unused)) struct cmdline *cl,
16483 __attribute__((unused)) void *data)
16485 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16486 int ret = -ENOTSUP;
16488 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16491 #ifdef RTE_LIBRTE_I40E_PMD
16492 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16499 printf("invalid port_id %d\n", res->port_id);
16502 printf("function not implemented\n");
16505 printf("programming error: (%s)\n", strerror(-ret));
16509 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16510 .f = cmd_ptype_mapping_reset_parsed,
16512 .help_str = "ptype mapping reset <port_id>",
16514 (void *)&cmd_ptype_mapping_reset_ptype,
16515 (void *)&cmd_ptype_mapping_reset_mapping,
16516 (void *)&cmd_ptype_mapping_reset_reset,
16517 (void *)&cmd_ptype_mapping_reset_port_id,
16522 /* ptype mapping update */
16524 /* Common result structure for ptype mapping update */
16525 struct cmd_ptype_mapping_update_result {
16526 cmdline_fixed_string_t ptype;
16527 cmdline_fixed_string_t mapping;
16528 cmdline_fixed_string_t reset;
16534 /* Common CLI fields for ptype mapping update*/
16535 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16536 TOKEN_STRING_INITIALIZER
16537 (struct cmd_ptype_mapping_update_result,
16539 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16540 TOKEN_STRING_INITIALIZER
16541 (struct cmd_ptype_mapping_update_result,
16542 mapping, "mapping");
16543 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16544 TOKEN_STRING_INITIALIZER
16545 (struct cmd_ptype_mapping_update_result,
16547 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16548 TOKEN_NUM_INITIALIZER
16549 (struct cmd_ptype_mapping_update_result,
16551 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16552 TOKEN_NUM_INITIALIZER
16553 (struct cmd_ptype_mapping_update_result,
16555 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16556 TOKEN_NUM_INITIALIZER
16557 (struct cmd_ptype_mapping_update_result,
16561 cmd_ptype_mapping_update_parsed(
16562 void *parsed_result,
16563 __attribute__((unused)) struct cmdline *cl,
16564 __attribute__((unused)) void *data)
16566 struct cmd_ptype_mapping_update_result *res = parsed_result;
16567 int ret = -ENOTSUP;
16568 #ifdef RTE_LIBRTE_I40E_PMD
16569 struct rte_pmd_i40e_ptype_mapping mapping;
16571 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16574 #ifdef RTE_LIBRTE_I40E_PMD
16575 mapping.hw_ptype = res->hw_ptype;
16576 mapping.sw_ptype = res->sw_ptype;
16577 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16587 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16590 printf("invalid port_id %d\n", res->port_id);
16593 printf("function not implemented\n");
16596 printf("programming error: (%s)\n", strerror(-ret));
16600 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16601 .f = cmd_ptype_mapping_update_parsed,
16603 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16605 (void *)&cmd_ptype_mapping_update_ptype,
16606 (void *)&cmd_ptype_mapping_update_mapping,
16607 (void *)&cmd_ptype_mapping_update_update,
16608 (void *)&cmd_ptype_mapping_update_port_id,
16609 (void *)&cmd_ptype_mapping_update_hw_ptype,
16610 (void *)&cmd_ptype_mapping_update_sw_ptype,
16615 /* Common result structure for file commands */
16616 struct cmd_cmdfile_result {
16617 cmdline_fixed_string_t load;
16618 cmdline_fixed_string_t filename;
16621 /* Common CLI fields for file commands */
16622 cmdline_parse_token_string_t cmd_load_cmdfile =
16623 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16624 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16625 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16628 cmd_load_from_file_parsed(
16629 void *parsed_result,
16630 __attribute__((unused)) struct cmdline *cl,
16631 __attribute__((unused)) void *data)
16633 struct cmd_cmdfile_result *res = parsed_result;
16635 cmdline_read_from_file(res->filename);
16638 cmdline_parse_inst_t cmd_load_from_file = {
16639 .f = cmd_load_from_file_parsed,
16641 .help_str = "load <filename>",
16643 (void *)&cmd_load_cmdfile,
16644 (void *)&cmd_load_cmdfile_filename,
16649 /* Get Rx offloads capabilities */
16650 struct cmd_rx_offload_get_capa_result {
16651 cmdline_fixed_string_t show;
16652 cmdline_fixed_string_t port;
16654 cmdline_fixed_string_t rx_offload;
16655 cmdline_fixed_string_t capabilities;
16658 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16659 TOKEN_STRING_INITIALIZER
16660 (struct cmd_rx_offload_get_capa_result,
16662 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16663 TOKEN_STRING_INITIALIZER
16664 (struct cmd_rx_offload_get_capa_result,
16666 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16667 TOKEN_NUM_INITIALIZER
16668 (struct cmd_rx_offload_get_capa_result,
16670 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16671 TOKEN_STRING_INITIALIZER
16672 (struct cmd_rx_offload_get_capa_result,
16673 rx_offload, "rx_offload");
16674 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16675 TOKEN_STRING_INITIALIZER
16676 (struct cmd_rx_offload_get_capa_result,
16677 capabilities, "capabilities");
16680 print_rx_offloads(uint64_t offloads)
16682 uint64_t single_offload;
16690 begin = __builtin_ctzll(offloads);
16691 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16693 single_offload = 1 << begin;
16694 for (bit = begin; bit < end; bit++) {
16695 if (offloads & single_offload)
16697 rte_eth_dev_rx_offload_name(single_offload));
16698 single_offload <<= 1;
16703 cmd_rx_offload_get_capa_parsed(
16704 void *parsed_result,
16705 __attribute__((unused)) struct cmdline *cl,
16706 __attribute__((unused)) void *data)
16708 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16709 struct rte_eth_dev_info dev_info;
16710 portid_t port_id = res->port_id;
16711 uint64_t queue_offloads;
16712 uint64_t port_offloads;
16714 rte_eth_dev_info_get(port_id, &dev_info);
16715 queue_offloads = dev_info.rx_queue_offload_capa;
16716 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16718 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16719 printf(" Per Queue :");
16720 print_rx_offloads(queue_offloads);
16723 printf(" Per Port :");
16724 print_rx_offloads(port_offloads);
16728 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16729 .f = cmd_rx_offload_get_capa_parsed,
16731 .help_str = "show port <port_id> rx_offload capabilities",
16733 (void *)&cmd_rx_offload_get_capa_show,
16734 (void *)&cmd_rx_offload_get_capa_port,
16735 (void *)&cmd_rx_offload_get_capa_port_id,
16736 (void *)&cmd_rx_offload_get_capa_rx_offload,
16737 (void *)&cmd_rx_offload_get_capa_capabilities,
16742 /* Get Rx offloads configuration */
16743 struct cmd_rx_offload_get_configuration_result {
16744 cmdline_fixed_string_t show;
16745 cmdline_fixed_string_t port;
16747 cmdline_fixed_string_t rx_offload;
16748 cmdline_fixed_string_t configuration;
16751 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16752 TOKEN_STRING_INITIALIZER
16753 (struct cmd_rx_offload_get_configuration_result,
16755 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16756 TOKEN_STRING_INITIALIZER
16757 (struct cmd_rx_offload_get_configuration_result,
16759 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16760 TOKEN_NUM_INITIALIZER
16761 (struct cmd_rx_offload_get_configuration_result,
16763 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16764 TOKEN_STRING_INITIALIZER
16765 (struct cmd_rx_offload_get_configuration_result,
16766 rx_offload, "rx_offload");
16767 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16768 TOKEN_STRING_INITIALIZER
16769 (struct cmd_rx_offload_get_configuration_result,
16770 configuration, "configuration");
16773 cmd_rx_offload_get_configuration_parsed(
16774 void *parsed_result,
16775 __attribute__((unused)) struct cmdline *cl,
16776 __attribute__((unused)) void *data)
16778 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16779 struct rte_eth_dev_info dev_info;
16780 portid_t port_id = res->port_id;
16781 struct rte_port *port = &ports[port_id];
16782 uint64_t port_offloads;
16783 uint64_t queue_offloads;
16784 uint16_t nb_rx_queues;
16787 printf("Rx Offloading Configuration of port %d :\n", port_id);
16789 port_offloads = port->dev_conf.rxmode.offloads;
16791 print_rx_offloads(port_offloads);
16794 rte_eth_dev_info_get(port_id, &dev_info);
16795 nb_rx_queues = dev_info.nb_rx_queues;
16796 for (q = 0; q < nb_rx_queues; q++) {
16797 queue_offloads = port->rx_conf[q].offloads;
16798 printf(" Queue[%2d] :", q);
16799 print_rx_offloads(queue_offloads);
16805 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16806 .f = cmd_rx_offload_get_configuration_parsed,
16808 .help_str = "show port <port_id> rx_offload configuration",
16810 (void *)&cmd_rx_offload_get_configuration_show,
16811 (void *)&cmd_rx_offload_get_configuration_port,
16812 (void *)&cmd_rx_offload_get_configuration_port_id,
16813 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16814 (void *)&cmd_rx_offload_get_configuration_configuration,
16819 /* Enable/Disable a per port offloading */
16820 struct cmd_config_per_port_rx_offload_result {
16821 cmdline_fixed_string_t port;
16822 cmdline_fixed_string_t config;
16824 cmdline_fixed_string_t rx_offload;
16825 cmdline_fixed_string_t offload;
16826 cmdline_fixed_string_t on_off;
16829 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16830 TOKEN_STRING_INITIALIZER
16831 (struct cmd_config_per_port_rx_offload_result,
16833 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16834 TOKEN_STRING_INITIALIZER
16835 (struct cmd_config_per_port_rx_offload_result,
16837 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16838 TOKEN_NUM_INITIALIZER
16839 (struct cmd_config_per_port_rx_offload_result,
16841 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16842 TOKEN_STRING_INITIALIZER
16843 (struct cmd_config_per_port_rx_offload_result,
16844 rx_offload, "rx_offload");
16845 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16846 TOKEN_STRING_INITIALIZER
16847 (struct cmd_config_per_port_rx_offload_result,
16848 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16849 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16850 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16851 "crc_strip#scatter#timestamp#security");
16852 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16853 TOKEN_STRING_INITIALIZER
16854 (struct cmd_config_per_port_rx_offload_result,
16858 search_rx_offload(const char *name)
16860 uint64_t single_offload;
16861 const char *single_name;
16865 single_offload = 1;
16866 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16867 single_name = rte_eth_dev_rx_offload_name(single_offload);
16868 if (!strcasecmp(single_name, name)) {
16871 } else if (!strcasecmp(single_name, "UNKNOWN"))
16873 else if (single_name == NULL)
16875 single_offload <<= 1;
16879 return single_offload;
16885 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16886 __attribute__((unused)) struct cmdline *cl,
16887 __attribute__((unused)) void *data)
16889 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16890 portid_t port_id = res->port_id;
16891 struct rte_eth_dev_info dev_info;
16892 struct rte_port *port = &ports[port_id];
16893 uint64_t single_offload;
16894 uint16_t nb_rx_queues;
16897 if (port->port_status != RTE_PORT_STOPPED) {
16898 printf("Error: Can't config offload when Port %d "
16899 "is not stopped\n", port_id);
16903 single_offload = search_rx_offload(res->offload);
16904 if (single_offload == 0) {
16905 printf("Unknown offload name: %s\n", res->offload);
16909 rte_eth_dev_info_get(port_id, &dev_info);
16910 nb_rx_queues = dev_info.nb_rx_queues;
16911 if (!strcmp(res->on_off, "on")) {
16912 port->dev_conf.rxmode.offloads |= single_offload;
16913 for (q = 0; q < nb_rx_queues; q++)
16914 port->rx_conf[q].offloads |= single_offload;
16916 port->dev_conf.rxmode.offloads &= ~single_offload;
16917 for (q = 0; q < nb_rx_queues; q++)
16918 port->rx_conf[q].offloads &= ~single_offload;
16921 cmd_reconfig_device_queue(port_id, 1, 1);
16924 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16925 .f = cmd_config_per_port_rx_offload_parsed,
16927 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16928 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16929 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16930 "jumbo_frame|crc_strip|scatter|timestamp|security "
16933 (void *)&cmd_config_per_port_rx_offload_result_port,
16934 (void *)&cmd_config_per_port_rx_offload_result_config,
16935 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16936 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16937 (void *)&cmd_config_per_port_rx_offload_result_offload,
16938 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16943 /* Enable/Disable a per queue offloading */
16944 struct cmd_config_per_queue_rx_offload_result {
16945 cmdline_fixed_string_t port;
16947 cmdline_fixed_string_t rxq;
16949 cmdline_fixed_string_t rx_offload;
16950 cmdline_fixed_string_t offload;
16951 cmdline_fixed_string_t on_off;
16954 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16955 TOKEN_STRING_INITIALIZER
16956 (struct cmd_config_per_queue_rx_offload_result,
16958 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16959 TOKEN_NUM_INITIALIZER
16960 (struct cmd_config_per_queue_rx_offload_result,
16962 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16963 TOKEN_STRING_INITIALIZER
16964 (struct cmd_config_per_queue_rx_offload_result,
16966 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16967 TOKEN_NUM_INITIALIZER
16968 (struct cmd_config_per_queue_rx_offload_result,
16970 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16971 TOKEN_STRING_INITIALIZER
16972 (struct cmd_config_per_queue_rx_offload_result,
16973 rx_offload, "rx_offload");
16974 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16975 TOKEN_STRING_INITIALIZER
16976 (struct cmd_config_per_queue_rx_offload_result,
16977 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16978 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16979 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16980 "crc_strip#scatter#timestamp#security");
16981 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16982 TOKEN_STRING_INITIALIZER
16983 (struct cmd_config_per_queue_rx_offload_result,
16987 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16988 __attribute__((unused)) struct cmdline *cl,
16989 __attribute__((unused)) void *data)
16991 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16992 struct rte_eth_dev_info dev_info;
16993 portid_t port_id = res->port_id;
16994 uint16_t queue_id = res->queue_id;
16995 struct rte_port *port = &ports[port_id];
16996 uint64_t single_offload;
16998 if (port->port_status != RTE_PORT_STOPPED) {
16999 printf("Error: Can't config offload when Port %d "
17000 "is not stopped\n", port_id);
17004 rte_eth_dev_info_get(port_id, &dev_info);
17005 if (queue_id >= dev_info.nb_rx_queues) {
17006 printf("Error: input queue_id should be 0 ... "
17007 "%d\n", dev_info.nb_rx_queues - 1);
17011 single_offload = search_rx_offload(res->offload);
17012 if (single_offload == 0) {
17013 printf("Unknown offload name: %s\n", res->offload);
17017 if (!strcmp(res->on_off, "on"))
17018 port->rx_conf[queue_id].offloads |= single_offload;
17020 port->rx_conf[queue_id].offloads &= ~single_offload;
17022 cmd_reconfig_device_queue(port_id, 1, 1);
17025 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17026 .f = cmd_config_per_queue_rx_offload_parsed,
17028 .help_str = "port <port_id> rxq <queue_id> rx_offload "
17029 "vlan_strip|ipv4_cksum|"
17030 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17031 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17032 "jumbo_frame|crc_strip|scatter|timestamp|security "
17035 (void *)&cmd_config_per_queue_rx_offload_result_port,
17036 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
17037 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
17038 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
17039 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
17040 (void *)&cmd_config_per_queue_rx_offload_result_offload,
17041 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
17046 /* Get Tx offloads capabilities */
17047 struct cmd_tx_offload_get_capa_result {
17048 cmdline_fixed_string_t show;
17049 cmdline_fixed_string_t port;
17051 cmdline_fixed_string_t tx_offload;
17052 cmdline_fixed_string_t capabilities;
17055 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17056 TOKEN_STRING_INITIALIZER
17057 (struct cmd_tx_offload_get_capa_result,
17059 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17060 TOKEN_STRING_INITIALIZER
17061 (struct cmd_tx_offload_get_capa_result,
17063 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
17064 TOKEN_NUM_INITIALIZER
17065 (struct cmd_tx_offload_get_capa_result,
17067 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
17068 TOKEN_STRING_INITIALIZER
17069 (struct cmd_tx_offload_get_capa_result,
17070 tx_offload, "tx_offload");
17071 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
17072 TOKEN_STRING_INITIALIZER
17073 (struct cmd_tx_offload_get_capa_result,
17074 capabilities, "capabilities");
17077 print_tx_offloads(uint64_t offloads)
17079 uint64_t single_offload;
17087 begin = __builtin_ctzll(offloads);
17088 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17090 single_offload = 1 << begin;
17091 for (bit = begin; bit < end; bit++) {
17092 if (offloads & single_offload)
17094 rte_eth_dev_tx_offload_name(single_offload));
17095 single_offload <<= 1;
17100 cmd_tx_offload_get_capa_parsed(
17101 void *parsed_result,
17102 __attribute__((unused)) struct cmdline *cl,
17103 __attribute__((unused)) void *data)
17105 struct cmd_tx_offload_get_capa_result *res = parsed_result;
17106 struct rte_eth_dev_info dev_info;
17107 portid_t port_id = res->port_id;
17108 uint64_t queue_offloads;
17109 uint64_t port_offloads;
17111 rte_eth_dev_info_get(port_id, &dev_info);
17112 queue_offloads = dev_info.tx_queue_offload_capa;
17113 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
17115 printf("Tx Offloading Capabilities of port %d :\n", port_id);
17116 printf(" Per Queue :");
17117 print_tx_offloads(queue_offloads);
17120 printf(" Per Port :");
17121 print_tx_offloads(port_offloads);
17125 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
17126 .f = cmd_tx_offload_get_capa_parsed,
17128 .help_str = "show port <port_id> tx_offload capabilities",
17130 (void *)&cmd_tx_offload_get_capa_show,
17131 (void *)&cmd_tx_offload_get_capa_port,
17132 (void *)&cmd_tx_offload_get_capa_port_id,
17133 (void *)&cmd_tx_offload_get_capa_tx_offload,
17134 (void *)&cmd_tx_offload_get_capa_capabilities,
17139 /* Get Tx offloads configuration */
17140 struct cmd_tx_offload_get_configuration_result {
17141 cmdline_fixed_string_t show;
17142 cmdline_fixed_string_t port;
17144 cmdline_fixed_string_t tx_offload;
17145 cmdline_fixed_string_t configuration;
17148 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
17149 TOKEN_STRING_INITIALIZER
17150 (struct cmd_tx_offload_get_configuration_result,
17152 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
17153 TOKEN_STRING_INITIALIZER
17154 (struct cmd_tx_offload_get_configuration_result,
17156 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
17157 TOKEN_NUM_INITIALIZER
17158 (struct cmd_tx_offload_get_configuration_result,
17160 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
17161 TOKEN_STRING_INITIALIZER
17162 (struct cmd_tx_offload_get_configuration_result,
17163 tx_offload, "tx_offload");
17164 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
17165 TOKEN_STRING_INITIALIZER
17166 (struct cmd_tx_offload_get_configuration_result,
17167 configuration, "configuration");
17170 cmd_tx_offload_get_configuration_parsed(
17171 void *parsed_result,
17172 __attribute__((unused)) struct cmdline *cl,
17173 __attribute__((unused)) void *data)
17175 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
17176 struct rte_eth_dev_info dev_info;
17177 portid_t port_id = res->port_id;
17178 struct rte_port *port = &ports[port_id];
17179 uint64_t port_offloads;
17180 uint64_t queue_offloads;
17181 uint16_t nb_tx_queues;
17184 printf("Tx Offloading Configuration of port %d :\n", port_id);
17186 port_offloads = port->dev_conf.txmode.offloads;
17188 print_tx_offloads(port_offloads);
17191 rte_eth_dev_info_get(port_id, &dev_info);
17192 nb_tx_queues = dev_info.nb_tx_queues;
17193 for (q = 0; q < nb_tx_queues; q++) {
17194 queue_offloads = port->tx_conf[q].offloads;
17195 printf(" Queue[%2d] :", q);
17196 print_tx_offloads(queue_offloads);
17202 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17203 .f = cmd_tx_offload_get_configuration_parsed,
17205 .help_str = "show port <port_id> tx_offload configuration",
17207 (void *)&cmd_tx_offload_get_configuration_show,
17208 (void *)&cmd_tx_offload_get_configuration_port,
17209 (void *)&cmd_tx_offload_get_configuration_port_id,
17210 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17211 (void *)&cmd_tx_offload_get_configuration_configuration,
17216 /* Enable/Disable a per port offloading */
17217 struct cmd_config_per_port_tx_offload_result {
17218 cmdline_fixed_string_t port;
17219 cmdline_fixed_string_t config;
17221 cmdline_fixed_string_t tx_offload;
17222 cmdline_fixed_string_t offload;
17223 cmdline_fixed_string_t on_off;
17226 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17227 TOKEN_STRING_INITIALIZER
17228 (struct cmd_config_per_port_tx_offload_result,
17230 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17231 TOKEN_STRING_INITIALIZER
17232 (struct cmd_config_per_port_tx_offload_result,
17234 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17235 TOKEN_NUM_INITIALIZER
17236 (struct cmd_config_per_port_tx_offload_result,
17238 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17239 TOKEN_STRING_INITIALIZER
17240 (struct cmd_config_per_port_tx_offload_result,
17241 tx_offload, "tx_offload");
17242 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17243 TOKEN_STRING_INITIALIZER
17244 (struct cmd_config_per_port_tx_offload_result,
17245 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17246 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17247 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17248 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17249 "mt_lockfree#multi_segs#fast_free#security");
17250 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17251 TOKEN_STRING_INITIALIZER
17252 (struct cmd_config_per_port_tx_offload_result,
17256 search_tx_offload(const char *name)
17258 uint64_t single_offload;
17259 const char *single_name;
17263 single_offload = 1;
17264 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17265 single_name = rte_eth_dev_tx_offload_name(single_offload);
17266 if (!strcasecmp(single_name, name)) {
17269 } else if (!strcasecmp(single_name, "UNKNOWN"))
17271 else if (single_name == NULL)
17273 single_offload <<= 1;
17277 return single_offload;
17283 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17284 __attribute__((unused)) struct cmdline *cl,
17285 __attribute__((unused)) void *data)
17287 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17288 portid_t port_id = res->port_id;
17289 struct rte_eth_dev_info dev_info;
17290 struct rte_port *port = &ports[port_id];
17291 uint64_t single_offload;
17292 uint16_t nb_tx_queues;
17295 if (port->port_status != RTE_PORT_STOPPED) {
17296 printf("Error: Can't config offload when Port %d "
17297 "is not stopped\n", port_id);
17301 single_offload = search_tx_offload(res->offload);
17302 if (single_offload == 0) {
17303 printf("Unknown offload name: %s\n", res->offload);
17307 rte_eth_dev_info_get(port_id, &dev_info);
17308 nb_tx_queues = dev_info.nb_tx_queues;
17309 if (!strcmp(res->on_off, "on")) {
17310 port->dev_conf.txmode.offloads |= single_offload;
17311 for (q = 0; q < nb_tx_queues; q++)
17312 port->tx_conf[q].offloads |= single_offload;
17314 port->dev_conf.txmode.offloads &= ~single_offload;
17315 for (q = 0; q < nb_tx_queues; q++)
17316 port->tx_conf[q].offloads &= ~single_offload;
17319 cmd_reconfig_device_queue(port_id, 1, 1);
17322 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17323 .f = cmd_config_per_port_tx_offload_parsed,
17325 .help_str = "port config <port_id> tx_offload "
17326 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17327 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17328 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17329 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17330 "mt_lockfree|multi_segs|fast_free|security "
17333 (void *)&cmd_config_per_port_tx_offload_result_port,
17334 (void *)&cmd_config_per_port_tx_offload_result_config,
17335 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17336 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17337 (void *)&cmd_config_per_port_tx_offload_result_offload,
17338 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17343 /* Enable/Disable a per queue offloading */
17344 struct cmd_config_per_queue_tx_offload_result {
17345 cmdline_fixed_string_t port;
17347 cmdline_fixed_string_t txq;
17349 cmdline_fixed_string_t tx_offload;
17350 cmdline_fixed_string_t offload;
17351 cmdline_fixed_string_t on_off;
17354 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17355 TOKEN_STRING_INITIALIZER
17356 (struct cmd_config_per_queue_tx_offload_result,
17358 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17359 TOKEN_NUM_INITIALIZER
17360 (struct cmd_config_per_queue_tx_offload_result,
17362 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17363 TOKEN_STRING_INITIALIZER
17364 (struct cmd_config_per_queue_tx_offload_result,
17366 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17367 TOKEN_NUM_INITIALIZER
17368 (struct cmd_config_per_queue_tx_offload_result,
17370 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17371 TOKEN_STRING_INITIALIZER
17372 (struct cmd_config_per_queue_tx_offload_result,
17373 tx_offload, "tx_offload");
17374 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17375 TOKEN_STRING_INITIALIZER
17376 (struct cmd_config_per_queue_tx_offload_result,
17377 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17378 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17379 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17380 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17381 "mt_lockfree#multi_segs#fast_free#security");
17382 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17383 TOKEN_STRING_INITIALIZER
17384 (struct cmd_config_per_queue_tx_offload_result,
17388 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17389 __attribute__((unused)) struct cmdline *cl,
17390 __attribute__((unused)) void *data)
17392 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17393 struct rte_eth_dev_info dev_info;
17394 portid_t port_id = res->port_id;
17395 uint16_t queue_id = res->queue_id;
17396 struct rte_port *port = &ports[port_id];
17397 uint64_t single_offload;
17399 if (port->port_status != RTE_PORT_STOPPED) {
17400 printf("Error: Can't config offload when Port %d "
17401 "is not stopped\n", port_id);
17405 rte_eth_dev_info_get(port_id, &dev_info);
17406 if (queue_id >= dev_info.nb_tx_queues) {
17407 printf("Error: input queue_id should be 0 ... "
17408 "%d\n", dev_info.nb_tx_queues - 1);
17412 single_offload = search_tx_offload(res->offload);
17413 if (single_offload == 0) {
17414 printf("Unknown offload name: %s\n", res->offload);
17418 if (!strcmp(res->on_off, "on"))
17419 port->tx_conf[queue_id].offloads |= single_offload;
17421 port->tx_conf[queue_id].offloads &= ~single_offload;
17423 cmd_reconfig_device_queue(port_id, 1, 1);
17426 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17427 .f = cmd_config_per_queue_tx_offload_parsed,
17429 .help_str = "port <port_id> txq <queue_id> tx_offload "
17430 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17431 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17432 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17433 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17434 "mt_lockfree|multi_segs|fast_free|security "
17437 (void *)&cmd_config_per_queue_tx_offload_result_port,
17438 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17439 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17440 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17441 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17442 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17443 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17448 /* ******************************************************************************** */
17450 /* list of instructions */
17451 cmdline_parse_ctx_t main_ctx[] = {
17452 (cmdline_parse_inst_t *)&cmd_help_brief,
17453 (cmdline_parse_inst_t *)&cmd_help_long,
17454 (cmdline_parse_inst_t *)&cmd_quit,
17455 (cmdline_parse_inst_t *)&cmd_load_from_file,
17456 (cmdline_parse_inst_t *)&cmd_showport,
17457 (cmdline_parse_inst_t *)&cmd_showqueue,
17458 (cmdline_parse_inst_t *)&cmd_showportall,
17459 (cmdline_parse_inst_t *)&cmd_showcfg,
17460 (cmdline_parse_inst_t *)&cmd_start,
17461 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17462 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17463 (cmdline_parse_inst_t *)&cmd_set_link_up,
17464 (cmdline_parse_inst_t *)&cmd_set_link_down,
17465 (cmdline_parse_inst_t *)&cmd_reset,
17466 (cmdline_parse_inst_t *)&cmd_set_numbers,
17467 (cmdline_parse_inst_t *)&cmd_set_log,
17468 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17469 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17470 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17471 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17472 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17473 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17474 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17475 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17476 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17477 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17478 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17479 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17480 (cmdline_parse_inst_t *)&cmd_set_link_check,
17481 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17482 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17483 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17484 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17485 #ifdef RTE_LIBRTE_PMD_BOND
17486 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17487 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17488 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17489 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17490 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17491 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17492 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17493 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17494 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17495 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17496 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17498 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17499 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17500 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17501 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17502 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17503 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17504 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17505 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17506 (cmdline_parse_inst_t *)&cmd_csum_set,
17507 (cmdline_parse_inst_t *)&cmd_csum_show,
17508 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17509 (cmdline_parse_inst_t *)&cmd_tso_set,
17510 (cmdline_parse_inst_t *)&cmd_tso_show,
17511 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17512 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17513 (cmdline_parse_inst_t *)&cmd_gro_enable,
17514 (cmdline_parse_inst_t *)&cmd_gro_flush,
17515 (cmdline_parse_inst_t *)&cmd_gro_show,
17516 (cmdline_parse_inst_t *)&cmd_gso_enable,
17517 (cmdline_parse_inst_t *)&cmd_gso_size,
17518 (cmdline_parse_inst_t *)&cmd_gso_show,
17519 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17520 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17521 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17522 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17523 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17524 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17525 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17526 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17527 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17528 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17529 (cmdline_parse_inst_t *)&cmd_config_dcb,
17530 (cmdline_parse_inst_t *)&cmd_read_reg,
17531 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17532 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17533 (cmdline_parse_inst_t *)&cmd_write_reg,
17534 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17535 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17536 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17537 (cmdline_parse_inst_t *)&cmd_stop,
17538 (cmdline_parse_inst_t *)&cmd_mac_addr,
17539 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17540 (cmdline_parse_inst_t *)&cmd_set_qmap,
17541 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17542 (cmdline_parse_inst_t *)&cmd_operate_port,
17543 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17544 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17545 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17546 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17547 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17548 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17549 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17550 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17551 (cmdline_parse_inst_t *)&cmd_config_mtu,
17552 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17553 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17554 (cmdline_parse_inst_t *)&cmd_config_rss,
17555 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17556 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17557 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17558 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17559 (cmdline_parse_inst_t *)&cmd_showport_reta,
17560 (cmdline_parse_inst_t *)&cmd_config_burst,
17561 (cmdline_parse_inst_t *)&cmd_config_thresh,
17562 (cmdline_parse_inst_t *)&cmd_config_threshold,
17563 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17564 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17565 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17566 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
17567 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17568 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
17569 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17570 (cmdline_parse_inst_t *)&cmd_global_config,
17571 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17572 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17573 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17574 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17575 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17576 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17577 (cmdline_parse_inst_t *)&cmd_dump,
17578 (cmdline_parse_inst_t *)&cmd_dump_one,
17579 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
17580 (cmdline_parse_inst_t *)&cmd_syn_filter,
17581 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
17582 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
17583 (cmdline_parse_inst_t *)&cmd_flex_filter,
17584 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
17585 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
17586 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
17587 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
17588 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
17589 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
17590 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17591 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
17592 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17593 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17594 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17595 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
17596 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17597 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
17598 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
17599 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
17600 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
17601 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
17602 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
17603 (cmdline_parse_inst_t *)&cmd_flow,
17604 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17605 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17606 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17607 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17608 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17609 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17610 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17611 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17612 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17613 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17614 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17615 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17616 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17617 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17618 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
17619 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
17620 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
17621 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
17622 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
17623 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
17624 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
17625 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
17626 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
17627 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
17628 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17629 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17630 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17631 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17632 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17633 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17634 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17635 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17636 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17637 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17638 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17639 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17640 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17641 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17642 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17643 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17644 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17645 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17646 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17647 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17648 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17649 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17650 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17651 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17652 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17653 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
17654 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
17656 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17657 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17658 (cmdline_parse_inst_t *)&cmd_ddp_add,
17659 (cmdline_parse_inst_t *)&cmd_ddp_del,
17660 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17661 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17662 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17663 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17664 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17665 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17666 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17667 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17668 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17669 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17671 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17672 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17673 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17674 (cmdline_parse_inst_t *)&cmd_queue_region,
17675 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17676 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17677 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17678 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17679 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17680 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17681 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17682 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17683 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17684 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17685 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17686 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17687 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17688 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17689 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17690 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17691 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17692 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17693 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17694 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17695 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17696 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17697 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17698 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17699 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17700 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17701 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17702 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17703 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17704 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17705 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17706 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17707 #ifdef RTE_LIBRTE_BPF
17708 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17709 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17714 /* read cmdline commands from file */
17716 cmdline_read_from_file(const char *filename)
17718 struct cmdline *cl;
17720 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17722 printf("Failed to create file based cmdline context: %s\n",
17727 cmdline_interact(cl);
17732 printf("Read CLI commands from %s\n", filename);
17735 /* prompt function, called from main on MASTER lcore */
17741 /* initialize non-constant commands */
17742 cmd_set_fwd_mode_init();
17743 cmd_set_fwd_retry_mode_init();
17745 #if defined RTE_LIBRTE_PMD_SOFTNIC
17746 portid_t softnic_portid, pid;
17747 uint8_t softnic_enable = 0;
17749 if (strcmp(cur_fwd_eng->fwd_mode_name, "softnic") == 0) {
17750 RTE_ETH_FOREACH_DEV(pid) {
17751 struct rte_port *port = &ports[pid];
17752 const char *driver = port->dev_info.driver_name;
17754 if (strcmp(driver, "net_softnic") == 0) {
17755 softnic_portid = pid;
17756 softnic_enable = 1;
17763 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17764 if (testpmd_cl == NULL)
17768 status = cmdline_poll(testpmd_cl);
17770 rte_panic("CLI poll error (%" PRId32 ")\n", status);
17771 else if (status == RDLINE_EXITED) {
17772 cmdline_stdin_exit(testpmd_cl);
17776 #if defined RTE_LIBRTE_PMD_SOFTNIC
17778 if ((softnic_enable == 1) &&
17779 (strcmp(cur_fwd_eng->fwd_mode_name, "softnic") == 0))
17780 rte_pmd_softnic_manage(softnic_portid);
17788 if (testpmd_cl != NULL)
17789 cmdline_quit(testpmd_cl);
17793 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17795 if (id == (portid_t)RTE_PORT_ALL) {
17798 RTE_ETH_FOREACH_DEV(pid) {
17799 /* check if need_reconfig has been set to 1 */
17800 if (ports[pid].need_reconfig == 0)
17801 ports[pid].need_reconfig = dev;
17802 /* check if need_reconfig_queues has been set to 1 */
17803 if (ports[pid].need_reconfig_queues == 0)
17804 ports[pid].need_reconfig_queues = queue;
17806 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17807 /* check if need_reconfig has been set to 1 */
17808 if (ports[id].need_reconfig == 0)
17809 ports[id].need_reconfig = dev;
17810 /* check if need_reconfig_queues has been set to 1 */
17811 if (ports[id].need_reconfig_queues == 0)
17812 ports[id].need_reconfig_queues = queue;