1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
16 #include <net/socket.h>
18 #include <sys/socket.h>
21 #include <netinet/in.h>
23 #include <sys/queue.h>
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
50 #include <cmdline_rdline.h>
51 #include <cmdline_parse.h>
52 #include <cmdline_parse_num.h>
53 #include <cmdline_parse_string.h>
54 #include <cmdline_parse_ipaddr.h>
55 #include <cmdline_parse_etheraddr.h>
56 #include <cmdline_socket.h>
58 #ifdef RTE_LIBRTE_PMD_BOND
59 #include <rte_eth_bond.h>
60 #include <rte_eth_bond_8023ad.h>
62 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
63 #include <rte_pmd_dpaa.h>
65 #ifdef RTE_LIBRTE_IXGBE_PMD
66 #include <rte_pmd_ixgbe.h>
68 #ifdef RTE_LIBRTE_I40E_PMD
69 #include <rte_pmd_i40e.h>
71 #ifdef RTE_LIBRTE_BNXT_PMD
72 #include <rte_pmd_bnxt.h>
75 #include "cmdline_mtr.h"
76 #include "cmdline_tm.h"
79 static struct cmdline *testpmd_cl;
81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
83 /* *** Help command with introduction. *** */
84 struct cmd_help_brief_result {
85 cmdline_fixed_string_t help;
88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
90 __attribute__((unused)) void *data)
95 "Help is available for the following sections:\n\n"
96 " help control : Start and stop forwarding.\n"
97 " help display : Displaying port, stats and config "
99 " help config : Configuration information.\n"
100 " help ports : Configuring ports.\n"
101 " help registers : Reading and setting port registers.\n"
102 " help filters : Filters configuration help.\n"
103 " help all : All of the above sections.\n\n"
108 cmdline_parse_token_string_t cmd_help_brief_help =
109 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
111 cmdline_parse_inst_t cmd_help_brief = {
112 .f = cmd_help_brief_parsed,
114 .help_str = "help: Show help",
116 (void *)&cmd_help_brief_help,
121 /* *** Help command with help sections. *** */
122 struct cmd_help_long_result {
123 cmdline_fixed_string_t help;
124 cmdline_fixed_string_t section;
127 static void cmd_help_long_parsed(void *parsed_result,
129 __attribute__((unused)) void *data)
132 struct cmd_help_long_result *res = parsed_result;
134 if (!strcmp(res->section, "all"))
137 if (show_all || !strcmp(res->section, "control")) {
142 "Control forwarding:\n"
143 "-------------------\n\n"
146 " Start packet forwarding with current configuration.\n\n"
149 " Start packet forwarding with current config"
150 " after sending one burst of packets.\n\n"
153 " Stop packet forwarding, and display accumulated"
157 " Quit to prompt.\n\n"
161 if (show_all || !strcmp(res->section, "display")) {
169 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
170 " Display information for port_id, or all.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
212 "show port tm cap (port_id)\n"
213 " Display the port TM capability.\n\n"
215 "show port tm level cap (port_id) (level_id)\n"
216 " Display the port TM hierarchical level capability.\n\n"
218 "show port tm node cap (port_id) (node_id)\n"
219 " Display the port TM node capability.\n\n"
221 "show port tm node type (port_id) (node_id)\n"
222 " Display the port TM node type.\n\n"
224 "show port tm node stats (port_id) (node_id) (clear)\n"
225 " Display the port TM node stats.\n\n"
227 "show fwd stats all\n"
228 " Display statistics for all fwd engines.\n\n"
230 "clear fwd stats all\n"
231 " Clear statistics for all fwd engines.\n\n"
235 if (show_all || !strcmp(res->section, "config")) {
241 "Configuration changes only become active when"
242 " forwarding is started/restarted.\n\n"
245 " Reset forwarding to the default configuration.\n\n"
247 "set verbose (level)\n"
248 " Set the debug verbosity level X.\n\n"
250 "set log global|(type) (level)\n"
251 " Set the log level.\n\n"
254 " Set number of ports.\n\n"
257 " Set number of cores.\n\n"
259 "set coremask (mask)\n"
260 " Set the forwarding cores hexadecimal mask.\n\n"
262 "set portmask (mask)\n"
263 " Set the forwarding ports hexadecimal mask.\n\n"
266 " Set number of packets per burst.\n\n"
268 "set burst tx delay (microseconds) retry (num)\n"
269 " Set the transmit delay time and number of retries,"
270 " effective when retry is enabled.\n\n"
272 "set txpkts (x[,y]*)\n"
273 " Set the length of each segment of TXONLY"
274 " and optionally CSUM packets.\n\n"
276 "set txsplit (off|on|rand)\n"
277 " Set the split policy for the TX packets."
278 " Right now only applicable for CSUM and TXONLY"
281 "set corelist (x[,y]*)\n"
282 " Set the list of forwarding cores.\n\n"
284 "set portlist (x[,y]*)\n"
285 " Set the list of forwarding ports.\n\n"
287 "set port setup on (iterator|event)\n"
288 " Select how attached port is retrieved for setup.\n\n"
290 "set tx loopback (port_id) (on|off)\n"
291 " Enable or disable tx loopback.\n\n"
293 "set all queues drop (port_id) (on|off)\n"
294 " Set drop enable bit for all queues.\n\n"
296 "set vf split drop (port_id) (vf_id) (on|off)\n"
297 " Set split drop enable bit for a VF from the PF.\n\n"
299 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
300 " Set MAC antispoof for a VF from the PF.\n\n"
302 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
303 " Enable MACsec offload.\n\n"
305 "set macsec offload (port_id) off\n"
306 " Disable MACsec offload.\n\n"
308 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
309 " Configure MACsec secure connection (SC).\n\n"
311 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
312 " Configure MACsec secure association (SA).\n\n"
314 "set vf broadcast (port_id) (vf_id) (on|off)\n"
315 " Set VF broadcast for a VF from the PF.\n\n"
317 "vlan set strip (on|off) (port_id)\n"
318 " Set the VLAN strip on a port.\n\n"
320 "vlan set stripq (on|off) (port_id,queue_id)\n"
321 " Set the VLAN strip for a queue on a port.\n\n"
323 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
324 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
326 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
327 " Set VLAN insert for a VF from the PF.\n\n"
329 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
330 " Set VLAN antispoof for a VF from the PF.\n\n"
332 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
333 " Set VLAN tag for a VF from the PF.\n\n"
335 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
336 " Set a VF's max bandwidth(Mbps).\n\n"
338 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
339 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
341 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
342 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
344 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
345 " Set some TCs' strict link priority mode on a physical port.\n\n"
347 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
348 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
350 "vlan set filter (on|off) (port_id)\n"
351 " Set the VLAN filter on a port.\n\n"
353 "vlan set qinq (on|off) (port_id)\n"
354 " Set the VLAN QinQ (extended queue in queue)"
357 "vlan set (inner|outer) tpid (value) (port_id)\n"
358 " Set the VLAN TPID for Packet Filtering on"
361 "rx_vlan add (vlan_id|all) (port_id)\n"
362 " Add a vlan_id, or all identifiers, to the set"
363 " of VLAN identifiers filtered by port_id.\n\n"
365 "rx_vlan rm (vlan_id|all) (port_id)\n"
366 " Remove a vlan_id, or all identifiers, from the set"
367 " of VLAN identifiers filtered by port_id.\n\n"
369 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
370 " Add a vlan_id, to the set of VLAN identifiers"
371 "filtered for VF(s) from port_id.\n\n"
373 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
374 " Remove a vlan_id, to the set of VLAN identifiers"
375 "filtered for VF(s) from port_id.\n\n"
377 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
378 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
379 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
380 " add a tunnel filter of a port.\n\n"
382 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
383 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
384 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
385 " remove a tunnel filter of a port.\n\n"
387 "rx_vxlan_port add (udp_port) (port_id)\n"
388 " Add an UDP port for VXLAN packet filter on a port\n\n"
390 "rx_vxlan_port rm (udp_port) (port_id)\n"
391 " Remove an UDP port for VXLAN packet filter on a port\n\n"
393 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
394 " Set hardware insertion of VLAN IDs (single or double VLAN "
395 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
397 "tx_vlan set pvid port_id vlan_id (on|off)\n"
398 " Set port based TX VLAN insertion.\n\n"
400 "tx_vlan reset (port_id)\n"
401 " Disable hardware insertion of a VLAN header in"
402 " packets sent on a port.\n\n"
404 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
405 " Select hardware or software calculation of the"
406 " checksum when transmitting a packet using the"
407 " csum forward engine.\n"
408 " ip|udp|tcp|sctp always concern the inner layer.\n"
409 " outer-ip concerns the outer IP layer in"
410 " outer-udp concerns the outer UDP layer in"
411 " case the packet is recognized as a tunnel packet by"
412 " the forward engine (vxlan, gre and ipip are supported)\n"
413 " Please check the NIC datasheet for HW limits.\n\n"
415 "csum parse-tunnel (on|off) (tx_port_id)\n"
416 " If disabled, treat tunnel packets as non-tunneled"
417 " packets (treat inner headers as payload). The port\n"
418 " argument is the port used for TX in csum forward"
421 "csum show (port_id)\n"
422 " Display tx checksum offload configuration\n\n"
424 "tso set (segsize) (portid)\n"
425 " Enable TCP Segmentation Offload in csum forward"
427 " Please check the NIC datasheet for HW limits.\n\n"
430 " Display the status of TCP Segmentation Offload.\n\n"
432 "set port (port_id) gro on|off\n"
433 " Enable or disable Generic Receive Offload in"
434 " csum forwarding engine.\n\n"
436 "show port (port_id) gro\n"
437 " Display GRO configuration.\n\n"
439 "set gro flush (cycles)\n"
440 " Set the cycle to flush GROed packets from"
441 " reassembly tables.\n\n"
443 "set port (port_id) gso (on|off)"
444 " Enable or disable Generic Segmentation Offload in"
445 " csum forwarding engine.\n\n"
447 "set gso segsz (length)\n"
448 " Set max packet length for output GSO segments,"
449 " including packet header and payload.\n\n"
451 "show port (port_id) gso\n"
452 " Show GSO configuration.\n\n"
455 " Set packet forwarding mode.\n\n"
457 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
458 " Add a MAC address on port_id.\n\n"
460 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
461 " Remove a MAC address from port_id.\n\n"
463 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
464 " Set the default MAC address for port_id.\n\n"
466 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
467 " Add a MAC address for a VF on the port.\n\n"
469 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
470 " Set the MAC address for a VF from the PF.\n\n"
472 "set eth-peer (port_id) (peer_addr)\n"
473 " set the peer address for certain port.\n\n"
475 "set port (port_id) uta (mac_address|all) (on|off)\n"
476 " Add/Remove a or all unicast hash filter(s)"
479 "set promisc (port_id|all) (on|off)\n"
480 " Set the promiscuous mode on port_id, or all.\n\n"
482 "set allmulti (port_id|all) (on|off)\n"
483 " Set the allmulti mode on port_id, or all.\n\n"
485 "set vf promisc (port_id) (vf_id) (on|off)\n"
486 " Set unicast promiscuous mode for a VF from the PF.\n\n"
488 "set vf allmulti (port_id) (vf_id) (on|off)\n"
489 " Set multicast promiscuous mode for a VF from the PF.\n\n"
491 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
492 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
493 " (on|off) autoneg (on|off) (port_id)\n"
494 "set flow_ctrl rx (on|off) (portid)\n"
495 "set flow_ctrl tx (on|off) (portid)\n"
496 "set flow_ctrl high_water (high_water) (portid)\n"
497 "set flow_ctrl low_water (low_water) (portid)\n"
498 "set flow_ctrl pause_time (pause_time) (portid)\n"
499 "set flow_ctrl send_xon (send_xon) (portid)\n"
500 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
501 "set flow_ctrl autoneg (on|off) (port_id)\n"
502 " Set the link flow control parameter on a port.\n\n"
504 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
505 " (low_water) (pause_time) (priority) (port_id)\n"
506 " Set the priority flow control parameter on a"
509 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
510 " Set statistics mapping (qmapping 0..15) for RX/TX"
512 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
513 " on port 0 to mapping 5.\n\n"
515 "set xstats-hide-zero on|off\n"
516 " Set the option to hide the zero values"
517 " for xstats display.\n"
519 "set port (port_id) vf (vf_id) rx|tx on|off\n"
520 " Enable/Disable a VF receive/tranmit from a port\n\n"
522 "set port (port_id) vf (vf_id) (mac_addr)"
523 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
524 " Add/Remove unicast or multicast MAC addr filter"
527 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
529 " AUPE:accepts untagged VLAN;"
530 "ROPE:accept unicast hash\n\n"
531 " BAM:accepts broadcast packets;"
532 "MPE:accepts all multicast packets\n\n"
533 " Enable/Disable a VF receive mode of a port\n\n"
535 "set port (port_id) queue (queue_id) rate (rate_num)\n"
536 " Set rate limit for a queue of a port\n\n"
538 "set port (port_id) vf (vf_id) rate (rate_num) "
539 "queue_mask (queue_mask_value)\n"
540 " Set rate limit for queues in VF of a port\n\n"
542 "set port (port_id) mirror-rule (rule_id)"
543 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
544 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
545 " Set pool or vlan type mirror rule on a port.\n"
546 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
547 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
550 "set port (port_id) mirror-rule (rule_id)"
551 " (uplink-mirror|downlink-mirror) dst-pool"
552 " (pool_id) (on|off)\n"
553 " Set uplink or downlink type mirror rule on a port.\n"
554 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
555 " 0 on' enable mirror income traffic to pool 0.\n\n"
557 "reset port (port_id) mirror-rule (rule_id)\n"
558 " Reset a mirror rule.\n\n"
560 "set flush_rx (on|off)\n"
561 " Flush (default) or don't flush RX streams before"
562 " forwarding. Mainly used with PCAP drivers.\n\n"
564 "set bypass mode (normal|bypass|isolate) (port_id)\n"
565 " Set the bypass mode for the lowest port on bypass enabled"
568 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
569 "mode (normal|bypass|isolate) (port_id)\n"
570 " Set the event required to initiate specified bypass mode for"
571 " the lowest port on a bypass enabled NIC where:\n"
572 " timeout = enable bypass after watchdog timeout.\n"
573 " os_on = enable bypass when OS/board is powered on.\n"
574 " os_off = enable bypass when OS/board is powered off.\n"
575 " power_on = enable bypass when power supply is turned on.\n"
576 " power_off = enable bypass when power supply is turned off."
579 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
580 " Set the bypass watchdog timeout to 'n' seconds"
581 " where 0 = instant.\n\n"
583 "show bypass config (port_id)\n"
584 " Show the bypass configuration for a bypass enabled NIC"
585 " using the lowest port on the NIC.\n\n"
587 #ifdef RTE_LIBRTE_PMD_BOND
588 "create bonded device (mode) (socket)\n"
589 " Create a new bonded device with specific bonding mode and socket.\n\n"
591 "add bonding slave (slave_id) (port_id)\n"
592 " Add a slave device to a bonded device.\n\n"
594 "remove bonding slave (slave_id) (port_id)\n"
595 " Remove a slave device from a bonded device.\n\n"
597 "set bonding mode (value) (port_id)\n"
598 " Set the bonding mode on a bonded device.\n\n"
600 "set bonding primary (slave_id) (port_id)\n"
601 " Set the primary slave for a bonded device.\n\n"
603 "show bonding config (port_id)\n"
604 " Show the bonding config for port_id.\n\n"
606 "set bonding mac_addr (port_id) (address)\n"
607 " Set the MAC address of a bonded device.\n\n"
609 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
610 " Set Aggregation mode for IEEE802.3AD (mode 4)"
612 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
613 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
615 "set bonding mon_period (port_id) (value)\n"
616 " Set the bonding link status monitoring polling period in ms.\n\n"
618 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
619 " Enable/disable dedicated queues for LACP control traffic.\n\n"
622 "set link-up port (port_id)\n"
623 " Set link up for a port.\n\n"
625 "set link-down port (port_id)\n"
626 " Set link down for a port.\n\n"
628 "E-tag set insertion on port-tag-id (value)"
629 " port (port_id) vf (vf_id)\n"
630 " Enable E-tag insertion for a VF on a port\n\n"
632 "E-tag set insertion off port (port_id) vf (vf_id)\n"
633 " Disable E-tag insertion for a VF on a port\n\n"
635 "E-tag set stripping (on|off) port (port_id)\n"
636 " Enable/disable E-tag stripping on a port\n\n"
638 "E-tag set forwarding (on|off) port (port_id)\n"
639 " Enable/disable E-tag based forwarding"
642 "E-tag set filter add e-tag-id (value) dst-pool"
643 " (pool_id) port (port_id)\n"
644 " Add an E-tag forwarding filter on a port\n\n"
646 "E-tag set filter del e-tag-id (value) port (port_id)\n"
647 " Delete an E-tag forwarding filter on a port\n\n"
649 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
650 "set port tm hierarchy default (port_id)\n"
651 " Set default traffic Management hierarchy on a port\n\n"
654 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
655 " Load a profile package on a port\n\n"
657 "ddp del (port_id) (backup_profile_path)\n"
658 " Delete a profile package from a port\n\n"
660 "ptype mapping get (port_id) (valid_only)\n"
661 " Get ptype mapping on a port\n\n"
663 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
664 " Replace target with the pkt_type in ptype mapping\n\n"
666 "ptype mapping reset (port_id)\n"
667 " Reset ptype mapping on a port\n\n"
669 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
670 " Update a ptype mapping item on a port\n\n"
672 "set port (port_id) queue-region region_id (value) "
673 "queue_start_index (value) queue_num (value)\n"
674 " Set a queue region on a port\n\n"
676 "set port (port_id) queue-region region_id (value) "
678 " Set a flowtype region index on a port\n\n"
680 "set port (port_id) queue-region UP (value) region_id (value)\n"
681 " Set the mapping of User Priority to "
682 "queue region on a port\n\n"
684 "set port (port_id) queue-region flush (on|off)\n"
685 " flush all queue region related configuration\n\n"
687 "show port meter cap (port_id)\n"
688 " Show port meter capability information\n\n"
690 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
691 " meter profile add - srtcm rfc 2697\n\n"
693 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
694 " meter profile add - trtcm rfc 2698\n\n"
696 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
697 " meter profile add - trtcm rfc 4115\n\n"
699 "del port meter profile (port_id) (profile_id)\n"
700 " meter profile delete\n\n"
702 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
703 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
704 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
705 "(dscp_tbl_entry63)]\n"
708 "enable port meter (port_id) (mtr_id)\n"
711 "disable port meter (port_id) (mtr_id)\n"
714 "del port meter (port_id) (mtr_id)\n"
717 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
718 " meter update meter profile\n\n"
720 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
721 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
722 " update meter dscp table entries\n\n"
724 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
725 "(action0) [(action1) (action2)]\n"
726 " meter update policer action\n\n"
728 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
729 " meter update stats\n\n"
731 "show port (port_id) queue-region\n"
732 " show all queue region related configuration info\n\n"
734 "add port tm node shaper profile (port_id) (shaper_profile_id)"
735 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
736 " (packet_length_adjust)\n"
737 " Add port tm node private shaper profile.\n\n"
739 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
740 " Delete port tm node private shaper profile.\n\n"
742 "add port tm node shared shaper (port_id) (shared_shaper_id)"
743 " (shaper_profile_id)\n"
744 " Add/update port tm node shared shaper.\n\n"
746 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
747 " Delete port tm node shared shaper.\n\n"
749 "set port tm node shaper profile (port_id) (node_id)"
750 " (shaper_profile_id)\n"
751 " Set port tm node shaper profile.\n\n"
753 "add port tm node wred profile (port_id) (wred_profile_id)"
754 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
755 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
756 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
757 " Add port tm node wred profile.\n\n"
759 "del port tm node wred profile (port_id) (wred_profile_id)\n"
760 " Delete port tm node wred profile.\n\n"
762 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
763 " (priority) (weight) (level_id) (shaper_profile_id)"
764 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
765 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
766 " Add port tm nonleaf node.\n\n"
768 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
769 " (priority) (weight) (level_id) (shaper_profile_id)"
770 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
771 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
772 " Add port tm leaf node.\n\n"
774 "del port tm node (port_id) (node_id)\n"
775 " Delete port tm node.\n\n"
777 "set port tm node parent (port_id) (node_id) (parent_node_id)"
778 " (priority) (weight)\n"
779 " Set port tm node parent.\n\n"
781 "suspend port tm node (port_id) (node_id)"
782 " Suspend tm node.\n\n"
784 "resume port tm node (port_id) (node_id)"
785 " Resume tm node.\n\n"
787 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
788 " Commit tm hierarchy.\n\n"
790 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
791 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
792 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
793 " Configure the VXLAN encapsulation for flows.\n\n"
795 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
796 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
797 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
798 " eth-dst (eth-dst)\n"
799 " Configure the VXLAN encapsulation for flows.\n\n"
801 "vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
802 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
803 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
804 " eth-dst (eth-dst)\n"
805 " Configure the VXLAN encapsulation for flows.\n\n"
807 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
808 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
810 " Configure the NVGRE encapsulation for flows.\n\n"
812 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
813 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
814 " eth-src (eth-src) eth-dst (eth-dst)\n"
815 " Configure the NVGRE encapsulation for flows.\n\n"
817 , list_pkt_forwarding_modes()
821 if (show_all || !strcmp(res->section, "ports")) {
827 "----------------\n\n"
829 "port start (port_id|all)\n"
830 " Start all ports or port_id.\n\n"
832 "port stop (port_id|all)\n"
833 " Stop all ports or port_id.\n\n"
835 "port close (port_id|all)\n"
836 " Close all ports or port_id.\n\n"
838 "port attach (ident)\n"
839 " Attach physical or virtual dev by pci address or virtual device name\n\n"
841 "port detach (port_id)\n"
842 " Detach physical or virtual dev by port_id\n\n"
844 "port config (port_id|all)"
845 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
846 " duplex (half|full|auto)\n"
847 " Set speed and duplex for all ports or port_id\n\n"
849 "port config (port_id|all) loopback (mode)\n"
850 " Set loopback mode for all ports or port_id\n\n"
852 "port config all (rxq|txq|rxd|txd) (value)\n"
853 " Set number for rxq/txq/rxd/txd.\n\n"
855 "port config all max-pkt-len (value)\n"
856 " Set the max packet length.\n\n"
858 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
859 "hw-vlan-strip|hw-vlan-extend|drop-en)"
861 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
864 "port config all rss (all|default|ip|tcp|udp|sctp|"
865 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
866 " Set the RSS mode.\n\n"
868 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
869 " Set the RSS redirection table.\n\n"
871 "port config (port_id) dcb vt (on|off) (traffic_class)"
873 " Set the DCB mode.\n\n"
875 "port config all burst (value)\n"
876 " Set the number of packets per burst.\n\n"
878 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
880 " Set the ring prefetch/host/writeback threshold"
881 " for tx/rx queue.\n\n"
883 "port config all (txfreet|txrst|rxfreet) (value)\n"
884 " Set free threshold for rx/tx, or set"
885 " tx rs bit threshold.\n\n"
886 "port config mtu X value\n"
887 " Set the MTU of port X to a given value\n\n"
889 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
890 " Set a rx/tx queue's ring size configuration, the new"
891 " value will take effect after command that (re-)start the port"
892 " or command that setup the specific queue\n\n"
894 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
895 " Start/stop a rx/tx queue of port X. Only take effect"
896 " when port X is started\n\n"
898 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
899 " Switch on/off a deferred start of port X rx/tx queue. Only"
900 " take effect when port X is stopped.\n\n"
902 "port (port_id) (rxq|txq) (queue_id) setup\n"
903 " Setup a rx/tx queue of port X.\n\n"
905 "port config (port_id|all) l2-tunnel E-tag ether-type"
907 " Set the value of E-tag ether-type.\n\n"
909 "port config (port_id|all) l2-tunnel E-tag"
910 " (enable|disable)\n"
911 " Enable/disable the E-tag support.\n\n"
913 "port config (port_id) pctype mapping reset\n"
914 " Reset flow type to pctype mapping on a port\n\n"
916 "port config (port_id) pctype mapping update"
917 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
918 " Update a flow type to pctype mapping item on a port\n\n"
920 "port config (port_id) pctype (pctype_id) hash_inset|"
921 "fdir_inset|fdir_flx_inset get|set|clear field\n"
923 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
925 "port config (port_id) pctype (pctype_id) hash_inset|"
926 "fdir_inset|fdir_flx_inset clear all"
927 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
929 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
930 " Add/remove UDP tunnel port for tunneling offload\n\n"
934 if (show_all || !strcmp(res->section, "registers")) {
942 "read reg (port_id) (address)\n"
943 " Display value of a port register.\n\n"
945 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
946 " Display a port register bit field.\n\n"
948 "read regbit (port_id) (address) (bit_x)\n"
949 " Display a single port register bit.\n\n"
951 "write reg (port_id) (address) (value)\n"
952 " Set value of a port register.\n\n"
954 "write regfield (port_id) (address) (bit_x) (bit_y)"
956 " Set bit field of a port register.\n\n"
958 "write regbit (port_id) (address) (bit_x) (value)\n"
959 " Set single bit value of a port register.\n\n"
962 if (show_all || !strcmp(res->section, "filters")) {
970 "ethertype_filter (port_id) (add|del)"
971 " (mac_addr|mac_ignr) (mac_address) ethertype"
972 " (ether_type) (drop|fwd) queue (queue_id)\n"
973 " Add/Del an ethertype filter.\n\n"
975 "2tuple_filter (port_id) (add|del)"
976 " dst_port (dst_port_value) protocol (protocol_value)"
977 " mask (mask_value) tcp_flags (tcp_flags_value)"
978 " priority (prio_value) queue (queue_id)\n"
979 " Add/Del a 2tuple filter.\n\n"
981 "5tuple_filter (port_id) (add|del)"
982 " dst_ip (dst_address) src_ip (src_address)"
983 " dst_port (dst_port_value) src_port (src_port_value)"
984 " protocol (protocol_value)"
985 " mask (mask_value) tcp_flags (tcp_flags_value)"
986 " priority (prio_value) queue (queue_id)\n"
987 " Add/Del a 5tuple filter.\n\n"
989 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
990 " Add/Del syn filter.\n\n"
992 "flex_filter (port_id) (add|del) len (len_value)"
993 " bytes (bytes_value) mask (mask_value)"
994 " priority (prio_value) queue (queue_id)\n"
995 " Add/Del a flex filter.\n\n"
997 "flow_director_filter (port_id) mode IP (add|del|update)"
998 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
999 " src (src_ip_address) dst (dst_ip_address)"
1000 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
1001 " vlan (vlan_value) flexbytes (flexbytes_value)"
1002 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1003 " fd_id (fd_id_value)\n"
1004 " Add/Del an IP type flow director filter.\n\n"
1006 "flow_director_filter (port_id) mode IP (add|del|update)"
1007 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1008 " src (src_ip_address) (src_port)"
1009 " dst (dst_ip_address) (dst_port)"
1010 " tos (tos_value) ttl (ttl_value)"
1011 " vlan (vlan_value) flexbytes (flexbytes_value)"
1012 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1013 " fd_id (fd_id_value)\n"
1014 " Add/Del an UDP/TCP type flow director filter.\n\n"
1016 "flow_director_filter (port_id) mode IP (add|del|update)"
1017 " flow (ipv4-sctp|ipv6-sctp)"
1018 " src (src_ip_address) (src_port)"
1019 " dst (dst_ip_address) (dst_port)"
1020 " tag (verification_tag) "
1021 " tos (tos_value) ttl (ttl_value)"
1022 " vlan (vlan_value)"
1023 " flexbytes (flexbytes_value) (drop|fwd)"
1024 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1025 " Add/Del a SCTP type flow director filter.\n\n"
1027 "flow_director_filter (port_id) mode IP (add|del|update)"
1028 " flow l2_payload ether (ethertype)"
1029 " flexbytes (flexbytes_value) (drop|fwd)"
1030 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1031 " Add/Del a l2 payload type flow director filter.\n\n"
1033 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1034 " mac (mac_address) vlan (vlan_value)"
1035 " flexbytes (flexbytes_value) (drop|fwd)"
1036 " queue (queue_id) fd_id (fd_id_value)\n"
1037 " Add/Del a MAC-VLAN flow director filter.\n\n"
1039 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1040 " mac (mac_address) vlan (vlan_value)"
1041 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1042 " flexbytes (flexbytes_value) (drop|fwd)"
1043 " queue (queue_id) fd_id (fd_id_value)\n"
1044 " Add/Del a Tunnel flow director filter.\n\n"
1046 "flow_director_filter (port_id) mode raw (add|del|update)"
1047 " flow (flow_id) (drop|fwd) queue (queue_id)"
1048 " fd_id (fd_id_value) packet (packet file name)\n"
1049 " Add/Del a raw type flow director filter.\n\n"
1051 "flush_flow_director (port_id)\n"
1052 " Flush all flow director entries of a device.\n\n"
1054 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1055 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1056 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1057 " Set flow director IP mask.\n\n"
1059 "flow_director_mask (port_id) mode MAC-VLAN"
1060 " vlan (vlan_value)\n"
1061 " Set flow director MAC-VLAN mask.\n\n"
1063 "flow_director_mask (port_id) mode Tunnel"
1064 " vlan (vlan_value) mac (mac_value)"
1065 " tunnel-type (tunnel_type_value)"
1066 " tunnel-id (tunnel_id_value)\n"
1067 " Set flow director Tunnel mask.\n\n"
1069 "flow_director_flex_mask (port_id)"
1070 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1071 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1073 " Configure mask of flex payload.\n\n"
1075 "flow_director_flex_payload (port_id)"
1076 " (raw|l2|l3|l4) (config)\n"
1077 " Configure flex payload selection.\n\n"
1079 "get_sym_hash_ena_per_port (port_id)\n"
1080 " get symmetric hash enable configuration per port.\n\n"
1082 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1083 " set symmetric hash enable configuration per port"
1084 " to enable or disable.\n\n"
1086 "get_hash_global_config (port_id)\n"
1087 " Get the global configurations of hash filters.\n\n"
1089 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1090 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1091 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1092 " (enable|disable)\n"
1093 " Set the global configurations of hash filters.\n\n"
1095 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1096 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1097 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1098 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1099 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1100 "ipv6-next-header|udp-src-port|udp-dst-port|"
1101 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1102 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1103 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1104 "fld-8th|none) (select|add)\n"
1105 " Set the input set for hash.\n\n"
1107 "set_fdir_input_set (port_id) "
1108 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1109 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1110 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1111 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1112 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1113 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1114 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1116 " Set the input set for FDir.\n\n"
1118 "flow validate {port_id}"
1119 " [group {group_id}] [priority {level}]"
1120 " [ingress] [egress]"
1121 " pattern {item} [/ {item} [...]] / end"
1122 " actions {action} [/ {action} [...]] / end\n"
1123 " Check whether a flow rule can be created.\n\n"
1125 "flow create {port_id}"
1126 " [group {group_id}] [priority {level}]"
1127 " [ingress] [egress]"
1128 " pattern {item} [/ {item} [...]] / end"
1129 " actions {action} [/ {action} [...]] / end\n"
1130 " Create a flow rule.\n\n"
1132 "flow destroy {port_id} rule {rule_id} [...]\n"
1133 " Destroy specific flow rules.\n\n"
1135 "flow flush {port_id}\n"
1136 " Destroy all flow rules.\n\n"
1138 "flow query {port_id} {rule_id} {action}\n"
1139 " Query an existing flow rule.\n\n"
1141 "flow list {port_id} [group {group_id}] [...]\n"
1142 " List existing flow rules sorted by priority,"
1143 " filtered by group identifiers.\n\n"
1145 "flow isolate {port_id} {boolean}\n"
1146 " Restrict ingress traffic to the defined"
1152 cmdline_parse_token_string_t cmd_help_long_help =
1153 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1155 cmdline_parse_token_string_t cmd_help_long_section =
1156 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1157 "all#control#display#config#"
1158 "ports#registers#filters");
1160 cmdline_parse_inst_t cmd_help_long = {
1161 .f = cmd_help_long_parsed,
1163 .help_str = "help all|control|display|config|ports|register|filters: "
1166 (void *)&cmd_help_long_help,
1167 (void *)&cmd_help_long_section,
1173 /* *** start/stop/close all ports *** */
1174 struct cmd_operate_port_result {
1175 cmdline_fixed_string_t keyword;
1176 cmdline_fixed_string_t name;
1177 cmdline_fixed_string_t value;
1180 static void cmd_operate_port_parsed(void *parsed_result,
1181 __attribute__((unused)) struct cmdline *cl,
1182 __attribute__((unused)) void *data)
1184 struct cmd_operate_port_result *res = parsed_result;
1186 if (!strcmp(res->name, "start"))
1187 start_port(RTE_PORT_ALL);
1188 else if (!strcmp(res->name, "stop"))
1189 stop_port(RTE_PORT_ALL);
1190 else if (!strcmp(res->name, "close"))
1191 close_port(RTE_PORT_ALL);
1192 else if (!strcmp(res->name, "reset"))
1193 reset_port(RTE_PORT_ALL);
1195 printf("Unknown parameter\n");
1198 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1199 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1201 cmdline_parse_token_string_t cmd_operate_port_all_port =
1202 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1203 "start#stop#close#reset");
1204 cmdline_parse_token_string_t cmd_operate_port_all_all =
1205 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1207 cmdline_parse_inst_t cmd_operate_port = {
1208 .f = cmd_operate_port_parsed,
1210 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1212 (void *)&cmd_operate_port_all_cmd,
1213 (void *)&cmd_operate_port_all_port,
1214 (void *)&cmd_operate_port_all_all,
1219 /* *** start/stop/close specific port *** */
1220 struct cmd_operate_specific_port_result {
1221 cmdline_fixed_string_t keyword;
1222 cmdline_fixed_string_t name;
1226 static void cmd_operate_specific_port_parsed(void *parsed_result,
1227 __attribute__((unused)) struct cmdline *cl,
1228 __attribute__((unused)) void *data)
1230 struct cmd_operate_specific_port_result *res = parsed_result;
1232 if (!strcmp(res->name, "start"))
1233 start_port(res->value);
1234 else if (!strcmp(res->name, "stop"))
1235 stop_port(res->value);
1236 else if (!strcmp(res->name, "close"))
1237 close_port(res->value);
1238 else if (!strcmp(res->name, "reset"))
1239 reset_port(res->value);
1241 printf("Unknown parameter\n");
1244 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1245 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1247 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1248 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1249 name, "start#stop#close#reset");
1250 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1251 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1254 cmdline_parse_inst_t cmd_operate_specific_port = {
1255 .f = cmd_operate_specific_port_parsed,
1257 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1259 (void *)&cmd_operate_specific_port_cmd,
1260 (void *)&cmd_operate_specific_port_port,
1261 (void *)&cmd_operate_specific_port_id,
1266 /* *** enable port setup (after attach) via iterator or event *** */
1267 struct cmd_set_port_setup_on_result {
1268 cmdline_fixed_string_t set;
1269 cmdline_fixed_string_t port;
1270 cmdline_fixed_string_t setup;
1271 cmdline_fixed_string_t on;
1272 cmdline_fixed_string_t mode;
1275 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1276 __attribute__((unused)) struct cmdline *cl,
1277 __attribute__((unused)) void *data)
1279 struct cmd_set_port_setup_on_result *res = parsed_result;
1281 if (strcmp(res->mode, "event") == 0)
1282 setup_on_probe_event = true;
1283 else if (strcmp(res->mode, "iterator") == 0)
1284 setup_on_probe_event = false;
1286 printf("Unknown mode\n");
1289 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1290 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1292 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1293 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1295 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1296 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1298 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1299 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1301 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1302 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1303 mode, "iterator#event");
1305 cmdline_parse_inst_t cmd_set_port_setup_on = {
1306 .f = cmd_set_port_setup_on_parsed,
1308 .help_str = "set port setup on iterator|event",
1310 (void *)&cmd_set_port_setup_on_set,
1311 (void *)&cmd_set_port_setup_on_port,
1312 (void *)&cmd_set_port_setup_on_setup,
1313 (void *)&cmd_set_port_setup_on_on,
1314 (void *)&cmd_set_port_setup_on_mode,
1319 /* *** attach a specified port *** */
1320 struct cmd_operate_attach_port_result {
1321 cmdline_fixed_string_t port;
1322 cmdline_fixed_string_t keyword;
1323 cmdline_fixed_string_t identifier;
1326 static void cmd_operate_attach_port_parsed(void *parsed_result,
1327 __attribute__((unused)) struct cmdline *cl,
1328 __attribute__((unused)) void *data)
1330 struct cmd_operate_attach_port_result *res = parsed_result;
1332 if (!strcmp(res->keyword, "attach"))
1333 attach_port(res->identifier);
1335 printf("Unknown parameter\n");
1338 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1339 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1341 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1342 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1344 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1345 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1348 cmdline_parse_inst_t cmd_operate_attach_port = {
1349 .f = cmd_operate_attach_port_parsed,
1351 .help_str = "port attach <identifier>: "
1352 "(identifier: pci address or virtual dev name)",
1354 (void *)&cmd_operate_attach_port_port,
1355 (void *)&cmd_operate_attach_port_keyword,
1356 (void *)&cmd_operate_attach_port_identifier,
1361 /* *** detach a specified port *** */
1362 struct cmd_operate_detach_port_result {
1363 cmdline_fixed_string_t port;
1364 cmdline_fixed_string_t keyword;
1368 static void cmd_operate_detach_port_parsed(void *parsed_result,
1369 __attribute__((unused)) struct cmdline *cl,
1370 __attribute__((unused)) void *data)
1372 struct cmd_operate_detach_port_result *res = parsed_result;
1374 if (!strcmp(res->keyword, "detach"))
1375 detach_port_device(res->port_id);
1377 printf("Unknown parameter\n");
1380 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1381 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1383 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1384 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1386 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1387 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1390 cmdline_parse_inst_t cmd_operate_detach_port = {
1391 .f = cmd_operate_detach_port_parsed,
1393 .help_str = "port detach <port_id>",
1395 (void *)&cmd_operate_detach_port_port,
1396 (void *)&cmd_operate_detach_port_keyword,
1397 (void *)&cmd_operate_detach_port_port_id,
1402 /* *** configure speed for all ports *** */
1403 struct cmd_config_speed_all {
1404 cmdline_fixed_string_t port;
1405 cmdline_fixed_string_t keyword;
1406 cmdline_fixed_string_t all;
1407 cmdline_fixed_string_t item1;
1408 cmdline_fixed_string_t item2;
1409 cmdline_fixed_string_t value1;
1410 cmdline_fixed_string_t value2;
1414 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1419 if (!strcmp(duplexstr, "half")) {
1420 duplex = ETH_LINK_HALF_DUPLEX;
1421 } else if (!strcmp(duplexstr, "full")) {
1422 duplex = ETH_LINK_FULL_DUPLEX;
1423 } else if (!strcmp(duplexstr, "auto")) {
1424 duplex = ETH_LINK_FULL_DUPLEX;
1426 printf("Unknown duplex parameter\n");
1430 if (!strcmp(speedstr, "10")) {
1431 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1432 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1433 } else if (!strcmp(speedstr, "100")) {
1434 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1435 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1437 if (duplex != ETH_LINK_FULL_DUPLEX) {
1438 printf("Invalid speed/duplex parameters\n");
1441 if (!strcmp(speedstr, "1000")) {
1442 *speed = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_FIXED;
1443 } else if (!strcmp(speedstr, "10000")) {
1444 *speed = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_FIXED;
1445 } else if (!strcmp(speedstr, "25000")) {
1446 *speed = ETH_LINK_SPEED_25G | ETH_LINK_SPEED_FIXED;
1447 } else if (!strcmp(speedstr, "40000")) {
1448 *speed = ETH_LINK_SPEED_40G | ETH_LINK_SPEED_FIXED;
1449 } else if (!strcmp(speedstr, "50000")) {
1450 *speed = ETH_LINK_SPEED_50G | ETH_LINK_SPEED_FIXED;
1451 } else if (!strcmp(speedstr, "100000")) {
1452 *speed = ETH_LINK_SPEED_100G | ETH_LINK_SPEED_FIXED;
1453 } else if (!strcmp(speedstr, "auto")) {
1454 *speed = ETH_LINK_SPEED_AUTONEG;
1456 printf("Unknown speed parameter\n");
1465 cmd_config_speed_all_parsed(void *parsed_result,
1466 __attribute__((unused)) struct cmdline *cl,
1467 __attribute__((unused)) void *data)
1469 struct cmd_config_speed_all *res = parsed_result;
1470 uint32_t link_speed;
1473 if (!all_ports_stopped()) {
1474 printf("Please stop all ports first\n");
1478 if (parse_and_check_speed_duplex(res->value1, res->value2,
1482 RTE_ETH_FOREACH_DEV(pid) {
1483 ports[pid].dev_conf.link_speeds = link_speed;
1486 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1489 cmdline_parse_token_string_t cmd_config_speed_all_port =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1491 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1492 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1494 cmdline_parse_token_string_t cmd_config_speed_all_all =
1495 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1496 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1497 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1498 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1499 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1500 "10#100#1000#10000#25000#40000#50000#100000#auto");
1501 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1502 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1503 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1504 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1507 cmdline_parse_inst_t cmd_config_speed_all = {
1508 .f = cmd_config_speed_all_parsed,
1510 .help_str = "port config all speed "
1511 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1514 (void *)&cmd_config_speed_all_port,
1515 (void *)&cmd_config_speed_all_keyword,
1516 (void *)&cmd_config_speed_all_all,
1517 (void *)&cmd_config_speed_all_item1,
1518 (void *)&cmd_config_speed_all_value1,
1519 (void *)&cmd_config_speed_all_item2,
1520 (void *)&cmd_config_speed_all_value2,
1525 /* *** configure speed for specific port *** */
1526 struct cmd_config_speed_specific {
1527 cmdline_fixed_string_t port;
1528 cmdline_fixed_string_t keyword;
1530 cmdline_fixed_string_t item1;
1531 cmdline_fixed_string_t item2;
1532 cmdline_fixed_string_t value1;
1533 cmdline_fixed_string_t value2;
1537 cmd_config_speed_specific_parsed(void *parsed_result,
1538 __attribute__((unused)) struct cmdline *cl,
1539 __attribute__((unused)) void *data)
1541 struct cmd_config_speed_specific *res = parsed_result;
1542 uint32_t link_speed;
1544 if (!all_ports_stopped()) {
1545 printf("Please stop all ports first\n");
1549 if (port_id_is_invalid(res->id, ENABLED_WARN))
1552 if (parse_and_check_speed_duplex(res->value1, res->value2,
1556 ports[res->id].dev_conf.link_speeds = link_speed;
1558 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1562 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1565 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1568 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1569 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1570 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1573 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1575 "10#100#1000#10000#25000#40000#50000#100000#auto");
1576 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1577 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1579 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1583 cmdline_parse_inst_t cmd_config_speed_specific = {
1584 .f = cmd_config_speed_specific_parsed,
1586 .help_str = "port config <port_id> speed "
1587 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1590 (void *)&cmd_config_speed_specific_port,
1591 (void *)&cmd_config_speed_specific_keyword,
1592 (void *)&cmd_config_speed_specific_id,
1593 (void *)&cmd_config_speed_specific_item1,
1594 (void *)&cmd_config_speed_specific_value1,
1595 (void *)&cmd_config_speed_specific_item2,
1596 (void *)&cmd_config_speed_specific_value2,
1601 /* *** configure loopback for all ports *** */
1602 struct cmd_config_loopback_all {
1603 cmdline_fixed_string_t port;
1604 cmdline_fixed_string_t keyword;
1605 cmdline_fixed_string_t all;
1606 cmdline_fixed_string_t item;
1611 cmd_config_loopback_all_parsed(void *parsed_result,
1612 __attribute__((unused)) struct cmdline *cl,
1613 __attribute__((unused)) void *data)
1615 struct cmd_config_loopback_all *res = parsed_result;
1618 if (!all_ports_stopped()) {
1619 printf("Please stop all ports first\n");
1623 RTE_ETH_FOREACH_DEV(pid) {
1624 ports[pid].dev_conf.lpbk_mode = res->mode;
1627 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1630 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1632 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1633 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1635 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1636 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1637 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1638 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1640 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1641 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1643 cmdline_parse_inst_t cmd_config_loopback_all = {
1644 .f = cmd_config_loopback_all_parsed,
1646 .help_str = "port config all loopback <mode>",
1648 (void *)&cmd_config_loopback_all_port,
1649 (void *)&cmd_config_loopback_all_keyword,
1650 (void *)&cmd_config_loopback_all_all,
1651 (void *)&cmd_config_loopback_all_item,
1652 (void *)&cmd_config_loopback_all_mode,
1657 /* *** configure loopback for specific port *** */
1658 struct cmd_config_loopback_specific {
1659 cmdline_fixed_string_t port;
1660 cmdline_fixed_string_t keyword;
1662 cmdline_fixed_string_t item;
1667 cmd_config_loopback_specific_parsed(void *parsed_result,
1668 __attribute__((unused)) struct cmdline *cl,
1669 __attribute__((unused)) void *data)
1671 struct cmd_config_loopback_specific *res = parsed_result;
1673 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1676 if (!port_is_stopped(res->port_id)) {
1677 printf("Please stop port %u first\n", res->port_id);
1681 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1683 cmd_reconfig_device_queue(res->port_id, 1, 1);
1687 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1688 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1690 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1691 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1693 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1694 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1696 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1697 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1699 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1700 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1703 cmdline_parse_inst_t cmd_config_loopback_specific = {
1704 .f = cmd_config_loopback_specific_parsed,
1706 .help_str = "port config <port_id> loopback <mode>",
1708 (void *)&cmd_config_loopback_specific_port,
1709 (void *)&cmd_config_loopback_specific_keyword,
1710 (void *)&cmd_config_loopback_specific_id,
1711 (void *)&cmd_config_loopback_specific_item,
1712 (void *)&cmd_config_loopback_specific_mode,
1717 /* *** configure txq/rxq, txd/rxd *** */
1718 struct cmd_config_rx_tx {
1719 cmdline_fixed_string_t port;
1720 cmdline_fixed_string_t keyword;
1721 cmdline_fixed_string_t all;
1722 cmdline_fixed_string_t name;
1727 cmd_config_rx_tx_parsed(void *parsed_result,
1728 __attribute__((unused)) struct cmdline *cl,
1729 __attribute__((unused)) void *data)
1731 struct cmd_config_rx_tx *res = parsed_result;
1733 if (!all_ports_stopped()) {
1734 printf("Please stop all ports first\n");
1737 if (!strcmp(res->name, "rxq")) {
1738 if (!res->value && !nb_txq) {
1739 printf("Warning: Either rx or tx queues should be non zero\n");
1742 if (check_nb_rxq(res->value) != 0)
1744 nb_rxq = res->value;
1746 else if (!strcmp(res->name, "txq")) {
1747 if (!res->value && !nb_rxq) {
1748 printf("Warning: Either rx or tx queues should be non zero\n");
1751 if (check_nb_txq(res->value) != 0)
1753 nb_txq = res->value;
1755 else if (!strcmp(res->name, "rxd")) {
1756 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1757 printf("rxd %d invalid - must be > 0 && <= %d\n",
1758 res->value, RTE_TEST_RX_DESC_MAX);
1761 nb_rxd = res->value;
1762 } else if (!strcmp(res->name, "txd")) {
1763 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1764 printf("txd %d invalid - must be > 0 && <= %d\n",
1765 res->value, RTE_TEST_TX_DESC_MAX);
1768 nb_txd = res->value;
1770 printf("Unknown parameter\n");
1778 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1781 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1783 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1784 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1785 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1786 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1787 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1790 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1791 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1793 cmdline_parse_inst_t cmd_config_rx_tx = {
1794 .f = cmd_config_rx_tx_parsed,
1796 .help_str = "port config all rxq|txq|rxd|txd <value>",
1798 (void *)&cmd_config_rx_tx_port,
1799 (void *)&cmd_config_rx_tx_keyword,
1800 (void *)&cmd_config_rx_tx_all,
1801 (void *)&cmd_config_rx_tx_name,
1802 (void *)&cmd_config_rx_tx_value,
1807 /* *** config max packet length *** */
1808 struct cmd_config_max_pkt_len_result {
1809 cmdline_fixed_string_t port;
1810 cmdline_fixed_string_t keyword;
1811 cmdline_fixed_string_t all;
1812 cmdline_fixed_string_t name;
1817 cmd_config_max_pkt_len_parsed(void *parsed_result,
1818 __attribute__((unused)) struct cmdline *cl,
1819 __attribute__((unused)) void *data)
1821 struct cmd_config_max_pkt_len_result *res = parsed_result;
1824 if (!all_ports_stopped()) {
1825 printf("Please stop all ports first\n");
1829 RTE_ETH_FOREACH_DEV(pid) {
1830 struct rte_port *port = &ports[pid];
1831 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1833 if (!strcmp(res->name, "max-pkt-len")) {
1834 if (res->value < ETHER_MIN_LEN) {
1835 printf("max-pkt-len can not be less than %d\n",
1839 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1842 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1843 if (res->value > ETHER_MAX_LEN)
1844 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1846 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1847 port->dev_conf.rxmode.offloads = rx_offloads;
1849 printf("Unknown parameter\n");
1856 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1859 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1862 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1863 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1865 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1868 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1869 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1871 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1872 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1875 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1876 .f = cmd_config_max_pkt_len_parsed,
1878 .help_str = "port config all max-pkt-len <value>",
1880 (void *)&cmd_config_max_pkt_len_port,
1881 (void *)&cmd_config_max_pkt_len_keyword,
1882 (void *)&cmd_config_max_pkt_len_all,
1883 (void *)&cmd_config_max_pkt_len_name,
1884 (void *)&cmd_config_max_pkt_len_value,
1889 /* *** configure port MTU *** */
1890 struct cmd_config_mtu_result {
1891 cmdline_fixed_string_t port;
1892 cmdline_fixed_string_t keyword;
1893 cmdline_fixed_string_t mtu;
1899 cmd_config_mtu_parsed(void *parsed_result,
1900 __attribute__((unused)) struct cmdline *cl,
1901 __attribute__((unused)) void *data)
1903 struct cmd_config_mtu_result *res = parsed_result;
1905 if (res->value < ETHER_MIN_LEN) {
1906 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1909 port_mtu_set(res->port_id, res->value);
1912 cmdline_parse_token_string_t cmd_config_mtu_port =
1913 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1915 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1916 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1918 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1919 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1921 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1922 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1923 cmdline_parse_token_num_t cmd_config_mtu_value =
1924 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1926 cmdline_parse_inst_t cmd_config_mtu = {
1927 .f = cmd_config_mtu_parsed,
1929 .help_str = "port config mtu <port_id> <value>",
1931 (void *)&cmd_config_mtu_port,
1932 (void *)&cmd_config_mtu_keyword,
1933 (void *)&cmd_config_mtu_mtu,
1934 (void *)&cmd_config_mtu_port_id,
1935 (void *)&cmd_config_mtu_value,
1940 /* *** configure rx mode *** */
1941 struct cmd_config_rx_mode_flag {
1942 cmdline_fixed_string_t port;
1943 cmdline_fixed_string_t keyword;
1944 cmdline_fixed_string_t all;
1945 cmdline_fixed_string_t name;
1946 cmdline_fixed_string_t value;
1950 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1951 __attribute__((unused)) struct cmdline *cl,
1952 __attribute__((unused)) void *data)
1954 struct cmd_config_rx_mode_flag *res = parsed_result;
1957 if (!all_ports_stopped()) {
1958 printf("Please stop all ports first\n");
1962 RTE_ETH_FOREACH_DEV(pid) {
1963 struct rte_port *port;
1964 uint64_t rx_offloads;
1967 rx_offloads = port->dev_conf.rxmode.offloads;
1968 if (!strcmp(res->name, "crc-strip")) {
1969 if (!strcmp(res->value, "on")) {
1970 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
1971 } else if (!strcmp(res->value, "off")) {
1972 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
1974 printf("Unknown parameter\n");
1977 } else if (!strcmp(res->name, "scatter")) {
1978 if (!strcmp(res->value, "on")) {
1979 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1980 } else if (!strcmp(res->value, "off")) {
1981 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1983 printf("Unknown parameter\n");
1986 } else if (!strcmp(res->name, "rx-cksum")) {
1987 if (!strcmp(res->value, "on"))
1988 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1989 else if (!strcmp(res->value, "off"))
1990 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1992 printf("Unknown parameter\n");
1995 } else if (!strcmp(res->name, "rx-timestamp")) {
1996 if (!strcmp(res->value, "on"))
1997 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1998 else if (!strcmp(res->value, "off"))
1999 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
2001 printf("Unknown parameter\n");
2004 } else if (!strcmp(res->name, "hw-vlan")) {
2005 if (!strcmp(res->value, "on")) {
2006 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
2007 DEV_RX_OFFLOAD_VLAN_STRIP);
2008 } else if (!strcmp(res->value, "off")) {
2009 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
2010 DEV_RX_OFFLOAD_VLAN_STRIP);
2012 printf("Unknown parameter\n");
2015 } else if (!strcmp(res->name, "hw-vlan-filter")) {
2016 if (!strcmp(res->value, "on"))
2017 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2018 else if (!strcmp(res->value, "off"))
2019 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2021 printf("Unknown parameter\n");
2024 } else if (!strcmp(res->name, "hw-vlan-strip")) {
2025 if (!strcmp(res->value, "on"))
2026 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2027 else if (!strcmp(res->value, "off"))
2028 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2030 printf("Unknown parameter\n");
2033 } else if (!strcmp(res->name, "hw-vlan-extend")) {
2034 if (!strcmp(res->value, "on"))
2035 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2036 else if (!strcmp(res->value, "off"))
2037 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2039 printf("Unknown parameter\n");
2042 } else if (!strcmp(res->name, "drop-en")) {
2043 if (!strcmp(res->value, "on"))
2045 else if (!strcmp(res->value, "off"))
2048 printf("Unknown parameter\n");
2052 printf("Unknown parameter\n");
2055 port->dev_conf.rxmode.offloads = rx_offloads;
2060 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2063 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2065 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2066 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2068 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2070 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2071 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2072 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2073 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2074 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2075 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2078 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2079 .f = cmd_config_rx_mode_flag_parsed,
2081 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2082 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2084 (void *)&cmd_config_rx_mode_flag_port,
2085 (void *)&cmd_config_rx_mode_flag_keyword,
2086 (void *)&cmd_config_rx_mode_flag_all,
2087 (void *)&cmd_config_rx_mode_flag_name,
2088 (void *)&cmd_config_rx_mode_flag_value,
2093 /* *** configure rss *** */
2094 struct cmd_config_rss {
2095 cmdline_fixed_string_t port;
2096 cmdline_fixed_string_t keyword;
2097 cmdline_fixed_string_t all;
2098 cmdline_fixed_string_t name;
2099 cmdline_fixed_string_t value;
2103 cmd_config_rss_parsed(void *parsed_result,
2104 __attribute__((unused)) struct cmdline *cl,
2105 __attribute__((unused)) void *data)
2107 struct cmd_config_rss *res = parsed_result;
2108 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2109 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2110 int use_default = 0;
2111 int all_updated = 1;
2115 if (!strcmp(res->value, "all"))
2116 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2117 ETH_RSS_UDP | ETH_RSS_SCTP |
2119 else if (!strcmp(res->value, "ip"))
2120 rss_conf.rss_hf = ETH_RSS_IP;
2121 else if (!strcmp(res->value, "udp"))
2122 rss_conf.rss_hf = ETH_RSS_UDP;
2123 else if (!strcmp(res->value, "tcp"))
2124 rss_conf.rss_hf = ETH_RSS_TCP;
2125 else if (!strcmp(res->value, "sctp"))
2126 rss_conf.rss_hf = ETH_RSS_SCTP;
2127 else if (!strcmp(res->value, "ether"))
2128 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2129 else if (!strcmp(res->value, "port"))
2130 rss_conf.rss_hf = ETH_RSS_PORT;
2131 else if (!strcmp(res->value, "vxlan"))
2132 rss_conf.rss_hf = ETH_RSS_VXLAN;
2133 else if (!strcmp(res->value, "geneve"))
2134 rss_conf.rss_hf = ETH_RSS_GENEVE;
2135 else if (!strcmp(res->value, "nvgre"))
2136 rss_conf.rss_hf = ETH_RSS_NVGRE;
2137 else if (!strcmp(res->value, "none"))
2138 rss_conf.rss_hf = 0;
2139 else if (!strcmp(res->value, "default"))
2141 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2142 atoi(res->value) < 64)
2143 rss_conf.rss_hf = 1ULL << atoi(res->value);
2145 printf("Unknown parameter\n");
2148 rss_conf.rss_key = NULL;
2149 /* Update global configuration for RSS types. */
2150 RTE_ETH_FOREACH_DEV(i) {
2151 struct rte_eth_rss_conf local_rss_conf;
2153 rte_eth_dev_info_get(i, &dev_info);
2155 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2157 local_rss_conf = rss_conf;
2158 local_rss_conf.rss_hf = rss_conf.rss_hf &
2159 dev_info.flow_type_rss_offloads;
2160 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2161 printf("Port %u modified RSS hash function based on hardware support,"
2162 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2163 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2165 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2168 printf("Configuration of RSS hash at ethernet port %d "
2169 "failed with error (%d): %s.\n",
2170 i, -diag, strerror(-diag));
2173 if (all_updated && !use_default)
2174 rss_hf = rss_conf.rss_hf;
2177 cmdline_parse_token_string_t cmd_config_rss_port =
2178 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2179 cmdline_parse_token_string_t cmd_config_rss_keyword =
2180 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2181 cmdline_parse_token_string_t cmd_config_rss_all =
2182 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2183 cmdline_parse_token_string_t cmd_config_rss_name =
2184 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2185 cmdline_parse_token_string_t cmd_config_rss_value =
2186 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2188 cmdline_parse_inst_t cmd_config_rss = {
2189 .f = cmd_config_rss_parsed,
2191 .help_str = "port config all rss "
2192 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2194 (void *)&cmd_config_rss_port,
2195 (void *)&cmd_config_rss_keyword,
2196 (void *)&cmd_config_rss_all,
2197 (void *)&cmd_config_rss_name,
2198 (void *)&cmd_config_rss_value,
2203 /* *** configure rss hash key *** */
2204 struct cmd_config_rss_hash_key {
2205 cmdline_fixed_string_t port;
2206 cmdline_fixed_string_t config;
2208 cmdline_fixed_string_t rss_hash_key;
2209 cmdline_fixed_string_t rss_type;
2210 cmdline_fixed_string_t key;
2214 hexa_digit_to_value(char hexa_digit)
2216 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2217 return (uint8_t) (hexa_digit - '0');
2218 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2219 return (uint8_t) ((hexa_digit - 'a') + 10);
2220 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2221 return (uint8_t) ((hexa_digit - 'A') + 10);
2222 /* Invalid hexa digit */
2227 parse_and_check_key_hexa_digit(char *key, int idx)
2231 hexa_v = hexa_digit_to_value(key[idx]);
2233 printf("invalid key: character %c at position %d is not a "
2234 "valid hexa digit\n", key[idx], idx);
2239 cmd_config_rss_hash_key_parsed(void *parsed_result,
2240 __attribute__((unused)) struct cmdline *cl,
2241 __attribute__((unused)) void *data)
2243 struct cmd_config_rss_hash_key *res = parsed_result;
2244 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2248 struct rte_eth_dev_info dev_info;
2249 uint8_t hash_key_size;
2252 memset(&dev_info, 0, sizeof(dev_info));
2253 rte_eth_dev_info_get(res->port_id, &dev_info);
2254 if (dev_info.hash_key_size > 0 &&
2255 dev_info.hash_key_size <= sizeof(hash_key))
2256 hash_key_size = dev_info.hash_key_size;
2258 printf("dev_info did not provide a valid hash key size\n");
2261 /* Check the length of the RSS hash key */
2262 key_len = strlen(res->key);
2263 if (key_len != (hash_key_size * 2)) {
2264 printf("key length: %d invalid - key must be a string of %d"
2265 " hexa-decimal numbers\n",
2266 (int) key_len, hash_key_size * 2);
2269 /* Translate RSS hash key into binary representation */
2270 for (i = 0; i < hash_key_size; i++) {
2271 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2274 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2277 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2279 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2283 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2284 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2285 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2286 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2288 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2289 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2290 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2291 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2292 rss_hash_key, "rss-hash-key");
2293 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2294 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2295 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2296 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2297 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2298 "ipv6-tcp-ex#ipv6-udp-ex");
2299 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2300 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2302 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2303 .f = cmd_config_rss_hash_key_parsed,
2305 .help_str = "port config <port_id> rss-hash-key "
2306 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2307 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2308 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2309 "<string of hex digits (variable length, NIC dependent)>",
2311 (void *)&cmd_config_rss_hash_key_port,
2312 (void *)&cmd_config_rss_hash_key_config,
2313 (void *)&cmd_config_rss_hash_key_port_id,
2314 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2315 (void *)&cmd_config_rss_hash_key_rss_type,
2316 (void *)&cmd_config_rss_hash_key_value,
2321 /* *** configure port rxq/txq ring size *** */
2322 struct cmd_config_rxtx_ring_size {
2323 cmdline_fixed_string_t port;
2324 cmdline_fixed_string_t config;
2326 cmdline_fixed_string_t rxtxq;
2328 cmdline_fixed_string_t rsize;
2333 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2334 __attribute__((unused)) struct cmdline *cl,
2335 __attribute__((unused)) void *data)
2337 struct cmd_config_rxtx_ring_size *res = parsed_result;
2338 struct rte_port *port;
2341 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2344 if (res->portid == (portid_t)RTE_PORT_ALL) {
2345 printf("Invalid port id\n");
2349 port = &ports[res->portid];
2351 if (!strcmp(res->rxtxq, "rxq"))
2353 else if (!strcmp(res->rxtxq, "txq"))
2356 printf("Unknown parameter\n");
2360 if (isrx && rx_queue_id_is_invalid(res->qid))
2362 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2365 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2366 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2372 port->nb_rx_desc[res->qid] = res->size;
2374 port->nb_tx_desc[res->qid] = res->size;
2376 cmd_reconfig_device_queue(res->portid, 0, 1);
2379 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2380 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2382 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2385 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2386 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2388 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2389 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2391 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2392 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2394 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2395 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2396 rsize, "ring_size");
2397 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2398 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2401 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2402 .f = cmd_config_rxtx_ring_size_parsed,
2404 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2406 (void *)&cmd_config_rxtx_ring_size_port,
2407 (void *)&cmd_config_rxtx_ring_size_config,
2408 (void *)&cmd_config_rxtx_ring_size_portid,
2409 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2410 (void *)&cmd_config_rxtx_ring_size_qid,
2411 (void *)&cmd_config_rxtx_ring_size_rsize,
2412 (void *)&cmd_config_rxtx_ring_size_size,
2417 /* *** configure port rxq/txq start/stop *** */
2418 struct cmd_config_rxtx_queue {
2419 cmdline_fixed_string_t port;
2421 cmdline_fixed_string_t rxtxq;
2423 cmdline_fixed_string_t opname;
2427 cmd_config_rxtx_queue_parsed(void *parsed_result,
2428 __attribute__((unused)) struct cmdline *cl,
2429 __attribute__((unused)) void *data)
2431 struct cmd_config_rxtx_queue *res = parsed_result;
2436 if (test_done == 0) {
2437 printf("Please stop forwarding first\n");
2441 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2444 if (port_is_started(res->portid) != 1) {
2445 printf("Please start port %u first\n", res->portid);
2449 if (!strcmp(res->rxtxq, "rxq"))
2451 else if (!strcmp(res->rxtxq, "txq"))
2454 printf("Unknown parameter\n");
2458 if (isrx && rx_queue_id_is_invalid(res->qid))
2460 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2463 if (!strcmp(res->opname, "start"))
2465 else if (!strcmp(res->opname, "stop"))
2468 printf("Unknown parameter\n");
2472 if (isstart && isrx)
2473 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2474 else if (!isstart && isrx)
2475 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2476 else if (isstart && !isrx)
2477 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2479 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2481 if (ret == -ENOTSUP)
2482 printf("Function not supported in PMD driver\n");
2485 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2486 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2487 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2488 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2489 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2490 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2491 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2492 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2493 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2494 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2497 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2498 .f = cmd_config_rxtx_queue_parsed,
2500 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2502 (void *)&cmd_config_rxtx_queue_port,
2503 (void *)&cmd_config_rxtx_queue_portid,
2504 (void *)&cmd_config_rxtx_queue_rxtxq,
2505 (void *)&cmd_config_rxtx_queue_qid,
2506 (void *)&cmd_config_rxtx_queue_opname,
2511 /* *** configure port rxq/txq deferred start on/off *** */
2512 struct cmd_config_deferred_start_rxtx_queue {
2513 cmdline_fixed_string_t port;
2515 cmdline_fixed_string_t rxtxq;
2517 cmdline_fixed_string_t opname;
2518 cmdline_fixed_string_t state;
2522 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2523 __attribute__((unused)) struct cmdline *cl,
2524 __attribute__((unused)) void *data)
2526 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2527 struct rte_port *port;
2530 uint8_t needreconfig = 0;
2532 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2535 if (port_is_started(res->port_id) != 0) {
2536 printf("Please stop port %u first\n", res->port_id);
2540 port = &ports[res->port_id];
2542 isrx = !strcmp(res->rxtxq, "rxq");
2544 if (isrx && rx_queue_id_is_invalid(res->qid))
2546 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2549 ison = !strcmp(res->state, "on");
2551 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2552 port->rx_conf[res->qid].rx_deferred_start = ison;
2554 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2555 port->tx_conf[res->qid].tx_deferred_start = ison;
2560 cmd_reconfig_device_queue(res->port_id, 0, 1);
2563 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2564 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2566 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2567 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2569 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2570 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2572 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2573 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2575 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2576 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2577 opname, "deferred_start");
2578 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2579 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2582 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2583 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2585 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2587 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2588 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2589 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2590 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2591 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2592 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2597 /* *** configure port rxq/txq setup *** */
2598 struct cmd_setup_rxtx_queue {
2599 cmdline_fixed_string_t port;
2601 cmdline_fixed_string_t rxtxq;
2603 cmdline_fixed_string_t setup;
2606 /* Common CLI fields for queue setup */
2607 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2608 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2609 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2610 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2611 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2612 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2613 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2614 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2615 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2616 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2619 cmd_setup_rxtx_queue_parsed(
2620 void *parsed_result,
2621 __attribute__((unused)) struct cmdline *cl,
2622 __attribute__((unused)) void *data)
2624 struct cmd_setup_rxtx_queue *res = parsed_result;
2625 struct rte_port *port;
2626 struct rte_mempool *mp;
2627 unsigned int socket_id;
2631 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2634 if (res->portid == (portid_t)RTE_PORT_ALL) {
2635 printf("Invalid port id\n");
2639 if (!strcmp(res->rxtxq, "rxq"))
2641 else if (!strcmp(res->rxtxq, "txq"))
2644 printf("Unknown parameter\n");
2648 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2649 printf("Invalid rx queue\n");
2651 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2652 printf("Invalid tx queue\n");
2656 port = &ports[res->portid];
2658 socket_id = rxring_numa[res->portid];
2659 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2660 socket_id = port->socket_id;
2662 mp = mbuf_pool_find(socket_id);
2664 printf("Failed to setup RX queue: "
2665 "No mempool allocation"
2666 " on the socket %d\n",
2667 rxring_numa[res->portid]);
2670 ret = rte_eth_rx_queue_setup(res->portid,
2672 port->nb_rx_desc[res->qid],
2674 &port->rx_conf[res->qid],
2677 printf("Failed to setup RX queue\n");
2679 socket_id = txring_numa[res->portid];
2680 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2681 socket_id = port->socket_id;
2683 ret = rte_eth_tx_queue_setup(res->portid,
2685 port->nb_tx_desc[res->qid],
2687 &port->tx_conf[res->qid]);
2689 printf("Failed to setup TX queue\n");
2693 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2694 .f = cmd_setup_rxtx_queue_parsed,
2696 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2698 (void *)&cmd_setup_rxtx_queue_port,
2699 (void *)&cmd_setup_rxtx_queue_portid,
2700 (void *)&cmd_setup_rxtx_queue_rxtxq,
2701 (void *)&cmd_setup_rxtx_queue_qid,
2702 (void *)&cmd_setup_rxtx_queue_setup,
2708 /* *** Configure RSS RETA *** */
2709 struct cmd_config_rss_reta {
2710 cmdline_fixed_string_t port;
2711 cmdline_fixed_string_t keyword;
2713 cmdline_fixed_string_t name;
2714 cmdline_fixed_string_t list_name;
2715 cmdline_fixed_string_t list_of_items;
2719 parse_reta_config(const char *str,
2720 struct rte_eth_rss_reta_entry64 *reta_conf,
2721 uint16_t nb_entries)
2725 uint16_t hash_index, idx, shift;
2728 const char *p, *p0 = str;
2735 unsigned long int_fld[_NUM_FLD];
2736 char *str_fld[_NUM_FLD];
2738 while ((p = strchr(p0,'(')) != NULL) {
2740 if((p0 = strchr(p,')')) == NULL)
2744 if(size >= sizeof(s))
2747 snprintf(s, sizeof(s), "%.*s", size, p);
2748 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2750 for (i = 0; i < _NUM_FLD; i++) {
2752 int_fld[i] = strtoul(str_fld[i], &end, 0);
2753 if (errno != 0 || end == str_fld[i] ||
2758 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2759 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2761 if (hash_index >= nb_entries) {
2762 printf("Invalid RETA hash index=%d\n", hash_index);
2766 idx = hash_index / RTE_RETA_GROUP_SIZE;
2767 shift = hash_index % RTE_RETA_GROUP_SIZE;
2768 reta_conf[idx].mask |= (1ULL << shift);
2769 reta_conf[idx].reta[shift] = nb_queue;
2776 cmd_set_rss_reta_parsed(void *parsed_result,
2777 __attribute__((unused)) struct cmdline *cl,
2778 __attribute__((unused)) void *data)
2781 struct rte_eth_dev_info dev_info;
2782 struct rte_eth_rss_reta_entry64 reta_conf[8];
2783 struct cmd_config_rss_reta *res = parsed_result;
2785 memset(&dev_info, 0, sizeof(dev_info));
2786 rte_eth_dev_info_get(res->port_id, &dev_info);
2787 if (dev_info.reta_size == 0) {
2788 printf("Redirection table size is 0 which is "
2789 "invalid for RSS\n");
2792 printf("The reta size of port %d is %u\n",
2793 res->port_id, dev_info.reta_size);
2794 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2795 printf("Currently do not support more than %u entries of "
2796 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2800 memset(reta_conf, 0, sizeof(reta_conf));
2801 if (!strcmp(res->list_name, "reta")) {
2802 if (parse_reta_config(res->list_of_items, reta_conf,
2803 dev_info.reta_size)) {
2804 printf("Invalid RSS Redirection Table "
2805 "config entered\n");
2808 ret = rte_eth_dev_rss_reta_update(res->port_id,
2809 reta_conf, dev_info.reta_size);
2811 printf("Bad redirection table parameter, "
2812 "return code = %d \n", ret);
2816 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2817 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2818 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2819 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2820 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2821 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2822 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2823 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2824 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2825 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2826 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2827 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2829 cmdline_parse_inst_t cmd_config_rss_reta = {
2830 .f = cmd_set_rss_reta_parsed,
2832 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2834 (void *)&cmd_config_rss_reta_port,
2835 (void *)&cmd_config_rss_reta_keyword,
2836 (void *)&cmd_config_rss_reta_port_id,
2837 (void *)&cmd_config_rss_reta_name,
2838 (void *)&cmd_config_rss_reta_list_name,
2839 (void *)&cmd_config_rss_reta_list_of_items,
2844 /* *** SHOW PORT RETA INFO *** */
2845 struct cmd_showport_reta {
2846 cmdline_fixed_string_t show;
2847 cmdline_fixed_string_t port;
2849 cmdline_fixed_string_t rss;
2850 cmdline_fixed_string_t reta;
2852 cmdline_fixed_string_t list_of_items;
2856 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2857 uint16_t nb_entries,
2861 const char *p, *p0 = str;
2866 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2867 RTE_RETA_GROUP_SIZE;
2870 p = strchr(p0, '(');
2874 p0 = strchr(p, ')');
2878 if (size >= sizeof(s)) {
2879 printf("The string size exceeds the internal buffer size\n");
2882 snprintf(s, sizeof(s), "%.*s", size, p);
2883 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2884 if (ret <= 0 || ret != num) {
2885 printf("The bits of masks do not match the number of "
2886 "reta entries: %u\n", num);
2889 for (i = 0; i < ret; i++)
2890 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2896 cmd_showport_reta_parsed(void *parsed_result,
2897 __attribute__((unused)) struct cmdline *cl,
2898 __attribute__((unused)) void *data)
2900 struct cmd_showport_reta *res = parsed_result;
2901 struct rte_eth_rss_reta_entry64 reta_conf[8];
2902 struct rte_eth_dev_info dev_info;
2903 uint16_t max_reta_size;
2905 memset(&dev_info, 0, sizeof(dev_info));
2906 rte_eth_dev_info_get(res->port_id, &dev_info);
2907 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2908 if (res->size == 0 || res->size > max_reta_size) {
2909 printf("Invalid redirection table size: %u (1-%u)\n",
2910 res->size, max_reta_size);
2914 memset(reta_conf, 0, sizeof(reta_conf));
2915 if (showport_parse_reta_config(reta_conf, res->size,
2916 res->list_of_items) < 0) {
2917 printf("Invalid string: %s for reta masks\n",
2918 res->list_of_items);
2921 port_rss_reta_info(res->port_id, reta_conf, res->size);
2924 cmdline_parse_token_string_t cmd_showport_reta_show =
2925 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2926 cmdline_parse_token_string_t cmd_showport_reta_port =
2927 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2928 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2929 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2930 cmdline_parse_token_string_t cmd_showport_reta_rss =
2931 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2932 cmdline_parse_token_string_t cmd_showport_reta_reta =
2933 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2934 cmdline_parse_token_num_t cmd_showport_reta_size =
2935 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2936 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2937 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2938 list_of_items, NULL);
2940 cmdline_parse_inst_t cmd_showport_reta = {
2941 .f = cmd_showport_reta_parsed,
2943 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2945 (void *)&cmd_showport_reta_show,
2946 (void *)&cmd_showport_reta_port,
2947 (void *)&cmd_showport_reta_port_id,
2948 (void *)&cmd_showport_reta_rss,
2949 (void *)&cmd_showport_reta_reta,
2950 (void *)&cmd_showport_reta_size,
2951 (void *)&cmd_showport_reta_list_of_items,
2956 /* *** Show RSS hash configuration *** */
2957 struct cmd_showport_rss_hash {
2958 cmdline_fixed_string_t show;
2959 cmdline_fixed_string_t port;
2961 cmdline_fixed_string_t rss_hash;
2962 cmdline_fixed_string_t rss_type;
2963 cmdline_fixed_string_t key; /* optional argument */
2966 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2967 __attribute__((unused)) struct cmdline *cl,
2970 struct cmd_showport_rss_hash *res = parsed_result;
2972 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
2975 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2976 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2977 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2978 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2979 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2980 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2981 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2982 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2984 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2985 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2987 cmdline_parse_inst_t cmd_showport_rss_hash = {
2988 .f = cmd_showport_rss_hash_parsed,
2990 .help_str = "show port <port_id> rss-hash",
2992 (void *)&cmd_showport_rss_hash_show,
2993 (void *)&cmd_showport_rss_hash_port,
2994 (void *)&cmd_showport_rss_hash_port_id,
2995 (void *)&cmd_showport_rss_hash_rss_hash,
3000 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3001 .f = cmd_showport_rss_hash_parsed,
3003 .help_str = "show port <port_id> rss-hash key",
3005 (void *)&cmd_showport_rss_hash_show,
3006 (void *)&cmd_showport_rss_hash_port,
3007 (void *)&cmd_showport_rss_hash_port_id,
3008 (void *)&cmd_showport_rss_hash_rss_hash,
3009 (void *)&cmd_showport_rss_hash_rss_key,
3014 /* *** Configure DCB *** */
3015 struct cmd_config_dcb {
3016 cmdline_fixed_string_t port;
3017 cmdline_fixed_string_t config;
3019 cmdline_fixed_string_t dcb;
3020 cmdline_fixed_string_t vt;
3021 cmdline_fixed_string_t vt_en;
3023 cmdline_fixed_string_t pfc;
3024 cmdline_fixed_string_t pfc_en;
3028 cmd_config_dcb_parsed(void *parsed_result,
3029 __attribute__((unused)) struct cmdline *cl,
3030 __attribute__((unused)) void *data)
3032 struct cmd_config_dcb *res = parsed_result;
3033 portid_t port_id = res->port_id;
3034 struct rte_port *port;
3038 port = &ports[port_id];
3039 /** Check if the port is not started **/
3040 if (port->port_status != RTE_PORT_STOPPED) {
3041 printf("Please stop port %d first\n", port_id);
3045 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3046 printf("The invalid number of traffic class,"
3047 " only 4 or 8 allowed.\n");
3051 if (nb_fwd_lcores < res->num_tcs) {
3052 printf("nb_cores shouldn't be less than number of TCs.\n");
3055 if (!strncmp(res->pfc_en, "on", 2))
3060 /* DCB in VT mode */
3061 if (!strncmp(res->vt_en, "on", 2))
3062 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3063 (enum rte_eth_nb_tcs)res->num_tcs,
3066 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3067 (enum rte_eth_nb_tcs)res->num_tcs,
3072 printf("Cannot initialize network ports.\n");
3076 cmd_reconfig_device_queue(port_id, 1, 1);
3079 cmdline_parse_token_string_t cmd_config_dcb_port =
3080 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3081 cmdline_parse_token_string_t cmd_config_dcb_config =
3082 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3083 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3084 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3085 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3086 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3087 cmdline_parse_token_string_t cmd_config_dcb_vt =
3088 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3089 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3090 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3091 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3092 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3093 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3094 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3095 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3096 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3098 cmdline_parse_inst_t cmd_config_dcb = {
3099 .f = cmd_config_dcb_parsed,
3101 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3103 (void *)&cmd_config_dcb_port,
3104 (void *)&cmd_config_dcb_config,
3105 (void *)&cmd_config_dcb_port_id,
3106 (void *)&cmd_config_dcb_dcb,
3107 (void *)&cmd_config_dcb_vt,
3108 (void *)&cmd_config_dcb_vt_en,
3109 (void *)&cmd_config_dcb_num_tcs,
3110 (void *)&cmd_config_dcb_pfc,
3111 (void *)&cmd_config_dcb_pfc_en,
3116 /* *** configure number of packets per burst *** */
3117 struct cmd_config_burst {
3118 cmdline_fixed_string_t port;
3119 cmdline_fixed_string_t keyword;
3120 cmdline_fixed_string_t all;
3121 cmdline_fixed_string_t name;
3126 cmd_config_burst_parsed(void *parsed_result,
3127 __attribute__((unused)) struct cmdline *cl,
3128 __attribute__((unused)) void *data)
3130 struct cmd_config_burst *res = parsed_result;
3131 struct rte_eth_dev_info dev_info;
3132 uint16_t rec_nb_pkts;
3134 if (!all_ports_stopped()) {
3135 printf("Please stop all ports first\n");
3139 if (!strcmp(res->name, "burst")) {
3140 if (res->value == 0) {
3141 /* If user gives a value of zero, query the PMD for
3142 * its recommended Rx burst size. Testpmd uses a single
3143 * size for all ports, so assume all ports are the same
3144 * NIC model and use the values from Port 0.
3146 rte_eth_dev_info_get(0, &dev_info);
3147 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3149 if (rec_nb_pkts == 0) {
3150 printf("PMD does not recommend a burst size.\n"
3151 "User provided value must be between"
3152 " 1 and %d\n", MAX_PKT_BURST);
3154 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3155 printf("PMD recommended burst size of %d"
3156 " exceeds maximum value of %d\n",
3157 rec_nb_pkts, MAX_PKT_BURST);
3160 printf("Using PMD-provided burst value of %d\n",
3162 nb_pkt_per_burst = rec_nb_pkts;
3163 } else if (res->value > MAX_PKT_BURST) {
3164 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3167 nb_pkt_per_burst = res->value;
3169 printf("Unknown parameter\n");
3175 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3178 cmdline_parse_token_string_t cmd_config_burst_port =
3179 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3180 cmdline_parse_token_string_t cmd_config_burst_keyword =
3181 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3182 cmdline_parse_token_string_t cmd_config_burst_all =
3183 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3184 cmdline_parse_token_string_t cmd_config_burst_name =
3185 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3186 cmdline_parse_token_num_t cmd_config_burst_value =
3187 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3189 cmdline_parse_inst_t cmd_config_burst = {
3190 .f = cmd_config_burst_parsed,
3192 .help_str = "port config all burst <value>",
3194 (void *)&cmd_config_burst_port,
3195 (void *)&cmd_config_burst_keyword,
3196 (void *)&cmd_config_burst_all,
3197 (void *)&cmd_config_burst_name,
3198 (void *)&cmd_config_burst_value,
3203 /* *** configure rx/tx queues *** */
3204 struct cmd_config_thresh {
3205 cmdline_fixed_string_t port;
3206 cmdline_fixed_string_t keyword;
3207 cmdline_fixed_string_t all;
3208 cmdline_fixed_string_t name;
3213 cmd_config_thresh_parsed(void *parsed_result,
3214 __attribute__((unused)) struct cmdline *cl,
3215 __attribute__((unused)) void *data)
3217 struct cmd_config_thresh *res = parsed_result;
3219 if (!all_ports_stopped()) {
3220 printf("Please stop all ports first\n");
3224 if (!strcmp(res->name, "txpt"))
3225 tx_pthresh = res->value;
3226 else if(!strcmp(res->name, "txht"))
3227 tx_hthresh = res->value;
3228 else if(!strcmp(res->name, "txwt"))
3229 tx_wthresh = res->value;
3230 else if(!strcmp(res->name, "rxpt"))
3231 rx_pthresh = res->value;
3232 else if(!strcmp(res->name, "rxht"))
3233 rx_hthresh = res->value;
3234 else if(!strcmp(res->name, "rxwt"))
3235 rx_wthresh = res->value;
3237 printf("Unknown parameter\n");
3243 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3246 cmdline_parse_token_string_t cmd_config_thresh_port =
3247 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3248 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3249 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3250 cmdline_parse_token_string_t cmd_config_thresh_all =
3251 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3252 cmdline_parse_token_string_t cmd_config_thresh_name =
3253 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3254 "txpt#txht#txwt#rxpt#rxht#rxwt");
3255 cmdline_parse_token_num_t cmd_config_thresh_value =
3256 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3258 cmdline_parse_inst_t cmd_config_thresh = {
3259 .f = cmd_config_thresh_parsed,
3261 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3263 (void *)&cmd_config_thresh_port,
3264 (void *)&cmd_config_thresh_keyword,
3265 (void *)&cmd_config_thresh_all,
3266 (void *)&cmd_config_thresh_name,
3267 (void *)&cmd_config_thresh_value,
3272 /* *** configure free/rs threshold *** */
3273 struct cmd_config_threshold {
3274 cmdline_fixed_string_t port;
3275 cmdline_fixed_string_t keyword;
3276 cmdline_fixed_string_t all;
3277 cmdline_fixed_string_t name;
3282 cmd_config_threshold_parsed(void *parsed_result,
3283 __attribute__((unused)) struct cmdline *cl,
3284 __attribute__((unused)) void *data)
3286 struct cmd_config_threshold *res = parsed_result;
3288 if (!all_ports_stopped()) {
3289 printf("Please stop all ports first\n");
3293 if (!strcmp(res->name, "txfreet"))
3294 tx_free_thresh = res->value;
3295 else if (!strcmp(res->name, "txrst"))
3296 tx_rs_thresh = res->value;
3297 else if (!strcmp(res->name, "rxfreet"))
3298 rx_free_thresh = res->value;
3300 printf("Unknown parameter\n");
3306 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3309 cmdline_parse_token_string_t cmd_config_threshold_port =
3310 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3311 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3312 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3314 cmdline_parse_token_string_t cmd_config_threshold_all =
3315 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3316 cmdline_parse_token_string_t cmd_config_threshold_name =
3317 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3318 "txfreet#txrst#rxfreet");
3319 cmdline_parse_token_num_t cmd_config_threshold_value =
3320 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3322 cmdline_parse_inst_t cmd_config_threshold = {
3323 .f = cmd_config_threshold_parsed,
3325 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3327 (void *)&cmd_config_threshold_port,
3328 (void *)&cmd_config_threshold_keyword,
3329 (void *)&cmd_config_threshold_all,
3330 (void *)&cmd_config_threshold_name,
3331 (void *)&cmd_config_threshold_value,
3337 struct cmd_stop_result {
3338 cmdline_fixed_string_t stop;
3341 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3342 __attribute__((unused)) struct cmdline *cl,
3343 __attribute__((unused)) void *data)
3345 stop_packet_forwarding();
3348 cmdline_parse_token_string_t cmd_stop_stop =
3349 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3351 cmdline_parse_inst_t cmd_stop = {
3352 .f = cmd_stop_parsed,
3354 .help_str = "stop: Stop packet forwarding",
3356 (void *)&cmd_stop_stop,
3361 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3364 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3365 unsigned int *parsed_items, int check_unique_values)
3367 unsigned int nb_item;
3375 * First parse all items in the list and store their value.
3380 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3382 if ((c >= '0') && (c <= '9')) {
3383 value = (unsigned int) (value * 10 + (c - '0'));
3388 printf("character %c is not a decimal digit\n", c);
3392 printf("No valid value before comma\n");
3395 if (nb_item < max_items) {
3396 parsed_items[nb_item] = value;
3402 if (nb_item >= max_items) {
3403 printf("Number of %s = %u > %u (maximum items)\n",
3404 item_name, nb_item + 1, max_items);
3407 parsed_items[nb_item++] = value;
3408 if (! check_unique_values)
3412 * Then, check that all values in the list are differents.
3413 * No optimization here...
3415 for (i = 0; i < nb_item; i++) {
3416 for (j = i + 1; j < nb_item; j++) {
3417 if (parsed_items[j] == parsed_items[i]) {
3418 printf("duplicated %s %u at index %u and %u\n",
3419 item_name, parsed_items[i], i, j);
3427 struct cmd_set_list_result {
3428 cmdline_fixed_string_t cmd_keyword;
3429 cmdline_fixed_string_t list_name;
3430 cmdline_fixed_string_t list_of_items;
3433 static void cmd_set_list_parsed(void *parsed_result,
3434 __attribute__((unused)) struct cmdline *cl,
3435 __attribute__((unused)) void *data)
3437 struct cmd_set_list_result *res;
3439 unsigned int lcorelist[RTE_MAX_LCORE];
3440 unsigned int portlist[RTE_MAX_ETHPORTS];
3442 unsigned int nb_item;
3444 if (test_done == 0) {
3445 printf("Please stop forwarding first\n");
3449 res = parsed_result;
3450 if (!strcmp(res->list_name, "corelist")) {
3451 nb_item = parse_item_list(res->list_of_items, "core",
3453 parsed_items.lcorelist, 1);
3455 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3460 if (!strcmp(res->list_name, "portlist")) {
3461 nb_item = parse_item_list(res->list_of_items, "port",
3463 parsed_items.portlist, 1);
3465 set_fwd_ports_list(parsed_items.portlist, nb_item);
3471 cmdline_parse_token_string_t cmd_set_list_keyword =
3472 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3474 cmdline_parse_token_string_t cmd_set_list_name =
3475 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3476 "corelist#portlist");
3477 cmdline_parse_token_string_t cmd_set_list_of_items =
3478 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3481 cmdline_parse_inst_t cmd_set_fwd_list = {
3482 .f = cmd_set_list_parsed,
3484 .help_str = "set corelist|portlist <list0[,list1]*>",
3486 (void *)&cmd_set_list_keyword,
3487 (void *)&cmd_set_list_name,
3488 (void *)&cmd_set_list_of_items,
3493 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3495 struct cmd_setmask_result {
3496 cmdline_fixed_string_t set;
3497 cmdline_fixed_string_t mask;
3501 static void cmd_set_mask_parsed(void *parsed_result,
3502 __attribute__((unused)) struct cmdline *cl,
3503 __attribute__((unused)) void *data)
3505 struct cmd_setmask_result *res = parsed_result;
3507 if (test_done == 0) {
3508 printf("Please stop forwarding first\n");
3511 if (!strcmp(res->mask, "coremask")) {
3512 set_fwd_lcores_mask(res->hexavalue);
3514 } else if (!strcmp(res->mask, "portmask")) {
3515 set_fwd_ports_mask(res->hexavalue);
3520 cmdline_parse_token_string_t cmd_setmask_set =
3521 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3522 cmdline_parse_token_string_t cmd_setmask_mask =
3523 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3524 "coremask#portmask");
3525 cmdline_parse_token_num_t cmd_setmask_value =
3526 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3528 cmdline_parse_inst_t cmd_set_fwd_mask = {
3529 .f = cmd_set_mask_parsed,
3531 .help_str = "set coremask|portmask <hexadecimal value>",
3533 (void *)&cmd_setmask_set,
3534 (void *)&cmd_setmask_mask,
3535 (void *)&cmd_setmask_value,
3541 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3543 struct cmd_set_result {
3544 cmdline_fixed_string_t set;
3545 cmdline_fixed_string_t what;
3549 static void cmd_set_parsed(void *parsed_result,
3550 __attribute__((unused)) struct cmdline *cl,
3551 __attribute__((unused)) void *data)
3553 struct cmd_set_result *res = parsed_result;
3554 if (!strcmp(res->what, "nbport")) {
3555 set_fwd_ports_number(res->value);
3557 } else if (!strcmp(res->what, "nbcore")) {
3558 set_fwd_lcores_number(res->value);
3560 } else if (!strcmp(res->what, "burst"))
3561 set_nb_pkt_per_burst(res->value);
3562 else if (!strcmp(res->what, "verbose"))
3563 set_verbose_level(res->value);
3566 cmdline_parse_token_string_t cmd_set_set =
3567 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3568 cmdline_parse_token_string_t cmd_set_what =
3569 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3570 "nbport#nbcore#burst#verbose");
3571 cmdline_parse_token_num_t cmd_set_value =
3572 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3574 cmdline_parse_inst_t cmd_set_numbers = {
3575 .f = cmd_set_parsed,
3577 .help_str = "set nbport|nbcore|burst|verbose <value>",
3579 (void *)&cmd_set_set,
3580 (void *)&cmd_set_what,
3581 (void *)&cmd_set_value,
3586 /* *** SET LOG LEVEL CONFIGURATION *** */
3588 struct cmd_set_log_result {
3589 cmdline_fixed_string_t set;
3590 cmdline_fixed_string_t log;
3591 cmdline_fixed_string_t type;
3596 cmd_set_log_parsed(void *parsed_result,
3597 __attribute__((unused)) struct cmdline *cl,
3598 __attribute__((unused)) void *data)
3600 struct cmd_set_log_result *res;
3603 res = parsed_result;
3604 if (!strcmp(res->type, "global"))
3605 rte_log_set_global_level(res->level);
3607 ret = rte_log_set_level_regexp(res->type, res->level);
3609 printf("Unable to set log level\n");
3613 cmdline_parse_token_string_t cmd_set_log_set =
3614 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3615 cmdline_parse_token_string_t cmd_set_log_log =
3616 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3617 cmdline_parse_token_string_t cmd_set_log_type =
3618 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3619 cmdline_parse_token_num_t cmd_set_log_level =
3620 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3622 cmdline_parse_inst_t cmd_set_log = {
3623 .f = cmd_set_log_parsed,
3625 .help_str = "set log global|<type> <level>",
3627 (void *)&cmd_set_log_set,
3628 (void *)&cmd_set_log_log,
3629 (void *)&cmd_set_log_type,
3630 (void *)&cmd_set_log_level,
3635 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3637 struct cmd_set_txpkts_result {
3638 cmdline_fixed_string_t cmd_keyword;
3639 cmdline_fixed_string_t txpkts;
3640 cmdline_fixed_string_t seg_lengths;
3644 cmd_set_txpkts_parsed(void *parsed_result,
3645 __attribute__((unused)) struct cmdline *cl,
3646 __attribute__((unused)) void *data)
3648 struct cmd_set_txpkts_result *res;
3649 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3650 unsigned int nb_segs;
3652 res = parsed_result;
3653 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3654 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3656 set_tx_pkt_segments(seg_lengths, nb_segs);
3659 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3660 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3661 cmd_keyword, "set");
3662 cmdline_parse_token_string_t cmd_set_txpkts_name =
3663 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3665 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3666 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3669 cmdline_parse_inst_t cmd_set_txpkts = {
3670 .f = cmd_set_txpkts_parsed,
3672 .help_str = "set txpkts <len0[,len1]*>",
3674 (void *)&cmd_set_txpkts_keyword,
3675 (void *)&cmd_set_txpkts_name,
3676 (void *)&cmd_set_txpkts_lengths,
3681 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3683 struct cmd_set_txsplit_result {
3684 cmdline_fixed_string_t cmd_keyword;
3685 cmdline_fixed_string_t txsplit;
3686 cmdline_fixed_string_t mode;
3690 cmd_set_txsplit_parsed(void *parsed_result,
3691 __attribute__((unused)) struct cmdline *cl,
3692 __attribute__((unused)) void *data)
3694 struct cmd_set_txsplit_result *res;
3696 res = parsed_result;
3697 set_tx_pkt_split(res->mode);
3700 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3701 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3702 cmd_keyword, "set");
3703 cmdline_parse_token_string_t cmd_set_txsplit_name =
3704 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3705 txsplit, "txsplit");
3706 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3707 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3710 cmdline_parse_inst_t cmd_set_txsplit = {
3711 .f = cmd_set_txsplit_parsed,
3713 .help_str = "set txsplit on|off|rand",
3715 (void *)&cmd_set_txsplit_keyword,
3716 (void *)&cmd_set_txsplit_name,
3717 (void *)&cmd_set_txsplit_mode,
3722 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3723 struct cmd_rx_vlan_filter_all_result {
3724 cmdline_fixed_string_t rx_vlan;
3725 cmdline_fixed_string_t what;
3726 cmdline_fixed_string_t all;
3731 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3732 __attribute__((unused)) struct cmdline *cl,
3733 __attribute__((unused)) void *data)
3735 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3737 if (!strcmp(res->what, "add"))
3738 rx_vlan_all_filter_set(res->port_id, 1);
3740 rx_vlan_all_filter_set(res->port_id, 0);
3743 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3744 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3745 rx_vlan, "rx_vlan");
3746 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3747 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3749 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3750 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3752 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3753 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3756 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3757 .f = cmd_rx_vlan_filter_all_parsed,
3759 .help_str = "rx_vlan add|rm all <port_id>: "
3760 "Add/Remove all identifiers to/from the set of VLAN "
3761 "identifiers filtered by a port",
3763 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3764 (void *)&cmd_rx_vlan_filter_all_what,
3765 (void *)&cmd_rx_vlan_filter_all_all,
3766 (void *)&cmd_rx_vlan_filter_all_portid,
3771 /* *** VLAN OFFLOAD SET ON A PORT *** */
3772 struct cmd_vlan_offload_result {
3773 cmdline_fixed_string_t vlan;
3774 cmdline_fixed_string_t set;
3775 cmdline_fixed_string_t vlan_type;
3776 cmdline_fixed_string_t what;
3777 cmdline_fixed_string_t on;
3778 cmdline_fixed_string_t port_id;
3782 cmd_vlan_offload_parsed(void *parsed_result,
3783 __attribute__((unused)) struct cmdline *cl,
3784 __attribute__((unused)) void *data)
3787 struct cmd_vlan_offload_result *res = parsed_result;
3790 portid_t port_id = 0;
3794 len = strnlen(str, STR_TOKEN_SIZE);
3796 /* Get port_id first */
3804 tmp = strtoul(str, NULL, 0);
3805 /* If port_id greater that what portid_t can represent, return */
3806 if(tmp >= RTE_MAX_ETHPORTS)
3808 port_id = (portid_t)tmp;
3810 if (!strcmp(res->on, "on"))
3815 if (!strcmp(res->what, "strip"))
3816 rx_vlan_strip_set(port_id, on);
3817 else if(!strcmp(res->what, "stripq")){
3818 uint16_t queue_id = 0;
3820 /* No queue_id, return */
3822 printf("must specify (port,queue_id)\n");
3825 tmp = strtoul(str + i + 1, NULL, 0);
3826 /* If queue_id greater that what 16-bits can represent, return */
3830 queue_id = (uint16_t)tmp;
3831 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3833 else if (!strcmp(res->what, "filter"))
3834 rx_vlan_filter_set(port_id, on);
3836 vlan_extend_set(port_id, on);
3841 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3842 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3844 cmdline_parse_token_string_t cmd_vlan_offload_set =
3845 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3847 cmdline_parse_token_string_t cmd_vlan_offload_what =
3848 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3849 what, "strip#filter#qinq#stripq");
3850 cmdline_parse_token_string_t cmd_vlan_offload_on =
3851 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3853 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3854 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3857 cmdline_parse_inst_t cmd_vlan_offload = {
3858 .f = cmd_vlan_offload_parsed,
3860 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3861 "<port_id[,queue_id]>: "
3862 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3864 (void *)&cmd_vlan_offload_vlan,
3865 (void *)&cmd_vlan_offload_set,
3866 (void *)&cmd_vlan_offload_what,
3867 (void *)&cmd_vlan_offload_on,
3868 (void *)&cmd_vlan_offload_portid,
3873 /* *** VLAN TPID SET ON A PORT *** */
3874 struct cmd_vlan_tpid_result {
3875 cmdline_fixed_string_t vlan;
3876 cmdline_fixed_string_t set;
3877 cmdline_fixed_string_t vlan_type;
3878 cmdline_fixed_string_t what;
3884 cmd_vlan_tpid_parsed(void *parsed_result,
3885 __attribute__((unused)) struct cmdline *cl,
3886 __attribute__((unused)) void *data)
3888 struct cmd_vlan_tpid_result *res = parsed_result;
3889 enum rte_vlan_type vlan_type;
3891 if (!strcmp(res->vlan_type, "inner"))
3892 vlan_type = ETH_VLAN_TYPE_INNER;
3893 else if (!strcmp(res->vlan_type, "outer"))
3894 vlan_type = ETH_VLAN_TYPE_OUTER;
3896 printf("Unknown vlan type\n");
3899 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3902 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3903 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3905 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3906 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3908 cmdline_parse_token_string_t cmd_vlan_type =
3909 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3910 vlan_type, "inner#outer");
3911 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3912 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3914 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3915 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3917 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3918 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3921 cmdline_parse_inst_t cmd_vlan_tpid = {
3922 .f = cmd_vlan_tpid_parsed,
3924 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3925 "Set the VLAN Ether type",
3927 (void *)&cmd_vlan_tpid_vlan,
3928 (void *)&cmd_vlan_tpid_set,
3929 (void *)&cmd_vlan_type,
3930 (void *)&cmd_vlan_tpid_what,
3931 (void *)&cmd_vlan_tpid_tpid,
3932 (void *)&cmd_vlan_tpid_portid,
3937 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3938 struct cmd_rx_vlan_filter_result {
3939 cmdline_fixed_string_t rx_vlan;
3940 cmdline_fixed_string_t what;
3946 cmd_rx_vlan_filter_parsed(void *parsed_result,
3947 __attribute__((unused)) struct cmdline *cl,
3948 __attribute__((unused)) void *data)
3950 struct cmd_rx_vlan_filter_result *res = parsed_result;
3952 if (!strcmp(res->what, "add"))
3953 rx_vft_set(res->port_id, res->vlan_id, 1);
3955 rx_vft_set(res->port_id, res->vlan_id, 0);
3958 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3959 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3960 rx_vlan, "rx_vlan");
3961 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3962 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3964 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3965 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3967 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3968 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3971 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3972 .f = cmd_rx_vlan_filter_parsed,
3974 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3975 "Add/Remove a VLAN identifier to/from the set of VLAN "
3976 "identifiers filtered by a port",
3978 (void *)&cmd_rx_vlan_filter_rx_vlan,
3979 (void *)&cmd_rx_vlan_filter_what,
3980 (void *)&cmd_rx_vlan_filter_vlanid,
3981 (void *)&cmd_rx_vlan_filter_portid,
3986 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3987 struct cmd_tx_vlan_set_result {
3988 cmdline_fixed_string_t tx_vlan;
3989 cmdline_fixed_string_t set;
3995 cmd_tx_vlan_set_parsed(void *parsed_result,
3996 __attribute__((unused)) struct cmdline *cl,
3997 __attribute__((unused)) void *data)
3999 struct cmd_tx_vlan_set_result *res = parsed_result;
4001 if (!port_is_stopped(res->port_id)) {
4002 printf("Please stop port %d first\n", res->port_id);
4006 tx_vlan_set(res->port_id, res->vlan_id);
4008 cmd_reconfig_device_queue(res->port_id, 1, 1);
4011 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4012 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4013 tx_vlan, "tx_vlan");
4014 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4015 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4017 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4018 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4020 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4021 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4024 cmdline_parse_inst_t cmd_tx_vlan_set = {
4025 .f = cmd_tx_vlan_set_parsed,
4027 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4028 "Enable hardware insertion of a single VLAN header "
4029 "with a given TAG Identifier in packets sent on a port",
4031 (void *)&cmd_tx_vlan_set_tx_vlan,
4032 (void *)&cmd_tx_vlan_set_set,
4033 (void *)&cmd_tx_vlan_set_portid,
4034 (void *)&cmd_tx_vlan_set_vlanid,
4039 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4040 struct cmd_tx_vlan_set_qinq_result {
4041 cmdline_fixed_string_t tx_vlan;
4042 cmdline_fixed_string_t set;
4045 uint16_t vlan_id_outer;
4049 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4050 __attribute__((unused)) struct cmdline *cl,
4051 __attribute__((unused)) void *data)
4053 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4055 if (!port_is_stopped(res->port_id)) {
4056 printf("Please stop port %d first\n", res->port_id);
4060 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4062 cmd_reconfig_device_queue(res->port_id, 1, 1);
4065 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4066 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4067 tx_vlan, "tx_vlan");
4068 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4069 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4071 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4072 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4074 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4075 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4077 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4078 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4079 vlan_id_outer, UINT16);
4081 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4082 .f = cmd_tx_vlan_set_qinq_parsed,
4084 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4085 "Enable hardware insertion of double VLAN header "
4086 "with given TAG Identifiers in packets sent on a port",
4088 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4089 (void *)&cmd_tx_vlan_set_qinq_set,
4090 (void *)&cmd_tx_vlan_set_qinq_portid,
4091 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4092 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4097 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4098 struct cmd_tx_vlan_set_pvid_result {
4099 cmdline_fixed_string_t tx_vlan;
4100 cmdline_fixed_string_t set;
4101 cmdline_fixed_string_t pvid;
4104 cmdline_fixed_string_t mode;
4108 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4109 __attribute__((unused)) struct cmdline *cl,
4110 __attribute__((unused)) void *data)
4112 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4114 if (strcmp(res->mode, "on") == 0)
4115 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4117 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4120 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4121 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4122 tx_vlan, "tx_vlan");
4123 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4124 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4126 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4127 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4129 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4130 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4132 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4133 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4135 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4136 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4139 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4140 .f = cmd_tx_vlan_set_pvid_parsed,
4142 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4144 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4145 (void *)&cmd_tx_vlan_set_pvid_set,
4146 (void *)&cmd_tx_vlan_set_pvid_pvid,
4147 (void *)&cmd_tx_vlan_set_pvid_port_id,
4148 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4149 (void *)&cmd_tx_vlan_set_pvid_mode,
4154 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4155 struct cmd_tx_vlan_reset_result {
4156 cmdline_fixed_string_t tx_vlan;
4157 cmdline_fixed_string_t reset;
4162 cmd_tx_vlan_reset_parsed(void *parsed_result,
4163 __attribute__((unused)) struct cmdline *cl,
4164 __attribute__((unused)) void *data)
4166 struct cmd_tx_vlan_reset_result *res = parsed_result;
4168 if (!port_is_stopped(res->port_id)) {
4169 printf("Please stop port %d first\n", res->port_id);
4173 tx_vlan_reset(res->port_id);
4175 cmd_reconfig_device_queue(res->port_id, 1, 1);
4178 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4179 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4180 tx_vlan, "tx_vlan");
4181 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4182 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4184 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4185 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4188 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4189 .f = cmd_tx_vlan_reset_parsed,
4191 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4192 "VLAN header in packets sent on a port",
4194 (void *)&cmd_tx_vlan_reset_tx_vlan,
4195 (void *)&cmd_tx_vlan_reset_reset,
4196 (void *)&cmd_tx_vlan_reset_portid,
4202 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4203 struct cmd_csum_result {
4204 cmdline_fixed_string_t csum;
4205 cmdline_fixed_string_t mode;
4206 cmdline_fixed_string_t proto;
4207 cmdline_fixed_string_t hwsw;
4212 csum_show(int port_id)
4214 struct rte_eth_dev_info dev_info;
4215 uint64_t tx_offloads;
4217 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4218 printf("Parse tunnel is %s\n",
4219 (ports[port_id].parse_tunnel) ? "on" : "off");
4220 printf("IP checksum offload is %s\n",
4221 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4222 printf("UDP checksum offload is %s\n",
4223 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4224 printf("TCP checksum offload is %s\n",
4225 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4226 printf("SCTP checksum offload is %s\n",
4227 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4228 printf("Outer-Ip checksum offload is %s\n",
4229 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4230 printf("Outer-Udp checksum offload is %s\n",
4231 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4233 /* display warnings if configuration is not supported by the NIC */
4234 rte_eth_dev_info_get(port_id, &dev_info);
4235 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4236 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4237 printf("Warning: hardware IP checksum enabled but not "
4238 "supported by port %d\n", port_id);
4240 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4241 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4242 printf("Warning: hardware UDP checksum enabled but not "
4243 "supported by port %d\n", port_id);
4245 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4246 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4247 printf("Warning: hardware TCP checksum enabled but not "
4248 "supported by port %d\n", port_id);
4250 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4251 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4252 printf("Warning: hardware SCTP checksum enabled but not "
4253 "supported by port %d\n", port_id);
4255 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4256 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4257 printf("Warning: hardware outer IP checksum enabled but not "
4258 "supported by port %d\n", port_id);
4260 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4261 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4263 printf("Warning: hardware outer UDP checksum enabled but not "
4264 "supported by port %d\n", port_id);
4269 cmd_csum_parsed(void *parsed_result,
4270 __attribute__((unused)) struct cmdline *cl,
4271 __attribute__((unused)) void *data)
4273 struct cmd_csum_result *res = parsed_result;
4275 uint64_t csum_offloads = 0;
4276 struct rte_eth_dev_info dev_info;
4278 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4279 printf("invalid port %d\n", res->port_id);
4282 if (!port_is_stopped(res->port_id)) {
4283 printf("Please stop port %d first\n", res->port_id);
4287 rte_eth_dev_info_get(res->port_id, &dev_info);
4288 if (!strcmp(res->mode, "set")) {
4290 if (!strcmp(res->hwsw, "hw"))
4293 if (!strcmp(res->proto, "ip")) {
4294 if (hw == 0 || (dev_info.tx_offload_capa &
4295 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4296 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4298 printf("IP checksum offload is not supported "
4299 "by port %u\n", res->port_id);
4301 } else if (!strcmp(res->proto, "udp")) {
4302 if (hw == 0 || (dev_info.tx_offload_capa &
4303 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4304 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4306 printf("UDP checksum offload is not supported "
4307 "by port %u\n", res->port_id);
4309 } else if (!strcmp(res->proto, "tcp")) {
4310 if (hw == 0 || (dev_info.tx_offload_capa &
4311 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4312 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4314 printf("TCP checksum offload is not supported "
4315 "by port %u\n", res->port_id);
4317 } else if (!strcmp(res->proto, "sctp")) {
4318 if (hw == 0 || (dev_info.tx_offload_capa &
4319 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4320 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4322 printf("SCTP checksum offload is not supported "
4323 "by port %u\n", res->port_id);
4325 } else if (!strcmp(res->proto, "outer-ip")) {
4326 if (hw == 0 || (dev_info.tx_offload_capa &
4327 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4329 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4331 printf("Outer IP checksum offload is not "
4332 "supported by port %u\n", res->port_id);
4334 } else if (!strcmp(res->proto, "outer-udp")) {
4335 if (hw == 0 || (dev_info.tx_offload_capa &
4336 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4338 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4340 printf("Outer UDP checksum offload is not "
4341 "supported by port %u\n", res->port_id);
4346 ports[res->port_id].dev_conf.txmode.offloads |=
4349 ports[res->port_id].dev_conf.txmode.offloads &=
4353 csum_show(res->port_id);
4355 cmd_reconfig_device_queue(res->port_id, 1, 1);
4358 cmdline_parse_token_string_t cmd_csum_csum =
4359 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4361 cmdline_parse_token_string_t cmd_csum_mode =
4362 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4364 cmdline_parse_token_string_t cmd_csum_proto =
4365 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4366 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4367 cmdline_parse_token_string_t cmd_csum_hwsw =
4368 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4370 cmdline_parse_token_num_t cmd_csum_portid =
4371 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4374 cmdline_parse_inst_t cmd_csum_set = {
4375 .f = cmd_csum_parsed,
4377 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4378 "Enable/Disable hardware calculation of L3/L4 checksum when "
4379 "using csum forward engine",
4381 (void *)&cmd_csum_csum,
4382 (void *)&cmd_csum_mode,
4383 (void *)&cmd_csum_proto,
4384 (void *)&cmd_csum_hwsw,
4385 (void *)&cmd_csum_portid,
4390 cmdline_parse_token_string_t cmd_csum_mode_show =
4391 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4394 cmdline_parse_inst_t cmd_csum_show = {
4395 .f = cmd_csum_parsed,
4397 .help_str = "csum show <port_id>: Show checksum offload configuration",
4399 (void *)&cmd_csum_csum,
4400 (void *)&cmd_csum_mode_show,
4401 (void *)&cmd_csum_portid,
4406 /* Enable/disable tunnel parsing */
4407 struct cmd_csum_tunnel_result {
4408 cmdline_fixed_string_t csum;
4409 cmdline_fixed_string_t parse;
4410 cmdline_fixed_string_t onoff;
4415 cmd_csum_tunnel_parsed(void *parsed_result,
4416 __attribute__((unused)) struct cmdline *cl,
4417 __attribute__((unused)) void *data)
4419 struct cmd_csum_tunnel_result *res = parsed_result;
4421 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4424 if (!strcmp(res->onoff, "on"))
4425 ports[res->port_id].parse_tunnel = 1;
4427 ports[res->port_id].parse_tunnel = 0;
4429 csum_show(res->port_id);
4432 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4433 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4435 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4436 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4437 parse, "parse-tunnel");
4438 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4439 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4441 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4442 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4445 cmdline_parse_inst_t cmd_csum_tunnel = {
4446 .f = cmd_csum_tunnel_parsed,
4448 .help_str = "csum parse-tunnel on|off <port_id>: "
4449 "Enable/Disable parsing of tunnels for csum engine",
4451 (void *)&cmd_csum_tunnel_csum,
4452 (void *)&cmd_csum_tunnel_parse,
4453 (void *)&cmd_csum_tunnel_onoff,
4454 (void *)&cmd_csum_tunnel_portid,
4459 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4460 struct cmd_tso_set_result {
4461 cmdline_fixed_string_t tso;
4462 cmdline_fixed_string_t mode;
4468 cmd_tso_set_parsed(void *parsed_result,
4469 __attribute__((unused)) struct cmdline *cl,
4470 __attribute__((unused)) void *data)
4472 struct cmd_tso_set_result *res = parsed_result;
4473 struct rte_eth_dev_info dev_info;
4475 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4477 if (!port_is_stopped(res->port_id)) {
4478 printf("Please stop port %d first\n", res->port_id);
4482 if (!strcmp(res->mode, "set"))
4483 ports[res->port_id].tso_segsz = res->tso_segsz;
4485 rte_eth_dev_info_get(res->port_id, &dev_info);
4486 if ((ports[res->port_id].tso_segsz != 0) &&
4487 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4488 printf("Error: TSO is not supported by port %d\n",
4493 if (ports[res->port_id].tso_segsz == 0) {
4494 ports[res->port_id].dev_conf.txmode.offloads &=
4495 ~DEV_TX_OFFLOAD_TCP_TSO;
4496 printf("TSO for non-tunneled packets is disabled\n");
4498 ports[res->port_id].dev_conf.txmode.offloads |=
4499 DEV_TX_OFFLOAD_TCP_TSO;
4500 printf("TSO segment size for non-tunneled packets is %d\n",
4501 ports[res->port_id].tso_segsz);
4504 /* display warnings if configuration is not supported by the NIC */
4505 rte_eth_dev_info_get(res->port_id, &dev_info);
4506 if ((ports[res->port_id].tso_segsz != 0) &&
4507 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4508 printf("Warning: TSO enabled but not "
4509 "supported by port %d\n", res->port_id);
4512 cmd_reconfig_device_queue(res->port_id, 1, 1);
4515 cmdline_parse_token_string_t cmd_tso_set_tso =
4516 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4518 cmdline_parse_token_string_t cmd_tso_set_mode =
4519 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4521 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4522 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4524 cmdline_parse_token_num_t cmd_tso_set_portid =
4525 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4528 cmdline_parse_inst_t cmd_tso_set = {
4529 .f = cmd_tso_set_parsed,
4531 .help_str = "tso set <tso_segsz> <port_id>: "
4532 "Set TSO segment size of non-tunneled packets for csum engine "
4535 (void *)&cmd_tso_set_tso,
4536 (void *)&cmd_tso_set_mode,
4537 (void *)&cmd_tso_set_tso_segsz,
4538 (void *)&cmd_tso_set_portid,
4543 cmdline_parse_token_string_t cmd_tso_show_mode =
4544 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4548 cmdline_parse_inst_t cmd_tso_show = {
4549 .f = cmd_tso_set_parsed,
4551 .help_str = "tso show <port_id>: "
4552 "Show TSO segment size of non-tunneled packets for csum engine",
4554 (void *)&cmd_tso_set_tso,
4555 (void *)&cmd_tso_show_mode,
4556 (void *)&cmd_tso_set_portid,
4561 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4562 struct cmd_tunnel_tso_set_result {
4563 cmdline_fixed_string_t tso;
4564 cmdline_fixed_string_t mode;
4569 static struct rte_eth_dev_info
4570 check_tunnel_tso_nic_support(portid_t port_id)
4572 struct rte_eth_dev_info dev_info;
4574 rte_eth_dev_info_get(port_id, &dev_info);
4575 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4576 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4577 "not enabled for port %d\n", port_id);
4578 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4579 printf("Warning: GRE TUNNEL TSO not supported therefore "
4580 "not enabled for port %d\n", port_id);
4581 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4582 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4583 "not enabled for port %d\n", port_id);
4584 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4585 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4586 "not enabled for port %d\n", port_id);
4587 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4588 printf("Warning: IP TUNNEL TSO not supported therefore "
4589 "not enabled for port %d\n", port_id);
4590 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4591 printf("Warning: UDP TUNNEL TSO not supported therefore "
4592 "not enabled for port %d\n", port_id);
4597 cmd_tunnel_tso_set_parsed(void *parsed_result,
4598 __attribute__((unused)) struct cmdline *cl,
4599 __attribute__((unused)) void *data)
4601 struct cmd_tunnel_tso_set_result *res = parsed_result;
4602 struct rte_eth_dev_info dev_info;
4604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4606 if (!port_is_stopped(res->port_id)) {
4607 printf("Please stop port %d first\n", res->port_id);
4611 if (!strcmp(res->mode, "set"))
4612 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4614 dev_info = check_tunnel_tso_nic_support(res->port_id);
4615 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4616 ports[res->port_id].dev_conf.txmode.offloads &=
4617 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4618 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4619 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4620 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4621 DEV_TX_OFFLOAD_IP_TNL_TSO |
4622 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4623 printf("TSO for tunneled packets is disabled\n");
4625 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4626 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4627 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4628 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4629 DEV_TX_OFFLOAD_IP_TNL_TSO |
4630 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4632 ports[res->port_id].dev_conf.txmode.offloads |=
4633 (tso_offloads & dev_info.tx_offload_capa);
4634 printf("TSO segment size for tunneled packets is %d\n",
4635 ports[res->port_id].tunnel_tso_segsz);
4637 /* Below conditions are needed to make it work:
4638 * (1) tunnel TSO is supported by the NIC;
4639 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4641 * (3) for tunneled pkts with outer L3 of IPv4,
4642 * "csum set outer-ip" must be set to hw, because after tso,
4643 * total_len of outer IP header is changed, and the checksum
4644 * of outer IP header calculated by sw should be wrong; that
4645 * is not necessary for IPv6 tunneled pkts because there's no
4646 * checksum in IP header anymore.
4649 if (!ports[res->port_id].parse_tunnel)
4650 printf("Warning: csum parse_tunnel must be set "
4651 "so that tunneled packets are recognized\n");
4652 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4653 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4654 printf("Warning: csum set outer-ip must be set to hw "
4655 "if outer L3 is IPv4; not necessary for IPv6\n");
4658 cmd_reconfig_device_queue(res->port_id, 1, 1);
4661 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4662 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4664 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4665 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4667 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4668 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4670 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4671 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4674 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4675 .f = cmd_tunnel_tso_set_parsed,
4677 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4678 "Set TSO segment size of tunneled packets for csum engine "
4681 (void *)&cmd_tunnel_tso_set_tso,
4682 (void *)&cmd_tunnel_tso_set_mode,
4683 (void *)&cmd_tunnel_tso_set_tso_segsz,
4684 (void *)&cmd_tunnel_tso_set_portid,
4689 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4690 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4694 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4695 .f = cmd_tunnel_tso_set_parsed,
4697 .help_str = "tunnel_tso show <port_id> "
4698 "Show TSO segment size of tunneled packets for csum engine",
4700 (void *)&cmd_tunnel_tso_set_tso,
4701 (void *)&cmd_tunnel_tso_show_mode,
4702 (void *)&cmd_tunnel_tso_set_portid,
4707 /* *** SET GRO FOR A PORT *** */
4708 struct cmd_gro_enable_result {
4709 cmdline_fixed_string_t cmd_set;
4710 cmdline_fixed_string_t cmd_port;
4711 cmdline_fixed_string_t cmd_keyword;
4712 cmdline_fixed_string_t cmd_onoff;
4717 cmd_gro_enable_parsed(void *parsed_result,
4718 __attribute__((unused)) struct cmdline *cl,
4719 __attribute__((unused)) void *data)
4721 struct cmd_gro_enable_result *res;
4723 res = parsed_result;
4724 if (!strcmp(res->cmd_keyword, "gro"))
4725 setup_gro(res->cmd_onoff, res->cmd_pid);
4728 cmdline_parse_token_string_t cmd_gro_enable_set =
4729 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4731 cmdline_parse_token_string_t cmd_gro_enable_port =
4732 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4733 cmd_keyword, "port");
4734 cmdline_parse_token_num_t cmd_gro_enable_pid =
4735 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4737 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4738 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4739 cmd_keyword, "gro");
4740 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4741 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4742 cmd_onoff, "on#off");
4744 cmdline_parse_inst_t cmd_gro_enable = {
4745 .f = cmd_gro_enable_parsed,
4747 .help_str = "set port <port_id> gro on|off",
4749 (void *)&cmd_gro_enable_set,
4750 (void *)&cmd_gro_enable_port,
4751 (void *)&cmd_gro_enable_pid,
4752 (void *)&cmd_gro_enable_keyword,
4753 (void *)&cmd_gro_enable_onoff,
4758 /* *** DISPLAY GRO CONFIGURATION *** */
4759 struct cmd_gro_show_result {
4760 cmdline_fixed_string_t cmd_show;
4761 cmdline_fixed_string_t cmd_port;
4762 cmdline_fixed_string_t cmd_keyword;
4767 cmd_gro_show_parsed(void *parsed_result,
4768 __attribute__((unused)) struct cmdline *cl,
4769 __attribute__((unused)) void *data)
4771 struct cmd_gro_show_result *res;
4773 res = parsed_result;
4774 if (!strcmp(res->cmd_keyword, "gro"))
4775 show_gro(res->cmd_pid);
4778 cmdline_parse_token_string_t cmd_gro_show_show =
4779 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4781 cmdline_parse_token_string_t cmd_gro_show_port =
4782 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4784 cmdline_parse_token_num_t cmd_gro_show_pid =
4785 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4787 cmdline_parse_token_string_t cmd_gro_show_keyword =
4788 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4789 cmd_keyword, "gro");
4791 cmdline_parse_inst_t cmd_gro_show = {
4792 .f = cmd_gro_show_parsed,
4794 .help_str = "show port <port_id> gro",
4796 (void *)&cmd_gro_show_show,
4797 (void *)&cmd_gro_show_port,
4798 (void *)&cmd_gro_show_pid,
4799 (void *)&cmd_gro_show_keyword,
4804 /* *** SET FLUSH CYCLES FOR GRO *** */
4805 struct cmd_gro_flush_result {
4806 cmdline_fixed_string_t cmd_set;
4807 cmdline_fixed_string_t cmd_keyword;
4808 cmdline_fixed_string_t cmd_flush;
4813 cmd_gro_flush_parsed(void *parsed_result,
4814 __attribute__((unused)) struct cmdline *cl,
4815 __attribute__((unused)) void *data)
4817 struct cmd_gro_flush_result *res;
4819 res = parsed_result;
4820 if ((!strcmp(res->cmd_keyword, "gro")) &&
4821 (!strcmp(res->cmd_flush, "flush")))
4822 setup_gro_flush_cycles(res->cmd_cycles);
4825 cmdline_parse_token_string_t cmd_gro_flush_set =
4826 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4828 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4829 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4830 cmd_keyword, "gro");
4831 cmdline_parse_token_string_t cmd_gro_flush_flush =
4832 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4833 cmd_flush, "flush");
4834 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4835 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4838 cmdline_parse_inst_t cmd_gro_flush = {
4839 .f = cmd_gro_flush_parsed,
4841 .help_str = "set gro flush <cycles>",
4843 (void *)&cmd_gro_flush_set,
4844 (void *)&cmd_gro_flush_keyword,
4845 (void *)&cmd_gro_flush_flush,
4846 (void *)&cmd_gro_flush_cycles,
4851 /* *** ENABLE/DISABLE GSO *** */
4852 struct cmd_gso_enable_result {
4853 cmdline_fixed_string_t cmd_set;
4854 cmdline_fixed_string_t cmd_port;
4855 cmdline_fixed_string_t cmd_keyword;
4856 cmdline_fixed_string_t cmd_mode;
4861 cmd_gso_enable_parsed(void *parsed_result,
4862 __attribute__((unused)) struct cmdline *cl,
4863 __attribute__((unused)) void *data)
4865 struct cmd_gso_enable_result *res;
4867 res = parsed_result;
4868 if (!strcmp(res->cmd_keyword, "gso"))
4869 setup_gso(res->cmd_mode, res->cmd_pid);
4872 cmdline_parse_token_string_t cmd_gso_enable_set =
4873 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4875 cmdline_parse_token_string_t cmd_gso_enable_port =
4876 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4878 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4879 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4880 cmd_keyword, "gso");
4881 cmdline_parse_token_string_t cmd_gso_enable_mode =
4882 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4883 cmd_mode, "on#off");
4884 cmdline_parse_token_num_t cmd_gso_enable_pid =
4885 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4888 cmdline_parse_inst_t cmd_gso_enable = {
4889 .f = cmd_gso_enable_parsed,
4891 .help_str = "set port <port_id> gso on|off",
4893 (void *)&cmd_gso_enable_set,
4894 (void *)&cmd_gso_enable_port,
4895 (void *)&cmd_gso_enable_pid,
4896 (void *)&cmd_gso_enable_keyword,
4897 (void *)&cmd_gso_enable_mode,
4902 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4903 struct cmd_gso_size_result {
4904 cmdline_fixed_string_t cmd_set;
4905 cmdline_fixed_string_t cmd_keyword;
4906 cmdline_fixed_string_t cmd_segsz;
4911 cmd_gso_size_parsed(void *parsed_result,
4912 __attribute__((unused)) struct cmdline *cl,
4913 __attribute__((unused)) void *data)
4915 struct cmd_gso_size_result *res = parsed_result;
4917 if (test_done == 0) {
4918 printf("Before setting GSO segsz, please first"
4919 " stop fowarding\n");
4923 if (!strcmp(res->cmd_keyword, "gso") &&
4924 !strcmp(res->cmd_segsz, "segsz")) {
4925 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4926 printf("gso_size should be larger than %zu."
4927 " Please input a legal value\n",
4928 RTE_GSO_SEG_SIZE_MIN);
4930 gso_max_segment_size = res->cmd_size;
4934 cmdline_parse_token_string_t cmd_gso_size_set =
4935 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4937 cmdline_parse_token_string_t cmd_gso_size_keyword =
4938 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4939 cmd_keyword, "gso");
4940 cmdline_parse_token_string_t cmd_gso_size_segsz =
4941 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4942 cmd_segsz, "segsz");
4943 cmdline_parse_token_num_t cmd_gso_size_size =
4944 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4947 cmdline_parse_inst_t cmd_gso_size = {
4948 .f = cmd_gso_size_parsed,
4950 .help_str = "set gso segsz <length>",
4952 (void *)&cmd_gso_size_set,
4953 (void *)&cmd_gso_size_keyword,
4954 (void *)&cmd_gso_size_segsz,
4955 (void *)&cmd_gso_size_size,
4960 /* *** SHOW GSO CONFIGURATION *** */
4961 struct cmd_gso_show_result {
4962 cmdline_fixed_string_t cmd_show;
4963 cmdline_fixed_string_t cmd_port;
4964 cmdline_fixed_string_t cmd_keyword;
4969 cmd_gso_show_parsed(void *parsed_result,
4970 __attribute__((unused)) struct cmdline *cl,
4971 __attribute__((unused)) void *data)
4973 struct cmd_gso_show_result *res = parsed_result;
4975 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4976 printf("invalid port id %u\n", res->cmd_pid);
4979 if (!strcmp(res->cmd_keyword, "gso")) {
4980 if (gso_ports[res->cmd_pid].enable) {
4981 printf("Max GSO'd packet size: %uB\n"
4982 "Supported GSO types: TCP/IPv4, "
4983 "UDP/IPv4, VxLAN with inner "
4984 "TCP/IPv4 packet, GRE with inner "
4985 "TCP/IPv4 packet\n",
4986 gso_max_segment_size);
4988 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4992 cmdline_parse_token_string_t cmd_gso_show_show =
4993 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4995 cmdline_parse_token_string_t cmd_gso_show_port =
4996 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4998 cmdline_parse_token_string_t cmd_gso_show_keyword =
4999 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5000 cmd_keyword, "gso");
5001 cmdline_parse_token_num_t cmd_gso_show_pid =
5002 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5005 cmdline_parse_inst_t cmd_gso_show = {
5006 .f = cmd_gso_show_parsed,
5008 .help_str = "show port <port_id> gso",
5010 (void *)&cmd_gso_show_show,
5011 (void *)&cmd_gso_show_port,
5012 (void *)&cmd_gso_show_pid,
5013 (void *)&cmd_gso_show_keyword,
5018 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5019 struct cmd_set_flush_rx {
5020 cmdline_fixed_string_t set;
5021 cmdline_fixed_string_t flush_rx;
5022 cmdline_fixed_string_t mode;
5026 cmd_set_flush_rx_parsed(void *parsed_result,
5027 __attribute__((unused)) struct cmdline *cl,
5028 __attribute__((unused)) void *data)
5030 struct cmd_set_flush_rx *res = parsed_result;
5031 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5034 cmdline_parse_token_string_t cmd_setflushrx_set =
5035 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5037 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5038 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5039 flush_rx, "flush_rx");
5040 cmdline_parse_token_string_t cmd_setflushrx_mode =
5041 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5045 cmdline_parse_inst_t cmd_set_flush_rx = {
5046 .f = cmd_set_flush_rx_parsed,
5047 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5050 (void *)&cmd_setflushrx_set,
5051 (void *)&cmd_setflushrx_flush_rx,
5052 (void *)&cmd_setflushrx_mode,
5057 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5058 struct cmd_set_link_check {
5059 cmdline_fixed_string_t set;
5060 cmdline_fixed_string_t link_check;
5061 cmdline_fixed_string_t mode;
5065 cmd_set_link_check_parsed(void *parsed_result,
5066 __attribute__((unused)) struct cmdline *cl,
5067 __attribute__((unused)) void *data)
5069 struct cmd_set_link_check *res = parsed_result;
5070 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5073 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5074 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5076 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5077 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5078 link_check, "link_check");
5079 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5080 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5084 cmdline_parse_inst_t cmd_set_link_check = {
5085 .f = cmd_set_link_check_parsed,
5086 .help_str = "set link_check on|off: Enable/Disable link status check "
5087 "when starting/stopping a port",
5090 (void *)&cmd_setlinkcheck_set,
5091 (void *)&cmd_setlinkcheck_link_check,
5092 (void *)&cmd_setlinkcheck_mode,
5097 /* *** SET NIC BYPASS MODE *** */
5098 struct cmd_set_bypass_mode_result {
5099 cmdline_fixed_string_t set;
5100 cmdline_fixed_string_t bypass;
5101 cmdline_fixed_string_t mode;
5102 cmdline_fixed_string_t value;
5107 cmd_set_bypass_mode_parsed(void *parsed_result,
5108 __attribute__((unused)) struct cmdline *cl,
5109 __attribute__((unused)) void *data)
5111 struct cmd_set_bypass_mode_result *res = parsed_result;
5112 portid_t port_id = res->port_id;
5113 int32_t rc = -EINVAL;
5115 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5116 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5118 if (!strcmp(res->value, "bypass"))
5119 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5120 else if (!strcmp(res->value, "isolate"))
5121 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5123 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5125 /* Set the bypass mode for the relevant port. */
5126 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5129 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5132 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5133 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5135 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5136 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5138 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5139 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5141 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5142 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5143 value, "normal#bypass#isolate");
5144 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5145 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5148 cmdline_parse_inst_t cmd_set_bypass_mode = {
5149 .f = cmd_set_bypass_mode_parsed,
5150 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5151 "Set the NIC bypass mode for port_id",
5154 (void *)&cmd_setbypass_mode_set,
5155 (void *)&cmd_setbypass_mode_bypass,
5156 (void *)&cmd_setbypass_mode_mode,
5157 (void *)&cmd_setbypass_mode_value,
5158 (void *)&cmd_setbypass_mode_port,
5163 /* *** SET NIC BYPASS EVENT *** */
5164 struct cmd_set_bypass_event_result {
5165 cmdline_fixed_string_t set;
5166 cmdline_fixed_string_t bypass;
5167 cmdline_fixed_string_t event;
5168 cmdline_fixed_string_t event_value;
5169 cmdline_fixed_string_t mode;
5170 cmdline_fixed_string_t mode_value;
5175 cmd_set_bypass_event_parsed(void *parsed_result,
5176 __attribute__((unused)) struct cmdline *cl,
5177 __attribute__((unused)) void *data)
5179 int32_t rc = -EINVAL;
5180 struct cmd_set_bypass_event_result *res = parsed_result;
5181 portid_t port_id = res->port_id;
5183 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5184 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5185 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5187 if (!strcmp(res->event_value, "timeout"))
5188 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5189 else if (!strcmp(res->event_value, "os_on"))
5190 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5191 else if (!strcmp(res->event_value, "os_off"))
5192 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5193 else if (!strcmp(res->event_value, "power_on"))
5194 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5195 else if (!strcmp(res->event_value, "power_off"))
5196 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5198 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5200 if (!strcmp(res->mode_value, "bypass"))
5201 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5202 else if (!strcmp(res->mode_value, "isolate"))
5203 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5205 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5207 /* Set the watchdog timeout. */
5208 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5211 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5212 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5216 printf("Failed to set timeout value %u "
5217 "for port %d, errto code: %d.\n",
5218 bypass_timeout, port_id, rc);
5222 /* Set the bypass event to transition to bypass mode. */
5223 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5228 printf("\t Failed to set bypass event for port = %d.\n",
5232 cmdline_parse_token_string_t cmd_setbypass_event_set =
5233 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5235 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5236 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5238 cmdline_parse_token_string_t cmd_setbypass_event_event =
5239 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5241 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5242 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5243 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5244 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5245 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5247 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5248 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5249 mode_value, "normal#bypass#isolate");
5250 cmdline_parse_token_num_t cmd_setbypass_event_port =
5251 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5254 cmdline_parse_inst_t cmd_set_bypass_event = {
5255 .f = cmd_set_bypass_event_parsed,
5256 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5257 "power_off mode normal|bypass|isolate <port_id>: "
5258 "Set the NIC bypass event mode for port_id",
5261 (void *)&cmd_setbypass_event_set,
5262 (void *)&cmd_setbypass_event_bypass,
5263 (void *)&cmd_setbypass_event_event,
5264 (void *)&cmd_setbypass_event_event_value,
5265 (void *)&cmd_setbypass_event_mode,
5266 (void *)&cmd_setbypass_event_mode_value,
5267 (void *)&cmd_setbypass_event_port,
5273 /* *** SET NIC BYPASS TIMEOUT *** */
5274 struct cmd_set_bypass_timeout_result {
5275 cmdline_fixed_string_t set;
5276 cmdline_fixed_string_t bypass;
5277 cmdline_fixed_string_t timeout;
5278 cmdline_fixed_string_t value;
5282 cmd_set_bypass_timeout_parsed(void *parsed_result,
5283 __attribute__((unused)) struct cmdline *cl,
5284 __attribute__((unused)) void *data)
5286 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5288 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5289 if (!strcmp(res->value, "1.5"))
5290 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5291 else if (!strcmp(res->value, "2"))
5292 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5293 else if (!strcmp(res->value, "3"))
5294 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5295 else if (!strcmp(res->value, "4"))
5296 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5297 else if (!strcmp(res->value, "8"))
5298 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5299 else if (!strcmp(res->value, "16"))
5300 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5301 else if (!strcmp(res->value, "32"))
5302 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5304 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5308 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5309 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5311 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5312 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5314 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5315 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5316 timeout, "timeout");
5317 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5318 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5319 value, "0#1.5#2#3#4#8#16#32");
5321 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5322 .f = cmd_set_bypass_timeout_parsed,
5323 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5324 "Set the NIC bypass watchdog timeout in seconds",
5327 (void *)&cmd_setbypass_timeout_set,
5328 (void *)&cmd_setbypass_timeout_bypass,
5329 (void *)&cmd_setbypass_timeout_timeout,
5330 (void *)&cmd_setbypass_timeout_value,
5335 /* *** SHOW NIC BYPASS MODE *** */
5336 struct cmd_show_bypass_config_result {
5337 cmdline_fixed_string_t show;
5338 cmdline_fixed_string_t bypass;
5339 cmdline_fixed_string_t config;
5344 cmd_show_bypass_config_parsed(void *parsed_result,
5345 __attribute__((unused)) struct cmdline *cl,
5346 __attribute__((unused)) void *data)
5348 struct cmd_show_bypass_config_result *res = parsed_result;
5349 portid_t port_id = res->port_id;
5351 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5352 uint32_t event_mode;
5353 uint32_t bypass_mode;
5354 uint32_t timeout = bypass_timeout;
5357 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5358 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5359 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5360 {"UNKNOWN", "normal", "bypass", "isolate"};
5361 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5368 int num_events = (sizeof events) / (sizeof events[0]);
5370 /* Display the bypass mode.*/
5371 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5372 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5376 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5377 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5379 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5382 /* Display the bypass timeout.*/
5383 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5384 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5386 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5388 /* Display the bypass events and associated modes. */
5389 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5391 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5392 printf("\tFailed to get bypass mode for event = %s\n",
5395 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5396 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5398 printf("\tbypass event: %-16s = %s\n", events[i],
5404 printf("\tFailed to get bypass configuration for port = %d\n",
5408 cmdline_parse_token_string_t cmd_showbypass_config_show =
5409 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5411 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5412 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5414 cmdline_parse_token_string_t cmd_showbypass_config_config =
5415 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5417 cmdline_parse_token_num_t cmd_showbypass_config_port =
5418 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5421 cmdline_parse_inst_t cmd_show_bypass_config = {
5422 .f = cmd_show_bypass_config_parsed,
5423 .help_str = "show bypass config <port_id>: "
5424 "Show the NIC bypass config for port_id",
5427 (void *)&cmd_showbypass_config_show,
5428 (void *)&cmd_showbypass_config_bypass,
5429 (void *)&cmd_showbypass_config_config,
5430 (void *)&cmd_showbypass_config_port,
5435 #ifdef RTE_LIBRTE_PMD_BOND
5436 /* *** SET BONDING MODE *** */
5437 struct cmd_set_bonding_mode_result {
5438 cmdline_fixed_string_t set;
5439 cmdline_fixed_string_t bonding;
5440 cmdline_fixed_string_t mode;
5445 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5446 __attribute__((unused)) struct cmdline *cl,
5447 __attribute__((unused)) void *data)
5449 struct cmd_set_bonding_mode_result *res = parsed_result;
5450 portid_t port_id = res->port_id;
5452 /* Set the bonding mode for the relevant port. */
5453 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5454 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5457 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5458 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5460 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5461 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5462 bonding, "bonding");
5463 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5464 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5466 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5467 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5469 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5470 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5473 cmdline_parse_inst_t cmd_set_bonding_mode = {
5474 .f = cmd_set_bonding_mode_parsed,
5475 .help_str = "set bonding mode <mode_value> <port_id>: "
5476 "Set the bonding mode for port_id",
5479 (void *) &cmd_setbonding_mode_set,
5480 (void *) &cmd_setbonding_mode_bonding,
5481 (void *) &cmd_setbonding_mode_mode,
5482 (void *) &cmd_setbonding_mode_value,
5483 (void *) &cmd_setbonding_mode_port,
5488 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5489 struct cmd_set_bonding_lacp_dedicated_queues_result {
5490 cmdline_fixed_string_t set;
5491 cmdline_fixed_string_t bonding;
5492 cmdline_fixed_string_t lacp;
5493 cmdline_fixed_string_t dedicated_queues;
5495 cmdline_fixed_string_t mode;
5498 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5499 __attribute__((unused)) struct cmdline *cl,
5500 __attribute__((unused)) void *data)
5502 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5503 portid_t port_id = res->port_id;
5504 struct rte_port *port;
5506 port = &ports[port_id];
5508 /** Check if the port is not started **/
5509 if (port->port_status != RTE_PORT_STOPPED) {
5510 printf("Please stop port %d first\n", port_id);
5514 if (!strcmp(res->mode, "enable")) {
5515 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5516 printf("Dedicate queues for LACP control packets"
5519 printf("Enabling dedicate queues for LACP control "
5520 "packets on port %d failed\n", port_id);
5521 } else if (!strcmp(res->mode, "disable")) {
5522 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5523 printf("Dedicated queues for LACP control packets "
5526 printf("Disabling dedicated queues for LACP control "
5527 "traffic on port %d failed\n", port_id);
5531 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5532 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5534 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5535 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5536 bonding, "bonding");
5537 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5538 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5540 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5541 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5542 dedicated_queues, "dedicated_queues");
5543 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5544 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5546 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5547 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5548 mode, "enable#disable");
5550 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5551 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5552 .help_str = "set bonding lacp dedicated_queues <port_id> "
5554 "Enable/disable dedicated queues for LACP control traffic for port_id",
5557 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5558 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5559 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5560 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5561 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5562 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5567 /* *** SET BALANCE XMIT POLICY *** */
5568 struct cmd_set_bonding_balance_xmit_policy_result {
5569 cmdline_fixed_string_t set;
5570 cmdline_fixed_string_t bonding;
5571 cmdline_fixed_string_t balance_xmit_policy;
5573 cmdline_fixed_string_t policy;
5576 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5577 __attribute__((unused)) struct cmdline *cl,
5578 __attribute__((unused)) void *data)
5580 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5581 portid_t port_id = res->port_id;
5584 if (!strcmp(res->policy, "l2")) {
5585 policy = BALANCE_XMIT_POLICY_LAYER2;
5586 } else if (!strcmp(res->policy, "l23")) {
5587 policy = BALANCE_XMIT_POLICY_LAYER23;
5588 } else if (!strcmp(res->policy, "l34")) {
5589 policy = BALANCE_XMIT_POLICY_LAYER34;
5591 printf("\t Invalid xmit policy selection");
5595 /* Set the bonding mode for the relevant port. */
5596 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5597 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5602 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5603 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5605 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5606 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5607 bonding, "bonding");
5608 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5609 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5610 balance_xmit_policy, "balance_xmit_policy");
5611 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5612 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5614 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5615 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5616 policy, "l2#l23#l34");
5618 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5619 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5620 .help_str = "set bonding balance_xmit_policy <port_id> "
5622 "Set the bonding balance_xmit_policy for port_id",
5625 (void *)&cmd_setbonding_balance_xmit_policy_set,
5626 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5627 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5628 (void *)&cmd_setbonding_balance_xmit_policy_port,
5629 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5634 /* *** SHOW NIC BONDING CONFIGURATION *** */
5635 struct cmd_show_bonding_config_result {
5636 cmdline_fixed_string_t show;
5637 cmdline_fixed_string_t bonding;
5638 cmdline_fixed_string_t config;
5642 static void cmd_show_bonding_config_parsed(void *parsed_result,
5643 __attribute__((unused)) struct cmdline *cl,
5644 __attribute__((unused)) void *data)
5646 struct cmd_show_bonding_config_result *res = parsed_result;
5647 int bonding_mode, agg_mode;
5648 portid_t slaves[RTE_MAX_ETHPORTS];
5649 int num_slaves, num_active_slaves;
5652 portid_t port_id = res->port_id;
5654 /* Display the bonding mode.*/
5655 bonding_mode = rte_eth_bond_mode_get(port_id);
5656 if (bonding_mode < 0) {
5657 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5660 printf("\tBonding mode: %d\n", bonding_mode);
5662 if (bonding_mode == BONDING_MODE_BALANCE) {
5663 int balance_xmit_policy;
5665 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5666 if (balance_xmit_policy < 0) {
5667 printf("\tFailed to get balance xmit policy for port = %d\n",
5671 printf("\tBalance Xmit Policy: ");
5673 switch (balance_xmit_policy) {
5674 case BALANCE_XMIT_POLICY_LAYER2:
5675 printf("BALANCE_XMIT_POLICY_LAYER2");
5677 case BALANCE_XMIT_POLICY_LAYER23:
5678 printf("BALANCE_XMIT_POLICY_LAYER23");
5680 case BALANCE_XMIT_POLICY_LAYER34:
5681 printf("BALANCE_XMIT_POLICY_LAYER34");
5688 if (bonding_mode == BONDING_MODE_8023AD) {
5689 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5690 printf("\tIEEE802.3AD Aggregator Mode: ");
5693 printf("bandwidth");
5705 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5707 if (num_slaves < 0) {
5708 printf("\tFailed to get slave list for port = %d\n", port_id);
5711 if (num_slaves > 0) {
5712 printf("\tSlaves (%d): [", num_slaves);
5713 for (i = 0; i < num_slaves - 1; i++)
5714 printf("%d ", slaves[i]);
5716 printf("%d]\n", slaves[num_slaves - 1]);
5718 printf("\tSlaves: []\n");
5722 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5725 if (num_active_slaves < 0) {
5726 printf("\tFailed to get active slave list for port = %d\n", port_id);
5729 if (num_active_slaves > 0) {
5730 printf("\tActive Slaves (%d): [", num_active_slaves);
5731 for (i = 0; i < num_active_slaves - 1; i++)
5732 printf("%d ", slaves[i]);
5734 printf("%d]\n", slaves[num_active_slaves - 1]);
5737 printf("\tActive Slaves: []\n");
5741 primary_id = rte_eth_bond_primary_get(port_id);
5742 if (primary_id < 0) {
5743 printf("\tFailed to get primary slave for port = %d\n", port_id);
5746 printf("\tPrimary: [%d]\n", primary_id);
5750 cmdline_parse_token_string_t cmd_showbonding_config_show =
5751 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5753 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5754 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5755 bonding, "bonding");
5756 cmdline_parse_token_string_t cmd_showbonding_config_config =
5757 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5759 cmdline_parse_token_num_t cmd_showbonding_config_port =
5760 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5763 cmdline_parse_inst_t cmd_show_bonding_config = {
5764 .f = cmd_show_bonding_config_parsed,
5765 .help_str = "show bonding config <port_id>: "
5766 "Show the bonding config for port_id",
5769 (void *)&cmd_showbonding_config_show,
5770 (void *)&cmd_showbonding_config_bonding,
5771 (void *)&cmd_showbonding_config_config,
5772 (void *)&cmd_showbonding_config_port,
5777 /* *** SET BONDING PRIMARY *** */
5778 struct cmd_set_bonding_primary_result {
5779 cmdline_fixed_string_t set;
5780 cmdline_fixed_string_t bonding;
5781 cmdline_fixed_string_t primary;
5786 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5787 __attribute__((unused)) struct cmdline *cl,
5788 __attribute__((unused)) void *data)
5790 struct cmd_set_bonding_primary_result *res = parsed_result;
5791 portid_t master_port_id = res->port_id;
5792 portid_t slave_port_id = res->slave_id;
5794 /* Set the primary slave for a bonded device. */
5795 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5796 printf("\t Failed to set primary slave for port = %d.\n",
5803 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5804 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5806 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5807 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5808 bonding, "bonding");
5809 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5810 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5811 primary, "primary");
5812 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5813 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5815 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5816 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5819 cmdline_parse_inst_t cmd_set_bonding_primary = {
5820 .f = cmd_set_bonding_primary_parsed,
5821 .help_str = "set bonding primary <slave_id> <port_id>: "
5822 "Set the primary slave for port_id",
5825 (void *)&cmd_setbonding_primary_set,
5826 (void *)&cmd_setbonding_primary_bonding,
5827 (void *)&cmd_setbonding_primary_primary,
5828 (void *)&cmd_setbonding_primary_slave,
5829 (void *)&cmd_setbonding_primary_port,
5834 /* *** ADD SLAVE *** */
5835 struct cmd_add_bonding_slave_result {
5836 cmdline_fixed_string_t add;
5837 cmdline_fixed_string_t bonding;
5838 cmdline_fixed_string_t slave;
5843 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5844 __attribute__((unused)) struct cmdline *cl,
5845 __attribute__((unused)) void *data)
5847 struct cmd_add_bonding_slave_result *res = parsed_result;
5848 portid_t master_port_id = res->port_id;
5849 portid_t slave_port_id = res->slave_id;
5851 /* add the slave for a bonded device. */
5852 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5853 printf("\t Failed to add slave %d to master port = %d.\n",
5854 slave_port_id, master_port_id);
5858 set_port_slave_flag(slave_port_id);
5861 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5862 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5864 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5865 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5866 bonding, "bonding");
5867 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5868 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5870 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5871 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5873 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5874 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5877 cmdline_parse_inst_t cmd_add_bonding_slave = {
5878 .f = cmd_add_bonding_slave_parsed,
5879 .help_str = "add bonding slave <slave_id> <port_id>: "
5880 "Add a slave device to a bonded device",
5883 (void *)&cmd_addbonding_slave_add,
5884 (void *)&cmd_addbonding_slave_bonding,
5885 (void *)&cmd_addbonding_slave_slave,
5886 (void *)&cmd_addbonding_slave_slaveid,
5887 (void *)&cmd_addbonding_slave_port,
5892 /* *** REMOVE SLAVE *** */
5893 struct cmd_remove_bonding_slave_result {
5894 cmdline_fixed_string_t remove;
5895 cmdline_fixed_string_t bonding;
5896 cmdline_fixed_string_t slave;
5901 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5902 __attribute__((unused)) struct cmdline *cl,
5903 __attribute__((unused)) void *data)
5905 struct cmd_remove_bonding_slave_result *res = parsed_result;
5906 portid_t master_port_id = res->port_id;
5907 portid_t slave_port_id = res->slave_id;
5909 /* remove the slave from a bonded device. */
5910 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5911 printf("\t Failed to remove slave %d from master port = %d.\n",
5912 slave_port_id, master_port_id);
5916 clear_port_slave_flag(slave_port_id);
5919 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5920 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5922 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5923 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5924 bonding, "bonding");
5925 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5926 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5928 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5929 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5931 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5932 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5935 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5936 .f = cmd_remove_bonding_slave_parsed,
5937 .help_str = "remove bonding slave <slave_id> <port_id>: "
5938 "Remove a slave device from a bonded device",
5941 (void *)&cmd_removebonding_slave_remove,
5942 (void *)&cmd_removebonding_slave_bonding,
5943 (void *)&cmd_removebonding_slave_slave,
5944 (void *)&cmd_removebonding_slave_slaveid,
5945 (void *)&cmd_removebonding_slave_port,
5950 /* *** CREATE BONDED DEVICE *** */
5951 struct cmd_create_bonded_device_result {
5952 cmdline_fixed_string_t create;
5953 cmdline_fixed_string_t bonded;
5954 cmdline_fixed_string_t device;
5959 static int bond_dev_num = 0;
5961 static void cmd_create_bonded_device_parsed(void *parsed_result,
5962 __attribute__((unused)) struct cmdline *cl,
5963 __attribute__((unused)) void *data)
5965 struct cmd_create_bonded_device_result *res = parsed_result;
5966 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5969 if (test_done == 0) {
5970 printf("Please stop forwarding first\n");
5974 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5977 /* Create a new bonded device. */
5978 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5980 printf("\t Failed to create bonded device.\n");
5983 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5986 /* Update number of ports */
5987 nb_ports = rte_eth_dev_count_avail();
5988 reconfig(port_id, res->socket);
5989 rte_eth_promiscuous_enable(port_id);
5990 ports[port_id].need_setup = 0;
5991 ports[port_id].port_status = RTE_PORT_STOPPED;
5996 cmdline_parse_token_string_t cmd_createbonded_device_create =
5997 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5999 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6000 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6002 cmdline_parse_token_string_t cmd_createbonded_device_device =
6003 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6005 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6006 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6008 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6009 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6012 cmdline_parse_inst_t cmd_create_bonded_device = {
6013 .f = cmd_create_bonded_device_parsed,
6014 .help_str = "create bonded device <mode> <socket>: "
6015 "Create a new bonded device with specific bonding mode and socket",
6018 (void *)&cmd_createbonded_device_create,
6019 (void *)&cmd_createbonded_device_bonded,
6020 (void *)&cmd_createbonded_device_device,
6021 (void *)&cmd_createbonded_device_mode,
6022 (void *)&cmd_createbonded_device_socket,
6027 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6028 struct cmd_set_bond_mac_addr_result {
6029 cmdline_fixed_string_t set;
6030 cmdline_fixed_string_t bonding;
6031 cmdline_fixed_string_t mac_addr;
6033 struct ether_addr address;
6036 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6037 __attribute__((unused)) struct cmdline *cl,
6038 __attribute__((unused)) void *data)
6040 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6043 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6046 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6048 /* check the return value and print it if is < 0 */
6050 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6053 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6054 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6055 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6056 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6058 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6059 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6061 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6062 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6064 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6065 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6067 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6068 .f = cmd_set_bond_mac_addr_parsed,
6070 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6072 (void *)&cmd_set_bond_mac_addr_set,
6073 (void *)&cmd_set_bond_mac_addr_bonding,
6074 (void *)&cmd_set_bond_mac_addr_mac,
6075 (void *)&cmd_set_bond_mac_addr_portnum,
6076 (void *)&cmd_set_bond_mac_addr_addr,
6082 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6083 struct cmd_set_bond_mon_period_result {
6084 cmdline_fixed_string_t set;
6085 cmdline_fixed_string_t bonding;
6086 cmdline_fixed_string_t mon_period;
6091 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6092 __attribute__((unused)) struct cmdline *cl,
6093 __attribute__((unused)) void *data)
6095 struct cmd_set_bond_mon_period_result *res = parsed_result;
6098 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6100 /* check the return value and print it if is < 0 */
6102 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6105 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6106 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6108 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6109 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6110 bonding, "bonding");
6111 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6112 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6113 mon_period, "mon_period");
6114 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6115 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6117 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6118 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6121 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6122 .f = cmd_set_bond_mon_period_parsed,
6124 .help_str = "set bonding mon_period <port_id> <period_ms>",
6126 (void *)&cmd_set_bond_mon_period_set,
6127 (void *)&cmd_set_bond_mon_period_bonding,
6128 (void *)&cmd_set_bond_mon_period_mon_period,
6129 (void *)&cmd_set_bond_mon_period_portnum,
6130 (void *)&cmd_set_bond_mon_period_period_ms,
6137 struct cmd_set_bonding_agg_mode_policy_result {
6138 cmdline_fixed_string_t set;
6139 cmdline_fixed_string_t bonding;
6140 cmdline_fixed_string_t agg_mode;
6142 cmdline_fixed_string_t policy;
6147 cmd_set_bonding_agg_mode(void *parsed_result,
6148 __attribute__((unused)) struct cmdline *cl,
6149 __attribute__((unused)) void *data)
6151 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6152 uint8_t policy = AGG_BANDWIDTH;
6154 if (!strcmp(res->policy, "bandwidth"))
6155 policy = AGG_BANDWIDTH;
6156 else if (!strcmp(res->policy, "stable"))
6157 policy = AGG_STABLE;
6158 else if (!strcmp(res->policy, "count"))
6161 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6165 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6166 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6168 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6169 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6170 bonding, "bonding");
6172 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6173 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6174 agg_mode, "agg_mode");
6176 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6177 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6180 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6181 TOKEN_STRING_INITIALIZER(
6182 struct cmd_set_bonding_balance_xmit_policy_result,
6183 policy, "stable#bandwidth#count");
6185 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6186 .f = cmd_set_bonding_agg_mode,
6188 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6190 (void *)&cmd_set_bonding_agg_mode_set,
6191 (void *)&cmd_set_bonding_agg_mode_bonding,
6192 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6193 (void *)&cmd_set_bonding_agg_mode_portnum,
6194 (void *)&cmd_set_bonding_agg_mode_policy_string,
6200 #endif /* RTE_LIBRTE_PMD_BOND */
6202 /* *** SET FORWARDING MODE *** */
6203 struct cmd_set_fwd_mode_result {
6204 cmdline_fixed_string_t set;
6205 cmdline_fixed_string_t fwd;
6206 cmdline_fixed_string_t mode;
6209 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6210 __attribute__((unused)) struct cmdline *cl,
6211 __attribute__((unused)) void *data)
6213 struct cmd_set_fwd_mode_result *res = parsed_result;
6216 set_pkt_forwarding_mode(res->mode);
6219 cmdline_parse_token_string_t cmd_setfwd_set =
6220 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6221 cmdline_parse_token_string_t cmd_setfwd_fwd =
6222 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6223 cmdline_parse_token_string_t cmd_setfwd_mode =
6224 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6225 "" /* defined at init */);
6227 cmdline_parse_inst_t cmd_set_fwd_mode = {
6228 .f = cmd_set_fwd_mode_parsed,
6230 .help_str = NULL, /* defined at init */
6232 (void *)&cmd_setfwd_set,
6233 (void *)&cmd_setfwd_fwd,
6234 (void *)&cmd_setfwd_mode,
6239 static void cmd_set_fwd_mode_init(void)
6242 static char token[128];
6243 static char help[256];
6244 cmdline_parse_token_string_t *token_struct;
6246 modes = list_pkt_forwarding_modes();
6247 snprintf(help, sizeof(help), "set fwd %s: "
6248 "Set packet forwarding mode", modes);
6249 cmd_set_fwd_mode.help_str = help;
6251 /* string token separator is # */
6252 for (c = token; *modes != '\0'; modes++)
6257 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6258 token_struct->string_data.str = token;
6261 /* *** SET RETRY FORWARDING MODE *** */
6262 struct cmd_set_fwd_retry_mode_result {
6263 cmdline_fixed_string_t set;
6264 cmdline_fixed_string_t fwd;
6265 cmdline_fixed_string_t mode;
6266 cmdline_fixed_string_t retry;
6269 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6270 __attribute__((unused)) struct cmdline *cl,
6271 __attribute__((unused)) void *data)
6273 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6276 set_pkt_forwarding_mode(res->mode);
6279 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6280 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6282 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6283 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6285 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6286 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6288 "" /* defined at init */);
6289 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6290 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6293 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6294 .f = cmd_set_fwd_retry_mode_parsed,
6296 .help_str = NULL, /* defined at init */
6298 (void *)&cmd_setfwd_retry_set,
6299 (void *)&cmd_setfwd_retry_fwd,
6300 (void *)&cmd_setfwd_retry_mode,
6301 (void *)&cmd_setfwd_retry_retry,
6306 static void cmd_set_fwd_retry_mode_init(void)
6309 static char token[128];
6310 static char help[256];
6311 cmdline_parse_token_string_t *token_struct;
6313 modes = list_pkt_forwarding_retry_modes();
6314 snprintf(help, sizeof(help), "set fwd %s retry: "
6315 "Set packet forwarding mode with retry", modes);
6316 cmd_set_fwd_retry_mode.help_str = help;
6318 /* string token separator is # */
6319 for (c = token; *modes != '\0'; modes++)
6324 token_struct = (cmdline_parse_token_string_t *)
6325 cmd_set_fwd_retry_mode.tokens[2];
6326 token_struct->string_data.str = token;
6329 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6330 struct cmd_set_burst_tx_retry_result {
6331 cmdline_fixed_string_t set;
6332 cmdline_fixed_string_t burst;
6333 cmdline_fixed_string_t tx;
6334 cmdline_fixed_string_t delay;
6336 cmdline_fixed_string_t retry;
6340 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6341 __attribute__((unused)) struct cmdline *cl,
6342 __attribute__((unused)) void *data)
6344 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6346 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6347 && !strcmp(res->tx, "tx")) {
6348 if (!strcmp(res->delay, "delay"))
6349 burst_tx_delay_time = res->time;
6350 if (!strcmp(res->retry, "retry"))
6351 burst_tx_retry_num = res->retry_num;
6356 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6357 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6358 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6359 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6361 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6362 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6363 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6365 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6366 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6367 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6368 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6369 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6370 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6372 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6373 .f = cmd_set_burst_tx_retry_parsed,
6374 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6376 (void *)&cmd_set_burst_tx_retry_set,
6377 (void *)&cmd_set_burst_tx_retry_burst,
6378 (void *)&cmd_set_burst_tx_retry_tx,
6379 (void *)&cmd_set_burst_tx_retry_delay,
6380 (void *)&cmd_set_burst_tx_retry_time,
6381 (void *)&cmd_set_burst_tx_retry_retry,
6382 (void *)&cmd_set_burst_tx_retry_retry_num,
6387 /* *** SET PROMISC MODE *** */
6388 struct cmd_set_promisc_mode_result {
6389 cmdline_fixed_string_t set;
6390 cmdline_fixed_string_t promisc;
6391 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6392 uint16_t port_num; /* valid if "allports" argument == 0 */
6393 cmdline_fixed_string_t mode;
6396 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6397 __attribute__((unused)) struct cmdline *cl,
6400 struct cmd_set_promisc_mode_result *res = parsed_result;
6404 if (!strcmp(res->mode, "on"))
6411 RTE_ETH_FOREACH_DEV(i) {
6413 rte_eth_promiscuous_enable(i);
6415 rte_eth_promiscuous_disable(i);
6420 rte_eth_promiscuous_enable(res->port_num);
6422 rte_eth_promiscuous_disable(res->port_num);
6426 cmdline_parse_token_string_t cmd_setpromisc_set =
6427 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6428 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6429 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6431 cmdline_parse_token_string_t cmd_setpromisc_portall =
6432 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6434 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6435 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6437 cmdline_parse_token_string_t cmd_setpromisc_mode =
6438 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6441 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6442 .f = cmd_set_promisc_mode_parsed,
6444 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6446 (void *)&cmd_setpromisc_set,
6447 (void *)&cmd_setpromisc_promisc,
6448 (void *)&cmd_setpromisc_portall,
6449 (void *)&cmd_setpromisc_mode,
6454 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6455 .f = cmd_set_promisc_mode_parsed,
6457 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6459 (void *)&cmd_setpromisc_set,
6460 (void *)&cmd_setpromisc_promisc,
6461 (void *)&cmd_setpromisc_portnum,
6462 (void *)&cmd_setpromisc_mode,
6467 /* *** SET ALLMULTI MODE *** */
6468 struct cmd_set_allmulti_mode_result {
6469 cmdline_fixed_string_t set;
6470 cmdline_fixed_string_t allmulti;
6471 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6472 uint16_t port_num; /* valid if "allports" argument == 0 */
6473 cmdline_fixed_string_t mode;
6476 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6477 __attribute__((unused)) struct cmdline *cl,
6480 struct cmd_set_allmulti_mode_result *res = parsed_result;
6484 if (!strcmp(res->mode, "on"))
6491 RTE_ETH_FOREACH_DEV(i) {
6493 rte_eth_allmulticast_enable(i);
6495 rte_eth_allmulticast_disable(i);
6500 rte_eth_allmulticast_enable(res->port_num);
6502 rte_eth_allmulticast_disable(res->port_num);
6506 cmdline_parse_token_string_t cmd_setallmulti_set =
6507 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6508 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6509 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6511 cmdline_parse_token_string_t cmd_setallmulti_portall =
6512 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6514 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6515 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6517 cmdline_parse_token_string_t cmd_setallmulti_mode =
6518 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6521 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6522 .f = cmd_set_allmulti_mode_parsed,
6524 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6526 (void *)&cmd_setallmulti_set,
6527 (void *)&cmd_setallmulti_allmulti,
6528 (void *)&cmd_setallmulti_portall,
6529 (void *)&cmd_setallmulti_mode,
6534 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6535 .f = cmd_set_allmulti_mode_parsed,
6537 .help_str = "set allmulti <port_id> on|off: "
6538 "Set allmulti mode on port_id",
6540 (void *)&cmd_setallmulti_set,
6541 (void *)&cmd_setallmulti_allmulti,
6542 (void *)&cmd_setallmulti_portnum,
6543 (void *)&cmd_setallmulti_mode,
6548 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6549 struct cmd_link_flow_ctrl_set_result {
6550 cmdline_fixed_string_t set;
6551 cmdline_fixed_string_t flow_ctrl;
6552 cmdline_fixed_string_t rx;
6553 cmdline_fixed_string_t rx_lfc_mode;
6554 cmdline_fixed_string_t tx;
6555 cmdline_fixed_string_t tx_lfc_mode;
6556 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6557 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6558 cmdline_fixed_string_t autoneg_str;
6559 cmdline_fixed_string_t autoneg;
6560 cmdline_fixed_string_t hw_str;
6561 uint32_t high_water;
6562 cmdline_fixed_string_t lw_str;
6564 cmdline_fixed_string_t pt_str;
6565 uint16_t pause_time;
6566 cmdline_fixed_string_t xon_str;
6571 cmdline_parse_token_string_t cmd_lfc_set_set =
6572 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6574 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6575 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6576 flow_ctrl, "flow_ctrl");
6577 cmdline_parse_token_string_t cmd_lfc_set_rx =
6578 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6580 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6581 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6582 rx_lfc_mode, "on#off");
6583 cmdline_parse_token_string_t cmd_lfc_set_tx =
6584 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6586 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6587 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6588 tx_lfc_mode, "on#off");
6589 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6590 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6591 hw_str, "high_water");
6592 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6593 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6594 high_water, UINT32);
6595 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6596 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6597 lw_str, "low_water");
6598 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6599 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6601 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6602 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6603 pt_str, "pause_time");
6604 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6605 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6606 pause_time, UINT16);
6607 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6608 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6609 xon_str, "send_xon");
6610 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6611 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6613 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6614 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6615 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6616 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6617 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6618 mac_ctrl_frame_fwd_mode, "on#off");
6619 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6620 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6621 autoneg_str, "autoneg");
6622 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6623 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6625 cmdline_parse_token_num_t cmd_lfc_set_portid =
6626 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6629 /* forward declaration */
6631 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6634 cmdline_parse_inst_t cmd_link_flow_control_set = {
6635 .f = cmd_link_flow_ctrl_set_parsed,
6637 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6638 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6639 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6641 (void *)&cmd_lfc_set_set,
6642 (void *)&cmd_lfc_set_flow_ctrl,
6643 (void *)&cmd_lfc_set_rx,
6644 (void *)&cmd_lfc_set_rx_mode,
6645 (void *)&cmd_lfc_set_tx,
6646 (void *)&cmd_lfc_set_tx_mode,
6647 (void *)&cmd_lfc_set_high_water,
6648 (void *)&cmd_lfc_set_low_water,
6649 (void *)&cmd_lfc_set_pause_time,
6650 (void *)&cmd_lfc_set_send_xon,
6651 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6652 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6653 (void *)&cmd_lfc_set_autoneg_str,
6654 (void *)&cmd_lfc_set_autoneg,
6655 (void *)&cmd_lfc_set_portid,
6660 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6661 .f = cmd_link_flow_ctrl_set_parsed,
6662 .data = (void *)&cmd_link_flow_control_set_rx,
6663 .help_str = "set flow_ctrl rx on|off <port_id>: "
6664 "Change rx flow control parameter",
6666 (void *)&cmd_lfc_set_set,
6667 (void *)&cmd_lfc_set_flow_ctrl,
6668 (void *)&cmd_lfc_set_rx,
6669 (void *)&cmd_lfc_set_rx_mode,
6670 (void *)&cmd_lfc_set_portid,
6675 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6676 .f = cmd_link_flow_ctrl_set_parsed,
6677 .data = (void *)&cmd_link_flow_control_set_tx,
6678 .help_str = "set flow_ctrl tx on|off <port_id>: "
6679 "Change tx flow control parameter",
6681 (void *)&cmd_lfc_set_set,
6682 (void *)&cmd_lfc_set_flow_ctrl,
6683 (void *)&cmd_lfc_set_tx,
6684 (void *)&cmd_lfc_set_tx_mode,
6685 (void *)&cmd_lfc_set_portid,
6690 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6691 .f = cmd_link_flow_ctrl_set_parsed,
6692 .data = (void *)&cmd_link_flow_control_set_hw,
6693 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6694 "Change high water flow control parameter",
6696 (void *)&cmd_lfc_set_set,
6697 (void *)&cmd_lfc_set_flow_ctrl,
6698 (void *)&cmd_lfc_set_high_water_str,
6699 (void *)&cmd_lfc_set_high_water,
6700 (void *)&cmd_lfc_set_portid,
6705 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6706 .f = cmd_link_flow_ctrl_set_parsed,
6707 .data = (void *)&cmd_link_flow_control_set_lw,
6708 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6709 "Change low water flow control parameter",
6711 (void *)&cmd_lfc_set_set,
6712 (void *)&cmd_lfc_set_flow_ctrl,
6713 (void *)&cmd_lfc_set_low_water_str,
6714 (void *)&cmd_lfc_set_low_water,
6715 (void *)&cmd_lfc_set_portid,
6720 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6721 .f = cmd_link_flow_ctrl_set_parsed,
6722 .data = (void *)&cmd_link_flow_control_set_pt,
6723 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6724 "Change pause time flow control parameter",
6726 (void *)&cmd_lfc_set_set,
6727 (void *)&cmd_lfc_set_flow_ctrl,
6728 (void *)&cmd_lfc_set_pause_time_str,
6729 (void *)&cmd_lfc_set_pause_time,
6730 (void *)&cmd_lfc_set_portid,
6735 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6736 .f = cmd_link_flow_ctrl_set_parsed,
6737 .data = (void *)&cmd_link_flow_control_set_xon,
6738 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6739 "Change send_xon flow control parameter",
6741 (void *)&cmd_lfc_set_set,
6742 (void *)&cmd_lfc_set_flow_ctrl,
6743 (void *)&cmd_lfc_set_send_xon_str,
6744 (void *)&cmd_lfc_set_send_xon,
6745 (void *)&cmd_lfc_set_portid,
6750 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6751 .f = cmd_link_flow_ctrl_set_parsed,
6752 .data = (void *)&cmd_link_flow_control_set_macfwd,
6753 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6754 "Change mac ctrl fwd flow control parameter",
6756 (void *)&cmd_lfc_set_set,
6757 (void *)&cmd_lfc_set_flow_ctrl,
6758 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6759 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6760 (void *)&cmd_lfc_set_portid,
6765 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6766 .f = cmd_link_flow_ctrl_set_parsed,
6767 .data = (void *)&cmd_link_flow_control_set_autoneg,
6768 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6769 "Change autoneg flow control parameter",
6771 (void *)&cmd_lfc_set_set,
6772 (void *)&cmd_lfc_set_flow_ctrl,
6773 (void *)&cmd_lfc_set_autoneg_str,
6774 (void *)&cmd_lfc_set_autoneg,
6775 (void *)&cmd_lfc_set_portid,
6781 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6782 __attribute__((unused)) struct cmdline *cl,
6785 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6786 cmdline_parse_inst_t *cmd = data;
6787 struct rte_eth_fc_conf fc_conf;
6793 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6794 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6795 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6796 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6798 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6799 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6802 /* Partial command line, retrieve current configuration */
6804 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6806 printf("cannot get current flow ctrl parameters, return"
6807 "code = %d\n", ret);
6811 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6812 (fc_conf.mode == RTE_FC_FULL))
6814 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6815 (fc_conf.mode == RTE_FC_FULL))
6819 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6820 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6822 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6823 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6825 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6827 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6828 fc_conf.high_water = res->high_water;
6830 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6831 fc_conf.low_water = res->low_water;
6833 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6834 fc_conf.pause_time = res->pause_time;
6836 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6837 fc_conf.send_xon = res->send_xon;
6839 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6840 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6841 fc_conf.mac_ctrl_frame_fwd = 1;
6843 fc_conf.mac_ctrl_frame_fwd = 0;
6846 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6847 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6849 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6851 printf("bad flow contrl parameter, return code = %d \n", ret);
6854 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6855 struct cmd_priority_flow_ctrl_set_result {
6856 cmdline_fixed_string_t set;
6857 cmdline_fixed_string_t pfc_ctrl;
6858 cmdline_fixed_string_t rx;
6859 cmdline_fixed_string_t rx_pfc_mode;
6860 cmdline_fixed_string_t tx;
6861 cmdline_fixed_string_t tx_pfc_mode;
6862 uint32_t high_water;
6864 uint16_t pause_time;
6870 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6871 __attribute__((unused)) struct cmdline *cl,
6872 __attribute__((unused)) void *data)
6874 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6875 struct rte_eth_pfc_conf pfc_conf;
6876 int rx_fc_enable, tx_fc_enable;
6880 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6881 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6882 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6883 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6885 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6886 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6889 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6890 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6891 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6892 pfc_conf.fc.high_water = res->high_water;
6893 pfc_conf.fc.low_water = res->low_water;
6894 pfc_conf.fc.pause_time = res->pause_time;
6895 pfc_conf.priority = res->priority;
6897 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6899 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6902 cmdline_parse_token_string_t cmd_pfc_set_set =
6903 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6905 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6906 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6907 pfc_ctrl, "pfc_ctrl");
6908 cmdline_parse_token_string_t cmd_pfc_set_rx =
6909 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6911 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6912 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6913 rx_pfc_mode, "on#off");
6914 cmdline_parse_token_string_t cmd_pfc_set_tx =
6915 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6917 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6918 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6919 tx_pfc_mode, "on#off");
6920 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6921 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6922 high_water, UINT32);
6923 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6924 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6926 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6927 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6928 pause_time, UINT16);
6929 cmdline_parse_token_num_t cmd_pfc_set_priority =
6930 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6932 cmdline_parse_token_num_t cmd_pfc_set_portid =
6933 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6936 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6937 .f = cmd_priority_flow_ctrl_set_parsed,
6939 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6940 "<pause_time> <priority> <port_id>: "
6941 "Configure the Ethernet priority flow control",
6943 (void *)&cmd_pfc_set_set,
6944 (void *)&cmd_pfc_set_flow_ctrl,
6945 (void *)&cmd_pfc_set_rx,
6946 (void *)&cmd_pfc_set_rx_mode,
6947 (void *)&cmd_pfc_set_tx,
6948 (void *)&cmd_pfc_set_tx_mode,
6949 (void *)&cmd_pfc_set_high_water,
6950 (void *)&cmd_pfc_set_low_water,
6951 (void *)&cmd_pfc_set_pause_time,
6952 (void *)&cmd_pfc_set_priority,
6953 (void *)&cmd_pfc_set_portid,
6958 /* *** RESET CONFIGURATION *** */
6959 struct cmd_reset_result {
6960 cmdline_fixed_string_t reset;
6961 cmdline_fixed_string_t def;
6964 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6966 __attribute__((unused)) void *data)
6968 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6969 set_def_fwd_config();
6972 cmdline_parse_token_string_t cmd_reset_set =
6973 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6974 cmdline_parse_token_string_t cmd_reset_def =
6975 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6978 cmdline_parse_inst_t cmd_reset = {
6979 .f = cmd_reset_parsed,
6981 .help_str = "set default: Reset default forwarding configuration",
6983 (void *)&cmd_reset_set,
6984 (void *)&cmd_reset_def,
6989 /* *** START FORWARDING *** */
6990 struct cmd_start_result {
6991 cmdline_fixed_string_t start;
6994 cmdline_parse_token_string_t cmd_start_start =
6995 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6997 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6998 __attribute__((unused)) struct cmdline *cl,
6999 __attribute__((unused)) void *data)
7001 start_packet_forwarding(0);
7004 cmdline_parse_inst_t cmd_start = {
7005 .f = cmd_start_parsed,
7007 .help_str = "start: Start packet forwarding",
7009 (void *)&cmd_start_start,
7014 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7015 struct cmd_start_tx_first_result {
7016 cmdline_fixed_string_t start;
7017 cmdline_fixed_string_t tx_first;
7021 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7022 __attribute__((unused)) struct cmdline *cl,
7023 __attribute__((unused)) void *data)
7025 start_packet_forwarding(1);
7028 cmdline_parse_token_string_t cmd_start_tx_first_start =
7029 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7031 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7032 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7033 tx_first, "tx_first");
7035 cmdline_parse_inst_t cmd_start_tx_first = {
7036 .f = cmd_start_tx_first_parsed,
7038 .help_str = "start tx_first: Start packet forwarding, "
7039 "after sending 1 burst of packets",
7041 (void *)&cmd_start_tx_first_start,
7042 (void *)&cmd_start_tx_first_tx_first,
7047 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7048 struct cmd_start_tx_first_n_result {
7049 cmdline_fixed_string_t start;
7050 cmdline_fixed_string_t tx_first;
7055 cmd_start_tx_first_n_parsed(void *parsed_result,
7056 __attribute__((unused)) struct cmdline *cl,
7057 __attribute__((unused)) void *data)
7059 struct cmd_start_tx_first_n_result *res = parsed_result;
7061 start_packet_forwarding(res->tx_num);
7064 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7065 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7067 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7068 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7069 tx_first, "tx_first");
7070 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7071 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7074 cmdline_parse_inst_t cmd_start_tx_first_n = {
7075 .f = cmd_start_tx_first_n_parsed,
7077 .help_str = "start tx_first <num>: "
7078 "packet forwarding, after sending <num> bursts of packets",
7080 (void *)&cmd_start_tx_first_n_start,
7081 (void *)&cmd_start_tx_first_n_tx_first,
7082 (void *)&cmd_start_tx_first_n_tx_num,
7087 /* *** SET LINK UP *** */
7088 struct cmd_set_link_up_result {
7089 cmdline_fixed_string_t set;
7090 cmdline_fixed_string_t link_up;
7091 cmdline_fixed_string_t port;
7095 cmdline_parse_token_string_t cmd_set_link_up_set =
7096 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7097 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7098 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7100 cmdline_parse_token_string_t cmd_set_link_up_port =
7101 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7102 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7103 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7105 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7106 __attribute__((unused)) struct cmdline *cl,
7107 __attribute__((unused)) void *data)
7109 struct cmd_set_link_up_result *res = parsed_result;
7110 dev_set_link_up(res->port_id);
7113 cmdline_parse_inst_t cmd_set_link_up = {
7114 .f = cmd_set_link_up_parsed,
7116 .help_str = "set link-up port <port id>",
7118 (void *)&cmd_set_link_up_set,
7119 (void *)&cmd_set_link_up_link_up,
7120 (void *)&cmd_set_link_up_port,
7121 (void *)&cmd_set_link_up_port_id,
7126 /* *** SET LINK DOWN *** */
7127 struct cmd_set_link_down_result {
7128 cmdline_fixed_string_t set;
7129 cmdline_fixed_string_t link_down;
7130 cmdline_fixed_string_t port;
7134 cmdline_parse_token_string_t cmd_set_link_down_set =
7135 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7136 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7137 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7139 cmdline_parse_token_string_t cmd_set_link_down_port =
7140 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7141 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7142 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7144 static void cmd_set_link_down_parsed(
7145 __attribute__((unused)) void *parsed_result,
7146 __attribute__((unused)) struct cmdline *cl,
7147 __attribute__((unused)) void *data)
7149 struct cmd_set_link_down_result *res = parsed_result;
7150 dev_set_link_down(res->port_id);
7153 cmdline_parse_inst_t cmd_set_link_down = {
7154 .f = cmd_set_link_down_parsed,
7156 .help_str = "set link-down port <port id>",
7158 (void *)&cmd_set_link_down_set,
7159 (void *)&cmd_set_link_down_link_down,
7160 (void *)&cmd_set_link_down_port,
7161 (void *)&cmd_set_link_down_port_id,
7166 /* *** SHOW CFG *** */
7167 struct cmd_showcfg_result {
7168 cmdline_fixed_string_t show;
7169 cmdline_fixed_string_t cfg;
7170 cmdline_fixed_string_t what;
7173 static void cmd_showcfg_parsed(void *parsed_result,
7174 __attribute__((unused)) struct cmdline *cl,
7175 __attribute__((unused)) void *data)
7177 struct cmd_showcfg_result *res = parsed_result;
7178 if (!strcmp(res->what, "rxtx"))
7179 rxtx_config_display();
7180 else if (!strcmp(res->what, "cores"))
7181 fwd_lcores_config_display();
7182 else if (!strcmp(res->what, "fwd"))
7183 pkt_fwd_config_display(&cur_fwd_config);
7184 else if (!strcmp(res->what, "txpkts"))
7185 show_tx_pkt_segments();
7188 cmdline_parse_token_string_t cmd_showcfg_show =
7189 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7190 cmdline_parse_token_string_t cmd_showcfg_port =
7191 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7192 cmdline_parse_token_string_t cmd_showcfg_what =
7193 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7194 "rxtx#cores#fwd#txpkts");
7196 cmdline_parse_inst_t cmd_showcfg = {
7197 .f = cmd_showcfg_parsed,
7199 .help_str = "show config rxtx|cores|fwd|txpkts",
7201 (void *)&cmd_showcfg_show,
7202 (void *)&cmd_showcfg_port,
7203 (void *)&cmd_showcfg_what,
7208 /* *** SHOW ALL PORT INFO *** */
7209 struct cmd_showportall_result {
7210 cmdline_fixed_string_t show;
7211 cmdline_fixed_string_t port;
7212 cmdline_fixed_string_t what;
7213 cmdline_fixed_string_t all;
7216 static void cmd_showportall_parsed(void *parsed_result,
7217 __attribute__((unused)) struct cmdline *cl,
7218 __attribute__((unused)) void *data)
7222 struct cmd_showportall_result *res = parsed_result;
7223 if (!strcmp(res->show, "clear")) {
7224 if (!strcmp(res->what, "stats"))
7225 RTE_ETH_FOREACH_DEV(i)
7227 else if (!strcmp(res->what, "xstats"))
7228 RTE_ETH_FOREACH_DEV(i)
7229 nic_xstats_clear(i);
7230 } else if (!strcmp(res->what, "info"))
7231 RTE_ETH_FOREACH_DEV(i)
7232 port_infos_display(i);
7233 else if (!strcmp(res->what, "summary")) {
7234 port_summary_header_display();
7235 RTE_ETH_FOREACH_DEV(i)
7236 port_summary_display(i);
7238 else if (!strcmp(res->what, "stats"))
7239 RTE_ETH_FOREACH_DEV(i)
7240 nic_stats_display(i);
7241 else if (!strcmp(res->what, "xstats"))
7242 RTE_ETH_FOREACH_DEV(i)
7243 nic_xstats_display(i);
7244 else if (!strcmp(res->what, "fdir"))
7245 RTE_ETH_FOREACH_DEV(i)
7247 else if (!strcmp(res->what, "stat_qmap"))
7248 RTE_ETH_FOREACH_DEV(i)
7249 nic_stats_mapping_display(i);
7250 else if (!strcmp(res->what, "dcb_tc"))
7251 RTE_ETH_FOREACH_DEV(i)
7252 port_dcb_info_display(i);
7253 else if (!strcmp(res->what, "cap"))
7254 RTE_ETH_FOREACH_DEV(i)
7255 port_offload_cap_display(i);
7258 cmdline_parse_token_string_t cmd_showportall_show =
7259 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7261 cmdline_parse_token_string_t cmd_showportall_port =
7262 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7263 cmdline_parse_token_string_t cmd_showportall_what =
7264 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7265 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7266 cmdline_parse_token_string_t cmd_showportall_all =
7267 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7268 cmdline_parse_inst_t cmd_showportall = {
7269 .f = cmd_showportall_parsed,
7271 .help_str = "show|clear port "
7272 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7274 (void *)&cmd_showportall_show,
7275 (void *)&cmd_showportall_port,
7276 (void *)&cmd_showportall_what,
7277 (void *)&cmd_showportall_all,
7282 /* *** SHOW PORT INFO *** */
7283 struct cmd_showport_result {
7284 cmdline_fixed_string_t show;
7285 cmdline_fixed_string_t port;
7286 cmdline_fixed_string_t what;
7290 static void cmd_showport_parsed(void *parsed_result,
7291 __attribute__((unused)) struct cmdline *cl,
7292 __attribute__((unused)) void *data)
7294 struct cmd_showport_result *res = parsed_result;
7295 if (!strcmp(res->show, "clear")) {
7296 if (!strcmp(res->what, "stats"))
7297 nic_stats_clear(res->portnum);
7298 else if (!strcmp(res->what, "xstats"))
7299 nic_xstats_clear(res->portnum);
7300 } else if (!strcmp(res->what, "info"))
7301 port_infos_display(res->portnum);
7302 else if (!strcmp(res->what, "summary")) {
7303 port_summary_header_display();
7304 port_summary_display(res->portnum);
7306 else if (!strcmp(res->what, "stats"))
7307 nic_stats_display(res->portnum);
7308 else if (!strcmp(res->what, "xstats"))
7309 nic_xstats_display(res->portnum);
7310 else if (!strcmp(res->what, "fdir"))
7311 fdir_get_infos(res->portnum);
7312 else if (!strcmp(res->what, "stat_qmap"))
7313 nic_stats_mapping_display(res->portnum);
7314 else if (!strcmp(res->what, "dcb_tc"))
7315 port_dcb_info_display(res->portnum);
7316 else if (!strcmp(res->what, "cap"))
7317 port_offload_cap_display(res->portnum);
7320 cmdline_parse_token_string_t cmd_showport_show =
7321 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7323 cmdline_parse_token_string_t cmd_showport_port =
7324 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7325 cmdline_parse_token_string_t cmd_showport_what =
7326 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7327 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7328 cmdline_parse_token_num_t cmd_showport_portnum =
7329 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7331 cmdline_parse_inst_t cmd_showport = {
7332 .f = cmd_showport_parsed,
7334 .help_str = "show|clear port "
7335 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7338 (void *)&cmd_showport_show,
7339 (void *)&cmd_showport_port,
7340 (void *)&cmd_showport_what,
7341 (void *)&cmd_showport_portnum,
7346 /* *** SHOW QUEUE INFO *** */
7347 struct cmd_showqueue_result {
7348 cmdline_fixed_string_t show;
7349 cmdline_fixed_string_t type;
7350 cmdline_fixed_string_t what;
7356 cmd_showqueue_parsed(void *parsed_result,
7357 __attribute__((unused)) struct cmdline *cl,
7358 __attribute__((unused)) void *data)
7360 struct cmd_showqueue_result *res = parsed_result;
7362 if (!strcmp(res->type, "rxq"))
7363 rx_queue_infos_display(res->portnum, res->queuenum);
7364 else if (!strcmp(res->type, "txq"))
7365 tx_queue_infos_display(res->portnum, res->queuenum);
7368 cmdline_parse_token_string_t cmd_showqueue_show =
7369 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7370 cmdline_parse_token_string_t cmd_showqueue_type =
7371 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7372 cmdline_parse_token_string_t cmd_showqueue_what =
7373 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7374 cmdline_parse_token_num_t cmd_showqueue_portnum =
7375 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7376 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7377 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7379 cmdline_parse_inst_t cmd_showqueue = {
7380 .f = cmd_showqueue_parsed,
7382 .help_str = "show rxq|txq info <port_id> <queue_id>",
7384 (void *)&cmd_showqueue_show,
7385 (void *)&cmd_showqueue_type,
7386 (void *)&cmd_showqueue_what,
7387 (void *)&cmd_showqueue_portnum,
7388 (void *)&cmd_showqueue_queuenum,
7393 /* show/clear fwd engine statistics */
7395 cmdline_fixed_string_t action;
7396 cmdline_fixed_string_t fwd;
7397 cmdline_fixed_string_t stats;
7398 cmdline_fixed_string_t all;
7401 cmdline_parse_token_string_t cmd_fwd_action =
7402 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7403 cmdline_parse_token_string_t cmd_fwd_fwd =
7404 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7405 cmdline_parse_token_string_t cmd_fwd_stats =
7406 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7407 cmdline_parse_token_string_t cmd_fwd_all =
7408 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7411 cmd_showfwdall_parsed(void *parsed_result,
7412 __rte_unused struct cmdline *cl,
7413 __rte_unused void *data)
7415 struct fwd_result *res = parsed_result;
7417 if (!strcmp(res->action, "show"))
7418 fwd_stats_display();
7423 static cmdline_parse_inst_t cmd_showfwdall = {
7424 .f = cmd_showfwdall_parsed,
7426 .help_str = "show|clear fwd stats all",
7428 (void *)&cmd_fwd_action,
7429 (void *)&cmd_fwd_fwd,
7430 (void *)&cmd_fwd_stats,
7431 (void *)&cmd_fwd_all,
7436 /* *** READ PORT REGISTER *** */
7437 struct cmd_read_reg_result {
7438 cmdline_fixed_string_t read;
7439 cmdline_fixed_string_t reg;
7445 cmd_read_reg_parsed(void *parsed_result,
7446 __attribute__((unused)) struct cmdline *cl,
7447 __attribute__((unused)) void *data)
7449 struct cmd_read_reg_result *res = parsed_result;
7450 port_reg_display(res->port_id, res->reg_off);
7453 cmdline_parse_token_string_t cmd_read_reg_read =
7454 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7455 cmdline_parse_token_string_t cmd_read_reg_reg =
7456 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7457 cmdline_parse_token_num_t cmd_read_reg_port_id =
7458 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7459 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7460 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7462 cmdline_parse_inst_t cmd_read_reg = {
7463 .f = cmd_read_reg_parsed,
7465 .help_str = "read reg <port_id> <reg_off>",
7467 (void *)&cmd_read_reg_read,
7468 (void *)&cmd_read_reg_reg,
7469 (void *)&cmd_read_reg_port_id,
7470 (void *)&cmd_read_reg_reg_off,
7475 /* *** READ PORT REGISTER BIT FIELD *** */
7476 struct cmd_read_reg_bit_field_result {
7477 cmdline_fixed_string_t read;
7478 cmdline_fixed_string_t regfield;
7486 cmd_read_reg_bit_field_parsed(void *parsed_result,
7487 __attribute__((unused)) struct cmdline *cl,
7488 __attribute__((unused)) void *data)
7490 struct cmd_read_reg_bit_field_result *res = parsed_result;
7491 port_reg_bit_field_display(res->port_id, res->reg_off,
7492 res->bit1_pos, res->bit2_pos);
7495 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7496 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7498 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7499 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7500 regfield, "regfield");
7501 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7502 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7504 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7505 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7507 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7508 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7510 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7511 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7514 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7515 .f = cmd_read_reg_bit_field_parsed,
7517 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7518 "Read register bit field between bit_x and bit_y included",
7520 (void *)&cmd_read_reg_bit_field_read,
7521 (void *)&cmd_read_reg_bit_field_regfield,
7522 (void *)&cmd_read_reg_bit_field_port_id,
7523 (void *)&cmd_read_reg_bit_field_reg_off,
7524 (void *)&cmd_read_reg_bit_field_bit1_pos,
7525 (void *)&cmd_read_reg_bit_field_bit2_pos,
7530 /* *** READ PORT REGISTER BIT *** */
7531 struct cmd_read_reg_bit_result {
7532 cmdline_fixed_string_t read;
7533 cmdline_fixed_string_t regbit;
7540 cmd_read_reg_bit_parsed(void *parsed_result,
7541 __attribute__((unused)) struct cmdline *cl,
7542 __attribute__((unused)) void *data)
7544 struct cmd_read_reg_bit_result *res = parsed_result;
7545 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7548 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7549 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7550 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7551 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7553 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7554 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7555 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7556 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7557 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7558 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7560 cmdline_parse_inst_t cmd_read_reg_bit = {
7561 .f = cmd_read_reg_bit_parsed,
7563 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7565 (void *)&cmd_read_reg_bit_read,
7566 (void *)&cmd_read_reg_bit_regbit,
7567 (void *)&cmd_read_reg_bit_port_id,
7568 (void *)&cmd_read_reg_bit_reg_off,
7569 (void *)&cmd_read_reg_bit_bit_pos,
7574 /* *** WRITE PORT REGISTER *** */
7575 struct cmd_write_reg_result {
7576 cmdline_fixed_string_t write;
7577 cmdline_fixed_string_t reg;
7584 cmd_write_reg_parsed(void *parsed_result,
7585 __attribute__((unused)) struct cmdline *cl,
7586 __attribute__((unused)) void *data)
7588 struct cmd_write_reg_result *res = parsed_result;
7589 port_reg_set(res->port_id, res->reg_off, res->value);
7592 cmdline_parse_token_string_t cmd_write_reg_write =
7593 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7594 cmdline_parse_token_string_t cmd_write_reg_reg =
7595 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7596 cmdline_parse_token_num_t cmd_write_reg_port_id =
7597 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7598 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7599 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7600 cmdline_parse_token_num_t cmd_write_reg_value =
7601 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7603 cmdline_parse_inst_t cmd_write_reg = {
7604 .f = cmd_write_reg_parsed,
7606 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7608 (void *)&cmd_write_reg_write,
7609 (void *)&cmd_write_reg_reg,
7610 (void *)&cmd_write_reg_port_id,
7611 (void *)&cmd_write_reg_reg_off,
7612 (void *)&cmd_write_reg_value,
7617 /* *** WRITE PORT REGISTER BIT FIELD *** */
7618 struct cmd_write_reg_bit_field_result {
7619 cmdline_fixed_string_t write;
7620 cmdline_fixed_string_t regfield;
7629 cmd_write_reg_bit_field_parsed(void *parsed_result,
7630 __attribute__((unused)) struct cmdline *cl,
7631 __attribute__((unused)) void *data)
7633 struct cmd_write_reg_bit_field_result *res = parsed_result;
7634 port_reg_bit_field_set(res->port_id, res->reg_off,
7635 res->bit1_pos, res->bit2_pos, res->value);
7638 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7639 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7641 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7642 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7643 regfield, "regfield");
7644 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7645 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7647 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7648 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7650 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7651 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7653 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7654 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7656 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7657 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7660 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7661 .f = cmd_write_reg_bit_field_parsed,
7663 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7665 "Set register bit field between bit_x and bit_y included",
7667 (void *)&cmd_write_reg_bit_field_write,
7668 (void *)&cmd_write_reg_bit_field_regfield,
7669 (void *)&cmd_write_reg_bit_field_port_id,
7670 (void *)&cmd_write_reg_bit_field_reg_off,
7671 (void *)&cmd_write_reg_bit_field_bit1_pos,
7672 (void *)&cmd_write_reg_bit_field_bit2_pos,
7673 (void *)&cmd_write_reg_bit_field_value,
7678 /* *** WRITE PORT REGISTER BIT *** */
7679 struct cmd_write_reg_bit_result {
7680 cmdline_fixed_string_t write;
7681 cmdline_fixed_string_t regbit;
7689 cmd_write_reg_bit_parsed(void *parsed_result,
7690 __attribute__((unused)) struct cmdline *cl,
7691 __attribute__((unused)) void *data)
7693 struct cmd_write_reg_bit_result *res = parsed_result;
7694 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7697 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7698 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7700 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7701 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7703 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7704 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7705 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7706 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7707 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7708 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7709 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7710 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7712 cmdline_parse_inst_t cmd_write_reg_bit = {
7713 .f = cmd_write_reg_bit_parsed,
7715 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7718 (void *)&cmd_write_reg_bit_write,
7719 (void *)&cmd_write_reg_bit_regbit,
7720 (void *)&cmd_write_reg_bit_port_id,
7721 (void *)&cmd_write_reg_bit_reg_off,
7722 (void *)&cmd_write_reg_bit_bit_pos,
7723 (void *)&cmd_write_reg_bit_value,
7728 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7729 struct cmd_read_rxd_txd_result {
7730 cmdline_fixed_string_t read;
7731 cmdline_fixed_string_t rxd_txd;
7738 cmd_read_rxd_txd_parsed(void *parsed_result,
7739 __attribute__((unused)) struct cmdline *cl,
7740 __attribute__((unused)) void *data)
7742 struct cmd_read_rxd_txd_result *res = parsed_result;
7744 if (!strcmp(res->rxd_txd, "rxd"))
7745 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7746 else if (!strcmp(res->rxd_txd, "txd"))
7747 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7750 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7751 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7752 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7753 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7755 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7756 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7757 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7758 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7759 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7760 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7762 cmdline_parse_inst_t cmd_read_rxd_txd = {
7763 .f = cmd_read_rxd_txd_parsed,
7765 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7767 (void *)&cmd_read_rxd_txd_read,
7768 (void *)&cmd_read_rxd_txd_rxd_txd,
7769 (void *)&cmd_read_rxd_txd_port_id,
7770 (void *)&cmd_read_rxd_txd_queue_id,
7771 (void *)&cmd_read_rxd_txd_desc_id,
7777 struct cmd_quit_result {
7778 cmdline_fixed_string_t quit;
7781 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7783 __attribute__((unused)) void *data)
7788 cmdline_parse_token_string_t cmd_quit_quit =
7789 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7791 cmdline_parse_inst_t cmd_quit = {
7792 .f = cmd_quit_parsed,
7794 .help_str = "quit: Exit application",
7796 (void *)&cmd_quit_quit,
7801 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7802 struct cmd_mac_addr_result {
7803 cmdline_fixed_string_t mac_addr_cmd;
7804 cmdline_fixed_string_t what;
7806 struct ether_addr address;
7809 static void cmd_mac_addr_parsed(void *parsed_result,
7810 __attribute__((unused)) struct cmdline *cl,
7811 __attribute__((unused)) void *data)
7813 struct cmd_mac_addr_result *res = parsed_result;
7816 if (strcmp(res->what, "add") == 0)
7817 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7818 else if (strcmp(res->what, "set") == 0)
7819 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7822 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7824 /* check the return value and print it if is < 0 */
7826 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7830 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7831 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7833 cmdline_parse_token_string_t cmd_mac_addr_what =
7834 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7836 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7837 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7839 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7840 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7842 cmdline_parse_inst_t cmd_mac_addr = {
7843 .f = cmd_mac_addr_parsed,
7845 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7846 "Add/Remove/Set MAC address on port_id",
7848 (void *)&cmd_mac_addr_cmd,
7849 (void *)&cmd_mac_addr_what,
7850 (void *)&cmd_mac_addr_portnum,
7851 (void *)&cmd_mac_addr_addr,
7856 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7857 struct cmd_eth_peer_result {
7858 cmdline_fixed_string_t set;
7859 cmdline_fixed_string_t eth_peer;
7861 cmdline_fixed_string_t peer_addr;
7864 static void cmd_set_eth_peer_parsed(void *parsed_result,
7865 __attribute__((unused)) struct cmdline *cl,
7866 __attribute__((unused)) void *data)
7868 struct cmd_eth_peer_result *res = parsed_result;
7870 if (test_done == 0) {
7871 printf("Please stop forwarding first\n");
7874 if (!strcmp(res->eth_peer, "eth-peer")) {
7875 set_fwd_eth_peer(res->port_id, res->peer_addr);
7879 cmdline_parse_token_string_t cmd_eth_peer_set =
7880 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7881 cmdline_parse_token_string_t cmd_eth_peer =
7882 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7883 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7884 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7885 cmdline_parse_token_string_t cmd_eth_peer_addr =
7886 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7888 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7889 .f = cmd_set_eth_peer_parsed,
7891 .help_str = "set eth-peer <port_id> <peer_mac>",
7893 (void *)&cmd_eth_peer_set,
7894 (void *)&cmd_eth_peer,
7895 (void *)&cmd_eth_peer_port_id,
7896 (void *)&cmd_eth_peer_addr,
7901 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7902 struct cmd_set_qmap_result {
7903 cmdline_fixed_string_t set;
7904 cmdline_fixed_string_t qmap;
7905 cmdline_fixed_string_t what;
7912 cmd_set_qmap_parsed(void *parsed_result,
7913 __attribute__((unused)) struct cmdline *cl,
7914 __attribute__((unused)) void *data)
7916 struct cmd_set_qmap_result *res = parsed_result;
7917 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7919 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7922 cmdline_parse_token_string_t cmd_setqmap_set =
7923 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7925 cmdline_parse_token_string_t cmd_setqmap_qmap =
7926 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7928 cmdline_parse_token_string_t cmd_setqmap_what =
7929 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7931 cmdline_parse_token_num_t cmd_setqmap_portid =
7932 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7934 cmdline_parse_token_num_t cmd_setqmap_queueid =
7935 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7937 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7938 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7941 cmdline_parse_inst_t cmd_set_qmap = {
7942 .f = cmd_set_qmap_parsed,
7944 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7945 "Set statistics mapping value on tx|rx queue_id of port_id",
7947 (void *)&cmd_setqmap_set,
7948 (void *)&cmd_setqmap_qmap,
7949 (void *)&cmd_setqmap_what,
7950 (void *)&cmd_setqmap_portid,
7951 (void *)&cmd_setqmap_queueid,
7952 (void *)&cmd_setqmap_mapvalue,
7957 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7958 struct cmd_set_xstats_hide_zero_result {
7959 cmdline_fixed_string_t keyword;
7960 cmdline_fixed_string_t name;
7961 cmdline_fixed_string_t on_off;
7965 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7966 __attribute__((unused)) struct cmdline *cl,
7967 __attribute__((unused)) void *data)
7969 struct cmd_set_xstats_hide_zero_result *res;
7970 uint16_t on_off = 0;
7972 res = parsed_result;
7973 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7974 set_xstats_hide_zero(on_off);
7977 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7978 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7980 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7981 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7982 name, "xstats-hide-zero");
7983 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7984 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7987 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7988 .f = cmd_set_xstats_hide_zero_parsed,
7990 .help_str = "set xstats-hide-zero on|off",
7992 (void *)&cmd_set_xstats_hide_zero_keyword,
7993 (void *)&cmd_set_xstats_hide_zero_name,
7994 (void *)&cmd_set_xstats_hide_zero_on_off,
7999 /* *** CONFIGURE UNICAST HASH TABLE *** */
8000 struct cmd_set_uc_hash_table {
8001 cmdline_fixed_string_t set;
8002 cmdline_fixed_string_t port;
8004 cmdline_fixed_string_t what;
8005 struct ether_addr address;
8006 cmdline_fixed_string_t mode;
8010 cmd_set_uc_hash_parsed(void *parsed_result,
8011 __attribute__((unused)) struct cmdline *cl,
8012 __attribute__((unused)) void *data)
8015 struct cmd_set_uc_hash_table *res = parsed_result;
8017 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8019 if (strcmp(res->what, "uta") == 0)
8020 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8021 &res->address,(uint8_t)is_on);
8023 printf("bad unicast hash table parameter, return code = %d \n", ret);
8027 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8028 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8030 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8031 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8033 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8034 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8036 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8037 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8039 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8040 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8042 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8043 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8046 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8047 .f = cmd_set_uc_hash_parsed,
8049 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8051 (void *)&cmd_set_uc_hash_set,
8052 (void *)&cmd_set_uc_hash_port,
8053 (void *)&cmd_set_uc_hash_portid,
8054 (void *)&cmd_set_uc_hash_what,
8055 (void *)&cmd_set_uc_hash_mac,
8056 (void *)&cmd_set_uc_hash_mode,
8061 struct cmd_set_uc_all_hash_table {
8062 cmdline_fixed_string_t set;
8063 cmdline_fixed_string_t port;
8065 cmdline_fixed_string_t what;
8066 cmdline_fixed_string_t value;
8067 cmdline_fixed_string_t mode;
8071 cmd_set_uc_all_hash_parsed(void *parsed_result,
8072 __attribute__((unused)) struct cmdline *cl,
8073 __attribute__((unused)) void *data)
8076 struct cmd_set_uc_all_hash_table *res = parsed_result;
8078 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8080 if ((strcmp(res->what, "uta") == 0) &&
8081 (strcmp(res->value, "all") == 0))
8082 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8084 printf("bad unicast hash table parameter,"
8085 "return code = %d \n", ret);
8088 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8089 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8091 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8092 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8094 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8095 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8097 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8098 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8100 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8101 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8103 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8104 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8107 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8108 .f = cmd_set_uc_all_hash_parsed,
8110 .help_str = "set port <port_id> uta all on|off",
8112 (void *)&cmd_set_uc_all_hash_set,
8113 (void *)&cmd_set_uc_all_hash_port,
8114 (void *)&cmd_set_uc_all_hash_portid,
8115 (void *)&cmd_set_uc_all_hash_what,
8116 (void *)&cmd_set_uc_all_hash_value,
8117 (void *)&cmd_set_uc_all_hash_mode,
8122 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8123 struct cmd_set_vf_macvlan_filter {
8124 cmdline_fixed_string_t set;
8125 cmdline_fixed_string_t port;
8127 cmdline_fixed_string_t vf;
8129 struct ether_addr address;
8130 cmdline_fixed_string_t filter_type;
8131 cmdline_fixed_string_t mode;
8135 cmd_set_vf_macvlan_parsed(void *parsed_result,
8136 __attribute__((unused)) struct cmdline *cl,
8137 __attribute__((unused)) void *data)
8140 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8141 struct rte_eth_mac_filter filter;
8143 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8145 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
8147 /* set VF MAC filter */
8151 filter.dst_id = res->vf_id;
8153 if (!strcmp(res->filter_type, "exact-mac"))
8154 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8155 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8156 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8157 else if (!strcmp(res->filter_type, "hashmac"))
8158 filter.filter_type = RTE_MAC_HASH_MATCH;
8159 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8160 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8162 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8165 ret = rte_eth_dev_filter_ctrl(res->port_id,
8166 RTE_ETH_FILTER_MACVLAN,
8170 ret = rte_eth_dev_filter_ctrl(res->port_id,
8171 RTE_ETH_FILTER_MACVLAN,
8172 RTE_ETH_FILTER_DELETE,
8176 printf("bad set MAC hash parameter, return code = %d\n", ret);
8180 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8181 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8183 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8184 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8186 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8187 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8189 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8190 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8192 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8193 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8195 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8196 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8198 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8199 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8200 filter_type, "exact-mac#exact-mac-vlan"
8201 "#hashmac#hashmac-vlan");
8202 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8203 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8206 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8207 .f = cmd_set_vf_macvlan_parsed,
8209 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8210 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8211 "Exact match rule: exact match of MAC or MAC and VLAN; "
8212 "hash match rule: hash match of MAC and exact match of VLAN",
8214 (void *)&cmd_set_vf_macvlan_set,
8215 (void *)&cmd_set_vf_macvlan_port,
8216 (void *)&cmd_set_vf_macvlan_portid,
8217 (void *)&cmd_set_vf_macvlan_vf,
8218 (void *)&cmd_set_vf_macvlan_vf_id,
8219 (void *)&cmd_set_vf_macvlan_mac,
8220 (void *)&cmd_set_vf_macvlan_filter_type,
8221 (void *)&cmd_set_vf_macvlan_mode,
8226 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8227 struct cmd_set_vf_traffic {
8228 cmdline_fixed_string_t set;
8229 cmdline_fixed_string_t port;
8231 cmdline_fixed_string_t vf;
8233 cmdline_fixed_string_t what;
8234 cmdline_fixed_string_t mode;
8238 cmd_set_vf_traffic_parsed(void *parsed_result,
8239 __attribute__((unused)) struct cmdline *cl,
8240 __attribute__((unused)) void *data)
8242 struct cmd_set_vf_traffic *res = parsed_result;
8243 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8244 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8246 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8249 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8250 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8252 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8253 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8255 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8256 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8258 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8259 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8261 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8262 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8264 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8265 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8267 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8268 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8271 cmdline_parse_inst_t cmd_set_vf_traffic = {
8272 .f = cmd_set_vf_traffic_parsed,
8274 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8276 (void *)&cmd_setvf_traffic_set,
8277 (void *)&cmd_setvf_traffic_port,
8278 (void *)&cmd_setvf_traffic_portid,
8279 (void *)&cmd_setvf_traffic_vf,
8280 (void *)&cmd_setvf_traffic_vfid,
8281 (void *)&cmd_setvf_traffic_what,
8282 (void *)&cmd_setvf_traffic_mode,
8287 /* *** CONFIGURE VF RECEIVE MODE *** */
8288 struct cmd_set_vf_rxmode {
8289 cmdline_fixed_string_t set;
8290 cmdline_fixed_string_t port;
8292 cmdline_fixed_string_t vf;
8294 cmdline_fixed_string_t what;
8295 cmdline_fixed_string_t mode;
8296 cmdline_fixed_string_t on;
8300 cmd_set_vf_rxmode_parsed(void *parsed_result,
8301 __attribute__((unused)) struct cmdline *cl,
8302 __attribute__((unused)) void *data)
8305 uint16_t rx_mode = 0;
8306 struct cmd_set_vf_rxmode *res = parsed_result;
8308 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8309 if (!strcmp(res->what,"rxmode")) {
8310 if (!strcmp(res->mode, "AUPE"))
8311 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8312 else if (!strcmp(res->mode, "ROPE"))
8313 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8314 else if (!strcmp(res->mode, "BAM"))
8315 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8316 else if (!strncmp(res->mode, "MPE",3))
8317 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8320 RTE_SET_USED(is_on);
8322 #ifdef RTE_LIBRTE_IXGBE_PMD
8323 if (ret == -ENOTSUP)
8324 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8325 rx_mode, (uint8_t)is_on);
8327 #ifdef RTE_LIBRTE_BNXT_PMD
8328 if (ret == -ENOTSUP)
8329 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8330 rx_mode, (uint8_t)is_on);
8333 printf("bad VF receive mode parameter, return code = %d \n",
8337 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8338 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8340 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8341 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8343 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8344 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8346 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8347 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8349 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8350 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8352 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8353 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8355 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8356 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8357 mode, "AUPE#ROPE#BAM#MPE");
8358 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8359 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8362 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8363 .f = cmd_set_vf_rxmode_parsed,
8365 .help_str = "set port <port_id> vf <vf_id> rxmode "
8366 "AUPE|ROPE|BAM|MPE on|off",
8368 (void *)&cmd_set_vf_rxmode_set,
8369 (void *)&cmd_set_vf_rxmode_port,
8370 (void *)&cmd_set_vf_rxmode_portid,
8371 (void *)&cmd_set_vf_rxmode_vf,
8372 (void *)&cmd_set_vf_rxmode_vfid,
8373 (void *)&cmd_set_vf_rxmode_what,
8374 (void *)&cmd_set_vf_rxmode_mode,
8375 (void *)&cmd_set_vf_rxmode_on,
8380 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8381 struct cmd_vf_mac_addr_result {
8382 cmdline_fixed_string_t mac_addr_cmd;
8383 cmdline_fixed_string_t what;
8384 cmdline_fixed_string_t port;
8386 cmdline_fixed_string_t vf;
8388 struct ether_addr address;
8391 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8392 __attribute__((unused)) struct cmdline *cl,
8393 __attribute__((unused)) void *data)
8395 struct cmd_vf_mac_addr_result *res = parsed_result;
8398 if (strcmp(res->what, "add") != 0)
8401 #ifdef RTE_LIBRTE_I40E_PMD
8402 if (ret == -ENOTSUP)
8403 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8406 #ifdef RTE_LIBRTE_BNXT_PMD
8407 if (ret == -ENOTSUP)
8408 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8413 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8417 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8418 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8419 mac_addr_cmd,"mac_addr");
8420 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8421 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8423 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8424 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8426 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8427 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8429 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8430 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8432 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8433 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8435 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8436 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8439 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8440 .f = cmd_vf_mac_addr_parsed,
8442 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8443 "Add MAC address filtering for a VF on port_id",
8445 (void *)&cmd_vf_mac_addr_cmd,
8446 (void *)&cmd_vf_mac_addr_what,
8447 (void *)&cmd_vf_mac_addr_port,
8448 (void *)&cmd_vf_mac_addr_portnum,
8449 (void *)&cmd_vf_mac_addr_vf,
8450 (void *)&cmd_vf_mac_addr_vfnum,
8451 (void *)&cmd_vf_mac_addr_addr,
8456 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8457 struct cmd_vf_rx_vlan_filter {
8458 cmdline_fixed_string_t rx_vlan;
8459 cmdline_fixed_string_t what;
8461 cmdline_fixed_string_t port;
8463 cmdline_fixed_string_t vf;
8468 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8469 __attribute__((unused)) struct cmdline *cl,
8470 __attribute__((unused)) void *data)
8472 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8475 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8477 #ifdef RTE_LIBRTE_IXGBE_PMD
8478 if (ret == -ENOTSUP)
8479 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8480 res->vlan_id, res->vf_mask, is_add);
8482 #ifdef RTE_LIBRTE_I40E_PMD
8483 if (ret == -ENOTSUP)
8484 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8485 res->vlan_id, res->vf_mask, is_add);
8487 #ifdef RTE_LIBRTE_BNXT_PMD
8488 if (ret == -ENOTSUP)
8489 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8490 res->vlan_id, res->vf_mask, is_add);
8497 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8498 res->vlan_id, res->vf_mask);
8501 printf("invalid port_id %d\n", res->port_id);
8504 printf("function not implemented or supported\n");
8507 printf("programming error: (%s)\n", strerror(-ret));
8511 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8512 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8513 rx_vlan, "rx_vlan");
8514 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8515 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8517 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8518 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8520 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8521 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8523 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8524 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8526 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8527 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8529 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8530 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8533 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8534 .f = cmd_vf_rx_vlan_filter_parsed,
8536 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8537 "(vf_mask = hexadecimal VF mask)",
8539 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8540 (void *)&cmd_vf_rx_vlan_filter_what,
8541 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8542 (void *)&cmd_vf_rx_vlan_filter_port,
8543 (void *)&cmd_vf_rx_vlan_filter_portid,
8544 (void *)&cmd_vf_rx_vlan_filter_vf,
8545 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8550 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8551 struct cmd_queue_rate_limit_result {
8552 cmdline_fixed_string_t set;
8553 cmdline_fixed_string_t port;
8555 cmdline_fixed_string_t queue;
8557 cmdline_fixed_string_t rate;
8561 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8562 __attribute__((unused)) struct cmdline *cl,
8563 __attribute__((unused)) void *data)
8565 struct cmd_queue_rate_limit_result *res = parsed_result;
8568 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8569 && (strcmp(res->queue, "queue") == 0)
8570 && (strcmp(res->rate, "rate") == 0))
8571 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8574 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8578 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8579 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8581 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8582 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8584 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8585 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8587 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8588 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8590 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8591 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8593 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8594 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8596 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8597 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8600 cmdline_parse_inst_t cmd_queue_rate_limit = {
8601 .f = cmd_queue_rate_limit_parsed,
8603 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8604 "Set rate limit for a queue on port_id",
8606 (void *)&cmd_queue_rate_limit_set,
8607 (void *)&cmd_queue_rate_limit_port,
8608 (void *)&cmd_queue_rate_limit_portnum,
8609 (void *)&cmd_queue_rate_limit_queue,
8610 (void *)&cmd_queue_rate_limit_queuenum,
8611 (void *)&cmd_queue_rate_limit_rate,
8612 (void *)&cmd_queue_rate_limit_ratenum,
8617 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8618 struct cmd_vf_rate_limit_result {
8619 cmdline_fixed_string_t set;
8620 cmdline_fixed_string_t port;
8622 cmdline_fixed_string_t vf;
8624 cmdline_fixed_string_t rate;
8626 cmdline_fixed_string_t q_msk;
8630 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8631 __attribute__((unused)) struct cmdline *cl,
8632 __attribute__((unused)) void *data)
8634 struct cmd_vf_rate_limit_result *res = parsed_result;
8637 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8638 && (strcmp(res->vf, "vf") == 0)
8639 && (strcmp(res->rate, "rate") == 0)
8640 && (strcmp(res->q_msk, "queue_mask") == 0))
8641 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8642 res->rate_num, res->q_msk_val);
8644 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8648 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8649 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8651 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8652 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8654 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8655 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8657 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8658 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8660 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8661 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8663 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8664 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8666 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8667 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8669 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8670 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8671 q_msk, "queue_mask");
8672 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8673 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8676 cmdline_parse_inst_t cmd_vf_rate_limit = {
8677 .f = cmd_vf_rate_limit_parsed,
8679 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8680 "queue_mask <queue_mask_value>: "
8681 "Set rate limit for queues of VF on port_id",
8683 (void *)&cmd_vf_rate_limit_set,
8684 (void *)&cmd_vf_rate_limit_port,
8685 (void *)&cmd_vf_rate_limit_portnum,
8686 (void *)&cmd_vf_rate_limit_vf,
8687 (void *)&cmd_vf_rate_limit_vfnum,
8688 (void *)&cmd_vf_rate_limit_rate,
8689 (void *)&cmd_vf_rate_limit_ratenum,
8690 (void *)&cmd_vf_rate_limit_q_msk,
8691 (void *)&cmd_vf_rate_limit_q_msk_val,
8696 /* *** ADD TUNNEL FILTER OF A PORT *** */
8697 struct cmd_tunnel_filter_result {
8698 cmdline_fixed_string_t cmd;
8699 cmdline_fixed_string_t what;
8701 struct ether_addr outer_mac;
8702 struct ether_addr inner_mac;
8703 cmdline_ipaddr_t ip_value;
8704 uint16_t inner_vlan;
8705 cmdline_fixed_string_t tunnel_type;
8706 cmdline_fixed_string_t filter_type;
8712 cmd_tunnel_filter_parsed(void *parsed_result,
8713 __attribute__((unused)) struct cmdline *cl,
8714 __attribute__((unused)) void *data)
8716 struct cmd_tunnel_filter_result *res = parsed_result;
8717 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8720 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8722 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8723 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8724 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8726 if (res->ip_value.family == AF_INET) {
8727 tunnel_filter_conf.ip_addr.ipv4_addr =
8728 res->ip_value.addr.ipv4.s_addr;
8729 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8731 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8732 &(res->ip_value.addr.ipv6),
8733 sizeof(struct in6_addr));
8734 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8737 if (!strcmp(res->filter_type, "imac-ivlan"))
8738 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8739 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8740 tunnel_filter_conf.filter_type =
8741 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8742 else if (!strcmp(res->filter_type, "imac-tenid"))
8743 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8744 else if (!strcmp(res->filter_type, "imac"))
8745 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8746 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8747 tunnel_filter_conf.filter_type =
8748 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8749 else if (!strcmp(res->filter_type, "oip"))
8750 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8751 else if (!strcmp(res->filter_type, "iip"))
8752 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8754 printf("The filter type is not supported");
8758 if (!strcmp(res->tunnel_type, "vxlan"))
8759 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8760 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8761 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8762 else if (!strcmp(res->tunnel_type, "nvgre"))
8763 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8764 else if (!strcmp(res->tunnel_type, "ipingre"))
8765 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8767 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8771 tunnel_filter_conf.tenant_id = res->tenant_id;
8772 tunnel_filter_conf.queue_id = res->queue_num;
8773 if (!strcmp(res->what, "add"))
8774 ret = rte_eth_dev_filter_ctrl(res->port_id,
8775 RTE_ETH_FILTER_TUNNEL,
8777 &tunnel_filter_conf);
8779 ret = rte_eth_dev_filter_ctrl(res->port_id,
8780 RTE_ETH_FILTER_TUNNEL,
8781 RTE_ETH_FILTER_DELETE,
8782 &tunnel_filter_conf);
8784 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8788 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8789 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8790 cmd, "tunnel_filter");
8791 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8792 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8794 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8795 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8797 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8798 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8800 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8801 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8803 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8804 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8805 inner_vlan, UINT16);
8806 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8807 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8809 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8810 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8811 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8813 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8814 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8815 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8816 "imac#omac-imac-tenid");
8817 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8818 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8820 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8821 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8824 cmdline_parse_inst_t cmd_tunnel_filter = {
8825 .f = cmd_tunnel_filter_parsed,
8827 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8828 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8829 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8830 "<queue_id>: Add/Rm tunnel filter of a port",
8832 (void *)&cmd_tunnel_filter_cmd,
8833 (void *)&cmd_tunnel_filter_what,
8834 (void *)&cmd_tunnel_filter_port_id,
8835 (void *)&cmd_tunnel_filter_outer_mac,
8836 (void *)&cmd_tunnel_filter_inner_mac,
8837 (void *)&cmd_tunnel_filter_ip_value,
8838 (void *)&cmd_tunnel_filter_innner_vlan,
8839 (void *)&cmd_tunnel_filter_tunnel_type,
8840 (void *)&cmd_tunnel_filter_filter_type,
8841 (void *)&cmd_tunnel_filter_tenant_id,
8842 (void *)&cmd_tunnel_filter_queue_num,
8847 /* *** CONFIGURE TUNNEL UDP PORT *** */
8848 struct cmd_tunnel_udp_config {
8849 cmdline_fixed_string_t cmd;
8850 cmdline_fixed_string_t what;
8856 cmd_tunnel_udp_config_parsed(void *parsed_result,
8857 __attribute__((unused)) struct cmdline *cl,
8858 __attribute__((unused)) void *data)
8860 struct cmd_tunnel_udp_config *res = parsed_result;
8861 struct rte_eth_udp_tunnel tunnel_udp;
8864 tunnel_udp.udp_port = res->udp_port;
8866 if (!strcmp(res->cmd, "rx_vxlan_port"))
8867 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8869 if (!strcmp(res->what, "add"))
8870 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8873 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8877 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8880 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8881 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8882 cmd, "rx_vxlan_port");
8883 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8884 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8886 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8887 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8889 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8890 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8893 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8894 .f = cmd_tunnel_udp_config_parsed,
8896 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8897 "Add/Remove a tunneling UDP port filter",
8899 (void *)&cmd_tunnel_udp_config_cmd,
8900 (void *)&cmd_tunnel_udp_config_what,
8901 (void *)&cmd_tunnel_udp_config_udp_port,
8902 (void *)&cmd_tunnel_udp_config_port_id,
8907 struct cmd_config_tunnel_udp_port {
8908 cmdline_fixed_string_t port;
8909 cmdline_fixed_string_t config;
8911 cmdline_fixed_string_t udp_tunnel_port;
8912 cmdline_fixed_string_t action;
8913 cmdline_fixed_string_t tunnel_type;
8918 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8919 __attribute__((unused)) struct cmdline *cl,
8920 __attribute__((unused)) void *data)
8922 struct cmd_config_tunnel_udp_port *res = parsed_result;
8923 struct rte_eth_udp_tunnel tunnel_udp;
8926 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8929 tunnel_udp.udp_port = res->udp_port;
8931 if (!strcmp(res->tunnel_type, "vxlan")) {
8932 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8933 } else if (!strcmp(res->tunnel_type, "geneve")) {
8934 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8935 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
8936 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8938 printf("Invalid tunnel type\n");
8942 if (!strcmp(res->action, "add"))
8943 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8946 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8950 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8953 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8954 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8956 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8957 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8959 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8960 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8962 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8963 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8966 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8967 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8969 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8970 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8971 "vxlan#geneve#vxlan-gpe");
8972 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8973 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8976 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8977 .f = cmd_cfg_tunnel_udp_port_parsed,
8979 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
8981 (void *)&cmd_config_tunnel_udp_port_port,
8982 (void *)&cmd_config_tunnel_udp_port_config,
8983 (void *)&cmd_config_tunnel_udp_port_port_id,
8984 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8985 (void *)&cmd_config_tunnel_udp_port_action,
8986 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8987 (void *)&cmd_config_tunnel_udp_port_value,
8992 /* *** GLOBAL CONFIG *** */
8993 struct cmd_global_config_result {
8994 cmdline_fixed_string_t cmd;
8996 cmdline_fixed_string_t cfg_type;
9001 cmd_global_config_parsed(void *parsed_result,
9002 __attribute__((unused)) struct cmdline *cl,
9003 __attribute__((unused)) void *data)
9005 struct cmd_global_config_result *res = parsed_result;
9006 struct rte_eth_global_cfg conf;
9009 memset(&conf, 0, sizeof(conf));
9010 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9011 conf.cfg.gre_key_len = res->len;
9012 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9013 RTE_ETH_FILTER_SET, &conf);
9015 printf("Global config error\n");
9018 cmdline_parse_token_string_t cmd_global_config_cmd =
9019 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9021 cmdline_parse_token_num_t cmd_global_config_port_id =
9022 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9024 cmdline_parse_token_string_t cmd_global_config_type =
9025 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9026 cfg_type, "gre-key-len");
9027 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9028 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9031 cmdline_parse_inst_t cmd_global_config = {
9032 .f = cmd_global_config_parsed,
9033 .data = (void *)NULL,
9034 .help_str = "global_config <port_id> gre-key-len <key_len>",
9036 (void *)&cmd_global_config_cmd,
9037 (void *)&cmd_global_config_port_id,
9038 (void *)&cmd_global_config_type,
9039 (void *)&cmd_global_config_gre_key_len,
9044 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9045 struct cmd_set_mirror_mask_result {
9046 cmdline_fixed_string_t set;
9047 cmdline_fixed_string_t port;
9049 cmdline_fixed_string_t mirror;
9051 cmdline_fixed_string_t what;
9052 cmdline_fixed_string_t value;
9053 cmdline_fixed_string_t dstpool;
9055 cmdline_fixed_string_t on;
9058 cmdline_parse_token_string_t cmd_mirror_mask_set =
9059 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9061 cmdline_parse_token_string_t cmd_mirror_mask_port =
9062 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9064 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9065 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9067 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9068 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9069 mirror, "mirror-rule");
9070 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9071 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9073 cmdline_parse_token_string_t cmd_mirror_mask_what =
9074 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9075 what, "pool-mirror-up#pool-mirror-down"
9077 cmdline_parse_token_string_t cmd_mirror_mask_value =
9078 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9080 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9081 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9082 dstpool, "dst-pool");
9083 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9084 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9086 cmdline_parse_token_string_t cmd_mirror_mask_on =
9087 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9091 cmd_set_mirror_mask_parsed(void *parsed_result,
9092 __attribute__((unused)) struct cmdline *cl,
9093 __attribute__((unused)) void *data)
9096 struct cmd_set_mirror_mask_result *res = parsed_result;
9097 struct rte_eth_mirror_conf mr_conf;
9099 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9101 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9103 mr_conf.dst_pool = res->dstpool_id;
9105 if (!strcmp(res->what, "pool-mirror-up")) {
9106 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9107 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9108 } else if (!strcmp(res->what, "pool-mirror-down")) {
9109 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9110 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9111 } else if (!strcmp(res->what, "vlan-mirror")) {
9112 mr_conf.rule_type = ETH_MIRROR_VLAN;
9113 nb_item = parse_item_list(res->value, "vlan",
9114 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9118 for (i = 0; i < nb_item; i++) {
9119 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
9120 printf("Invalid vlan_id: must be < 4096\n");
9124 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9125 mr_conf.vlan.vlan_mask |= 1ULL << i;
9129 if (!strcmp(res->on, "on"))
9130 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9133 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9136 printf("mirror rule add error: (%s)\n", strerror(-ret));
9139 cmdline_parse_inst_t cmd_set_mirror_mask = {
9140 .f = cmd_set_mirror_mask_parsed,
9142 .help_str = "set port <port_id> mirror-rule <rule_id> "
9143 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9144 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9146 (void *)&cmd_mirror_mask_set,
9147 (void *)&cmd_mirror_mask_port,
9148 (void *)&cmd_mirror_mask_portid,
9149 (void *)&cmd_mirror_mask_mirror,
9150 (void *)&cmd_mirror_mask_ruleid,
9151 (void *)&cmd_mirror_mask_what,
9152 (void *)&cmd_mirror_mask_value,
9153 (void *)&cmd_mirror_mask_dstpool,
9154 (void *)&cmd_mirror_mask_poolid,
9155 (void *)&cmd_mirror_mask_on,
9160 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9161 struct cmd_set_mirror_link_result {
9162 cmdline_fixed_string_t set;
9163 cmdline_fixed_string_t port;
9165 cmdline_fixed_string_t mirror;
9167 cmdline_fixed_string_t what;
9168 cmdline_fixed_string_t dstpool;
9170 cmdline_fixed_string_t on;
9173 cmdline_parse_token_string_t cmd_mirror_link_set =
9174 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9176 cmdline_parse_token_string_t cmd_mirror_link_port =
9177 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9179 cmdline_parse_token_num_t cmd_mirror_link_portid =
9180 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9182 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9183 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9184 mirror, "mirror-rule");
9185 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9186 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9188 cmdline_parse_token_string_t cmd_mirror_link_what =
9189 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9190 what, "uplink-mirror#downlink-mirror");
9191 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9192 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9193 dstpool, "dst-pool");
9194 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9195 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9197 cmdline_parse_token_string_t cmd_mirror_link_on =
9198 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9202 cmd_set_mirror_link_parsed(void *parsed_result,
9203 __attribute__((unused)) struct cmdline *cl,
9204 __attribute__((unused)) void *data)
9207 struct cmd_set_mirror_link_result *res = parsed_result;
9208 struct rte_eth_mirror_conf mr_conf;
9210 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9211 if (!strcmp(res->what, "uplink-mirror"))
9212 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9214 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9216 mr_conf.dst_pool = res->dstpool_id;
9218 if (!strcmp(res->on, "on"))
9219 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9222 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9225 /* check the return value and print it if is < 0 */
9227 printf("mirror rule add error: (%s)\n", strerror(-ret));
9231 cmdline_parse_inst_t cmd_set_mirror_link = {
9232 .f = cmd_set_mirror_link_parsed,
9234 .help_str = "set port <port_id> mirror-rule <rule_id> "
9235 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9237 (void *)&cmd_mirror_link_set,
9238 (void *)&cmd_mirror_link_port,
9239 (void *)&cmd_mirror_link_portid,
9240 (void *)&cmd_mirror_link_mirror,
9241 (void *)&cmd_mirror_link_ruleid,
9242 (void *)&cmd_mirror_link_what,
9243 (void *)&cmd_mirror_link_dstpool,
9244 (void *)&cmd_mirror_link_poolid,
9245 (void *)&cmd_mirror_link_on,
9250 /* *** RESET VM MIRROR RULE *** */
9251 struct cmd_rm_mirror_rule_result {
9252 cmdline_fixed_string_t reset;
9253 cmdline_fixed_string_t port;
9255 cmdline_fixed_string_t mirror;
9259 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9260 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9262 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9263 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9265 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9266 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9268 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9269 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9270 mirror, "mirror-rule");
9271 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9272 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9276 cmd_reset_mirror_rule_parsed(void *parsed_result,
9277 __attribute__((unused)) struct cmdline *cl,
9278 __attribute__((unused)) void *data)
9281 struct cmd_set_mirror_link_result *res = parsed_result;
9283 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9285 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9288 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9289 .f = cmd_reset_mirror_rule_parsed,
9291 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9293 (void *)&cmd_rm_mirror_rule_reset,
9294 (void *)&cmd_rm_mirror_rule_port,
9295 (void *)&cmd_rm_mirror_rule_portid,
9296 (void *)&cmd_rm_mirror_rule_mirror,
9297 (void *)&cmd_rm_mirror_rule_ruleid,
9302 /* ******************************************************************************** */
9304 struct cmd_dump_result {
9305 cmdline_fixed_string_t dump;
9309 dump_struct_sizes(void)
9311 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9312 DUMP_SIZE(struct rte_mbuf);
9313 DUMP_SIZE(struct rte_mempool);
9314 DUMP_SIZE(struct rte_ring);
9318 static void cmd_dump_parsed(void *parsed_result,
9319 __attribute__((unused)) struct cmdline *cl,
9320 __attribute__((unused)) void *data)
9322 struct cmd_dump_result *res = parsed_result;
9324 if (!strcmp(res->dump, "dump_physmem"))
9325 rte_dump_physmem_layout(stdout);
9326 else if (!strcmp(res->dump, "dump_memzone"))
9327 rte_memzone_dump(stdout);
9328 else if (!strcmp(res->dump, "dump_struct_sizes"))
9329 dump_struct_sizes();
9330 else if (!strcmp(res->dump, "dump_ring"))
9331 rte_ring_list_dump(stdout);
9332 else if (!strcmp(res->dump, "dump_mempool"))
9333 rte_mempool_list_dump(stdout);
9334 else if (!strcmp(res->dump, "dump_devargs"))
9335 rte_devargs_dump(stdout);
9336 else if (!strcmp(res->dump, "dump_log_types"))
9337 rte_log_dump(stdout);
9340 cmdline_parse_token_string_t cmd_dump_dump =
9341 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9344 "dump_struct_sizes#"
9350 cmdline_parse_inst_t cmd_dump = {
9351 .f = cmd_dump_parsed, /* function to call */
9352 .data = NULL, /* 2nd arg of func */
9353 .help_str = "Dump status",
9354 .tokens = { /* token list, NULL terminated */
9355 (void *)&cmd_dump_dump,
9360 /* ******************************************************************************** */
9362 struct cmd_dump_one_result {
9363 cmdline_fixed_string_t dump;
9364 cmdline_fixed_string_t name;
9367 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9368 __attribute__((unused)) void *data)
9370 struct cmd_dump_one_result *res = parsed_result;
9372 if (!strcmp(res->dump, "dump_ring")) {
9374 r = rte_ring_lookup(res->name);
9376 cmdline_printf(cl, "Cannot find ring\n");
9379 rte_ring_dump(stdout, r);
9380 } else if (!strcmp(res->dump, "dump_mempool")) {
9381 struct rte_mempool *mp;
9382 mp = rte_mempool_lookup(res->name);
9384 cmdline_printf(cl, "Cannot find mempool\n");
9387 rte_mempool_dump(stdout, mp);
9391 cmdline_parse_token_string_t cmd_dump_one_dump =
9392 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9393 "dump_ring#dump_mempool");
9395 cmdline_parse_token_string_t cmd_dump_one_name =
9396 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9398 cmdline_parse_inst_t cmd_dump_one = {
9399 .f = cmd_dump_one_parsed, /* function to call */
9400 .data = NULL, /* 2nd arg of func */
9401 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9402 .tokens = { /* token list, NULL terminated */
9403 (void *)&cmd_dump_one_dump,
9404 (void *)&cmd_dump_one_name,
9409 /* *** Add/Del syn filter *** */
9410 struct cmd_syn_filter_result {
9411 cmdline_fixed_string_t filter;
9413 cmdline_fixed_string_t ops;
9414 cmdline_fixed_string_t priority;
9415 cmdline_fixed_string_t high;
9416 cmdline_fixed_string_t queue;
9421 cmd_syn_filter_parsed(void *parsed_result,
9422 __attribute__((unused)) struct cmdline *cl,
9423 __attribute__((unused)) void *data)
9425 struct cmd_syn_filter_result *res = parsed_result;
9426 struct rte_eth_syn_filter syn_filter;
9429 ret = rte_eth_dev_filter_supported(res->port_id,
9430 RTE_ETH_FILTER_SYN);
9432 printf("syn filter is not supported on port %u.\n",
9437 memset(&syn_filter, 0, sizeof(syn_filter));
9439 if (!strcmp(res->ops, "add")) {
9440 if (!strcmp(res->high, "high"))
9441 syn_filter.hig_pri = 1;
9443 syn_filter.hig_pri = 0;
9445 syn_filter.queue = res->queue_id;
9446 ret = rte_eth_dev_filter_ctrl(res->port_id,
9451 ret = rte_eth_dev_filter_ctrl(res->port_id,
9453 RTE_ETH_FILTER_DELETE,
9457 printf("syn filter programming error: (%s)\n",
9461 cmdline_parse_token_string_t cmd_syn_filter_filter =
9462 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9463 filter, "syn_filter");
9464 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9465 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9467 cmdline_parse_token_string_t cmd_syn_filter_ops =
9468 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9470 cmdline_parse_token_string_t cmd_syn_filter_priority =
9471 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9472 priority, "priority");
9473 cmdline_parse_token_string_t cmd_syn_filter_high =
9474 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9476 cmdline_parse_token_string_t cmd_syn_filter_queue =
9477 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9479 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9480 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9483 cmdline_parse_inst_t cmd_syn_filter = {
9484 .f = cmd_syn_filter_parsed,
9486 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9487 "<queue_id>: Add/Delete syn filter",
9489 (void *)&cmd_syn_filter_filter,
9490 (void *)&cmd_syn_filter_port_id,
9491 (void *)&cmd_syn_filter_ops,
9492 (void *)&cmd_syn_filter_priority,
9493 (void *)&cmd_syn_filter_high,
9494 (void *)&cmd_syn_filter_queue,
9495 (void *)&cmd_syn_filter_queue_id,
9500 /* *** queue region set *** */
9501 struct cmd_queue_region_result {
9502 cmdline_fixed_string_t set;
9503 cmdline_fixed_string_t port;
9505 cmdline_fixed_string_t cmd;
9506 cmdline_fixed_string_t region;
9508 cmdline_fixed_string_t queue_start_index;
9510 cmdline_fixed_string_t queue_num;
9511 uint8_t queue_num_value;
9515 cmd_queue_region_parsed(void *parsed_result,
9516 __attribute__((unused)) struct cmdline *cl,
9517 __attribute__((unused)) void *data)
9519 struct cmd_queue_region_result *res = parsed_result;
9521 #ifdef RTE_LIBRTE_I40E_PMD
9522 struct rte_pmd_i40e_queue_region_conf region_conf;
9523 enum rte_pmd_i40e_queue_region_op op_type;
9526 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9529 #ifdef RTE_LIBRTE_I40E_PMD
9530 memset(®ion_conf, 0, sizeof(region_conf));
9531 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9532 region_conf.region_id = res->region_id;
9533 region_conf.queue_num = res->queue_num_value;
9534 region_conf.queue_start_index = res->queue_id;
9536 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9537 op_type, ®ion_conf);
9544 printf("function not implemented or supported\n");
9547 printf("queue region config error: (%s)\n", strerror(-ret));
9551 cmdline_parse_token_string_t cmd_queue_region_set =
9552 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9554 cmdline_parse_token_string_t cmd_queue_region_port =
9555 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9556 cmdline_parse_token_num_t cmd_queue_region_port_id =
9557 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9559 cmdline_parse_token_string_t cmd_queue_region_cmd =
9560 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9561 cmd, "queue-region");
9562 cmdline_parse_token_string_t cmd_queue_region_id =
9563 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9564 region, "region_id");
9565 cmdline_parse_token_num_t cmd_queue_region_index =
9566 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9568 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9569 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9570 queue_start_index, "queue_start_index");
9571 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9572 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9574 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9575 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9576 queue_num, "queue_num");
9577 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9578 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9579 queue_num_value, UINT8);
9581 cmdline_parse_inst_t cmd_queue_region = {
9582 .f = cmd_queue_region_parsed,
9584 .help_str = "set port <port_id> queue-region region_id <value> "
9585 "queue_start_index <value> queue_num <value>: Set a queue region",
9587 (void *)&cmd_queue_region_set,
9588 (void *)&cmd_queue_region_port,
9589 (void *)&cmd_queue_region_port_id,
9590 (void *)&cmd_queue_region_cmd,
9591 (void *)&cmd_queue_region_id,
9592 (void *)&cmd_queue_region_index,
9593 (void *)&cmd_queue_region_queue_start_index,
9594 (void *)&cmd_queue_region_queue_id,
9595 (void *)&cmd_queue_region_queue_num,
9596 (void *)&cmd_queue_region_queue_num_value,
9601 /* *** queue region and flowtype set *** */
9602 struct cmd_region_flowtype_result {
9603 cmdline_fixed_string_t set;
9604 cmdline_fixed_string_t port;
9606 cmdline_fixed_string_t cmd;
9607 cmdline_fixed_string_t region;
9609 cmdline_fixed_string_t flowtype;
9610 uint8_t flowtype_id;
9614 cmd_region_flowtype_parsed(void *parsed_result,
9615 __attribute__((unused)) struct cmdline *cl,
9616 __attribute__((unused)) void *data)
9618 struct cmd_region_flowtype_result *res = parsed_result;
9620 #ifdef RTE_LIBRTE_I40E_PMD
9621 struct rte_pmd_i40e_queue_region_conf region_conf;
9622 enum rte_pmd_i40e_queue_region_op op_type;
9625 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9628 #ifdef RTE_LIBRTE_I40E_PMD
9629 memset(®ion_conf, 0, sizeof(region_conf));
9631 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9632 region_conf.region_id = res->region_id;
9633 region_conf.hw_flowtype = res->flowtype_id;
9635 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9636 op_type, ®ion_conf);
9643 printf("function not implemented or supported\n");
9646 printf("region flowtype config error: (%s)\n", strerror(-ret));
9650 cmdline_parse_token_string_t cmd_region_flowtype_set =
9651 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9653 cmdline_parse_token_string_t cmd_region_flowtype_port =
9654 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9656 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9657 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9659 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9660 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9661 cmd, "queue-region");
9662 cmdline_parse_token_string_t cmd_region_flowtype_index =
9663 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9664 region, "region_id");
9665 cmdline_parse_token_num_t cmd_region_flowtype_id =
9666 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9668 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9669 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9670 flowtype, "flowtype");
9671 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9672 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9673 flowtype_id, UINT8);
9674 cmdline_parse_inst_t cmd_region_flowtype = {
9675 .f = cmd_region_flowtype_parsed,
9677 .help_str = "set port <port_id> queue-region region_id <value> "
9678 "flowtype <value>: Set a flowtype region index",
9680 (void *)&cmd_region_flowtype_set,
9681 (void *)&cmd_region_flowtype_port,
9682 (void *)&cmd_region_flowtype_port_index,
9683 (void *)&cmd_region_flowtype_cmd,
9684 (void *)&cmd_region_flowtype_index,
9685 (void *)&cmd_region_flowtype_id,
9686 (void *)&cmd_region_flowtype_flow_index,
9687 (void *)&cmd_region_flowtype_flow_id,
9692 /* *** User Priority (UP) to queue region (region_id) set *** */
9693 struct cmd_user_priority_region_result {
9694 cmdline_fixed_string_t set;
9695 cmdline_fixed_string_t port;
9697 cmdline_fixed_string_t cmd;
9698 cmdline_fixed_string_t user_priority;
9699 uint8_t user_priority_id;
9700 cmdline_fixed_string_t region;
9705 cmd_user_priority_region_parsed(void *parsed_result,
9706 __attribute__((unused)) struct cmdline *cl,
9707 __attribute__((unused)) void *data)
9709 struct cmd_user_priority_region_result *res = parsed_result;
9711 #ifdef RTE_LIBRTE_I40E_PMD
9712 struct rte_pmd_i40e_queue_region_conf region_conf;
9713 enum rte_pmd_i40e_queue_region_op op_type;
9716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9719 #ifdef RTE_LIBRTE_I40E_PMD
9720 memset(®ion_conf, 0, sizeof(region_conf));
9721 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9722 region_conf.user_priority = res->user_priority_id;
9723 region_conf.region_id = res->region_id;
9725 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9726 op_type, ®ion_conf);
9733 printf("function not implemented or supported\n");
9736 printf("user_priority region config error: (%s)\n",
9741 cmdline_parse_token_string_t cmd_user_priority_region_set =
9742 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9744 cmdline_parse_token_string_t cmd_user_priority_region_port =
9745 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9747 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9748 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9750 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9751 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9752 cmd, "queue-region");
9753 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9754 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9755 user_priority, "UP");
9756 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9757 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9758 user_priority_id, UINT8);
9759 cmdline_parse_token_string_t cmd_user_priority_region_region =
9760 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9761 region, "region_id");
9762 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9763 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9766 cmdline_parse_inst_t cmd_user_priority_region = {
9767 .f = cmd_user_priority_region_parsed,
9769 .help_str = "set port <port_id> queue-region UP <value> "
9770 "region_id <value>: Set the mapping of User Priority (UP) "
9771 "to queue region (region_id) ",
9773 (void *)&cmd_user_priority_region_set,
9774 (void *)&cmd_user_priority_region_port,
9775 (void *)&cmd_user_priority_region_port_index,
9776 (void *)&cmd_user_priority_region_cmd,
9777 (void *)&cmd_user_priority_region_UP,
9778 (void *)&cmd_user_priority_region_UP_id,
9779 (void *)&cmd_user_priority_region_region,
9780 (void *)&cmd_user_priority_region_region_id,
9785 /* *** flush all queue region related configuration *** */
9786 struct cmd_flush_queue_region_result {
9787 cmdline_fixed_string_t set;
9788 cmdline_fixed_string_t port;
9790 cmdline_fixed_string_t cmd;
9791 cmdline_fixed_string_t flush;
9792 cmdline_fixed_string_t what;
9796 cmd_flush_queue_region_parsed(void *parsed_result,
9797 __attribute__((unused)) struct cmdline *cl,
9798 __attribute__((unused)) void *data)
9800 struct cmd_flush_queue_region_result *res = parsed_result;
9802 #ifdef RTE_LIBRTE_I40E_PMD
9803 struct rte_pmd_i40e_queue_region_conf region_conf;
9804 enum rte_pmd_i40e_queue_region_op op_type;
9807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9810 #ifdef RTE_LIBRTE_I40E_PMD
9811 memset(®ion_conf, 0, sizeof(region_conf));
9813 if (strcmp(res->what, "on") == 0)
9814 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9816 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9818 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9819 op_type, ®ion_conf);
9826 printf("function not implemented or supported\n");
9829 printf("queue region config flush error: (%s)\n",
9834 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9835 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9837 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9838 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9840 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9841 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9843 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9844 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9845 cmd, "queue-region");
9846 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9847 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9849 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9850 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9853 cmdline_parse_inst_t cmd_flush_queue_region = {
9854 .f = cmd_flush_queue_region_parsed,
9856 .help_str = "set port <port_id> queue-region flush on|off"
9857 ": flush all queue region related configuration",
9859 (void *)&cmd_flush_queue_region_set,
9860 (void *)&cmd_flush_queue_region_port,
9861 (void *)&cmd_flush_queue_region_port_index,
9862 (void *)&cmd_flush_queue_region_cmd,
9863 (void *)&cmd_flush_queue_region_flush,
9864 (void *)&cmd_flush_queue_region_what,
9869 /* *** get all queue region related configuration info *** */
9870 struct cmd_show_queue_region_info {
9871 cmdline_fixed_string_t show;
9872 cmdline_fixed_string_t port;
9874 cmdline_fixed_string_t cmd;
9878 cmd_show_queue_region_info_parsed(void *parsed_result,
9879 __attribute__((unused)) struct cmdline *cl,
9880 __attribute__((unused)) void *data)
9882 struct cmd_show_queue_region_info *res = parsed_result;
9884 #ifdef RTE_LIBRTE_I40E_PMD
9885 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9886 enum rte_pmd_i40e_queue_region_op op_type;
9889 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9892 #ifdef RTE_LIBRTE_I40E_PMD
9893 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9895 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9897 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9898 op_type, &rte_pmd_regions);
9900 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9907 printf("function not implemented or supported\n");
9910 printf("queue region config info show error: (%s)\n",
9915 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9916 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9918 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9919 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9921 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9922 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9924 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9925 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9926 cmd, "queue-region");
9928 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9929 .f = cmd_show_queue_region_info_parsed,
9931 .help_str = "show port <port_id> queue-region"
9932 ": show all queue region related configuration info",
9934 (void *)&cmd_show_queue_region_info_get,
9935 (void *)&cmd_show_queue_region_info_port,
9936 (void *)&cmd_show_queue_region_info_port_index,
9937 (void *)&cmd_show_queue_region_info_cmd,
9942 /* *** ADD/REMOVE A 2tuple FILTER *** */
9943 struct cmd_2tuple_filter_result {
9944 cmdline_fixed_string_t filter;
9946 cmdline_fixed_string_t ops;
9947 cmdline_fixed_string_t dst_port;
9948 uint16_t dst_port_value;
9949 cmdline_fixed_string_t protocol;
9950 uint8_t protocol_value;
9951 cmdline_fixed_string_t mask;
9953 cmdline_fixed_string_t tcp_flags;
9954 uint8_t tcp_flags_value;
9955 cmdline_fixed_string_t priority;
9956 uint8_t priority_value;
9957 cmdline_fixed_string_t queue;
9962 cmd_2tuple_filter_parsed(void *parsed_result,
9963 __attribute__((unused)) struct cmdline *cl,
9964 __attribute__((unused)) void *data)
9966 struct rte_eth_ntuple_filter filter;
9967 struct cmd_2tuple_filter_result *res = parsed_result;
9970 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9972 printf("ntuple filter is not supported on port %u.\n",
9977 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9979 filter.flags = RTE_2TUPLE_FLAGS;
9980 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9981 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9982 filter.proto = res->protocol_value;
9983 filter.priority = res->priority_value;
9984 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9985 printf("nonzero tcp_flags is only meaningful"
9986 " when protocol is TCP.\n");
9989 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9990 printf("invalid TCP flags.\n");
9994 if (res->tcp_flags_value != 0) {
9995 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9996 filter.tcp_flags = res->tcp_flags_value;
9999 /* need convert to big endian. */
10000 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10001 filter.queue = res->queue_id;
10003 if (!strcmp(res->ops, "add"))
10004 ret = rte_eth_dev_filter_ctrl(res->port_id,
10005 RTE_ETH_FILTER_NTUPLE,
10006 RTE_ETH_FILTER_ADD,
10009 ret = rte_eth_dev_filter_ctrl(res->port_id,
10010 RTE_ETH_FILTER_NTUPLE,
10011 RTE_ETH_FILTER_DELETE,
10014 printf("2tuple filter programming error: (%s)\n",
10019 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10020 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10021 filter, "2tuple_filter");
10022 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10023 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10025 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10026 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10028 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10029 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10030 dst_port, "dst_port");
10031 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10032 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10033 dst_port_value, UINT16);
10034 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10035 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10036 protocol, "protocol");
10037 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10038 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10039 protocol_value, UINT8);
10040 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10041 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10043 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10044 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10046 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10047 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10048 tcp_flags, "tcp_flags");
10049 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10050 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10051 tcp_flags_value, UINT8);
10052 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10053 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10054 priority, "priority");
10055 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10056 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10057 priority_value, UINT8);
10058 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10059 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10061 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10062 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10065 cmdline_parse_inst_t cmd_2tuple_filter = {
10066 .f = cmd_2tuple_filter_parsed,
10068 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10069 "<value> mask <value> tcp_flags <value> priority <value> queue "
10070 "<queue_id>: Add a 2tuple filter",
10072 (void *)&cmd_2tuple_filter_filter,
10073 (void *)&cmd_2tuple_filter_port_id,
10074 (void *)&cmd_2tuple_filter_ops,
10075 (void *)&cmd_2tuple_filter_dst_port,
10076 (void *)&cmd_2tuple_filter_dst_port_value,
10077 (void *)&cmd_2tuple_filter_protocol,
10078 (void *)&cmd_2tuple_filter_protocol_value,
10079 (void *)&cmd_2tuple_filter_mask,
10080 (void *)&cmd_2tuple_filter_mask_value,
10081 (void *)&cmd_2tuple_filter_tcp_flags,
10082 (void *)&cmd_2tuple_filter_tcp_flags_value,
10083 (void *)&cmd_2tuple_filter_priority,
10084 (void *)&cmd_2tuple_filter_priority_value,
10085 (void *)&cmd_2tuple_filter_queue,
10086 (void *)&cmd_2tuple_filter_queue_id,
10091 /* *** ADD/REMOVE A 5tuple FILTER *** */
10092 struct cmd_5tuple_filter_result {
10093 cmdline_fixed_string_t filter;
10095 cmdline_fixed_string_t ops;
10096 cmdline_fixed_string_t dst_ip;
10097 cmdline_ipaddr_t dst_ip_value;
10098 cmdline_fixed_string_t src_ip;
10099 cmdline_ipaddr_t src_ip_value;
10100 cmdline_fixed_string_t dst_port;
10101 uint16_t dst_port_value;
10102 cmdline_fixed_string_t src_port;
10103 uint16_t src_port_value;
10104 cmdline_fixed_string_t protocol;
10105 uint8_t protocol_value;
10106 cmdline_fixed_string_t mask;
10107 uint8_t mask_value;
10108 cmdline_fixed_string_t tcp_flags;
10109 uint8_t tcp_flags_value;
10110 cmdline_fixed_string_t priority;
10111 uint8_t priority_value;
10112 cmdline_fixed_string_t queue;
10117 cmd_5tuple_filter_parsed(void *parsed_result,
10118 __attribute__((unused)) struct cmdline *cl,
10119 __attribute__((unused)) void *data)
10121 struct rte_eth_ntuple_filter filter;
10122 struct cmd_5tuple_filter_result *res = parsed_result;
10125 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10127 printf("ntuple filter is not supported on port %u.\n",
10132 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10134 filter.flags = RTE_5TUPLE_FLAGS;
10135 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10136 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10137 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10138 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10139 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10140 filter.proto = res->protocol_value;
10141 filter.priority = res->priority_value;
10142 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10143 printf("nonzero tcp_flags is only meaningful"
10144 " when protocol is TCP.\n");
10147 if (res->tcp_flags_value > TCP_FLAG_ALL) {
10148 printf("invalid TCP flags.\n");
10152 if (res->tcp_flags_value != 0) {
10153 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10154 filter.tcp_flags = res->tcp_flags_value;
10157 if (res->dst_ip_value.family == AF_INET)
10158 /* no need to convert, already big endian. */
10159 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10161 if (filter.dst_ip_mask == 0) {
10162 printf("can not support ipv6 involved compare.\n");
10168 if (res->src_ip_value.family == AF_INET)
10169 /* no need to convert, already big endian. */
10170 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10172 if (filter.src_ip_mask == 0) {
10173 printf("can not support ipv6 involved compare.\n");
10178 /* need convert to big endian. */
10179 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10180 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10181 filter.queue = res->queue_id;
10183 if (!strcmp(res->ops, "add"))
10184 ret = rte_eth_dev_filter_ctrl(res->port_id,
10185 RTE_ETH_FILTER_NTUPLE,
10186 RTE_ETH_FILTER_ADD,
10189 ret = rte_eth_dev_filter_ctrl(res->port_id,
10190 RTE_ETH_FILTER_NTUPLE,
10191 RTE_ETH_FILTER_DELETE,
10194 printf("5tuple filter programming error: (%s)\n",
10198 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10199 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10200 filter, "5tuple_filter");
10201 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10202 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10204 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10205 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10207 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10208 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10210 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10211 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10213 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10214 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10216 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10217 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10219 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10220 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10221 dst_port, "dst_port");
10222 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10223 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10224 dst_port_value, UINT16);
10225 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10226 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10227 src_port, "src_port");
10228 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10229 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10230 src_port_value, UINT16);
10231 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10232 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10233 protocol, "protocol");
10234 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10235 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10236 protocol_value, UINT8);
10237 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10238 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10240 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10241 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10243 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10244 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10245 tcp_flags, "tcp_flags");
10246 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10247 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10248 tcp_flags_value, UINT8);
10249 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10250 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10251 priority, "priority");
10252 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10253 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10254 priority_value, UINT8);
10255 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10256 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10258 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10259 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10262 cmdline_parse_inst_t cmd_5tuple_filter = {
10263 .f = cmd_5tuple_filter_parsed,
10265 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10266 "src_ip <value> dst_port <value> src_port <value> "
10267 "protocol <value> mask <value> tcp_flags <value> "
10268 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10270 (void *)&cmd_5tuple_filter_filter,
10271 (void *)&cmd_5tuple_filter_port_id,
10272 (void *)&cmd_5tuple_filter_ops,
10273 (void *)&cmd_5tuple_filter_dst_ip,
10274 (void *)&cmd_5tuple_filter_dst_ip_value,
10275 (void *)&cmd_5tuple_filter_src_ip,
10276 (void *)&cmd_5tuple_filter_src_ip_value,
10277 (void *)&cmd_5tuple_filter_dst_port,
10278 (void *)&cmd_5tuple_filter_dst_port_value,
10279 (void *)&cmd_5tuple_filter_src_port,
10280 (void *)&cmd_5tuple_filter_src_port_value,
10281 (void *)&cmd_5tuple_filter_protocol,
10282 (void *)&cmd_5tuple_filter_protocol_value,
10283 (void *)&cmd_5tuple_filter_mask,
10284 (void *)&cmd_5tuple_filter_mask_value,
10285 (void *)&cmd_5tuple_filter_tcp_flags,
10286 (void *)&cmd_5tuple_filter_tcp_flags_value,
10287 (void *)&cmd_5tuple_filter_priority,
10288 (void *)&cmd_5tuple_filter_priority_value,
10289 (void *)&cmd_5tuple_filter_queue,
10290 (void *)&cmd_5tuple_filter_queue_id,
10295 /* *** ADD/REMOVE A flex FILTER *** */
10296 struct cmd_flex_filter_result {
10297 cmdline_fixed_string_t filter;
10298 cmdline_fixed_string_t ops;
10300 cmdline_fixed_string_t len;
10302 cmdline_fixed_string_t bytes;
10303 cmdline_fixed_string_t bytes_value;
10304 cmdline_fixed_string_t mask;
10305 cmdline_fixed_string_t mask_value;
10306 cmdline_fixed_string_t priority;
10307 uint8_t priority_value;
10308 cmdline_fixed_string_t queue;
10312 static int xdigit2val(unsigned char c)
10317 else if (isupper(c))
10318 val = c - 'A' + 10;
10320 val = c - 'a' + 10;
10325 cmd_flex_filter_parsed(void *parsed_result,
10326 __attribute__((unused)) struct cmdline *cl,
10327 __attribute__((unused)) void *data)
10330 struct rte_eth_flex_filter filter;
10331 struct cmd_flex_filter_result *res = parsed_result;
10332 char *bytes_ptr, *mask_ptr;
10333 uint16_t len, i, j = 0;
10338 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10339 printf("the len exceed the max length 128\n");
10342 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10343 filter.len = res->len_value;
10344 filter.priority = res->priority_value;
10345 filter.queue = res->queue_id;
10346 bytes_ptr = res->bytes_value;
10347 mask_ptr = res->mask_value;
10349 /* translate bytes string to array. */
10350 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10351 (bytes_ptr[1] == 'X')))
10353 len = strnlen(bytes_ptr, res->len_value * 2);
10354 if (len == 0 || (len % 8 != 0)) {
10355 printf("please check len and bytes input\n");
10358 for (i = 0; i < len; i++) {
10360 if (isxdigit(c) == 0) {
10361 /* invalid characters. */
10362 printf("invalid input\n");
10365 val = xdigit2val(c);
10368 filter.bytes[j] = byte;
10369 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10376 /* translate mask string to uint8_t array. */
10377 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10378 (mask_ptr[1] == 'X')))
10380 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10382 printf("invalid input\n");
10387 for (i = 0; i < len; i++) {
10389 if (isxdigit(c) == 0) {
10390 /* invalid characters. */
10391 printf("invalid input\n");
10394 val = xdigit2val(c);
10397 filter.mask[j] = byte;
10398 printf("mask[%d]:%02x ", j, filter.mask[j]);
10406 if (!strcmp(res->ops, "add"))
10407 ret = rte_eth_dev_filter_ctrl(res->port_id,
10408 RTE_ETH_FILTER_FLEXIBLE,
10409 RTE_ETH_FILTER_ADD,
10412 ret = rte_eth_dev_filter_ctrl(res->port_id,
10413 RTE_ETH_FILTER_FLEXIBLE,
10414 RTE_ETH_FILTER_DELETE,
10418 printf("flex filter setting error: (%s)\n", strerror(-ret));
10421 cmdline_parse_token_string_t cmd_flex_filter_filter =
10422 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10423 filter, "flex_filter");
10424 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10425 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10427 cmdline_parse_token_string_t cmd_flex_filter_ops =
10428 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10430 cmdline_parse_token_string_t cmd_flex_filter_len =
10431 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10433 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10434 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10436 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10437 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10439 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10440 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10441 bytes_value, NULL);
10442 cmdline_parse_token_string_t cmd_flex_filter_mask =
10443 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10445 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10446 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10448 cmdline_parse_token_string_t cmd_flex_filter_priority =
10449 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10450 priority, "priority");
10451 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10452 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10453 priority_value, UINT8);
10454 cmdline_parse_token_string_t cmd_flex_filter_queue =
10455 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10457 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10458 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10460 cmdline_parse_inst_t cmd_flex_filter = {
10461 .f = cmd_flex_filter_parsed,
10463 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10464 "<value> mask <value> priority <value> queue <queue_id>: "
10465 "Add/Del a flex filter",
10467 (void *)&cmd_flex_filter_filter,
10468 (void *)&cmd_flex_filter_port_id,
10469 (void *)&cmd_flex_filter_ops,
10470 (void *)&cmd_flex_filter_len,
10471 (void *)&cmd_flex_filter_len_value,
10472 (void *)&cmd_flex_filter_bytes,
10473 (void *)&cmd_flex_filter_bytes_value,
10474 (void *)&cmd_flex_filter_mask,
10475 (void *)&cmd_flex_filter_mask_value,
10476 (void *)&cmd_flex_filter_priority,
10477 (void *)&cmd_flex_filter_priority_value,
10478 (void *)&cmd_flex_filter_queue,
10479 (void *)&cmd_flex_filter_queue_id,
10484 /* *** Filters Control *** */
10486 /* *** deal with ethertype filter *** */
10487 struct cmd_ethertype_filter_result {
10488 cmdline_fixed_string_t filter;
10490 cmdline_fixed_string_t ops;
10491 cmdline_fixed_string_t mac;
10492 struct ether_addr mac_addr;
10493 cmdline_fixed_string_t ethertype;
10494 uint16_t ethertype_value;
10495 cmdline_fixed_string_t drop;
10496 cmdline_fixed_string_t queue;
10500 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10501 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10502 filter, "ethertype_filter");
10503 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10504 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10506 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10507 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10509 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10510 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10511 mac, "mac_addr#mac_ignr");
10512 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10513 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10515 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10516 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10517 ethertype, "ethertype");
10518 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10519 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10520 ethertype_value, UINT16);
10521 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10522 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10524 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10525 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10527 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10528 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10532 cmd_ethertype_filter_parsed(void *parsed_result,
10533 __attribute__((unused)) struct cmdline *cl,
10534 __attribute__((unused)) void *data)
10536 struct cmd_ethertype_filter_result *res = parsed_result;
10537 struct rte_eth_ethertype_filter filter;
10540 ret = rte_eth_dev_filter_supported(res->port_id,
10541 RTE_ETH_FILTER_ETHERTYPE);
10543 printf("ethertype filter is not supported on port %u.\n",
10548 memset(&filter, 0, sizeof(filter));
10549 if (!strcmp(res->mac, "mac_addr")) {
10550 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10551 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10552 sizeof(struct ether_addr));
10554 if (!strcmp(res->drop, "drop"))
10555 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10556 filter.ether_type = res->ethertype_value;
10557 filter.queue = res->queue_id;
10559 if (!strcmp(res->ops, "add"))
10560 ret = rte_eth_dev_filter_ctrl(res->port_id,
10561 RTE_ETH_FILTER_ETHERTYPE,
10562 RTE_ETH_FILTER_ADD,
10565 ret = rte_eth_dev_filter_ctrl(res->port_id,
10566 RTE_ETH_FILTER_ETHERTYPE,
10567 RTE_ETH_FILTER_DELETE,
10570 printf("ethertype filter programming error: (%s)\n",
10574 cmdline_parse_inst_t cmd_ethertype_filter = {
10575 .f = cmd_ethertype_filter_parsed,
10577 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10578 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10579 "Add or delete an ethertype filter entry",
10581 (void *)&cmd_ethertype_filter_filter,
10582 (void *)&cmd_ethertype_filter_port_id,
10583 (void *)&cmd_ethertype_filter_ops,
10584 (void *)&cmd_ethertype_filter_mac,
10585 (void *)&cmd_ethertype_filter_mac_addr,
10586 (void *)&cmd_ethertype_filter_ethertype,
10587 (void *)&cmd_ethertype_filter_ethertype_value,
10588 (void *)&cmd_ethertype_filter_drop,
10589 (void *)&cmd_ethertype_filter_queue,
10590 (void *)&cmd_ethertype_filter_queue_id,
10595 /* *** deal with flow director filter *** */
10596 struct cmd_flow_director_result {
10597 cmdline_fixed_string_t flow_director_filter;
10599 cmdline_fixed_string_t mode;
10600 cmdline_fixed_string_t mode_value;
10601 cmdline_fixed_string_t ops;
10602 cmdline_fixed_string_t flow;
10603 cmdline_fixed_string_t flow_type;
10604 cmdline_fixed_string_t ether;
10605 uint16_t ether_type;
10606 cmdline_fixed_string_t src;
10607 cmdline_ipaddr_t ip_src;
10609 cmdline_fixed_string_t dst;
10610 cmdline_ipaddr_t ip_dst;
10612 cmdline_fixed_string_t verify_tag;
10613 uint32_t verify_tag_value;
10614 cmdline_fixed_string_t tos;
10616 cmdline_fixed_string_t proto;
10617 uint8_t proto_value;
10618 cmdline_fixed_string_t ttl;
10620 cmdline_fixed_string_t vlan;
10621 uint16_t vlan_value;
10622 cmdline_fixed_string_t flexbytes;
10623 cmdline_fixed_string_t flexbytes_value;
10624 cmdline_fixed_string_t pf_vf;
10625 cmdline_fixed_string_t drop;
10626 cmdline_fixed_string_t queue;
10628 cmdline_fixed_string_t fd_id;
10629 uint32_t fd_id_value;
10630 cmdline_fixed_string_t mac;
10631 struct ether_addr mac_addr;
10632 cmdline_fixed_string_t tunnel;
10633 cmdline_fixed_string_t tunnel_type;
10634 cmdline_fixed_string_t tunnel_id;
10635 uint32_t tunnel_id_value;
10636 cmdline_fixed_string_t packet;
10641 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10644 const char *p, *p0 = q_arg;
10646 unsigned long int_fld;
10647 char *str_fld[max_num];
10652 p = strchr(p0, '(');
10656 p0 = strchr(p, ')');
10661 if (size >= sizeof(s))
10664 snprintf(s, sizeof(s), "%.*s", size, p);
10665 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10666 if (ret < 0 || ret > max_num)
10668 for (i = 0; i < ret; i++) {
10670 int_fld = strtoul(str_fld[i], &end, 0);
10671 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10673 flexbytes[i] = (uint8_t)int_fld;
10679 str2flowtype(char *string)
10682 static const struct {
10685 } flowtype_str[] = {
10686 {"raw", RTE_ETH_FLOW_RAW},
10687 {"ipv4", RTE_ETH_FLOW_IPV4},
10688 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10689 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10690 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10691 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10692 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10693 {"ipv6", RTE_ETH_FLOW_IPV6},
10694 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10695 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10696 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10697 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10698 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10699 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10702 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10703 if (!strcmp(flowtype_str[i].str, string))
10704 return flowtype_str[i].type;
10707 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10708 return (uint16_t)atoi(string);
10710 return RTE_ETH_FLOW_UNKNOWN;
10713 static enum rte_eth_fdir_tunnel_type
10714 str2fdir_tunneltype(char *string)
10718 static const struct {
10720 enum rte_eth_fdir_tunnel_type type;
10721 } tunneltype_str[] = {
10722 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10723 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10726 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10727 if (!strcmp(tunneltype_str[i].str, string))
10728 return tunneltype_str[i].type;
10730 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10733 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10735 if ((ip_addr).family == AF_INET) \
10736 (ip) = (ip_addr).addr.ipv4.s_addr; \
10738 printf("invalid parameter.\n"); \
10743 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10745 if ((ip_addr).family == AF_INET6) \
10746 rte_memcpy(&(ip), \
10747 &((ip_addr).addr.ipv6), \
10748 sizeof(struct in6_addr)); \
10750 printf("invalid parameter.\n"); \
10756 cmd_flow_director_filter_parsed(void *parsed_result,
10757 __attribute__((unused)) struct cmdline *cl,
10758 __attribute__((unused)) void *data)
10760 struct cmd_flow_director_result *res = parsed_result;
10761 struct rte_eth_fdir_filter entry;
10762 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10764 unsigned long vf_id;
10767 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10769 printf("flow director is not supported on port %u.\n",
10773 memset(flexbytes, 0, sizeof(flexbytes));
10774 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10776 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10777 if (strcmp(res->mode_value, "MAC-VLAN")) {
10778 printf("Please set mode to MAC-VLAN.\n");
10781 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10782 if (strcmp(res->mode_value, "Tunnel")) {
10783 printf("Please set mode to Tunnel.\n");
10787 if (!strcmp(res->mode_value, "raw")) {
10788 #ifdef RTE_LIBRTE_I40E_PMD
10789 struct rte_pmd_i40e_flow_type_mapping
10790 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10791 struct rte_pmd_i40e_pkt_template_conf conf;
10792 uint16_t flow_type = str2flowtype(res->flow_type);
10793 uint16_t i, port = res->port_id;
10796 memset(&conf, 0, sizeof(conf));
10798 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10799 printf("Invalid flow type specified.\n");
10802 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10806 if (mapping[flow_type].pctype == 0ULL) {
10807 printf("Invalid flow type specified.\n");
10810 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10811 if (mapping[flow_type].pctype & (1ULL << i)) {
10812 conf.input.pctype = i;
10817 conf.input.packet = open_file(res->filepath,
10818 &conf.input.length);
10819 if (!conf.input.packet)
10821 if (!strcmp(res->drop, "drop"))
10822 conf.action.behavior =
10823 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10825 conf.action.behavior =
10826 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10827 conf.action.report_status =
10828 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10829 conf.action.rx_queue = res->queue_id;
10830 conf.soft_id = res->fd_id_value;
10831 add = strcmp(res->ops, "del") ? 1 : 0;
10832 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10836 printf("flow director config error: (%s)\n",
10838 close_file(conf.input.packet);
10841 } else if (strcmp(res->mode_value, "IP")) {
10842 printf("Please set mode to IP or raw.\n");
10845 entry.input.flow_type = str2flowtype(res->flow_type);
10848 ret = parse_flexbytes(res->flexbytes_value,
10850 RTE_ETH_FDIR_MAX_FLEXLEN);
10852 printf("error: Cannot parse flexbytes input.\n");
10856 switch (entry.input.flow_type) {
10857 case RTE_ETH_FLOW_FRAG_IPV4:
10858 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10859 entry.input.flow.ip4_flow.proto = res->proto_value;
10861 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10862 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10863 IPV4_ADDR_TO_UINT(res->ip_dst,
10864 entry.input.flow.ip4_flow.dst_ip);
10865 IPV4_ADDR_TO_UINT(res->ip_src,
10866 entry.input.flow.ip4_flow.src_ip);
10867 entry.input.flow.ip4_flow.tos = res->tos_value;
10868 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10869 /* need convert to big endian. */
10870 entry.input.flow.udp4_flow.dst_port =
10871 rte_cpu_to_be_16(res->port_dst);
10872 entry.input.flow.udp4_flow.src_port =
10873 rte_cpu_to_be_16(res->port_src);
10875 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10876 IPV4_ADDR_TO_UINT(res->ip_dst,
10877 entry.input.flow.sctp4_flow.ip.dst_ip);
10878 IPV4_ADDR_TO_UINT(res->ip_src,
10879 entry.input.flow.sctp4_flow.ip.src_ip);
10880 entry.input.flow.ip4_flow.tos = res->tos_value;
10881 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10882 /* need convert to big endian. */
10883 entry.input.flow.sctp4_flow.dst_port =
10884 rte_cpu_to_be_16(res->port_dst);
10885 entry.input.flow.sctp4_flow.src_port =
10886 rte_cpu_to_be_16(res->port_src);
10887 entry.input.flow.sctp4_flow.verify_tag =
10888 rte_cpu_to_be_32(res->verify_tag_value);
10890 case RTE_ETH_FLOW_FRAG_IPV6:
10891 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10892 entry.input.flow.ipv6_flow.proto = res->proto_value;
10894 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10895 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10896 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10897 entry.input.flow.ipv6_flow.dst_ip);
10898 IPV6_ADDR_TO_ARRAY(res->ip_src,
10899 entry.input.flow.ipv6_flow.src_ip);
10900 entry.input.flow.ipv6_flow.tc = res->tos_value;
10901 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10902 /* need convert to big endian. */
10903 entry.input.flow.udp6_flow.dst_port =
10904 rte_cpu_to_be_16(res->port_dst);
10905 entry.input.flow.udp6_flow.src_port =
10906 rte_cpu_to_be_16(res->port_src);
10908 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10909 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10910 entry.input.flow.sctp6_flow.ip.dst_ip);
10911 IPV6_ADDR_TO_ARRAY(res->ip_src,
10912 entry.input.flow.sctp6_flow.ip.src_ip);
10913 entry.input.flow.ipv6_flow.tc = res->tos_value;
10914 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10915 /* need convert to big endian. */
10916 entry.input.flow.sctp6_flow.dst_port =
10917 rte_cpu_to_be_16(res->port_dst);
10918 entry.input.flow.sctp6_flow.src_port =
10919 rte_cpu_to_be_16(res->port_src);
10920 entry.input.flow.sctp6_flow.verify_tag =
10921 rte_cpu_to_be_32(res->verify_tag_value);
10923 case RTE_ETH_FLOW_L2_PAYLOAD:
10924 entry.input.flow.l2_flow.ether_type =
10925 rte_cpu_to_be_16(res->ether_type);
10931 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10932 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10934 sizeof(struct ether_addr));
10936 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10937 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10939 sizeof(struct ether_addr));
10940 entry.input.flow.tunnel_flow.tunnel_type =
10941 str2fdir_tunneltype(res->tunnel_type);
10942 entry.input.flow.tunnel_flow.tunnel_id =
10943 rte_cpu_to_be_32(res->tunnel_id_value);
10946 rte_memcpy(entry.input.flow_ext.flexbytes,
10948 RTE_ETH_FDIR_MAX_FLEXLEN);
10950 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10952 entry.action.flex_off = 0; /*use 0 by default */
10953 if (!strcmp(res->drop, "drop"))
10954 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10956 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10958 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10959 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10960 if (!strcmp(res->pf_vf, "pf"))
10961 entry.input.flow_ext.is_vf = 0;
10962 else if (!strncmp(res->pf_vf, "vf", 2)) {
10963 struct rte_eth_dev_info dev_info;
10965 memset(&dev_info, 0, sizeof(dev_info));
10966 rte_eth_dev_info_get(res->port_id, &dev_info);
10968 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10969 if (errno != 0 || *end != '\0' ||
10970 vf_id >= dev_info.max_vfs) {
10971 printf("invalid parameter %s.\n", res->pf_vf);
10974 entry.input.flow_ext.is_vf = 1;
10975 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10977 printf("invalid parameter %s.\n", res->pf_vf);
10982 /* set to report FD ID by default */
10983 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10984 entry.action.rx_queue = res->queue_id;
10985 entry.soft_id = res->fd_id_value;
10986 if (!strcmp(res->ops, "add"))
10987 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10988 RTE_ETH_FILTER_ADD, &entry);
10989 else if (!strcmp(res->ops, "del"))
10990 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10991 RTE_ETH_FILTER_DELETE, &entry);
10993 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10994 RTE_ETH_FILTER_UPDATE, &entry);
10996 printf("flow director programming error: (%s)\n",
11000 cmdline_parse_token_string_t cmd_flow_director_filter =
11001 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11002 flow_director_filter, "flow_director_filter");
11003 cmdline_parse_token_num_t cmd_flow_director_port_id =
11004 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11006 cmdline_parse_token_string_t cmd_flow_director_ops =
11007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11008 ops, "add#del#update");
11009 cmdline_parse_token_string_t cmd_flow_director_flow =
11010 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11012 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11013 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11015 cmdline_parse_token_string_t cmd_flow_director_ether =
11016 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11018 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11019 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11020 ether_type, UINT16);
11021 cmdline_parse_token_string_t cmd_flow_director_src =
11022 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11024 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11025 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11027 cmdline_parse_token_num_t cmd_flow_director_port_src =
11028 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11030 cmdline_parse_token_string_t cmd_flow_director_dst =
11031 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11033 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11034 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11036 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11037 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11039 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11040 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11041 verify_tag, "verify_tag");
11042 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11043 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11044 verify_tag_value, UINT32);
11045 cmdline_parse_token_string_t cmd_flow_director_tos =
11046 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11048 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11049 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11051 cmdline_parse_token_string_t cmd_flow_director_proto =
11052 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11054 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11055 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11056 proto_value, UINT8);
11057 cmdline_parse_token_string_t cmd_flow_director_ttl =
11058 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11060 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11061 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11063 cmdline_parse_token_string_t cmd_flow_director_vlan =
11064 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11066 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11067 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11068 vlan_value, UINT16);
11069 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11070 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11071 flexbytes, "flexbytes");
11072 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11073 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11074 flexbytes_value, NULL);
11075 cmdline_parse_token_string_t cmd_flow_director_drop =
11076 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11078 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11079 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11081 cmdline_parse_token_string_t cmd_flow_director_queue =
11082 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11084 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11085 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11087 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11088 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11090 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11091 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11092 fd_id_value, UINT32);
11094 cmdline_parse_token_string_t cmd_flow_director_mode =
11095 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11097 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11098 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11100 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11101 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11102 mode_value, "MAC-VLAN");
11103 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11104 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11105 mode_value, "Tunnel");
11106 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11107 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11108 mode_value, "raw");
11109 cmdline_parse_token_string_t cmd_flow_director_mac =
11110 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11112 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11113 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11115 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11116 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11118 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11119 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11120 tunnel_type, "NVGRE#VxLAN");
11121 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11122 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11123 tunnel_id, "tunnel-id");
11124 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11125 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11126 tunnel_id_value, UINT32);
11127 cmdline_parse_token_string_t cmd_flow_director_packet =
11128 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11130 cmdline_parse_token_string_t cmd_flow_director_filepath =
11131 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11134 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11135 .f = cmd_flow_director_filter_parsed,
11137 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11138 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11139 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11140 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11141 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11142 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11143 "fd_id <fd_id_value>: "
11144 "Add or delete an ip flow director entry on NIC",
11146 (void *)&cmd_flow_director_filter,
11147 (void *)&cmd_flow_director_port_id,
11148 (void *)&cmd_flow_director_mode,
11149 (void *)&cmd_flow_director_mode_ip,
11150 (void *)&cmd_flow_director_ops,
11151 (void *)&cmd_flow_director_flow,
11152 (void *)&cmd_flow_director_flow_type,
11153 (void *)&cmd_flow_director_src,
11154 (void *)&cmd_flow_director_ip_src,
11155 (void *)&cmd_flow_director_dst,
11156 (void *)&cmd_flow_director_ip_dst,
11157 (void *)&cmd_flow_director_tos,
11158 (void *)&cmd_flow_director_tos_value,
11159 (void *)&cmd_flow_director_proto,
11160 (void *)&cmd_flow_director_proto_value,
11161 (void *)&cmd_flow_director_ttl,
11162 (void *)&cmd_flow_director_ttl_value,
11163 (void *)&cmd_flow_director_vlan,
11164 (void *)&cmd_flow_director_vlan_value,
11165 (void *)&cmd_flow_director_flexbytes,
11166 (void *)&cmd_flow_director_flexbytes_value,
11167 (void *)&cmd_flow_director_drop,
11168 (void *)&cmd_flow_director_pf_vf,
11169 (void *)&cmd_flow_director_queue,
11170 (void *)&cmd_flow_director_queue_id,
11171 (void *)&cmd_flow_director_fd_id,
11172 (void *)&cmd_flow_director_fd_id_value,
11177 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11178 .f = cmd_flow_director_filter_parsed,
11180 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11181 "director entry on NIC",
11183 (void *)&cmd_flow_director_filter,
11184 (void *)&cmd_flow_director_port_id,
11185 (void *)&cmd_flow_director_mode,
11186 (void *)&cmd_flow_director_mode_ip,
11187 (void *)&cmd_flow_director_ops,
11188 (void *)&cmd_flow_director_flow,
11189 (void *)&cmd_flow_director_flow_type,
11190 (void *)&cmd_flow_director_src,
11191 (void *)&cmd_flow_director_ip_src,
11192 (void *)&cmd_flow_director_port_src,
11193 (void *)&cmd_flow_director_dst,
11194 (void *)&cmd_flow_director_ip_dst,
11195 (void *)&cmd_flow_director_port_dst,
11196 (void *)&cmd_flow_director_tos,
11197 (void *)&cmd_flow_director_tos_value,
11198 (void *)&cmd_flow_director_ttl,
11199 (void *)&cmd_flow_director_ttl_value,
11200 (void *)&cmd_flow_director_vlan,
11201 (void *)&cmd_flow_director_vlan_value,
11202 (void *)&cmd_flow_director_flexbytes,
11203 (void *)&cmd_flow_director_flexbytes_value,
11204 (void *)&cmd_flow_director_drop,
11205 (void *)&cmd_flow_director_pf_vf,
11206 (void *)&cmd_flow_director_queue,
11207 (void *)&cmd_flow_director_queue_id,
11208 (void *)&cmd_flow_director_fd_id,
11209 (void *)&cmd_flow_director_fd_id_value,
11214 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11215 .f = cmd_flow_director_filter_parsed,
11217 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11218 "director entry on NIC",
11220 (void *)&cmd_flow_director_filter,
11221 (void *)&cmd_flow_director_port_id,
11222 (void *)&cmd_flow_director_mode,
11223 (void *)&cmd_flow_director_mode_ip,
11224 (void *)&cmd_flow_director_ops,
11225 (void *)&cmd_flow_director_flow,
11226 (void *)&cmd_flow_director_flow_type,
11227 (void *)&cmd_flow_director_src,
11228 (void *)&cmd_flow_director_ip_src,
11229 (void *)&cmd_flow_director_port_src,
11230 (void *)&cmd_flow_director_dst,
11231 (void *)&cmd_flow_director_ip_dst,
11232 (void *)&cmd_flow_director_port_dst,
11233 (void *)&cmd_flow_director_verify_tag,
11234 (void *)&cmd_flow_director_verify_tag_value,
11235 (void *)&cmd_flow_director_tos,
11236 (void *)&cmd_flow_director_tos_value,
11237 (void *)&cmd_flow_director_ttl,
11238 (void *)&cmd_flow_director_ttl_value,
11239 (void *)&cmd_flow_director_vlan,
11240 (void *)&cmd_flow_director_vlan_value,
11241 (void *)&cmd_flow_director_flexbytes,
11242 (void *)&cmd_flow_director_flexbytes_value,
11243 (void *)&cmd_flow_director_drop,
11244 (void *)&cmd_flow_director_pf_vf,
11245 (void *)&cmd_flow_director_queue,
11246 (void *)&cmd_flow_director_queue_id,
11247 (void *)&cmd_flow_director_fd_id,
11248 (void *)&cmd_flow_director_fd_id_value,
11253 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11254 .f = cmd_flow_director_filter_parsed,
11256 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11257 "director entry on NIC",
11259 (void *)&cmd_flow_director_filter,
11260 (void *)&cmd_flow_director_port_id,
11261 (void *)&cmd_flow_director_mode,
11262 (void *)&cmd_flow_director_mode_ip,
11263 (void *)&cmd_flow_director_ops,
11264 (void *)&cmd_flow_director_flow,
11265 (void *)&cmd_flow_director_flow_type,
11266 (void *)&cmd_flow_director_ether,
11267 (void *)&cmd_flow_director_ether_type,
11268 (void *)&cmd_flow_director_flexbytes,
11269 (void *)&cmd_flow_director_flexbytes_value,
11270 (void *)&cmd_flow_director_drop,
11271 (void *)&cmd_flow_director_pf_vf,
11272 (void *)&cmd_flow_director_queue,
11273 (void *)&cmd_flow_director_queue_id,
11274 (void *)&cmd_flow_director_fd_id,
11275 (void *)&cmd_flow_director_fd_id_value,
11280 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11281 .f = cmd_flow_director_filter_parsed,
11283 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11284 "director entry on NIC",
11286 (void *)&cmd_flow_director_filter,
11287 (void *)&cmd_flow_director_port_id,
11288 (void *)&cmd_flow_director_mode,
11289 (void *)&cmd_flow_director_mode_mac_vlan,
11290 (void *)&cmd_flow_director_ops,
11291 (void *)&cmd_flow_director_mac,
11292 (void *)&cmd_flow_director_mac_addr,
11293 (void *)&cmd_flow_director_vlan,
11294 (void *)&cmd_flow_director_vlan_value,
11295 (void *)&cmd_flow_director_flexbytes,
11296 (void *)&cmd_flow_director_flexbytes_value,
11297 (void *)&cmd_flow_director_drop,
11298 (void *)&cmd_flow_director_queue,
11299 (void *)&cmd_flow_director_queue_id,
11300 (void *)&cmd_flow_director_fd_id,
11301 (void *)&cmd_flow_director_fd_id_value,
11306 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11307 .f = cmd_flow_director_filter_parsed,
11309 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11310 "director entry on NIC",
11312 (void *)&cmd_flow_director_filter,
11313 (void *)&cmd_flow_director_port_id,
11314 (void *)&cmd_flow_director_mode,
11315 (void *)&cmd_flow_director_mode_tunnel,
11316 (void *)&cmd_flow_director_ops,
11317 (void *)&cmd_flow_director_mac,
11318 (void *)&cmd_flow_director_mac_addr,
11319 (void *)&cmd_flow_director_vlan,
11320 (void *)&cmd_flow_director_vlan_value,
11321 (void *)&cmd_flow_director_tunnel,
11322 (void *)&cmd_flow_director_tunnel_type,
11323 (void *)&cmd_flow_director_tunnel_id,
11324 (void *)&cmd_flow_director_tunnel_id_value,
11325 (void *)&cmd_flow_director_flexbytes,
11326 (void *)&cmd_flow_director_flexbytes_value,
11327 (void *)&cmd_flow_director_drop,
11328 (void *)&cmd_flow_director_queue,
11329 (void *)&cmd_flow_director_queue_id,
11330 (void *)&cmd_flow_director_fd_id,
11331 (void *)&cmd_flow_director_fd_id_value,
11336 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11337 .f = cmd_flow_director_filter_parsed,
11339 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11340 "director entry on NIC",
11342 (void *)&cmd_flow_director_filter,
11343 (void *)&cmd_flow_director_port_id,
11344 (void *)&cmd_flow_director_mode,
11345 (void *)&cmd_flow_director_mode_raw,
11346 (void *)&cmd_flow_director_ops,
11347 (void *)&cmd_flow_director_flow,
11348 (void *)&cmd_flow_director_flow_type,
11349 (void *)&cmd_flow_director_drop,
11350 (void *)&cmd_flow_director_queue,
11351 (void *)&cmd_flow_director_queue_id,
11352 (void *)&cmd_flow_director_fd_id,
11353 (void *)&cmd_flow_director_fd_id_value,
11354 (void *)&cmd_flow_director_packet,
11355 (void *)&cmd_flow_director_filepath,
11360 struct cmd_flush_flow_director_result {
11361 cmdline_fixed_string_t flush_flow_director;
11365 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11366 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11367 flush_flow_director, "flush_flow_director");
11368 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11369 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11373 cmd_flush_flow_director_parsed(void *parsed_result,
11374 __attribute__((unused)) struct cmdline *cl,
11375 __attribute__((unused)) void *data)
11377 struct cmd_flow_director_result *res = parsed_result;
11380 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11382 printf("flow director is not supported on port %u.\n",
11387 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11388 RTE_ETH_FILTER_FLUSH, NULL);
11390 printf("flow director table flushing error: (%s)\n",
11394 cmdline_parse_inst_t cmd_flush_flow_director = {
11395 .f = cmd_flush_flow_director_parsed,
11397 .help_str = "flush_flow_director <port_id>: "
11398 "Flush all flow director entries of a device on NIC",
11400 (void *)&cmd_flush_flow_director_flush,
11401 (void *)&cmd_flush_flow_director_port_id,
11406 /* *** deal with flow director mask *** */
11407 struct cmd_flow_director_mask_result {
11408 cmdline_fixed_string_t flow_director_mask;
11410 cmdline_fixed_string_t mode;
11411 cmdline_fixed_string_t mode_value;
11412 cmdline_fixed_string_t vlan;
11413 uint16_t vlan_mask;
11414 cmdline_fixed_string_t src_mask;
11415 cmdline_ipaddr_t ipv4_src;
11416 cmdline_ipaddr_t ipv6_src;
11418 cmdline_fixed_string_t dst_mask;
11419 cmdline_ipaddr_t ipv4_dst;
11420 cmdline_ipaddr_t ipv6_dst;
11422 cmdline_fixed_string_t mac;
11423 uint8_t mac_addr_byte_mask;
11424 cmdline_fixed_string_t tunnel_id;
11425 uint32_t tunnel_id_mask;
11426 cmdline_fixed_string_t tunnel_type;
11427 uint8_t tunnel_type_mask;
11431 cmd_flow_director_mask_parsed(void *parsed_result,
11432 __attribute__((unused)) struct cmdline *cl,
11433 __attribute__((unused)) void *data)
11435 struct cmd_flow_director_mask_result *res = parsed_result;
11436 struct rte_eth_fdir_masks *mask;
11437 struct rte_port *port;
11439 port = &ports[res->port_id];
11440 /** Check if the port is not started **/
11441 if (port->port_status != RTE_PORT_STOPPED) {
11442 printf("Please stop port %d first\n", res->port_id);
11446 mask = &port->dev_conf.fdir_conf.mask;
11448 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11449 if (strcmp(res->mode_value, "MAC-VLAN")) {
11450 printf("Please set mode to MAC-VLAN.\n");
11454 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11455 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11456 if (strcmp(res->mode_value, "Tunnel")) {
11457 printf("Please set mode to Tunnel.\n");
11461 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11462 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11463 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11464 mask->tunnel_type_mask = res->tunnel_type_mask;
11466 if (strcmp(res->mode_value, "IP")) {
11467 printf("Please set mode to IP.\n");
11471 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11472 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11473 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11474 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11475 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11476 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11477 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11480 cmd_reconfig_device_queue(res->port_id, 1, 1);
11483 cmdline_parse_token_string_t cmd_flow_director_mask =
11484 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11485 flow_director_mask, "flow_director_mask");
11486 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11487 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11489 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11490 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11492 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11493 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11494 vlan_mask, UINT16);
11495 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11496 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11497 src_mask, "src_mask");
11498 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11499 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11501 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11502 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11504 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11505 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11507 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11508 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11509 dst_mask, "dst_mask");
11510 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11511 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11513 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11514 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11516 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11517 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11520 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11523 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11524 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11526 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11527 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11528 mode_value, "MAC-VLAN");
11529 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11530 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11531 mode_value, "Tunnel");
11532 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11533 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11535 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11536 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11537 mac_addr_byte_mask, UINT8);
11538 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11539 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11540 tunnel_type, "tunnel-type");
11541 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11542 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11543 tunnel_type_mask, UINT8);
11544 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11546 tunnel_id, "tunnel-id");
11547 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11548 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11549 tunnel_id_mask, UINT32);
11551 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11552 .f = cmd_flow_director_mask_parsed,
11554 .help_str = "flow_director_mask ... : "
11555 "Set IP mode flow director's mask on NIC",
11557 (void *)&cmd_flow_director_mask,
11558 (void *)&cmd_flow_director_mask_port_id,
11559 (void *)&cmd_flow_director_mask_mode,
11560 (void *)&cmd_flow_director_mask_mode_ip,
11561 (void *)&cmd_flow_director_mask_vlan,
11562 (void *)&cmd_flow_director_mask_vlan_value,
11563 (void *)&cmd_flow_director_mask_src,
11564 (void *)&cmd_flow_director_mask_ipv4_src,
11565 (void *)&cmd_flow_director_mask_ipv6_src,
11566 (void *)&cmd_flow_director_mask_port_src,
11567 (void *)&cmd_flow_director_mask_dst,
11568 (void *)&cmd_flow_director_mask_ipv4_dst,
11569 (void *)&cmd_flow_director_mask_ipv6_dst,
11570 (void *)&cmd_flow_director_mask_port_dst,
11575 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11576 .f = cmd_flow_director_mask_parsed,
11578 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11579 "flow director's mask on NIC",
11581 (void *)&cmd_flow_director_mask,
11582 (void *)&cmd_flow_director_mask_port_id,
11583 (void *)&cmd_flow_director_mask_mode,
11584 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11585 (void *)&cmd_flow_director_mask_vlan,
11586 (void *)&cmd_flow_director_mask_vlan_value,
11591 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11592 .f = cmd_flow_director_mask_parsed,
11594 .help_str = "flow_director_mask ... : Set tunnel mode "
11595 "flow director's mask on NIC",
11597 (void *)&cmd_flow_director_mask,
11598 (void *)&cmd_flow_director_mask_port_id,
11599 (void *)&cmd_flow_director_mask_mode,
11600 (void *)&cmd_flow_director_mask_mode_tunnel,
11601 (void *)&cmd_flow_director_mask_vlan,
11602 (void *)&cmd_flow_director_mask_vlan_value,
11603 (void *)&cmd_flow_director_mask_mac,
11604 (void *)&cmd_flow_director_mask_mac_value,
11605 (void *)&cmd_flow_director_mask_tunnel_type,
11606 (void *)&cmd_flow_director_mask_tunnel_type_value,
11607 (void *)&cmd_flow_director_mask_tunnel_id,
11608 (void *)&cmd_flow_director_mask_tunnel_id_value,
11613 /* *** deal with flow director mask on flexible payload *** */
11614 struct cmd_flow_director_flex_mask_result {
11615 cmdline_fixed_string_t flow_director_flexmask;
11617 cmdline_fixed_string_t flow;
11618 cmdline_fixed_string_t flow_type;
11619 cmdline_fixed_string_t mask;
11623 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11624 __attribute__((unused)) struct cmdline *cl,
11625 __attribute__((unused)) void *data)
11627 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11628 struct rte_eth_fdir_info fdir_info;
11629 struct rte_eth_fdir_flex_mask flex_mask;
11630 struct rte_port *port;
11631 uint64_t flow_type_mask;
11635 port = &ports[res->port_id];
11636 /** Check if the port is not started **/
11637 if (port->port_status != RTE_PORT_STOPPED) {
11638 printf("Please stop port %d first\n", res->port_id);
11642 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11643 ret = parse_flexbytes(res->mask,
11645 RTE_ETH_FDIR_MAX_FLEXLEN);
11647 printf("error: Cannot parse mask input.\n");
11651 memset(&fdir_info, 0, sizeof(fdir_info));
11652 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11653 RTE_ETH_FILTER_INFO, &fdir_info);
11655 printf("Cannot get FDir filter info\n");
11659 if (!strcmp(res->flow_type, "none")) {
11660 /* means don't specify the flow type */
11661 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11662 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11663 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11664 0, sizeof(struct rte_eth_fdir_flex_mask));
11665 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11666 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11668 sizeof(struct rte_eth_fdir_flex_mask));
11669 cmd_reconfig_device_queue(res->port_id, 1, 1);
11672 flow_type_mask = fdir_info.flow_types_mask[0];
11673 if (!strcmp(res->flow_type, "all")) {
11674 if (!flow_type_mask) {
11675 printf("No flow type supported\n");
11678 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11679 if (flow_type_mask & (1ULL << i)) {
11680 flex_mask.flow_type = i;
11681 fdir_set_flex_mask(res->port_id, &flex_mask);
11684 cmd_reconfig_device_queue(res->port_id, 1, 1);
11687 flex_mask.flow_type = str2flowtype(res->flow_type);
11688 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11689 printf("Flow type %s not supported on port %d\n",
11690 res->flow_type, res->port_id);
11693 fdir_set_flex_mask(res->port_id, &flex_mask);
11694 cmd_reconfig_device_queue(res->port_id, 1, 1);
11697 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11698 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11699 flow_director_flexmask,
11700 "flow_director_flex_mask");
11701 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11702 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11704 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11707 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11709 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11710 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11711 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11712 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11715 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11716 .f = cmd_flow_director_flex_mask_parsed,
11718 .help_str = "flow_director_flex_mask ... : "
11719 "Set flow director's flex mask on NIC",
11721 (void *)&cmd_flow_director_flexmask,
11722 (void *)&cmd_flow_director_flexmask_port_id,
11723 (void *)&cmd_flow_director_flexmask_flow,
11724 (void *)&cmd_flow_director_flexmask_flow_type,
11725 (void *)&cmd_flow_director_flexmask_mask,
11730 /* *** deal with flow director flexible payload configuration *** */
11731 struct cmd_flow_director_flexpayload_result {
11732 cmdline_fixed_string_t flow_director_flexpayload;
11734 cmdline_fixed_string_t payload_layer;
11735 cmdline_fixed_string_t payload_cfg;
11739 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11742 const char *p, *p0 = q_arg;
11744 unsigned long int_fld;
11745 char *str_fld[max_num];
11750 p = strchr(p0, '(');
11754 p0 = strchr(p, ')');
11759 if (size >= sizeof(s))
11762 snprintf(s, sizeof(s), "%.*s", size, p);
11763 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11764 if (ret < 0 || ret > max_num)
11766 for (i = 0; i < ret; i++) {
11768 int_fld = strtoul(str_fld[i], &end, 0);
11769 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11771 offsets[i] = (uint16_t)int_fld;
11777 cmd_flow_director_flxpld_parsed(void *parsed_result,
11778 __attribute__((unused)) struct cmdline *cl,
11779 __attribute__((unused)) void *data)
11781 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11782 struct rte_eth_flex_payload_cfg flex_cfg;
11783 struct rte_port *port;
11786 port = &ports[res->port_id];
11787 /** Check if the port is not started **/
11788 if (port->port_status != RTE_PORT_STOPPED) {
11789 printf("Please stop port %d first\n", res->port_id);
11793 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11795 if (!strcmp(res->payload_layer, "raw"))
11796 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11797 else if (!strcmp(res->payload_layer, "l2"))
11798 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11799 else if (!strcmp(res->payload_layer, "l3"))
11800 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11801 else if (!strcmp(res->payload_layer, "l4"))
11802 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11804 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11805 RTE_ETH_FDIR_MAX_FLEXLEN);
11807 printf("error: Cannot parse flex payload input.\n");
11811 fdir_set_flex_payload(res->port_id, &flex_cfg);
11812 cmd_reconfig_device_queue(res->port_id, 1, 1);
11815 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11817 flow_director_flexpayload,
11818 "flow_director_flex_payload");
11819 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11820 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11822 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11824 payload_layer, "raw#l2#l3#l4");
11825 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11827 payload_cfg, NULL);
11829 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11830 .f = cmd_flow_director_flxpld_parsed,
11832 .help_str = "flow_director_flexpayload ... : "
11833 "Set flow director's flex payload on NIC",
11835 (void *)&cmd_flow_director_flexpayload,
11836 (void *)&cmd_flow_director_flexpayload_port_id,
11837 (void *)&cmd_flow_director_flexpayload_payload_layer,
11838 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11843 /* Generic flow interface command. */
11844 extern cmdline_parse_inst_t cmd_flow;
11846 /* *** Classification Filters Control *** */
11847 /* *** Get symmetric hash enable per port *** */
11848 struct cmd_get_sym_hash_ena_per_port_result {
11849 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11854 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11855 __rte_unused struct cmdline *cl,
11856 __rte_unused void *data)
11858 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11859 struct rte_eth_hash_filter_info info;
11862 if (rte_eth_dev_filter_supported(res->port_id,
11863 RTE_ETH_FILTER_HASH) < 0) {
11864 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11869 memset(&info, 0, sizeof(info));
11870 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11871 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11872 RTE_ETH_FILTER_GET, &info);
11875 printf("Cannot get symmetric hash enable per port "
11876 "on port %u\n", res->port_id);
11880 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11881 "enabled" : "disabled", res->port_id);
11884 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11885 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11886 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11887 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11888 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11891 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11892 .f = cmd_get_sym_hash_per_port_parsed,
11894 .help_str = "get_sym_hash_ena_per_port <port_id>",
11896 (void *)&cmd_get_sym_hash_ena_per_port_all,
11897 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11902 /* *** Set symmetric hash enable per port *** */
11903 struct cmd_set_sym_hash_ena_per_port_result {
11904 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11905 cmdline_fixed_string_t enable;
11910 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11911 __rte_unused struct cmdline *cl,
11912 __rte_unused void *data)
11914 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11915 struct rte_eth_hash_filter_info info;
11918 if (rte_eth_dev_filter_supported(res->port_id,
11919 RTE_ETH_FILTER_HASH) < 0) {
11920 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11925 memset(&info, 0, sizeof(info));
11926 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11927 if (!strcmp(res->enable, "enable"))
11928 info.info.enable = 1;
11929 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11930 RTE_ETH_FILTER_SET, &info);
11932 printf("Cannot set symmetric hash enable per port on "
11933 "port %u\n", res->port_id);
11936 printf("Symmetric hash has been set to %s on port %u\n",
11937 res->enable, res->port_id);
11940 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11941 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11942 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11943 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11944 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11946 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11947 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11948 enable, "enable#disable");
11950 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11951 .f = cmd_set_sym_hash_per_port_parsed,
11953 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11955 (void *)&cmd_set_sym_hash_ena_per_port_all,
11956 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11957 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11962 /* Get global config of hash function */
11963 struct cmd_get_hash_global_config_result {
11964 cmdline_fixed_string_t get_hash_global_config;
11969 flowtype_to_str(uint16_t ftype)
11975 } ftype_table[] = {
11976 {"ipv4", RTE_ETH_FLOW_IPV4},
11977 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11978 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11979 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11980 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11981 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11982 {"ipv6", RTE_ETH_FLOW_IPV6},
11983 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11984 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11985 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11986 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11987 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11988 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11989 {"port", RTE_ETH_FLOW_PORT},
11990 {"vxlan", RTE_ETH_FLOW_VXLAN},
11991 {"geneve", RTE_ETH_FLOW_GENEVE},
11992 {"nvgre", RTE_ETH_FLOW_NVGRE},
11993 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
11996 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11997 if (ftype_table[i].ftype == ftype)
11998 return ftype_table[i].str;
12005 cmd_get_hash_global_config_parsed(void *parsed_result,
12006 __rte_unused struct cmdline *cl,
12007 __rte_unused void *data)
12009 struct cmd_get_hash_global_config_result *res = parsed_result;
12010 struct rte_eth_hash_filter_info info;
12011 uint32_t idx, offset;
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_GLOBAL_CONFIG;
12025 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12026 RTE_ETH_FILTER_GET, &info);
12028 printf("Cannot get hash global configurations by port %d\n",
12033 switch (info.info.global_conf.hash_func) {
12034 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12035 printf("Hash function is Toeplitz\n");
12037 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12038 printf("Hash function is Simple XOR\n");
12041 printf("Unknown hash function\n");
12045 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12046 idx = i / UINT64_BIT;
12047 offset = i % UINT64_BIT;
12048 if (!(info.info.global_conf.valid_bit_mask[idx] &
12051 str = flowtype_to_str(i);
12054 printf("Symmetric hash is %s globally for flow type %s "
12056 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12057 (1ULL << offset)) ? "enabled" : "disabled"), str,
12062 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12063 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12064 get_hash_global_config, "get_hash_global_config");
12065 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12066 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12069 cmdline_parse_inst_t cmd_get_hash_global_config = {
12070 .f = cmd_get_hash_global_config_parsed,
12072 .help_str = "get_hash_global_config <port_id>",
12074 (void *)&cmd_get_hash_global_config_all,
12075 (void *)&cmd_get_hash_global_config_port_id,
12080 /* Set global config of hash function */
12081 struct cmd_set_hash_global_config_result {
12082 cmdline_fixed_string_t set_hash_global_config;
12084 cmdline_fixed_string_t hash_func;
12085 cmdline_fixed_string_t flow_type;
12086 cmdline_fixed_string_t enable;
12090 cmd_set_hash_global_config_parsed(void *parsed_result,
12091 __rte_unused struct cmdline *cl,
12092 __rte_unused void *data)
12094 struct cmd_set_hash_global_config_result *res = parsed_result;
12095 struct rte_eth_hash_filter_info info;
12096 uint32_t ftype, idx, offset;
12099 if (rte_eth_dev_filter_supported(res->port_id,
12100 RTE_ETH_FILTER_HASH) < 0) {
12101 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12105 memset(&info, 0, sizeof(info));
12106 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12107 if (!strcmp(res->hash_func, "toeplitz"))
12108 info.info.global_conf.hash_func =
12109 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12110 else if (!strcmp(res->hash_func, "simple_xor"))
12111 info.info.global_conf.hash_func =
12112 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12113 else if (!strcmp(res->hash_func, "default"))
12114 info.info.global_conf.hash_func =
12115 RTE_ETH_HASH_FUNCTION_DEFAULT;
12117 ftype = str2flowtype(res->flow_type);
12118 idx = ftype / UINT64_BIT;
12119 offset = ftype % UINT64_BIT;
12120 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12121 if (!strcmp(res->enable, "enable"))
12122 info.info.global_conf.sym_hash_enable_mask[idx] |=
12124 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12125 RTE_ETH_FILTER_SET, &info);
12127 printf("Cannot set global hash configurations by port %d\n",
12130 printf("Global hash configurations have been set "
12131 "successfully by port %d\n", res->port_id);
12134 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12135 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12136 set_hash_global_config, "set_hash_global_config");
12137 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12138 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12140 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12141 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12142 hash_func, "toeplitz#simple_xor#default");
12143 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12144 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12146 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12147 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12148 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12149 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12150 enable, "enable#disable");
12152 cmdline_parse_inst_t cmd_set_hash_global_config = {
12153 .f = cmd_set_hash_global_config_parsed,
12155 .help_str = "set_hash_global_config <port_id> "
12156 "toeplitz|simple_xor|default "
12157 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12158 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12159 "l2_payload enable|disable",
12161 (void *)&cmd_set_hash_global_config_all,
12162 (void *)&cmd_set_hash_global_config_port_id,
12163 (void *)&cmd_set_hash_global_config_hash_func,
12164 (void *)&cmd_set_hash_global_config_flow_type,
12165 (void *)&cmd_set_hash_global_config_enable,
12170 /* Set hash input set */
12171 struct cmd_set_hash_input_set_result {
12172 cmdline_fixed_string_t set_hash_input_set;
12174 cmdline_fixed_string_t flow_type;
12175 cmdline_fixed_string_t inset_field;
12176 cmdline_fixed_string_t select;
12179 static enum rte_eth_input_set_field
12180 str2inset(char *string)
12184 static const struct {
12186 enum rte_eth_input_set_field inset;
12187 } inset_table[] = {
12188 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12189 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12190 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12191 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12192 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12193 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12194 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12195 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12196 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12197 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12198 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12199 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12200 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12201 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12202 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12203 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12204 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12205 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12206 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12207 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12208 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12209 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12210 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12211 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12212 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12213 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12214 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12215 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12216 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12217 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12218 {"none", RTE_ETH_INPUT_SET_NONE},
12221 for (i = 0; i < RTE_DIM(inset_table); i++) {
12222 if (!strcmp(string, inset_table[i].str))
12223 return inset_table[i].inset;
12226 return RTE_ETH_INPUT_SET_UNKNOWN;
12230 cmd_set_hash_input_set_parsed(void *parsed_result,
12231 __rte_unused struct cmdline *cl,
12232 __rte_unused void *data)
12234 struct cmd_set_hash_input_set_result *res = parsed_result;
12235 struct rte_eth_hash_filter_info info;
12237 memset(&info, 0, sizeof(info));
12238 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12239 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12240 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12241 info.info.input_set_conf.inset_size = 1;
12242 if (!strcmp(res->select, "select"))
12243 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12244 else if (!strcmp(res->select, "add"))
12245 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12246 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12247 RTE_ETH_FILTER_SET, &info);
12250 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12251 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12252 set_hash_input_set, "set_hash_input_set");
12253 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12254 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12256 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12257 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12259 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12260 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12262 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12263 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12264 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12265 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12266 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12268 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12269 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12270 select, "select#add");
12272 cmdline_parse_inst_t cmd_set_hash_input_set = {
12273 .f = cmd_set_hash_input_set_parsed,
12275 .help_str = "set_hash_input_set <port_id> "
12276 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12277 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12278 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12279 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12280 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12281 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12282 "fld-7th|fld-8th|none select|add",
12284 (void *)&cmd_set_hash_input_set_cmd,
12285 (void *)&cmd_set_hash_input_set_port_id,
12286 (void *)&cmd_set_hash_input_set_flow_type,
12287 (void *)&cmd_set_hash_input_set_field,
12288 (void *)&cmd_set_hash_input_set_select,
12293 /* Set flow director input set */
12294 struct cmd_set_fdir_input_set_result {
12295 cmdline_fixed_string_t set_fdir_input_set;
12297 cmdline_fixed_string_t flow_type;
12298 cmdline_fixed_string_t inset_field;
12299 cmdline_fixed_string_t select;
12303 cmd_set_fdir_input_set_parsed(void *parsed_result,
12304 __rte_unused struct cmdline *cl,
12305 __rte_unused void *data)
12307 struct cmd_set_fdir_input_set_result *res = parsed_result;
12308 struct rte_eth_fdir_filter_info info;
12310 memset(&info, 0, sizeof(info));
12311 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12312 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12313 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12314 info.info.input_set_conf.inset_size = 1;
12315 if (!strcmp(res->select, "select"))
12316 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12317 else if (!strcmp(res->select, "add"))
12318 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12319 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12320 RTE_ETH_FILTER_SET, &info);
12323 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12324 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12325 set_fdir_input_set, "set_fdir_input_set");
12326 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12327 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12329 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12330 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12332 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12333 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12334 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12335 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12337 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12338 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12339 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12340 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12341 "sctp-veri-tag#none");
12342 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12343 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12344 select, "select#add");
12346 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12347 .f = cmd_set_fdir_input_set_parsed,
12349 .help_str = "set_fdir_input_set <port_id> "
12350 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12351 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12352 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12353 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12354 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12355 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12356 "sctp-veri-tag|none select|add",
12358 (void *)&cmd_set_fdir_input_set_cmd,
12359 (void *)&cmd_set_fdir_input_set_port_id,
12360 (void *)&cmd_set_fdir_input_set_flow_type,
12361 (void *)&cmd_set_fdir_input_set_field,
12362 (void *)&cmd_set_fdir_input_set_select,
12367 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12368 struct cmd_mcast_addr_result {
12369 cmdline_fixed_string_t mcast_addr_cmd;
12370 cmdline_fixed_string_t what;
12372 struct ether_addr mc_addr;
12375 static void cmd_mcast_addr_parsed(void *parsed_result,
12376 __attribute__((unused)) struct cmdline *cl,
12377 __attribute__((unused)) void *data)
12379 struct cmd_mcast_addr_result *res = parsed_result;
12381 if (!is_multicast_ether_addr(&res->mc_addr)) {
12382 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12383 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12384 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12385 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12388 if (strcmp(res->what, "add") == 0)
12389 mcast_addr_add(res->port_num, &res->mc_addr);
12391 mcast_addr_remove(res->port_num, &res->mc_addr);
12394 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12395 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12396 mcast_addr_cmd, "mcast_addr");
12397 cmdline_parse_token_string_t cmd_mcast_addr_what =
12398 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12400 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12401 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12402 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12403 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12405 cmdline_parse_inst_t cmd_mcast_addr = {
12406 .f = cmd_mcast_addr_parsed,
12408 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12409 "Add/Remove multicast MAC address on port_id",
12411 (void *)&cmd_mcast_addr_cmd,
12412 (void *)&cmd_mcast_addr_what,
12413 (void *)&cmd_mcast_addr_portnum,
12414 (void *)&cmd_mcast_addr_addr,
12419 /* l2 tunnel config
12420 * only support E-tag now.
12423 /* Ether type config */
12424 struct cmd_config_l2_tunnel_eth_type_result {
12425 cmdline_fixed_string_t port;
12426 cmdline_fixed_string_t config;
12427 cmdline_fixed_string_t all;
12429 cmdline_fixed_string_t l2_tunnel;
12430 cmdline_fixed_string_t l2_tunnel_type;
12431 cmdline_fixed_string_t eth_type;
12432 uint16_t eth_type_val;
12435 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12436 TOKEN_STRING_INITIALIZER
12437 (struct cmd_config_l2_tunnel_eth_type_result,
12439 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12440 TOKEN_STRING_INITIALIZER
12441 (struct cmd_config_l2_tunnel_eth_type_result,
12443 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12444 TOKEN_STRING_INITIALIZER
12445 (struct cmd_config_l2_tunnel_eth_type_result,
12447 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12448 TOKEN_NUM_INITIALIZER
12449 (struct cmd_config_l2_tunnel_eth_type_result,
12451 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12452 TOKEN_STRING_INITIALIZER
12453 (struct cmd_config_l2_tunnel_eth_type_result,
12454 l2_tunnel, "l2-tunnel");
12455 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12456 TOKEN_STRING_INITIALIZER
12457 (struct cmd_config_l2_tunnel_eth_type_result,
12458 l2_tunnel_type, "E-tag");
12459 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12460 TOKEN_STRING_INITIALIZER
12461 (struct cmd_config_l2_tunnel_eth_type_result,
12462 eth_type, "ether-type");
12463 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12464 TOKEN_NUM_INITIALIZER
12465 (struct cmd_config_l2_tunnel_eth_type_result,
12466 eth_type_val, UINT16);
12468 static enum rte_eth_tunnel_type
12469 str2fdir_l2_tunnel_type(char *string)
12473 static const struct {
12475 enum rte_eth_tunnel_type type;
12476 } l2_tunnel_type_str[] = {
12477 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12480 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12481 if (!strcmp(l2_tunnel_type_str[i].str, string))
12482 return l2_tunnel_type_str[i].type;
12484 return RTE_TUNNEL_TYPE_NONE;
12487 /* ether type config for all ports */
12489 cmd_config_l2_tunnel_eth_type_all_parsed
12490 (void *parsed_result,
12491 __attribute__((unused)) struct cmdline *cl,
12492 __attribute__((unused)) void *data)
12494 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12495 struct rte_eth_l2_tunnel_conf entry;
12498 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12499 entry.ether_type = res->eth_type_val;
12501 RTE_ETH_FOREACH_DEV(pid) {
12502 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12506 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12507 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12509 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12511 (void *)&cmd_config_l2_tunnel_eth_type_port,
12512 (void *)&cmd_config_l2_tunnel_eth_type_config,
12513 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12514 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12515 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12516 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12517 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12522 /* ether type config for a specific port */
12524 cmd_config_l2_tunnel_eth_type_specific_parsed(
12525 void *parsed_result,
12526 __attribute__((unused)) struct cmdline *cl,
12527 __attribute__((unused)) void *data)
12529 struct cmd_config_l2_tunnel_eth_type_result *res =
12531 struct rte_eth_l2_tunnel_conf entry;
12533 if (port_id_is_invalid(res->id, ENABLED_WARN))
12536 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12537 entry.ether_type = res->eth_type_val;
12539 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12542 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12543 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12545 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12547 (void *)&cmd_config_l2_tunnel_eth_type_port,
12548 (void *)&cmd_config_l2_tunnel_eth_type_config,
12549 (void *)&cmd_config_l2_tunnel_eth_type_id,
12550 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12551 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12552 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12553 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12558 /* Enable/disable l2 tunnel */
12559 struct cmd_config_l2_tunnel_en_dis_result {
12560 cmdline_fixed_string_t port;
12561 cmdline_fixed_string_t config;
12562 cmdline_fixed_string_t all;
12564 cmdline_fixed_string_t l2_tunnel;
12565 cmdline_fixed_string_t l2_tunnel_type;
12566 cmdline_fixed_string_t en_dis;
12569 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12570 TOKEN_STRING_INITIALIZER
12571 (struct cmd_config_l2_tunnel_en_dis_result,
12573 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12574 TOKEN_STRING_INITIALIZER
12575 (struct cmd_config_l2_tunnel_en_dis_result,
12577 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12578 TOKEN_STRING_INITIALIZER
12579 (struct cmd_config_l2_tunnel_en_dis_result,
12581 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12582 TOKEN_NUM_INITIALIZER
12583 (struct cmd_config_l2_tunnel_en_dis_result,
12585 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12586 TOKEN_STRING_INITIALIZER
12587 (struct cmd_config_l2_tunnel_en_dis_result,
12588 l2_tunnel, "l2-tunnel");
12589 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12590 TOKEN_STRING_INITIALIZER
12591 (struct cmd_config_l2_tunnel_en_dis_result,
12592 l2_tunnel_type, "E-tag");
12593 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12594 TOKEN_STRING_INITIALIZER
12595 (struct cmd_config_l2_tunnel_en_dis_result,
12596 en_dis, "enable#disable");
12598 /* enable/disable l2 tunnel for all ports */
12600 cmd_config_l2_tunnel_en_dis_all_parsed(
12601 void *parsed_result,
12602 __attribute__((unused)) struct cmdline *cl,
12603 __attribute__((unused)) void *data)
12605 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12606 struct rte_eth_l2_tunnel_conf entry;
12610 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12612 if (!strcmp("enable", res->en_dis))
12617 RTE_ETH_FOREACH_DEV(pid) {
12618 rte_eth_dev_l2_tunnel_offload_set(pid,
12620 ETH_L2_TUNNEL_ENABLE_MASK,
12625 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12626 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12628 .help_str = "port config all l2-tunnel E-tag enable|disable",
12630 (void *)&cmd_config_l2_tunnel_en_dis_port,
12631 (void *)&cmd_config_l2_tunnel_en_dis_config,
12632 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12633 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12634 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12635 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12640 /* enable/disable l2 tunnel for a port */
12642 cmd_config_l2_tunnel_en_dis_specific_parsed(
12643 void *parsed_result,
12644 __attribute__((unused)) struct cmdline *cl,
12645 __attribute__((unused)) void *data)
12647 struct cmd_config_l2_tunnel_en_dis_result *res =
12649 struct rte_eth_l2_tunnel_conf entry;
12651 if (port_id_is_invalid(res->id, ENABLED_WARN))
12654 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12656 if (!strcmp("enable", res->en_dis))
12657 rte_eth_dev_l2_tunnel_offload_set(res->id,
12659 ETH_L2_TUNNEL_ENABLE_MASK,
12662 rte_eth_dev_l2_tunnel_offload_set(res->id,
12664 ETH_L2_TUNNEL_ENABLE_MASK,
12668 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12669 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12671 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12673 (void *)&cmd_config_l2_tunnel_en_dis_port,
12674 (void *)&cmd_config_l2_tunnel_en_dis_config,
12675 (void *)&cmd_config_l2_tunnel_en_dis_id,
12676 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12677 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12678 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12683 /* E-tag configuration */
12685 /* Common result structure for all E-tag configuration */
12686 struct cmd_config_e_tag_result {
12687 cmdline_fixed_string_t e_tag;
12688 cmdline_fixed_string_t set;
12689 cmdline_fixed_string_t insertion;
12690 cmdline_fixed_string_t stripping;
12691 cmdline_fixed_string_t forwarding;
12692 cmdline_fixed_string_t filter;
12693 cmdline_fixed_string_t add;
12694 cmdline_fixed_string_t del;
12695 cmdline_fixed_string_t on;
12696 cmdline_fixed_string_t off;
12697 cmdline_fixed_string_t on_off;
12698 cmdline_fixed_string_t port_tag_id;
12699 uint32_t port_tag_id_val;
12700 cmdline_fixed_string_t e_tag_id;
12701 uint16_t e_tag_id_val;
12702 cmdline_fixed_string_t dst_pool;
12703 uint8_t dst_pool_val;
12704 cmdline_fixed_string_t port;
12706 cmdline_fixed_string_t vf;
12710 /* Common CLI fields for all E-tag configuration */
12711 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12712 TOKEN_STRING_INITIALIZER
12713 (struct cmd_config_e_tag_result,
12715 cmdline_parse_token_string_t cmd_config_e_tag_set =
12716 TOKEN_STRING_INITIALIZER
12717 (struct cmd_config_e_tag_result,
12719 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12720 TOKEN_STRING_INITIALIZER
12721 (struct cmd_config_e_tag_result,
12722 insertion, "insertion");
12723 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12724 TOKEN_STRING_INITIALIZER
12725 (struct cmd_config_e_tag_result,
12726 stripping, "stripping");
12727 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12728 TOKEN_STRING_INITIALIZER
12729 (struct cmd_config_e_tag_result,
12730 forwarding, "forwarding");
12731 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12732 TOKEN_STRING_INITIALIZER
12733 (struct cmd_config_e_tag_result,
12735 cmdline_parse_token_string_t cmd_config_e_tag_add =
12736 TOKEN_STRING_INITIALIZER
12737 (struct cmd_config_e_tag_result,
12739 cmdline_parse_token_string_t cmd_config_e_tag_del =
12740 TOKEN_STRING_INITIALIZER
12741 (struct cmd_config_e_tag_result,
12743 cmdline_parse_token_string_t cmd_config_e_tag_on =
12744 TOKEN_STRING_INITIALIZER
12745 (struct cmd_config_e_tag_result,
12747 cmdline_parse_token_string_t cmd_config_e_tag_off =
12748 TOKEN_STRING_INITIALIZER
12749 (struct cmd_config_e_tag_result,
12751 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12752 TOKEN_STRING_INITIALIZER
12753 (struct cmd_config_e_tag_result,
12755 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12756 TOKEN_STRING_INITIALIZER
12757 (struct cmd_config_e_tag_result,
12758 port_tag_id, "port-tag-id");
12759 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12760 TOKEN_NUM_INITIALIZER
12761 (struct cmd_config_e_tag_result,
12762 port_tag_id_val, UINT32);
12763 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12764 TOKEN_STRING_INITIALIZER
12765 (struct cmd_config_e_tag_result,
12766 e_tag_id, "e-tag-id");
12767 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12768 TOKEN_NUM_INITIALIZER
12769 (struct cmd_config_e_tag_result,
12770 e_tag_id_val, UINT16);
12771 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12772 TOKEN_STRING_INITIALIZER
12773 (struct cmd_config_e_tag_result,
12774 dst_pool, "dst-pool");
12775 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12776 TOKEN_NUM_INITIALIZER
12777 (struct cmd_config_e_tag_result,
12778 dst_pool_val, UINT8);
12779 cmdline_parse_token_string_t cmd_config_e_tag_port =
12780 TOKEN_STRING_INITIALIZER
12781 (struct cmd_config_e_tag_result,
12783 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12784 TOKEN_NUM_INITIALIZER
12785 (struct cmd_config_e_tag_result,
12787 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12788 TOKEN_STRING_INITIALIZER
12789 (struct cmd_config_e_tag_result,
12791 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12792 TOKEN_NUM_INITIALIZER
12793 (struct cmd_config_e_tag_result,
12796 /* E-tag insertion configuration */
12798 cmd_config_e_tag_insertion_en_parsed(
12799 void *parsed_result,
12800 __attribute__((unused)) struct cmdline *cl,
12801 __attribute__((unused)) void *data)
12803 struct cmd_config_e_tag_result *res =
12805 struct rte_eth_l2_tunnel_conf entry;
12807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12810 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12811 entry.tunnel_id = res->port_tag_id_val;
12812 entry.vf_id = res->vf_id;
12813 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12815 ETH_L2_TUNNEL_INSERTION_MASK,
12820 cmd_config_e_tag_insertion_dis_parsed(
12821 void *parsed_result,
12822 __attribute__((unused)) struct cmdline *cl,
12823 __attribute__((unused)) void *data)
12825 struct cmd_config_e_tag_result *res =
12827 struct rte_eth_l2_tunnel_conf entry;
12829 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12832 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12833 entry.vf_id = res->vf_id;
12835 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12837 ETH_L2_TUNNEL_INSERTION_MASK,
12841 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12842 .f = cmd_config_e_tag_insertion_en_parsed,
12844 .help_str = "E-tag ... : E-tag insertion enable",
12846 (void *)&cmd_config_e_tag_e_tag,
12847 (void *)&cmd_config_e_tag_set,
12848 (void *)&cmd_config_e_tag_insertion,
12849 (void *)&cmd_config_e_tag_on,
12850 (void *)&cmd_config_e_tag_port_tag_id,
12851 (void *)&cmd_config_e_tag_port_tag_id_val,
12852 (void *)&cmd_config_e_tag_port,
12853 (void *)&cmd_config_e_tag_port_id,
12854 (void *)&cmd_config_e_tag_vf,
12855 (void *)&cmd_config_e_tag_vf_id,
12860 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12861 .f = cmd_config_e_tag_insertion_dis_parsed,
12863 .help_str = "E-tag ... : E-tag insertion disable",
12865 (void *)&cmd_config_e_tag_e_tag,
12866 (void *)&cmd_config_e_tag_set,
12867 (void *)&cmd_config_e_tag_insertion,
12868 (void *)&cmd_config_e_tag_off,
12869 (void *)&cmd_config_e_tag_port,
12870 (void *)&cmd_config_e_tag_port_id,
12871 (void *)&cmd_config_e_tag_vf,
12872 (void *)&cmd_config_e_tag_vf_id,
12877 /* E-tag stripping configuration */
12879 cmd_config_e_tag_stripping_parsed(
12880 void *parsed_result,
12881 __attribute__((unused)) struct cmdline *cl,
12882 __attribute__((unused)) void *data)
12884 struct cmd_config_e_tag_result *res =
12886 struct rte_eth_l2_tunnel_conf entry;
12888 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12891 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12893 if (!strcmp(res->on_off, "on"))
12894 rte_eth_dev_l2_tunnel_offload_set
12897 ETH_L2_TUNNEL_STRIPPING_MASK,
12900 rte_eth_dev_l2_tunnel_offload_set
12903 ETH_L2_TUNNEL_STRIPPING_MASK,
12907 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12908 .f = cmd_config_e_tag_stripping_parsed,
12910 .help_str = "E-tag ... : E-tag stripping enable/disable",
12912 (void *)&cmd_config_e_tag_e_tag,
12913 (void *)&cmd_config_e_tag_set,
12914 (void *)&cmd_config_e_tag_stripping,
12915 (void *)&cmd_config_e_tag_on_off,
12916 (void *)&cmd_config_e_tag_port,
12917 (void *)&cmd_config_e_tag_port_id,
12922 /* E-tag forwarding configuration */
12924 cmd_config_e_tag_forwarding_parsed(
12925 void *parsed_result,
12926 __attribute__((unused)) struct cmdline *cl,
12927 __attribute__((unused)) void *data)
12929 struct cmd_config_e_tag_result *res = parsed_result;
12930 struct rte_eth_l2_tunnel_conf entry;
12932 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12935 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12937 if (!strcmp(res->on_off, "on"))
12938 rte_eth_dev_l2_tunnel_offload_set
12941 ETH_L2_TUNNEL_FORWARDING_MASK,
12944 rte_eth_dev_l2_tunnel_offload_set
12947 ETH_L2_TUNNEL_FORWARDING_MASK,
12951 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12952 .f = cmd_config_e_tag_forwarding_parsed,
12954 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12956 (void *)&cmd_config_e_tag_e_tag,
12957 (void *)&cmd_config_e_tag_set,
12958 (void *)&cmd_config_e_tag_forwarding,
12959 (void *)&cmd_config_e_tag_on_off,
12960 (void *)&cmd_config_e_tag_port,
12961 (void *)&cmd_config_e_tag_port_id,
12966 /* E-tag filter configuration */
12968 cmd_config_e_tag_filter_add_parsed(
12969 void *parsed_result,
12970 __attribute__((unused)) struct cmdline *cl,
12971 __attribute__((unused)) void *data)
12973 struct cmd_config_e_tag_result *res = parsed_result;
12974 struct rte_eth_l2_tunnel_conf entry;
12977 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12980 if (res->e_tag_id_val > 0x3fff) {
12981 printf("e-tag-id must be equal or less than 0x3fff.\n");
12985 ret = rte_eth_dev_filter_supported(res->port_id,
12986 RTE_ETH_FILTER_L2_TUNNEL);
12988 printf("E-tag filter is not supported on port %u.\n",
12993 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12994 entry.tunnel_id = res->e_tag_id_val;
12995 entry.pool = res->dst_pool_val;
12997 ret = rte_eth_dev_filter_ctrl(res->port_id,
12998 RTE_ETH_FILTER_L2_TUNNEL,
12999 RTE_ETH_FILTER_ADD,
13002 printf("E-tag filter programming error: (%s)\n",
13006 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13007 .f = cmd_config_e_tag_filter_add_parsed,
13009 .help_str = "E-tag ... : E-tag filter add",
13011 (void *)&cmd_config_e_tag_e_tag,
13012 (void *)&cmd_config_e_tag_set,
13013 (void *)&cmd_config_e_tag_filter,
13014 (void *)&cmd_config_e_tag_add,
13015 (void *)&cmd_config_e_tag_e_tag_id,
13016 (void *)&cmd_config_e_tag_e_tag_id_val,
13017 (void *)&cmd_config_e_tag_dst_pool,
13018 (void *)&cmd_config_e_tag_dst_pool_val,
13019 (void *)&cmd_config_e_tag_port,
13020 (void *)&cmd_config_e_tag_port_id,
13026 cmd_config_e_tag_filter_del_parsed(
13027 void *parsed_result,
13028 __attribute__((unused)) struct cmdline *cl,
13029 __attribute__((unused)) void *data)
13031 struct cmd_config_e_tag_result *res = parsed_result;
13032 struct rte_eth_l2_tunnel_conf entry;
13035 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13038 if (res->e_tag_id_val > 0x3fff) {
13039 printf("e-tag-id must be less than 0x3fff.\n");
13043 ret = rte_eth_dev_filter_supported(res->port_id,
13044 RTE_ETH_FILTER_L2_TUNNEL);
13046 printf("E-tag filter is not supported on port %u.\n",
13051 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13052 entry.tunnel_id = res->e_tag_id_val;
13054 ret = rte_eth_dev_filter_ctrl(res->port_id,
13055 RTE_ETH_FILTER_L2_TUNNEL,
13056 RTE_ETH_FILTER_DELETE,
13059 printf("E-tag filter programming error: (%s)\n",
13063 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13064 .f = cmd_config_e_tag_filter_del_parsed,
13066 .help_str = "E-tag ... : E-tag filter delete",
13068 (void *)&cmd_config_e_tag_e_tag,
13069 (void *)&cmd_config_e_tag_set,
13070 (void *)&cmd_config_e_tag_filter,
13071 (void *)&cmd_config_e_tag_del,
13072 (void *)&cmd_config_e_tag_e_tag_id,
13073 (void *)&cmd_config_e_tag_e_tag_id_val,
13074 (void *)&cmd_config_e_tag_port,
13075 (void *)&cmd_config_e_tag_port_id,
13080 /* vf vlan anti spoof configuration */
13082 /* Common result structure for vf vlan anti spoof */
13083 struct cmd_vf_vlan_anti_spoof_result {
13084 cmdline_fixed_string_t set;
13085 cmdline_fixed_string_t vf;
13086 cmdline_fixed_string_t vlan;
13087 cmdline_fixed_string_t antispoof;
13090 cmdline_fixed_string_t on_off;
13093 /* Common CLI fields for vf vlan anti spoof enable disable */
13094 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13095 TOKEN_STRING_INITIALIZER
13096 (struct cmd_vf_vlan_anti_spoof_result,
13098 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13099 TOKEN_STRING_INITIALIZER
13100 (struct cmd_vf_vlan_anti_spoof_result,
13102 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13103 TOKEN_STRING_INITIALIZER
13104 (struct cmd_vf_vlan_anti_spoof_result,
13106 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13107 TOKEN_STRING_INITIALIZER
13108 (struct cmd_vf_vlan_anti_spoof_result,
13109 antispoof, "antispoof");
13110 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13111 TOKEN_NUM_INITIALIZER
13112 (struct cmd_vf_vlan_anti_spoof_result,
13114 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13115 TOKEN_NUM_INITIALIZER
13116 (struct cmd_vf_vlan_anti_spoof_result,
13118 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13119 TOKEN_STRING_INITIALIZER
13120 (struct cmd_vf_vlan_anti_spoof_result,
13124 cmd_set_vf_vlan_anti_spoof_parsed(
13125 void *parsed_result,
13126 __attribute__((unused)) struct cmdline *cl,
13127 __attribute__((unused)) void *data)
13129 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13130 int ret = -ENOTSUP;
13132 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13134 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13137 #ifdef RTE_LIBRTE_IXGBE_PMD
13138 if (ret == -ENOTSUP)
13139 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13140 res->vf_id, is_on);
13142 #ifdef RTE_LIBRTE_I40E_PMD
13143 if (ret == -ENOTSUP)
13144 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13145 res->vf_id, is_on);
13147 #ifdef RTE_LIBRTE_BNXT_PMD
13148 if (ret == -ENOTSUP)
13149 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13150 res->vf_id, is_on);
13157 printf("invalid vf_id %d\n", res->vf_id);
13160 printf("invalid port_id %d\n", res->port_id);
13163 printf("function not implemented\n");
13166 printf("programming error: (%s)\n", strerror(-ret));
13170 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13171 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13173 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13175 (void *)&cmd_vf_vlan_anti_spoof_set,
13176 (void *)&cmd_vf_vlan_anti_spoof_vf,
13177 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13178 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13179 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13180 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13181 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13186 /* vf mac anti spoof configuration */
13188 /* Common result structure for vf mac anti spoof */
13189 struct cmd_vf_mac_anti_spoof_result {
13190 cmdline_fixed_string_t set;
13191 cmdline_fixed_string_t vf;
13192 cmdline_fixed_string_t mac;
13193 cmdline_fixed_string_t antispoof;
13196 cmdline_fixed_string_t on_off;
13199 /* Common CLI fields for vf mac anti spoof enable disable */
13200 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13201 TOKEN_STRING_INITIALIZER
13202 (struct cmd_vf_mac_anti_spoof_result,
13204 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13205 TOKEN_STRING_INITIALIZER
13206 (struct cmd_vf_mac_anti_spoof_result,
13208 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13209 TOKEN_STRING_INITIALIZER
13210 (struct cmd_vf_mac_anti_spoof_result,
13212 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13213 TOKEN_STRING_INITIALIZER
13214 (struct cmd_vf_mac_anti_spoof_result,
13215 antispoof, "antispoof");
13216 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13217 TOKEN_NUM_INITIALIZER
13218 (struct cmd_vf_mac_anti_spoof_result,
13220 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13221 TOKEN_NUM_INITIALIZER
13222 (struct cmd_vf_mac_anti_spoof_result,
13224 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13225 TOKEN_STRING_INITIALIZER
13226 (struct cmd_vf_mac_anti_spoof_result,
13230 cmd_set_vf_mac_anti_spoof_parsed(
13231 void *parsed_result,
13232 __attribute__((unused)) struct cmdline *cl,
13233 __attribute__((unused)) void *data)
13235 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13236 int ret = -ENOTSUP;
13238 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13240 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13243 #ifdef RTE_LIBRTE_IXGBE_PMD
13244 if (ret == -ENOTSUP)
13245 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13246 res->vf_id, is_on);
13248 #ifdef RTE_LIBRTE_I40E_PMD
13249 if (ret == -ENOTSUP)
13250 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13251 res->vf_id, is_on);
13253 #ifdef RTE_LIBRTE_BNXT_PMD
13254 if (ret == -ENOTSUP)
13255 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13256 res->vf_id, is_on);
13263 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13266 printf("invalid port_id %d\n", res->port_id);
13269 printf("function not implemented\n");
13272 printf("programming error: (%s)\n", strerror(-ret));
13276 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13277 .f = cmd_set_vf_mac_anti_spoof_parsed,
13279 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13281 (void *)&cmd_vf_mac_anti_spoof_set,
13282 (void *)&cmd_vf_mac_anti_spoof_vf,
13283 (void *)&cmd_vf_mac_anti_spoof_mac,
13284 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13285 (void *)&cmd_vf_mac_anti_spoof_port_id,
13286 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13287 (void *)&cmd_vf_mac_anti_spoof_on_off,
13292 /* vf vlan strip queue configuration */
13294 /* Common result structure for vf mac anti spoof */
13295 struct cmd_vf_vlan_stripq_result {
13296 cmdline_fixed_string_t set;
13297 cmdline_fixed_string_t vf;
13298 cmdline_fixed_string_t vlan;
13299 cmdline_fixed_string_t stripq;
13302 cmdline_fixed_string_t on_off;
13305 /* Common CLI fields for vf vlan strip enable disable */
13306 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13307 TOKEN_STRING_INITIALIZER
13308 (struct cmd_vf_vlan_stripq_result,
13310 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13311 TOKEN_STRING_INITIALIZER
13312 (struct cmd_vf_vlan_stripq_result,
13314 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13315 TOKEN_STRING_INITIALIZER
13316 (struct cmd_vf_vlan_stripq_result,
13318 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13319 TOKEN_STRING_INITIALIZER
13320 (struct cmd_vf_vlan_stripq_result,
13322 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13323 TOKEN_NUM_INITIALIZER
13324 (struct cmd_vf_vlan_stripq_result,
13326 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13327 TOKEN_NUM_INITIALIZER
13328 (struct cmd_vf_vlan_stripq_result,
13330 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13331 TOKEN_STRING_INITIALIZER
13332 (struct cmd_vf_vlan_stripq_result,
13336 cmd_set_vf_vlan_stripq_parsed(
13337 void *parsed_result,
13338 __attribute__((unused)) struct cmdline *cl,
13339 __attribute__((unused)) void *data)
13341 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13342 int ret = -ENOTSUP;
13344 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13346 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13349 #ifdef RTE_LIBRTE_IXGBE_PMD
13350 if (ret == -ENOTSUP)
13351 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13352 res->vf_id, is_on);
13354 #ifdef RTE_LIBRTE_I40E_PMD
13355 if (ret == -ENOTSUP)
13356 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13357 res->vf_id, is_on);
13359 #ifdef RTE_LIBRTE_BNXT_PMD
13360 if (ret == -ENOTSUP)
13361 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13362 res->vf_id, is_on);
13369 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13372 printf("invalid port_id %d\n", res->port_id);
13375 printf("function not implemented\n");
13378 printf("programming error: (%s)\n", strerror(-ret));
13382 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13383 .f = cmd_set_vf_vlan_stripq_parsed,
13385 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13387 (void *)&cmd_vf_vlan_stripq_set,
13388 (void *)&cmd_vf_vlan_stripq_vf,
13389 (void *)&cmd_vf_vlan_stripq_vlan,
13390 (void *)&cmd_vf_vlan_stripq_stripq,
13391 (void *)&cmd_vf_vlan_stripq_port_id,
13392 (void *)&cmd_vf_vlan_stripq_vf_id,
13393 (void *)&cmd_vf_vlan_stripq_on_off,
13398 /* vf vlan insert configuration */
13400 /* Common result structure for vf vlan insert */
13401 struct cmd_vf_vlan_insert_result {
13402 cmdline_fixed_string_t set;
13403 cmdline_fixed_string_t vf;
13404 cmdline_fixed_string_t vlan;
13405 cmdline_fixed_string_t insert;
13411 /* Common CLI fields for vf vlan insert enable disable */
13412 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13413 TOKEN_STRING_INITIALIZER
13414 (struct cmd_vf_vlan_insert_result,
13416 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13417 TOKEN_STRING_INITIALIZER
13418 (struct cmd_vf_vlan_insert_result,
13420 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13421 TOKEN_STRING_INITIALIZER
13422 (struct cmd_vf_vlan_insert_result,
13424 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13425 TOKEN_STRING_INITIALIZER
13426 (struct cmd_vf_vlan_insert_result,
13428 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13429 TOKEN_NUM_INITIALIZER
13430 (struct cmd_vf_vlan_insert_result,
13432 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13433 TOKEN_NUM_INITIALIZER
13434 (struct cmd_vf_vlan_insert_result,
13436 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13437 TOKEN_NUM_INITIALIZER
13438 (struct cmd_vf_vlan_insert_result,
13442 cmd_set_vf_vlan_insert_parsed(
13443 void *parsed_result,
13444 __attribute__((unused)) struct cmdline *cl,
13445 __attribute__((unused)) void *data)
13447 struct cmd_vf_vlan_insert_result *res = parsed_result;
13448 int ret = -ENOTSUP;
13450 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13453 #ifdef RTE_LIBRTE_IXGBE_PMD
13454 if (ret == -ENOTSUP)
13455 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13458 #ifdef RTE_LIBRTE_I40E_PMD
13459 if (ret == -ENOTSUP)
13460 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13463 #ifdef RTE_LIBRTE_BNXT_PMD
13464 if (ret == -ENOTSUP)
13465 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13473 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13476 printf("invalid port_id %d\n", res->port_id);
13479 printf("function not implemented\n");
13482 printf("programming error: (%s)\n", strerror(-ret));
13486 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13487 .f = cmd_set_vf_vlan_insert_parsed,
13489 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13491 (void *)&cmd_vf_vlan_insert_set,
13492 (void *)&cmd_vf_vlan_insert_vf,
13493 (void *)&cmd_vf_vlan_insert_vlan,
13494 (void *)&cmd_vf_vlan_insert_insert,
13495 (void *)&cmd_vf_vlan_insert_port_id,
13496 (void *)&cmd_vf_vlan_insert_vf_id,
13497 (void *)&cmd_vf_vlan_insert_vlan_id,
13502 /* tx loopback configuration */
13504 /* Common result structure for tx loopback */
13505 struct cmd_tx_loopback_result {
13506 cmdline_fixed_string_t set;
13507 cmdline_fixed_string_t tx;
13508 cmdline_fixed_string_t loopback;
13510 cmdline_fixed_string_t on_off;
13513 /* Common CLI fields for tx loopback enable disable */
13514 cmdline_parse_token_string_t cmd_tx_loopback_set =
13515 TOKEN_STRING_INITIALIZER
13516 (struct cmd_tx_loopback_result,
13518 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13519 TOKEN_STRING_INITIALIZER
13520 (struct cmd_tx_loopback_result,
13522 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13523 TOKEN_STRING_INITIALIZER
13524 (struct cmd_tx_loopback_result,
13525 loopback, "loopback");
13526 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13527 TOKEN_NUM_INITIALIZER
13528 (struct cmd_tx_loopback_result,
13530 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13531 TOKEN_STRING_INITIALIZER
13532 (struct cmd_tx_loopback_result,
13536 cmd_set_tx_loopback_parsed(
13537 void *parsed_result,
13538 __attribute__((unused)) struct cmdline *cl,
13539 __attribute__((unused)) void *data)
13541 struct cmd_tx_loopback_result *res = parsed_result;
13542 int ret = -ENOTSUP;
13544 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13546 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13549 #ifdef RTE_LIBRTE_IXGBE_PMD
13550 if (ret == -ENOTSUP)
13551 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13553 #ifdef RTE_LIBRTE_I40E_PMD
13554 if (ret == -ENOTSUP)
13555 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13557 #ifdef RTE_LIBRTE_BNXT_PMD
13558 if (ret == -ENOTSUP)
13559 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13561 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13562 if (ret == -ENOTSUP)
13563 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13570 printf("invalid is_on %d\n", is_on);
13573 printf("invalid port_id %d\n", res->port_id);
13576 printf("function not implemented\n");
13579 printf("programming error: (%s)\n", strerror(-ret));
13583 cmdline_parse_inst_t cmd_set_tx_loopback = {
13584 .f = cmd_set_tx_loopback_parsed,
13586 .help_str = "set tx loopback <port_id> on|off",
13588 (void *)&cmd_tx_loopback_set,
13589 (void *)&cmd_tx_loopback_tx,
13590 (void *)&cmd_tx_loopback_loopback,
13591 (void *)&cmd_tx_loopback_port_id,
13592 (void *)&cmd_tx_loopback_on_off,
13597 /* all queues drop enable configuration */
13599 /* Common result structure for all queues drop enable */
13600 struct cmd_all_queues_drop_en_result {
13601 cmdline_fixed_string_t set;
13602 cmdline_fixed_string_t all;
13603 cmdline_fixed_string_t queues;
13604 cmdline_fixed_string_t drop;
13606 cmdline_fixed_string_t on_off;
13609 /* Common CLI fields for tx loopback enable disable */
13610 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13611 TOKEN_STRING_INITIALIZER
13612 (struct cmd_all_queues_drop_en_result,
13614 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13615 TOKEN_STRING_INITIALIZER
13616 (struct cmd_all_queues_drop_en_result,
13618 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13619 TOKEN_STRING_INITIALIZER
13620 (struct cmd_all_queues_drop_en_result,
13622 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13623 TOKEN_STRING_INITIALIZER
13624 (struct cmd_all_queues_drop_en_result,
13626 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13627 TOKEN_NUM_INITIALIZER
13628 (struct cmd_all_queues_drop_en_result,
13630 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13631 TOKEN_STRING_INITIALIZER
13632 (struct cmd_all_queues_drop_en_result,
13636 cmd_set_all_queues_drop_en_parsed(
13637 void *parsed_result,
13638 __attribute__((unused)) struct cmdline *cl,
13639 __attribute__((unused)) void *data)
13641 struct cmd_all_queues_drop_en_result *res = parsed_result;
13642 int ret = -ENOTSUP;
13643 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13645 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13648 #ifdef RTE_LIBRTE_IXGBE_PMD
13649 if (ret == -ENOTSUP)
13650 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13652 #ifdef RTE_LIBRTE_BNXT_PMD
13653 if (ret == -ENOTSUP)
13654 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13660 printf("invalid is_on %d\n", is_on);
13663 printf("invalid port_id %d\n", res->port_id);
13666 printf("function not implemented\n");
13669 printf("programming error: (%s)\n", strerror(-ret));
13673 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13674 .f = cmd_set_all_queues_drop_en_parsed,
13676 .help_str = "set all queues drop <port_id> on|off",
13678 (void *)&cmd_all_queues_drop_en_set,
13679 (void *)&cmd_all_queues_drop_en_all,
13680 (void *)&cmd_all_queues_drop_en_queues,
13681 (void *)&cmd_all_queues_drop_en_drop,
13682 (void *)&cmd_all_queues_drop_en_port_id,
13683 (void *)&cmd_all_queues_drop_en_on_off,
13688 /* vf split drop enable configuration */
13690 /* Common result structure for vf split drop enable */
13691 struct cmd_vf_split_drop_en_result {
13692 cmdline_fixed_string_t set;
13693 cmdline_fixed_string_t vf;
13694 cmdline_fixed_string_t split;
13695 cmdline_fixed_string_t drop;
13698 cmdline_fixed_string_t on_off;
13701 /* Common CLI fields for vf split drop enable disable */
13702 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13703 TOKEN_STRING_INITIALIZER
13704 (struct cmd_vf_split_drop_en_result,
13706 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13707 TOKEN_STRING_INITIALIZER
13708 (struct cmd_vf_split_drop_en_result,
13710 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13711 TOKEN_STRING_INITIALIZER
13712 (struct cmd_vf_split_drop_en_result,
13714 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13715 TOKEN_STRING_INITIALIZER
13716 (struct cmd_vf_split_drop_en_result,
13718 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13719 TOKEN_NUM_INITIALIZER
13720 (struct cmd_vf_split_drop_en_result,
13722 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13723 TOKEN_NUM_INITIALIZER
13724 (struct cmd_vf_split_drop_en_result,
13726 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13727 TOKEN_STRING_INITIALIZER
13728 (struct cmd_vf_split_drop_en_result,
13732 cmd_set_vf_split_drop_en_parsed(
13733 void *parsed_result,
13734 __attribute__((unused)) struct cmdline *cl,
13735 __attribute__((unused)) void *data)
13737 struct cmd_vf_split_drop_en_result *res = parsed_result;
13738 int ret = -ENOTSUP;
13739 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13741 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13744 #ifdef RTE_LIBRTE_IXGBE_PMD
13745 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13752 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13755 printf("invalid port_id %d\n", res->port_id);
13758 printf("not supported on port %d\n", res->port_id);
13761 printf("programming error: (%s)\n", strerror(-ret));
13765 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13766 .f = cmd_set_vf_split_drop_en_parsed,
13768 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13770 (void *)&cmd_vf_split_drop_en_set,
13771 (void *)&cmd_vf_split_drop_en_vf,
13772 (void *)&cmd_vf_split_drop_en_split,
13773 (void *)&cmd_vf_split_drop_en_drop,
13774 (void *)&cmd_vf_split_drop_en_port_id,
13775 (void *)&cmd_vf_split_drop_en_vf_id,
13776 (void *)&cmd_vf_split_drop_en_on_off,
13781 /* vf mac address configuration */
13783 /* Common result structure for vf mac address */
13784 struct cmd_set_vf_mac_addr_result {
13785 cmdline_fixed_string_t set;
13786 cmdline_fixed_string_t vf;
13787 cmdline_fixed_string_t mac;
13788 cmdline_fixed_string_t addr;
13791 struct ether_addr mac_addr;
13795 /* Common CLI fields for vf split drop enable disable */
13796 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13797 TOKEN_STRING_INITIALIZER
13798 (struct cmd_set_vf_mac_addr_result,
13800 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13801 TOKEN_STRING_INITIALIZER
13802 (struct cmd_set_vf_mac_addr_result,
13804 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13805 TOKEN_STRING_INITIALIZER
13806 (struct cmd_set_vf_mac_addr_result,
13808 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13809 TOKEN_STRING_INITIALIZER
13810 (struct cmd_set_vf_mac_addr_result,
13812 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13813 TOKEN_NUM_INITIALIZER
13814 (struct cmd_set_vf_mac_addr_result,
13816 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13817 TOKEN_NUM_INITIALIZER
13818 (struct cmd_set_vf_mac_addr_result,
13820 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13821 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13825 cmd_set_vf_mac_addr_parsed(
13826 void *parsed_result,
13827 __attribute__((unused)) struct cmdline *cl,
13828 __attribute__((unused)) void *data)
13830 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13831 int ret = -ENOTSUP;
13833 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13836 #ifdef RTE_LIBRTE_IXGBE_PMD
13837 if (ret == -ENOTSUP)
13838 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13841 #ifdef RTE_LIBRTE_I40E_PMD
13842 if (ret == -ENOTSUP)
13843 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13846 #ifdef RTE_LIBRTE_BNXT_PMD
13847 if (ret == -ENOTSUP)
13848 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13856 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13859 printf("invalid port_id %d\n", res->port_id);
13862 printf("function not implemented\n");
13865 printf("programming error: (%s)\n", strerror(-ret));
13869 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13870 .f = cmd_set_vf_mac_addr_parsed,
13872 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13874 (void *)&cmd_set_vf_mac_addr_set,
13875 (void *)&cmd_set_vf_mac_addr_vf,
13876 (void *)&cmd_set_vf_mac_addr_mac,
13877 (void *)&cmd_set_vf_mac_addr_addr,
13878 (void *)&cmd_set_vf_mac_addr_port_id,
13879 (void *)&cmd_set_vf_mac_addr_vf_id,
13880 (void *)&cmd_set_vf_mac_addr_mac_addr,
13885 /* MACsec configuration */
13887 /* Common result structure for MACsec offload enable */
13888 struct cmd_macsec_offload_on_result {
13889 cmdline_fixed_string_t set;
13890 cmdline_fixed_string_t macsec;
13891 cmdline_fixed_string_t offload;
13893 cmdline_fixed_string_t on;
13894 cmdline_fixed_string_t encrypt;
13895 cmdline_fixed_string_t en_on_off;
13896 cmdline_fixed_string_t replay_protect;
13897 cmdline_fixed_string_t rp_on_off;
13900 /* Common CLI fields for MACsec offload disable */
13901 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13902 TOKEN_STRING_INITIALIZER
13903 (struct cmd_macsec_offload_on_result,
13905 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13906 TOKEN_STRING_INITIALIZER
13907 (struct cmd_macsec_offload_on_result,
13909 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13910 TOKEN_STRING_INITIALIZER
13911 (struct cmd_macsec_offload_on_result,
13912 offload, "offload");
13913 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13914 TOKEN_NUM_INITIALIZER
13915 (struct cmd_macsec_offload_on_result,
13917 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13918 TOKEN_STRING_INITIALIZER
13919 (struct cmd_macsec_offload_on_result,
13921 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13922 TOKEN_STRING_INITIALIZER
13923 (struct cmd_macsec_offload_on_result,
13924 encrypt, "encrypt");
13925 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13926 TOKEN_STRING_INITIALIZER
13927 (struct cmd_macsec_offload_on_result,
13928 en_on_off, "on#off");
13929 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13930 TOKEN_STRING_INITIALIZER
13931 (struct cmd_macsec_offload_on_result,
13932 replay_protect, "replay-protect");
13933 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13934 TOKEN_STRING_INITIALIZER
13935 (struct cmd_macsec_offload_on_result,
13936 rp_on_off, "on#off");
13939 cmd_set_macsec_offload_on_parsed(
13940 void *parsed_result,
13941 __attribute__((unused)) struct cmdline *cl,
13942 __attribute__((unused)) void *data)
13944 struct cmd_macsec_offload_on_result *res = parsed_result;
13945 int ret = -ENOTSUP;
13946 portid_t port_id = res->port_id;
13947 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13948 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13949 struct rte_eth_dev_info dev_info;
13951 if (port_id_is_invalid(port_id, ENABLED_WARN))
13953 if (!port_is_stopped(port_id)) {
13954 printf("Please stop port %d first\n", port_id);
13958 rte_eth_dev_info_get(port_id, &dev_info);
13959 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13960 #ifdef RTE_LIBRTE_IXGBE_PMD
13961 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13969 ports[port_id].dev_conf.txmode.offloads |=
13970 DEV_TX_OFFLOAD_MACSEC_INSERT;
13971 cmd_reconfig_device_queue(port_id, 1, 1);
13974 printf("invalid port_id %d\n", port_id);
13977 printf("not supported on port %d\n", port_id);
13980 printf("programming error: (%s)\n", strerror(-ret));
13984 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13985 .f = cmd_set_macsec_offload_on_parsed,
13987 .help_str = "set macsec offload <port_id> on "
13988 "encrypt on|off replay-protect on|off",
13990 (void *)&cmd_macsec_offload_on_set,
13991 (void *)&cmd_macsec_offload_on_macsec,
13992 (void *)&cmd_macsec_offload_on_offload,
13993 (void *)&cmd_macsec_offload_on_port_id,
13994 (void *)&cmd_macsec_offload_on_on,
13995 (void *)&cmd_macsec_offload_on_encrypt,
13996 (void *)&cmd_macsec_offload_on_en_on_off,
13997 (void *)&cmd_macsec_offload_on_replay_protect,
13998 (void *)&cmd_macsec_offload_on_rp_on_off,
14003 /* Common result structure for MACsec offload disable */
14004 struct cmd_macsec_offload_off_result {
14005 cmdline_fixed_string_t set;
14006 cmdline_fixed_string_t macsec;
14007 cmdline_fixed_string_t offload;
14009 cmdline_fixed_string_t off;
14012 /* Common CLI fields for MACsec offload disable */
14013 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14014 TOKEN_STRING_INITIALIZER
14015 (struct cmd_macsec_offload_off_result,
14017 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14018 TOKEN_STRING_INITIALIZER
14019 (struct cmd_macsec_offload_off_result,
14021 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14022 TOKEN_STRING_INITIALIZER
14023 (struct cmd_macsec_offload_off_result,
14024 offload, "offload");
14025 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14026 TOKEN_NUM_INITIALIZER
14027 (struct cmd_macsec_offload_off_result,
14029 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14030 TOKEN_STRING_INITIALIZER
14031 (struct cmd_macsec_offload_off_result,
14035 cmd_set_macsec_offload_off_parsed(
14036 void *parsed_result,
14037 __attribute__((unused)) struct cmdline *cl,
14038 __attribute__((unused)) void *data)
14040 struct cmd_macsec_offload_off_result *res = parsed_result;
14041 int ret = -ENOTSUP;
14042 struct rte_eth_dev_info dev_info;
14043 portid_t port_id = res->port_id;
14045 if (port_id_is_invalid(port_id, ENABLED_WARN))
14047 if (!port_is_stopped(port_id)) {
14048 printf("Please stop port %d first\n", port_id);
14052 rte_eth_dev_info_get(port_id, &dev_info);
14053 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14054 #ifdef RTE_LIBRTE_IXGBE_PMD
14055 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14060 ports[port_id].dev_conf.txmode.offloads &=
14061 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14062 cmd_reconfig_device_queue(port_id, 1, 1);
14065 printf("invalid port_id %d\n", port_id);
14068 printf("not supported on port %d\n", port_id);
14071 printf("programming error: (%s)\n", strerror(-ret));
14075 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14076 .f = cmd_set_macsec_offload_off_parsed,
14078 .help_str = "set macsec offload <port_id> off",
14080 (void *)&cmd_macsec_offload_off_set,
14081 (void *)&cmd_macsec_offload_off_macsec,
14082 (void *)&cmd_macsec_offload_off_offload,
14083 (void *)&cmd_macsec_offload_off_port_id,
14084 (void *)&cmd_macsec_offload_off_off,
14089 /* Common result structure for MACsec secure connection configure */
14090 struct cmd_macsec_sc_result {
14091 cmdline_fixed_string_t set;
14092 cmdline_fixed_string_t macsec;
14093 cmdline_fixed_string_t sc;
14094 cmdline_fixed_string_t tx_rx;
14096 struct ether_addr mac;
14100 /* Common CLI fields for MACsec secure connection configure */
14101 cmdline_parse_token_string_t cmd_macsec_sc_set =
14102 TOKEN_STRING_INITIALIZER
14103 (struct cmd_macsec_sc_result,
14105 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14106 TOKEN_STRING_INITIALIZER
14107 (struct cmd_macsec_sc_result,
14109 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14110 TOKEN_STRING_INITIALIZER
14111 (struct cmd_macsec_sc_result,
14113 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14114 TOKEN_STRING_INITIALIZER
14115 (struct cmd_macsec_sc_result,
14117 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14118 TOKEN_NUM_INITIALIZER
14119 (struct cmd_macsec_sc_result,
14121 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14122 TOKEN_ETHERADDR_INITIALIZER
14123 (struct cmd_macsec_sc_result,
14125 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14126 TOKEN_NUM_INITIALIZER
14127 (struct cmd_macsec_sc_result,
14131 cmd_set_macsec_sc_parsed(
14132 void *parsed_result,
14133 __attribute__((unused)) struct cmdline *cl,
14134 __attribute__((unused)) void *data)
14136 struct cmd_macsec_sc_result *res = parsed_result;
14137 int ret = -ENOTSUP;
14138 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14140 #ifdef RTE_LIBRTE_IXGBE_PMD
14142 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14143 res->mac.addr_bytes) :
14144 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14145 res->mac.addr_bytes, res->pi);
14147 RTE_SET_USED(is_tx);
14153 printf("invalid port_id %d\n", res->port_id);
14156 printf("not supported on port %d\n", res->port_id);
14159 printf("programming error: (%s)\n", strerror(-ret));
14163 cmdline_parse_inst_t cmd_set_macsec_sc = {
14164 .f = cmd_set_macsec_sc_parsed,
14166 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14168 (void *)&cmd_macsec_sc_set,
14169 (void *)&cmd_macsec_sc_macsec,
14170 (void *)&cmd_macsec_sc_sc,
14171 (void *)&cmd_macsec_sc_tx_rx,
14172 (void *)&cmd_macsec_sc_port_id,
14173 (void *)&cmd_macsec_sc_mac,
14174 (void *)&cmd_macsec_sc_pi,
14179 /* Common result structure for MACsec secure connection configure */
14180 struct cmd_macsec_sa_result {
14181 cmdline_fixed_string_t set;
14182 cmdline_fixed_string_t macsec;
14183 cmdline_fixed_string_t sa;
14184 cmdline_fixed_string_t tx_rx;
14189 cmdline_fixed_string_t key;
14192 /* Common CLI fields for MACsec secure connection configure */
14193 cmdline_parse_token_string_t cmd_macsec_sa_set =
14194 TOKEN_STRING_INITIALIZER
14195 (struct cmd_macsec_sa_result,
14197 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14198 TOKEN_STRING_INITIALIZER
14199 (struct cmd_macsec_sa_result,
14201 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14202 TOKEN_STRING_INITIALIZER
14203 (struct cmd_macsec_sa_result,
14205 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14206 TOKEN_STRING_INITIALIZER
14207 (struct cmd_macsec_sa_result,
14209 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14210 TOKEN_NUM_INITIALIZER
14211 (struct cmd_macsec_sa_result,
14213 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14214 TOKEN_NUM_INITIALIZER
14215 (struct cmd_macsec_sa_result,
14217 cmdline_parse_token_num_t cmd_macsec_sa_an =
14218 TOKEN_NUM_INITIALIZER
14219 (struct cmd_macsec_sa_result,
14221 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14222 TOKEN_NUM_INITIALIZER
14223 (struct cmd_macsec_sa_result,
14225 cmdline_parse_token_string_t cmd_macsec_sa_key =
14226 TOKEN_STRING_INITIALIZER
14227 (struct cmd_macsec_sa_result,
14231 cmd_set_macsec_sa_parsed(
14232 void *parsed_result,
14233 __attribute__((unused)) struct cmdline *cl,
14234 __attribute__((unused)) void *data)
14236 struct cmd_macsec_sa_result *res = parsed_result;
14237 int ret = -ENOTSUP;
14238 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14239 uint8_t key[16] = { 0 };
14245 key_len = strlen(res->key) / 2;
14249 for (i = 0; i < key_len; i++) {
14250 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14253 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14256 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14259 #ifdef RTE_LIBRTE_IXGBE_PMD
14261 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14262 res->idx, res->an, res->pn, key) :
14263 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14264 res->idx, res->an, res->pn, key);
14266 RTE_SET_USED(is_tx);
14273 printf("invalid idx %d or an %d\n", res->idx, res->an);
14276 printf("invalid port_id %d\n", res->port_id);
14279 printf("not supported on port %d\n", res->port_id);
14282 printf("programming error: (%s)\n", strerror(-ret));
14286 cmdline_parse_inst_t cmd_set_macsec_sa = {
14287 .f = cmd_set_macsec_sa_parsed,
14289 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14291 (void *)&cmd_macsec_sa_set,
14292 (void *)&cmd_macsec_sa_macsec,
14293 (void *)&cmd_macsec_sa_sa,
14294 (void *)&cmd_macsec_sa_tx_rx,
14295 (void *)&cmd_macsec_sa_port_id,
14296 (void *)&cmd_macsec_sa_idx,
14297 (void *)&cmd_macsec_sa_an,
14298 (void *)&cmd_macsec_sa_pn,
14299 (void *)&cmd_macsec_sa_key,
14304 /* VF unicast promiscuous mode configuration */
14306 /* Common result structure for VF unicast promiscuous mode */
14307 struct cmd_vf_promisc_result {
14308 cmdline_fixed_string_t set;
14309 cmdline_fixed_string_t vf;
14310 cmdline_fixed_string_t promisc;
14313 cmdline_fixed_string_t on_off;
14316 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14317 cmdline_parse_token_string_t cmd_vf_promisc_set =
14318 TOKEN_STRING_INITIALIZER
14319 (struct cmd_vf_promisc_result,
14321 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14322 TOKEN_STRING_INITIALIZER
14323 (struct cmd_vf_promisc_result,
14325 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14326 TOKEN_STRING_INITIALIZER
14327 (struct cmd_vf_promisc_result,
14328 promisc, "promisc");
14329 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14330 TOKEN_NUM_INITIALIZER
14331 (struct cmd_vf_promisc_result,
14333 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14334 TOKEN_NUM_INITIALIZER
14335 (struct cmd_vf_promisc_result,
14337 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14338 TOKEN_STRING_INITIALIZER
14339 (struct cmd_vf_promisc_result,
14343 cmd_set_vf_promisc_parsed(
14344 void *parsed_result,
14345 __attribute__((unused)) struct cmdline *cl,
14346 __attribute__((unused)) void *data)
14348 struct cmd_vf_promisc_result *res = parsed_result;
14349 int ret = -ENOTSUP;
14351 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14353 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14356 #ifdef RTE_LIBRTE_I40E_PMD
14357 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14358 res->vf_id, is_on);
14365 printf("invalid vf_id %d\n", res->vf_id);
14368 printf("invalid port_id %d\n", res->port_id);
14371 printf("function not implemented\n");
14374 printf("programming error: (%s)\n", strerror(-ret));
14378 cmdline_parse_inst_t cmd_set_vf_promisc = {
14379 .f = cmd_set_vf_promisc_parsed,
14381 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14382 "Set unicast promiscuous mode for a VF from the PF",
14384 (void *)&cmd_vf_promisc_set,
14385 (void *)&cmd_vf_promisc_vf,
14386 (void *)&cmd_vf_promisc_promisc,
14387 (void *)&cmd_vf_promisc_port_id,
14388 (void *)&cmd_vf_promisc_vf_id,
14389 (void *)&cmd_vf_promisc_on_off,
14394 /* VF multicast promiscuous mode configuration */
14396 /* Common result structure for VF multicast promiscuous mode */
14397 struct cmd_vf_allmulti_result {
14398 cmdline_fixed_string_t set;
14399 cmdline_fixed_string_t vf;
14400 cmdline_fixed_string_t allmulti;
14403 cmdline_fixed_string_t on_off;
14406 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14407 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14408 TOKEN_STRING_INITIALIZER
14409 (struct cmd_vf_allmulti_result,
14411 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14412 TOKEN_STRING_INITIALIZER
14413 (struct cmd_vf_allmulti_result,
14415 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14416 TOKEN_STRING_INITIALIZER
14417 (struct cmd_vf_allmulti_result,
14418 allmulti, "allmulti");
14419 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14420 TOKEN_NUM_INITIALIZER
14421 (struct cmd_vf_allmulti_result,
14423 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14424 TOKEN_NUM_INITIALIZER
14425 (struct cmd_vf_allmulti_result,
14427 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14428 TOKEN_STRING_INITIALIZER
14429 (struct cmd_vf_allmulti_result,
14433 cmd_set_vf_allmulti_parsed(
14434 void *parsed_result,
14435 __attribute__((unused)) struct cmdline *cl,
14436 __attribute__((unused)) void *data)
14438 struct cmd_vf_allmulti_result *res = parsed_result;
14439 int ret = -ENOTSUP;
14441 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14443 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14446 #ifdef RTE_LIBRTE_I40E_PMD
14447 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14448 res->vf_id, is_on);
14455 printf("invalid vf_id %d\n", res->vf_id);
14458 printf("invalid port_id %d\n", res->port_id);
14461 printf("function not implemented\n");
14464 printf("programming error: (%s)\n", strerror(-ret));
14468 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14469 .f = cmd_set_vf_allmulti_parsed,
14471 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14472 "Set multicast promiscuous mode for a VF from the PF",
14474 (void *)&cmd_vf_allmulti_set,
14475 (void *)&cmd_vf_allmulti_vf,
14476 (void *)&cmd_vf_allmulti_allmulti,
14477 (void *)&cmd_vf_allmulti_port_id,
14478 (void *)&cmd_vf_allmulti_vf_id,
14479 (void *)&cmd_vf_allmulti_on_off,
14484 /* vf broadcast mode configuration */
14486 /* Common result structure for vf broadcast */
14487 struct cmd_set_vf_broadcast_result {
14488 cmdline_fixed_string_t set;
14489 cmdline_fixed_string_t vf;
14490 cmdline_fixed_string_t broadcast;
14493 cmdline_fixed_string_t on_off;
14496 /* Common CLI fields for vf broadcast enable disable */
14497 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14498 TOKEN_STRING_INITIALIZER
14499 (struct cmd_set_vf_broadcast_result,
14501 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14502 TOKEN_STRING_INITIALIZER
14503 (struct cmd_set_vf_broadcast_result,
14505 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14506 TOKEN_STRING_INITIALIZER
14507 (struct cmd_set_vf_broadcast_result,
14508 broadcast, "broadcast");
14509 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14510 TOKEN_NUM_INITIALIZER
14511 (struct cmd_set_vf_broadcast_result,
14513 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14514 TOKEN_NUM_INITIALIZER
14515 (struct cmd_set_vf_broadcast_result,
14517 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14518 TOKEN_STRING_INITIALIZER
14519 (struct cmd_set_vf_broadcast_result,
14523 cmd_set_vf_broadcast_parsed(
14524 void *parsed_result,
14525 __attribute__((unused)) struct cmdline *cl,
14526 __attribute__((unused)) void *data)
14528 struct cmd_set_vf_broadcast_result *res = parsed_result;
14529 int ret = -ENOTSUP;
14531 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14533 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14536 #ifdef RTE_LIBRTE_I40E_PMD
14537 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14538 res->vf_id, is_on);
14545 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14548 printf("invalid port_id %d\n", res->port_id);
14551 printf("function not implemented\n");
14554 printf("programming error: (%s)\n", strerror(-ret));
14558 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14559 .f = cmd_set_vf_broadcast_parsed,
14561 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14563 (void *)&cmd_set_vf_broadcast_set,
14564 (void *)&cmd_set_vf_broadcast_vf,
14565 (void *)&cmd_set_vf_broadcast_broadcast,
14566 (void *)&cmd_set_vf_broadcast_port_id,
14567 (void *)&cmd_set_vf_broadcast_vf_id,
14568 (void *)&cmd_set_vf_broadcast_on_off,
14573 /* vf vlan tag configuration */
14575 /* Common result structure for vf vlan tag */
14576 struct cmd_set_vf_vlan_tag_result {
14577 cmdline_fixed_string_t set;
14578 cmdline_fixed_string_t vf;
14579 cmdline_fixed_string_t vlan;
14580 cmdline_fixed_string_t tag;
14583 cmdline_fixed_string_t on_off;
14586 /* Common CLI fields for vf vlan tag enable disable */
14587 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14588 TOKEN_STRING_INITIALIZER
14589 (struct cmd_set_vf_vlan_tag_result,
14591 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14592 TOKEN_STRING_INITIALIZER
14593 (struct cmd_set_vf_vlan_tag_result,
14595 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14596 TOKEN_STRING_INITIALIZER
14597 (struct cmd_set_vf_vlan_tag_result,
14599 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14600 TOKEN_STRING_INITIALIZER
14601 (struct cmd_set_vf_vlan_tag_result,
14603 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14604 TOKEN_NUM_INITIALIZER
14605 (struct cmd_set_vf_vlan_tag_result,
14607 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14608 TOKEN_NUM_INITIALIZER
14609 (struct cmd_set_vf_vlan_tag_result,
14611 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14612 TOKEN_STRING_INITIALIZER
14613 (struct cmd_set_vf_vlan_tag_result,
14617 cmd_set_vf_vlan_tag_parsed(
14618 void *parsed_result,
14619 __attribute__((unused)) struct cmdline *cl,
14620 __attribute__((unused)) void *data)
14622 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14623 int ret = -ENOTSUP;
14625 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14627 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14630 #ifdef RTE_LIBRTE_I40E_PMD
14631 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14632 res->vf_id, is_on);
14639 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14642 printf("invalid port_id %d\n", res->port_id);
14645 printf("function not implemented\n");
14648 printf("programming error: (%s)\n", strerror(-ret));
14652 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14653 .f = cmd_set_vf_vlan_tag_parsed,
14655 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14657 (void *)&cmd_set_vf_vlan_tag_set,
14658 (void *)&cmd_set_vf_vlan_tag_vf,
14659 (void *)&cmd_set_vf_vlan_tag_vlan,
14660 (void *)&cmd_set_vf_vlan_tag_tag,
14661 (void *)&cmd_set_vf_vlan_tag_port_id,
14662 (void *)&cmd_set_vf_vlan_tag_vf_id,
14663 (void *)&cmd_set_vf_vlan_tag_on_off,
14668 /* Common definition of VF and TC TX bandwidth configuration */
14669 struct cmd_vf_tc_bw_result {
14670 cmdline_fixed_string_t set;
14671 cmdline_fixed_string_t vf;
14672 cmdline_fixed_string_t tc;
14673 cmdline_fixed_string_t tx;
14674 cmdline_fixed_string_t min_bw;
14675 cmdline_fixed_string_t max_bw;
14676 cmdline_fixed_string_t strict_link_prio;
14681 cmdline_fixed_string_t bw_list;
14685 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14686 TOKEN_STRING_INITIALIZER
14687 (struct cmd_vf_tc_bw_result,
14689 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14690 TOKEN_STRING_INITIALIZER
14691 (struct cmd_vf_tc_bw_result,
14693 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14694 TOKEN_STRING_INITIALIZER
14695 (struct cmd_vf_tc_bw_result,
14697 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14698 TOKEN_STRING_INITIALIZER
14699 (struct cmd_vf_tc_bw_result,
14701 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14702 TOKEN_STRING_INITIALIZER
14703 (struct cmd_vf_tc_bw_result,
14704 strict_link_prio, "strict-link-priority");
14705 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14706 TOKEN_STRING_INITIALIZER
14707 (struct cmd_vf_tc_bw_result,
14708 min_bw, "min-bandwidth");
14709 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14710 TOKEN_STRING_INITIALIZER
14711 (struct cmd_vf_tc_bw_result,
14712 max_bw, "max-bandwidth");
14713 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14714 TOKEN_NUM_INITIALIZER
14715 (struct cmd_vf_tc_bw_result,
14717 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14718 TOKEN_NUM_INITIALIZER
14719 (struct cmd_vf_tc_bw_result,
14721 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14722 TOKEN_NUM_INITIALIZER
14723 (struct cmd_vf_tc_bw_result,
14725 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14726 TOKEN_NUM_INITIALIZER
14727 (struct cmd_vf_tc_bw_result,
14729 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14730 TOKEN_STRING_INITIALIZER
14731 (struct cmd_vf_tc_bw_result,
14733 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14734 TOKEN_NUM_INITIALIZER
14735 (struct cmd_vf_tc_bw_result,
14738 /* VF max bandwidth setting */
14740 cmd_vf_max_bw_parsed(
14741 void *parsed_result,
14742 __attribute__((unused)) struct cmdline *cl,
14743 __attribute__((unused)) void *data)
14745 struct cmd_vf_tc_bw_result *res = parsed_result;
14746 int ret = -ENOTSUP;
14748 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14751 #ifdef RTE_LIBRTE_I40E_PMD
14752 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14753 res->vf_id, res->bw);
14760 printf("invalid vf_id %d or bandwidth %d\n",
14761 res->vf_id, res->bw);
14764 printf("invalid port_id %d\n", res->port_id);
14767 printf("function not implemented\n");
14770 printf("programming error: (%s)\n", strerror(-ret));
14774 cmdline_parse_inst_t cmd_vf_max_bw = {
14775 .f = cmd_vf_max_bw_parsed,
14777 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14779 (void *)&cmd_vf_tc_bw_set,
14780 (void *)&cmd_vf_tc_bw_vf,
14781 (void *)&cmd_vf_tc_bw_tx,
14782 (void *)&cmd_vf_tc_bw_max_bw,
14783 (void *)&cmd_vf_tc_bw_port_id,
14784 (void *)&cmd_vf_tc_bw_vf_id,
14785 (void *)&cmd_vf_tc_bw_bw,
14791 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14796 const char *p, *p0 = str;
14803 p = strchr(p0, '(');
14805 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14809 p0 = strchr(p, ')');
14811 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14815 if (size >= sizeof(s)) {
14816 printf("The string size exceeds the internal buffer size\n");
14819 snprintf(s, sizeof(s), "%.*s", size, p);
14820 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14822 printf("Failed to get the bandwidth list. ");
14826 for (i = 0; i < ret; i++)
14827 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14832 /* TC min bandwidth setting */
14834 cmd_vf_tc_min_bw_parsed(
14835 void *parsed_result,
14836 __attribute__((unused)) struct cmdline *cl,
14837 __attribute__((unused)) void *data)
14839 struct cmd_vf_tc_bw_result *res = parsed_result;
14842 int ret = -ENOTSUP;
14844 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14847 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14851 #ifdef RTE_LIBRTE_I40E_PMD
14852 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14860 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14863 printf("invalid port_id %d\n", res->port_id);
14866 printf("function not implemented\n");
14869 printf("programming error: (%s)\n", strerror(-ret));
14873 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14874 .f = cmd_vf_tc_min_bw_parsed,
14876 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14877 " <bw1, bw2, ...>",
14879 (void *)&cmd_vf_tc_bw_set,
14880 (void *)&cmd_vf_tc_bw_vf,
14881 (void *)&cmd_vf_tc_bw_tc,
14882 (void *)&cmd_vf_tc_bw_tx,
14883 (void *)&cmd_vf_tc_bw_min_bw,
14884 (void *)&cmd_vf_tc_bw_port_id,
14885 (void *)&cmd_vf_tc_bw_vf_id,
14886 (void *)&cmd_vf_tc_bw_bw_list,
14892 cmd_tc_min_bw_parsed(
14893 void *parsed_result,
14894 __attribute__((unused)) struct cmdline *cl,
14895 __attribute__((unused)) void *data)
14897 struct cmd_vf_tc_bw_result *res = parsed_result;
14898 struct rte_port *port;
14901 int ret = -ENOTSUP;
14903 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14906 port = &ports[res->port_id];
14907 /** Check if the port is not started **/
14908 if (port->port_status != RTE_PORT_STOPPED) {
14909 printf("Please stop port %d first\n", res->port_id);
14913 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14917 #ifdef RTE_LIBRTE_IXGBE_PMD
14918 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14925 printf("invalid bandwidth\n");
14928 printf("invalid port_id %d\n", res->port_id);
14931 printf("function not implemented\n");
14934 printf("programming error: (%s)\n", strerror(-ret));
14938 cmdline_parse_inst_t cmd_tc_min_bw = {
14939 .f = cmd_tc_min_bw_parsed,
14941 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14943 (void *)&cmd_vf_tc_bw_set,
14944 (void *)&cmd_vf_tc_bw_tc,
14945 (void *)&cmd_vf_tc_bw_tx,
14946 (void *)&cmd_vf_tc_bw_min_bw,
14947 (void *)&cmd_vf_tc_bw_port_id,
14948 (void *)&cmd_vf_tc_bw_bw_list,
14953 /* TC max bandwidth setting */
14955 cmd_vf_tc_max_bw_parsed(
14956 void *parsed_result,
14957 __attribute__((unused)) struct cmdline *cl,
14958 __attribute__((unused)) void *data)
14960 struct cmd_vf_tc_bw_result *res = parsed_result;
14961 int ret = -ENOTSUP;
14963 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14966 #ifdef RTE_LIBRTE_I40E_PMD
14967 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14968 res->tc_no, res->bw);
14975 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14976 res->vf_id, res->tc_no, res->bw);
14979 printf("invalid port_id %d\n", res->port_id);
14982 printf("function not implemented\n");
14985 printf("programming error: (%s)\n", strerror(-ret));
14989 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14990 .f = cmd_vf_tc_max_bw_parsed,
14992 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14995 (void *)&cmd_vf_tc_bw_set,
14996 (void *)&cmd_vf_tc_bw_vf,
14997 (void *)&cmd_vf_tc_bw_tc,
14998 (void *)&cmd_vf_tc_bw_tx,
14999 (void *)&cmd_vf_tc_bw_max_bw,
15000 (void *)&cmd_vf_tc_bw_port_id,
15001 (void *)&cmd_vf_tc_bw_vf_id,
15002 (void *)&cmd_vf_tc_bw_tc_no,
15003 (void *)&cmd_vf_tc_bw_bw,
15009 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15011 /* *** Set Port default Traffic Management Hierarchy *** */
15012 struct cmd_set_port_tm_hierarchy_default_result {
15013 cmdline_fixed_string_t set;
15014 cmdline_fixed_string_t port;
15015 cmdline_fixed_string_t tm;
15016 cmdline_fixed_string_t hierarchy;
15017 cmdline_fixed_string_t def;
15021 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15022 TOKEN_STRING_INITIALIZER(
15023 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15024 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15025 TOKEN_STRING_INITIALIZER(
15026 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15027 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15028 TOKEN_STRING_INITIALIZER(
15029 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15030 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15031 TOKEN_STRING_INITIALIZER(
15032 struct cmd_set_port_tm_hierarchy_default_result,
15033 hierarchy, "hierarchy");
15034 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15035 TOKEN_STRING_INITIALIZER(
15036 struct cmd_set_port_tm_hierarchy_default_result,
15038 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15039 TOKEN_NUM_INITIALIZER(
15040 struct cmd_set_port_tm_hierarchy_default_result,
15043 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15044 __attribute__((unused)) struct cmdline *cl,
15045 __attribute__((unused)) void *data)
15047 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15048 struct rte_port *p;
15049 portid_t port_id = res->port_id;
15051 if (port_id_is_invalid(port_id, ENABLED_WARN))
15054 p = &ports[port_id];
15056 /* Forward mode: tm */
15057 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15058 printf(" softnicfwd mode not enabled(error)\n");
15062 /* Set the default tm hierarchy */
15063 p->softport.default_tm_hierarchy_enable = 1;
15066 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15067 .f = cmd_set_port_tm_hierarchy_default_parsed,
15069 .help_str = "set port tm hierarchy default <port_id>",
15071 (void *)&cmd_set_port_tm_hierarchy_default_set,
15072 (void *)&cmd_set_port_tm_hierarchy_default_port,
15073 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15074 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15075 (void *)&cmd_set_port_tm_hierarchy_default_default,
15076 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15082 /** Set VXLAN encapsulation details */
15083 struct cmd_set_vxlan_result {
15084 cmdline_fixed_string_t set;
15085 cmdline_fixed_string_t vxlan;
15086 cmdline_fixed_string_t pos_token;
15087 cmdline_fixed_string_t ip_version;
15088 uint32_t vlan_present:1;
15092 cmdline_ipaddr_t ip_src;
15093 cmdline_ipaddr_t ip_dst;
15097 struct ether_addr eth_src;
15098 struct ether_addr eth_dst;
15101 cmdline_parse_token_string_t cmd_set_vxlan_set =
15102 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15103 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15104 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15105 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15106 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15108 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15109 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15110 "vxlan-with-vlan");
15111 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15112 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15114 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15115 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15117 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15118 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15120 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15121 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15122 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15123 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15125 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15126 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15127 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15128 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15130 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15131 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15132 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15133 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15135 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15136 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15137 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15138 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15140 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15141 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15142 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15143 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15145 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15146 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15147 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15148 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15150 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15151 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15152 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15153 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15155 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15156 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15157 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15158 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15160 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15161 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15162 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15163 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15165 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15166 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15168 static void cmd_set_vxlan_parsed(void *parsed_result,
15169 __attribute__((unused)) struct cmdline *cl,
15170 __attribute__((unused)) void *data)
15172 struct cmd_set_vxlan_result *res = parsed_result;
15177 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15180 vxlan_encap_conf.select_tos_ttl = 0;
15181 if (strcmp(res->vxlan, "vxlan") == 0)
15182 vxlan_encap_conf.select_vlan = 0;
15183 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15184 vxlan_encap_conf.select_vlan = 1;
15185 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15186 vxlan_encap_conf.select_vlan = 0;
15187 vxlan_encap_conf.select_tos_ttl = 1;
15189 if (strcmp(res->ip_version, "ipv4") == 0)
15190 vxlan_encap_conf.select_ipv4 = 1;
15191 else if (strcmp(res->ip_version, "ipv6") == 0)
15192 vxlan_encap_conf.select_ipv4 = 0;
15195 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15196 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15197 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15198 vxlan_encap_conf.ip_tos = res->tos;
15199 vxlan_encap_conf.ip_ttl = res->ttl;
15200 if (vxlan_encap_conf.select_ipv4) {
15201 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15202 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15204 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15205 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15207 if (vxlan_encap_conf.select_vlan)
15208 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15209 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15211 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15215 cmdline_parse_inst_t cmd_set_vxlan = {
15216 .f = cmd_set_vxlan_parsed,
15218 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15219 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15220 " eth-src <eth-src> eth-dst <eth-dst>",
15222 (void *)&cmd_set_vxlan_set,
15223 (void *)&cmd_set_vxlan_vxlan,
15224 (void *)&cmd_set_vxlan_ip_version,
15225 (void *)&cmd_set_vxlan_ip_version_value,
15226 (void *)&cmd_set_vxlan_vni,
15227 (void *)&cmd_set_vxlan_vni_value,
15228 (void *)&cmd_set_vxlan_udp_src,
15229 (void *)&cmd_set_vxlan_udp_src_value,
15230 (void *)&cmd_set_vxlan_udp_dst,
15231 (void *)&cmd_set_vxlan_udp_dst_value,
15232 (void *)&cmd_set_vxlan_ip_src,
15233 (void *)&cmd_set_vxlan_ip_src_value,
15234 (void *)&cmd_set_vxlan_ip_dst,
15235 (void *)&cmd_set_vxlan_ip_dst_value,
15236 (void *)&cmd_set_vxlan_eth_src,
15237 (void *)&cmd_set_vxlan_eth_src_value,
15238 (void *)&cmd_set_vxlan_eth_dst,
15239 (void *)&cmd_set_vxlan_eth_dst_value,
15244 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15245 .f = cmd_set_vxlan_parsed,
15247 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15248 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15249 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15250 " eth-dst <eth-dst>",
15252 (void *)&cmd_set_vxlan_set,
15253 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15254 (void *)&cmd_set_vxlan_ip_version,
15255 (void *)&cmd_set_vxlan_ip_version_value,
15256 (void *)&cmd_set_vxlan_vni,
15257 (void *)&cmd_set_vxlan_vni_value,
15258 (void *)&cmd_set_vxlan_udp_src,
15259 (void *)&cmd_set_vxlan_udp_src_value,
15260 (void *)&cmd_set_vxlan_udp_dst,
15261 (void *)&cmd_set_vxlan_udp_dst_value,
15262 (void *)&cmd_set_vxlan_ip_tos,
15263 (void *)&cmd_set_vxlan_ip_tos_value,
15264 (void *)&cmd_set_vxlan_ip_ttl,
15265 (void *)&cmd_set_vxlan_ip_ttl_value,
15266 (void *)&cmd_set_vxlan_ip_src,
15267 (void *)&cmd_set_vxlan_ip_src_value,
15268 (void *)&cmd_set_vxlan_ip_dst,
15269 (void *)&cmd_set_vxlan_ip_dst_value,
15270 (void *)&cmd_set_vxlan_eth_src,
15271 (void *)&cmd_set_vxlan_eth_src_value,
15272 (void *)&cmd_set_vxlan_eth_dst,
15273 (void *)&cmd_set_vxlan_eth_dst_value,
15278 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15279 .f = cmd_set_vxlan_parsed,
15281 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15282 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15283 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15286 (void *)&cmd_set_vxlan_set,
15287 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15288 (void *)&cmd_set_vxlan_ip_version,
15289 (void *)&cmd_set_vxlan_ip_version_value,
15290 (void *)&cmd_set_vxlan_vni,
15291 (void *)&cmd_set_vxlan_vni_value,
15292 (void *)&cmd_set_vxlan_udp_src,
15293 (void *)&cmd_set_vxlan_udp_src_value,
15294 (void *)&cmd_set_vxlan_udp_dst,
15295 (void *)&cmd_set_vxlan_udp_dst_value,
15296 (void *)&cmd_set_vxlan_ip_src,
15297 (void *)&cmd_set_vxlan_ip_src_value,
15298 (void *)&cmd_set_vxlan_ip_dst,
15299 (void *)&cmd_set_vxlan_ip_dst_value,
15300 (void *)&cmd_set_vxlan_vlan,
15301 (void *)&cmd_set_vxlan_vlan_value,
15302 (void *)&cmd_set_vxlan_eth_src,
15303 (void *)&cmd_set_vxlan_eth_src_value,
15304 (void *)&cmd_set_vxlan_eth_dst,
15305 (void *)&cmd_set_vxlan_eth_dst_value,
15310 /** Set NVGRE encapsulation details */
15311 struct cmd_set_nvgre_result {
15312 cmdline_fixed_string_t set;
15313 cmdline_fixed_string_t nvgre;
15314 cmdline_fixed_string_t pos_token;
15315 cmdline_fixed_string_t ip_version;
15317 cmdline_ipaddr_t ip_src;
15318 cmdline_ipaddr_t ip_dst;
15320 struct ether_addr eth_src;
15321 struct ether_addr eth_dst;
15324 cmdline_parse_token_string_t cmd_set_nvgre_set =
15325 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15326 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15327 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15328 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15329 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15330 "nvgre-with-vlan");
15331 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15332 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15334 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15335 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15337 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15338 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15340 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15341 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15342 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15343 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15345 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15346 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15347 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15348 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15350 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15351 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15352 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15353 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15355 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15356 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15357 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15358 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15360 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15361 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15362 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15363 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15365 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15366 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15368 static void cmd_set_nvgre_parsed(void *parsed_result,
15369 __attribute__((unused)) struct cmdline *cl,
15370 __attribute__((unused)) void *data)
15372 struct cmd_set_nvgre_result *res = parsed_result;
15374 uint32_t nvgre_tni;
15377 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15380 if (strcmp(res->nvgre, "nvgre") == 0)
15381 nvgre_encap_conf.select_vlan = 0;
15382 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15383 nvgre_encap_conf.select_vlan = 1;
15384 if (strcmp(res->ip_version, "ipv4") == 0)
15385 nvgre_encap_conf.select_ipv4 = 1;
15386 else if (strcmp(res->ip_version, "ipv6") == 0)
15387 nvgre_encap_conf.select_ipv4 = 0;
15390 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15391 if (nvgre_encap_conf.select_ipv4) {
15392 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15393 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15395 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15396 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15398 if (nvgre_encap_conf.select_vlan)
15399 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15400 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15402 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15406 cmdline_parse_inst_t cmd_set_nvgre = {
15407 .f = cmd_set_nvgre_parsed,
15409 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15410 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15411 " eth-dst <eth-dst>",
15413 (void *)&cmd_set_nvgre_set,
15414 (void *)&cmd_set_nvgre_nvgre,
15415 (void *)&cmd_set_nvgre_ip_version,
15416 (void *)&cmd_set_nvgre_ip_version_value,
15417 (void *)&cmd_set_nvgre_tni,
15418 (void *)&cmd_set_nvgre_tni_value,
15419 (void *)&cmd_set_nvgre_ip_src,
15420 (void *)&cmd_set_nvgre_ip_src_value,
15421 (void *)&cmd_set_nvgre_ip_dst,
15422 (void *)&cmd_set_nvgre_ip_dst_value,
15423 (void *)&cmd_set_nvgre_eth_src,
15424 (void *)&cmd_set_nvgre_eth_src_value,
15425 (void *)&cmd_set_nvgre_eth_dst,
15426 (void *)&cmd_set_nvgre_eth_dst_value,
15431 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15432 .f = cmd_set_nvgre_parsed,
15434 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15435 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15436 " eth-src <eth-src> eth-dst <eth-dst>",
15438 (void *)&cmd_set_nvgre_set,
15439 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15440 (void *)&cmd_set_nvgre_ip_version,
15441 (void *)&cmd_set_nvgre_ip_version_value,
15442 (void *)&cmd_set_nvgre_tni,
15443 (void *)&cmd_set_nvgre_tni_value,
15444 (void *)&cmd_set_nvgre_ip_src,
15445 (void *)&cmd_set_nvgre_ip_src_value,
15446 (void *)&cmd_set_nvgre_ip_dst,
15447 (void *)&cmd_set_nvgre_ip_dst_value,
15448 (void *)&cmd_set_nvgre_vlan,
15449 (void *)&cmd_set_nvgre_vlan_value,
15450 (void *)&cmd_set_nvgre_eth_src,
15451 (void *)&cmd_set_nvgre_eth_src_value,
15452 (void *)&cmd_set_nvgre_eth_dst,
15453 (void *)&cmd_set_nvgre_eth_dst_value,
15458 /** Set L2 encapsulation details */
15459 struct cmd_set_l2_encap_result {
15460 cmdline_fixed_string_t set;
15461 cmdline_fixed_string_t l2_encap;
15462 cmdline_fixed_string_t pos_token;
15463 cmdline_fixed_string_t ip_version;
15464 uint32_t vlan_present:1;
15466 struct ether_addr eth_src;
15467 struct ether_addr eth_dst;
15470 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15471 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15472 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15473 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15474 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15475 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15476 "l2_encap-with-vlan");
15477 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15478 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15480 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15481 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15483 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15484 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15486 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15487 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15488 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15489 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15491 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15492 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15493 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15494 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15496 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15497 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15499 static void cmd_set_l2_encap_parsed(void *parsed_result,
15500 __attribute__((unused)) struct cmdline *cl,
15501 __attribute__((unused)) void *data)
15503 struct cmd_set_l2_encap_result *res = parsed_result;
15505 if (strcmp(res->l2_encap, "l2_encap") == 0)
15506 l2_encap_conf.select_vlan = 0;
15507 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15508 l2_encap_conf.select_vlan = 1;
15509 if (strcmp(res->ip_version, "ipv4") == 0)
15510 l2_encap_conf.select_ipv4 = 1;
15511 else if (strcmp(res->ip_version, "ipv6") == 0)
15512 l2_encap_conf.select_ipv4 = 0;
15515 if (l2_encap_conf.select_vlan)
15516 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15517 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15519 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15523 cmdline_parse_inst_t cmd_set_l2_encap = {
15524 .f = cmd_set_l2_encap_parsed,
15526 .help_str = "set l2_encap ip-version ipv4|ipv6"
15527 " eth-src <eth-src> eth-dst <eth-dst>",
15529 (void *)&cmd_set_l2_encap_set,
15530 (void *)&cmd_set_l2_encap_l2_encap,
15531 (void *)&cmd_set_l2_encap_ip_version,
15532 (void *)&cmd_set_l2_encap_ip_version_value,
15533 (void *)&cmd_set_l2_encap_eth_src,
15534 (void *)&cmd_set_l2_encap_eth_src_value,
15535 (void *)&cmd_set_l2_encap_eth_dst,
15536 (void *)&cmd_set_l2_encap_eth_dst_value,
15541 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15542 .f = cmd_set_l2_encap_parsed,
15544 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15545 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15547 (void *)&cmd_set_l2_encap_set,
15548 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15549 (void *)&cmd_set_l2_encap_ip_version,
15550 (void *)&cmd_set_l2_encap_ip_version_value,
15551 (void *)&cmd_set_l2_encap_vlan,
15552 (void *)&cmd_set_l2_encap_vlan_value,
15553 (void *)&cmd_set_l2_encap_eth_src,
15554 (void *)&cmd_set_l2_encap_eth_src_value,
15555 (void *)&cmd_set_l2_encap_eth_dst,
15556 (void *)&cmd_set_l2_encap_eth_dst_value,
15561 /** Set L2 decapsulation details */
15562 struct cmd_set_l2_decap_result {
15563 cmdline_fixed_string_t set;
15564 cmdline_fixed_string_t l2_decap;
15565 cmdline_fixed_string_t pos_token;
15566 uint32_t vlan_present:1;
15569 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15570 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15571 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15572 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15574 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15575 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15576 "l2_decap-with-vlan");
15578 static void cmd_set_l2_decap_parsed(void *parsed_result,
15579 __attribute__((unused)) struct cmdline *cl,
15580 __attribute__((unused)) void *data)
15582 struct cmd_set_l2_decap_result *res = parsed_result;
15584 if (strcmp(res->l2_decap, "l2_decap") == 0)
15585 l2_decap_conf.select_vlan = 0;
15586 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15587 l2_decap_conf.select_vlan = 1;
15590 cmdline_parse_inst_t cmd_set_l2_decap = {
15591 .f = cmd_set_l2_decap_parsed,
15593 .help_str = "set l2_decap",
15595 (void *)&cmd_set_l2_decap_set,
15596 (void *)&cmd_set_l2_decap_l2_decap,
15601 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15602 .f = cmd_set_l2_decap_parsed,
15604 .help_str = "set l2_decap-with-vlan",
15606 (void *)&cmd_set_l2_decap_set,
15607 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15612 /** Set MPLSoGRE encapsulation details */
15613 struct cmd_set_mplsogre_encap_result {
15614 cmdline_fixed_string_t set;
15615 cmdline_fixed_string_t mplsogre;
15616 cmdline_fixed_string_t pos_token;
15617 cmdline_fixed_string_t ip_version;
15618 uint32_t vlan_present:1;
15620 cmdline_ipaddr_t ip_src;
15621 cmdline_ipaddr_t ip_dst;
15623 struct ether_addr eth_src;
15624 struct ether_addr eth_dst;
15627 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15628 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15630 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15631 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15633 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15634 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15635 mplsogre, "mplsogre_encap-with-vlan");
15636 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15637 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15638 pos_token, "ip-version");
15639 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15640 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15641 ip_version, "ipv4#ipv6");
15642 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15643 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15644 pos_token, "label");
15645 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15646 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15648 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15649 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15650 pos_token, "ip-src");
15651 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15652 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15653 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15654 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15655 pos_token, "ip-dst");
15656 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15657 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15658 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15659 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15660 pos_token, "vlan-tci");
15661 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15662 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15664 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15665 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15666 pos_token, "eth-src");
15667 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15668 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15670 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15671 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15672 pos_token, "eth-dst");
15673 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15674 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15677 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15678 __attribute__((unused)) struct cmdline *cl,
15679 __attribute__((unused)) void *data)
15681 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15683 uint32_t mplsogre_label;
15686 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15689 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15690 mplsogre_encap_conf.select_vlan = 0;
15691 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15692 mplsogre_encap_conf.select_vlan = 1;
15693 if (strcmp(res->ip_version, "ipv4") == 0)
15694 mplsogre_encap_conf.select_ipv4 = 1;
15695 else if (strcmp(res->ip_version, "ipv6") == 0)
15696 mplsogre_encap_conf.select_ipv4 = 0;
15699 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15700 if (mplsogre_encap_conf.select_ipv4) {
15701 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15702 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15704 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15705 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15707 if (mplsogre_encap_conf.select_vlan)
15708 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15709 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15711 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15715 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15716 .f = cmd_set_mplsogre_encap_parsed,
15718 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15719 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15720 " eth-dst <eth-dst>",
15722 (void *)&cmd_set_mplsogre_encap_set,
15723 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15724 (void *)&cmd_set_mplsogre_encap_ip_version,
15725 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15726 (void *)&cmd_set_mplsogre_encap_label,
15727 (void *)&cmd_set_mplsogre_encap_label_value,
15728 (void *)&cmd_set_mplsogre_encap_ip_src,
15729 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15730 (void *)&cmd_set_mplsogre_encap_ip_dst,
15731 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15732 (void *)&cmd_set_mplsogre_encap_eth_src,
15733 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15734 (void *)&cmd_set_mplsogre_encap_eth_dst,
15735 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15740 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15741 .f = cmd_set_mplsogre_encap_parsed,
15743 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15744 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15745 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15747 (void *)&cmd_set_mplsogre_encap_set,
15748 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15749 (void *)&cmd_set_mplsogre_encap_ip_version,
15750 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15751 (void *)&cmd_set_mplsogre_encap_label,
15752 (void *)&cmd_set_mplsogre_encap_label_value,
15753 (void *)&cmd_set_mplsogre_encap_ip_src,
15754 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15755 (void *)&cmd_set_mplsogre_encap_ip_dst,
15756 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15757 (void *)&cmd_set_mplsogre_encap_vlan,
15758 (void *)&cmd_set_mplsogre_encap_vlan_value,
15759 (void *)&cmd_set_mplsogre_encap_eth_src,
15760 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15761 (void *)&cmd_set_mplsogre_encap_eth_dst,
15762 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15767 /** Set MPLSoGRE decapsulation details */
15768 struct cmd_set_mplsogre_decap_result {
15769 cmdline_fixed_string_t set;
15770 cmdline_fixed_string_t mplsogre;
15771 cmdline_fixed_string_t pos_token;
15772 cmdline_fixed_string_t ip_version;
15773 uint32_t vlan_present:1;
15776 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15777 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15779 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15780 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15782 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15783 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15784 mplsogre, "mplsogre_decap-with-vlan");
15785 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15786 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15787 pos_token, "ip-version");
15788 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15789 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15790 ip_version, "ipv4#ipv6");
15792 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15793 __attribute__((unused)) struct cmdline *cl,
15794 __attribute__((unused)) void *data)
15796 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15798 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15799 mplsogre_decap_conf.select_vlan = 0;
15800 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15801 mplsogre_decap_conf.select_vlan = 1;
15802 if (strcmp(res->ip_version, "ipv4") == 0)
15803 mplsogre_decap_conf.select_ipv4 = 1;
15804 else if (strcmp(res->ip_version, "ipv6") == 0)
15805 mplsogre_decap_conf.select_ipv4 = 0;
15808 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15809 .f = cmd_set_mplsogre_decap_parsed,
15811 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15813 (void *)&cmd_set_mplsogre_decap_set,
15814 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15815 (void *)&cmd_set_mplsogre_decap_ip_version,
15816 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15821 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15822 .f = cmd_set_mplsogre_decap_parsed,
15824 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15826 (void *)&cmd_set_mplsogre_decap_set,
15827 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15828 (void *)&cmd_set_mplsogre_decap_ip_version,
15829 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15834 /** Set MPLSoUDP encapsulation details */
15835 struct cmd_set_mplsoudp_encap_result {
15836 cmdline_fixed_string_t set;
15837 cmdline_fixed_string_t mplsoudp;
15838 cmdline_fixed_string_t pos_token;
15839 cmdline_fixed_string_t ip_version;
15840 uint32_t vlan_present:1;
15844 cmdline_ipaddr_t ip_src;
15845 cmdline_ipaddr_t ip_dst;
15847 struct ether_addr eth_src;
15848 struct ether_addr eth_dst;
15851 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15852 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15854 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15855 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15857 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15858 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15859 mplsoudp, "mplsoudp_encap-with-vlan");
15860 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15861 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15862 pos_token, "ip-version");
15863 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15864 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15865 ip_version, "ipv4#ipv6");
15866 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15867 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15868 pos_token, "label");
15869 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15870 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15872 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15873 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15874 pos_token, "udp-src");
15875 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15876 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15878 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15879 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15880 pos_token, "udp-dst");
15881 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15882 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15884 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15885 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15886 pos_token, "ip-src");
15887 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
15888 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
15889 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
15890 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15891 pos_token, "ip-dst");
15892 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
15893 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
15894 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
15895 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15896 pos_token, "vlan-tci");
15897 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
15898 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
15900 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
15901 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15902 pos_token, "eth-src");
15903 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
15904 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15906 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
15907 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15908 pos_token, "eth-dst");
15909 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
15910 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15913 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
15914 __attribute__((unused)) struct cmdline *cl,
15915 __attribute__((unused)) void *data)
15917 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
15919 uint32_t mplsoudp_label;
15922 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
15925 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
15926 mplsoudp_encap_conf.select_vlan = 0;
15927 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
15928 mplsoudp_encap_conf.select_vlan = 1;
15929 if (strcmp(res->ip_version, "ipv4") == 0)
15930 mplsoudp_encap_conf.select_ipv4 = 1;
15931 else if (strcmp(res->ip_version, "ipv6") == 0)
15932 mplsoudp_encap_conf.select_ipv4 = 0;
15935 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
15936 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15937 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15938 if (mplsoudp_encap_conf.select_ipv4) {
15939 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
15940 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
15942 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
15943 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
15945 if (mplsoudp_encap_conf.select_vlan)
15946 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15947 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
15949 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15953 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15954 .f = cmd_set_mplsoudp_encap_parsed,
15956 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15957 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15958 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15960 (void *)&cmd_set_mplsoudp_encap_set,
15961 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15962 (void *)&cmd_set_mplsoudp_encap_ip_version,
15963 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15964 (void *)&cmd_set_mplsoudp_encap_label,
15965 (void *)&cmd_set_mplsoudp_encap_label_value,
15966 (void *)&cmd_set_mplsoudp_encap_udp_src,
15967 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15968 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15969 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15970 (void *)&cmd_set_mplsoudp_encap_ip_src,
15971 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15972 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15973 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15974 (void *)&cmd_set_mplsoudp_encap_eth_src,
15975 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15976 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15977 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15982 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15983 .f = cmd_set_mplsoudp_encap_parsed,
15985 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15986 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
15987 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15988 " eth-src <eth-src> eth-dst <eth-dst>",
15990 (void *)&cmd_set_mplsoudp_encap_set,
15991 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15992 (void *)&cmd_set_mplsoudp_encap_ip_version,
15993 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15994 (void *)&cmd_set_mplsoudp_encap_label,
15995 (void *)&cmd_set_mplsoudp_encap_label_value,
15996 (void *)&cmd_set_mplsoudp_encap_udp_src,
15997 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15998 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15999 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16000 (void *)&cmd_set_mplsoudp_encap_ip_src,
16001 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16002 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16003 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16004 (void *)&cmd_set_mplsoudp_encap_vlan,
16005 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16006 (void *)&cmd_set_mplsoudp_encap_eth_src,
16007 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16008 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16009 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16014 /** Set MPLSoUDP decapsulation details */
16015 struct cmd_set_mplsoudp_decap_result {
16016 cmdline_fixed_string_t set;
16017 cmdline_fixed_string_t mplsoudp;
16018 cmdline_fixed_string_t pos_token;
16019 cmdline_fixed_string_t ip_version;
16020 uint32_t vlan_present:1;
16023 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16024 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16026 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16027 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16029 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16030 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16031 mplsoudp, "mplsoudp_decap-with-vlan");
16032 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16033 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16034 pos_token, "ip-version");
16035 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16036 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16037 ip_version, "ipv4#ipv6");
16039 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16040 __attribute__((unused)) struct cmdline *cl,
16041 __attribute__((unused)) void *data)
16043 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16045 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16046 mplsoudp_decap_conf.select_vlan = 0;
16047 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16048 mplsoudp_decap_conf.select_vlan = 1;
16049 if (strcmp(res->ip_version, "ipv4") == 0)
16050 mplsoudp_decap_conf.select_ipv4 = 1;
16051 else if (strcmp(res->ip_version, "ipv6") == 0)
16052 mplsoudp_decap_conf.select_ipv4 = 0;
16055 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16056 .f = cmd_set_mplsoudp_decap_parsed,
16058 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16060 (void *)&cmd_set_mplsoudp_decap_set,
16061 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16062 (void *)&cmd_set_mplsoudp_decap_ip_version,
16063 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16068 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16069 .f = cmd_set_mplsoudp_decap_parsed,
16071 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16073 (void *)&cmd_set_mplsoudp_decap_set,
16074 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16075 (void *)&cmd_set_mplsoudp_decap_ip_version,
16076 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16081 /* Strict link priority scheduling mode setting */
16083 cmd_strict_link_prio_parsed(
16084 void *parsed_result,
16085 __attribute__((unused)) struct cmdline *cl,
16086 __attribute__((unused)) void *data)
16088 struct cmd_vf_tc_bw_result *res = parsed_result;
16089 int ret = -ENOTSUP;
16091 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16094 #ifdef RTE_LIBRTE_I40E_PMD
16095 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16102 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16105 printf("invalid port_id %d\n", res->port_id);
16108 printf("function not implemented\n");
16111 printf("programming error: (%s)\n", strerror(-ret));
16115 cmdline_parse_inst_t cmd_strict_link_prio = {
16116 .f = cmd_strict_link_prio_parsed,
16118 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16120 (void *)&cmd_vf_tc_bw_set,
16121 (void *)&cmd_vf_tc_bw_tx,
16122 (void *)&cmd_vf_tc_bw_strict_link_prio,
16123 (void *)&cmd_vf_tc_bw_port_id,
16124 (void *)&cmd_vf_tc_bw_tc_map,
16129 /* Load dynamic device personalization*/
16130 struct cmd_ddp_add_result {
16131 cmdline_fixed_string_t ddp;
16132 cmdline_fixed_string_t add;
16137 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16138 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16139 cmdline_parse_token_string_t cmd_ddp_add_add =
16140 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16141 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16142 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16143 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16144 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16147 cmd_ddp_add_parsed(
16148 void *parsed_result,
16149 __attribute__((unused)) struct cmdline *cl,
16150 __attribute__((unused)) void *data)
16152 struct cmd_ddp_add_result *res = parsed_result;
16158 int ret = -ENOTSUP;
16160 if (!all_ports_stopped()) {
16161 printf("Please stop all ports first\n");
16165 filepath = strdup(res->filepath);
16166 if (filepath == NULL) {
16167 printf("Failed to allocate memory\n");
16170 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16172 buff = open_file(file_fld[0], &size);
16174 free((void *)filepath);
16178 #ifdef RTE_LIBRTE_I40E_PMD
16179 if (ret == -ENOTSUP)
16180 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16182 RTE_PMD_I40E_PKG_OP_WR_ADD);
16185 if (ret == -EEXIST)
16186 printf("Profile has already existed.\n");
16188 printf("Failed to load profile.\n");
16189 else if (file_num == 2)
16190 save_file(file_fld[1], buff, size);
16193 free((void *)filepath);
16196 cmdline_parse_inst_t cmd_ddp_add = {
16197 .f = cmd_ddp_add_parsed,
16199 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16201 (void *)&cmd_ddp_add_ddp,
16202 (void *)&cmd_ddp_add_add,
16203 (void *)&cmd_ddp_add_port_id,
16204 (void *)&cmd_ddp_add_filepath,
16209 /* Delete dynamic device personalization*/
16210 struct cmd_ddp_del_result {
16211 cmdline_fixed_string_t ddp;
16212 cmdline_fixed_string_t del;
16217 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16218 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16219 cmdline_parse_token_string_t cmd_ddp_del_del =
16220 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16221 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16222 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16223 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16224 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16227 cmd_ddp_del_parsed(
16228 void *parsed_result,
16229 __attribute__((unused)) struct cmdline *cl,
16230 __attribute__((unused)) void *data)
16232 struct cmd_ddp_del_result *res = parsed_result;
16235 int ret = -ENOTSUP;
16237 if (!all_ports_stopped()) {
16238 printf("Please stop all ports first\n");
16242 buff = open_file(res->filepath, &size);
16246 #ifdef RTE_LIBRTE_I40E_PMD
16247 if (ret == -ENOTSUP)
16248 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16250 RTE_PMD_I40E_PKG_OP_WR_DEL);
16253 if (ret == -EACCES)
16254 printf("Profile does not exist.\n");
16256 printf("Failed to delete profile.\n");
16261 cmdline_parse_inst_t cmd_ddp_del = {
16262 .f = cmd_ddp_del_parsed,
16264 .help_str = "ddp del <port_id> <backup_profile_path>",
16266 (void *)&cmd_ddp_del_ddp,
16267 (void *)&cmd_ddp_del_del,
16268 (void *)&cmd_ddp_del_port_id,
16269 (void *)&cmd_ddp_del_filepath,
16274 /* Get dynamic device personalization profile info */
16275 struct cmd_ddp_info_result {
16276 cmdline_fixed_string_t ddp;
16277 cmdline_fixed_string_t get;
16278 cmdline_fixed_string_t info;
16282 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16283 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16284 cmdline_parse_token_string_t cmd_ddp_info_get =
16285 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16286 cmdline_parse_token_string_t cmd_ddp_info_info =
16287 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16288 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16289 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16292 cmd_ddp_info_parsed(
16293 void *parsed_result,
16294 __attribute__((unused)) struct cmdline *cl,
16295 __attribute__((unused)) void *data)
16297 struct cmd_ddp_info_result *res = parsed_result;
16300 int ret = -ENOTSUP;
16301 #ifdef RTE_LIBRTE_I40E_PMD
16304 uint32_t buff_size = 0;
16305 struct rte_pmd_i40e_profile_info info;
16306 uint32_t dev_num = 0;
16307 struct rte_pmd_i40e_ddp_device_id *devs;
16308 uint32_t proto_num = 0;
16309 struct rte_pmd_i40e_proto_info *proto = NULL;
16310 uint32_t pctype_num = 0;
16311 struct rte_pmd_i40e_ptype_info *pctype;
16312 uint32_t ptype_num = 0;
16313 struct rte_pmd_i40e_ptype_info *ptype;
16318 pkg = open_file(res->filepath, &pkg_size);
16322 #ifdef RTE_LIBRTE_I40E_PMD
16323 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16324 (uint8_t *)&info, sizeof(info),
16325 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16327 printf("Global Track id: 0x%x\n", info.track_id);
16328 printf("Global Version: %d.%d.%d.%d\n",
16329 info.version.major,
16330 info.version.minor,
16331 info.version.update,
16332 info.version.draft);
16333 printf("Global Package name: %s\n\n", info.name);
16336 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16337 (uint8_t *)&info, sizeof(info),
16338 RTE_PMD_I40E_PKG_INFO_HEADER);
16340 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16341 printf("i40e Profile Version: %d.%d.%d.%d\n",
16342 info.version.major,
16343 info.version.minor,
16344 info.version.update,
16345 info.version.draft);
16346 printf("i40e Profile name: %s\n\n", info.name);
16349 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16350 (uint8_t *)&buff_size, sizeof(buff_size),
16351 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16352 if (!ret && buff_size) {
16353 buff = (uint8_t *)malloc(buff_size);
16355 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16357 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16359 printf("Package Notes:\n%s\n\n", buff);
16364 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16365 (uint8_t *)&dev_num, sizeof(dev_num),
16366 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16367 if (!ret && dev_num) {
16368 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16369 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16371 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16372 (uint8_t *)devs, buff_size,
16373 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16375 printf("List of supported devices:\n");
16376 for (i = 0; i < dev_num; i++) {
16377 printf(" %04X:%04X %04X:%04X\n",
16378 devs[i].vendor_dev_id >> 16,
16379 devs[i].vendor_dev_id & 0xFFFF,
16380 devs[i].sub_vendor_dev_id >> 16,
16381 devs[i].sub_vendor_dev_id & 0xFFFF);
16389 /* get information about protocols and packet types */
16390 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16391 (uint8_t *)&proto_num, sizeof(proto_num),
16392 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16393 if (ret || !proto_num)
16394 goto no_print_return;
16396 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16397 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16399 goto no_print_return;
16401 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16403 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16405 printf("List of used protocols:\n");
16406 for (i = 0; i < proto_num; i++)
16407 printf(" %2u: %s\n", proto[i].proto_id,
16411 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16412 (uint8_t *)&pctype_num, sizeof(pctype_num),
16413 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16414 if (ret || !pctype_num)
16415 goto no_print_pctypes;
16417 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16418 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16420 goto no_print_pctypes;
16422 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16424 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16427 goto no_print_pctypes;
16430 printf("List of defined packet classification types:\n");
16431 for (i = 0; i < pctype_num; i++) {
16432 printf(" %2u:", pctype[i].ptype_id);
16433 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16434 proto_id = pctype[i].protocols[j];
16435 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16436 for (n = 0; n < proto_num; n++) {
16437 if (proto[n].proto_id == proto_id) {
16438 printf(" %s", proto[n].name);
16451 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16453 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16454 if (ret || !ptype_num)
16455 goto no_print_return;
16457 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16458 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16460 goto no_print_return;
16462 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16464 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16467 goto no_print_return;
16469 printf("List of defined packet types:\n");
16470 for (i = 0; i < ptype_num; i++) {
16471 printf(" %2u:", ptype[i].ptype_id);
16472 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16473 proto_id = ptype[i].protocols[j];
16474 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16475 for (n = 0; n < proto_num; n++) {
16476 if (proto[n].proto_id == proto_id) {
16477 printf(" %s", proto[n].name);
16493 if (ret == -ENOTSUP)
16494 printf("Function not supported in PMD driver\n");
16498 cmdline_parse_inst_t cmd_ddp_get_info = {
16499 .f = cmd_ddp_info_parsed,
16501 .help_str = "ddp get info <profile_path>",
16503 (void *)&cmd_ddp_info_ddp,
16504 (void *)&cmd_ddp_info_get,
16505 (void *)&cmd_ddp_info_info,
16506 (void *)&cmd_ddp_info_filepath,
16511 /* Get dynamic device personalization profile info list*/
16512 #define PROFILE_INFO_SIZE 48
16513 #define MAX_PROFILE_NUM 16
16515 struct cmd_ddp_get_list_result {
16516 cmdline_fixed_string_t ddp;
16517 cmdline_fixed_string_t get;
16518 cmdline_fixed_string_t list;
16522 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16523 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16524 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16525 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16526 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16527 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16528 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16529 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16532 cmd_ddp_get_list_parsed(
16533 __attribute__((unused)) void *parsed_result,
16534 __attribute__((unused)) struct cmdline *cl,
16535 __attribute__((unused)) void *data)
16537 #ifdef RTE_LIBRTE_I40E_PMD
16538 struct cmd_ddp_get_list_result *res = parsed_result;
16539 struct rte_pmd_i40e_profile_list *p_list;
16540 struct rte_pmd_i40e_profile_info *p_info;
16545 int ret = -ENOTSUP;
16547 #ifdef RTE_LIBRTE_I40E_PMD
16548 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16549 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16551 printf("%s: Failed to malloc buffer\n", __func__);
16553 if (ret == -ENOTSUP)
16554 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16555 (uint8_t *)p_list, size);
16558 p_num = p_list->p_count;
16559 printf("Profile number is: %d\n\n", p_num);
16561 for (i = 0; i < p_num; i++) {
16562 p_info = &p_list->p_info[i];
16563 printf("Profile %d:\n", i);
16564 printf("Track id: 0x%x\n", p_info->track_id);
16565 printf("Version: %d.%d.%d.%d\n",
16566 p_info->version.major,
16567 p_info->version.minor,
16568 p_info->version.update,
16569 p_info->version.draft);
16570 printf("Profile name: %s\n\n", p_info->name);
16578 printf("Failed to get ddp list\n");
16581 cmdline_parse_inst_t cmd_ddp_get_list = {
16582 .f = cmd_ddp_get_list_parsed,
16584 .help_str = "ddp get list <port_id>",
16586 (void *)&cmd_ddp_get_list_ddp,
16587 (void *)&cmd_ddp_get_list_get,
16588 (void *)&cmd_ddp_get_list_list,
16589 (void *)&cmd_ddp_get_list_port_id,
16594 /* Configure input set */
16595 struct cmd_cfg_input_set_result {
16596 cmdline_fixed_string_t port;
16597 cmdline_fixed_string_t cfg;
16599 cmdline_fixed_string_t pctype;
16601 cmdline_fixed_string_t inset_type;
16602 cmdline_fixed_string_t opt;
16603 cmdline_fixed_string_t field;
16608 cmd_cfg_input_set_parsed(
16609 __attribute__((unused)) void *parsed_result,
16610 __attribute__((unused)) struct cmdline *cl,
16611 __attribute__((unused)) void *data)
16613 #ifdef RTE_LIBRTE_I40E_PMD
16614 struct cmd_cfg_input_set_result *res = parsed_result;
16615 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16616 struct rte_pmd_i40e_inset inset;
16618 int ret = -ENOTSUP;
16620 if (!all_ports_stopped()) {
16621 printf("Please stop all ports first\n");
16625 #ifdef RTE_LIBRTE_I40E_PMD
16626 if (!strcmp(res->inset_type, "hash_inset"))
16627 inset_type = INSET_HASH;
16628 else if (!strcmp(res->inset_type, "fdir_inset"))
16629 inset_type = INSET_FDIR;
16630 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16631 inset_type = INSET_FDIR_FLX;
16632 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16633 &inset, inset_type);
16635 printf("Failed to get input set.\n");
16639 if (!strcmp(res->opt, "get")) {
16640 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16643 printf("Field index %d is enabled.\n", res->field_idx);
16645 printf("Field index %d is disabled.\n", res->field_idx);
16647 } else if (!strcmp(res->opt, "set"))
16648 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16650 else if (!strcmp(res->opt, "clear"))
16651 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16654 printf("Failed to configure input set field.\n");
16658 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16659 &inset, inset_type);
16661 printf("Failed to set input set.\n");
16666 if (ret == -ENOTSUP)
16667 printf("Function not supported\n");
16670 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16671 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16673 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16674 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16676 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16677 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16679 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16680 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16682 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16683 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16685 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16686 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16688 "hash_inset#fdir_inset#fdir_flx_inset");
16689 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16690 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16691 opt, "get#set#clear");
16692 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16693 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16695 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16696 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16699 cmdline_parse_inst_t cmd_cfg_input_set = {
16700 .f = cmd_cfg_input_set_parsed,
16702 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16703 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16705 (void *)&cmd_cfg_input_set_port,
16706 (void *)&cmd_cfg_input_set_cfg,
16707 (void *)&cmd_cfg_input_set_port_id,
16708 (void *)&cmd_cfg_input_set_pctype,
16709 (void *)&cmd_cfg_input_set_pctype_id,
16710 (void *)&cmd_cfg_input_set_inset_type,
16711 (void *)&cmd_cfg_input_set_opt,
16712 (void *)&cmd_cfg_input_set_field,
16713 (void *)&cmd_cfg_input_set_field_idx,
16718 /* Clear input set */
16719 struct cmd_clear_input_set_result {
16720 cmdline_fixed_string_t port;
16721 cmdline_fixed_string_t cfg;
16723 cmdline_fixed_string_t pctype;
16725 cmdline_fixed_string_t inset_type;
16726 cmdline_fixed_string_t clear;
16727 cmdline_fixed_string_t all;
16731 cmd_clear_input_set_parsed(
16732 __attribute__((unused)) void *parsed_result,
16733 __attribute__((unused)) struct cmdline *cl,
16734 __attribute__((unused)) void *data)
16736 #ifdef RTE_LIBRTE_I40E_PMD
16737 struct cmd_clear_input_set_result *res = parsed_result;
16738 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16739 struct rte_pmd_i40e_inset inset;
16741 int ret = -ENOTSUP;
16743 if (!all_ports_stopped()) {
16744 printf("Please stop all ports first\n");
16748 #ifdef RTE_LIBRTE_I40E_PMD
16749 if (!strcmp(res->inset_type, "hash_inset"))
16750 inset_type = INSET_HASH;
16751 else if (!strcmp(res->inset_type, "fdir_inset"))
16752 inset_type = INSET_FDIR;
16753 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16754 inset_type = INSET_FDIR_FLX;
16756 memset(&inset, 0, sizeof(inset));
16758 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16759 &inset, inset_type);
16761 printf("Failed to clear input set.\n");
16767 if (ret == -ENOTSUP)
16768 printf("Function not supported\n");
16771 cmdline_parse_token_string_t cmd_clear_input_set_port =
16772 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16774 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16775 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16777 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16778 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16780 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16781 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16783 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16784 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16786 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16787 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16789 "hash_inset#fdir_inset#fdir_flx_inset");
16790 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16791 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16793 cmdline_parse_token_string_t cmd_clear_input_set_all =
16794 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16797 cmdline_parse_inst_t cmd_clear_input_set = {
16798 .f = cmd_clear_input_set_parsed,
16800 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16801 "fdir_inset|fdir_flx_inset clear all",
16803 (void *)&cmd_clear_input_set_port,
16804 (void *)&cmd_clear_input_set_cfg,
16805 (void *)&cmd_clear_input_set_port_id,
16806 (void *)&cmd_clear_input_set_pctype,
16807 (void *)&cmd_clear_input_set_pctype_id,
16808 (void *)&cmd_clear_input_set_inset_type,
16809 (void *)&cmd_clear_input_set_clear,
16810 (void *)&cmd_clear_input_set_all,
16815 /* show vf stats */
16817 /* Common result structure for show vf stats */
16818 struct cmd_show_vf_stats_result {
16819 cmdline_fixed_string_t show;
16820 cmdline_fixed_string_t vf;
16821 cmdline_fixed_string_t stats;
16826 /* Common CLI fields show vf stats*/
16827 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16828 TOKEN_STRING_INITIALIZER
16829 (struct cmd_show_vf_stats_result,
16831 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16832 TOKEN_STRING_INITIALIZER
16833 (struct cmd_show_vf_stats_result,
16835 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16836 TOKEN_STRING_INITIALIZER
16837 (struct cmd_show_vf_stats_result,
16839 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16840 TOKEN_NUM_INITIALIZER
16841 (struct cmd_show_vf_stats_result,
16843 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16844 TOKEN_NUM_INITIALIZER
16845 (struct cmd_show_vf_stats_result,
16849 cmd_show_vf_stats_parsed(
16850 void *parsed_result,
16851 __attribute__((unused)) struct cmdline *cl,
16852 __attribute__((unused)) void *data)
16854 struct cmd_show_vf_stats_result *res = parsed_result;
16855 struct rte_eth_stats stats;
16856 int ret = -ENOTSUP;
16857 static const char *nic_stats_border = "########################";
16859 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16862 memset(&stats, 0, sizeof(stats));
16864 #ifdef RTE_LIBRTE_I40E_PMD
16865 if (ret == -ENOTSUP)
16866 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16870 #ifdef RTE_LIBRTE_BNXT_PMD
16871 if (ret == -ENOTSUP)
16872 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16881 printf("invalid vf_id %d\n", res->vf_id);
16884 printf("invalid port_id %d\n", res->port_id);
16887 printf("function not implemented\n");
16890 printf("programming error: (%s)\n", strerror(-ret));
16893 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16894 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16896 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16898 stats.ipackets, stats.imissed, stats.ibytes);
16899 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16900 printf(" RX-nombuf: %-10"PRIu64"\n",
16902 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16904 stats.opackets, stats.oerrors, stats.obytes);
16906 printf(" %s############################%s\n",
16907 nic_stats_border, nic_stats_border);
16910 cmdline_parse_inst_t cmd_show_vf_stats = {
16911 .f = cmd_show_vf_stats_parsed,
16913 .help_str = "show vf stats <port_id> <vf_id>",
16915 (void *)&cmd_show_vf_stats_show,
16916 (void *)&cmd_show_vf_stats_vf,
16917 (void *)&cmd_show_vf_stats_stats,
16918 (void *)&cmd_show_vf_stats_port_id,
16919 (void *)&cmd_show_vf_stats_vf_id,
16924 /* clear vf stats */
16926 /* Common result structure for clear vf stats */
16927 struct cmd_clear_vf_stats_result {
16928 cmdline_fixed_string_t clear;
16929 cmdline_fixed_string_t vf;
16930 cmdline_fixed_string_t stats;
16935 /* Common CLI fields clear vf stats*/
16936 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16937 TOKEN_STRING_INITIALIZER
16938 (struct cmd_clear_vf_stats_result,
16940 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16941 TOKEN_STRING_INITIALIZER
16942 (struct cmd_clear_vf_stats_result,
16944 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16945 TOKEN_STRING_INITIALIZER
16946 (struct cmd_clear_vf_stats_result,
16948 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16949 TOKEN_NUM_INITIALIZER
16950 (struct cmd_clear_vf_stats_result,
16952 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16953 TOKEN_NUM_INITIALIZER
16954 (struct cmd_clear_vf_stats_result,
16958 cmd_clear_vf_stats_parsed(
16959 void *parsed_result,
16960 __attribute__((unused)) struct cmdline *cl,
16961 __attribute__((unused)) void *data)
16963 struct cmd_clear_vf_stats_result *res = parsed_result;
16964 int ret = -ENOTSUP;
16966 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16969 #ifdef RTE_LIBRTE_I40E_PMD
16970 if (ret == -ENOTSUP)
16971 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16974 #ifdef RTE_LIBRTE_BNXT_PMD
16975 if (ret == -ENOTSUP)
16976 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16984 printf("invalid vf_id %d\n", res->vf_id);
16987 printf("invalid port_id %d\n", res->port_id);
16990 printf("function not implemented\n");
16993 printf("programming error: (%s)\n", strerror(-ret));
16997 cmdline_parse_inst_t cmd_clear_vf_stats = {
16998 .f = cmd_clear_vf_stats_parsed,
17000 .help_str = "clear vf stats <port_id> <vf_id>",
17002 (void *)&cmd_clear_vf_stats_clear,
17003 (void *)&cmd_clear_vf_stats_vf,
17004 (void *)&cmd_clear_vf_stats_stats,
17005 (void *)&cmd_clear_vf_stats_port_id,
17006 (void *)&cmd_clear_vf_stats_vf_id,
17011 /* port config pctype mapping reset */
17013 /* Common result structure for port config pctype mapping reset */
17014 struct cmd_pctype_mapping_reset_result {
17015 cmdline_fixed_string_t port;
17016 cmdline_fixed_string_t config;
17018 cmdline_fixed_string_t pctype;
17019 cmdline_fixed_string_t mapping;
17020 cmdline_fixed_string_t reset;
17023 /* Common CLI fields for port config pctype mapping reset*/
17024 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17025 TOKEN_STRING_INITIALIZER
17026 (struct cmd_pctype_mapping_reset_result,
17028 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17029 TOKEN_STRING_INITIALIZER
17030 (struct cmd_pctype_mapping_reset_result,
17032 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17033 TOKEN_NUM_INITIALIZER
17034 (struct cmd_pctype_mapping_reset_result,
17036 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17037 TOKEN_STRING_INITIALIZER
17038 (struct cmd_pctype_mapping_reset_result,
17040 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17041 TOKEN_STRING_INITIALIZER
17042 (struct cmd_pctype_mapping_reset_result,
17043 mapping, "mapping");
17044 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17045 TOKEN_STRING_INITIALIZER
17046 (struct cmd_pctype_mapping_reset_result,
17050 cmd_pctype_mapping_reset_parsed(
17051 void *parsed_result,
17052 __attribute__((unused)) struct cmdline *cl,
17053 __attribute__((unused)) void *data)
17055 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17056 int ret = -ENOTSUP;
17058 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17061 #ifdef RTE_LIBRTE_I40E_PMD
17062 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17069 printf("invalid port_id %d\n", res->port_id);
17072 printf("function not implemented\n");
17075 printf("programming error: (%s)\n", strerror(-ret));
17079 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17080 .f = cmd_pctype_mapping_reset_parsed,
17082 .help_str = "port config <port_id> pctype mapping reset",
17084 (void *)&cmd_pctype_mapping_reset_port,
17085 (void *)&cmd_pctype_mapping_reset_config,
17086 (void *)&cmd_pctype_mapping_reset_port_id,
17087 (void *)&cmd_pctype_mapping_reset_pctype,
17088 (void *)&cmd_pctype_mapping_reset_mapping,
17089 (void *)&cmd_pctype_mapping_reset_reset,
17094 /* show port pctype mapping */
17096 /* Common result structure for show port pctype mapping */
17097 struct cmd_pctype_mapping_get_result {
17098 cmdline_fixed_string_t show;
17099 cmdline_fixed_string_t port;
17101 cmdline_fixed_string_t pctype;
17102 cmdline_fixed_string_t mapping;
17105 /* Common CLI fields for pctype mapping get */
17106 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17107 TOKEN_STRING_INITIALIZER
17108 (struct cmd_pctype_mapping_get_result,
17110 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17111 TOKEN_STRING_INITIALIZER
17112 (struct cmd_pctype_mapping_get_result,
17114 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17115 TOKEN_NUM_INITIALIZER
17116 (struct cmd_pctype_mapping_get_result,
17118 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17119 TOKEN_STRING_INITIALIZER
17120 (struct cmd_pctype_mapping_get_result,
17122 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17123 TOKEN_STRING_INITIALIZER
17124 (struct cmd_pctype_mapping_get_result,
17125 mapping, "mapping");
17128 cmd_pctype_mapping_get_parsed(
17129 void *parsed_result,
17130 __attribute__((unused)) struct cmdline *cl,
17131 __attribute__((unused)) void *data)
17133 struct cmd_pctype_mapping_get_result *res = parsed_result;
17134 int ret = -ENOTSUP;
17135 #ifdef RTE_LIBRTE_I40E_PMD
17136 struct rte_pmd_i40e_flow_type_mapping
17137 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17138 int i, j, first_pctype;
17141 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17144 #ifdef RTE_LIBRTE_I40E_PMD
17145 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17152 printf("invalid port_id %d\n", res->port_id);
17155 printf("function not implemented\n");
17158 printf("programming error: (%s)\n", strerror(-ret));
17162 #ifdef RTE_LIBRTE_I40E_PMD
17163 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17164 if (mapping[i].pctype != 0ULL) {
17167 printf("pctype: ");
17168 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17169 if (mapping[i].pctype & (1ULL << j)) {
17170 printf(first_pctype ?
17171 "%02d" : ",%02d", j);
17175 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17181 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17182 .f = cmd_pctype_mapping_get_parsed,
17184 .help_str = "show port <port_id> pctype mapping",
17186 (void *)&cmd_pctype_mapping_get_show,
17187 (void *)&cmd_pctype_mapping_get_port,
17188 (void *)&cmd_pctype_mapping_get_port_id,
17189 (void *)&cmd_pctype_mapping_get_pctype,
17190 (void *)&cmd_pctype_mapping_get_mapping,
17195 /* port config pctype mapping update */
17197 /* Common result structure for port config pctype mapping update */
17198 struct cmd_pctype_mapping_update_result {
17199 cmdline_fixed_string_t port;
17200 cmdline_fixed_string_t config;
17202 cmdline_fixed_string_t pctype;
17203 cmdline_fixed_string_t mapping;
17204 cmdline_fixed_string_t update;
17205 cmdline_fixed_string_t pctype_list;
17206 uint16_t flow_type;
17209 /* Common CLI fields for pctype mapping update*/
17210 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17211 TOKEN_STRING_INITIALIZER
17212 (struct cmd_pctype_mapping_update_result,
17214 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17215 TOKEN_STRING_INITIALIZER
17216 (struct cmd_pctype_mapping_update_result,
17218 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17219 TOKEN_NUM_INITIALIZER
17220 (struct cmd_pctype_mapping_update_result,
17222 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17223 TOKEN_STRING_INITIALIZER
17224 (struct cmd_pctype_mapping_update_result,
17226 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17227 TOKEN_STRING_INITIALIZER
17228 (struct cmd_pctype_mapping_update_result,
17229 mapping, "mapping");
17230 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17231 TOKEN_STRING_INITIALIZER
17232 (struct cmd_pctype_mapping_update_result,
17234 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17235 TOKEN_STRING_INITIALIZER
17236 (struct cmd_pctype_mapping_update_result,
17237 pctype_list, NULL);
17238 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17239 TOKEN_NUM_INITIALIZER
17240 (struct cmd_pctype_mapping_update_result,
17241 flow_type, UINT16);
17244 cmd_pctype_mapping_update_parsed(
17245 void *parsed_result,
17246 __attribute__((unused)) struct cmdline *cl,
17247 __attribute__((unused)) void *data)
17249 struct cmd_pctype_mapping_update_result *res = parsed_result;
17250 int ret = -ENOTSUP;
17251 #ifdef RTE_LIBRTE_I40E_PMD
17252 struct rte_pmd_i40e_flow_type_mapping mapping;
17254 unsigned int nb_item;
17255 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17258 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17261 #ifdef RTE_LIBRTE_I40E_PMD
17262 nb_item = parse_item_list(res->pctype_list, "pctypes",
17263 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17264 mapping.flow_type = res->flow_type;
17265 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17266 mapping.pctype |= (1ULL << pctype_list[i]);
17267 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17277 printf("invalid pctype or flow type\n");
17280 printf("invalid port_id %d\n", res->port_id);
17283 printf("function not implemented\n");
17286 printf("programming error: (%s)\n", strerror(-ret));
17290 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17291 .f = cmd_pctype_mapping_update_parsed,
17293 .help_str = "port config <port_id> pctype mapping update"
17294 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17296 (void *)&cmd_pctype_mapping_update_port,
17297 (void *)&cmd_pctype_mapping_update_config,
17298 (void *)&cmd_pctype_mapping_update_port_id,
17299 (void *)&cmd_pctype_mapping_update_pctype,
17300 (void *)&cmd_pctype_mapping_update_mapping,
17301 (void *)&cmd_pctype_mapping_update_update,
17302 (void *)&cmd_pctype_mapping_update_pc_type,
17303 (void *)&cmd_pctype_mapping_update_flow_type,
17308 /* ptype mapping get */
17310 /* Common result structure for ptype mapping get */
17311 struct cmd_ptype_mapping_get_result {
17312 cmdline_fixed_string_t ptype;
17313 cmdline_fixed_string_t mapping;
17314 cmdline_fixed_string_t get;
17316 uint8_t valid_only;
17319 /* Common CLI fields for ptype mapping get */
17320 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17321 TOKEN_STRING_INITIALIZER
17322 (struct cmd_ptype_mapping_get_result,
17324 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17325 TOKEN_STRING_INITIALIZER
17326 (struct cmd_ptype_mapping_get_result,
17327 mapping, "mapping");
17328 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17329 TOKEN_STRING_INITIALIZER
17330 (struct cmd_ptype_mapping_get_result,
17332 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17333 TOKEN_NUM_INITIALIZER
17334 (struct cmd_ptype_mapping_get_result,
17336 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17337 TOKEN_NUM_INITIALIZER
17338 (struct cmd_ptype_mapping_get_result,
17339 valid_only, UINT8);
17342 cmd_ptype_mapping_get_parsed(
17343 void *parsed_result,
17344 __attribute__((unused)) struct cmdline *cl,
17345 __attribute__((unused)) void *data)
17347 struct cmd_ptype_mapping_get_result *res = parsed_result;
17348 int ret = -ENOTSUP;
17349 #ifdef RTE_LIBRTE_I40E_PMD
17350 int max_ptype_num = 256;
17351 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17356 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17359 #ifdef RTE_LIBRTE_I40E_PMD
17360 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17371 printf("invalid port_id %d\n", res->port_id);
17374 printf("function not implemented\n");
17377 printf("programming error: (%s)\n", strerror(-ret));
17380 #ifdef RTE_LIBRTE_I40E_PMD
17382 for (i = 0; i < count; i++)
17383 printf("%3d\t0x%08x\n",
17384 mapping[i].hw_ptype, mapping[i].sw_ptype);
17389 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17390 .f = cmd_ptype_mapping_get_parsed,
17392 .help_str = "ptype mapping get <port_id> <valid_only>",
17394 (void *)&cmd_ptype_mapping_get_ptype,
17395 (void *)&cmd_ptype_mapping_get_mapping,
17396 (void *)&cmd_ptype_mapping_get_get,
17397 (void *)&cmd_ptype_mapping_get_port_id,
17398 (void *)&cmd_ptype_mapping_get_valid_only,
17403 /* ptype mapping replace */
17405 /* Common result structure for ptype mapping replace */
17406 struct cmd_ptype_mapping_replace_result {
17407 cmdline_fixed_string_t ptype;
17408 cmdline_fixed_string_t mapping;
17409 cmdline_fixed_string_t replace;
17416 /* Common CLI fields for ptype mapping replace */
17417 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17418 TOKEN_STRING_INITIALIZER
17419 (struct cmd_ptype_mapping_replace_result,
17421 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17422 TOKEN_STRING_INITIALIZER
17423 (struct cmd_ptype_mapping_replace_result,
17424 mapping, "mapping");
17425 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17426 TOKEN_STRING_INITIALIZER
17427 (struct cmd_ptype_mapping_replace_result,
17428 replace, "replace");
17429 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17430 TOKEN_NUM_INITIALIZER
17431 (struct cmd_ptype_mapping_replace_result,
17433 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17434 TOKEN_NUM_INITIALIZER
17435 (struct cmd_ptype_mapping_replace_result,
17437 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17438 TOKEN_NUM_INITIALIZER
17439 (struct cmd_ptype_mapping_replace_result,
17441 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17442 TOKEN_NUM_INITIALIZER
17443 (struct cmd_ptype_mapping_replace_result,
17447 cmd_ptype_mapping_replace_parsed(
17448 void *parsed_result,
17449 __attribute__((unused)) struct cmdline *cl,
17450 __attribute__((unused)) void *data)
17452 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17453 int ret = -ENOTSUP;
17455 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17458 #ifdef RTE_LIBRTE_I40E_PMD
17459 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17469 printf("invalid ptype 0x%8x or 0x%8x\n",
17470 res->target, res->pkt_type);
17473 printf("invalid port_id %d\n", res->port_id);
17476 printf("function not implemented\n");
17479 printf("programming error: (%s)\n", strerror(-ret));
17483 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17484 .f = cmd_ptype_mapping_replace_parsed,
17487 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17489 (void *)&cmd_ptype_mapping_replace_ptype,
17490 (void *)&cmd_ptype_mapping_replace_mapping,
17491 (void *)&cmd_ptype_mapping_replace_replace,
17492 (void *)&cmd_ptype_mapping_replace_port_id,
17493 (void *)&cmd_ptype_mapping_replace_target,
17494 (void *)&cmd_ptype_mapping_replace_mask,
17495 (void *)&cmd_ptype_mapping_replace_pkt_type,
17500 /* ptype mapping reset */
17502 /* Common result structure for ptype mapping reset */
17503 struct cmd_ptype_mapping_reset_result {
17504 cmdline_fixed_string_t ptype;
17505 cmdline_fixed_string_t mapping;
17506 cmdline_fixed_string_t reset;
17510 /* Common CLI fields for ptype mapping reset*/
17511 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17512 TOKEN_STRING_INITIALIZER
17513 (struct cmd_ptype_mapping_reset_result,
17515 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17516 TOKEN_STRING_INITIALIZER
17517 (struct cmd_ptype_mapping_reset_result,
17518 mapping, "mapping");
17519 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17520 TOKEN_STRING_INITIALIZER
17521 (struct cmd_ptype_mapping_reset_result,
17523 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17524 TOKEN_NUM_INITIALIZER
17525 (struct cmd_ptype_mapping_reset_result,
17529 cmd_ptype_mapping_reset_parsed(
17530 void *parsed_result,
17531 __attribute__((unused)) struct cmdline *cl,
17532 __attribute__((unused)) void *data)
17534 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17535 int ret = -ENOTSUP;
17537 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17540 #ifdef RTE_LIBRTE_I40E_PMD
17541 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17548 printf("invalid port_id %d\n", res->port_id);
17551 printf("function not implemented\n");
17554 printf("programming error: (%s)\n", strerror(-ret));
17558 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17559 .f = cmd_ptype_mapping_reset_parsed,
17561 .help_str = "ptype mapping reset <port_id>",
17563 (void *)&cmd_ptype_mapping_reset_ptype,
17564 (void *)&cmd_ptype_mapping_reset_mapping,
17565 (void *)&cmd_ptype_mapping_reset_reset,
17566 (void *)&cmd_ptype_mapping_reset_port_id,
17571 /* ptype mapping update */
17573 /* Common result structure for ptype mapping update */
17574 struct cmd_ptype_mapping_update_result {
17575 cmdline_fixed_string_t ptype;
17576 cmdline_fixed_string_t mapping;
17577 cmdline_fixed_string_t reset;
17583 /* Common CLI fields for ptype mapping update*/
17584 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17585 TOKEN_STRING_INITIALIZER
17586 (struct cmd_ptype_mapping_update_result,
17588 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17589 TOKEN_STRING_INITIALIZER
17590 (struct cmd_ptype_mapping_update_result,
17591 mapping, "mapping");
17592 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17593 TOKEN_STRING_INITIALIZER
17594 (struct cmd_ptype_mapping_update_result,
17596 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17597 TOKEN_NUM_INITIALIZER
17598 (struct cmd_ptype_mapping_update_result,
17600 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17601 TOKEN_NUM_INITIALIZER
17602 (struct cmd_ptype_mapping_update_result,
17604 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17605 TOKEN_NUM_INITIALIZER
17606 (struct cmd_ptype_mapping_update_result,
17610 cmd_ptype_mapping_update_parsed(
17611 void *parsed_result,
17612 __attribute__((unused)) struct cmdline *cl,
17613 __attribute__((unused)) void *data)
17615 struct cmd_ptype_mapping_update_result *res = parsed_result;
17616 int ret = -ENOTSUP;
17617 #ifdef RTE_LIBRTE_I40E_PMD
17618 struct rte_pmd_i40e_ptype_mapping mapping;
17620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17623 #ifdef RTE_LIBRTE_I40E_PMD
17624 mapping.hw_ptype = res->hw_ptype;
17625 mapping.sw_ptype = res->sw_ptype;
17626 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17636 printf("invalid ptype 0x%8x\n", res->sw_ptype);
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_update = {
17650 .f = cmd_ptype_mapping_update_parsed,
17652 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17654 (void *)&cmd_ptype_mapping_update_ptype,
17655 (void *)&cmd_ptype_mapping_update_mapping,
17656 (void *)&cmd_ptype_mapping_update_update,
17657 (void *)&cmd_ptype_mapping_update_port_id,
17658 (void *)&cmd_ptype_mapping_update_hw_ptype,
17659 (void *)&cmd_ptype_mapping_update_sw_ptype,
17664 /* Common result structure for file commands */
17665 struct cmd_cmdfile_result {
17666 cmdline_fixed_string_t load;
17667 cmdline_fixed_string_t filename;
17670 /* Common CLI fields for file commands */
17671 cmdline_parse_token_string_t cmd_load_cmdfile =
17672 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17673 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17674 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17677 cmd_load_from_file_parsed(
17678 void *parsed_result,
17679 __attribute__((unused)) struct cmdline *cl,
17680 __attribute__((unused)) void *data)
17682 struct cmd_cmdfile_result *res = parsed_result;
17684 cmdline_read_from_file(res->filename);
17687 cmdline_parse_inst_t cmd_load_from_file = {
17688 .f = cmd_load_from_file_parsed,
17690 .help_str = "load <filename>",
17692 (void *)&cmd_load_cmdfile,
17693 (void *)&cmd_load_cmdfile_filename,
17698 /* Get Rx offloads capabilities */
17699 struct cmd_rx_offload_get_capa_result {
17700 cmdline_fixed_string_t show;
17701 cmdline_fixed_string_t port;
17703 cmdline_fixed_string_t rx_offload;
17704 cmdline_fixed_string_t capabilities;
17707 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17708 TOKEN_STRING_INITIALIZER
17709 (struct cmd_rx_offload_get_capa_result,
17711 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17712 TOKEN_STRING_INITIALIZER
17713 (struct cmd_rx_offload_get_capa_result,
17715 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17716 TOKEN_NUM_INITIALIZER
17717 (struct cmd_rx_offload_get_capa_result,
17719 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17720 TOKEN_STRING_INITIALIZER
17721 (struct cmd_rx_offload_get_capa_result,
17722 rx_offload, "rx_offload");
17723 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17724 TOKEN_STRING_INITIALIZER
17725 (struct cmd_rx_offload_get_capa_result,
17726 capabilities, "capabilities");
17729 print_rx_offloads(uint64_t offloads)
17731 uint64_t single_offload;
17739 begin = __builtin_ctzll(offloads);
17740 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17742 single_offload = 1 << begin;
17743 for (bit = begin; bit < end; bit++) {
17744 if (offloads & single_offload)
17746 rte_eth_dev_rx_offload_name(single_offload));
17747 single_offload <<= 1;
17752 cmd_rx_offload_get_capa_parsed(
17753 void *parsed_result,
17754 __attribute__((unused)) struct cmdline *cl,
17755 __attribute__((unused)) void *data)
17757 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17758 struct rte_eth_dev_info dev_info;
17759 portid_t port_id = res->port_id;
17760 uint64_t queue_offloads;
17761 uint64_t port_offloads;
17763 rte_eth_dev_info_get(port_id, &dev_info);
17764 queue_offloads = dev_info.rx_queue_offload_capa;
17765 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17767 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17768 printf(" Per Queue :");
17769 print_rx_offloads(queue_offloads);
17772 printf(" Per Port :");
17773 print_rx_offloads(port_offloads);
17777 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17778 .f = cmd_rx_offload_get_capa_parsed,
17780 .help_str = "show port <port_id> rx_offload capabilities",
17782 (void *)&cmd_rx_offload_get_capa_show,
17783 (void *)&cmd_rx_offload_get_capa_port,
17784 (void *)&cmd_rx_offload_get_capa_port_id,
17785 (void *)&cmd_rx_offload_get_capa_rx_offload,
17786 (void *)&cmd_rx_offload_get_capa_capabilities,
17791 /* Get Rx offloads configuration */
17792 struct cmd_rx_offload_get_configuration_result {
17793 cmdline_fixed_string_t show;
17794 cmdline_fixed_string_t port;
17796 cmdline_fixed_string_t rx_offload;
17797 cmdline_fixed_string_t configuration;
17800 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17801 TOKEN_STRING_INITIALIZER
17802 (struct cmd_rx_offload_get_configuration_result,
17804 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17805 TOKEN_STRING_INITIALIZER
17806 (struct cmd_rx_offload_get_configuration_result,
17808 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17809 TOKEN_NUM_INITIALIZER
17810 (struct cmd_rx_offload_get_configuration_result,
17812 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17813 TOKEN_STRING_INITIALIZER
17814 (struct cmd_rx_offload_get_configuration_result,
17815 rx_offload, "rx_offload");
17816 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17817 TOKEN_STRING_INITIALIZER
17818 (struct cmd_rx_offload_get_configuration_result,
17819 configuration, "configuration");
17822 cmd_rx_offload_get_configuration_parsed(
17823 void *parsed_result,
17824 __attribute__((unused)) struct cmdline *cl,
17825 __attribute__((unused)) void *data)
17827 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17828 struct rte_eth_dev_info dev_info;
17829 portid_t port_id = res->port_id;
17830 struct rte_port *port = &ports[port_id];
17831 uint64_t port_offloads;
17832 uint64_t queue_offloads;
17833 uint16_t nb_rx_queues;
17836 printf("Rx Offloading Configuration of port %d :\n", port_id);
17838 port_offloads = port->dev_conf.rxmode.offloads;
17840 print_rx_offloads(port_offloads);
17843 rte_eth_dev_info_get(port_id, &dev_info);
17844 nb_rx_queues = dev_info.nb_rx_queues;
17845 for (q = 0; q < nb_rx_queues; q++) {
17846 queue_offloads = port->rx_conf[q].offloads;
17847 printf(" Queue[%2d] :", q);
17848 print_rx_offloads(queue_offloads);
17854 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17855 .f = cmd_rx_offload_get_configuration_parsed,
17857 .help_str = "show port <port_id> rx_offload configuration",
17859 (void *)&cmd_rx_offload_get_configuration_show,
17860 (void *)&cmd_rx_offload_get_configuration_port,
17861 (void *)&cmd_rx_offload_get_configuration_port_id,
17862 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17863 (void *)&cmd_rx_offload_get_configuration_configuration,
17868 /* Enable/Disable a per port offloading */
17869 struct cmd_config_per_port_rx_offload_result {
17870 cmdline_fixed_string_t port;
17871 cmdline_fixed_string_t config;
17873 cmdline_fixed_string_t rx_offload;
17874 cmdline_fixed_string_t offload;
17875 cmdline_fixed_string_t on_off;
17878 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17879 TOKEN_STRING_INITIALIZER
17880 (struct cmd_config_per_port_rx_offload_result,
17882 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17883 TOKEN_STRING_INITIALIZER
17884 (struct cmd_config_per_port_rx_offload_result,
17886 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17887 TOKEN_NUM_INITIALIZER
17888 (struct cmd_config_per_port_rx_offload_result,
17890 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17891 TOKEN_STRING_INITIALIZER
17892 (struct cmd_config_per_port_rx_offload_result,
17893 rx_offload, "rx_offload");
17894 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17895 TOKEN_STRING_INITIALIZER
17896 (struct cmd_config_per_port_rx_offload_result,
17897 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17898 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17899 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17900 "crc_strip#scatter#timestamp#security#keep_crc");
17901 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17902 TOKEN_STRING_INITIALIZER
17903 (struct cmd_config_per_port_rx_offload_result,
17907 search_rx_offload(const char *name)
17909 uint64_t single_offload;
17910 const char *single_name;
17914 single_offload = 1;
17915 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17916 single_name = rte_eth_dev_rx_offload_name(single_offload);
17917 if (!strcasecmp(single_name, name)) {
17921 single_offload <<= 1;
17925 return single_offload;
17931 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17932 __attribute__((unused)) struct cmdline *cl,
17933 __attribute__((unused)) void *data)
17935 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17936 portid_t port_id = res->port_id;
17937 struct rte_eth_dev_info dev_info;
17938 struct rte_port *port = &ports[port_id];
17939 uint64_t single_offload;
17940 uint16_t nb_rx_queues;
17943 if (port->port_status != RTE_PORT_STOPPED) {
17944 printf("Error: Can't config offload when Port %d "
17945 "is not stopped\n", port_id);
17949 single_offload = search_rx_offload(res->offload);
17950 if (single_offload == 0) {
17951 printf("Unknown offload name: %s\n", res->offload);
17955 rte_eth_dev_info_get(port_id, &dev_info);
17956 nb_rx_queues = dev_info.nb_rx_queues;
17957 if (!strcmp(res->on_off, "on")) {
17958 port->dev_conf.rxmode.offloads |= single_offload;
17959 for (q = 0; q < nb_rx_queues; q++)
17960 port->rx_conf[q].offloads |= single_offload;
17962 port->dev_conf.rxmode.offloads &= ~single_offload;
17963 for (q = 0; q < nb_rx_queues; q++)
17964 port->rx_conf[q].offloads &= ~single_offload;
17967 cmd_reconfig_device_queue(port_id, 1, 1);
17970 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17971 .f = cmd_config_per_port_rx_offload_parsed,
17973 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17974 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17975 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17976 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17979 (void *)&cmd_config_per_port_rx_offload_result_port,
17980 (void *)&cmd_config_per_port_rx_offload_result_config,
17981 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17982 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17983 (void *)&cmd_config_per_port_rx_offload_result_offload,
17984 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17989 /* Enable/Disable a per queue offloading */
17990 struct cmd_config_per_queue_rx_offload_result {
17991 cmdline_fixed_string_t port;
17993 cmdline_fixed_string_t rxq;
17995 cmdline_fixed_string_t rx_offload;
17996 cmdline_fixed_string_t offload;
17997 cmdline_fixed_string_t on_off;
18000 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18001 TOKEN_STRING_INITIALIZER
18002 (struct cmd_config_per_queue_rx_offload_result,
18004 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18005 TOKEN_NUM_INITIALIZER
18006 (struct cmd_config_per_queue_rx_offload_result,
18008 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18009 TOKEN_STRING_INITIALIZER
18010 (struct cmd_config_per_queue_rx_offload_result,
18012 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18013 TOKEN_NUM_INITIALIZER
18014 (struct cmd_config_per_queue_rx_offload_result,
18016 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18017 TOKEN_STRING_INITIALIZER
18018 (struct cmd_config_per_queue_rx_offload_result,
18019 rx_offload, "rx_offload");
18020 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18021 TOKEN_STRING_INITIALIZER
18022 (struct cmd_config_per_queue_rx_offload_result,
18023 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18024 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18025 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18026 "crc_strip#scatter#timestamp#security#keep_crc");
18027 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18028 TOKEN_STRING_INITIALIZER
18029 (struct cmd_config_per_queue_rx_offload_result,
18033 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18034 __attribute__((unused)) struct cmdline *cl,
18035 __attribute__((unused)) void *data)
18037 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18038 struct rte_eth_dev_info dev_info;
18039 portid_t port_id = res->port_id;
18040 uint16_t queue_id = res->queue_id;
18041 struct rte_port *port = &ports[port_id];
18042 uint64_t single_offload;
18044 if (port->port_status != RTE_PORT_STOPPED) {
18045 printf("Error: Can't config offload when Port %d "
18046 "is not stopped\n", port_id);
18050 rte_eth_dev_info_get(port_id, &dev_info);
18051 if (queue_id >= dev_info.nb_rx_queues) {
18052 printf("Error: input queue_id should be 0 ... "
18053 "%d\n", dev_info.nb_rx_queues - 1);
18057 single_offload = search_rx_offload(res->offload);
18058 if (single_offload == 0) {
18059 printf("Unknown offload name: %s\n", res->offload);
18063 if (!strcmp(res->on_off, "on"))
18064 port->rx_conf[queue_id].offloads |= single_offload;
18066 port->rx_conf[queue_id].offloads &= ~single_offload;
18068 cmd_reconfig_device_queue(port_id, 1, 1);
18071 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18072 .f = cmd_config_per_queue_rx_offload_parsed,
18074 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18075 "vlan_strip|ipv4_cksum|"
18076 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18077 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18078 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18081 (void *)&cmd_config_per_queue_rx_offload_result_port,
18082 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18083 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18084 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18085 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18086 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18087 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18092 /* Get Tx offloads capabilities */
18093 struct cmd_tx_offload_get_capa_result {
18094 cmdline_fixed_string_t show;
18095 cmdline_fixed_string_t port;
18097 cmdline_fixed_string_t tx_offload;
18098 cmdline_fixed_string_t capabilities;
18101 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18102 TOKEN_STRING_INITIALIZER
18103 (struct cmd_tx_offload_get_capa_result,
18105 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18106 TOKEN_STRING_INITIALIZER
18107 (struct cmd_tx_offload_get_capa_result,
18109 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18110 TOKEN_NUM_INITIALIZER
18111 (struct cmd_tx_offload_get_capa_result,
18113 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18114 TOKEN_STRING_INITIALIZER
18115 (struct cmd_tx_offload_get_capa_result,
18116 tx_offload, "tx_offload");
18117 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18118 TOKEN_STRING_INITIALIZER
18119 (struct cmd_tx_offload_get_capa_result,
18120 capabilities, "capabilities");
18123 print_tx_offloads(uint64_t offloads)
18125 uint64_t single_offload;
18133 begin = __builtin_ctzll(offloads);
18134 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18136 single_offload = 1 << begin;
18137 for (bit = begin; bit < end; bit++) {
18138 if (offloads & single_offload)
18140 rte_eth_dev_tx_offload_name(single_offload));
18141 single_offload <<= 1;
18146 cmd_tx_offload_get_capa_parsed(
18147 void *parsed_result,
18148 __attribute__((unused)) struct cmdline *cl,
18149 __attribute__((unused)) void *data)
18151 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18152 struct rte_eth_dev_info dev_info;
18153 portid_t port_id = res->port_id;
18154 uint64_t queue_offloads;
18155 uint64_t port_offloads;
18157 rte_eth_dev_info_get(port_id, &dev_info);
18158 queue_offloads = dev_info.tx_queue_offload_capa;
18159 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18161 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18162 printf(" Per Queue :");
18163 print_tx_offloads(queue_offloads);
18166 printf(" Per Port :");
18167 print_tx_offloads(port_offloads);
18171 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18172 .f = cmd_tx_offload_get_capa_parsed,
18174 .help_str = "show port <port_id> tx_offload capabilities",
18176 (void *)&cmd_tx_offload_get_capa_show,
18177 (void *)&cmd_tx_offload_get_capa_port,
18178 (void *)&cmd_tx_offload_get_capa_port_id,
18179 (void *)&cmd_tx_offload_get_capa_tx_offload,
18180 (void *)&cmd_tx_offload_get_capa_capabilities,
18185 /* Get Tx offloads configuration */
18186 struct cmd_tx_offload_get_configuration_result {
18187 cmdline_fixed_string_t show;
18188 cmdline_fixed_string_t port;
18190 cmdline_fixed_string_t tx_offload;
18191 cmdline_fixed_string_t configuration;
18194 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18195 TOKEN_STRING_INITIALIZER
18196 (struct cmd_tx_offload_get_configuration_result,
18198 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18199 TOKEN_STRING_INITIALIZER
18200 (struct cmd_tx_offload_get_configuration_result,
18202 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18203 TOKEN_NUM_INITIALIZER
18204 (struct cmd_tx_offload_get_configuration_result,
18206 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18207 TOKEN_STRING_INITIALIZER
18208 (struct cmd_tx_offload_get_configuration_result,
18209 tx_offload, "tx_offload");
18210 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18211 TOKEN_STRING_INITIALIZER
18212 (struct cmd_tx_offload_get_configuration_result,
18213 configuration, "configuration");
18216 cmd_tx_offload_get_configuration_parsed(
18217 void *parsed_result,
18218 __attribute__((unused)) struct cmdline *cl,
18219 __attribute__((unused)) void *data)
18221 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18222 struct rte_eth_dev_info dev_info;
18223 portid_t port_id = res->port_id;
18224 struct rte_port *port = &ports[port_id];
18225 uint64_t port_offloads;
18226 uint64_t queue_offloads;
18227 uint16_t nb_tx_queues;
18230 printf("Tx Offloading Configuration of port %d :\n", port_id);
18232 port_offloads = port->dev_conf.txmode.offloads;
18234 print_tx_offloads(port_offloads);
18237 rte_eth_dev_info_get(port_id, &dev_info);
18238 nb_tx_queues = dev_info.nb_tx_queues;
18239 for (q = 0; q < nb_tx_queues; q++) {
18240 queue_offloads = port->tx_conf[q].offloads;
18241 printf(" Queue[%2d] :", q);
18242 print_tx_offloads(queue_offloads);
18248 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18249 .f = cmd_tx_offload_get_configuration_parsed,
18251 .help_str = "show port <port_id> tx_offload configuration",
18253 (void *)&cmd_tx_offload_get_configuration_show,
18254 (void *)&cmd_tx_offload_get_configuration_port,
18255 (void *)&cmd_tx_offload_get_configuration_port_id,
18256 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18257 (void *)&cmd_tx_offload_get_configuration_configuration,
18262 /* Enable/Disable a per port offloading */
18263 struct cmd_config_per_port_tx_offload_result {
18264 cmdline_fixed_string_t port;
18265 cmdline_fixed_string_t config;
18267 cmdline_fixed_string_t tx_offload;
18268 cmdline_fixed_string_t offload;
18269 cmdline_fixed_string_t on_off;
18272 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18273 TOKEN_STRING_INITIALIZER
18274 (struct cmd_config_per_port_tx_offload_result,
18276 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18277 TOKEN_STRING_INITIALIZER
18278 (struct cmd_config_per_port_tx_offload_result,
18280 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18281 TOKEN_NUM_INITIALIZER
18282 (struct cmd_config_per_port_tx_offload_result,
18284 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18285 TOKEN_STRING_INITIALIZER
18286 (struct cmd_config_per_port_tx_offload_result,
18287 tx_offload, "tx_offload");
18288 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18289 TOKEN_STRING_INITIALIZER
18290 (struct cmd_config_per_port_tx_offload_result,
18291 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18292 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18293 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18294 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18295 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18297 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18298 TOKEN_STRING_INITIALIZER
18299 (struct cmd_config_per_port_tx_offload_result,
18303 search_tx_offload(const char *name)
18305 uint64_t single_offload;
18306 const char *single_name;
18310 single_offload = 1;
18311 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18312 single_name = rte_eth_dev_tx_offload_name(single_offload);
18313 if (!strcasecmp(single_name, name)) {
18316 } else if (!strcasecmp(single_name, "UNKNOWN"))
18318 else if (single_name == NULL)
18320 single_offload <<= 1;
18324 return single_offload;
18330 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18331 __attribute__((unused)) struct cmdline *cl,
18332 __attribute__((unused)) void *data)
18334 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18335 portid_t port_id = res->port_id;
18336 struct rte_eth_dev_info dev_info;
18337 struct rte_port *port = &ports[port_id];
18338 uint64_t single_offload;
18339 uint16_t nb_tx_queues;
18342 if (port->port_status != RTE_PORT_STOPPED) {
18343 printf("Error: Can't config offload when Port %d "
18344 "is not stopped\n", port_id);
18348 single_offload = search_tx_offload(res->offload);
18349 if (single_offload == 0) {
18350 printf("Unknown offload name: %s\n", res->offload);
18354 rte_eth_dev_info_get(port_id, &dev_info);
18355 nb_tx_queues = dev_info.nb_tx_queues;
18356 if (!strcmp(res->on_off, "on")) {
18357 port->dev_conf.txmode.offloads |= single_offload;
18358 for (q = 0; q < nb_tx_queues; q++)
18359 port->tx_conf[q].offloads |= single_offload;
18361 port->dev_conf.txmode.offloads &= ~single_offload;
18362 for (q = 0; q < nb_tx_queues; q++)
18363 port->tx_conf[q].offloads &= ~single_offload;
18366 cmd_reconfig_device_queue(port_id, 1, 1);
18369 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18370 .f = cmd_config_per_port_tx_offload_parsed,
18372 .help_str = "port config <port_id> tx_offload "
18373 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18374 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18375 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18376 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18377 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18378 "match_metadata on|off",
18380 (void *)&cmd_config_per_port_tx_offload_result_port,
18381 (void *)&cmd_config_per_port_tx_offload_result_config,
18382 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18383 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18384 (void *)&cmd_config_per_port_tx_offload_result_offload,
18385 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18390 /* Enable/Disable a per queue offloading */
18391 struct cmd_config_per_queue_tx_offload_result {
18392 cmdline_fixed_string_t port;
18394 cmdline_fixed_string_t txq;
18396 cmdline_fixed_string_t tx_offload;
18397 cmdline_fixed_string_t offload;
18398 cmdline_fixed_string_t on_off;
18401 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18402 TOKEN_STRING_INITIALIZER
18403 (struct cmd_config_per_queue_tx_offload_result,
18405 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18406 TOKEN_NUM_INITIALIZER
18407 (struct cmd_config_per_queue_tx_offload_result,
18409 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18410 TOKEN_STRING_INITIALIZER
18411 (struct cmd_config_per_queue_tx_offload_result,
18413 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18414 TOKEN_NUM_INITIALIZER
18415 (struct cmd_config_per_queue_tx_offload_result,
18417 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18418 TOKEN_STRING_INITIALIZER
18419 (struct cmd_config_per_queue_tx_offload_result,
18420 tx_offload, "tx_offload");
18421 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18422 TOKEN_STRING_INITIALIZER
18423 (struct cmd_config_per_queue_tx_offload_result,
18424 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18425 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18426 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18427 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18428 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18429 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18430 TOKEN_STRING_INITIALIZER
18431 (struct cmd_config_per_queue_tx_offload_result,
18435 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18436 __attribute__((unused)) struct cmdline *cl,
18437 __attribute__((unused)) void *data)
18439 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18440 struct rte_eth_dev_info dev_info;
18441 portid_t port_id = res->port_id;
18442 uint16_t queue_id = res->queue_id;
18443 struct rte_port *port = &ports[port_id];
18444 uint64_t single_offload;
18446 if (port->port_status != RTE_PORT_STOPPED) {
18447 printf("Error: Can't config offload when Port %d "
18448 "is not stopped\n", port_id);
18452 rte_eth_dev_info_get(port_id, &dev_info);
18453 if (queue_id >= dev_info.nb_tx_queues) {
18454 printf("Error: input queue_id should be 0 ... "
18455 "%d\n", dev_info.nb_tx_queues - 1);
18459 single_offload = search_tx_offload(res->offload);
18460 if (single_offload == 0) {
18461 printf("Unknown offload name: %s\n", res->offload);
18465 if (!strcmp(res->on_off, "on"))
18466 port->tx_conf[queue_id].offloads |= single_offload;
18468 port->tx_conf[queue_id].offloads &= ~single_offload;
18470 cmd_reconfig_device_queue(port_id, 1, 1);
18473 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18474 .f = cmd_config_per_queue_tx_offload_parsed,
18476 .help_str = "port <port_id> txq <queue_id> tx_offload "
18477 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18478 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18479 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18480 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18481 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18484 (void *)&cmd_config_per_queue_tx_offload_result_port,
18485 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18486 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18487 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18488 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18489 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18490 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18495 /* *** configure tx_metadata for specific port *** */
18496 struct cmd_config_tx_metadata_specific_result {
18497 cmdline_fixed_string_t port;
18498 cmdline_fixed_string_t keyword;
18500 cmdline_fixed_string_t item;
18505 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18506 __attribute__((unused)) struct cmdline *cl,
18507 __attribute__((unused)) void *data)
18509 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18511 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18513 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18514 /* Add/remove callback to insert valid metadata in every Tx packet. */
18515 if (ports[res->port_id].tx_metadata)
18516 add_tx_md_callback(res->port_id);
18518 remove_tx_md_callback(res->port_id);
18521 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18522 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18524 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18525 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18526 keyword, "config");
18527 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18528 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18530 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18531 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18532 item, "tx_metadata");
18533 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18534 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18537 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18538 .f = cmd_config_tx_metadata_specific_parsed,
18540 .help_str = "port config <port_id> tx_metadata <value>",
18542 (void *)&cmd_config_tx_metadata_specific_port,
18543 (void *)&cmd_config_tx_metadata_specific_keyword,
18544 (void *)&cmd_config_tx_metadata_specific_id,
18545 (void *)&cmd_config_tx_metadata_specific_item,
18546 (void *)&cmd_config_tx_metadata_specific_value,
18551 /* *** display tx_metadata per port configuration *** */
18552 struct cmd_show_tx_metadata_result {
18553 cmdline_fixed_string_t cmd_show;
18554 cmdline_fixed_string_t cmd_port;
18555 cmdline_fixed_string_t cmd_keyword;
18560 cmd_show_tx_metadata_parsed(void *parsed_result,
18561 __attribute__((unused)) struct cmdline *cl,
18562 __attribute__((unused)) void *data)
18564 struct cmd_show_tx_metadata_result *res = parsed_result;
18566 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18567 printf("invalid port id %u\n", res->cmd_pid);
18570 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18571 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18572 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18576 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18577 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18579 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18580 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18582 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18583 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18585 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18586 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18587 cmd_keyword, "tx_metadata");
18589 cmdline_parse_inst_t cmd_show_tx_metadata = {
18590 .f = cmd_show_tx_metadata_parsed,
18592 .help_str = "show port <port_id> tx_metadata",
18594 (void *)&cmd_show_tx_metadata_show,
18595 (void *)&cmd_show_tx_metadata_port,
18596 (void *)&cmd_show_tx_metadata_pid,
18597 (void *)&cmd_show_tx_metadata_keyword,
18602 /* ******************************************************************************** */
18604 /* list of instructions */
18605 cmdline_parse_ctx_t main_ctx[] = {
18606 (cmdline_parse_inst_t *)&cmd_help_brief,
18607 (cmdline_parse_inst_t *)&cmd_help_long,
18608 (cmdline_parse_inst_t *)&cmd_quit,
18609 (cmdline_parse_inst_t *)&cmd_load_from_file,
18610 (cmdline_parse_inst_t *)&cmd_showport,
18611 (cmdline_parse_inst_t *)&cmd_showqueue,
18612 (cmdline_parse_inst_t *)&cmd_showportall,
18613 (cmdline_parse_inst_t *)&cmd_showcfg,
18614 (cmdline_parse_inst_t *)&cmd_showfwdall,
18615 (cmdline_parse_inst_t *)&cmd_start,
18616 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18617 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18618 (cmdline_parse_inst_t *)&cmd_set_link_up,
18619 (cmdline_parse_inst_t *)&cmd_set_link_down,
18620 (cmdline_parse_inst_t *)&cmd_reset,
18621 (cmdline_parse_inst_t *)&cmd_set_numbers,
18622 (cmdline_parse_inst_t *)&cmd_set_log,
18623 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18624 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18625 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18626 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18627 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18628 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18629 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18630 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18631 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18632 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18633 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18634 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18635 (cmdline_parse_inst_t *)&cmd_set_link_check,
18636 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18637 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18638 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18639 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18640 #ifdef RTE_LIBRTE_PMD_BOND
18641 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18642 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18643 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18644 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18645 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18646 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18647 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18648 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18649 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18650 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18651 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18653 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18654 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18655 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18656 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18657 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18658 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18659 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18660 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18661 (cmdline_parse_inst_t *)&cmd_csum_set,
18662 (cmdline_parse_inst_t *)&cmd_csum_show,
18663 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18664 (cmdline_parse_inst_t *)&cmd_tso_set,
18665 (cmdline_parse_inst_t *)&cmd_tso_show,
18666 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18667 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18668 (cmdline_parse_inst_t *)&cmd_gro_enable,
18669 (cmdline_parse_inst_t *)&cmd_gro_flush,
18670 (cmdline_parse_inst_t *)&cmd_gro_show,
18671 (cmdline_parse_inst_t *)&cmd_gso_enable,
18672 (cmdline_parse_inst_t *)&cmd_gso_size,
18673 (cmdline_parse_inst_t *)&cmd_gso_show,
18674 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18675 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18676 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18677 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18678 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18679 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18680 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18681 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18682 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18683 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18684 (cmdline_parse_inst_t *)&cmd_config_dcb,
18685 (cmdline_parse_inst_t *)&cmd_read_reg,
18686 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18687 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18688 (cmdline_parse_inst_t *)&cmd_write_reg,
18689 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18690 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18691 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18692 (cmdline_parse_inst_t *)&cmd_stop,
18693 (cmdline_parse_inst_t *)&cmd_mac_addr,
18694 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18695 (cmdline_parse_inst_t *)&cmd_set_qmap,
18696 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18697 (cmdline_parse_inst_t *)&cmd_operate_port,
18698 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18699 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18700 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18701 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18702 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18703 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18704 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18705 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18706 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18707 (cmdline_parse_inst_t *)&cmd_config_mtu,
18708 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18709 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18710 (cmdline_parse_inst_t *)&cmd_config_rss,
18711 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18712 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18713 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18714 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18715 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18716 (cmdline_parse_inst_t *)&cmd_showport_reta,
18717 (cmdline_parse_inst_t *)&cmd_config_burst,
18718 (cmdline_parse_inst_t *)&cmd_config_thresh,
18719 (cmdline_parse_inst_t *)&cmd_config_threshold,
18720 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18721 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18722 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18723 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18724 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18725 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18726 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18727 (cmdline_parse_inst_t *)&cmd_global_config,
18728 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18729 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18730 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18731 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18732 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18733 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18734 (cmdline_parse_inst_t *)&cmd_dump,
18735 (cmdline_parse_inst_t *)&cmd_dump_one,
18736 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18737 (cmdline_parse_inst_t *)&cmd_syn_filter,
18738 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18739 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18740 (cmdline_parse_inst_t *)&cmd_flex_filter,
18741 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18742 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18743 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18744 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18745 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18746 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18747 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18748 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18749 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18750 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18751 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18752 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18753 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18754 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18755 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18756 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18757 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18758 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18759 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18760 (cmdline_parse_inst_t *)&cmd_flow,
18761 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18762 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18763 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18764 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18765 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18766 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18767 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18768 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18769 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18770 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18771 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18772 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18773 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18774 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18775 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18776 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18777 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18778 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18779 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18780 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18781 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18782 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18783 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18784 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18785 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18786 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18787 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18788 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18789 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18790 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18791 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18792 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18793 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18794 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18795 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18796 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18797 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18798 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18799 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18800 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18801 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18802 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18803 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18804 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18805 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18806 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18807 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18808 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18809 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18810 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18811 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18813 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18814 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18815 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18816 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18817 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18818 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18819 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18820 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18821 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18822 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18823 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18824 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18825 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18826 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18827 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18828 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18829 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18830 (cmdline_parse_inst_t *)&cmd_ddp_add,
18831 (cmdline_parse_inst_t *)&cmd_ddp_del,
18832 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18833 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18834 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18835 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18836 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18837 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18838 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18839 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18840 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18841 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18843 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18844 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18845 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18846 (cmdline_parse_inst_t *)&cmd_queue_region,
18847 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18848 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18849 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18850 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18851 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18852 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18853 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18854 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18855 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18856 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18857 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18858 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18859 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18860 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18861 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18862 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18863 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18864 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18865 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18866 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18867 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18868 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18869 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18870 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18871 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18872 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18873 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18874 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18875 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18876 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18877 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18878 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18879 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18880 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18881 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18882 #ifdef RTE_LIBRTE_BPF
18883 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18884 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18886 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18887 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18891 /* read cmdline commands from file */
18893 cmdline_read_from_file(const char *filename)
18895 struct cmdline *cl;
18897 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18899 printf("Failed to create file based cmdline context: %s\n",
18904 cmdline_interact(cl);
18909 printf("Read CLI commands from %s\n", filename);
18912 /* prompt function, called from main on MASTER lcore */
18916 /* initialize non-constant commands */
18917 cmd_set_fwd_mode_init();
18918 cmd_set_fwd_retry_mode_init();
18920 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18921 if (testpmd_cl == NULL)
18923 cmdline_interact(testpmd_cl);
18924 cmdline_stdin_exit(testpmd_cl);
18930 if (testpmd_cl != NULL)
18931 cmdline_quit(testpmd_cl);
18935 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18937 if (id == (portid_t)RTE_PORT_ALL) {
18940 RTE_ETH_FOREACH_DEV(pid) {
18941 /* check if need_reconfig has been set to 1 */
18942 if (ports[pid].need_reconfig == 0)
18943 ports[pid].need_reconfig = dev;
18944 /* check if need_reconfig_queues has been set to 1 */
18945 if (ports[pid].need_reconfig_queues == 0)
18946 ports[pid].need_reconfig_queues = queue;
18948 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18949 /* check if need_reconfig has been set to 1 */
18950 if (ports[id].need_reconfig == 0)
18951 ports[id].need_reconfig = dev;
18952 /* check if need_reconfig_queues has been set to 1 */
18953 if (ports[id].need_reconfig_queues == 0)
18954 ports[id].need_reconfig_queues = queue;