1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
15 #include <sys/socket.h>
17 #include <netinet/in.h>
19 #include <sys/queue.h>
21 #include <rte_common.h>
22 #include <rte_byteorder.h>
24 #include <rte_debug.h>
25 #include <rte_cycles.h>
26 #include <rte_memory.h>
27 #include <rte_memzone.h>
28 #include <rte_malloc.h>
29 #include <rte_launch.h>
31 #include <rte_per_lcore.h>
32 #include <rte_lcore.h>
33 #include <rte_atomic.h>
34 #include <rte_branch_prediction.h>
36 #include <rte_mempool.h>
37 #include <rte_interrupts.h>
39 #include <rte_ether.h>
40 #include <rte_ethdev.h>
41 #include <rte_string_fns.h>
42 #include <rte_devargs.h>
46 #include <cmdline_rdline.h>
47 #include <cmdline_parse.h>
48 #include <cmdline_parse_num.h>
49 #include <cmdline_parse_string.h>
50 #include <cmdline_parse_ipaddr.h>
51 #include <cmdline_parse_etheraddr.h>
52 #include <cmdline_socket.h>
54 #ifdef RTE_LIBRTE_PMD_BOND
55 #include <rte_eth_bond.h>
56 #include <rte_eth_bond_8023ad.h>
58 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
59 #include <rte_pmd_dpaa.h>
61 #ifdef RTE_LIBRTE_IXGBE_PMD
62 #include <rte_pmd_ixgbe.h>
64 #ifdef RTE_LIBRTE_I40E_PMD
65 #include <rte_pmd_i40e.h>
67 #ifdef RTE_LIBRTE_BNXT_PMD
68 #include <rte_pmd_bnxt.h>
71 #include "cmdline_mtr.h"
72 #include "cmdline_tm.h"
75 static struct cmdline *testpmd_cl;
77 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
79 /* *** Help command with introduction. *** */
80 struct cmd_help_brief_result {
81 cmdline_fixed_string_t help;
84 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
86 __attribute__((unused)) void *data)
91 "Help is available for the following sections:\n\n"
92 " help control : Start and stop forwarding.\n"
93 " help display : Displaying port, stats and config "
95 " help config : Configuration information.\n"
96 " help ports : Configuring ports.\n"
97 " help registers : Reading and setting port registers.\n"
98 " help filters : Filters configuration help.\n"
99 " help traffic_management : Traffic Management commmands.\n"
100 " help devices : Device related cmds.\n"
101 " help all : All of the above sections.\n\n"
106 cmdline_parse_token_string_t cmd_help_brief_help =
107 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
109 cmdline_parse_inst_t cmd_help_brief = {
110 .f = cmd_help_brief_parsed,
112 .help_str = "help: Show help",
114 (void *)&cmd_help_brief_help,
119 /* *** Help command with help sections. *** */
120 struct cmd_help_long_result {
121 cmdline_fixed_string_t help;
122 cmdline_fixed_string_t section;
125 static void cmd_help_long_parsed(void *parsed_result,
127 __attribute__((unused)) void *data)
130 struct cmd_help_long_result *res = parsed_result;
132 if (!strcmp(res->section, "all"))
135 if (show_all || !strcmp(res->section, "control")) {
140 "Control forwarding:\n"
141 "-------------------\n\n"
144 " Start packet forwarding with current configuration.\n\n"
147 " Start packet forwarding with current config"
148 " after sending one burst of packets.\n\n"
151 " Stop packet forwarding, and display accumulated"
155 " Quit to prompt.\n\n"
159 if (show_all || !strcmp(res->section, "display")) {
167 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
168 " Display information for port_id, or all.\n\n"
170 "show port X rss reta (size) (mask0,mask1,...)\n"
171 " Display the rss redirection table entry indicated"
172 " by masks on port X. size is used to indicate the"
173 " hardware supported reta size\n\n"
175 "show port (port_id) rss-hash [key]\n"
176 " Display the RSS hash functions and RSS hash key of port\n\n"
178 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
179 " Clear information for port_id, or all.\n\n"
181 "show (rxq|txq) info (port_id) (queue_id)\n"
182 " Display information for configured RX/TX queue.\n\n"
184 "show config (rxtx|cores|fwd|txpkts)\n"
185 " Display the given configuration.\n\n"
187 "read rxd (port_id) (queue_id) (rxd_id)\n"
188 " Display an RX descriptor of a port RX queue.\n\n"
190 "read txd (port_id) (queue_id) (txd_id)\n"
191 " Display a TX descriptor of a port TX queue.\n\n"
193 "ddp get list (port_id)\n"
194 " Get ddp profile info list\n\n"
196 "ddp get info (profile_path)\n"
197 " Get ddp profile information.\n\n"
199 "show vf stats (port_id) (vf_id)\n"
200 " Display a VF's statistics.\n\n"
202 "clear vf stats (port_id) (vf_id)\n"
203 " Reset a VF's statistics.\n\n"
205 "show port (port_id) pctype mapping\n"
206 " Get flow ptype to pctype mapping on a port\n\n"
208 "show port meter stats (port_id) (meter_id) (clear)\n"
209 " Get meter stats on a port\n\n"
211 "show fwd stats all\n"
212 " Display statistics for all fwd engines.\n\n"
214 "clear fwd stats all\n"
215 " Clear statistics for all fwd engines.\n\n"
217 "show port (port_id) rx_offload capabilities\n"
218 " List all per queue and per port Rx offloading"
219 " capabilities of a port\n\n"
221 "show port (port_id) rx_offload configuration\n"
222 " List port level and all queue level"
223 " Rx offloading configuration\n\n"
225 "show port (port_id) tx_offload capabilities\n"
226 " List all per queue and per port"
227 " Tx offloading capabilities of a port\n\n"
229 "show port (port_id) tx_offload configuration\n"
230 " List port level and all queue level"
231 " Tx offloading configuration\n\n"
233 "show port (port_id) tx_metadata\n"
234 " Show Tx metadata value set"
235 " for a specific port\n\n"
237 "show port (port_id) ptypes\n"
238 " Show port supported ptypes"
239 " for a specific port\n\n"
241 "show device info (<identifier>|all)"
242 " Show general information about devices probed.\n\n"
246 if (show_all || !strcmp(res->section, "config")) {
252 "Configuration changes only become active when"
253 " forwarding is started/restarted.\n\n"
256 " Reset forwarding to the default configuration.\n\n"
258 "set verbose (level)\n"
259 " Set the debug verbosity level X.\n\n"
261 "set log global|(type) (level)\n"
262 " Set the log level.\n\n"
265 " Set number of ports.\n\n"
268 " Set number of cores.\n\n"
270 "set coremask (mask)\n"
271 " Set the forwarding cores hexadecimal mask.\n\n"
273 "set portmask (mask)\n"
274 " Set the forwarding ports hexadecimal mask.\n\n"
277 " Set number of packets per burst.\n\n"
279 "set burst tx delay (microseconds) retry (num)\n"
280 " Set the transmit delay time and number of retries,"
281 " effective when retry is enabled.\n\n"
283 "set txpkts (x[,y]*)\n"
284 " Set the length of each segment of TXONLY"
285 " and optionally CSUM packets.\n\n"
287 "set txsplit (off|on|rand)\n"
288 " Set the split policy for the TX packets."
289 " Right now only applicable for CSUM and TXONLY"
292 "set corelist (x[,y]*)\n"
293 " Set the list of forwarding cores.\n\n"
295 "set portlist (x[,y]*)\n"
296 " Set the list of forwarding ports.\n\n"
298 "set port setup on (iterator|event)\n"
299 " Select how attached port is retrieved for setup.\n\n"
301 "set tx loopback (port_id) (on|off)\n"
302 " Enable or disable tx loopback.\n\n"
304 "set all queues drop (port_id) (on|off)\n"
305 " Set drop enable bit for all queues.\n\n"
307 "set vf split drop (port_id) (vf_id) (on|off)\n"
308 " Set split drop enable bit for a VF from the PF.\n\n"
310 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
311 " Set MAC antispoof for a VF from the PF.\n\n"
313 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
314 " Enable MACsec offload.\n\n"
316 "set macsec offload (port_id) off\n"
317 " Disable MACsec offload.\n\n"
319 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
320 " Configure MACsec secure connection (SC).\n\n"
322 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
323 " Configure MACsec secure association (SA).\n\n"
325 "set vf broadcast (port_id) (vf_id) (on|off)\n"
326 " Set VF broadcast for a VF from the PF.\n\n"
328 "vlan set stripq (on|off) (port_id,queue_id)\n"
329 " Set the VLAN strip for a queue on a port.\n\n"
331 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
332 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
334 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
335 " Set VLAN insert for a VF from the PF.\n\n"
337 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
338 " Set VLAN antispoof for a VF from the PF.\n\n"
340 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
341 " Set VLAN tag for a VF from the PF.\n\n"
343 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
344 " Set a VF's max bandwidth(Mbps).\n\n"
346 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
347 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
349 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
350 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
352 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
353 " Set some TCs' strict link priority mode on a physical port.\n\n"
355 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
356 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
358 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
359 " Set the VLAN strip or filter or qinq strip or extend\n\n"
361 "vlan set (inner|outer) tpid (value) (port_id)\n"
362 " Set the VLAN TPID for Packet Filtering on"
365 "rx_vlan add (vlan_id|all) (port_id)\n"
366 " Add a vlan_id, or all identifiers, to the set"
367 " of VLAN identifiers filtered by port_id.\n\n"
369 "rx_vlan rm (vlan_id|all) (port_id)\n"
370 " Remove a vlan_id, or all identifiers, from the set"
371 " of VLAN identifiers filtered by port_id.\n\n"
373 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
374 " Add a vlan_id, to the set of VLAN identifiers"
375 "filtered for VF(s) from port_id.\n\n"
377 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
378 " Remove a vlan_id, to the set of VLAN identifiers"
379 "filtered for VF(s) from port_id.\n\n"
381 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
382 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
383 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
384 " add a tunnel filter of a port.\n\n"
386 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
387 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
388 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
389 " remove a tunnel filter of a port.\n\n"
391 "rx_vxlan_port add (udp_port) (port_id)\n"
392 " Add an UDP port for VXLAN packet filter on a port\n\n"
394 "rx_vxlan_port rm (udp_port) (port_id)\n"
395 " Remove an UDP port for VXLAN packet filter on a port\n\n"
397 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
398 " Set hardware insertion of VLAN IDs (single or double VLAN "
399 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
401 "tx_vlan set pvid port_id vlan_id (on|off)\n"
402 " Set port based TX VLAN insertion.\n\n"
404 "tx_vlan reset (port_id)\n"
405 " Disable hardware insertion of a VLAN header in"
406 " packets sent on a port.\n\n"
408 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
409 " Select hardware or software calculation of the"
410 " checksum when transmitting a packet using the"
411 " csum forward engine.\n"
412 " ip|udp|tcp|sctp always concern the inner layer.\n"
413 " outer-ip concerns the outer IP layer in"
414 " outer-udp concerns the outer UDP layer in"
415 " case the packet is recognized as a tunnel packet by"
416 " the forward engine (vxlan, gre and ipip are supported)\n"
417 " Please check the NIC datasheet for HW limits.\n\n"
419 "csum parse-tunnel (on|off) (tx_port_id)\n"
420 " If disabled, treat tunnel packets as non-tunneled"
421 " packets (treat inner headers as payload). The port\n"
422 " argument is the port used for TX in csum forward"
425 "csum show (port_id)\n"
426 " Display tx checksum offload configuration\n\n"
428 "tso set (segsize) (portid)\n"
429 " Enable TCP Segmentation Offload in csum forward"
431 " Please check the NIC datasheet for HW limits.\n\n"
434 " Display the status of TCP Segmentation Offload.\n\n"
436 "set port (port_id) gro on|off\n"
437 " Enable or disable Generic Receive Offload in"
438 " csum forwarding engine.\n\n"
440 "show port (port_id) gro\n"
441 " Display GRO configuration.\n\n"
443 "set gro flush (cycles)\n"
444 " Set the cycle to flush GROed packets from"
445 " reassembly tables.\n\n"
447 "set port (port_id) gso (on|off)"
448 " Enable or disable Generic Segmentation Offload in"
449 " csum forwarding engine.\n\n"
451 "set gso segsz (length)\n"
452 " Set max packet length for output GSO segments,"
453 " including packet header and payload.\n\n"
455 "show port (port_id) gso\n"
456 " Show GSO configuration.\n\n"
459 " Set packet forwarding mode.\n\n"
461 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
462 " Add a MAC address on port_id.\n\n"
464 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
465 " Remove a MAC address from port_id.\n\n"
467 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
468 " Set the default MAC address for port_id.\n\n"
470 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
471 " Add a MAC address for a VF on the port.\n\n"
473 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
474 " Set the MAC address for a VF from the PF.\n\n"
476 "set eth-peer (port_id) (peer_addr)\n"
477 " set the peer address for certain port.\n\n"
479 "set port (port_id) uta (mac_address|all) (on|off)\n"
480 " Add/Remove a or all unicast hash filter(s)"
483 "set promisc (port_id|all) (on|off)\n"
484 " Set the promiscuous mode on port_id, or all.\n\n"
486 "set allmulti (port_id|all) (on|off)\n"
487 " Set the allmulti mode on port_id, or all.\n\n"
489 "set vf promisc (port_id) (vf_id) (on|off)\n"
490 " Set unicast promiscuous mode for a VF from the PF.\n\n"
492 "set vf allmulti (port_id) (vf_id) (on|off)\n"
493 " Set multicast promiscuous mode for a VF from the PF.\n\n"
495 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
496 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
497 " (on|off) autoneg (on|off) (port_id)\n"
498 "set flow_ctrl rx (on|off) (portid)\n"
499 "set flow_ctrl tx (on|off) (portid)\n"
500 "set flow_ctrl high_water (high_water) (portid)\n"
501 "set flow_ctrl low_water (low_water) (portid)\n"
502 "set flow_ctrl pause_time (pause_time) (portid)\n"
503 "set flow_ctrl send_xon (send_xon) (portid)\n"
504 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
505 "set flow_ctrl autoneg (on|off) (port_id)\n"
506 " Set the link flow control parameter on a port.\n\n"
508 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
509 " (low_water) (pause_time) (priority) (port_id)\n"
510 " Set the priority flow control parameter on a"
513 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
514 " Set statistics mapping (qmapping 0..15) for RX/TX"
516 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
517 " on port 0 to mapping 5.\n\n"
519 "set xstats-hide-zero on|off\n"
520 " Set the option to hide the zero values"
521 " for xstats display.\n"
523 "set port (port_id) vf (vf_id) rx|tx on|off\n"
524 " Enable/Disable a VF receive/tranmit from a port\n\n"
526 "set port (port_id) vf (vf_id) (mac_addr)"
527 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
528 " Add/Remove unicast or multicast MAC addr filter"
531 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
533 " AUPE:accepts untagged VLAN;"
534 "ROPE:accept unicast hash\n\n"
535 " BAM:accepts broadcast packets;"
536 "MPE:accepts all multicast packets\n\n"
537 " Enable/Disable a VF receive mode of a port\n\n"
539 "set port (port_id) queue (queue_id) rate (rate_num)\n"
540 " Set rate limit for a queue of a port\n\n"
542 "set port (port_id) vf (vf_id) rate (rate_num) "
543 "queue_mask (queue_mask_value)\n"
544 " Set rate limit for queues in VF of a port\n\n"
546 "set port (port_id) mirror-rule (rule_id)"
547 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
548 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
549 " Set pool or vlan type mirror rule on a port.\n"
550 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
551 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
554 "set port (port_id) mirror-rule (rule_id)"
555 " (uplink-mirror|downlink-mirror) dst-pool"
556 " (pool_id) (on|off)\n"
557 " Set uplink or downlink type mirror rule on a port.\n"
558 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
559 " 0 on' enable mirror income traffic to pool 0.\n\n"
561 "reset port (port_id) mirror-rule (rule_id)\n"
562 " Reset a mirror rule.\n\n"
564 "set flush_rx (on|off)\n"
565 " Flush (default) or don't flush RX streams before"
566 " forwarding. Mainly used with PCAP drivers.\n\n"
568 "set bypass mode (normal|bypass|isolate) (port_id)\n"
569 " Set the bypass mode for the lowest port on bypass enabled"
572 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
573 "mode (normal|bypass|isolate) (port_id)\n"
574 " Set the event required to initiate specified bypass mode for"
575 " the lowest port on a bypass enabled NIC where:\n"
576 " timeout = enable bypass after watchdog timeout.\n"
577 " os_on = enable bypass when OS/board is powered on.\n"
578 " os_off = enable bypass when OS/board is powered off.\n"
579 " power_on = enable bypass when power supply is turned on.\n"
580 " power_off = enable bypass when power supply is turned off."
583 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
584 " Set the bypass watchdog timeout to 'n' seconds"
585 " where 0 = instant.\n\n"
587 "show bypass config (port_id)\n"
588 " Show the bypass configuration for a bypass enabled NIC"
589 " using the lowest port on the NIC.\n\n"
591 #ifdef RTE_LIBRTE_PMD_BOND
592 "create bonded device (mode) (socket)\n"
593 " Create a new bonded device with specific bonding mode and socket.\n\n"
595 "add bonding slave (slave_id) (port_id)\n"
596 " Add a slave device to a bonded device.\n\n"
598 "remove bonding slave (slave_id) (port_id)\n"
599 " Remove a slave device from a bonded device.\n\n"
601 "set bonding mode (value) (port_id)\n"
602 " Set the bonding mode on a bonded device.\n\n"
604 "set bonding primary (slave_id) (port_id)\n"
605 " Set the primary slave for a bonded device.\n\n"
607 "show bonding config (port_id)\n"
608 " Show the bonding config for port_id.\n\n"
610 "set bonding mac_addr (port_id) (address)\n"
611 " Set the MAC address of a bonded device.\n\n"
613 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
614 " Set Aggregation mode for IEEE802.3AD (mode 4)"
616 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
617 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
619 "set bonding mon_period (port_id) (value)\n"
620 " Set the bonding link status monitoring polling period in ms.\n\n"
622 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
623 " Enable/disable dedicated queues for LACP control traffic.\n\n"
626 "set link-up port (port_id)\n"
627 " Set link up for a port.\n\n"
629 "set link-down port (port_id)\n"
630 " Set link down for a port.\n\n"
632 "E-tag set insertion on port-tag-id (value)"
633 " port (port_id) vf (vf_id)\n"
634 " Enable E-tag insertion for a VF on a port\n\n"
636 "E-tag set insertion off port (port_id) vf (vf_id)\n"
637 " Disable E-tag insertion for a VF on a port\n\n"
639 "E-tag set stripping (on|off) port (port_id)\n"
640 " Enable/disable E-tag stripping on a port\n\n"
642 "E-tag set forwarding (on|off) port (port_id)\n"
643 " Enable/disable E-tag based forwarding"
646 "E-tag set filter add e-tag-id (value) dst-pool"
647 " (pool_id) port (port_id)\n"
648 " Add an E-tag forwarding filter on a port\n\n"
650 "E-tag set filter del e-tag-id (value) port (port_id)\n"
651 " Delete an E-tag forwarding filter on a port\n\n"
653 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
654 " Load a profile package on a port\n\n"
656 "ddp del (port_id) (backup_profile_path)\n"
657 " Delete a profile package from a port\n\n"
659 "ptype mapping get (port_id) (valid_only)\n"
660 " Get ptype mapping on a port\n\n"
662 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
663 " Replace target with the pkt_type in ptype mapping\n\n"
665 "ptype mapping reset (port_id)\n"
666 " Reset ptype mapping on a port\n\n"
668 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
669 " Update a ptype mapping item on a port\n\n"
671 "set port (port_id) queue-region region_id (value) "
672 "queue_start_index (value) queue_num (value)\n"
673 " Set a queue region on a port\n\n"
675 "set port (port_id) queue-region region_id (value) "
677 " Set a flowtype region index on a port\n\n"
679 "set port (port_id) queue-region UP (value) region_id (value)\n"
680 " Set the mapping of User Priority to "
681 "queue region on a port\n\n"
683 "set port (port_id) queue-region flush (on|off)\n"
684 " flush all queue region related configuration\n\n"
686 "show port meter cap (port_id)\n"
687 " Show port meter capability information\n\n"
689 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
690 " meter profile add - srtcm rfc 2697\n\n"
692 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
693 " meter profile add - trtcm rfc 2698\n\n"
695 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
696 " meter profile add - trtcm rfc 4115\n\n"
698 "del port meter profile (port_id) (profile_id)\n"
699 " meter profile delete\n\n"
701 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
702 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
703 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
704 "(dscp_tbl_entry63)]\n"
707 "enable port meter (port_id) (mtr_id)\n"
710 "disable port meter (port_id) (mtr_id)\n"
713 "del port meter (port_id) (mtr_id)\n"
716 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
717 " meter update meter profile\n\n"
719 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
720 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
721 " update meter dscp table entries\n\n"
723 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
724 "(action0) [(action1) (action2)]\n"
725 " meter update policer action\n\n"
727 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
728 " meter update stats\n\n"
730 "show port (port_id) queue-region\n"
731 " show all queue region related configuration info\n\n"
733 , list_pkt_forwarding_modes()
737 if (show_all || !strcmp(res->section, "ports")) {
743 "----------------\n\n"
745 "port start (port_id|all)\n"
746 " Start all ports or port_id.\n\n"
748 "port stop (port_id|all)\n"
749 " Stop all ports or port_id.\n\n"
751 "port close (port_id|all)\n"
752 " Close all ports or port_id.\n\n"
754 "port reset (port_id|all)\n"
755 " Reset all ports or port_id.\n\n"
757 "port attach (ident)\n"
758 " Attach physical or virtual dev by pci address or virtual device name\n\n"
760 "port detach (port_id)\n"
761 " Detach physical or virtual dev by port_id\n\n"
763 "port config (port_id|all)"
764 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
765 " duplex (half|full|auto)\n"
766 " Set speed and duplex for all ports or port_id\n\n"
768 "port config (port_id|all) loopback (mode)\n"
769 " Set loopback mode for all ports or port_id\n\n"
771 "port config all (rxq|txq|rxd|txd) (value)\n"
772 " Set number for rxq/txq/rxd/txd.\n\n"
774 "port config all max-pkt-len (value)\n"
775 " Set the max packet length.\n\n"
777 "port config all drop-en (on|off)\n"
778 " Enable or disable packet drop on all RX queues of all ports when no "
779 "receive buffers available.\n\n"
781 "port config all rss (all|default|ip|tcp|udp|sctp|"
782 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
783 " Set the RSS mode.\n\n"
785 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
786 " Set the RSS redirection table.\n\n"
788 "port config (port_id) dcb vt (on|off) (traffic_class)"
790 " Set the DCB mode.\n\n"
792 "port config all burst (value)\n"
793 " Set the number of packets per burst.\n\n"
795 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
797 " Set the ring prefetch/host/writeback threshold"
798 " for tx/rx queue.\n\n"
800 "port config all (txfreet|txrst|rxfreet) (value)\n"
801 " Set free threshold for rx/tx, or set"
802 " tx rs bit threshold.\n\n"
803 "port config mtu X value\n"
804 " Set the MTU of port X to a given value\n\n"
806 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
807 " Set a rx/tx queue's ring size configuration, the new"
808 " value will take effect after command that (re-)start the port"
809 " or command that setup the specific queue\n\n"
811 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
812 " Start/stop a rx/tx queue of port X. Only take effect"
813 " when port X is started\n\n"
815 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
816 " Switch on/off a deferred start of port X rx/tx queue. Only"
817 " take effect when port X is stopped.\n\n"
819 "port (port_id) (rxq|txq) (queue_id) setup\n"
820 " Setup a rx/tx queue of port X.\n\n"
822 "port config (port_id|all) l2-tunnel E-tag ether-type"
824 " Set the value of E-tag ether-type.\n\n"
826 "port config (port_id|all) l2-tunnel E-tag"
827 " (enable|disable)\n"
828 " Enable/disable the E-tag support.\n\n"
830 "port config (port_id) pctype mapping reset\n"
831 " Reset flow type to pctype mapping on a port\n\n"
833 "port config (port_id) pctype mapping update"
834 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
835 " Update a flow type to pctype mapping item on a port\n\n"
837 "port config (port_id) pctype (pctype_id) hash_inset|"
838 "fdir_inset|fdir_flx_inset get|set|clear field\n"
840 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
842 "port config (port_id) pctype (pctype_id) hash_inset|"
843 "fdir_inset|fdir_flx_inset clear all"
844 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
846 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
847 " Add/remove UDP tunnel port for tunneling offload\n\n"
849 "port config <port_id> rx_offload vlan_strip|"
850 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
851 "outer_ipv4_cksum|macsec_strip|header_split|"
852 "vlan_filter|vlan_extend|jumbo_frame|"
853 "scatter|timestamp|security|keep_crc on|off\n"
854 " Enable or disable a per port Rx offloading"
855 " on all Rx queues of a port\n\n"
857 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
858 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
859 "outer_ipv4_cksum|macsec_strip|header_split|"
860 "vlan_filter|vlan_extend|jumbo_frame|"
861 "scatter|timestamp|security|keep_crc on|off\n"
862 " Enable or disable a per queue Rx offloading"
863 " only on a specific Rx queue\n\n"
865 "port config (port_id) tx_offload vlan_insert|"
866 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
867 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
868 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
869 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
870 "security|match_metadata on|off\n"
871 " Enable or disable a per port Tx offloading"
872 " on all Tx queues of a port\n\n"
874 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
875 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
876 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
877 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
878 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
880 " Enable or disable a per queue Tx offloading"
881 " only on a specific Tx queue\n\n"
883 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
884 " Load an eBPF program as a callback"
885 " for particular RX/TX queue\n\n"
887 "bpf-unload rx|tx (port) (queue)\n"
888 " Unload previously loaded eBPF program"
889 " for particular RX/TX queue\n\n"
891 "port config (port_id) tx_metadata (value)\n"
892 " Set Tx metadata value per port. Testpmd will add this value"
893 " to any Tx packet sent from this port\n\n"
897 if (show_all || !strcmp(res->section, "registers")) {
905 "read reg (port_id) (address)\n"
906 " Display value of a port register.\n\n"
908 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
909 " Display a port register bit field.\n\n"
911 "read regbit (port_id) (address) (bit_x)\n"
912 " Display a single port register bit.\n\n"
914 "write reg (port_id) (address) (value)\n"
915 " Set value of a port register.\n\n"
917 "write regfield (port_id) (address) (bit_x) (bit_y)"
919 " Set bit field of a port register.\n\n"
921 "write regbit (port_id) (address) (bit_x) (value)\n"
922 " Set single bit value of a port register.\n\n"
925 if (show_all || !strcmp(res->section, "filters")) {
933 "ethertype_filter (port_id) (add|del)"
934 " (mac_addr|mac_ignr) (mac_address) ethertype"
935 " (ether_type) (drop|fwd) queue (queue_id)\n"
936 " Add/Del an ethertype filter.\n\n"
938 "2tuple_filter (port_id) (add|del)"
939 " dst_port (dst_port_value) protocol (protocol_value)"
940 " mask (mask_value) tcp_flags (tcp_flags_value)"
941 " priority (prio_value) queue (queue_id)\n"
942 " Add/Del a 2tuple filter.\n\n"
944 "5tuple_filter (port_id) (add|del)"
945 " dst_ip (dst_address) src_ip (src_address)"
946 " dst_port (dst_port_value) src_port (src_port_value)"
947 " protocol (protocol_value)"
948 " mask (mask_value) tcp_flags (tcp_flags_value)"
949 " priority (prio_value) queue (queue_id)\n"
950 " Add/Del a 5tuple filter.\n\n"
952 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
953 " Add/Del syn filter.\n\n"
955 "flex_filter (port_id) (add|del) len (len_value)"
956 " bytes (bytes_value) mask (mask_value)"
957 " priority (prio_value) queue (queue_id)\n"
958 " Add/Del a flex filter.\n\n"
960 "flow_director_filter (port_id) mode IP (add|del|update)"
961 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
962 " src (src_ip_address) dst (dst_ip_address)"
963 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
964 " vlan (vlan_value) flexbytes (flexbytes_value)"
965 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
966 " fd_id (fd_id_value)\n"
967 " Add/Del an IP type flow director filter.\n\n"
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
971 " src (src_ip_address) (src_port)"
972 " dst (dst_ip_address) (dst_port)"
973 " tos (tos_value) ttl (ttl_value)"
974 " vlan (vlan_value) flexbytes (flexbytes_value)"
975 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
976 " fd_id (fd_id_value)\n"
977 " Add/Del an UDP/TCP type flow director filter.\n\n"
979 "flow_director_filter (port_id) mode IP (add|del|update)"
980 " flow (ipv4-sctp|ipv6-sctp)"
981 " src (src_ip_address) (src_port)"
982 " dst (dst_ip_address) (dst_port)"
983 " tag (verification_tag) "
984 " tos (tos_value) ttl (ttl_value)"
986 " flexbytes (flexbytes_value) (drop|fwd)"
987 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
988 " Add/Del a SCTP type flow director filter.\n\n"
990 "flow_director_filter (port_id) mode IP (add|del|update)"
991 " flow l2_payload ether (ethertype)"
992 " flexbytes (flexbytes_value) (drop|fwd)"
993 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
994 " Add/Del a l2 payload type flow director filter.\n\n"
996 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
997 " mac (mac_address) vlan (vlan_value)"
998 " flexbytes (flexbytes_value) (drop|fwd)"
999 " queue (queue_id) fd_id (fd_id_value)\n"
1000 " Add/Del a MAC-VLAN flow director filter.\n\n"
1002 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1003 " mac (mac_address) vlan (vlan_value)"
1004 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1005 " flexbytes (flexbytes_value) (drop|fwd)"
1006 " queue (queue_id) fd_id (fd_id_value)\n"
1007 " Add/Del a Tunnel flow director filter.\n\n"
1009 "flow_director_filter (port_id) mode raw (add|del|update)"
1010 " flow (flow_id) (drop|fwd) queue (queue_id)"
1011 " fd_id (fd_id_value) packet (packet file name)\n"
1012 " Add/Del a raw type flow director filter.\n\n"
1014 "flush_flow_director (port_id)\n"
1015 " Flush all flow director entries of a device.\n\n"
1017 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1018 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1019 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1020 " Set flow director IP mask.\n\n"
1022 "flow_director_mask (port_id) mode MAC-VLAN"
1023 " vlan (vlan_value)\n"
1024 " Set flow director MAC-VLAN mask.\n\n"
1026 "flow_director_mask (port_id) mode Tunnel"
1027 " vlan (vlan_value) mac (mac_value)"
1028 " tunnel-type (tunnel_type_value)"
1029 " tunnel-id (tunnel_id_value)\n"
1030 " Set flow director Tunnel mask.\n\n"
1032 "flow_director_flex_mask (port_id)"
1033 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1034 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1036 " Configure mask of flex payload.\n\n"
1038 "flow_director_flex_payload (port_id)"
1039 " (raw|l2|l3|l4) (config)\n"
1040 " Configure flex payload selection.\n\n"
1042 "get_sym_hash_ena_per_port (port_id)\n"
1043 " get symmetric hash enable configuration per port.\n\n"
1045 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1046 " set symmetric hash enable configuration per port"
1047 " to enable or disable.\n\n"
1049 "get_hash_global_config (port_id)\n"
1050 " Get the global configurations of hash filters.\n\n"
1052 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1053 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1054 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1055 " (enable|disable)\n"
1056 " Set the global configurations of hash filters.\n\n"
1058 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1059 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1060 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1061 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1062 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1063 "ipv6-next-header|udp-src-port|udp-dst-port|"
1064 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1065 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1066 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1067 "fld-8th|none) (select|add)\n"
1068 " Set the input set for hash.\n\n"
1070 "set_fdir_input_set (port_id) "
1071 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1072 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1073 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1074 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1075 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1076 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1077 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1079 " Set the input set for FDir.\n\n"
1081 "flow validate {port_id}"
1082 " [group {group_id}] [priority {level}]"
1083 " [ingress] [egress]"
1084 " pattern {item} [/ {item} [...]] / end"
1085 " actions {action} [/ {action} [...]] / end\n"
1086 " Check whether a flow rule can be created.\n\n"
1088 "flow create {port_id}"
1089 " [group {group_id}] [priority {level}]"
1090 " [ingress] [egress]"
1091 " pattern {item} [/ {item} [...]] / end"
1092 " actions {action} [/ {action} [...]] / end\n"
1093 " Create a flow rule.\n\n"
1095 "flow destroy {port_id} rule {rule_id} [...]\n"
1096 " Destroy specific flow rules.\n\n"
1098 "flow flush {port_id}\n"
1099 " Destroy all flow rules.\n\n"
1101 "flow query {port_id} {rule_id} {action}\n"
1102 " Query an existing flow rule.\n\n"
1104 "flow list {port_id} [group {group_id}] [...]\n"
1105 " List existing flow rules sorted by priority,"
1106 " filtered by group identifiers.\n\n"
1108 "flow isolate {port_id} {boolean}\n"
1109 " Restrict ingress traffic to the defined"
1112 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1113 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1114 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1115 " Configure the VXLAN encapsulation for flows.\n\n"
1117 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1118 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1119 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1120 " eth-dst (eth-dst)\n"
1121 " Configure the VXLAN encapsulation for flows.\n\n"
1123 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1124 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1125 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1126 " eth-dst (eth-dst)\n"
1127 " Configure the VXLAN encapsulation for flows.\n\n"
1129 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1130 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1132 " Configure the NVGRE encapsulation for flows.\n\n"
1134 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1135 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1136 " eth-src (eth-src) eth-dst (eth-dst)\n"
1137 " Configure the NVGRE encapsulation for flows.\n\n"
1139 "set raw_encap {flow items}\n"
1140 " Configure the encapsulation with raw data.\n\n"
1142 "set raw_decap {flow items}\n"
1143 " Configure the decapsulation with raw data.\n\n"
1148 if (show_all || !strcmp(res->section, "traffic_management")) {
1152 "Traffic Management:\n"
1154 "show port tm cap (port_id)\n"
1155 " Display the port TM capability.\n\n"
1157 "show port tm level cap (port_id) (level_id)\n"
1158 " Display the port TM hierarchical level capability.\n\n"
1160 "show port tm node cap (port_id) (node_id)\n"
1161 " Display the port TM node capability.\n\n"
1163 "show port tm node type (port_id) (node_id)\n"
1164 " Display the port TM node type.\n\n"
1166 "show port tm node stats (port_id) (node_id) (clear)\n"
1167 " Display the port TM node stats.\n\n"
1169 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1170 "set port tm hierarchy default (port_id)\n"
1171 " Set default traffic Management hierarchy on a port\n\n"
1174 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1175 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1176 " (packet_length_adjust)\n"
1177 " Add port tm node private shaper profile.\n\n"
1179 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1180 " Delete port tm node private shaper profile.\n\n"
1182 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1183 " (shaper_profile_id)\n"
1184 " Add/update port tm node shared shaper.\n\n"
1186 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1187 " Delete port tm node shared shaper.\n\n"
1189 "set port tm node shaper profile (port_id) (node_id)"
1190 " (shaper_profile_id)\n"
1191 " Set port tm node shaper profile.\n\n"
1193 "add port tm node wred profile (port_id) (wred_profile_id)"
1194 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1195 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1196 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1197 " Add port tm node wred profile.\n\n"
1199 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1200 " Delete port tm node wred profile.\n\n"
1202 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1203 " (priority) (weight) (level_id) (shaper_profile_id)"
1204 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1205 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1206 " Add port tm nonleaf node.\n\n"
1208 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1209 " (priority) (weight) (level_id) (shaper_profile_id)"
1210 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1211 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1212 " Add port tm leaf node.\n\n"
1214 "del port tm node (port_id) (node_id)\n"
1215 " Delete port tm node.\n\n"
1217 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1218 " (priority) (weight)\n"
1219 " Set port tm node parent.\n\n"
1221 "suspend port tm node (port_id) (node_id)"
1222 " Suspend tm node.\n\n"
1224 "resume port tm node (port_id) (node_id)"
1225 " Resume tm node.\n\n"
1227 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1228 " Commit tm hierarchy.\n\n"
1230 "set port tm mark ip_ecn (port) (green) (yellow)"
1232 " Enables/Disables the traffic management marking"
1233 " for IP ECN (Explicit Congestion Notification)"
1234 " packets on a given port\n\n"
1236 "set port tm mark ip_dscp (port) (green) (yellow)"
1238 " Enables/Disables the traffic management marking"
1239 " on the port for IP dscp packets\n\n"
1241 "set port tm mark vlan_dei (port) (green) (yellow)"
1243 " Enables/Disables the traffic management marking"
1244 " on the port for VLAN packets with DEI enabled\n\n"
1248 if (show_all || !strcmp(res->section, "devices")) {
1252 "Device Operations:\n"
1254 "device detach (identifier)\n"
1255 " Detach device by identifier.\n\n"
1261 cmdline_parse_token_string_t cmd_help_long_help =
1262 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1264 cmdline_parse_token_string_t cmd_help_long_section =
1265 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1266 "all#control#display#config#"
1267 "ports#registers#filters#traffic_management#devices");
1269 cmdline_parse_inst_t cmd_help_long = {
1270 .f = cmd_help_long_parsed,
1272 .help_str = "help all|control|display|config|ports|register|"
1273 "filters|traffic_management|devices: "
1276 (void *)&cmd_help_long_help,
1277 (void *)&cmd_help_long_section,
1283 /* *** start/stop/close all ports *** */
1284 struct cmd_operate_port_result {
1285 cmdline_fixed_string_t keyword;
1286 cmdline_fixed_string_t name;
1287 cmdline_fixed_string_t value;
1290 static void cmd_operate_port_parsed(void *parsed_result,
1291 __attribute__((unused)) struct cmdline *cl,
1292 __attribute__((unused)) void *data)
1294 struct cmd_operate_port_result *res = parsed_result;
1296 if (!strcmp(res->name, "start"))
1297 start_port(RTE_PORT_ALL);
1298 else if (!strcmp(res->name, "stop"))
1299 stop_port(RTE_PORT_ALL);
1300 else if (!strcmp(res->name, "close"))
1301 close_port(RTE_PORT_ALL);
1302 else if (!strcmp(res->name, "reset"))
1303 reset_port(RTE_PORT_ALL);
1305 printf("Unknown parameter\n");
1308 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1309 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1311 cmdline_parse_token_string_t cmd_operate_port_all_port =
1312 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1313 "start#stop#close#reset");
1314 cmdline_parse_token_string_t cmd_operate_port_all_all =
1315 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1317 cmdline_parse_inst_t cmd_operate_port = {
1318 .f = cmd_operate_port_parsed,
1320 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1322 (void *)&cmd_operate_port_all_cmd,
1323 (void *)&cmd_operate_port_all_port,
1324 (void *)&cmd_operate_port_all_all,
1329 /* *** start/stop/close specific port *** */
1330 struct cmd_operate_specific_port_result {
1331 cmdline_fixed_string_t keyword;
1332 cmdline_fixed_string_t name;
1336 static void cmd_operate_specific_port_parsed(void *parsed_result,
1337 __attribute__((unused)) struct cmdline *cl,
1338 __attribute__((unused)) void *data)
1340 struct cmd_operate_specific_port_result *res = parsed_result;
1342 if (!strcmp(res->name, "start"))
1343 start_port(res->value);
1344 else if (!strcmp(res->name, "stop"))
1345 stop_port(res->value);
1346 else if (!strcmp(res->name, "close"))
1347 close_port(res->value);
1348 else if (!strcmp(res->name, "reset"))
1349 reset_port(res->value);
1351 printf("Unknown parameter\n");
1354 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1355 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1357 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1358 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1359 name, "start#stop#close#reset");
1360 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1361 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1364 cmdline_parse_inst_t cmd_operate_specific_port = {
1365 .f = cmd_operate_specific_port_parsed,
1367 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1369 (void *)&cmd_operate_specific_port_cmd,
1370 (void *)&cmd_operate_specific_port_port,
1371 (void *)&cmd_operate_specific_port_id,
1376 /* *** enable port setup (after attach) via iterator or event *** */
1377 struct cmd_set_port_setup_on_result {
1378 cmdline_fixed_string_t set;
1379 cmdline_fixed_string_t port;
1380 cmdline_fixed_string_t setup;
1381 cmdline_fixed_string_t on;
1382 cmdline_fixed_string_t mode;
1385 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1386 __attribute__((unused)) struct cmdline *cl,
1387 __attribute__((unused)) void *data)
1389 struct cmd_set_port_setup_on_result *res = parsed_result;
1391 if (strcmp(res->mode, "event") == 0)
1392 setup_on_probe_event = true;
1393 else if (strcmp(res->mode, "iterator") == 0)
1394 setup_on_probe_event = false;
1396 printf("Unknown mode\n");
1399 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1400 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1402 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1403 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1405 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1406 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1408 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1409 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1411 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1412 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1413 mode, "iterator#event");
1415 cmdline_parse_inst_t cmd_set_port_setup_on = {
1416 .f = cmd_set_port_setup_on_parsed,
1418 .help_str = "set port setup on iterator|event",
1420 (void *)&cmd_set_port_setup_on_set,
1421 (void *)&cmd_set_port_setup_on_port,
1422 (void *)&cmd_set_port_setup_on_setup,
1423 (void *)&cmd_set_port_setup_on_on,
1424 (void *)&cmd_set_port_setup_on_mode,
1429 /* *** attach a specified port *** */
1430 struct cmd_operate_attach_port_result {
1431 cmdline_fixed_string_t port;
1432 cmdline_fixed_string_t keyword;
1433 cmdline_fixed_string_t identifier;
1436 static void cmd_operate_attach_port_parsed(void *parsed_result,
1437 __attribute__((unused)) struct cmdline *cl,
1438 __attribute__((unused)) void *data)
1440 struct cmd_operate_attach_port_result *res = parsed_result;
1442 if (!strcmp(res->keyword, "attach"))
1443 attach_port(res->identifier);
1445 printf("Unknown parameter\n");
1448 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1449 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1451 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1452 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1454 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1458 cmdline_parse_inst_t cmd_operate_attach_port = {
1459 .f = cmd_operate_attach_port_parsed,
1461 .help_str = "port attach <identifier>: "
1462 "(identifier: pci address or virtual dev name)",
1464 (void *)&cmd_operate_attach_port_port,
1465 (void *)&cmd_operate_attach_port_keyword,
1466 (void *)&cmd_operate_attach_port_identifier,
1471 /* *** detach a specified port *** */
1472 struct cmd_operate_detach_port_result {
1473 cmdline_fixed_string_t port;
1474 cmdline_fixed_string_t keyword;
1478 static void cmd_operate_detach_port_parsed(void *parsed_result,
1479 __attribute__((unused)) struct cmdline *cl,
1480 __attribute__((unused)) void *data)
1482 struct cmd_operate_detach_port_result *res = parsed_result;
1484 if (!strcmp(res->keyword, "detach"))
1485 detach_port_device(res->port_id);
1487 printf("Unknown parameter\n");
1490 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1491 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1493 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1494 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1496 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1497 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1500 cmdline_parse_inst_t cmd_operate_detach_port = {
1501 .f = cmd_operate_detach_port_parsed,
1503 .help_str = "port detach <port_id>",
1505 (void *)&cmd_operate_detach_port_port,
1506 (void *)&cmd_operate_detach_port_keyword,
1507 (void *)&cmd_operate_detach_port_port_id,
1512 /* *** detach device by identifier *** */
1513 struct cmd_operate_detach_device_result {
1514 cmdline_fixed_string_t device;
1515 cmdline_fixed_string_t keyword;
1516 cmdline_fixed_string_t identifier;
1519 static void cmd_operate_detach_device_parsed(void *parsed_result,
1520 __attribute__((unused)) struct cmdline *cl,
1521 __attribute__((unused)) void *data)
1523 struct cmd_operate_detach_device_result *res = parsed_result;
1525 if (!strcmp(res->keyword, "detach"))
1526 detach_device(res->identifier);
1528 printf("Unknown parameter\n");
1531 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1532 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1534 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1535 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1537 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1538 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1541 cmdline_parse_inst_t cmd_operate_detach_device = {
1542 .f = cmd_operate_detach_device_parsed,
1544 .help_str = "device detach <identifier>:"
1545 "(identifier: pci address or virtual dev name)",
1547 (void *)&cmd_operate_detach_device_device,
1548 (void *)&cmd_operate_detach_device_keyword,
1549 (void *)&cmd_operate_detach_device_identifier,
1553 /* *** configure speed for all ports *** */
1554 struct cmd_config_speed_all {
1555 cmdline_fixed_string_t port;
1556 cmdline_fixed_string_t keyword;
1557 cmdline_fixed_string_t all;
1558 cmdline_fixed_string_t item1;
1559 cmdline_fixed_string_t item2;
1560 cmdline_fixed_string_t value1;
1561 cmdline_fixed_string_t value2;
1565 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1570 if (!strcmp(duplexstr, "half")) {
1571 duplex = ETH_LINK_HALF_DUPLEX;
1572 } else if (!strcmp(duplexstr, "full")) {
1573 duplex = ETH_LINK_FULL_DUPLEX;
1574 } else if (!strcmp(duplexstr, "auto")) {
1575 duplex = ETH_LINK_FULL_DUPLEX;
1577 printf("Unknown duplex parameter\n");
1581 if (!strcmp(speedstr, "10")) {
1582 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1583 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1584 } else if (!strcmp(speedstr, "100")) {
1585 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1586 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1588 if (duplex != ETH_LINK_FULL_DUPLEX) {
1589 printf("Invalid speed/duplex parameters\n");
1592 if (!strcmp(speedstr, "1000")) {
1593 *speed = ETH_LINK_SPEED_1G;
1594 } else if (!strcmp(speedstr, "10000")) {
1595 *speed = ETH_LINK_SPEED_10G;
1596 } else if (!strcmp(speedstr, "25000")) {
1597 *speed = ETH_LINK_SPEED_25G;
1598 } else if (!strcmp(speedstr, "40000")) {
1599 *speed = ETH_LINK_SPEED_40G;
1600 } else if (!strcmp(speedstr, "50000")) {
1601 *speed = ETH_LINK_SPEED_50G;
1602 } else if (!strcmp(speedstr, "100000")) {
1603 *speed = ETH_LINK_SPEED_100G;
1604 } else if (!strcmp(speedstr, "auto")) {
1605 *speed = ETH_LINK_SPEED_AUTONEG;
1607 printf("Unknown speed parameter\n");
1616 cmd_config_speed_all_parsed(void *parsed_result,
1617 __attribute__((unused)) struct cmdline *cl,
1618 __attribute__((unused)) void *data)
1620 struct cmd_config_speed_all *res = parsed_result;
1621 uint32_t link_speed;
1624 if (!all_ports_stopped()) {
1625 printf("Please stop all ports first\n");
1629 if (parse_and_check_speed_duplex(res->value1, res->value2,
1633 RTE_ETH_FOREACH_DEV(pid) {
1634 ports[pid].dev_conf.link_speeds = link_speed;
1637 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1640 cmdline_parse_token_string_t cmd_config_speed_all_port =
1641 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1642 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1645 cmdline_parse_token_string_t cmd_config_speed_all_all =
1646 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1647 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1648 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1649 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1651 "10#100#1000#10000#25000#40000#50000#100000#auto");
1652 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1654 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1658 cmdline_parse_inst_t cmd_config_speed_all = {
1659 .f = cmd_config_speed_all_parsed,
1661 .help_str = "port config all speed "
1662 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1665 (void *)&cmd_config_speed_all_port,
1666 (void *)&cmd_config_speed_all_keyword,
1667 (void *)&cmd_config_speed_all_all,
1668 (void *)&cmd_config_speed_all_item1,
1669 (void *)&cmd_config_speed_all_value1,
1670 (void *)&cmd_config_speed_all_item2,
1671 (void *)&cmd_config_speed_all_value2,
1676 /* *** configure speed for specific port *** */
1677 struct cmd_config_speed_specific {
1678 cmdline_fixed_string_t port;
1679 cmdline_fixed_string_t keyword;
1681 cmdline_fixed_string_t item1;
1682 cmdline_fixed_string_t item2;
1683 cmdline_fixed_string_t value1;
1684 cmdline_fixed_string_t value2;
1688 cmd_config_speed_specific_parsed(void *parsed_result,
1689 __attribute__((unused)) struct cmdline *cl,
1690 __attribute__((unused)) void *data)
1692 struct cmd_config_speed_specific *res = parsed_result;
1693 uint32_t link_speed;
1695 if (!all_ports_stopped()) {
1696 printf("Please stop all ports first\n");
1700 if (port_id_is_invalid(res->id, ENABLED_WARN))
1703 if (parse_and_check_speed_duplex(res->value1, res->value2,
1707 ports[res->id].dev_conf.link_speeds = link_speed;
1709 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1713 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1716 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1719 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1720 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1721 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1724 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1725 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1726 "10#100#1000#10000#25000#40000#50000#100000#auto");
1727 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1730 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1734 cmdline_parse_inst_t cmd_config_speed_specific = {
1735 .f = cmd_config_speed_specific_parsed,
1737 .help_str = "port config <port_id> speed "
1738 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1741 (void *)&cmd_config_speed_specific_port,
1742 (void *)&cmd_config_speed_specific_keyword,
1743 (void *)&cmd_config_speed_specific_id,
1744 (void *)&cmd_config_speed_specific_item1,
1745 (void *)&cmd_config_speed_specific_value1,
1746 (void *)&cmd_config_speed_specific_item2,
1747 (void *)&cmd_config_speed_specific_value2,
1752 /* *** configure loopback for all ports *** */
1753 struct cmd_config_loopback_all {
1754 cmdline_fixed_string_t port;
1755 cmdline_fixed_string_t keyword;
1756 cmdline_fixed_string_t all;
1757 cmdline_fixed_string_t item;
1762 cmd_config_loopback_all_parsed(void *parsed_result,
1763 __attribute__((unused)) struct cmdline *cl,
1764 __attribute__((unused)) void *data)
1766 struct cmd_config_loopback_all *res = parsed_result;
1769 if (!all_ports_stopped()) {
1770 printf("Please stop all ports first\n");
1774 RTE_ETH_FOREACH_DEV(pid) {
1775 ports[pid].dev_conf.lpbk_mode = res->mode;
1778 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1781 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1783 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1784 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1786 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1787 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1788 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1791 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1792 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1794 cmdline_parse_inst_t cmd_config_loopback_all = {
1795 .f = cmd_config_loopback_all_parsed,
1797 .help_str = "port config all loopback <mode>",
1799 (void *)&cmd_config_loopback_all_port,
1800 (void *)&cmd_config_loopback_all_keyword,
1801 (void *)&cmd_config_loopback_all_all,
1802 (void *)&cmd_config_loopback_all_item,
1803 (void *)&cmd_config_loopback_all_mode,
1808 /* *** configure loopback for specific port *** */
1809 struct cmd_config_loopback_specific {
1810 cmdline_fixed_string_t port;
1811 cmdline_fixed_string_t keyword;
1813 cmdline_fixed_string_t item;
1818 cmd_config_loopback_specific_parsed(void *parsed_result,
1819 __attribute__((unused)) struct cmdline *cl,
1820 __attribute__((unused)) void *data)
1822 struct cmd_config_loopback_specific *res = parsed_result;
1824 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1827 if (!port_is_stopped(res->port_id)) {
1828 printf("Please stop port %u first\n", res->port_id);
1832 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1834 cmd_reconfig_device_queue(res->port_id, 1, 1);
1838 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1839 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1841 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1842 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1844 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1845 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1847 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1848 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1850 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1851 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1854 cmdline_parse_inst_t cmd_config_loopback_specific = {
1855 .f = cmd_config_loopback_specific_parsed,
1857 .help_str = "port config <port_id> loopback <mode>",
1859 (void *)&cmd_config_loopback_specific_port,
1860 (void *)&cmd_config_loopback_specific_keyword,
1861 (void *)&cmd_config_loopback_specific_id,
1862 (void *)&cmd_config_loopback_specific_item,
1863 (void *)&cmd_config_loopback_specific_mode,
1868 /* *** configure txq/rxq, txd/rxd *** */
1869 struct cmd_config_rx_tx {
1870 cmdline_fixed_string_t port;
1871 cmdline_fixed_string_t keyword;
1872 cmdline_fixed_string_t all;
1873 cmdline_fixed_string_t name;
1878 cmd_config_rx_tx_parsed(void *parsed_result,
1879 __attribute__((unused)) struct cmdline *cl,
1880 __attribute__((unused)) void *data)
1882 struct cmd_config_rx_tx *res = parsed_result;
1884 if (!all_ports_stopped()) {
1885 printf("Please stop all ports first\n");
1888 if (!strcmp(res->name, "rxq")) {
1889 if (!res->value && !nb_txq) {
1890 printf("Warning: Either rx or tx queues should be non zero\n");
1893 if (check_nb_rxq(res->value) != 0)
1895 nb_rxq = res->value;
1897 else if (!strcmp(res->name, "txq")) {
1898 if (!res->value && !nb_rxq) {
1899 printf("Warning: Either rx or tx queues should be non zero\n");
1902 if (check_nb_txq(res->value) != 0)
1904 nb_txq = res->value;
1906 else if (!strcmp(res->name, "rxd")) {
1907 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1908 printf("rxd %d invalid - must be > 0 && <= %d\n",
1909 res->value, RTE_TEST_RX_DESC_MAX);
1912 nb_rxd = res->value;
1913 } else if (!strcmp(res->name, "txd")) {
1914 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1915 printf("txd %d invalid - must be > 0 && <= %d\n",
1916 res->value, RTE_TEST_TX_DESC_MAX);
1919 nb_txd = res->value;
1921 printf("Unknown parameter\n");
1929 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1932 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1934 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1936 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1937 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1938 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1941 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1942 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1944 cmdline_parse_inst_t cmd_config_rx_tx = {
1945 .f = cmd_config_rx_tx_parsed,
1947 .help_str = "port config all rxq|txq|rxd|txd <value>",
1949 (void *)&cmd_config_rx_tx_port,
1950 (void *)&cmd_config_rx_tx_keyword,
1951 (void *)&cmd_config_rx_tx_all,
1952 (void *)&cmd_config_rx_tx_name,
1953 (void *)&cmd_config_rx_tx_value,
1958 /* *** config max packet length *** */
1959 struct cmd_config_max_pkt_len_result {
1960 cmdline_fixed_string_t port;
1961 cmdline_fixed_string_t keyword;
1962 cmdline_fixed_string_t all;
1963 cmdline_fixed_string_t name;
1968 cmd_config_max_pkt_len_parsed(void *parsed_result,
1969 __attribute__((unused)) struct cmdline *cl,
1970 __attribute__((unused)) void *data)
1972 struct cmd_config_max_pkt_len_result *res = parsed_result;
1975 if (!all_ports_stopped()) {
1976 printf("Please stop all ports first\n");
1980 RTE_ETH_FOREACH_DEV(pid) {
1981 struct rte_port *port = &ports[pid];
1982 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1984 if (!strcmp(res->name, "max-pkt-len")) {
1985 if (res->value < RTE_ETHER_MIN_LEN) {
1986 printf("max-pkt-len can not be less than %d\n",
1990 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1993 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1994 if (res->value > RTE_ETHER_MAX_LEN)
1995 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1997 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1998 port->dev_conf.rxmode.offloads = rx_offloads;
2000 printf("Unknown parameter\n");
2007 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2010 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2011 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2013 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2016 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2019 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2022 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2023 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2026 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2027 .f = cmd_config_max_pkt_len_parsed,
2029 .help_str = "port config all max-pkt-len <value>",
2031 (void *)&cmd_config_max_pkt_len_port,
2032 (void *)&cmd_config_max_pkt_len_keyword,
2033 (void *)&cmd_config_max_pkt_len_all,
2034 (void *)&cmd_config_max_pkt_len_name,
2035 (void *)&cmd_config_max_pkt_len_value,
2040 /* *** configure port MTU *** */
2041 struct cmd_config_mtu_result {
2042 cmdline_fixed_string_t port;
2043 cmdline_fixed_string_t keyword;
2044 cmdline_fixed_string_t mtu;
2050 cmd_config_mtu_parsed(void *parsed_result,
2051 __attribute__((unused)) struct cmdline *cl,
2052 __attribute__((unused)) void *data)
2054 struct cmd_config_mtu_result *res = parsed_result;
2056 if (res->value < RTE_ETHER_MIN_LEN) {
2057 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2060 port_mtu_set(res->port_id, res->value);
2063 cmdline_parse_token_string_t cmd_config_mtu_port =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2066 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2069 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2072 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2073 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2074 cmdline_parse_token_num_t cmd_config_mtu_value =
2075 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2077 cmdline_parse_inst_t cmd_config_mtu = {
2078 .f = cmd_config_mtu_parsed,
2080 .help_str = "port config mtu <port_id> <value>",
2082 (void *)&cmd_config_mtu_port,
2083 (void *)&cmd_config_mtu_keyword,
2084 (void *)&cmd_config_mtu_mtu,
2085 (void *)&cmd_config_mtu_port_id,
2086 (void *)&cmd_config_mtu_value,
2091 /* *** configure rx mode *** */
2092 struct cmd_config_rx_mode_flag {
2093 cmdline_fixed_string_t port;
2094 cmdline_fixed_string_t keyword;
2095 cmdline_fixed_string_t all;
2096 cmdline_fixed_string_t name;
2097 cmdline_fixed_string_t value;
2101 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2102 __attribute__((unused)) struct cmdline *cl,
2103 __attribute__((unused)) void *data)
2105 struct cmd_config_rx_mode_flag *res = parsed_result;
2107 if (!all_ports_stopped()) {
2108 printf("Please stop all ports first\n");
2112 if (!strcmp(res->name, "drop-en")) {
2113 if (!strcmp(res->value, "on"))
2115 else if (!strcmp(res->value, "off"))
2118 printf("Unknown parameter\n");
2122 printf("Unknown parameter\n");
2128 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2131 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2133 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2134 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2138 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2139 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2141 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2142 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2145 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2146 .f = cmd_config_rx_mode_flag_parsed,
2148 .help_str = "port config all drop-en on|off",
2150 (void *)&cmd_config_rx_mode_flag_port,
2151 (void *)&cmd_config_rx_mode_flag_keyword,
2152 (void *)&cmd_config_rx_mode_flag_all,
2153 (void *)&cmd_config_rx_mode_flag_name,
2154 (void *)&cmd_config_rx_mode_flag_value,
2159 /* *** configure rss *** */
2160 struct cmd_config_rss {
2161 cmdline_fixed_string_t port;
2162 cmdline_fixed_string_t keyword;
2163 cmdline_fixed_string_t all;
2164 cmdline_fixed_string_t name;
2165 cmdline_fixed_string_t value;
2169 cmd_config_rss_parsed(void *parsed_result,
2170 __attribute__((unused)) struct cmdline *cl,
2171 __attribute__((unused)) void *data)
2173 struct cmd_config_rss *res = parsed_result;
2174 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2175 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2176 int use_default = 0;
2177 int all_updated = 1;
2182 if (!strcmp(res->value, "all"))
2183 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2184 ETH_RSS_UDP | ETH_RSS_SCTP |
2186 else if (!strcmp(res->value, "ip"))
2187 rss_conf.rss_hf = ETH_RSS_IP;
2188 else if (!strcmp(res->value, "udp"))
2189 rss_conf.rss_hf = ETH_RSS_UDP;
2190 else if (!strcmp(res->value, "tcp"))
2191 rss_conf.rss_hf = ETH_RSS_TCP;
2192 else if (!strcmp(res->value, "sctp"))
2193 rss_conf.rss_hf = ETH_RSS_SCTP;
2194 else if (!strcmp(res->value, "ether"))
2195 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2196 else if (!strcmp(res->value, "port"))
2197 rss_conf.rss_hf = ETH_RSS_PORT;
2198 else if (!strcmp(res->value, "vxlan"))
2199 rss_conf.rss_hf = ETH_RSS_VXLAN;
2200 else if (!strcmp(res->value, "geneve"))
2201 rss_conf.rss_hf = ETH_RSS_GENEVE;
2202 else if (!strcmp(res->value, "nvgre"))
2203 rss_conf.rss_hf = ETH_RSS_NVGRE;
2204 else if (!strcmp(res->value, "none"))
2205 rss_conf.rss_hf = 0;
2206 else if (!strcmp(res->value, "default"))
2208 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2209 atoi(res->value) < 64)
2210 rss_conf.rss_hf = 1ULL << atoi(res->value);
2212 printf("Unknown parameter\n");
2215 rss_conf.rss_key = NULL;
2216 /* Update global configuration for RSS types. */
2217 RTE_ETH_FOREACH_DEV(i) {
2218 struct rte_eth_rss_conf local_rss_conf;
2220 ret = eth_dev_info_get_print_err(i, &dev_info);
2225 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2227 local_rss_conf = rss_conf;
2228 local_rss_conf.rss_hf = rss_conf.rss_hf &
2229 dev_info.flow_type_rss_offloads;
2230 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2231 printf("Port %u modified RSS hash function based on hardware support,"
2232 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2233 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2235 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2238 printf("Configuration of RSS hash at ethernet port %d "
2239 "failed with error (%d): %s.\n",
2240 i, -diag, strerror(-diag));
2243 if (all_updated && !use_default)
2244 rss_hf = rss_conf.rss_hf;
2247 cmdline_parse_token_string_t cmd_config_rss_port =
2248 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2249 cmdline_parse_token_string_t cmd_config_rss_keyword =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2251 cmdline_parse_token_string_t cmd_config_rss_all =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2253 cmdline_parse_token_string_t cmd_config_rss_name =
2254 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2255 cmdline_parse_token_string_t cmd_config_rss_value =
2256 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2258 cmdline_parse_inst_t cmd_config_rss = {
2259 .f = cmd_config_rss_parsed,
2261 .help_str = "port config all rss "
2262 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2264 (void *)&cmd_config_rss_port,
2265 (void *)&cmd_config_rss_keyword,
2266 (void *)&cmd_config_rss_all,
2267 (void *)&cmd_config_rss_name,
2268 (void *)&cmd_config_rss_value,
2273 /* *** configure rss hash key *** */
2274 struct cmd_config_rss_hash_key {
2275 cmdline_fixed_string_t port;
2276 cmdline_fixed_string_t config;
2278 cmdline_fixed_string_t rss_hash_key;
2279 cmdline_fixed_string_t rss_type;
2280 cmdline_fixed_string_t key;
2284 hexa_digit_to_value(char hexa_digit)
2286 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2287 return (uint8_t) (hexa_digit - '0');
2288 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2289 return (uint8_t) ((hexa_digit - 'a') + 10);
2290 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2291 return (uint8_t) ((hexa_digit - 'A') + 10);
2292 /* Invalid hexa digit */
2297 parse_and_check_key_hexa_digit(char *key, int idx)
2301 hexa_v = hexa_digit_to_value(key[idx]);
2303 printf("invalid key: character %c at position %d is not a "
2304 "valid hexa digit\n", key[idx], idx);
2309 cmd_config_rss_hash_key_parsed(void *parsed_result,
2310 __attribute__((unused)) struct cmdline *cl,
2311 __attribute__((unused)) void *data)
2313 struct cmd_config_rss_hash_key *res = parsed_result;
2314 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2318 struct rte_eth_dev_info dev_info;
2319 uint8_t hash_key_size;
2323 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2327 if (dev_info.hash_key_size > 0 &&
2328 dev_info.hash_key_size <= sizeof(hash_key))
2329 hash_key_size = dev_info.hash_key_size;
2331 printf("dev_info did not provide a valid hash key size\n");
2334 /* Check the length of the RSS hash key */
2335 key_len = strlen(res->key);
2336 if (key_len != (hash_key_size * 2)) {
2337 printf("key length: %d invalid - key must be a string of %d"
2338 " hexa-decimal numbers\n",
2339 (int) key_len, hash_key_size * 2);
2342 /* Translate RSS hash key into binary representation */
2343 for (i = 0; i < hash_key_size; i++) {
2344 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2347 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2350 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2352 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2356 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2357 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2358 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2359 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2361 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2362 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2363 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2364 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2365 rss_hash_key, "rss-hash-key");
2366 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2367 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2368 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2369 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2370 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2371 "ipv6-tcp-ex#ipv6-udp-ex");
2372 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2373 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2375 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2376 .f = cmd_config_rss_hash_key_parsed,
2378 .help_str = "port config <port_id> rss-hash-key "
2379 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2380 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2381 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2382 "<string of hex digits (variable length, NIC dependent)>",
2384 (void *)&cmd_config_rss_hash_key_port,
2385 (void *)&cmd_config_rss_hash_key_config,
2386 (void *)&cmd_config_rss_hash_key_port_id,
2387 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2388 (void *)&cmd_config_rss_hash_key_rss_type,
2389 (void *)&cmd_config_rss_hash_key_value,
2394 /* *** configure port rxq/txq ring size *** */
2395 struct cmd_config_rxtx_ring_size {
2396 cmdline_fixed_string_t port;
2397 cmdline_fixed_string_t config;
2399 cmdline_fixed_string_t rxtxq;
2401 cmdline_fixed_string_t rsize;
2406 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2407 __attribute__((unused)) struct cmdline *cl,
2408 __attribute__((unused)) void *data)
2410 struct cmd_config_rxtx_ring_size *res = parsed_result;
2411 struct rte_port *port;
2414 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2417 if (res->portid == (portid_t)RTE_PORT_ALL) {
2418 printf("Invalid port id\n");
2422 port = &ports[res->portid];
2424 if (!strcmp(res->rxtxq, "rxq"))
2426 else if (!strcmp(res->rxtxq, "txq"))
2429 printf("Unknown parameter\n");
2433 if (isrx && rx_queue_id_is_invalid(res->qid))
2435 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2438 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2439 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2445 port->nb_rx_desc[res->qid] = res->size;
2447 port->nb_tx_desc[res->qid] = res->size;
2449 cmd_reconfig_device_queue(res->portid, 0, 1);
2452 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2453 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2455 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2456 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2458 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2459 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2461 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2462 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2464 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2465 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2467 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2468 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2469 rsize, "ring_size");
2470 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2471 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2474 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2475 .f = cmd_config_rxtx_ring_size_parsed,
2477 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2479 (void *)&cmd_config_rxtx_ring_size_port,
2480 (void *)&cmd_config_rxtx_ring_size_config,
2481 (void *)&cmd_config_rxtx_ring_size_portid,
2482 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2483 (void *)&cmd_config_rxtx_ring_size_qid,
2484 (void *)&cmd_config_rxtx_ring_size_rsize,
2485 (void *)&cmd_config_rxtx_ring_size_size,
2490 /* *** configure port rxq/txq start/stop *** */
2491 struct cmd_config_rxtx_queue {
2492 cmdline_fixed_string_t port;
2494 cmdline_fixed_string_t rxtxq;
2496 cmdline_fixed_string_t opname;
2500 cmd_config_rxtx_queue_parsed(void *parsed_result,
2501 __attribute__((unused)) struct cmdline *cl,
2502 __attribute__((unused)) void *data)
2504 struct cmd_config_rxtx_queue *res = parsed_result;
2509 if (test_done == 0) {
2510 printf("Please stop forwarding first\n");
2514 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2517 if (port_is_started(res->portid) != 1) {
2518 printf("Please start port %u first\n", res->portid);
2522 if (!strcmp(res->rxtxq, "rxq"))
2524 else if (!strcmp(res->rxtxq, "txq"))
2527 printf("Unknown parameter\n");
2531 if (isrx && rx_queue_id_is_invalid(res->qid))
2533 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2536 if (!strcmp(res->opname, "start"))
2538 else if (!strcmp(res->opname, "stop"))
2541 printf("Unknown parameter\n");
2545 if (isstart && isrx)
2546 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2547 else if (!isstart && isrx)
2548 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2549 else if (isstart && !isrx)
2550 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2552 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2554 if (ret == -ENOTSUP)
2555 printf("Function not supported in PMD driver\n");
2558 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2559 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2560 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2561 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2562 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2563 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2564 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2565 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2566 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2567 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2570 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2571 .f = cmd_config_rxtx_queue_parsed,
2573 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2575 (void *)&cmd_config_rxtx_queue_port,
2576 (void *)&cmd_config_rxtx_queue_portid,
2577 (void *)&cmd_config_rxtx_queue_rxtxq,
2578 (void *)&cmd_config_rxtx_queue_qid,
2579 (void *)&cmd_config_rxtx_queue_opname,
2584 /* *** configure port rxq/txq deferred start on/off *** */
2585 struct cmd_config_deferred_start_rxtx_queue {
2586 cmdline_fixed_string_t port;
2588 cmdline_fixed_string_t rxtxq;
2590 cmdline_fixed_string_t opname;
2591 cmdline_fixed_string_t state;
2595 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2596 __attribute__((unused)) struct cmdline *cl,
2597 __attribute__((unused)) void *data)
2599 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2600 struct rte_port *port;
2603 uint8_t needreconfig = 0;
2605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2608 if (port_is_started(res->port_id) != 0) {
2609 printf("Please stop port %u first\n", res->port_id);
2613 port = &ports[res->port_id];
2615 isrx = !strcmp(res->rxtxq, "rxq");
2617 if (isrx && rx_queue_id_is_invalid(res->qid))
2619 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2622 ison = !strcmp(res->state, "on");
2624 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2625 port->rx_conf[res->qid].rx_deferred_start = ison;
2627 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2628 port->tx_conf[res->qid].tx_deferred_start = ison;
2633 cmd_reconfig_device_queue(res->port_id, 0, 1);
2636 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2637 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2639 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2640 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2642 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2643 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2645 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2646 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2648 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2649 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2650 opname, "deferred_start");
2651 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2652 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2655 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2656 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2658 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2660 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2661 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2662 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2663 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2664 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2665 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2670 /* *** configure port rxq/txq setup *** */
2671 struct cmd_setup_rxtx_queue {
2672 cmdline_fixed_string_t port;
2674 cmdline_fixed_string_t rxtxq;
2676 cmdline_fixed_string_t setup;
2679 /* Common CLI fields for queue setup */
2680 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2681 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2682 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2683 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2684 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2685 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2686 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2687 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2688 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2689 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2692 cmd_setup_rxtx_queue_parsed(
2693 void *parsed_result,
2694 __attribute__((unused)) struct cmdline *cl,
2695 __attribute__((unused)) void *data)
2697 struct cmd_setup_rxtx_queue *res = parsed_result;
2698 struct rte_port *port;
2699 struct rte_mempool *mp;
2700 unsigned int socket_id;
2704 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2707 if (res->portid == (portid_t)RTE_PORT_ALL) {
2708 printf("Invalid port id\n");
2712 if (!strcmp(res->rxtxq, "rxq"))
2714 else if (!strcmp(res->rxtxq, "txq"))
2717 printf("Unknown parameter\n");
2721 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2722 printf("Invalid rx queue\n");
2724 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2725 printf("Invalid tx queue\n");
2729 port = &ports[res->portid];
2731 socket_id = rxring_numa[res->portid];
2732 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2733 socket_id = port->socket_id;
2735 mp = mbuf_pool_find(socket_id);
2737 printf("Failed to setup RX queue: "
2738 "No mempool allocation"
2739 " on the socket %d\n",
2740 rxring_numa[res->portid]);
2743 ret = rte_eth_rx_queue_setup(res->portid,
2745 port->nb_rx_desc[res->qid],
2747 &port->rx_conf[res->qid],
2750 printf("Failed to setup RX queue\n");
2752 socket_id = txring_numa[res->portid];
2753 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2754 socket_id = port->socket_id;
2756 ret = rte_eth_tx_queue_setup(res->portid,
2758 port->nb_tx_desc[res->qid],
2760 &port->tx_conf[res->qid]);
2762 printf("Failed to setup TX queue\n");
2766 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2767 .f = cmd_setup_rxtx_queue_parsed,
2769 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2771 (void *)&cmd_setup_rxtx_queue_port,
2772 (void *)&cmd_setup_rxtx_queue_portid,
2773 (void *)&cmd_setup_rxtx_queue_rxtxq,
2774 (void *)&cmd_setup_rxtx_queue_qid,
2775 (void *)&cmd_setup_rxtx_queue_setup,
2781 /* *** Configure RSS RETA *** */
2782 struct cmd_config_rss_reta {
2783 cmdline_fixed_string_t port;
2784 cmdline_fixed_string_t keyword;
2786 cmdline_fixed_string_t name;
2787 cmdline_fixed_string_t list_name;
2788 cmdline_fixed_string_t list_of_items;
2792 parse_reta_config(const char *str,
2793 struct rte_eth_rss_reta_entry64 *reta_conf,
2794 uint16_t nb_entries)
2798 uint16_t hash_index, idx, shift;
2801 const char *p, *p0 = str;
2808 unsigned long int_fld[_NUM_FLD];
2809 char *str_fld[_NUM_FLD];
2811 while ((p = strchr(p0,'(')) != NULL) {
2813 if((p0 = strchr(p,')')) == NULL)
2817 if(size >= sizeof(s))
2820 snprintf(s, sizeof(s), "%.*s", size, p);
2821 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2823 for (i = 0; i < _NUM_FLD; i++) {
2825 int_fld[i] = strtoul(str_fld[i], &end, 0);
2826 if (errno != 0 || end == str_fld[i] ||
2831 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2832 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2834 if (hash_index >= nb_entries) {
2835 printf("Invalid RETA hash index=%d\n", hash_index);
2839 idx = hash_index / RTE_RETA_GROUP_SIZE;
2840 shift = hash_index % RTE_RETA_GROUP_SIZE;
2841 reta_conf[idx].mask |= (1ULL << shift);
2842 reta_conf[idx].reta[shift] = nb_queue;
2849 cmd_set_rss_reta_parsed(void *parsed_result,
2850 __attribute__((unused)) struct cmdline *cl,
2851 __attribute__((unused)) void *data)
2854 struct rte_eth_dev_info dev_info;
2855 struct rte_eth_rss_reta_entry64 reta_conf[8];
2856 struct cmd_config_rss_reta *res = parsed_result;
2858 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2862 if (dev_info.reta_size == 0) {
2863 printf("Redirection table size is 0 which is "
2864 "invalid for RSS\n");
2867 printf("The reta size of port %d is %u\n",
2868 res->port_id, dev_info.reta_size);
2869 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2870 printf("Currently do not support more than %u entries of "
2871 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2875 memset(reta_conf, 0, sizeof(reta_conf));
2876 if (!strcmp(res->list_name, "reta")) {
2877 if (parse_reta_config(res->list_of_items, reta_conf,
2878 dev_info.reta_size)) {
2879 printf("Invalid RSS Redirection Table "
2880 "config entered\n");
2883 ret = rte_eth_dev_rss_reta_update(res->port_id,
2884 reta_conf, dev_info.reta_size);
2886 printf("Bad redirection table parameter, "
2887 "return code = %d \n", ret);
2891 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2892 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2893 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2894 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2895 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2896 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2897 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2898 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2899 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2900 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2901 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2904 cmdline_parse_inst_t cmd_config_rss_reta = {
2905 .f = cmd_set_rss_reta_parsed,
2907 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2909 (void *)&cmd_config_rss_reta_port,
2910 (void *)&cmd_config_rss_reta_keyword,
2911 (void *)&cmd_config_rss_reta_port_id,
2912 (void *)&cmd_config_rss_reta_name,
2913 (void *)&cmd_config_rss_reta_list_name,
2914 (void *)&cmd_config_rss_reta_list_of_items,
2919 /* *** SHOW PORT RETA INFO *** */
2920 struct cmd_showport_reta {
2921 cmdline_fixed_string_t show;
2922 cmdline_fixed_string_t port;
2924 cmdline_fixed_string_t rss;
2925 cmdline_fixed_string_t reta;
2927 cmdline_fixed_string_t list_of_items;
2931 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2932 uint16_t nb_entries,
2936 const char *p, *p0 = str;
2941 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2942 RTE_RETA_GROUP_SIZE;
2945 p = strchr(p0, '(');
2949 p0 = strchr(p, ')');
2953 if (size >= sizeof(s)) {
2954 printf("The string size exceeds the internal buffer size\n");
2957 snprintf(s, sizeof(s), "%.*s", size, p);
2958 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2959 if (ret <= 0 || ret != num) {
2960 printf("The bits of masks do not match the number of "
2961 "reta entries: %u\n", num);
2964 for (i = 0; i < ret; i++)
2965 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2971 cmd_showport_reta_parsed(void *parsed_result,
2972 __attribute__((unused)) struct cmdline *cl,
2973 __attribute__((unused)) void *data)
2975 struct cmd_showport_reta *res = parsed_result;
2976 struct rte_eth_rss_reta_entry64 reta_conf[8];
2977 struct rte_eth_dev_info dev_info;
2978 uint16_t max_reta_size;
2981 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2985 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2986 if (res->size == 0 || res->size > max_reta_size) {
2987 printf("Invalid redirection table size: %u (1-%u)\n",
2988 res->size, max_reta_size);
2992 memset(reta_conf, 0, sizeof(reta_conf));
2993 if (showport_parse_reta_config(reta_conf, res->size,
2994 res->list_of_items) < 0) {
2995 printf("Invalid string: %s for reta masks\n",
2996 res->list_of_items);
2999 port_rss_reta_info(res->port_id, reta_conf, res->size);
3002 cmdline_parse_token_string_t cmd_showport_reta_show =
3003 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3004 cmdline_parse_token_string_t cmd_showport_reta_port =
3005 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3006 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3007 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3008 cmdline_parse_token_string_t cmd_showport_reta_rss =
3009 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3010 cmdline_parse_token_string_t cmd_showport_reta_reta =
3011 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3012 cmdline_parse_token_num_t cmd_showport_reta_size =
3013 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3014 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3015 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3016 list_of_items, NULL);
3018 cmdline_parse_inst_t cmd_showport_reta = {
3019 .f = cmd_showport_reta_parsed,
3021 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3023 (void *)&cmd_showport_reta_show,
3024 (void *)&cmd_showport_reta_port,
3025 (void *)&cmd_showport_reta_port_id,
3026 (void *)&cmd_showport_reta_rss,
3027 (void *)&cmd_showport_reta_reta,
3028 (void *)&cmd_showport_reta_size,
3029 (void *)&cmd_showport_reta_list_of_items,
3034 /* *** Show RSS hash configuration *** */
3035 struct cmd_showport_rss_hash {
3036 cmdline_fixed_string_t show;
3037 cmdline_fixed_string_t port;
3039 cmdline_fixed_string_t rss_hash;
3040 cmdline_fixed_string_t rss_type;
3041 cmdline_fixed_string_t key; /* optional argument */
3044 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3045 __attribute__((unused)) struct cmdline *cl,
3048 struct cmd_showport_rss_hash *res = parsed_result;
3050 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3053 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3054 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3055 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3056 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3057 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3058 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3059 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3060 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3062 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3063 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3065 cmdline_parse_inst_t cmd_showport_rss_hash = {
3066 .f = cmd_showport_rss_hash_parsed,
3068 .help_str = "show port <port_id> rss-hash",
3070 (void *)&cmd_showport_rss_hash_show,
3071 (void *)&cmd_showport_rss_hash_port,
3072 (void *)&cmd_showport_rss_hash_port_id,
3073 (void *)&cmd_showport_rss_hash_rss_hash,
3078 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3079 .f = cmd_showport_rss_hash_parsed,
3081 .help_str = "show port <port_id> rss-hash key",
3083 (void *)&cmd_showport_rss_hash_show,
3084 (void *)&cmd_showport_rss_hash_port,
3085 (void *)&cmd_showport_rss_hash_port_id,
3086 (void *)&cmd_showport_rss_hash_rss_hash,
3087 (void *)&cmd_showport_rss_hash_rss_key,
3092 /* *** Configure DCB *** */
3093 struct cmd_config_dcb {
3094 cmdline_fixed_string_t port;
3095 cmdline_fixed_string_t config;
3097 cmdline_fixed_string_t dcb;
3098 cmdline_fixed_string_t vt;
3099 cmdline_fixed_string_t vt_en;
3101 cmdline_fixed_string_t pfc;
3102 cmdline_fixed_string_t pfc_en;
3106 cmd_config_dcb_parsed(void *parsed_result,
3107 __attribute__((unused)) struct cmdline *cl,
3108 __attribute__((unused)) void *data)
3110 struct cmd_config_dcb *res = parsed_result;
3111 portid_t port_id = res->port_id;
3112 struct rte_port *port;
3116 port = &ports[port_id];
3117 /** Check if the port is not started **/
3118 if (port->port_status != RTE_PORT_STOPPED) {
3119 printf("Please stop port %d first\n", port_id);
3123 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3124 printf("The invalid number of traffic class,"
3125 " only 4 or 8 allowed.\n");
3129 if (nb_fwd_lcores < res->num_tcs) {
3130 printf("nb_cores shouldn't be less than number of TCs.\n");
3133 if (!strncmp(res->pfc_en, "on", 2))
3138 /* DCB in VT mode */
3139 if (!strncmp(res->vt_en, "on", 2))
3140 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3141 (enum rte_eth_nb_tcs)res->num_tcs,
3144 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3145 (enum rte_eth_nb_tcs)res->num_tcs,
3150 printf("Cannot initialize network ports.\n");
3154 cmd_reconfig_device_queue(port_id, 1, 1);
3157 cmdline_parse_token_string_t cmd_config_dcb_port =
3158 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3159 cmdline_parse_token_string_t cmd_config_dcb_config =
3160 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3161 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3162 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3163 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3164 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3165 cmdline_parse_token_string_t cmd_config_dcb_vt =
3166 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3167 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3168 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3169 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3170 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3171 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3172 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3173 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3174 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3176 cmdline_parse_inst_t cmd_config_dcb = {
3177 .f = cmd_config_dcb_parsed,
3179 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3181 (void *)&cmd_config_dcb_port,
3182 (void *)&cmd_config_dcb_config,
3183 (void *)&cmd_config_dcb_port_id,
3184 (void *)&cmd_config_dcb_dcb,
3185 (void *)&cmd_config_dcb_vt,
3186 (void *)&cmd_config_dcb_vt_en,
3187 (void *)&cmd_config_dcb_num_tcs,
3188 (void *)&cmd_config_dcb_pfc,
3189 (void *)&cmd_config_dcb_pfc_en,
3194 /* *** configure number of packets per burst *** */
3195 struct cmd_config_burst {
3196 cmdline_fixed_string_t port;
3197 cmdline_fixed_string_t keyword;
3198 cmdline_fixed_string_t all;
3199 cmdline_fixed_string_t name;
3204 cmd_config_burst_parsed(void *parsed_result,
3205 __attribute__((unused)) struct cmdline *cl,
3206 __attribute__((unused)) void *data)
3208 struct cmd_config_burst *res = parsed_result;
3209 struct rte_eth_dev_info dev_info;
3210 uint16_t rec_nb_pkts;
3213 if (!all_ports_stopped()) {
3214 printf("Please stop all ports first\n");
3218 if (!strcmp(res->name, "burst")) {
3219 if (res->value == 0) {
3220 /* If user gives a value of zero, query the PMD for
3221 * its recommended Rx burst size. Testpmd uses a single
3222 * size for all ports, so assume all ports are the same
3223 * NIC model and use the values from Port 0.
3225 ret = eth_dev_info_get_print_err(0, &dev_info);
3229 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3231 if (rec_nb_pkts == 0) {
3232 printf("PMD does not recommend a burst size.\n"
3233 "User provided value must be between"
3234 " 1 and %d\n", MAX_PKT_BURST);
3236 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3237 printf("PMD recommended burst size of %d"
3238 " exceeds maximum value of %d\n",
3239 rec_nb_pkts, MAX_PKT_BURST);
3242 printf("Using PMD-provided burst value of %d\n",
3244 nb_pkt_per_burst = rec_nb_pkts;
3245 } else if (res->value > MAX_PKT_BURST) {
3246 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3249 nb_pkt_per_burst = res->value;
3251 printf("Unknown parameter\n");
3257 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3260 cmdline_parse_token_string_t cmd_config_burst_port =
3261 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3262 cmdline_parse_token_string_t cmd_config_burst_keyword =
3263 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3264 cmdline_parse_token_string_t cmd_config_burst_all =
3265 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3266 cmdline_parse_token_string_t cmd_config_burst_name =
3267 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3268 cmdline_parse_token_num_t cmd_config_burst_value =
3269 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3271 cmdline_parse_inst_t cmd_config_burst = {
3272 .f = cmd_config_burst_parsed,
3274 .help_str = "port config all burst <value>",
3276 (void *)&cmd_config_burst_port,
3277 (void *)&cmd_config_burst_keyword,
3278 (void *)&cmd_config_burst_all,
3279 (void *)&cmd_config_burst_name,
3280 (void *)&cmd_config_burst_value,
3285 /* *** configure rx/tx queues *** */
3286 struct cmd_config_thresh {
3287 cmdline_fixed_string_t port;
3288 cmdline_fixed_string_t keyword;
3289 cmdline_fixed_string_t all;
3290 cmdline_fixed_string_t name;
3295 cmd_config_thresh_parsed(void *parsed_result,
3296 __attribute__((unused)) struct cmdline *cl,
3297 __attribute__((unused)) void *data)
3299 struct cmd_config_thresh *res = parsed_result;
3301 if (!all_ports_stopped()) {
3302 printf("Please stop all ports first\n");
3306 if (!strcmp(res->name, "txpt"))
3307 tx_pthresh = res->value;
3308 else if(!strcmp(res->name, "txht"))
3309 tx_hthresh = res->value;
3310 else if(!strcmp(res->name, "txwt"))
3311 tx_wthresh = res->value;
3312 else if(!strcmp(res->name, "rxpt"))
3313 rx_pthresh = res->value;
3314 else if(!strcmp(res->name, "rxht"))
3315 rx_hthresh = res->value;
3316 else if(!strcmp(res->name, "rxwt"))
3317 rx_wthresh = res->value;
3319 printf("Unknown parameter\n");
3325 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3328 cmdline_parse_token_string_t cmd_config_thresh_port =
3329 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3330 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3331 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3332 cmdline_parse_token_string_t cmd_config_thresh_all =
3333 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3334 cmdline_parse_token_string_t cmd_config_thresh_name =
3335 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3336 "txpt#txht#txwt#rxpt#rxht#rxwt");
3337 cmdline_parse_token_num_t cmd_config_thresh_value =
3338 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3340 cmdline_parse_inst_t cmd_config_thresh = {
3341 .f = cmd_config_thresh_parsed,
3343 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3345 (void *)&cmd_config_thresh_port,
3346 (void *)&cmd_config_thresh_keyword,
3347 (void *)&cmd_config_thresh_all,
3348 (void *)&cmd_config_thresh_name,
3349 (void *)&cmd_config_thresh_value,
3354 /* *** configure free/rs threshold *** */
3355 struct cmd_config_threshold {
3356 cmdline_fixed_string_t port;
3357 cmdline_fixed_string_t keyword;
3358 cmdline_fixed_string_t all;
3359 cmdline_fixed_string_t name;
3364 cmd_config_threshold_parsed(void *parsed_result,
3365 __attribute__((unused)) struct cmdline *cl,
3366 __attribute__((unused)) void *data)
3368 struct cmd_config_threshold *res = parsed_result;
3370 if (!all_ports_stopped()) {
3371 printf("Please stop all ports first\n");
3375 if (!strcmp(res->name, "txfreet"))
3376 tx_free_thresh = res->value;
3377 else if (!strcmp(res->name, "txrst"))
3378 tx_rs_thresh = res->value;
3379 else if (!strcmp(res->name, "rxfreet"))
3380 rx_free_thresh = res->value;
3382 printf("Unknown parameter\n");
3388 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3391 cmdline_parse_token_string_t cmd_config_threshold_port =
3392 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3393 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3394 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3396 cmdline_parse_token_string_t cmd_config_threshold_all =
3397 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3398 cmdline_parse_token_string_t cmd_config_threshold_name =
3399 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3400 "txfreet#txrst#rxfreet");
3401 cmdline_parse_token_num_t cmd_config_threshold_value =
3402 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3404 cmdline_parse_inst_t cmd_config_threshold = {
3405 .f = cmd_config_threshold_parsed,
3407 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3409 (void *)&cmd_config_threshold_port,
3410 (void *)&cmd_config_threshold_keyword,
3411 (void *)&cmd_config_threshold_all,
3412 (void *)&cmd_config_threshold_name,
3413 (void *)&cmd_config_threshold_value,
3419 struct cmd_stop_result {
3420 cmdline_fixed_string_t stop;
3423 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3424 __attribute__((unused)) struct cmdline *cl,
3425 __attribute__((unused)) void *data)
3427 stop_packet_forwarding();
3430 cmdline_parse_token_string_t cmd_stop_stop =
3431 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3433 cmdline_parse_inst_t cmd_stop = {
3434 .f = cmd_stop_parsed,
3436 .help_str = "stop: Stop packet forwarding",
3438 (void *)&cmd_stop_stop,
3443 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3446 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3447 unsigned int *parsed_items, int check_unique_values)
3449 unsigned int nb_item;
3457 * First parse all items in the list and store their value.
3462 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3464 if ((c >= '0') && (c <= '9')) {
3465 value = (unsigned int) (value * 10 + (c - '0'));
3470 printf("character %c is not a decimal digit\n", c);
3474 printf("No valid value before comma\n");
3477 if (nb_item < max_items) {
3478 parsed_items[nb_item] = value;
3484 if (nb_item >= max_items) {
3485 printf("Number of %s = %u > %u (maximum items)\n",
3486 item_name, nb_item + 1, max_items);
3489 parsed_items[nb_item++] = value;
3490 if (! check_unique_values)
3494 * Then, check that all values in the list are differents.
3495 * No optimization here...
3497 for (i = 0; i < nb_item; i++) {
3498 for (j = i + 1; j < nb_item; j++) {
3499 if (parsed_items[j] == parsed_items[i]) {
3500 printf("duplicated %s %u at index %u and %u\n",
3501 item_name, parsed_items[i], i, j);
3509 struct cmd_set_list_result {
3510 cmdline_fixed_string_t cmd_keyword;
3511 cmdline_fixed_string_t list_name;
3512 cmdline_fixed_string_t list_of_items;
3515 static void cmd_set_list_parsed(void *parsed_result,
3516 __attribute__((unused)) struct cmdline *cl,
3517 __attribute__((unused)) void *data)
3519 struct cmd_set_list_result *res;
3521 unsigned int lcorelist[RTE_MAX_LCORE];
3522 unsigned int portlist[RTE_MAX_ETHPORTS];
3524 unsigned int nb_item;
3526 if (test_done == 0) {
3527 printf("Please stop forwarding first\n");
3531 res = parsed_result;
3532 if (!strcmp(res->list_name, "corelist")) {
3533 nb_item = parse_item_list(res->list_of_items, "core",
3535 parsed_items.lcorelist, 1);
3537 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3542 if (!strcmp(res->list_name, "portlist")) {
3543 nb_item = parse_item_list(res->list_of_items, "port",
3545 parsed_items.portlist, 1);
3547 set_fwd_ports_list(parsed_items.portlist, nb_item);
3553 cmdline_parse_token_string_t cmd_set_list_keyword =
3554 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3556 cmdline_parse_token_string_t cmd_set_list_name =
3557 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3558 "corelist#portlist");
3559 cmdline_parse_token_string_t cmd_set_list_of_items =
3560 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3563 cmdline_parse_inst_t cmd_set_fwd_list = {
3564 .f = cmd_set_list_parsed,
3566 .help_str = "set corelist|portlist <list0[,list1]*>",
3568 (void *)&cmd_set_list_keyword,
3569 (void *)&cmd_set_list_name,
3570 (void *)&cmd_set_list_of_items,
3575 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3577 struct cmd_setmask_result {
3578 cmdline_fixed_string_t set;
3579 cmdline_fixed_string_t mask;
3583 static void cmd_set_mask_parsed(void *parsed_result,
3584 __attribute__((unused)) struct cmdline *cl,
3585 __attribute__((unused)) void *data)
3587 struct cmd_setmask_result *res = parsed_result;
3589 if (test_done == 0) {
3590 printf("Please stop forwarding first\n");
3593 if (!strcmp(res->mask, "coremask")) {
3594 set_fwd_lcores_mask(res->hexavalue);
3596 } else if (!strcmp(res->mask, "portmask")) {
3597 set_fwd_ports_mask(res->hexavalue);
3602 cmdline_parse_token_string_t cmd_setmask_set =
3603 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3604 cmdline_parse_token_string_t cmd_setmask_mask =
3605 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3606 "coremask#portmask");
3607 cmdline_parse_token_num_t cmd_setmask_value =
3608 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3610 cmdline_parse_inst_t cmd_set_fwd_mask = {
3611 .f = cmd_set_mask_parsed,
3613 .help_str = "set coremask|portmask <hexadecimal value>",
3615 (void *)&cmd_setmask_set,
3616 (void *)&cmd_setmask_mask,
3617 (void *)&cmd_setmask_value,
3623 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3625 struct cmd_set_result {
3626 cmdline_fixed_string_t set;
3627 cmdline_fixed_string_t what;
3631 static void cmd_set_parsed(void *parsed_result,
3632 __attribute__((unused)) struct cmdline *cl,
3633 __attribute__((unused)) void *data)
3635 struct cmd_set_result *res = parsed_result;
3636 if (!strcmp(res->what, "nbport")) {
3637 set_fwd_ports_number(res->value);
3639 } else if (!strcmp(res->what, "nbcore")) {
3640 set_fwd_lcores_number(res->value);
3642 } else if (!strcmp(res->what, "burst"))
3643 set_nb_pkt_per_burst(res->value);
3644 else if (!strcmp(res->what, "verbose"))
3645 set_verbose_level(res->value);
3648 cmdline_parse_token_string_t cmd_set_set =
3649 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3650 cmdline_parse_token_string_t cmd_set_what =
3651 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3652 "nbport#nbcore#burst#verbose");
3653 cmdline_parse_token_num_t cmd_set_value =
3654 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3656 cmdline_parse_inst_t cmd_set_numbers = {
3657 .f = cmd_set_parsed,
3659 .help_str = "set nbport|nbcore|burst|verbose <value>",
3661 (void *)&cmd_set_set,
3662 (void *)&cmd_set_what,
3663 (void *)&cmd_set_value,
3668 /* *** SET LOG LEVEL CONFIGURATION *** */
3670 struct cmd_set_log_result {
3671 cmdline_fixed_string_t set;
3672 cmdline_fixed_string_t log;
3673 cmdline_fixed_string_t type;
3678 cmd_set_log_parsed(void *parsed_result,
3679 __attribute__((unused)) struct cmdline *cl,
3680 __attribute__((unused)) void *data)
3682 struct cmd_set_log_result *res;
3685 res = parsed_result;
3686 if (!strcmp(res->type, "global"))
3687 rte_log_set_global_level(res->level);
3689 ret = rte_log_set_level_regexp(res->type, res->level);
3691 printf("Unable to set log level\n");
3695 cmdline_parse_token_string_t cmd_set_log_set =
3696 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3697 cmdline_parse_token_string_t cmd_set_log_log =
3698 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3699 cmdline_parse_token_string_t cmd_set_log_type =
3700 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3701 cmdline_parse_token_num_t cmd_set_log_level =
3702 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3704 cmdline_parse_inst_t cmd_set_log = {
3705 .f = cmd_set_log_parsed,
3707 .help_str = "set log global|<type> <level>",
3709 (void *)&cmd_set_log_set,
3710 (void *)&cmd_set_log_log,
3711 (void *)&cmd_set_log_type,
3712 (void *)&cmd_set_log_level,
3717 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3719 struct cmd_set_txpkts_result {
3720 cmdline_fixed_string_t cmd_keyword;
3721 cmdline_fixed_string_t txpkts;
3722 cmdline_fixed_string_t seg_lengths;
3726 cmd_set_txpkts_parsed(void *parsed_result,
3727 __attribute__((unused)) struct cmdline *cl,
3728 __attribute__((unused)) void *data)
3730 struct cmd_set_txpkts_result *res;
3731 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3732 unsigned int nb_segs;
3734 res = parsed_result;
3735 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3736 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3738 set_tx_pkt_segments(seg_lengths, nb_segs);
3741 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3742 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3743 cmd_keyword, "set");
3744 cmdline_parse_token_string_t cmd_set_txpkts_name =
3745 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3747 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3748 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3751 cmdline_parse_inst_t cmd_set_txpkts = {
3752 .f = cmd_set_txpkts_parsed,
3754 .help_str = "set txpkts <len0[,len1]*>",
3756 (void *)&cmd_set_txpkts_keyword,
3757 (void *)&cmd_set_txpkts_name,
3758 (void *)&cmd_set_txpkts_lengths,
3763 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3765 struct cmd_set_txsplit_result {
3766 cmdline_fixed_string_t cmd_keyword;
3767 cmdline_fixed_string_t txsplit;
3768 cmdline_fixed_string_t mode;
3772 cmd_set_txsplit_parsed(void *parsed_result,
3773 __attribute__((unused)) struct cmdline *cl,
3774 __attribute__((unused)) void *data)
3776 struct cmd_set_txsplit_result *res;
3778 res = parsed_result;
3779 set_tx_pkt_split(res->mode);
3782 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3783 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3784 cmd_keyword, "set");
3785 cmdline_parse_token_string_t cmd_set_txsplit_name =
3786 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3787 txsplit, "txsplit");
3788 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3789 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3792 cmdline_parse_inst_t cmd_set_txsplit = {
3793 .f = cmd_set_txsplit_parsed,
3795 .help_str = "set txsplit on|off|rand",
3797 (void *)&cmd_set_txsplit_keyword,
3798 (void *)&cmd_set_txsplit_name,
3799 (void *)&cmd_set_txsplit_mode,
3804 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3805 struct cmd_rx_vlan_filter_all_result {
3806 cmdline_fixed_string_t rx_vlan;
3807 cmdline_fixed_string_t what;
3808 cmdline_fixed_string_t all;
3813 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3814 __attribute__((unused)) struct cmdline *cl,
3815 __attribute__((unused)) void *data)
3817 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3819 if (!strcmp(res->what, "add"))
3820 rx_vlan_all_filter_set(res->port_id, 1);
3822 rx_vlan_all_filter_set(res->port_id, 0);
3825 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3826 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3827 rx_vlan, "rx_vlan");
3828 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3829 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3831 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3832 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3834 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3835 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3838 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3839 .f = cmd_rx_vlan_filter_all_parsed,
3841 .help_str = "rx_vlan add|rm all <port_id>: "
3842 "Add/Remove all identifiers to/from the set of VLAN "
3843 "identifiers filtered by a port",
3845 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3846 (void *)&cmd_rx_vlan_filter_all_what,
3847 (void *)&cmd_rx_vlan_filter_all_all,
3848 (void *)&cmd_rx_vlan_filter_all_portid,
3853 /* *** VLAN OFFLOAD SET ON A PORT *** */
3854 struct cmd_vlan_offload_result {
3855 cmdline_fixed_string_t vlan;
3856 cmdline_fixed_string_t set;
3857 cmdline_fixed_string_t vlan_type;
3858 cmdline_fixed_string_t what;
3859 cmdline_fixed_string_t on;
3860 cmdline_fixed_string_t port_id;
3864 cmd_vlan_offload_parsed(void *parsed_result,
3865 __attribute__((unused)) struct cmdline *cl,
3866 __attribute__((unused)) void *data)
3869 struct cmd_vlan_offload_result *res = parsed_result;
3872 portid_t port_id = 0;
3876 len = strnlen(str, STR_TOKEN_SIZE);
3878 /* Get port_id first */
3886 tmp = strtoul(str, NULL, 0);
3887 /* If port_id greater that what portid_t can represent, return */
3888 if(tmp >= RTE_MAX_ETHPORTS)
3890 port_id = (portid_t)tmp;
3892 if (!strcmp(res->on, "on"))
3897 if (!strcmp(res->what, "strip"))
3898 rx_vlan_strip_set(port_id, on);
3899 else if(!strcmp(res->what, "stripq")){
3900 uint16_t queue_id = 0;
3902 /* No queue_id, return */
3904 printf("must specify (port,queue_id)\n");
3907 tmp = strtoul(str + i + 1, NULL, 0);
3908 /* If queue_id greater that what 16-bits can represent, return */
3912 queue_id = (uint16_t)tmp;
3913 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3915 else if (!strcmp(res->what, "filter"))
3916 rx_vlan_filter_set(port_id, on);
3917 else if (!strcmp(res->what, "qinq_strip"))
3918 rx_vlan_qinq_strip_set(port_id, on);
3920 vlan_extend_set(port_id, on);
3925 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3926 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3928 cmdline_parse_token_string_t cmd_vlan_offload_set =
3929 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3931 cmdline_parse_token_string_t cmd_vlan_offload_what =
3932 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3933 what, "strip#filter#qinq_strip#extend#stripq");
3934 cmdline_parse_token_string_t cmd_vlan_offload_on =
3935 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3937 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3938 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3941 cmdline_parse_inst_t cmd_vlan_offload = {
3942 .f = cmd_vlan_offload_parsed,
3944 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
3945 "<port_id[,queue_id]>: "
3946 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
3948 (void *)&cmd_vlan_offload_vlan,
3949 (void *)&cmd_vlan_offload_set,
3950 (void *)&cmd_vlan_offload_what,
3951 (void *)&cmd_vlan_offload_on,
3952 (void *)&cmd_vlan_offload_portid,
3957 /* *** VLAN TPID SET ON A PORT *** */
3958 struct cmd_vlan_tpid_result {
3959 cmdline_fixed_string_t vlan;
3960 cmdline_fixed_string_t set;
3961 cmdline_fixed_string_t vlan_type;
3962 cmdline_fixed_string_t what;
3968 cmd_vlan_tpid_parsed(void *parsed_result,
3969 __attribute__((unused)) struct cmdline *cl,
3970 __attribute__((unused)) void *data)
3972 struct cmd_vlan_tpid_result *res = parsed_result;
3973 enum rte_vlan_type vlan_type;
3975 if (!strcmp(res->vlan_type, "inner"))
3976 vlan_type = ETH_VLAN_TYPE_INNER;
3977 else if (!strcmp(res->vlan_type, "outer"))
3978 vlan_type = ETH_VLAN_TYPE_OUTER;
3980 printf("Unknown vlan type\n");
3983 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3986 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3987 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3989 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3990 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3992 cmdline_parse_token_string_t cmd_vlan_type =
3993 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3994 vlan_type, "inner#outer");
3995 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3996 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3998 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3999 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4001 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4002 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4005 cmdline_parse_inst_t cmd_vlan_tpid = {
4006 .f = cmd_vlan_tpid_parsed,
4008 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4009 "Set the VLAN Ether type",
4011 (void *)&cmd_vlan_tpid_vlan,
4012 (void *)&cmd_vlan_tpid_set,
4013 (void *)&cmd_vlan_type,
4014 (void *)&cmd_vlan_tpid_what,
4015 (void *)&cmd_vlan_tpid_tpid,
4016 (void *)&cmd_vlan_tpid_portid,
4021 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4022 struct cmd_rx_vlan_filter_result {
4023 cmdline_fixed_string_t rx_vlan;
4024 cmdline_fixed_string_t what;
4030 cmd_rx_vlan_filter_parsed(void *parsed_result,
4031 __attribute__((unused)) struct cmdline *cl,
4032 __attribute__((unused)) void *data)
4034 struct cmd_rx_vlan_filter_result *res = parsed_result;
4036 if (!strcmp(res->what, "add"))
4037 rx_vft_set(res->port_id, res->vlan_id, 1);
4039 rx_vft_set(res->port_id, res->vlan_id, 0);
4042 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4043 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4044 rx_vlan, "rx_vlan");
4045 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4046 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4048 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4049 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4051 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4052 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4055 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4056 .f = cmd_rx_vlan_filter_parsed,
4058 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4059 "Add/Remove a VLAN identifier to/from the set of VLAN "
4060 "identifiers filtered by a port",
4062 (void *)&cmd_rx_vlan_filter_rx_vlan,
4063 (void *)&cmd_rx_vlan_filter_what,
4064 (void *)&cmd_rx_vlan_filter_vlanid,
4065 (void *)&cmd_rx_vlan_filter_portid,
4070 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4071 struct cmd_tx_vlan_set_result {
4072 cmdline_fixed_string_t tx_vlan;
4073 cmdline_fixed_string_t set;
4079 cmd_tx_vlan_set_parsed(void *parsed_result,
4080 __attribute__((unused)) struct cmdline *cl,
4081 __attribute__((unused)) void *data)
4083 struct cmd_tx_vlan_set_result *res = parsed_result;
4085 if (!port_is_stopped(res->port_id)) {
4086 printf("Please stop port %d first\n", res->port_id);
4090 tx_vlan_set(res->port_id, res->vlan_id);
4092 cmd_reconfig_device_queue(res->port_id, 1, 1);
4095 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4096 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4097 tx_vlan, "tx_vlan");
4098 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4099 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4101 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4102 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4104 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4105 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4108 cmdline_parse_inst_t cmd_tx_vlan_set = {
4109 .f = cmd_tx_vlan_set_parsed,
4111 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4112 "Enable hardware insertion of a single VLAN header "
4113 "with a given TAG Identifier in packets sent on a port",
4115 (void *)&cmd_tx_vlan_set_tx_vlan,
4116 (void *)&cmd_tx_vlan_set_set,
4117 (void *)&cmd_tx_vlan_set_portid,
4118 (void *)&cmd_tx_vlan_set_vlanid,
4123 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4124 struct cmd_tx_vlan_set_qinq_result {
4125 cmdline_fixed_string_t tx_vlan;
4126 cmdline_fixed_string_t set;
4129 uint16_t vlan_id_outer;
4133 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4134 __attribute__((unused)) struct cmdline *cl,
4135 __attribute__((unused)) void *data)
4137 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4139 if (!port_is_stopped(res->port_id)) {
4140 printf("Please stop port %d first\n", res->port_id);
4144 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4146 cmd_reconfig_device_queue(res->port_id, 1, 1);
4149 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4150 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4151 tx_vlan, "tx_vlan");
4152 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4153 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4155 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4156 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4158 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4159 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4161 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4162 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4163 vlan_id_outer, UINT16);
4165 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4166 .f = cmd_tx_vlan_set_qinq_parsed,
4168 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4169 "Enable hardware insertion of double VLAN header "
4170 "with given TAG Identifiers in packets sent on a port",
4172 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4173 (void *)&cmd_tx_vlan_set_qinq_set,
4174 (void *)&cmd_tx_vlan_set_qinq_portid,
4175 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4176 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4181 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4182 struct cmd_tx_vlan_set_pvid_result {
4183 cmdline_fixed_string_t tx_vlan;
4184 cmdline_fixed_string_t set;
4185 cmdline_fixed_string_t pvid;
4188 cmdline_fixed_string_t mode;
4192 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4193 __attribute__((unused)) struct cmdline *cl,
4194 __attribute__((unused)) void *data)
4196 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4198 if (strcmp(res->mode, "on") == 0)
4199 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4201 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4204 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4205 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4206 tx_vlan, "tx_vlan");
4207 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4208 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4210 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4211 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4213 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4214 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4216 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4217 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4219 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4220 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4223 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4224 .f = cmd_tx_vlan_set_pvid_parsed,
4226 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4228 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4229 (void *)&cmd_tx_vlan_set_pvid_set,
4230 (void *)&cmd_tx_vlan_set_pvid_pvid,
4231 (void *)&cmd_tx_vlan_set_pvid_port_id,
4232 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4233 (void *)&cmd_tx_vlan_set_pvid_mode,
4238 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4239 struct cmd_tx_vlan_reset_result {
4240 cmdline_fixed_string_t tx_vlan;
4241 cmdline_fixed_string_t reset;
4246 cmd_tx_vlan_reset_parsed(void *parsed_result,
4247 __attribute__((unused)) struct cmdline *cl,
4248 __attribute__((unused)) void *data)
4250 struct cmd_tx_vlan_reset_result *res = parsed_result;
4252 if (!port_is_stopped(res->port_id)) {
4253 printf("Please stop port %d first\n", res->port_id);
4257 tx_vlan_reset(res->port_id);
4259 cmd_reconfig_device_queue(res->port_id, 1, 1);
4262 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4263 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4264 tx_vlan, "tx_vlan");
4265 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4266 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4268 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4269 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4272 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4273 .f = cmd_tx_vlan_reset_parsed,
4275 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4276 "VLAN header in packets sent on a port",
4278 (void *)&cmd_tx_vlan_reset_tx_vlan,
4279 (void *)&cmd_tx_vlan_reset_reset,
4280 (void *)&cmd_tx_vlan_reset_portid,
4286 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4287 struct cmd_csum_result {
4288 cmdline_fixed_string_t csum;
4289 cmdline_fixed_string_t mode;
4290 cmdline_fixed_string_t proto;
4291 cmdline_fixed_string_t hwsw;
4296 csum_show(int port_id)
4298 struct rte_eth_dev_info dev_info;
4299 uint64_t tx_offloads;
4302 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4303 printf("Parse tunnel is %s\n",
4304 (ports[port_id].parse_tunnel) ? "on" : "off");
4305 printf("IP checksum offload is %s\n",
4306 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4307 printf("UDP checksum offload is %s\n",
4308 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4309 printf("TCP checksum offload is %s\n",
4310 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4311 printf("SCTP checksum offload is %s\n",
4312 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4313 printf("Outer-Ip checksum offload is %s\n",
4314 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4315 printf("Outer-Udp checksum offload is %s\n",
4316 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4318 /* display warnings if configuration is not supported by the NIC */
4319 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4323 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4324 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4325 printf("Warning: hardware IP checksum enabled but not "
4326 "supported by port %d\n", port_id);
4328 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4329 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4330 printf("Warning: hardware UDP checksum enabled but not "
4331 "supported by port %d\n", port_id);
4333 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4334 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4335 printf("Warning: hardware TCP checksum enabled but not "
4336 "supported by port %d\n", port_id);
4338 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4339 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4340 printf("Warning: hardware SCTP checksum enabled but not "
4341 "supported by port %d\n", port_id);
4343 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4344 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4345 printf("Warning: hardware outer IP checksum enabled but not "
4346 "supported by port %d\n", port_id);
4348 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4349 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4351 printf("Warning: hardware outer UDP checksum enabled but not "
4352 "supported by port %d\n", port_id);
4357 cmd_config_queue_tx_offloads(struct rte_port *port)
4361 /* Apply queue tx offloads configuration */
4362 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4363 port->tx_conf[k].offloads =
4364 port->dev_conf.txmode.offloads;
4368 cmd_csum_parsed(void *parsed_result,
4369 __attribute__((unused)) struct cmdline *cl,
4370 __attribute__((unused)) void *data)
4372 struct cmd_csum_result *res = parsed_result;
4374 uint64_t csum_offloads = 0;
4375 struct rte_eth_dev_info dev_info;
4378 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4379 printf("invalid port %d\n", res->port_id);
4382 if (!port_is_stopped(res->port_id)) {
4383 printf("Please stop port %d first\n", res->port_id);
4387 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4391 if (!strcmp(res->mode, "set")) {
4393 if (!strcmp(res->hwsw, "hw"))
4396 if (!strcmp(res->proto, "ip")) {
4397 if (hw == 0 || (dev_info.tx_offload_capa &
4398 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4399 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4401 printf("IP checksum offload is not supported "
4402 "by port %u\n", res->port_id);
4404 } else if (!strcmp(res->proto, "udp")) {
4405 if (hw == 0 || (dev_info.tx_offload_capa &
4406 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4407 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4409 printf("UDP checksum offload is not supported "
4410 "by port %u\n", res->port_id);
4412 } else if (!strcmp(res->proto, "tcp")) {
4413 if (hw == 0 || (dev_info.tx_offload_capa &
4414 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4415 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4417 printf("TCP checksum offload is not supported "
4418 "by port %u\n", res->port_id);
4420 } else if (!strcmp(res->proto, "sctp")) {
4421 if (hw == 0 || (dev_info.tx_offload_capa &
4422 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4423 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4425 printf("SCTP checksum offload is not supported "
4426 "by port %u\n", res->port_id);
4428 } else if (!strcmp(res->proto, "outer-ip")) {
4429 if (hw == 0 || (dev_info.tx_offload_capa &
4430 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4432 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4434 printf("Outer IP checksum offload is not "
4435 "supported by port %u\n", res->port_id);
4437 } else if (!strcmp(res->proto, "outer-udp")) {
4438 if (hw == 0 || (dev_info.tx_offload_capa &
4439 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4441 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4443 printf("Outer UDP checksum offload is not "
4444 "supported by port %u\n", res->port_id);
4449 ports[res->port_id].dev_conf.txmode.offloads |=
4452 ports[res->port_id].dev_conf.txmode.offloads &=
4455 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4457 csum_show(res->port_id);
4459 cmd_reconfig_device_queue(res->port_id, 1, 1);
4462 cmdline_parse_token_string_t cmd_csum_csum =
4463 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4465 cmdline_parse_token_string_t cmd_csum_mode =
4466 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4468 cmdline_parse_token_string_t cmd_csum_proto =
4469 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4470 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4471 cmdline_parse_token_string_t cmd_csum_hwsw =
4472 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4474 cmdline_parse_token_num_t cmd_csum_portid =
4475 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4478 cmdline_parse_inst_t cmd_csum_set = {
4479 .f = cmd_csum_parsed,
4481 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4482 "Enable/Disable hardware calculation of L3/L4 checksum when "
4483 "using csum forward engine",
4485 (void *)&cmd_csum_csum,
4486 (void *)&cmd_csum_mode,
4487 (void *)&cmd_csum_proto,
4488 (void *)&cmd_csum_hwsw,
4489 (void *)&cmd_csum_portid,
4494 cmdline_parse_token_string_t cmd_csum_mode_show =
4495 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4498 cmdline_parse_inst_t cmd_csum_show = {
4499 .f = cmd_csum_parsed,
4501 .help_str = "csum show <port_id>: Show checksum offload configuration",
4503 (void *)&cmd_csum_csum,
4504 (void *)&cmd_csum_mode_show,
4505 (void *)&cmd_csum_portid,
4510 /* Enable/disable tunnel parsing */
4511 struct cmd_csum_tunnel_result {
4512 cmdline_fixed_string_t csum;
4513 cmdline_fixed_string_t parse;
4514 cmdline_fixed_string_t onoff;
4519 cmd_csum_tunnel_parsed(void *parsed_result,
4520 __attribute__((unused)) struct cmdline *cl,
4521 __attribute__((unused)) void *data)
4523 struct cmd_csum_tunnel_result *res = parsed_result;
4525 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4528 if (!strcmp(res->onoff, "on"))
4529 ports[res->port_id].parse_tunnel = 1;
4531 ports[res->port_id].parse_tunnel = 0;
4533 csum_show(res->port_id);
4536 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4537 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4539 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4540 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4541 parse, "parse-tunnel");
4542 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4543 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4545 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4546 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4549 cmdline_parse_inst_t cmd_csum_tunnel = {
4550 .f = cmd_csum_tunnel_parsed,
4552 .help_str = "csum parse-tunnel on|off <port_id>: "
4553 "Enable/Disable parsing of tunnels for csum engine",
4555 (void *)&cmd_csum_tunnel_csum,
4556 (void *)&cmd_csum_tunnel_parse,
4557 (void *)&cmd_csum_tunnel_onoff,
4558 (void *)&cmd_csum_tunnel_portid,
4563 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4564 struct cmd_tso_set_result {
4565 cmdline_fixed_string_t tso;
4566 cmdline_fixed_string_t mode;
4572 cmd_tso_set_parsed(void *parsed_result,
4573 __attribute__((unused)) struct cmdline *cl,
4574 __attribute__((unused)) void *data)
4576 struct cmd_tso_set_result *res = parsed_result;
4577 struct rte_eth_dev_info dev_info;
4580 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4582 if (!port_is_stopped(res->port_id)) {
4583 printf("Please stop port %d first\n", res->port_id);
4587 if (!strcmp(res->mode, "set"))
4588 ports[res->port_id].tso_segsz = res->tso_segsz;
4590 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4594 if ((ports[res->port_id].tso_segsz != 0) &&
4595 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4596 printf("Error: TSO is not supported by port %d\n",
4601 if (ports[res->port_id].tso_segsz == 0) {
4602 ports[res->port_id].dev_conf.txmode.offloads &=
4603 ~DEV_TX_OFFLOAD_TCP_TSO;
4604 printf("TSO for non-tunneled packets is disabled\n");
4606 ports[res->port_id].dev_conf.txmode.offloads |=
4607 DEV_TX_OFFLOAD_TCP_TSO;
4608 printf("TSO segment size for non-tunneled packets is %d\n",
4609 ports[res->port_id].tso_segsz);
4611 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4613 /* display warnings if configuration is not supported by the NIC */
4614 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4618 if ((ports[res->port_id].tso_segsz != 0) &&
4619 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4620 printf("Warning: TSO enabled but not "
4621 "supported by port %d\n", res->port_id);
4624 cmd_reconfig_device_queue(res->port_id, 1, 1);
4627 cmdline_parse_token_string_t cmd_tso_set_tso =
4628 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4630 cmdline_parse_token_string_t cmd_tso_set_mode =
4631 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4633 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4634 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4636 cmdline_parse_token_num_t cmd_tso_set_portid =
4637 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4640 cmdline_parse_inst_t cmd_tso_set = {
4641 .f = cmd_tso_set_parsed,
4643 .help_str = "tso set <tso_segsz> <port_id>: "
4644 "Set TSO segment size of non-tunneled packets for csum engine "
4647 (void *)&cmd_tso_set_tso,
4648 (void *)&cmd_tso_set_mode,
4649 (void *)&cmd_tso_set_tso_segsz,
4650 (void *)&cmd_tso_set_portid,
4655 cmdline_parse_token_string_t cmd_tso_show_mode =
4656 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4660 cmdline_parse_inst_t cmd_tso_show = {
4661 .f = cmd_tso_set_parsed,
4663 .help_str = "tso show <port_id>: "
4664 "Show TSO segment size of non-tunneled packets for csum engine",
4666 (void *)&cmd_tso_set_tso,
4667 (void *)&cmd_tso_show_mode,
4668 (void *)&cmd_tso_set_portid,
4673 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4674 struct cmd_tunnel_tso_set_result {
4675 cmdline_fixed_string_t tso;
4676 cmdline_fixed_string_t mode;
4681 static struct rte_eth_dev_info
4682 check_tunnel_tso_nic_support(portid_t port_id)
4684 struct rte_eth_dev_info dev_info;
4686 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4689 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4690 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4691 "not enabled for port %d\n", port_id);
4692 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4693 printf("Warning: GRE TUNNEL TSO not supported therefore "
4694 "not enabled for port %d\n", port_id);
4695 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4696 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4697 "not enabled for port %d\n", port_id);
4698 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4699 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4700 "not enabled for port %d\n", port_id);
4701 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4702 printf("Warning: IP TUNNEL TSO not supported therefore "
4703 "not enabled for port %d\n", port_id);
4704 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4705 printf("Warning: UDP TUNNEL TSO not supported therefore "
4706 "not enabled for port %d\n", port_id);
4711 cmd_tunnel_tso_set_parsed(void *parsed_result,
4712 __attribute__((unused)) struct cmdline *cl,
4713 __attribute__((unused)) void *data)
4715 struct cmd_tunnel_tso_set_result *res = parsed_result;
4716 struct rte_eth_dev_info dev_info;
4718 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4720 if (!port_is_stopped(res->port_id)) {
4721 printf("Please stop port %d first\n", res->port_id);
4725 if (!strcmp(res->mode, "set"))
4726 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4728 dev_info = check_tunnel_tso_nic_support(res->port_id);
4729 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4730 ports[res->port_id].dev_conf.txmode.offloads &=
4731 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4732 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4733 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4734 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4735 DEV_TX_OFFLOAD_IP_TNL_TSO |
4736 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4737 printf("TSO for tunneled packets is disabled\n");
4739 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4740 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4741 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4742 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4743 DEV_TX_OFFLOAD_IP_TNL_TSO |
4744 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4746 ports[res->port_id].dev_conf.txmode.offloads |=
4747 (tso_offloads & dev_info.tx_offload_capa);
4748 printf("TSO segment size for tunneled packets is %d\n",
4749 ports[res->port_id].tunnel_tso_segsz);
4751 /* Below conditions are needed to make it work:
4752 * (1) tunnel TSO is supported by the NIC;
4753 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4755 * (3) for tunneled pkts with outer L3 of IPv4,
4756 * "csum set outer-ip" must be set to hw, because after tso,
4757 * total_len of outer IP header is changed, and the checksum
4758 * of outer IP header calculated by sw should be wrong; that
4759 * is not necessary for IPv6 tunneled pkts because there's no
4760 * checksum in IP header anymore.
4763 if (!ports[res->port_id].parse_tunnel)
4764 printf("Warning: csum parse_tunnel must be set "
4765 "so that tunneled packets are recognized\n");
4766 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4767 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4768 printf("Warning: csum set outer-ip must be set to hw "
4769 "if outer L3 is IPv4; not necessary for IPv6\n");
4772 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4773 cmd_reconfig_device_queue(res->port_id, 1, 1);
4776 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4777 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4779 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4780 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4782 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4783 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4785 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4786 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4789 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4790 .f = cmd_tunnel_tso_set_parsed,
4792 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4793 "Set TSO segment size of tunneled packets for csum engine "
4796 (void *)&cmd_tunnel_tso_set_tso,
4797 (void *)&cmd_tunnel_tso_set_mode,
4798 (void *)&cmd_tunnel_tso_set_tso_segsz,
4799 (void *)&cmd_tunnel_tso_set_portid,
4804 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4805 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4809 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4810 .f = cmd_tunnel_tso_set_parsed,
4812 .help_str = "tunnel_tso show <port_id> "
4813 "Show TSO segment size of tunneled packets for csum engine",
4815 (void *)&cmd_tunnel_tso_set_tso,
4816 (void *)&cmd_tunnel_tso_show_mode,
4817 (void *)&cmd_tunnel_tso_set_portid,
4822 /* *** SET GRO FOR A PORT *** */
4823 struct cmd_gro_enable_result {
4824 cmdline_fixed_string_t cmd_set;
4825 cmdline_fixed_string_t cmd_port;
4826 cmdline_fixed_string_t cmd_keyword;
4827 cmdline_fixed_string_t cmd_onoff;
4832 cmd_gro_enable_parsed(void *parsed_result,
4833 __attribute__((unused)) struct cmdline *cl,
4834 __attribute__((unused)) void *data)
4836 struct cmd_gro_enable_result *res;
4838 res = parsed_result;
4839 if (!strcmp(res->cmd_keyword, "gro"))
4840 setup_gro(res->cmd_onoff, res->cmd_pid);
4843 cmdline_parse_token_string_t cmd_gro_enable_set =
4844 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4846 cmdline_parse_token_string_t cmd_gro_enable_port =
4847 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4848 cmd_keyword, "port");
4849 cmdline_parse_token_num_t cmd_gro_enable_pid =
4850 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4852 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4853 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4854 cmd_keyword, "gro");
4855 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4856 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4857 cmd_onoff, "on#off");
4859 cmdline_parse_inst_t cmd_gro_enable = {
4860 .f = cmd_gro_enable_parsed,
4862 .help_str = "set port <port_id> gro on|off",
4864 (void *)&cmd_gro_enable_set,
4865 (void *)&cmd_gro_enable_port,
4866 (void *)&cmd_gro_enable_pid,
4867 (void *)&cmd_gro_enable_keyword,
4868 (void *)&cmd_gro_enable_onoff,
4873 /* *** DISPLAY GRO CONFIGURATION *** */
4874 struct cmd_gro_show_result {
4875 cmdline_fixed_string_t cmd_show;
4876 cmdline_fixed_string_t cmd_port;
4877 cmdline_fixed_string_t cmd_keyword;
4882 cmd_gro_show_parsed(void *parsed_result,
4883 __attribute__((unused)) struct cmdline *cl,
4884 __attribute__((unused)) void *data)
4886 struct cmd_gro_show_result *res;
4888 res = parsed_result;
4889 if (!strcmp(res->cmd_keyword, "gro"))
4890 show_gro(res->cmd_pid);
4893 cmdline_parse_token_string_t cmd_gro_show_show =
4894 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4896 cmdline_parse_token_string_t cmd_gro_show_port =
4897 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4899 cmdline_parse_token_num_t cmd_gro_show_pid =
4900 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4902 cmdline_parse_token_string_t cmd_gro_show_keyword =
4903 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4904 cmd_keyword, "gro");
4906 cmdline_parse_inst_t cmd_gro_show = {
4907 .f = cmd_gro_show_parsed,
4909 .help_str = "show port <port_id> gro",
4911 (void *)&cmd_gro_show_show,
4912 (void *)&cmd_gro_show_port,
4913 (void *)&cmd_gro_show_pid,
4914 (void *)&cmd_gro_show_keyword,
4919 /* *** SET FLUSH CYCLES FOR GRO *** */
4920 struct cmd_gro_flush_result {
4921 cmdline_fixed_string_t cmd_set;
4922 cmdline_fixed_string_t cmd_keyword;
4923 cmdline_fixed_string_t cmd_flush;
4928 cmd_gro_flush_parsed(void *parsed_result,
4929 __attribute__((unused)) struct cmdline *cl,
4930 __attribute__((unused)) void *data)
4932 struct cmd_gro_flush_result *res;
4934 res = parsed_result;
4935 if ((!strcmp(res->cmd_keyword, "gro")) &&
4936 (!strcmp(res->cmd_flush, "flush")))
4937 setup_gro_flush_cycles(res->cmd_cycles);
4940 cmdline_parse_token_string_t cmd_gro_flush_set =
4941 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4943 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4944 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4945 cmd_keyword, "gro");
4946 cmdline_parse_token_string_t cmd_gro_flush_flush =
4947 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4948 cmd_flush, "flush");
4949 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4950 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4953 cmdline_parse_inst_t cmd_gro_flush = {
4954 .f = cmd_gro_flush_parsed,
4956 .help_str = "set gro flush <cycles>",
4958 (void *)&cmd_gro_flush_set,
4959 (void *)&cmd_gro_flush_keyword,
4960 (void *)&cmd_gro_flush_flush,
4961 (void *)&cmd_gro_flush_cycles,
4966 /* *** ENABLE/DISABLE GSO *** */
4967 struct cmd_gso_enable_result {
4968 cmdline_fixed_string_t cmd_set;
4969 cmdline_fixed_string_t cmd_port;
4970 cmdline_fixed_string_t cmd_keyword;
4971 cmdline_fixed_string_t cmd_mode;
4976 cmd_gso_enable_parsed(void *parsed_result,
4977 __attribute__((unused)) struct cmdline *cl,
4978 __attribute__((unused)) void *data)
4980 struct cmd_gso_enable_result *res;
4982 res = parsed_result;
4983 if (!strcmp(res->cmd_keyword, "gso"))
4984 setup_gso(res->cmd_mode, res->cmd_pid);
4987 cmdline_parse_token_string_t cmd_gso_enable_set =
4988 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4990 cmdline_parse_token_string_t cmd_gso_enable_port =
4991 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4993 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4994 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4995 cmd_keyword, "gso");
4996 cmdline_parse_token_string_t cmd_gso_enable_mode =
4997 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4998 cmd_mode, "on#off");
4999 cmdline_parse_token_num_t cmd_gso_enable_pid =
5000 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5003 cmdline_parse_inst_t cmd_gso_enable = {
5004 .f = cmd_gso_enable_parsed,
5006 .help_str = "set port <port_id> gso on|off",
5008 (void *)&cmd_gso_enable_set,
5009 (void *)&cmd_gso_enable_port,
5010 (void *)&cmd_gso_enable_pid,
5011 (void *)&cmd_gso_enable_keyword,
5012 (void *)&cmd_gso_enable_mode,
5017 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5018 struct cmd_gso_size_result {
5019 cmdline_fixed_string_t cmd_set;
5020 cmdline_fixed_string_t cmd_keyword;
5021 cmdline_fixed_string_t cmd_segsz;
5026 cmd_gso_size_parsed(void *parsed_result,
5027 __attribute__((unused)) struct cmdline *cl,
5028 __attribute__((unused)) void *data)
5030 struct cmd_gso_size_result *res = parsed_result;
5032 if (test_done == 0) {
5033 printf("Before setting GSO segsz, please first"
5034 " stop fowarding\n");
5038 if (!strcmp(res->cmd_keyword, "gso") &&
5039 !strcmp(res->cmd_segsz, "segsz")) {
5040 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5041 printf("gso_size should be larger than %zu."
5042 " Please input a legal value\n",
5043 RTE_GSO_SEG_SIZE_MIN);
5045 gso_max_segment_size = res->cmd_size;
5049 cmdline_parse_token_string_t cmd_gso_size_set =
5050 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5052 cmdline_parse_token_string_t cmd_gso_size_keyword =
5053 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5054 cmd_keyword, "gso");
5055 cmdline_parse_token_string_t cmd_gso_size_segsz =
5056 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5057 cmd_segsz, "segsz");
5058 cmdline_parse_token_num_t cmd_gso_size_size =
5059 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5062 cmdline_parse_inst_t cmd_gso_size = {
5063 .f = cmd_gso_size_parsed,
5065 .help_str = "set gso segsz <length>",
5067 (void *)&cmd_gso_size_set,
5068 (void *)&cmd_gso_size_keyword,
5069 (void *)&cmd_gso_size_segsz,
5070 (void *)&cmd_gso_size_size,
5075 /* *** SHOW GSO CONFIGURATION *** */
5076 struct cmd_gso_show_result {
5077 cmdline_fixed_string_t cmd_show;
5078 cmdline_fixed_string_t cmd_port;
5079 cmdline_fixed_string_t cmd_keyword;
5084 cmd_gso_show_parsed(void *parsed_result,
5085 __attribute__((unused)) struct cmdline *cl,
5086 __attribute__((unused)) void *data)
5088 struct cmd_gso_show_result *res = parsed_result;
5090 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5091 printf("invalid port id %u\n", res->cmd_pid);
5094 if (!strcmp(res->cmd_keyword, "gso")) {
5095 if (gso_ports[res->cmd_pid].enable) {
5096 printf("Max GSO'd packet size: %uB\n"
5097 "Supported GSO types: TCP/IPv4, "
5098 "UDP/IPv4, VxLAN with inner "
5099 "TCP/IPv4 packet, GRE with inner "
5100 "TCP/IPv4 packet\n",
5101 gso_max_segment_size);
5103 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5107 cmdline_parse_token_string_t cmd_gso_show_show =
5108 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5110 cmdline_parse_token_string_t cmd_gso_show_port =
5111 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5113 cmdline_parse_token_string_t cmd_gso_show_keyword =
5114 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5115 cmd_keyword, "gso");
5116 cmdline_parse_token_num_t cmd_gso_show_pid =
5117 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5120 cmdline_parse_inst_t cmd_gso_show = {
5121 .f = cmd_gso_show_parsed,
5123 .help_str = "show port <port_id> gso",
5125 (void *)&cmd_gso_show_show,
5126 (void *)&cmd_gso_show_port,
5127 (void *)&cmd_gso_show_pid,
5128 (void *)&cmd_gso_show_keyword,
5133 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5134 struct cmd_set_flush_rx {
5135 cmdline_fixed_string_t set;
5136 cmdline_fixed_string_t flush_rx;
5137 cmdline_fixed_string_t mode;
5141 cmd_set_flush_rx_parsed(void *parsed_result,
5142 __attribute__((unused)) struct cmdline *cl,
5143 __attribute__((unused)) void *data)
5145 struct cmd_set_flush_rx *res = parsed_result;
5146 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5149 cmdline_parse_token_string_t cmd_setflushrx_set =
5150 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5152 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5153 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5154 flush_rx, "flush_rx");
5155 cmdline_parse_token_string_t cmd_setflushrx_mode =
5156 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5160 cmdline_parse_inst_t cmd_set_flush_rx = {
5161 .f = cmd_set_flush_rx_parsed,
5162 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5165 (void *)&cmd_setflushrx_set,
5166 (void *)&cmd_setflushrx_flush_rx,
5167 (void *)&cmd_setflushrx_mode,
5172 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5173 struct cmd_set_link_check {
5174 cmdline_fixed_string_t set;
5175 cmdline_fixed_string_t link_check;
5176 cmdline_fixed_string_t mode;
5180 cmd_set_link_check_parsed(void *parsed_result,
5181 __attribute__((unused)) struct cmdline *cl,
5182 __attribute__((unused)) void *data)
5184 struct cmd_set_link_check *res = parsed_result;
5185 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5188 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5189 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5191 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5192 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5193 link_check, "link_check");
5194 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5195 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5199 cmdline_parse_inst_t cmd_set_link_check = {
5200 .f = cmd_set_link_check_parsed,
5201 .help_str = "set link_check on|off: Enable/Disable link status check "
5202 "when starting/stopping a port",
5205 (void *)&cmd_setlinkcheck_set,
5206 (void *)&cmd_setlinkcheck_link_check,
5207 (void *)&cmd_setlinkcheck_mode,
5212 /* *** SET NIC BYPASS MODE *** */
5213 struct cmd_set_bypass_mode_result {
5214 cmdline_fixed_string_t set;
5215 cmdline_fixed_string_t bypass;
5216 cmdline_fixed_string_t mode;
5217 cmdline_fixed_string_t value;
5222 cmd_set_bypass_mode_parsed(void *parsed_result,
5223 __attribute__((unused)) struct cmdline *cl,
5224 __attribute__((unused)) void *data)
5226 struct cmd_set_bypass_mode_result *res = parsed_result;
5227 portid_t port_id = res->port_id;
5228 int32_t rc = -EINVAL;
5230 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5231 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5233 if (!strcmp(res->value, "bypass"))
5234 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5235 else if (!strcmp(res->value, "isolate"))
5236 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5238 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5240 /* Set the bypass mode for the relevant port. */
5241 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5244 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5247 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5248 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5250 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5251 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5253 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5254 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5256 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5257 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5258 value, "normal#bypass#isolate");
5259 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5260 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5263 cmdline_parse_inst_t cmd_set_bypass_mode = {
5264 .f = cmd_set_bypass_mode_parsed,
5265 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5266 "Set the NIC bypass mode for port_id",
5269 (void *)&cmd_setbypass_mode_set,
5270 (void *)&cmd_setbypass_mode_bypass,
5271 (void *)&cmd_setbypass_mode_mode,
5272 (void *)&cmd_setbypass_mode_value,
5273 (void *)&cmd_setbypass_mode_port,
5278 /* *** SET NIC BYPASS EVENT *** */
5279 struct cmd_set_bypass_event_result {
5280 cmdline_fixed_string_t set;
5281 cmdline_fixed_string_t bypass;
5282 cmdline_fixed_string_t event;
5283 cmdline_fixed_string_t event_value;
5284 cmdline_fixed_string_t mode;
5285 cmdline_fixed_string_t mode_value;
5290 cmd_set_bypass_event_parsed(void *parsed_result,
5291 __attribute__((unused)) struct cmdline *cl,
5292 __attribute__((unused)) void *data)
5294 int32_t rc = -EINVAL;
5295 struct cmd_set_bypass_event_result *res = parsed_result;
5296 portid_t port_id = res->port_id;
5298 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5299 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5300 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5302 if (!strcmp(res->event_value, "timeout"))
5303 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5304 else if (!strcmp(res->event_value, "os_on"))
5305 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5306 else if (!strcmp(res->event_value, "os_off"))
5307 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5308 else if (!strcmp(res->event_value, "power_on"))
5309 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5310 else if (!strcmp(res->event_value, "power_off"))
5311 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5313 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5315 if (!strcmp(res->mode_value, "bypass"))
5316 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5317 else if (!strcmp(res->mode_value, "isolate"))
5318 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5320 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5322 /* Set the watchdog timeout. */
5323 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5326 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5327 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5331 printf("Failed to set timeout value %u "
5332 "for port %d, errto code: %d.\n",
5333 bypass_timeout, port_id, rc);
5337 /* Set the bypass event to transition to bypass mode. */
5338 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5343 printf("\t Failed to set bypass event for port = %d.\n",
5347 cmdline_parse_token_string_t cmd_setbypass_event_set =
5348 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5350 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5351 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5353 cmdline_parse_token_string_t cmd_setbypass_event_event =
5354 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5356 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5357 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5358 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5359 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5360 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5362 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5363 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5364 mode_value, "normal#bypass#isolate");
5365 cmdline_parse_token_num_t cmd_setbypass_event_port =
5366 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5369 cmdline_parse_inst_t cmd_set_bypass_event = {
5370 .f = cmd_set_bypass_event_parsed,
5371 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5372 "power_off mode normal|bypass|isolate <port_id>: "
5373 "Set the NIC bypass event mode for port_id",
5376 (void *)&cmd_setbypass_event_set,
5377 (void *)&cmd_setbypass_event_bypass,
5378 (void *)&cmd_setbypass_event_event,
5379 (void *)&cmd_setbypass_event_event_value,
5380 (void *)&cmd_setbypass_event_mode,
5381 (void *)&cmd_setbypass_event_mode_value,
5382 (void *)&cmd_setbypass_event_port,
5388 /* *** SET NIC BYPASS TIMEOUT *** */
5389 struct cmd_set_bypass_timeout_result {
5390 cmdline_fixed_string_t set;
5391 cmdline_fixed_string_t bypass;
5392 cmdline_fixed_string_t timeout;
5393 cmdline_fixed_string_t value;
5397 cmd_set_bypass_timeout_parsed(void *parsed_result,
5398 __attribute__((unused)) struct cmdline *cl,
5399 __attribute__((unused)) void *data)
5401 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5403 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5404 if (!strcmp(res->value, "1.5"))
5405 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5406 else if (!strcmp(res->value, "2"))
5407 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5408 else if (!strcmp(res->value, "3"))
5409 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5410 else if (!strcmp(res->value, "4"))
5411 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5412 else if (!strcmp(res->value, "8"))
5413 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5414 else if (!strcmp(res->value, "16"))
5415 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5416 else if (!strcmp(res->value, "32"))
5417 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5419 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5423 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5424 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5426 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5427 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5429 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5430 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5431 timeout, "timeout");
5432 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5433 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5434 value, "0#1.5#2#3#4#8#16#32");
5436 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5437 .f = cmd_set_bypass_timeout_parsed,
5438 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5439 "Set the NIC bypass watchdog timeout in seconds",
5442 (void *)&cmd_setbypass_timeout_set,
5443 (void *)&cmd_setbypass_timeout_bypass,
5444 (void *)&cmd_setbypass_timeout_timeout,
5445 (void *)&cmd_setbypass_timeout_value,
5450 /* *** SHOW NIC BYPASS MODE *** */
5451 struct cmd_show_bypass_config_result {
5452 cmdline_fixed_string_t show;
5453 cmdline_fixed_string_t bypass;
5454 cmdline_fixed_string_t config;
5459 cmd_show_bypass_config_parsed(void *parsed_result,
5460 __attribute__((unused)) struct cmdline *cl,
5461 __attribute__((unused)) void *data)
5463 struct cmd_show_bypass_config_result *res = parsed_result;
5464 portid_t port_id = res->port_id;
5466 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5467 uint32_t event_mode;
5468 uint32_t bypass_mode;
5469 uint32_t timeout = bypass_timeout;
5472 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5473 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5474 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5475 {"UNKNOWN", "normal", "bypass", "isolate"};
5476 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5483 int num_events = (sizeof events) / (sizeof events[0]);
5485 /* Display the bypass mode.*/
5486 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5487 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5491 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5492 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5494 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5497 /* Display the bypass timeout.*/
5498 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5499 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5501 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5503 /* Display the bypass events and associated modes. */
5504 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5506 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5507 printf("\tFailed to get bypass mode for event = %s\n",
5510 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5511 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5513 printf("\tbypass event: %-16s = %s\n", events[i],
5519 printf("\tFailed to get bypass configuration for port = %d\n",
5523 cmdline_parse_token_string_t cmd_showbypass_config_show =
5524 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5526 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5527 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5529 cmdline_parse_token_string_t cmd_showbypass_config_config =
5530 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5532 cmdline_parse_token_num_t cmd_showbypass_config_port =
5533 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5536 cmdline_parse_inst_t cmd_show_bypass_config = {
5537 .f = cmd_show_bypass_config_parsed,
5538 .help_str = "show bypass config <port_id>: "
5539 "Show the NIC bypass config for port_id",
5542 (void *)&cmd_showbypass_config_show,
5543 (void *)&cmd_showbypass_config_bypass,
5544 (void *)&cmd_showbypass_config_config,
5545 (void *)&cmd_showbypass_config_port,
5550 #ifdef RTE_LIBRTE_PMD_BOND
5551 /* *** SET BONDING MODE *** */
5552 struct cmd_set_bonding_mode_result {
5553 cmdline_fixed_string_t set;
5554 cmdline_fixed_string_t bonding;
5555 cmdline_fixed_string_t mode;
5560 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5561 __attribute__((unused)) struct cmdline *cl,
5562 __attribute__((unused)) void *data)
5564 struct cmd_set_bonding_mode_result *res = parsed_result;
5565 portid_t port_id = res->port_id;
5567 /* Set the bonding mode for the relevant port. */
5568 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5569 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5572 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5573 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5575 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5576 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5577 bonding, "bonding");
5578 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5579 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5581 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5582 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5584 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5585 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5588 cmdline_parse_inst_t cmd_set_bonding_mode = {
5589 .f = cmd_set_bonding_mode_parsed,
5590 .help_str = "set bonding mode <mode_value> <port_id>: "
5591 "Set the bonding mode for port_id",
5594 (void *) &cmd_setbonding_mode_set,
5595 (void *) &cmd_setbonding_mode_bonding,
5596 (void *) &cmd_setbonding_mode_mode,
5597 (void *) &cmd_setbonding_mode_value,
5598 (void *) &cmd_setbonding_mode_port,
5603 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5604 struct cmd_set_bonding_lacp_dedicated_queues_result {
5605 cmdline_fixed_string_t set;
5606 cmdline_fixed_string_t bonding;
5607 cmdline_fixed_string_t lacp;
5608 cmdline_fixed_string_t dedicated_queues;
5610 cmdline_fixed_string_t mode;
5613 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5614 __attribute__((unused)) struct cmdline *cl,
5615 __attribute__((unused)) void *data)
5617 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5618 portid_t port_id = res->port_id;
5619 struct rte_port *port;
5621 port = &ports[port_id];
5623 /** Check if the port is not started **/
5624 if (port->port_status != RTE_PORT_STOPPED) {
5625 printf("Please stop port %d first\n", port_id);
5629 if (!strcmp(res->mode, "enable")) {
5630 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5631 printf("Dedicate queues for LACP control packets"
5634 printf("Enabling dedicate queues for LACP control "
5635 "packets on port %d failed\n", port_id);
5636 } else if (!strcmp(res->mode, "disable")) {
5637 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5638 printf("Dedicated queues for LACP control packets "
5641 printf("Disabling dedicated queues for LACP control "
5642 "traffic on port %d failed\n", port_id);
5646 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5647 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5649 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5650 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5651 bonding, "bonding");
5652 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5653 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5655 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5656 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5657 dedicated_queues, "dedicated_queues");
5658 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5659 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5661 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5662 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5663 mode, "enable#disable");
5665 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5666 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5667 .help_str = "set bonding lacp dedicated_queues <port_id> "
5669 "Enable/disable dedicated queues for LACP control traffic for port_id",
5672 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5673 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5674 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5675 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5676 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5677 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5682 /* *** SET BALANCE XMIT POLICY *** */
5683 struct cmd_set_bonding_balance_xmit_policy_result {
5684 cmdline_fixed_string_t set;
5685 cmdline_fixed_string_t bonding;
5686 cmdline_fixed_string_t balance_xmit_policy;
5688 cmdline_fixed_string_t policy;
5691 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5692 __attribute__((unused)) struct cmdline *cl,
5693 __attribute__((unused)) void *data)
5695 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5696 portid_t port_id = res->port_id;
5699 if (!strcmp(res->policy, "l2")) {
5700 policy = BALANCE_XMIT_POLICY_LAYER2;
5701 } else if (!strcmp(res->policy, "l23")) {
5702 policy = BALANCE_XMIT_POLICY_LAYER23;
5703 } else if (!strcmp(res->policy, "l34")) {
5704 policy = BALANCE_XMIT_POLICY_LAYER34;
5706 printf("\t Invalid xmit policy selection");
5710 /* Set the bonding mode for the relevant port. */
5711 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5712 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5717 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5718 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5720 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5721 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5722 bonding, "bonding");
5723 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5724 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5725 balance_xmit_policy, "balance_xmit_policy");
5726 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5727 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5729 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5730 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5731 policy, "l2#l23#l34");
5733 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5734 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5735 .help_str = "set bonding balance_xmit_policy <port_id> "
5737 "Set the bonding balance_xmit_policy for port_id",
5740 (void *)&cmd_setbonding_balance_xmit_policy_set,
5741 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5742 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5743 (void *)&cmd_setbonding_balance_xmit_policy_port,
5744 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5749 /* *** SHOW NIC BONDING CONFIGURATION *** */
5750 struct cmd_show_bonding_config_result {
5751 cmdline_fixed_string_t show;
5752 cmdline_fixed_string_t bonding;
5753 cmdline_fixed_string_t config;
5757 static void cmd_show_bonding_config_parsed(void *parsed_result,
5758 __attribute__((unused)) struct cmdline *cl,
5759 __attribute__((unused)) void *data)
5761 struct cmd_show_bonding_config_result *res = parsed_result;
5762 int bonding_mode, agg_mode;
5763 portid_t slaves[RTE_MAX_ETHPORTS];
5764 int num_slaves, num_active_slaves;
5767 portid_t port_id = res->port_id;
5769 /* Display the bonding mode.*/
5770 bonding_mode = rte_eth_bond_mode_get(port_id);
5771 if (bonding_mode < 0) {
5772 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5775 printf("\tBonding mode: %d\n", bonding_mode);
5777 if (bonding_mode == BONDING_MODE_BALANCE) {
5778 int balance_xmit_policy;
5780 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5781 if (balance_xmit_policy < 0) {
5782 printf("\tFailed to get balance xmit policy for port = %d\n",
5786 printf("\tBalance Xmit Policy: ");
5788 switch (balance_xmit_policy) {
5789 case BALANCE_XMIT_POLICY_LAYER2:
5790 printf("BALANCE_XMIT_POLICY_LAYER2");
5792 case BALANCE_XMIT_POLICY_LAYER23:
5793 printf("BALANCE_XMIT_POLICY_LAYER23");
5795 case BALANCE_XMIT_POLICY_LAYER34:
5796 printf("BALANCE_XMIT_POLICY_LAYER34");
5803 if (bonding_mode == BONDING_MODE_8023AD) {
5804 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5805 printf("\tIEEE802.3AD Aggregator Mode: ");
5808 printf("bandwidth");
5820 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5822 if (num_slaves < 0) {
5823 printf("\tFailed to get slave list for port = %d\n", port_id);
5826 if (num_slaves > 0) {
5827 printf("\tSlaves (%d): [", num_slaves);
5828 for (i = 0; i < num_slaves - 1; i++)
5829 printf("%d ", slaves[i]);
5831 printf("%d]\n", slaves[num_slaves - 1]);
5833 printf("\tSlaves: []\n");
5837 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5840 if (num_active_slaves < 0) {
5841 printf("\tFailed to get active slave list for port = %d\n", port_id);
5844 if (num_active_slaves > 0) {
5845 printf("\tActive Slaves (%d): [", num_active_slaves);
5846 for (i = 0; i < num_active_slaves - 1; i++)
5847 printf("%d ", slaves[i]);
5849 printf("%d]\n", slaves[num_active_slaves - 1]);
5852 printf("\tActive Slaves: []\n");
5856 primary_id = rte_eth_bond_primary_get(port_id);
5857 if (primary_id < 0) {
5858 printf("\tFailed to get primary slave for port = %d\n", port_id);
5861 printf("\tPrimary: [%d]\n", primary_id);
5865 cmdline_parse_token_string_t cmd_showbonding_config_show =
5866 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5868 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5869 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5870 bonding, "bonding");
5871 cmdline_parse_token_string_t cmd_showbonding_config_config =
5872 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5874 cmdline_parse_token_num_t cmd_showbonding_config_port =
5875 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5878 cmdline_parse_inst_t cmd_show_bonding_config = {
5879 .f = cmd_show_bonding_config_parsed,
5880 .help_str = "show bonding config <port_id>: "
5881 "Show the bonding config for port_id",
5884 (void *)&cmd_showbonding_config_show,
5885 (void *)&cmd_showbonding_config_bonding,
5886 (void *)&cmd_showbonding_config_config,
5887 (void *)&cmd_showbonding_config_port,
5892 /* *** SET BONDING PRIMARY *** */
5893 struct cmd_set_bonding_primary_result {
5894 cmdline_fixed_string_t set;
5895 cmdline_fixed_string_t bonding;
5896 cmdline_fixed_string_t primary;
5901 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5902 __attribute__((unused)) struct cmdline *cl,
5903 __attribute__((unused)) void *data)
5905 struct cmd_set_bonding_primary_result *res = parsed_result;
5906 portid_t master_port_id = res->port_id;
5907 portid_t slave_port_id = res->slave_id;
5909 /* Set the primary slave for a bonded device. */
5910 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5911 printf("\t Failed to set primary slave for port = %d.\n",
5918 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5919 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5921 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5922 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5923 bonding, "bonding");
5924 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5925 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5926 primary, "primary");
5927 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5928 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5930 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5931 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5934 cmdline_parse_inst_t cmd_set_bonding_primary = {
5935 .f = cmd_set_bonding_primary_parsed,
5936 .help_str = "set bonding primary <slave_id> <port_id>: "
5937 "Set the primary slave for port_id",
5940 (void *)&cmd_setbonding_primary_set,
5941 (void *)&cmd_setbonding_primary_bonding,
5942 (void *)&cmd_setbonding_primary_primary,
5943 (void *)&cmd_setbonding_primary_slave,
5944 (void *)&cmd_setbonding_primary_port,
5949 /* *** ADD SLAVE *** */
5950 struct cmd_add_bonding_slave_result {
5951 cmdline_fixed_string_t add;
5952 cmdline_fixed_string_t bonding;
5953 cmdline_fixed_string_t slave;
5958 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5959 __attribute__((unused)) struct cmdline *cl,
5960 __attribute__((unused)) void *data)
5962 struct cmd_add_bonding_slave_result *res = parsed_result;
5963 portid_t master_port_id = res->port_id;
5964 portid_t slave_port_id = res->slave_id;
5966 /* add the slave for a bonded device. */
5967 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5968 printf("\t Failed to add slave %d to master port = %d.\n",
5969 slave_port_id, master_port_id);
5973 set_port_slave_flag(slave_port_id);
5976 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5977 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5979 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5980 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5981 bonding, "bonding");
5982 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5983 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5985 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5986 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5988 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5989 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5992 cmdline_parse_inst_t cmd_add_bonding_slave = {
5993 .f = cmd_add_bonding_slave_parsed,
5994 .help_str = "add bonding slave <slave_id> <port_id>: "
5995 "Add a slave device to a bonded device",
5998 (void *)&cmd_addbonding_slave_add,
5999 (void *)&cmd_addbonding_slave_bonding,
6000 (void *)&cmd_addbonding_slave_slave,
6001 (void *)&cmd_addbonding_slave_slaveid,
6002 (void *)&cmd_addbonding_slave_port,
6007 /* *** REMOVE SLAVE *** */
6008 struct cmd_remove_bonding_slave_result {
6009 cmdline_fixed_string_t remove;
6010 cmdline_fixed_string_t bonding;
6011 cmdline_fixed_string_t slave;
6016 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6017 __attribute__((unused)) struct cmdline *cl,
6018 __attribute__((unused)) void *data)
6020 struct cmd_remove_bonding_slave_result *res = parsed_result;
6021 portid_t master_port_id = res->port_id;
6022 portid_t slave_port_id = res->slave_id;
6024 /* remove the slave from a bonded device. */
6025 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6026 printf("\t Failed to remove slave %d from master port = %d.\n",
6027 slave_port_id, master_port_id);
6031 clear_port_slave_flag(slave_port_id);
6034 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6035 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6037 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6038 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6039 bonding, "bonding");
6040 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6041 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6043 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6044 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6046 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6047 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6050 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6051 .f = cmd_remove_bonding_slave_parsed,
6052 .help_str = "remove bonding slave <slave_id> <port_id>: "
6053 "Remove a slave device from a bonded device",
6056 (void *)&cmd_removebonding_slave_remove,
6057 (void *)&cmd_removebonding_slave_bonding,
6058 (void *)&cmd_removebonding_slave_slave,
6059 (void *)&cmd_removebonding_slave_slaveid,
6060 (void *)&cmd_removebonding_slave_port,
6065 /* *** CREATE BONDED DEVICE *** */
6066 struct cmd_create_bonded_device_result {
6067 cmdline_fixed_string_t create;
6068 cmdline_fixed_string_t bonded;
6069 cmdline_fixed_string_t device;
6074 static int bond_dev_num = 0;
6076 static void cmd_create_bonded_device_parsed(void *parsed_result,
6077 __attribute__((unused)) struct cmdline *cl,
6078 __attribute__((unused)) void *data)
6080 struct cmd_create_bonded_device_result *res = parsed_result;
6081 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6085 if (test_done == 0) {
6086 printf("Please stop forwarding first\n");
6090 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6093 /* Create a new bonded device. */
6094 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6096 printf("\t Failed to create bonded device.\n");
6099 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6102 /* Update number of ports */
6103 nb_ports = rte_eth_dev_count_avail();
6104 reconfig(port_id, res->socket);
6105 ret = rte_eth_promiscuous_enable(port_id);
6107 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6108 port_id, rte_strerror(-ret));
6110 ports[port_id].need_setup = 0;
6111 ports[port_id].port_status = RTE_PORT_STOPPED;
6116 cmdline_parse_token_string_t cmd_createbonded_device_create =
6117 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6119 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6120 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6122 cmdline_parse_token_string_t cmd_createbonded_device_device =
6123 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6125 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6126 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6128 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6129 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6132 cmdline_parse_inst_t cmd_create_bonded_device = {
6133 .f = cmd_create_bonded_device_parsed,
6134 .help_str = "create bonded device <mode> <socket>: "
6135 "Create a new bonded device with specific bonding mode and socket",
6138 (void *)&cmd_createbonded_device_create,
6139 (void *)&cmd_createbonded_device_bonded,
6140 (void *)&cmd_createbonded_device_device,
6141 (void *)&cmd_createbonded_device_mode,
6142 (void *)&cmd_createbonded_device_socket,
6147 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6148 struct cmd_set_bond_mac_addr_result {
6149 cmdline_fixed_string_t set;
6150 cmdline_fixed_string_t bonding;
6151 cmdline_fixed_string_t mac_addr;
6153 struct rte_ether_addr address;
6156 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6157 __attribute__((unused)) struct cmdline *cl,
6158 __attribute__((unused)) void *data)
6160 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6163 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6166 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6168 /* check the return value and print it if is < 0 */
6170 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6173 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6174 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6175 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6176 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6178 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6179 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6181 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6182 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6184 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6185 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6187 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6188 .f = cmd_set_bond_mac_addr_parsed,
6190 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6192 (void *)&cmd_set_bond_mac_addr_set,
6193 (void *)&cmd_set_bond_mac_addr_bonding,
6194 (void *)&cmd_set_bond_mac_addr_mac,
6195 (void *)&cmd_set_bond_mac_addr_portnum,
6196 (void *)&cmd_set_bond_mac_addr_addr,
6202 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6203 struct cmd_set_bond_mon_period_result {
6204 cmdline_fixed_string_t set;
6205 cmdline_fixed_string_t bonding;
6206 cmdline_fixed_string_t mon_period;
6211 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6212 __attribute__((unused)) struct cmdline *cl,
6213 __attribute__((unused)) void *data)
6215 struct cmd_set_bond_mon_period_result *res = parsed_result;
6218 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6220 /* check the return value and print it if is < 0 */
6222 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6225 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6226 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6228 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6230 bonding, "bonding");
6231 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6232 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6233 mon_period, "mon_period");
6234 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6235 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6237 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6238 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6241 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6242 .f = cmd_set_bond_mon_period_parsed,
6244 .help_str = "set bonding mon_period <port_id> <period_ms>",
6246 (void *)&cmd_set_bond_mon_period_set,
6247 (void *)&cmd_set_bond_mon_period_bonding,
6248 (void *)&cmd_set_bond_mon_period_mon_period,
6249 (void *)&cmd_set_bond_mon_period_portnum,
6250 (void *)&cmd_set_bond_mon_period_period_ms,
6257 struct cmd_set_bonding_agg_mode_policy_result {
6258 cmdline_fixed_string_t set;
6259 cmdline_fixed_string_t bonding;
6260 cmdline_fixed_string_t agg_mode;
6262 cmdline_fixed_string_t policy;
6267 cmd_set_bonding_agg_mode(void *parsed_result,
6268 __attribute__((unused)) struct cmdline *cl,
6269 __attribute__((unused)) void *data)
6271 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6272 uint8_t policy = AGG_BANDWIDTH;
6274 if (!strcmp(res->policy, "bandwidth"))
6275 policy = AGG_BANDWIDTH;
6276 else if (!strcmp(res->policy, "stable"))
6277 policy = AGG_STABLE;
6278 else if (!strcmp(res->policy, "count"))
6281 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6285 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6288 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6289 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6290 bonding, "bonding");
6292 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6293 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6294 agg_mode, "agg_mode");
6296 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6297 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6300 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6301 TOKEN_STRING_INITIALIZER(
6302 struct cmd_set_bonding_balance_xmit_policy_result,
6303 policy, "stable#bandwidth#count");
6305 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6306 .f = cmd_set_bonding_agg_mode,
6308 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6310 (void *)&cmd_set_bonding_agg_mode_set,
6311 (void *)&cmd_set_bonding_agg_mode_bonding,
6312 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6313 (void *)&cmd_set_bonding_agg_mode_portnum,
6314 (void *)&cmd_set_bonding_agg_mode_policy_string,
6320 #endif /* RTE_LIBRTE_PMD_BOND */
6322 /* *** SET FORWARDING MODE *** */
6323 struct cmd_set_fwd_mode_result {
6324 cmdline_fixed_string_t set;
6325 cmdline_fixed_string_t fwd;
6326 cmdline_fixed_string_t mode;
6329 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6330 __attribute__((unused)) struct cmdline *cl,
6331 __attribute__((unused)) void *data)
6333 struct cmd_set_fwd_mode_result *res = parsed_result;
6336 set_pkt_forwarding_mode(res->mode);
6339 cmdline_parse_token_string_t cmd_setfwd_set =
6340 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6341 cmdline_parse_token_string_t cmd_setfwd_fwd =
6342 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6343 cmdline_parse_token_string_t cmd_setfwd_mode =
6344 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6345 "" /* defined at init */);
6347 cmdline_parse_inst_t cmd_set_fwd_mode = {
6348 .f = cmd_set_fwd_mode_parsed,
6350 .help_str = NULL, /* defined at init */
6352 (void *)&cmd_setfwd_set,
6353 (void *)&cmd_setfwd_fwd,
6354 (void *)&cmd_setfwd_mode,
6359 static void cmd_set_fwd_mode_init(void)
6362 static char token[128];
6363 static char help[256];
6364 cmdline_parse_token_string_t *token_struct;
6366 modes = list_pkt_forwarding_modes();
6367 snprintf(help, sizeof(help), "set fwd %s: "
6368 "Set packet forwarding mode", modes);
6369 cmd_set_fwd_mode.help_str = help;
6371 /* string token separator is # */
6372 for (c = token; *modes != '\0'; modes++)
6377 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6378 token_struct->string_data.str = token;
6381 /* *** SET RETRY FORWARDING MODE *** */
6382 struct cmd_set_fwd_retry_mode_result {
6383 cmdline_fixed_string_t set;
6384 cmdline_fixed_string_t fwd;
6385 cmdline_fixed_string_t mode;
6386 cmdline_fixed_string_t retry;
6389 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6390 __attribute__((unused)) struct cmdline *cl,
6391 __attribute__((unused)) void *data)
6393 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6396 set_pkt_forwarding_mode(res->mode);
6399 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6400 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6402 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6403 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6405 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6406 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6408 "" /* defined at init */);
6409 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6410 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6413 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6414 .f = cmd_set_fwd_retry_mode_parsed,
6416 .help_str = NULL, /* defined at init */
6418 (void *)&cmd_setfwd_retry_set,
6419 (void *)&cmd_setfwd_retry_fwd,
6420 (void *)&cmd_setfwd_retry_mode,
6421 (void *)&cmd_setfwd_retry_retry,
6426 static void cmd_set_fwd_retry_mode_init(void)
6429 static char token[128];
6430 static char help[256];
6431 cmdline_parse_token_string_t *token_struct;
6433 modes = list_pkt_forwarding_retry_modes();
6434 snprintf(help, sizeof(help), "set fwd %s retry: "
6435 "Set packet forwarding mode with retry", modes);
6436 cmd_set_fwd_retry_mode.help_str = help;
6438 /* string token separator is # */
6439 for (c = token; *modes != '\0'; modes++)
6444 token_struct = (cmdline_parse_token_string_t *)
6445 cmd_set_fwd_retry_mode.tokens[2];
6446 token_struct->string_data.str = token;
6449 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6450 struct cmd_set_burst_tx_retry_result {
6451 cmdline_fixed_string_t set;
6452 cmdline_fixed_string_t burst;
6453 cmdline_fixed_string_t tx;
6454 cmdline_fixed_string_t delay;
6456 cmdline_fixed_string_t retry;
6460 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6461 __attribute__((unused)) struct cmdline *cl,
6462 __attribute__((unused)) void *data)
6464 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6466 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6467 && !strcmp(res->tx, "tx")) {
6468 if (!strcmp(res->delay, "delay"))
6469 burst_tx_delay_time = res->time;
6470 if (!strcmp(res->retry, "retry"))
6471 burst_tx_retry_num = res->retry_num;
6476 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6478 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6481 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6483 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6485 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6486 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6487 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6488 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6489 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6490 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6492 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6493 .f = cmd_set_burst_tx_retry_parsed,
6494 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6496 (void *)&cmd_set_burst_tx_retry_set,
6497 (void *)&cmd_set_burst_tx_retry_burst,
6498 (void *)&cmd_set_burst_tx_retry_tx,
6499 (void *)&cmd_set_burst_tx_retry_delay,
6500 (void *)&cmd_set_burst_tx_retry_time,
6501 (void *)&cmd_set_burst_tx_retry_retry,
6502 (void *)&cmd_set_burst_tx_retry_retry_num,
6507 /* *** SET PROMISC MODE *** */
6508 struct cmd_set_promisc_mode_result {
6509 cmdline_fixed_string_t set;
6510 cmdline_fixed_string_t promisc;
6511 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6512 uint16_t port_num; /* valid if "allports" argument == 0 */
6513 cmdline_fixed_string_t mode;
6516 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6517 __attribute__((unused)) struct cmdline *cl,
6520 struct cmd_set_promisc_mode_result *res = parsed_result;
6524 if (!strcmp(res->mode, "on"))
6531 RTE_ETH_FOREACH_DEV(i)
6532 eth_set_promisc_mode(i, enable);
6534 eth_set_promisc_mode(res->port_num, enable);
6538 cmdline_parse_token_string_t cmd_setpromisc_set =
6539 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6540 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6541 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6543 cmdline_parse_token_string_t cmd_setpromisc_portall =
6544 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6546 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6547 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6549 cmdline_parse_token_string_t cmd_setpromisc_mode =
6550 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6553 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6554 .f = cmd_set_promisc_mode_parsed,
6556 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6558 (void *)&cmd_setpromisc_set,
6559 (void *)&cmd_setpromisc_promisc,
6560 (void *)&cmd_setpromisc_portall,
6561 (void *)&cmd_setpromisc_mode,
6566 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6567 .f = cmd_set_promisc_mode_parsed,
6569 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6571 (void *)&cmd_setpromisc_set,
6572 (void *)&cmd_setpromisc_promisc,
6573 (void *)&cmd_setpromisc_portnum,
6574 (void *)&cmd_setpromisc_mode,
6579 /* *** SET ALLMULTI MODE *** */
6580 struct cmd_set_allmulti_mode_result {
6581 cmdline_fixed_string_t set;
6582 cmdline_fixed_string_t allmulti;
6583 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6584 uint16_t port_num; /* valid if "allports" argument == 0 */
6585 cmdline_fixed_string_t mode;
6588 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6589 __attribute__((unused)) struct cmdline *cl,
6592 struct cmd_set_allmulti_mode_result *res = parsed_result;
6596 if (!strcmp(res->mode, "on"))
6603 RTE_ETH_FOREACH_DEV(i) {
6604 eth_set_allmulticast_mode(i, enable);
6608 eth_set_allmulticast_mode(res->port_num, enable);
6612 cmdline_parse_token_string_t cmd_setallmulti_set =
6613 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6614 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6615 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6617 cmdline_parse_token_string_t cmd_setallmulti_portall =
6618 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6620 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6621 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6623 cmdline_parse_token_string_t cmd_setallmulti_mode =
6624 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6627 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6628 .f = cmd_set_allmulti_mode_parsed,
6630 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6632 (void *)&cmd_setallmulti_set,
6633 (void *)&cmd_setallmulti_allmulti,
6634 (void *)&cmd_setallmulti_portall,
6635 (void *)&cmd_setallmulti_mode,
6640 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6641 .f = cmd_set_allmulti_mode_parsed,
6643 .help_str = "set allmulti <port_id> on|off: "
6644 "Set allmulti mode on port_id",
6646 (void *)&cmd_setallmulti_set,
6647 (void *)&cmd_setallmulti_allmulti,
6648 (void *)&cmd_setallmulti_portnum,
6649 (void *)&cmd_setallmulti_mode,
6654 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6655 struct cmd_link_flow_ctrl_set_result {
6656 cmdline_fixed_string_t set;
6657 cmdline_fixed_string_t flow_ctrl;
6658 cmdline_fixed_string_t rx;
6659 cmdline_fixed_string_t rx_lfc_mode;
6660 cmdline_fixed_string_t tx;
6661 cmdline_fixed_string_t tx_lfc_mode;
6662 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6663 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6664 cmdline_fixed_string_t autoneg_str;
6665 cmdline_fixed_string_t autoneg;
6666 cmdline_fixed_string_t hw_str;
6667 uint32_t high_water;
6668 cmdline_fixed_string_t lw_str;
6670 cmdline_fixed_string_t pt_str;
6671 uint16_t pause_time;
6672 cmdline_fixed_string_t xon_str;
6677 cmdline_parse_token_string_t cmd_lfc_set_set =
6678 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6680 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6681 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6682 flow_ctrl, "flow_ctrl");
6683 cmdline_parse_token_string_t cmd_lfc_set_rx =
6684 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6686 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6687 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6688 rx_lfc_mode, "on#off");
6689 cmdline_parse_token_string_t cmd_lfc_set_tx =
6690 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6692 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6693 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6694 tx_lfc_mode, "on#off");
6695 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6696 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6697 hw_str, "high_water");
6698 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6699 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6700 high_water, UINT32);
6701 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6702 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6703 lw_str, "low_water");
6704 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6705 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6707 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6708 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6709 pt_str, "pause_time");
6710 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6711 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6712 pause_time, UINT16);
6713 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6714 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6715 xon_str, "send_xon");
6716 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6717 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6719 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6720 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6721 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6722 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6723 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6724 mac_ctrl_frame_fwd_mode, "on#off");
6725 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6726 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6727 autoneg_str, "autoneg");
6728 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6729 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6731 cmdline_parse_token_num_t cmd_lfc_set_portid =
6732 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6735 /* forward declaration */
6737 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6740 cmdline_parse_inst_t cmd_link_flow_control_set = {
6741 .f = cmd_link_flow_ctrl_set_parsed,
6743 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6744 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6745 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6747 (void *)&cmd_lfc_set_set,
6748 (void *)&cmd_lfc_set_flow_ctrl,
6749 (void *)&cmd_lfc_set_rx,
6750 (void *)&cmd_lfc_set_rx_mode,
6751 (void *)&cmd_lfc_set_tx,
6752 (void *)&cmd_lfc_set_tx_mode,
6753 (void *)&cmd_lfc_set_high_water,
6754 (void *)&cmd_lfc_set_low_water,
6755 (void *)&cmd_lfc_set_pause_time,
6756 (void *)&cmd_lfc_set_send_xon,
6757 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6758 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6759 (void *)&cmd_lfc_set_autoneg_str,
6760 (void *)&cmd_lfc_set_autoneg,
6761 (void *)&cmd_lfc_set_portid,
6766 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6767 .f = cmd_link_flow_ctrl_set_parsed,
6768 .data = (void *)&cmd_link_flow_control_set_rx,
6769 .help_str = "set flow_ctrl rx on|off <port_id>: "
6770 "Change rx flow control parameter",
6772 (void *)&cmd_lfc_set_set,
6773 (void *)&cmd_lfc_set_flow_ctrl,
6774 (void *)&cmd_lfc_set_rx,
6775 (void *)&cmd_lfc_set_rx_mode,
6776 (void *)&cmd_lfc_set_portid,
6781 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6782 .f = cmd_link_flow_ctrl_set_parsed,
6783 .data = (void *)&cmd_link_flow_control_set_tx,
6784 .help_str = "set flow_ctrl tx on|off <port_id>: "
6785 "Change tx flow control parameter",
6787 (void *)&cmd_lfc_set_set,
6788 (void *)&cmd_lfc_set_flow_ctrl,
6789 (void *)&cmd_lfc_set_tx,
6790 (void *)&cmd_lfc_set_tx_mode,
6791 (void *)&cmd_lfc_set_portid,
6796 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6797 .f = cmd_link_flow_ctrl_set_parsed,
6798 .data = (void *)&cmd_link_flow_control_set_hw,
6799 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6800 "Change high water flow control parameter",
6802 (void *)&cmd_lfc_set_set,
6803 (void *)&cmd_lfc_set_flow_ctrl,
6804 (void *)&cmd_lfc_set_high_water_str,
6805 (void *)&cmd_lfc_set_high_water,
6806 (void *)&cmd_lfc_set_portid,
6811 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6812 .f = cmd_link_flow_ctrl_set_parsed,
6813 .data = (void *)&cmd_link_flow_control_set_lw,
6814 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6815 "Change low water flow control parameter",
6817 (void *)&cmd_lfc_set_set,
6818 (void *)&cmd_lfc_set_flow_ctrl,
6819 (void *)&cmd_lfc_set_low_water_str,
6820 (void *)&cmd_lfc_set_low_water,
6821 (void *)&cmd_lfc_set_portid,
6826 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6827 .f = cmd_link_flow_ctrl_set_parsed,
6828 .data = (void *)&cmd_link_flow_control_set_pt,
6829 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6830 "Change pause time flow control parameter",
6832 (void *)&cmd_lfc_set_set,
6833 (void *)&cmd_lfc_set_flow_ctrl,
6834 (void *)&cmd_lfc_set_pause_time_str,
6835 (void *)&cmd_lfc_set_pause_time,
6836 (void *)&cmd_lfc_set_portid,
6841 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6842 .f = cmd_link_flow_ctrl_set_parsed,
6843 .data = (void *)&cmd_link_flow_control_set_xon,
6844 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6845 "Change send_xon flow control parameter",
6847 (void *)&cmd_lfc_set_set,
6848 (void *)&cmd_lfc_set_flow_ctrl,
6849 (void *)&cmd_lfc_set_send_xon_str,
6850 (void *)&cmd_lfc_set_send_xon,
6851 (void *)&cmd_lfc_set_portid,
6856 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6857 .f = cmd_link_flow_ctrl_set_parsed,
6858 .data = (void *)&cmd_link_flow_control_set_macfwd,
6859 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6860 "Change mac ctrl fwd flow control parameter",
6862 (void *)&cmd_lfc_set_set,
6863 (void *)&cmd_lfc_set_flow_ctrl,
6864 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6865 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6866 (void *)&cmd_lfc_set_portid,
6871 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6872 .f = cmd_link_flow_ctrl_set_parsed,
6873 .data = (void *)&cmd_link_flow_control_set_autoneg,
6874 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6875 "Change autoneg flow control parameter",
6877 (void *)&cmd_lfc_set_set,
6878 (void *)&cmd_lfc_set_flow_ctrl,
6879 (void *)&cmd_lfc_set_autoneg_str,
6880 (void *)&cmd_lfc_set_autoneg,
6881 (void *)&cmd_lfc_set_portid,
6887 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6888 __attribute__((unused)) struct cmdline *cl,
6891 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6892 cmdline_parse_inst_t *cmd = data;
6893 struct rte_eth_fc_conf fc_conf;
6899 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6900 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6901 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6902 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6904 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6905 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6908 /* Partial command line, retrieve current configuration */
6910 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6912 printf("cannot get current flow ctrl parameters, return"
6913 "code = %d\n", ret);
6917 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6918 (fc_conf.mode == RTE_FC_FULL))
6920 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6921 (fc_conf.mode == RTE_FC_FULL))
6925 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6926 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6928 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6929 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6931 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6933 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6934 fc_conf.high_water = res->high_water;
6936 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6937 fc_conf.low_water = res->low_water;
6939 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6940 fc_conf.pause_time = res->pause_time;
6942 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6943 fc_conf.send_xon = res->send_xon;
6945 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6946 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6947 fc_conf.mac_ctrl_frame_fwd = 1;
6949 fc_conf.mac_ctrl_frame_fwd = 0;
6952 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6953 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6955 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6957 printf("bad flow contrl parameter, return code = %d \n", ret);
6960 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6961 struct cmd_priority_flow_ctrl_set_result {
6962 cmdline_fixed_string_t set;
6963 cmdline_fixed_string_t pfc_ctrl;
6964 cmdline_fixed_string_t rx;
6965 cmdline_fixed_string_t rx_pfc_mode;
6966 cmdline_fixed_string_t tx;
6967 cmdline_fixed_string_t tx_pfc_mode;
6968 uint32_t high_water;
6970 uint16_t pause_time;
6976 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6977 __attribute__((unused)) struct cmdline *cl,
6978 __attribute__((unused)) void *data)
6980 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6981 struct rte_eth_pfc_conf pfc_conf;
6982 int rx_fc_enable, tx_fc_enable;
6986 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6987 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6988 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6989 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6991 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6992 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6995 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6996 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6997 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6998 pfc_conf.fc.high_water = res->high_water;
6999 pfc_conf.fc.low_water = res->low_water;
7000 pfc_conf.fc.pause_time = res->pause_time;
7001 pfc_conf.priority = res->priority;
7003 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7005 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7008 cmdline_parse_token_string_t cmd_pfc_set_set =
7009 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7011 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7012 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7013 pfc_ctrl, "pfc_ctrl");
7014 cmdline_parse_token_string_t cmd_pfc_set_rx =
7015 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7017 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7018 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7019 rx_pfc_mode, "on#off");
7020 cmdline_parse_token_string_t cmd_pfc_set_tx =
7021 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7023 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7024 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7025 tx_pfc_mode, "on#off");
7026 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7027 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7028 high_water, UINT32);
7029 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7030 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7032 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7033 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7034 pause_time, UINT16);
7035 cmdline_parse_token_num_t cmd_pfc_set_priority =
7036 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7038 cmdline_parse_token_num_t cmd_pfc_set_portid =
7039 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7042 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7043 .f = cmd_priority_flow_ctrl_set_parsed,
7045 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7046 "<pause_time> <priority> <port_id>: "
7047 "Configure the Ethernet priority flow control",
7049 (void *)&cmd_pfc_set_set,
7050 (void *)&cmd_pfc_set_flow_ctrl,
7051 (void *)&cmd_pfc_set_rx,
7052 (void *)&cmd_pfc_set_rx_mode,
7053 (void *)&cmd_pfc_set_tx,
7054 (void *)&cmd_pfc_set_tx_mode,
7055 (void *)&cmd_pfc_set_high_water,
7056 (void *)&cmd_pfc_set_low_water,
7057 (void *)&cmd_pfc_set_pause_time,
7058 (void *)&cmd_pfc_set_priority,
7059 (void *)&cmd_pfc_set_portid,
7064 /* *** RESET CONFIGURATION *** */
7065 struct cmd_reset_result {
7066 cmdline_fixed_string_t reset;
7067 cmdline_fixed_string_t def;
7070 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7072 __attribute__((unused)) void *data)
7074 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7075 set_def_fwd_config();
7078 cmdline_parse_token_string_t cmd_reset_set =
7079 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7080 cmdline_parse_token_string_t cmd_reset_def =
7081 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7084 cmdline_parse_inst_t cmd_reset = {
7085 .f = cmd_reset_parsed,
7087 .help_str = "set default: Reset default forwarding configuration",
7089 (void *)&cmd_reset_set,
7090 (void *)&cmd_reset_def,
7095 /* *** START FORWARDING *** */
7096 struct cmd_start_result {
7097 cmdline_fixed_string_t start;
7100 cmdline_parse_token_string_t cmd_start_start =
7101 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7103 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7104 __attribute__((unused)) struct cmdline *cl,
7105 __attribute__((unused)) void *data)
7107 start_packet_forwarding(0);
7110 cmdline_parse_inst_t cmd_start = {
7111 .f = cmd_start_parsed,
7113 .help_str = "start: Start packet forwarding",
7115 (void *)&cmd_start_start,
7120 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7121 struct cmd_start_tx_first_result {
7122 cmdline_fixed_string_t start;
7123 cmdline_fixed_string_t tx_first;
7127 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7128 __attribute__((unused)) struct cmdline *cl,
7129 __attribute__((unused)) void *data)
7131 start_packet_forwarding(1);
7134 cmdline_parse_token_string_t cmd_start_tx_first_start =
7135 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7137 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7138 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7139 tx_first, "tx_first");
7141 cmdline_parse_inst_t cmd_start_tx_first = {
7142 .f = cmd_start_tx_first_parsed,
7144 .help_str = "start tx_first: Start packet forwarding, "
7145 "after sending 1 burst of packets",
7147 (void *)&cmd_start_tx_first_start,
7148 (void *)&cmd_start_tx_first_tx_first,
7153 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7154 struct cmd_start_tx_first_n_result {
7155 cmdline_fixed_string_t start;
7156 cmdline_fixed_string_t tx_first;
7161 cmd_start_tx_first_n_parsed(void *parsed_result,
7162 __attribute__((unused)) struct cmdline *cl,
7163 __attribute__((unused)) void *data)
7165 struct cmd_start_tx_first_n_result *res = parsed_result;
7167 start_packet_forwarding(res->tx_num);
7170 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7171 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7173 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7174 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7175 tx_first, "tx_first");
7176 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7177 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7180 cmdline_parse_inst_t cmd_start_tx_first_n = {
7181 .f = cmd_start_tx_first_n_parsed,
7183 .help_str = "start tx_first <num>: "
7184 "packet forwarding, after sending <num> bursts of packets",
7186 (void *)&cmd_start_tx_first_n_start,
7187 (void *)&cmd_start_tx_first_n_tx_first,
7188 (void *)&cmd_start_tx_first_n_tx_num,
7193 /* *** SET LINK UP *** */
7194 struct cmd_set_link_up_result {
7195 cmdline_fixed_string_t set;
7196 cmdline_fixed_string_t link_up;
7197 cmdline_fixed_string_t port;
7201 cmdline_parse_token_string_t cmd_set_link_up_set =
7202 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7203 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7204 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7206 cmdline_parse_token_string_t cmd_set_link_up_port =
7207 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7208 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7209 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7211 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7212 __attribute__((unused)) struct cmdline *cl,
7213 __attribute__((unused)) void *data)
7215 struct cmd_set_link_up_result *res = parsed_result;
7216 dev_set_link_up(res->port_id);
7219 cmdline_parse_inst_t cmd_set_link_up = {
7220 .f = cmd_set_link_up_parsed,
7222 .help_str = "set link-up port <port id>",
7224 (void *)&cmd_set_link_up_set,
7225 (void *)&cmd_set_link_up_link_up,
7226 (void *)&cmd_set_link_up_port,
7227 (void *)&cmd_set_link_up_port_id,
7232 /* *** SET LINK DOWN *** */
7233 struct cmd_set_link_down_result {
7234 cmdline_fixed_string_t set;
7235 cmdline_fixed_string_t link_down;
7236 cmdline_fixed_string_t port;
7240 cmdline_parse_token_string_t cmd_set_link_down_set =
7241 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7242 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7243 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7245 cmdline_parse_token_string_t cmd_set_link_down_port =
7246 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7247 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7248 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7250 static void cmd_set_link_down_parsed(
7251 __attribute__((unused)) void *parsed_result,
7252 __attribute__((unused)) struct cmdline *cl,
7253 __attribute__((unused)) void *data)
7255 struct cmd_set_link_down_result *res = parsed_result;
7256 dev_set_link_down(res->port_id);
7259 cmdline_parse_inst_t cmd_set_link_down = {
7260 .f = cmd_set_link_down_parsed,
7262 .help_str = "set link-down port <port id>",
7264 (void *)&cmd_set_link_down_set,
7265 (void *)&cmd_set_link_down_link_down,
7266 (void *)&cmd_set_link_down_port,
7267 (void *)&cmd_set_link_down_port_id,
7272 /* *** SHOW CFG *** */
7273 struct cmd_showcfg_result {
7274 cmdline_fixed_string_t show;
7275 cmdline_fixed_string_t cfg;
7276 cmdline_fixed_string_t what;
7279 static void cmd_showcfg_parsed(void *parsed_result,
7280 __attribute__((unused)) struct cmdline *cl,
7281 __attribute__((unused)) void *data)
7283 struct cmd_showcfg_result *res = parsed_result;
7284 if (!strcmp(res->what, "rxtx"))
7285 rxtx_config_display();
7286 else if (!strcmp(res->what, "cores"))
7287 fwd_lcores_config_display();
7288 else if (!strcmp(res->what, "fwd"))
7289 pkt_fwd_config_display(&cur_fwd_config);
7290 else if (!strcmp(res->what, "txpkts"))
7291 show_tx_pkt_segments();
7294 cmdline_parse_token_string_t cmd_showcfg_show =
7295 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7296 cmdline_parse_token_string_t cmd_showcfg_port =
7297 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7298 cmdline_parse_token_string_t cmd_showcfg_what =
7299 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7300 "rxtx#cores#fwd#txpkts");
7302 cmdline_parse_inst_t cmd_showcfg = {
7303 .f = cmd_showcfg_parsed,
7305 .help_str = "show config rxtx|cores|fwd|txpkts",
7307 (void *)&cmd_showcfg_show,
7308 (void *)&cmd_showcfg_port,
7309 (void *)&cmd_showcfg_what,
7314 /* *** SHOW ALL PORT INFO *** */
7315 struct cmd_showportall_result {
7316 cmdline_fixed_string_t show;
7317 cmdline_fixed_string_t port;
7318 cmdline_fixed_string_t what;
7319 cmdline_fixed_string_t all;
7322 static void cmd_showportall_parsed(void *parsed_result,
7323 __attribute__((unused)) struct cmdline *cl,
7324 __attribute__((unused)) void *data)
7328 struct cmd_showportall_result *res = parsed_result;
7329 if (!strcmp(res->show, "clear")) {
7330 if (!strcmp(res->what, "stats"))
7331 RTE_ETH_FOREACH_DEV(i)
7333 else if (!strcmp(res->what, "xstats"))
7334 RTE_ETH_FOREACH_DEV(i)
7335 nic_xstats_clear(i);
7336 } else if (!strcmp(res->what, "info"))
7337 RTE_ETH_FOREACH_DEV(i)
7338 port_infos_display(i);
7339 else if (!strcmp(res->what, "summary")) {
7340 port_summary_header_display();
7341 RTE_ETH_FOREACH_DEV(i)
7342 port_summary_display(i);
7344 else if (!strcmp(res->what, "stats"))
7345 RTE_ETH_FOREACH_DEV(i)
7346 nic_stats_display(i);
7347 else if (!strcmp(res->what, "xstats"))
7348 RTE_ETH_FOREACH_DEV(i)
7349 nic_xstats_display(i);
7350 else if (!strcmp(res->what, "fdir"))
7351 RTE_ETH_FOREACH_DEV(i)
7353 else if (!strcmp(res->what, "stat_qmap"))
7354 RTE_ETH_FOREACH_DEV(i)
7355 nic_stats_mapping_display(i);
7356 else if (!strcmp(res->what, "dcb_tc"))
7357 RTE_ETH_FOREACH_DEV(i)
7358 port_dcb_info_display(i);
7359 else if (!strcmp(res->what, "cap"))
7360 RTE_ETH_FOREACH_DEV(i)
7361 port_offload_cap_display(i);
7364 cmdline_parse_token_string_t cmd_showportall_show =
7365 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7367 cmdline_parse_token_string_t cmd_showportall_port =
7368 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7369 cmdline_parse_token_string_t cmd_showportall_what =
7370 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7371 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7372 cmdline_parse_token_string_t cmd_showportall_all =
7373 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7374 cmdline_parse_inst_t cmd_showportall = {
7375 .f = cmd_showportall_parsed,
7377 .help_str = "show|clear port "
7378 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7380 (void *)&cmd_showportall_show,
7381 (void *)&cmd_showportall_port,
7382 (void *)&cmd_showportall_what,
7383 (void *)&cmd_showportall_all,
7388 /* *** SHOW PORT INFO *** */
7389 struct cmd_showport_result {
7390 cmdline_fixed_string_t show;
7391 cmdline_fixed_string_t port;
7392 cmdline_fixed_string_t what;
7396 static void cmd_showport_parsed(void *parsed_result,
7397 __attribute__((unused)) struct cmdline *cl,
7398 __attribute__((unused)) void *data)
7400 struct cmd_showport_result *res = parsed_result;
7401 if (!strcmp(res->show, "clear")) {
7402 if (!strcmp(res->what, "stats"))
7403 nic_stats_clear(res->portnum);
7404 else if (!strcmp(res->what, "xstats"))
7405 nic_xstats_clear(res->portnum);
7406 } else if (!strcmp(res->what, "info"))
7407 port_infos_display(res->portnum);
7408 else if (!strcmp(res->what, "summary")) {
7409 port_summary_header_display();
7410 port_summary_display(res->portnum);
7412 else if (!strcmp(res->what, "stats"))
7413 nic_stats_display(res->portnum);
7414 else if (!strcmp(res->what, "xstats"))
7415 nic_xstats_display(res->portnum);
7416 else if (!strcmp(res->what, "fdir"))
7417 fdir_get_infos(res->portnum);
7418 else if (!strcmp(res->what, "stat_qmap"))
7419 nic_stats_mapping_display(res->portnum);
7420 else if (!strcmp(res->what, "dcb_tc"))
7421 port_dcb_info_display(res->portnum);
7422 else if (!strcmp(res->what, "cap"))
7423 port_offload_cap_display(res->portnum);
7426 cmdline_parse_token_string_t cmd_showport_show =
7427 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7429 cmdline_parse_token_string_t cmd_showport_port =
7430 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7431 cmdline_parse_token_string_t cmd_showport_what =
7432 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7433 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7434 cmdline_parse_token_num_t cmd_showport_portnum =
7435 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7437 cmdline_parse_inst_t cmd_showport = {
7438 .f = cmd_showport_parsed,
7440 .help_str = "show|clear port "
7441 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7444 (void *)&cmd_showport_show,
7445 (void *)&cmd_showport_port,
7446 (void *)&cmd_showport_what,
7447 (void *)&cmd_showport_portnum,
7452 /* *** SHOW DEVICE INFO *** */
7453 struct cmd_showdevice_result {
7454 cmdline_fixed_string_t show;
7455 cmdline_fixed_string_t device;
7456 cmdline_fixed_string_t what;
7457 cmdline_fixed_string_t identifier;
7460 static void cmd_showdevice_parsed(void *parsed_result,
7461 __attribute__((unused)) struct cmdline *cl,
7462 __attribute__((unused)) void *data)
7464 struct cmd_showdevice_result *res = parsed_result;
7465 if (!strcmp(res->what, "info")) {
7466 if (!strcmp(res->identifier, "all"))
7467 device_infos_display(NULL);
7469 device_infos_display(res->identifier);
7473 cmdline_parse_token_string_t cmd_showdevice_show =
7474 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7476 cmdline_parse_token_string_t cmd_showdevice_device =
7477 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7478 cmdline_parse_token_string_t cmd_showdevice_what =
7479 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7481 cmdline_parse_token_string_t cmd_showdevice_identifier =
7482 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7485 cmdline_parse_inst_t cmd_showdevice = {
7486 .f = cmd_showdevice_parsed,
7488 .help_str = "show device info <identifier>|all",
7490 (void *)&cmd_showdevice_show,
7491 (void *)&cmd_showdevice_device,
7492 (void *)&cmd_showdevice_what,
7493 (void *)&cmd_showdevice_identifier,
7497 /* *** SHOW QUEUE INFO *** */
7498 struct cmd_showqueue_result {
7499 cmdline_fixed_string_t show;
7500 cmdline_fixed_string_t type;
7501 cmdline_fixed_string_t what;
7507 cmd_showqueue_parsed(void *parsed_result,
7508 __attribute__((unused)) struct cmdline *cl,
7509 __attribute__((unused)) void *data)
7511 struct cmd_showqueue_result *res = parsed_result;
7513 if (!strcmp(res->type, "rxq"))
7514 rx_queue_infos_display(res->portnum, res->queuenum);
7515 else if (!strcmp(res->type, "txq"))
7516 tx_queue_infos_display(res->portnum, res->queuenum);
7519 cmdline_parse_token_string_t cmd_showqueue_show =
7520 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7521 cmdline_parse_token_string_t cmd_showqueue_type =
7522 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7523 cmdline_parse_token_string_t cmd_showqueue_what =
7524 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7525 cmdline_parse_token_num_t cmd_showqueue_portnum =
7526 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7527 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7528 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7530 cmdline_parse_inst_t cmd_showqueue = {
7531 .f = cmd_showqueue_parsed,
7533 .help_str = "show rxq|txq info <port_id> <queue_id>",
7535 (void *)&cmd_showqueue_show,
7536 (void *)&cmd_showqueue_type,
7537 (void *)&cmd_showqueue_what,
7538 (void *)&cmd_showqueue_portnum,
7539 (void *)&cmd_showqueue_queuenum,
7544 /* show/clear fwd engine statistics */
7546 cmdline_fixed_string_t action;
7547 cmdline_fixed_string_t fwd;
7548 cmdline_fixed_string_t stats;
7549 cmdline_fixed_string_t all;
7552 cmdline_parse_token_string_t cmd_fwd_action =
7553 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7554 cmdline_parse_token_string_t cmd_fwd_fwd =
7555 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7556 cmdline_parse_token_string_t cmd_fwd_stats =
7557 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7558 cmdline_parse_token_string_t cmd_fwd_all =
7559 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7562 cmd_showfwdall_parsed(void *parsed_result,
7563 __rte_unused struct cmdline *cl,
7564 __rte_unused void *data)
7566 struct fwd_result *res = parsed_result;
7568 if (!strcmp(res->action, "show"))
7569 fwd_stats_display();
7574 static cmdline_parse_inst_t cmd_showfwdall = {
7575 .f = cmd_showfwdall_parsed,
7577 .help_str = "show|clear fwd stats all",
7579 (void *)&cmd_fwd_action,
7580 (void *)&cmd_fwd_fwd,
7581 (void *)&cmd_fwd_stats,
7582 (void *)&cmd_fwd_all,
7587 /* *** READ PORT REGISTER *** */
7588 struct cmd_read_reg_result {
7589 cmdline_fixed_string_t read;
7590 cmdline_fixed_string_t reg;
7596 cmd_read_reg_parsed(void *parsed_result,
7597 __attribute__((unused)) struct cmdline *cl,
7598 __attribute__((unused)) void *data)
7600 struct cmd_read_reg_result *res = parsed_result;
7601 port_reg_display(res->port_id, res->reg_off);
7604 cmdline_parse_token_string_t cmd_read_reg_read =
7605 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7606 cmdline_parse_token_string_t cmd_read_reg_reg =
7607 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7608 cmdline_parse_token_num_t cmd_read_reg_port_id =
7609 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7610 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7611 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7613 cmdline_parse_inst_t cmd_read_reg = {
7614 .f = cmd_read_reg_parsed,
7616 .help_str = "read reg <port_id> <reg_off>",
7618 (void *)&cmd_read_reg_read,
7619 (void *)&cmd_read_reg_reg,
7620 (void *)&cmd_read_reg_port_id,
7621 (void *)&cmd_read_reg_reg_off,
7626 /* *** READ PORT REGISTER BIT FIELD *** */
7627 struct cmd_read_reg_bit_field_result {
7628 cmdline_fixed_string_t read;
7629 cmdline_fixed_string_t regfield;
7637 cmd_read_reg_bit_field_parsed(void *parsed_result,
7638 __attribute__((unused)) struct cmdline *cl,
7639 __attribute__((unused)) void *data)
7641 struct cmd_read_reg_bit_field_result *res = parsed_result;
7642 port_reg_bit_field_display(res->port_id, res->reg_off,
7643 res->bit1_pos, res->bit2_pos);
7646 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7647 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7649 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7650 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7651 regfield, "regfield");
7652 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7653 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7655 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7656 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7658 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7659 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7661 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7662 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7665 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7666 .f = cmd_read_reg_bit_field_parsed,
7668 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7669 "Read register bit field between bit_x and bit_y included",
7671 (void *)&cmd_read_reg_bit_field_read,
7672 (void *)&cmd_read_reg_bit_field_regfield,
7673 (void *)&cmd_read_reg_bit_field_port_id,
7674 (void *)&cmd_read_reg_bit_field_reg_off,
7675 (void *)&cmd_read_reg_bit_field_bit1_pos,
7676 (void *)&cmd_read_reg_bit_field_bit2_pos,
7681 /* *** READ PORT REGISTER BIT *** */
7682 struct cmd_read_reg_bit_result {
7683 cmdline_fixed_string_t read;
7684 cmdline_fixed_string_t regbit;
7691 cmd_read_reg_bit_parsed(void *parsed_result,
7692 __attribute__((unused)) struct cmdline *cl,
7693 __attribute__((unused)) void *data)
7695 struct cmd_read_reg_bit_result *res = parsed_result;
7696 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7699 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7700 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7701 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7702 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7704 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7705 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7706 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7707 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7708 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7709 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7711 cmdline_parse_inst_t cmd_read_reg_bit = {
7712 .f = cmd_read_reg_bit_parsed,
7714 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7716 (void *)&cmd_read_reg_bit_read,
7717 (void *)&cmd_read_reg_bit_regbit,
7718 (void *)&cmd_read_reg_bit_port_id,
7719 (void *)&cmd_read_reg_bit_reg_off,
7720 (void *)&cmd_read_reg_bit_bit_pos,
7725 /* *** WRITE PORT REGISTER *** */
7726 struct cmd_write_reg_result {
7727 cmdline_fixed_string_t write;
7728 cmdline_fixed_string_t reg;
7735 cmd_write_reg_parsed(void *parsed_result,
7736 __attribute__((unused)) struct cmdline *cl,
7737 __attribute__((unused)) void *data)
7739 struct cmd_write_reg_result *res = parsed_result;
7740 port_reg_set(res->port_id, res->reg_off, res->value);
7743 cmdline_parse_token_string_t cmd_write_reg_write =
7744 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7745 cmdline_parse_token_string_t cmd_write_reg_reg =
7746 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7747 cmdline_parse_token_num_t cmd_write_reg_port_id =
7748 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7749 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7750 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7751 cmdline_parse_token_num_t cmd_write_reg_value =
7752 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7754 cmdline_parse_inst_t cmd_write_reg = {
7755 .f = cmd_write_reg_parsed,
7757 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7759 (void *)&cmd_write_reg_write,
7760 (void *)&cmd_write_reg_reg,
7761 (void *)&cmd_write_reg_port_id,
7762 (void *)&cmd_write_reg_reg_off,
7763 (void *)&cmd_write_reg_value,
7768 /* *** WRITE PORT REGISTER BIT FIELD *** */
7769 struct cmd_write_reg_bit_field_result {
7770 cmdline_fixed_string_t write;
7771 cmdline_fixed_string_t regfield;
7780 cmd_write_reg_bit_field_parsed(void *parsed_result,
7781 __attribute__((unused)) struct cmdline *cl,
7782 __attribute__((unused)) void *data)
7784 struct cmd_write_reg_bit_field_result *res = parsed_result;
7785 port_reg_bit_field_set(res->port_id, res->reg_off,
7786 res->bit1_pos, res->bit2_pos, res->value);
7789 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7790 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7792 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7793 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7794 regfield, "regfield");
7795 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7796 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7798 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7799 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7801 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7802 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7804 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7805 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7807 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7808 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7811 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7812 .f = cmd_write_reg_bit_field_parsed,
7814 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7816 "Set register bit field between bit_x and bit_y included",
7818 (void *)&cmd_write_reg_bit_field_write,
7819 (void *)&cmd_write_reg_bit_field_regfield,
7820 (void *)&cmd_write_reg_bit_field_port_id,
7821 (void *)&cmd_write_reg_bit_field_reg_off,
7822 (void *)&cmd_write_reg_bit_field_bit1_pos,
7823 (void *)&cmd_write_reg_bit_field_bit2_pos,
7824 (void *)&cmd_write_reg_bit_field_value,
7829 /* *** WRITE PORT REGISTER BIT *** */
7830 struct cmd_write_reg_bit_result {
7831 cmdline_fixed_string_t write;
7832 cmdline_fixed_string_t regbit;
7840 cmd_write_reg_bit_parsed(void *parsed_result,
7841 __attribute__((unused)) struct cmdline *cl,
7842 __attribute__((unused)) void *data)
7844 struct cmd_write_reg_bit_result *res = parsed_result;
7845 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7848 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7849 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7851 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7852 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7854 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7855 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7856 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7857 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7858 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7859 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7860 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7861 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7863 cmdline_parse_inst_t cmd_write_reg_bit = {
7864 .f = cmd_write_reg_bit_parsed,
7866 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7869 (void *)&cmd_write_reg_bit_write,
7870 (void *)&cmd_write_reg_bit_regbit,
7871 (void *)&cmd_write_reg_bit_port_id,
7872 (void *)&cmd_write_reg_bit_reg_off,
7873 (void *)&cmd_write_reg_bit_bit_pos,
7874 (void *)&cmd_write_reg_bit_value,
7879 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7880 struct cmd_read_rxd_txd_result {
7881 cmdline_fixed_string_t read;
7882 cmdline_fixed_string_t rxd_txd;
7889 cmd_read_rxd_txd_parsed(void *parsed_result,
7890 __attribute__((unused)) struct cmdline *cl,
7891 __attribute__((unused)) void *data)
7893 struct cmd_read_rxd_txd_result *res = parsed_result;
7895 if (!strcmp(res->rxd_txd, "rxd"))
7896 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7897 else if (!strcmp(res->rxd_txd, "txd"))
7898 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7901 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7902 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7903 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7904 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7906 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7907 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7908 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7909 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7910 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7911 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7913 cmdline_parse_inst_t cmd_read_rxd_txd = {
7914 .f = cmd_read_rxd_txd_parsed,
7916 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7918 (void *)&cmd_read_rxd_txd_read,
7919 (void *)&cmd_read_rxd_txd_rxd_txd,
7920 (void *)&cmd_read_rxd_txd_port_id,
7921 (void *)&cmd_read_rxd_txd_queue_id,
7922 (void *)&cmd_read_rxd_txd_desc_id,
7928 struct cmd_quit_result {
7929 cmdline_fixed_string_t quit;
7932 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7934 __attribute__((unused)) void *data)
7939 cmdline_parse_token_string_t cmd_quit_quit =
7940 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7942 cmdline_parse_inst_t cmd_quit = {
7943 .f = cmd_quit_parsed,
7945 .help_str = "quit: Exit application",
7947 (void *)&cmd_quit_quit,
7952 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7953 struct cmd_mac_addr_result {
7954 cmdline_fixed_string_t mac_addr_cmd;
7955 cmdline_fixed_string_t what;
7957 struct rte_ether_addr address;
7960 static void cmd_mac_addr_parsed(void *parsed_result,
7961 __attribute__((unused)) struct cmdline *cl,
7962 __attribute__((unused)) void *data)
7964 struct cmd_mac_addr_result *res = parsed_result;
7967 if (strcmp(res->what, "add") == 0)
7968 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7969 else if (strcmp(res->what, "set") == 0)
7970 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7973 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7975 /* check the return value and print it if is < 0 */
7977 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7981 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7982 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7984 cmdline_parse_token_string_t cmd_mac_addr_what =
7985 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7987 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7988 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7990 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7991 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7993 cmdline_parse_inst_t cmd_mac_addr = {
7994 .f = cmd_mac_addr_parsed,
7996 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7997 "Add/Remove/Set MAC address on port_id",
7999 (void *)&cmd_mac_addr_cmd,
8000 (void *)&cmd_mac_addr_what,
8001 (void *)&cmd_mac_addr_portnum,
8002 (void *)&cmd_mac_addr_addr,
8007 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8008 struct cmd_eth_peer_result {
8009 cmdline_fixed_string_t set;
8010 cmdline_fixed_string_t eth_peer;
8012 cmdline_fixed_string_t peer_addr;
8015 static void cmd_set_eth_peer_parsed(void *parsed_result,
8016 __attribute__((unused)) struct cmdline *cl,
8017 __attribute__((unused)) void *data)
8019 struct cmd_eth_peer_result *res = parsed_result;
8021 if (test_done == 0) {
8022 printf("Please stop forwarding first\n");
8025 if (!strcmp(res->eth_peer, "eth-peer")) {
8026 set_fwd_eth_peer(res->port_id, res->peer_addr);
8030 cmdline_parse_token_string_t cmd_eth_peer_set =
8031 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8032 cmdline_parse_token_string_t cmd_eth_peer =
8033 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8034 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8035 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8036 cmdline_parse_token_string_t cmd_eth_peer_addr =
8037 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8039 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8040 .f = cmd_set_eth_peer_parsed,
8042 .help_str = "set eth-peer <port_id> <peer_mac>",
8044 (void *)&cmd_eth_peer_set,
8045 (void *)&cmd_eth_peer,
8046 (void *)&cmd_eth_peer_port_id,
8047 (void *)&cmd_eth_peer_addr,
8052 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8053 struct cmd_set_qmap_result {
8054 cmdline_fixed_string_t set;
8055 cmdline_fixed_string_t qmap;
8056 cmdline_fixed_string_t what;
8063 cmd_set_qmap_parsed(void *parsed_result,
8064 __attribute__((unused)) struct cmdline *cl,
8065 __attribute__((unused)) void *data)
8067 struct cmd_set_qmap_result *res = parsed_result;
8068 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8070 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8073 cmdline_parse_token_string_t cmd_setqmap_set =
8074 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8076 cmdline_parse_token_string_t cmd_setqmap_qmap =
8077 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8079 cmdline_parse_token_string_t cmd_setqmap_what =
8080 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8082 cmdline_parse_token_num_t cmd_setqmap_portid =
8083 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8085 cmdline_parse_token_num_t cmd_setqmap_queueid =
8086 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8088 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8089 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8092 cmdline_parse_inst_t cmd_set_qmap = {
8093 .f = cmd_set_qmap_parsed,
8095 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8096 "Set statistics mapping value on tx|rx queue_id of port_id",
8098 (void *)&cmd_setqmap_set,
8099 (void *)&cmd_setqmap_qmap,
8100 (void *)&cmd_setqmap_what,
8101 (void *)&cmd_setqmap_portid,
8102 (void *)&cmd_setqmap_queueid,
8103 (void *)&cmd_setqmap_mapvalue,
8108 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8109 struct cmd_set_xstats_hide_zero_result {
8110 cmdline_fixed_string_t keyword;
8111 cmdline_fixed_string_t name;
8112 cmdline_fixed_string_t on_off;
8116 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8117 __attribute__((unused)) struct cmdline *cl,
8118 __attribute__((unused)) void *data)
8120 struct cmd_set_xstats_hide_zero_result *res;
8121 uint16_t on_off = 0;
8123 res = parsed_result;
8124 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8125 set_xstats_hide_zero(on_off);
8128 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8129 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8131 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8132 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8133 name, "xstats-hide-zero");
8134 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8135 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8138 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8139 .f = cmd_set_xstats_hide_zero_parsed,
8141 .help_str = "set xstats-hide-zero on|off",
8143 (void *)&cmd_set_xstats_hide_zero_keyword,
8144 (void *)&cmd_set_xstats_hide_zero_name,
8145 (void *)&cmd_set_xstats_hide_zero_on_off,
8150 /* *** CONFIGURE UNICAST HASH TABLE *** */
8151 struct cmd_set_uc_hash_table {
8152 cmdline_fixed_string_t set;
8153 cmdline_fixed_string_t port;
8155 cmdline_fixed_string_t what;
8156 struct rte_ether_addr address;
8157 cmdline_fixed_string_t mode;
8161 cmd_set_uc_hash_parsed(void *parsed_result,
8162 __attribute__((unused)) struct cmdline *cl,
8163 __attribute__((unused)) void *data)
8166 struct cmd_set_uc_hash_table *res = parsed_result;
8168 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8170 if (strcmp(res->what, "uta") == 0)
8171 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8172 &res->address,(uint8_t)is_on);
8174 printf("bad unicast hash table parameter, return code = %d \n", ret);
8178 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8179 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8181 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8182 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8184 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8185 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8187 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8188 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8190 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8191 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8193 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8194 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8197 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8198 .f = cmd_set_uc_hash_parsed,
8200 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8202 (void *)&cmd_set_uc_hash_set,
8203 (void *)&cmd_set_uc_hash_port,
8204 (void *)&cmd_set_uc_hash_portid,
8205 (void *)&cmd_set_uc_hash_what,
8206 (void *)&cmd_set_uc_hash_mac,
8207 (void *)&cmd_set_uc_hash_mode,
8212 struct cmd_set_uc_all_hash_table {
8213 cmdline_fixed_string_t set;
8214 cmdline_fixed_string_t port;
8216 cmdline_fixed_string_t what;
8217 cmdline_fixed_string_t value;
8218 cmdline_fixed_string_t mode;
8222 cmd_set_uc_all_hash_parsed(void *parsed_result,
8223 __attribute__((unused)) struct cmdline *cl,
8224 __attribute__((unused)) void *data)
8227 struct cmd_set_uc_all_hash_table *res = parsed_result;
8229 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8231 if ((strcmp(res->what, "uta") == 0) &&
8232 (strcmp(res->value, "all") == 0))
8233 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8235 printf("bad unicast hash table parameter,"
8236 "return code = %d \n", ret);
8239 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8240 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8242 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8243 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8245 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8246 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8248 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8249 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8251 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8252 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8254 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8255 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8258 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8259 .f = cmd_set_uc_all_hash_parsed,
8261 .help_str = "set port <port_id> uta all on|off",
8263 (void *)&cmd_set_uc_all_hash_set,
8264 (void *)&cmd_set_uc_all_hash_port,
8265 (void *)&cmd_set_uc_all_hash_portid,
8266 (void *)&cmd_set_uc_all_hash_what,
8267 (void *)&cmd_set_uc_all_hash_value,
8268 (void *)&cmd_set_uc_all_hash_mode,
8273 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8274 struct cmd_set_vf_macvlan_filter {
8275 cmdline_fixed_string_t set;
8276 cmdline_fixed_string_t port;
8278 cmdline_fixed_string_t vf;
8280 struct rte_ether_addr address;
8281 cmdline_fixed_string_t filter_type;
8282 cmdline_fixed_string_t mode;
8286 cmd_set_vf_macvlan_parsed(void *parsed_result,
8287 __attribute__((unused)) struct cmdline *cl,
8288 __attribute__((unused)) void *data)
8291 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8292 struct rte_eth_mac_filter filter;
8294 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8296 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8298 /* set VF MAC filter */
8302 filter.dst_id = res->vf_id;
8304 if (!strcmp(res->filter_type, "exact-mac"))
8305 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8306 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8307 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8308 else if (!strcmp(res->filter_type, "hashmac"))
8309 filter.filter_type = RTE_MAC_HASH_MATCH;
8310 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8311 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8313 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8316 ret = rte_eth_dev_filter_ctrl(res->port_id,
8317 RTE_ETH_FILTER_MACVLAN,
8321 ret = rte_eth_dev_filter_ctrl(res->port_id,
8322 RTE_ETH_FILTER_MACVLAN,
8323 RTE_ETH_FILTER_DELETE,
8327 printf("bad set MAC hash parameter, return code = %d\n", ret);
8331 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8332 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8334 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8335 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8337 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8338 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8340 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8341 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8343 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8344 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8346 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8347 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8349 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8350 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8351 filter_type, "exact-mac#exact-mac-vlan"
8352 "#hashmac#hashmac-vlan");
8353 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8354 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8357 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8358 .f = cmd_set_vf_macvlan_parsed,
8360 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8361 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8362 "Exact match rule: exact match of MAC or MAC and VLAN; "
8363 "hash match rule: hash match of MAC and exact match of VLAN",
8365 (void *)&cmd_set_vf_macvlan_set,
8366 (void *)&cmd_set_vf_macvlan_port,
8367 (void *)&cmd_set_vf_macvlan_portid,
8368 (void *)&cmd_set_vf_macvlan_vf,
8369 (void *)&cmd_set_vf_macvlan_vf_id,
8370 (void *)&cmd_set_vf_macvlan_mac,
8371 (void *)&cmd_set_vf_macvlan_filter_type,
8372 (void *)&cmd_set_vf_macvlan_mode,
8377 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8378 struct cmd_set_vf_traffic {
8379 cmdline_fixed_string_t set;
8380 cmdline_fixed_string_t port;
8382 cmdline_fixed_string_t vf;
8384 cmdline_fixed_string_t what;
8385 cmdline_fixed_string_t mode;
8389 cmd_set_vf_traffic_parsed(void *parsed_result,
8390 __attribute__((unused)) struct cmdline *cl,
8391 __attribute__((unused)) void *data)
8393 struct cmd_set_vf_traffic *res = parsed_result;
8394 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8395 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8397 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8400 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8401 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8403 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8404 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8406 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8407 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8409 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8410 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8412 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8413 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8415 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8416 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8418 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8419 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8422 cmdline_parse_inst_t cmd_set_vf_traffic = {
8423 .f = cmd_set_vf_traffic_parsed,
8425 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8427 (void *)&cmd_setvf_traffic_set,
8428 (void *)&cmd_setvf_traffic_port,
8429 (void *)&cmd_setvf_traffic_portid,
8430 (void *)&cmd_setvf_traffic_vf,
8431 (void *)&cmd_setvf_traffic_vfid,
8432 (void *)&cmd_setvf_traffic_what,
8433 (void *)&cmd_setvf_traffic_mode,
8438 /* *** CONFIGURE VF RECEIVE MODE *** */
8439 struct cmd_set_vf_rxmode {
8440 cmdline_fixed_string_t set;
8441 cmdline_fixed_string_t port;
8443 cmdline_fixed_string_t vf;
8445 cmdline_fixed_string_t what;
8446 cmdline_fixed_string_t mode;
8447 cmdline_fixed_string_t on;
8451 cmd_set_vf_rxmode_parsed(void *parsed_result,
8452 __attribute__((unused)) struct cmdline *cl,
8453 __attribute__((unused)) void *data)
8456 uint16_t vf_rxmode = 0;
8457 struct cmd_set_vf_rxmode *res = parsed_result;
8459 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8460 if (!strcmp(res->what,"rxmode")) {
8461 if (!strcmp(res->mode, "AUPE"))
8462 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8463 else if (!strcmp(res->mode, "ROPE"))
8464 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8465 else if (!strcmp(res->mode, "BAM"))
8466 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8467 else if (!strncmp(res->mode, "MPE",3))
8468 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8471 RTE_SET_USED(is_on);
8473 #ifdef RTE_LIBRTE_IXGBE_PMD
8474 if (ret == -ENOTSUP)
8475 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8476 vf_rxmode, (uint8_t)is_on);
8478 #ifdef RTE_LIBRTE_BNXT_PMD
8479 if (ret == -ENOTSUP)
8480 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8481 vf_rxmode, (uint8_t)is_on);
8484 printf("bad VF receive mode parameter, return code = %d \n",
8488 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8489 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8491 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8492 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8494 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8495 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8497 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8498 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8500 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8501 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8503 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8504 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8506 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8507 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8508 mode, "AUPE#ROPE#BAM#MPE");
8509 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8510 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8513 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8514 .f = cmd_set_vf_rxmode_parsed,
8516 .help_str = "set port <port_id> vf <vf_id> rxmode "
8517 "AUPE|ROPE|BAM|MPE on|off",
8519 (void *)&cmd_set_vf_rxmode_set,
8520 (void *)&cmd_set_vf_rxmode_port,
8521 (void *)&cmd_set_vf_rxmode_portid,
8522 (void *)&cmd_set_vf_rxmode_vf,
8523 (void *)&cmd_set_vf_rxmode_vfid,
8524 (void *)&cmd_set_vf_rxmode_what,
8525 (void *)&cmd_set_vf_rxmode_mode,
8526 (void *)&cmd_set_vf_rxmode_on,
8531 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8532 struct cmd_vf_mac_addr_result {
8533 cmdline_fixed_string_t mac_addr_cmd;
8534 cmdline_fixed_string_t what;
8535 cmdline_fixed_string_t port;
8537 cmdline_fixed_string_t vf;
8539 struct rte_ether_addr address;
8542 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8543 __attribute__((unused)) struct cmdline *cl,
8544 __attribute__((unused)) void *data)
8546 struct cmd_vf_mac_addr_result *res = parsed_result;
8549 if (strcmp(res->what, "add") != 0)
8552 #ifdef RTE_LIBRTE_I40E_PMD
8553 if (ret == -ENOTSUP)
8554 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8557 #ifdef RTE_LIBRTE_BNXT_PMD
8558 if (ret == -ENOTSUP)
8559 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8564 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8568 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8569 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8570 mac_addr_cmd,"mac_addr");
8571 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8572 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8574 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8575 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8577 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8578 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8580 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8581 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8583 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8584 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8586 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8587 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8590 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8591 .f = cmd_vf_mac_addr_parsed,
8593 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8594 "Add MAC address filtering for a VF on port_id",
8596 (void *)&cmd_vf_mac_addr_cmd,
8597 (void *)&cmd_vf_mac_addr_what,
8598 (void *)&cmd_vf_mac_addr_port,
8599 (void *)&cmd_vf_mac_addr_portnum,
8600 (void *)&cmd_vf_mac_addr_vf,
8601 (void *)&cmd_vf_mac_addr_vfnum,
8602 (void *)&cmd_vf_mac_addr_addr,
8607 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8608 struct cmd_vf_rx_vlan_filter {
8609 cmdline_fixed_string_t rx_vlan;
8610 cmdline_fixed_string_t what;
8612 cmdline_fixed_string_t port;
8614 cmdline_fixed_string_t vf;
8619 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8620 __attribute__((unused)) struct cmdline *cl,
8621 __attribute__((unused)) void *data)
8623 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8626 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8628 #ifdef RTE_LIBRTE_IXGBE_PMD
8629 if (ret == -ENOTSUP)
8630 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8631 res->vlan_id, res->vf_mask, is_add);
8633 #ifdef RTE_LIBRTE_I40E_PMD
8634 if (ret == -ENOTSUP)
8635 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8636 res->vlan_id, res->vf_mask, is_add);
8638 #ifdef RTE_LIBRTE_BNXT_PMD
8639 if (ret == -ENOTSUP)
8640 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8641 res->vlan_id, res->vf_mask, is_add);
8648 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8649 res->vlan_id, res->vf_mask);
8652 printf("invalid port_id %d\n", res->port_id);
8655 printf("function not implemented or supported\n");
8658 printf("programming error: (%s)\n", strerror(-ret));
8662 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8663 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8664 rx_vlan, "rx_vlan");
8665 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8666 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8668 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8669 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8671 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8672 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8674 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8675 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8677 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8678 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8680 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8681 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8684 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8685 .f = cmd_vf_rx_vlan_filter_parsed,
8687 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8688 "(vf_mask = hexadecimal VF mask)",
8690 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8691 (void *)&cmd_vf_rx_vlan_filter_what,
8692 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8693 (void *)&cmd_vf_rx_vlan_filter_port,
8694 (void *)&cmd_vf_rx_vlan_filter_portid,
8695 (void *)&cmd_vf_rx_vlan_filter_vf,
8696 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8701 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8702 struct cmd_queue_rate_limit_result {
8703 cmdline_fixed_string_t set;
8704 cmdline_fixed_string_t port;
8706 cmdline_fixed_string_t queue;
8708 cmdline_fixed_string_t rate;
8712 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8713 __attribute__((unused)) struct cmdline *cl,
8714 __attribute__((unused)) void *data)
8716 struct cmd_queue_rate_limit_result *res = parsed_result;
8719 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8720 && (strcmp(res->queue, "queue") == 0)
8721 && (strcmp(res->rate, "rate") == 0))
8722 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8725 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8729 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8730 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8732 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8733 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8735 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8736 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8738 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8739 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8741 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8742 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8744 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8745 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8747 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8748 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8751 cmdline_parse_inst_t cmd_queue_rate_limit = {
8752 .f = cmd_queue_rate_limit_parsed,
8754 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8755 "Set rate limit for a queue on port_id",
8757 (void *)&cmd_queue_rate_limit_set,
8758 (void *)&cmd_queue_rate_limit_port,
8759 (void *)&cmd_queue_rate_limit_portnum,
8760 (void *)&cmd_queue_rate_limit_queue,
8761 (void *)&cmd_queue_rate_limit_queuenum,
8762 (void *)&cmd_queue_rate_limit_rate,
8763 (void *)&cmd_queue_rate_limit_ratenum,
8768 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8769 struct cmd_vf_rate_limit_result {
8770 cmdline_fixed_string_t set;
8771 cmdline_fixed_string_t port;
8773 cmdline_fixed_string_t vf;
8775 cmdline_fixed_string_t rate;
8777 cmdline_fixed_string_t q_msk;
8781 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8782 __attribute__((unused)) struct cmdline *cl,
8783 __attribute__((unused)) void *data)
8785 struct cmd_vf_rate_limit_result *res = parsed_result;
8788 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8789 && (strcmp(res->vf, "vf") == 0)
8790 && (strcmp(res->rate, "rate") == 0)
8791 && (strcmp(res->q_msk, "queue_mask") == 0))
8792 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8793 res->rate_num, res->q_msk_val);
8795 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8799 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8800 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8802 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8803 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8805 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8806 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8808 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8809 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8811 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8812 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8814 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8815 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8817 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8818 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8820 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8821 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8822 q_msk, "queue_mask");
8823 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8824 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8827 cmdline_parse_inst_t cmd_vf_rate_limit = {
8828 .f = cmd_vf_rate_limit_parsed,
8830 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8831 "queue_mask <queue_mask_value>: "
8832 "Set rate limit for queues of VF on port_id",
8834 (void *)&cmd_vf_rate_limit_set,
8835 (void *)&cmd_vf_rate_limit_port,
8836 (void *)&cmd_vf_rate_limit_portnum,
8837 (void *)&cmd_vf_rate_limit_vf,
8838 (void *)&cmd_vf_rate_limit_vfnum,
8839 (void *)&cmd_vf_rate_limit_rate,
8840 (void *)&cmd_vf_rate_limit_ratenum,
8841 (void *)&cmd_vf_rate_limit_q_msk,
8842 (void *)&cmd_vf_rate_limit_q_msk_val,
8847 /* *** ADD TUNNEL FILTER OF A PORT *** */
8848 struct cmd_tunnel_filter_result {
8849 cmdline_fixed_string_t cmd;
8850 cmdline_fixed_string_t what;
8852 struct rte_ether_addr outer_mac;
8853 struct rte_ether_addr inner_mac;
8854 cmdline_ipaddr_t ip_value;
8855 uint16_t inner_vlan;
8856 cmdline_fixed_string_t tunnel_type;
8857 cmdline_fixed_string_t filter_type;
8863 cmd_tunnel_filter_parsed(void *parsed_result,
8864 __attribute__((unused)) struct cmdline *cl,
8865 __attribute__((unused)) void *data)
8867 struct cmd_tunnel_filter_result *res = parsed_result;
8868 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8871 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8873 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8874 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8875 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8877 if (res->ip_value.family == AF_INET) {
8878 tunnel_filter_conf.ip_addr.ipv4_addr =
8879 res->ip_value.addr.ipv4.s_addr;
8880 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8882 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8883 &(res->ip_value.addr.ipv6),
8884 sizeof(struct in6_addr));
8885 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8888 if (!strcmp(res->filter_type, "imac-ivlan"))
8889 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8890 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8891 tunnel_filter_conf.filter_type =
8892 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8893 else if (!strcmp(res->filter_type, "imac-tenid"))
8894 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8895 else if (!strcmp(res->filter_type, "imac"))
8896 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8897 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8898 tunnel_filter_conf.filter_type =
8899 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8900 else if (!strcmp(res->filter_type, "oip"))
8901 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8902 else if (!strcmp(res->filter_type, "iip"))
8903 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8905 printf("The filter type is not supported");
8909 if (!strcmp(res->tunnel_type, "vxlan"))
8910 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8911 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8912 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8913 else if (!strcmp(res->tunnel_type, "nvgre"))
8914 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8915 else if (!strcmp(res->tunnel_type, "ipingre"))
8916 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8918 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8922 tunnel_filter_conf.tenant_id = res->tenant_id;
8923 tunnel_filter_conf.queue_id = res->queue_num;
8924 if (!strcmp(res->what, "add"))
8925 ret = rte_eth_dev_filter_ctrl(res->port_id,
8926 RTE_ETH_FILTER_TUNNEL,
8928 &tunnel_filter_conf);
8930 ret = rte_eth_dev_filter_ctrl(res->port_id,
8931 RTE_ETH_FILTER_TUNNEL,
8932 RTE_ETH_FILTER_DELETE,
8933 &tunnel_filter_conf);
8935 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8939 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8940 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8941 cmd, "tunnel_filter");
8942 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8943 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8945 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8946 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8948 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8949 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8951 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8952 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8954 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8955 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8956 inner_vlan, UINT16);
8957 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8958 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8960 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8961 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8962 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8964 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8965 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8966 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8967 "imac#omac-imac-tenid");
8968 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8969 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8971 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8972 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8975 cmdline_parse_inst_t cmd_tunnel_filter = {
8976 .f = cmd_tunnel_filter_parsed,
8978 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8979 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8980 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8981 "<queue_id>: Add/Rm tunnel filter of a port",
8983 (void *)&cmd_tunnel_filter_cmd,
8984 (void *)&cmd_tunnel_filter_what,
8985 (void *)&cmd_tunnel_filter_port_id,
8986 (void *)&cmd_tunnel_filter_outer_mac,
8987 (void *)&cmd_tunnel_filter_inner_mac,
8988 (void *)&cmd_tunnel_filter_ip_value,
8989 (void *)&cmd_tunnel_filter_innner_vlan,
8990 (void *)&cmd_tunnel_filter_tunnel_type,
8991 (void *)&cmd_tunnel_filter_filter_type,
8992 (void *)&cmd_tunnel_filter_tenant_id,
8993 (void *)&cmd_tunnel_filter_queue_num,
8998 /* *** CONFIGURE TUNNEL UDP PORT *** */
8999 struct cmd_tunnel_udp_config {
9000 cmdline_fixed_string_t cmd;
9001 cmdline_fixed_string_t what;
9007 cmd_tunnel_udp_config_parsed(void *parsed_result,
9008 __attribute__((unused)) struct cmdline *cl,
9009 __attribute__((unused)) void *data)
9011 struct cmd_tunnel_udp_config *res = parsed_result;
9012 struct rte_eth_udp_tunnel tunnel_udp;
9015 tunnel_udp.udp_port = res->udp_port;
9017 if (!strcmp(res->cmd, "rx_vxlan_port"))
9018 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9020 if (!strcmp(res->what, "add"))
9021 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9024 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9028 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9031 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9032 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9033 cmd, "rx_vxlan_port");
9034 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9035 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9037 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9038 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9040 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9041 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9044 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9045 .f = cmd_tunnel_udp_config_parsed,
9047 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9048 "Add/Remove a tunneling UDP port filter",
9050 (void *)&cmd_tunnel_udp_config_cmd,
9051 (void *)&cmd_tunnel_udp_config_what,
9052 (void *)&cmd_tunnel_udp_config_udp_port,
9053 (void *)&cmd_tunnel_udp_config_port_id,
9058 struct cmd_config_tunnel_udp_port {
9059 cmdline_fixed_string_t port;
9060 cmdline_fixed_string_t config;
9062 cmdline_fixed_string_t udp_tunnel_port;
9063 cmdline_fixed_string_t action;
9064 cmdline_fixed_string_t tunnel_type;
9069 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9070 __attribute__((unused)) struct cmdline *cl,
9071 __attribute__((unused)) void *data)
9073 struct cmd_config_tunnel_udp_port *res = parsed_result;
9074 struct rte_eth_udp_tunnel tunnel_udp;
9077 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9080 tunnel_udp.udp_port = res->udp_port;
9082 if (!strcmp(res->tunnel_type, "vxlan")) {
9083 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9084 } else if (!strcmp(res->tunnel_type, "geneve")) {
9085 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9086 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9087 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9089 printf("Invalid tunnel type\n");
9093 if (!strcmp(res->action, "add"))
9094 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9097 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9101 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9104 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9105 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9107 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9108 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9110 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9111 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9113 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9114 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9117 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9118 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9120 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9121 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9122 "vxlan#geneve#vxlan-gpe");
9123 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9124 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9127 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9128 .f = cmd_cfg_tunnel_udp_port_parsed,
9130 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9132 (void *)&cmd_config_tunnel_udp_port_port,
9133 (void *)&cmd_config_tunnel_udp_port_config,
9134 (void *)&cmd_config_tunnel_udp_port_port_id,
9135 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9136 (void *)&cmd_config_tunnel_udp_port_action,
9137 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9138 (void *)&cmd_config_tunnel_udp_port_value,
9143 /* *** GLOBAL CONFIG *** */
9144 struct cmd_global_config_result {
9145 cmdline_fixed_string_t cmd;
9147 cmdline_fixed_string_t cfg_type;
9152 cmd_global_config_parsed(void *parsed_result,
9153 __attribute__((unused)) struct cmdline *cl,
9154 __attribute__((unused)) void *data)
9156 struct cmd_global_config_result *res = parsed_result;
9157 struct rte_eth_global_cfg conf;
9160 memset(&conf, 0, sizeof(conf));
9161 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9162 conf.cfg.gre_key_len = res->len;
9163 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9164 RTE_ETH_FILTER_SET, &conf);
9166 printf("Global config error\n");
9169 cmdline_parse_token_string_t cmd_global_config_cmd =
9170 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9172 cmdline_parse_token_num_t cmd_global_config_port_id =
9173 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9175 cmdline_parse_token_string_t cmd_global_config_type =
9176 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9177 cfg_type, "gre-key-len");
9178 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9179 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9182 cmdline_parse_inst_t cmd_global_config = {
9183 .f = cmd_global_config_parsed,
9184 .data = (void *)NULL,
9185 .help_str = "global_config <port_id> gre-key-len <key_len>",
9187 (void *)&cmd_global_config_cmd,
9188 (void *)&cmd_global_config_port_id,
9189 (void *)&cmd_global_config_type,
9190 (void *)&cmd_global_config_gre_key_len,
9195 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9196 struct cmd_set_mirror_mask_result {
9197 cmdline_fixed_string_t set;
9198 cmdline_fixed_string_t port;
9200 cmdline_fixed_string_t mirror;
9202 cmdline_fixed_string_t what;
9203 cmdline_fixed_string_t value;
9204 cmdline_fixed_string_t dstpool;
9206 cmdline_fixed_string_t on;
9209 cmdline_parse_token_string_t cmd_mirror_mask_set =
9210 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9212 cmdline_parse_token_string_t cmd_mirror_mask_port =
9213 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9215 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9216 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9218 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9219 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9220 mirror, "mirror-rule");
9221 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9222 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9224 cmdline_parse_token_string_t cmd_mirror_mask_what =
9225 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9226 what, "pool-mirror-up#pool-mirror-down"
9228 cmdline_parse_token_string_t cmd_mirror_mask_value =
9229 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9231 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9232 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9233 dstpool, "dst-pool");
9234 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9235 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9237 cmdline_parse_token_string_t cmd_mirror_mask_on =
9238 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9242 cmd_set_mirror_mask_parsed(void *parsed_result,
9243 __attribute__((unused)) struct cmdline *cl,
9244 __attribute__((unused)) void *data)
9247 struct cmd_set_mirror_mask_result *res = parsed_result;
9248 struct rte_eth_mirror_conf mr_conf;
9250 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9252 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9254 mr_conf.dst_pool = res->dstpool_id;
9256 if (!strcmp(res->what, "pool-mirror-up")) {
9257 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9258 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9259 } else if (!strcmp(res->what, "pool-mirror-down")) {
9260 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9261 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9262 } else if (!strcmp(res->what, "vlan-mirror")) {
9263 mr_conf.rule_type = ETH_MIRROR_VLAN;
9264 nb_item = parse_item_list(res->value, "vlan",
9265 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9269 for (i = 0; i < nb_item; i++) {
9270 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9271 printf("Invalid vlan_id: must be < 4096\n");
9275 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9276 mr_conf.vlan.vlan_mask |= 1ULL << i;
9280 if (!strcmp(res->on, "on"))
9281 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9284 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9287 printf("mirror rule add error: (%s)\n", strerror(-ret));
9290 cmdline_parse_inst_t cmd_set_mirror_mask = {
9291 .f = cmd_set_mirror_mask_parsed,
9293 .help_str = "set port <port_id> mirror-rule <rule_id> "
9294 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9295 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9297 (void *)&cmd_mirror_mask_set,
9298 (void *)&cmd_mirror_mask_port,
9299 (void *)&cmd_mirror_mask_portid,
9300 (void *)&cmd_mirror_mask_mirror,
9301 (void *)&cmd_mirror_mask_ruleid,
9302 (void *)&cmd_mirror_mask_what,
9303 (void *)&cmd_mirror_mask_value,
9304 (void *)&cmd_mirror_mask_dstpool,
9305 (void *)&cmd_mirror_mask_poolid,
9306 (void *)&cmd_mirror_mask_on,
9311 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9312 struct cmd_set_mirror_link_result {
9313 cmdline_fixed_string_t set;
9314 cmdline_fixed_string_t port;
9316 cmdline_fixed_string_t mirror;
9318 cmdline_fixed_string_t what;
9319 cmdline_fixed_string_t dstpool;
9321 cmdline_fixed_string_t on;
9324 cmdline_parse_token_string_t cmd_mirror_link_set =
9325 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9327 cmdline_parse_token_string_t cmd_mirror_link_port =
9328 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9330 cmdline_parse_token_num_t cmd_mirror_link_portid =
9331 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9333 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9334 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9335 mirror, "mirror-rule");
9336 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9337 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9339 cmdline_parse_token_string_t cmd_mirror_link_what =
9340 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9341 what, "uplink-mirror#downlink-mirror");
9342 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9343 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9344 dstpool, "dst-pool");
9345 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9346 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9348 cmdline_parse_token_string_t cmd_mirror_link_on =
9349 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9353 cmd_set_mirror_link_parsed(void *parsed_result,
9354 __attribute__((unused)) struct cmdline *cl,
9355 __attribute__((unused)) void *data)
9358 struct cmd_set_mirror_link_result *res = parsed_result;
9359 struct rte_eth_mirror_conf mr_conf;
9361 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9362 if (!strcmp(res->what, "uplink-mirror"))
9363 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9365 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9367 mr_conf.dst_pool = res->dstpool_id;
9369 if (!strcmp(res->on, "on"))
9370 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9373 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9376 /* check the return value and print it if is < 0 */
9378 printf("mirror rule add error: (%s)\n", strerror(-ret));
9382 cmdline_parse_inst_t cmd_set_mirror_link = {
9383 .f = cmd_set_mirror_link_parsed,
9385 .help_str = "set port <port_id> mirror-rule <rule_id> "
9386 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9388 (void *)&cmd_mirror_link_set,
9389 (void *)&cmd_mirror_link_port,
9390 (void *)&cmd_mirror_link_portid,
9391 (void *)&cmd_mirror_link_mirror,
9392 (void *)&cmd_mirror_link_ruleid,
9393 (void *)&cmd_mirror_link_what,
9394 (void *)&cmd_mirror_link_dstpool,
9395 (void *)&cmd_mirror_link_poolid,
9396 (void *)&cmd_mirror_link_on,
9401 /* *** RESET VM MIRROR RULE *** */
9402 struct cmd_rm_mirror_rule_result {
9403 cmdline_fixed_string_t reset;
9404 cmdline_fixed_string_t port;
9406 cmdline_fixed_string_t mirror;
9410 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9411 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9413 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9414 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9416 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9417 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9419 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9420 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9421 mirror, "mirror-rule");
9422 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9423 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9427 cmd_reset_mirror_rule_parsed(void *parsed_result,
9428 __attribute__((unused)) struct cmdline *cl,
9429 __attribute__((unused)) void *data)
9432 struct cmd_set_mirror_link_result *res = parsed_result;
9434 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9436 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9439 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9440 .f = cmd_reset_mirror_rule_parsed,
9442 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9444 (void *)&cmd_rm_mirror_rule_reset,
9445 (void *)&cmd_rm_mirror_rule_port,
9446 (void *)&cmd_rm_mirror_rule_portid,
9447 (void *)&cmd_rm_mirror_rule_mirror,
9448 (void *)&cmd_rm_mirror_rule_ruleid,
9453 /* ******************************************************************************** */
9455 struct cmd_dump_result {
9456 cmdline_fixed_string_t dump;
9460 dump_struct_sizes(void)
9462 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9463 DUMP_SIZE(struct rte_mbuf);
9464 DUMP_SIZE(struct rte_mempool);
9465 DUMP_SIZE(struct rte_ring);
9469 static void cmd_dump_parsed(void *parsed_result,
9470 __attribute__((unused)) struct cmdline *cl,
9471 __attribute__((unused)) void *data)
9473 struct cmd_dump_result *res = parsed_result;
9475 if (!strcmp(res->dump, "dump_physmem"))
9476 rte_dump_physmem_layout(stdout);
9477 else if (!strcmp(res->dump, "dump_memzone"))
9478 rte_memzone_dump(stdout);
9479 else if (!strcmp(res->dump, "dump_struct_sizes"))
9480 dump_struct_sizes();
9481 else if (!strcmp(res->dump, "dump_ring"))
9482 rte_ring_list_dump(stdout);
9483 else if (!strcmp(res->dump, "dump_mempool"))
9484 rte_mempool_list_dump(stdout);
9485 else if (!strcmp(res->dump, "dump_devargs"))
9486 rte_devargs_dump(stdout);
9487 else if (!strcmp(res->dump, "dump_log_types"))
9488 rte_log_dump(stdout);
9491 cmdline_parse_token_string_t cmd_dump_dump =
9492 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9495 "dump_struct_sizes#"
9501 cmdline_parse_inst_t cmd_dump = {
9502 .f = cmd_dump_parsed, /* function to call */
9503 .data = NULL, /* 2nd arg of func */
9504 .help_str = "Dump status",
9505 .tokens = { /* token list, NULL terminated */
9506 (void *)&cmd_dump_dump,
9511 /* ******************************************************************************** */
9513 struct cmd_dump_one_result {
9514 cmdline_fixed_string_t dump;
9515 cmdline_fixed_string_t name;
9518 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9519 __attribute__((unused)) void *data)
9521 struct cmd_dump_one_result *res = parsed_result;
9523 if (!strcmp(res->dump, "dump_ring")) {
9525 r = rte_ring_lookup(res->name);
9527 cmdline_printf(cl, "Cannot find ring\n");
9530 rte_ring_dump(stdout, r);
9531 } else if (!strcmp(res->dump, "dump_mempool")) {
9532 struct rte_mempool *mp;
9533 mp = rte_mempool_lookup(res->name);
9535 cmdline_printf(cl, "Cannot find mempool\n");
9538 rte_mempool_dump(stdout, mp);
9542 cmdline_parse_token_string_t cmd_dump_one_dump =
9543 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9544 "dump_ring#dump_mempool");
9546 cmdline_parse_token_string_t cmd_dump_one_name =
9547 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9549 cmdline_parse_inst_t cmd_dump_one = {
9550 .f = cmd_dump_one_parsed, /* function to call */
9551 .data = NULL, /* 2nd arg of func */
9552 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9553 .tokens = { /* token list, NULL terminated */
9554 (void *)&cmd_dump_one_dump,
9555 (void *)&cmd_dump_one_name,
9560 /* *** Add/Del syn filter *** */
9561 struct cmd_syn_filter_result {
9562 cmdline_fixed_string_t filter;
9564 cmdline_fixed_string_t ops;
9565 cmdline_fixed_string_t priority;
9566 cmdline_fixed_string_t high;
9567 cmdline_fixed_string_t queue;
9572 cmd_syn_filter_parsed(void *parsed_result,
9573 __attribute__((unused)) struct cmdline *cl,
9574 __attribute__((unused)) void *data)
9576 struct cmd_syn_filter_result *res = parsed_result;
9577 struct rte_eth_syn_filter syn_filter;
9580 ret = rte_eth_dev_filter_supported(res->port_id,
9581 RTE_ETH_FILTER_SYN);
9583 printf("syn filter is not supported on port %u.\n",
9588 memset(&syn_filter, 0, sizeof(syn_filter));
9590 if (!strcmp(res->ops, "add")) {
9591 if (!strcmp(res->high, "high"))
9592 syn_filter.hig_pri = 1;
9594 syn_filter.hig_pri = 0;
9596 syn_filter.queue = res->queue_id;
9597 ret = rte_eth_dev_filter_ctrl(res->port_id,
9602 ret = rte_eth_dev_filter_ctrl(res->port_id,
9604 RTE_ETH_FILTER_DELETE,
9608 printf("syn filter programming error: (%s)\n",
9612 cmdline_parse_token_string_t cmd_syn_filter_filter =
9613 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9614 filter, "syn_filter");
9615 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9616 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9618 cmdline_parse_token_string_t cmd_syn_filter_ops =
9619 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9621 cmdline_parse_token_string_t cmd_syn_filter_priority =
9622 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9623 priority, "priority");
9624 cmdline_parse_token_string_t cmd_syn_filter_high =
9625 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9627 cmdline_parse_token_string_t cmd_syn_filter_queue =
9628 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9630 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9631 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9634 cmdline_parse_inst_t cmd_syn_filter = {
9635 .f = cmd_syn_filter_parsed,
9637 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9638 "<queue_id>: Add/Delete syn filter",
9640 (void *)&cmd_syn_filter_filter,
9641 (void *)&cmd_syn_filter_port_id,
9642 (void *)&cmd_syn_filter_ops,
9643 (void *)&cmd_syn_filter_priority,
9644 (void *)&cmd_syn_filter_high,
9645 (void *)&cmd_syn_filter_queue,
9646 (void *)&cmd_syn_filter_queue_id,
9651 /* *** queue region set *** */
9652 struct cmd_queue_region_result {
9653 cmdline_fixed_string_t set;
9654 cmdline_fixed_string_t port;
9656 cmdline_fixed_string_t cmd;
9657 cmdline_fixed_string_t region;
9659 cmdline_fixed_string_t queue_start_index;
9661 cmdline_fixed_string_t queue_num;
9662 uint8_t queue_num_value;
9666 cmd_queue_region_parsed(void *parsed_result,
9667 __attribute__((unused)) struct cmdline *cl,
9668 __attribute__((unused)) void *data)
9670 struct cmd_queue_region_result *res = parsed_result;
9672 #ifdef RTE_LIBRTE_I40E_PMD
9673 struct rte_pmd_i40e_queue_region_conf region_conf;
9674 enum rte_pmd_i40e_queue_region_op op_type;
9677 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9680 #ifdef RTE_LIBRTE_I40E_PMD
9681 memset(®ion_conf, 0, sizeof(region_conf));
9682 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9683 region_conf.region_id = res->region_id;
9684 region_conf.queue_num = res->queue_num_value;
9685 region_conf.queue_start_index = res->queue_id;
9687 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9688 op_type, ®ion_conf);
9695 printf("function not implemented or supported\n");
9698 printf("queue region config error: (%s)\n", strerror(-ret));
9702 cmdline_parse_token_string_t cmd_queue_region_set =
9703 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9705 cmdline_parse_token_string_t cmd_queue_region_port =
9706 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9707 cmdline_parse_token_num_t cmd_queue_region_port_id =
9708 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9710 cmdline_parse_token_string_t cmd_queue_region_cmd =
9711 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9712 cmd, "queue-region");
9713 cmdline_parse_token_string_t cmd_queue_region_id =
9714 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9715 region, "region_id");
9716 cmdline_parse_token_num_t cmd_queue_region_index =
9717 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9719 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9720 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9721 queue_start_index, "queue_start_index");
9722 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9723 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9725 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9726 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9727 queue_num, "queue_num");
9728 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9729 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9730 queue_num_value, UINT8);
9732 cmdline_parse_inst_t cmd_queue_region = {
9733 .f = cmd_queue_region_parsed,
9735 .help_str = "set port <port_id> queue-region region_id <value> "
9736 "queue_start_index <value> queue_num <value>: Set a queue region",
9738 (void *)&cmd_queue_region_set,
9739 (void *)&cmd_queue_region_port,
9740 (void *)&cmd_queue_region_port_id,
9741 (void *)&cmd_queue_region_cmd,
9742 (void *)&cmd_queue_region_id,
9743 (void *)&cmd_queue_region_index,
9744 (void *)&cmd_queue_region_queue_start_index,
9745 (void *)&cmd_queue_region_queue_id,
9746 (void *)&cmd_queue_region_queue_num,
9747 (void *)&cmd_queue_region_queue_num_value,
9752 /* *** queue region and flowtype set *** */
9753 struct cmd_region_flowtype_result {
9754 cmdline_fixed_string_t set;
9755 cmdline_fixed_string_t port;
9757 cmdline_fixed_string_t cmd;
9758 cmdline_fixed_string_t region;
9760 cmdline_fixed_string_t flowtype;
9761 uint8_t flowtype_id;
9765 cmd_region_flowtype_parsed(void *parsed_result,
9766 __attribute__((unused)) struct cmdline *cl,
9767 __attribute__((unused)) void *data)
9769 struct cmd_region_flowtype_result *res = parsed_result;
9771 #ifdef RTE_LIBRTE_I40E_PMD
9772 struct rte_pmd_i40e_queue_region_conf region_conf;
9773 enum rte_pmd_i40e_queue_region_op op_type;
9776 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9779 #ifdef RTE_LIBRTE_I40E_PMD
9780 memset(®ion_conf, 0, sizeof(region_conf));
9782 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9783 region_conf.region_id = res->region_id;
9784 region_conf.hw_flowtype = res->flowtype_id;
9786 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9787 op_type, ®ion_conf);
9794 printf("function not implemented or supported\n");
9797 printf("region flowtype config error: (%s)\n", strerror(-ret));
9801 cmdline_parse_token_string_t cmd_region_flowtype_set =
9802 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9804 cmdline_parse_token_string_t cmd_region_flowtype_port =
9805 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9807 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9808 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9810 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9811 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9812 cmd, "queue-region");
9813 cmdline_parse_token_string_t cmd_region_flowtype_index =
9814 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9815 region, "region_id");
9816 cmdline_parse_token_num_t cmd_region_flowtype_id =
9817 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9819 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9820 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9821 flowtype, "flowtype");
9822 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9823 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9824 flowtype_id, UINT8);
9825 cmdline_parse_inst_t cmd_region_flowtype = {
9826 .f = cmd_region_flowtype_parsed,
9828 .help_str = "set port <port_id> queue-region region_id <value> "
9829 "flowtype <value>: Set a flowtype region index",
9831 (void *)&cmd_region_flowtype_set,
9832 (void *)&cmd_region_flowtype_port,
9833 (void *)&cmd_region_flowtype_port_index,
9834 (void *)&cmd_region_flowtype_cmd,
9835 (void *)&cmd_region_flowtype_index,
9836 (void *)&cmd_region_flowtype_id,
9837 (void *)&cmd_region_flowtype_flow_index,
9838 (void *)&cmd_region_flowtype_flow_id,
9843 /* *** User Priority (UP) to queue region (region_id) set *** */
9844 struct cmd_user_priority_region_result {
9845 cmdline_fixed_string_t set;
9846 cmdline_fixed_string_t port;
9848 cmdline_fixed_string_t cmd;
9849 cmdline_fixed_string_t user_priority;
9850 uint8_t user_priority_id;
9851 cmdline_fixed_string_t region;
9856 cmd_user_priority_region_parsed(void *parsed_result,
9857 __attribute__((unused)) struct cmdline *cl,
9858 __attribute__((unused)) void *data)
9860 struct cmd_user_priority_region_result *res = parsed_result;
9862 #ifdef RTE_LIBRTE_I40E_PMD
9863 struct rte_pmd_i40e_queue_region_conf region_conf;
9864 enum rte_pmd_i40e_queue_region_op op_type;
9867 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9870 #ifdef RTE_LIBRTE_I40E_PMD
9871 memset(®ion_conf, 0, sizeof(region_conf));
9872 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9873 region_conf.user_priority = res->user_priority_id;
9874 region_conf.region_id = res->region_id;
9876 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9877 op_type, ®ion_conf);
9884 printf("function not implemented or supported\n");
9887 printf("user_priority region config error: (%s)\n",
9892 cmdline_parse_token_string_t cmd_user_priority_region_set =
9893 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9895 cmdline_parse_token_string_t cmd_user_priority_region_port =
9896 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9898 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9899 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9901 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9902 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9903 cmd, "queue-region");
9904 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9905 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9906 user_priority, "UP");
9907 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9908 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9909 user_priority_id, UINT8);
9910 cmdline_parse_token_string_t cmd_user_priority_region_region =
9911 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9912 region, "region_id");
9913 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9914 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9917 cmdline_parse_inst_t cmd_user_priority_region = {
9918 .f = cmd_user_priority_region_parsed,
9920 .help_str = "set port <port_id> queue-region UP <value> "
9921 "region_id <value>: Set the mapping of User Priority (UP) "
9922 "to queue region (region_id) ",
9924 (void *)&cmd_user_priority_region_set,
9925 (void *)&cmd_user_priority_region_port,
9926 (void *)&cmd_user_priority_region_port_index,
9927 (void *)&cmd_user_priority_region_cmd,
9928 (void *)&cmd_user_priority_region_UP,
9929 (void *)&cmd_user_priority_region_UP_id,
9930 (void *)&cmd_user_priority_region_region,
9931 (void *)&cmd_user_priority_region_region_id,
9936 /* *** flush all queue region related configuration *** */
9937 struct cmd_flush_queue_region_result {
9938 cmdline_fixed_string_t set;
9939 cmdline_fixed_string_t port;
9941 cmdline_fixed_string_t cmd;
9942 cmdline_fixed_string_t flush;
9943 cmdline_fixed_string_t what;
9947 cmd_flush_queue_region_parsed(void *parsed_result,
9948 __attribute__((unused)) struct cmdline *cl,
9949 __attribute__((unused)) void *data)
9951 struct cmd_flush_queue_region_result *res = parsed_result;
9953 #ifdef RTE_LIBRTE_I40E_PMD
9954 struct rte_pmd_i40e_queue_region_conf region_conf;
9955 enum rte_pmd_i40e_queue_region_op op_type;
9958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9961 #ifdef RTE_LIBRTE_I40E_PMD
9962 memset(®ion_conf, 0, sizeof(region_conf));
9964 if (strcmp(res->what, "on") == 0)
9965 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9967 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9969 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9970 op_type, ®ion_conf);
9977 printf("function not implemented or supported\n");
9980 printf("queue region config flush error: (%s)\n",
9985 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9986 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9988 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9989 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9991 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9992 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9994 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9995 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9996 cmd, "queue-region");
9997 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9998 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10000 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10001 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10004 cmdline_parse_inst_t cmd_flush_queue_region = {
10005 .f = cmd_flush_queue_region_parsed,
10007 .help_str = "set port <port_id> queue-region flush on|off"
10008 ": flush all queue region related configuration",
10010 (void *)&cmd_flush_queue_region_set,
10011 (void *)&cmd_flush_queue_region_port,
10012 (void *)&cmd_flush_queue_region_port_index,
10013 (void *)&cmd_flush_queue_region_cmd,
10014 (void *)&cmd_flush_queue_region_flush,
10015 (void *)&cmd_flush_queue_region_what,
10020 /* *** get all queue region related configuration info *** */
10021 struct cmd_show_queue_region_info {
10022 cmdline_fixed_string_t show;
10023 cmdline_fixed_string_t port;
10025 cmdline_fixed_string_t cmd;
10029 cmd_show_queue_region_info_parsed(void *parsed_result,
10030 __attribute__((unused)) struct cmdline *cl,
10031 __attribute__((unused)) void *data)
10033 struct cmd_show_queue_region_info *res = parsed_result;
10034 int ret = -ENOTSUP;
10035 #ifdef RTE_LIBRTE_I40E_PMD
10036 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10037 enum rte_pmd_i40e_queue_region_op op_type;
10040 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10043 #ifdef RTE_LIBRTE_I40E_PMD
10044 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10046 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10048 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10049 op_type, &rte_pmd_regions);
10051 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10058 printf("function not implemented or supported\n");
10061 printf("queue region config info show error: (%s)\n",
10066 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10067 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10069 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10070 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10072 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10073 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10075 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10076 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10077 cmd, "queue-region");
10079 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10080 .f = cmd_show_queue_region_info_parsed,
10082 .help_str = "show port <port_id> queue-region"
10083 ": show all queue region related configuration info",
10085 (void *)&cmd_show_queue_region_info_get,
10086 (void *)&cmd_show_queue_region_info_port,
10087 (void *)&cmd_show_queue_region_info_port_index,
10088 (void *)&cmd_show_queue_region_info_cmd,
10093 /* *** ADD/REMOVE A 2tuple FILTER *** */
10094 struct cmd_2tuple_filter_result {
10095 cmdline_fixed_string_t filter;
10097 cmdline_fixed_string_t ops;
10098 cmdline_fixed_string_t dst_port;
10099 uint16_t dst_port_value;
10100 cmdline_fixed_string_t protocol;
10101 uint8_t protocol_value;
10102 cmdline_fixed_string_t mask;
10103 uint8_t mask_value;
10104 cmdline_fixed_string_t tcp_flags;
10105 uint8_t tcp_flags_value;
10106 cmdline_fixed_string_t priority;
10107 uint8_t priority_value;
10108 cmdline_fixed_string_t queue;
10113 cmd_2tuple_filter_parsed(void *parsed_result,
10114 __attribute__((unused)) struct cmdline *cl,
10115 __attribute__((unused)) void *data)
10117 struct rte_eth_ntuple_filter filter;
10118 struct cmd_2tuple_filter_result *res = parsed_result;
10121 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10123 printf("ntuple filter is not supported on port %u.\n",
10128 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10130 filter.flags = RTE_2TUPLE_FLAGS;
10131 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10132 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10133 filter.proto = res->protocol_value;
10134 filter.priority = res->priority_value;
10135 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10136 printf("nonzero tcp_flags is only meaningful"
10137 " when protocol is TCP.\n");
10140 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10141 printf("invalid TCP flags.\n");
10145 if (res->tcp_flags_value != 0) {
10146 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10147 filter.tcp_flags = res->tcp_flags_value;
10150 /* need convert to big endian. */
10151 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10152 filter.queue = res->queue_id;
10154 if (!strcmp(res->ops, "add"))
10155 ret = rte_eth_dev_filter_ctrl(res->port_id,
10156 RTE_ETH_FILTER_NTUPLE,
10157 RTE_ETH_FILTER_ADD,
10160 ret = rte_eth_dev_filter_ctrl(res->port_id,
10161 RTE_ETH_FILTER_NTUPLE,
10162 RTE_ETH_FILTER_DELETE,
10165 printf("2tuple filter programming error: (%s)\n",
10170 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10171 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10172 filter, "2tuple_filter");
10173 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10174 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10176 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10177 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10179 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10180 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10181 dst_port, "dst_port");
10182 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10183 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10184 dst_port_value, UINT16);
10185 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10186 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10187 protocol, "protocol");
10188 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10189 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10190 protocol_value, UINT8);
10191 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10192 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10194 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10195 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10197 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10198 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10199 tcp_flags, "tcp_flags");
10200 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10201 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10202 tcp_flags_value, UINT8);
10203 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10204 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10205 priority, "priority");
10206 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10207 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10208 priority_value, UINT8);
10209 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10210 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10212 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10213 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10216 cmdline_parse_inst_t cmd_2tuple_filter = {
10217 .f = cmd_2tuple_filter_parsed,
10219 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10220 "<value> mask <value> tcp_flags <value> priority <value> queue "
10221 "<queue_id>: Add a 2tuple filter",
10223 (void *)&cmd_2tuple_filter_filter,
10224 (void *)&cmd_2tuple_filter_port_id,
10225 (void *)&cmd_2tuple_filter_ops,
10226 (void *)&cmd_2tuple_filter_dst_port,
10227 (void *)&cmd_2tuple_filter_dst_port_value,
10228 (void *)&cmd_2tuple_filter_protocol,
10229 (void *)&cmd_2tuple_filter_protocol_value,
10230 (void *)&cmd_2tuple_filter_mask,
10231 (void *)&cmd_2tuple_filter_mask_value,
10232 (void *)&cmd_2tuple_filter_tcp_flags,
10233 (void *)&cmd_2tuple_filter_tcp_flags_value,
10234 (void *)&cmd_2tuple_filter_priority,
10235 (void *)&cmd_2tuple_filter_priority_value,
10236 (void *)&cmd_2tuple_filter_queue,
10237 (void *)&cmd_2tuple_filter_queue_id,
10242 /* *** ADD/REMOVE A 5tuple FILTER *** */
10243 struct cmd_5tuple_filter_result {
10244 cmdline_fixed_string_t filter;
10246 cmdline_fixed_string_t ops;
10247 cmdline_fixed_string_t dst_ip;
10248 cmdline_ipaddr_t dst_ip_value;
10249 cmdline_fixed_string_t src_ip;
10250 cmdline_ipaddr_t src_ip_value;
10251 cmdline_fixed_string_t dst_port;
10252 uint16_t dst_port_value;
10253 cmdline_fixed_string_t src_port;
10254 uint16_t src_port_value;
10255 cmdline_fixed_string_t protocol;
10256 uint8_t protocol_value;
10257 cmdline_fixed_string_t mask;
10258 uint8_t mask_value;
10259 cmdline_fixed_string_t tcp_flags;
10260 uint8_t tcp_flags_value;
10261 cmdline_fixed_string_t priority;
10262 uint8_t priority_value;
10263 cmdline_fixed_string_t queue;
10268 cmd_5tuple_filter_parsed(void *parsed_result,
10269 __attribute__((unused)) struct cmdline *cl,
10270 __attribute__((unused)) void *data)
10272 struct rte_eth_ntuple_filter filter;
10273 struct cmd_5tuple_filter_result *res = parsed_result;
10276 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10278 printf("ntuple filter is not supported on port %u.\n",
10283 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10285 filter.flags = RTE_5TUPLE_FLAGS;
10286 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10287 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10288 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10289 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10290 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10291 filter.proto = res->protocol_value;
10292 filter.priority = res->priority_value;
10293 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10294 printf("nonzero tcp_flags is only meaningful"
10295 " when protocol is TCP.\n");
10298 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10299 printf("invalid TCP flags.\n");
10303 if (res->tcp_flags_value != 0) {
10304 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10305 filter.tcp_flags = res->tcp_flags_value;
10308 if (res->dst_ip_value.family == AF_INET)
10309 /* no need to convert, already big endian. */
10310 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10312 if (filter.dst_ip_mask == 0) {
10313 printf("can not support ipv6 involved compare.\n");
10319 if (res->src_ip_value.family == AF_INET)
10320 /* no need to convert, already big endian. */
10321 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10323 if (filter.src_ip_mask == 0) {
10324 printf("can not support ipv6 involved compare.\n");
10329 /* need convert to big endian. */
10330 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10331 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10332 filter.queue = res->queue_id;
10334 if (!strcmp(res->ops, "add"))
10335 ret = rte_eth_dev_filter_ctrl(res->port_id,
10336 RTE_ETH_FILTER_NTUPLE,
10337 RTE_ETH_FILTER_ADD,
10340 ret = rte_eth_dev_filter_ctrl(res->port_id,
10341 RTE_ETH_FILTER_NTUPLE,
10342 RTE_ETH_FILTER_DELETE,
10345 printf("5tuple filter programming error: (%s)\n",
10349 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10350 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10351 filter, "5tuple_filter");
10352 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10353 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10355 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10356 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10358 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10359 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10361 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10362 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10364 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10365 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10367 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10368 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10370 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10371 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10372 dst_port, "dst_port");
10373 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10374 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10375 dst_port_value, UINT16);
10376 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10377 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10378 src_port, "src_port");
10379 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10380 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10381 src_port_value, UINT16);
10382 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10383 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10384 protocol, "protocol");
10385 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10386 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10387 protocol_value, UINT8);
10388 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10389 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10391 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10392 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10394 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10395 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10396 tcp_flags, "tcp_flags");
10397 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10398 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10399 tcp_flags_value, UINT8);
10400 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10401 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10402 priority, "priority");
10403 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10404 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10405 priority_value, UINT8);
10406 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10407 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10409 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10410 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10413 cmdline_parse_inst_t cmd_5tuple_filter = {
10414 .f = cmd_5tuple_filter_parsed,
10416 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10417 "src_ip <value> dst_port <value> src_port <value> "
10418 "protocol <value> mask <value> tcp_flags <value> "
10419 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10421 (void *)&cmd_5tuple_filter_filter,
10422 (void *)&cmd_5tuple_filter_port_id,
10423 (void *)&cmd_5tuple_filter_ops,
10424 (void *)&cmd_5tuple_filter_dst_ip,
10425 (void *)&cmd_5tuple_filter_dst_ip_value,
10426 (void *)&cmd_5tuple_filter_src_ip,
10427 (void *)&cmd_5tuple_filter_src_ip_value,
10428 (void *)&cmd_5tuple_filter_dst_port,
10429 (void *)&cmd_5tuple_filter_dst_port_value,
10430 (void *)&cmd_5tuple_filter_src_port,
10431 (void *)&cmd_5tuple_filter_src_port_value,
10432 (void *)&cmd_5tuple_filter_protocol,
10433 (void *)&cmd_5tuple_filter_protocol_value,
10434 (void *)&cmd_5tuple_filter_mask,
10435 (void *)&cmd_5tuple_filter_mask_value,
10436 (void *)&cmd_5tuple_filter_tcp_flags,
10437 (void *)&cmd_5tuple_filter_tcp_flags_value,
10438 (void *)&cmd_5tuple_filter_priority,
10439 (void *)&cmd_5tuple_filter_priority_value,
10440 (void *)&cmd_5tuple_filter_queue,
10441 (void *)&cmd_5tuple_filter_queue_id,
10446 /* *** ADD/REMOVE A flex FILTER *** */
10447 struct cmd_flex_filter_result {
10448 cmdline_fixed_string_t filter;
10449 cmdline_fixed_string_t ops;
10451 cmdline_fixed_string_t len;
10453 cmdline_fixed_string_t bytes;
10454 cmdline_fixed_string_t bytes_value;
10455 cmdline_fixed_string_t mask;
10456 cmdline_fixed_string_t mask_value;
10457 cmdline_fixed_string_t priority;
10458 uint8_t priority_value;
10459 cmdline_fixed_string_t queue;
10463 static int xdigit2val(unsigned char c)
10468 else if (isupper(c))
10469 val = c - 'A' + 10;
10471 val = c - 'a' + 10;
10476 cmd_flex_filter_parsed(void *parsed_result,
10477 __attribute__((unused)) struct cmdline *cl,
10478 __attribute__((unused)) void *data)
10481 struct rte_eth_flex_filter filter;
10482 struct cmd_flex_filter_result *res = parsed_result;
10483 char *bytes_ptr, *mask_ptr;
10484 uint16_t len, i, j = 0;
10489 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10490 printf("the len exceed the max length 128\n");
10493 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10494 filter.len = res->len_value;
10495 filter.priority = res->priority_value;
10496 filter.queue = res->queue_id;
10497 bytes_ptr = res->bytes_value;
10498 mask_ptr = res->mask_value;
10500 /* translate bytes string to array. */
10501 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10502 (bytes_ptr[1] == 'X')))
10504 len = strnlen(bytes_ptr, res->len_value * 2);
10505 if (len == 0 || (len % 8 != 0)) {
10506 printf("please check len and bytes input\n");
10509 for (i = 0; i < len; i++) {
10511 if (isxdigit(c) == 0) {
10512 /* invalid characters. */
10513 printf("invalid input\n");
10516 val = xdigit2val(c);
10519 filter.bytes[j] = byte;
10520 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10527 /* translate mask string to uint8_t array. */
10528 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10529 (mask_ptr[1] == 'X')))
10531 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10533 printf("invalid input\n");
10538 for (i = 0; i < len; i++) {
10540 if (isxdigit(c) == 0) {
10541 /* invalid characters. */
10542 printf("invalid input\n");
10545 val = xdigit2val(c);
10548 filter.mask[j] = byte;
10549 printf("mask[%d]:%02x ", j, filter.mask[j]);
10557 if (!strcmp(res->ops, "add"))
10558 ret = rte_eth_dev_filter_ctrl(res->port_id,
10559 RTE_ETH_FILTER_FLEXIBLE,
10560 RTE_ETH_FILTER_ADD,
10563 ret = rte_eth_dev_filter_ctrl(res->port_id,
10564 RTE_ETH_FILTER_FLEXIBLE,
10565 RTE_ETH_FILTER_DELETE,
10569 printf("flex filter setting error: (%s)\n", strerror(-ret));
10572 cmdline_parse_token_string_t cmd_flex_filter_filter =
10573 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10574 filter, "flex_filter");
10575 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10576 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10578 cmdline_parse_token_string_t cmd_flex_filter_ops =
10579 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10581 cmdline_parse_token_string_t cmd_flex_filter_len =
10582 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10584 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10585 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10587 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10588 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10590 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10591 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10592 bytes_value, NULL);
10593 cmdline_parse_token_string_t cmd_flex_filter_mask =
10594 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10596 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10597 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10599 cmdline_parse_token_string_t cmd_flex_filter_priority =
10600 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10601 priority, "priority");
10602 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10603 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10604 priority_value, UINT8);
10605 cmdline_parse_token_string_t cmd_flex_filter_queue =
10606 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10608 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10609 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10611 cmdline_parse_inst_t cmd_flex_filter = {
10612 .f = cmd_flex_filter_parsed,
10614 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10615 "<value> mask <value> priority <value> queue <queue_id>: "
10616 "Add/Del a flex filter",
10618 (void *)&cmd_flex_filter_filter,
10619 (void *)&cmd_flex_filter_port_id,
10620 (void *)&cmd_flex_filter_ops,
10621 (void *)&cmd_flex_filter_len,
10622 (void *)&cmd_flex_filter_len_value,
10623 (void *)&cmd_flex_filter_bytes,
10624 (void *)&cmd_flex_filter_bytes_value,
10625 (void *)&cmd_flex_filter_mask,
10626 (void *)&cmd_flex_filter_mask_value,
10627 (void *)&cmd_flex_filter_priority,
10628 (void *)&cmd_flex_filter_priority_value,
10629 (void *)&cmd_flex_filter_queue,
10630 (void *)&cmd_flex_filter_queue_id,
10635 /* *** Filters Control *** */
10637 /* *** deal with ethertype filter *** */
10638 struct cmd_ethertype_filter_result {
10639 cmdline_fixed_string_t filter;
10641 cmdline_fixed_string_t ops;
10642 cmdline_fixed_string_t mac;
10643 struct rte_ether_addr mac_addr;
10644 cmdline_fixed_string_t ethertype;
10645 uint16_t ethertype_value;
10646 cmdline_fixed_string_t drop;
10647 cmdline_fixed_string_t queue;
10651 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10652 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10653 filter, "ethertype_filter");
10654 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10655 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10657 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10658 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10660 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10661 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10662 mac, "mac_addr#mac_ignr");
10663 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10664 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10666 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10667 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10668 ethertype, "ethertype");
10669 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10670 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10671 ethertype_value, UINT16);
10672 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10673 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10675 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10676 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10678 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10679 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10683 cmd_ethertype_filter_parsed(void *parsed_result,
10684 __attribute__((unused)) struct cmdline *cl,
10685 __attribute__((unused)) void *data)
10687 struct cmd_ethertype_filter_result *res = parsed_result;
10688 struct rte_eth_ethertype_filter filter;
10691 ret = rte_eth_dev_filter_supported(res->port_id,
10692 RTE_ETH_FILTER_ETHERTYPE);
10694 printf("ethertype filter is not supported on port %u.\n",
10699 memset(&filter, 0, sizeof(filter));
10700 if (!strcmp(res->mac, "mac_addr")) {
10701 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10702 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10703 sizeof(struct rte_ether_addr));
10705 if (!strcmp(res->drop, "drop"))
10706 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10707 filter.ether_type = res->ethertype_value;
10708 filter.queue = res->queue_id;
10710 if (!strcmp(res->ops, "add"))
10711 ret = rte_eth_dev_filter_ctrl(res->port_id,
10712 RTE_ETH_FILTER_ETHERTYPE,
10713 RTE_ETH_FILTER_ADD,
10716 ret = rte_eth_dev_filter_ctrl(res->port_id,
10717 RTE_ETH_FILTER_ETHERTYPE,
10718 RTE_ETH_FILTER_DELETE,
10721 printf("ethertype filter programming error: (%s)\n",
10725 cmdline_parse_inst_t cmd_ethertype_filter = {
10726 .f = cmd_ethertype_filter_parsed,
10728 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10729 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10730 "Add or delete an ethertype filter entry",
10732 (void *)&cmd_ethertype_filter_filter,
10733 (void *)&cmd_ethertype_filter_port_id,
10734 (void *)&cmd_ethertype_filter_ops,
10735 (void *)&cmd_ethertype_filter_mac,
10736 (void *)&cmd_ethertype_filter_mac_addr,
10737 (void *)&cmd_ethertype_filter_ethertype,
10738 (void *)&cmd_ethertype_filter_ethertype_value,
10739 (void *)&cmd_ethertype_filter_drop,
10740 (void *)&cmd_ethertype_filter_queue,
10741 (void *)&cmd_ethertype_filter_queue_id,
10746 /* *** deal with flow director filter *** */
10747 struct cmd_flow_director_result {
10748 cmdline_fixed_string_t flow_director_filter;
10750 cmdline_fixed_string_t mode;
10751 cmdline_fixed_string_t mode_value;
10752 cmdline_fixed_string_t ops;
10753 cmdline_fixed_string_t flow;
10754 cmdline_fixed_string_t flow_type;
10755 cmdline_fixed_string_t ether;
10756 uint16_t ether_type;
10757 cmdline_fixed_string_t src;
10758 cmdline_ipaddr_t ip_src;
10760 cmdline_fixed_string_t dst;
10761 cmdline_ipaddr_t ip_dst;
10763 cmdline_fixed_string_t verify_tag;
10764 uint32_t verify_tag_value;
10765 cmdline_fixed_string_t tos;
10767 cmdline_fixed_string_t proto;
10768 uint8_t proto_value;
10769 cmdline_fixed_string_t ttl;
10771 cmdline_fixed_string_t vlan;
10772 uint16_t vlan_value;
10773 cmdline_fixed_string_t flexbytes;
10774 cmdline_fixed_string_t flexbytes_value;
10775 cmdline_fixed_string_t pf_vf;
10776 cmdline_fixed_string_t drop;
10777 cmdline_fixed_string_t queue;
10779 cmdline_fixed_string_t fd_id;
10780 uint32_t fd_id_value;
10781 cmdline_fixed_string_t mac;
10782 struct rte_ether_addr mac_addr;
10783 cmdline_fixed_string_t tunnel;
10784 cmdline_fixed_string_t tunnel_type;
10785 cmdline_fixed_string_t tunnel_id;
10786 uint32_t tunnel_id_value;
10787 cmdline_fixed_string_t packet;
10792 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10795 const char *p, *p0 = q_arg;
10797 unsigned long int_fld;
10798 char *str_fld[max_num];
10803 p = strchr(p0, '(');
10807 p0 = strchr(p, ')');
10812 if (size >= sizeof(s))
10815 snprintf(s, sizeof(s), "%.*s", size, p);
10816 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10817 if (ret < 0 || ret > max_num)
10819 for (i = 0; i < ret; i++) {
10821 int_fld = strtoul(str_fld[i], &end, 0);
10822 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10824 flexbytes[i] = (uint8_t)int_fld;
10830 str2flowtype(char *string)
10833 static const struct {
10836 } flowtype_str[] = {
10837 {"raw", RTE_ETH_FLOW_RAW},
10838 {"ipv4", RTE_ETH_FLOW_IPV4},
10839 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10840 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10841 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10842 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10843 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10844 {"ipv6", RTE_ETH_FLOW_IPV6},
10845 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10846 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10847 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10848 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10849 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10850 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10853 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10854 if (!strcmp(flowtype_str[i].str, string))
10855 return flowtype_str[i].type;
10858 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10859 return (uint16_t)atoi(string);
10861 return RTE_ETH_FLOW_UNKNOWN;
10864 static enum rte_eth_fdir_tunnel_type
10865 str2fdir_tunneltype(char *string)
10869 static const struct {
10871 enum rte_eth_fdir_tunnel_type type;
10872 } tunneltype_str[] = {
10873 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10874 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10877 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10878 if (!strcmp(tunneltype_str[i].str, string))
10879 return tunneltype_str[i].type;
10881 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10884 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10886 if ((ip_addr).family == AF_INET) \
10887 (ip) = (ip_addr).addr.ipv4.s_addr; \
10889 printf("invalid parameter.\n"); \
10894 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10896 if ((ip_addr).family == AF_INET6) \
10897 rte_memcpy(&(ip), \
10898 &((ip_addr).addr.ipv6), \
10899 sizeof(struct in6_addr)); \
10901 printf("invalid parameter.\n"); \
10907 cmd_flow_director_filter_parsed(void *parsed_result,
10908 __attribute__((unused)) struct cmdline *cl,
10909 __attribute__((unused)) void *data)
10911 struct cmd_flow_director_result *res = parsed_result;
10912 struct rte_eth_fdir_filter entry;
10913 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10915 unsigned long vf_id;
10918 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10920 printf("flow director is not supported on port %u.\n",
10924 memset(flexbytes, 0, sizeof(flexbytes));
10925 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10927 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10928 if (strcmp(res->mode_value, "MAC-VLAN")) {
10929 printf("Please set mode to MAC-VLAN.\n");
10932 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10933 if (strcmp(res->mode_value, "Tunnel")) {
10934 printf("Please set mode to Tunnel.\n");
10938 if (!strcmp(res->mode_value, "raw")) {
10939 #ifdef RTE_LIBRTE_I40E_PMD
10940 struct rte_pmd_i40e_flow_type_mapping
10941 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10942 struct rte_pmd_i40e_pkt_template_conf conf;
10943 uint16_t flow_type = str2flowtype(res->flow_type);
10944 uint16_t i, port = res->port_id;
10947 memset(&conf, 0, sizeof(conf));
10949 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10950 printf("Invalid flow type specified.\n");
10953 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10957 if (mapping[flow_type].pctype == 0ULL) {
10958 printf("Invalid flow type specified.\n");
10961 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10962 if (mapping[flow_type].pctype & (1ULL << i)) {
10963 conf.input.pctype = i;
10968 conf.input.packet = open_file(res->filepath,
10969 &conf.input.length);
10970 if (!conf.input.packet)
10972 if (!strcmp(res->drop, "drop"))
10973 conf.action.behavior =
10974 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10976 conf.action.behavior =
10977 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10978 conf.action.report_status =
10979 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10980 conf.action.rx_queue = res->queue_id;
10981 conf.soft_id = res->fd_id_value;
10982 add = strcmp(res->ops, "del") ? 1 : 0;
10983 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10987 printf("flow director config error: (%s)\n",
10989 close_file(conf.input.packet);
10992 } else if (strcmp(res->mode_value, "IP")) {
10993 printf("Please set mode to IP or raw.\n");
10996 entry.input.flow_type = str2flowtype(res->flow_type);
10999 ret = parse_flexbytes(res->flexbytes_value,
11001 RTE_ETH_FDIR_MAX_FLEXLEN);
11003 printf("error: Cannot parse flexbytes input.\n");
11007 switch (entry.input.flow_type) {
11008 case RTE_ETH_FLOW_FRAG_IPV4:
11009 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11010 entry.input.flow.ip4_flow.proto = res->proto_value;
11012 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11013 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11014 IPV4_ADDR_TO_UINT(res->ip_dst,
11015 entry.input.flow.ip4_flow.dst_ip);
11016 IPV4_ADDR_TO_UINT(res->ip_src,
11017 entry.input.flow.ip4_flow.src_ip);
11018 entry.input.flow.ip4_flow.tos = res->tos_value;
11019 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11020 /* need convert to big endian. */
11021 entry.input.flow.udp4_flow.dst_port =
11022 rte_cpu_to_be_16(res->port_dst);
11023 entry.input.flow.udp4_flow.src_port =
11024 rte_cpu_to_be_16(res->port_src);
11026 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11027 IPV4_ADDR_TO_UINT(res->ip_dst,
11028 entry.input.flow.sctp4_flow.ip.dst_ip);
11029 IPV4_ADDR_TO_UINT(res->ip_src,
11030 entry.input.flow.sctp4_flow.ip.src_ip);
11031 entry.input.flow.ip4_flow.tos = res->tos_value;
11032 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11033 /* need convert to big endian. */
11034 entry.input.flow.sctp4_flow.dst_port =
11035 rte_cpu_to_be_16(res->port_dst);
11036 entry.input.flow.sctp4_flow.src_port =
11037 rte_cpu_to_be_16(res->port_src);
11038 entry.input.flow.sctp4_flow.verify_tag =
11039 rte_cpu_to_be_32(res->verify_tag_value);
11041 case RTE_ETH_FLOW_FRAG_IPV6:
11042 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11043 entry.input.flow.ipv6_flow.proto = res->proto_value;
11045 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11046 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11047 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11048 entry.input.flow.ipv6_flow.dst_ip);
11049 IPV6_ADDR_TO_ARRAY(res->ip_src,
11050 entry.input.flow.ipv6_flow.src_ip);
11051 entry.input.flow.ipv6_flow.tc = res->tos_value;
11052 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11053 /* need convert to big endian. */
11054 entry.input.flow.udp6_flow.dst_port =
11055 rte_cpu_to_be_16(res->port_dst);
11056 entry.input.flow.udp6_flow.src_port =
11057 rte_cpu_to_be_16(res->port_src);
11059 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11060 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11061 entry.input.flow.sctp6_flow.ip.dst_ip);
11062 IPV6_ADDR_TO_ARRAY(res->ip_src,
11063 entry.input.flow.sctp6_flow.ip.src_ip);
11064 entry.input.flow.ipv6_flow.tc = res->tos_value;
11065 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11066 /* need convert to big endian. */
11067 entry.input.flow.sctp6_flow.dst_port =
11068 rte_cpu_to_be_16(res->port_dst);
11069 entry.input.flow.sctp6_flow.src_port =
11070 rte_cpu_to_be_16(res->port_src);
11071 entry.input.flow.sctp6_flow.verify_tag =
11072 rte_cpu_to_be_32(res->verify_tag_value);
11074 case RTE_ETH_FLOW_L2_PAYLOAD:
11075 entry.input.flow.l2_flow.ether_type =
11076 rte_cpu_to_be_16(res->ether_type);
11082 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11083 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11085 sizeof(struct rte_ether_addr));
11087 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11088 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11090 sizeof(struct rte_ether_addr));
11091 entry.input.flow.tunnel_flow.tunnel_type =
11092 str2fdir_tunneltype(res->tunnel_type);
11093 entry.input.flow.tunnel_flow.tunnel_id =
11094 rte_cpu_to_be_32(res->tunnel_id_value);
11097 rte_memcpy(entry.input.flow_ext.flexbytes,
11099 RTE_ETH_FDIR_MAX_FLEXLEN);
11101 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11103 entry.action.flex_off = 0; /*use 0 by default */
11104 if (!strcmp(res->drop, "drop"))
11105 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11107 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11109 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11110 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11111 if (!strcmp(res->pf_vf, "pf"))
11112 entry.input.flow_ext.is_vf = 0;
11113 else if (!strncmp(res->pf_vf, "vf", 2)) {
11114 struct rte_eth_dev_info dev_info;
11116 ret = eth_dev_info_get_print_err(res->port_id,
11122 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11123 if (errno != 0 || *end != '\0' ||
11124 vf_id >= dev_info.max_vfs) {
11125 printf("invalid parameter %s.\n", res->pf_vf);
11128 entry.input.flow_ext.is_vf = 1;
11129 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11131 printf("invalid parameter %s.\n", res->pf_vf);
11136 /* set to report FD ID by default */
11137 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11138 entry.action.rx_queue = res->queue_id;
11139 entry.soft_id = res->fd_id_value;
11140 if (!strcmp(res->ops, "add"))
11141 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11142 RTE_ETH_FILTER_ADD, &entry);
11143 else if (!strcmp(res->ops, "del"))
11144 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11145 RTE_ETH_FILTER_DELETE, &entry);
11147 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11148 RTE_ETH_FILTER_UPDATE, &entry);
11150 printf("flow director programming error: (%s)\n",
11154 cmdline_parse_token_string_t cmd_flow_director_filter =
11155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11156 flow_director_filter, "flow_director_filter");
11157 cmdline_parse_token_num_t cmd_flow_director_port_id =
11158 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11160 cmdline_parse_token_string_t cmd_flow_director_ops =
11161 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11162 ops, "add#del#update");
11163 cmdline_parse_token_string_t cmd_flow_director_flow =
11164 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11166 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11167 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11169 cmdline_parse_token_string_t cmd_flow_director_ether =
11170 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11172 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11173 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11174 ether_type, UINT16);
11175 cmdline_parse_token_string_t cmd_flow_director_src =
11176 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11178 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11179 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11181 cmdline_parse_token_num_t cmd_flow_director_port_src =
11182 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11184 cmdline_parse_token_string_t cmd_flow_director_dst =
11185 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11187 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11188 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11190 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11191 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11193 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11194 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11195 verify_tag, "verify_tag");
11196 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11197 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11198 verify_tag_value, UINT32);
11199 cmdline_parse_token_string_t cmd_flow_director_tos =
11200 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11202 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11203 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11205 cmdline_parse_token_string_t cmd_flow_director_proto =
11206 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11208 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11209 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11210 proto_value, UINT8);
11211 cmdline_parse_token_string_t cmd_flow_director_ttl =
11212 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11214 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11215 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11217 cmdline_parse_token_string_t cmd_flow_director_vlan =
11218 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11220 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11221 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11222 vlan_value, UINT16);
11223 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11224 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11225 flexbytes, "flexbytes");
11226 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11227 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11228 flexbytes_value, NULL);
11229 cmdline_parse_token_string_t cmd_flow_director_drop =
11230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11232 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11233 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11235 cmdline_parse_token_string_t cmd_flow_director_queue =
11236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11238 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11239 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11241 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11242 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11244 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11245 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11246 fd_id_value, UINT32);
11248 cmdline_parse_token_string_t cmd_flow_director_mode =
11249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11251 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11254 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11256 mode_value, "MAC-VLAN");
11257 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11259 mode_value, "Tunnel");
11260 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11262 mode_value, "raw");
11263 cmdline_parse_token_string_t cmd_flow_director_mac =
11264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11266 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11267 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11269 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11272 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11273 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11274 tunnel_type, "NVGRE#VxLAN");
11275 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11277 tunnel_id, "tunnel-id");
11278 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11279 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11280 tunnel_id_value, UINT32);
11281 cmdline_parse_token_string_t cmd_flow_director_packet =
11282 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11284 cmdline_parse_token_string_t cmd_flow_director_filepath =
11285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11288 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11289 .f = cmd_flow_director_filter_parsed,
11291 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11292 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11293 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11294 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11295 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11296 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11297 "fd_id <fd_id_value>: "
11298 "Add or delete an ip flow director entry on NIC",
11300 (void *)&cmd_flow_director_filter,
11301 (void *)&cmd_flow_director_port_id,
11302 (void *)&cmd_flow_director_mode,
11303 (void *)&cmd_flow_director_mode_ip,
11304 (void *)&cmd_flow_director_ops,
11305 (void *)&cmd_flow_director_flow,
11306 (void *)&cmd_flow_director_flow_type,
11307 (void *)&cmd_flow_director_src,
11308 (void *)&cmd_flow_director_ip_src,
11309 (void *)&cmd_flow_director_dst,
11310 (void *)&cmd_flow_director_ip_dst,
11311 (void *)&cmd_flow_director_tos,
11312 (void *)&cmd_flow_director_tos_value,
11313 (void *)&cmd_flow_director_proto,
11314 (void *)&cmd_flow_director_proto_value,
11315 (void *)&cmd_flow_director_ttl,
11316 (void *)&cmd_flow_director_ttl_value,
11317 (void *)&cmd_flow_director_vlan,
11318 (void *)&cmd_flow_director_vlan_value,
11319 (void *)&cmd_flow_director_flexbytes,
11320 (void *)&cmd_flow_director_flexbytes_value,
11321 (void *)&cmd_flow_director_drop,
11322 (void *)&cmd_flow_director_pf_vf,
11323 (void *)&cmd_flow_director_queue,
11324 (void *)&cmd_flow_director_queue_id,
11325 (void *)&cmd_flow_director_fd_id,
11326 (void *)&cmd_flow_director_fd_id_value,
11331 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11332 .f = cmd_flow_director_filter_parsed,
11334 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11335 "director entry on NIC",
11337 (void *)&cmd_flow_director_filter,
11338 (void *)&cmd_flow_director_port_id,
11339 (void *)&cmd_flow_director_mode,
11340 (void *)&cmd_flow_director_mode_ip,
11341 (void *)&cmd_flow_director_ops,
11342 (void *)&cmd_flow_director_flow,
11343 (void *)&cmd_flow_director_flow_type,
11344 (void *)&cmd_flow_director_src,
11345 (void *)&cmd_flow_director_ip_src,
11346 (void *)&cmd_flow_director_port_src,
11347 (void *)&cmd_flow_director_dst,
11348 (void *)&cmd_flow_director_ip_dst,
11349 (void *)&cmd_flow_director_port_dst,
11350 (void *)&cmd_flow_director_tos,
11351 (void *)&cmd_flow_director_tos_value,
11352 (void *)&cmd_flow_director_ttl,
11353 (void *)&cmd_flow_director_ttl_value,
11354 (void *)&cmd_flow_director_vlan,
11355 (void *)&cmd_flow_director_vlan_value,
11356 (void *)&cmd_flow_director_flexbytes,
11357 (void *)&cmd_flow_director_flexbytes_value,
11358 (void *)&cmd_flow_director_drop,
11359 (void *)&cmd_flow_director_pf_vf,
11360 (void *)&cmd_flow_director_queue,
11361 (void *)&cmd_flow_director_queue_id,
11362 (void *)&cmd_flow_director_fd_id,
11363 (void *)&cmd_flow_director_fd_id_value,
11368 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11369 .f = cmd_flow_director_filter_parsed,
11371 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11372 "director entry on NIC",
11374 (void *)&cmd_flow_director_filter,
11375 (void *)&cmd_flow_director_port_id,
11376 (void *)&cmd_flow_director_mode,
11377 (void *)&cmd_flow_director_mode_ip,
11378 (void *)&cmd_flow_director_ops,
11379 (void *)&cmd_flow_director_flow,
11380 (void *)&cmd_flow_director_flow_type,
11381 (void *)&cmd_flow_director_src,
11382 (void *)&cmd_flow_director_ip_src,
11383 (void *)&cmd_flow_director_port_src,
11384 (void *)&cmd_flow_director_dst,
11385 (void *)&cmd_flow_director_ip_dst,
11386 (void *)&cmd_flow_director_port_dst,
11387 (void *)&cmd_flow_director_verify_tag,
11388 (void *)&cmd_flow_director_verify_tag_value,
11389 (void *)&cmd_flow_director_tos,
11390 (void *)&cmd_flow_director_tos_value,
11391 (void *)&cmd_flow_director_ttl,
11392 (void *)&cmd_flow_director_ttl_value,
11393 (void *)&cmd_flow_director_vlan,
11394 (void *)&cmd_flow_director_vlan_value,
11395 (void *)&cmd_flow_director_flexbytes,
11396 (void *)&cmd_flow_director_flexbytes_value,
11397 (void *)&cmd_flow_director_drop,
11398 (void *)&cmd_flow_director_pf_vf,
11399 (void *)&cmd_flow_director_queue,
11400 (void *)&cmd_flow_director_queue_id,
11401 (void *)&cmd_flow_director_fd_id,
11402 (void *)&cmd_flow_director_fd_id_value,
11407 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11408 .f = cmd_flow_director_filter_parsed,
11410 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11411 "director entry on NIC",
11413 (void *)&cmd_flow_director_filter,
11414 (void *)&cmd_flow_director_port_id,
11415 (void *)&cmd_flow_director_mode,
11416 (void *)&cmd_flow_director_mode_ip,
11417 (void *)&cmd_flow_director_ops,
11418 (void *)&cmd_flow_director_flow,
11419 (void *)&cmd_flow_director_flow_type,
11420 (void *)&cmd_flow_director_ether,
11421 (void *)&cmd_flow_director_ether_type,
11422 (void *)&cmd_flow_director_flexbytes,
11423 (void *)&cmd_flow_director_flexbytes_value,
11424 (void *)&cmd_flow_director_drop,
11425 (void *)&cmd_flow_director_pf_vf,
11426 (void *)&cmd_flow_director_queue,
11427 (void *)&cmd_flow_director_queue_id,
11428 (void *)&cmd_flow_director_fd_id,
11429 (void *)&cmd_flow_director_fd_id_value,
11434 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11435 .f = cmd_flow_director_filter_parsed,
11437 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11438 "director entry on NIC",
11440 (void *)&cmd_flow_director_filter,
11441 (void *)&cmd_flow_director_port_id,
11442 (void *)&cmd_flow_director_mode,
11443 (void *)&cmd_flow_director_mode_mac_vlan,
11444 (void *)&cmd_flow_director_ops,
11445 (void *)&cmd_flow_director_mac,
11446 (void *)&cmd_flow_director_mac_addr,
11447 (void *)&cmd_flow_director_vlan,
11448 (void *)&cmd_flow_director_vlan_value,
11449 (void *)&cmd_flow_director_flexbytes,
11450 (void *)&cmd_flow_director_flexbytes_value,
11451 (void *)&cmd_flow_director_drop,
11452 (void *)&cmd_flow_director_queue,
11453 (void *)&cmd_flow_director_queue_id,
11454 (void *)&cmd_flow_director_fd_id,
11455 (void *)&cmd_flow_director_fd_id_value,
11460 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11461 .f = cmd_flow_director_filter_parsed,
11463 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11464 "director entry on NIC",
11466 (void *)&cmd_flow_director_filter,
11467 (void *)&cmd_flow_director_port_id,
11468 (void *)&cmd_flow_director_mode,
11469 (void *)&cmd_flow_director_mode_tunnel,
11470 (void *)&cmd_flow_director_ops,
11471 (void *)&cmd_flow_director_mac,
11472 (void *)&cmd_flow_director_mac_addr,
11473 (void *)&cmd_flow_director_vlan,
11474 (void *)&cmd_flow_director_vlan_value,
11475 (void *)&cmd_flow_director_tunnel,
11476 (void *)&cmd_flow_director_tunnel_type,
11477 (void *)&cmd_flow_director_tunnel_id,
11478 (void *)&cmd_flow_director_tunnel_id_value,
11479 (void *)&cmd_flow_director_flexbytes,
11480 (void *)&cmd_flow_director_flexbytes_value,
11481 (void *)&cmd_flow_director_drop,
11482 (void *)&cmd_flow_director_queue,
11483 (void *)&cmd_flow_director_queue_id,
11484 (void *)&cmd_flow_director_fd_id,
11485 (void *)&cmd_flow_director_fd_id_value,
11490 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11491 .f = cmd_flow_director_filter_parsed,
11493 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11494 "director entry on NIC",
11496 (void *)&cmd_flow_director_filter,
11497 (void *)&cmd_flow_director_port_id,
11498 (void *)&cmd_flow_director_mode,
11499 (void *)&cmd_flow_director_mode_raw,
11500 (void *)&cmd_flow_director_ops,
11501 (void *)&cmd_flow_director_flow,
11502 (void *)&cmd_flow_director_flow_type,
11503 (void *)&cmd_flow_director_drop,
11504 (void *)&cmd_flow_director_queue,
11505 (void *)&cmd_flow_director_queue_id,
11506 (void *)&cmd_flow_director_fd_id,
11507 (void *)&cmd_flow_director_fd_id_value,
11508 (void *)&cmd_flow_director_packet,
11509 (void *)&cmd_flow_director_filepath,
11514 struct cmd_flush_flow_director_result {
11515 cmdline_fixed_string_t flush_flow_director;
11519 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11520 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11521 flush_flow_director, "flush_flow_director");
11522 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11523 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11527 cmd_flush_flow_director_parsed(void *parsed_result,
11528 __attribute__((unused)) struct cmdline *cl,
11529 __attribute__((unused)) void *data)
11531 struct cmd_flow_director_result *res = parsed_result;
11534 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11536 printf("flow director is not supported on port %u.\n",
11541 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11542 RTE_ETH_FILTER_FLUSH, NULL);
11544 printf("flow director table flushing error: (%s)\n",
11548 cmdline_parse_inst_t cmd_flush_flow_director = {
11549 .f = cmd_flush_flow_director_parsed,
11551 .help_str = "flush_flow_director <port_id>: "
11552 "Flush all flow director entries of a device on NIC",
11554 (void *)&cmd_flush_flow_director_flush,
11555 (void *)&cmd_flush_flow_director_port_id,
11560 /* *** deal with flow director mask *** */
11561 struct cmd_flow_director_mask_result {
11562 cmdline_fixed_string_t flow_director_mask;
11564 cmdline_fixed_string_t mode;
11565 cmdline_fixed_string_t mode_value;
11566 cmdline_fixed_string_t vlan;
11567 uint16_t vlan_mask;
11568 cmdline_fixed_string_t src_mask;
11569 cmdline_ipaddr_t ipv4_src;
11570 cmdline_ipaddr_t ipv6_src;
11572 cmdline_fixed_string_t dst_mask;
11573 cmdline_ipaddr_t ipv4_dst;
11574 cmdline_ipaddr_t ipv6_dst;
11576 cmdline_fixed_string_t mac;
11577 uint8_t mac_addr_byte_mask;
11578 cmdline_fixed_string_t tunnel_id;
11579 uint32_t tunnel_id_mask;
11580 cmdline_fixed_string_t tunnel_type;
11581 uint8_t tunnel_type_mask;
11585 cmd_flow_director_mask_parsed(void *parsed_result,
11586 __attribute__((unused)) struct cmdline *cl,
11587 __attribute__((unused)) void *data)
11589 struct cmd_flow_director_mask_result *res = parsed_result;
11590 struct rte_eth_fdir_masks *mask;
11591 struct rte_port *port;
11593 port = &ports[res->port_id];
11594 /** Check if the port is not started **/
11595 if (port->port_status != RTE_PORT_STOPPED) {
11596 printf("Please stop port %d first\n", res->port_id);
11600 mask = &port->dev_conf.fdir_conf.mask;
11602 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11603 if (strcmp(res->mode_value, "MAC-VLAN")) {
11604 printf("Please set mode to MAC-VLAN.\n");
11608 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11609 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11610 if (strcmp(res->mode_value, "Tunnel")) {
11611 printf("Please set mode to Tunnel.\n");
11615 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11616 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11617 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11618 mask->tunnel_type_mask = res->tunnel_type_mask;
11620 if (strcmp(res->mode_value, "IP")) {
11621 printf("Please set mode to IP.\n");
11625 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11626 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11627 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11628 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11629 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11630 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11631 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11634 cmd_reconfig_device_queue(res->port_id, 1, 1);
11637 cmdline_parse_token_string_t cmd_flow_director_mask =
11638 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11639 flow_director_mask, "flow_director_mask");
11640 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11641 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11643 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11644 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11646 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11647 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11648 vlan_mask, UINT16);
11649 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11650 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11651 src_mask, "src_mask");
11652 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11653 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11655 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11656 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11658 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11659 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11661 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11662 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11663 dst_mask, "dst_mask");
11664 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11665 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11667 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11668 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11670 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11671 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11674 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11675 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11677 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11678 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11680 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11681 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11682 mode_value, "MAC-VLAN");
11683 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11685 mode_value, "Tunnel");
11686 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11687 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11689 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11690 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11691 mac_addr_byte_mask, UINT8);
11692 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11693 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11694 tunnel_type, "tunnel-type");
11695 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11696 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11697 tunnel_type_mask, UINT8);
11698 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11699 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11700 tunnel_id, "tunnel-id");
11701 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11702 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11703 tunnel_id_mask, UINT32);
11705 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11706 .f = cmd_flow_director_mask_parsed,
11708 .help_str = "flow_director_mask ... : "
11709 "Set IP mode flow director's mask on NIC",
11711 (void *)&cmd_flow_director_mask,
11712 (void *)&cmd_flow_director_mask_port_id,
11713 (void *)&cmd_flow_director_mask_mode,
11714 (void *)&cmd_flow_director_mask_mode_ip,
11715 (void *)&cmd_flow_director_mask_vlan,
11716 (void *)&cmd_flow_director_mask_vlan_value,
11717 (void *)&cmd_flow_director_mask_src,
11718 (void *)&cmd_flow_director_mask_ipv4_src,
11719 (void *)&cmd_flow_director_mask_ipv6_src,
11720 (void *)&cmd_flow_director_mask_port_src,
11721 (void *)&cmd_flow_director_mask_dst,
11722 (void *)&cmd_flow_director_mask_ipv4_dst,
11723 (void *)&cmd_flow_director_mask_ipv6_dst,
11724 (void *)&cmd_flow_director_mask_port_dst,
11729 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11730 .f = cmd_flow_director_mask_parsed,
11732 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11733 "flow director's mask on NIC",
11735 (void *)&cmd_flow_director_mask,
11736 (void *)&cmd_flow_director_mask_port_id,
11737 (void *)&cmd_flow_director_mask_mode,
11738 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11739 (void *)&cmd_flow_director_mask_vlan,
11740 (void *)&cmd_flow_director_mask_vlan_value,
11745 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11746 .f = cmd_flow_director_mask_parsed,
11748 .help_str = "flow_director_mask ... : Set tunnel mode "
11749 "flow director's mask on NIC",
11751 (void *)&cmd_flow_director_mask,
11752 (void *)&cmd_flow_director_mask_port_id,
11753 (void *)&cmd_flow_director_mask_mode,
11754 (void *)&cmd_flow_director_mask_mode_tunnel,
11755 (void *)&cmd_flow_director_mask_vlan,
11756 (void *)&cmd_flow_director_mask_vlan_value,
11757 (void *)&cmd_flow_director_mask_mac,
11758 (void *)&cmd_flow_director_mask_mac_value,
11759 (void *)&cmd_flow_director_mask_tunnel_type,
11760 (void *)&cmd_flow_director_mask_tunnel_type_value,
11761 (void *)&cmd_flow_director_mask_tunnel_id,
11762 (void *)&cmd_flow_director_mask_tunnel_id_value,
11767 /* *** deal with flow director mask on flexible payload *** */
11768 struct cmd_flow_director_flex_mask_result {
11769 cmdline_fixed_string_t flow_director_flexmask;
11771 cmdline_fixed_string_t flow;
11772 cmdline_fixed_string_t flow_type;
11773 cmdline_fixed_string_t mask;
11777 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11778 __attribute__((unused)) struct cmdline *cl,
11779 __attribute__((unused)) void *data)
11781 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11782 struct rte_eth_fdir_info fdir_info;
11783 struct rte_eth_fdir_flex_mask flex_mask;
11784 struct rte_port *port;
11785 uint64_t flow_type_mask;
11789 port = &ports[res->port_id];
11790 /** Check if the port is not started **/
11791 if (port->port_status != RTE_PORT_STOPPED) {
11792 printf("Please stop port %d first\n", res->port_id);
11796 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11797 ret = parse_flexbytes(res->mask,
11799 RTE_ETH_FDIR_MAX_FLEXLEN);
11801 printf("error: Cannot parse mask input.\n");
11805 memset(&fdir_info, 0, sizeof(fdir_info));
11806 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11807 RTE_ETH_FILTER_INFO, &fdir_info);
11809 printf("Cannot get FDir filter info\n");
11813 if (!strcmp(res->flow_type, "none")) {
11814 /* means don't specify the flow type */
11815 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11816 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11817 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11818 0, sizeof(struct rte_eth_fdir_flex_mask));
11819 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11820 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11822 sizeof(struct rte_eth_fdir_flex_mask));
11823 cmd_reconfig_device_queue(res->port_id, 1, 1);
11826 flow_type_mask = fdir_info.flow_types_mask[0];
11827 if (!strcmp(res->flow_type, "all")) {
11828 if (!flow_type_mask) {
11829 printf("No flow type supported\n");
11832 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11833 if (flow_type_mask & (1ULL << i)) {
11834 flex_mask.flow_type = i;
11835 fdir_set_flex_mask(res->port_id, &flex_mask);
11838 cmd_reconfig_device_queue(res->port_id, 1, 1);
11841 flex_mask.flow_type = str2flowtype(res->flow_type);
11842 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11843 printf("Flow type %s not supported on port %d\n",
11844 res->flow_type, res->port_id);
11847 fdir_set_flex_mask(res->port_id, &flex_mask);
11848 cmd_reconfig_device_queue(res->port_id, 1, 1);
11851 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11853 flow_director_flexmask,
11854 "flow_director_flex_mask");
11855 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11856 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11858 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11861 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11863 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11864 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11865 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11866 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11869 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11870 .f = cmd_flow_director_flex_mask_parsed,
11872 .help_str = "flow_director_flex_mask ... : "
11873 "Set flow director's flex mask on NIC",
11875 (void *)&cmd_flow_director_flexmask,
11876 (void *)&cmd_flow_director_flexmask_port_id,
11877 (void *)&cmd_flow_director_flexmask_flow,
11878 (void *)&cmd_flow_director_flexmask_flow_type,
11879 (void *)&cmd_flow_director_flexmask_mask,
11884 /* *** deal with flow director flexible payload configuration *** */
11885 struct cmd_flow_director_flexpayload_result {
11886 cmdline_fixed_string_t flow_director_flexpayload;
11888 cmdline_fixed_string_t payload_layer;
11889 cmdline_fixed_string_t payload_cfg;
11893 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11896 const char *p, *p0 = q_arg;
11898 unsigned long int_fld;
11899 char *str_fld[max_num];
11904 p = strchr(p0, '(');
11908 p0 = strchr(p, ')');
11913 if (size >= sizeof(s))
11916 snprintf(s, sizeof(s), "%.*s", size, p);
11917 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11918 if (ret < 0 || ret > max_num)
11920 for (i = 0; i < ret; i++) {
11922 int_fld = strtoul(str_fld[i], &end, 0);
11923 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11925 offsets[i] = (uint16_t)int_fld;
11931 cmd_flow_director_flxpld_parsed(void *parsed_result,
11932 __attribute__((unused)) struct cmdline *cl,
11933 __attribute__((unused)) void *data)
11935 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11936 struct rte_eth_flex_payload_cfg flex_cfg;
11937 struct rte_port *port;
11940 port = &ports[res->port_id];
11941 /** Check if the port is not started **/
11942 if (port->port_status != RTE_PORT_STOPPED) {
11943 printf("Please stop port %d first\n", res->port_id);
11947 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11949 if (!strcmp(res->payload_layer, "raw"))
11950 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11951 else if (!strcmp(res->payload_layer, "l2"))
11952 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11953 else if (!strcmp(res->payload_layer, "l3"))
11954 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11955 else if (!strcmp(res->payload_layer, "l4"))
11956 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11958 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11959 RTE_ETH_FDIR_MAX_FLEXLEN);
11961 printf("error: Cannot parse flex payload input.\n");
11965 fdir_set_flex_payload(res->port_id, &flex_cfg);
11966 cmd_reconfig_device_queue(res->port_id, 1, 1);
11969 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11970 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11971 flow_director_flexpayload,
11972 "flow_director_flex_payload");
11973 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11974 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11976 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11978 payload_layer, "raw#l2#l3#l4");
11979 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11981 payload_cfg, NULL);
11983 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11984 .f = cmd_flow_director_flxpld_parsed,
11986 .help_str = "flow_director_flexpayload ... : "
11987 "Set flow director's flex payload on NIC",
11989 (void *)&cmd_flow_director_flexpayload,
11990 (void *)&cmd_flow_director_flexpayload_port_id,
11991 (void *)&cmd_flow_director_flexpayload_payload_layer,
11992 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11997 /* Generic flow interface command. */
11998 extern cmdline_parse_inst_t cmd_flow;
12000 /* *** Classification Filters Control *** */
12001 /* *** Get symmetric hash enable per port *** */
12002 struct cmd_get_sym_hash_ena_per_port_result {
12003 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12008 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12009 __rte_unused struct cmdline *cl,
12010 __rte_unused void *data)
12012 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12013 struct rte_eth_hash_filter_info info;
12016 if (rte_eth_dev_filter_supported(res->port_id,
12017 RTE_ETH_FILTER_HASH) < 0) {
12018 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12023 memset(&info, 0, sizeof(info));
12024 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12025 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12026 RTE_ETH_FILTER_GET, &info);
12029 printf("Cannot get symmetric hash enable per port "
12030 "on port %u\n", res->port_id);
12034 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12035 "enabled" : "disabled", res->port_id);
12038 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12039 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12040 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12041 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12042 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12045 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12046 .f = cmd_get_sym_hash_per_port_parsed,
12048 .help_str = "get_sym_hash_ena_per_port <port_id>",
12050 (void *)&cmd_get_sym_hash_ena_per_port_all,
12051 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12056 /* *** Set symmetric hash enable per port *** */
12057 struct cmd_set_sym_hash_ena_per_port_result {
12058 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12059 cmdline_fixed_string_t enable;
12064 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12065 __rte_unused struct cmdline *cl,
12066 __rte_unused void *data)
12068 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12069 struct rte_eth_hash_filter_info info;
12072 if (rte_eth_dev_filter_supported(res->port_id,
12073 RTE_ETH_FILTER_HASH) < 0) {
12074 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12079 memset(&info, 0, sizeof(info));
12080 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12081 if (!strcmp(res->enable, "enable"))
12082 info.info.enable = 1;
12083 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12084 RTE_ETH_FILTER_SET, &info);
12086 printf("Cannot set symmetric hash enable per port on "
12087 "port %u\n", res->port_id);
12090 printf("Symmetric hash has been set to %s on port %u\n",
12091 res->enable, res->port_id);
12094 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12095 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12096 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12097 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12098 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12100 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12101 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12102 enable, "enable#disable");
12104 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12105 .f = cmd_set_sym_hash_per_port_parsed,
12107 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12109 (void *)&cmd_set_sym_hash_ena_per_port_all,
12110 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12111 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12116 /* Get global config of hash function */
12117 struct cmd_get_hash_global_config_result {
12118 cmdline_fixed_string_t get_hash_global_config;
12123 flowtype_to_str(uint16_t ftype)
12129 } ftype_table[] = {
12130 {"ipv4", RTE_ETH_FLOW_IPV4},
12131 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12132 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12133 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12134 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12135 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12136 {"ipv6", RTE_ETH_FLOW_IPV6},
12137 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12138 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12139 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12140 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12141 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12142 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12143 {"port", RTE_ETH_FLOW_PORT},
12144 {"vxlan", RTE_ETH_FLOW_VXLAN},
12145 {"geneve", RTE_ETH_FLOW_GENEVE},
12146 {"nvgre", RTE_ETH_FLOW_NVGRE},
12147 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12150 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12151 if (ftype_table[i].ftype == ftype)
12152 return ftype_table[i].str;
12159 cmd_get_hash_global_config_parsed(void *parsed_result,
12160 __rte_unused struct cmdline *cl,
12161 __rte_unused void *data)
12163 struct cmd_get_hash_global_config_result *res = parsed_result;
12164 struct rte_eth_hash_filter_info info;
12165 uint32_t idx, offset;
12170 if (rte_eth_dev_filter_supported(res->port_id,
12171 RTE_ETH_FILTER_HASH) < 0) {
12172 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12177 memset(&info, 0, sizeof(info));
12178 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12179 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12180 RTE_ETH_FILTER_GET, &info);
12182 printf("Cannot get hash global configurations by port %d\n",
12187 switch (info.info.global_conf.hash_func) {
12188 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12189 printf("Hash function is Toeplitz\n");
12191 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12192 printf("Hash function is Simple XOR\n");
12194 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12195 printf("Hash function is Symmetric Toeplitz\n");
12198 printf("Unknown hash function\n");
12202 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12203 idx = i / UINT64_BIT;
12204 offset = i % UINT64_BIT;
12205 if (!(info.info.global_conf.valid_bit_mask[idx] &
12208 str = flowtype_to_str(i);
12211 printf("Symmetric hash is %s globally for flow type %s "
12213 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12214 (1ULL << offset)) ? "enabled" : "disabled"), str,
12219 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12220 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12221 get_hash_global_config, "get_hash_global_config");
12222 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12223 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12226 cmdline_parse_inst_t cmd_get_hash_global_config = {
12227 .f = cmd_get_hash_global_config_parsed,
12229 .help_str = "get_hash_global_config <port_id>",
12231 (void *)&cmd_get_hash_global_config_all,
12232 (void *)&cmd_get_hash_global_config_port_id,
12237 /* Set global config of hash function */
12238 struct cmd_set_hash_global_config_result {
12239 cmdline_fixed_string_t set_hash_global_config;
12241 cmdline_fixed_string_t hash_func;
12242 cmdline_fixed_string_t flow_type;
12243 cmdline_fixed_string_t enable;
12247 cmd_set_hash_global_config_parsed(void *parsed_result,
12248 __rte_unused struct cmdline *cl,
12249 __rte_unused void *data)
12251 struct cmd_set_hash_global_config_result *res = parsed_result;
12252 struct rte_eth_hash_filter_info info;
12253 uint32_t ftype, idx, offset;
12256 if (rte_eth_dev_filter_supported(res->port_id,
12257 RTE_ETH_FILTER_HASH) < 0) {
12258 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12262 memset(&info, 0, sizeof(info));
12263 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12264 if (!strcmp(res->hash_func, "toeplitz"))
12265 info.info.global_conf.hash_func =
12266 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12267 else if (!strcmp(res->hash_func, "simple_xor"))
12268 info.info.global_conf.hash_func =
12269 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12270 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12271 info.info.global_conf.hash_func =
12272 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12273 else if (!strcmp(res->hash_func, "default"))
12274 info.info.global_conf.hash_func =
12275 RTE_ETH_HASH_FUNCTION_DEFAULT;
12277 ftype = str2flowtype(res->flow_type);
12278 idx = ftype / UINT64_BIT;
12279 offset = ftype % UINT64_BIT;
12280 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12281 if (!strcmp(res->enable, "enable"))
12282 info.info.global_conf.sym_hash_enable_mask[idx] |=
12284 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12285 RTE_ETH_FILTER_SET, &info);
12287 printf("Cannot set global hash configurations by port %d\n",
12290 printf("Global hash configurations have been set "
12291 "successfully by port %d\n", res->port_id);
12294 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12295 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12296 set_hash_global_config, "set_hash_global_config");
12297 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12298 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12300 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12301 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12302 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12303 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12304 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12306 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12307 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12308 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12309 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12310 enable, "enable#disable");
12312 cmdline_parse_inst_t cmd_set_hash_global_config = {
12313 .f = cmd_set_hash_global_config_parsed,
12315 .help_str = "set_hash_global_config <port_id> "
12316 "toeplitz|simple_xor|symmetric_toeplitz|default "
12317 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12318 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12319 "l2_payload enable|disable",
12321 (void *)&cmd_set_hash_global_config_all,
12322 (void *)&cmd_set_hash_global_config_port_id,
12323 (void *)&cmd_set_hash_global_config_hash_func,
12324 (void *)&cmd_set_hash_global_config_flow_type,
12325 (void *)&cmd_set_hash_global_config_enable,
12330 /* Set hash input set */
12331 struct cmd_set_hash_input_set_result {
12332 cmdline_fixed_string_t set_hash_input_set;
12334 cmdline_fixed_string_t flow_type;
12335 cmdline_fixed_string_t inset_field;
12336 cmdline_fixed_string_t select;
12339 static enum rte_eth_input_set_field
12340 str2inset(char *string)
12344 static const struct {
12346 enum rte_eth_input_set_field inset;
12347 } inset_table[] = {
12348 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12349 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12350 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12351 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12352 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12353 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12354 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12355 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12356 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12357 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12358 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12359 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12360 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12361 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12362 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12363 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12364 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12365 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12366 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12367 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12368 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12369 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12370 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12371 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12372 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12373 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12374 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12375 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12376 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12377 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12378 {"none", RTE_ETH_INPUT_SET_NONE},
12381 for (i = 0; i < RTE_DIM(inset_table); i++) {
12382 if (!strcmp(string, inset_table[i].str))
12383 return inset_table[i].inset;
12386 return RTE_ETH_INPUT_SET_UNKNOWN;
12390 cmd_set_hash_input_set_parsed(void *parsed_result,
12391 __rte_unused struct cmdline *cl,
12392 __rte_unused void *data)
12394 struct cmd_set_hash_input_set_result *res = parsed_result;
12395 struct rte_eth_hash_filter_info info;
12397 memset(&info, 0, sizeof(info));
12398 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12399 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12400 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12401 info.info.input_set_conf.inset_size = 1;
12402 if (!strcmp(res->select, "select"))
12403 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12404 else if (!strcmp(res->select, "add"))
12405 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12406 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12407 RTE_ETH_FILTER_SET, &info);
12410 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12411 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12412 set_hash_input_set, "set_hash_input_set");
12413 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12414 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12416 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12417 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12419 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12420 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12422 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12423 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12424 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12425 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12426 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12428 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12429 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12430 select, "select#add");
12432 cmdline_parse_inst_t cmd_set_hash_input_set = {
12433 .f = cmd_set_hash_input_set_parsed,
12435 .help_str = "set_hash_input_set <port_id> "
12436 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12437 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12438 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12439 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12440 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12441 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12442 "fld-7th|fld-8th|none select|add",
12444 (void *)&cmd_set_hash_input_set_cmd,
12445 (void *)&cmd_set_hash_input_set_port_id,
12446 (void *)&cmd_set_hash_input_set_flow_type,
12447 (void *)&cmd_set_hash_input_set_field,
12448 (void *)&cmd_set_hash_input_set_select,
12453 /* Set flow director input set */
12454 struct cmd_set_fdir_input_set_result {
12455 cmdline_fixed_string_t set_fdir_input_set;
12457 cmdline_fixed_string_t flow_type;
12458 cmdline_fixed_string_t inset_field;
12459 cmdline_fixed_string_t select;
12463 cmd_set_fdir_input_set_parsed(void *parsed_result,
12464 __rte_unused struct cmdline *cl,
12465 __rte_unused void *data)
12467 struct cmd_set_fdir_input_set_result *res = parsed_result;
12468 struct rte_eth_fdir_filter_info info;
12470 memset(&info, 0, sizeof(info));
12471 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12472 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12473 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12474 info.info.input_set_conf.inset_size = 1;
12475 if (!strcmp(res->select, "select"))
12476 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12477 else if (!strcmp(res->select, "add"))
12478 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12479 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12480 RTE_ETH_FILTER_SET, &info);
12483 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12484 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12485 set_fdir_input_set, "set_fdir_input_set");
12486 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12487 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12489 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12490 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12492 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12493 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12494 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12495 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12497 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12498 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12499 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12500 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12501 "sctp-veri-tag#none");
12502 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12503 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12504 select, "select#add");
12506 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12507 .f = cmd_set_fdir_input_set_parsed,
12509 .help_str = "set_fdir_input_set <port_id> "
12510 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12511 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12512 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12513 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12514 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12515 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12516 "sctp-veri-tag|none select|add",
12518 (void *)&cmd_set_fdir_input_set_cmd,
12519 (void *)&cmd_set_fdir_input_set_port_id,
12520 (void *)&cmd_set_fdir_input_set_flow_type,
12521 (void *)&cmd_set_fdir_input_set_field,
12522 (void *)&cmd_set_fdir_input_set_select,
12527 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12528 struct cmd_mcast_addr_result {
12529 cmdline_fixed_string_t mcast_addr_cmd;
12530 cmdline_fixed_string_t what;
12532 struct rte_ether_addr mc_addr;
12535 static void cmd_mcast_addr_parsed(void *parsed_result,
12536 __attribute__((unused)) struct cmdline *cl,
12537 __attribute__((unused)) void *data)
12539 struct cmd_mcast_addr_result *res = parsed_result;
12541 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12542 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12543 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12544 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12545 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12548 if (strcmp(res->what, "add") == 0)
12549 mcast_addr_add(res->port_num, &res->mc_addr);
12551 mcast_addr_remove(res->port_num, &res->mc_addr);
12554 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12555 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12556 mcast_addr_cmd, "mcast_addr");
12557 cmdline_parse_token_string_t cmd_mcast_addr_what =
12558 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12560 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12561 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12562 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12563 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12565 cmdline_parse_inst_t cmd_mcast_addr = {
12566 .f = cmd_mcast_addr_parsed,
12568 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12569 "Add/Remove multicast MAC address on port_id",
12571 (void *)&cmd_mcast_addr_cmd,
12572 (void *)&cmd_mcast_addr_what,
12573 (void *)&cmd_mcast_addr_portnum,
12574 (void *)&cmd_mcast_addr_addr,
12579 /* l2 tunnel config
12580 * only support E-tag now.
12583 /* Ether type config */
12584 struct cmd_config_l2_tunnel_eth_type_result {
12585 cmdline_fixed_string_t port;
12586 cmdline_fixed_string_t config;
12587 cmdline_fixed_string_t all;
12589 cmdline_fixed_string_t l2_tunnel;
12590 cmdline_fixed_string_t l2_tunnel_type;
12591 cmdline_fixed_string_t eth_type;
12592 uint16_t eth_type_val;
12595 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12596 TOKEN_STRING_INITIALIZER
12597 (struct cmd_config_l2_tunnel_eth_type_result,
12599 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12600 TOKEN_STRING_INITIALIZER
12601 (struct cmd_config_l2_tunnel_eth_type_result,
12603 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12604 TOKEN_STRING_INITIALIZER
12605 (struct cmd_config_l2_tunnel_eth_type_result,
12607 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12608 TOKEN_NUM_INITIALIZER
12609 (struct cmd_config_l2_tunnel_eth_type_result,
12611 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12612 TOKEN_STRING_INITIALIZER
12613 (struct cmd_config_l2_tunnel_eth_type_result,
12614 l2_tunnel, "l2-tunnel");
12615 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12616 TOKEN_STRING_INITIALIZER
12617 (struct cmd_config_l2_tunnel_eth_type_result,
12618 l2_tunnel_type, "E-tag");
12619 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12620 TOKEN_STRING_INITIALIZER
12621 (struct cmd_config_l2_tunnel_eth_type_result,
12622 eth_type, "ether-type");
12623 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12624 TOKEN_NUM_INITIALIZER
12625 (struct cmd_config_l2_tunnel_eth_type_result,
12626 eth_type_val, UINT16);
12628 static enum rte_eth_tunnel_type
12629 str2fdir_l2_tunnel_type(char *string)
12633 static const struct {
12635 enum rte_eth_tunnel_type type;
12636 } l2_tunnel_type_str[] = {
12637 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12640 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12641 if (!strcmp(l2_tunnel_type_str[i].str, string))
12642 return l2_tunnel_type_str[i].type;
12644 return RTE_TUNNEL_TYPE_NONE;
12647 /* ether type config for all ports */
12649 cmd_config_l2_tunnel_eth_type_all_parsed
12650 (void *parsed_result,
12651 __attribute__((unused)) struct cmdline *cl,
12652 __attribute__((unused)) void *data)
12654 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12655 struct rte_eth_l2_tunnel_conf entry;
12658 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12659 entry.ether_type = res->eth_type_val;
12661 RTE_ETH_FOREACH_DEV(pid) {
12662 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12666 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12667 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12669 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12671 (void *)&cmd_config_l2_tunnel_eth_type_port,
12672 (void *)&cmd_config_l2_tunnel_eth_type_config,
12673 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12674 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12675 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12676 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12677 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12682 /* ether type config for a specific port */
12684 cmd_config_l2_tunnel_eth_type_specific_parsed(
12685 void *parsed_result,
12686 __attribute__((unused)) struct cmdline *cl,
12687 __attribute__((unused)) void *data)
12689 struct cmd_config_l2_tunnel_eth_type_result *res =
12691 struct rte_eth_l2_tunnel_conf entry;
12693 if (port_id_is_invalid(res->id, ENABLED_WARN))
12696 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12697 entry.ether_type = res->eth_type_val;
12699 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12702 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12703 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12705 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12707 (void *)&cmd_config_l2_tunnel_eth_type_port,
12708 (void *)&cmd_config_l2_tunnel_eth_type_config,
12709 (void *)&cmd_config_l2_tunnel_eth_type_id,
12710 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12711 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12712 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12713 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12718 /* Enable/disable l2 tunnel */
12719 struct cmd_config_l2_tunnel_en_dis_result {
12720 cmdline_fixed_string_t port;
12721 cmdline_fixed_string_t config;
12722 cmdline_fixed_string_t all;
12724 cmdline_fixed_string_t l2_tunnel;
12725 cmdline_fixed_string_t l2_tunnel_type;
12726 cmdline_fixed_string_t en_dis;
12729 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12730 TOKEN_STRING_INITIALIZER
12731 (struct cmd_config_l2_tunnel_en_dis_result,
12733 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12734 TOKEN_STRING_INITIALIZER
12735 (struct cmd_config_l2_tunnel_en_dis_result,
12737 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12738 TOKEN_STRING_INITIALIZER
12739 (struct cmd_config_l2_tunnel_en_dis_result,
12741 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12742 TOKEN_NUM_INITIALIZER
12743 (struct cmd_config_l2_tunnel_en_dis_result,
12745 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12746 TOKEN_STRING_INITIALIZER
12747 (struct cmd_config_l2_tunnel_en_dis_result,
12748 l2_tunnel, "l2-tunnel");
12749 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12750 TOKEN_STRING_INITIALIZER
12751 (struct cmd_config_l2_tunnel_en_dis_result,
12752 l2_tunnel_type, "E-tag");
12753 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12754 TOKEN_STRING_INITIALIZER
12755 (struct cmd_config_l2_tunnel_en_dis_result,
12756 en_dis, "enable#disable");
12758 /* enable/disable l2 tunnel for all ports */
12760 cmd_config_l2_tunnel_en_dis_all_parsed(
12761 void *parsed_result,
12762 __attribute__((unused)) struct cmdline *cl,
12763 __attribute__((unused)) void *data)
12765 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12766 struct rte_eth_l2_tunnel_conf entry;
12770 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12772 if (!strcmp("enable", res->en_dis))
12777 RTE_ETH_FOREACH_DEV(pid) {
12778 rte_eth_dev_l2_tunnel_offload_set(pid,
12780 ETH_L2_TUNNEL_ENABLE_MASK,
12785 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12786 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12788 .help_str = "port config all l2-tunnel E-tag enable|disable",
12790 (void *)&cmd_config_l2_tunnel_en_dis_port,
12791 (void *)&cmd_config_l2_tunnel_en_dis_config,
12792 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12793 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12794 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12795 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12800 /* enable/disable l2 tunnel for a port */
12802 cmd_config_l2_tunnel_en_dis_specific_parsed(
12803 void *parsed_result,
12804 __attribute__((unused)) struct cmdline *cl,
12805 __attribute__((unused)) void *data)
12807 struct cmd_config_l2_tunnel_en_dis_result *res =
12809 struct rte_eth_l2_tunnel_conf entry;
12811 if (port_id_is_invalid(res->id, ENABLED_WARN))
12814 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12816 if (!strcmp("enable", res->en_dis))
12817 rte_eth_dev_l2_tunnel_offload_set(res->id,
12819 ETH_L2_TUNNEL_ENABLE_MASK,
12822 rte_eth_dev_l2_tunnel_offload_set(res->id,
12824 ETH_L2_TUNNEL_ENABLE_MASK,
12828 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12829 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12831 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12833 (void *)&cmd_config_l2_tunnel_en_dis_port,
12834 (void *)&cmd_config_l2_tunnel_en_dis_config,
12835 (void *)&cmd_config_l2_tunnel_en_dis_id,
12836 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12837 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12838 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12843 /* E-tag configuration */
12845 /* Common result structure for all E-tag configuration */
12846 struct cmd_config_e_tag_result {
12847 cmdline_fixed_string_t e_tag;
12848 cmdline_fixed_string_t set;
12849 cmdline_fixed_string_t insertion;
12850 cmdline_fixed_string_t stripping;
12851 cmdline_fixed_string_t forwarding;
12852 cmdline_fixed_string_t filter;
12853 cmdline_fixed_string_t add;
12854 cmdline_fixed_string_t del;
12855 cmdline_fixed_string_t on;
12856 cmdline_fixed_string_t off;
12857 cmdline_fixed_string_t on_off;
12858 cmdline_fixed_string_t port_tag_id;
12859 uint32_t port_tag_id_val;
12860 cmdline_fixed_string_t e_tag_id;
12861 uint16_t e_tag_id_val;
12862 cmdline_fixed_string_t dst_pool;
12863 uint8_t dst_pool_val;
12864 cmdline_fixed_string_t port;
12866 cmdline_fixed_string_t vf;
12870 /* Common CLI fields for all E-tag configuration */
12871 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12872 TOKEN_STRING_INITIALIZER
12873 (struct cmd_config_e_tag_result,
12875 cmdline_parse_token_string_t cmd_config_e_tag_set =
12876 TOKEN_STRING_INITIALIZER
12877 (struct cmd_config_e_tag_result,
12879 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12880 TOKEN_STRING_INITIALIZER
12881 (struct cmd_config_e_tag_result,
12882 insertion, "insertion");
12883 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12884 TOKEN_STRING_INITIALIZER
12885 (struct cmd_config_e_tag_result,
12886 stripping, "stripping");
12887 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12888 TOKEN_STRING_INITIALIZER
12889 (struct cmd_config_e_tag_result,
12890 forwarding, "forwarding");
12891 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12892 TOKEN_STRING_INITIALIZER
12893 (struct cmd_config_e_tag_result,
12895 cmdline_parse_token_string_t cmd_config_e_tag_add =
12896 TOKEN_STRING_INITIALIZER
12897 (struct cmd_config_e_tag_result,
12899 cmdline_parse_token_string_t cmd_config_e_tag_del =
12900 TOKEN_STRING_INITIALIZER
12901 (struct cmd_config_e_tag_result,
12903 cmdline_parse_token_string_t cmd_config_e_tag_on =
12904 TOKEN_STRING_INITIALIZER
12905 (struct cmd_config_e_tag_result,
12907 cmdline_parse_token_string_t cmd_config_e_tag_off =
12908 TOKEN_STRING_INITIALIZER
12909 (struct cmd_config_e_tag_result,
12911 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12912 TOKEN_STRING_INITIALIZER
12913 (struct cmd_config_e_tag_result,
12915 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12916 TOKEN_STRING_INITIALIZER
12917 (struct cmd_config_e_tag_result,
12918 port_tag_id, "port-tag-id");
12919 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12920 TOKEN_NUM_INITIALIZER
12921 (struct cmd_config_e_tag_result,
12922 port_tag_id_val, UINT32);
12923 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12924 TOKEN_STRING_INITIALIZER
12925 (struct cmd_config_e_tag_result,
12926 e_tag_id, "e-tag-id");
12927 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12928 TOKEN_NUM_INITIALIZER
12929 (struct cmd_config_e_tag_result,
12930 e_tag_id_val, UINT16);
12931 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12932 TOKEN_STRING_INITIALIZER
12933 (struct cmd_config_e_tag_result,
12934 dst_pool, "dst-pool");
12935 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12936 TOKEN_NUM_INITIALIZER
12937 (struct cmd_config_e_tag_result,
12938 dst_pool_val, UINT8);
12939 cmdline_parse_token_string_t cmd_config_e_tag_port =
12940 TOKEN_STRING_INITIALIZER
12941 (struct cmd_config_e_tag_result,
12943 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12944 TOKEN_NUM_INITIALIZER
12945 (struct cmd_config_e_tag_result,
12947 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12948 TOKEN_STRING_INITIALIZER
12949 (struct cmd_config_e_tag_result,
12951 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12952 TOKEN_NUM_INITIALIZER
12953 (struct cmd_config_e_tag_result,
12956 /* E-tag insertion configuration */
12958 cmd_config_e_tag_insertion_en_parsed(
12959 void *parsed_result,
12960 __attribute__((unused)) struct cmdline *cl,
12961 __attribute__((unused)) void *data)
12963 struct cmd_config_e_tag_result *res =
12965 struct rte_eth_l2_tunnel_conf entry;
12967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12970 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12971 entry.tunnel_id = res->port_tag_id_val;
12972 entry.vf_id = res->vf_id;
12973 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12975 ETH_L2_TUNNEL_INSERTION_MASK,
12980 cmd_config_e_tag_insertion_dis_parsed(
12981 void *parsed_result,
12982 __attribute__((unused)) struct cmdline *cl,
12983 __attribute__((unused)) void *data)
12985 struct cmd_config_e_tag_result *res =
12987 struct rte_eth_l2_tunnel_conf entry;
12989 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12992 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12993 entry.vf_id = res->vf_id;
12995 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12997 ETH_L2_TUNNEL_INSERTION_MASK,
13001 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13002 .f = cmd_config_e_tag_insertion_en_parsed,
13004 .help_str = "E-tag ... : E-tag insertion enable",
13006 (void *)&cmd_config_e_tag_e_tag,
13007 (void *)&cmd_config_e_tag_set,
13008 (void *)&cmd_config_e_tag_insertion,
13009 (void *)&cmd_config_e_tag_on,
13010 (void *)&cmd_config_e_tag_port_tag_id,
13011 (void *)&cmd_config_e_tag_port_tag_id_val,
13012 (void *)&cmd_config_e_tag_port,
13013 (void *)&cmd_config_e_tag_port_id,
13014 (void *)&cmd_config_e_tag_vf,
13015 (void *)&cmd_config_e_tag_vf_id,
13020 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13021 .f = cmd_config_e_tag_insertion_dis_parsed,
13023 .help_str = "E-tag ... : E-tag insertion disable",
13025 (void *)&cmd_config_e_tag_e_tag,
13026 (void *)&cmd_config_e_tag_set,
13027 (void *)&cmd_config_e_tag_insertion,
13028 (void *)&cmd_config_e_tag_off,
13029 (void *)&cmd_config_e_tag_port,
13030 (void *)&cmd_config_e_tag_port_id,
13031 (void *)&cmd_config_e_tag_vf,
13032 (void *)&cmd_config_e_tag_vf_id,
13037 /* E-tag stripping configuration */
13039 cmd_config_e_tag_stripping_parsed(
13040 void *parsed_result,
13041 __attribute__((unused)) struct cmdline *cl,
13042 __attribute__((unused)) void *data)
13044 struct cmd_config_e_tag_result *res =
13046 struct rte_eth_l2_tunnel_conf entry;
13048 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13051 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13053 if (!strcmp(res->on_off, "on"))
13054 rte_eth_dev_l2_tunnel_offload_set
13057 ETH_L2_TUNNEL_STRIPPING_MASK,
13060 rte_eth_dev_l2_tunnel_offload_set
13063 ETH_L2_TUNNEL_STRIPPING_MASK,
13067 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13068 .f = cmd_config_e_tag_stripping_parsed,
13070 .help_str = "E-tag ... : E-tag stripping enable/disable",
13072 (void *)&cmd_config_e_tag_e_tag,
13073 (void *)&cmd_config_e_tag_set,
13074 (void *)&cmd_config_e_tag_stripping,
13075 (void *)&cmd_config_e_tag_on_off,
13076 (void *)&cmd_config_e_tag_port,
13077 (void *)&cmd_config_e_tag_port_id,
13082 /* E-tag forwarding configuration */
13084 cmd_config_e_tag_forwarding_parsed(
13085 void *parsed_result,
13086 __attribute__((unused)) struct cmdline *cl,
13087 __attribute__((unused)) void *data)
13089 struct cmd_config_e_tag_result *res = parsed_result;
13090 struct rte_eth_l2_tunnel_conf entry;
13092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13095 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13097 if (!strcmp(res->on_off, "on"))
13098 rte_eth_dev_l2_tunnel_offload_set
13101 ETH_L2_TUNNEL_FORWARDING_MASK,
13104 rte_eth_dev_l2_tunnel_offload_set
13107 ETH_L2_TUNNEL_FORWARDING_MASK,
13111 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13112 .f = cmd_config_e_tag_forwarding_parsed,
13114 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13116 (void *)&cmd_config_e_tag_e_tag,
13117 (void *)&cmd_config_e_tag_set,
13118 (void *)&cmd_config_e_tag_forwarding,
13119 (void *)&cmd_config_e_tag_on_off,
13120 (void *)&cmd_config_e_tag_port,
13121 (void *)&cmd_config_e_tag_port_id,
13126 /* E-tag filter configuration */
13128 cmd_config_e_tag_filter_add_parsed(
13129 void *parsed_result,
13130 __attribute__((unused)) struct cmdline *cl,
13131 __attribute__((unused)) void *data)
13133 struct cmd_config_e_tag_result *res = parsed_result;
13134 struct rte_eth_l2_tunnel_conf entry;
13137 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13140 if (res->e_tag_id_val > 0x3fff) {
13141 printf("e-tag-id must be equal or less than 0x3fff.\n");
13145 ret = rte_eth_dev_filter_supported(res->port_id,
13146 RTE_ETH_FILTER_L2_TUNNEL);
13148 printf("E-tag filter is not supported on port %u.\n",
13153 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13154 entry.tunnel_id = res->e_tag_id_val;
13155 entry.pool = res->dst_pool_val;
13157 ret = rte_eth_dev_filter_ctrl(res->port_id,
13158 RTE_ETH_FILTER_L2_TUNNEL,
13159 RTE_ETH_FILTER_ADD,
13162 printf("E-tag filter programming error: (%s)\n",
13166 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13167 .f = cmd_config_e_tag_filter_add_parsed,
13169 .help_str = "E-tag ... : E-tag filter add",
13171 (void *)&cmd_config_e_tag_e_tag,
13172 (void *)&cmd_config_e_tag_set,
13173 (void *)&cmd_config_e_tag_filter,
13174 (void *)&cmd_config_e_tag_add,
13175 (void *)&cmd_config_e_tag_e_tag_id,
13176 (void *)&cmd_config_e_tag_e_tag_id_val,
13177 (void *)&cmd_config_e_tag_dst_pool,
13178 (void *)&cmd_config_e_tag_dst_pool_val,
13179 (void *)&cmd_config_e_tag_port,
13180 (void *)&cmd_config_e_tag_port_id,
13186 cmd_config_e_tag_filter_del_parsed(
13187 void *parsed_result,
13188 __attribute__((unused)) struct cmdline *cl,
13189 __attribute__((unused)) void *data)
13191 struct cmd_config_e_tag_result *res = parsed_result;
13192 struct rte_eth_l2_tunnel_conf entry;
13195 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13198 if (res->e_tag_id_val > 0x3fff) {
13199 printf("e-tag-id must be less than 0x3fff.\n");
13203 ret = rte_eth_dev_filter_supported(res->port_id,
13204 RTE_ETH_FILTER_L2_TUNNEL);
13206 printf("E-tag filter is not supported on port %u.\n",
13211 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13212 entry.tunnel_id = res->e_tag_id_val;
13214 ret = rte_eth_dev_filter_ctrl(res->port_id,
13215 RTE_ETH_FILTER_L2_TUNNEL,
13216 RTE_ETH_FILTER_DELETE,
13219 printf("E-tag filter programming error: (%s)\n",
13223 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13224 .f = cmd_config_e_tag_filter_del_parsed,
13226 .help_str = "E-tag ... : E-tag filter delete",
13228 (void *)&cmd_config_e_tag_e_tag,
13229 (void *)&cmd_config_e_tag_set,
13230 (void *)&cmd_config_e_tag_filter,
13231 (void *)&cmd_config_e_tag_del,
13232 (void *)&cmd_config_e_tag_e_tag_id,
13233 (void *)&cmd_config_e_tag_e_tag_id_val,
13234 (void *)&cmd_config_e_tag_port,
13235 (void *)&cmd_config_e_tag_port_id,
13240 /* vf vlan anti spoof configuration */
13242 /* Common result structure for vf vlan anti spoof */
13243 struct cmd_vf_vlan_anti_spoof_result {
13244 cmdline_fixed_string_t set;
13245 cmdline_fixed_string_t vf;
13246 cmdline_fixed_string_t vlan;
13247 cmdline_fixed_string_t antispoof;
13250 cmdline_fixed_string_t on_off;
13253 /* Common CLI fields for vf vlan anti spoof enable disable */
13254 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13255 TOKEN_STRING_INITIALIZER
13256 (struct cmd_vf_vlan_anti_spoof_result,
13258 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13259 TOKEN_STRING_INITIALIZER
13260 (struct cmd_vf_vlan_anti_spoof_result,
13262 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13263 TOKEN_STRING_INITIALIZER
13264 (struct cmd_vf_vlan_anti_spoof_result,
13266 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13267 TOKEN_STRING_INITIALIZER
13268 (struct cmd_vf_vlan_anti_spoof_result,
13269 antispoof, "antispoof");
13270 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13271 TOKEN_NUM_INITIALIZER
13272 (struct cmd_vf_vlan_anti_spoof_result,
13274 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13275 TOKEN_NUM_INITIALIZER
13276 (struct cmd_vf_vlan_anti_spoof_result,
13278 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13279 TOKEN_STRING_INITIALIZER
13280 (struct cmd_vf_vlan_anti_spoof_result,
13284 cmd_set_vf_vlan_anti_spoof_parsed(
13285 void *parsed_result,
13286 __attribute__((unused)) struct cmdline *cl,
13287 __attribute__((unused)) void *data)
13289 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13290 int ret = -ENOTSUP;
13292 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13294 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13297 #ifdef RTE_LIBRTE_IXGBE_PMD
13298 if (ret == -ENOTSUP)
13299 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13300 res->vf_id, is_on);
13302 #ifdef RTE_LIBRTE_I40E_PMD
13303 if (ret == -ENOTSUP)
13304 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13305 res->vf_id, is_on);
13307 #ifdef RTE_LIBRTE_BNXT_PMD
13308 if (ret == -ENOTSUP)
13309 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13310 res->vf_id, is_on);
13317 printf("invalid vf_id %d\n", res->vf_id);
13320 printf("invalid port_id %d\n", res->port_id);
13323 printf("function not implemented\n");
13326 printf("programming error: (%s)\n", strerror(-ret));
13330 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13331 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13333 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13335 (void *)&cmd_vf_vlan_anti_spoof_set,
13336 (void *)&cmd_vf_vlan_anti_spoof_vf,
13337 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13338 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13339 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13340 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13341 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13346 /* vf mac anti spoof configuration */
13348 /* Common result structure for vf mac anti spoof */
13349 struct cmd_vf_mac_anti_spoof_result {
13350 cmdline_fixed_string_t set;
13351 cmdline_fixed_string_t vf;
13352 cmdline_fixed_string_t mac;
13353 cmdline_fixed_string_t antispoof;
13356 cmdline_fixed_string_t on_off;
13359 /* Common CLI fields for vf mac anti spoof enable disable */
13360 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13361 TOKEN_STRING_INITIALIZER
13362 (struct cmd_vf_mac_anti_spoof_result,
13364 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13365 TOKEN_STRING_INITIALIZER
13366 (struct cmd_vf_mac_anti_spoof_result,
13368 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13369 TOKEN_STRING_INITIALIZER
13370 (struct cmd_vf_mac_anti_spoof_result,
13372 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13373 TOKEN_STRING_INITIALIZER
13374 (struct cmd_vf_mac_anti_spoof_result,
13375 antispoof, "antispoof");
13376 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13377 TOKEN_NUM_INITIALIZER
13378 (struct cmd_vf_mac_anti_spoof_result,
13380 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13381 TOKEN_NUM_INITIALIZER
13382 (struct cmd_vf_mac_anti_spoof_result,
13384 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13385 TOKEN_STRING_INITIALIZER
13386 (struct cmd_vf_mac_anti_spoof_result,
13390 cmd_set_vf_mac_anti_spoof_parsed(
13391 void *parsed_result,
13392 __attribute__((unused)) struct cmdline *cl,
13393 __attribute__((unused)) void *data)
13395 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13396 int ret = -ENOTSUP;
13398 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13400 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13403 #ifdef RTE_LIBRTE_IXGBE_PMD
13404 if (ret == -ENOTSUP)
13405 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13406 res->vf_id, is_on);
13408 #ifdef RTE_LIBRTE_I40E_PMD
13409 if (ret == -ENOTSUP)
13410 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13411 res->vf_id, is_on);
13413 #ifdef RTE_LIBRTE_BNXT_PMD
13414 if (ret == -ENOTSUP)
13415 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13416 res->vf_id, is_on);
13423 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13426 printf("invalid port_id %d\n", res->port_id);
13429 printf("function not implemented\n");
13432 printf("programming error: (%s)\n", strerror(-ret));
13436 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13437 .f = cmd_set_vf_mac_anti_spoof_parsed,
13439 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13441 (void *)&cmd_vf_mac_anti_spoof_set,
13442 (void *)&cmd_vf_mac_anti_spoof_vf,
13443 (void *)&cmd_vf_mac_anti_spoof_mac,
13444 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13445 (void *)&cmd_vf_mac_anti_spoof_port_id,
13446 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13447 (void *)&cmd_vf_mac_anti_spoof_on_off,
13452 /* vf vlan strip queue configuration */
13454 /* Common result structure for vf mac anti spoof */
13455 struct cmd_vf_vlan_stripq_result {
13456 cmdline_fixed_string_t set;
13457 cmdline_fixed_string_t vf;
13458 cmdline_fixed_string_t vlan;
13459 cmdline_fixed_string_t stripq;
13462 cmdline_fixed_string_t on_off;
13465 /* Common CLI fields for vf vlan strip enable disable */
13466 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13467 TOKEN_STRING_INITIALIZER
13468 (struct cmd_vf_vlan_stripq_result,
13470 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13471 TOKEN_STRING_INITIALIZER
13472 (struct cmd_vf_vlan_stripq_result,
13474 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13475 TOKEN_STRING_INITIALIZER
13476 (struct cmd_vf_vlan_stripq_result,
13478 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13479 TOKEN_STRING_INITIALIZER
13480 (struct cmd_vf_vlan_stripq_result,
13482 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13483 TOKEN_NUM_INITIALIZER
13484 (struct cmd_vf_vlan_stripq_result,
13486 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13487 TOKEN_NUM_INITIALIZER
13488 (struct cmd_vf_vlan_stripq_result,
13490 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13491 TOKEN_STRING_INITIALIZER
13492 (struct cmd_vf_vlan_stripq_result,
13496 cmd_set_vf_vlan_stripq_parsed(
13497 void *parsed_result,
13498 __attribute__((unused)) struct cmdline *cl,
13499 __attribute__((unused)) void *data)
13501 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13502 int ret = -ENOTSUP;
13504 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13506 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13509 #ifdef RTE_LIBRTE_IXGBE_PMD
13510 if (ret == -ENOTSUP)
13511 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13512 res->vf_id, is_on);
13514 #ifdef RTE_LIBRTE_I40E_PMD
13515 if (ret == -ENOTSUP)
13516 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13517 res->vf_id, is_on);
13519 #ifdef RTE_LIBRTE_BNXT_PMD
13520 if (ret == -ENOTSUP)
13521 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13522 res->vf_id, is_on);
13529 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13532 printf("invalid port_id %d\n", res->port_id);
13535 printf("function not implemented\n");
13538 printf("programming error: (%s)\n", strerror(-ret));
13542 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13543 .f = cmd_set_vf_vlan_stripq_parsed,
13545 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13547 (void *)&cmd_vf_vlan_stripq_set,
13548 (void *)&cmd_vf_vlan_stripq_vf,
13549 (void *)&cmd_vf_vlan_stripq_vlan,
13550 (void *)&cmd_vf_vlan_stripq_stripq,
13551 (void *)&cmd_vf_vlan_stripq_port_id,
13552 (void *)&cmd_vf_vlan_stripq_vf_id,
13553 (void *)&cmd_vf_vlan_stripq_on_off,
13558 /* vf vlan insert configuration */
13560 /* Common result structure for vf vlan insert */
13561 struct cmd_vf_vlan_insert_result {
13562 cmdline_fixed_string_t set;
13563 cmdline_fixed_string_t vf;
13564 cmdline_fixed_string_t vlan;
13565 cmdline_fixed_string_t insert;
13571 /* Common CLI fields for vf vlan insert enable disable */
13572 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13573 TOKEN_STRING_INITIALIZER
13574 (struct cmd_vf_vlan_insert_result,
13576 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13577 TOKEN_STRING_INITIALIZER
13578 (struct cmd_vf_vlan_insert_result,
13580 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13581 TOKEN_STRING_INITIALIZER
13582 (struct cmd_vf_vlan_insert_result,
13584 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13585 TOKEN_STRING_INITIALIZER
13586 (struct cmd_vf_vlan_insert_result,
13588 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13589 TOKEN_NUM_INITIALIZER
13590 (struct cmd_vf_vlan_insert_result,
13592 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13593 TOKEN_NUM_INITIALIZER
13594 (struct cmd_vf_vlan_insert_result,
13596 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13597 TOKEN_NUM_INITIALIZER
13598 (struct cmd_vf_vlan_insert_result,
13602 cmd_set_vf_vlan_insert_parsed(
13603 void *parsed_result,
13604 __attribute__((unused)) struct cmdline *cl,
13605 __attribute__((unused)) void *data)
13607 struct cmd_vf_vlan_insert_result *res = parsed_result;
13608 int ret = -ENOTSUP;
13610 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13613 #ifdef RTE_LIBRTE_IXGBE_PMD
13614 if (ret == -ENOTSUP)
13615 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13618 #ifdef RTE_LIBRTE_I40E_PMD
13619 if (ret == -ENOTSUP)
13620 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13623 #ifdef RTE_LIBRTE_BNXT_PMD
13624 if (ret == -ENOTSUP)
13625 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13633 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13636 printf("invalid port_id %d\n", res->port_id);
13639 printf("function not implemented\n");
13642 printf("programming error: (%s)\n", strerror(-ret));
13646 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13647 .f = cmd_set_vf_vlan_insert_parsed,
13649 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13651 (void *)&cmd_vf_vlan_insert_set,
13652 (void *)&cmd_vf_vlan_insert_vf,
13653 (void *)&cmd_vf_vlan_insert_vlan,
13654 (void *)&cmd_vf_vlan_insert_insert,
13655 (void *)&cmd_vf_vlan_insert_port_id,
13656 (void *)&cmd_vf_vlan_insert_vf_id,
13657 (void *)&cmd_vf_vlan_insert_vlan_id,
13662 /* tx loopback configuration */
13664 /* Common result structure for tx loopback */
13665 struct cmd_tx_loopback_result {
13666 cmdline_fixed_string_t set;
13667 cmdline_fixed_string_t tx;
13668 cmdline_fixed_string_t loopback;
13670 cmdline_fixed_string_t on_off;
13673 /* Common CLI fields for tx loopback enable disable */
13674 cmdline_parse_token_string_t cmd_tx_loopback_set =
13675 TOKEN_STRING_INITIALIZER
13676 (struct cmd_tx_loopback_result,
13678 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13679 TOKEN_STRING_INITIALIZER
13680 (struct cmd_tx_loopback_result,
13682 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13683 TOKEN_STRING_INITIALIZER
13684 (struct cmd_tx_loopback_result,
13685 loopback, "loopback");
13686 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13687 TOKEN_NUM_INITIALIZER
13688 (struct cmd_tx_loopback_result,
13690 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13691 TOKEN_STRING_INITIALIZER
13692 (struct cmd_tx_loopback_result,
13696 cmd_set_tx_loopback_parsed(
13697 void *parsed_result,
13698 __attribute__((unused)) struct cmdline *cl,
13699 __attribute__((unused)) void *data)
13701 struct cmd_tx_loopback_result *res = parsed_result;
13702 int ret = -ENOTSUP;
13704 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13706 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13709 #ifdef RTE_LIBRTE_IXGBE_PMD
13710 if (ret == -ENOTSUP)
13711 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13713 #ifdef RTE_LIBRTE_I40E_PMD
13714 if (ret == -ENOTSUP)
13715 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13717 #ifdef RTE_LIBRTE_BNXT_PMD
13718 if (ret == -ENOTSUP)
13719 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13721 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13722 if (ret == -ENOTSUP)
13723 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13730 printf("invalid is_on %d\n", is_on);
13733 printf("invalid port_id %d\n", res->port_id);
13736 printf("function not implemented\n");
13739 printf("programming error: (%s)\n", strerror(-ret));
13743 cmdline_parse_inst_t cmd_set_tx_loopback = {
13744 .f = cmd_set_tx_loopback_parsed,
13746 .help_str = "set tx loopback <port_id> on|off",
13748 (void *)&cmd_tx_loopback_set,
13749 (void *)&cmd_tx_loopback_tx,
13750 (void *)&cmd_tx_loopback_loopback,
13751 (void *)&cmd_tx_loopback_port_id,
13752 (void *)&cmd_tx_loopback_on_off,
13757 /* all queues drop enable configuration */
13759 /* Common result structure for all queues drop enable */
13760 struct cmd_all_queues_drop_en_result {
13761 cmdline_fixed_string_t set;
13762 cmdline_fixed_string_t all;
13763 cmdline_fixed_string_t queues;
13764 cmdline_fixed_string_t drop;
13766 cmdline_fixed_string_t on_off;
13769 /* Common CLI fields for tx loopback enable disable */
13770 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13771 TOKEN_STRING_INITIALIZER
13772 (struct cmd_all_queues_drop_en_result,
13774 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13775 TOKEN_STRING_INITIALIZER
13776 (struct cmd_all_queues_drop_en_result,
13778 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13779 TOKEN_STRING_INITIALIZER
13780 (struct cmd_all_queues_drop_en_result,
13782 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13783 TOKEN_STRING_INITIALIZER
13784 (struct cmd_all_queues_drop_en_result,
13786 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13787 TOKEN_NUM_INITIALIZER
13788 (struct cmd_all_queues_drop_en_result,
13790 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13791 TOKEN_STRING_INITIALIZER
13792 (struct cmd_all_queues_drop_en_result,
13796 cmd_set_all_queues_drop_en_parsed(
13797 void *parsed_result,
13798 __attribute__((unused)) struct cmdline *cl,
13799 __attribute__((unused)) void *data)
13801 struct cmd_all_queues_drop_en_result *res = parsed_result;
13802 int ret = -ENOTSUP;
13803 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13805 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13808 #ifdef RTE_LIBRTE_IXGBE_PMD
13809 if (ret == -ENOTSUP)
13810 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13812 #ifdef RTE_LIBRTE_BNXT_PMD
13813 if (ret == -ENOTSUP)
13814 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13820 printf("invalid is_on %d\n", is_on);
13823 printf("invalid port_id %d\n", res->port_id);
13826 printf("function not implemented\n");
13829 printf("programming error: (%s)\n", strerror(-ret));
13833 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13834 .f = cmd_set_all_queues_drop_en_parsed,
13836 .help_str = "set all queues drop <port_id> on|off",
13838 (void *)&cmd_all_queues_drop_en_set,
13839 (void *)&cmd_all_queues_drop_en_all,
13840 (void *)&cmd_all_queues_drop_en_queues,
13841 (void *)&cmd_all_queues_drop_en_drop,
13842 (void *)&cmd_all_queues_drop_en_port_id,
13843 (void *)&cmd_all_queues_drop_en_on_off,
13848 /* vf split drop enable configuration */
13850 /* Common result structure for vf split drop enable */
13851 struct cmd_vf_split_drop_en_result {
13852 cmdline_fixed_string_t set;
13853 cmdline_fixed_string_t vf;
13854 cmdline_fixed_string_t split;
13855 cmdline_fixed_string_t drop;
13858 cmdline_fixed_string_t on_off;
13861 /* Common CLI fields for vf split drop enable disable */
13862 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13863 TOKEN_STRING_INITIALIZER
13864 (struct cmd_vf_split_drop_en_result,
13866 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13867 TOKEN_STRING_INITIALIZER
13868 (struct cmd_vf_split_drop_en_result,
13870 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13871 TOKEN_STRING_INITIALIZER
13872 (struct cmd_vf_split_drop_en_result,
13874 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13875 TOKEN_STRING_INITIALIZER
13876 (struct cmd_vf_split_drop_en_result,
13878 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13879 TOKEN_NUM_INITIALIZER
13880 (struct cmd_vf_split_drop_en_result,
13882 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13883 TOKEN_NUM_INITIALIZER
13884 (struct cmd_vf_split_drop_en_result,
13886 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13887 TOKEN_STRING_INITIALIZER
13888 (struct cmd_vf_split_drop_en_result,
13892 cmd_set_vf_split_drop_en_parsed(
13893 void *parsed_result,
13894 __attribute__((unused)) struct cmdline *cl,
13895 __attribute__((unused)) void *data)
13897 struct cmd_vf_split_drop_en_result *res = parsed_result;
13898 int ret = -ENOTSUP;
13899 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13901 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13904 #ifdef RTE_LIBRTE_IXGBE_PMD
13905 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13912 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13915 printf("invalid port_id %d\n", res->port_id);
13918 printf("not supported on port %d\n", res->port_id);
13921 printf("programming error: (%s)\n", strerror(-ret));
13925 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13926 .f = cmd_set_vf_split_drop_en_parsed,
13928 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13930 (void *)&cmd_vf_split_drop_en_set,
13931 (void *)&cmd_vf_split_drop_en_vf,
13932 (void *)&cmd_vf_split_drop_en_split,
13933 (void *)&cmd_vf_split_drop_en_drop,
13934 (void *)&cmd_vf_split_drop_en_port_id,
13935 (void *)&cmd_vf_split_drop_en_vf_id,
13936 (void *)&cmd_vf_split_drop_en_on_off,
13941 /* vf mac address configuration */
13943 /* Common result structure for vf mac address */
13944 struct cmd_set_vf_mac_addr_result {
13945 cmdline_fixed_string_t set;
13946 cmdline_fixed_string_t vf;
13947 cmdline_fixed_string_t mac;
13948 cmdline_fixed_string_t addr;
13951 struct rte_ether_addr mac_addr;
13955 /* Common CLI fields for vf split drop enable disable */
13956 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13957 TOKEN_STRING_INITIALIZER
13958 (struct cmd_set_vf_mac_addr_result,
13960 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13961 TOKEN_STRING_INITIALIZER
13962 (struct cmd_set_vf_mac_addr_result,
13964 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_set_vf_mac_addr_result,
13968 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13969 TOKEN_STRING_INITIALIZER
13970 (struct cmd_set_vf_mac_addr_result,
13972 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13973 TOKEN_NUM_INITIALIZER
13974 (struct cmd_set_vf_mac_addr_result,
13976 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13977 TOKEN_NUM_INITIALIZER
13978 (struct cmd_set_vf_mac_addr_result,
13980 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13981 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13985 cmd_set_vf_mac_addr_parsed(
13986 void *parsed_result,
13987 __attribute__((unused)) struct cmdline *cl,
13988 __attribute__((unused)) void *data)
13990 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13991 int ret = -ENOTSUP;
13993 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13996 #ifdef RTE_LIBRTE_IXGBE_PMD
13997 if (ret == -ENOTSUP)
13998 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14001 #ifdef RTE_LIBRTE_I40E_PMD
14002 if (ret == -ENOTSUP)
14003 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14006 #ifdef RTE_LIBRTE_BNXT_PMD
14007 if (ret == -ENOTSUP)
14008 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14016 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14019 printf("invalid port_id %d\n", res->port_id);
14022 printf("function not implemented\n");
14025 printf("programming error: (%s)\n", strerror(-ret));
14029 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14030 .f = cmd_set_vf_mac_addr_parsed,
14032 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14034 (void *)&cmd_set_vf_mac_addr_set,
14035 (void *)&cmd_set_vf_mac_addr_vf,
14036 (void *)&cmd_set_vf_mac_addr_mac,
14037 (void *)&cmd_set_vf_mac_addr_addr,
14038 (void *)&cmd_set_vf_mac_addr_port_id,
14039 (void *)&cmd_set_vf_mac_addr_vf_id,
14040 (void *)&cmd_set_vf_mac_addr_mac_addr,
14045 /* MACsec configuration */
14047 /* Common result structure for MACsec offload enable */
14048 struct cmd_macsec_offload_on_result {
14049 cmdline_fixed_string_t set;
14050 cmdline_fixed_string_t macsec;
14051 cmdline_fixed_string_t offload;
14053 cmdline_fixed_string_t on;
14054 cmdline_fixed_string_t encrypt;
14055 cmdline_fixed_string_t en_on_off;
14056 cmdline_fixed_string_t replay_protect;
14057 cmdline_fixed_string_t rp_on_off;
14060 /* Common CLI fields for MACsec offload disable */
14061 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14062 TOKEN_STRING_INITIALIZER
14063 (struct cmd_macsec_offload_on_result,
14065 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14066 TOKEN_STRING_INITIALIZER
14067 (struct cmd_macsec_offload_on_result,
14069 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14070 TOKEN_STRING_INITIALIZER
14071 (struct cmd_macsec_offload_on_result,
14072 offload, "offload");
14073 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14074 TOKEN_NUM_INITIALIZER
14075 (struct cmd_macsec_offload_on_result,
14077 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14078 TOKEN_STRING_INITIALIZER
14079 (struct cmd_macsec_offload_on_result,
14081 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14082 TOKEN_STRING_INITIALIZER
14083 (struct cmd_macsec_offload_on_result,
14084 encrypt, "encrypt");
14085 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14086 TOKEN_STRING_INITIALIZER
14087 (struct cmd_macsec_offload_on_result,
14088 en_on_off, "on#off");
14089 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14090 TOKEN_STRING_INITIALIZER
14091 (struct cmd_macsec_offload_on_result,
14092 replay_protect, "replay-protect");
14093 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14094 TOKEN_STRING_INITIALIZER
14095 (struct cmd_macsec_offload_on_result,
14096 rp_on_off, "on#off");
14099 cmd_set_macsec_offload_on_parsed(
14100 void *parsed_result,
14101 __attribute__((unused)) struct cmdline *cl,
14102 __attribute__((unused)) void *data)
14104 struct cmd_macsec_offload_on_result *res = parsed_result;
14105 int ret = -ENOTSUP;
14106 portid_t port_id = res->port_id;
14107 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14108 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14109 struct rte_eth_dev_info dev_info;
14111 if (port_id_is_invalid(port_id, ENABLED_WARN))
14113 if (!port_is_stopped(port_id)) {
14114 printf("Please stop port %d first\n", port_id);
14118 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14122 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14123 #ifdef RTE_LIBRTE_IXGBE_PMD
14124 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14132 ports[port_id].dev_conf.txmode.offloads |=
14133 DEV_TX_OFFLOAD_MACSEC_INSERT;
14134 cmd_reconfig_device_queue(port_id, 1, 1);
14137 printf("invalid port_id %d\n", port_id);
14140 printf("not supported on port %d\n", port_id);
14143 printf("programming error: (%s)\n", strerror(-ret));
14147 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14148 .f = cmd_set_macsec_offload_on_parsed,
14150 .help_str = "set macsec offload <port_id> on "
14151 "encrypt on|off replay-protect on|off",
14153 (void *)&cmd_macsec_offload_on_set,
14154 (void *)&cmd_macsec_offload_on_macsec,
14155 (void *)&cmd_macsec_offload_on_offload,
14156 (void *)&cmd_macsec_offload_on_port_id,
14157 (void *)&cmd_macsec_offload_on_on,
14158 (void *)&cmd_macsec_offload_on_encrypt,
14159 (void *)&cmd_macsec_offload_on_en_on_off,
14160 (void *)&cmd_macsec_offload_on_replay_protect,
14161 (void *)&cmd_macsec_offload_on_rp_on_off,
14166 /* Common result structure for MACsec offload disable */
14167 struct cmd_macsec_offload_off_result {
14168 cmdline_fixed_string_t set;
14169 cmdline_fixed_string_t macsec;
14170 cmdline_fixed_string_t offload;
14172 cmdline_fixed_string_t off;
14175 /* Common CLI fields for MACsec offload disable */
14176 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14177 TOKEN_STRING_INITIALIZER
14178 (struct cmd_macsec_offload_off_result,
14180 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14181 TOKEN_STRING_INITIALIZER
14182 (struct cmd_macsec_offload_off_result,
14184 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14185 TOKEN_STRING_INITIALIZER
14186 (struct cmd_macsec_offload_off_result,
14187 offload, "offload");
14188 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14189 TOKEN_NUM_INITIALIZER
14190 (struct cmd_macsec_offload_off_result,
14192 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14193 TOKEN_STRING_INITIALIZER
14194 (struct cmd_macsec_offload_off_result,
14198 cmd_set_macsec_offload_off_parsed(
14199 void *parsed_result,
14200 __attribute__((unused)) struct cmdline *cl,
14201 __attribute__((unused)) void *data)
14203 struct cmd_macsec_offload_off_result *res = parsed_result;
14204 int ret = -ENOTSUP;
14205 struct rte_eth_dev_info dev_info;
14206 portid_t port_id = res->port_id;
14208 if (port_id_is_invalid(port_id, ENABLED_WARN))
14210 if (!port_is_stopped(port_id)) {
14211 printf("Please stop port %d first\n", port_id);
14215 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14219 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14220 #ifdef RTE_LIBRTE_IXGBE_PMD
14221 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14226 ports[port_id].dev_conf.txmode.offloads &=
14227 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14228 cmd_reconfig_device_queue(port_id, 1, 1);
14231 printf("invalid port_id %d\n", port_id);
14234 printf("not supported on port %d\n", port_id);
14237 printf("programming error: (%s)\n", strerror(-ret));
14241 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14242 .f = cmd_set_macsec_offload_off_parsed,
14244 .help_str = "set macsec offload <port_id> off",
14246 (void *)&cmd_macsec_offload_off_set,
14247 (void *)&cmd_macsec_offload_off_macsec,
14248 (void *)&cmd_macsec_offload_off_offload,
14249 (void *)&cmd_macsec_offload_off_port_id,
14250 (void *)&cmd_macsec_offload_off_off,
14255 /* Common result structure for MACsec secure connection configure */
14256 struct cmd_macsec_sc_result {
14257 cmdline_fixed_string_t set;
14258 cmdline_fixed_string_t macsec;
14259 cmdline_fixed_string_t sc;
14260 cmdline_fixed_string_t tx_rx;
14262 struct rte_ether_addr mac;
14266 /* Common CLI fields for MACsec secure connection configure */
14267 cmdline_parse_token_string_t cmd_macsec_sc_set =
14268 TOKEN_STRING_INITIALIZER
14269 (struct cmd_macsec_sc_result,
14271 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14272 TOKEN_STRING_INITIALIZER
14273 (struct cmd_macsec_sc_result,
14275 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14276 TOKEN_STRING_INITIALIZER
14277 (struct cmd_macsec_sc_result,
14279 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14280 TOKEN_STRING_INITIALIZER
14281 (struct cmd_macsec_sc_result,
14283 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14284 TOKEN_NUM_INITIALIZER
14285 (struct cmd_macsec_sc_result,
14287 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14288 TOKEN_ETHERADDR_INITIALIZER
14289 (struct cmd_macsec_sc_result,
14291 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14292 TOKEN_NUM_INITIALIZER
14293 (struct cmd_macsec_sc_result,
14297 cmd_set_macsec_sc_parsed(
14298 void *parsed_result,
14299 __attribute__((unused)) struct cmdline *cl,
14300 __attribute__((unused)) void *data)
14302 struct cmd_macsec_sc_result *res = parsed_result;
14303 int ret = -ENOTSUP;
14304 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14306 #ifdef RTE_LIBRTE_IXGBE_PMD
14308 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14309 res->mac.addr_bytes) :
14310 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14311 res->mac.addr_bytes, res->pi);
14313 RTE_SET_USED(is_tx);
14319 printf("invalid port_id %d\n", res->port_id);
14322 printf("not supported on port %d\n", res->port_id);
14325 printf("programming error: (%s)\n", strerror(-ret));
14329 cmdline_parse_inst_t cmd_set_macsec_sc = {
14330 .f = cmd_set_macsec_sc_parsed,
14332 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14334 (void *)&cmd_macsec_sc_set,
14335 (void *)&cmd_macsec_sc_macsec,
14336 (void *)&cmd_macsec_sc_sc,
14337 (void *)&cmd_macsec_sc_tx_rx,
14338 (void *)&cmd_macsec_sc_port_id,
14339 (void *)&cmd_macsec_sc_mac,
14340 (void *)&cmd_macsec_sc_pi,
14345 /* Common result structure for MACsec secure connection configure */
14346 struct cmd_macsec_sa_result {
14347 cmdline_fixed_string_t set;
14348 cmdline_fixed_string_t macsec;
14349 cmdline_fixed_string_t sa;
14350 cmdline_fixed_string_t tx_rx;
14355 cmdline_fixed_string_t key;
14358 /* Common CLI fields for MACsec secure connection configure */
14359 cmdline_parse_token_string_t cmd_macsec_sa_set =
14360 TOKEN_STRING_INITIALIZER
14361 (struct cmd_macsec_sa_result,
14363 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14364 TOKEN_STRING_INITIALIZER
14365 (struct cmd_macsec_sa_result,
14367 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14368 TOKEN_STRING_INITIALIZER
14369 (struct cmd_macsec_sa_result,
14371 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14372 TOKEN_STRING_INITIALIZER
14373 (struct cmd_macsec_sa_result,
14375 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14376 TOKEN_NUM_INITIALIZER
14377 (struct cmd_macsec_sa_result,
14379 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14380 TOKEN_NUM_INITIALIZER
14381 (struct cmd_macsec_sa_result,
14383 cmdline_parse_token_num_t cmd_macsec_sa_an =
14384 TOKEN_NUM_INITIALIZER
14385 (struct cmd_macsec_sa_result,
14387 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14388 TOKEN_NUM_INITIALIZER
14389 (struct cmd_macsec_sa_result,
14391 cmdline_parse_token_string_t cmd_macsec_sa_key =
14392 TOKEN_STRING_INITIALIZER
14393 (struct cmd_macsec_sa_result,
14397 cmd_set_macsec_sa_parsed(
14398 void *parsed_result,
14399 __attribute__((unused)) struct cmdline *cl,
14400 __attribute__((unused)) void *data)
14402 struct cmd_macsec_sa_result *res = parsed_result;
14403 int ret = -ENOTSUP;
14404 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14405 uint8_t key[16] = { 0 };
14411 key_len = strlen(res->key) / 2;
14415 for (i = 0; i < key_len; i++) {
14416 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14419 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14422 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14425 #ifdef RTE_LIBRTE_IXGBE_PMD
14427 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14428 res->idx, res->an, res->pn, key) :
14429 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14430 res->idx, res->an, res->pn, key);
14432 RTE_SET_USED(is_tx);
14439 printf("invalid idx %d or an %d\n", res->idx, res->an);
14442 printf("invalid port_id %d\n", res->port_id);
14445 printf("not supported on port %d\n", res->port_id);
14448 printf("programming error: (%s)\n", strerror(-ret));
14452 cmdline_parse_inst_t cmd_set_macsec_sa = {
14453 .f = cmd_set_macsec_sa_parsed,
14455 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14457 (void *)&cmd_macsec_sa_set,
14458 (void *)&cmd_macsec_sa_macsec,
14459 (void *)&cmd_macsec_sa_sa,
14460 (void *)&cmd_macsec_sa_tx_rx,
14461 (void *)&cmd_macsec_sa_port_id,
14462 (void *)&cmd_macsec_sa_idx,
14463 (void *)&cmd_macsec_sa_an,
14464 (void *)&cmd_macsec_sa_pn,
14465 (void *)&cmd_macsec_sa_key,
14470 /* VF unicast promiscuous mode configuration */
14472 /* Common result structure for VF unicast promiscuous mode */
14473 struct cmd_vf_promisc_result {
14474 cmdline_fixed_string_t set;
14475 cmdline_fixed_string_t vf;
14476 cmdline_fixed_string_t promisc;
14479 cmdline_fixed_string_t on_off;
14482 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14483 cmdline_parse_token_string_t cmd_vf_promisc_set =
14484 TOKEN_STRING_INITIALIZER
14485 (struct cmd_vf_promisc_result,
14487 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14488 TOKEN_STRING_INITIALIZER
14489 (struct cmd_vf_promisc_result,
14491 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14492 TOKEN_STRING_INITIALIZER
14493 (struct cmd_vf_promisc_result,
14494 promisc, "promisc");
14495 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14496 TOKEN_NUM_INITIALIZER
14497 (struct cmd_vf_promisc_result,
14499 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14500 TOKEN_NUM_INITIALIZER
14501 (struct cmd_vf_promisc_result,
14503 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14504 TOKEN_STRING_INITIALIZER
14505 (struct cmd_vf_promisc_result,
14509 cmd_set_vf_promisc_parsed(
14510 void *parsed_result,
14511 __attribute__((unused)) struct cmdline *cl,
14512 __attribute__((unused)) void *data)
14514 struct cmd_vf_promisc_result *res = parsed_result;
14515 int ret = -ENOTSUP;
14517 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14519 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14522 #ifdef RTE_LIBRTE_I40E_PMD
14523 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14524 res->vf_id, is_on);
14531 printf("invalid vf_id %d\n", res->vf_id);
14534 printf("invalid port_id %d\n", res->port_id);
14537 printf("function not implemented\n");
14540 printf("programming error: (%s)\n", strerror(-ret));
14544 cmdline_parse_inst_t cmd_set_vf_promisc = {
14545 .f = cmd_set_vf_promisc_parsed,
14547 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14548 "Set unicast promiscuous mode for a VF from the PF",
14550 (void *)&cmd_vf_promisc_set,
14551 (void *)&cmd_vf_promisc_vf,
14552 (void *)&cmd_vf_promisc_promisc,
14553 (void *)&cmd_vf_promisc_port_id,
14554 (void *)&cmd_vf_promisc_vf_id,
14555 (void *)&cmd_vf_promisc_on_off,
14560 /* VF multicast promiscuous mode configuration */
14562 /* Common result structure for VF multicast promiscuous mode */
14563 struct cmd_vf_allmulti_result {
14564 cmdline_fixed_string_t set;
14565 cmdline_fixed_string_t vf;
14566 cmdline_fixed_string_t allmulti;
14569 cmdline_fixed_string_t on_off;
14572 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14573 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14574 TOKEN_STRING_INITIALIZER
14575 (struct cmd_vf_allmulti_result,
14577 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14578 TOKEN_STRING_INITIALIZER
14579 (struct cmd_vf_allmulti_result,
14581 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14582 TOKEN_STRING_INITIALIZER
14583 (struct cmd_vf_allmulti_result,
14584 allmulti, "allmulti");
14585 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14586 TOKEN_NUM_INITIALIZER
14587 (struct cmd_vf_allmulti_result,
14589 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14590 TOKEN_NUM_INITIALIZER
14591 (struct cmd_vf_allmulti_result,
14593 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14594 TOKEN_STRING_INITIALIZER
14595 (struct cmd_vf_allmulti_result,
14599 cmd_set_vf_allmulti_parsed(
14600 void *parsed_result,
14601 __attribute__((unused)) struct cmdline *cl,
14602 __attribute__((unused)) void *data)
14604 struct cmd_vf_allmulti_result *res = parsed_result;
14605 int ret = -ENOTSUP;
14607 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14609 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14612 #ifdef RTE_LIBRTE_I40E_PMD
14613 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14614 res->vf_id, is_on);
14621 printf("invalid vf_id %d\n", res->vf_id);
14624 printf("invalid port_id %d\n", res->port_id);
14627 printf("function not implemented\n");
14630 printf("programming error: (%s)\n", strerror(-ret));
14634 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14635 .f = cmd_set_vf_allmulti_parsed,
14637 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14638 "Set multicast promiscuous mode for a VF from the PF",
14640 (void *)&cmd_vf_allmulti_set,
14641 (void *)&cmd_vf_allmulti_vf,
14642 (void *)&cmd_vf_allmulti_allmulti,
14643 (void *)&cmd_vf_allmulti_port_id,
14644 (void *)&cmd_vf_allmulti_vf_id,
14645 (void *)&cmd_vf_allmulti_on_off,
14650 /* vf broadcast mode configuration */
14652 /* Common result structure for vf broadcast */
14653 struct cmd_set_vf_broadcast_result {
14654 cmdline_fixed_string_t set;
14655 cmdline_fixed_string_t vf;
14656 cmdline_fixed_string_t broadcast;
14659 cmdline_fixed_string_t on_off;
14662 /* Common CLI fields for vf broadcast enable disable */
14663 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14664 TOKEN_STRING_INITIALIZER
14665 (struct cmd_set_vf_broadcast_result,
14667 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14668 TOKEN_STRING_INITIALIZER
14669 (struct cmd_set_vf_broadcast_result,
14671 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14672 TOKEN_STRING_INITIALIZER
14673 (struct cmd_set_vf_broadcast_result,
14674 broadcast, "broadcast");
14675 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14676 TOKEN_NUM_INITIALIZER
14677 (struct cmd_set_vf_broadcast_result,
14679 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14680 TOKEN_NUM_INITIALIZER
14681 (struct cmd_set_vf_broadcast_result,
14683 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14684 TOKEN_STRING_INITIALIZER
14685 (struct cmd_set_vf_broadcast_result,
14689 cmd_set_vf_broadcast_parsed(
14690 void *parsed_result,
14691 __attribute__((unused)) struct cmdline *cl,
14692 __attribute__((unused)) void *data)
14694 struct cmd_set_vf_broadcast_result *res = parsed_result;
14695 int ret = -ENOTSUP;
14697 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14702 #ifdef RTE_LIBRTE_I40E_PMD
14703 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14704 res->vf_id, is_on);
14711 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14714 printf("invalid port_id %d\n", res->port_id);
14717 printf("function not implemented\n");
14720 printf("programming error: (%s)\n", strerror(-ret));
14724 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14725 .f = cmd_set_vf_broadcast_parsed,
14727 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14729 (void *)&cmd_set_vf_broadcast_set,
14730 (void *)&cmd_set_vf_broadcast_vf,
14731 (void *)&cmd_set_vf_broadcast_broadcast,
14732 (void *)&cmd_set_vf_broadcast_port_id,
14733 (void *)&cmd_set_vf_broadcast_vf_id,
14734 (void *)&cmd_set_vf_broadcast_on_off,
14739 /* vf vlan tag configuration */
14741 /* Common result structure for vf vlan tag */
14742 struct cmd_set_vf_vlan_tag_result {
14743 cmdline_fixed_string_t set;
14744 cmdline_fixed_string_t vf;
14745 cmdline_fixed_string_t vlan;
14746 cmdline_fixed_string_t tag;
14749 cmdline_fixed_string_t on_off;
14752 /* Common CLI fields for vf vlan tag enable disable */
14753 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14754 TOKEN_STRING_INITIALIZER
14755 (struct cmd_set_vf_vlan_tag_result,
14757 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14758 TOKEN_STRING_INITIALIZER
14759 (struct cmd_set_vf_vlan_tag_result,
14761 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14762 TOKEN_STRING_INITIALIZER
14763 (struct cmd_set_vf_vlan_tag_result,
14765 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14766 TOKEN_STRING_INITIALIZER
14767 (struct cmd_set_vf_vlan_tag_result,
14769 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14770 TOKEN_NUM_INITIALIZER
14771 (struct cmd_set_vf_vlan_tag_result,
14773 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14774 TOKEN_NUM_INITIALIZER
14775 (struct cmd_set_vf_vlan_tag_result,
14777 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14778 TOKEN_STRING_INITIALIZER
14779 (struct cmd_set_vf_vlan_tag_result,
14783 cmd_set_vf_vlan_tag_parsed(
14784 void *parsed_result,
14785 __attribute__((unused)) struct cmdline *cl,
14786 __attribute__((unused)) void *data)
14788 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14789 int ret = -ENOTSUP;
14791 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14793 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14796 #ifdef RTE_LIBRTE_I40E_PMD
14797 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14798 res->vf_id, is_on);
14805 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14808 printf("invalid port_id %d\n", res->port_id);
14811 printf("function not implemented\n");
14814 printf("programming error: (%s)\n", strerror(-ret));
14818 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14819 .f = cmd_set_vf_vlan_tag_parsed,
14821 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14823 (void *)&cmd_set_vf_vlan_tag_set,
14824 (void *)&cmd_set_vf_vlan_tag_vf,
14825 (void *)&cmd_set_vf_vlan_tag_vlan,
14826 (void *)&cmd_set_vf_vlan_tag_tag,
14827 (void *)&cmd_set_vf_vlan_tag_port_id,
14828 (void *)&cmd_set_vf_vlan_tag_vf_id,
14829 (void *)&cmd_set_vf_vlan_tag_on_off,
14834 /* Common definition of VF and TC TX bandwidth configuration */
14835 struct cmd_vf_tc_bw_result {
14836 cmdline_fixed_string_t set;
14837 cmdline_fixed_string_t vf;
14838 cmdline_fixed_string_t tc;
14839 cmdline_fixed_string_t tx;
14840 cmdline_fixed_string_t min_bw;
14841 cmdline_fixed_string_t max_bw;
14842 cmdline_fixed_string_t strict_link_prio;
14847 cmdline_fixed_string_t bw_list;
14851 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14852 TOKEN_STRING_INITIALIZER
14853 (struct cmd_vf_tc_bw_result,
14855 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14856 TOKEN_STRING_INITIALIZER
14857 (struct cmd_vf_tc_bw_result,
14859 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14860 TOKEN_STRING_INITIALIZER
14861 (struct cmd_vf_tc_bw_result,
14863 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14864 TOKEN_STRING_INITIALIZER
14865 (struct cmd_vf_tc_bw_result,
14867 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14868 TOKEN_STRING_INITIALIZER
14869 (struct cmd_vf_tc_bw_result,
14870 strict_link_prio, "strict-link-priority");
14871 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14872 TOKEN_STRING_INITIALIZER
14873 (struct cmd_vf_tc_bw_result,
14874 min_bw, "min-bandwidth");
14875 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14876 TOKEN_STRING_INITIALIZER
14877 (struct cmd_vf_tc_bw_result,
14878 max_bw, "max-bandwidth");
14879 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14880 TOKEN_NUM_INITIALIZER
14881 (struct cmd_vf_tc_bw_result,
14883 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14884 TOKEN_NUM_INITIALIZER
14885 (struct cmd_vf_tc_bw_result,
14887 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14888 TOKEN_NUM_INITIALIZER
14889 (struct cmd_vf_tc_bw_result,
14891 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14892 TOKEN_NUM_INITIALIZER
14893 (struct cmd_vf_tc_bw_result,
14895 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14896 TOKEN_STRING_INITIALIZER
14897 (struct cmd_vf_tc_bw_result,
14899 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14900 TOKEN_NUM_INITIALIZER
14901 (struct cmd_vf_tc_bw_result,
14904 /* VF max bandwidth setting */
14906 cmd_vf_max_bw_parsed(
14907 void *parsed_result,
14908 __attribute__((unused)) struct cmdline *cl,
14909 __attribute__((unused)) void *data)
14911 struct cmd_vf_tc_bw_result *res = parsed_result;
14912 int ret = -ENOTSUP;
14914 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14917 #ifdef RTE_LIBRTE_I40E_PMD
14918 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14919 res->vf_id, res->bw);
14926 printf("invalid vf_id %d or bandwidth %d\n",
14927 res->vf_id, res->bw);
14930 printf("invalid port_id %d\n", res->port_id);
14933 printf("function not implemented\n");
14936 printf("programming error: (%s)\n", strerror(-ret));
14940 cmdline_parse_inst_t cmd_vf_max_bw = {
14941 .f = cmd_vf_max_bw_parsed,
14943 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14945 (void *)&cmd_vf_tc_bw_set,
14946 (void *)&cmd_vf_tc_bw_vf,
14947 (void *)&cmd_vf_tc_bw_tx,
14948 (void *)&cmd_vf_tc_bw_max_bw,
14949 (void *)&cmd_vf_tc_bw_port_id,
14950 (void *)&cmd_vf_tc_bw_vf_id,
14951 (void *)&cmd_vf_tc_bw_bw,
14957 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14962 const char *p, *p0 = str;
14969 p = strchr(p0, '(');
14971 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14975 p0 = strchr(p, ')');
14977 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14981 if (size >= sizeof(s)) {
14982 printf("The string size exceeds the internal buffer size\n");
14985 snprintf(s, sizeof(s), "%.*s", size, p);
14986 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14988 printf("Failed to get the bandwidth list. ");
14992 for (i = 0; i < ret; i++)
14993 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14998 /* TC min bandwidth setting */
15000 cmd_vf_tc_min_bw_parsed(
15001 void *parsed_result,
15002 __attribute__((unused)) struct cmdline *cl,
15003 __attribute__((unused)) void *data)
15005 struct cmd_vf_tc_bw_result *res = parsed_result;
15008 int ret = -ENOTSUP;
15010 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15013 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15017 #ifdef RTE_LIBRTE_I40E_PMD
15018 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15026 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15029 printf("invalid port_id %d\n", res->port_id);
15032 printf("function not implemented\n");
15035 printf("programming error: (%s)\n", strerror(-ret));
15039 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15040 .f = cmd_vf_tc_min_bw_parsed,
15042 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15043 " <bw1, bw2, ...>",
15045 (void *)&cmd_vf_tc_bw_set,
15046 (void *)&cmd_vf_tc_bw_vf,
15047 (void *)&cmd_vf_tc_bw_tc,
15048 (void *)&cmd_vf_tc_bw_tx,
15049 (void *)&cmd_vf_tc_bw_min_bw,
15050 (void *)&cmd_vf_tc_bw_port_id,
15051 (void *)&cmd_vf_tc_bw_vf_id,
15052 (void *)&cmd_vf_tc_bw_bw_list,
15058 cmd_tc_min_bw_parsed(
15059 void *parsed_result,
15060 __attribute__((unused)) struct cmdline *cl,
15061 __attribute__((unused)) void *data)
15063 struct cmd_vf_tc_bw_result *res = parsed_result;
15064 struct rte_port *port;
15067 int ret = -ENOTSUP;
15069 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15072 port = &ports[res->port_id];
15073 /** Check if the port is not started **/
15074 if (port->port_status != RTE_PORT_STOPPED) {
15075 printf("Please stop port %d first\n", res->port_id);
15079 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15083 #ifdef RTE_LIBRTE_IXGBE_PMD
15084 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15091 printf("invalid bandwidth\n");
15094 printf("invalid port_id %d\n", res->port_id);
15097 printf("function not implemented\n");
15100 printf("programming error: (%s)\n", strerror(-ret));
15104 cmdline_parse_inst_t cmd_tc_min_bw = {
15105 .f = cmd_tc_min_bw_parsed,
15107 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15109 (void *)&cmd_vf_tc_bw_set,
15110 (void *)&cmd_vf_tc_bw_tc,
15111 (void *)&cmd_vf_tc_bw_tx,
15112 (void *)&cmd_vf_tc_bw_min_bw,
15113 (void *)&cmd_vf_tc_bw_port_id,
15114 (void *)&cmd_vf_tc_bw_bw_list,
15119 /* TC max bandwidth setting */
15121 cmd_vf_tc_max_bw_parsed(
15122 void *parsed_result,
15123 __attribute__((unused)) struct cmdline *cl,
15124 __attribute__((unused)) void *data)
15126 struct cmd_vf_tc_bw_result *res = parsed_result;
15127 int ret = -ENOTSUP;
15129 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15132 #ifdef RTE_LIBRTE_I40E_PMD
15133 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15134 res->tc_no, res->bw);
15141 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15142 res->vf_id, res->tc_no, res->bw);
15145 printf("invalid port_id %d\n", res->port_id);
15148 printf("function not implemented\n");
15151 printf("programming error: (%s)\n", strerror(-ret));
15155 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15156 .f = cmd_vf_tc_max_bw_parsed,
15158 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15161 (void *)&cmd_vf_tc_bw_set,
15162 (void *)&cmd_vf_tc_bw_vf,
15163 (void *)&cmd_vf_tc_bw_tc,
15164 (void *)&cmd_vf_tc_bw_tx,
15165 (void *)&cmd_vf_tc_bw_max_bw,
15166 (void *)&cmd_vf_tc_bw_port_id,
15167 (void *)&cmd_vf_tc_bw_vf_id,
15168 (void *)&cmd_vf_tc_bw_tc_no,
15169 (void *)&cmd_vf_tc_bw_bw,
15175 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15177 /* *** Set Port default Traffic Management Hierarchy *** */
15178 struct cmd_set_port_tm_hierarchy_default_result {
15179 cmdline_fixed_string_t set;
15180 cmdline_fixed_string_t port;
15181 cmdline_fixed_string_t tm;
15182 cmdline_fixed_string_t hierarchy;
15183 cmdline_fixed_string_t def;
15187 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15188 TOKEN_STRING_INITIALIZER(
15189 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15190 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15191 TOKEN_STRING_INITIALIZER(
15192 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15193 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15194 TOKEN_STRING_INITIALIZER(
15195 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15196 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15197 TOKEN_STRING_INITIALIZER(
15198 struct cmd_set_port_tm_hierarchy_default_result,
15199 hierarchy, "hierarchy");
15200 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15201 TOKEN_STRING_INITIALIZER(
15202 struct cmd_set_port_tm_hierarchy_default_result,
15204 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15205 TOKEN_NUM_INITIALIZER(
15206 struct cmd_set_port_tm_hierarchy_default_result,
15209 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15210 __attribute__((unused)) struct cmdline *cl,
15211 __attribute__((unused)) void *data)
15213 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15214 struct rte_port *p;
15215 portid_t port_id = res->port_id;
15217 if (port_id_is_invalid(port_id, ENABLED_WARN))
15220 p = &ports[port_id];
15222 /* Forward mode: tm */
15223 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15224 printf(" softnicfwd mode not enabled(error)\n");
15228 /* Set the default tm hierarchy */
15229 p->softport.default_tm_hierarchy_enable = 1;
15232 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15233 .f = cmd_set_port_tm_hierarchy_default_parsed,
15235 .help_str = "set port tm hierarchy default <port_id>",
15237 (void *)&cmd_set_port_tm_hierarchy_default_set,
15238 (void *)&cmd_set_port_tm_hierarchy_default_port,
15239 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15240 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15241 (void *)&cmd_set_port_tm_hierarchy_default_default,
15242 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15248 /** Set VXLAN encapsulation details */
15249 struct cmd_set_vxlan_result {
15250 cmdline_fixed_string_t set;
15251 cmdline_fixed_string_t vxlan;
15252 cmdline_fixed_string_t pos_token;
15253 cmdline_fixed_string_t ip_version;
15254 uint32_t vlan_present:1;
15258 cmdline_ipaddr_t ip_src;
15259 cmdline_ipaddr_t ip_dst;
15263 struct rte_ether_addr eth_src;
15264 struct rte_ether_addr eth_dst;
15267 cmdline_parse_token_string_t cmd_set_vxlan_set =
15268 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15269 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15270 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15271 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15272 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15274 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15275 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15276 "vxlan-with-vlan");
15277 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15278 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15280 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15281 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15283 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15284 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15286 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15287 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15288 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15289 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15291 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15292 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15293 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15294 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15296 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15297 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15298 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15299 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15301 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15302 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15303 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15304 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15306 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15307 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15308 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15309 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15311 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15312 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15313 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15314 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15316 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15317 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15318 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15319 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15321 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15322 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15323 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15324 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15326 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15327 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15328 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15329 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15331 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15332 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15334 static void cmd_set_vxlan_parsed(void *parsed_result,
15335 __attribute__((unused)) struct cmdline *cl,
15336 __attribute__((unused)) void *data)
15338 struct cmd_set_vxlan_result *res = parsed_result;
15343 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15346 vxlan_encap_conf.select_tos_ttl = 0;
15347 if (strcmp(res->vxlan, "vxlan") == 0)
15348 vxlan_encap_conf.select_vlan = 0;
15349 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15350 vxlan_encap_conf.select_vlan = 1;
15351 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15352 vxlan_encap_conf.select_vlan = 0;
15353 vxlan_encap_conf.select_tos_ttl = 1;
15355 if (strcmp(res->ip_version, "ipv4") == 0)
15356 vxlan_encap_conf.select_ipv4 = 1;
15357 else if (strcmp(res->ip_version, "ipv6") == 0)
15358 vxlan_encap_conf.select_ipv4 = 0;
15361 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15362 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15363 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15364 vxlan_encap_conf.ip_tos = res->tos;
15365 vxlan_encap_conf.ip_ttl = res->ttl;
15366 if (vxlan_encap_conf.select_ipv4) {
15367 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15368 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15370 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15371 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15373 if (vxlan_encap_conf.select_vlan)
15374 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15375 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15376 RTE_ETHER_ADDR_LEN);
15377 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15378 RTE_ETHER_ADDR_LEN);
15381 cmdline_parse_inst_t cmd_set_vxlan = {
15382 .f = cmd_set_vxlan_parsed,
15384 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15385 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15386 " eth-src <eth-src> eth-dst <eth-dst>",
15388 (void *)&cmd_set_vxlan_set,
15389 (void *)&cmd_set_vxlan_vxlan,
15390 (void *)&cmd_set_vxlan_ip_version,
15391 (void *)&cmd_set_vxlan_ip_version_value,
15392 (void *)&cmd_set_vxlan_vni,
15393 (void *)&cmd_set_vxlan_vni_value,
15394 (void *)&cmd_set_vxlan_udp_src,
15395 (void *)&cmd_set_vxlan_udp_src_value,
15396 (void *)&cmd_set_vxlan_udp_dst,
15397 (void *)&cmd_set_vxlan_udp_dst_value,
15398 (void *)&cmd_set_vxlan_ip_src,
15399 (void *)&cmd_set_vxlan_ip_src_value,
15400 (void *)&cmd_set_vxlan_ip_dst,
15401 (void *)&cmd_set_vxlan_ip_dst_value,
15402 (void *)&cmd_set_vxlan_eth_src,
15403 (void *)&cmd_set_vxlan_eth_src_value,
15404 (void *)&cmd_set_vxlan_eth_dst,
15405 (void *)&cmd_set_vxlan_eth_dst_value,
15410 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15411 .f = cmd_set_vxlan_parsed,
15413 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15414 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15415 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15416 " eth-dst <eth-dst>",
15418 (void *)&cmd_set_vxlan_set,
15419 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15420 (void *)&cmd_set_vxlan_ip_version,
15421 (void *)&cmd_set_vxlan_ip_version_value,
15422 (void *)&cmd_set_vxlan_vni,
15423 (void *)&cmd_set_vxlan_vni_value,
15424 (void *)&cmd_set_vxlan_udp_src,
15425 (void *)&cmd_set_vxlan_udp_src_value,
15426 (void *)&cmd_set_vxlan_udp_dst,
15427 (void *)&cmd_set_vxlan_udp_dst_value,
15428 (void *)&cmd_set_vxlan_ip_tos,
15429 (void *)&cmd_set_vxlan_ip_tos_value,
15430 (void *)&cmd_set_vxlan_ip_ttl,
15431 (void *)&cmd_set_vxlan_ip_ttl_value,
15432 (void *)&cmd_set_vxlan_ip_src,
15433 (void *)&cmd_set_vxlan_ip_src_value,
15434 (void *)&cmd_set_vxlan_ip_dst,
15435 (void *)&cmd_set_vxlan_ip_dst_value,
15436 (void *)&cmd_set_vxlan_eth_src,
15437 (void *)&cmd_set_vxlan_eth_src_value,
15438 (void *)&cmd_set_vxlan_eth_dst,
15439 (void *)&cmd_set_vxlan_eth_dst_value,
15444 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15445 .f = cmd_set_vxlan_parsed,
15447 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15448 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15449 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15452 (void *)&cmd_set_vxlan_set,
15453 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15454 (void *)&cmd_set_vxlan_ip_version,
15455 (void *)&cmd_set_vxlan_ip_version_value,
15456 (void *)&cmd_set_vxlan_vni,
15457 (void *)&cmd_set_vxlan_vni_value,
15458 (void *)&cmd_set_vxlan_udp_src,
15459 (void *)&cmd_set_vxlan_udp_src_value,
15460 (void *)&cmd_set_vxlan_udp_dst,
15461 (void *)&cmd_set_vxlan_udp_dst_value,
15462 (void *)&cmd_set_vxlan_ip_src,
15463 (void *)&cmd_set_vxlan_ip_src_value,
15464 (void *)&cmd_set_vxlan_ip_dst,
15465 (void *)&cmd_set_vxlan_ip_dst_value,
15466 (void *)&cmd_set_vxlan_vlan,
15467 (void *)&cmd_set_vxlan_vlan_value,
15468 (void *)&cmd_set_vxlan_eth_src,
15469 (void *)&cmd_set_vxlan_eth_src_value,
15470 (void *)&cmd_set_vxlan_eth_dst,
15471 (void *)&cmd_set_vxlan_eth_dst_value,
15476 /** Set NVGRE encapsulation details */
15477 struct cmd_set_nvgre_result {
15478 cmdline_fixed_string_t set;
15479 cmdline_fixed_string_t nvgre;
15480 cmdline_fixed_string_t pos_token;
15481 cmdline_fixed_string_t ip_version;
15483 cmdline_ipaddr_t ip_src;
15484 cmdline_ipaddr_t ip_dst;
15486 struct rte_ether_addr eth_src;
15487 struct rte_ether_addr eth_dst;
15490 cmdline_parse_token_string_t cmd_set_nvgre_set =
15491 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15492 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15493 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15494 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15495 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15496 "nvgre-with-vlan");
15497 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15498 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15500 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15501 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15503 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15504 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15506 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15507 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15508 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15509 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15511 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15512 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15513 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15514 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15516 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15517 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15518 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15519 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15521 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15522 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15523 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15524 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15526 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15527 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15528 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15529 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15531 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15532 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15534 static void cmd_set_nvgre_parsed(void *parsed_result,
15535 __attribute__((unused)) struct cmdline *cl,
15536 __attribute__((unused)) void *data)
15538 struct cmd_set_nvgre_result *res = parsed_result;
15540 uint32_t nvgre_tni;
15543 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15546 if (strcmp(res->nvgre, "nvgre") == 0)
15547 nvgre_encap_conf.select_vlan = 0;
15548 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15549 nvgre_encap_conf.select_vlan = 1;
15550 if (strcmp(res->ip_version, "ipv4") == 0)
15551 nvgre_encap_conf.select_ipv4 = 1;
15552 else if (strcmp(res->ip_version, "ipv6") == 0)
15553 nvgre_encap_conf.select_ipv4 = 0;
15556 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15557 if (nvgre_encap_conf.select_ipv4) {
15558 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15559 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15561 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15562 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15564 if (nvgre_encap_conf.select_vlan)
15565 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15566 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15567 RTE_ETHER_ADDR_LEN);
15568 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15569 RTE_ETHER_ADDR_LEN);
15572 cmdline_parse_inst_t cmd_set_nvgre = {
15573 .f = cmd_set_nvgre_parsed,
15575 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15576 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15577 " eth-dst <eth-dst>",
15579 (void *)&cmd_set_nvgre_set,
15580 (void *)&cmd_set_nvgre_nvgre,
15581 (void *)&cmd_set_nvgre_ip_version,
15582 (void *)&cmd_set_nvgre_ip_version_value,
15583 (void *)&cmd_set_nvgre_tni,
15584 (void *)&cmd_set_nvgre_tni_value,
15585 (void *)&cmd_set_nvgre_ip_src,
15586 (void *)&cmd_set_nvgre_ip_src_value,
15587 (void *)&cmd_set_nvgre_ip_dst,
15588 (void *)&cmd_set_nvgre_ip_dst_value,
15589 (void *)&cmd_set_nvgre_eth_src,
15590 (void *)&cmd_set_nvgre_eth_src_value,
15591 (void *)&cmd_set_nvgre_eth_dst,
15592 (void *)&cmd_set_nvgre_eth_dst_value,
15597 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15598 .f = cmd_set_nvgre_parsed,
15600 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15601 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15602 " eth-src <eth-src> eth-dst <eth-dst>",
15604 (void *)&cmd_set_nvgre_set,
15605 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15606 (void *)&cmd_set_nvgre_ip_version,
15607 (void *)&cmd_set_nvgre_ip_version_value,
15608 (void *)&cmd_set_nvgre_tni,
15609 (void *)&cmd_set_nvgre_tni_value,
15610 (void *)&cmd_set_nvgre_ip_src,
15611 (void *)&cmd_set_nvgre_ip_src_value,
15612 (void *)&cmd_set_nvgre_ip_dst,
15613 (void *)&cmd_set_nvgre_ip_dst_value,
15614 (void *)&cmd_set_nvgre_vlan,
15615 (void *)&cmd_set_nvgre_vlan_value,
15616 (void *)&cmd_set_nvgre_eth_src,
15617 (void *)&cmd_set_nvgre_eth_src_value,
15618 (void *)&cmd_set_nvgre_eth_dst,
15619 (void *)&cmd_set_nvgre_eth_dst_value,
15624 /** Set L2 encapsulation details */
15625 struct cmd_set_l2_encap_result {
15626 cmdline_fixed_string_t set;
15627 cmdline_fixed_string_t l2_encap;
15628 cmdline_fixed_string_t pos_token;
15629 cmdline_fixed_string_t ip_version;
15630 uint32_t vlan_present:1;
15632 struct rte_ether_addr eth_src;
15633 struct rte_ether_addr eth_dst;
15636 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15637 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15638 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15639 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15640 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15641 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15642 "l2_encap-with-vlan");
15643 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15644 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15646 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15647 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15649 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15650 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15652 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15653 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15654 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15655 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15657 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15658 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15659 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15660 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15662 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15663 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15665 static void cmd_set_l2_encap_parsed(void *parsed_result,
15666 __attribute__((unused)) struct cmdline *cl,
15667 __attribute__((unused)) void *data)
15669 struct cmd_set_l2_encap_result *res = parsed_result;
15671 if (strcmp(res->l2_encap, "l2_encap") == 0)
15672 l2_encap_conf.select_vlan = 0;
15673 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15674 l2_encap_conf.select_vlan = 1;
15675 if (strcmp(res->ip_version, "ipv4") == 0)
15676 l2_encap_conf.select_ipv4 = 1;
15677 else if (strcmp(res->ip_version, "ipv6") == 0)
15678 l2_encap_conf.select_ipv4 = 0;
15681 if (l2_encap_conf.select_vlan)
15682 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15683 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15684 RTE_ETHER_ADDR_LEN);
15685 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15686 RTE_ETHER_ADDR_LEN);
15689 cmdline_parse_inst_t cmd_set_l2_encap = {
15690 .f = cmd_set_l2_encap_parsed,
15692 .help_str = "set l2_encap ip-version ipv4|ipv6"
15693 " eth-src <eth-src> eth-dst <eth-dst>",
15695 (void *)&cmd_set_l2_encap_set,
15696 (void *)&cmd_set_l2_encap_l2_encap,
15697 (void *)&cmd_set_l2_encap_ip_version,
15698 (void *)&cmd_set_l2_encap_ip_version_value,
15699 (void *)&cmd_set_l2_encap_eth_src,
15700 (void *)&cmd_set_l2_encap_eth_src_value,
15701 (void *)&cmd_set_l2_encap_eth_dst,
15702 (void *)&cmd_set_l2_encap_eth_dst_value,
15707 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15708 .f = cmd_set_l2_encap_parsed,
15710 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15711 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15713 (void *)&cmd_set_l2_encap_set,
15714 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15715 (void *)&cmd_set_l2_encap_ip_version,
15716 (void *)&cmd_set_l2_encap_ip_version_value,
15717 (void *)&cmd_set_l2_encap_vlan,
15718 (void *)&cmd_set_l2_encap_vlan_value,
15719 (void *)&cmd_set_l2_encap_eth_src,
15720 (void *)&cmd_set_l2_encap_eth_src_value,
15721 (void *)&cmd_set_l2_encap_eth_dst,
15722 (void *)&cmd_set_l2_encap_eth_dst_value,
15727 /** Set L2 decapsulation details */
15728 struct cmd_set_l2_decap_result {
15729 cmdline_fixed_string_t set;
15730 cmdline_fixed_string_t l2_decap;
15731 cmdline_fixed_string_t pos_token;
15732 uint32_t vlan_present:1;
15735 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15736 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15737 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15738 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15740 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15741 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15742 "l2_decap-with-vlan");
15744 static void cmd_set_l2_decap_parsed(void *parsed_result,
15745 __attribute__((unused)) struct cmdline *cl,
15746 __attribute__((unused)) void *data)
15748 struct cmd_set_l2_decap_result *res = parsed_result;
15750 if (strcmp(res->l2_decap, "l2_decap") == 0)
15751 l2_decap_conf.select_vlan = 0;
15752 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15753 l2_decap_conf.select_vlan = 1;
15756 cmdline_parse_inst_t cmd_set_l2_decap = {
15757 .f = cmd_set_l2_decap_parsed,
15759 .help_str = "set l2_decap",
15761 (void *)&cmd_set_l2_decap_set,
15762 (void *)&cmd_set_l2_decap_l2_decap,
15767 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15768 .f = cmd_set_l2_decap_parsed,
15770 .help_str = "set l2_decap-with-vlan",
15772 (void *)&cmd_set_l2_decap_set,
15773 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15778 /** Set MPLSoGRE encapsulation details */
15779 struct cmd_set_mplsogre_encap_result {
15780 cmdline_fixed_string_t set;
15781 cmdline_fixed_string_t mplsogre;
15782 cmdline_fixed_string_t pos_token;
15783 cmdline_fixed_string_t ip_version;
15784 uint32_t vlan_present:1;
15786 cmdline_ipaddr_t ip_src;
15787 cmdline_ipaddr_t ip_dst;
15789 struct rte_ether_addr eth_src;
15790 struct rte_ether_addr eth_dst;
15793 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15794 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15796 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15797 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15799 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15800 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15801 mplsogre, "mplsogre_encap-with-vlan");
15802 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15803 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15804 pos_token, "ip-version");
15805 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15806 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15807 ip_version, "ipv4#ipv6");
15808 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15809 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15810 pos_token, "label");
15811 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15812 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15814 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15815 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15816 pos_token, "ip-src");
15817 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15818 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15819 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15820 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15821 pos_token, "ip-dst");
15822 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15823 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15824 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15825 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15826 pos_token, "vlan-tci");
15827 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15828 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15830 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15831 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15832 pos_token, "eth-src");
15833 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15834 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15836 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15837 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15838 pos_token, "eth-dst");
15839 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15840 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15843 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15844 __attribute__((unused)) struct cmdline *cl,
15845 __attribute__((unused)) void *data)
15847 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15849 uint32_t mplsogre_label;
15852 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15855 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15856 mplsogre_encap_conf.select_vlan = 0;
15857 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15858 mplsogre_encap_conf.select_vlan = 1;
15859 if (strcmp(res->ip_version, "ipv4") == 0)
15860 mplsogre_encap_conf.select_ipv4 = 1;
15861 else if (strcmp(res->ip_version, "ipv6") == 0)
15862 mplsogre_encap_conf.select_ipv4 = 0;
15865 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15866 if (mplsogre_encap_conf.select_ipv4) {
15867 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15868 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15870 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15871 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15873 if (mplsogre_encap_conf.select_vlan)
15874 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15875 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15876 RTE_ETHER_ADDR_LEN);
15877 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15878 RTE_ETHER_ADDR_LEN);
15881 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15882 .f = cmd_set_mplsogre_encap_parsed,
15884 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15885 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15886 " eth-dst <eth-dst>",
15888 (void *)&cmd_set_mplsogre_encap_set,
15889 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15890 (void *)&cmd_set_mplsogre_encap_ip_version,
15891 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15892 (void *)&cmd_set_mplsogre_encap_label,
15893 (void *)&cmd_set_mplsogre_encap_label_value,
15894 (void *)&cmd_set_mplsogre_encap_ip_src,
15895 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15896 (void *)&cmd_set_mplsogre_encap_ip_dst,
15897 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15898 (void *)&cmd_set_mplsogre_encap_eth_src,
15899 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15900 (void *)&cmd_set_mplsogre_encap_eth_dst,
15901 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15906 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15907 .f = cmd_set_mplsogre_encap_parsed,
15909 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15910 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15911 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15913 (void *)&cmd_set_mplsogre_encap_set,
15914 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15915 (void *)&cmd_set_mplsogre_encap_ip_version,
15916 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15917 (void *)&cmd_set_mplsogre_encap_label,
15918 (void *)&cmd_set_mplsogre_encap_label_value,
15919 (void *)&cmd_set_mplsogre_encap_ip_src,
15920 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15921 (void *)&cmd_set_mplsogre_encap_ip_dst,
15922 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15923 (void *)&cmd_set_mplsogre_encap_vlan,
15924 (void *)&cmd_set_mplsogre_encap_vlan_value,
15925 (void *)&cmd_set_mplsogre_encap_eth_src,
15926 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15927 (void *)&cmd_set_mplsogre_encap_eth_dst,
15928 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15933 /** Set MPLSoGRE decapsulation details */
15934 struct cmd_set_mplsogre_decap_result {
15935 cmdline_fixed_string_t set;
15936 cmdline_fixed_string_t mplsogre;
15937 cmdline_fixed_string_t pos_token;
15938 cmdline_fixed_string_t ip_version;
15939 uint32_t vlan_present:1;
15942 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15943 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15945 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15946 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15948 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15949 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15950 mplsogre, "mplsogre_decap-with-vlan");
15951 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15952 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15953 pos_token, "ip-version");
15954 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15955 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15956 ip_version, "ipv4#ipv6");
15958 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15959 __attribute__((unused)) struct cmdline *cl,
15960 __attribute__((unused)) void *data)
15962 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15964 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15965 mplsogre_decap_conf.select_vlan = 0;
15966 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15967 mplsogre_decap_conf.select_vlan = 1;
15968 if (strcmp(res->ip_version, "ipv4") == 0)
15969 mplsogre_decap_conf.select_ipv4 = 1;
15970 else if (strcmp(res->ip_version, "ipv6") == 0)
15971 mplsogre_decap_conf.select_ipv4 = 0;
15974 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15975 .f = cmd_set_mplsogre_decap_parsed,
15977 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15979 (void *)&cmd_set_mplsogre_decap_set,
15980 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15981 (void *)&cmd_set_mplsogre_decap_ip_version,
15982 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15987 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15988 .f = cmd_set_mplsogre_decap_parsed,
15990 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15992 (void *)&cmd_set_mplsogre_decap_set,
15993 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15994 (void *)&cmd_set_mplsogre_decap_ip_version,
15995 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16000 /** Set MPLSoUDP encapsulation details */
16001 struct cmd_set_mplsoudp_encap_result {
16002 cmdline_fixed_string_t set;
16003 cmdline_fixed_string_t mplsoudp;
16004 cmdline_fixed_string_t pos_token;
16005 cmdline_fixed_string_t ip_version;
16006 uint32_t vlan_present:1;
16010 cmdline_ipaddr_t ip_src;
16011 cmdline_ipaddr_t ip_dst;
16013 struct rte_ether_addr eth_src;
16014 struct rte_ether_addr eth_dst;
16017 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16018 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16020 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16021 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16023 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16024 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16025 mplsoudp, "mplsoudp_encap-with-vlan");
16026 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16027 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16028 pos_token, "ip-version");
16029 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16030 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16031 ip_version, "ipv4#ipv6");
16032 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16033 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16034 pos_token, "label");
16035 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16036 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16038 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16039 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16040 pos_token, "udp-src");
16041 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16042 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16044 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16045 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16046 pos_token, "udp-dst");
16047 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16048 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16050 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16051 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16052 pos_token, "ip-src");
16053 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16054 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16055 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16056 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16057 pos_token, "ip-dst");
16058 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16059 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16060 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16061 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16062 pos_token, "vlan-tci");
16063 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16064 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16066 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16067 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16068 pos_token, "eth-src");
16069 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16070 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16072 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16073 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16074 pos_token, "eth-dst");
16075 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16076 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16079 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16080 __attribute__((unused)) struct cmdline *cl,
16081 __attribute__((unused)) void *data)
16083 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16085 uint32_t mplsoudp_label;
16088 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16091 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16092 mplsoudp_encap_conf.select_vlan = 0;
16093 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16094 mplsoudp_encap_conf.select_vlan = 1;
16095 if (strcmp(res->ip_version, "ipv4") == 0)
16096 mplsoudp_encap_conf.select_ipv4 = 1;
16097 else if (strcmp(res->ip_version, "ipv6") == 0)
16098 mplsoudp_encap_conf.select_ipv4 = 0;
16101 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16102 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16103 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16104 if (mplsoudp_encap_conf.select_ipv4) {
16105 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16106 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16108 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16109 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16111 if (mplsoudp_encap_conf.select_vlan)
16112 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16113 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16114 RTE_ETHER_ADDR_LEN);
16115 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16116 RTE_ETHER_ADDR_LEN);
16119 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16120 .f = cmd_set_mplsoudp_encap_parsed,
16122 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16123 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16124 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16126 (void *)&cmd_set_mplsoudp_encap_set,
16127 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16128 (void *)&cmd_set_mplsoudp_encap_ip_version,
16129 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16130 (void *)&cmd_set_mplsoudp_encap_label,
16131 (void *)&cmd_set_mplsoudp_encap_label_value,
16132 (void *)&cmd_set_mplsoudp_encap_udp_src,
16133 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16134 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16135 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16136 (void *)&cmd_set_mplsoudp_encap_ip_src,
16137 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16138 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16139 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16140 (void *)&cmd_set_mplsoudp_encap_eth_src,
16141 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16142 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16143 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16148 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16149 .f = cmd_set_mplsoudp_encap_parsed,
16151 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16152 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16153 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16154 " eth-src <eth-src> eth-dst <eth-dst>",
16156 (void *)&cmd_set_mplsoudp_encap_set,
16157 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16158 (void *)&cmd_set_mplsoudp_encap_ip_version,
16159 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16160 (void *)&cmd_set_mplsoudp_encap_label,
16161 (void *)&cmd_set_mplsoudp_encap_label_value,
16162 (void *)&cmd_set_mplsoudp_encap_udp_src,
16163 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16164 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16165 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16166 (void *)&cmd_set_mplsoudp_encap_ip_src,
16167 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16168 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16169 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16170 (void *)&cmd_set_mplsoudp_encap_vlan,
16171 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16172 (void *)&cmd_set_mplsoudp_encap_eth_src,
16173 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16174 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16175 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16180 /** Set MPLSoUDP decapsulation details */
16181 struct cmd_set_mplsoudp_decap_result {
16182 cmdline_fixed_string_t set;
16183 cmdline_fixed_string_t mplsoudp;
16184 cmdline_fixed_string_t pos_token;
16185 cmdline_fixed_string_t ip_version;
16186 uint32_t vlan_present:1;
16189 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16190 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16192 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16193 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16195 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16196 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16197 mplsoudp, "mplsoudp_decap-with-vlan");
16198 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16199 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16200 pos_token, "ip-version");
16201 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16202 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16203 ip_version, "ipv4#ipv6");
16205 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16206 __attribute__((unused)) struct cmdline *cl,
16207 __attribute__((unused)) void *data)
16209 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16211 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16212 mplsoudp_decap_conf.select_vlan = 0;
16213 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16214 mplsoudp_decap_conf.select_vlan = 1;
16215 if (strcmp(res->ip_version, "ipv4") == 0)
16216 mplsoudp_decap_conf.select_ipv4 = 1;
16217 else if (strcmp(res->ip_version, "ipv6") == 0)
16218 mplsoudp_decap_conf.select_ipv4 = 0;
16221 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16222 .f = cmd_set_mplsoudp_decap_parsed,
16224 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16226 (void *)&cmd_set_mplsoudp_decap_set,
16227 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16228 (void *)&cmd_set_mplsoudp_decap_ip_version,
16229 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16234 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16235 .f = cmd_set_mplsoudp_decap_parsed,
16237 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16239 (void *)&cmd_set_mplsoudp_decap_set,
16240 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16241 (void *)&cmd_set_mplsoudp_decap_ip_version,
16242 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16247 /* Strict link priority scheduling mode setting */
16249 cmd_strict_link_prio_parsed(
16250 void *parsed_result,
16251 __attribute__((unused)) struct cmdline *cl,
16252 __attribute__((unused)) void *data)
16254 struct cmd_vf_tc_bw_result *res = parsed_result;
16255 int ret = -ENOTSUP;
16257 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16260 #ifdef RTE_LIBRTE_I40E_PMD
16261 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16268 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16271 printf("invalid port_id %d\n", res->port_id);
16274 printf("function not implemented\n");
16277 printf("programming error: (%s)\n", strerror(-ret));
16281 cmdline_parse_inst_t cmd_strict_link_prio = {
16282 .f = cmd_strict_link_prio_parsed,
16284 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16286 (void *)&cmd_vf_tc_bw_set,
16287 (void *)&cmd_vf_tc_bw_tx,
16288 (void *)&cmd_vf_tc_bw_strict_link_prio,
16289 (void *)&cmd_vf_tc_bw_port_id,
16290 (void *)&cmd_vf_tc_bw_tc_map,
16295 /* Load dynamic device personalization*/
16296 struct cmd_ddp_add_result {
16297 cmdline_fixed_string_t ddp;
16298 cmdline_fixed_string_t add;
16303 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16304 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16305 cmdline_parse_token_string_t cmd_ddp_add_add =
16306 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16307 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16308 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16309 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16310 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16313 cmd_ddp_add_parsed(
16314 void *parsed_result,
16315 __attribute__((unused)) struct cmdline *cl,
16316 __attribute__((unused)) void *data)
16318 struct cmd_ddp_add_result *res = parsed_result;
16324 int ret = -ENOTSUP;
16326 if (!all_ports_stopped()) {
16327 printf("Please stop all ports first\n");
16331 filepath = strdup(res->filepath);
16332 if (filepath == NULL) {
16333 printf("Failed to allocate memory\n");
16336 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16338 buff = open_file(file_fld[0], &size);
16340 free((void *)filepath);
16344 #ifdef RTE_LIBRTE_I40E_PMD
16345 if (ret == -ENOTSUP)
16346 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16348 RTE_PMD_I40E_PKG_OP_WR_ADD);
16351 if (ret == -EEXIST)
16352 printf("Profile has already existed.\n");
16354 printf("Failed to load profile.\n");
16355 else if (file_num == 2)
16356 save_file(file_fld[1], buff, size);
16359 free((void *)filepath);
16362 cmdline_parse_inst_t cmd_ddp_add = {
16363 .f = cmd_ddp_add_parsed,
16365 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16367 (void *)&cmd_ddp_add_ddp,
16368 (void *)&cmd_ddp_add_add,
16369 (void *)&cmd_ddp_add_port_id,
16370 (void *)&cmd_ddp_add_filepath,
16375 /* Delete dynamic device personalization*/
16376 struct cmd_ddp_del_result {
16377 cmdline_fixed_string_t ddp;
16378 cmdline_fixed_string_t del;
16383 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16384 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16385 cmdline_parse_token_string_t cmd_ddp_del_del =
16386 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16387 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16388 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16389 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16390 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16393 cmd_ddp_del_parsed(
16394 void *parsed_result,
16395 __attribute__((unused)) struct cmdline *cl,
16396 __attribute__((unused)) void *data)
16398 struct cmd_ddp_del_result *res = parsed_result;
16401 int ret = -ENOTSUP;
16403 if (!all_ports_stopped()) {
16404 printf("Please stop all ports first\n");
16408 buff = open_file(res->filepath, &size);
16412 #ifdef RTE_LIBRTE_I40E_PMD
16413 if (ret == -ENOTSUP)
16414 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16416 RTE_PMD_I40E_PKG_OP_WR_DEL);
16419 if (ret == -EACCES)
16420 printf("Profile does not exist.\n");
16422 printf("Failed to delete profile.\n");
16427 cmdline_parse_inst_t cmd_ddp_del = {
16428 .f = cmd_ddp_del_parsed,
16430 .help_str = "ddp del <port_id> <backup_profile_path>",
16432 (void *)&cmd_ddp_del_ddp,
16433 (void *)&cmd_ddp_del_del,
16434 (void *)&cmd_ddp_del_port_id,
16435 (void *)&cmd_ddp_del_filepath,
16440 /* Get dynamic device personalization profile info */
16441 struct cmd_ddp_info_result {
16442 cmdline_fixed_string_t ddp;
16443 cmdline_fixed_string_t get;
16444 cmdline_fixed_string_t info;
16448 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16449 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16450 cmdline_parse_token_string_t cmd_ddp_info_get =
16451 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16452 cmdline_parse_token_string_t cmd_ddp_info_info =
16453 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16454 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16455 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16458 cmd_ddp_info_parsed(
16459 void *parsed_result,
16460 __attribute__((unused)) struct cmdline *cl,
16461 __attribute__((unused)) void *data)
16463 struct cmd_ddp_info_result *res = parsed_result;
16466 int ret = -ENOTSUP;
16467 #ifdef RTE_LIBRTE_I40E_PMD
16470 uint32_t buff_size = 0;
16471 struct rte_pmd_i40e_profile_info info;
16472 uint32_t dev_num = 0;
16473 struct rte_pmd_i40e_ddp_device_id *devs;
16474 uint32_t proto_num = 0;
16475 struct rte_pmd_i40e_proto_info *proto = NULL;
16476 uint32_t pctype_num = 0;
16477 struct rte_pmd_i40e_ptype_info *pctype;
16478 uint32_t ptype_num = 0;
16479 struct rte_pmd_i40e_ptype_info *ptype;
16484 pkg = open_file(res->filepath, &pkg_size);
16488 #ifdef RTE_LIBRTE_I40E_PMD
16489 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16490 (uint8_t *)&info, sizeof(info),
16491 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16493 printf("Global Track id: 0x%x\n", info.track_id);
16494 printf("Global Version: %d.%d.%d.%d\n",
16495 info.version.major,
16496 info.version.minor,
16497 info.version.update,
16498 info.version.draft);
16499 printf("Global Package name: %s\n\n", info.name);
16502 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16503 (uint8_t *)&info, sizeof(info),
16504 RTE_PMD_I40E_PKG_INFO_HEADER);
16506 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16507 printf("i40e Profile Version: %d.%d.%d.%d\n",
16508 info.version.major,
16509 info.version.minor,
16510 info.version.update,
16511 info.version.draft);
16512 printf("i40e Profile name: %s\n\n", info.name);
16515 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16516 (uint8_t *)&buff_size, sizeof(buff_size),
16517 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16518 if (!ret && buff_size) {
16519 buff = (uint8_t *)malloc(buff_size);
16521 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16523 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16525 printf("Package Notes:\n%s\n\n", buff);
16530 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16531 (uint8_t *)&dev_num, sizeof(dev_num),
16532 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16533 if (!ret && dev_num) {
16534 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16535 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16537 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16538 (uint8_t *)devs, buff_size,
16539 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16541 printf("List of supported devices:\n");
16542 for (i = 0; i < dev_num; i++) {
16543 printf(" %04X:%04X %04X:%04X\n",
16544 devs[i].vendor_dev_id >> 16,
16545 devs[i].vendor_dev_id & 0xFFFF,
16546 devs[i].sub_vendor_dev_id >> 16,
16547 devs[i].sub_vendor_dev_id & 0xFFFF);
16555 /* get information about protocols and packet types */
16556 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16557 (uint8_t *)&proto_num, sizeof(proto_num),
16558 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16559 if (ret || !proto_num)
16560 goto no_print_return;
16562 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16563 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16565 goto no_print_return;
16567 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16569 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16571 printf("List of used protocols:\n");
16572 for (i = 0; i < proto_num; i++)
16573 printf(" %2u: %s\n", proto[i].proto_id,
16577 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16578 (uint8_t *)&pctype_num, sizeof(pctype_num),
16579 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16580 if (ret || !pctype_num)
16581 goto no_print_pctypes;
16583 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16584 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16586 goto no_print_pctypes;
16588 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16590 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16593 goto no_print_pctypes;
16596 printf("List of defined packet classification types:\n");
16597 for (i = 0; i < pctype_num; i++) {
16598 printf(" %2u:", pctype[i].ptype_id);
16599 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16600 proto_id = pctype[i].protocols[j];
16601 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16602 for (n = 0; n < proto_num; n++) {
16603 if (proto[n].proto_id == proto_id) {
16604 printf(" %s", proto[n].name);
16617 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16619 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16620 if (ret || !ptype_num)
16621 goto no_print_return;
16623 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16624 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16626 goto no_print_return;
16628 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16630 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16633 goto no_print_return;
16635 printf("List of defined packet types:\n");
16636 for (i = 0; i < ptype_num; i++) {
16637 printf(" %2u:", ptype[i].ptype_id);
16638 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16639 proto_id = ptype[i].protocols[j];
16640 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16641 for (n = 0; n < proto_num; n++) {
16642 if (proto[n].proto_id == proto_id) {
16643 printf(" %s", proto[n].name);
16659 if (ret == -ENOTSUP)
16660 printf("Function not supported in PMD driver\n");
16664 cmdline_parse_inst_t cmd_ddp_get_info = {
16665 .f = cmd_ddp_info_parsed,
16667 .help_str = "ddp get info <profile_path>",
16669 (void *)&cmd_ddp_info_ddp,
16670 (void *)&cmd_ddp_info_get,
16671 (void *)&cmd_ddp_info_info,
16672 (void *)&cmd_ddp_info_filepath,
16677 /* Get dynamic device personalization profile info list*/
16678 #define PROFILE_INFO_SIZE 48
16679 #define MAX_PROFILE_NUM 16
16681 struct cmd_ddp_get_list_result {
16682 cmdline_fixed_string_t ddp;
16683 cmdline_fixed_string_t get;
16684 cmdline_fixed_string_t list;
16688 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16689 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16690 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16691 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16692 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16693 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16694 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16695 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16698 cmd_ddp_get_list_parsed(
16699 __attribute__((unused)) void *parsed_result,
16700 __attribute__((unused)) struct cmdline *cl,
16701 __attribute__((unused)) void *data)
16703 #ifdef RTE_LIBRTE_I40E_PMD
16704 struct cmd_ddp_get_list_result *res = parsed_result;
16705 struct rte_pmd_i40e_profile_list *p_list;
16706 struct rte_pmd_i40e_profile_info *p_info;
16711 int ret = -ENOTSUP;
16713 #ifdef RTE_LIBRTE_I40E_PMD
16714 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16715 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16717 printf("%s: Failed to malloc buffer\n", __func__);
16719 if (ret == -ENOTSUP)
16720 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16721 (uint8_t *)p_list, size);
16724 p_num = p_list->p_count;
16725 printf("Profile number is: %d\n\n", p_num);
16727 for (i = 0; i < p_num; i++) {
16728 p_info = &p_list->p_info[i];
16729 printf("Profile %d:\n", i);
16730 printf("Track id: 0x%x\n", p_info->track_id);
16731 printf("Version: %d.%d.%d.%d\n",
16732 p_info->version.major,
16733 p_info->version.minor,
16734 p_info->version.update,
16735 p_info->version.draft);
16736 printf("Profile name: %s\n\n", p_info->name);
16744 printf("Failed to get ddp list\n");
16747 cmdline_parse_inst_t cmd_ddp_get_list = {
16748 .f = cmd_ddp_get_list_parsed,
16750 .help_str = "ddp get list <port_id>",
16752 (void *)&cmd_ddp_get_list_ddp,
16753 (void *)&cmd_ddp_get_list_get,
16754 (void *)&cmd_ddp_get_list_list,
16755 (void *)&cmd_ddp_get_list_port_id,
16760 /* Configure input set */
16761 struct cmd_cfg_input_set_result {
16762 cmdline_fixed_string_t port;
16763 cmdline_fixed_string_t cfg;
16765 cmdline_fixed_string_t pctype;
16767 cmdline_fixed_string_t inset_type;
16768 cmdline_fixed_string_t opt;
16769 cmdline_fixed_string_t field;
16774 cmd_cfg_input_set_parsed(
16775 __attribute__((unused)) void *parsed_result,
16776 __attribute__((unused)) struct cmdline *cl,
16777 __attribute__((unused)) void *data)
16779 #ifdef RTE_LIBRTE_I40E_PMD
16780 struct cmd_cfg_input_set_result *res = parsed_result;
16781 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16782 struct rte_pmd_i40e_inset inset;
16784 int ret = -ENOTSUP;
16786 if (!all_ports_stopped()) {
16787 printf("Please stop all ports first\n");
16791 #ifdef RTE_LIBRTE_I40E_PMD
16792 if (!strcmp(res->inset_type, "hash_inset"))
16793 inset_type = INSET_HASH;
16794 else if (!strcmp(res->inset_type, "fdir_inset"))
16795 inset_type = INSET_FDIR;
16796 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16797 inset_type = INSET_FDIR_FLX;
16798 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16799 &inset, inset_type);
16801 printf("Failed to get input set.\n");
16805 if (!strcmp(res->opt, "get")) {
16806 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16809 printf("Field index %d is enabled.\n", res->field_idx);
16811 printf("Field index %d is disabled.\n", res->field_idx);
16813 } else if (!strcmp(res->opt, "set"))
16814 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16816 else if (!strcmp(res->opt, "clear"))
16817 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16820 printf("Failed to configure input set field.\n");
16824 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16825 &inset, inset_type);
16827 printf("Failed to set input set.\n");
16832 if (ret == -ENOTSUP)
16833 printf("Function not supported\n");
16836 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16837 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16839 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16840 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16842 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16843 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16845 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16846 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16848 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16849 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16851 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16852 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16854 "hash_inset#fdir_inset#fdir_flx_inset");
16855 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16856 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16857 opt, "get#set#clear");
16858 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16859 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16861 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16862 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16865 cmdline_parse_inst_t cmd_cfg_input_set = {
16866 .f = cmd_cfg_input_set_parsed,
16868 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16869 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16871 (void *)&cmd_cfg_input_set_port,
16872 (void *)&cmd_cfg_input_set_cfg,
16873 (void *)&cmd_cfg_input_set_port_id,
16874 (void *)&cmd_cfg_input_set_pctype,
16875 (void *)&cmd_cfg_input_set_pctype_id,
16876 (void *)&cmd_cfg_input_set_inset_type,
16877 (void *)&cmd_cfg_input_set_opt,
16878 (void *)&cmd_cfg_input_set_field,
16879 (void *)&cmd_cfg_input_set_field_idx,
16884 /* Clear input set */
16885 struct cmd_clear_input_set_result {
16886 cmdline_fixed_string_t port;
16887 cmdline_fixed_string_t cfg;
16889 cmdline_fixed_string_t pctype;
16891 cmdline_fixed_string_t inset_type;
16892 cmdline_fixed_string_t clear;
16893 cmdline_fixed_string_t all;
16897 cmd_clear_input_set_parsed(
16898 __attribute__((unused)) void *parsed_result,
16899 __attribute__((unused)) struct cmdline *cl,
16900 __attribute__((unused)) void *data)
16902 #ifdef RTE_LIBRTE_I40E_PMD
16903 struct cmd_clear_input_set_result *res = parsed_result;
16904 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16905 struct rte_pmd_i40e_inset inset;
16907 int ret = -ENOTSUP;
16909 if (!all_ports_stopped()) {
16910 printf("Please stop all ports first\n");
16914 #ifdef RTE_LIBRTE_I40E_PMD
16915 if (!strcmp(res->inset_type, "hash_inset"))
16916 inset_type = INSET_HASH;
16917 else if (!strcmp(res->inset_type, "fdir_inset"))
16918 inset_type = INSET_FDIR;
16919 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16920 inset_type = INSET_FDIR_FLX;
16922 memset(&inset, 0, sizeof(inset));
16924 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16925 &inset, inset_type);
16927 printf("Failed to clear input set.\n");
16933 if (ret == -ENOTSUP)
16934 printf("Function not supported\n");
16937 cmdline_parse_token_string_t cmd_clear_input_set_port =
16938 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16940 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16941 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16943 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16944 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16946 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16947 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16949 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16950 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16952 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16953 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16955 "hash_inset#fdir_inset#fdir_flx_inset");
16956 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16957 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16959 cmdline_parse_token_string_t cmd_clear_input_set_all =
16960 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16963 cmdline_parse_inst_t cmd_clear_input_set = {
16964 .f = cmd_clear_input_set_parsed,
16966 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16967 "fdir_inset|fdir_flx_inset clear all",
16969 (void *)&cmd_clear_input_set_port,
16970 (void *)&cmd_clear_input_set_cfg,
16971 (void *)&cmd_clear_input_set_port_id,
16972 (void *)&cmd_clear_input_set_pctype,
16973 (void *)&cmd_clear_input_set_pctype_id,
16974 (void *)&cmd_clear_input_set_inset_type,
16975 (void *)&cmd_clear_input_set_clear,
16976 (void *)&cmd_clear_input_set_all,
16981 /* show vf stats */
16983 /* Common result structure for show vf stats */
16984 struct cmd_show_vf_stats_result {
16985 cmdline_fixed_string_t show;
16986 cmdline_fixed_string_t vf;
16987 cmdline_fixed_string_t stats;
16992 /* Common CLI fields show vf stats*/
16993 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16994 TOKEN_STRING_INITIALIZER
16995 (struct cmd_show_vf_stats_result,
16997 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16998 TOKEN_STRING_INITIALIZER
16999 (struct cmd_show_vf_stats_result,
17001 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17002 TOKEN_STRING_INITIALIZER
17003 (struct cmd_show_vf_stats_result,
17005 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17006 TOKEN_NUM_INITIALIZER
17007 (struct cmd_show_vf_stats_result,
17009 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17010 TOKEN_NUM_INITIALIZER
17011 (struct cmd_show_vf_stats_result,
17015 cmd_show_vf_stats_parsed(
17016 void *parsed_result,
17017 __attribute__((unused)) struct cmdline *cl,
17018 __attribute__((unused)) void *data)
17020 struct cmd_show_vf_stats_result *res = parsed_result;
17021 struct rte_eth_stats stats;
17022 int ret = -ENOTSUP;
17023 static const char *nic_stats_border = "########################";
17025 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17028 memset(&stats, 0, sizeof(stats));
17030 #ifdef RTE_LIBRTE_I40E_PMD
17031 if (ret == -ENOTSUP)
17032 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17036 #ifdef RTE_LIBRTE_BNXT_PMD
17037 if (ret == -ENOTSUP)
17038 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17047 printf("invalid vf_id %d\n", res->vf_id);
17050 printf("invalid port_id %d\n", res->port_id);
17053 printf("function not implemented\n");
17056 printf("programming error: (%s)\n", strerror(-ret));
17059 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17060 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17062 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17064 stats.ipackets, stats.imissed, stats.ibytes);
17065 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17066 printf(" RX-nombuf: %-10"PRIu64"\n",
17068 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17070 stats.opackets, stats.oerrors, stats.obytes);
17072 printf(" %s############################%s\n",
17073 nic_stats_border, nic_stats_border);
17076 cmdline_parse_inst_t cmd_show_vf_stats = {
17077 .f = cmd_show_vf_stats_parsed,
17079 .help_str = "show vf stats <port_id> <vf_id>",
17081 (void *)&cmd_show_vf_stats_show,
17082 (void *)&cmd_show_vf_stats_vf,
17083 (void *)&cmd_show_vf_stats_stats,
17084 (void *)&cmd_show_vf_stats_port_id,
17085 (void *)&cmd_show_vf_stats_vf_id,
17090 /* clear vf stats */
17092 /* Common result structure for clear vf stats */
17093 struct cmd_clear_vf_stats_result {
17094 cmdline_fixed_string_t clear;
17095 cmdline_fixed_string_t vf;
17096 cmdline_fixed_string_t stats;
17101 /* Common CLI fields clear vf stats*/
17102 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17103 TOKEN_STRING_INITIALIZER
17104 (struct cmd_clear_vf_stats_result,
17106 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17107 TOKEN_STRING_INITIALIZER
17108 (struct cmd_clear_vf_stats_result,
17110 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17111 TOKEN_STRING_INITIALIZER
17112 (struct cmd_clear_vf_stats_result,
17114 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17115 TOKEN_NUM_INITIALIZER
17116 (struct cmd_clear_vf_stats_result,
17118 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17119 TOKEN_NUM_INITIALIZER
17120 (struct cmd_clear_vf_stats_result,
17124 cmd_clear_vf_stats_parsed(
17125 void *parsed_result,
17126 __attribute__((unused)) struct cmdline *cl,
17127 __attribute__((unused)) void *data)
17129 struct cmd_clear_vf_stats_result *res = parsed_result;
17130 int ret = -ENOTSUP;
17132 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17135 #ifdef RTE_LIBRTE_I40E_PMD
17136 if (ret == -ENOTSUP)
17137 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17140 #ifdef RTE_LIBRTE_BNXT_PMD
17141 if (ret == -ENOTSUP)
17142 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17150 printf("invalid vf_id %d\n", res->vf_id);
17153 printf("invalid port_id %d\n", res->port_id);
17156 printf("function not implemented\n");
17159 printf("programming error: (%s)\n", strerror(-ret));
17163 cmdline_parse_inst_t cmd_clear_vf_stats = {
17164 .f = cmd_clear_vf_stats_parsed,
17166 .help_str = "clear vf stats <port_id> <vf_id>",
17168 (void *)&cmd_clear_vf_stats_clear,
17169 (void *)&cmd_clear_vf_stats_vf,
17170 (void *)&cmd_clear_vf_stats_stats,
17171 (void *)&cmd_clear_vf_stats_port_id,
17172 (void *)&cmd_clear_vf_stats_vf_id,
17177 /* port config pctype mapping reset */
17179 /* Common result structure for port config pctype mapping reset */
17180 struct cmd_pctype_mapping_reset_result {
17181 cmdline_fixed_string_t port;
17182 cmdline_fixed_string_t config;
17184 cmdline_fixed_string_t pctype;
17185 cmdline_fixed_string_t mapping;
17186 cmdline_fixed_string_t reset;
17189 /* Common CLI fields for port config pctype mapping reset*/
17190 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17191 TOKEN_STRING_INITIALIZER
17192 (struct cmd_pctype_mapping_reset_result,
17194 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17195 TOKEN_STRING_INITIALIZER
17196 (struct cmd_pctype_mapping_reset_result,
17198 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17199 TOKEN_NUM_INITIALIZER
17200 (struct cmd_pctype_mapping_reset_result,
17202 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17203 TOKEN_STRING_INITIALIZER
17204 (struct cmd_pctype_mapping_reset_result,
17206 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17207 TOKEN_STRING_INITIALIZER
17208 (struct cmd_pctype_mapping_reset_result,
17209 mapping, "mapping");
17210 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17211 TOKEN_STRING_INITIALIZER
17212 (struct cmd_pctype_mapping_reset_result,
17216 cmd_pctype_mapping_reset_parsed(
17217 void *parsed_result,
17218 __attribute__((unused)) struct cmdline *cl,
17219 __attribute__((unused)) void *data)
17221 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17222 int ret = -ENOTSUP;
17224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17227 #ifdef RTE_LIBRTE_I40E_PMD
17228 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17235 printf("invalid port_id %d\n", res->port_id);
17238 printf("function not implemented\n");
17241 printf("programming error: (%s)\n", strerror(-ret));
17245 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17246 .f = cmd_pctype_mapping_reset_parsed,
17248 .help_str = "port config <port_id> pctype mapping reset",
17250 (void *)&cmd_pctype_mapping_reset_port,
17251 (void *)&cmd_pctype_mapping_reset_config,
17252 (void *)&cmd_pctype_mapping_reset_port_id,
17253 (void *)&cmd_pctype_mapping_reset_pctype,
17254 (void *)&cmd_pctype_mapping_reset_mapping,
17255 (void *)&cmd_pctype_mapping_reset_reset,
17260 /* show port pctype mapping */
17262 /* Common result structure for show port pctype mapping */
17263 struct cmd_pctype_mapping_get_result {
17264 cmdline_fixed_string_t show;
17265 cmdline_fixed_string_t port;
17267 cmdline_fixed_string_t pctype;
17268 cmdline_fixed_string_t mapping;
17271 /* Common CLI fields for pctype mapping get */
17272 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17273 TOKEN_STRING_INITIALIZER
17274 (struct cmd_pctype_mapping_get_result,
17276 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17277 TOKEN_STRING_INITIALIZER
17278 (struct cmd_pctype_mapping_get_result,
17280 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17281 TOKEN_NUM_INITIALIZER
17282 (struct cmd_pctype_mapping_get_result,
17284 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17285 TOKEN_STRING_INITIALIZER
17286 (struct cmd_pctype_mapping_get_result,
17288 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17289 TOKEN_STRING_INITIALIZER
17290 (struct cmd_pctype_mapping_get_result,
17291 mapping, "mapping");
17294 cmd_pctype_mapping_get_parsed(
17295 void *parsed_result,
17296 __attribute__((unused)) struct cmdline *cl,
17297 __attribute__((unused)) void *data)
17299 struct cmd_pctype_mapping_get_result *res = parsed_result;
17300 int ret = -ENOTSUP;
17301 #ifdef RTE_LIBRTE_I40E_PMD
17302 struct rte_pmd_i40e_flow_type_mapping
17303 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17304 int i, j, first_pctype;
17307 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17310 #ifdef RTE_LIBRTE_I40E_PMD
17311 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17318 printf("invalid port_id %d\n", res->port_id);
17321 printf("function not implemented\n");
17324 printf("programming error: (%s)\n", strerror(-ret));
17328 #ifdef RTE_LIBRTE_I40E_PMD
17329 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17330 if (mapping[i].pctype != 0ULL) {
17333 printf("pctype: ");
17334 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17335 if (mapping[i].pctype & (1ULL << j)) {
17336 printf(first_pctype ?
17337 "%02d" : ",%02d", j);
17341 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17347 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17348 .f = cmd_pctype_mapping_get_parsed,
17350 .help_str = "show port <port_id> pctype mapping",
17352 (void *)&cmd_pctype_mapping_get_show,
17353 (void *)&cmd_pctype_mapping_get_port,
17354 (void *)&cmd_pctype_mapping_get_port_id,
17355 (void *)&cmd_pctype_mapping_get_pctype,
17356 (void *)&cmd_pctype_mapping_get_mapping,
17361 /* port config pctype mapping update */
17363 /* Common result structure for port config pctype mapping update */
17364 struct cmd_pctype_mapping_update_result {
17365 cmdline_fixed_string_t port;
17366 cmdline_fixed_string_t config;
17368 cmdline_fixed_string_t pctype;
17369 cmdline_fixed_string_t mapping;
17370 cmdline_fixed_string_t update;
17371 cmdline_fixed_string_t pctype_list;
17372 uint16_t flow_type;
17375 /* Common CLI fields for pctype mapping update*/
17376 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17377 TOKEN_STRING_INITIALIZER
17378 (struct cmd_pctype_mapping_update_result,
17380 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17381 TOKEN_STRING_INITIALIZER
17382 (struct cmd_pctype_mapping_update_result,
17384 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17385 TOKEN_NUM_INITIALIZER
17386 (struct cmd_pctype_mapping_update_result,
17388 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17389 TOKEN_STRING_INITIALIZER
17390 (struct cmd_pctype_mapping_update_result,
17392 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17393 TOKEN_STRING_INITIALIZER
17394 (struct cmd_pctype_mapping_update_result,
17395 mapping, "mapping");
17396 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17397 TOKEN_STRING_INITIALIZER
17398 (struct cmd_pctype_mapping_update_result,
17400 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17401 TOKEN_STRING_INITIALIZER
17402 (struct cmd_pctype_mapping_update_result,
17403 pctype_list, NULL);
17404 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17405 TOKEN_NUM_INITIALIZER
17406 (struct cmd_pctype_mapping_update_result,
17407 flow_type, UINT16);
17410 cmd_pctype_mapping_update_parsed(
17411 void *parsed_result,
17412 __attribute__((unused)) struct cmdline *cl,
17413 __attribute__((unused)) void *data)
17415 struct cmd_pctype_mapping_update_result *res = parsed_result;
17416 int ret = -ENOTSUP;
17417 #ifdef RTE_LIBRTE_I40E_PMD
17418 struct rte_pmd_i40e_flow_type_mapping mapping;
17420 unsigned int nb_item;
17421 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17424 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17427 #ifdef RTE_LIBRTE_I40E_PMD
17428 nb_item = parse_item_list(res->pctype_list, "pctypes",
17429 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17430 mapping.flow_type = res->flow_type;
17431 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17432 mapping.pctype |= (1ULL << pctype_list[i]);
17433 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17443 printf("invalid pctype or flow type\n");
17446 printf("invalid port_id %d\n", res->port_id);
17449 printf("function not implemented\n");
17452 printf("programming error: (%s)\n", strerror(-ret));
17456 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17457 .f = cmd_pctype_mapping_update_parsed,
17459 .help_str = "port config <port_id> pctype mapping update"
17460 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17462 (void *)&cmd_pctype_mapping_update_port,
17463 (void *)&cmd_pctype_mapping_update_config,
17464 (void *)&cmd_pctype_mapping_update_port_id,
17465 (void *)&cmd_pctype_mapping_update_pctype,
17466 (void *)&cmd_pctype_mapping_update_mapping,
17467 (void *)&cmd_pctype_mapping_update_update,
17468 (void *)&cmd_pctype_mapping_update_pc_type,
17469 (void *)&cmd_pctype_mapping_update_flow_type,
17474 /* ptype mapping get */
17476 /* Common result structure for ptype mapping get */
17477 struct cmd_ptype_mapping_get_result {
17478 cmdline_fixed_string_t ptype;
17479 cmdline_fixed_string_t mapping;
17480 cmdline_fixed_string_t get;
17482 uint8_t valid_only;
17485 /* Common CLI fields for ptype mapping get */
17486 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17487 TOKEN_STRING_INITIALIZER
17488 (struct cmd_ptype_mapping_get_result,
17490 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17491 TOKEN_STRING_INITIALIZER
17492 (struct cmd_ptype_mapping_get_result,
17493 mapping, "mapping");
17494 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17495 TOKEN_STRING_INITIALIZER
17496 (struct cmd_ptype_mapping_get_result,
17498 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17499 TOKEN_NUM_INITIALIZER
17500 (struct cmd_ptype_mapping_get_result,
17502 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17503 TOKEN_NUM_INITIALIZER
17504 (struct cmd_ptype_mapping_get_result,
17505 valid_only, UINT8);
17508 cmd_ptype_mapping_get_parsed(
17509 void *parsed_result,
17510 __attribute__((unused)) struct cmdline *cl,
17511 __attribute__((unused)) void *data)
17513 struct cmd_ptype_mapping_get_result *res = parsed_result;
17514 int ret = -ENOTSUP;
17515 #ifdef RTE_LIBRTE_I40E_PMD
17516 int max_ptype_num = 256;
17517 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17522 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17525 #ifdef RTE_LIBRTE_I40E_PMD
17526 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17537 printf("invalid port_id %d\n", res->port_id);
17540 printf("function not implemented\n");
17543 printf("programming error: (%s)\n", strerror(-ret));
17546 #ifdef RTE_LIBRTE_I40E_PMD
17548 for (i = 0; i < count; i++)
17549 printf("%3d\t0x%08x\n",
17550 mapping[i].hw_ptype, mapping[i].sw_ptype);
17555 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17556 .f = cmd_ptype_mapping_get_parsed,
17558 .help_str = "ptype mapping get <port_id> <valid_only>",
17560 (void *)&cmd_ptype_mapping_get_ptype,
17561 (void *)&cmd_ptype_mapping_get_mapping,
17562 (void *)&cmd_ptype_mapping_get_get,
17563 (void *)&cmd_ptype_mapping_get_port_id,
17564 (void *)&cmd_ptype_mapping_get_valid_only,
17569 /* ptype mapping replace */
17571 /* Common result structure for ptype mapping replace */
17572 struct cmd_ptype_mapping_replace_result {
17573 cmdline_fixed_string_t ptype;
17574 cmdline_fixed_string_t mapping;
17575 cmdline_fixed_string_t replace;
17582 /* Common CLI fields for ptype mapping replace */
17583 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17584 TOKEN_STRING_INITIALIZER
17585 (struct cmd_ptype_mapping_replace_result,
17587 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17588 TOKEN_STRING_INITIALIZER
17589 (struct cmd_ptype_mapping_replace_result,
17590 mapping, "mapping");
17591 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17592 TOKEN_STRING_INITIALIZER
17593 (struct cmd_ptype_mapping_replace_result,
17594 replace, "replace");
17595 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17596 TOKEN_NUM_INITIALIZER
17597 (struct cmd_ptype_mapping_replace_result,
17599 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17600 TOKEN_NUM_INITIALIZER
17601 (struct cmd_ptype_mapping_replace_result,
17603 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17604 TOKEN_NUM_INITIALIZER
17605 (struct cmd_ptype_mapping_replace_result,
17607 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17608 TOKEN_NUM_INITIALIZER
17609 (struct cmd_ptype_mapping_replace_result,
17613 cmd_ptype_mapping_replace_parsed(
17614 void *parsed_result,
17615 __attribute__((unused)) struct cmdline *cl,
17616 __attribute__((unused)) void *data)
17618 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17619 int ret = -ENOTSUP;
17621 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17624 #ifdef RTE_LIBRTE_I40E_PMD
17625 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17635 printf("invalid ptype 0x%8x or 0x%8x\n",
17636 res->target, res->pkt_type);
17639 printf("invalid port_id %d\n", res->port_id);
17642 printf("function not implemented\n");
17645 printf("programming error: (%s)\n", strerror(-ret));
17649 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17650 .f = cmd_ptype_mapping_replace_parsed,
17653 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17655 (void *)&cmd_ptype_mapping_replace_ptype,
17656 (void *)&cmd_ptype_mapping_replace_mapping,
17657 (void *)&cmd_ptype_mapping_replace_replace,
17658 (void *)&cmd_ptype_mapping_replace_port_id,
17659 (void *)&cmd_ptype_mapping_replace_target,
17660 (void *)&cmd_ptype_mapping_replace_mask,
17661 (void *)&cmd_ptype_mapping_replace_pkt_type,
17666 /* ptype mapping reset */
17668 /* Common result structure for ptype mapping reset */
17669 struct cmd_ptype_mapping_reset_result {
17670 cmdline_fixed_string_t ptype;
17671 cmdline_fixed_string_t mapping;
17672 cmdline_fixed_string_t reset;
17676 /* Common CLI fields for ptype mapping reset*/
17677 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17678 TOKEN_STRING_INITIALIZER
17679 (struct cmd_ptype_mapping_reset_result,
17681 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17682 TOKEN_STRING_INITIALIZER
17683 (struct cmd_ptype_mapping_reset_result,
17684 mapping, "mapping");
17685 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17686 TOKEN_STRING_INITIALIZER
17687 (struct cmd_ptype_mapping_reset_result,
17689 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17690 TOKEN_NUM_INITIALIZER
17691 (struct cmd_ptype_mapping_reset_result,
17695 cmd_ptype_mapping_reset_parsed(
17696 void *parsed_result,
17697 __attribute__((unused)) struct cmdline *cl,
17698 __attribute__((unused)) void *data)
17700 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17701 int ret = -ENOTSUP;
17703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17706 #ifdef RTE_LIBRTE_I40E_PMD
17707 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17714 printf("invalid port_id %d\n", res->port_id);
17717 printf("function not implemented\n");
17720 printf("programming error: (%s)\n", strerror(-ret));
17724 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17725 .f = cmd_ptype_mapping_reset_parsed,
17727 .help_str = "ptype mapping reset <port_id>",
17729 (void *)&cmd_ptype_mapping_reset_ptype,
17730 (void *)&cmd_ptype_mapping_reset_mapping,
17731 (void *)&cmd_ptype_mapping_reset_reset,
17732 (void *)&cmd_ptype_mapping_reset_port_id,
17737 /* ptype mapping update */
17739 /* Common result structure for ptype mapping update */
17740 struct cmd_ptype_mapping_update_result {
17741 cmdline_fixed_string_t ptype;
17742 cmdline_fixed_string_t mapping;
17743 cmdline_fixed_string_t reset;
17749 /* Common CLI fields for ptype mapping update*/
17750 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17751 TOKEN_STRING_INITIALIZER
17752 (struct cmd_ptype_mapping_update_result,
17754 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17755 TOKEN_STRING_INITIALIZER
17756 (struct cmd_ptype_mapping_update_result,
17757 mapping, "mapping");
17758 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17759 TOKEN_STRING_INITIALIZER
17760 (struct cmd_ptype_mapping_update_result,
17762 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17763 TOKEN_NUM_INITIALIZER
17764 (struct cmd_ptype_mapping_update_result,
17766 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17767 TOKEN_NUM_INITIALIZER
17768 (struct cmd_ptype_mapping_update_result,
17770 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17771 TOKEN_NUM_INITIALIZER
17772 (struct cmd_ptype_mapping_update_result,
17776 cmd_ptype_mapping_update_parsed(
17777 void *parsed_result,
17778 __attribute__((unused)) struct cmdline *cl,
17779 __attribute__((unused)) void *data)
17781 struct cmd_ptype_mapping_update_result *res = parsed_result;
17782 int ret = -ENOTSUP;
17783 #ifdef RTE_LIBRTE_I40E_PMD
17784 struct rte_pmd_i40e_ptype_mapping mapping;
17786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17789 #ifdef RTE_LIBRTE_I40E_PMD
17790 mapping.hw_ptype = res->hw_ptype;
17791 mapping.sw_ptype = res->sw_ptype;
17792 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17802 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17805 printf("invalid port_id %d\n", res->port_id);
17808 printf("function not implemented\n");
17811 printf("programming error: (%s)\n", strerror(-ret));
17815 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17816 .f = cmd_ptype_mapping_update_parsed,
17818 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17820 (void *)&cmd_ptype_mapping_update_ptype,
17821 (void *)&cmd_ptype_mapping_update_mapping,
17822 (void *)&cmd_ptype_mapping_update_update,
17823 (void *)&cmd_ptype_mapping_update_port_id,
17824 (void *)&cmd_ptype_mapping_update_hw_ptype,
17825 (void *)&cmd_ptype_mapping_update_sw_ptype,
17830 /* Common result structure for file commands */
17831 struct cmd_cmdfile_result {
17832 cmdline_fixed_string_t load;
17833 cmdline_fixed_string_t filename;
17836 /* Common CLI fields for file commands */
17837 cmdline_parse_token_string_t cmd_load_cmdfile =
17838 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17839 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17840 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17843 cmd_load_from_file_parsed(
17844 void *parsed_result,
17845 __attribute__((unused)) struct cmdline *cl,
17846 __attribute__((unused)) void *data)
17848 struct cmd_cmdfile_result *res = parsed_result;
17850 cmdline_read_from_file(res->filename);
17853 cmdline_parse_inst_t cmd_load_from_file = {
17854 .f = cmd_load_from_file_parsed,
17856 .help_str = "load <filename>",
17858 (void *)&cmd_load_cmdfile,
17859 (void *)&cmd_load_cmdfile_filename,
17864 /* Get Rx offloads capabilities */
17865 struct cmd_rx_offload_get_capa_result {
17866 cmdline_fixed_string_t show;
17867 cmdline_fixed_string_t port;
17869 cmdline_fixed_string_t rx_offload;
17870 cmdline_fixed_string_t capabilities;
17873 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17874 TOKEN_STRING_INITIALIZER
17875 (struct cmd_rx_offload_get_capa_result,
17877 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17878 TOKEN_STRING_INITIALIZER
17879 (struct cmd_rx_offload_get_capa_result,
17881 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17882 TOKEN_NUM_INITIALIZER
17883 (struct cmd_rx_offload_get_capa_result,
17885 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17886 TOKEN_STRING_INITIALIZER
17887 (struct cmd_rx_offload_get_capa_result,
17888 rx_offload, "rx_offload");
17889 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17890 TOKEN_STRING_INITIALIZER
17891 (struct cmd_rx_offload_get_capa_result,
17892 capabilities, "capabilities");
17895 print_rx_offloads(uint64_t offloads)
17897 uint64_t single_offload;
17905 begin = __builtin_ctzll(offloads);
17906 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17908 single_offload = 1ULL << begin;
17909 for (bit = begin; bit < end; bit++) {
17910 if (offloads & single_offload)
17912 rte_eth_dev_rx_offload_name(single_offload));
17913 single_offload <<= 1;
17918 cmd_rx_offload_get_capa_parsed(
17919 void *parsed_result,
17920 __attribute__((unused)) struct cmdline *cl,
17921 __attribute__((unused)) void *data)
17923 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17924 struct rte_eth_dev_info dev_info;
17925 portid_t port_id = res->port_id;
17926 uint64_t queue_offloads;
17927 uint64_t port_offloads;
17930 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17934 queue_offloads = dev_info.rx_queue_offload_capa;
17935 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17937 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17938 printf(" Per Queue :");
17939 print_rx_offloads(queue_offloads);
17942 printf(" Per Port :");
17943 print_rx_offloads(port_offloads);
17947 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17948 .f = cmd_rx_offload_get_capa_parsed,
17950 .help_str = "show port <port_id> rx_offload capabilities",
17952 (void *)&cmd_rx_offload_get_capa_show,
17953 (void *)&cmd_rx_offload_get_capa_port,
17954 (void *)&cmd_rx_offload_get_capa_port_id,
17955 (void *)&cmd_rx_offload_get_capa_rx_offload,
17956 (void *)&cmd_rx_offload_get_capa_capabilities,
17961 /* Get Rx offloads configuration */
17962 struct cmd_rx_offload_get_configuration_result {
17963 cmdline_fixed_string_t show;
17964 cmdline_fixed_string_t port;
17966 cmdline_fixed_string_t rx_offload;
17967 cmdline_fixed_string_t configuration;
17970 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17971 TOKEN_STRING_INITIALIZER
17972 (struct cmd_rx_offload_get_configuration_result,
17974 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17975 TOKEN_STRING_INITIALIZER
17976 (struct cmd_rx_offload_get_configuration_result,
17978 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17979 TOKEN_NUM_INITIALIZER
17980 (struct cmd_rx_offload_get_configuration_result,
17982 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17983 TOKEN_STRING_INITIALIZER
17984 (struct cmd_rx_offload_get_configuration_result,
17985 rx_offload, "rx_offload");
17986 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17987 TOKEN_STRING_INITIALIZER
17988 (struct cmd_rx_offload_get_configuration_result,
17989 configuration, "configuration");
17992 cmd_rx_offload_get_configuration_parsed(
17993 void *parsed_result,
17994 __attribute__((unused)) struct cmdline *cl,
17995 __attribute__((unused)) void *data)
17997 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17998 struct rte_eth_dev_info dev_info;
17999 portid_t port_id = res->port_id;
18000 struct rte_port *port = &ports[port_id];
18001 uint64_t port_offloads;
18002 uint64_t queue_offloads;
18003 uint16_t nb_rx_queues;
18007 printf("Rx Offloading Configuration of port %d :\n", port_id);
18009 port_offloads = port->dev_conf.rxmode.offloads;
18011 print_rx_offloads(port_offloads);
18014 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18018 nb_rx_queues = dev_info.nb_rx_queues;
18019 for (q = 0; q < nb_rx_queues; q++) {
18020 queue_offloads = port->rx_conf[q].offloads;
18021 printf(" Queue[%2d] :", q);
18022 print_rx_offloads(queue_offloads);
18028 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18029 .f = cmd_rx_offload_get_configuration_parsed,
18031 .help_str = "show port <port_id> rx_offload configuration",
18033 (void *)&cmd_rx_offload_get_configuration_show,
18034 (void *)&cmd_rx_offload_get_configuration_port,
18035 (void *)&cmd_rx_offload_get_configuration_port_id,
18036 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18037 (void *)&cmd_rx_offload_get_configuration_configuration,
18042 /* Enable/Disable a per port offloading */
18043 struct cmd_config_per_port_rx_offload_result {
18044 cmdline_fixed_string_t port;
18045 cmdline_fixed_string_t config;
18047 cmdline_fixed_string_t rx_offload;
18048 cmdline_fixed_string_t offload;
18049 cmdline_fixed_string_t on_off;
18052 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18053 TOKEN_STRING_INITIALIZER
18054 (struct cmd_config_per_port_rx_offload_result,
18056 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18057 TOKEN_STRING_INITIALIZER
18058 (struct cmd_config_per_port_rx_offload_result,
18060 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18061 TOKEN_NUM_INITIALIZER
18062 (struct cmd_config_per_port_rx_offload_result,
18064 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18065 TOKEN_STRING_INITIALIZER
18066 (struct cmd_config_per_port_rx_offload_result,
18067 rx_offload, "rx_offload");
18068 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18069 TOKEN_STRING_INITIALIZER
18070 (struct cmd_config_per_port_rx_offload_result,
18071 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18072 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18073 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18074 "scatter#timestamp#security#keep_crc");
18075 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18076 TOKEN_STRING_INITIALIZER
18077 (struct cmd_config_per_port_rx_offload_result,
18081 search_rx_offload(const char *name)
18083 uint64_t single_offload;
18084 const char *single_name;
18088 single_offload = 1;
18089 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18090 single_name = rte_eth_dev_rx_offload_name(single_offload);
18091 if (!strcasecmp(single_name, name)) {
18095 single_offload <<= 1;
18099 return single_offload;
18105 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18106 __attribute__((unused)) struct cmdline *cl,
18107 __attribute__((unused)) void *data)
18109 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18110 portid_t port_id = res->port_id;
18111 struct rte_eth_dev_info dev_info;
18112 struct rte_port *port = &ports[port_id];
18113 uint64_t single_offload;
18114 uint16_t nb_rx_queues;
18118 if (port->port_status != RTE_PORT_STOPPED) {
18119 printf("Error: Can't config offload when Port %d "
18120 "is not stopped\n", port_id);
18124 single_offload = search_rx_offload(res->offload);
18125 if (single_offload == 0) {
18126 printf("Unknown offload name: %s\n", res->offload);
18130 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18134 nb_rx_queues = dev_info.nb_rx_queues;
18135 if (!strcmp(res->on_off, "on")) {
18136 port->dev_conf.rxmode.offloads |= single_offload;
18137 for (q = 0; q < nb_rx_queues; q++)
18138 port->rx_conf[q].offloads |= single_offload;
18140 port->dev_conf.rxmode.offloads &= ~single_offload;
18141 for (q = 0; q < nb_rx_queues; q++)
18142 port->rx_conf[q].offloads &= ~single_offload;
18145 cmd_reconfig_device_queue(port_id, 1, 1);
18148 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18149 .f = cmd_config_per_port_rx_offload_parsed,
18151 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18152 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18153 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18154 "jumbo_frame|scatter|timestamp|security|keep_crc "
18157 (void *)&cmd_config_per_port_rx_offload_result_port,
18158 (void *)&cmd_config_per_port_rx_offload_result_config,
18159 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18160 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18161 (void *)&cmd_config_per_port_rx_offload_result_offload,
18162 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18167 /* Enable/Disable a per queue offloading */
18168 struct cmd_config_per_queue_rx_offload_result {
18169 cmdline_fixed_string_t port;
18171 cmdline_fixed_string_t rxq;
18173 cmdline_fixed_string_t rx_offload;
18174 cmdline_fixed_string_t offload;
18175 cmdline_fixed_string_t on_off;
18178 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18179 TOKEN_STRING_INITIALIZER
18180 (struct cmd_config_per_queue_rx_offload_result,
18182 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18183 TOKEN_NUM_INITIALIZER
18184 (struct cmd_config_per_queue_rx_offload_result,
18186 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18187 TOKEN_STRING_INITIALIZER
18188 (struct cmd_config_per_queue_rx_offload_result,
18190 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18191 TOKEN_NUM_INITIALIZER
18192 (struct cmd_config_per_queue_rx_offload_result,
18194 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18195 TOKEN_STRING_INITIALIZER
18196 (struct cmd_config_per_queue_rx_offload_result,
18197 rx_offload, "rx_offload");
18198 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18199 TOKEN_STRING_INITIALIZER
18200 (struct cmd_config_per_queue_rx_offload_result,
18201 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18202 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18203 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18204 "scatter#timestamp#security#keep_crc");
18205 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18206 TOKEN_STRING_INITIALIZER
18207 (struct cmd_config_per_queue_rx_offload_result,
18211 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18212 __attribute__((unused)) struct cmdline *cl,
18213 __attribute__((unused)) void *data)
18215 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18216 struct rte_eth_dev_info dev_info;
18217 portid_t port_id = res->port_id;
18218 uint16_t queue_id = res->queue_id;
18219 struct rte_port *port = &ports[port_id];
18220 uint64_t single_offload;
18223 if (port->port_status != RTE_PORT_STOPPED) {
18224 printf("Error: Can't config offload when Port %d "
18225 "is not stopped\n", port_id);
18229 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18233 if (queue_id >= dev_info.nb_rx_queues) {
18234 printf("Error: input queue_id should be 0 ... "
18235 "%d\n", dev_info.nb_rx_queues - 1);
18239 single_offload = search_rx_offload(res->offload);
18240 if (single_offload == 0) {
18241 printf("Unknown offload name: %s\n", res->offload);
18245 if (!strcmp(res->on_off, "on"))
18246 port->rx_conf[queue_id].offloads |= single_offload;
18248 port->rx_conf[queue_id].offloads &= ~single_offload;
18250 cmd_reconfig_device_queue(port_id, 1, 1);
18253 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18254 .f = cmd_config_per_queue_rx_offload_parsed,
18256 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18257 "vlan_strip|ipv4_cksum|"
18258 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18259 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18260 "jumbo_frame|scatter|timestamp|security|keep_crc "
18263 (void *)&cmd_config_per_queue_rx_offload_result_port,
18264 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18265 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18266 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18267 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18268 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18269 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18274 /* Get Tx offloads capabilities */
18275 struct cmd_tx_offload_get_capa_result {
18276 cmdline_fixed_string_t show;
18277 cmdline_fixed_string_t port;
18279 cmdline_fixed_string_t tx_offload;
18280 cmdline_fixed_string_t capabilities;
18283 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18284 TOKEN_STRING_INITIALIZER
18285 (struct cmd_tx_offload_get_capa_result,
18287 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18288 TOKEN_STRING_INITIALIZER
18289 (struct cmd_tx_offload_get_capa_result,
18291 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18292 TOKEN_NUM_INITIALIZER
18293 (struct cmd_tx_offload_get_capa_result,
18295 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18296 TOKEN_STRING_INITIALIZER
18297 (struct cmd_tx_offload_get_capa_result,
18298 tx_offload, "tx_offload");
18299 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18300 TOKEN_STRING_INITIALIZER
18301 (struct cmd_tx_offload_get_capa_result,
18302 capabilities, "capabilities");
18305 print_tx_offloads(uint64_t offloads)
18307 uint64_t single_offload;
18315 begin = __builtin_ctzll(offloads);
18316 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18318 single_offload = 1ULL << begin;
18319 for (bit = begin; bit < end; bit++) {
18320 if (offloads & single_offload)
18322 rte_eth_dev_tx_offload_name(single_offload));
18323 single_offload <<= 1;
18328 cmd_tx_offload_get_capa_parsed(
18329 void *parsed_result,
18330 __attribute__((unused)) struct cmdline *cl,
18331 __attribute__((unused)) void *data)
18333 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18334 struct rte_eth_dev_info dev_info;
18335 portid_t port_id = res->port_id;
18336 uint64_t queue_offloads;
18337 uint64_t port_offloads;
18340 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18344 queue_offloads = dev_info.tx_queue_offload_capa;
18345 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18347 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18348 printf(" Per Queue :");
18349 print_tx_offloads(queue_offloads);
18352 printf(" Per Port :");
18353 print_tx_offloads(port_offloads);
18357 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18358 .f = cmd_tx_offload_get_capa_parsed,
18360 .help_str = "show port <port_id> tx_offload capabilities",
18362 (void *)&cmd_tx_offload_get_capa_show,
18363 (void *)&cmd_tx_offload_get_capa_port,
18364 (void *)&cmd_tx_offload_get_capa_port_id,
18365 (void *)&cmd_tx_offload_get_capa_tx_offload,
18366 (void *)&cmd_tx_offload_get_capa_capabilities,
18371 /* Get Tx offloads configuration */
18372 struct cmd_tx_offload_get_configuration_result {
18373 cmdline_fixed_string_t show;
18374 cmdline_fixed_string_t port;
18376 cmdline_fixed_string_t tx_offload;
18377 cmdline_fixed_string_t configuration;
18380 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18381 TOKEN_STRING_INITIALIZER
18382 (struct cmd_tx_offload_get_configuration_result,
18384 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18385 TOKEN_STRING_INITIALIZER
18386 (struct cmd_tx_offload_get_configuration_result,
18388 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18389 TOKEN_NUM_INITIALIZER
18390 (struct cmd_tx_offload_get_configuration_result,
18392 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18393 TOKEN_STRING_INITIALIZER
18394 (struct cmd_tx_offload_get_configuration_result,
18395 tx_offload, "tx_offload");
18396 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18397 TOKEN_STRING_INITIALIZER
18398 (struct cmd_tx_offload_get_configuration_result,
18399 configuration, "configuration");
18402 cmd_tx_offload_get_configuration_parsed(
18403 void *parsed_result,
18404 __attribute__((unused)) struct cmdline *cl,
18405 __attribute__((unused)) void *data)
18407 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18408 struct rte_eth_dev_info dev_info;
18409 portid_t port_id = res->port_id;
18410 struct rte_port *port = &ports[port_id];
18411 uint64_t port_offloads;
18412 uint64_t queue_offloads;
18413 uint16_t nb_tx_queues;
18417 printf("Tx Offloading Configuration of port %d :\n", port_id);
18419 port_offloads = port->dev_conf.txmode.offloads;
18421 print_tx_offloads(port_offloads);
18424 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18428 nb_tx_queues = dev_info.nb_tx_queues;
18429 for (q = 0; q < nb_tx_queues; q++) {
18430 queue_offloads = port->tx_conf[q].offloads;
18431 printf(" Queue[%2d] :", q);
18432 print_tx_offloads(queue_offloads);
18438 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18439 .f = cmd_tx_offload_get_configuration_parsed,
18441 .help_str = "show port <port_id> tx_offload configuration",
18443 (void *)&cmd_tx_offload_get_configuration_show,
18444 (void *)&cmd_tx_offload_get_configuration_port,
18445 (void *)&cmd_tx_offload_get_configuration_port_id,
18446 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18447 (void *)&cmd_tx_offload_get_configuration_configuration,
18452 /* Enable/Disable a per port offloading */
18453 struct cmd_config_per_port_tx_offload_result {
18454 cmdline_fixed_string_t port;
18455 cmdline_fixed_string_t config;
18457 cmdline_fixed_string_t tx_offload;
18458 cmdline_fixed_string_t offload;
18459 cmdline_fixed_string_t on_off;
18462 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18463 TOKEN_STRING_INITIALIZER
18464 (struct cmd_config_per_port_tx_offload_result,
18466 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18467 TOKEN_STRING_INITIALIZER
18468 (struct cmd_config_per_port_tx_offload_result,
18470 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18471 TOKEN_NUM_INITIALIZER
18472 (struct cmd_config_per_port_tx_offload_result,
18474 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18475 TOKEN_STRING_INITIALIZER
18476 (struct cmd_config_per_port_tx_offload_result,
18477 tx_offload, "tx_offload");
18478 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18479 TOKEN_STRING_INITIALIZER
18480 (struct cmd_config_per_port_tx_offload_result,
18481 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18482 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18483 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18484 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18485 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18487 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18488 TOKEN_STRING_INITIALIZER
18489 (struct cmd_config_per_port_tx_offload_result,
18493 search_tx_offload(const char *name)
18495 uint64_t single_offload;
18496 const char *single_name;
18500 single_offload = 1;
18501 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18502 single_name = rte_eth_dev_tx_offload_name(single_offload);
18503 if (single_name == NULL)
18505 if (!strcasecmp(single_name, name)) {
18508 } else if (!strcasecmp(single_name, "UNKNOWN"))
18510 single_offload <<= 1;
18514 return single_offload;
18520 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18521 __attribute__((unused)) struct cmdline *cl,
18522 __attribute__((unused)) void *data)
18524 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18525 portid_t port_id = res->port_id;
18526 struct rte_eth_dev_info dev_info;
18527 struct rte_port *port = &ports[port_id];
18528 uint64_t single_offload;
18529 uint16_t nb_tx_queues;
18533 if (port->port_status != RTE_PORT_STOPPED) {
18534 printf("Error: Can't config offload when Port %d "
18535 "is not stopped\n", port_id);
18539 single_offload = search_tx_offload(res->offload);
18540 if (single_offload == 0) {
18541 printf("Unknown offload name: %s\n", res->offload);
18545 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18549 nb_tx_queues = dev_info.nb_tx_queues;
18550 if (!strcmp(res->on_off, "on")) {
18551 port->dev_conf.txmode.offloads |= single_offload;
18552 for (q = 0; q < nb_tx_queues; q++)
18553 port->tx_conf[q].offloads |= single_offload;
18555 port->dev_conf.txmode.offloads &= ~single_offload;
18556 for (q = 0; q < nb_tx_queues; q++)
18557 port->tx_conf[q].offloads &= ~single_offload;
18560 cmd_reconfig_device_queue(port_id, 1, 1);
18563 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18564 .f = cmd_config_per_port_tx_offload_parsed,
18566 .help_str = "port config <port_id> tx_offload "
18567 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18568 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18569 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18570 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18571 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18572 "match_metadata on|off",
18574 (void *)&cmd_config_per_port_tx_offload_result_port,
18575 (void *)&cmd_config_per_port_tx_offload_result_config,
18576 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18577 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18578 (void *)&cmd_config_per_port_tx_offload_result_offload,
18579 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18584 /* Enable/Disable a per queue offloading */
18585 struct cmd_config_per_queue_tx_offload_result {
18586 cmdline_fixed_string_t port;
18588 cmdline_fixed_string_t txq;
18590 cmdline_fixed_string_t tx_offload;
18591 cmdline_fixed_string_t offload;
18592 cmdline_fixed_string_t on_off;
18595 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18596 TOKEN_STRING_INITIALIZER
18597 (struct cmd_config_per_queue_tx_offload_result,
18599 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18600 TOKEN_NUM_INITIALIZER
18601 (struct cmd_config_per_queue_tx_offload_result,
18603 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18604 TOKEN_STRING_INITIALIZER
18605 (struct cmd_config_per_queue_tx_offload_result,
18607 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18608 TOKEN_NUM_INITIALIZER
18609 (struct cmd_config_per_queue_tx_offload_result,
18611 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18612 TOKEN_STRING_INITIALIZER
18613 (struct cmd_config_per_queue_tx_offload_result,
18614 tx_offload, "tx_offload");
18615 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18616 TOKEN_STRING_INITIALIZER
18617 (struct cmd_config_per_queue_tx_offload_result,
18618 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18619 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18620 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18621 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18622 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18623 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18624 TOKEN_STRING_INITIALIZER
18625 (struct cmd_config_per_queue_tx_offload_result,
18629 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18630 __attribute__((unused)) struct cmdline *cl,
18631 __attribute__((unused)) void *data)
18633 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18634 struct rte_eth_dev_info dev_info;
18635 portid_t port_id = res->port_id;
18636 uint16_t queue_id = res->queue_id;
18637 struct rte_port *port = &ports[port_id];
18638 uint64_t single_offload;
18641 if (port->port_status != RTE_PORT_STOPPED) {
18642 printf("Error: Can't config offload when Port %d "
18643 "is not stopped\n", port_id);
18647 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18651 if (queue_id >= dev_info.nb_tx_queues) {
18652 printf("Error: input queue_id should be 0 ... "
18653 "%d\n", dev_info.nb_tx_queues - 1);
18657 single_offload = search_tx_offload(res->offload);
18658 if (single_offload == 0) {
18659 printf("Unknown offload name: %s\n", res->offload);
18663 if (!strcmp(res->on_off, "on"))
18664 port->tx_conf[queue_id].offloads |= single_offload;
18666 port->tx_conf[queue_id].offloads &= ~single_offload;
18668 cmd_reconfig_device_queue(port_id, 1, 1);
18671 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18672 .f = cmd_config_per_queue_tx_offload_parsed,
18674 .help_str = "port <port_id> txq <queue_id> tx_offload "
18675 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18676 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18677 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18678 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18679 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18682 (void *)&cmd_config_per_queue_tx_offload_result_port,
18683 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18684 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18685 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18686 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18687 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18688 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18693 /* *** configure tx_metadata for specific port *** */
18694 struct cmd_config_tx_metadata_specific_result {
18695 cmdline_fixed_string_t port;
18696 cmdline_fixed_string_t keyword;
18698 cmdline_fixed_string_t item;
18703 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18704 __attribute__((unused)) struct cmdline *cl,
18705 __attribute__((unused)) void *data)
18707 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18709 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18711 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18712 /* Add/remove callback to insert valid metadata in every Tx packet. */
18713 if (ports[res->port_id].tx_metadata)
18714 add_tx_md_callback(res->port_id);
18716 remove_tx_md_callback(res->port_id);
18719 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18720 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18722 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18723 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18724 keyword, "config");
18725 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18726 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18728 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18729 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18730 item, "tx_metadata");
18731 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18732 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18735 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18736 .f = cmd_config_tx_metadata_specific_parsed,
18738 .help_str = "port config <port_id> tx_metadata <value>",
18740 (void *)&cmd_config_tx_metadata_specific_port,
18741 (void *)&cmd_config_tx_metadata_specific_keyword,
18742 (void *)&cmd_config_tx_metadata_specific_id,
18743 (void *)&cmd_config_tx_metadata_specific_item,
18744 (void *)&cmd_config_tx_metadata_specific_value,
18749 /* *** display tx_metadata per port configuration *** */
18750 struct cmd_show_tx_metadata_result {
18751 cmdline_fixed_string_t cmd_show;
18752 cmdline_fixed_string_t cmd_port;
18753 cmdline_fixed_string_t cmd_keyword;
18758 cmd_show_tx_metadata_parsed(void *parsed_result,
18759 __attribute__((unused)) struct cmdline *cl,
18760 __attribute__((unused)) void *data)
18762 struct cmd_show_tx_metadata_result *res = parsed_result;
18764 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18765 printf("invalid port id %u\n", res->cmd_pid);
18768 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18769 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18770 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18774 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18775 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18777 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18778 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18780 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18781 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18783 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18784 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18785 cmd_keyword, "tx_metadata");
18787 cmdline_parse_inst_t cmd_show_tx_metadata = {
18788 .f = cmd_show_tx_metadata_parsed,
18790 .help_str = "show port <port_id> tx_metadata",
18792 (void *)&cmd_show_tx_metadata_show,
18793 (void *)&cmd_show_tx_metadata_port,
18794 (void *)&cmd_show_tx_metadata_pid,
18795 (void *)&cmd_show_tx_metadata_keyword,
18800 /* show port supported ptypes */
18802 /* Common result structure for show port ptypes */
18803 struct cmd_show_port_supported_ptypes_result {
18804 cmdline_fixed_string_t show;
18805 cmdline_fixed_string_t port;
18807 cmdline_fixed_string_t ptypes;
18810 /* Common CLI fields for show port ptypes */
18811 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18812 TOKEN_STRING_INITIALIZER
18813 (struct cmd_show_port_supported_ptypes_result,
18815 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18816 TOKEN_STRING_INITIALIZER
18817 (struct cmd_show_port_supported_ptypes_result,
18819 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18820 TOKEN_NUM_INITIALIZER
18821 (struct cmd_show_port_supported_ptypes_result,
18823 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18824 TOKEN_STRING_INITIALIZER
18825 (struct cmd_show_port_supported_ptypes_result,
18829 cmd_show_port_supported_ptypes_parsed(
18830 void *parsed_result,
18831 __attribute__((unused)) struct cmdline *cl,
18832 __attribute__((unused)) void *data)
18834 #define RSVD_PTYPE_MASK 0xf0000000
18835 #define MAX_PTYPES_PER_LAYER 16
18836 #define LTYPE_NAMESIZE 32
18837 #define PTYPE_NAMESIZE 256
18838 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
18839 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
18840 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
18841 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
18842 uint16_t port_id = res->port_id;
18845 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
18849 while (ptype_mask != RSVD_PTYPE_MASK) {
18851 switch (ptype_mask) {
18852 case RTE_PTYPE_L2_MASK:
18853 strlcpy(ltype, "L2", sizeof(ltype));
18855 case RTE_PTYPE_L3_MASK:
18856 strlcpy(ltype, "L3", sizeof(ltype));
18858 case RTE_PTYPE_L4_MASK:
18859 strlcpy(ltype, "L4", sizeof(ltype));
18861 case RTE_PTYPE_TUNNEL_MASK:
18862 strlcpy(ltype, "Tunnel", sizeof(ltype));
18864 case RTE_PTYPE_INNER_L2_MASK:
18865 strlcpy(ltype, "Inner L2", sizeof(ltype));
18867 case RTE_PTYPE_INNER_L3_MASK:
18868 strlcpy(ltype, "Inner L3", sizeof(ltype));
18870 case RTE_PTYPE_INNER_L4_MASK:
18871 strlcpy(ltype, "Inner L4", sizeof(ltype));
18877 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18878 ptype_mask, ptypes,
18879 MAX_PTYPES_PER_LAYER);
18882 printf("Supported %s ptypes:\n", ltype);
18884 printf("%s ptypes unsupported\n", ltype);
18886 for (i = 0; i < ret; ++i) {
18887 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18888 printf("%s\n", buf);
18895 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18896 .f = cmd_show_port_supported_ptypes_parsed,
18898 .help_str = "show port <port_id> ptypes",
18900 (void *)&cmd_show_port_supported_ptypes_show,
18901 (void *)&cmd_show_port_supported_ptypes_port,
18902 (void *)&cmd_show_port_supported_ptypes_port_id,
18903 (void *)&cmd_show_port_supported_ptypes_ptypes,
18908 /* ******************************************************************************** */
18910 /* list of instructions */
18911 cmdline_parse_ctx_t main_ctx[] = {
18912 (cmdline_parse_inst_t *)&cmd_help_brief,
18913 (cmdline_parse_inst_t *)&cmd_help_long,
18914 (cmdline_parse_inst_t *)&cmd_quit,
18915 (cmdline_parse_inst_t *)&cmd_load_from_file,
18916 (cmdline_parse_inst_t *)&cmd_showport,
18917 (cmdline_parse_inst_t *)&cmd_showqueue,
18918 (cmdline_parse_inst_t *)&cmd_showportall,
18919 (cmdline_parse_inst_t *)&cmd_showdevice,
18920 (cmdline_parse_inst_t *)&cmd_showcfg,
18921 (cmdline_parse_inst_t *)&cmd_showfwdall,
18922 (cmdline_parse_inst_t *)&cmd_start,
18923 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18924 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18925 (cmdline_parse_inst_t *)&cmd_set_link_up,
18926 (cmdline_parse_inst_t *)&cmd_set_link_down,
18927 (cmdline_parse_inst_t *)&cmd_reset,
18928 (cmdline_parse_inst_t *)&cmd_set_numbers,
18929 (cmdline_parse_inst_t *)&cmd_set_log,
18930 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18931 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18932 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18933 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18934 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18935 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18936 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18937 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18938 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18939 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18940 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18941 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18942 (cmdline_parse_inst_t *)&cmd_set_link_check,
18943 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18944 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18945 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18946 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18947 #ifdef RTE_LIBRTE_PMD_BOND
18948 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18949 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18950 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18951 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18952 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18953 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18954 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18955 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18956 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18957 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18958 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18960 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18961 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18962 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18963 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18964 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18965 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18966 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18967 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18968 (cmdline_parse_inst_t *)&cmd_csum_set,
18969 (cmdline_parse_inst_t *)&cmd_csum_show,
18970 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18971 (cmdline_parse_inst_t *)&cmd_tso_set,
18972 (cmdline_parse_inst_t *)&cmd_tso_show,
18973 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18974 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18975 (cmdline_parse_inst_t *)&cmd_gro_enable,
18976 (cmdline_parse_inst_t *)&cmd_gro_flush,
18977 (cmdline_parse_inst_t *)&cmd_gro_show,
18978 (cmdline_parse_inst_t *)&cmd_gso_enable,
18979 (cmdline_parse_inst_t *)&cmd_gso_size,
18980 (cmdline_parse_inst_t *)&cmd_gso_show,
18981 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18982 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18983 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18984 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18985 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18986 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18987 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18988 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18989 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18990 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18991 (cmdline_parse_inst_t *)&cmd_config_dcb,
18992 (cmdline_parse_inst_t *)&cmd_read_reg,
18993 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18994 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18995 (cmdline_parse_inst_t *)&cmd_write_reg,
18996 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18997 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18998 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18999 (cmdline_parse_inst_t *)&cmd_stop,
19000 (cmdline_parse_inst_t *)&cmd_mac_addr,
19001 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19002 (cmdline_parse_inst_t *)&cmd_set_qmap,
19003 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19004 (cmdline_parse_inst_t *)&cmd_operate_port,
19005 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19006 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19007 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19008 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19009 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19010 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19011 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19012 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19013 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19014 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19015 (cmdline_parse_inst_t *)&cmd_config_mtu,
19016 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19017 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19018 (cmdline_parse_inst_t *)&cmd_config_rss,
19019 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19020 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19021 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19022 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19023 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19024 (cmdline_parse_inst_t *)&cmd_showport_reta,
19025 (cmdline_parse_inst_t *)&cmd_config_burst,
19026 (cmdline_parse_inst_t *)&cmd_config_thresh,
19027 (cmdline_parse_inst_t *)&cmd_config_threshold,
19028 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19029 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19030 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19031 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19032 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19033 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19034 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19035 (cmdline_parse_inst_t *)&cmd_global_config,
19036 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19037 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19038 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19039 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19040 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19041 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19042 (cmdline_parse_inst_t *)&cmd_dump,
19043 (cmdline_parse_inst_t *)&cmd_dump_one,
19044 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19045 (cmdline_parse_inst_t *)&cmd_syn_filter,
19046 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19047 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19048 (cmdline_parse_inst_t *)&cmd_flex_filter,
19049 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19050 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19051 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19052 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19053 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19054 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19055 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19056 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19057 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19058 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19059 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19060 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19061 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19062 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19063 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19064 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19065 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19066 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19067 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19068 (cmdline_parse_inst_t *)&cmd_flow,
19069 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19070 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19071 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19072 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19073 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19074 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19075 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19076 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19077 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19078 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19079 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19080 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19081 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19082 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19083 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19084 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19085 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19086 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19087 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19088 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19089 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19090 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19091 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19092 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19093 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19094 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19095 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19096 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19097 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19098 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19099 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19100 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19101 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19102 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19103 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19104 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19105 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19106 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19107 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19108 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19109 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19110 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19111 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19112 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19113 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19114 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19115 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19116 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19117 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19118 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19119 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19121 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19122 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19123 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19124 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19125 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19126 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19127 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19128 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19129 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19130 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19131 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19132 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19133 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19134 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19135 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19136 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19137 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19138 (cmdline_parse_inst_t *)&cmd_ddp_add,
19139 (cmdline_parse_inst_t *)&cmd_ddp_del,
19140 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19141 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19142 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19143 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19144 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19145 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19146 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19147 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19148 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19149 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19150 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19152 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19153 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19154 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19155 (cmdline_parse_inst_t *)&cmd_queue_region,
19156 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19157 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19158 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19159 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19160 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19161 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19162 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19163 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19164 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19165 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19166 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19167 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19168 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19169 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19170 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19171 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19172 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19173 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19174 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19175 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19176 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19177 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19178 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19179 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19180 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19181 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19182 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19183 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19184 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19185 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19186 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19187 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19188 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19189 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19190 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19191 #ifdef RTE_LIBRTE_BPF
19192 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19193 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19195 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19196 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19197 (cmdline_parse_inst_t *)&cmd_set_raw,
19201 /* read cmdline commands from file */
19203 cmdline_read_from_file(const char *filename)
19205 struct cmdline *cl;
19207 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19209 printf("Failed to create file based cmdline context: %s\n",
19214 cmdline_interact(cl);
19219 printf("Read CLI commands from %s\n", filename);
19222 /* prompt function, called from main on MASTER lcore */
19226 /* initialize non-constant commands */
19227 cmd_set_fwd_mode_init();
19228 cmd_set_fwd_retry_mode_init();
19230 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19231 if (testpmd_cl == NULL)
19233 cmdline_interact(testpmd_cl);
19234 cmdline_stdin_exit(testpmd_cl);
19240 if (testpmd_cl != NULL)
19241 cmdline_quit(testpmd_cl);
19245 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19247 if (id == (portid_t)RTE_PORT_ALL) {
19250 RTE_ETH_FOREACH_DEV(pid) {
19251 /* check if need_reconfig has been set to 1 */
19252 if (ports[pid].need_reconfig == 0)
19253 ports[pid].need_reconfig = dev;
19254 /* check if need_reconfig_queues has been set to 1 */
19255 if (ports[pid].need_reconfig_queues == 0)
19256 ports[pid].need_reconfig_queues = queue;
19258 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19259 /* check if need_reconfig has been set to 1 */
19260 if (ports[id].need_reconfig == 0)
19261 ports[id].need_reconfig = dev;
19262 /* check if need_reconfig_queues has been set to 1 */
19263 if (ports[id].need_reconfig_queues == 0)
19264 ports[id].need_reconfig_queues = queue;