1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
16 #include <net/socket.h>
18 #include <sys/socket.h>
21 #include <netinet/in.h>
23 #include <sys/queue.h>
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
47 #include <rte_eth_ctrl.h>
51 #include <cmdline_rdline.h>
52 #include <cmdline_parse.h>
53 #include <cmdline_parse_num.h>
54 #include <cmdline_parse_string.h>
55 #include <cmdline_parse_ipaddr.h>
56 #include <cmdline_parse_etheraddr.h>
57 #include <cmdline_socket.h>
59 #ifdef RTE_LIBRTE_PMD_BOND
60 #include <rte_eth_bond.h>
61 #include <rte_eth_bond_8023ad.h>
63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
64 #include <rte_pmd_dpaa.h>
66 #ifdef RTE_LIBRTE_IXGBE_PMD
67 #include <rte_pmd_ixgbe.h>
69 #ifdef RTE_LIBRTE_I40E_PMD
70 #include <rte_pmd_i40e.h>
72 #ifdef RTE_LIBRTE_BNXT_PMD
73 #include <rte_pmd_bnxt.h>
76 #include "cmdline_mtr.h"
77 #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|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 rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
178 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
179 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
180 " Display the RSS hash functions and RSS hash key"
183 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
184 " Clear information for port_id, or all.\n\n"
186 "show (rxq|txq) info (port_id) (queue_id)\n"
187 " Display information for configured RX/TX queue.\n\n"
189 "show config (rxtx|cores|fwd|txpkts)\n"
190 " Display the given configuration.\n\n"
192 "read rxd (port_id) (queue_id) (rxd_id)\n"
193 " Display an RX descriptor of a port RX queue.\n\n"
195 "read txd (port_id) (queue_id) (txd_id)\n"
196 " Display a TX descriptor of a port TX queue.\n\n"
198 "ddp get list (port_id)\n"
199 " Get ddp profile info list\n\n"
201 "ddp get info (profile_path)\n"
202 " Get ddp profile information.\n\n"
204 "show vf stats (port_id) (vf_id)\n"
205 " Display a VF's statistics.\n\n"
207 "clear vf stats (port_id) (vf_id)\n"
208 " Reset a VF's statistics.\n\n"
210 "show port (port_id) pctype mapping\n"
211 " Get flow ptype to pctype mapping on a port\n\n"
213 "show port meter stats (port_id) (meter_id) (clear)\n"
214 " Get meter stats on a port\n\n"
215 "show port tm cap (port_id)\n"
216 " Display the port TM capability.\n\n"
218 "show port tm level cap (port_id) (level_id)\n"
219 " Display the port TM hierarchical level capability.\n\n"
221 "show port tm node cap (port_id) (node_id)\n"
222 " Display the port TM node capability.\n\n"
224 "show port tm node type (port_id) (node_id)\n"
225 " Display the port TM node type.\n\n"
227 "show port tm node stats (port_id) (node_id) (clear)\n"
228 " Display the port TM node stats.\n\n"
233 if (show_all || !strcmp(res->section, "config")) {
239 "Configuration changes only become active when"
240 " forwarding is started/restarted.\n\n"
243 " Reset forwarding to the default configuration.\n\n"
245 "set verbose (level)\n"
246 " Set the debug verbosity level X.\n\n"
248 "set log global|(type) (level)\n"
249 " Set the log level.\n\n"
252 " Set number of ports.\n\n"
255 " Set number of cores.\n\n"
257 "set coremask (mask)\n"
258 " Set the forwarding cores hexadecimal mask.\n\n"
260 "set portmask (mask)\n"
261 " Set the forwarding ports hexadecimal mask.\n\n"
264 " Set number of packets per burst.\n\n"
266 "set burst tx delay (microseconds) retry (num)\n"
267 " Set the transmit delay time and number of retries,"
268 " effective when retry is enabled.\n\n"
270 "set txpkts (x[,y]*)\n"
271 " Set the length of each segment of TXONLY"
272 " and optionally CSUM packets.\n\n"
274 "set txsplit (off|on|rand)\n"
275 " Set the split policy for the TX packets."
276 " Right now only applicable for CSUM and TXONLY"
279 "set corelist (x[,y]*)\n"
280 " Set the list of forwarding cores.\n\n"
282 "set portlist (x[,y]*)\n"
283 " Set the list of forwarding ports.\n\n"
285 "set tx loopback (port_id) (on|off)\n"
286 " Enable or disable tx loopback.\n\n"
288 "set all queues drop (port_id) (on|off)\n"
289 " Set drop enable bit for all queues.\n\n"
291 "set vf split drop (port_id) (vf_id) (on|off)\n"
292 " Set split drop enable bit for a VF from the PF.\n\n"
294 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
295 " Set MAC antispoof for a VF from the PF.\n\n"
297 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
298 " Enable MACsec offload.\n\n"
300 "set macsec offload (port_id) off\n"
301 " Disable MACsec offload.\n\n"
303 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
304 " Configure MACsec secure connection (SC).\n\n"
306 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
307 " Configure MACsec secure association (SA).\n\n"
309 "set vf broadcast (port_id) (vf_id) (on|off)\n"
310 " Set VF broadcast for a VF from the PF.\n\n"
312 "vlan set strip (on|off) (port_id)\n"
313 " Set the VLAN strip on a port.\n\n"
315 "vlan set stripq (on|off) (port_id,queue_id)\n"
316 " Set the VLAN strip for a queue on a port.\n\n"
318 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
319 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
321 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
322 " Set VLAN insert for a VF from the PF.\n\n"
324 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
325 " Set VLAN antispoof for a VF from the PF.\n\n"
327 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
328 " Set VLAN tag for a VF from the PF.\n\n"
330 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
331 " Set a VF's max bandwidth(Mbps).\n\n"
333 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
334 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
336 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
337 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
339 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
340 " Set some TCs' strict link priority mode on a physical port.\n\n"
342 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
343 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
345 "vlan set filter (on|off) (port_id)\n"
346 " Set the VLAN filter on a port.\n\n"
348 "vlan set qinq (on|off) (port_id)\n"
349 " Set the VLAN QinQ (extended queue in queue)"
352 "vlan set (inner|outer) tpid (value) (port_id)\n"
353 " Set the VLAN TPID for Packet Filtering on"
356 "rx_vlan add (vlan_id|all) (port_id)\n"
357 " Add a vlan_id, or all identifiers, to the set"
358 " of VLAN identifiers filtered by port_id.\n\n"
360 "rx_vlan rm (vlan_id|all) (port_id)\n"
361 " Remove a vlan_id, or all identifiers, from the set"
362 " of VLAN identifiers filtered by port_id.\n\n"
364 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
365 " Add a vlan_id, to the set of VLAN identifiers"
366 "filtered for VF(s) from port_id.\n\n"
368 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
369 " Remove a vlan_id, to the set of VLAN identifiers"
370 "filtered for VF(s) from port_id.\n\n"
372 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
373 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
374 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
375 " add a tunnel filter of a port.\n\n"
377 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
378 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
379 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
380 " remove a tunnel filter of a port.\n\n"
382 "rx_vxlan_port add (udp_port) (port_id)\n"
383 " Add an UDP port for VXLAN packet filter on a port\n\n"
385 "rx_vxlan_port rm (udp_port) (port_id)\n"
386 " Remove an UDP port for VXLAN packet filter on a port\n\n"
388 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
389 " Set hardware insertion of VLAN IDs (single or double VLAN "
390 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
392 "tx_vlan set pvid port_id vlan_id (on|off)\n"
393 " Set port based TX VLAN insertion.\n\n"
395 "tx_vlan reset (port_id)\n"
396 " Disable hardware insertion of a VLAN header in"
397 " packets sent on a port.\n\n"
399 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
400 " Select hardware or software calculation of the"
401 " checksum when transmitting a packet using the"
402 " csum forward engine.\n"
403 " ip|udp|tcp|sctp always concern the inner layer.\n"
404 " outer-ip concerns the outer IP layer in"
405 " case the packet is recognized as a tunnel packet by"
406 " the forward engine (vxlan, gre and ipip are supported)\n"
407 " Please check the NIC datasheet for HW limits.\n\n"
409 "csum parse-tunnel (on|off) (tx_port_id)\n"
410 " If disabled, treat tunnel packets as non-tunneled"
411 " packets (treat inner headers as payload). The port\n"
412 " argument is the port used for TX in csum forward"
415 "csum show (port_id)\n"
416 " Display tx checksum offload configuration\n\n"
418 "tso set (segsize) (portid)\n"
419 " Enable TCP Segmentation Offload in csum forward"
421 " Please check the NIC datasheet for HW limits.\n\n"
424 " Display the status of TCP Segmentation Offload.\n\n"
426 "set port (port_id) gro on|off\n"
427 " Enable or disable Generic Receive Offload in"
428 " csum forwarding engine.\n\n"
430 "show port (port_id) gro\n"
431 " Display GRO configuration.\n\n"
433 "set gro flush (cycles)\n"
434 " Set the cycle to flush GROed packets from"
435 " reassembly tables.\n\n"
437 "set port (port_id) gso (on|off)"
438 " Enable or disable Generic Segmentation Offload in"
439 " csum forwarding engine.\n\n"
441 "set gso segsz (length)\n"
442 " Set max packet length for output GSO segments,"
443 " including packet header and payload.\n\n"
445 "show port (port_id) gso\n"
446 " Show GSO configuration.\n\n"
449 " Set packet forwarding mode.\n\n"
451 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
452 " Add a MAC address on port_id.\n\n"
454 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
455 " Remove a MAC address from port_id.\n\n"
457 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
458 " Set the default MAC address for port_id.\n\n"
460 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
461 " Add a MAC address for a VF on the port.\n\n"
463 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
464 " Set the MAC address for a VF from the PF.\n\n"
466 "set eth-peer (port_id) (peer_addr)\n"
467 " set the peer address for certain port.\n\n"
469 "set port (port_id) uta (mac_address|all) (on|off)\n"
470 " Add/Remove a or all unicast hash filter(s)"
473 "set promisc (port_id|all) (on|off)\n"
474 " Set the promiscuous mode on port_id, or all.\n\n"
476 "set allmulti (port_id|all) (on|off)\n"
477 " Set the allmulti mode on port_id, or all.\n\n"
479 "set vf promisc (port_id) (vf_id) (on|off)\n"
480 " Set unicast promiscuous mode for a VF from the PF.\n\n"
482 "set vf allmulti (port_id) (vf_id) (on|off)\n"
483 " Set multicast promiscuous mode for a VF from the PF.\n\n"
485 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
486 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
487 " (on|off) autoneg (on|off) (port_id)\n"
488 "set flow_ctrl rx (on|off) (portid)\n"
489 "set flow_ctrl tx (on|off) (portid)\n"
490 "set flow_ctrl high_water (high_water) (portid)\n"
491 "set flow_ctrl low_water (low_water) (portid)\n"
492 "set flow_ctrl pause_time (pause_time) (portid)\n"
493 "set flow_ctrl send_xon (send_xon) (portid)\n"
494 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
495 "set flow_ctrl autoneg (on|off) (port_id)\n"
496 " Set the link flow control parameter on a port.\n\n"
498 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
499 " (low_water) (pause_time) (priority) (port_id)\n"
500 " Set the priority flow control parameter on a"
503 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
504 " Set statistics mapping (qmapping 0..15) for RX/TX"
506 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
507 " on port 0 to mapping 5.\n\n"
509 "set xstats-hide-zero on|off\n"
510 " Set the option to hide the zero values"
511 " for xstats display.\n"
513 "set port (port_id) vf (vf_id) rx|tx on|off\n"
514 " Enable/Disable a VF receive/tranmit from a port\n\n"
516 "set port (port_id) vf (vf_id) (mac_addr)"
517 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
518 " Add/Remove unicast or multicast MAC addr filter"
521 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
523 " AUPE:accepts untagged VLAN;"
524 "ROPE:accept unicast hash\n\n"
525 " BAM:accepts broadcast packets;"
526 "MPE:accepts all multicast packets\n\n"
527 " Enable/Disable a VF receive mode of a port\n\n"
529 "set port (port_id) queue (queue_id) rate (rate_num)\n"
530 " Set rate limit for a queue of a port\n\n"
532 "set port (port_id) vf (vf_id) rate (rate_num) "
533 "queue_mask (queue_mask_value)\n"
534 " Set rate limit for queues in VF of a port\n\n"
536 "set port (port_id) mirror-rule (rule_id)"
537 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
538 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
539 " Set pool or vlan type mirror rule on a port.\n"
540 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
541 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
544 "set port (port_id) mirror-rule (rule_id)"
545 " (uplink-mirror|downlink-mirror) dst-pool"
546 " (pool_id) (on|off)\n"
547 " Set uplink or downlink type mirror rule on a port.\n"
548 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
549 " 0 on' enable mirror income traffic to pool 0.\n\n"
551 "reset port (port_id) mirror-rule (rule_id)\n"
552 " Reset a mirror rule.\n\n"
554 "set flush_rx (on|off)\n"
555 " Flush (default) or don't flush RX streams before"
556 " forwarding. Mainly used with PCAP drivers.\n\n"
558 "set bypass mode (normal|bypass|isolate) (port_id)\n"
559 " Set the bypass mode for the lowest port on bypass enabled"
562 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
563 "mode (normal|bypass|isolate) (port_id)\n"
564 " Set the event required to initiate specified bypass mode for"
565 " the lowest port on a bypass enabled NIC where:\n"
566 " timeout = enable bypass after watchdog timeout.\n"
567 " os_on = enable bypass when OS/board is powered on.\n"
568 " os_off = enable bypass when OS/board is powered off.\n"
569 " power_on = enable bypass when power supply is turned on.\n"
570 " power_off = enable bypass when power supply is turned off."
573 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
574 " Set the bypass watchdog timeout to 'n' seconds"
575 " where 0 = instant.\n\n"
577 "show bypass config (port_id)\n"
578 " Show the bypass configuration for a bypass enabled NIC"
579 " using the lowest port on the NIC.\n\n"
581 #ifdef RTE_LIBRTE_PMD_BOND
582 "create bonded device (mode) (socket)\n"
583 " Create a new bonded device with specific bonding mode and socket.\n\n"
585 "add bonding slave (slave_id) (port_id)\n"
586 " Add a slave device to a bonded device.\n\n"
588 "remove bonding slave (slave_id) (port_id)\n"
589 " Remove a slave device from a bonded device.\n\n"
591 "set bonding mode (value) (port_id)\n"
592 " Set the bonding mode on a bonded device.\n\n"
594 "set bonding primary (slave_id) (port_id)\n"
595 " Set the primary slave for a bonded device.\n\n"
597 "show bonding config (port_id)\n"
598 " Show the bonding config for port_id.\n\n"
600 "set bonding mac_addr (port_id) (address)\n"
601 " Set the MAC address of a bonded device.\n\n"
603 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
604 " Set Aggregation mode for IEEE802.3AD (mode 4)"
606 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
607 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
609 "set bonding mon_period (port_id) (value)\n"
610 " Set the bonding link status monitoring polling period in ms.\n\n"
612 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
613 " Enable/disable dedicated queues for LACP control traffic.\n\n"
616 "set link-up port (port_id)\n"
617 " Set link up for a port.\n\n"
619 "set link-down port (port_id)\n"
620 " Set link down for a port.\n\n"
622 "E-tag set insertion on port-tag-id (value)"
623 " port (port_id) vf (vf_id)\n"
624 " Enable E-tag insertion for a VF on a port\n\n"
626 "E-tag set insertion off port (port_id) vf (vf_id)\n"
627 " Disable E-tag insertion for a VF on a port\n\n"
629 "E-tag set stripping (on|off) port (port_id)\n"
630 " Enable/disable E-tag stripping on a port\n\n"
632 "E-tag set forwarding (on|off) port (port_id)\n"
633 " Enable/disable E-tag based forwarding"
636 "E-tag set filter add e-tag-id (value) dst-pool"
637 " (pool_id) port (port_id)\n"
638 " Add an E-tag forwarding filter on a port\n\n"
640 "E-tag set filter del e-tag-id (value) port (port_id)\n"
641 " Delete an E-tag forwarding filter on a port\n\n"
643 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
644 "set port tm hierarchy default (port_id)\n"
645 " Set default traffic Management hierarchy on a port\n\n"
648 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
649 " Load a profile package on a port\n\n"
651 "ddp del (port_id) (backup_profile_path)\n"
652 " Delete a profile package from a port\n\n"
654 "ptype mapping get (port_id) (valid_only)\n"
655 " Get ptype mapping on a port\n\n"
657 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
658 " Replace target with the pkt_type in ptype mapping\n\n"
660 "ptype mapping reset (port_id)\n"
661 " Reset ptype mapping on a port\n\n"
663 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
664 " Update a ptype mapping item on a port\n\n"
666 "set port (port_id) queue-region region_id (value) "
667 "queue_start_index (value) queue_num (value)\n"
668 " Set a queue region on a port\n\n"
670 "set port (port_id) queue-region region_id (value) "
672 " Set a flowtype region index on a port\n\n"
674 "set port (port_id) queue-region UP (value) region_id (value)\n"
675 " Set the mapping of User Priority to "
676 "queue region on a port\n\n"
678 "set port (port_id) queue-region flush (on|off)\n"
679 " flush all queue region related configuration\n\n"
681 "show port meter cap (port_id)\n"
682 " Show port meter capability information\n\n"
684 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
685 " meter profile add - srtcm rfc 2697\n\n"
687 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
688 " meter profile add - trtcm rfc 2698\n\n"
690 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
691 " meter profile add - trtcm rfc 4115\n\n"
693 "del port meter profile (port_id) (profile_id)\n"
694 " meter profile delete\n\n"
696 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
697 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
698 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
699 "(dscp_tbl_entry63)]\n"
702 "enable port meter (port_id) (mtr_id)\n"
705 "disable port meter (port_id) (mtr_id)\n"
708 "del port meter (port_id) (mtr_id)\n"
711 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
712 " meter update meter profile\n\n"
714 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
715 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
716 " update meter dscp table entries\n\n"
718 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
719 "(action0) [(action1) (action2)]\n"
720 " meter update policer action\n\n"
722 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
723 " meter update stats\n\n"
725 "show port (port_id) queue-region\n"
726 " show all queue region related configuration info\n\n"
728 "add port tm node shaper profile (port_id) (shaper_profile_id)"
729 " (tb_rate) (tb_size) (packet_length_adjust)\n"
730 " Add port tm node private shaper profile.\n\n"
732 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
733 " Delete port tm node private shaper profile.\n\n"
735 "add port tm node shared shaper (port_id) (shared_shaper_id)"
736 " (shaper_profile_id)\n"
737 " Add/update port tm node shared shaper.\n\n"
739 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
740 " Delete port tm node shared shaper.\n\n"
742 "set port tm node shaper profile (port_id) (node_id)"
743 " (shaper_profile_id)\n"
744 " Set port tm node shaper profile.\n\n"
746 "add port tm node wred profile (port_id) (wred_profile_id)"
747 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
748 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
749 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
750 " Add port tm node wred profile.\n\n"
752 "del port tm node wred profile (port_id) (wred_profile_id)\n"
753 " Delete port tm node wred profile.\n\n"
755 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
756 " (priority) (weight) (level_id) (shaper_profile_id)"
757 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
758 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
759 " Add port tm nonleaf node.\n\n"
761 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
762 " (priority) (weight) (level_id) (shaper_profile_id)"
763 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
764 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
765 " Add port tm leaf node.\n\n"
767 "del port tm node (port_id) (node_id)\n"
768 " Delete port tm node.\n\n"
770 "set port tm node parent (port_id) (node_id) (parent_node_id)"
771 " (priority) (weight)\n"
772 " Set port tm node parent.\n\n"
774 "suspend port tm node (port_id) (node_id)"
775 " Suspend tm node.\n\n"
777 "resume port tm node (port_id) (node_id)"
778 " Resume tm node.\n\n"
780 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
781 " Commit tm hierarchy.\n\n"
783 , list_pkt_forwarding_modes()
787 if (show_all || !strcmp(res->section, "ports")) {
793 "----------------\n\n"
795 "port start (port_id|all)\n"
796 " Start all ports or port_id.\n\n"
798 "port stop (port_id|all)\n"
799 " Stop all ports or port_id.\n\n"
801 "port close (port_id|all)\n"
802 " Close all ports or port_id.\n\n"
804 "port attach (ident)\n"
805 " Attach physical or virtual dev by pci address or virtual device name\n\n"
807 "port detach (port_id)\n"
808 " Detach physical or virtual dev by port_id\n\n"
810 "port config (port_id|all)"
811 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
812 " duplex (half|full|auto)\n"
813 " Set speed and duplex for all ports or port_id\n\n"
815 "port config (port_id|all) loopback (mode)\n"
816 " Set loopback mode for all ports or port_id\n\n"
818 "port config all (rxq|txq|rxd|txd) (value)\n"
819 " Set number for rxq/txq/rxd/txd.\n\n"
821 "port config all max-pkt-len (value)\n"
822 " Set the max packet length.\n\n"
824 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
825 "hw-vlan-strip|hw-vlan-extend|drop-en)"
827 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
830 "port config all rss (all|default|ip|tcp|udp|sctp|"
831 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
832 " Set the RSS mode.\n\n"
834 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
835 " Set the RSS redirection table.\n\n"
837 "port config (port_id) dcb vt (on|off) (traffic_class)"
839 " Set the DCB mode.\n\n"
841 "port config all burst (value)\n"
842 " Set the number of packets per burst.\n\n"
844 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
846 " Set the ring prefetch/host/writeback threshold"
847 " for tx/rx queue.\n\n"
849 "port config all (txfreet|txrst|rxfreet) (value)\n"
850 " Set free threshold for rx/tx, or set"
851 " tx rs bit threshold.\n\n"
852 "port config mtu X value\n"
853 " Set the MTU of port X to a given value\n\n"
855 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
856 " Set a rx/tx queue's ring size configuration, the new"
857 " value will take effect after command that (re-)start the port"
858 " or command that setup the specific queue\n\n"
860 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
861 " Start/stop a rx/tx queue of port X. Only take effect"
862 " when port X is started\n\n"
864 "port (port_id) (rxq|txq) (queue_id) setup\n"
865 " Setup a rx/tx queue of port X.\n\n"
867 "port config (port_id|all) l2-tunnel E-tag ether-type"
869 " Set the value of E-tag ether-type.\n\n"
871 "port config (port_id|all) l2-tunnel E-tag"
872 " (enable|disable)\n"
873 " Enable/disable the E-tag support.\n\n"
875 "port config (port_id) pctype mapping reset\n"
876 " Reset flow type to pctype mapping on a port\n\n"
878 "port config (port_id) pctype mapping update"
879 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
880 " Update a flow type to pctype mapping item on a port\n\n"
882 "port config (port_id) pctype (pctype_id) hash_inset|"
883 "fdir_inset|fdir_flx_inset get|set|clear field\n"
885 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
887 "port config (port_id) pctype (pctype_id) hash_inset|"
888 "fdir_inset|fdir_flx_inset clear all"
889 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
891 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
892 " Add/remove UDP tunnel port for tunneling offload\n\n"
896 if (show_all || !strcmp(res->section, "registers")) {
904 "read reg (port_id) (address)\n"
905 " Display value of a port register.\n\n"
907 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
908 " Display a port register bit field.\n\n"
910 "read regbit (port_id) (address) (bit_x)\n"
911 " Display a single port register bit.\n\n"
913 "write reg (port_id) (address) (value)\n"
914 " Set value of a port register.\n\n"
916 "write regfield (port_id) (address) (bit_x) (bit_y)"
918 " Set bit field of a port register.\n\n"
920 "write regbit (port_id) (address) (bit_x) (value)\n"
921 " Set single bit value of a port register.\n\n"
924 if (show_all || !strcmp(res->section, "filters")) {
932 "ethertype_filter (port_id) (add|del)"
933 " (mac_addr|mac_ignr) (mac_address) ethertype"
934 " (ether_type) (drop|fwd) queue (queue_id)\n"
935 " Add/Del an ethertype filter.\n\n"
937 "2tuple_filter (port_id) (add|del)"
938 " dst_port (dst_port_value) protocol (protocol_value)"
939 " mask (mask_value) tcp_flags (tcp_flags_value)"
940 " priority (prio_value) queue (queue_id)\n"
941 " Add/Del a 2tuple filter.\n\n"
943 "5tuple_filter (port_id) (add|del)"
944 " dst_ip (dst_address) src_ip (src_address)"
945 " dst_port (dst_port_value) src_port (src_port_value)"
946 " protocol (protocol_value)"
947 " mask (mask_value) tcp_flags (tcp_flags_value)"
948 " priority (prio_value) queue (queue_id)\n"
949 " Add/Del a 5tuple filter.\n\n"
951 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
952 " Add/Del syn filter.\n\n"
954 "flex_filter (port_id) (add|del) len (len_value)"
955 " bytes (bytes_value) mask (mask_value)"
956 " priority (prio_value) queue (queue_id)\n"
957 " Add/Del a flex filter.\n\n"
959 "flow_director_filter (port_id) mode IP (add|del|update)"
960 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
961 " src (src_ip_address) dst (dst_ip_address)"
962 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
963 " vlan (vlan_value) flexbytes (flexbytes_value)"
964 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
965 " fd_id (fd_id_value)\n"
966 " Add/Del an IP type flow director filter.\n\n"
968 "flow_director_filter (port_id) mode IP (add|del|update)"
969 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
970 " src (src_ip_address) (src_port)"
971 " dst (dst_ip_address) (dst_port)"
972 " tos (tos_value) ttl (ttl_value)"
973 " vlan (vlan_value) flexbytes (flexbytes_value)"
974 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
975 " fd_id (fd_id_value)\n"
976 " Add/Del an UDP/TCP type flow director filter.\n\n"
978 "flow_director_filter (port_id) mode IP (add|del|update)"
979 " flow (ipv4-sctp|ipv6-sctp)"
980 " src (src_ip_address) (src_port)"
981 " dst (dst_ip_address) (dst_port)"
982 " tag (verification_tag) "
983 " tos (tos_value) ttl (ttl_value)"
985 " flexbytes (flexbytes_value) (drop|fwd)"
986 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
987 " Add/Del a SCTP type flow director filter.\n\n"
989 "flow_director_filter (port_id) mode IP (add|del|update)"
990 " flow l2_payload ether (ethertype)"
991 " flexbytes (flexbytes_value) (drop|fwd)"
992 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
993 " Add/Del a l2 payload type flow director filter.\n\n"
995 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
996 " mac (mac_address) vlan (vlan_value)"
997 " flexbytes (flexbytes_value) (drop|fwd)"
998 " queue (queue_id) fd_id (fd_id_value)\n"
999 " Add/Del a MAC-VLAN flow director filter.\n\n"
1001 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1002 " mac (mac_address) vlan (vlan_value)"
1003 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1004 " flexbytes (flexbytes_value) (drop|fwd)"
1005 " queue (queue_id) fd_id (fd_id_value)\n"
1006 " Add/Del a Tunnel flow director filter.\n\n"
1008 "flow_director_filter (port_id) mode raw (add|del|update)"
1009 " flow (flow_id) (drop|fwd) queue (queue_id)"
1010 " fd_id (fd_id_value) packet (packet file name)\n"
1011 " Add/Del a raw type flow director filter.\n\n"
1013 "flush_flow_director (port_id)\n"
1014 " Flush all flow director entries of a device.\n\n"
1016 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1017 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1018 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1019 " Set flow director IP mask.\n\n"
1021 "flow_director_mask (port_id) mode MAC-VLAN"
1022 " vlan (vlan_value)\n"
1023 " Set flow director MAC-VLAN mask.\n\n"
1025 "flow_director_mask (port_id) mode Tunnel"
1026 " vlan (vlan_value) mac (mac_value)"
1027 " tunnel-type (tunnel_type_value)"
1028 " tunnel-id (tunnel_id_value)\n"
1029 " Set flow director Tunnel mask.\n\n"
1031 "flow_director_flex_mask (port_id)"
1032 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1033 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1035 " Configure mask of flex payload.\n\n"
1037 "flow_director_flex_payload (port_id)"
1038 " (raw|l2|l3|l4) (config)\n"
1039 " Configure flex payload selection.\n\n"
1041 "get_sym_hash_ena_per_port (port_id)\n"
1042 " get symmetric hash enable configuration per port.\n\n"
1044 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1045 " set symmetric hash enable configuration per port"
1046 " to enable or disable.\n\n"
1048 "get_hash_global_config (port_id)\n"
1049 " Get the global configurations of hash filters.\n\n"
1051 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1052 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1053 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1054 " (enable|disable)\n"
1055 " Set the global configurations of hash filters.\n\n"
1057 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1058 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1059 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1060 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1061 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1062 "ipv6-next-header|udp-src-port|udp-dst-port|"
1063 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1064 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1065 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1066 "fld-8th|none) (select|add)\n"
1067 " Set the input set for hash.\n\n"
1069 "set_fdir_input_set (port_id) "
1070 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1071 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1072 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1073 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1074 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1075 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1076 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1078 " Set the input set for FDir.\n\n"
1080 "flow validate {port_id}"
1081 " [group {group_id}] [priority {level}]"
1082 " [ingress] [egress]"
1083 " pattern {item} [/ {item} [...]] / end"
1084 " actions {action} [/ {action} [...]] / end\n"
1085 " Check whether a flow rule can be created.\n\n"
1087 "flow create {port_id}"
1088 " [group {group_id}] [priority {level}]"
1089 " [ingress] [egress]"
1090 " pattern {item} [/ {item} [...]] / end"
1091 " actions {action} [/ {action} [...]] / end\n"
1092 " Create a flow rule.\n\n"
1094 "flow destroy {port_id} rule {rule_id} [...]\n"
1095 " Destroy specific flow rules.\n\n"
1097 "flow flush {port_id}\n"
1098 " Destroy all flow rules.\n\n"
1100 "flow query {port_id} {rule_id} {action}\n"
1101 " Query an existing flow rule.\n\n"
1103 "flow list {port_id} [group {group_id}] [...]\n"
1104 " List existing flow rules sorted by priority,"
1105 " filtered by group identifiers.\n\n"
1107 "flow isolate {port_id} {boolean}\n"
1108 " Restrict ingress traffic to the defined"
1114 cmdline_parse_token_string_t cmd_help_long_help =
1115 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1117 cmdline_parse_token_string_t cmd_help_long_section =
1118 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1119 "all#control#display#config#"
1120 "ports#registers#filters");
1122 cmdline_parse_inst_t cmd_help_long = {
1123 .f = cmd_help_long_parsed,
1125 .help_str = "help all|control|display|config|ports|register|filters: "
1128 (void *)&cmd_help_long_help,
1129 (void *)&cmd_help_long_section,
1135 /* *** start/stop/close all ports *** */
1136 struct cmd_operate_port_result {
1137 cmdline_fixed_string_t keyword;
1138 cmdline_fixed_string_t name;
1139 cmdline_fixed_string_t value;
1142 static void cmd_operate_port_parsed(void *parsed_result,
1143 __attribute__((unused)) struct cmdline *cl,
1144 __attribute__((unused)) void *data)
1146 struct cmd_operate_port_result *res = parsed_result;
1148 if (!strcmp(res->name, "start"))
1149 start_port(RTE_PORT_ALL);
1150 else if (!strcmp(res->name, "stop"))
1151 stop_port(RTE_PORT_ALL);
1152 else if (!strcmp(res->name, "close"))
1153 close_port(RTE_PORT_ALL);
1154 else if (!strcmp(res->name, "reset"))
1155 reset_port(RTE_PORT_ALL);
1157 printf("Unknown parameter\n");
1160 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1161 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1163 cmdline_parse_token_string_t cmd_operate_port_all_port =
1164 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1165 "start#stop#close#reset");
1166 cmdline_parse_token_string_t cmd_operate_port_all_all =
1167 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1169 cmdline_parse_inst_t cmd_operate_port = {
1170 .f = cmd_operate_port_parsed,
1172 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1174 (void *)&cmd_operate_port_all_cmd,
1175 (void *)&cmd_operate_port_all_port,
1176 (void *)&cmd_operate_port_all_all,
1181 /* *** start/stop/close specific port *** */
1182 struct cmd_operate_specific_port_result {
1183 cmdline_fixed_string_t keyword;
1184 cmdline_fixed_string_t name;
1188 static void cmd_operate_specific_port_parsed(void *parsed_result,
1189 __attribute__((unused)) struct cmdline *cl,
1190 __attribute__((unused)) void *data)
1192 struct cmd_operate_specific_port_result *res = parsed_result;
1194 if (!strcmp(res->name, "start"))
1195 start_port(res->value);
1196 else if (!strcmp(res->name, "stop"))
1197 stop_port(res->value);
1198 else if (!strcmp(res->name, "close"))
1199 close_port(res->value);
1200 else if (!strcmp(res->name, "reset"))
1201 reset_port(res->value);
1203 printf("Unknown parameter\n");
1206 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1207 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1209 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1210 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1211 name, "start#stop#close#reset");
1212 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1213 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1216 cmdline_parse_inst_t cmd_operate_specific_port = {
1217 .f = cmd_operate_specific_port_parsed,
1219 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1221 (void *)&cmd_operate_specific_port_cmd,
1222 (void *)&cmd_operate_specific_port_port,
1223 (void *)&cmd_operate_specific_port_id,
1228 /* *** attach a specified port *** */
1229 struct cmd_operate_attach_port_result {
1230 cmdline_fixed_string_t port;
1231 cmdline_fixed_string_t keyword;
1232 cmdline_fixed_string_t identifier;
1235 static void cmd_operate_attach_port_parsed(void *parsed_result,
1236 __attribute__((unused)) struct cmdline *cl,
1237 __attribute__((unused)) void *data)
1239 struct cmd_operate_attach_port_result *res = parsed_result;
1241 if (!strcmp(res->keyword, "attach"))
1242 attach_port(res->identifier);
1244 printf("Unknown parameter\n");
1247 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1248 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1250 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1251 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1253 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1254 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1257 cmdline_parse_inst_t cmd_operate_attach_port = {
1258 .f = cmd_operate_attach_port_parsed,
1260 .help_str = "port attach <identifier>: "
1261 "(identifier: pci address or virtual dev name)",
1263 (void *)&cmd_operate_attach_port_port,
1264 (void *)&cmd_operate_attach_port_keyword,
1265 (void *)&cmd_operate_attach_port_identifier,
1270 /* *** detach a specified port *** */
1271 struct cmd_operate_detach_port_result {
1272 cmdline_fixed_string_t port;
1273 cmdline_fixed_string_t keyword;
1277 static void cmd_operate_detach_port_parsed(void *parsed_result,
1278 __attribute__((unused)) struct cmdline *cl,
1279 __attribute__((unused)) void *data)
1281 struct cmd_operate_detach_port_result *res = parsed_result;
1283 if (!strcmp(res->keyword, "detach"))
1284 detach_port(res->port_id);
1286 printf("Unknown parameter\n");
1289 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1290 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1292 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1293 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1295 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1296 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1299 cmdline_parse_inst_t cmd_operate_detach_port = {
1300 .f = cmd_operate_detach_port_parsed,
1302 .help_str = "port detach <port_id>",
1304 (void *)&cmd_operate_detach_port_port,
1305 (void *)&cmd_operate_detach_port_keyword,
1306 (void *)&cmd_operate_detach_port_port_id,
1311 /* *** configure speed for all ports *** */
1312 struct cmd_config_speed_all {
1313 cmdline_fixed_string_t port;
1314 cmdline_fixed_string_t keyword;
1315 cmdline_fixed_string_t all;
1316 cmdline_fixed_string_t item1;
1317 cmdline_fixed_string_t item2;
1318 cmdline_fixed_string_t value1;
1319 cmdline_fixed_string_t value2;
1323 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1328 if (!strcmp(duplexstr, "half")) {
1329 duplex = ETH_LINK_HALF_DUPLEX;
1330 } else if (!strcmp(duplexstr, "full")) {
1331 duplex = ETH_LINK_FULL_DUPLEX;
1332 } else if (!strcmp(duplexstr, "auto")) {
1333 duplex = ETH_LINK_FULL_DUPLEX;
1335 printf("Unknown duplex parameter\n");
1339 if (!strcmp(speedstr, "10")) {
1340 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1341 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1342 } else if (!strcmp(speedstr, "100")) {
1343 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1344 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1346 if (duplex != ETH_LINK_FULL_DUPLEX) {
1347 printf("Invalid speed/duplex parameters\n");
1350 if (!strcmp(speedstr, "1000")) {
1351 *speed = ETH_LINK_SPEED_1G;
1352 } else if (!strcmp(speedstr, "10000")) {
1353 *speed = ETH_LINK_SPEED_10G;
1354 } else if (!strcmp(speedstr, "25000")) {
1355 *speed = ETH_LINK_SPEED_25G;
1356 } else if (!strcmp(speedstr, "40000")) {
1357 *speed = ETH_LINK_SPEED_40G;
1358 } else if (!strcmp(speedstr, "50000")) {
1359 *speed = ETH_LINK_SPEED_50G;
1360 } else if (!strcmp(speedstr, "100000")) {
1361 *speed = ETH_LINK_SPEED_100G;
1362 } else if (!strcmp(speedstr, "auto")) {
1363 *speed = ETH_LINK_SPEED_AUTONEG;
1365 printf("Unknown speed parameter\n");
1374 cmd_config_speed_all_parsed(void *parsed_result,
1375 __attribute__((unused)) struct cmdline *cl,
1376 __attribute__((unused)) void *data)
1378 struct cmd_config_speed_all *res = parsed_result;
1379 uint32_t link_speed;
1382 if (!all_ports_stopped()) {
1383 printf("Please stop all ports first\n");
1387 if (parse_and_check_speed_duplex(res->value1, res->value2,
1391 RTE_ETH_FOREACH_DEV(pid) {
1392 ports[pid].dev_conf.link_speeds = link_speed;
1395 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1398 cmdline_parse_token_string_t cmd_config_speed_all_port =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1400 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1401 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1403 cmdline_parse_token_string_t cmd_config_speed_all_all =
1404 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1405 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1406 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1407 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1409 "10#100#1000#10000#25000#40000#50000#100000#auto");
1410 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1411 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1412 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1413 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1416 cmdline_parse_inst_t cmd_config_speed_all = {
1417 .f = cmd_config_speed_all_parsed,
1419 .help_str = "port config all speed "
1420 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1423 (void *)&cmd_config_speed_all_port,
1424 (void *)&cmd_config_speed_all_keyword,
1425 (void *)&cmd_config_speed_all_all,
1426 (void *)&cmd_config_speed_all_item1,
1427 (void *)&cmd_config_speed_all_value1,
1428 (void *)&cmd_config_speed_all_item2,
1429 (void *)&cmd_config_speed_all_value2,
1434 /* *** configure speed for specific port *** */
1435 struct cmd_config_speed_specific {
1436 cmdline_fixed_string_t port;
1437 cmdline_fixed_string_t keyword;
1439 cmdline_fixed_string_t item1;
1440 cmdline_fixed_string_t item2;
1441 cmdline_fixed_string_t value1;
1442 cmdline_fixed_string_t value2;
1446 cmd_config_speed_specific_parsed(void *parsed_result,
1447 __attribute__((unused)) struct cmdline *cl,
1448 __attribute__((unused)) void *data)
1450 struct cmd_config_speed_specific *res = parsed_result;
1451 uint32_t link_speed;
1453 if (!all_ports_stopped()) {
1454 printf("Please stop all ports first\n");
1458 if (port_id_is_invalid(res->id, ENABLED_WARN))
1461 if (parse_and_check_speed_duplex(res->value1, res->value2,
1465 ports[res->id].dev_conf.link_speeds = link_speed;
1467 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1471 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1474 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1477 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1478 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1479 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1482 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1483 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1484 "10#100#1000#10000#25000#40000#50000#100000#auto");
1485 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1488 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1489 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1492 cmdline_parse_inst_t cmd_config_speed_specific = {
1493 .f = cmd_config_speed_specific_parsed,
1495 .help_str = "port config <port_id> speed "
1496 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1499 (void *)&cmd_config_speed_specific_port,
1500 (void *)&cmd_config_speed_specific_keyword,
1501 (void *)&cmd_config_speed_specific_id,
1502 (void *)&cmd_config_speed_specific_item1,
1503 (void *)&cmd_config_speed_specific_value1,
1504 (void *)&cmd_config_speed_specific_item2,
1505 (void *)&cmd_config_speed_specific_value2,
1510 /* *** configure loopback for all ports *** */
1511 struct cmd_config_loopback_all {
1512 cmdline_fixed_string_t port;
1513 cmdline_fixed_string_t keyword;
1514 cmdline_fixed_string_t all;
1515 cmdline_fixed_string_t item;
1520 cmd_config_loopback_all_parsed(void *parsed_result,
1521 __attribute__((unused)) struct cmdline *cl,
1522 __attribute__((unused)) void *data)
1524 struct cmd_config_loopback_all *res = parsed_result;
1527 if (!all_ports_stopped()) {
1528 printf("Please stop all ports first\n");
1532 RTE_ETH_FOREACH_DEV(pid) {
1533 ports[pid].dev_conf.lpbk_mode = res->mode;
1536 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1539 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1540 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1541 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1542 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1544 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1545 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1546 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1547 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1549 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1550 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1552 cmdline_parse_inst_t cmd_config_loopback_all = {
1553 .f = cmd_config_loopback_all_parsed,
1555 .help_str = "port config all loopback <mode>",
1557 (void *)&cmd_config_loopback_all_port,
1558 (void *)&cmd_config_loopback_all_keyword,
1559 (void *)&cmd_config_loopback_all_all,
1560 (void *)&cmd_config_loopback_all_item,
1561 (void *)&cmd_config_loopback_all_mode,
1566 /* *** configure loopback for specific port *** */
1567 struct cmd_config_loopback_specific {
1568 cmdline_fixed_string_t port;
1569 cmdline_fixed_string_t keyword;
1571 cmdline_fixed_string_t item;
1576 cmd_config_loopback_specific_parsed(void *parsed_result,
1577 __attribute__((unused)) struct cmdline *cl,
1578 __attribute__((unused)) void *data)
1580 struct cmd_config_loopback_specific *res = parsed_result;
1582 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1585 if (!port_is_stopped(res->port_id)) {
1586 printf("Please stop port %u first\n", res->port_id);
1590 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1592 cmd_reconfig_device_queue(res->port_id, 1, 1);
1596 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1597 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1599 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1600 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1602 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1603 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1605 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1606 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1608 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1609 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1612 cmdline_parse_inst_t cmd_config_loopback_specific = {
1613 .f = cmd_config_loopback_specific_parsed,
1615 .help_str = "port config <port_id> loopback <mode>",
1617 (void *)&cmd_config_loopback_specific_port,
1618 (void *)&cmd_config_loopback_specific_keyword,
1619 (void *)&cmd_config_loopback_specific_id,
1620 (void *)&cmd_config_loopback_specific_item,
1621 (void *)&cmd_config_loopback_specific_mode,
1626 /* *** configure txq/rxq, txd/rxd *** */
1627 struct cmd_config_rx_tx {
1628 cmdline_fixed_string_t port;
1629 cmdline_fixed_string_t keyword;
1630 cmdline_fixed_string_t all;
1631 cmdline_fixed_string_t name;
1636 cmd_config_rx_tx_parsed(void *parsed_result,
1637 __attribute__((unused)) struct cmdline *cl,
1638 __attribute__((unused)) void *data)
1640 struct cmd_config_rx_tx *res = parsed_result;
1642 if (!all_ports_stopped()) {
1643 printf("Please stop all ports first\n");
1646 if (!strcmp(res->name, "rxq")) {
1647 if (!res->value && !nb_txq) {
1648 printf("Warning: Either rx or tx queues should be non zero\n");
1651 if (check_nb_rxq(res->value) != 0)
1653 nb_rxq = res->value;
1655 else if (!strcmp(res->name, "txq")) {
1656 if (!res->value && !nb_rxq) {
1657 printf("Warning: Either rx or tx queues should be non zero\n");
1660 if (check_nb_txq(res->value) != 0)
1662 nb_txq = res->value;
1664 else if (!strcmp(res->name, "rxd")) {
1665 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1666 printf("rxd %d invalid - must be > 0 && <= %d\n",
1667 res->value, RTE_TEST_RX_DESC_MAX);
1670 nb_rxd = res->value;
1671 } else if (!strcmp(res->name, "txd")) {
1672 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1673 printf("txd %d invalid - must be > 0 && <= %d\n",
1674 res->value, RTE_TEST_TX_DESC_MAX);
1677 nb_txd = res->value;
1679 printf("Unknown parameter\n");
1687 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1690 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1691 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1692 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1693 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1694 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1695 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1696 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1697 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1699 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1700 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1702 cmdline_parse_inst_t cmd_config_rx_tx = {
1703 .f = cmd_config_rx_tx_parsed,
1705 .help_str = "port config all rxq|txq|rxd|txd <value>",
1707 (void *)&cmd_config_rx_tx_port,
1708 (void *)&cmd_config_rx_tx_keyword,
1709 (void *)&cmd_config_rx_tx_all,
1710 (void *)&cmd_config_rx_tx_name,
1711 (void *)&cmd_config_rx_tx_value,
1716 /* *** config max packet length *** */
1717 struct cmd_config_max_pkt_len_result {
1718 cmdline_fixed_string_t port;
1719 cmdline_fixed_string_t keyword;
1720 cmdline_fixed_string_t all;
1721 cmdline_fixed_string_t name;
1726 cmd_config_max_pkt_len_parsed(void *parsed_result,
1727 __attribute__((unused)) struct cmdline *cl,
1728 __attribute__((unused)) void *data)
1730 struct cmd_config_max_pkt_len_result *res = parsed_result;
1733 if (!all_ports_stopped()) {
1734 printf("Please stop all ports first\n");
1738 RTE_ETH_FOREACH_DEV(pid) {
1739 struct rte_port *port = &ports[pid];
1740 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1742 if (!strcmp(res->name, "max-pkt-len")) {
1743 if (res->value < ETHER_MIN_LEN) {
1744 printf("max-pkt-len can not be less than %d\n",
1748 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1751 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1752 if (res->value > ETHER_MAX_LEN)
1753 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1755 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1756 port->dev_conf.rxmode.offloads = rx_offloads;
1758 printf("Unknown parameter\n");
1765 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1768 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1771 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1772 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1774 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1775 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1777 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1778 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1780 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1781 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1784 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1785 .f = cmd_config_max_pkt_len_parsed,
1787 .help_str = "port config all max-pkt-len <value>",
1789 (void *)&cmd_config_max_pkt_len_port,
1790 (void *)&cmd_config_max_pkt_len_keyword,
1791 (void *)&cmd_config_max_pkt_len_all,
1792 (void *)&cmd_config_max_pkt_len_name,
1793 (void *)&cmd_config_max_pkt_len_value,
1798 /* *** configure port MTU *** */
1799 struct cmd_config_mtu_result {
1800 cmdline_fixed_string_t port;
1801 cmdline_fixed_string_t keyword;
1802 cmdline_fixed_string_t mtu;
1808 cmd_config_mtu_parsed(void *parsed_result,
1809 __attribute__((unused)) struct cmdline *cl,
1810 __attribute__((unused)) void *data)
1812 struct cmd_config_mtu_result *res = parsed_result;
1814 if (res->value < ETHER_MIN_LEN) {
1815 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1818 port_mtu_set(res->port_id, res->value);
1821 cmdline_parse_token_string_t cmd_config_mtu_port =
1822 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1824 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1825 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1827 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1828 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1830 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1831 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1832 cmdline_parse_token_num_t cmd_config_mtu_value =
1833 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1835 cmdline_parse_inst_t cmd_config_mtu = {
1836 .f = cmd_config_mtu_parsed,
1838 .help_str = "port config mtu <port_id> <value>",
1840 (void *)&cmd_config_mtu_port,
1841 (void *)&cmd_config_mtu_keyword,
1842 (void *)&cmd_config_mtu_mtu,
1843 (void *)&cmd_config_mtu_port_id,
1844 (void *)&cmd_config_mtu_value,
1849 /* *** configure rx mode *** */
1850 struct cmd_config_rx_mode_flag {
1851 cmdline_fixed_string_t port;
1852 cmdline_fixed_string_t keyword;
1853 cmdline_fixed_string_t all;
1854 cmdline_fixed_string_t name;
1855 cmdline_fixed_string_t value;
1859 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1860 __attribute__((unused)) struct cmdline *cl,
1861 __attribute__((unused)) void *data)
1863 struct cmd_config_rx_mode_flag *res = parsed_result;
1866 if (!all_ports_stopped()) {
1867 printf("Please stop all ports first\n");
1871 RTE_ETH_FOREACH_DEV(pid) {
1872 struct rte_port *port;
1873 uint64_t rx_offloads;
1876 rx_offloads = port->dev_conf.rxmode.offloads;
1877 if (!strcmp(res->name, "crc-strip")) {
1878 if (!strcmp(res->value, "on"))
1879 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1880 else if (!strcmp(res->value, "off"))
1881 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1883 printf("Unknown parameter\n");
1886 } else if (!strcmp(res->name, "scatter")) {
1887 if (!strcmp(res->value, "on")) {
1888 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1889 } else if (!strcmp(res->value, "off")) {
1890 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1892 printf("Unknown parameter\n");
1895 } else if (!strcmp(res->name, "rx-cksum")) {
1896 if (!strcmp(res->value, "on"))
1897 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1898 else if (!strcmp(res->value, "off"))
1899 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1901 printf("Unknown parameter\n");
1904 } else if (!strcmp(res->name, "rx-timestamp")) {
1905 if (!strcmp(res->value, "on"))
1906 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1907 else if (!strcmp(res->value, "off"))
1908 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1910 printf("Unknown parameter\n");
1913 } else if (!strcmp(res->name, "hw-vlan")) {
1914 if (!strcmp(res->value, "on")) {
1915 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1916 DEV_RX_OFFLOAD_VLAN_STRIP);
1917 } else if (!strcmp(res->value, "off")) {
1918 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1919 DEV_RX_OFFLOAD_VLAN_STRIP);
1921 printf("Unknown parameter\n");
1924 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1925 if (!strcmp(res->value, "on"))
1926 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1927 else if (!strcmp(res->value, "off"))
1928 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1930 printf("Unknown parameter\n");
1933 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1934 if (!strcmp(res->value, "on"))
1935 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1936 else if (!strcmp(res->value, "off"))
1937 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1939 printf("Unknown parameter\n");
1942 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1943 if (!strcmp(res->value, "on"))
1944 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1945 else if (!strcmp(res->value, "off"))
1946 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1948 printf("Unknown parameter\n");
1951 } else if (!strcmp(res->name, "drop-en")) {
1952 if (!strcmp(res->value, "on"))
1954 else if (!strcmp(res->value, "off"))
1957 printf("Unknown parameter\n");
1961 printf("Unknown parameter\n");
1964 port->dev_conf.rxmode.offloads = rx_offloads;
1969 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1972 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1973 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1974 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1975 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1977 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1978 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1979 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1980 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1981 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1982 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1983 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1984 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1987 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1988 .f = cmd_config_rx_mode_flag_parsed,
1990 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1991 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1993 (void *)&cmd_config_rx_mode_flag_port,
1994 (void *)&cmd_config_rx_mode_flag_keyword,
1995 (void *)&cmd_config_rx_mode_flag_all,
1996 (void *)&cmd_config_rx_mode_flag_name,
1997 (void *)&cmd_config_rx_mode_flag_value,
2002 /* *** configure rss *** */
2003 struct cmd_config_rss {
2004 cmdline_fixed_string_t port;
2005 cmdline_fixed_string_t keyword;
2006 cmdline_fixed_string_t all;
2007 cmdline_fixed_string_t name;
2008 cmdline_fixed_string_t value;
2012 cmd_config_rss_parsed(void *parsed_result,
2013 __attribute__((unused)) struct cmdline *cl,
2014 __attribute__((unused)) void *data)
2016 struct cmd_config_rss *res = parsed_result;
2017 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2018 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2019 int use_default = 0;
2020 int all_updated = 1;
2024 if (!strcmp(res->value, "all"))
2025 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2026 ETH_RSS_UDP | ETH_RSS_SCTP |
2028 else if (!strcmp(res->value, "ip"))
2029 rss_conf.rss_hf = ETH_RSS_IP;
2030 else if (!strcmp(res->value, "udp"))
2031 rss_conf.rss_hf = ETH_RSS_UDP;
2032 else if (!strcmp(res->value, "tcp"))
2033 rss_conf.rss_hf = ETH_RSS_TCP;
2034 else if (!strcmp(res->value, "sctp"))
2035 rss_conf.rss_hf = ETH_RSS_SCTP;
2036 else if (!strcmp(res->value, "ether"))
2037 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2038 else if (!strcmp(res->value, "port"))
2039 rss_conf.rss_hf = ETH_RSS_PORT;
2040 else if (!strcmp(res->value, "vxlan"))
2041 rss_conf.rss_hf = ETH_RSS_VXLAN;
2042 else if (!strcmp(res->value, "geneve"))
2043 rss_conf.rss_hf = ETH_RSS_GENEVE;
2044 else if (!strcmp(res->value, "nvgre"))
2045 rss_conf.rss_hf = ETH_RSS_NVGRE;
2046 else if (!strcmp(res->value, "none"))
2047 rss_conf.rss_hf = 0;
2048 else if (!strcmp(res->value, "default"))
2050 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2051 atoi(res->value) < 64)
2052 rss_conf.rss_hf = 1ULL << atoi(res->value);
2054 printf("Unknown parameter\n");
2057 rss_conf.rss_key = NULL;
2058 /* Update global configuration for RSS types. */
2059 RTE_ETH_FOREACH_DEV(i) {
2061 rte_eth_dev_info_get(i, &dev_info);
2062 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2064 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2067 printf("Configuration of RSS hash at ethernet port %d "
2068 "failed with error (%d): %s.\n",
2069 i, -diag, strerror(-diag));
2072 if (all_updated && !use_default)
2073 rss_hf = rss_conf.rss_hf;
2076 cmdline_parse_token_string_t cmd_config_rss_port =
2077 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2078 cmdline_parse_token_string_t cmd_config_rss_keyword =
2079 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2080 cmdline_parse_token_string_t cmd_config_rss_all =
2081 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2082 cmdline_parse_token_string_t cmd_config_rss_name =
2083 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2084 cmdline_parse_token_string_t cmd_config_rss_value =
2085 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2087 cmdline_parse_inst_t cmd_config_rss = {
2088 .f = cmd_config_rss_parsed,
2090 .help_str = "port config all rss "
2091 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2093 (void *)&cmd_config_rss_port,
2094 (void *)&cmd_config_rss_keyword,
2095 (void *)&cmd_config_rss_all,
2096 (void *)&cmd_config_rss_name,
2097 (void *)&cmd_config_rss_value,
2102 /* *** configure rss hash key *** */
2103 struct cmd_config_rss_hash_key {
2104 cmdline_fixed_string_t port;
2105 cmdline_fixed_string_t config;
2107 cmdline_fixed_string_t rss_hash_key;
2108 cmdline_fixed_string_t rss_type;
2109 cmdline_fixed_string_t key;
2113 hexa_digit_to_value(char hexa_digit)
2115 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2116 return (uint8_t) (hexa_digit - '0');
2117 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2118 return (uint8_t) ((hexa_digit - 'a') + 10);
2119 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2120 return (uint8_t) ((hexa_digit - 'A') + 10);
2121 /* Invalid hexa digit */
2126 parse_and_check_key_hexa_digit(char *key, int idx)
2130 hexa_v = hexa_digit_to_value(key[idx]);
2132 printf("invalid key: character %c at position %d is not a "
2133 "valid hexa digit\n", key[idx], idx);
2138 cmd_config_rss_hash_key_parsed(void *parsed_result,
2139 __attribute__((unused)) struct cmdline *cl,
2140 __attribute__((unused)) void *data)
2142 struct cmd_config_rss_hash_key *res = parsed_result;
2143 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2147 struct rte_eth_dev_info dev_info;
2148 uint8_t hash_key_size;
2151 memset(&dev_info, 0, sizeof(dev_info));
2152 rte_eth_dev_info_get(res->port_id, &dev_info);
2153 if (dev_info.hash_key_size > 0 &&
2154 dev_info.hash_key_size <= sizeof(hash_key))
2155 hash_key_size = dev_info.hash_key_size;
2157 printf("dev_info did not provide a valid hash key size\n");
2160 /* Check the length of the RSS hash key */
2161 key_len = strlen(res->key);
2162 if (key_len != (hash_key_size * 2)) {
2163 printf("key length: %d invalid - key must be a string of %d"
2164 " hexa-decimal numbers\n",
2165 (int) key_len, hash_key_size * 2);
2168 /* Translate RSS hash key into binary representation */
2169 for (i = 0; i < hash_key_size; i++) {
2170 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2173 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2176 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2178 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2182 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2183 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2184 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2185 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2187 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2188 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2189 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2190 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2191 rss_hash_key, "rss-hash-key");
2192 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2193 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2194 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2195 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2196 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2197 "ipv6-tcp-ex#ipv6-udp-ex");
2198 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2199 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2201 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2202 .f = cmd_config_rss_hash_key_parsed,
2204 .help_str = "port config <port_id> rss-hash-key "
2205 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2206 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2207 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2208 "<string of hex digits (variable length, NIC dependent)>",
2210 (void *)&cmd_config_rss_hash_key_port,
2211 (void *)&cmd_config_rss_hash_key_config,
2212 (void *)&cmd_config_rss_hash_key_port_id,
2213 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2214 (void *)&cmd_config_rss_hash_key_rss_type,
2215 (void *)&cmd_config_rss_hash_key_value,
2220 /* *** configure port rxq/txq ring size *** */
2221 struct cmd_config_rxtx_ring_size {
2222 cmdline_fixed_string_t port;
2223 cmdline_fixed_string_t config;
2225 cmdline_fixed_string_t rxtxq;
2227 cmdline_fixed_string_t rsize;
2232 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2233 __attribute__((unused)) struct cmdline *cl,
2234 __attribute__((unused)) void *data)
2236 struct cmd_config_rxtx_ring_size *res = parsed_result;
2237 struct rte_port *port;
2240 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2243 if (res->portid == (portid_t)RTE_PORT_ALL) {
2244 printf("Invalid port id\n");
2248 port = &ports[res->portid];
2250 if (!strcmp(res->rxtxq, "rxq"))
2252 else if (!strcmp(res->rxtxq, "txq"))
2255 printf("Unknown parameter\n");
2259 if (isrx && rx_queue_id_is_invalid(res->qid))
2261 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2264 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2265 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2271 port->nb_rx_desc[res->qid] = res->size;
2273 port->nb_tx_desc[res->qid] = res->size;
2275 cmd_reconfig_device_queue(res->portid, 0, 1);
2278 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2279 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2281 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2282 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2284 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2285 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2287 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2288 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2290 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2291 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2293 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2294 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2295 rsize, "ring_size");
2296 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2297 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2300 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2301 .f = cmd_config_rxtx_ring_size_parsed,
2303 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2305 (void *)&cmd_config_rxtx_ring_size_port,
2306 (void *)&cmd_config_rxtx_ring_size_config,
2307 (void *)&cmd_config_rxtx_ring_size_portid,
2308 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2309 (void *)&cmd_config_rxtx_ring_size_qid,
2310 (void *)&cmd_config_rxtx_ring_size_rsize,
2311 (void *)&cmd_config_rxtx_ring_size_size,
2316 /* *** configure port rxq/txq start/stop *** */
2317 struct cmd_config_rxtx_queue {
2318 cmdline_fixed_string_t port;
2320 cmdline_fixed_string_t rxtxq;
2322 cmdline_fixed_string_t opname;
2326 cmd_config_rxtx_queue_parsed(void *parsed_result,
2327 __attribute__((unused)) struct cmdline *cl,
2328 __attribute__((unused)) void *data)
2330 struct cmd_config_rxtx_queue *res = parsed_result;
2335 if (test_done == 0) {
2336 printf("Please stop forwarding first\n");
2340 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2343 if (port_is_started(res->portid) != 1) {
2344 printf("Please start port %u first\n", res->portid);
2348 if (!strcmp(res->rxtxq, "rxq"))
2350 else if (!strcmp(res->rxtxq, "txq"))
2353 printf("Unknown parameter\n");
2357 if (isrx && rx_queue_id_is_invalid(res->qid))
2359 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2362 if (!strcmp(res->opname, "start"))
2364 else if (!strcmp(res->opname, "stop"))
2367 printf("Unknown parameter\n");
2371 if (isstart && isrx)
2372 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2373 else if (!isstart && isrx)
2374 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2375 else if (isstart && !isrx)
2376 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2378 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2380 if (ret == -ENOTSUP)
2381 printf("Function not supported in PMD driver\n");
2384 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2385 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2386 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2387 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2388 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2389 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2390 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2391 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2392 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2393 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2396 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2397 .f = cmd_config_rxtx_queue_parsed,
2399 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2401 (void *)&cmd_config_rxtx_queue_port,
2402 (void *)&cmd_config_rxtx_queue_portid,
2403 (void *)&cmd_config_rxtx_queue_rxtxq,
2404 (void *)&cmd_config_rxtx_queue_qid,
2405 (void *)&cmd_config_rxtx_queue_opname,
2410 /* *** configure port rxq/txq setup *** */
2411 struct cmd_setup_rxtx_queue {
2412 cmdline_fixed_string_t port;
2414 cmdline_fixed_string_t rxtxq;
2416 cmdline_fixed_string_t setup;
2419 /* Common CLI fields for queue setup */
2420 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2421 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2422 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2423 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2424 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2425 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2426 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2427 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2428 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2429 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2432 cmd_setup_rxtx_queue_parsed(
2433 void *parsed_result,
2434 __attribute__((unused)) struct cmdline *cl,
2435 __attribute__((unused)) void *data)
2437 struct cmd_setup_rxtx_queue *res = parsed_result;
2438 struct rte_port *port;
2439 struct rte_mempool *mp;
2440 unsigned int socket_id;
2444 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2447 if (res->portid == (portid_t)RTE_PORT_ALL) {
2448 printf("Invalid port id\n");
2452 if (!strcmp(res->rxtxq, "rxq"))
2454 else if (!strcmp(res->rxtxq, "txq"))
2457 printf("Unknown parameter\n");
2461 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2462 printf("Invalid rx queue\n");
2464 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2465 printf("Invalid tx queue\n");
2469 port = &ports[res->portid];
2471 socket_id = rxring_numa[res->portid];
2472 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2473 socket_id = port->socket_id;
2475 mp = mbuf_pool_find(socket_id);
2477 printf("Failed to setup RX queue: "
2478 "No mempool allocation"
2479 " on the socket %d\n",
2480 rxring_numa[res->portid]);
2483 ret = rte_eth_rx_queue_setup(res->portid,
2485 port->nb_rx_desc[res->qid],
2487 &port->rx_conf[res->qid],
2490 printf("Failed to setup RX queue\n");
2492 socket_id = txring_numa[res->portid];
2493 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2494 socket_id = port->socket_id;
2496 ret = rte_eth_tx_queue_setup(res->portid,
2498 port->nb_tx_desc[res->qid],
2500 &port->tx_conf[res->qid]);
2502 printf("Failed to setup TX queue\n");
2506 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2507 .f = cmd_setup_rxtx_queue_parsed,
2509 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2511 (void *)&cmd_setup_rxtx_queue_port,
2512 (void *)&cmd_setup_rxtx_queue_portid,
2513 (void *)&cmd_setup_rxtx_queue_rxtxq,
2514 (void *)&cmd_setup_rxtx_queue_qid,
2515 (void *)&cmd_setup_rxtx_queue_setup,
2521 /* *** Configure RSS RETA *** */
2522 struct cmd_config_rss_reta {
2523 cmdline_fixed_string_t port;
2524 cmdline_fixed_string_t keyword;
2526 cmdline_fixed_string_t name;
2527 cmdline_fixed_string_t list_name;
2528 cmdline_fixed_string_t list_of_items;
2532 parse_reta_config(const char *str,
2533 struct rte_eth_rss_reta_entry64 *reta_conf,
2534 uint16_t nb_entries)
2538 uint16_t hash_index, idx, shift;
2541 const char *p, *p0 = str;
2548 unsigned long int_fld[_NUM_FLD];
2549 char *str_fld[_NUM_FLD];
2551 while ((p = strchr(p0,'(')) != NULL) {
2553 if((p0 = strchr(p,')')) == NULL)
2557 if(size >= sizeof(s))
2560 snprintf(s, sizeof(s), "%.*s", size, p);
2561 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2563 for (i = 0; i < _NUM_FLD; i++) {
2565 int_fld[i] = strtoul(str_fld[i], &end, 0);
2566 if (errno != 0 || end == str_fld[i] ||
2571 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2572 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2574 if (hash_index >= nb_entries) {
2575 printf("Invalid RETA hash index=%d\n", hash_index);
2579 idx = hash_index / RTE_RETA_GROUP_SIZE;
2580 shift = hash_index % RTE_RETA_GROUP_SIZE;
2581 reta_conf[idx].mask |= (1ULL << shift);
2582 reta_conf[idx].reta[shift] = nb_queue;
2589 cmd_set_rss_reta_parsed(void *parsed_result,
2590 __attribute__((unused)) struct cmdline *cl,
2591 __attribute__((unused)) void *data)
2594 struct rte_eth_dev_info dev_info;
2595 struct rte_eth_rss_reta_entry64 reta_conf[8];
2596 struct cmd_config_rss_reta *res = parsed_result;
2598 memset(&dev_info, 0, sizeof(dev_info));
2599 rte_eth_dev_info_get(res->port_id, &dev_info);
2600 if (dev_info.reta_size == 0) {
2601 printf("Redirection table size is 0 which is "
2602 "invalid for RSS\n");
2605 printf("The reta size of port %d is %u\n",
2606 res->port_id, dev_info.reta_size);
2607 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2608 printf("Currently do not support more than %u entries of "
2609 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2613 memset(reta_conf, 0, sizeof(reta_conf));
2614 if (!strcmp(res->list_name, "reta")) {
2615 if (parse_reta_config(res->list_of_items, reta_conf,
2616 dev_info.reta_size)) {
2617 printf("Invalid RSS Redirection Table "
2618 "config entered\n");
2621 ret = rte_eth_dev_rss_reta_update(res->port_id,
2622 reta_conf, dev_info.reta_size);
2624 printf("Bad redirection table parameter, "
2625 "return code = %d \n", ret);
2629 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2630 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2631 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2632 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2633 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2634 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2635 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2636 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2637 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2638 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2639 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2640 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2642 cmdline_parse_inst_t cmd_config_rss_reta = {
2643 .f = cmd_set_rss_reta_parsed,
2645 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2647 (void *)&cmd_config_rss_reta_port,
2648 (void *)&cmd_config_rss_reta_keyword,
2649 (void *)&cmd_config_rss_reta_port_id,
2650 (void *)&cmd_config_rss_reta_name,
2651 (void *)&cmd_config_rss_reta_list_name,
2652 (void *)&cmd_config_rss_reta_list_of_items,
2657 /* *** SHOW PORT RETA INFO *** */
2658 struct cmd_showport_reta {
2659 cmdline_fixed_string_t show;
2660 cmdline_fixed_string_t port;
2662 cmdline_fixed_string_t rss;
2663 cmdline_fixed_string_t reta;
2665 cmdline_fixed_string_t list_of_items;
2669 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2670 uint16_t nb_entries,
2674 const char *p, *p0 = str;
2679 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2680 RTE_RETA_GROUP_SIZE;
2683 p = strchr(p0, '(');
2687 p0 = strchr(p, ')');
2691 if (size >= sizeof(s)) {
2692 printf("The string size exceeds the internal buffer size\n");
2695 snprintf(s, sizeof(s), "%.*s", size, p);
2696 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2697 if (ret <= 0 || ret != num) {
2698 printf("The bits of masks do not match the number of "
2699 "reta entries: %u\n", num);
2702 for (i = 0; i < ret; i++)
2703 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2709 cmd_showport_reta_parsed(void *parsed_result,
2710 __attribute__((unused)) struct cmdline *cl,
2711 __attribute__((unused)) void *data)
2713 struct cmd_showport_reta *res = parsed_result;
2714 struct rte_eth_rss_reta_entry64 reta_conf[8];
2715 struct rte_eth_dev_info dev_info;
2716 uint16_t max_reta_size;
2718 memset(&dev_info, 0, sizeof(dev_info));
2719 rte_eth_dev_info_get(res->port_id, &dev_info);
2720 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2721 if (res->size == 0 || res->size > max_reta_size) {
2722 printf("Invalid redirection table size: %u (1-%u)\n",
2723 res->size, max_reta_size);
2727 memset(reta_conf, 0, sizeof(reta_conf));
2728 if (showport_parse_reta_config(reta_conf, res->size,
2729 res->list_of_items) < 0) {
2730 printf("Invalid string: %s for reta masks\n",
2731 res->list_of_items);
2734 port_rss_reta_info(res->port_id, reta_conf, res->size);
2737 cmdline_parse_token_string_t cmd_showport_reta_show =
2738 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2739 cmdline_parse_token_string_t cmd_showport_reta_port =
2740 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2741 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2742 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2743 cmdline_parse_token_string_t cmd_showport_reta_rss =
2744 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2745 cmdline_parse_token_string_t cmd_showport_reta_reta =
2746 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2747 cmdline_parse_token_num_t cmd_showport_reta_size =
2748 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2749 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2750 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2751 list_of_items, NULL);
2753 cmdline_parse_inst_t cmd_showport_reta = {
2754 .f = cmd_showport_reta_parsed,
2756 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2758 (void *)&cmd_showport_reta_show,
2759 (void *)&cmd_showport_reta_port,
2760 (void *)&cmd_showport_reta_port_id,
2761 (void *)&cmd_showport_reta_rss,
2762 (void *)&cmd_showport_reta_reta,
2763 (void *)&cmd_showport_reta_size,
2764 (void *)&cmd_showport_reta_list_of_items,
2769 /* *** Show RSS hash configuration *** */
2770 struct cmd_showport_rss_hash {
2771 cmdline_fixed_string_t show;
2772 cmdline_fixed_string_t port;
2774 cmdline_fixed_string_t rss_hash;
2775 cmdline_fixed_string_t rss_type;
2776 cmdline_fixed_string_t key; /* optional argument */
2779 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2780 __attribute__((unused)) struct cmdline *cl,
2783 struct cmd_showport_rss_hash *res = parsed_result;
2785 port_rss_hash_conf_show(res->port_id, res->rss_type,
2786 show_rss_key != NULL);
2789 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2790 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2791 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2792 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2793 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2794 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2795 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2796 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2798 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2799 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2800 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2801 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2802 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2803 "ipv6-tcp-ex#ipv6-udp-ex");
2804 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2805 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2807 cmdline_parse_inst_t cmd_showport_rss_hash = {
2808 .f = cmd_showport_rss_hash_parsed,
2810 .help_str = "show port <port_id> rss-hash "
2811 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2812 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2813 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2815 (void *)&cmd_showport_rss_hash_show,
2816 (void *)&cmd_showport_rss_hash_port,
2817 (void *)&cmd_showport_rss_hash_port_id,
2818 (void *)&cmd_showport_rss_hash_rss_hash,
2819 (void *)&cmd_showport_rss_hash_rss_hash_info,
2824 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2825 .f = cmd_showport_rss_hash_parsed,
2827 .help_str = "show port <port_id> rss-hash "
2828 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2829 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2830 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2832 (void *)&cmd_showport_rss_hash_show,
2833 (void *)&cmd_showport_rss_hash_port,
2834 (void *)&cmd_showport_rss_hash_port_id,
2835 (void *)&cmd_showport_rss_hash_rss_hash,
2836 (void *)&cmd_showport_rss_hash_rss_hash_info,
2837 (void *)&cmd_showport_rss_hash_rss_key,
2842 /* *** Configure DCB *** */
2843 struct cmd_config_dcb {
2844 cmdline_fixed_string_t port;
2845 cmdline_fixed_string_t config;
2847 cmdline_fixed_string_t dcb;
2848 cmdline_fixed_string_t vt;
2849 cmdline_fixed_string_t vt_en;
2851 cmdline_fixed_string_t pfc;
2852 cmdline_fixed_string_t pfc_en;
2856 cmd_config_dcb_parsed(void *parsed_result,
2857 __attribute__((unused)) struct cmdline *cl,
2858 __attribute__((unused)) void *data)
2860 struct cmd_config_dcb *res = parsed_result;
2861 portid_t port_id = res->port_id;
2862 struct rte_port *port;
2866 port = &ports[port_id];
2867 /** Check if the port is not started **/
2868 if (port->port_status != RTE_PORT_STOPPED) {
2869 printf("Please stop port %d first\n", port_id);
2873 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2874 printf("The invalid number of traffic class,"
2875 " only 4 or 8 allowed.\n");
2879 if (nb_fwd_lcores < res->num_tcs) {
2880 printf("nb_cores shouldn't be less than number of TCs.\n");
2883 if (!strncmp(res->pfc_en, "on", 2))
2888 /* DCB in VT mode */
2889 if (!strncmp(res->vt_en, "on", 2))
2890 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2891 (enum rte_eth_nb_tcs)res->num_tcs,
2894 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2895 (enum rte_eth_nb_tcs)res->num_tcs,
2900 printf("Cannot initialize network ports.\n");
2904 cmd_reconfig_device_queue(port_id, 1, 1);
2907 cmdline_parse_token_string_t cmd_config_dcb_port =
2908 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2909 cmdline_parse_token_string_t cmd_config_dcb_config =
2910 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2911 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2912 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2913 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2914 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2915 cmdline_parse_token_string_t cmd_config_dcb_vt =
2916 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2917 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2918 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2919 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2920 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2921 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2922 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2923 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2924 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2926 cmdline_parse_inst_t cmd_config_dcb = {
2927 .f = cmd_config_dcb_parsed,
2929 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2931 (void *)&cmd_config_dcb_port,
2932 (void *)&cmd_config_dcb_config,
2933 (void *)&cmd_config_dcb_port_id,
2934 (void *)&cmd_config_dcb_dcb,
2935 (void *)&cmd_config_dcb_vt,
2936 (void *)&cmd_config_dcb_vt_en,
2937 (void *)&cmd_config_dcb_num_tcs,
2938 (void *)&cmd_config_dcb_pfc,
2939 (void *)&cmd_config_dcb_pfc_en,
2944 /* *** configure number of packets per burst *** */
2945 struct cmd_config_burst {
2946 cmdline_fixed_string_t port;
2947 cmdline_fixed_string_t keyword;
2948 cmdline_fixed_string_t all;
2949 cmdline_fixed_string_t name;
2954 cmd_config_burst_parsed(void *parsed_result,
2955 __attribute__((unused)) struct cmdline *cl,
2956 __attribute__((unused)) void *data)
2958 struct cmd_config_burst *res = parsed_result;
2959 struct rte_eth_dev_info dev_info;
2960 uint16_t rec_nb_pkts;
2962 if (!all_ports_stopped()) {
2963 printf("Please stop all ports first\n");
2967 if (!strcmp(res->name, "burst")) {
2968 if (res->value == 0) {
2969 /* If user gives a value of zero, query the PMD for
2970 * its recommended Rx burst size. Testpmd uses a single
2971 * size for all ports, so assume all ports are the same
2972 * NIC model and use the values from Port 0.
2974 rte_eth_dev_info_get(0, &dev_info);
2975 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2977 if (rec_nb_pkts == 0) {
2978 printf("PMD does not recommend a burst size.\n"
2979 "User provided value must be between"
2980 " 1 and %d\n", MAX_PKT_BURST);
2982 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2983 printf("PMD recommended burst size of %d"
2984 " exceeds maximum value of %d\n",
2985 rec_nb_pkts, MAX_PKT_BURST);
2988 printf("Using PMD-provided burst value of %d\n",
2990 nb_pkt_per_burst = rec_nb_pkts;
2991 } else if (res->value > MAX_PKT_BURST) {
2992 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2995 nb_pkt_per_burst = res->value;
2997 printf("Unknown parameter\n");
3003 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3006 cmdline_parse_token_string_t cmd_config_burst_port =
3007 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3008 cmdline_parse_token_string_t cmd_config_burst_keyword =
3009 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3010 cmdline_parse_token_string_t cmd_config_burst_all =
3011 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3012 cmdline_parse_token_string_t cmd_config_burst_name =
3013 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3014 cmdline_parse_token_num_t cmd_config_burst_value =
3015 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3017 cmdline_parse_inst_t cmd_config_burst = {
3018 .f = cmd_config_burst_parsed,
3020 .help_str = "port config all burst <value>",
3022 (void *)&cmd_config_burst_port,
3023 (void *)&cmd_config_burst_keyword,
3024 (void *)&cmd_config_burst_all,
3025 (void *)&cmd_config_burst_name,
3026 (void *)&cmd_config_burst_value,
3031 /* *** configure rx/tx queues *** */
3032 struct cmd_config_thresh {
3033 cmdline_fixed_string_t port;
3034 cmdline_fixed_string_t keyword;
3035 cmdline_fixed_string_t all;
3036 cmdline_fixed_string_t name;
3041 cmd_config_thresh_parsed(void *parsed_result,
3042 __attribute__((unused)) struct cmdline *cl,
3043 __attribute__((unused)) void *data)
3045 struct cmd_config_thresh *res = parsed_result;
3047 if (!all_ports_stopped()) {
3048 printf("Please stop all ports first\n");
3052 if (!strcmp(res->name, "txpt"))
3053 tx_pthresh = res->value;
3054 else if(!strcmp(res->name, "txht"))
3055 tx_hthresh = res->value;
3056 else if(!strcmp(res->name, "txwt"))
3057 tx_wthresh = res->value;
3058 else if(!strcmp(res->name, "rxpt"))
3059 rx_pthresh = res->value;
3060 else if(!strcmp(res->name, "rxht"))
3061 rx_hthresh = res->value;
3062 else if(!strcmp(res->name, "rxwt"))
3063 rx_wthresh = res->value;
3065 printf("Unknown parameter\n");
3071 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3074 cmdline_parse_token_string_t cmd_config_thresh_port =
3075 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3076 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3077 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3078 cmdline_parse_token_string_t cmd_config_thresh_all =
3079 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3080 cmdline_parse_token_string_t cmd_config_thresh_name =
3081 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3082 "txpt#txht#txwt#rxpt#rxht#rxwt");
3083 cmdline_parse_token_num_t cmd_config_thresh_value =
3084 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3086 cmdline_parse_inst_t cmd_config_thresh = {
3087 .f = cmd_config_thresh_parsed,
3089 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3091 (void *)&cmd_config_thresh_port,
3092 (void *)&cmd_config_thresh_keyword,
3093 (void *)&cmd_config_thresh_all,
3094 (void *)&cmd_config_thresh_name,
3095 (void *)&cmd_config_thresh_value,
3100 /* *** configure free/rs threshold *** */
3101 struct cmd_config_threshold {
3102 cmdline_fixed_string_t port;
3103 cmdline_fixed_string_t keyword;
3104 cmdline_fixed_string_t all;
3105 cmdline_fixed_string_t name;
3110 cmd_config_threshold_parsed(void *parsed_result,
3111 __attribute__((unused)) struct cmdline *cl,
3112 __attribute__((unused)) void *data)
3114 struct cmd_config_threshold *res = parsed_result;
3116 if (!all_ports_stopped()) {
3117 printf("Please stop all ports first\n");
3121 if (!strcmp(res->name, "txfreet"))
3122 tx_free_thresh = res->value;
3123 else if (!strcmp(res->name, "txrst"))
3124 tx_rs_thresh = res->value;
3125 else if (!strcmp(res->name, "rxfreet"))
3126 rx_free_thresh = res->value;
3128 printf("Unknown parameter\n");
3134 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3137 cmdline_parse_token_string_t cmd_config_threshold_port =
3138 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3139 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3140 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3142 cmdline_parse_token_string_t cmd_config_threshold_all =
3143 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3144 cmdline_parse_token_string_t cmd_config_threshold_name =
3145 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3146 "txfreet#txrst#rxfreet");
3147 cmdline_parse_token_num_t cmd_config_threshold_value =
3148 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3150 cmdline_parse_inst_t cmd_config_threshold = {
3151 .f = cmd_config_threshold_parsed,
3153 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3155 (void *)&cmd_config_threshold_port,
3156 (void *)&cmd_config_threshold_keyword,
3157 (void *)&cmd_config_threshold_all,
3158 (void *)&cmd_config_threshold_name,
3159 (void *)&cmd_config_threshold_value,
3165 struct cmd_stop_result {
3166 cmdline_fixed_string_t stop;
3169 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3170 __attribute__((unused)) struct cmdline *cl,
3171 __attribute__((unused)) void *data)
3173 stop_packet_forwarding();
3176 cmdline_parse_token_string_t cmd_stop_stop =
3177 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3179 cmdline_parse_inst_t cmd_stop = {
3180 .f = cmd_stop_parsed,
3182 .help_str = "stop: Stop packet forwarding",
3184 (void *)&cmd_stop_stop,
3189 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3192 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3193 unsigned int *parsed_items, int check_unique_values)
3195 unsigned int nb_item;
3203 * First parse all items in the list and store their value.
3208 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3210 if ((c >= '0') && (c <= '9')) {
3211 value = (unsigned int) (value * 10 + (c - '0'));
3216 printf("character %c is not a decimal digit\n", c);
3220 printf("No valid value before comma\n");
3223 if (nb_item < max_items) {
3224 parsed_items[nb_item] = value;
3230 if (nb_item >= max_items) {
3231 printf("Number of %s = %u > %u (maximum items)\n",
3232 item_name, nb_item + 1, max_items);
3235 parsed_items[nb_item++] = value;
3236 if (! check_unique_values)
3240 * Then, check that all values in the list are differents.
3241 * No optimization here...
3243 for (i = 0; i < nb_item; i++) {
3244 for (j = i + 1; j < nb_item; j++) {
3245 if (parsed_items[j] == parsed_items[i]) {
3246 printf("duplicated %s %u at index %u and %u\n",
3247 item_name, parsed_items[i], i, j);
3255 struct cmd_set_list_result {
3256 cmdline_fixed_string_t cmd_keyword;
3257 cmdline_fixed_string_t list_name;
3258 cmdline_fixed_string_t list_of_items;
3261 static void cmd_set_list_parsed(void *parsed_result,
3262 __attribute__((unused)) struct cmdline *cl,
3263 __attribute__((unused)) void *data)
3265 struct cmd_set_list_result *res;
3267 unsigned int lcorelist[RTE_MAX_LCORE];
3268 unsigned int portlist[RTE_MAX_ETHPORTS];
3270 unsigned int nb_item;
3272 if (test_done == 0) {
3273 printf("Please stop forwarding first\n");
3277 res = parsed_result;
3278 if (!strcmp(res->list_name, "corelist")) {
3279 nb_item = parse_item_list(res->list_of_items, "core",
3281 parsed_items.lcorelist, 1);
3283 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3288 if (!strcmp(res->list_name, "portlist")) {
3289 nb_item = parse_item_list(res->list_of_items, "port",
3291 parsed_items.portlist, 1);
3293 set_fwd_ports_list(parsed_items.portlist, nb_item);
3299 cmdline_parse_token_string_t cmd_set_list_keyword =
3300 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3302 cmdline_parse_token_string_t cmd_set_list_name =
3303 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3304 "corelist#portlist");
3305 cmdline_parse_token_string_t cmd_set_list_of_items =
3306 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3309 cmdline_parse_inst_t cmd_set_fwd_list = {
3310 .f = cmd_set_list_parsed,
3312 .help_str = "set corelist|portlist <list0[,list1]*>",
3314 (void *)&cmd_set_list_keyword,
3315 (void *)&cmd_set_list_name,
3316 (void *)&cmd_set_list_of_items,
3321 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3323 struct cmd_setmask_result {
3324 cmdline_fixed_string_t set;
3325 cmdline_fixed_string_t mask;
3329 static void cmd_set_mask_parsed(void *parsed_result,
3330 __attribute__((unused)) struct cmdline *cl,
3331 __attribute__((unused)) void *data)
3333 struct cmd_setmask_result *res = parsed_result;
3335 if (test_done == 0) {
3336 printf("Please stop forwarding first\n");
3339 if (!strcmp(res->mask, "coremask")) {
3340 set_fwd_lcores_mask(res->hexavalue);
3342 } else if (!strcmp(res->mask, "portmask")) {
3343 set_fwd_ports_mask(res->hexavalue);
3348 cmdline_parse_token_string_t cmd_setmask_set =
3349 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3350 cmdline_parse_token_string_t cmd_setmask_mask =
3351 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3352 "coremask#portmask");
3353 cmdline_parse_token_num_t cmd_setmask_value =
3354 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3356 cmdline_parse_inst_t cmd_set_fwd_mask = {
3357 .f = cmd_set_mask_parsed,
3359 .help_str = "set coremask|portmask <hexadecimal value>",
3361 (void *)&cmd_setmask_set,
3362 (void *)&cmd_setmask_mask,
3363 (void *)&cmd_setmask_value,
3369 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3371 struct cmd_set_result {
3372 cmdline_fixed_string_t set;
3373 cmdline_fixed_string_t what;
3377 static void cmd_set_parsed(void *parsed_result,
3378 __attribute__((unused)) struct cmdline *cl,
3379 __attribute__((unused)) void *data)
3381 struct cmd_set_result *res = parsed_result;
3382 if (!strcmp(res->what, "nbport")) {
3383 set_fwd_ports_number(res->value);
3385 } else if (!strcmp(res->what, "nbcore")) {
3386 set_fwd_lcores_number(res->value);
3388 } else if (!strcmp(res->what, "burst"))
3389 set_nb_pkt_per_burst(res->value);
3390 else if (!strcmp(res->what, "verbose"))
3391 set_verbose_level(res->value);
3394 cmdline_parse_token_string_t cmd_set_set =
3395 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3396 cmdline_parse_token_string_t cmd_set_what =
3397 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3398 "nbport#nbcore#burst#verbose");
3399 cmdline_parse_token_num_t cmd_set_value =
3400 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3402 cmdline_parse_inst_t cmd_set_numbers = {
3403 .f = cmd_set_parsed,
3405 .help_str = "set nbport|nbcore|burst|verbose <value>",
3407 (void *)&cmd_set_set,
3408 (void *)&cmd_set_what,
3409 (void *)&cmd_set_value,
3414 /* *** SET LOG LEVEL CONFIGURATION *** */
3416 struct cmd_set_log_result {
3417 cmdline_fixed_string_t set;
3418 cmdline_fixed_string_t log;
3419 cmdline_fixed_string_t type;
3424 cmd_set_log_parsed(void *parsed_result,
3425 __attribute__((unused)) struct cmdline *cl,
3426 __attribute__((unused)) void *data)
3428 struct cmd_set_log_result *res;
3431 res = parsed_result;
3432 if (!strcmp(res->type, "global"))
3433 rte_log_set_global_level(res->level);
3435 ret = rte_log_set_level_regexp(res->type, res->level);
3437 printf("Unable to set log level\n");
3441 cmdline_parse_token_string_t cmd_set_log_set =
3442 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3443 cmdline_parse_token_string_t cmd_set_log_log =
3444 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3445 cmdline_parse_token_string_t cmd_set_log_type =
3446 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3447 cmdline_parse_token_num_t cmd_set_log_level =
3448 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3450 cmdline_parse_inst_t cmd_set_log = {
3451 .f = cmd_set_log_parsed,
3453 .help_str = "set log global|<type> <level>",
3455 (void *)&cmd_set_log_set,
3456 (void *)&cmd_set_log_log,
3457 (void *)&cmd_set_log_type,
3458 (void *)&cmd_set_log_level,
3463 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3465 struct cmd_set_txpkts_result {
3466 cmdline_fixed_string_t cmd_keyword;
3467 cmdline_fixed_string_t txpkts;
3468 cmdline_fixed_string_t seg_lengths;
3472 cmd_set_txpkts_parsed(void *parsed_result,
3473 __attribute__((unused)) struct cmdline *cl,
3474 __attribute__((unused)) void *data)
3476 struct cmd_set_txpkts_result *res;
3477 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3478 unsigned int nb_segs;
3480 res = parsed_result;
3481 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3482 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3484 set_tx_pkt_segments(seg_lengths, nb_segs);
3487 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3488 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3489 cmd_keyword, "set");
3490 cmdline_parse_token_string_t cmd_set_txpkts_name =
3491 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3493 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3494 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3497 cmdline_parse_inst_t cmd_set_txpkts = {
3498 .f = cmd_set_txpkts_parsed,
3500 .help_str = "set txpkts <len0[,len1]*>",
3502 (void *)&cmd_set_txpkts_keyword,
3503 (void *)&cmd_set_txpkts_name,
3504 (void *)&cmd_set_txpkts_lengths,
3509 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3511 struct cmd_set_txsplit_result {
3512 cmdline_fixed_string_t cmd_keyword;
3513 cmdline_fixed_string_t txsplit;
3514 cmdline_fixed_string_t mode;
3518 cmd_set_txsplit_parsed(void *parsed_result,
3519 __attribute__((unused)) struct cmdline *cl,
3520 __attribute__((unused)) void *data)
3522 struct cmd_set_txsplit_result *res;
3524 res = parsed_result;
3525 set_tx_pkt_split(res->mode);
3528 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3529 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3530 cmd_keyword, "set");
3531 cmdline_parse_token_string_t cmd_set_txsplit_name =
3532 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3533 txsplit, "txsplit");
3534 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3535 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3538 cmdline_parse_inst_t cmd_set_txsplit = {
3539 .f = cmd_set_txsplit_parsed,
3541 .help_str = "set txsplit on|off|rand",
3543 (void *)&cmd_set_txsplit_keyword,
3544 (void *)&cmd_set_txsplit_name,
3545 (void *)&cmd_set_txsplit_mode,
3550 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3551 struct cmd_rx_vlan_filter_all_result {
3552 cmdline_fixed_string_t rx_vlan;
3553 cmdline_fixed_string_t what;
3554 cmdline_fixed_string_t all;
3559 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3560 __attribute__((unused)) struct cmdline *cl,
3561 __attribute__((unused)) void *data)
3563 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3565 if (!strcmp(res->what, "add"))
3566 rx_vlan_all_filter_set(res->port_id, 1);
3568 rx_vlan_all_filter_set(res->port_id, 0);
3571 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3572 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3573 rx_vlan, "rx_vlan");
3574 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3575 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3577 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3578 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3580 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3581 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3584 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3585 .f = cmd_rx_vlan_filter_all_parsed,
3587 .help_str = "rx_vlan add|rm all <port_id>: "
3588 "Add/Remove all identifiers to/from the set of VLAN "
3589 "identifiers filtered by a port",
3591 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3592 (void *)&cmd_rx_vlan_filter_all_what,
3593 (void *)&cmd_rx_vlan_filter_all_all,
3594 (void *)&cmd_rx_vlan_filter_all_portid,
3599 /* *** VLAN OFFLOAD SET ON A PORT *** */
3600 struct cmd_vlan_offload_result {
3601 cmdline_fixed_string_t vlan;
3602 cmdline_fixed_string_t set;
3603 cmdline_fixed_string_t vlan_type;
3604 cmdline_fixed_string_t what;
3605 cmdline_fixed_string_t on;
3606 cmdline_fixed_string_t port_id;
3610 cmd_vlan_offload_parsed(void *parsed_result,
3611 __attribute__((unused)) struct cmdline *cl,
3612 __attribute__((unused)) void *data)
3615 struct cmd_vlan_offload_result *res = parsed_result;
3618 portid_t port_id = 0;
3622 len = strnlen(str, STR_TOKEN_SIZE);
3624 /* Get port_id first */
3632 tmp = strtoul(str, NULL, 0);
3633 /* If port_id greater that what portid_t can represent, return */
3634 if(tmp >= RTE_MAX_ETHPORTS)
3636 port_id = (portid_t)tmp;
3638 if (!strcmp(res->on, "on"))
3643 if (!strcmp(res->what, "strip"))
3644 rx_vlan_strip_set(port_id, on);
3645 else if(!strcmp(res->what, "stripq")){
3646 uint16_t queue_id = 0;
3648 /* No queue_id, return */
3650 printf("must specify (port,queue_id)\n");
3653 tmp = strtoul(str + i + 1, NULL, 0);
3654 /* If queue_id greater that what 16-bits can represent, return */
3658 queue_id = (uint16_t)tmp;
3659 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3661 else if (!strcmp(res->what, "filter"))
3662 rx_vlan_filter_set(port_id, on);
3664 vlan_extend_set(port_id, on);
3669 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3670 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3672 cmdline_parse_token_string_t cmd_vlan_offload_set =
3673 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3675 cmdline_parse_token_string_t cmd_vlan_offload_what =
3676 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3677 what, "strip#filter#qinq#stripq");
3678 cmdline_parse_token_string_t cmd_vlan_offload_on =
3679 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3681 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3682 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3685 cmdline_parse_inst_t cmd_vlan_offload = {
3686 .f = cmd_vlan_offload_parsed,
3688 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3689 "<port_id[,queue_id]>: "
3690 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3692 (void *)&cmd_vlan_offload_vlan,
3693 (void *)&cmd_vlan_offload_set,
3694 (void *)&cmd_vlan_offload_what,
3695 (void *)&cmd_vlan_offload_on,
3696 (void *)&cmd_vlan_offload_portid,
3701 /* *** VLAN TPID SET ON A PORT *** */
3702 struct cmd_vlan_tpid_result {
3703 cmdline_fixed_string_t vlan;
3704 cmdline_fixed_string_t set;
3705 cmdline_fixed_string_t vlan_type;
3706 cmdline_fixed_string_t what;
3712 cmd_vlan_tpid_parsed(void *parsed_result,
3713 __attribute__((unused)) struct cmdline *cl,
3714 __attribute__((unused)) void *data)
3716 struct cmd_vlan_tpid_result *res = parsed_result;
3717 enum rte_vlan_type vlan_type;
3719 if (!strcmp(res->vlan_type, "inner"))
3720 vlan_type = ETH_VLAN_TYPE_INNER;
3721 else if (!strcmp(res->vlan_type, "outer"))
3722 vlan_type = ETH_VLAN_TYPE_OUTER;
3724 printf("Unknown vlan type\n");
3727 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3730 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3731 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3733 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3734 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3736 cmdline_parse_token_string_t cmd_vlan_type =
3737 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3738 vlan_type, "inner#outer");
3739 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3740 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3742 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3743 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3745 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3746 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3749 cmdline_parse_inst_t cmd_vlan_tpid = {
3750 .f = cmd_vlan_tpid_parsed,
3752 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3753 "Set the VLAN Ether type",
3755 (void *)&cmd_vlan_tpid_vlan,
3756 (void *)&cmd_vlan_tpid_set,
3757 (void *)&cmd_vlan_type,
3758 (void *)&cmd_vlan_tpid_what,
3759 (void *)&cmd_vlan_tpid_tpid,
3760 (void *)&cmd_vlan_tpid_portid,
3765 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3766 struct cmd_rx_vlan_filter_result {
3767 cmdline_fixed_string_t rx_vlan;
3768 cmdline_fixed_string_t what;
3774 cmd_rx_vlan_filter_parsed(void *parsed_result,
3775 __attribute__((unused)) struct cmdline *cl,
3776 __attribute__((unused)) void *data)
3778 struct cmd_rx_vlan_filter_result *res = parsed_result;
3780 if (!strcmp(res->what, "add"))
3781 rx_vft_set(res->port_id, res->vlan_id, 1);
3783 rx_vft_set(res->port_id, res->vlan_id, 0);
3786 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3787 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3788 rx_vlan, "rx_vlan");
3789 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3790 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3792 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3793 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3795 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3796 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3799 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3800 .f = cmd_rx_vlan_filter_parsed,
3802 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3803 "Add/Remove a VLAN identifier to/from the set of VLAN "
3804 "identifiers filtered by a port",
3806 (void *)&cmd_rx_vlan_filter_rx_vlan,
3807 (void *)&cmd_rx_vlan_filter_what,
3808 (void *)&cmd_rx_vlan_filter_vlanid,
3809 (void *)&cmd_rx_vlan_filter_portid,
3814 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3815 struct cmd_tx_vlan_set_result {
3816 cmdline_fixed_string_t tx_vlan;
3817 cmdline_fixed_string_t set;
3823 cmd_tx_vlan_set_parsed(void *parsed_result,
3824 __attribute__((unused)) struct cmdline *cl,
3825 __attribute__((unused)) void *data)
3827 struct cmd_tx_vlan_set_result *res = parsed_result;
3829 if (!port_is_stopped(res->port_id)) {
3830 printf("Please stop port %d first\n", res->port_id);
3834 tx_vlan_set(res->port_id, res->vlan_id);
3836 cmd_reconfig_device_queue(res->port_id, 1, 1);
3839 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3840 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3841 tx_vlan, "tx_vlan");
3842 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3843 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3845 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3846 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3848 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3849 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3852 cmdline_parse_inst_t cmd_tx_vlan_set = {
3853 .f = cmd_tx_vlan_set_parsed,
3855 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3856 "Enable hardware insertion of a single VLAN header "
3857 "with a given TAG Identifier in packets sent on a port",
3859 (void *)&cmd_tx_vlan_set_tx_vlan,
3860 (void *)&cmd_tx_vlan_set_set,
3861 (void *)&cmd_tx_vlan_set_portid,
3862 (void *)&cmd_tx_vlan_set_vlanid,
3867 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3868 struct cmd_tx_vlan_set_qinq_result {
3869 cmdline_fixed_string_t tx_vlan;
3870 cmdline_fixed_string_t set;
3873 uint16_t vlan_id_outer;
3877 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3878 __attribute__((unused)) struct cmdline *cl,
3879 __attribute__((unused)) void *data)
3881 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3883 if (!port_is_stopped(res->port_id)) {
3884 printf("Please stop port %d first\n", res->port_id);
3888 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3890 cmd_reconfig_device_queue(res->port_id, 1, 1);
3893 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3894 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3895 tx_vlan, "tx_vlan");
3896 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3897 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3899 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3900 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3902 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3903 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3905 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3906 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3907 vlan_id_outer, UINT16);
3909 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3910 .f = cmd_tx_vlan_set_qinq_parsed,
3912 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3913 "Enable hardware insertion of double VLAN header "
3914 "with given TAG Identifiers in packets sent on a port",
3916 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3917 (void *)&cmd_tx_vlan_set_qinq_set,
3918 (void *)&cmd_tx_vlan_set_qinq_portid,
3919 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3920 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3925 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3926 struct cmd_tx_vlan_set_pvid_result {
3927 cmdline_fixed_string_t tx_vlan;
3928 cmdline_fixed_string_t set;
3929 cmdline_fixed_string_t pvid;
3932 cmdline_fixed_string_t mode;
3936 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3937 __attribute__((unused)) struct cmdline *cl,
3938 __attribute__((unused)) void *data)
3940 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3942 if (strcmp(res->mode, "on") == 0)
3943 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3945 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3948 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3949 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3950 tx_vlan, "tx_vlan");
3951 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3952 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3954 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3955 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3957 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3958 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3960 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3961 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3963 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3964 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3967 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3968 .f = cmd_tx_vlan_set_pvid_parsed,
3970 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3972 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3973 (void *)&cmd_tx_vlan_set_pvid_set,
3974 (void *)&cmd_tx_vlan_set_pvid_pvid,
3975 (void *)&cmd_tx_vlan_set_pvid_port_id,
3976 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3977 (void *)&cmd_tx_vlan_set_pvid_mode,
3982 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3983 struct cmd_tx_vlan_reset_result {
3984 cmdline_fixed_string_t tx_vlan;
3985 cmdline_fixed_string_t reset;
3990 cmd_tx_vlan_reset_parsed(void *parsed_result,
3991 __attribute__((unused)) struct cmdline *cl,
3992 __attribute__((unused)) void *data)
3994 struct cmd_tx_vlan_reset_result *res = parsed_result;
3996 if (!port_is_stopped(res->port_id)) {
3997 printf("Please stop port %d first\n", res->port_id);
4001 tx_vlan_reset(res->port_id);
4003 cmd_reconfig_device_queue(res->port_id, 1, 1);
4006 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4007 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4008 tx_vlan, "tx_vlan");
4009 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4010 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4012 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4013 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4016 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4017 .f = cmd_tx_vlan_reset_parsed,
4019 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4020 "VLAN header in packets sent on a port",
4022 (void *)&cmd_tx_vlan_reset_tx_vlan,
4023 (void *)&cmd_tx_vlan_reset_reset,
4024 (void *)&cmd_tx_vlan_reset_portid,
4030 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4031 struct cmd_csum_result {
4032 cmdline_fixed_string_t csum;
4033 cmdline_fixed_string_t mode;
4034 cmdline_fixed_string_t proto;
4035 cmdline_fixed_string_t hwsw;
4040 csum_show(int port_id)
4042 struct rte_eth_dev_info dev_info;
4043 uint64_t tx_offloads;
4045 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4046 printf("Parse tunnel is %s\n",
4047 (ports[port_id].parse_tunnel) ? "on" : "off");
4048 printf("IP checksum offload is %s\n",
4049 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4050 printf("UDP checksum offload is %s\n",
4051 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4052 printf("TCP checksum offload is %s\n",
4053 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4054 printf("SCTP checksum offload is %s\n",
4055 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4056 printf("Outer-Ip checksum offload is %s\n",
4057 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4059 /* display warnings if configuration is not supported by the NIC */
4060 rte_eth_dev_info_get(port_id, &dev_info);
4061 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4062 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4063 printf("Warning: hardware IP checksum enabled but not "
4064 "supported by port %d\n", port_id);
4066 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4067 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4068 printf("Warning: hardware UDP checksum enabled but not "
4069 "supported by port %d\n", port_id);
4071 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4072 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4073 printf("Warning: hardware TCP checksum enabled but not "
4074 "supported by port %d\n", port_id);
4076 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4077 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4078 printf("Warning: hardware SCTP checksum enabled but not "
4079 "supported by port %d\n", port_id);
4081 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4082 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4083 printf("Warning: hardware outer IP checksum enabled but not "
4084 "supported by port %d\n", port_id);
4089 cmd_csum_parsed(void *parsed_result,
4090 __attribute__((unused)) struct cmdline *cl,
4091 __attribute__((unused)) void *data)
4093 struct cmd_csum_result *res = parsed_result;
4095 uint64_t csum_offloads = 0;
4096 struct rte_eth_dev_info dev_info;
4098 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4099 printf("invalid port %d\n", res->port_id);
4102 if (!port_is_stopped(res->port_id)) {
4103 printf("Please stop port %d first\n", res->port_id);
4107 rte_eth_dev_info_get(res->port_id, &dev_info);
4108 if (!strcmp(res->mode, "set")) {
4110 if (!strcmp(res->hwsw, "hw"))
4113 if (!strcmp(res->proto, "ip")) {
4114 if (hw == 0 || (dev_info.tx_offload_capa &
4115 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4116 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4118 printf("IP checksum offload is not supported "
4119 "by port %u\n", res->port_id);
4121 } else if (!strcmp(res->proto, "udp")) {
4122 if (hw == 0 || (dev_info.tx_offload_capa &
4123 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4124 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4126 printf("UDP checksum offload is not supported "
4127 "by port %u\n", res->port_id);
4129 } else if (!strcmp(res->proto, "tcp")) {
4130 if (hw == 0 || (dev_info.tx_offload_capa &
4131 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4132 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4134 printf("TCP checksum offload is not supported "
4135 "by port %u\n", res->port_id);
4137 } else if (!strcmp(res->proto, "sctp")) {
4138 if (hw == 0 || (dev_info.tx_offload_capa &
4139 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4140 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4142 printf("SCTP checksum offload is not supported "
4143 "by port %u\n", res->port_id);
4145 } else if (!strcmp(res->proto, "outer-ip")) {
4146 if (hw == 0 || (dev_info.tx_offload_capa &
4147 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4149 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4151 printf("Outer IP checksum offload is not "
4152 "supported by port %u\n", res->port_id);
4157 ports[res->port_id].dev_conf.txmode.offloads |=
4160 ports[res->port_id].dev_conf.txmode.offloads &=
4164 csum_show(res->port_id);
4166 cmd_reconfig_device_queue(res->port_id, 1, 1);
4169 cmdline_parse_token_string_t cmd_csum_csum =
4170 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4172 cmdline_parse_token_string_t cmd_csum_mode =
4173 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4175 cmdline_parse_token_string_t cmd_csum_proto =
4176 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4177 proto, "ip#tcp#udp#sctp#outer-ip");
4178 cmdline_parse_token_string_t cmd_csum_hwsw =
4179 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4181 cmdline_parse_token_num_t cmd_csum_portid =
4182 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4185 cmdline_parse_inst_t cmd_csum_set = {
4186 .f = cmd_csum_parsed,
4188 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4189 "Enable/Disable hardware calculation of L3/L4 checksum when "
4190 "using csum forward engine",
4192 (void *)&cmd_csum_csum,
4193 (void *)&cmd_csum_mode,
4194 (void *)&cmd_csum_proto,
4195 (void *)&cmd_csum_hwsw,
4196 (void *)&cmd_csum_portid,
4201 cmdline_parse_token_string_t cmd_csum_mode_show =
4202 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4205 cmdline_parse_inst_t cmd_csum_show = {
4206 .f = cmd_csum_parsed,
4208 .help_str = "csum show <port_id>: Show checksum offload configuration",
4210 (void *)&cmd_csum_csum,
4211 (void *)&cmd_csum_mode_show,
4212 (void *)&cmd_csum_portid,
4217 /* Enable/disable tunnel parsing */
4218 struct cmd_csum_tunnel_result {
4219 cmdline_fixed_string_t csum;
4220 cmdline_fixed_string_t parse;
4221 cmdline_fixed_string_t onoff;
4226 cmd_csum_tunnel_parsed(void *parsed_result,
4227 __attribute__((unused)) struct cmdline *cl,
4228 __attribute__((unused)) void *data)
4230 struct cmd_csum_tunnel_result *res = parsed_result;
4232 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4235 if (!strcmp(res->onoff, "on"))
4236 ports[res->port_id].parse_tunnel = 1;
4238 ports[res->port_id].parse_tunnel = 0;
4240 csum_show(res->port_id);
4243 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4244 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4246 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4247 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4248 parse, "parse_tunnel");
4249 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4250 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4252 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4253 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4256 cmdline_parse_inst_t cmd_csum_tunnel = {
4257 .f = cmd_csum_tunnel_parsed,
4259 .help_str = "csum parse_tunnel on|off <port_id>: "
4260 "Enable/Disable parsing of tunnels for csum engine",
4262 (void *)&cmd_csum_tunnel_csum,
4263 (void *)&cmd_csum_tunnel_parse,
4264 (void *)&cmd_csum_tunnel_onoff,
4265 (void *)&cmd_csum_tunnel_portid,
4270 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4271 struct cmd_tso_set_result {
4272 cmdline_fixed_string_t tso;
4273 cmdline_fixed_string_t mode;
4279 cmd_tso_set_parsed(void *parsed_result,
4280 __attribute__((unused)) struct cmdline *cl,
4281 __attribute__((unused)) void *data)
4283 struct cmd_tso_set_result *res = parsed_result;
4284 struct rte_eth_dev_info dev_info;
4286 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4288 if (!port_is_stopped(res->port_id)) {
4289 printf("Please stop port %d first\n", res->port_id);
4293 if (!strcmp(res->mode, "set"))
4294 ports[res->port_id].tso_segsz = res->tso_segsz;
4296 rte_eth_dev_info_get(res->port_id, &dev_info);
4297 if ((ports[res->port_id].tso_segsz != 0) &&
4298 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4299 printf("Error: TSO is not supported by port %d\n",
4304 if (ports[res->port_id].tso_segsz == 0) {
4305 ports[res->port_id].dev_conf.txmode.offloads &=
4306 ~DEV_TX_OFFLOAD_TCP_TSO;
4307 printf("TSO for non-tunneled packets is disabled\n");
4309 ports[res->port_id].dev_conf.txmode.offloads |=
4310 DEV_TX_OFFLOAD_TCP_TSO;
4311 printf("TSO segment size for non-tunneled packets is %d\n",
4312 ports[res->port_id].tso_segsz);
4315 /* display warnings if configuration is not supported by the NIC */
4316 rte_eth_dev_info_get(res->port_id, &dev_info);
4317 if ((ports[res->port_id].tso_segsz != 0) &&
4318 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4319 printf("Warning: TSO enabled but not "
4320 "supported by port %d\n", res->port_id);
4323 cmd_reconfig_device_queue(res->port_id, 1, 1);
4326 cmdline_parse_token_string_t cmd_tso_set_tso =
4327 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4329 cmdline_parse_token_string_t cmd_tso_set_mode =
4330 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4332 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4333 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4335 cmdline_parse_token_num_t cmd_tso_set_portid =
4336 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4339 cmdline_parse_inst_t cmd_tso_set = {
4340 .f = cmd_tso_set_parsed,
4342 .help_str = "tso set <tso_segsz> <port_id>: "
4343 "Set TSO segment size of non-tunneled packets for csum engine "
4346 (void *)&cmd_tso_set_tso,
4347 (void *)&cmd_tso_set_mode,
4348 (void *)&cmd_tso_set_tso_segsz,
4349 (void *)&cmd_tso_set_portid,
4354 cmdline_parse_token_string_t cmd_tso_show_mode =
4355 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4359 cmdline_parse_inst_t cmd_tso_show = {
4360 .f = cmd_tso_set_parsed,
4362 .help_str = "tso show <port_id>: "
4363 "Show TSO segment size of non-tunneled packets for csum engine",
4365 (void *)&cmd_tso_set_tso,
4366 (void *)&cmd_tso_show_mode,
4367 (void *)&cmd_tso_set_portid,
4372 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4373 struct cmd_tunnel_tso_set_result {
4374 cmdline_fixed_string_t tso;
4375 cmdline_fixed_string_t mode;
4380 static struct rte_eth_dev_info
4381 check_tunnel_tso_nic_support(portid_t port_id)
4383 struct rte_eth_dev_info dev_info;
4385 rte_eth_dev_info_get(port_id, &dev_info);
4386 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4387 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4388 "not enabled for port %d\n", port_id);
4389 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4390 printf("Warning: GRE TUNNEL TSO not supported therefore "
4391 "not enabled for port %d\n", port_id);
4392 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4393 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4394 "not enabled for port %d\n", port_id);
4395 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4396 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4397 "not enabled for port %d\n", port_id);
4398 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4399 printf("Warning: IP TUNNEL TSO not supported therefore "
4400 "not enabled for port %d\n", port_id);
4401 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4402 printf("Warning: UDP TUNNEL TSO not supported therefore "
4403 "not enabled for port %d\n", port_id);
4408 cmd_tunnel_tso_set_parsed(void *parsed_result,
4409 __attribute__((unused)) struct cmdline *cl,
4410 __attribute__((unused)) void *data)
4412 struct cmd_tunnel_tso_set_result *res = parsed_result;
4413 struct rte_eth_dev_info dev_info;
4415 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4417 if (!port_is_stopped(res->port_id)) {
4418 printf("Please stop port %d first\n", res->port_id);
4422 if (!strcmp(res->mode, "set"))
4423 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4425 dev_info = check_tunnel_tso_nic_support(res->port_id);
4426 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4427 ports[res->port_id].dev_conf.txmode.offloads &=
4428 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4429 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4430 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4431 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4432 DEV_TX_OFFLOAD_IP_TNL_TSO |
4433 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4434 printf("TSO for tunneled packets is disabled\n");
4436 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4437 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4438 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4439 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4440 DEV_TX_OFFLOAD_IP_TNL_TSO |
4441 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4443 ports[res->port_id].dev_conf.txmode.offloads |=
4444 (tso_offloads & dev_info.tx_offload_capa);
4445 printf("TSO segment size for tunneled packets is %d\n",
4446 ports[res->port_id].tunnel_tso_segsz);
4448 /* Below conditions are needed to make it work:
4449 * (1) tunnel TSO is supported by the NIC;
4450 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4452 * (3) for tunneled pkts with outer L3 of IPv4,
4453 * "csum set outer-ip" must be set to hw, because after tso,
4454 * total_len of outer IP header is changed, and the checksum
4455 * of outer IP header calculated by sw should be wrong; that
4456 * is not necessary for IPv6 tunneled pkts because there's no
4457 * checksum in IP header anymore.
4460 if (!ports[res->port_id].parse_tunnel)
4461 printf("Warning: csum parse_tunnel must be set "
4462 "so that tunneled packets are recognized\n");
4463 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4464 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4465 printf("Warning: csum set outer-ip must be set to hw "
4466 "if outer L3 is IPv4; not necessary for IPv6\n");
4469 cmd_reconfig_device_queue(res->port_id, 1, 1);
4472 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4473 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4475 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4476 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4478 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4479 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4481 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4482 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4485 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4486 .f = cmd_tunnel_tso_set_parsed,
4488 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4489 "Set TSO segment size of tunneled packets for csum engine "
4492 (void *)&cmd_tunnel_tso_set_tso,
4493 (void *)&cmd_tunnel_tso_set_mode,
4494 (void *)&cmd_tunnel_tso_set_tso_segsz,
4495 (void *)&cmd_tunnel_tso_set_portid,
4500 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4501 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4505 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4506 .f = cmd_tunnel_tso_set_parsed,
4508 .help_str = "tunnel_tso show <port_id> "
4509 "Show TSO segment size of tunneled packets for csum engine",
4511 (void *)&cmd_tunnel_tso_set_tso,
4512 (void *)&cmd_tunnel_tso_show_mode,
4513 (void *)&cmd_tunnel_tso_set_portid,
4518 /* *** SET GRO FOR A PORT *** */
4519 struct cmd_gro_enable_result {
4520 cmdline_fixed_string_t cmd_set;
4521 cmdline_fixed_string_t cmd_port;
4522 cmdline_fixed_string_t cmd_keyword;
4523 cmdline_fixed_string_t cmd_onoff;
4528 cmd_gro_enable_parsed(void *parsed_result,
4529 __attribute__((unused)) struct cmdline *cl,
4530 __attribute__((unused)) void *data)
4532 struct cmd_gro_enable_result *res;
4534 res = parsed_result;
4535 if (!strcmp(res->cmd_keyword, "gro"))
4536 setup_gro(res->cmd_onoff, res->cmd_pid);
4539 cmdline_parse_token_string_t cmd_gro_enable_set =
4540 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4542 cmdline_parse_token_string_t cmd_gro_enable_port =
4543 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4544 cmd_keyword, "port");
4545 cmdline_parse_token_num_t cmd_gro_enable_pid =
4546 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4548 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4549 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4550 cmd_keyword, "gro");
4551 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4552 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4553 cmd_onoff, "on#off");
4555 cmdline_parse_inst_t cmd_gro_enable = {
4556 .f = cmd_gro_enable_parsed,
4558 .help_str = "set port <port_id> gro on|off",
4560 (void *)&cmd_gro_enable_set,
4561 (void *)&cmd_gro_enable_port,
4562 (void *)&cmd_gro_enable_pid,
4563 (void *)&cmd_gro_enable_keyword,
4564 (void *)&cmd_gro_enable_onoff,
4569 /* *** DISPLAY GRO CONFIGURATION *** */
4570 struct cmd_gro_show_result {
4571 cmdline_fixed_string_t cmd_show;
4572 cmdline_fixed_string_t cmd_port;
4573 cmdline_fixed_string_t cmd_keyword;
4578 cmd_gro_show_parsed(void *parsed_result,
4579 __attribute__((unused)) struct cmdline *cl,
4580 __attribute__((unused)) void *data)
4582 struct cmd_gro_show_result *res;
4584 res = parsed_result;
4585 if (!strcmp(res->cmd_keyword, "gro"))
4586 show_gro(res->cmd_pid);
4589 cmdline_parse_token_string_t cmd_gro_show_show =
4590 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4592 cmdline_parse_token_string_t cmd_gro_show_port =
4593 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4595 cmdline_parse_token_num_t cmd_gro_show_pid =
4596 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4598 cmdline_parse_token_string_t cmd_gro_show_keyword =
4599 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4600 cmd_keyword, "gro");
4602 cmdline_parse_inst_t cmd_gro_show = {
4603 .f = cmd_gro_show_parsed,
4605 .help_str = "show port <port_id> gro",
4607 (void *)&cmd_gro_show_show,
4608 (void *)&cmd_gro_show_port,
4609 (void *)&cmd_gro_show_pid,
4610 (void *)&cmd_gro_show_keyword,
4615 /* *** SET FLUSH CYCLES FOR GRO *** */
4616 struct cmd_gro_flush_result {
4617 cmdline_fixed_string_t cmd_set;
4618 cmdline_fixed_string_t cmd_keyword;
4619 cmdline_fixed_string_t cmd_flush;
4624 cmd_gro_flush_parsed(void *parsed_result,
4625 __attribute__((unused)) struct cmdline *cl,
4626 __attribute__((unused)) void *data)
4628 struct cmd_gro_flush_result *res;
4630 res = parsed_result;
4631 if ((!strcmp(res->cmd_keyword, "gro")) &&
4632 (!strcmp(res->cmd_flush, "flush")))
4633 setup_gro_flush_cycles(res->cmd_cycles);
4636 cmdline_parse_token_string_t cmd_gro_flush_set =
4637 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4639 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4640 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4641 cmd_keyword, "gro");
4642 cmdline_parse_token_string_t cmd_gro_flush_flush =
4643 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4644 cmd_flush, "flush");
4645 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4646 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4649 cmdline_parse_inst_t cmd_gro_flush = {
4650 .f = cmd_gro_flush_parsed,
4652 .help_str = "set gro flush <cycles>",
4654 (void *)&cmd_gro_flush_set,
4655 (void *)&cmd_gro_flush_keyword,
4656 (void *)&cmd_gro_flush_flush,
4657 (void *)&cmd_gro_flush_cycles,
4662 /* *** ENABLE/DISABLE GSO *** */
4663 struct cmd_gso_enable_result {
4664 cmdline_fixed_string_t cmd_set;
4665 cmdline_fixed_string_t cmd_port;
4666 cmdline_fixed_string_t cmd_keyword;
4667 cmdline_fixed_string_t cmd_mode;
4672 cmd_gso_enable_parsed(void *parsed_result,
4673 __attribute__((unused)) struct cmdline *cl,
4674 __attribute__((unused)) void *data)
4676 struct cmd_gso_enable_result *res;
4678 res = parsed_result;
4679 if (!strcmp(res->cmd_keyword, "gso"))
4680 setup_gso(res->cmd_mode, res->cmd_pid);
4683 cmdline_parse_token_string_t cmd_gso_enable_set =
4684 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4686 cmdline_parse_token_string_t cmd_gso_enable_port =
4687 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4689 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4690 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4691 cmd_keyword, "gso");
4692 cmdline_parse_token_string_t cmd_gso_enable_mode =
4693 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4694 cmd_mode, "on#off");
4695 cmdline_parse_token_num_t cmd_gso_enable_pid =
4696 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4699 cmdline_parse_inst_t cmd_gso_enable = {
4700 .f = cmd_gso_enable_parsed,
4702 .help_str = "set port <port_id> gso on|off",
4704 (void *)&cmd_gso_enable_set,
4705 (void *)&cmd_gso_enable_port,
4706 (void *)&cmd_gso_enable_pid,
4707 (void *)&cmd_gso_enable_keyword,
4708 (void *)&cmd_gso_enable_mode,
4713 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4714 struct cmd_gso_size_result {
4715 cmdline_fixed_string_t cmd_set;
4716 cmdline_fixed_string_t cmd_keyword;
4717 cmdline_fixed_string_t cmd_segsz;
4722 cmd_gso_size_parsed(void *parsed_result,
4723 __attribute__((unused)) struct cmdline *cl,
4724 __attribute__((unused)) void *data)
4726 struct cmd_gso_size_result *res = parsed_result;
4728 if (test_done == 0) {
4729 printf("Before setting GSO segsz, please first"
4730 " stop fowarding\n");
4734 if (!strcmp(res->cmd_keyword, "gso") &&
4735 !strcmp(res->cmd_segsz, "segsz")) {
4736 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4737 printf("gso_size should be larger than %zu."
4738 " Please input a legal value\n",
4739 RTE_GSO_SEG_SIZE_MIN);
4741 gso_max_segment_size = res->cmd_size;
4745 cmdline_parse_token_string_t cmd_gso_size_set =
4746 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4748 cmdline_parse_token_string_t cmd_gso_size_keyword =
4749 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4750 cmd_keyword, "gso");
4751 cmdline_parse_token_string_t cmd_gso_size_segsz =
4752 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4753 cmd_segsz, "segsz");
4754 cmdline_parse_token_num_t cmd_gso_size_size =
4755 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4758 cmdline_parse_inst_t cmd_gso_size = {
4759 .f = cmd_gso_size_parsed,
4761 .help_str = "set gso segsz <length>",
4763 (void *)&cmd_gso_size_set,
4764 (void *)&cmd_gso_size_keyword,
4765 (void *)&cmd_gso_size_segsz,
4766 (void *)&cmd_gso_size_size,
4771 /* *** SHOW GSO CONFIGURATION *** */
4772 struct cmd_gso_show_result {
4773 cmdline_fixed_string_t cmd_show;
4774 cmdline_fixed_string_t cmd_port;
4775 cmdline_fixed_string_t cmd_keyword;
4780 cmd_gso_show_parsed(void *parsed_result,
4781 __attribute__((unused)) struct cmdline *cl,
4782 __attribute__((unused)) void *data)
4784 struct cmd_gso_show_result *res = parsed_result;
4786 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4787 printf("invalid port id %u\n", res->cmd_pid);
4790 if (!strcmp(res->cmd_keyword, "gso")) {
4791 if (gso_ports[res->cmd_pid].enable) {
4792 printf("Max GSO'd packet size: %uB\n"
4793 "Supported GSO types: TCP/IPv4, "
4794 "VxLAN with inner TCP/IPv4 packet, "
4795 "GRE with inner TCP/IPv4 packet\n",
4796 gso_max_segment_size);
4798 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4802 cmdline_parse_token_string_t cmd_gso_show_show =
4803 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4805 cmdline_parse_token_string_t cmd_gso_show_port =
4806 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4808 cmdline_parse_token_string_t cmd_gso_show_keyword =
4809 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4810 cmd_keyword, "gso");
4811 cmdline_parse_token_num_t cmd_gso_show_pid =
4812 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4815 cmdline_parse_inst_t cmd_gso_show = {
4816 .f = cmd_gso_show_parsed,
4818 .help_str = "show port <port_id> gso",
4820 (void *)&cmd_gso_show_show,
4821 (void *)&cmd_gso_show_port,
4822 (void *)&cmd_gso_show_pid,
4823 (void *)&cmd_gso_show_keyword,
4828 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4829 struct cmd_set_flush_rx {
4830 cmdline_fixed_string_t set;
4831 cmdline_fixed_string_t flush_rx;
4832 cmdline_fixed_string_t mode;
4836 cmd_set_flush_rx_parsed(void *parsed_result,
4837 __attribute__((unused)) struct cmdline *cl,
4838 __attribute__((unused)) void *data)
4840 struct cmd_set_flush_rx *res = parsed_result;
4841 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4844 cmdline_parse_token_string_t cmd_setflushrx_set =
4845 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4847 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4848 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4849 flush_rx, "flush_rx");
4850 cmdline_parse_token_string_t cmd_setflushrx_mode =
4851 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4855 cmdline_parse_inst_t cmd_set_flush_rx = {
4856 .f = cmd_set_flush_rx_parsed,
4857 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4860 (void *)&cmd_setflushrx_set,
4861 (void *)&cmd_setflushrx_flush_rx,
4862 (void *)&cmd_setflushrx_mode,
4867 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4868 struct cmd_set_link_check {
4869 cmdline_fixed_string_t set;
4870 cmdline_fixed_string_t link_check;
4871 cmdline_fixed_string_t mode;
4875 cmd_set_link_check_parsed(void *parsed_result,
4876 __attribute__((unused)) struct cmdline *cl,
4877 __attribute__((unused)) void *data)
4879 struct cmd_set_link_check *res = parsed_result;
4880 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4883 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4884 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4886 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4887 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4888 link_check, "link_check");
4889 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4890 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4894 cmdline_parse_inst_t cmd_set_link_check = {
4895 .f = cmd_set_link_check_parsed,
4896 .help_str = "set link_check on|off: Enable/Disable link status check "
4897 "when starting/stopping a port",
4900 (void *)&cmd_setlinkcheck_set,
4901 (void *)&cmd_setlinkcheck_link_check,
4902 (void *)&cmd_setlinkcheck_mode,
4907 /* *** SET NIC BYPASS MODE *** */
4908 struct cmd_set_bypass_mode_result {
4909 cmdline_fixed_string_t set;
4910 cmdline_fixed_string_t bypass;
4911 cmdline_fixed_string_t mode;
4912 cmdline_fixed_string_t value;
4917 cmd_set_bypass_mode_parsed(void *parsed_result,
4918 __attribute__((unused)) struct cmdline *cl,
4919 __attribute__((unused)) void *data)
4921 struct cmd_set_bypass_mode_result *res = parsed_result;
4922 portid_t port_id = res->port_id;
4923 int32_t rc = -EINVAL;
4925 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4926 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4928 if (!strcmp(res->value, "bypass"))
4929 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4930 else if (!strcmp(res->value, "isolate"))
4931 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4933 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4935 /* Set the bypass mode for the relevant port. */
4936 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4939 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4942 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4943 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4945 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4946 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4948 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4949 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4951 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4952 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4953 value, "normal#bypass#isolate");
4954 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4955 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4958 cmdline_parse_inst_t cmd_set_bypass_mode = {
4959 .f = cmd_set_bypass_mode_parsed,
4960 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4961 "Set the NIC bypass mode for port_id",
4964 (void *)&cmd_setbypass_mode_set,
4965 (void *)&cmd_setbypass_mode_bypass,
4966 (void *)&cmd_setbypass_mode_mode,
4967 (void *)&cmd_setbypass_mode_value,
4968 (void *)&cmd_setbypass_mode_port,
4973 /* *** SET NIC BYPASS EVENT *** */
4974 struct cmd_set_bypass_event_result {
4975 cmdline_fixed_string_t set;
4976 cmdline_fixed_string_t bypass;
4977 cmdline_fixed_string_t event;
4978 cmdline_fixed_string_t event_value;
4979 cmdline_fixed_string_t mode;
4980 cmdline_fixed_string_t mode_value;
4985 cmd_set_bypass_event_parsed(void *parsed_result,
4986 __attribute__((unused)) struct cmdline *cl,
4987 __attribute__((unused)) void *data)
4989 int32_t rc = -EINVAL;
4990 struct cmd_set_bypass_event_result *res = parsed_result;
4991 portid_t port_id = res->port_id;
4993 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4994 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4995 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4997 if (!strcmp(res->event_value, "timeout"))
4998 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4999 else if (!strcmp(res->event_value, "os_on"))
5000 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5001 else if (!strcmp(res->event_value, "os_off"))
5002 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5003 else if (!strcmp(res->event_value, "power_on"))
5004 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5005 else if (!strcmp(res->event_value, "power_off"))
5006 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5008 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5010 if (!strcmp(res->mode_value, "bypass"))
5011 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5012 else if (!strcmp(res->mode_value, "isolate"))
5013 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5015 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5017 /* Set the watchdog timeout. */
5018 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5021 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5022 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5026 printf("Failed to set timeout value %u "
5027 "for port %d, errto code: %d.\n",
5028 bypass_timeout, port_id, rc);
5032 /* Set the bypass event to transition to bypass mode. */
5033 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5038 printf("\t Failed to set bypass event for port = %d.\n",
5042 cmdline_parse_token_string_t cmd_setbypass_event_set =
5043 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5045 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5046 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5048 cmdline_parse_token_string_t cmd_setbypass_event_event =
5049 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5051 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5052 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5053 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5054 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5055 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5057 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5058 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5059 mode_value, "normal#bypass#isolate");
5060 cmdline_parse_token_num_t cmd_setbypass_event_port =
5061 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5064 cmdline_parse_inst_t cmd_set_bypass_event = {
5065 .f = cmd_set_bypass_event_parsed,
5066 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5067 "power_off mode normal|bypass|isolate <port_id>: "
5068 "Set the NIC bypass event mode for port_id",
5071 (void *)&cmd_setbypass_event_set,
5072 (void *)&cmd_setbypass_event_bypass,
5073 (void *)&cmd_setbypass_event_event,
5074 (void *)&cmd_setbypass_event_event_value,
5075 (void *)&cmd_setbypass_event_mode,
5076 (void *)&cmd_setbypass_event_mode_value,
5077 (void *)&cmd_setbypass_event_port,
5083 /* *** SET NIC BYPASS TIMEOUT *** */
5084 struct cmd_set_bypass_timeout_result {
5085 cmdline_fixed_string_t set;
5086 cmdline_fixed_string_t bypass;
5087 cmdline_fixed_string_t timeout;
5088 cmdline_fixed_string_t value;
5092 cmd_set_bypass_timeout_parsed(void *parsed_result,
5093 __attribute__((unused)) struct cmdline *cl,
5094 __attribute__((unused)) void *data)
5096 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5098 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5099 if (!strcmp(res->value, "1.5"))
5100 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5101 else if (!strcmp(res->value, "2"))
5102 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5103 else if (!strcmp(res->value, "3"))
5104 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5105 else if (!strcmp(res->value, "4"))
5106 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5107 else if (!strcmp(res->value, "8"))
5108 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5109 else if (!strcmp(res->value, "16"))
5110 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5111 else if (!strcmp(res->value, "32"))
5112 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5114 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5118 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5119 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5121 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5124 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5125 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5126 timeout, "timeout");
5127 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5128 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5129 value, "0#1.5#2#3#4#8#16#32");
5131 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5132 .f = cmd_set_bypass_timeout_parsed,
5133 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5134 "Set the NIC bypass watchdog timeout in seconds",
5137 (void *)&cmd_setbypass_timeout_set,
5138 (void *)&cmd_setbypass_timeout_bypass,
5139 (void *)&cmd_setbypass_timeout_timeout,
5140 (void *)&cmd_setbypass_timeout_value,
5145 /* *** SHOW NIC BYPASS MODE *** */
5146 struct cmd_show_bypass_config_result {
5147 cmdline_fixed_string_t show;
5148 cmdline_fixed_string_t bypass;
5149 cmdline_fixed_string_t config;
5154 cmd_show_bypass_config_parsed(void *parsed_result,
5155 __attribute__((unused)) struct cmdline *cl,
5156 __attribute__((unused)) void *data)
5158 struct cmd_show_bypass_config_result *res = parsed_result;
5159 portid_t port_id = res->port_id;
5161 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5162 uint32_t event_mode;
5163 uint32_t bypass_mode;
5164 uint32_t timeout = bypass_timeout;
5167 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5168 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5169 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5170 {"UNKNOWN", "normal", "bypass", "isolate"};
5171 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5178 int num_events = (sizeof events) / (sizeof events[0]);
5180 /* Display the bypass mode.*/
5181 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5182 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5186 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5187 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5189 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5192 /* Display the bypass timeout.*/
5193 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5194 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5196 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5198 /* Display the bypass events and associated modes. */
5199 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5201 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5202 printf("\tFailed to get bypass mode for event = %s\n",
5205 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5206 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5208 printf("\tbypass event: %-16s = %s\n", events[i],
5214 printf("\tFailed to get bypass configuration for port = %d\n",
5218 cmdline_parse_token_string_t cmd_showbypass_config_show =
5219 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5221 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5222 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5224 cmdline_parse_token_string_t cmd_showbypass_config_config =
5225 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5227 cmdline_parse_token_num_t cmd_showbypass_config_port =
5228 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5231 cmdline_parse_inst_t cmd_show_bypass_config = {
5232 .f = cmd_show_bypass_config_parsed,
5233 .help_str = "show bypass config <port_id>: "
5234 "Show the NIC bypass config for port_id",
5237 (void *)&cmd_showbypass_config_show,
5238 (void *)&cmd_showbypass_config_bypass,
5239 (void *)&cmd_showbypass_config_config,
5240 (void *)&cmd_showbypass_config_port,
5245 #ifdef RTE_LIBRTE_PMD_BOND
5246 /* *** SET BONDING MODE *** */
5247 struct cmd_set_bonding_mode_result {
5248 cmdline_fixed_string_t set;
5249 cmdline_fixed_string_t bonding;
5250 cmdline_fixed_string_t mode;
5255 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5256 __attribute__((unused)) struct cmdline *cl,
5257 __attribute__((unused)) void *data)
5259 struct cmd_set_bonding_mode_result *res = parsed_result;
5260 portid_t port_id = res->port_id;
5262 /* Set the bonding mode for the relevant port. */
5263 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5264 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5267 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5268 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5270 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5271 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5272 bonding, "bonding");
5273 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5274 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5276 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5277 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5279 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5280 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5283 cmdline_parse_inst_t cmd_set_bonding_mode = {
5284 .f = cmd_set_bonding_mode_parsed,
5285 .help_str = "set bonding mode <mode_value> <port_id>: "
5286 "Set the bonding mode for port_id",
5289 (void *) &cmd_setbonding_mode_set,
5290 (void *) &cmd_setbonding_mode_bonding,
5291 (void *) &cmd_setbonding_mode_mode,
5292 (void *) &cmd_setbonding_mode_value,
5293 (void *) &cmd_setbonding_mode_port,
5298 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5299 struct cmd_set_bonding_lacp_dedicated_queues_result {
5300 cmdline_fixed_string_t set;
5301 cmdline_fixed_string_t bonding;
5302 cmdline_fixed_string_t lacp;
5303 cmdline_fixed_string_t dedicated_queues;
5305 cmdline_fixed_string_t mode;
5308 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5309 __attribute__((unused)) struct cmdline *cl,
5310 __attribute__((unused)) void *data)
5312 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5313 portid_t port_id = res->port_id;
5314 struct rte_port *port;
5316 port = &ports[port_id];
5318 /** Check if the port is not started **/
5319 if (port->port_status != RTE_PORT_STOPPED) {
5320 printf("Please stop port %d first\n", port_id);
5324 if (!strcmp(res->mode, "enable")) {
5325 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5326 printf("Dedicate queues for LACP control packets"
5329 printf("Enabling dedicate queues for LACP control "
5330 "packets on port %d failed\n", port_id);
5331 } else if (!strcmp(res->mode, "disable")) {
5332 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5333 printf("Dedicated queues for LACP control packets "
5336 printf("Disabling dedicated queues for LACP control "
5337 "traffic on port %d failed\n", port_id);
5341 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5342 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5344 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5345 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5346 bonding, "bonding");
5347 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5348 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5350 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5351 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5352 dedicated_queues, "dedicated_queues");
5353 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5354 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5356 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5357 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5358 mode, "enable#disable");
5360 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5361 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5362 .help_str = "set bonding lacp dedicated_queues <port_id> "
5364 "Enable/disable dedicated queues for LACP control traffic for port_id",
5367 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5368 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5369 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5370 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5371 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5372 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5377 /* *** SET BALANCE XMIT POLICY *** */
5378 struct cmd_set_bonding_balance_xmit_policy_result {
5379 cmdline_fixed_string_t set;
5380 cmdline_fixed_string_t bonding;
5381 cmdline_fixed_string_t balance_xmit_policy;
5383 cmdline_fixed_string_t policy;
5386 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5387 __attribute__((unused)) struct cmdline *cl,
5388 __attribute__((unused)) void *data)
5390 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5391 portid_t port_id = res->port_id;
5394 if (!strcmp(res->policy, "l2")) {
5395 policy = BALANCE_XMIT_POLICY_LAYER2;
5396 } else if (!strcmp(res->policy, "l23")) {
5397 policy = BALANCE_XMIT_POLICY_LAYER23;
5398 } else if (!strcmp(res->policy, "l34")) {
5399 policy = BALANCE_XMIT_POLICY_LAYER34;
5401 printf("\t Invalid xmit policy selection");
5405 /* Set the bonding mode for the relevant port. */
5406 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5407 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5412 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5413 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5415 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5416 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5417 bonding, "bonding");
5418 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5419 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5420 balance_xmit_policy, "balance_xmit_policy");
5421 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5422 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5424 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5425 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5426 policy, "l2#l23#l34");
5428 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5429 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5430 .help_str = "set bonding balance_xmit_policy <port_id> "
5432 "Set the bonding balance_xmit_policy for port_id",
5435 (void *)&cmd_setbonding_balance_xmit_policy_set,
5436 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5437 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5438 (void *)&cmd_setbonding_balance_xmit_policy_port,
5439 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5444 /* *** SHOW NIC BONDING CONFIGURATION *** */
5445 struct cmd_show_bonding_config_result {
5446 cmdline_fixed_string_t show;
5447 cmdline_fixed_string_t bonding;
5448 cmdline_fixed_string_t config;
5452 static void cmd_show_bonding_config_parsed(void *parsed_result,
5453 __attribute__((unused)) struct cmdline *cl,
5454 __attribute__((unused)) void *data)
5456 struct cmd_show_bonding_config_result *res = parsed_result;
5457 int bonding_mode, agg_mode;
5458 portid_t slaves[RTE_MAX_ETHPORTS];
5459 int num_slaves, num_active_slaves;
5462 portid_t port_id = res->port_id;
5464 /* Display the bonding mode.*/
5465 bonding_mode = rte_eth_bond_mode_get(port_id);
5466 if (bonding_mode < 0) {
5467 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5470 printf("\tBonding mode: %d\n", bonding_mode);
5472 if (bonding_mode == BONDING_MODE_BALANCE) {
5473 int balance_xmit_policy;
5475 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5476 if (balance_xmit_policy < 0) {
5477 printf("\tFailed to get balance xmit policy for port = %d\n",
5481 printf("\tBalance Xmit Policy: ");
5483 switch (balance_xmit_policy) {
5484 case BALANCE_XMIT_POLICY_LAYER2:
5485 printf("BALANCE_XMIT_POLICY_LAYER2");
5487 case BALANCE_XMIT_POLICY_LAYER23:
5488 printf("BALANCE_XMIT_POLICY_LAYER23");
5490 case BALANCE_XMIT_POLICY_LAYER34:
5491 printf("BALANCE_XMIT_POLICY_LAYER34");
5498 if (bonding_mode == BONDING_MODE_8023AD) {
5499 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5500 printf("\tIEEE802.3AD Aggregator Mode: ");
5503 printf("bandwidth");
5515 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5517 if (num_slaves < 0) {
5518 printf("\tFailed to get slave list for port = %d\n", port_id);
5521 if (num_slaves > 0) {
5522 printf("\tSlaves (%d): [", num_slaves);
5523 for (i = 0; i < num_slaves - 1; i++)
5524 printf("%d ", slaves[i]);
5526 printf("%d]\n", slaves[num_slaves - 1]);
5528 printf("\tSlaves: []\n");
5532 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5535 if (num_active_slaves < 0) {
5536 printf("\tFailed to get active slave list for port = %d\n", port_id);
5539 if (num_active_slaves > 0) {
5540 printf("\tActive Slaves (%d): [", num_active_slaves);
5541 for (i = 0; i < num_active_slaves - 1; i++)
5542 printf("%d ", slaves[i]);
5544 printf("%d]\n", slaves[num_active_slaves - 1]);
5547 printf("\tActive Slaves: []\n");
5551 primary_id = rte_eth_bond_primary_get(port_id);
5552 if (primary_id < 0) {
5553 printf("\tFailed to get primary slave for port = %d\n", port_id);
5556 printf("\tPrimary: [%d]\n", primary_id);
5560 cmdline_parse_token_string_t cmd_showbonding_config_show =
5561 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5563 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5564 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5565 bonding, "bonding");
5566 cmdline_parse_token_string_t cmd_showbonding_config_config =
5567 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5569 cmdline_parse_token_num_t cmd_showbonding_config_port =
5570 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5573 cmdline_parse_inst_t cmd_show_bonding_config = {
5574 .f = cmd_show_bonding_config_parsed,
5575 .help_str = "show bonding config <port_id>: "
5576 "Show the bonding config for port_id",
5579 (void *)&cmd_showbonding_config_show,
5580 (void *)&cmd_showbonding_config_bonding,
5581 (void *)&cmd_showbonding_config_config,
5582 (void *)&cmd_showbonding_config_port,
5587 /* *** SET BONDING PRIMARY *** */
5588 struct cmd_set_bonding_primary_result {
5589 cmdline_fixed_string_t set;
5590 cmdline_fixed_string_t bonding;
5591 cmdline_fixed_string_t primary;
5596 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5597 __attribute__((unused)) struct cmdline *cl,
5598 __attribute__((unused)) void *data)
5600 struct cmd_set_bonding_primary_result *res = parsed_result;
5601 portid_t master_port_id = res->port_id;
5602 portid_t slave_port_id = res->slave_id;
5604 /* Set the primary slave for a bonded device. */
5605 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5606 printf("\t Failed to set primary slave for port = %d.\n",
5613 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5616 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5617 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5618 bonding, "bonding");
5619 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5620 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5621 primary, "primary");
5622 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5623 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5625 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5626 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5629 cmdline_parse_inst_t cmd_set_bonding_primary = {
5630 .f = cmd_set_bonding_primary_parsed,
5631 .help_str = "set bonding primary <slave_id> <port_id>: "
5632 "Set the primary slave for port_id",
5635 (void *)&cmd_setbonding_primary_set,
5636 (void *)&cmd_setbonding_primary_bonding,
5637 (void *)&cmd_setbonding_primary_primary,
5638 (void *)&cmd_setbonding_primary_slave,
5639 (void *)&cmd_setbonding_primary_port,
5644 /* *** ADD SLAVE *** */
5645 struct cmd_add_bonding_slave_result {
5646 cmdline_fixed_string_t add;
5647 cmdline_fixed_string_t bonding;
5648 cmdline_fixed_string_t slave;
5653 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5654 __attribute__((unused)) struct cmdline *cl,
5655 __attribute__((unused)) void *data)
5657 struct cmd_add_bonding_slave_result *res = parsed_result;
5658 portid_t master_port_id = res->port_id;
5659 portid_t slave_port_id = res->slave_id;
5661 /* add the slave for a bonded device. */
5662 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5663 printf("\t Failed to add slave %d to master port = %d.\n",
5664 slave_port_id, master_port_id);
5668 set_port_slave_flag(slave_port_id);
5671 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5672 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5674 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5675 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5676 bonding, "bonding");
5677 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5678 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5680 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5681 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5683 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5684 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5687 cmdline_parse_inst_t cmd_add_bonding_slave = {
5688 .f = cmd_add_bonding_slave_parsed,
5689 .help_str = "add bonding slave <slave_id> <port_id>: "
5690 "Add a slave device to a bonded device",
5693 (void *)&cmd_addbonding_slave_add,
5694 (void *)&cmd_addbonding_slave_bonding,
5695 (void *)&cmd_addbonding_slave_slave,
5696 (void *)&cmd_addbonding_slave_slaveid,
5697 (void *)&cmd_addbonding_slave_port,
5702 /* *** REMOVE SLAVE *** */
5703 struct cmd_remove_bonding_slave_result {
5704 cmdline_fixed_string_t remove;
5705 cmdline_fixed_string_t bonding;
5706 cmdline_fixed_string_t slave;
5711 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5712 __attribute__((unused)) struct cmdline *cl,
5713 __attribute__((unused)) void *data)
5715 struct cmd_remove_bonding_slave_result *res = parsed_result;
5716 portid_t master_port_id = res->port_id;
5717 portid_t slave_port_id = res->slave_id;
5719 /* remove the slave from a bonded device. */
5720 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5721 printf("\t Failed to remove slave %d from master port = %d.\n",
5722 slave_port_id, master_port_id);
5726 clear_port_slave_flag(slave_port_id);
5729 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5730 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5732 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5733 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5734 bonding, "bonding");
5735 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5736 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5738 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5739 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5741 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5742 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5745 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5746 .f = cmd_remove_bonding_slave_parsed,
5747 .help_str = "remove bonding slave <slave_id> <port_id>: "
5748 "Remove a slave device from a bonded device",
5751 (void *)&cmd_removebonding_slave_remove,
5752 (void *)&cmd_removebonding_slave_bonding,
5753 (void *)&cmd_removebonding_slave_slave,
5754 (void *)&cmd_removebonding_slave_slaveid,
5755 (void *)&cmd_removebonding_slave_port,
5760 /* *** CREATE BONDED DEVICE *** */
5761 struct cmd_create_bonded_device_result {
5762 cmdline_fixed_string_t create;
5763 cmdline_fixed_string_t bonded;
5764 cmdline_fixed_string_t device;
5769 static int bond_dev_num = 0;
5771 static void cmd_create_bonded_device_parsed(void *parsed_result,
5772 __attribute__((unused)) struct cmdline *cl,
5773 __attribute__((unused)) void *data)
5775 struct cmd_create_bonded_device_result *res = parsed_result;
5776 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5779 if (test_done == 0) {
5780 printf("Please stop forwarding first\n");
5784 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5787 /* Create a new bonded device. */
5788 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5790 printf("\t Failed to create bonded device.\n");
5793 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5796 /* Update number of ports */
5797 nb_ports = rte_eth_dev_count_avail();
5798 reconfig(port_id, res->socket);
5799 rte_eth_promiscuous_enable(port_id);
5804 cmdline_parse_token_string_t cmd_createbonded_device_create =
5805 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5807 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5808 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5810 cmdline_parse_token_string_t cmd_createbonded_device_device =
5811 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5813 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5814 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5816 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5817 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5820 cmdline_parse_inst_t cmd_create_bonded_device = {
5821 .f = cmd_create_bonded_device_parsed,
5822 .help_str = "create bonded device <mode> <socket>: "
5823 "Create a new bonded device with specific bonding mode and socket",
5826 (void *)&cmd_createbonded_device_create,
5827 (void *)&cmd_createbonded_device_bonded,
5828 (void *)&cmd_createbonded_device_device,
5829 (void *)&cmd_createbonded_device_mode,
5830 (void *)&cmd_createbonded_device_socket,
5835 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5836 struct cmd_set_bond_mac_addr_result {
5837 cmdline_fixed_string_t set;
5838 cmdline_fixed_string_t bonding;
5839 cmdline_fixed_string_t mac_addr;
5841 struct ether_addr address;
5844 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5845 __attribute__((unused)) struct cmdline *cl,
5846 __attribute__((unused)) void *data)
5848 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5851 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5854 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5856 /* check the return value and print it if is < 0 */
5858 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5861 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5862 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5863 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5864 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5866 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5867 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5869 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5870 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5872 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5873 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5875 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5876 .f = cmd_set_bond_mac_addr_parsed,
5878 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5880 (void *)&cmd_set_bond_mac_addr_set,
5881 (void *)&cmd_set_bond_mac_addr_bonding,
5882 (void *)&cmd_set_bond_mac_addr_mac,
5883 (void *)&cmd_set_bond_mac_addr_portnum,
5884 (void *)&cmd_set_bond_mac_addr_addr,
5890 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5891 struct cmd_set_bond_mon_period_result {
5892 cmdline_fixed_string_t set;
5893 cmdline_fixed_string_t bonding;
5894 cmdline_fixed_string_t mon_period;
5899 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5900 __attribute__((unused)) struct cmdline *cl,
5901 __attribute__((unused)) void *data)
5903 struct cmd_set_bond_mon_period_result *res = parsed_result;
5906 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5908 /* check the return value and print it if is < 0 */
5910 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5913 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5916 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5917 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5918 bonding, "bonding");
5919 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5920 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5921 mon_period, "mon_period");
5922 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5923 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5925 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5926 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5929 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5930 .f = cmd_set_bond_mon_period_parsed,
5932 .help_str = "set bonding mon_period <port_id> <period_ms>",
5934 (void *)&cmd_set_bond_mon_period_set,
5935 (void *)&cmd_set_bond_mon_period_bonding,
5936 (void *)&cmd_set_bond_mon_period_mon_period,
5937 (void *)&cmd_set_bond_mon_period_portnum,
5938 (void *)&cmd_set_bond_mon_period_period_ms,
5945 struct cmd_set_bonding_agg_mode_policy_result {
5946 cmdline_fixed_string_t set;
5947 cmdline_fixed_string_t bonding;
5948 cmdline_fixed_string_t agg_mode;
5950 cmdline_fixed_string_t policy;
5955 cmd_set_bonding_agg_mode(void *parsed_result,
5956 __attribute__((unused)) struct cmdline *cl,
5957 __attribute__((unused)) void *data)
5959 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5960 uint8_t policy = AGG_BANDWIDTH;
5962 if (!strcmp(res->policy, "bandwidth"))
5963 policy = AGG_BANDWIDTH;
5964 else if (!strcmp(res->policy, "stable"))
5965 policy = AGG_STABLE;
5966 else if (!strcmp(res->policy, "count"))
5969 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5973 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5974 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5976 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5977 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5978 bonding, "bonding");
5980 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5981 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5982 agg_mode, "agg_mode");
5984 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5985 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5988 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5989 TOKEN_STRING_INITIALIZER(
5990 struct cmd_set_bonding_balance_xmit_policy_result,
5991 policy, "stable#bandwidth#count");
5993 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5994 .f = cmd_set_bonding_agg_mode,
5996 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5998 (void *)&cmd_set_bonding_agg_mode_set,
5999 (void *)&cmd_set_bonding_agg_mode_bonding,
6000 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6001 (void *)&cmd_set_bonding_agg_mode_portnum,
6002 (void *)&cmd_set_bonding_agg_mode_policy_string,
6008 #endif /* RTE_LIBRTE_PMD_BOND */
6010 /* *** SET FORWARDING MODE *** */
6011 struct cmd_set_fwd_mode_result {
6012 cmdline_fixed_string_t set;
6013 cmdline_fixed_string_t fwd;
6014 cmdline_fixed_string_t mode;
6017 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6018 __attribute__((unused)) struct cmdline *cl,
6019 __attribute__((unused)) void *data)
6021 struct cmd_set_fwd_mode_result *res = parsed_result;
6024 set_pkt_forwarding_mode(res->mode);
6027 cmdline_parse_token_string_t cmd_setfwd_set =
6028 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6029 cmdline_parse_token_string_t cmd_setfwd_fwd =
6030 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6031 cmdline_parse_token_string_t cmd_setfwd_mode =
6032 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6033 "" /* defined at init */);
6035 cmdline_parse_inst_t cmd_set_fwd_mode = {
6036 .f = cmd_set_fwd_mode_parsed,
6038 .help_str = NULL, /* defined at init */
6040 (void *)&cmd_setfwd_set,
6041 (void *)&cmd_setfwd_fwd,
6042 (void *)&cmd_setfwd_mode,
6047 static void cmd_set_fwd_mode_init(void)
6050 static char token[128];
6051 static char help[256];
6052 cmdline_parse_token_string_t *token_struct;
6054 modes = list_pkt_forwarding_modes();
6055 snprintf(help, sizeof(help), "set fwd %s: "
6056 "Set packet forwarding mode", modes);
6057 cmd_set_fwd_mode.help_str = help;
6059 /* string token separator is # */
6060 for (c = token; *modes != '\0'; modes++)
6065 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6066 token_struct->string_data.str = token;
6069 /* *** SET RETRY FORWARDING MODE *** */
6070 struct cmd_set_fwd_retry_mode_result {
6071 cmdline_fixed_string_t set;
6072 cmdline_fixed_string_t fwd;
6073 cmdline_fixed_string_t mode;
6074 cmdline_fixed_string_t retry;
6077 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6078 __attribute__((unused)) struct cmdline *cl,
6079 __attribute__((unused)) void *data)
6081 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6084 set_pkt_forwarding_mode(res->mode);
6087 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6088 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6090 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6091 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6093 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6094 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6096 "" /* defined at init */);
6097 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6098 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6101 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6102 .f = cmd_set_fwd_retry_mode_parsed,
6104 .help_str = NULL, /* defined at init */
6106 (void *)&cmd_setfwd_retry_set,
6107 (void *)&cmd_setfwd_retry_fwd,
6108 (void *)&cmd_setfwd_retry_mode,
6109 (void *)&cmd_setfwd_retry_retry,
6114 static void cmd_set_fwd_retry_mode_init(void)
6117 static char token[128];
6118 static char help[256];
6119 cmdline_parse_token_string_t *token_struct;
6121 modes = list_pkt_forwarding_retry_modes();
6122 snprintf(help, sizeof(help), "set fwd %s retry: "
6123 "Set packet forwarding mode with retry", modes);
6124 cmd_set_fwd_retry_mode.help_str = help;
6126 /* string token separator is # */
6127 for (c = token; *modes != '\0'; modes++)
6132 token_struct = (cmdline_parse_token_string_t *)
6133 cmd_set_fwd_retry_mode.tokens[2];
6134 token_struct->string_data.str = token;
6137 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6138 struct cmd_set_burst_tx_retry_result {
6139 cmdline_fixed_string_t set;
6140 cmdline_fixed_string_t burst;
6141 cmdline_fixed_string_t tx;
6142 cmdline_fixed_string_t delay;
6144 cmdline_fixed_string_t retry;
6148 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6149 __attribute__((unused)) struct cmdline *cl,
6150 __attribute__((unused)) void *data)
6152 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6154 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6155 && !strcmp(res->tx, "tx")) {
6156 if (!strcmp(res->delay, "delay"))
6157 burst_tx_delay_time = res->time;
6158 if (!strcmp(res->retry, "retry"))
6159 burst_tx_retry_num = res->retry_num;
6164 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6165 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6166 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6167 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6169 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6170 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6171 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6172 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6173 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6174 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6175 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6176 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6177 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6178 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6180 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6181 .f = cmd_set_burst_tx_retry_parsed,
6182 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6184 (void *)&cmd_set_burst_tx_retry_set,
6185 (void *)&cmd_set_burst_tx_retry_burst,
6186 (void *)&cmd_set_burst_tx_retry_tx,
6187 (void *)&cmd_set_burst_tx_retry_delay,
6188 (void *)&cmd_set_burst_tx_retry_time,
6189 (void *)&cmd_set_burst_tx_retry_retry,
6190 (void *)&cmd_set_burst_tx_retry_retry_num,
6195 /* *** SET PROMISC MODE *** */
6196 struct cmd_set_promisc_mode_result {
6197 cmdline_fixed_string_t set;
6198 cmdline_fixed_string_t promisc;
6199 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6200 uint16_t port_num; /* valid if "allports" argument == 0 */
6201 cmdline_fixed_string_t mode;
6204 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6205 __attribute__((unused)) struct cmdline *cl,
6208 struct cmd_set_promisc_mode_result *res = parsed_result;
6212 if (!strcmp(res->mode, "on"))
6219 RTE_ETH_FOREACH_DEV(i) {
6221 rte_eth_promiscuous_enable(i);
6223 rte_eth_promiscuous_disable(i);
6228 rte_eth_promiscuous_enable(res->port_num);
6230 rte_eth_promiscuous_disable(res->port_num);
6234 cmdline_parse_token_string_t cmd_setpromisc_set =
6235 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6236 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6237 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6239 cmdline_parse_token_string_t cmd_setpromisc_portall =
6240 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6242 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6243 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6245 cmdline_parse_token_string_t cmd_setpromisc_mode =
6246 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6249 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6250 .f = cmd_set_promisc_mode_parsed,
6252 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6254 (void *)&cmd_setpromisc_set,
6255 (void *)&cmd_setpromisc_promisc,
6256 (void *)&cmd_setpromisc_portall,
6257 (void *)&cmd_setpromisc_mode,
6262 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6263 .f = cmd_set_promisc_mode_parsed,
6265 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6267 (void *)&cmd_setpromisc_set,
6268 (void *)&cmd_setpromisc_promisc,
6269 (void *)&cmd_setpromisc_portnum,
6270 (void *)&cmd_setpromisc_mode,
6275 /* *** SET ALLMULTI MODE *** */
6276 struct cmd_set_allmulti_mode_result {
6277 cmdline_fixed_string_t set;
6278 cmdline_fixed_string_t allmulti;
6279 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6280 uint16_t port_num; /* valid if "allports" argument == 0 */
6281 cmdline_fixed_string_t mode;
6284 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6285 __attribute__((unused)) struct cmdline *cl,
6288 struct cmd_set_allmulti_mode_result *res = parsed_result;
6292 if (!strcmp(res->mode, "on"))
6299 RTE_ETH_FOREACH_DEV(i) {
6301 rte_eth_allmulticast_enable(i);
6303 rte_eth_allmulticast_disable(i);
6308 rte_eth_allmulticast_enable(res->port_num);
6310 rte_eth_allmulticast_disable(res->port_num);
6314 cmdline_parse_token_string_t cmd_setallmulti_set =
6315 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6316 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6317 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6319 cmdline_parse_token_string_t cmd_setallmulti_portall =
6320 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6322 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6323 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6325 cmdline_parse_token_string_t cmd_setallmulti_mode =
6326 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6329 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6330 .f = cmd_set_allmulti_mode_parsed,
6332 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6334 (void *)&cmd_setallmulti_set,
6335 (void *)&cmd_setallmulti_allmulti,
6336 (void *)&cmd_setallmulti_portall,
6337 (void *)&cmd_setallmulti_mode,
6342 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6343 .f = cmd_set_allmulti_mode_parsed,
6345 .help_str = "set allmulti <port_id> on|off: "
6346 "Set allmulti mode on port_id",
6348 (void *)&cmd_setallmulti_set,
6349 (void *)&cmd_setallmulti_allmulti,
6350 (void *)&cmd_setallmulti_portnum,
6351 (void *)&cmd_setallmulti_mode,
6356 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6357 struct cmd_link_flow_ctrl_set_result {
6358 cmdline_fixed_string_t set;
6359 cmdline_fixed_string_t flow_ctrl;
6360 cmdline_fixed_string_t rx;
6361 cmdline_fixed_string_t rx_lfc_mode;
6362 cmdline_fixed_string_t tx;
6363 cmdline_fixed_string_t tx_lfc_mode;
6364 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6365 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6366 cmdline_fixed_string_t autoneg_str;
6367 cmdline_fixed_string_t autoneg;
6368 cmdline_fixed_string_t hw_str;
6369 uint32_t high_water;
6370 cmdline_fixed_string_t lw_str;
6372 cmdline_fixed_string_t pt_str;
6373 uint16_t pause_time;
6374 cmdline_fixed_string_t xon_str;
6379 cmdline_parse_token_string_t cmd_lfc_set_set =
6380 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6382 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6383 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6384 flow_ctrl, "flow_ctrl");
6385 cmdline_parse_token_string_t cmd_lfc_set_rx =
6386 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6388 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6389 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6390 rx_lfc_mode, "on#off");
6391 cmdline_parse_token_string_t cmd_lfc_set_tx =
6392 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6394 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6395 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6396 tx_lfc_mode, "on#off");
6397 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6398 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6399 hw_str, "high_water");
6400 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6401 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6402 high_water, UINT32);
6403 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6404 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6405 lw_str, "low_water");
6406 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6407 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6409 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6410 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6411 pt_str, "pause_time");
6412 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6413 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6414 pause_time, UINT16);
6415 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6416 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6417 xon_str, "send_xon");
6418 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6419 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6421 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6423 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6424 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6426 mac_ctrl_frame_fwd_mode, "on#off");
6427 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6429 autoneg_str, "autoneg");
6430 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6433 cmdline_parse_token_num_t cmd_lfc_set_portid =
6434 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6437 /* forward declaration */
6439 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6442 cmdline_parse_inst_t cmd_link_flow_control_set = {
6443 .f = cmd_link_flow_ctrl_set_parsed,
6445 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6446 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6447 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6449 (void *)&cmd_lfc_set_set,
6450 (void *)&cmd_lfc_set_flow_ctrl,
6451 (void *)&cmd_lfc_set_rx,
6452 (void *)&cmd_lfc_set_rx_mode,
6453 (void *)&cmd_lfc_set_tx,
6454 (void *)&cmd_lfc_set_tx_mode,
6455 (void *)&cmd_lfc_set_high_water,
6456 (void *)&cmd_lfc_set_low_water,
6457 (void *)&cmd_lfc_set_pause_time,
6458 (void *)&cmd_lfc_set_send_xon,
6459 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6460 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6461 (void *)&cmd_lfc_set_autoneg_str,
6462 (void *)&cmd_lfc_set_autoneg,
6463 (void *)&cmd_lfc_set_portid,
6468 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6469 .f = cmd_link_flow_ctrl_set_parsed,
6470 .data = (void *)&cmd_link_flow_control_set_rx,
6471 .help_str = "set flow_ctrl rx on|off <port_id>: "
6472 "Change rx flow control parameter",
6474 (void *)&cmd_lfc_set_set,
6475 (void *)&cmd_lfc_set_flow_ctrl,
6476 (void *)&cmd_lfc_set_rx,
6477 (void *)&cmd_lfc_set_rx_mode,
6478 (void *)&cmd_lfc_set_portid,
6483 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6484 .f = cmd_link_flow_ctrl_set_parsed,
6485 .data = (void *)&cmd_link_flow_control_set_tx,
6486 .help_str = "set flow_ctrl tx on|off <port_id>: "
6487 "Change tx flow control parameter",
6489 (void *)&cmd_lfc_set_set,
6490 (void *)&cmd_lfc_set_flow_ctrl,
6491 (void *)&cmd_lfc_set_tx,
6492 (void *)&cmd_lfc_set_tx_mode,
6493 (void *)&cmd_lfc_set_portid,
6498 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6499 .f = cmd_link_flow_ctrl_set_parsed,
6500 .data = (void *)&cmd_link_flow_control_set_hw,
6501 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6502 "Change high water flow control parameter",
6504 (void *)&cmd_lfc_set_set,
6505 (void *)&cmd_lfc_set_flow_ctrl,
6506 (void *)&cmd_lfc_set_high_water_str,
6507 (void *)&cmd_lfc_set_high_water,
6508 (void *)&cmd_lfc_set_portid,
6513 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6514 .f = cmd_link_flow_ctrl_set_parsed,
6515 .data = (void *)&cmd_link_flow_control_set_lw,
6516 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6517 "Change low water flow control parameter",
6519 (void *)&cmd_lfc_set_set,
6520 (void *)&cmd_lfc_set_flow_ctrl,
6521 (void *)&cmd_lfc_set_low_water_str,
6522 (void *)&cmd_lfc_set_low_water,
6523 (void *)&cmd_lfc_set_portid,
6528 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6529 .f = cmd_link_flow_ctrl_set_parsed,
6530 .data = (void *)&cmd_link_flow_control_set_pt,
6531 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6532 "Change pause time flow control parameter",
6534 (void *)&cmd_lfc_set_set,
6535 (void *)&cmd_lfc_set_flow_ctrl,
6536 (void *)&cmd_lfc_set_pause_time_str,
6537 (void *)&cmd_lfc_set_pause_time,
6538 (void *)&cmd_lfc_set_portid,
6543 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6544 .f = cmd_link_flow_ctrl_set_parsed,
6545 .data = (void *)&cmd_link_flow_control_set_xon,
6546 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6547 "Change send_xon flow control parameter",
6549 (void *)&cmd_lfc_set_set,
6550 (void *)&cmd_lfc_set_flow_ctrl,
6551 (void *)&cmd_lfc_set_send_xon_str,
6552 (void *)&cmd_lfc_set_send_xon,
6553 (void *)&cmd_lfc_set_portid,
6558 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6559 .f = cmd_link_flow_ctrl_set_parsed,
6560 .data = (void *)&cmd_link_flow_control_set_macfwd,
6561 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6562 "Change mac ctrl fwd flow control parameter",
6564 (void *)&cmd_lfc_set_set,
6565 (void *)&cmd_lfc_set_flow_ctrl,
6566 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6567 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6568 (void *)&cmd_lfc_set_portid,
6573 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6574 .f = cmd_link_flow_ctrl_set_parsed,
6575 .data = (void *)&cmd_link_flow_control_set_autoneg,
6576 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6577 "Change autoneg flow control parameter",
6579 (void *)&cmd_lfc_set_set,
6580 (void *)&cmd_lfc_set_flow_ctrl,
6581 (void *)&cmd_lfc_set_autoneg_str,
6582 (void *)&cmd_lfc_set_autoneg,
6583 (void *)&cmd_lfc_set_portid,
6589 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6590 __attribute__((unused)) struct cmdline *cl,
6593 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6594 cmdline_parse_inst_t *cmd = data;
6595 struct rte_eth_fc_conf fc_conf;
6601 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6602 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6603 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6604 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6606 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6607 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6610 /* Partial command line, retrieve current configuration */
6612 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6614 printf("cannot get current flow ctrl parameters, return"
6615 "code = %d\n", ret);
6619 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6620 (fc_conf.mode == RTE_FC_FULL))
6622 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6623 (fc_conf.mode == RTE_FC_FULL))
6627 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6628 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6630 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6631 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6633 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6635 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6636 fc_conf.high_water = res->high_water;
6638 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6639 fc_conf.low_water = res->low_water;
6641 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6642 fc_conf.pause_time = res->pause_time;
6644 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6645 fc_conf.send_xon = res->send_xon;
6647 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6648 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6649 fc_conf.mac_ctrl_frame_fwd = 1;
6651 fc_conf.mac_ctrl_frame_fwd = 0;
6654 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6655 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6657 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6659 printf("bad flow contrl parameter, return code = %d \n", ret);
6662 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6663 struct cmd_priority_flow_ctrl_set_result {
6664 cmdline_fixed_string_t set;
6665 cmdline_fixed_string_t pfc_ctrl;
6666 cmdline_fixed_string_t rx;
6667 cmdline_fixed_string_t rx_pfc_mode;
6668 cmdline_fixed_string_t tx;
6669 cmdline_fixed_string_t tx_pfc_mode;
6670 uint32_t high_water;
6672 uint16_t pause_time;
6678 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6679 __attribute__((unused)) struct cmdline *cl,
6680 __attribute__((unused)) void *data)
6682 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6683 struct rte_eth_pfc_conf pfc_conf;
6684 int rx_fc_enable, tx_fc_enable;
6688 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6689 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6690 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6691 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6693 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6694 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6697 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6698 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6699 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6700 pfc_conf.fc.high_water = res->high_water;
6701 pfc_conf.fc.low_water = res->low_water;
6702 pfc_conf.fc.pause_time = res->pause_time;
6703 pfc_conf.priority = res->priority;
6705 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6707 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6710 cmdline_parse_token_string_t cmd_pfc_set_set =
6711 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6713 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6714 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6715 pfc_ctrl, "pfc_ctrl");
6716 cmdline_parse_token_string_t cmd_pfc_set_rx =
6717 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6719 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6720 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6721 rx_pfc_mode, "on#off");
6722 cmdline_parse_token_string_t cmd_pfc_set_tx =
6723 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6725 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6726 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6727 tx_pfc_mode, "on#off");
6728 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6729 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6730 high_water, UINT32);
6731 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6732 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6734 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6735 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6736 pause_time, UINT16);
6737 cmdline_parse_token_num_t cmd_pfc_set_priority =
6738 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6740 cmdline_parse_token_num_t cmd_pfc_set_portid =
6741 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6744 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6745 .f = cmd_priority_flow_ctrl_set_parsed,
6747 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6748 "<pause_time> <priority> <port_id>: "
6749 "Configure the Ethernet priority flow control",
6751 (void *)&cmd_pfc_set_set,
6752 (void *)&cmd_pfc_set_flow_ctrl,
6753 (void *)&cmd_pfc_set_rx,
6754 (void *)&cmd_pfc_set_rx_mode,
6755 (void *)&cmd_pfc_set_tx,
6756 (void *)&cmd_pfc_set_tx_mode,
6757 (void *)&cmd_pfc_set_high_water,
6758 (void *)&cmd_pfc_set_low_water,
6759 (void *)&cmd_pfc_set_pause_time,
6760 (void *)&cmd_pfc_set_priority,
6761 (void *)&cmd_pfc_set_portid,
6766 /* *** RESET CONFIGURATION *** */
6767 struct cmd_reset_result {
6768 cmdline_fixed_string_t reset;
6769 cmdline_fixed_string_t def;
6772 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6774 __attribute__((unused)) void *data)
6776 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6777 set_def_fwd_config();
6780 cmdline_parse_token_string_t cmd_reset_set =
6781 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6782 cmdline_parse_token_string_t cmd_reset_def =
6783 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6786 cmdline_parse_inst_t cmd_reset = {
6787 .f = cmd_reset_parsed,
6789 .help_str = "set default: Reset default forwarding configuration",
6791 (void *)&cmd_reset_set,
6792 (void *)&cmd_reset_def,
6797 /* *** START FORWARDING *** */
6798 struct cmd_start_result {
6799 cmdline_fixed_string_t start;
6802 cmdline_parse_token_string_t cmd_start_start =
6803 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6805 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6806 __attribute__((unused)) struct cmdline *cl,
6807 __attribute__((unused)) void *data)
6809 start_packet_forwarding(0);
6812 cmdline_parse_inst_t cmd_start = {
6813 .f = cmd_start_parsed,
6815 .help_str = "start: Start packet forwarding",
6817 (void *)&cmd_start_start,
6822 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6823 struct cmd_start_tx_first_result {
6824 cmdline_fixed_string_t start;
6825 cmdline_fixed_string_t tx_first;
6829 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6830 __attribute__((unused)) struct cmdline *cl,
6831 __attribute__((unused)) void *data)
6833 start_packet_forwarding(1);
6836 cmdline_parse_token_string_t cmd_start_tx_first_start =
6837 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6839 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6840 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6841 tx_first, "tx_first");
6843 cmdline_parse_inst_t cmd_start_tx_first = {
6844 .f = cmd_start_tx_first_parsed,
6846 .help_str = "start tx_first: Start packet forwarding, "
6847 "after sending 1 burst of packets",
6849 (void *)&cmd_start_tx_first_start,
6850 (void *)&cmd_start_tx_first_tx_first,
6855 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6856 struct cmd_start_tx_first_n_result {
6857 cmdline_fixed_string_t start;
6858 cmdline_fixed_string_t tx_first;
6863 cmd_start_tx_first_n_parsed(void *parsed_result,
6864 __attribute__((unused)) struct cmdline *cl,
6865 __attribute__((unused)) void *data)
6867 struct cmd_start_tx_first_n_result *res = parsed_result;
6869 start_packet_forwarding(res->tx_num);
6872 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6873 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6875 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6876 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6877 tx_first, "tx_first");
6878 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6879 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6882 cmdline_parse_inst_t cmd_start_tx_first_n = {
6883 .f = cmd_start_tx_first_n_parsed,
6885 .help_str = "start tx_first <num>: "
6886 "packet forwarding, after sending <num> bursts of packets",
6888 (void *)&cmd_start_tx_first_n_start,
6889 (void *)&cmd_start_tx_first_n_tx_first,
6890 (void *)&cmd_start_tx_first_n_tx_num,
6895 /* *** SET LINK UP *** */
6896 struct cmd_set_link_up_result {
6897 cmdline_fixed_string_t set;
6898 cmdline_fixed_string_t link_up;
6899 cmdline_fixed_string_t port;
6903 cmdline_parse_token_string_t cmd_set_link_up_set =
6904 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6905 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6906 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6908 cmdline_parse_token_string_t cmd_set_link_up_port =
6909 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6910 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6911 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6913 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6914 __attribute__((unused)) struct cmdline *cl,
6915 __attribute__((unused)) void *data)
6917 struct cmd_set_link_up_result *res = parsed_result;
6918 dev_set_link_up(res->port_id);
6921 cmdline_parse_inst_t cmd_set_link_up = {
6922 .f = cmd_set_link_up_parsed,
6924 .help_str = "set link-up port <port id>",
6926 (void *)&cmd_set_link_up_set,
6927 (void *)&cmd_set_link_up_link_up,
6928 (void *)&cmd_set_link_up_port,
6929 (void *)&cmd_set_link_up_port_id,
6934 /* *** SET LINK DOWN *** */
6935 struct cmd_set_link_down_result {
6936 cmdline_fixed_string_t set;
6937 cmdline_fixed_string_t link_down;
6938 cmdline_fixed_string_t port;
6942 cmdline_parse_token_string_t cmd_set_link_down_set =
6943 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6944 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6945 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6947 cmdline_parse_token_string_t cmd_set_link_down_port =
6948 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6949 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6950 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6952 static void cmd_set_link_down_parsed(
6953 __attribute__((unused)) void *parsed_result,
6954 __attribute__((unused)) struct cmdline *cl,
6955 __attribute__((unused)) void *data)
6957 struct cmd_set_link_down_result *res = parsed_result;
6958 dev_set_link_down(res->port_id);
6961 cmdline_parse_inst_t cmd_set_link_down = {
6962 .f = cmd_set_link_down_parsed,
6964 .help_str = "set link-down port <port id>",
6966 (void *)&cmd_set_link_down_set,
6967 (void *)&cmd_set_link_down_link_down,
6968 (void *)&cmd_set_link_down_port,
6969 (void *)&cmd_set_link_down_port_id,
6974 /* *** SHOW CFG *** */
6975 struct cmd_showcfg_result {
6976 cmdline_fixed_string_t show;
6977 cmdline_fixed_string_t cfg;
6978 cmdline_fixed_string_t what;
6981 static void cmd_showcfg_parsed(void *parsed_result,
6982 __attribute__((unused)) struct cmdline *cl,
6983 __attribute__((unused)) void *data)
6985 struct cmd_showcfg_result *res = parsed_result;
6986 if (!strcmp(res->what, "rxtx"))
6987 rxtx_config_display();
6988 else if (!strcmp(res->what, "cores"))
6989 fwd_lcores_config_display();
6990 else if (!strcmp(res->what, "fwd"))
6991 pkt_fwd_config_display(&cur_fwd_config);
6992 else if (!strcmp(res->what, "txpkts"))
6993 show_tx_pkt_segments();
6996 cmdline_parse_token_string_t cmd_showcfg_show =
6997 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6998 cmdline_parse_token_string_t cmd_showcfg_port =
6999 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7000 cmdline_parse_token_string_t cmd_showcfg_what =
7001 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7002 "rxtx#cores#fwd#txpkts");
7004 cmdline_parse_inst_t cmd_showcfg = {
7005 .f = cmd_showcfg_parsed,
7007 .help_str = "show config rxtx|cores|fwd|txpkts",
7009 (void *)&cmd_showcfg_show,
7010 (void *)&cmd_showcfg_port,
7011 (void *)&cmd_showcfg_what,
7016 /* *** SHOW ALL PORT INFO *** */
7017 struct cmd_showportall_result {
7018 cmdline_fixed_string_t show;
7019 cmdline_fixed_string_t port;
7020 cmdline_fixed_string_t what;
7021 cmdline_fixed_string_t all;
7024 static void cmd_showportall_parsed(void *parsed_result,
7025 __attribute__((unused)) struct cmdline *cl,
7026 __attribute__((unused)) void *data)
7030 struct cmd_showportall_result *res = parsed_result;
7031 if (!strcmp(res->show, "clear")) {
7032 if (!strcmp(res->what, "stats"))
7033 RTE_ETH_FOREACH_DEV(i)
7035 else if (!strcmp(res->what, "xstats"))
7036 RTE_ETH_FOREACH_DEV(i)
7037 nic_xstats_clear(i);
7038 } else if (!strcmp(res->what, "info"))
7039 RTE_ETH_FOREACH_DEV(i)
7040 port_infos_display(i);
7041 else if (!strcmp(res->what, "stats"))
7042 RTE_ETH_FOREACH_DEV(i)
7043 nic_stats_display(i);
7044 else if (!strcmp(res->what, "xstats"))
7045 RTE_ETH_FOREACH_DEV(i)
7046 nic_xstats_display(i);
7047 else if (!strcmp(res->what, "fdir"))
7048 RTE_ETH_FOREACH_DEV(i)
7050 else if (!strcmp(res->what, "stat_qmap"))
7051 RTE_ETH_FOREACH_DEV(i)
7052 nic_stats_mapping_display(i);
7053 else if (!strcmp(res->what, "dcb_tc"))
7054 RTE_ETH_FOREACH_DEV(i)
7055 port_dcb_info_display(i);
7056 else if (!strcmp(res->what, "cap"))
7057 RTE_ETH_FOREACH_DEV(i)
7058 port_offload_cap_display(i);
7061 cmdline_parse_token_string_t cmd_showportall_show =
7062 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7064 cmdline_parse_token_string_t cmd_showportall_port =
7065 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7066 cmdline_parse_token_string_t cmd_showportall_what =
7067 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7068 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7069 cmdline_parse_token_string_t cmd_showportall_all =
7070 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7071 cmdline_parse_inst_t cmd_showportall = {
7072 .f = cmd_showportall_parsed,
7074 .help_str = "show|clear port "
7075 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7077 (void *)&cmd_showportall_show,
7078 (void *)&cmd_showportall_port,
7079 (void *)&cmd_showportall_what,
7080 (void *)&cmd_showportall_all,
7085 /* *** SHOW PORT INFO *** */
7086 struct cmd_showport_result {
7087 cmdline_fixed_string_t show;
7088 cmdline_fixed_string_t port;
7089 cmdline_fixed_string_t what;
7093 static void cmd_showport_parsed(void *parsed_result,
7094 __attribute__((unused)) struct cmdline *cl,
7095 __attribute__((unused)) void *data)
7097 struct cmd_showport_result *res = parsed_result;
7098 if (!strcmp(res->show, "clear")) {
7099 if (!strcmp(res->what, "stats"))
7100 nic_stats_clear(res->portnum);
7101 else if (!strcmp(res->what, "xstats"))
7102 nic_xstats_clear(res->portnum);
7103 } else if (!strcmp(res->what, "info"))
7104 port_infos_display(res->portnum);
7105 else if (!strcmp(res->what, "stats"))
7106 nic_stats_display(res->portnum);
7107 else if (!strcmp(res->what, "xstats"))
7108 nic_xstats_display(res->portnum);
7109 else if (!strcmp(res->what, "fdir"))
7110 fdir_get_infos(res->portnum);
7111 else if (!strcmp(res->what, "stat_qmap"))
7112 nic_stats_mapping_display(res->portnum);
7113 else if (!strcmp(res->what, "dcb_tc"))
7114 port_dcb_info_display(res->portnum);
7115 else if (!strcmp(res->what, "cap"))
7116 port_offload_cap_display(res->portnum);
7119 cmdline_parse_token_string_t cmd_showport_show =
7120 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7122 cmdline_parse_token_string_t cmd_showport_port =
7123 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7124 cmdline_parse_token_string_t cmd_showport_what =
7125 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7126 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7127 cmdline_parse_token_num_t cmd_showport_portnum =
7128 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7130 cmdline_parse_inst_t cmd_showport = {
7131 .f = cmd_showport_parsed,
7133 .help_str = "show|clear port "
7134 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7137 (void *)&cmd_showport_show,
7138 (void *)&cmd_showport_port,
7139 (void *)&cmd_showport_what,
7140 (void *)&cmd_showport_portnum,
7145 /* *** SHOW QUEUE INFO *** */
7146 struct cmd_showqueue_result {
7147 cmdline_fixed_string_t show;
7148 cmdline_fixed_string_t type;
7149 cmdline_fixed_string_t what;
7155 cmd_showqueue_parsed(void *parsed_result,
7156 __attribute__((unused)) struct cmdline *cl,
7157 __attribute__((unused)) void *data)
7159 struct cmd_showqueue_result *res = parsed_result;
7161 if (!strcmp(res->type, "rxq"))
7162 rx_queue_infos_display(res->portnum, res->queuenum);
7163 else if (!strcmp(res->type, "txq"))
7164 tx_queue_infos_display(res->portnum, res->queuenum);
7167 cmdline_parse_token_string_t cmd_showqueue_show =
7168 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7169 cmdline_parse_token_string_t cmd_showqueue_type =
7170 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7171 cmdline_parse_token_string_t cmd_showqueue_what =
7172 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7173 cmdline_parse_token_num_t cmd_showqueue_portnum =
7174 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7175 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7176 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7178 cmdline_parse_inst_t cmd_showqueue = {
7179 .f = cmd_showqueue_parsed,
7181 .help_str = "show rxq|txq info <port_id> <queue_id>",
7183 (void *)&cmd_showqueue_show,
7184 (void *)&cmd_showqueue_type,
7185 (void *)&cmd_showqueue_what,
7186 (void *)&cmd_showqueue_portnum,
7187 (void *)&cmd_showqueue_queuenum,
7192 /* *** READ PORT REGISTER *** */
7193 struct cmd_read_reg_result {
7194 cmdline_fixed_string_t read;
7195 cmdline_fixed_string_t reg;
7201 cmd_read_reg_parsed(void *parsed_result,
7202 __attribute__((unused)) struct cmdline *cl,
7203 __attribute__((unused)) void *data)
7205 struct cmd_read_reg_result *res = parsed_result;
7206 port_reg_display(res->port_id, res->reg_off);
7209 cmdline_parse_token_string_t cmd_read_reg_read =
7210 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7211 cmdline_parse_token_string_t cmd_read_reg_reg =
7212 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7213 cmdline_parse_token_num_t cmd_read_reg_port_id =
7214 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7215 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7216 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7218 cmdline_parse_inst_t cmd_read_reg = {
7219 .f = cmd_read_reg_parsed,
7221 .help_str = "read reg <port_id> <reg_off>",
7223 (void *)&cmd_read_reg_read,
7224 (void *)&cmd_read_reg_reg,
7225 (void *)&cmd_read_reg_port_id,
7226 (void *)&cmd_read_reg_reg_off,
7231 /* *** READ PORT REGISTER BIT FIELD *** */
7232 struct cmd_read_reg_bit_field_result {
7233 cmdline_fixed_string_t read;
7234 cmdline_fixed_string_t regfield;
7242 cmd_read_reg_bit_field_parsed(void *parsed_result,
7243 __attribute__((unused)) struct cmdline *cl,
7244 __attribute__((unused)) void *data)
7246 struct cmd_read_reg_bit_field_result *res = parsed_result;
7247 port_reg_bit_field_display(res->port_id, res->reg_off,
7248 res->bit1_pos, res->bit2_pos);
7251 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7252 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7254 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7255 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7256 regfield, "regfield");
7257 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7258 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7260 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7261 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7263 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7264 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7266 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7267 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7270 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7271 .f = cmd_read_reg_bit_field_parsed,
7273 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7274 "Read register bit field between bit_x and bit_y included",
7276 (void *)&cmd_read_reg_bit_field_read,
7277 (void *)&cmd_read_reg_bit_field_regfield,
7278 (void *)&cmd_read_reg_bit_field_port_id,
7279 (void *)&cmd_read_reg_bit_field_reg_off,
7280 (void *)&cmd_read_reg_bit_field_bit1_pos,
7281 (void *)&cmd_read_reg_bit_field_bit2_pos,
7286 /* *** READ PORT REGISTER BIT *** */
7287 struct cmd_read_reg_bit_result {
7288 cmdline_fixed_string_t read;
7289 cmdline_fixed_string_t regbit;
7296 cmd_read_reg_bit_parsed(void *parsed_result,
7297 __attribute__((unused)) struct cmdline *cl,
7298 __attribute__((unused)) void *data)
7300 struct cmd_read_reg_bit_result *res = parsed_result;
7301 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7304 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7305 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7306 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7307 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7309 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7310 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7311 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7312 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7313 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7314 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7316 cmdline_parse_inst_t cmd_read_reg_bit = {
7317 .f = cmd_read_reg_bit_parsed,
7319 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7321 (void *)&cmd_read_reg_bit_read,
7322 (void *)&cmd_read_reg_bit_regbit,
7323 (void *)&cmd_read_reg_bit_port_id,
7324 (void *)&cmd_read_reg_bit_reg_off,
7325 (void *)&cmd_read_reg_bit_bit_pos,
7330 /* *** WRITE PORT REGISTER *** */
7331 struct cmd_write_reg_result {
7332 cmdline_fixed_string_t write;
7333 cmdline_fixed_string_t reg;
7340 cmd_write_reg_parsed(void *parsed_result,
7341 __attribute__((unused)) struct cmdline *cl,
7342 __attribute__((unused)) void *data)
7344 struct cmd_write_reg_result *res = parsed_result;
7345 port_reg_set(res->port_id, res->reg_off, res->value);
7348 cmdline_parse_token_string_t cmd_write_reg_write =
7349 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7350 cmdline_parse_token_string_t cmd_write_reg_reg =
7351 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7352 cmdline_parse_token_num_t cmd_write_reg_port_id =
7353 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7354 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7355 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7356 cmdline_parse_token_num_t cmd_write_reg_value =
7357 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7359 cmdline_parse_inst_t cmd_write_reg = {
7360 .f = cmd_write_reg_parsed,
7362 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7364 (void *)&cmd_write_reg_write,
7365 (void *)&cmd_write_reg_reg,
7366 (void *)&cmd_write_reg_port_id,
7367 (void *)&cmd_write_reg_reg_off,
7368 (void *)&cmd_write_reg_value,
7373 /* *** WRITE PORT REGISTER BIT FIELD *** */
7374 struct cmd_write_reg_bit_field_result {
7375 cmdline_fixed_string_t write;
7376 cmdline_fixed_string_t regfield;
7385 cmd_write_reg_bit_field_parsed(void *parsed_result,
7386 __attribute__((unused)) struct cmdline *cl,
7387 __attribute__((unused)) void *data)
7389 struct cmd_write_reg_bit_field_result *res = parsed_result;
7390 port_reg_bit_field_set(res->port_id, res->reg_off,
7391 res->bit1_pos, res->bit2_pos, res->value);
7394 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7395 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7397 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7398 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7399 regfield, "regfield");
7400 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7401 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7403 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7404 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7406 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7407 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7409 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7410 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7412 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7413 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7416 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7417 .f = cmd_write_reg_bit_field_parsed,
7419 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7421 "Set register bit field between bit_x and bit_y included",
7423 (void *)&cmd_write_reg_bit_field_write,
7424 (void *)&cmd_write_reg_bit_field_regfield,
7425 (void *)&cmd_write_reg_bit_field_port_id,
7426 (void *)&cmd_write_reg_bit_field_reg_off,
7427 (void *)&cmd_write_reg_bit_field_bit1_pos,
7428 (void *)&cmd_write_reg_bit_field_bit2_pos,
7429 (void *)&cmd_write_reg_bit_field_value,
7434 /* *** WRITE PORT REGISTER BIT *** */
7435 struct cmd_write_reg_bit_result {
7436 cmdline_fixed_string_t write;
7437 cmdline_fixed_string_t regbit;
7445 cmd_write_reg_bit_parsed(void *parsed_result,
7446 __attribute__((unused)) struct cmdline *cl,
7447 __attribute__((unused)) void *data)
7449 struct cmd_write_reg_bit_result *res = parsed_result;
7450 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7453 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7454 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7456 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7457 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7459 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7460 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7461 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7462 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7463 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7464 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7465 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7466 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7468 cmdline_parse_inst_t cmd_write_reg_bit = {
7469 .f = cmd_write_reg_bit_parsed,
7471 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7474 (void *)&cmd_write_reg_bit_write,
7475 (void *)&cmd_write_reg_bit_regbit,
7476 (void *)&cmd_write_reg_bit_port_id,
7477 (void *)&cmd_write_reg_bit_reg_off,
7478 (void *)&cmd_write_reg_bit_bit_pos,
7479 (void *)&cmd_write_reg_bit_value,
7484 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7485 struct cmd_read_rxd_txd_result {
7486 cmdline_fixed_string_t read;
7487 cmdline_fixed_string_t rxd_txd;
7494 cmd_read_rxd_txd_parsed(void *parsed_result,
7495 __attribute__((unused)) struct cmdline *cl,
7496 __attribute__((unused)) void *data)
7498 struct cmd_read_rxd_txd_result *res = parsed_result;
7500 if (!strcmp(res->rxd_txd, "rxd"))
7501 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7502 else if (!strcmp(res->rxd_txd, "txd"))
7503 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7506 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7507 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7508 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7509 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7511 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7512 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7513 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7514 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7515 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7516 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7518 cmdline_parse_inst_t cmd_read_rxd_txd = {
7519 .f = cmd_read_rxd_txd_parsed,
7521 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7523 (void *)&cmd_read_rxd_txd_read,
7524 (void *)&cmd_read_rxd_txd_rxd_txd,
7525 (void *)&cmd_read_rxd_txd_port_id,
7526 (void *)&cmd_read_rxd_txd_queue_id,
7527 (void *)&cmd_read_rxd_txd_desc_id,
7533 struct cmd_quit_result {
7534 cmdline_fixed_string_t quit;
7537 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7539 __attribute__((unused)) void *data)
7545 cmdline_parse_token_string_t cmd_quit_quit =
7546 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7548 cmdline_parse_inst_t cmd_quit = {
7549 .f = cmd_quit_parsed,
7551 .help_str = "quit: Exit application",
7553 (void *)&cmd_quit_quit,
7558 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7559 struct cmd_mac_addr_result {
7560 cmdline_fixed_string_t mac_addr_cmd;
7561 cmdline_fixed_string_t what;
7563 struct ether_addr address;
7566 static void cmd_mac_addr_parsed(void *parsed_result,
7567 __attribute__((unused)) struct cmdline *cl,
7568 __attribute__((unused)) void *data)
7570 struct cmd_mac_addr_result *res = parsed_result;
7573 if (strcmp(res->what, "add") == 0)
7574 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7575 else if (strcmp(res->what, "set") == 0)
7576 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7579 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7581 /* check the return value and print it if is < 0 */
7583 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7587 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7588 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7590 cmdline_parse_token_string_t cmd_mac_addr_what =
7591 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7593 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7594 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7596 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7597 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7599 cmdline_parse_inst_t cmd_mac_addr = {
7600 .f = cmd_mac_addr_parsed,
7602 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7603 "Add/Remove/Set MAC address on port_id",
7605 (void *)&cmd_mac_addr_cmd,
7606 (void *)&cmd_mac_addr_what,
7607 (void *)&cmd_mac_addr_portnum,
7608 (void *)&cmd_mac_addr_addr,
7613 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7614 struct cmd_eth_peer_result {
7615 cmdline_fixed_string_t set;
7616 cmdline_fixed_string_t eth_peer;
7618 cmdline_fixed_string_t peer_addr;
7621 static void cmd_set_eth_peer_parsed(void *parsed_result,
7622 __attribute__((unused)) struct cmdline *cl,
7623 __attribute__((unused)) void *data)
7625 struct cmd_eth_peer_result *res = parsed_result;
7627 if (test_done == 0) {
7628 printf("Please stop forwarding first\n");
7631 if (!strcmp(res->eth_peer, "eth-peer")) {
7632 set_fwd_eth_peer(res->port_id, res->peer_addr);
7636 cmdline_parse_token_string_t cmd_eth_peer_set =
7637 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7638 cmdline_parse_token_string_t cmd_eth_peer =
7639 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7640 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7641 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7642 cmdline_parse_token_string_t cmd_eth_peer_addr =
7643 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7645 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7646 .f = cmd_set_eth_peer_parsed,
7648 .help_str = "set eth-peer <port_id> <peer_mac>",
7650 (void *)&cmd_eth_peer_set,
7651 (void *)&cmd_eth_peer,
7652 (void *)&cmd_eth_peer_port_id,
7653 (void *)&cmd_eth_peer_addr,
7658 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7659 struct cmd_set_qmap_result {
7660 cmdline_fixed_string_t set;
7661 cmdline_fixed_string_t qmap;
7662 cmdline_fixed_string_t what;
7669 cmd_set_qmap_parsed(void *parsed_result,
7670 __attribute__((unused)) struct cmdline *cl,
7671 __attribute__((unused)) void *data)
7673 struct cmd_set_qmap_result *res = parsed_result;
7674 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7676 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7679 cmdline_parse_token_string_t cmd_setqmap_set =
7680 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7682 cmdline_parse_token_string_t cmd_setqmap_qmap =
7683 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7685 cmdline_parse_token_string_t cmd_setqmap_what =
7686 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7688 cmdline_parse_token_num_t cmd_setqmap_portid =
7689 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7691 cmdline_parse_token_num_t cmd_setqmap_queueid =
7692 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7694 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7695 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7698 cmdline_parse_inst_t cmd_set_qmap = {
7699 .f = cmd_set_qmap_parsed,
7701 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7702 "Set statistics mapping value on tx|rx queue_id of port_id",
7704 (void *)&cmd_setqmap_set,
7705 (void *)&cmd_setqmap_qmap,
7706 (void *)&cmd_setqmap_what,
7707 (void *)&cmd_setqmap_portid,
7708 (void *)&cmd_setqmap_queueid,
7709 (void *)&cmd_setqmap_mapvalue,
7714 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7715 struct cmd_set_xstats_hide_zero_result {
7716 cmdline_fixed_string_t keyword;
7717 cmdline_fixed_string_t name;
7718 cmdline_fixed_string_t on_off;
7722 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7723 __attribute__((unused)) struct cmdline *cl,
7724 __attribute__((unused)) void *data)
7726 struct cmd_set_xstats_hide_zero_result *res;
7727 uint16_t on_off = 0;
7729 res = parsed_result;
7730 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7731 set_xstats_hide_zero(on_off);
7734 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7735 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7737 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7738 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7739 name, "xstats-hide-zero");
7740 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7741 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7744 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7745 .f = cmd_set_xstats_hide_zero_parsed,
7747 .help_str = "set xstats-hide-zero on|off",
7749 (void *)&cmd_set_xstats_hide_zero_keyword,
7750 (void *)&cmd_set_xstats_hide_zero_name,
7751 (void *)&cmd_set_xstats_hide_zero_on_off,
7756 /* *** CONFIGURE UNICAST HASH TABLE *** */
7757 struct cmd_set_uc_hash_table {
7758 cmdline_fixed_string_t set;
7759 cmdline_fixed_string_t port;
7761 cmdline_fixed_string_t what;
7762 struct ether_addr address;
7763 cmdline_fixed_string_t mode;
7767 cmd_set_uc_hash_parsed(void *parsed_result,
7768 __attribute__((unused)) struct cmdline *cl,
7769 __attribute__((unused)) void *data)
7772 struct cmd_set_uc_hash_table *res = parsed_result;
7774 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7776 if (strcmp(res->what, "uta") == 0)
7777 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7778 &res->address,(uint8_t)is_on);
7780 printf("bad unicast hash table parameter, return code = %d \n", ret);
7784 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7785 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7787 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7788 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7790 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7791 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7793 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7794 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7796 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7797 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7799 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7800 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7803 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7804 .f = cmd_set_uc_hash_parsed,
7806 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7808 (void *)&cmd_set_uc_hash_set,
7809 (void *)&cmd_set_uc_hash_port,
7810 (void *)&cmd_set_uc_hash_portid,
7811 (void *)&cmd_set_uc_hash_what,
7812 (void *)&cmd_set_uc_hash_mac,
7813 (void *)&cmd_set_uc_hash_mode,
7818 struct cmd_set_uc_all_hash_table {
7819 cmdline_fixed_string_t set;
7820 cmdline_fixed_string_t port;
7822 cmdline_fixed_string_t what;
7823 cmdline_fixed_string_t value;
7824 cmdline_fixed_string_t mode;
7828 cmd_set_uc_all_hash_parsed(void *parsed_result,
7829 __attribute__((unused)) struct cmdline *cl,
7830 __attribute__((unused)) void *data)
7833 struct cmd_set_uc_all_hash_table *res = parsed_result;
7835 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7837 if ((strcmp(res->what, "uta") == 0) &&
7838 (strcmp(res->value, "all") == 0))
7839 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7841 printf("bad unicast hash table parameter,"
7842 "return code = %d \n", ret);
7845 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7846 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7848 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7849 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7851 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7852 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7854 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7855 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7857 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7858 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7860 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7861 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7864 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7865 .f = cmd_set_uc_all_hash_parsed,
7867 .help_str = "set port <port_id> uta all on|off",
7869 (void *)&cmd_set_uc_all_hash_set,
7870 (void *)&cmd_set_uc_all_hash_port,
7871 (void *)&cmd_set_uc_all_hash_portid,
7872 (void *)&cmd_set_uc_all_hash_what,
7873 (void *)&cmd_set_uc_all_hash_value,
7874 (void *)&cmd_set_uc_all_hash_mode,
7879 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7880 struct cmd_set_vf_macvlan_filter {
7881 cmdline_fixed_string_t set;
7882 cmdline_fixed_string_t port;
7884 cmdline_fixed_string_t vf;
7886 struct ether_addr address;
7887 cmdline_fixed_string_t filter_type;
7888 cmdline_fixed_string_t mode;
7892 cmd_set_vf_macvlan_parsed(void *parsed_result,
7893 __attribute__((unused)) struct cmdline *cl,
7894 __attribute__((unused)) void *data)
7897 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7898 struct rte_eth_mac_filter filter;
7900 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7902 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7904 /* set VF MAC filter */
7908 filter.dst_id = res->vf_id;
7910 if (!strcmp(res->filter_type, "exact-mac"))
7911 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7912 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7913 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7914 else if (!strcmp(res->filter_type, "hashmac"))
7915 filter.filter_type = RTE_MAC_HASH_MATCH;
7916 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7917 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7919 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7922 ret = rte_eth_dev_filter_ctrl(res->port_id,
7923 RTE_ETH_FILTER_MACVLAN,
7927 ret = rte_eth_dev_filter_ctrl(res->port_id,
7928 RTE_ETH_FILTER_MACVLAN,
7929 RTE_ETH_FILTER_DELETE,
7933 printf("bad set MAC hash parameter, return code = %d\n", ret);
7937 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7938 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7940 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7941 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7943 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7944 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7946 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7947 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7949 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7950 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7952 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7953 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7955 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7956 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7957 filter_type, "exact-mac#exact-mac-vlan"
7958 "#hashmac#hashmac-vlan");
7959 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7960 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7963 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7964 .f = cmd_set_vf_macvlan_parsed,
7966 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7967 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7968 "Exact match rule: exact match of MAC or MAC and VLAN; "
7969 "hash match rule: hash match of MAC and exact match of VLAN",
7971 (void *)&cmd_set_vf_macvlan_set,
7972 (void *)&cmd_set_vf_macvlan_port,
7973 (void *)&cmd_set_vf_macvlan_portid,
7974 (void *)&cmd_set_vf_macvlan_vf,
7975 (void *)&cmd_set_vf_macvlan_vf_id,
7976 (void *)&cmd_set_vf_macvlan_mac,
7977 (void *)&cmd_set_vf_macvlan_filter_type,
7978 (void *)&cmd_set_vf_macvlan_mode,
7983 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7984 struct cmd_set_vf_traffic {
7985 cmdline_fixed_string_t set;
7986 cmdline_fixed_string_t port;
7988 cmdline_fixed_string_t vf;
7990 cmdline_fixed_string_t what;
7991 cmdline_fixed_string_t mode;
7995 cmd_set_vf_traffic_parsed(void *parsed_result,
7996 __attribute__((unused)) struct cmdline *cl,
7997 __attribute__((unused)) void *data)
7999 struct cmd_set_vf_traffic *res = parsed_result;
8000 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8001 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8003 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8006 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8007 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8009 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8010 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8012 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8013 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8015 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8016 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8018 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8019 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8021 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8022 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8024 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8025 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8028 cmdline_parse_inst_t cmd_set_vf_traffic = {
8029 .f = cmd_set_vf_traffic_parsed,
8031 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8033 (void *)&cmd_setvf_traffic_set,
8034 (void *)&cmd_setvf_traffic_port,
8035 (void *)&cmd_setvf_traffic_portid,
8036 (void *)&cmd_setvf_traffic_vf,
8037 (void *)&cmd_setvf_traffic_vfid,
8038 (void *)&cmd_setvf_traffic_what,
8039 (void *)&cmd_setvf_traffic_mode,
8044 /* *** CONFIGURE VF RECEIVE MODE *** */
8045 struct cmd_set_vf_rxmode {
8046 cmdline_fixed_string_t set;
8047 cmdline_fixed_string_t port;
8049 cmdline_fixed_string_t vf;
8051 cmdline_fixed_string_t what;
8052 cmdline_fixed_string_t mode;
8053 cmdline_fixed_string_t on;
8057 cmd_set_vf_rxmode_parsed(void *parsed_result,
8058 __attribute__((unused)) struct cmdline *cl,
8059 __attribute__((unused)) void *data)
8062 uint16_t rx_mode = 0;
8063 struct cmd_set_vf_rxmode *res = parsed_result;
8065 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8066 if (!strcmp(res->what,"rxmode")) {
8067 if (!strcmp(res->mode, "AUPE"))
8068 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8069 else if (!strcmp(res->mode, "ROPE"))
8070 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8071 else if (!strcmp(res->mode, "BAM"))
8072 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8073 else if (!strncmp(res->mode, "MPE",3))
8074 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8077 RTE_SET_USED(is_on);
8079 #ifdef RTE_LIBRTE_IXGBE_PMD
8080 if (ret == -ENOTSUP)
8081 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8082 rx_mode, (uint8_t)is_on);
8084 #ifdef RTE_LIBRTE_BNXT_PMD
8085 if (ret == -ENOTSUP)
8086 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8087 rx_mode, (uint8_t)is_on);
8090 printf("bad VF receive mode parameter, return code = %d \n",
8094 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8095 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8097 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8098 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8100 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8101 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8103 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8104 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8106 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8107 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8109 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8110 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8112 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8113 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8114 mode, "AUPE#ROPE#BAM#MPE");
8115 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8116 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8119 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8120 .f = cmd_set_vf_rxmode_parsed,
8122 .help_str = "set port <port_id> vf <vf_id> rxmode "
8123 "AUPE|ROPE|BAM|MPE on|off",
8125 (void *)&cmd_set_vf_rxmode_set,
8126 (void *)&cmd_set_vf_rxmode_port,
8127 (void *)&cmd_set_vf_rxmode_portid,
8128 (void *)&cmd_set_vf_rxmode_vf,
8129 (void *)&cmd_set_vf_rxmode_vfid,
8130 (void *)&cmd_set_vf_rxmode_what,
8131 (void *)&cmd_set_vf_rxmode_mode,
8132 (void *)&cmd_set_vf_rxmode_on,
8137 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8138 struct cmd_vf_mac_addr_result {
8139 cmdline_fixed_string_t mac_addr_cmd;
8140 cmdline_fixed_string_t what;
8141 cmdline_fixed_string_t port;
8143 cmdline_fixed_string_t vf;
8145 struct ether_addr address;
8148 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8149 __attribute__((unused)) struct cmdline *cl,
8150 __attribute__((unused)) void *data)
8152 struct cmd_vf_mac_addr_result *res = parsed_result;
8155 if (strcmp(res->what, "add") != 0)
8158 #ifdef RTE_LIBRTE_I40E_PMD
8159 if (ret == -ENOTSUP)
8160 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8163 #ifdef RTE_LIBRTE_BNXT_PMD
8164 if (ret == -ENOTSUP)
8165 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8170 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8174 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8175 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8176 mac_addr_cmd,"mac_addr");
8177 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8178 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8180 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8181 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8183 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8184 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8186 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8187 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8189 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8190 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8192 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8193 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8196 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8197 .f = cmd_vf_mac_addr_parsed,
8199 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8200 "Add MAC address filtering for a VF on port_id",
8202 (void *)&cmd_vf_mac_addr_cmd,
8203 (void *)&cmd_vf_mac_addr_what,
8204 (void *)&cmd_vf_mac_addr_port,
8205 (void *)&cmd_vf_mac_addr_portnum,
8206 (void *)&cmd_vf_mac_addr_vf,
8207 (void *)&cmd_vf_mac_addr_vfnum,
8208 (void *)&cmd_vf_mac_addr_addr,
8213 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8214 struct cmd_vf_rx_vlan_filter {
8215 cmdline_fixed_string_t rx_vlan;
8216 cmdline_fixed_string_t what;
8218 cmdline_fixed_string_t port;
8220 cmdline_fixed_string_t vf;
8225 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8226 __attribute__((unused)) struct cmdline *cl,
8227 __attribute__((unused)) void *data)
8229 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8232 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8234 #ifdef RTE_LIBRTE_IXGBE_PMD
8235 if (ret == -ENOTSUP)
8236 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8237 res->vlan_id, res->vf_mask, is_add);
8239 #ifdef RTE_LIBRTE_I40E_PMD
8240 if (ret == -ENOTSUP)
8241 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8242 res->vlan_id, res->vf_mask, is_add);
8244 #ifdef RTE_LIBRTE_BNXT_PMD
8245 if (ret == -ENOTSUP)
8246 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8247 res->vlan_id, res->vf_mask, is_add);
8254 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8255 res->vlan_id, res->vf_mask);
8258 printf("invalid port_id %d\n", res->port_id);
8261 printf("function not implemented or supported\n");
8264 printf("programming error: (%s)\n", strerror(-ret));
8268 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8269 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8270 rx_vlan, "rx_vlan");
8271 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8272 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8274 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8275 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8277 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8278 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8280 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8281 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8283 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8284 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8286 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8287 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8290 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8291 .f = cmd_vf_rx_vlan_filter_parsed,
8293 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8294 "(vf_mask = hexadecimal VF mask)",
8296 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8297 (void *)&cmd_vf_rx_vlan_filter_what,
8298 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8299 (void *)&cmd_vf_rx_vlan_filter_port,
8300 (void *)&cmd_vf_rx_vlan_filter_portid,
8301 (void *)&cmd_vf_rx_vlan_filter_vf,
8302 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8307 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8308 struct cmd_queue_rate_limit_result {
8309 cmdline_fixed_string_t set;
8310 cmdline_fixed_string_t port;
8312 cmdline_fixed_string_t queue;
8314 cmdline_fixed_string_t rate;
8318 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8319 __attribute__((unused)) struct cmdline *cl,
8320 __attribute__((unused)) void *data)
8322 struct cmd_queue_rate_limit_result *res = parsed_result;
8325 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8326 && (strcmp(res->queue, "queue") == 0)
8327 && (strcmp(res->rate, "rate") == 0))
8328 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8331 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8335 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8336 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8338 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8339 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8341 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8342 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8344 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8345 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8347 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8348 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8350 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8351 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8353 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8354 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8357 cmdline_parse_inst_t cmd_queue_rate_limit = {
8358 .f = cmd_queue_rate_limit_parsed,
8360 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8361 "Set rate limit for a queue on port_id",
8363 (void *)&cmd_queue_rate_limit_set,
8364 (void *)&cmd_queue_rate_limit_port,
8365 (void *)&cmd_queue_rate_limit_portnum,
8366 (void *)&cmd_queue_rate_limit_queue,
8367 (void *)&cmd_queue_rate_limit_queuenum,
8368 (void *)&cmd_queue_rate_limit_rate,
8369 (void *)&cmd_queue_rate_limit_ratenum,
8374 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8375 struct cmd_vf_rate_limit_result {
8376 cmdline_fixed_string_t set;
8377 cmdline_fixed_string_t port;
8379 cmdline_fixed_string_t vf;
8381 cmdline_fixed_string_t rate;
8383 cmdline_fixed_string_t q_msk;
8387 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8388 __attribute__((unused)) struct cmdline *cl,
8389 __attribute__((unused)) void *data)
8391 struct cmd_vf_rate_limit_result *res = parsed_result;
8394 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8395 && (strcmp(res->vf, "vf") == 0)
8396 && (strcmp(res->rate, "rate") == 0)
8397 && (strcmp(res->q_msk, "queue_mask") == 0))
8398 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8399 res->rate_num, res->q_msk_val);
8401 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8405 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8406 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8408 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8409 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8411 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8412 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8414 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8415 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8417 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8418 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8420 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8421 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8423 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8424 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8426 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8427 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8428 q_msk, "queue_mask");
8429 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8430 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8433 cmdline_parse_inst_t cmd_vf_rate_limit = {
8434 .f = cmd_vf_rate_limit_parsed,
8436 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8437 "queue_mask <queue_mask_value>: "
8438 "Set rate limit for queues of VF on port_id",
8440 (void *)&cmd_vf_rate_limit_set,
8441 (void *)&cmd_vf_rate_limit_port,
8442 (void *)&cmd_vf_rate_limit_portnum,
8443 (void *)&cmd_vf_rate_limit_vf,
8444 (void *)&cmd_vf_rate_limit_vfnum,
8445 (void *)&cmd_vf_rate_limit_rate,
8446 (void *)&cmd_vf_rate_limit_ratenum,
8447 (void *)&cmd_vf_rate_limit_q_msk,
8448 (void *)&cmd_vf_rate_limit_q_msk_val,
8453 /* *** ADD TUNNEL FILTER OF A PORT *** */
8454 struct cmd_tunnel_filter_result {
8455 cmdline_fixed_string_t cmd;
8456 cmdline_fixed_string_t what;
8458 struct ether_addr outer_mac;
8459 struct ether_addr inner_mac;
8460 cmdline_ipaddr_t ip_value;
8461 uint16_t inner_vlan;
8462 cmdline_fixed_string_t tunnel_type;
8463 cmdline_fixed_string_t filter_type;
8469 cmd_tunnel_filter_parsed(void *parsed_result,
8470 __attribute__((unused)) struct cmdline *cl,
8471 __attribute__((unused)) void *data)
8473 struct cmd_tunnel_filter_result *res = parsed_result;
8474 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8477 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8479 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8480 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8481 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8483 if (res->ip_value.family == AF_INET) {
8484 tunnel_filter_conf.ip_addr.ipv4_addr =
8485 res->ip_value.addr.ipv4.s_addr;
8486 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8488 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8489 &(res->ip_value.addr.ipv6),
8490 sizeof(struct in6_addr));
8491 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8494 if (!strcmp(res->filter_type, "imac-ivlan"))
8495 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8496 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8497 tunnel_filter_conf.filter_type =
8498 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8499 else if (!strcmp(res->filter_type, "imac-tenid"))
8500 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8501 else if (!strcmp(res->filter_type, "imac"))
8502 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8503 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8504 tunnel_filter_conf.filter_type =
8505 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8506 else if (!strcmp(res->filter_type, "oip"))
8507 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8508 else if (!strcmp(res->filter_type, "iip"))
8509 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8511 printf("The filter type is not supported");
8515 if (!strcmp(res->tunnel_type, "vxlan"))
8516 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8517 else if (!strcmp(res->tunnel_type, "nvgre"))
8518 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8519 else if (!strcmp(res->tunnel_type, "ipingre"))
8520 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8522 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8526 tunnel_filter_conf.tenant_id = res->tenant_id;
8527 tunnel_filter_conf.queue_id = res->queue_num;
8528 if (!strcmp(res->what, "add"))
8529 ret = rte_eth_dev_filter_ctrl(res->port_id,
8530 RTE_ETH_FILTER_TUNNEL,
8532 &tunnel_filter_conf);
8534 ret = rte_eth_dev_filter_ctrl(res->port_id,
8535 RTE_ETH_FILTER_TUNNEL,
8536 RTE_ETH_FILTER_DELETE,
8537 &tunnel_filter_conf);
8539 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8543 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8544 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8545 cmd, "tunnel_filter");
8546 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8547 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8549 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8550 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8552 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8553 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8555 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8556 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8558 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8559 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8560 inner_vlan, UINT16);
8561 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8562 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8564 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8565 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8566 tunnel_type, "vxlan#nvgre#ipingre");
8568 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8569 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8570 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8571 "imac#omac-imac-tenid");
8572 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8573 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8575 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8576 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8579 cmdline_parse_inst_t cmd_tunnel_filter = {
8580 .f = cmd_tunnel_filter_parsed,
8582 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8583 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8584 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8585 "<queue_id>: Add/Rm tunnel filter of a port",
8587 (void *)&cmd_tunnel_filter_cmd,
8588 (void *)&cmd_tunnel_filter_what,
8589 (void *)&cmd_tunnel_filter_port_id,
8590 (void *)&cmd_tunnel_filter_outer_mac,
8591 (void *)&cmd_tunnel_filter_inner_mac,
8592 (void *)&cmd_tunnel_filter_ip_value,
8593 (void *)&cmd_tunnel_filter_innner_vlan,
8594 (void *)&cmd_tunnel_filter_tunnel_type,
8595 (void *)&cmd_tunnel_filter_filter_type,
8596 (void *)&cmd_tunnel_filter_tenant_id,
8597 (void *)&cmd_tunnel_filter_queue_num,
8602 /* *** CONFIGURE TUNNEL UDP PORT *** */
8603 struct cmd_tunnel_udp_config {
8604 cmdline_fixed_string_t cmd;
8605 cmdline_fixed_string_t what;
8611 cmd_tunnel_udp_config_parsed(void *parsed_result,
8612 __attribute__((unused)) struct cmdline *cl,
8613 __attribute__((unused)) void *data)
8615 struct cmd_tunnel_udp_config *res = parsed_result;
8616 struct rte_eth_udp_tunnel tunnel_udp;
8619 tunnel_udp.udp_port = res->udp_port;
8621 if (!strcmp(res->cmd, "rx_vxlan_port"))
8622 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8624 if (!strcmp(res->what, "add"))
8625 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8628 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8632 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8635 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8636 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8637 cmd, "rx_vxlan_port");
8638 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8639 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8641 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8642 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8644 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8645 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8648 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8649 .f = cmd_tunnel_udp_config_parsed,
8651 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8652 "Add/Remove a tunneling UDP port filter",
8654 (void *)&cmd_tunnel_udp_config_cmd,
8655 (void *)&cmd_tunnel_udp_config_what,
8656 (void *)&cmd_tunnel_udp_config_udp_port,
8657 (void *)&cmd_tunnel_udp_config_port_id,
8662 struct cmd_config_tunnel_udp_port {
8663 cmdline_fixed_string_t port;
8664 cmdline_fixed_string_t config;
8666 cmdline_fixed_string_t udp_tunnel_port;
8667 cmdline_fixed_string_t action;
8668 cmdline_fixed_string_t tunnel_type;
8673 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8674 __attribute__((unused)) struct cmdline *cl,
8675 __attribute__((unused)) void *data)
8677 struct cmd_config_tunnel_udp_port *res = parsed_result;
8678 struct rte_eth_udp_tunnel tunnel_udp;
8681 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8684 tunnel_udp.udp_port = res->udp_port;
8686 if (!strcmp(res->tunnel_type, "vxlan")) {
8687 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8688 } else if (!strcmp(res->tunnel_type, "geneve")) {
8689 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8691 printf("Invalid tunnel type\n");
8695 if (!strcmp(res->action, "add"))
8696 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8699 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8703 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8706 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8707 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8709 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8710 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8712 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8713 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8715 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8716 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8719 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8720 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8722 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8723 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8725 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8726 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8729 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8730 .f = cmd_cfg_tunnel_udp_port_parsed,
8732 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8734 (void *)&cmd_config_tunnel_udp_port_port,
8735 (void *)&cmd_config_tunnel_udp_port_config,
8736 (void *)&cmd_config_tunnel_udp_port_port_id,
8737 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8738 (void *)&cmd_config_tunnel_udp_port_action,
8739 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8740 (void *)&cmd_config_tunnel_udp_port_value,
8745 /* *** GLOBAL CONFIG *** */
8746 struct cmd_global_config_result {
8747 cmdline_fixed_string_t cmd;
8749 cmdline_fixed_string_t cfg_type;
8754 cmd_global_config_parsed(void *parsed_result,
8755 __attribute__((unused)) struct cmdline *cl,
8756 __attribute__((unused)) void *data)
8758 struct cmd_global_config_result *res = parsed_result;
8759 struct rte_eth_global_cfg conf;
8762 memset(&conf, 0, sizeof(conf));
8763 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8764 conf.cfg.gre_key_len = res->len;
8765 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8766 RTE_ETH_FILTER_SET, &conf);
8768 printf("Global config error\n");
8771 cmdline_parse_token_string_t cmd_global_config_cmd =
8772 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8774 cmdline_parse_token_num_t cmd_global_config_port_id =
8775 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8777 cmdline_parse_token_string_t cmd_global_config_type =
8778 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8779 cfg_type, "gre-key-len");
8780 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8781 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8784 cmdline_parse_inst_t cmd_global_config = {
8785 .f = cmd_global_config_parsed,
8786 .data = (void *)NULL,
8787 .help_str = "global_config <port_id> gre-key-len <key_len>",
8789 (void *)&cmd_global_config_cmd,
8790 (void *)&cmd_global_config_port_id,
8791 (void *)&cmd_global_config_type,
8792 (void *)&cmd_global_config_gre_key_len,
8797 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8798 struct cmd_set_mirror_mask_result {
8799 cmdline_fixed_string_t set;
8800 cmdline_fixed_string_t port;
8802 cmdline_fixed_string_t mirror;
8804 cmdline_fixed_string_t what;
8805 cmdline_fixed_string_t value;
8806 cmdline_fixed_string_t dstpool;
8808 cmdline_fixed_string_t on;
8811 cmdline_parse_token_string_t cmd_mirror_mask_set =
8812 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8814 cmdline_parse_token_string_t cmd_mirror_mask_port =
8815 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8817 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8818 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8820 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8821 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8822 mirror, "mirror-rule");
8823 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8824 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8826 cmdline_parse_token_string_t cmd_mirror_mask_what =
8827 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8828 what, "pool-mirror-up#pool-mirror-down"
8830 cmdline_parse_token_string_t cmd_mirror_mask_value =
8831 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8833 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8834 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8835 dstpool, "dst-pool");
8836 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8837 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8839 cmdline_parse_token_string_t cmd_mirror_mask_on =
8840 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8844 cmd_set_mirror_mask_parsed(void *parsed_result,
8845 __attribute__((unused)) struct cmdline *cl,
8846 __attribute__((unused)) void *data)
8849 struct cmd_set_mirror_mask_result *res = parsed_result;
8850 struct rte_eth_mirror_conf mr_conf;
8852 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8854 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8856 mr_conf.dst_pool = res->dstpool_id;
8858 if (!strcmp(res->what, "pool-mirror-up")) {
8859 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8860 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8861 } else if (!strcmp(res->what, "pool-mirror-down")) {
8862 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8863 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8864 } else if (!strcmp(res->what, "vlan-mirror")) {
8865 mr_conf.rule_type = ETH_MIRROR_VLAN;
8866 nb_item = parse_item_list(res->value, "vlan",
8867 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8871 for (i = 0; i < nb_item; i++) {
8872 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8873 printf("Invalid vlan_id: must be < 4096\n");
8877 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8878 mr_conf.vlan.vlan_mask |= 1ULL << i;
8882 if (!strcmp(res->on, "on"))
8883 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8886 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8889 printf("mirror rule add error: (%s)\n", strerror(-ret));
8892 cmdline_parse_inst_t cmd_set_mirror_mask = {
8893 .f = cmd_set_mirror_mask_parsed,
8895 .help_str = "set port <port_id> mirror-rule <rule_id> "
8896 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8897 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8899 (void *)&cmd_mirror_mask_set,
8900 (void *)&cmd_mirror_mask_port,
8901 (void *)&cmd_mirror_mask_portid,
8902 (void *)&cmd_mirror_mask_mirror,
8903 (void *)&cmd_mirror_mask_ruleid,
8904 (void *)&cmd_mirror_mask_what,
8905 (void *)&cmd_mirror_mask_value,
8906 (void *)&cmd_mirror_mask_dstpool,
8907 (void *)&cmd_mirror_mask_poolid,
8908 (void *)&cmd_mirror_mask_on,
8913 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8914 struct cmd_set_mirror_link_result {
8915 cmdline_fixed_string_t set;
8916 cmdline_fixed_string_t port;
8918 cmdline_fixed_string_t mirror;
8920 cmdline_fixed_string_t what;
8921 cmdline_fixed_string_t dstpool;
8923 cmdline_fixed_string_t on;
8926 cmdline_parse_token_string_t cmd_mirror_link_set =
8927 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8929 cmdline_parse_token_string_t cmd_mirror_link_port =
8930 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8932 cmdline_parse_token_num_t cmd_mirror_link_portid =
8933 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8935 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8936 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8937 mirror, "mirror-rule");
8938 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8939 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8941 cmdline_parse_token_string_t cmd_mirror_link_what =
8942 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8943 what, "uplink-mirror#downlink-mirror");
8944 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8945 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8946 dstpool, "dst-pool");
8947 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8948 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8950 cmdline_parse_token_string_t cmd_mirror_link_on =
8951 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8955 cmd_set_mirror_link_parsed(void *parsed_result,
8956 __attribute__((unused)) struct cmdline *cl,
8957 __attribute__((unused)) void *data)
8960 struct cmd_set_mirror_link_result *res = parsed_result;
8961 struct rte_eth_mirror_conf mr_conf;
8963 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8964 if (!strcmp(res->what, "uplink-mirror"))
8965 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8967 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8969 mr_conf.dst_pool = res->dstpool_id;
8971 if (!strcmp(res->on, "on"))
8972 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8975 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8978 /* check the return value and print it if is < 0 */
8980 printf("mirror rule add error: (%s)\n", strerror(-ret));
8984 cmdline_parse_inst_t cmd_set_mirror_link = {
8985 .f = cmd_set_mirror_link_parsed,
8987 .help_str = "set port <port_id> mirror-rule <rule_id> "
8988 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8990 (void *)&cmd_mirror_link_set,
8991 (void *)&cmd_mirror_link_port,
8992 (void *)&cmd_mirror_link_portid,
8993 (void *)&cmd_mirror_link_mirror,
8994 (void *)&cmd_mirror_link_ruleid,
8995 (void *)&cmd_mirror_link_what,
8996 (void *)&cmd_mirror_link_dstpool,
8997 (void *)&cmd_mirror_link_poolid,
8998 (void *)&cmd_mirror_link_on,
9003 /* *** RESET VM MIRROR RULE *** */
9004 struct cmd_rm_mirror_rule_result {
9005 cmdline_fixed_string_t reset;
9006 cmdline_fixed_string_t port;
9008 cmdline_fixed_string_t mirror;
9012 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9013 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9015 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9016 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9018 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9019 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9021 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9022 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9023 mirror, "mirror-rule");
9024 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9025 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9029 cmd_reset_mirror_rule_parsed(void *parsed_result,
9030 __attribute__((unused)) struct cmdline *cl,
9031 __attribute__((unused)) void *data)
9034 struct cmd_set_mirror_link_result *res = parsed_result;
9036 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9038 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9041 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9042 .f = cmd_reset_mirror_rule_parsed,
9044 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9046 (void *)&cmd_rm_mirror_rule_reset,
9047 (void *)&cmd_rm_mirror_rule_port,
9048 (void *)&cmd_rm_mirror_rule_portid,
9049 (void *)&cmd_rm_mirror_rule_mirror,
9050 (void *)&cmd_rm_mirror_rule_ruleid,
9055 /* ******************************************************************************** */
9057 struct cmd_dump_result {
9058 cmdline_fixed_string_t dump;
9062 dump_struct_sizes(void)
9064 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9065 DUMP_SIZE(struct rte_mbuf);
9066 DUMP_SIZE(struct rte_mempool);
9067 DUMP_SIZE(struct rte_ring);
9071 static void cmd_dump_parsed(void *parsed_result,
9072 __attribute__((unused)) struct cmdline *cl,
9073 __attribute__((unused)) void *data)
9075 struct cmd_dump_result *res = parsed_result;
9077 if (!strcmp(res->dump, "dump_physmem"))
9078 rte_dump_physmem_layout(stdout);
9079 else if (!strcmp(res->dump, "dump_memzone"))
9080 rte_memzone_dump(stdout);
9081 else if (!strcmp(res->dump, "dump_struct_sizes"))
9082 dump_struct_sizes();
9083 else if (!strcmp(res->dump, "dump_ring"))
9084 rte_ring_list_dump(stdout);
9085 else if (!strcmp(res->dump, "dump_mempool"))
9086 rte_mempool_list_dump(stdout);
9087 else if (!strcmp(res->dump, "dump_devargs"))
9088 rte_devargs_dump(stdout);
9089 else if (!strcmp(res->dump, "dump_log_types"))
9090 rte_log_dump(stdout);
9093 cmdline_parse_token_string_t cmd_dump_dump =
9094 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9097 "dump_struct_sizes#"
9103 cmdline_parse_inst_t cmd_dump = {
9104 .f = cmd_dump_parsed, /* function to call */
9105 .data = NULL, /* 2nd arg of func */
9106 .help_str = "Dump status",
9107 .tokens = { /* token list, NULL terminated */
9108 (void *)&cmd_dump_dump,
9113 /* ******************************************************************************** */
9115 struct cmd_dump_one_result {
9116 cmdline_fixed_string_t dump;
9117 cmdline_fixed_string_t name;
9120 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9121 __attribute__((unused)) void *data)
9123 struct cmd_dump_one_result *res = parsed_result;
9125 if (!strcmp(res->dump, "dump_ring")) {
9127 r = rte_ring_lookup(res->name);
9129 cmdline_printf(cl, "Cannot find ring\n");
9132 rte_ring_dump(stdout, r);
9133 } else if (!strcmp(res->dump, "dump_mempool")) {
9134 struct rte_mempool *mp;
9135 mp = rte_mempool_lookup(res->name);
9137 cmdline_printf(cl, "Cannot find mempool\n");
9140 rte_mempool_dump(stdout, mp);
9144 cmdline_parse_token_string_t cmd_dump_one_dump =
9145 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9146 "dump_ring#dump_mempool");
9148 cmdline_parse_token_string_t cmd_dump_one_name =
9149 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9151 cmdline_parse_inst_t cmd_dump_one = {
9152 .f = cmd_dump_one_parsed, /* function to call */
9153 .data = NULL, /* 2nd arg of func */
9154 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9155 .tokens = { /* token list, NULL terminated */
9156 (void *)&cmd_dump_one_dump,
9157 (void *)&cmd_dump_one_name,
9162 /* *** Add/Del syn filter *** */
9163 struct cmd_syn_filter_result {
9164 cmdline_fixed_string_t filter;
9166 cmdline_fixed_string_t ops;
9167 cmdline_fixed_string_t priority;
9168 cmdline_fixed_string_t high;
9169 cmdline_fixed_string_t queue;
9174 cmd_syn_filter_parsed(void *parsed_result,
9175 __attribute__((unused)) struct cmdline *cl,
9176 __attribute__((unused)) void *data)
9178 struct cmd_syn_filter_result *res = parsed_result;
9179 struct rte_eth_syn_filter syn_filter;
9182 ret = rte_eth_dev_filter_supported(res->port_id,
9183 RTE_ETH_FILTER_SYN);
9185 printf("syn filter is not supported on port %u.\n",
9190 memset(&syn_filter, 0, sizeof(syn_filter));
9192 if (!strcmp(res->ops, "add")) {
9193 if (!strcmp(res->high, "high"))
9194 syn_filter.hig_pri = 1;
9196 syn_filter.hig_pri = 0;
9198 syn_filter.queue = res->queue_id;
9199 ret = rte_eth_dev_filter_ctrl(res->port_id,
9204 ret = rte_eth_dev_filter_ctrl(res->port_id,
9206 RTE_ETH_FILTER_DELETE,
9210 printf("syn filter programming error: (%s)\n",
9214 cmdline_parse_token_string_t cmd_syn_filter_filter =
9215 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9216 filter, "syn_filter");
9217 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9218 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9220 cmdline_parse_token_string_t cmd_syn_filter_ops =
9221 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9223 cmdline_parse_token_string_t cmd_syn_filter_priority =
9224 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9225 priority, "priority");
9226 cmdline_parse_token_string_t cmd_syn_filter_high =
9227 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9229 cmdline_parse_token_string_t cmd_syn_filter_queue =
9230 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9232 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9233 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9236 cmdline_parse_inst_t cmd_syn_filter = {
9237 .f = cmd_syn_filter_parsed,
9239 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9240 "<queue_id>: Add/Delete syn filter",
9242 (void *)&cmd_syn_filter_filter,
9243 (void *)&cmd_syn_filter_port_id,
9244 (void *)&cmd_syn_filter_ops,
9245 (void *)&cmd_syn_filter_priority,
9246 (void *)&cmd_syn_filter_high,
9247 (void *)&cmd_syn_filter_queue,
9248 (void *)&cmd_syn_filter_queue_id,
9253 /* *** queue region set *** */
9254 struct cmd_queue_region_result {
9255 cmdline_fixed_string_t set;
9256 cmdline_fixed_string_t port;
9258 cmdline_fixed_string_t cmd;
9259 cmdline_fixed_string_t region;
9261 cmdline_fixed_string_t queue_start_index;
9263 cmdline_fixed_string_t queue_num;
9264 uint8_t queue_num_value;
9268 cmd_queue_region_parsed(void *parsed_result,
9269 __attribute__((unused)) struct cmdline *cl,
9270 __attribute__((unused)) void *data)
9272 struct cmd_queue_region_result *res = parsed_result;
9274 #ifdef RTE_LIBRTE_I40E_PMD
9275 struct rte_pmd_i40e_queue_region_conf region_conf;
9276 enum rte_pmd_i40e_queue_region_op op_type;
9279 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9282 #ifdef RTE_LIBRTE_I40E_PMD
9283 memset(®ion_conf, 0, sizeof(region_conf));
9284 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9285 region_conf.region_id = res->region_id;
9286 region_conf.queue_num = res->queue_num_value;
9287 region_conf.queue_start_index = res->queue_id;
9289 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9290 op_type, ®ion_conf);
9297 printf("function not implemented or supported\n");
9300 printf("queue region config error: (%s)\n", strerror(-ret));
9304 cmdline_parse_token_string_t cmd_queue_region_set =
9305 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9307 cmdline_parse_token_string_t cmd_queue_region_port =
9308 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9309 cmdline_parse_token_num_t cmd_queue_region_port_id =
9310 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9312 cmdline_parse_token_string_t cmd_queue_region_cmd =
9313 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9314 cmd, "queue-region");
9315 cmdline_parse_token_string_t cmd_queue_region_id =
9316 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9317 region, "region_id");
9318 cmdline_parse_token_num_t cmd_queue_region_index =
9319 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9321 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9322 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9323 queue_start_index, "queue_start_index");
9324 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9325 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9327 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9328 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9329 queue_num, "queue_num");
9330 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9331 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9332 queue_num_value, UINT8);
9334 cmdline_parse_inst_t cmd_queue_region = {
9335 .f = cmd_queue_region_parsed,
9337 .help_str = "set port <port_id> queue-region region_id <value> "
9338 "queue_start_index <value> queue_num <value>: Set a queue region",
9340 (void *)&cmd_queue_region_set,
9341 (void *)&cmd_queue_region_port,
9342 (void *)&cmd_queue_region_port_id,
9343 (void *)&cmd_queue_region_cmd,
9344 (void *)&cmd_queue_region_id,
9345 (void *)&cmd_queue_region_index,
9346 (void *)&cmd_queue_region_queue_start_index,
9347 (void *)&cmd_queue_region_queue_id,
9348 (void *)&cmd_queue_region_queue_num,
9349 (void *)&cmd_queue_region_queue_num_value,
9354 /* *** queue region and flowtype set *** */
9355 struct cmd_region_flowtype_result {
9356 cmdline_fixed_string_t set;
9357 cmdline_fixed_string_t port;
9359 cmdline_fixed_string_t cmd;
9360 cmdline_fixed_string_t region;
9362 cmdline_fixed_string_t flowtype;
9363 uint8_t flowtype_id;
9367 cmd_region_flowtype_parsed(void *parsed_result,
9368 __attribute__((unused)) struct cmdline *cl,
9369 __attribute__((unused)) void *data)
9371 struct cmd_region_flowtype_result *res = parsed_result;
9373 #ifdef RTE_LIBRTE_I40E_PMD
9374 struct rte_pmd_i40e_queue_region_conf region_conf;
9375 enum rte_pmd_i40e_queue_region_op op_type;
9378 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9381 #ifdef RTE_LIBRTE_I40E_PMD
9382 memset(®ion_conf, 0, sizeof(region_conf));
9384 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9385 region_conf.region_id = res->region_id;
9386 region_conf.hw_flowtype = res->flowtype_id;
9388 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9389 op_type, ®ion_conf);
9396 printf("function not implemented or supported\n");
9399 printf("region flowtype config error: (%s)\n", strerror(-ret));
9403 cmdline_parse_token_string_t cmd_region_flowtype_set =
9404 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9406 cmdline_parse_token_string_t cmd_region_flowtype_port =
9407 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9409 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9410 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9412 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9413 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9414 cmd, "queue-region");
9415 cmdline_parse_token_string_t cmd_region_flowtype_index =
9416 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9417 region, "region_id");
9418 cmdline_parse_token_num_t cmd_region_flowtype_id =
9419 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9421 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9422 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9423 flowtype, "flowtype");
9424 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9425 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9426 flowtype_id, UINT8);
9427 cmdline_parse_inst_t cmd_region_flowtype = {
9428 .f = cmd_region_flowtype_parsed,
9430 .help_str = "set port <port_id> queue-region region_id <value> "
9431 "flowtype <value>: Set a flowtype region index",
9433 (void *)&cmd_region_flowtype_set,
9434 (void *)&cmd_region_flowtype_port,
9435 (void *)&cmd_region_flowtype_port_index,
9436 (void *)&cmd_region_flowtype_cmd,
9437 (void *)&cmd_region_flowtype_index,
9438 (void *)&cmd_region_flowtype_id,
9439 (void *)&cmd_region_flowtype_flow_index,
9440 (void *)&cmd_region_flowtype_flow_id,
9445 /* *** User Priority (UP) to queue region (region_id) set *** */
9446 struct cmd_user_priority_region_result {
9447 cmdline_fixed_string_t set;
9448 cmdline_fixed_string_t port;
9450 cmdline_fixed_string_t cmd;
9451 cmdline_fixed_string_t user_priority;
9452 uint8_t user_priority_id;
9453 cmdline_fixed_string_t region;
9458 cmd_user_priority_region_parsed(void *parsed_result,
9459 __attribute__((unused)) struct cmdline *cl,
9460 __attribute__((unused)) void *data)
9462 struct cmd_user_priority_region_result *res = parsed_result;
9464 #ifdef RTE_LIBRTE_I40E_PMD
9465 struct rte_pmd_i40e_queue_region_conf region_conf;
9466 enum rte_pmd_i40e_queue_region_op op_type;
9469 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9472 #ifdef RTE_LIBRTE_I40E_PMD
9473 memset(®ion_conf, 0, sizeof(region_conf));
9474 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9475 region_conf.user_priority = res->user_priority_id;
9476 region_conf.region_id = res->region_id;
9478 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9479 op_type, ®ion_conf);
9486 printf("function not implemented or supported\n");
9489 printf("user_priority region config error: (%s)\n",
9494 cmdline_parse_token_string_t cmd_user_priority_region_set =
9495 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9497 cmdline_parse_token_string_t cmd_user_priority_region_port =
9498 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9500 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9501 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9503 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9504 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9505 cmd, "queue-region");
9506 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9507 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9508 user_priority, "UP");
9509 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9510 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9511 user_priority_id, UINT8);
9512 cmdline_parse_token_string_t cmd_user_priority_region_region =
9513 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9514 region, "region_id");
9515 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9516 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9519 cmdline_parse_inst_t cmd_user_priority_region = {
9520 .f = cmd_user_priority_region_parsed,
9522 .help_str = "set port <port_id> queue-region UP <value> "
9523 "region_id <value>: Set the mapping of User Priority (UP) "
9524 "to queue region (region_id) ",
9526 (void *)&cmd_user_priority_region_set,
9527 (void *)&cmd_user_priority_region_port,
9528 (void *)&cmd_user_priority_region_port_index,
9529 (void *)&cmd_user_priority_region_cmd,
9530 (void *)&cmd_user_priority_region_UP,
9531 (void *)&cmd_user_priority_region_UP_id,
9532 (void *)&cmd_user_priority_region_region,
9533 (void *)&cmd_user_priority_region_region_id,
9538 /* *** flush all queue region related configuration *** */
9539 struct cmd_flush_queue_region_result {
9540 cmdline_fixed_string_t set;
9541 cmdline_fixed_string_t port;
9543 cmdline_fixed_string_t cmd;
9544 cmdline_fixed_string_t flush;
9545 cmdline_fixed_string_t what;
9549 cmd_flush_queue_region_parsed(void *parsed_result,
9550 __attribute__((unused)) struct cmdline *cl,
9551 __attribute__((unused)) void *data)
9553 struct cmd_flush_queue_region_result *res = parsed_result;
9555 #ifdef RTE_LIBRTE_I40E_PMD
9556 struct rte_pmd_i40e_queue_region_conf region_conf;
9557 enum rte_pmd_i40e_queue_region_op op_type;
9560 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9563 #ifdef RTE_LIBRTE_I40E_PMD
9564 memset(®ion_conf, 0, sizeof(region_conf));
9566 if (strcmp(res->what, "on") == 0)
9567 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9569 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9571 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9572 op_type, ®ion_conf);
9579 printf("function not implemented or supported\n");
9582 printf("queue region config flush error: (%s)\n",
9587 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9588 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9590 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9591 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9593 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9594 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9596 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9597 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9598 cmd, "queue-region");
9599 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9600 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9602 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9603 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9606 cmdline_parse_inst_t cmd_flush_queue_region = {
9607 .f = cmd_flush_queue_region_parsed,
9609 .help_str = "set port <port_id> queue-region flush on|off"
9610 ": flush all queue region related configuration",
9612 (void *)&cmd_flush_queue_region_set,
9613 (void *)&cmd_flush_queue_region_port,
9614 (void *)&cmd_flush_queue_region_port_index,
9615 (void *)&cmd_flush_queue_region_cmd,
9616 (void *)&cmd_flush_queue_region_flush,
9617 (void *)&cmd_flush_queue_region_what,
9622 /* *** get all queue region related configuration info *** */
9623 struct cmd_show_queue_region_info {
9624 cmdline_fixed_string_t show;
9625 cmdline_fixed_string_t port;
9627 cmdline_fixed_string_t cmd;
9631 cmd_show_queue_region_info_parsed(void *parsed_result,
9632 __attribute__((unused)) struct cmdline *cl,
9633 __attribute__((unused)) void *data)
9635 struct cmd_show_queue_region_info *res = parsed_result;
9637 #ifdef RTE_LIBRTE_I40E_PMD
9638 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9639 enum rte_pmd_i40e_queue_region_op op_type;
9642 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9645 #ifdef RTE_LIBRTE_I40E_PMD
9646 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9648 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9650 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9651 op_type, &rte_pmd_regions);
9653 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9660 printf("function not implemented or supported\n");
9663 printf("queue region config info show error: (%s)\n",
9668 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9669 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9671 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9672 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9674 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9675 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9677 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9678 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9679 cmd, "queue-region");
9681 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9682 .f = cmd_show_queue_region_info_parsed,
9684 .help_str = "show port <port_id> queue-region"
9685 ": show all queue region related configuration info",
9687 (void *)&cmd_show_queue_region_info_get,
9688 (void *)&cmd_show_queue_region_info_port,
9689 (void *)&cmd_show_queue_region_info_port_index,
9690 (void *)&cmd_show_queue_region_info_cmd,
9695 /* *** ADD/REMOVE A 2tuple FILTER *** */
9696 struct cmd_2tuple_filter_result {
9697 cmdline_fixed_string_t filter;
9699 cmdline_fixed_string_t ops;
9700 cmdline_fixed_string_t dst_port;
9701 uint16_t dst_port_value;
9702 cmdline_fixed_string_t protocol;
9703 uint8_t protocol_value;
9704 cmdline_fixed_string_t mask;
9706 cmdline_fixed_string_t tcp_flags;
9707 uint8_t tcp_flags_value;
9708 cmdline_fixed_string_t priority;
9709 uint8_t priority_value;
9710 cmdline_fixed_string_t queue;
9715 cmd_2tuple_filter_parsed(void *parsed_result,
9716 __attribute__((unused)) struct cmdline *cl,
9717 __attribute__((unused)) void *data)
9719 struct rte_eth_ntuple_filter filter;
9720 struct cmd_2tuple_filter_result *res = parsed_result;
9723 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9725 printf("ntuple filter is not supported on port %u.\n",
9730 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9732 filter.flags = RTE_2TUPLE_FLAGS;
9733 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9734 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9735 filter.proto = res->protocol_value;
9736 filter.priority = res->priority_value;
9737 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9738 printf("nonzero tcp_flags is only meaningful"
9739 " when protocol is TCP.\n");
9742 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9743 printf("invalid TCP flags.\n");
9747 if (res->tcp_flags_value != 0) {
9748 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9749 filter.tcp_flags = res->tcp_flags_value;
9752 /* need convert to big endian. */
9753 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9754 filter.queue = res->queue_id;
9756 if (!strcmp(res->ops, "add"))
9757 ret = rte_eth_dev_filter_ctrl(res->port_id,
9758 RTE_ETH_FILTER_NTUPLE,
9762 ret = rte_eth_dev_filter_ctrl(res->port_id,
9763 RTE_ETH_FILTER_NTUPLE,
9764 RTE_ETH_FILTER_DELETE,
9767 printf("2tuple filter programming error: (%s)\n",
9772 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9773 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9774 filter, "2tuple_filter");
9775 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9776 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9778 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9779 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9781 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9782 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9783 dst_port, "dst_port");
9784 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9785 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9786 dst_port_value, UINT16);
9787 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9788 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9789 protocol, "protocol");
9790 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9791 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9792 protocol_value, UINT8);
9793 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9794 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9796 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9797 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9799 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9800 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9801 tcp_flags, "tcp_flags");
9802 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9803 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9804 tcp_flags_value, UINT8);
9805 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9806 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9807 priority, "priority");
9808 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9809 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9810 priority_value, UINT8);
9811 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9812 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9814 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9815 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9818 cmdline_parse_inst_t cmd_2tuple_filter = {
9819 .f = cmd_2tuple_filter_parsed,
9821 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9822 "<value> mask <value> tcp_flags <value> priority <value> queue "
9823 "<queue_id>: Add a 2tuple filter",
9825 (void *)&cmd_2tuple_filter_filter,
9826 (void *)&cmd_2tuple_filter_port_id,
9827 (void *)&cmd_2tuple_filter_ops,
9828 (void *)&cmd_2tuple_filter_dst_port,
9829 (void *)&cmd_2tuple_filter_dst_port_value,
9830 (void *)&cmd_2tuple_filter_protocol,
9831 (void *)&cmd_2tuple_filter_protocol_value,
9832 (void *)&cmd_2tuple_filter_mask,
9833 (void *)&cmd_2tuple_filter_mask_value,
9834 (void *)&cmd_2tuple_filter_tcp_flags,
9835 (void *)&cmd_2tuple_filter_tcp_flags_value,
9836 (void *)&cmd_2tuple_filter_priority,
9837 (void *)&cmd_2tuple_filter_priority_value,
9838 (void *)&cmd_2tuple_filter_queue,
9839 (void *)&cmd_2tuple_filter_queue_id,
9844 /* *** ADD/REMOVE A 5tuple FILTER *** */
9845 struct cmd_5tuple_filter_result {
9846 cmdline_fixed_string_t filter;
9848 cmdline_fixed_string_t ops;
9849 cmdline_fixed_string_t dst_ip;
9850 cmdline_ipaddr_t dst_ip_value;
9851 cmdline_fixed_string_t src_ip;
9852 cmdline_ipaddr_t src_ip_value;
9853 cmdline_fixed_string_t dst_port;
9854 uint16_t dst_port_value;
9855 cmdline_fixed_string_t src_port;
9856 uint16_t src_port_value;
9857 cmdline_fixed_string_t protocol;
9858 uint8_t protocol_value;
9859 cmdline_fixed_string_t mask;
9861 cmdline_fixed_string_t tcp_flags;
9862 uint8_t tcp_flags_value;
9863 cmdline_fixed_string_t priority;
9864 uint8_t priority_value;
9865 cmdline_fixed_string_t queue;
9870 cmd_5tuple_filter_parsed(void *parsed_result,
9871 __attribute__((unused)) struct cmdline *cl,
9872 __attribute__((unused)) void *data)
9874 struct rte_eth_ntuple_filter filter;
9875 struct cmd_5tuple_filter_result *res = parsed_result;
9878 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9880 printf("ntuple filter is not supported on port %u.\n",
9885 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9887 filter.flags = RTE_5TUPLE_FLAGS;
9888 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9889 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9890 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9891 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9892 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9893 filter.proto = res->protocol_value;
9894 filter.priority = res->priority_value;
9895 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9896 printf("nonzero tcp_flags is only meaningful"
9897 " when protocol is TCP.\n");
9900 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9901 printf("invalid TCP flags.\n");
9905 if (res->tcp_flags_value != 0) {
9906 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9907 filter.tcp_flags = res->tcp_flags_value;
9910 if (res->dst_ip_value.family == AF_INET)
9911 /* no need to convert, already big endian. */
9912 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9914 if (filter.dst_ip_mask == 0) {
9915 printf("can not support ipv6 involved compare.\n");
9921 if (res->src_ip_value.family == AF_INET)
9922 /* no need to convert, already big endian. */
9923 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9925 if (filter.src_ip_mask == 0) {
9926 printf("can not support ipv6 involved compare.\n");
9931 /* need convert to big endian. */
9932 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9933 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9934 filter.queue = res->queue_id;
9936 if (!strcmp(res->ops, "add"))
9937 ret = rte_eth_dev_filter_ctrl(res->port_id,
9938 RTE_ETH_FILTER_NTUPLE,
9942 ret = rte_eth_dev_filter_ctrl(res->port_id,
9943 RTE_ETH_FILTER_NTUPLE,
9944 RTE_ETH_FILTER_DELETE,
9947 printf("5tuple filter programming error: (%s)\n",
9951 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9952 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9953 filter, "5tuple_filter");
9954 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9955 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9957 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9958 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9960 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9961 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9963 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9964 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9966 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9967 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9969 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9970 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9972 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9973 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9974 dst_port, "dst_port");
9975 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9976 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9977 dst_port_value, UINT16);
9978 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9979 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9980 src_port, "src_port");
9981 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9982 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9983 src_port_value, UINT16);
9984 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9985 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9986 protocol, "protocol");
9987 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9988 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9989 protocol_value, UINT8);
9990 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9991 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9993 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9994 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9996 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9997 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9998 tcp_flags, "tcp_flags");
9999 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10000 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10001 tcp_flags_value, UINT8);
10002 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10003 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10004 priority, "priority");
10005 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10006 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10007 priority_value, UINT8);
10008 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10009 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10011 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10012 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10015 cmdline_parse_inst_t cmd_5tuple_filter = {
10016 .f = cmd_5tuple_filter_parsed,
10018 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10019 "src_ip <value> dst_port <value> src_port <value> "
10020 "protocol <value> mask <value> tcp_flags <value> "
10021 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10023 (void *)&cmd_5tuple_filter_filter,
10024 (void *)&cmd_5tuple_filter_port_id,
10025 (void *)&cmd_5tuple_filter_ops,
10026 (void *)&cmd_5tuple_filter_dst_ip,
10027 (void *)&cmd_5tuple_filter_dst_ip_value,
10028 (void *)&cmd_5tuple_filter_src_ip,
10029 (void *)&cmd_5tuple_filter_src_ip_value,
10030 (void *)&cmd_5tuple_filter_dst_port,
10031 (void *)&cmd_5tuple_filter_dst_port_value,
10032 (void *)&cmd_5tuple_filter_src_port,
10033 (void *)&cmd_5tuple_filter_src_port_value,
10034 (void *)&cmd_5tuple_filter_protocol,
10035 (void *)&cmd_5tuple_filter_protocol_value,
10036 (void *)&cmd_5tuple_filter_mask,
10037 (void *)&cmd_5tuple_filter_mask_value,
10038 (void *)&cmd_5tuple_filter_tcp_flags,
10039 (void *)&cmd_5tuple_filter_tcp_flags_value,
10040 (void *)&cmd_5tuple_filter_priority,
10041 (void *)&cmd_5tuple_filter_priority_value,
10042 (void *)&cmd_5tuple_filter_queue,
10043 (void *)&cmd_5tuple_filter_queue_id,
10048 /* *** ADD/REMOVE A flex FILTER *** */
10049 struct cmd_flex_filter_result {
10050 cmdline_fixed_string_t filter;
10051 cmdline_fixed_string_t ops;
10053 cmdline_fixed_string_t len;
10055 cmdline_fixed_string_t bytes;
10056 cmdline_fixed_string_t bytes_value;
10057 cmdline_fixed_string_t mask;
10058 cmdline_fixed_string_t mask_value;
10059 cmdline_fixed_string_t priority;
10060 uint8_t priority_value;
10061 cmdline_fixed_string_t queue;
10065 static int xdigit2val(unsigned char c)
10070 else if (isupper(c))
10071 val = c - 'A' + 10;
10073 val = c - 'a' + 10;
10078 cmd_flex_filter_parsed(void *parsed_result,
10079 __attribute__((unused)) struct cmdline *cl,
10080 __attribute__((unused)) void *data)
10083 struct rte_eth_flex_filter filter;
10084 struct cmd_flex_filter_result *res = parsed_result;
10085 char *bytes_ptr, *mask_ptr;
10086 uint16_t len, i, j = 0;
10091 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10092 printf("the len exceed the max length 128\n");
10095 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10096 filter.len = res->len_value;
10097 filter.priority = res->priority_value;
10098 filter.queue = res->queue_id;
10099 bytes_ptr = res->bytes_value;
10100 mask_ptr = res->mask_value;
10102 /* translate bytes string to array. */
10103 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10104 (bytes_ptr[1] == 'X')))
10106 len = strnlen(bytes_ptr, res->len_value * 2);
10107 if (len == 0 || (len % 8 != 0)) {
10108 printf("please check len and bytes input\n");
10111 for (i = 0; i < len; i++) {
10113 if (isxdigit(c) == 0) {
10114 /* invalid characters. */
10115 printf("invalid input\n");
10118 val = xdigit2val(c);
10121 filter.bytes[j] = byte;
10122 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10129 /* translate mask string to uint8_t array. */
10130 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10131 (mask_ptr[1] == 'X')))
10133 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10135 printf("invalid input\n");
10140 for (i = 0; i < len; i++) {
10142 if (isxdigit(c) == 0) {
10143 /* invalid characters. */
10144 printf("invalid input\n");
10147 val = xdigit2val(c);
10150 filter.mask[j] = byte;
10151 printf("mask[%d]:%02x ", j, filter.mask[j]);
10159 if (!strcmp(res->ops, "add"))
10160 ret = rte_eth_dev_filter_ctrl(res->port_id,
10161 RTE_ETH_FILTER_FLEXIBLE,
10162 RTE_ETH_FILTER_ADD,
10165 ret = rte_eth_dev_filter_ctrl(res->port_id,
10166 RTE_ETH_FILTER_FLEXIBLE,
10167 RTE_ETH_FILTER_DELETE,
10171 printf("flex filter setting error: (%s)\n", strerror(-ret));
10174 cmdline_parse_token_string_t cmd_flex_filter_filter =
10175 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10176 filter, "flex_filter");
10177 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10178 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10180 cmdline_parse_token_string_t cmd_flex_filter_ops =
10181 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10183 cmdline_parse_token_string_t cmd_flex_filter_len =
10184 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10186 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10187 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10189 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10190 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10192 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10193 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10194 bytes_value, NULL);
10195 cmdline_parse_token_string_t cmd_flex_filter_mask =
10196 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10198 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10199 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10201 cmdline_parse_token_string_t cmd_flex_filter_priority =
10202 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10203 priority, "priority");
10204 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10205 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10206 priority_value, UINT8);
10207 cmdline_parse_token_string_t cmd_flex_filter_queue =
10208 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10210 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10211 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10213 cmdline_parse_inst_t cmd_flex_filter = {
10214 .f = cmd_flex_filter_parsed,
10216 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10217 "<value> mask <value> priority <value> queue <queue_id>: "
10218 "Add/Del a flex filter",
10220 (void *)&cmd_flex_filter_filter,
10221 (void *)&cmd_flex_filter_port_id,
10222 (void *)&cmd_flex_filter_ops,
10223 (void *)&cmd_flex_filter_len,
10224 (void *)&cmd_flex_filter_len_value,
10225 (void *)&cmd_flex_filter_bytes,
10226 (void *)&cmd_flex_filter_bytes_value,
10227 (void *)&cmd_flex_filter_mask,
10228 (void *)&cmd_flex_filter_mask_value,
10229 (void *)&cmd_flex_filter_priority,
10230 (void *)&cmd_flex_filter_priority_value,
10231 (void *)&cmd_flex_filter_queue,
10232 (void *)&cmd_flex_filter_queue_id,
10237 /* *** Filters Control *** */
10239 /* *** deal with ethertype filter *** */
10240 struct cmd_ethertype_filter_result {
10241 cmdline_fixed_string_t filter;
10243 cmdline_fixed_string_t ops;
10244 cmdline_fixed_string_t mac;
10245 struct ether_addr mac_addr;
10246 cmdline_fixed_string_t ethertype;
10247 uint16_t ethertype_value;
10248 cmdline_fixed_string_t drop;
10249 cmdline_fixed_string_t queue;
10253 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10254 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10255 filter, "ethertype_filter");
10256 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10257 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10259 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10260 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10262 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10263 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10264 mac, "mac_addr#mac_ignr");
10265 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10266 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10268 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10269 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10270 ethertype, "ethertype");
10271 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10272 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10273 ethertype_value, UINT16);
10274 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10275 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10277 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10278 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10280 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10281 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10285 cmd_ethertype_filter_parsed(void *parsed_result,
10286 __attribute__((unused)) struct cmdline *cl,
10287 __attribute__((unused)) void *data)
10289 struct cmd_ethertype_filter_result *res = parsed_result;
10290 struct rte_eth_ethertype_filter filter;
10293 ret = rte_eth_dev_filter_supported(res->port_id,
10294 RTE_ETH_FILTER_ETHERTYPE);
10296 printf("ethertype filter is not supported on port %u.\n",
10301 memset(&filter, 0, sizeof(filter));
10302 if (!strcmp(res->mac, "mac_addr")) {
10303 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10304 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10305 sizeof(struct ether_addr));
10307 if (!strcmp(res->drop, "drop"))
10308 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10309 filter.ether_type = res->ethertype_value;
10310 filter.queue = res->queue_id;
10312 if (!strcmp(res->ops, "add"))
10313 ret = rte_eth_dev_filter_ctrl(res->port_id,
10314 RTE_ETH_FILTER_ETHERTYPE,
10315 RTE_ETH_FILTER_ADD,
10318 ret = rte_eth_dev_filter_ctrl(res->port_id,
10319 RTE_ETH_FILTER_ETHERTYPE,
10320 RTE_ETH_FILTER_DELETE,
10323 printf("ethertype filter programming error: (%s)\n",
10327 cmdline_parse_inst_t cmd_ethertype_filter = {
10328 .f = cmd_ethertype_filter_parsed,
10330 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10331 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10332 "Add or delete an ethertype filter entry",
10334 (void *)&cmd_ethertype_filter_filter,
10335 (void *)&cmd_ethertype_filter_port_id,
10336 (void *)&cmd_ethertype_filter_ops,
10337 (void *)&cmd_ethertype_filter_mac,
10338 (void *)&cmd_ethertype_filter_mac_addr,
10339 (void *)&cmd_ethertype_filter_ethertype,
10340 (void *)&cmd_ethertype_filter_ethertype_value,
10341 (void *)&cmd_ethertype_filter_drop,
10342 (void *)&cmd_ethertype_filter_queue,
10343 (void *)&cmd_ethertype_filter_queue_id,
10348 /* *** deal with flow director filter *** */
10349 struct cmd_flow_director_result {
10350 cmdline_fixed_string_t flow_director_filter;
10352 cmdline_fixed_string_t mode;
10353 cmdline_fixed_string_t mode_value;
10354 cmdline_fixed_string_t ops;
10355 cmdline_fixed_string_t flow;
10356 cmdline_fixed_string_t flow_type;
10357 cmdline_fixed_string_t ether;
10358 uint16_t ether_type;
10359 cmdline_fixed_string_t src;
10360 cmdline_ipaddr_t ip_src;
10362 cmdline_fixed_string_t dst;
10363 cmdline_ipaddr_t ip_dst;
10365 cmdline_fixed_string_t verify_tag;
10366 uint32_t verify_tag_value;
10367 cmdline_fixed_string_t tos;
10369 cmdline_fixed_string_t proto;
10370 uint8_t proto_value;
10371 cmdline_fixed_string_t ttl;
10373 cmdline_fixed_string_t vlan;
10374 uint16_t vlan_value;
10375 cmdline_fixed_string_t flexbytes;
10376 cmdline_fixed_string_t flexbytes_value;
10377 cmdline_fixed_string_t pf_vf;
10378 cmdline_fixed_string_t drop;
10379 cmdline_fixed_string_t queue;
10381 cmdline_fixed_string_t fd_id;
10382 uint32_t fd_id_value;
10383 cmdline_fixed_string_t mac;
10384 struct ether_addr mac_addr;
10385 cmdline_fixed_string_t tunnel;
10386 cmdline_fixed_string_t tunnel_type;
10387 cmdline_fixed_string_t tunnel_id;
10388 uint32_t tunnel_id_value;
10389 cmdline_fixed_string_t packet;
10394 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10397 const char *p, *p0 = q_arg;
10399 unsigned long int_fld;
10400 char *str_fld[max_num];
10405 p = strchr(p0, '(');
10409 p0 = strchr(p, ')');
10414 if (size >= sizeof(s))
10417 snprintf(s, sizeof(s), "%.*s", size, p);
10418 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10419 if (ret < 0 || ret > max_num)
10421 for (i = 0; i < ret; i++) {
10423 int_fld = strtoul(str_fld[i], &end, 0);
10424 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10426 flexbytes[i] = (uint8_t)int_fld;
10432 str2flowtype(char *string)
10435 static const struct {
10438 } flowtype_str[] = {
10439 {"raw", RTE_ETH_FLOW_RAW},
10440 {"ipv4", RTE_ETH_FLOW_IPV4},
10441 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10442 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10443 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10444 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10445 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10446 {"ipv6", RTE_ETH_FLOW_IPV6},
10447 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10448 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10449 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10450 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10451 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10452 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10455 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10456 if (!strcmp(flowtype_str[i].str, string))
10457 return flowtype_str[i].type;
10460 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10461 return (uint16_t)atoi(string);
10463 return RTE_ETH_FLOW_UNKNOWN;
10466 static enum rte_eth_fdir_tunnel_type
10467 str2fdir_tunneltype(char *string)
10471 static const struct {
10473 enum rte_eth_fdir_tunnel_type type;
10474 } tunneltype_str[] = {
10475 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10476 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10479 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10480 if (!strcmp(tunneltype_str[i].str, string))
10481 return tunneltype_str[i].type;
10483 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10486 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10488 if ((ip_addr).family == AF_INET) \
10489 (ip) = (ip_addr).addr.ipv4.s_addr; \
10491 printf("invalid parameter.\n"); \
10496 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10498 if ((ip_addr).family == AF_INET6) \
10499 rte_memcpy(&(ip), \
10500 &((ip_addr).addr.ipv6), \
10501 sizeof(struct in6_addr)); \
10503 printf("invalid parameter.\n"); \
10509 cmd_flow_director_filter_parsed(void *parsed_result,
10510 __attribute__((unused)) struct cmdline *cl,
10511 __attribute__((unused)) void *data)
10513 struct cmd_flow_director_result *res = parsed_result;
10514 struct rte_eth_fdir_filter entry;
10515 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10517 unsigned long vf_id;
10520 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10522 printf("flow director is not supported on port %u.\n",
10526 memset(flexbytes, 0, sizeof(flexbytes));
10527 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10529 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10530 if (strcmp(res->mode_value, "MAC-VLAN")) {
10531 printf("Please set mode to MAC-VLAN.\n");
10534 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10535 if (strcmp(res->mode_value, "Tunnel")) {
10536 printf("Please set mode to Tunnel.\n");
10540 if (!strcmp(res->mode_value, "raw")) {
10541 #ifdef RTE_LIBRTE_I40E_PMD
10542 struct rte_pmd_i40e_flow_type_mapping
10543 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10544 struct rte_pmd_i40e_pkt_template_conf conf;
10545 uint16_t flow_type = str2flowtype(res->flow_type);
10546 uint16_t i, port = res->port_id;
10549 memset(&conf, 0, sizeof(conf));
10551 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10552 printf("Invalid flow type specified.\n");
10555 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10559 if (mapping[flow_type].pctype == 0ULL) {
10560 printf("Invalid flow type specified.\n");
10563 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10564 if (mapping[flow_type].pctype & (1ULL << i)) {
10565 conf.input.pctype = i;
10570 conf.input.packet = open_file(res->filepath,
10571 &conf.input.length);
10572 if (!conf.input.packet)
10574 if (!strcmp(res->drop, "drop"))
10575 conf.action.behavior =
10576 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10578 conf.action.behavior =
10579 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10580 conf.action.report_status =
10581 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10582 conf.action.rx_queue = res->queue_id;
10583 conf.soft_id = res->fd_id_value;
10584 add = strcmp(res->ops, "del") ? 1 : 0;
10585 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10589 printf("flow director config error: (%s)\n",
10591 close_file(conf.input.packet);
10594 } else if (strcmp(res->mode_value, "IP")) {
10595 printf("Please set mode to IP or raw.\n");
10598 entry.input.flow_type = str2flowtype(res->flow_type);
10601 ret = parse_flexbytes(res->flexbytes_value,
10603 RTE_ETH_FDIR_MAX_FLEXLEN);
10605 printf("error: Cannot parse flexbytes input.\n");
10609 switch (entry.input.flow_type) {
10610 case RTE_ETH_FLOW_FRAG_IPV4:
10611 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10612 entry.input.flow.ip4_flow.proto = res->proto_value;
10614 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10615 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10616 IPV4_ADDR_TO_UINT(res->ip_dst,
10617 entry.input.flow.ip4_flow.dst_ip);
10618 IPV4_ADDR_TO_UINT(res->ip_src,
10619 entry.input.flow.ip4_flow.src_ip);
10620 entry.input.flow.ip4_flow.tos = res->tos_value;
10621 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10622 /* need convert to big endian. */
10623 entry.input.flow.udp4_flow.dst_port =
10624 rte_cpu_to_be_16(res->port_dst);
10625 entry.input.flow.udp4_flow.src_port =
10626 rte_cpu_to_be_16(res->port_src);
10628 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10629 IPV4_ADDR_TO_UINT(res->ip_dst,
10630 entry.input.flow.sctp4_flow.ip.dst_ip);
10631 IPV4_ADDR_TO_UINT(res->ip_src,
10632 entry.input.flow.sctp4_flow.ip.src_ip);
10633 entry.input.flow.ip4_flow.tos = res->tos_value;
10634 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10635 /* need convert to big endian. */
10636 entry.input.flow.sctp4_flow.dst_port =
10637 rte_cpu_to_be_16(res->port_dst);
10638 entry.input.flow.sctp4_flow.src_port =
10639 rte_cpu_to_be_16(res->port_src);
10640 entry.input.flow.sctp4_flow.verify_tag =
10641 rte_cpu_to_be_32(res->verify_tag_value);
10643 case RTE_ETH_FLOW_FRAG_IPV6:
10644 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10645 entry.input.flow.ipv6_flow.proto = res->proto_value;
10647 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10648 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10649 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10650 entry.input.flow.ipv6_flow.dst_ip);
10651 IPV6_ADDR_TO_ARRAY(res->ip_src,
10652 entry.input.flow.ipv6_flow.src_ip);
10653 entry.input.flow.ipv6_flow.tc = res->tos_value;
10654 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10655 /* need convert to big endian. */
10656 entry.input.flow.udp6_flow.dst_port =
10657 rte_cpu_to_be_16(res->port_dst);
10658 entry.input.flow.udp6_flow.src_port =
10659 rte_cpu_to_be_16(res->port_src);
10661 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10662 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10663 entry.input.flow.sctp6_flow.ip.dst_ip);
10664 IPV6_ADDR_TO_ARRAY(res->ip_src,
10665 entry.input.flow.sctp6_flow.ip.src_ip);
10666 entry.input.flow.ipv6_flow.tc = res->tos_value;
10667 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10668 /* need convert to big endian. */
10669 entry.input.flow.sctp6_flow.dst_port =
10670 rte_cpu_to_be_16(res->port_dst);
10671 entry.input.flow.sctp6_flow.src_port =
10672 rte_cpu_to_be_16(res->port_src);
10673 entry.input.flow.sctp6_flow.verify_tag =
10674 rte_cpu_to_be_32(res->verify_tag_value);
10676 case RTE_ETH_FLOW_L2_PAYLOAD:
10677 entry.input.flow.l2_flow.ether_type =
10678 rte_cpu_to_be_16(res->ether_type);
10684 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10685 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10687 sizeof(struct ether_addr));
10689 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10690 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10692 sizeof(struct ether_addr));
10693 entry.input.flow.tunnel_flow.tunnel_type =
10694 str2fdir_tunneltype(res->tunnel_type);
10695 entry.input.flow.tunnel_flow.tunnel_id =
10696 rte_cpu_to_be_32(res->tunnel_id_value);
10699 rte_memcpy(entry.input.flow_ext.flexbytes,
10701 RTE_ETH_FDIR_MAX_FLEXLEN);
10703 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10705 entry.action.flex_off = 0; /*use 0 by default */
10706 if (!strcmp(res->drop, "drop"))
10707 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10709 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10711 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10712 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10713 if (!strcmp(res->pf_vf, "pf"))
10714 entry.input.flow_ext.is_vf = 0;
10715 else if (!strncmp(res->pf_vf, "vf", 2)) {
10716 struct rte_eth_dev_info dev_info;
10718 memset(&dev_info, 0, sizeof(dev_info));
10719 rte_eth_dev_info_get(res->port_id, &dev_info);
10721 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10722 if (errno != 0 || *end != '\0' ||
10723 vf_id >= dev_info.max_vfs) {
10724 printf("invalid parameter %s.\n", res->pf_vf);
10727 entry.input.flow_ext.is_vf = 1;
10728 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10730 printf("invalid parameter %s.\n", res->pf_vf);
10735 /* set to report FD ID by default */
10736 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10737 entry.action.rx_queue = res->queue_id;
10738 entry.soft_id = res->fd_id_value;
10739 if (!strcmp(res->ops, "add"))
10740 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10741 RTE_ETH_FILTER_ADD, &entry);
10742 else if (!strcmp(res->ops, "del"))
10743 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10744 RTE_ETH_FILTER_DELETE, &entry);
10746 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10747 RTE_ETH_FILTER_UPDATE, &entry);
10749 printf("flow director programming error: (%s)\n",
10753 cmdline_parse_token_string_t cmd_flow_director_filter =
10754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10755 flow_director_filter, "flow_director_filter");
10756 cmdline_parse_token_num_t cmd_flow_director_port_id =
10757 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10759 cmdline_parse_token_string_t cmd_flow_director_ops =
10760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10761 ops, "add#del#update");
10762 cmdline_parse_token_string_t cmd_flow_director_flow =
10763 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10765 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10768 cmdline_parse_token_string_t cmd_flow_director_ether =
10769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10771 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10772 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10773 ether_type, UINT16);
10774 cmdline_parse_token_string_t cmd_flow_director_src =
10775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10777 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10778 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10780 cmdline_parse_token_num_t cmd_flow_director_port_src =
10781 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10783 cmdline_parse_token_string_t cmd_flow_director_dst =
10784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10786 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10787 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10789 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10790 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10792 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10793 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10794 verify_tag, "verify_tag");
10795 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10796 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10797 verify_tag_value, UINT32);
10798 cmdline_parse_token_string_t cmd_flow_director_tos =
10799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10801 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10802 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10804 cmdline_parse_token_string_t cmd_flow_director_proto =
10805 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10807 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10808 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10809 proto_value, UINT8);
10810 cmdline_parse_token_string_t cmd_flow_director_ttl =
10811 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10813 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10814 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10816 cmdline_parse_token_string_t cmd_flow_director_vlan =
10817 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10819 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10820 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10821 vlan_value, UINT16);
10822 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10824 flexbytes, "flexbytes");
10825 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10827 flexbytes_value, NULL);
10828 cmdline_parse_token_string_t cmd_flow_director_drop =
10829 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10831 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10834 cmdline_parse_token_string_t cmd_flow_director_queue =
10835 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10837 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10838 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10840 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10841 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10843 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10844 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10845 fd_id_value, UINT32);
10847 cmdline_parse_token_string_t cmd_flow_director_mode =
10848 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10850 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10851 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10853 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10854 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10855 mode_value, "MAC-VLAN");
10856 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10857 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10858 mode_value, "Tunnel");
10859 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10860 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10861 mode_value, "raw");
10862 cmdline_parse_token_string_t cmd_flow_director_mac =
10863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10865 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10866 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10868 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10871 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10873 tunnel_type, "NVGRE#VxLAN");
10874 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10876 tunnel_id, "tunnel-id");
10877 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10878 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10879 tunnel_id_value, UINT32);
10880 cmdline_parse_token_string_t cmd_flow_director_packet =
10881 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10883 cmdline_parse_token_string_t cmd_flow_director_filepath =
10884 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10887 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10888 .f = cmd_flow_director_filter_parsed,
10890 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10891 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10892 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10893 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10894 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10895 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10896 "fd_id <fd_id_value>: "
10897 "Add or delete an ip flow director entry on NIC",
10899 (void *)&cmd_flow_director_filter,
10900 (void *)&cmd_flow_director_port_id,
10901 (void *)&cmd_flow_director_mode,
10902 (void *)&cmd_flow_director_mode_ip,
10903 (void *)&cmd_flow_director_ops,
10904 (void *)&cmd_flow_director_flow,
10905 (void *)&cmd_flow_director_flow_type,
10906 (void *)&cmd_flow_director_src,
10907 (void *)&cmd_flow_director_ip_src,
10908 (void *)&cmd_flow_director_dst,
10909 (void *)&cmd_flow_director_ip_dst,
10910 (void *)&cmd_flow_director_tos,
10911 (void *)&cmd_flow_director_tos_value,
10912 (void *)&cmd_flow_director_proto,
10913 (void *)&cmd_flow_director_proto_value,
10914 (void *)&cmd_flow_director_ttl,
10915 (void *)&cmd_flow_director_ttl_value,
10916 (void *)&cmd_flow_director_vlan,
10917 (void *)&cmd_flow_director_vlan_value,
10918 (void *)&cmd_flow_director_flexbytes,
10919 (void *)&cmd_flow_director_flexbytes_value,
10920 (void *)&cmd_flow_director_drop,
10921 (void *)&cmd_flow_director_pf_vf,
10922 (void *)&cmd_flow_director_queue,
10923 (void *)&cmd_flow_director_queue_id,
10924 (void *)&cmd_flow_director_fd_id,
10925 (void *)&cmd_flow_director_fd_id_value,
10930 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10931 .f = cmd_flow_director_filter_parsed,
10933 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10934 "director entry on NIC",
10936 (void *)&cmd_flow_director_filter,
10937 (void *)&cmd_flow_director_port_id,
10938 (void *)&cmd_flow_director_mode,
10939 (void *)&cmd_flow_director_mode_ip,
10940 (void *)&cmd_flow_director_ops,
10941 (void *)&cmd_flow_director_flow,
10942 (void *)&cmd_flow_director_flow_type,
10943 (void *)&cmd_flow_director_src,
10944 (void *)&cmd_flow_director_ip_src,
10945 (void *)&cmd_flow_director_port_src,
10946 (void *)&cmd_flow_director_dst,
10947 (void *)&cmd_flow_director_ip_dst,
10948 (void *)&cmd_flow_director_port_dst,
10949 (void *)&cmd_flow_director_tos,
10950 (void *)&cmd_flow_director_tos_value,
10951 (void *)&cmd_flow_director_ttl,
10952 (void *)&cmd_flow_director_ttl_value,
10953 (void *)&cmd_flow_director_vlan,
10954 (void *)&cmd_flow_director_vlan_value,
10955 (void *)&cmd_flow_director_flexbytes,
10956 (void *)&cmd_flow_director_flexbytes_value,
10957 (void *)&cmd_flow_director_drop,
10958 (void *)&cmd_flow_director_pf_vf,
10959 (void *)&cmd_flow_director_queue,
10960 (void *)&cmd_flow_director_queue_id,
10961 (void *)&cmd_flow_director_fd_id,
10962 (void *)&cmd_flow_director_fd_id_value,
10967 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10968 .f = cmd_flow_director_filter_parsed,
10970 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10971 "director entry on NIC",
10973 (void *)&cmd_flow_director_filter,
10974 (void *)&cmd_flow_director_port_id,
10975 (void *)&cmd_flow_director_mode,
10976 (void *)&cmd_flow_director_mode_ip,
10977 (void *)&cmd_flow_director_ops,
10978 (void *)&cmd_flow_director_flow,
10979 (void *)&cmd_flow_director_flow_type,
10980 (void *)&cmd_flow_director_src,
10981 (void *)&cmd_flow_director_ip_src,
10982 (void *)&cmd_flow_director_port_src,
10983 (void *)&cmd_flow_director_dst,
10984 (void *)&cmd_flow_director_ip_dst,
10985 (void *)&cmd_flow_director_port_dst,
10986 (void *)&cmd_flow_director_verify_tag,
10987 (void *)&cmd_flow_director_verify_tag_value,
10988 (void *)&cmd_flow_director_tos,
10989 (void *)&cmd_flow_director_tos_value,
10990 (void *)&cmd_flow_director_ttl,
10991 (void *)&cmd_flow_director_ttl_value,
10992 (void *)&cmd_flow_director_vlan,
10993 (void *)&cmd_flow_director_vlan_value,
10994 (void *)&cmd_flow_director_flexbytes,
10995 (void *)&cmd_flow_director_flexbytes_value,
10996 (void *)&cmd_flow_director_drop,
10997 (void *)&cmd_flow_director_pf_vf,
10998 (void *)&cmd_flow_director_queue,
10999 (void *)&cmd_flow_director_queue_id,
11000 (void *)&cmd_flow_director_fd_id,
11001 (void *)&cmd_flow_director_fd_id_value,
11006 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11007 .f = cmd_flow_director_filter_parsed,
11009 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11010 "director entry on NIC",
11012 (void *)&cmd_flow_director_filter,
11013 (void *)&cmd_flow_director_port_id,
11014 (void *)&cmd_flow_director_mode,
11015 (void *)&cmd_flow_director_mode_ip,
11016 (void *)&cmd_flow_director_ops,
11017 (void *)&cmd_flow_director_flow,
11018 (void *)&cmd_flow_director_flow_type,
11019 (void *)&cmd_flow_director_ether,
11020 (void *)&cmd_flow_director_ether_type,
11021 (void *)&cmd_flow_director_flexbytes,
11022 (void *)&cmd_flow_director_flexbytes_value,
11023 (void *)&cmd_flow_director_drop,
11024 (void *)&cmd_flow_director_pf_vf,
11025 (void *)&cmd_flow_director_queue,
11026 (void *)&cmd_flow_director_queue_id,
11027 (void *)&cmd_flow_director_fd_id,
11028 (void *)&cmd_flow_director_fd_id_value,
11033 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11034 .f = cmd_flow_director_filter_parsed,
11036 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11037 "director entry on NIC",
11039 (void *)&cmd_flow_director_filter,
11040 (void *)&cmd_flow_director_port_id,
11041 (void *)&cmd_flow_director_mode,
11042 (void *)&cmd_flow_director_mode_mac_vlan,
11043 (void *)&cmd_flow_director_ops,
11044 (void *)&cmd_flow_director_mac,
11045 (void *)&cmd_flow_director_mac_addr,
11046 (void *)&cmd_flow_director_vlan,
11047 (void *)&cmd_flow_director_vlan_value,
11048 (void *)&cmd_flow_director_flexbytes,
11049 (void *)&cmd_flow_director_flexbytes_value,
11050 (void *)&cmd_flow_director_drop,
11051 (void *)&cmd_flow_director_queue,
11052 (void *)&cmd_flow_director_queue_id,
11053 (void *)&cmd_flow_director_fd_id,
11054 (void *)&cmd_flow_director_fd_id_value,
11059 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11060 .f = cmd_flow_director_filter_parsed,
11062 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11063 "director entry on NIC",
11065 (void *)&cmd_flow_director_filter,
11066 (void *)&cmd_flow_director_port_id,
11067 (void *)&cmd_flow_director_mode,
11068 (void *)&cmd_flow_director_mode_tunnel,
11069 (void *)&cmd_flow_director_ops,
11070 (void *)&cmd_flow_director_mac,
11071 (void *)&cmd_flow_director_mac_addr,
11072 (void *)&cmd_flow_director_vlan,
11073 (void *)&cmd_flow_director_vlan_value,
11074 (void *)&cmd_flow_director_tunnel,
11075 (void *)&cmd_flow_director_tunnel_type,
11076 (void *)&cmd_flow_director_tunnel_id,
11077 (void *)&cmd_flow_director_tunnel_id_value,
11078 (void *)&cmd_flow_director_flexbytes,
11079 (void *)&cmd_flow_director_flexbytes_value,
11080 (void *)&cmd_flow_director_drop,
11081 (void *)&cmd_flow_director_queue,
11082 (void *)&cmd_flow_director_queue_id,
11083 (void *)&cmd_flow_director_fd_id,
11084 (void *)&cmd_flow_director_fd_id_value,
11089 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11090 .f = cmd_flow_director_filter_parsed,
11092 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11093 "director entry on NIC",
11095 (void *)&cmd_flow_director_filter,
11096 (void *)&cmd_flow_director_port_id,
11097 (void *)&cmd_flow_director_mode,
11098 (void *)&cmd_flow_director_mode_raw,
11099 (void *)&cmd_flow_director_ops,
11100 (void *)&cmd_flow_director_flow,
11101 (void *)&cmd_flow_director_flow_type,
11102 (void *)&cmd_flow_director_drop,
11103 (void *)&cmd_flow_director_queue,
11104 (void *)&cmd_flow_director_queue_id,
11105 (void *)&cmd_flow_director_fd_id,
11106 (void *)&cmd_flow_director_fd_id_value,
11107 (void *)&cmd_flow_director_packet,
11108 (void *)&cmd_flow_director_filepath,
11113 struct cmd_flush_flow_director_result {
11114 cmdline_fixed_string_t flush_flow_director;
11118 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11119 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11120 flush_flow_director, "flush_flow_director");
11121 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11122 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11126 cmd_flush_flow_director_parsed(void *parsed_result,
11127 __attribute__((unused)) struct cmdline *cl,
11128 __attribute__((unused)) void *data)
11130 struct cmd_flow_director_result *res = parsed_result;
11133 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11135 printf("flow director is not supported on port %u.\n",
11140 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11141 RTE_ETH_FILTER_FLUSH, NULL);
11143 printf("flow director table flushing error: (%s)\n",
11147 cmdline_parse_inst_t cmd_flush_flow_director = {
11148 .f = cmd_flush_flow_director_parsed,
11150 .help_str = "flush_flow_director <port_id>: "
11151 "Flush all flow director entries of a device on NIC",
11153 (void *)&cmd_flush_flow_director_flush,
11154 (void *)&cmd_flush_flow_director_port_id,
11159 /* *** deal with flow director mask *** */
11160 struct cmd_flow_director_mask_result {
11161 cmdline_fixed_string_t flow_director_mask;
11163 cmdline_fixed_string_t mode;
11164 cmdline_fixed_string_t mode_value;
11165 cmdline_fixed_string_t vlan;
11166 uint16_t vlan_mask;
11167 cmdline_fixed_string_t src_mask;
11168 cmdline_ipaddr_t ipv4_src;
11169 cmdline_ipaddr_t ipv6_src;
11171 cmdline_fixed_string_t dst_mask;
11172 cmdline_ipaddr_t ipv4_dst;
11173 cmdline_ipaddr_t ipv6_dst;
11175 cmdline_fixed_string_t mac;
11176 uint8_t mac_addr_byte_mask;
11177 cmdline_fixed_string_t tunnel_id;
11178 uint32_t tunnel_id_mask;
11179 cmdline_fixed_string_t tunnel_type;
11180 uint8_t tunnel_type_mask;
11184 cmd_flow_director_mask_parsed(void *parsed_result,
11185 __attribute__((unused)) struct cmdline *cl,
11186 __attribute__((unused)) void *data)
11188 struct cmd_flow_director_mask_result *res = parsed_result;
11189 struct rte_eth_fdir_masks *mask;
11190 struct rte_port *port;
11192 port = &ports[res->port_id];
11193 /** Check if the port is not started **/
11194 if (port->port_status != RTE_PORT_STOPPED) {
11195 printf("Please stop port %d first\n", res->port_id);
11199 mask = &port->dev_conf.fdir_conf.mask;
11201 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11202 if (strcmp(res->mode_value, "MAC-VLAN")) {
11203 printf("Please set mode to MAC-VLAN.\n");
11207 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11208 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11209 if (strcmp(res->mode_value, "Tunnel")) {
11210 printf("Please set mode to Tunnel.\n");
11214 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11215 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11216 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11217 mask->tunnel_type_mask = res->tunnel_type_mask;
11219 if (strcmp(res->mode_value, "IP")) {
11220 printf("Please set mode to IP.\n");
11224 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11225 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11226 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11227 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11228 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11229 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11230 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11233 cmd_reconfig_device_queue(res->port_id, 1, 1);
11236 cmdline_parse_token_string_t cmd_flow_director_mask =
11237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11238 flow_director_mask, "flow_director_mask");
11239 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11240 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11242 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11245 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11246 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11247 vlan_mask, UINT16);
11248 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11250 src_mask, "src_mask");
11251 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11252 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11254 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11255 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11257 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11258 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11260 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11262 dst_mask, "dst_mask");
11263 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11264 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11266 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11267 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11269 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11270 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11273 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11276 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11279 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11281 mode_value, "MAC-VLAN");
11282 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11284 mode_value, "Tunnel");
11285 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11288 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11289 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11290 mac_addr_byte_mask, UINT8);
11291 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11293 tunnel_type, "tunnel-type");
11294 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11295 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11296 tunnel_type_mask, UINT8);
11297 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11299 tunnel_id, "tunnel-id");
11300 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11301 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11302 tunnel_id_mask, UINT32);
11304 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11305 .f = cmd_flow_director_mask_parsed,
11307 .help_str = "flow_director_mask ... : "
11308 "Set IP mode flow director's mask on NIC",
11310 (void *)&cmd_flow_director_mask,
11311 (void *)&cmd_flow_director_mask_port_id,
11312 (void *)&cmd_flow_director_mask_mode,
11313 (void *)&cmd_flow_director_mask_mode_ip,
11314 (void *)&cmd_flow_director_mask_vlan,
11315 (void *)&cmd_flow_director_mask_vlan_value,
11316 (void *)&cmd_flow_director_mask_src,
11317 (void *)&cmd_flow_director_mask_ipv4_src,
11318 (void *)&cmd_flow_director_mask_ipv6_src,
11319 (void *)&cmd_flow_director_mask_port_src,
11320 (void *)&cmd_flow_director_mask_dst,
11321 (void *)&cmd_flow_director_mask_ipv4_dst,
11322 (void *)&cmd_flow_director_mask_ipv6_dst,
11323 (void *)&cmd_flow_director_mask_port_dst,
11328 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11329 .f = cmd_flow_director_mask_parsed,
11331 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11332 "flow director's mask on NIC",
11334 (void *)&cmd_flow_director_mask,
11335 (void *)&cmd_flow_director_mask_port_id,
11336 (void *)&cmd_flow_director_mask_mode,
11337 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11338 (void *)&cmd_flow_director_mask_vlan,
11339 (void *)&cmd_flow_director_mask_vlan_value,
11344 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11345 .f = cmd_flow_director_mask_parsed,
11347 .help_str = "flow_director_mask ... : Set tunnel mode "
11348 "flow director's mask on NIC",
11350 (void *)&cmd_flow_director_mask,
11351 (void *)&cmd_flow_director_mask_port_id,
11352 (void *)&cmd_flow_director_mask_mode,
11353 (void *)&cmd_flow_director_mask_mode_tunnel,
11354 (void *)&cmd_flow_director_mask_vlan,
11355 (void *)&cmd_flow_director_mask_vlan_value,
11356 (void *)&cmd_flow_director_mask_mac,
11357 (void *)&cmd_flow_director_mask_mac_value,
11358 (void *)&cmd_flow_director_mask_tunnel_type,
11359 (void *)&cmd_flow_director_mask_tunnel_type_value,
11360 (void *)&cmd_flow_director_mask_tunnel_id,
11361 (void *)&cmd_flow_director_mask_tunnel_id_value,
11366 /* *** deal with flow director mask on flexible payload *** */
11367 struct cmd_flow_director_flex_mask_result {
11368 cmdline_fixed_string_t flow_director_flexmask;
11370 cmdline_fixed_string_t flow;
11371 cmdline_fixed_string_t flow_type;
11372 cmdline_fixed_string_t mask;
11376 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11377 __attribute__((unused)) struct cmdline *cl,
11378 __attribute__((unused)) void *data)
11380 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11381 struct rte_eth_fdir_info fdir_info;
11382 struct rte_eth_fdir_flex_mask flex_mask;
11383 struct rte_port *port;
11384 uint64_t flow_type_mask;
11388 port = &ports[res->port_id];
11389 /** Check if the port is not started **/
11390 if (port->port_status != RTE_PORT_STOPPED) {
11391 printf("Please stop port %d first\n", res->port_id);
11395 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11396 ret = parse_flexbytes(res->mask,
11398 RTE_ETH_FDIR_MAX_FLEXLEN);
11400 printf("error: Cannot parse mask input.\n");
11404 memset(&fdir_info, 0, sizeof(fdir_info));
11405 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11406 RTE_ETH_FILTER_INFO, &fdir_info);
11408 printf("Cannot get FDir filter info\n");
11412 if (!strcmp(res->flow_type, "none")) {
11413 /* means don't specify the flow type */
11414 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11415 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11416 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11417 0, sizeof(struct rte_eth_fdir_flex_mask));
11418 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11419 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11421 sizeof(struct rte_eth_fdir_flex_mask));
11422 cmd_reconfig_device_queue(res->port_id, 1, 1);
11425 flow_type_mask = fdir_info.flow_types_mask[0];
11426 if (!strcmp(res->flow_type, "all")) {
11427 if (!flow_type_mask) {
11428 printf("No flow type supported\n");
11431 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11432 if (flow_type_mask & (1ULL << i)) {
11433 flex_mask.flow_type = i;
11434 fdir_set_flex_mask(res->port_id, &flex_mask);
11437 cmd_reconfig_device_queue(res->port_id, 1, 1);
11440 flex_mask.flow_type = str2flowtype(res->flow_type);
11441 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11442 printf("Flow type %s not supported on port %d\n",
11443 res->flow_type, res->port_id);
11446 fdir_set_flex_mask(res->port_id, &flex_mask);
11447 cmd_reconfig_device_queue(res->port_id, 1, 1);
11450 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11452 flow_director_flexmask,
11453 "flow_director_flex_mask");
11454 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11455 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11457 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11458 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11460 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11461 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11462 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11463 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11464 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11465 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11468 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11469 .f = cmd_flow_director_flex_mask_parsed,
11471 .help_str = "flow_director_flex_mask ... : "
11472 "Set flow director's flex mask on NIC",
11474 (void *)&cmd_flow_director_flexmask,
11475 (void *)&cmd_flow_director_flexmask_port_id,
11476 (void *)&cmd_flow_director_flexmask_flow,
11477 (void *)&cmd_flow_director_flexmask_flow_type,
11478 (void *)&cmd_flow_director_flexmask_mask,
11483 /* *** deal with flow director flexible payload configuration *** */
11484 struct cmd_flow_director_flexpayload_result {
11485 cmdline_fixed_string_t flow_director_flexpayload;
11487 cmdline_fixed_string_t payload_layer;
11488 cmdline_fixed_string_t payload_cfg;
11492 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11495 const char *p, *p0 = q_arg;
11497 unsigned long int_fld;
11498 char *str_fld[max_num];
11503 p = strchr(p0, '(');
11507 p0 = strchr(p, ')');
11512 if (size >= sizeof(s))
11515 snprintf(s, sizeof(s), "%.*s", size, p);
11516 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11517 if (ret < 0 || ret > max_num)
11519 for (i = 0; i < ret; i++) {
11521 int_fld = strtoul(str_fld[i], &end, 0);
11522 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11524 offsets[i] = (uint16_t)int_fld;
11530 cmd_flow_director_flxpld_parsed(void *parsed_result,
11531 __attribute__((unused)) struct cmdline *cl,
11532 __attribute__((unused)) void *data)
11534 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11535 struct rte_eth_flex_payload_cfg flex_cfg;
11536 struct rte_port *port;
11539 port = &ports[res->port_id];
11540 /** Check if the port is not started **/
11541 if (port->port_status != RTE_PORT_STOPPED) {
11542 printf("Please stop port %d first\n", res->port_id);
11546 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11548 if (!strcmp(res->payload_layer, "raw"))
11549 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11550 else if (!strcmp(res->payload_layer, "l2"))
11551 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11552 else if (!strcmp(res->payload_layer, "l3"))
11553 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11554 else if (!strcmp(res->payload_layer, "l4"))
11555 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11557 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11558 RTE_ETH_FDIR_MAX_FLEXLEN);
11560 printf("error: Cannot parse flex payload input.\n");
11564 fdir_set_flex_payload(res->port_id, &flex_cfg);
11565 cmd_reconfig_device_queue(res->port_id, 1, 1);
11568 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11569 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11570 flow_director_flexpayload,
11571 "flow_director_flex_payload");
11572 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11573 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11575 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11576 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11577 payload_layer, "raw#l2#l3#l4");
11578 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11580 payload_cfg, NULL);
11582 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11583 .f = cmd_flow_director_flxpld_parsed,
11585 .help_str = "flow_director_flexpayload ... : "
11586 "Set flow director's flex payload on NIC",
11588 (void *)&cmd_flow_director_flexpayload,
11589 (void *)&cmd_flow_director_flexpayload_port_id,
11590 (void *)&cmd_flow_director_flexpayload_payload_layer,
11591 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11596 /* Generic flow interface command. */
11597 extern cmdline_parse_inst_t cmd_flow;
11599 /* *** Classification Filters Control *** */
11600 /* *** Get symmetric hash enable per port *** */
11601 struct cmd_get_sym_hash_ena_per_port_result {
11602 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11607 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11608 __rte_unused struct cmdline *cl,
11609 __rte_unused void *data)
11611 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11612 struct rte_eth_hash_filter_info info;
11615 if (rte_eth_dev_filter_supported(res->port_id,
11616 RTE_ETH_FILTER_HASH) < 0) {
11617 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11622 memset(&info, 0, sizeof(info));
11623 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11624 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11625 RTE_ETH_FILTER_GET, &info);
11628 printf("Cannot get symmetric hash enable per port "
11629 "on port %u\n", res->port_id);
11633 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11634 "enabled" : "disabled", res->port_id);
11637 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11638 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11639 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11640 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11641 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11644 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11645 .f = cmd_get_sym_hash_per_port_parsed,
11647 .help_str = "get_sym_hash_ena_per_port <port_id>",
11649 (void *)&cmd_get_sym_hash_ena_per_port_all,
11650 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11655 /* *** Set symmetric hash enable per port *** */
11656 struct cmd_set_sym_hash_ena_per_port_result {
11657 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11658 cmdline_fixed_string_t enable;
11663 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11664 __rte_unused struct cmdline *cl,
11665 __rte_unused void *data)
11667 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11668 struct rte_eth_hash_filter_info info;
11671 if (rte_eth_dev_filter_supported(res->port_id,
11672 RTE_ETH_FILTER_HASH) < 0) {
11673 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11678 memset(&info, 0, sizeof(info));
11679 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11680 if (!strcmp(res->enable, "enable"))
11681 info.info.enable = 1;
11682 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11683 RTE_ETH_FILTER_SET, &info);
11685 printf("Cannot set symmetric hash enable per port on "
11686 "port %u\n", res->port_id);
11689 printf("Symmetric hash has been set to %s on port %u\n",
11690 res->enable, res->port_id);
11693 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11694 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11695 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11696 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11697 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11699 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11700 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11701 enable, "enable#disable");
11703 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11704 .f = cmd_set_sym_hash_per_port_parsed,
11706 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11708 (void *)&cmd_set_sym_hash_ena_per_port_all,
11709 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11710 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11715 /* Get global config of hash function */
11716 struct cmd_get_hash_global_config_result {
11717 cmdline_fixed_string_t get_hash_global_config;
11722 flowtype_to_str(uint16_t ftype)
11728 } ftype_table[] = {
11729 {"ipv4", RTE_ETH_FLOW_IPV4},
11730 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11731 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11732 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11733 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11734 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11735 {"ipv6", RTE_ETH_FLOW_IPV6},
11736 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11737 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11738 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11739 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11740 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11741 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11742 {"port", RTE_ETH_FLOW_PORT},
11743 {"vxlan", RTE_ETH_FLOW_VXLAN},
11744 {"geneve", RTE_ETH_FLOW_GENEVE},
11745 {"nvgre", RTE_ETH_FLOW_NVGRE},
11748 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11749 if (ftype_table[i].ftype == ftype)
11750 return ftype_table[i].str;
11757 cmd_get_hash_global_config_parsed(void *parsed_result,
11758 __rte_unused struct cmdline *cl,
11759 __rte_unused void *data)
11761 struct cmd_get_hash_global_config_result *res = parsed_result;
11762 struct rte_eth_hash_filter_info info;
11763 uint32_t idx, offset;
11768 if (rte_eth_dev_filter_supported(res->port_id,
11769 RTE_ETH_FILTER_HASH) < 0) {
11770 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11775 memset(&info, 0, sizeof(info));
11776 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11777 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11778 RTE_ETH_FILTER_GET, &info);
11780 printf("Cannot get hash global configurations by port %d\n",
11785 switch (info.info.global_conf.hash_func) {
11786 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11787 printf("Hash function is Toeplitz\n");
11789 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11790 printf("Hash function is Simple XOR\n");
11793 printf("Unknown hash function\n");
11797 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11798 idx = i / UINT64_BIT;
11799 offset = i % UINT64_BIT;
11800 if (!(info.info.global_conf.valid_bit_mask[idx] &
11803 str = flowtype_to_str(i);
11806 printf("Symmetric hash is %s globally for flow type %s "
11808 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11809 (1ULL << offset)) ? "enabled" : "disabled"), str,
11814 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11815 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11816 get_hash_global_config, "get_hash_global_config");
11817 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11818 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11821 cmdline_parse_inst_t cmd_get_hash_global_config = {
11822 .f = cmd_get_hash_global_config_parsed,
11824 .help_str = "get_hash_global_config <port_id>",
11826 (void *)&cmd_get_hash_global_config_all,
11827 (void *)&cmd_get_hash_global_config_port_id,
11832 /* Set global config of hash function */
11833 struct cmd_set_hash_global_config_result {
11834 cmdline_fixed_string_t set_hash_global_config;
11836 cmdline_fixed_string_t hash_func;
11837 cmdline_fixed_string_t flow_type;
11838 cmdline_fixed_string_t enable;
11842 cmd_set_hash_global_config_parsed(void *parsed_result,
11843 __rte_unused struct cmdline *cl,
11844 __rte_unused void *data)
11846 struct cmd_set_hash_global_config_result *res = parsed_result;
11847 struct rte_eth_hash_filter_info info;
11848 uint32_t ftype, idx, offset;
11851 if (rte_eth_dev_filter_supported(res->port_id,
11852 RTE_ETH_FILTER_HASH) < 0) {
11853 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11857 memset(&info, 0, sizeof(info));
11858 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11859 if (!strcmp(res->hash_func, "toeplitz"))
11860 info.info.global_conf.hash_func =
11861 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11862 else if (!strcmp(res->hash_func, "simple_xor"))
11863 info.info.global_conf.hash_func =
11864 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11865 else if (!strcmp(res->hash_func, "default"))
11866 info.info.global_conf.hash_func =
11867 RTE_ETH_HASH_FUNCTION_DEFAULT;
11869 ftype = str2flowtype(res->flow_type);
11870 idx = ftype / UINT64_BIT;
11871 offset = ftype % UINT64_BIT;
11872 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11873 if (!strcmp(res->enable, "enable"))
11874 info.info.global_conf.sym_hash_enable_mask[idx] |=
11876 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11877 RTE_ETH_FILTER_SET, &info);
11879 printf("Cannot set global hash configurations by port %d\n",
11882 printf("Global hash configurations have been set "
11883 "succcessfully by port %d\n", res->port_id);
11886 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11887 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11888 set_hash_global_config, "set_hash_global_config");
11889 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11890 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11892 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11893 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11894 hash_func, "toeplitz#simple_xor#default");
11895 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11896 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11898 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11899 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11900 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11901 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11902 enable, "enable#disable");
11904 cmdline_parse_inst_t cmd_set_hash_global_config = {
11905 .f = cmd_set_hash_global_config_parsed,
11907 .help_str = "set_hash_global_config <port_id> "
11908 "toeplitz|simple_xor|default "
11909 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11910 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11911 "l2_payload enable|disable",
11913 (void *)&cmd_set_hash_global_config_all,
11914 (void *)&cmd_set_hash_global_config_port_id,
11915 (void *)&cmd_set_hash_global_config_hash_func,
11916 (void *)&cmd_set_hash_global_config_flow_type,
11917 (void *)&cmd_set_hash_global_config_enable,
11922 /* Set hash input set */
11923 struct cmd_set_hash_input_set_result {
11924 cmdline_fixed_string_t set_hash_input_set;
11926 cmdline_fixed_string_t flow_type;
11927 cmdline_fixed_string_t inset_field;
11928 cmdline_fixed_string_t select;
11931 static enum rte_eth_input_set_field
11932 str2inset(char *string)
11936 static const struct {
11938 enum rte_eth_input_set_field inset;
11939 } inset_table[] = {
11940 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11941 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11942 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11943 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11944 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11945 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11946 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11947 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11948 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11949 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11950 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11951 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11952 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11953 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11954 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11955 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11956 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11957 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11958 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11959 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11960 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11961 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11962 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11963 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11964 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11965 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11966 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11967 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11968 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11969 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11970 {"none", RTE_ETH_INPUT_SET_NONE},
11973 for (i = 0; i < RTE_DIM(inset_table); i++) {
11974 if (!strcmp(string, inset_table[i].str))
11975 return inset_table[i].inset;
11978 return RTE_ETH_INPUT_SET_UNKNOWN;
11982 cmd_set_hash_input_set_parsed(void *parsed_result,
11983 __rte_unused struct cmdline *cl,
11984 __rte_unused void *data)
11986 struct cmd_set_hash_input_set_result *res = parsed_result;
11987 struct rte_eth_hash_filter_info info;
11989 memset(&info, 0, sizeof(info));
11990 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11991 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11992 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11993 info.info.input_set_conf.inset_size = 1;
11994 if (!strcmp(res->select, "select"))
11995 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11996 else if (!strcmp(res->select, "add"))
11997 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11998 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11999 RTE_ETH_FILTER_SET, &info);
12002 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12003 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12004 set_hash_input_set, "set_hash_input_set");
12005 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12006 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12008 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12009 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12011 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12012 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12014 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12015 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12016 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12017 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12018 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12020 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12021 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12022 select, "select#add");
12024 cmdline_parse_inst_t cmd_set_hash_input_set = {
12025 .f = cmd_set_hash_input_set_parsed,
12027 .help_str = "set_hash_input_set <port_id> "
12028 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12029 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12030 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12031 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12032 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12033 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12034 "fld-7th|fld-8th|none select|add",
12036 (void *)&cmd_set_hash_input_set_cmd,
12037 (void *)&cmd_set_hash_input_set_port_id,
12038 (void *)&cmd_set_hash_input_set_flow_type,
12039 (void *)&cmd_set_hash_input_set_field,
12040 (void *)&cmd_set_hash_input_set_select,
12045 /* Set flow director input set */
12046 struct cmd_set_fdir_input_set_result {
12047 cmdline_fixed_string_t set_fdir_input_set;
12049 cmdline_fixed_string_t flow_type;
12050 cmdline_fixed_string_t inset_field;
12051 cmdline_fixed_string_t select;
12055 cmd_set_fdir_input_set_parsed(void *parsed_result,
12056 __rte_unused struct cmdline *cl,
12057 __rte_unused void *data)
12059 struct cmd_set_fdir_input_set_result *res = parsed_result;
12060 struct rte_eth_fdir_filter_info info;
12062 memset(&info, 0, sizeof(info));
12063 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12064 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12065 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12066 info.info.input_set_conf.inset_size = 1;
12067 if (!strcmp(res->select, "select"))
12068 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12069 else if (!strcmp(res->select, "add"))
12070 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12071 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12072 RTE_ETH_FILTER_SET, &info);
12075 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12076 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12077 set_fdir_input_set, "set_fdir_input_set");
12078 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12079 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12081 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12082 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12084 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12085 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12086 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12087 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12089 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12090 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12091 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12092 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12093 "sctp-veri-tag#none");
12094 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12095 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12096 select, "select#add");
12098 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12099 .f = cmd_set_fdir_input_set_parsed,
12101 .help_str = "set_fdir_input_set <port_id> "
12102 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12103 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12104 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12105 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12106 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12107 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12108 "sctp-veri-tag|none select|add",
12110 (void *)&cmd_set_fdir_input_set_cmd,
12111 (void *)&cmd_set_fdir_input_set_port_id,
12112 (void *)&cmd_set_fdir_input_set_flow_type,
12113 (void *)&cmd_set_fdir_input_set_field,
12114 (void *)&cmd_set_fdir_input_set_select,
12119 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12120 struct cmd_mcast_addr_result {
12121 cmdline_fixed_string_t mcast_addr_cmd;
12122 cmdline_fixed_string_t what;
12124 struct ether_addr mc_addr;
12127 static void cmd_mcast_addr_parsed(void *parsed_result,
12128 __attribute__((unused)) struct cmdline *cl,
12129 __attribute__((unused)) void *data)
12131 struct cmd_mcast_addr_result *res = parsed_result;
12133 if (!is_multicast_ether_addr(&res->mc_addr)) {
12134 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12135 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12136 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12137 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12140 if (strcmp(res->what, "add") == 0)
12141 mcast_addr_add(res->port_num, &res->mc_addr);
12143 mcast_addr_remove(res->port_num, &res->mc_addr);
12146 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12147 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12148 mcast_addr_cmd, "mcast_addr");
12149 cmdline_parse_token_string_t cmd_mcast_addr_what =
12150 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12152 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12153 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12154 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12155 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12157 cmdline_parse_inst_t cmd_mcast_addr = {
12158 .f = cmd_mcast_addr_parsed,
12160 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12161 "Add/Remove multicast MAC address on port_id",
12163 (void *)&cmd_mcast_addr_cmd,
12164 (void *)&cmd_mcast_addr_what,
12165 (void *)&cmd_mcast_addr_portnum,
12166 (void *)&cmd_mcast_addr_addr,
12171 /* l2 tunnel config
12172 * only support E-tag now.
12175 /* Ether type config */
12176 struct cmd_config_l2_tunnel_eth_type_result {
12177 cmdline_fixed_string_t port;
12178 cmdline_fixed_string_t config;
12179 cmdline_fixed_string_t all;
12181 cmdline_fixed_string_t l2_tunnel;
12182 cmdline_fixed_string_t l2_tunnel_type;
12183 cmdline_fixed_string_t eth_type;
12184 uint16_t eth_type_val;
12187 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12188 TOKEN_STRING_INITIALIZER
12189 (struct cmd_config_l2_tunnel_eth_type_result,
12191 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12192 TOKEN_STRING_INITIALIZER
12193 (struct cmd_config_l2_tunnel_eth_type_result,
12195 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12196 TOKEN_STRING_INITIALIZER
12197 (struct cmd_config_l2_tunnel_eth_type_result,
12199 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12200 TOKEN_NUM_INITIALIZER
12201 (struct cmd_config_l2_tunnel_eth_type_result,
12203 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12204 TOKEN_STRING_INITIALIZER
12205 (struct cmd_config_l2_tunnel_eth_type_result,
12206 l2_tunnel, "l2-tunnel");
12207 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12208 TOKEN_STRING_INITIALIZER
12209 (struct cmd_config_l2_tunnel_eth_type_result,
12210 l2_tunnel_type, "E-tag");
12211 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12212 TOKEN_STRING_INITIALIZER
12213 (struct cmd_config_l2_tunnel_eth_type_result,
12214 eth_type, "ether-type");
12215 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12216 TOKEN_NUM_INITIALIZER
12217 (struct cmd_config_l2_tunnel_eth_type_result,
12218 eth_type_val, UINT16);
12220 static enum rte_eth_tunnel_type
12221 str2fdir_l2_tunnel_type(char *string)
12225 static const struct {
12227 enum rte_eth_tunnel_type type;
12228 } l2_tunnel_type_str[] = {
12229 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12232 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12233 if (!strcmp(l2_tunnel_type_str[i].str, string))
12234 return l2_tunnel_type_str[i].type;
12236 return RTE_TUNNEL_TYPE_NONE;
12239 /* ether type config for all ports */
12241 cmd_config_l2_tunnel_eth_type_all_parsed
12242 (void *parsed_result,
12243 __attribute__((unused)) struct cmdline *cl,
12244 __attribute__((unused)) void *data)
12246 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12247 struct rte_eth_l2_tunnel_conf entry;
12250 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12251 entry.ether_type = res->eth_type_val;
12253 RTE_ETH_FOREACH_DEV(pid) {
12254 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12258 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12259 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12261 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12263 (void *)&cmd_config_l2_tunnel_eth_type_port,
12264 (void *)&cmd_config_l2_tunnel_eth_type_config,
12265 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12266 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12267 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12268 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12269 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12274 /* ether type config for a specific port */
12276 cmd_config_l2_tunnel_eth_type_specific_parsed(
12277 void *parsed_result,
12278 __attribute__((unused)) struct cmdline *cl,
12279 __attribute__((unused)) void *data)
12281 struct cmd_config_l2_tunnel_eth_type_result *res =
12283 struct rte_eth_l2_tunnel_conf entry;
12285 if (port_id_is_invalid(res->id, ENABLED_WARN))
12288 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12289 entry.ether_type = res->eth_type_val;
12291 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12294 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12295 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12297 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12299 (void *)&cmd_config_l2_tunnel_eth_type_port,
12300 (void *)&cmd_config_l2_tunnel_eth_type_config,
12301 (void *)&cmd_config_l2_tunnel_eth_type_id,
12302 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12303 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12304 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12305 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12310 /* Enable/disable l2 tunnel */
12311 struct cmd_config_l2_tunnel_en_dis_result {
12312 cmdline_fixed_string_t port;
12313 cmdline_fixed_string_t config;
12314 cmdline_fixed_string_t all;
12316 cmdline_fixed_string_t l2_tunnel;
12317 cmdline_fixed_string_t l2_tunnel_type;
12318 cmdline_fixed_string_t en_dis;
12321 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12322 TOKEN_STRING_INITIALIZER
12323 (struct cmd_config_l2_tunnel_en_dis_result,
12325 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12326 TOKEN_STRING_INITIALIZER
12327 (struct cmd_config_l2_tunnel_en_dis_result,
12329 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12330 TOKEN_STRING_INITIALIZER
12331 (struct cmd_config_l2_tunnel_en_dis_result,
12333 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12334 TOKEN_NUM_INITIALIZER
12335 (struct cmd_config_l2_tunnel_en_dis_result,
12337 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12338 TOKEN_STRING_INITIALIZER
12339 (struct cmd_config_l2_tunnel_en_dis_result,
12340 l2_tunnel, "l2-tunnel");
12341 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12342 TOKEN_STRING_INITIALIZER
12343 (struct cmd_config_l2_tunnel_en_dis_result,
12344 l2_tunnel_type, "E-tag");
12345 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12346 TOKEN_STRING_INITIALIZER
12347 (struct cmd_config_l2_tunnel_en_dis_result,
12348 en_dis, "enable#disable");
12350 /* enable/disable l2 tunnel for all ports */
12352 cmd_config_l2_tunnel_en_dis_all_parsed(
12353 void *parsed_result,
12354 __attribute__((unused)) struct cmdline *cl,
12355 __attribute__((unused)) void *data)
12357 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12358 struct rte_eth_l2_tunnel_conf entry;
12362 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12364 if (!strcmp("enable", res->en_dis))
12369 RTE_ETH_FOREACH_DEV(pid) {
12370 rte_eth_dev_l2_tunnel_offload_set(pid,
12372 ETH_L2_TUNNEL_ENABLE_MASK,
12377 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12378 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12380 .help_str = "port config all l2-tunnel E-tag enable|disable",
12382 (void *)&cmd_config_l2_tunnel_en_dis_port,
12383 (void *)&cmd_config_l2_tunnel_en_dis_config,
12384 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12385 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12386 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12387 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12392 /* enable/disable l2 tunnel for a port */
12394 cmd_config_l2_tunnel_en_dis_specific_parsed(
12395 void *parsed_result,
12396 __attribute__((unused)) struct cmdline *cl,
12397 __attribute__((unused)) void *data)
12399 struct cmd_config_l2_tunnel_en_dis_result *res =
12401 struct rte_eth_l2_tunnel_conf entry;
12403 if (port_id_is_invalid(res->id, ENABLED_WARN))
12406 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12408 if (!strcmp("enable", res->en_dis))
12409 rte_eth_dev_l2_tunnel_offload_set(res->id,
12411 ETH_L2_TUNNEL_ENABLE_MASK,
12414 rte_eth_dev_l2_tunnel_offload_set(res->id,
12416 ETH_L2_TUNNEL_ENABLE_MASK,
12420 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12421 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12423 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12425 (void *)&cmd_config_l2_tunnel_en_dis_port,
12426 (void *)&cmd_config_l2_tunnel_en_dis_config,
12427 (void *)&cmd_config_l2_tunnel_en_dis_id,
12428 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12429 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12430 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12435 /* E-tag configuration */
12437 /* Common result structure for all E-tag configuration */
12438 struct cmd_config_e_tag_result {
12439 cmdline_fixed_string_t e_tag;
12440 cmdline_fixed_string_t set;
12441 cmdline_fixed_string_t insertion;
12442 cmdline_fixed_string_t stripping;
12443 cmdline_fixed_string_t forwarding;
12444 cmdline_fixed_string_t filter;
12445 cmdline_fixed_string_t add;
12446 cmdline_fixed_string_t del;
12447 cmdline_fixed_string_t on;
12448 cmdline_fixed_string_t off;
12449 cmdline_fixed_string_t on_off;
12450 cmdline_fixed_string_t port_tag_id;
12451 uint32_t port_tag_id_val;
12452 cmdline_fixed_string_t e_tag_id;
12453 uint16_t e_tag_id_val;
12454 cmdline_fixed_string_t dst_pool;
12455 uint8_t dst_pool_val;
12456 cmdline_fixed_string_t port;
12458 cmdline_fixed_string_t vf;
12462 /* Common CLI fields for all E-tag configuration */
12463 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12464 TOKEN_STRING_INITIALIZER
12465 (struct cmd_config_e_tag_result,
12467 cmdline_parse_token_string_t cmd_config_e_tag_set =
12468 TOKEN_STRING_INITIALIZER
12469 (struct cmd_config_e_tag_result,
12471 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12472 TOKEN_STRING_INITIALIZER
12473 (struct cmd_config_e_tag_result,
12474 insertion, "insertion");
12475 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12476 TOKEN_STRING_INITIALIZER
12477 (struct cmd_config_e_tag_result,
12478 stripping, "stripping");
12479 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12480 TOKEN_STRING_INITIALIZER
12481 (struct cmd_config_e_tag_result,
12482 forwarding, "forwarding");
12483 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12484 TOKEN_STRING_INITIALIZER
12485 (struct cmd_config_e_tag_result,
12487 cmdline_parse_token_string_t cmd_config_e_tag_add =
12488 TOKEN_STRING_INITIALIZER
12489 (struct cmd_config_e_tag_result,
12491 cmdline_parse_token_string_t cmd_config_e_tag_del =
12492 TOKEN_STRING_INITIALIZER
12493 (struct cmd_config_e_tag_result,
12495 cmdline_parse_token_string_t cmd_config_e_tag_on =
12496 TOKEN_STRING_INITIALIZER
12497 (struct cmd_config_e_tag_result,
12499 cmdline_parse_token_string_t cmd_config_e_tag_off =
12500 TOKEN_STRING_INITIALIZER
12501 (struct cmd_config_e_tag_result,
12503 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12504 TOKEN_STRING_INITIALIZER
12505 (struct cmd_config_e_tag_result,
12507 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12508 TOKEN_STRING_INITIALIZER
12509 (struct cmd_config_e_tag_result,
12510 port_tag_id, "port-tag-id");
12511 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12512 TOKEN_NUM_INITIALIZER
12513 (struct cmd_config_e_tag_result,
12514 port_tag_id_val, UINT32);
12515 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12516 TOKEN_STRING_INITIALIZER
12517 (struct cmd_config_e_tag_result,
12518 e_tag_id, "e-tag-id");
12519 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12520 TOKEN_NUM_INITIALIZER
12521 (struct cmd_config_e_tag_result,
12522 e_tag_id_val, UINT16);
12523 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12524 TOKEN_STRING_INITIALIZER
12525 (struct cmd_config_e_tag_result,
12526 dst_pool, "dst-pool");
12527 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12528 TOKEN_NUM_INITIALIZER
12529 (struct cmd_config_e_tag_result,
12530 dst_pool_val, UINT8);
12531 cmdline_parse_token_string_t cmd_config_e_tag_port =
12532 TOKEN_STRING_INITIALIZER
12533 (struct cmd_config_e_tag_result,
12535 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12536 TOKEN_NUM_INITIALIZER
12537 (struct cmd_config_e_tag_result,
12539 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12540 TOKEN_STRING_INITIALIZER
12541 (struct cmd_config_e_tag_result,
12543 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12544 TOKEN_NUM_INITIALIZER
12545 (struct cmd_config_e_tag_result,
12548 /* E-tag insertion configuration */
12550 cmd_config_e_tag_insertion_en_parsed(
12551 void *parsed_result,
12552 __attribute__((unused)) struct cmdline *cl,
12553 __attribute__((unused)) void *data)
12555 struct cmd_config_e_tag_result *res =
12557 struct rte_eth_l2_tunnel_conf entry;
12559 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12562 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12563 entry.tunnel_id = res->port_tag_id_val;
12564 entry.vf_id = res->vf_id;
12565 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12567 ETH_L2_TUNNEL_INSERTION_MASK,
12572 cmd_config_e_tag_insertion_dis_parsed(
12573 void *parsed_result,
12574 __attribute__((unused)) struct cmdline *cl,
12575 __attribute__((unused)) void *data)
12577 struct cmd_config_e_tag_result *res =
12579 struct rte_eth_l2_tunnel_conf entry;
12581 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12584 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12585 entry.vf_id = res->vf_id;
12587 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12589 ETH_L2_TUNNEL_INSERTION_MASK,
12593 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12594 .f = cmd_config_e_tag_insertion_en_parsed,
12596 .help_str = "E-tag ... : E-tag insertion enable",
12598 (void *)&cmd_config_e_tag_e_tag,
12599 (void *)&cmd_config_e_tag_set,
12600 (void *)&cmd_config_e_tag_insertion,
12601 (void *)&cmd_config_e_tag_on,
12602 (void *)&cmd_config_e_tag_port_tag_id,
12603 (void *)&cmd_config_e_tag_port_tag_id_val,
12604 (void *)&cmd_config_e_tag_port,
12605 (void *)&cmd_config_e_tag_port_id,
12606 (void *)&cmd_config_e_tag_vf,
12607 (void *)&cmd_config_e_tag_vf_id,
12612 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12613 .f = cmd_config_e_tag_insertion_dis_parsed,
12615 .help_str = "E-tag ... : E-tag insertion disable",
12617 (void *)&cmd_config_e_tag_e_tag,
12618 (void *)&cmd_config_e_tag_set,
12619 (void *)&cmd_config_e_tag_insertion,
12620 (void *)&cmd_config_e_tag_off,
12621 (void *)&cmd_config_e_tag_port,
12622 (void *)&cmd_config_e_tag_port_id,
12623 (void *)&cmd_config_e_tag_vf,
12624 (void *)&cmd_config_e_tag_vf_id,
12629 /* E-tag stripping configuration */
12631 cmd_config_e_tag_stripping_parsed(
12632 void *parsed_result,
12633 __attribute__((unused)) struct cmdline *cl,
12634 __attribute__((unused)) void *data)
12636 struct cmd_config_e_tag_result *res =
12638 struct rte_eth_l2_tunnel_conf entry;
12640 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12643 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12645 if (!strcmp(res->on_off, "on"))
12646 rte_eth_dev_l2_tunnel_offload_set
12649 ETH_L2_TUNNEL_STRIPPING_MASK,
12652 rte_eth_dev_l2_tunnel_offload_set
12655 ETH_L2_TUNNEL_STRIPPING_MASK,
12659 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12660 .f = cmd_config_e_tag_stripping_parsed,
12662 .help_str = "E-tag ... : E-tag stripping enable/disable",
12664 (void *)&cmd_config_e_tag_e_tag,
12665 (void *)&cmd_config_e_tag_set,
12666 (void *)&cmd_config_e_tag_stripping,
12667 (void *)&cmd_config_e_tag_on_off,
12668 (void *)&cmd_config_e_tag_port,
12669 (void *)&cmd_config_e_tag_port_id,
12674 /* E-tag forwarding configuration */
12676 cmd_config_e_tag_forwarding_parsed(
12677 void *parsed_result,
12678 __attribute__((unused)) struct cmdline *cl,
12679 __attribute__((unused)) void *data)
12681 struct cmd_config_e_tag_result *res = parsed_result;
12682 struct rte_eth_l2_tunnel_conf entry;
12684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12687 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12689 if (!strcmp(res->on_off, "on"))
12690 rte_eth_dev_l2_tunnel_offload_set
12693 ETH_L2_TUNNEL_FORWARDING_MASK,
12696 rte_eth_dev_l2_tunnel_offload_set
12699 ETH_L2_TUNNEL_FORWARDING_MASK,
12703 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12704 .f = cmd_config_e_tag_forwarding_parsed,
12706 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12708 (void *)&cmd_config_e_tag_e_tag,
12709 (void *)&cmd_config_e_tag_set,
12710 (void *)&cmd_config_e_tag_forwarding,
12711 (void *)&cmd_config_e_tag_on_off,
12712 (void *)&cmd_config_e_tag_port,
12713 (void *)&cmd_config_e_tag_port_id,
12718 /* E-tag filter configuration */
12720 cmd_config_e_tag_filter_add_parsed(
12721 void *parsed_result,
12722 __attribute__((unused)) struct cmdline *cl,
12723 __attribute__((unused)) void *data)
12725 struct cmd_config_e_tag_result *res = parsed_result;
12726 struct rte_eth_l2_tunnel_conf entry;
12729 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12732 if (res->e_tag_id_val > 0x3fff) {
12733 printf("e-tag-id must be equal or less than 0x3fff.\n");
12737 ret = rte_eth_dev_filter_supported(res->port_id,
12738 RTE_ETH_FILTER_L2_TUNNEL);
12740 printf("E-tag filter is not supported on port %u.\n",
12745 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12746 entry.tunnel_id = res->e_tag_id_val;
12747 entry.pool = res->dst_pool_val;
12749 ret = rte_eth_dev_filter_ctrl(res->port_id,
12750 RTE_ETH_FILTER_L2_TUNNEL,
12751 RTE_ETH_FILTER_ADD,
12754 printf("E-tag filter programming error: (%s)\n",
12758 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12759 .f = cmd_config_e_tag_filter_add_parsed,
12761 .help_str = "E-tag ... : E-tag filter add",
12763 (void *)&cmd_config_e_tag_e_tag,
12764 (void *)&cmd_config_e_tag_set,
12765 (void *)&cmd_config_e_tag_filter,
12766 (void *)&cmd_config_e_tag_add,
12767 (void *)&cmd_config_e_tag_e_tag_id,
12768 (void *)&cmd_config_e_tag_e_tag_id_val,
12769 (void *)&cmd_config_e_tag_dst_pool,
12770 (void *)&cmd_config_e_tag_dst_pool_val,
12771 (void *)&cmd_config_e_tag_port,
12772 (void *)&cmd_config_e_tag_port_id,
12778 cmd_config_e_tag_filter_del_parsed(
12779 void *parsed_result,
12780 __attribute__((unused)) struct cmdline *cl,
12781 __attribute__((unused)) void *data)
12783 struct cmd_config_e_tag_result *res = parsed_result;
12784 struct rte_eth_l2_tunnel_conf entry;
12787 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12790 if (res->e_tag_id_val > 0x3fff) {
12791 printf("e-tag-id must be less than 0x3fff.\n");
12795 ret = rte_eth_dev_filter_supported(res->port_id,
12796 RTE_ETH_FILTER_L2_TUNNEL);
12798 printf("E-tag filter is not supported on port %u.\n",
12803 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12804 entry.tunnel_id = res->e_tag_id_val;
12806 ret = rte_eth_dev_filter_ctrl(res->port_id,
12807 RTE_ETH_FILTER_L2_TUNNEL,
12808 RTE_ETH_FILTER_DELETE,
12811 printf("E-tag filter programming error: (%s)\n",
12815 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12816 .f = cmd_config_e_tag_filter_del_parsed,
12818 .help_str = "E-tag ... : E-tag filter delete",
12820 (void *)&cmd_config_e_tag_e_tag,
12821 (void *)&cmd_config_e_tag_set,
12822 (void *)&cmd_config_e_tag_filter,
12823 (void *)&cmd_config_e_tag_del,
12824 (void *)&cmd_config_e_tag_e_tag_id,
12825 (void *)&cmd_config_e_tag_e_tag_id_val,
12826 (void *)&cmd_config_e_tag_port,
12827 (void *)&cmd_config_e_tag_port_id,
12832 /* vf vlan anti spoof configuration */
12834 /* Common result structure for vf vlan anti spoof */
12835 struct cmd_vf_vlan_anti_spoof_result {
12836 cmdline_fixed_string_t set;
12837 cmdline_fixed_string_t vf;
12838 cmdline_fixed_string_t vlan;
12839 cmdline_fixed_string_t antispoof;
12842 cmdline_fixed_string_t on_off;
12845 /* Common CLI fields for vf vlan anti spoof enable disable */
12846 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12847 TOKEN_STRING_INITIALIZER
12848 (struct cmd_vf_vlan_anti_spoof_result,
12850 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12851 TOKEN_STRING_INITIALIZER
12852 (struct cmd_vf_vlan_anti_spoof_result,
12854 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12855 TOKEN_STRING_INITIALIZER
12856 (struct cmd_vf_vlan_anti_spoof_result,
12858 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12859 TOKEN_STRING_INITIALIZER
12860 (struct cmd_vf_vlan_anti_spoof_result,
12861 antispoof, "antispoof");
12862 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12863 TOKEN_NUM_INITIALIZER
12864 (struct cmd_vf_vlan_anti_spoof_result,
12866 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12867 TOKEN_NUM_INITIALIZER
12868 (struct cmd_vf_vlan_anti_spoof_result,
12870 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12871 TOKEN_STRING_INITIALIZER
12872 (struct cmd_vf_vlan_anti_spoof_result,
12876 cmd_set_vf_vlan_anti_spoof_parsed(
12877 void *parsed_result,
12878 __attribute__((unused)) struct cmdline *cl,
12879 __attribute__((unused)) void *data)
12881 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12882 int ret = -ENOTSUP;
12884 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12886 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12889 #ifdef RTE_LIBRTE_IXGBE_PMD
12890 if (ret == -ENOTSUP)
12891 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12892 res->vf_id, is_on);
12894 #ifdef RTE_LIBRTE_I40E_PMD
12895 if (ret == -ENOTSUP)
12896 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12897 res->vf_id, is_on);
12899 #ifdef RTE_LIBRTE_BNXT_PMD
12900 if (ret == -ENOTSUP)
12901 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12902 res->vf_id, is_on);
12909 printf("invalid vf_id %d\n", res->vf_id);
12912 printf("invalid port_id %d\n", res->port_id);
12915 printf("function not implemented\n");
12918 printf("programming error: (%s)\n", strerror(-ret));
12922 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12923 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12925 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12927 (void *)&cmd_vf_vlan_anti_spoof_set,
12928 (void *)&cmd_vf_vlan_anti_spoof_vf,
12929 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12930 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12931 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12932 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12933 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12938 /* vf mac anti spoof configuration */
12940 /* Common result structure for vf mac anti spoof */
12941 struct cmd_vf_mac_anti_spoof_result {
12942 cmdline_fixed_string_t set;
12943 cmdline_fixed_string_t vf;
12944 cmdline_fixed_string_t mac;
12945 cmdline_fixed_string_t antispoof;
12948 cmdline_fixed_string_t on_off;
12951 /* Common CLI fields for vf mac anti spoof enable disable */
12952 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12953 TOKEN_STRING_INITIALIZER
12954 (struct cmd_vf_mac_anti_spoof_result,
12956 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12957 TOKEN_STRING_INITIALIZER
12958 (struct cmd_vf_mac_anti_spoof_result,
12960 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12961 TOKEN_STRING_INITIALIZER
12962 (struct cmd_vf_mac_anti_spoof_result,
12964 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12965 TOKEN_STRING_INITIALIZER
12966 (struct cmd_vf_mac_anti_spoof_result,
12967 antispoof, "antispoof");
12968 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12969 TOKEN_NUM_INITIALIZER
12970 (struct cmd_vf_mac_anti_spoof_result,
12972 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12973 TOKEN_NUM_INITIALIZER
12974 (struct cmd_vf_mac_anti_spoof_result,
12976 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12977 TOKEN_STRING_INITIALIZER
12978 (struct cmd_vf_mac_anti_spoof_result,
12982 cmd_set_vf_mac_anti_spoof_parsed(
12983 void *parsed_result,
12984 __attribute__((unused)) struct cmdline *cl,
12985 __attribute__((unused)) void *data)
12987 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12988 int ret = -ENOTSUP;
12990 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12992 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12995 #ifdef RTE_LIBRTE_IXGBE_PMD
12996 if (ret == -ENOTSUP)
12997 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12998 res->vf_id, is_on);
13000 #ifdef RTE_LIBRTE_I40E_PMD
13001 if (ret == -ENOTSUP)
13002 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13003 res->vf_id, is_on);
13005 #ifdef RTE_LIBRTE_BNXT_PMD
13006 if (ret == -ENOTSUP)
13007 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13008 res->vf_id, is_on);
13015 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13018 printf("invalid port_id %d\n", res->port_id);
13021 printf("function not implemented\n");
13024 printf("programming error: (%s)\n", strerror(-ret));
13028 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13029 .f = cmd_set_vf_mac_anti_spoof_parsed,
13031 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13033 (void *)&cmd_vf_mac_anti_spoof_set,
13034 (void *)&cmd_vf_mac_anti_spoof_vf,
13035 (void *)&cmd_vf_mac_anti_spoof_mac,
13036 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13037 (void *)&cmd_vf_mac_anti_spoof_port_id,
13038 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13039 (void *)&cmd_vf_mac_anti_spoof_on_off,
13044 /* vf vlan strip queue configuration */
13046 /* Common result structure for vf mac anti spoof */
13047 struct cmd_vf_vlan_stripq_result {
13048 cmdline_fixed_string_t set;
13049 cmdline_fixed_string_t vf;
13050 cmdline_fixed_string_t vlan;
13051 cmdline_fixed_string_t stripq;
13054 cmdline_fixed_string_t on_off;
13057 /* Common CLI fields for vf vlan strip enable disable */
13058 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13059 TOKEN_STRING_INITIALIZER
13060 (struct cmd_vf_vlan_stripq_result,
13062 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13063 TOKEN_STRING_INITIALIZER
13064 (struct cmd_vf_vlan_stripq_result,
13066 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13067 TOKEN_STRING_INITIALIZER
13068 (struct cmd_vf_vlan_stripq_result,
13070 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13071 TOKEN_STRING_INITIALIZER
13072 (struct cmd_vf_vlan_stripq_result,
13074 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13075 TOKEN_NUM_INITIALIZER
13076 (struct cmd_vf_vlan_stripq_result,
13078 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13079 TOKEN_NUM_INITIALIZER
13080 (struct cmd_vf_vlan_stripq_result,
13082 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13083 TOKEN_STRING_INITIALIZER
13084 (struct cmd_vf_vlan_stripq_result,
13088 cmd_set_vf_vlan_stripq_parsed(
13089 void *parsed_result,
13090 __attribute__((unused)) struct cmdline *cl,
13091 __attribute__((unused)) void *data)
13093 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13094 int ret = -ENOTSUP;
13096 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13098 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13101 #ifdef RTE_LIBRTE_IXGBE_PMD
13102 if (ret == -ENOTSUP)
13103 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13104 res->vf_id, is_on);
13106 #ifdef RTE_LIBRTE_I40E_PMD
13107 if (ret == -ENOTSUP)
13108 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13109 res->vf_id, is_on);
13111 #ifdef RTE_LIBRTE_BNXT_PMD
13112 if (ret == -ENOTSUP)
13113 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13114 res->vf_id, is_on);
13121 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13124 printf("invalid port_id %d\n", res->port_id);
13127 printf("function not implemented\n");
13130 printf("programming error: (%s)\n", strerror(-ret));
13134 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13135 .f = cmd_set_vf_vlan_stripq_parsed,
13137 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13139 (void *)&cmd_vf_vlan_stripq_set,
13140 (void *)&cmd_vf_vlan_stripq_vf,
13141 (void *)&cmd_vf_vlan_stripq_vlan,
13142 (void *)&cmd_vf_vlan_stripq_stripq,
13143 (void *)&cmd_vf_vlan_stripq_port_id,
13144 (void *)&cmd_vf_vlan_stripq_vf_id,
13145 (void *)&cmd_vf_vlan_stripq_on_off,
13150 /* vf vlan insert configuration */
13152 /* Common result structure for vf vlan insert */
13153 struct cmd_vf_vlan_insert_result {
13154 cmdline_fixed_string_t set;
13155 cmdline_fixed_string_t vf;
13156 cmdline_fixed_string_t vlan;
13157 cmdline_fixed_string_t insert;
13163 /* Common CLI fields for vf vlan insert enable disable */
13164 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13165 TOKEN_STRING_INITIALIZER
13166 (struct cmd_vf_vlan_insert_result,
13168 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13169 TOKEN_STRING_INITIALIZER
13170 (struct cmd_vf_vlan_insert_result,
13172 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13173 TOKEN_STRING_INITIALIZER
13174 (struct cmd_vf_vlan_insert_result,
13176 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13177 TOKEN_STRING_INITIALIZER
13178 (struct cmd_vf_vlan_insert_result,
13180 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13181 TOKEN_NUM_INITIALIZER
13182 (struct cmd_vf_vlan_insert_result,
13184 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13185 TOKEN_NUM_INITIALIZER
13186 (struct cmd_vf_vlan_insert_result,
13188 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13189 TOKEN_NUM_INITIALIZER
13190 (struct cmd_vf_vlan_insert_result,
13194 cmd_set_vf_vlan_insert_parsed(
13195 void *parsed_result,
13196 __attribute__((unused)) struct cmdline *cl,
13197 __attribute__((unused)) void *data)
13199 struct cmd_vf_vlan_insert_result *res = parsed_result;
13200 int ret = -ENOTSUP;
13202 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13205 #ifdef RTE_LIBRTE_IXGBE_PMD
13206 if (ret == -ENOTSUP)
13207 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13210 #ifdef RTE_LIBRTE_I40E_PMD
13211 if (ret == -ENOTSUP)
13212 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13215 #ifdef RTE_LIBRTE_BNXT_PMD
13216 if (ret == -ENOTSUP)
13217 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13225 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13228 printf("invalid port_id %d\n", res->port_id);
13231 printf("function not implemented\n");
13234 printf("programming error: (%s)\n", strerror(-ret));
13238 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13239 .f = cmd_set_vf_vlan_insert_parsed,
13241 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13243 (void *)&cmd_vf_vlan_insert_set,
13244 (void *)&cmd_vf_vlan_insert_vf,
13245 (void *)&cmd_vf_vlan_insert_vlan,
13246 (void *)&cmd_vf_vlan_insert_insert,
13247 (void *)&cmd_vf_vlan_insert_port_id,
13248 (void *)&cmd_vf_vlan_insert_vf_id,
13249 (void *)&cmd_vf_vlan_insert_vlan_id,
13254 /* tx loopback configuration */
13256 /* Common result structure for tx loopback */
13257 struct cmd_tx_loopback_result {
13258 cmdline_fixed_string_t set;
13259 cmdline_fixed_string_t tx;
13260 cmdline_fixed_string_t loopback;
13262 cmdline_fixed_string_t on_off;
13265 /* Common CLI fields for tx loopback enable disable */
13266 cmdline_parse_token_string_t cmd_tx_loopback_set =
13267 TOKEN_STRING_INITIALIZER
13268 (struct cmd_tx_loopback_result,
13270 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13271 TOKEN_STRING_INITIALIZER
13272 (struct cmd_tx_loopback_result,
13274 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13275 TOKEN_STRING_INITIALIZER
13276 (struct cmd_tx_loopback_result,
13277 loopback, "loopback");
13278 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13279 TOKEN_NUM_INITIALIZER
13280 (struct cmd_tx_loopback_result,
13282 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13283 TOKEN_STRING_INITIALIZER
13284 (struct cmd_tx_loopback_result,
13288 cmd_set_tx_loopback_parsed(
13289 void *parsed_result,
13290 __attribute__((unused)) struct cmdline *cl,
13291 __attribute__((unused)) void *data)
13293 struct cmd_tx_loopback_result *res = parsed_result;
13294 int ret = -ENOTSUP;
13296 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13298 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13301 #ifdef RTE_LIBRTE_IXGBE_PMD
13302 if (ret == -ENOTSUP)
13303 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13305 #ifdef RTE_LIBRTE_I40E_PMD
13306 if (ret == -ENOTSUP)
13307 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13309 #ifdef RTE_LIBRTE_BNXT_PMD
13310 if (ret == -ENOTSUP)
13311 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13313 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13314 if (ret == -ENOTSUP)
13315 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13322 printf("invalid is_on %d\n", is_on);
13325 printf("invalid port_id %d\n", res->port_id);
13328 printf("function not implemented\n");
13331 printf("programming error: (%s)\n", strerror(-ret));
13335 cmdline_parse_inst_t cmd_set_tx_loopback = {
13336 .f = cmd_set_tx_loopback_parsed,
13338 .help_str = "set tx loopback <port_id> on|off",
13340 (void *)&cmd_tx_loopback_set,
13341 (void *)&cmd_tx_loopback_tx,
13342 (void *)&cmd_tx_loopback_loopback,
13343 (void *)&cmd_tx_loopback_port_id,
13344 (void *)&cmd_tx_loopback_on_off,
13349 /* all queues drop enable configuration */
13351 /* Common result structure for all queues drop enable */
13352 struct cmd_all_queues_drop_en_result {
13353 cmdline_fixed_string_t set;
13354 cmdline_fixed_string_t all;
13355 cmdline_fixed_string_t queues;
13356 cmdline_fixed_string_t drop;
13358 cmdline_fixed_string_t on_off;
13361 /* Common CLI fields for tx loopback enable disable */
13362 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13363 TOKEN_STRING_INITIALIZER
13364 (struct cmd_all_queues_drop_en_result,
13366 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13367 TOKEN_STRING_INITIALIZER
13368 (struct cmd_all_queues_drop_en_result,
13370 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13371 TOKEN_STRING_INITIALIZER
13372 (struct cmd_all_queues_drop_en_result,
13374 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13375 TOKEN_STRING_INITIALIZER
13376 (struct cmd_all_queues_drop_en_result,
13378 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13379 TOKEN_NUM_INITIALIZER
13380 (struct cmd_all_queues_drop_en_result,
13382 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13383 TOKEN_STRING_INITIALIZER
13384 (struct cmd_all_queues_drop_en_result,
13388 cmd_set_all_queues_drop_en_parsed(
13389 void *parsed_result,
13390 __attribute__((unused)) struct cmdline *cl,
13391 __attribute__((unused)) void *data)
13393 struct cmd_all_queues_drop_en_result *res = parsed_result;
13394 int ret = -ENOTSUP;
13395 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13397 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13400 #ifdef RTE_LIBRTE_IXGBE_PMD
13401 if (ret == -ENOTSUP)
13402 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13404 #ifdef RTE_LIBRTE_BNXT_PMD
13405 if (ret == -ENOTSUP)
13406 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13412 printf("invalid is_on %d\n", is_on);
13415 printf("invalid port_id %d\n", res->port_id);
13418 printf("function not implemented\n");
13421 printf("programming error: (%s)\n", strerror(-ret));
13425 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13426 .f = cmd_set_all_queues_drop_en_parsed,
13428 .help_str = "set all queues drop <port_id> on|off",
13430 (void *)&cmd_all_queues_drop_en_set,
13431 (void *)&cmd_all_queues_drop_en_all,
13432 (void *)&cmd_all_queues_drop_en_queues,
13433 (void *)&cmd_all_queues_drop_en_drop,
13434 (void *)&cmd_all_queues_drop_en_port_id,
13435 (void *)&cmd_all_queues_drop_en_on_off,
13440 /* vf split drop enable configuration */
13442 /* Common result structure for vf split drop enable */
13443 struct cmd_vf_split_drop_en_result {
13444 cmdline_fixed_string_t set;
13445 cmdline_fixed_string_t vf;
13446 cmdline_fixed_string_t split;
13447 cmdline_fixed_string_t drop;
13450 cmdline_fixed_string_t on_off;
13453 /* Common CLI fields for vf split drop enable disable */
13454 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13455 TOKEN_STRING_INITIALIZER
13456 (struct cmd_vf_split_drop_en_result,
13458 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13459 TOKEN_STRING_INITIALIZER
13460 (struct cmd_vf_split_drop_en_result,
13462 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13463 TOKEN_STRING_INITIALIZER
13464 (struct cmd_vf_split_drop_en_result,
13466 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13467 TOKEN_STRING_INITIALIZER
13468 (struct cmd_vf_split_drop_en_result,
13470 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13471 TOKEN_NUM_INITIALIZER
13472 (struct cmd_vf_split_drop_en_result,
13474 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13475 TOKEN_NUM_INITIALIZER
13476 (struct cmd_vf_split_drop_en_result,
13478 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13479 TOKEN_STRING_INITIALIZER
13480 (struct cmd_vf_split_drop_en_result,
13484 cmd_set_vf_split_drop_en_parsed(
13485 void *parsed_result,
13486 __attribute__((unused)) struct cmdline *cl,
13487 __attribute__((unused)) void *data)
13489 struct cmd_vf_split_drop_en_result *res = parsed_result;
13490 int ret = -ENOTSUP;
13491 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13493 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13496 #ifdef RTE_LIBRTE_IXGBE_PMD
13497 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13504 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13507 printf("invalid port_id %d\n", res->port_id);
13510 printf("not supported on port %d\n", res->port_id);
13513 printf("programming error: (%s)\n", strerror(-ret));
13517 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13518 .f = cmd_set_vf_split_drop_en_parsed,
13520 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13522 (void *)&cmd_vf_split_drop_en_set,
13523 (void *)&cmd_vf_split_drop_en_vf,
13524 (void *)&cmd_vf_split_drop_en_split,
13525 (void *)&cmd_vf_split_drop_en_drop,
13526 (void *)&cmd_vf_split_drop_en_port_id,
13527 (void *)&cmd_vf_split_drop_en_vf_id,
13528 (void *)&cmd_vf_split_drop_en_on_off,
13533 /* vf mac address configuration */
13535 /* Common result structure for vf mac address */
13536 struct cmd_set_vf_mac_addr_result {
13537 cmdline_fixed_string_t set;
13538 cmdline_fixed_string_t vf;
13539 cmdline_fixed_string_t mac;
13540 cmdline_fixed_string_t addr;
13543 struct ether_addr mac_addr;
13547 /* Common CLI fields for vf split drop enable disable */
13548 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13549 TOKEN_STRING_INITIALIZER
13550 (struct cmd_set_vf_mac_addr_result,
13552 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13553 TOKEN_STRING_INITIALIZER
13554 (struct cmd_set_vf_mac_addr_result,
13556 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13557 TOKEN_STRING_INITIALIZER
13558 (struct cmd_set_vf_mac_addr_result,
13560 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13561 TOKEN_STRING_INITIALIZER
13562 (struct cmd_set_vf_mac_addr_result,
13564 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13565 TOKEN_NUM_INITIALIZER
13566 (struct cmd_set_vf_mac_addr_result,
13568 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13569 TOKEN_NUM_INITIALIZER
13570 (struct cmd_set_vf_mac_addr_result,
13572 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13573 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13577 cmd_set_vf_mac_addr_parsed(
13578 void *parsed_result,
13579 __attribute__((unused)) struct cmdline *cl,
13580 __attribute__((unused)) void *data)
13582 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13583 int ret = -ENOTSUP;
13585 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13588 #ifdef RTE_LIBRTE_IXGBE_PMD
13589 if (ret == -ENOTSUP)
13590 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13593 #ifdef RTE_LIBRTE_I40E_PMD
13594 if (ret == -ENOTSUP)
13595 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13598 #ifdef RTE_LIBRTE_BNXT_PMD
13599 if (ret == -ENOTSUP)
13600 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13608 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13611 printf("invalid port_id %d\n", res->port_id);
13614 printf("function not implemented\n");
13617 printf("programming error: (%s)\n", strerror(-ret));
13621 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13622 .f = cmd_set_vf_mac_addr_parsed,
13624 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13626 (void *)&cmd_set_vf_mac_addr_set,
13627 (void *)&cmd_set_vf_mac_addr_vf,
13628 (void *)&cmd_set_vf_mac_addr_mac,
13629 (void *)&cmd_set_vf_mac_addr_addr,
13630 (void *)&cmd_set_vf_mac_addr_port_id,
13631 (void *)&cmd_set_vf_mac_addr_vf_id,
13632 (void *)&cmd_set_vf_mac_addr_mac_addr,
13637 /* MACsec configuration */
13639 /* Common result structure for MACsec offload enable */
13640 struct cmd_macsec_offload_on_result {
13641 cmdline_fixed_string_t set;
13642 cmdline_fixed_string_t macsec;
13643 cmdline_fixed_string_t offload;
13645 cmdline_fixed_string_t on;
13646 cmdline_fixed_string_t encrypt;
13647 cmdline_fixed_string_t en_on_off;
13648 cmdline_fixed_string_t replay_protect;
13649 cmdline_fixed_string_t rp_on_off;
13652 /* Common CLI fields for MACsec offload disable */
13653 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13654 TOKEN_STRING_INITIALIZER
13655 (struct cmd_macsec_offload_on_result,
13657 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13658 TOKEN_STRING_INITIALIZER
13659 (struct cmd_macsec_offload_on_result,
13661 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13662 TOKEN_STRING_INITIALIZER
13663 (struct cmd_macsec_offload_on_result,
13664 offload, "offload");
13665 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13666 TOKEN_NUM_INITIALIZER
13667 (struct cmd_macsec_offload_on_result,
13669 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13670 TOKEN_STRING_INITIALIZER
13671 (struct cmd_macsec_offload_on_result,
13673 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13674 TOKEN_STRING_INITIALIZER
13675 (struct cmd_macsec_offload_on_result,
13676 encrypt, "encrypt");
13677 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13678 TOKEN_STRING_INITIALIZER
13679 (struct cmd_macsec_offload_on_result,
13680 en_on_off, "on#off");
13681 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13682 TOKEN_STRING_INITIALIZER
13683 (struct cmd_macsec_offload_on_result,
13684 replay_protect, "replay-protect");
13685 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13686 TOKEN_STRING_INITIALIZER
13687 (struct cmd_macsec_offload_on_result,
13688 rp_on_off, "on#off");
13691 cmd_set_macsec_offload_on_parsed(
13692 void *parsed_result,
13693 __attribute__((unused)) struct cmdline *cl,
13694 __attribute__((unused)) void *data)
13696 struct cmd_macsec_offload_on_result *res = parsed_result;
13697 int ret = -ENOTSUP;
13698 portid_t port_id = res->port_id;
13699 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13700 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13701 struct rte_eth_dev_info dev_info;
13703 if (port_id_is_invalid(port_id, ENABLED_WARN))
13705 if (!port_is_stopped(port_id)) {
13706 printf("Please stop port %d first\n", port_id);
13710 rte_eth_dev_info_get(port_id, &dev_info);
13711 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13712 #ifdef RTE_LIBRTE_IXGBE_PMD
13713 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13721 ports[port_id].dev_conf.txmode.offloads |=
13722 DEV_TX_OFFLOAD_MACSEC_INSERT;
13723 cmd_reconfig_device_queue(port_id, 1, 1);
13726 printf("invalid port_id %d\n", port_id);
13729 printf("not supported on port %d\n", port_id);
13732 printf("programming error: (%s)\n", strerror(-ret));
13736 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13737 .f = cmd_set_macsec_offload_on_parsed,
13739 .help_str = "set macsec offload <port_id> on "
13740 "encrypt on|off replay-protect on|off",
13742 (void *)&cmd_macsec_offload_on_set,
13743 (void *)&cmd_macsec_offload_on_macsec,
13744 (void *)&cmd_macsec_offload_on_offload,
13745 (void *)&cmd_macsec_offload_on_port_id,
13746 (void *)&cmd_macsec_offload_on_on,
13747 (void *)&cmd_macsec_offload_on_encrypt,
13748 (void *)&cmd_macsec_offload_on_en_on_off,
13749 (void *)&cmd_macsec_offload_on_replay_protect,
13750 (void *)&cmd_macsec_offload_on_rp_on_off,
13755 /* Common result structure for MACsec offload disable */
13756 struct cmd_macsec_offload_off_result {
13757 cmdline_fixed_string_t set;
13758 cmdline_fixed_string_t macsec;
13759 cmdline_fixed_string_t offload;
13761 cmdline_fixed_string_t off;
13764 /* Common CLI fields for MACsec offload disable */
13765 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13766 TOKEN_STRING_INITIALIZER
13767 (struct cmd_macsec_offload_off_result,
13769 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13770 TOKEN_STRING_INITIALIZER
13771 (struct cmd_macsec_offload_off_result,
13773 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13774 TOKEN_STRING_INITIALIZER
13775 (struct cmd_macsec_offload_off_result,
13776 offload, "offload");
13777 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13778 TOKEN_NUM_INITIALIZER
13779 (struct cmd_macsec_offload_off_result,
13781 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13782 TOKEN_STRING_INITIALIZER
13783 (struct cmd_macsec_offload_off_result,
13787 cmd_set_macsec_offload_off_parsed(
13788 void *parsed_result,
13789 __attribute__((unused)) struct cmdline *cl,
13790 __attribute__((unused)) void *data)
13792 struct cmd_macsec_offload_off_result *res = parsed_result;
13793 int ret = -ENOTSUP;
13794 struct rte_eth_dev_info dev_info;
13795 portid_t port_id = res->port_id;
13797 if (port_id_is_invalid(port_id, ENABLED_WARN))
13799 if (!port_is_stopped(port_id)) {
13800 printf("Please stop port %d first\n", port_id);
13804 rte_eth_dev_info_get(port_id, &dev_info);
13805 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13806 #ifdef RTE_LIBRTE_IXGBE_PMD
13807 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13812 ports[port_id].dev_conf.txmode.offloads &=
13813 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13814 cmd_reconfig_device_queue(port_id, 1, 1);
13817 printf("invalid port_id %d\n", port_id);
13820 printf("not supported on port %d\n", port_id);
13823 printf("programming error: (%s)\n", strerror(-ret));
13827 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13828 .f = cmd_set_macsec_offload_off_parsed,
13830 .help_str = "set macsec offload <port_id> off",
13832 (void *)&cmd_macsec_offload_off_set,
13833 (void *)&cmd_macsec_offload_off_macsec,
13834 (void *)&cmd_macsec_offload_off_offload,
13835 (void *)&cmd_macsec_offload_off_port_id,
13836 (void *)&cmd_macsec_offload_off_off,
13841 /* Common result structure for MACsec secure connection configure */
13842 struct cmd_macsec_sc_result {
13843 cmdline_fixed_string_t set;
13844 cmdline_fixed_string_t macsec;
13845 cmdline_fixed_string_t sc;
13846 cmdline_fixed_string_t tx_rx;
13848 struct ether_addr mac;
13852 /* Common CLI fields for MACsec secure connection configure */
13853 cmdline_parse_token_string_t cmd_macsec_sc_set =
13854 TOKEN_STRING_INITIALIZER
13855 (struct cmd_macsec_sc_result,
13857 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13858 TOKEN_STRING_INITIALIZER
13859 (struct cmd_macsec_sc_result,
13861 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13862 TOKEN_STRING_INITIALIZER
13863 (struct cmd_macsec_sc_result,
13865 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13866 TOKEN_STRING_INITIALIZER
13867 (struct cmd_macsec_sc_result,
13869 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13870 TOKEN_NUM_INITIALIZER
13871 (struct cmd_macsec_sc_result,
13873 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13874 TOKEN_ETHERADDR_INITIALIZER
13875 (struct cmd_macsec_sc_result,
13877 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13878 TOKEN_NUM_INITIALIZER
13879 (struct cmd_macsec_sc_result,
13883 cmd_set_macsec_sc_parsed(
13884 void *parsed_result,
13885 __attribute__((unused)) struct cmdline *cl,
13886 __attribute__((unused)) void *data)
13888 struct cmd_macsec_sc_result *res = parsed_result;
13889 int ret = -ENOTSUP;
13890 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13892 #ifdef RTE_LIBRTE_IXGBE_PMD
13894 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13895 res->mac.addr_bytes) :
13896 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13897 res->mac.addr_bytes, res->pi);
13899 RTE_SET_USED(is_tx);
13905 printf("invalid port_id %d\n", res->port_id);
13908 printf("not supported on port %d\n", res->port_id);
13911 printf("programming error: (%s)\n", strerror(-ret));
13915 cmdline_parse_inst_t cmd_set_macsec_sc = {
13916 .f = cmd_set_macsec_sc_parsed,
13918 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13920 (void *)&cmd_macsec_sc_set,
13921 (void *)&cmd_macsec_sc_macsec,
13922 (void *)&cmd_macsec_sc_sc,
13923 (void *)&cmd_macsec_sc_tx_rx,
13924 (void *)&cmd_macsec_sc_port_id,
13925 (void *)&cmd_macsec_sc_mac,
13926 (void *)&cmd_macsec_sc_pi,
13931 /* Common result structure for MACsec secure connection configure */
13932 struct cmd_macsec_sa_result {
13933 cmdline_fixed_string_t set;
13934 cmdline_fixed_string_t macsec;
13935 cmdline_fixed_string_t sa;
13936 cmdline_fixed_string_t tx_rx;
13941 cmdline_fixed_string_t key;
13944 /* Common CLI fields for MACsec secure connection configure */
13945 cmdline_parse_token_string_t cmd_macsec_sa_set =
13946 TOKEN_STRING_INITIALIZER
13947 (struct cmd_macsec_sa_result,
13949 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13950 TOKEN_STRING_INITIALIZER
13951 (struct cmd_macsec_sa_result,
13953 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13954 TOKEN_STRING_INITIALIZER
13955 (struct cmd_macsec_sa_result,
13957 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13958 TOKEN_STRING_INITIALIZER
13959 (struct cmd_macsec_sa_result,
13961 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13962 TOKEN_NUM_INITIALIZER
13963 (struct cmd_macsec_sa_result,
13965 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13966 TOKEN_NUM_INITIALIZER
13967 (struct cmd_macsec_sa_result,
13969 cmdline_parse_token_num_t cmd_macsec_sa_an =
13970 TOKEN_NUM_INITIALIZER
13971 (struct cmd_macsec_sa_result,
13973 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13974 TOKEN_NUM_INITIALIZER
13975 (struct cmd_macsec_sa_result,
13977 cmdline_parse_token_string_t cmd_macsec_sa_key =
13978 TOKEN_STRING_INITIALIZER
13979 (struct cmd_macsec_sa_result,
13983 cmd_set_macsec_sa_parsed(
13984 void *parsed_result,
13985 __attribute__((unused)) struct cmdline *cl,
13986 __attribute__((unused)) void *data)
13988 struct cmd_macsec_sa_result *res = parsed_result;
13989 int ret = -ENOTSUP;
13990 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13991 uint8_t key[16] = { 0 };
13997 key_len = strlen(res->key) / 2;
14001 for (i = 0; i < key_len; i++) {
14002 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14005 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14008 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14011 #ifdef RTE_LIBRTE_IXGBE_PMD
14013 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14014 res->idx, res->an, res->pn, key) :
14015 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14016 res->idx, res->an, res->pn, key);
14018 RTE_SET_USED(is_tx);
14025 printf("invalid idx %d or an %d\n", res->idx, res->an);
14028 printf("invalid port_id %d\n", res->port_id);
14031 printf("not supported on port %d\n", res->port_id);
14034 printf("programming error: (%s)\n", strerror(-ret));
14038 cmdline_parse_inst_t cmd_set_macsec_sa = {
14039 .f = cmd_set_macsec_sa_parsed,
14041 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14043 (void *)&cmd_macsec_sa_set,
14044 (void *)&cmd_macsec_sa_macsec,
14045 (void *)&cmd_macsec_sa_sa,
14046 (void *)&cmd_macsec_sa_tx_rx,
14047 (void *)&cmd_macsec_sa_port_id,
14048 (void *)&cmd_macsec_sa_idx,
14049 (void *)&cmd_macsec_sa_an,
14050 (void *)&cmd_macsec_sa_pn,
14051 (void *)&cmd_macsec_sa_key,
14056 /* VF unicast promiscuous mode configuration */
14058 /* Common result structure for VF unicast promiscuous mode */
14059 struct cmd_vf_promisc_result {
14060 cmdline_fixed_string_t set;
14061 cmdline_fixed_string_t vf;
14062 cmdline_fixed_string_t promisc;
14065 cmdline_fixed_string_t on_off;
14068 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14069 cmdline_parse_token_string_t cmd_vf_promisc_set =
14070 TOKEN_STRING_INITIALIZER
14071 (struct cmd_vf_promisc_result,
14073 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14074 TOKEN_STRING_INITIALIZER
14075 (struct cmd_vf_promisc_result,
14077 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14078 TOKEN_STRING_INITIALIZER
14079 (struct cmd_vf_promisc_result,
14080 promisc, "promisc");
14081 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14082 TOKEN_NUM_INITIALIZER
14083 (struct cmd_vf_promisc_result,
14085 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14086 TOKEN_NUM_INITIALIZER
14087 (struct cmd_vf_promisc_result,
14089 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14090 TOKEN_STRING_INITIALIZER
14091 (struct cmd_vf_promisc_result,
14095 cmd_set_vf_promisc_parsed(
14096 void *parsed_result,
14097 __attribute__((unused)) struct cmdline *cl,
14098 __attribute__((unused)) void *data)
14100 struct cmd_vf_promisc_result *res = parsed_result;
14101 int ret = -ENOTSUP;
14103 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14105 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14108 #ifdef RTE_LIBRTE_I40E_PMD
14109 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14110 res->vf_id, is_on);
14117 printf("invalid vf_id %d\n", res->vf_id);
14120 printf("invalid port_id %d\n", res->port_id);
14123 printf("function not implemented\n");
14126 printf("programming error: (%s)\n", strerror(-ret));
14130 cmdline_parse_inst_t cmd_set_vf_promisc = {
14131 .f = cmd_set_vf_promisc_parsed,
14133 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14134 "Set unicast promiscuous mode for a VF from the PF",
14136 (void *)&cmd_vf_promisc_set,
14137 (void *)&cmd_vf_promisc_vf,
14138 (void *)&cmd_vf_promisc_promisc,
14139 (void *)&cmd_vf_promisc_port_id,
14140 (void *)&cmd_vf_promisc_vf_id,
14141 (void *)&cmd_vf_promisc_on_off,
14146 /* VF multicast promiscuous mode configuration */
14148 /* Common result structure for VF multicast promiscuous mode */
14149 struct cmd_vf_allmulti_result {
14150 cmdline_fixed_string_t set;
14151 cmdline_fixed_string_t vf;
14152 cmdline_fixed_string_t allmulti;
14155 cmdline_fixed_string_t on_off;
14158 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14159 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14160 TOKEN_STRING_INITIALIZER
14161 (struct cmd_vf_allmulti_result,
14163 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14164 TOKEN_STRING_INITIALIZER
14165 (struct cmd_vf_allmulti_result,
14167 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14168 TOKEN_STRING_INITIALIZER
14169 (struct cmd_vf_allmulti_result,
14170 allmulti, "allmulti");
14171 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14172 TOKEN_NUM_INITIALIZER
14173 (struct cmd_vf_allmulti_result,
14175 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14176 TOKEN_NUM_INITIALIZER
14177 (struct cmd_vf_allmulti_result,
14179 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14180 TOKEN_STRING_INITIALIZER
14181 (struct cmd_vf_allmulti_result,
14185 cmd_set_vf_allmulti_parsed(
14186 void *parsed_result,
14187 __attribute__((unused)) struct cmdline *cl,
14188 __attribute__((unused)) void *data)
14190 struct cmd_vf_allmulti_result *res = parsed_result;
14191 int ret = -ENOTSUP;
14193 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14195 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14198 #ifdef RTE_LIBRTE_I40E_PMD
14199 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14200 res->vf_id, is_on);
14207 printf("invalid vf_id %d\n", res->vf_id);
14210 printf("invalid port_id %d\n", res->port_id);
14213 printf("function not implemented\n");
14216 printf("programming error: (%s)\n", strerror(-ret));
14220 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14221 .f = cmd_set_vf_allmulti_parsed,
14223 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14224 "Set multicast promiscuous mode for a VF from the PF",
14226 (void *)&cmd_vf_allmulti_set,
14227 (void *)&cmd_vf_allmulti_vf,
14228 (void *)&cmd_vf_allmulti_allmulti,
14229 (void *)&cmd_vf_allmulti_port_id,
14230 (void *)&cmd_vf_allmulti_vf_id,
14231 (void *)&cmd_vf_allmulti_on_off,
14236 /* vf broadcast mode configuration */
14238 /* Common result structure for vf broadcast */
14239 struct cmd_set_vf_broadcast_result {
14240 cmdline_fixed_string_t set;
14241 cmdline_fixed_string_t vf;
14242 cmdline_fixed_string_t broadcast;
14245 cmdline_fixed_string_t on_off;
14248 /* Common CLI fields for vf broadcast enable disable */
14249 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14250 TOKEN_STRING_INITIALIZER
14251 (struct cmd_set_vf_broadcast_result,
14253 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14254 TOKEN_STRING_INITIALIZER
14255 (struct cmd_set_vf_broadcast_result,
14257 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14258 TOKEN_STRING_INITIALIZER
14259 (struct cmd_set_vf_broadcast_result,
14260 broadcast, "broadcast");
14261 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14262 TOKEN_NUM_INITIALIZER
14263 (struct cmd_set_vf_broadcast_result,
14265 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14266 TOKEN_NUM_INITIALIZER
14267 (struct cmd_set_vf_broadcast_result,
14269 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14270 TOKEN_STRING_INITIALIZER
14271 (struct cmd_set_vf_broadcast_result,
14275 cmd_set_vf_broadcast_parsed(
14276 void *parsed_result,
14277 __attribute__((unused)) struct cmdline *cl,
14278 __attribute__((unused)) void *data)
14280 struct cmd_set_vf_broadcast_result *res = parsed_result;
14281 int ret = -ENOTSUP;
14283 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14285 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14288 #ifdef RTE_LIBRTE_I40E_PMD
14289 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14290 res->vf_id, is_on);
14297 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14300 printf("invalid port_id %d\n", res->port_id);
14303 printf("function not implemented\n");
14306 printf("programming error: (%s)\n", strerror(-ret));
14310 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14311 .f = cmd_set_vf_broadcast_parsed,
14313 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14315 (void *)&cmd_set_vf_broadcast_set,
14316 (void *)&cmd_set_vf_broadcast_vf,
14317 (void *)&cmd_set_vf_broadcast_broadcast,
14318 (void *)&cmd_set_vf_broadcast_port_id,
14319 (void *)&cmd_set_vf_broadcast_vf_id,
14320 (void *)&cmd_set_vf_broadcast_on_off,
14325 /* vf vlan tag configuration */
14327 /* Common result structure for vf vlan tag */
14328 struct cmd_set_vf_vlan_tag_result {
14329 cmdline_fixed_string_t set;
14330 cmdline_fixed_string_t vf;
14331 cmdline_fixed_string_t vlan;
14332 cmdline_fixed_string_t tag;
14335 cmdline_fixed_string_t on_off;
14338 /* Common CLI fields for vf vlan tag enable disable */
14339 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14340 TOKEN_STRING_INITIALIZER
14341 (struct cmd_set_vf_vlan_tag_result,
14343 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14344 TOKEN_STRING_INITIALIZER
14345 (struct cmd_set_vf_vlan_tag_result,
14347 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14348 TOKEN_STRING_INITIALIZER
14349 (struct cmd_set_vf_vlan_tag_result,
14351 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14352 TOKEN_STRING_INITIALIZER
14353 (struct cmd_set_vf_vlan_tag_result,
14355 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14356 TOKEN_NUM_INITIALIZER
14357 (struct cmd_set_vf_vlan_tag_result,
14359 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14360 TOKEN_NUM_INITIALIZER
14361 (struct cmd_set_vf_vlan_tag_result,
14363 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14364 TOKEN_STRING_INITIALIZER
14365 (struct cmd_set_vf_vlan_tag_result,
14369 cmd_set_vf_vlan_tag_parsed(
14370 void *parsed_result,
14371 __attribute__((unused)) struct cmdline *cl,
14372 __attribute__((unused)) void *data)
14374 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14375 int ret = -ENOTSUP;
14377 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14379 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14382 #ifdef RTE_LIBRTE_I40E_PMD
14383 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14384 res->vf_id, is_on);
14391 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14394 printf("invalid port_id %d\n", res->port_id);
14397 printf("function not implemented\n");
14400 printf("programming error: (%s)\n", strerror(-ret));
14404 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14405 .f = cmd_set_vf_vlan_tag_parsed,
14407 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14409 (void *)&cmd_set_vf_vlan_tag_set,
14410 (void *)&cmd_set_vf_vlan_tag_vf,
14411 (void *)&cmd_set_vf_vlan_tag_vlan,
14412 (void *)&cmd_set_vf_vlan_tag_tag,
14413 (void *)&cmd_set_vf_vlan_tag_port_id,
14414 (void *)&cmd_set_vf_vlan_tag_vf_id,
14415 (void *)&cmd_set_vf_vlan_tag_on_off,
14420 /* Common definition of VF and TC TX bandwidth configuration */
14421 struct cmd_vf_tc_bw_result {
14422 cmdline_fixed_string_t set;
14423 cmdline_fixed_string_t vf;
14424 cmdline_fixed_string_t tc;
14425 cmdline_fixed_string_t tx;
14426 cmdline_fixed_string_t min_bw;
14427 cmdline_fixed_string_t max_bw;
14428 cmdline_fixed_string_t strict_link_prio;
14433 cmdline_fixed_string_t bw_list;
14437 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14438 TOKEN_STRING_INITIALIZER
14439 (struct cmd_vf_tc_bw_result,
14441 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14442 TOKEN_STRING_INITIALIZER
14443 (struct cmd_vf_tc_bw_result,
14445 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14446 TOKEN_STRING_INITIALIZER
14447 (struct cmd_vf_tc_bw_result,
14449 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14450 TOKEN_STRING_INITIALIZER
14451 (struct cmd_vf_tc_bw_result,
14453 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14454 TOKEN_STRING_INITIALIZER
14455 (struct cmd_vf_tc_bw_result,
14456 strict_link_prio, "strict-link-priority");
14457 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14458 TOKEN_STRING_INITIALIZER
14459 (struct cmd_vf_tc_bw_result,
14460 min_bw, "min-bandwidth");
14461 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14462 TOKEN_STRING_INITIALIZER
14463 (struct cmd_vf_tc_bw_result,
14464 max_bw, "max-bandwidth");
14465 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14466 TOKEN_NUM_INITIALIZER
14467 (struct cmd_vf_tc_bw_result,
14469 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14470 TOKEN_NUM_INITIALIZER
14471 (struct cmd_vf_tc_bw_result,
14473 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14474 TOKEN_NUM_INITIALIZER
14475 (struct cmd_vf_tc_bw_result,
14477 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14478 TOKEN_NUM_INITIALIZER
14479 (struct cmd_vf_tc_bw_result,
14481 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14482 TOKEN_STRING_INITIALIZER
14483 (struct cmd_vf_tc_bw_result,
14485 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14486 TOKEN_NUM_INITIALIZER
14487 (struct cmd_vf_tc_bw_result,
14490 /* VF max bandwidth setting */
14492 cmd_vf_max_bw_parsed(
14493 void *parsed_result,
14494 __attribute__((unused)) struct cmdline *cl,
14495 __attribute__((unused)) void *data)
14497 struct cmd_vf_tc_bw_result *res = parsed_result;
14498 int ret = -ENOTSUP;
14500 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14503 #ifdef RTE_LIBRTE_I40E_PMD
14504 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14505 res->vf_id, res->bw);
14512 printf("invalid vf_id %d or bandwidth %d\n",
14513 res->vf_id, res->bw);
14516 printf("invalid port_id %d\n", res->port_id);
14519 printf("function not implemented\n");
14522 printf("programming error: (%s)\n", strerror(-ret));
14526 cmdline_parse_inst_t cmd_vf_max_bw = {
14527 .f = cmd_vf_max_bw_parsed,
14529 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14531 (void *)&cmd_vf_tc_bw_set,
14532 (void *)&cmd_vf_tc_bw_vf,
14533 (void *)&cmd_vf_tc_bw_tx,
14534 (void *)&cmd_vf_tc_bw_max_bw,
14535 (void *)&cmd_vf_tc_bw_port_id,
14536 (void *)&cmd_vf_tc_bw_vf_id,
14537 (void *)&cmd_vf_tc_bw_bw,
14543 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14548 const char *p, *p0 = str;
14555 p = strchr(p0, '(');
14557 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14561 p0 = strchr(p, ')');
14563 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14567 if (size >= sizeof(s)) {
14568 printf("The string size exceeds the internal buffer size\n");
14571 snprintf(s, sizeof(s), "%.*s", size, p);
14572 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14574 printf("Failed to get the bandwidth list. ");
14578 for (i = 0; i < ret; i++)
14579 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14584 /* TC min bandwidth setting */
14586 cmd_vf_tc_min_bw_parsed(
14587 void *parsed_result,
14588 __attribute__((unused)) struct cmdline *cl,
14589 __attribute__((unused)) void *data)
14591 struct cmd_vf_tc_bw_result *res = parsed_result;
14594 int ret = -ENOTSUP;
14596 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14599 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14603 #ifdef RTE_LIBRTE_I40E_PMD
14604 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14612 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14615 printf("invalid port_id %d\n", res->port_id);
14618 printf("function not implemented\n");
14621 printf("programming error: (%s)\n", strerror(-ret));
14625 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14626 .f = cmd_vf_tc_min_bw_parsed,
14628 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14629 " <bw1, bw2, ...>",
14631 (void *)&cmd_vf_tc_bw_set,
14632 (void *)&cmd_vf_tc_bw_vf,
14633 (void *)&cmd_vf_tc_bw_tc,
14634 (void *)&cmd_vf_tc_bw_tx,
14635 (void *)&cmd_vf_tc_bw_min_bw,
14636 (void *)&cmd_vf_tc_bw_port_id,
14637 (void *)&cmd_vf_tc_bw_vf_id,
14638 (void *)&cmd_vf_tc_bw_bw_list,
14644 cmd_tc_min_bw_parsed(
14645 void *parsed_result,
14646 __attribute__((unused)) struct cmdline *cl,
14647 __attribute__((unused)) void *data)
14649 struct cmd_vf_tc_bw_result *res = parsed_result;
14650 struct rte_port *port;
14653 int ret = -ENOTSUP;
14655 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14658 port = &ports[res->port_id];
14659 /** Check if the port is not started **/
14660 if (port->port_status != RTE_PORT_STOPPED) {
14661 printf("Please stop port %d first\n", res->port_id);
14665 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14669 #ifdef RTE_LIBRTE_IXGBE_PMD
14670 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14677 printf("invalid bandwidth\n");
14680 printf("invalid port_id %d\n", res->port_id);
14683 printf("function not implemented\n");
14686 printf("programming error: (%s)\n", strerror(-ret));
14690 cmdline_parse_inst_t cmd_tc_min_bw = {
14691 .f = cmd_tc_min_bw_parsed,
14693 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14695 (void *)&cmd_vf_tc_bw_set,
14696 (void *)&cmd_vf_tc_bw_tc,
14697 (void *)&cmd_vf_tc_bw_tx,
14698 (void *)&cmd_vf_tc_bw_min_bw,
14699 (void *)&cmd_vf_tc_bw_port_id,
14700 (void *)&cmd_vf_tc_bw_bw_list,
14705 /* TC max bandwidth setting */
14707 cmd_vf_tc_max_bw_parsed(
14708 void *parsed_result,
14709 __attribute__((unused)) struct cmdline *cl,
14710 __attribute__((unused)) void *data)
14712 struct cmd_vf_tc_bw_result *res = parsed_result;
14713 int ret = -ENOTSUP;
14715 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14718 #ifdef RTE_LIBRTE_I40E_PMD
14719 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14720 res->tc_no, res->bw);
14727 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14728 res->vf_id, res->tc_no, res->bw);
14731 printf("invalid port_id %d\n", res->port_id);
14734 printf("function not implemented\n");
14737 printf("programming error: (%s)\n", strerror(-ret));
14741 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14742 .f = cmd_vf_tc_max_bw_parsed,
14744 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14747 (void *)&cmd_vf_tc_bw_set,
14748 (void *)&cmd_vf_tc_bw_vf,
14749 (void *)&cmd_vf_tc_bw_tc,
14750 (void *)&cmd_vf_tc_bw_tx,
14751 (void *)&cmd_vf_tc_bw_max_bw,
14752 (void *)&cmd_vf_tc_bw_port_id,
14753 (void *)&cmd_vf_tc_bw_vf_id,
14754 (void *)&cmd_vf_tc_bw_tc_no,
14755 (void *)&cmd_vf_tc_bw_bw,
14761 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14763 /* *** Set Port default Traffic Management Hierarchy *** */
14764 struct cmd_set_port_tm_hierarchy_default_result {
14765 cmdline_fixed_string_t set;
14766 cmdline_fixed_string_t port;
14767 cmdline_fixed_string_t tm;
14768 cmdline_fixed_string_t hierarchy;
14769 cmdline_fixed_string_t def;
14773 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14774 TOKEN_STRING_INITIALIZER(
14775 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14776 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14777 TOKEN_STRING_INITIALIZER(
14778 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14779 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14780 TOKEN_STRING_INITIALIZER(
14781 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14782 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14783 TOKEN_STRING_INITIALIZER(
14784 struct cmd_set_port_tm_hierarchy_default_result,
14785 hierarchy, "hierarchy");
14786 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14787 TOKEN_STRING_INITIALIZER(
14788 struct cmd_set_port_tm_hierarchy_default_result,
14790 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14791 TOKEN_NUM_INITIALIZER(
14792 struct cmd_set_port_tm_hierarchy_default_result,
14795 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14796 __attribute__((unused)) struct cmdline *cl,
14797 __attribute__((unused)) void *data)
14799 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14800 struct rte_port *p;
14801 portid_t port_id = res->port_id;
14803 if (port_id_is_invalid(port_id, ENABLED_WARN))
14806 p = &ports[port_id];
14809 if (p->softport.tm_flag == 0) {
14810 printf(" tm not enabled on port %u (error)\n", port_id);
14814 /* Forward mode: tm */
14815 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14816 printf(" tm mode not enabled(error)\n");
14820 /* Set the default tm hierarchy */
14821 p->softport.tm.default_hierarchy_enable = 1;
14824 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14825 .f = cmd_set_port_tm_hierarchy_default_parsed,
14827 .help_str = "set port tm hierarchy default <port_id>",
14829 (void *)&cmd_set_port_tm_hierarchy_default_set,
14830 (void *)&cmd_set_port_tm_hierarchy_default_port,
14831 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14832 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14833 (void *)&cmd_set_port_tm_hierarchy_default_default,
14834 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14840 /* Strict link priority scheduling mode setting */
14842 cmd_strict_link_prio_parsed(
14843 void *parsed_result,
14844 __attribute__((unused)) struct cmdline *cl,
14845 __attribute__((unused)) void *data)
14847 struct cmd_vf_tc_bw_result *res = parsed_result;
14848 int ret = -ENOTSUP;
14850 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14853 #ifdef RTE_LIBRTE_I40E_PMD
14854 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14861 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14864 printf("invalid port_id %d\n", res->port_id);
14867 printf("function not implemented\n");
14870 printf("programming error: (%s)\n", strerror(-ret));
14874 cmdline_parse_inst_t cmd_strict_link_prio = {
14875 .f = cmd_strict_link_prio_parsed,
14877 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14879 (void *)&cmd_vf_tc_bw_set,
14880 (void *)&cmd_vf_tc_bw_tx,
14881 (void *)&cmd_vf_tc_bw_strict_link_prio,
14882 (void *)&cmd_vf_tc_bw_port_id,
14883 (void *)&cmd_vf_tc_bw_tc_map,
14888 /* Load dynamic device personalization*/
14889 struct cmd_ddp_add_result {
14890 cmdline_fixed_string_t ddp;
14891 cmdline_fixed_string_t add;
14896 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14897 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14898 cmdline_parse_token_string_t cmd_ddp_add_add =
14899 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14900 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14901 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14902 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14903 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14906 cmd_ddp_add_parsed(
14907 void *parsed_result,
14908 __attribute__((unused)) struct cmdline *cl,
14909 __attribute__((unused)) void *data)
14911 struct cmd_ddp_add_result *res = parsed_result;
14917 int ret = -ENOTSUP;
14919 if (!all_ports_stopped()) {
14920 printf("Please stop all ports first\n");
14924 filepath = strdup(res->filepath);
14925 if (filepath == NULL) {
14926 printf("Failed to allocate memory\n");
14929 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14931 buff = open_file(file_fld[0], &size);
14933 free((void *)filepath);
14937 #ifdef RTE_LIBRTE_I40E_PMD
14938 if (ret == -ENOTSUP)
14939 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14941 RTE_PMD_I40E_PKG_OP_WR_ADD);
14944 if (ret == -EEXIST)
14945 printf("Profile has already existed.\n");
14947 printf("Failed to load profile.\n");
14948 else if (file_num == 2)
14949 save_file(file_fld[1], buff, size);
14952 free((void *)filepath);
14955 cmdline_parse_inst_t cmd_ddp_add = {
14956 .f = cmd_ddp_add_parsed,
14958 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14960 (void *)&cmd_ddp_add_ddp,
14961 (void *)&cmd_ddp_add_add,
14962 (void *)&cmd_ddp_add_port_id,
14963 (void *)&cmd_ddp_add_filepath,
14968 /* Delete dynamic device personalization*/
14969 struct cmd_ddp_del_result {
14970 cmdline_fixed_string_t ddp;
14971 cmdline_fixed_string_t del;
14976 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14977 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14978 cmdline_parse_token_string_t cmd_ddp_del_del =
14979 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14980 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14981 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14982 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14983 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14986 cmd_ddp_del_parsed(
14987 void *parsed_result,
14988 __attribute__((unused)) struct cmdline *cl,
14989 __attribute__((unused)) void *data)
14991 struct cmd_ddp_del_result *res = parsed_result;
14994 int ret = -ENOTSUP;
14996 if (!all_ports_stopped()) {
14997 printf("Please stop all ports first\n");
15001 buff = open_file(res->filepath, &size);
15005 #ifdef RTE_LIBRTE_I40E_PMD
15006 if (ret == -ENOTSUP)
15007 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15009 RTE_PMD_I40E_PKG_OP_WR_DEL);
15012 if (ret == -EACCES)
15013 printf("Profile does not exist.\n");
15015 printf("Failed to delete profile.\n");
15020 cmdline_parse_inst_t cmd_ddp_del = {
15021 .f = cmd_ddp_del_parsed,
15023 .help_str = "ddp del <port_id> <backup_profile_path>",
15025 (void *)&cmd_ddp_del_ddp,
15026 (void *)&cmd_ddp_del_del,
15027 (void *)&cmd_ddp_del_port_id,
15028 (void *)&cmd_ddp_del_filepath,
15033 /* Get dynamic device personalization profile info */
15034 struct cmd_ddp_info_result {
15035 cmdline_fixed_string_t ddp;
15036 cmdline_fixed_string_t get;
15037 cmdline_fixed_string_t info;
15041 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15042 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15043 cmdline_parse_token_string_t cmd_ddp_info_get =
15044 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15045 cmdline_parse_token_string_t cmd_ddp_info_info =
15046 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15047 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15048 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15051 cmd_ddp_info_parsed(
15052 void *parsed_result,
15053 __attribute__((unused)) struct cmdline *cl,
15054 __attribute__((unused)) void *data)
15056 struct cmd_ddp_info_result *res = parsed_result;
15059 int ret = -ENOTSUP;
15060 #ifdef RTE_LIBRTE_I40E_PMD
15063 uint32_t buff_size = 0;
15064 struct rte_pmd_i40e_profile_info info;
15065 uint32_t dev_num = 0;
15066 struct rte_pmd_i40e_ddp_device_id *devs;
15067 uint32_t proto_num = 0;
15068 struct rte_pmd_i40e_proto_info *proto = NULL;
15069 uint32_t pctype_num = 0;
15070 struct rte_pmd_i40e_ptype_info *pctype;
15071 uint32_t ptype_num = 0;
15072 struct rte_pmd_i40e_ptype_info *ptype;
15077 pkg = open_file(res->filepath, &pkg_size);
15081 #ifdef RTE_LIBRTE_I40E_PMD
15082 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15083 (uint8_t *)&info, sizeof(info),
15084 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15086 printf("Global Track id: 0x%x\n", info.track_id);
15087 printf("Global Version: %d.%d.%d.%d\n",
15088 info.version.major,
15089 info.version.minor,
15090 info.version.update,
15091 info.version.draft);
15092 printf("Global Package name: %s\n\n", info.name);
15095 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15096 (uint8_t *)&info, sizeof(info),
15097 RTE_PMD_I40E_PKG_INFO_HEADER);
15099 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15100 printf("i40e Profile Version: %d.%d.%d.%d\n",
15101 info.version.major,
15102 info.version.minor,
15103 info.version.update,
15104 info.version.draft);
15105 printf("i40e Profile name: %s\n\n", info.name);
15108 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15109 (uint8_t *)&buff_size, sizeof(buff_size),
15110 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15111 if (!ret && buff_size) {
15112 buff = (uint8_t *)malloc(buff_size);
15114 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15116 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15118 printf("Package Notes:\n%s\n\n", buff);
15123 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15124 (uint8_t *)&dev_num, sizeof(dev_num),
15125 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15126 if (!ret && dev_num) {
15127 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15128 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15130 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15131 (uint8_t *)devs, buff_size,
15132 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15134 printf("List of supported devices:\n");
15135 for (i = 0; i < dev_num; i++) {
15136 printf(" %04X:%04X %04X:%04X\n",
15137 devs[i].vendor_dev_id >> 16,
15138 devs[i].vendor_dev_id & 0xFFFF,
15139 devs[i].sub_vendor_dev_id >> 16,
15140 devs[i].sub_vendor_dev_id & 0xFFFF);
15148 /* get information about protocols and packet types */
15149 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15150 (uint8_t *)&proto_num, sizeof(proto_num),
15151 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15152 if (ret || !proto_num)
15153 goto no_print_return;
15155 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15156 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15158 goto no_print_return;
15160 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15162 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15164 printf("List of used protocols:\n");
15165 for (i = 0; i < proto_num; i++)
15166 printf(" %2u: %s\n", proto[i].proto_id,
15170 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15171 (uint8_t *)&pctype_num, sizeof(pctype_num),
15172 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15173 if (ret || !pctype_num)
15174 goto no_print_pctypes;
15176 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15177 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15179 goto no_print_pctypes;
15181 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15183 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15186 goto no_print_pctypes;
15189 printf("List of defined packet classification types:\n");
15190 for (i = 0; i < pctype_num; i++) {
15191 printf(" %2u:", pctype[i].ptype_id);
15192 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15193 proto_id = pctype[i].protocols[j];
15194 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15195 for (n = 0; n < proto_num; n++) {
15196 if (proto[n].proto_id == proto_id) {
15197 printf(" %s", proto[n].name);
15210 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15212 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15213 if (ret || !ptype_num)
15214 goto no_print_return;
15216 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15217 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15219 goto no_print_return;
15221 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15223 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15226 goto no_print_return;
15228 printf("List of defined packet types:\n");
15229 for (i = 0; i < ptype_num; i++) {
15230 printf(" %2u:", ptype[i].ptype_id);
15231 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15232 proto_id = ptype[i].protocols[j];
15233 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15234 for (n = 0; n < proto_num; n++) {
15235 if (proto[n].proto_id == proto_id) {
15236 printf(" %s", proto[n].name);
15252 if (ret == -ENOTSUP)
15253 printf("Function not supported in PMD driver\n");
15257 cmdline_parse_inst_t cmd_ddp_get_info = {
15258 .f = cmd_ddp_info_parsed,
15260 .help_str = "ddp get info <profile_path>",
15262 (void *)&cmd_ddp_info_ddp,
15263 (void *)&cmd_ddp_info_get,
15264 (void *)&cmd_ddp_info_info,
15265 (void *)&cmd_ddp_info_filepath,
15270 /* Get dynamic device personalization profile info list*/
15271 #define PROFILE_INFO_SIZE 48
15272 #define MAX_PROFILE_NUM 16
15274 struct cmd_ddp_get_list_result {
15275 cmdline_fixed_string_t ddp;
15276 cmdline_fixed_string_t get;
15277 cmdline_fixed_string_t list;
15281 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15282 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15283 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15284 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15285 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15286 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15287 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15288 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15291 cmd_ddp_get_list_parsed(
15292 __attribute__((unused)) void *parsed_result,
15293 __attribute__((unused)) struct cmdline *cl,
15294 __attribute__((unused)) void *data)
15296 #ifdef RTE_LIBRTE_I40E_PMD
15297 struct cmd_ddp_get_list_result *res = parsed_result;
15298 struct rte_pmd_i40e_profile_list *p_list;
15299 struct rte_pmd_i40e_profile_info *p_info;
15304 int ret = -ENOTSUP;
15306 #ifdef RTE_LIBRTE_I40E_PMD
15307 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15308 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15310 printf("%s: Failed to malloc buffer\n", __func__);
15312 if (ret == -ENOTSUP)
15313 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15314 (uint8_t *)p_list, size);
15317 p_num = p_list->p_count;
15318 printf("Profile number is: %d\n\n", p_num);
15320 for (i = 0; i < p_num; i++) {
15321 p_info = &p_list->p_info[i];
15322 printf("Profile %d:\n", i);
15323 printf("Track id: 0x%x\n", p_info->track_id);
15324 printf("Version: %d.%d.%d.%d\n",
15325 p_info->version.major,
15326 p_info->version.minor,
15327 p_info->version.update,
15328 p_info->version.draft);
15329 printf("Profile name: %s\n\n", p_info->name);
15337 printf("Failed to get ddp list\n");
15340 cmdline_parse_inst_t cmd_ddp_get_list = {
15341 .f = cmd_ddp_get_list_parsed,
15343 .help_str = "ddp get list <port_id>",
15345 (void *)&cmd_ddp_get_list_ddp,
15346 (void *)&cmd_ddp_get_list_get,
15347 (void *)&cmd_ddp_get_list_list,
15348 (void *)&cmd_ddp_get_list_port_id,
15353 /* Configure input set */
15354 struct cmd_cfg_input_set_result {
15355 cmdline_fixed_string_t port;
15356 cmdline_fixed_string_t cfg;
15358 cmdline_fixed_string_t pctype;
15360 cmdline_fixed_string_t inset_type;
15361 cmdline_fixed_string_t opt;
15362 cmdline_fixed_string_t field;
15367 cmd_cfg_input_set_parsed(
15368 __attribute__((unused)) void *parsed_result,
15369 __attribute__((unused)) struct cmdline *cl,
15370 __attribute__((unused)) void *data)
15372 #ifdef RTE_LIBRTE_I40E_PMD
15373 struct cmd_cfg_input_set_result *res = parsed_result;
15374 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15375 struct rte_pmd_i40e_inset inset;
15377 int ret = -ENOTSUP;
15379 if (!all_ports_stopped()) {
15380 printf("Please stop all ports first\n");
15384 #ifdef RTE_LIBRTE_I40E_PMD
15385 if (!strcmp(res->inset_type, "hash_inset"))
15386 inset_type = INSET_HASH;
15387 else if (!strcmp(res->inset_type, "fdir_inset"))
15388 inset_type = INSET_FDIR;
15389 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15390 inset_type = INSET_FDIR_FLX;
15391 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15392 &inset, inset_type);
15394 printf("Failed to get input set.\n");
15398 if (!strcmp(res->opt, "get")) {
15399 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15402 printf("Field index %d is enabled.\n", res->field_idx);
15404 printf("Field index %d is disabled.\n", res->field_idx);
15406 } else if (!strcmp(res->opt, "set"))
15407 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15409 else if (!strcmp(res->opt, "clear"))
15410 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15413 printf("Failed to configure input set field.\n");
15417 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15418 &inset, inset_type);
15420 printf("Failed to set input set.\n");
15425 if (ret == -ENOTSUP)
15426 printf("Function not supported\n");
15429 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15430 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15432 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15433 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15435 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15436 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15438 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15439 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15441 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15442 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15444 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15445 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15447 "hash_inset#fdir_inset#fdir_flx_inset");
15448 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15449 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15450 opt, "get#set#clear");
15451 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15452 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15454 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15455 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15458 cmdline_parse_inst_t cmd_cfg_input_set = {
15459 .f = cmd_cfg_input_set_parsed,
15461 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15462 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15464 (void *)&cmd_cfg_input_set_port,
15465 (void *)&cmd_cfg_input_set_cfg,
15466 (void *)&cmd_cfg_input_set_port_id,
15467 (void *)&cmd_cfg_input_set_pctype,
15468 (void *)&cmd_cfg_input_set_pctype_id,
15469 (void *)&cmd_cfg_input_set_inset_type,
15470 (void *)&cmd_cfg_input_set_opt,
15471 (void *)&cmd_cfg_input_set_field,
15472 (void *)&cmd_cfg_input_set_field_idx,
15477 /* Clear input set */
15478 struct cmd_clear_input_set_result {
15479 cmdline_fixed_string_t port;
15480 cmdline_fixed_string_t cfg;
15482 cmdline_fixed_string_t pctype;
15484 cmdline_fixed_string_t inset_type;
15485 cmdline_fixed_string_t clear;
15486 cmdline_fixed_string_t all;
15490 cmd_clear_input_set_parsed(
15491 __attribute__((unused)) void *parsed_result,
15492 __attribute__((unused)) struct cmdline *cl,
15493 __attribute__((unused)) void *data)
15495 #ifdef RTE_LIBRTE_I40E_PMD
15496 struct cmd_clear_input_set_result *res = parsed_result;
15497 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15498 struct rte_pmd_i40e_inset inset;
15500 int ret = -ENOTSUP;
15502 if (!all_ports_stopped()) {
15503 printf("Please stop all ports first\n");
15507 #ifdef RTE_LIBRTE_I40E_PMD
15508 if (!strcmp(res->inset_type, "hash_inset"))
15509 inset_type = INSET_HASH;
15510 else if (!strcmp(res->inset_type, "fdir_inset"))
15511 inset_type = INSET_FDIR;
15512 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15513 inset_type = INSET_FDIR_FLX;
15515 memset(&inset, 0, sizeof(inset));
15517 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15518 &inset, inset_type);
15520 printf("Failed to clear input set.\n");
15526 if (ret == -ENOTSUP)
15527 printf("Function not supported\n");
15530 cmdline_parse_token_string_t cmd_clear_input_set_port =
15531 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15533 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15534 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15536 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15537 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15539 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15540 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15542 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15543 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15545 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15546 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15548 "hash_inset#fdir_inset#fdir_flx_inset");
15549 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15550 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15552 cmdline_parse_token_string_t cmd_clear_input_set_all =
15553 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15556 cmdline_parse_inst_t cmd_clear_input_set = {
15557 .f = cmd_clear_input_set_parsed,
15559 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15560 "fdir_inset|fdir_flx_inset clear all",
15562 (void *)&cmd_clear_input_set_port,
15563 (void *)&cmd_clear_input_set_cfg,
15564 (void *)&cmd_clear_input_set_port_id,
15565 (void *)&cmd_clear_input_set_pctype,
15566 (void *)&cmd_clear_input_set_pctype_id,
15567 (void *)&cmd_clear_input_set_inset_type,
15568 (void *)&cmd_clear_input_set_clear,
15569 (void *)&cmd_clear_input_set_all,
15574 /* show vf stats */
15576 /* Common result structure for show vf stats */
15577 struct cmd_show_vf_stats_result {
15578 cmdline_fixed_string_t show;
15579 cmdline_fixed_string_t vf;
15580 cmdline_fixed_string_t stats;
15585 /* Common CLI fields show vf stats*/
15586 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15587 TOKEN_STRING_INITIALIZER
15588 (struct cmd_show_vf_stats_result,
15590 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15591 TOKEN_STRING_INITIALIZER
15592 (struct cmd_show_vf_stats_result,
15594 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15595 TOKEN_STRING_INITIALIZER
15596 (struct cmd_show_vf_stats_result,
15598 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15599 TOKEN_NUM_INITIALIZER
15600 (struct cmd_show_vf_stats_result,
15602 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15603 TOKEN_NUM_INITIALIZER
15604 (struct cmd_show_vf_stats_result,
15608 cmd_show_vf_stats_parsed(
15609 void *parsed_result,
15610 __attribute__((unused)) struct cmdline *cl,
15611 __attribute__((unused)) void *data)
15613 struct cmd_show_vf_stats_result *res = parsed_result;
15614 struct rte_eth_stats stats;
15615 int ret = -ENOTSUP;
15616 static const char *nic_stats_border = "########################";
15618 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15621 memset(&stats, 0, sizeof(stats));
15623 #ifdef RTE_LIBRTE_I40E_PMD
15624 if (ret == -ENOTSUP)
15625 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15629 #ifdef RTE_LIBRTE_BNXT_PMD
15630 if (ret == -ENOTSUP)
15631 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15640 printf("invalid vf_id %d\n", res->vf_id);
15643 printf("invalid port_id %d\n", res->port_id);
15646 printf("function not implemented\n");
15649 printf("programming error: (%s)\n", strerror(-ret));
15652 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15653 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15655 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15657 stats.ipackets, stats.imissed, stats.ibytes);
15658 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15659 printf(" RX-nombuf: %-10"PRIu64"\n",
15661 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15663 stats.opackets, stats.oerrors, stats.obytes);
15665 printf(" %s############################%s\n",
15666 nic_stats_border, nic_stats_border);
15669 cmdline_parse_inst_t cmd_show_vf_stats = {
15670 .f = cmd_show_vf_stats_parsed,
15672 .help_str = "show vf stats <port_id> <vf_id>",
15674 (void *)&cmd_show_vf_stats_show,
15675 (void *)&cmd_show_vf_stats_vf,
15676 (void *)&cmd_show_vf_stats_stats,
15677 (void *)&cmd_show_vf_stats_port_id,
15678 (void *)&cmd_show_vf_stats_vf_id,
15683 /* clear vf stats */
15685 /* Common result structure for clear vf stats */
15686 struct cmd_clear_vf_stats_result {
15687 cmdline_fixed_string_t clear;
15688 cmdline_fixed_string_t vf;
15689 cmdline_fixed_string_t stats;
15694 /* Common CLI fields clear vf stats*/
15695 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15696 TOKEN_STRING_INITIALIZER
15697 (struct cmd_clear_vf_stats_result,
15699 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15700 TOKEN_STRING_INITIALIZER
15701 (struct cmd_clear_vf_stats_result,
15703 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15704 TOKEN_STRING_INITIALIZER
15705 (struct cmd_clear_vf_stats_result,
15707 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15708 TOKEN_NUM_INITIALIZER
15709 (struct cmd_clear_vf_stats_result,
15711 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15712 TOKEN_NUM_INITIALIZER
15713 (struct cmd_clear_vf_stats_result,
15717 cmd_clear_vf_stats_parsed(
15718 void *parsed_result,
15719 __attribute__((unused)) struct cmdline *cl,
15720 __attribute__((unused)) void *data)
15722 struct cmd_clear_vf_stats_result *res = parsed_result;
15723 int ret = -ENOTSUP;
15725 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15728 #ifdef RTE_LIBRTE_I40E_PMD
15729 if (ret == -ENOTSUP)
15730 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15733 #ifdef RTE_LIBRTE_BNXT_PMD
15734 if (ret == -ENOTSUP)
15735 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15743 printf("invalid vf_id %d\n", res->vf_id);
15746 printf("invalid port_id %d\n", res->port_id);
15749 printf("function not implemented\n");
15752 printf("programming error: (%s)\n", strerror(-ret));
15756 cmdline_parse_inst_t cmd_clear_vf_stats = {
15757 .f = cmd_clear_vf_stats_parsed,
15759 .help_str = "clear vf stats <port_id> <vf_id>",
15761 (void *)&cmd_clear_vf_stats_clear,
15762 (void *)&cmd_clear_vf_stats_vf,
15763 (void *)&cmd_clear_vf_stats_stats,
15764 (void *)&cmd_clear_vf_stats_port_id,
15765 (void *)&cmd_clear_vf_stats_vf_id,
15770 /* port config pctype mapping reset */
15772 /* Common result structure for port config pctype mapping reset */
15773 struct cmd_pctype_mapping_reset_result {
15774 cmdline_fixed_string_t port;
15775 cmdline_fixed_string_t config;
15777 cmdline_fixed_string_t pctype;
15778 cmdline_fixed_string_t mapping;
15779 cmdline_fixed_string_t reset;
15782 /* Common CLI fields for port config pctype mapping reset*/
15783 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15784 TOKEN_STRING_INITIALIZER
15785 (struct cmd_pctype_mapping_reset_result,
15787 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15788 TOKEN_STRING_INITIALIZER
15789 (struct cmd_pctype_mapping_reset_result,
15791 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15792 TOKEN_NUM_INITIALIZER
15793 (struct cmd_pctype_mapping_reset_result,
15795 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15796 TOKEN_STRING_INITIALIZER
15797 (struct cmd_pctype_mapping_reset_result,
15799 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15800 TOKEN_STRING_INITIALIZER
15801 (struct cmd_pctype_mapping_reset_result,
15802 mapping, "mapping");
15803 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15804 TOKEN_STRING_INITIALIZER
15805 (struct cmd_pctype_mapping_reset_result,
15809 cmd_pctype_mapping_reset_parsed(
15810 void *parsed_result,
15811 __attribute__((unused)) struct cmdline *cl,
15812 __attribute__((unused)) void *data)
15814 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15815 int ret = -ENOTSUP;
15817 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15820 #ifdef RTE_LIBRTE_I40E_PMD
15821 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15828 printf("invalid port_id %d\n", res->port_id);
15831 printf("function not implemented\n");
15834 printf("programming error: (%s)\n", strerror(-ret));
15838 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15839 .f = cmd_pctype_mapping_reset_parsed,
15841 .help_str = "port config <port_id> pctype mapping reset",
15843 (void *)&cmd_pctype_mapping_reset_port,
15844 (void *)&cmd_pctype_mapping_reset_config,
15845 (void *)&cmd_pctype_mapping_reset_port_id,
15846 (void *)&cmd_pctype_mapping_reset_pctype,
15847 (void *)&cmd_pctype_mapping_reset_mapping,
15848 (void *)&cmd_pctype_mapping_reset_reset,
15853 /* show port pctype mapping */
15855 /* Common result structure for show port pctype mapping */
15856 struct cmd_pctype_mapping_get_result {
15857 cmdline_fixed_string_t show;
15858 cmdline_fixed_string_t port;
15860 cmdline_fixed_string_t pctype;
15861 cmdline_fixed_string_t mapping;
15864 /* Common CLI fields for pctype mapping get */
15865 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15866 TOKEN_STRING_INITIALIZER
15867 (struct cmd_pctype_mapping_get_result,
15869 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15870 TOKEN_STRING_INITIALIZER
15871 (struct cmd_pctype_mapping_get_result,
15873 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15874 TOKEN_NUM_INITIALIZER
15875 (struct cmd_pctype_mapping_get_result,
15877 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15878 TOKEN_STRING_INITIALIZER
15879 (struct cmd_pctype_mapping_get_result,
15881 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15882 TOKEN_STRING_INITIALIZER
15883 (struct cmd_pctype_mapping_get_result,
15884 mapping, "mapping");
15887 cmd_pctype_mapping_get_parsed(
15888 void *parsed_result,
15889 __attribute__((unused)) struct cmdline *cl,
15890 __attribute__((unused)) void *data)
15892 struct cmd_pctype_mapping_get_result *res = parsed_result;
15893 int ret = -ENOTSUP;
15894 #ifdef RTE_LIBRTE_I40E_PMD
15895 struct rte_pmd_i40e_flow_type_mapping
15896 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15897 int i, j, first_pctype;
15900 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15903 #ifdef RTE_LIBRTE_I40E_PMD
15904 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15911 printf("invalid port_id %d\n", res->port_id);
15914 printf("function not implemented\n");
15917 printf("programming error: (%s)\n", strerror(-ret));
15921 #ifdef RTE_LIBRTE_I40E_PMD
15922 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15923 if (mapping[i].pctype != 0ULL) {
15926 printf("pctype: ");
15927 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15928 if (mapping[i].pctype & (1ULL << j)) {
15929 printf(first_pctype ?
15930 "%02d" : ",%02d", j);
15934 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15940 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15941 .f = cmd_pctype_mapping_get_parsed,
15943 .help_str = "show port <port_id> pctype mapping",
15945 (void *)&cmd_pctype_mapping_get_show,
15946 (void *)&cmd_pctype_mapping_get_port,
15947 (void *)&cmd_pctype_mapping_get_port_id,
15948 (void *)&cmd_pctype_mapping_get_pctype,
15949 (void *)&cmd_pctype_mapping_get_mapping,
15954 /* port config pctype mapping update */
15956 /* Common result structure for port config pctype mapping update */
15957 struct cmd_pctype_mapping_update_result {
15958 cmdline_fixed_string_t port;
15959 cmdline_fixed_string_t config;
15961 cmdline_fixed_string_t pctype;
15962 cmdline_fixed_string_t mapping;
15963 cmdline_fixed_string_t update;
15964 cmdline_fixed_string_t pctype_list;
15965 uint16_t flow_type;
15968 /* Common CLI fields for pctype mapping update*/
15969 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15970 TOKEN_STRING_INITIALIZER
15971 (struct cmd_pctype_mapping_update_result,
15973 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15974 TOKEN_STRING_INITIALIZER
15975 (struct cmd_pctype_mapping_update_result,
15977 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15978 TOKEN_NUM_INITIALIZER
15979 (struct cmd_pctype_mapping_update_result,
15981 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15982 TOKEN_STRING_INITIALIZER
15983 (struct cmd_pctype_mapping_update_result,
15985 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15986 TOKEN_STRING_INITIALIZER
15987 (struct cmd_pctype_mapping_update_result,
15988 mapping, "mapping");
15989 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15990 TOKEN_STRING_INITIALIZER
15991 (struct cmd_pctype_mapping_update_result,
15993 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15994 TOKEN_STRING_INITIALIZER
15995 (struct cmd_pctype_mapping_update_result,
15996 pctype_list, NULL);
15997 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15998 TOKEN_NUM_INITIALIZER
15999 (struct cmd_pctype_mapping_update_result,
16000 flow_type, UINT16);
16003 cmd_pctype_mapping_update_parsed(
16004 void *parsed_result,
16005 __attribute__((unused)) struct cmdline *cl,
16006 __attribute__((unused)) void *data)
16008 struct cmd_pctype_mapping_update_result *res = parsed_result;
16009 int ret = -ENOTSUP;
16010 #ifdef RTE_LIBRTE_I40E_PMD
16011 struct rte_pmd_i40e_flow_type_mapping mapping;
16013 unsigned int nb_item;
16014 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16017 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16020 #ifdef RTE_LIBRTE_I40E_PMD
16021 nb_item = parse_item_list(res->pctype_list, "pctypes",
16022 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16023 mapping.flow_type = res->flow_type;
16024 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16025 mapping.pctype |= (1ULL << pctype_list[i]);
16026 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16036 printf("invalid pctype or flow type\n");
16039 printf("invalid port_id %d\n", res->port_id);
16042 printf("function not implemented\n");
16045 printf("programming error: (%s)\n", strerror(-ret));
16049 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16050 .f = cmd_pctype_mapping_update_parsed,
16052 .help_str = "port config <port_id> pctype mapping update"
16053 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16055 (void *)&cmd_pctype_mapping_update_port,
16056 (void *)&cmd_pctype_mapping_update_config,
16057 (void *)&cmd_pctype_mapping_update_port_id,
16058 (void *)&cmd_pctype_mapping_update_pctype,
16059 (void *)&cmd_pctype_mapping_update_mapping,
16060 (void *)&cmd_pctype_mapping_update_update,
16061 (void *)&cmd_pctype_mapping_update_pc_type,
16062 (void *)&cmd_pctype_mapping_update_flow_type,
16067 /* ptype mapping get */
16069 /* Common result structure for ptype mapping get */
16070 struct cmd_ptype_mapping_get_result {
16071 cmdline_fixed_string_t ptype;
16072 cmdline_fixed_string_t mapping;
16073 cmdline_fixed_string_t get;
16075 uint8_t valid_only;
16078 /* Common CLI fields for ptype mapping get */
16079 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16080 TOKEN_STRING_INITIALIZER
16081 (struct cmd_ptype_mapping_get_result,
16083 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16084 TOKEN_STRING_INITIALIZER
16085 (struct cmd_ptype_mapping_get_result,
16086 mapping, "mapping");
16087 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16088 TOKEN_STRING_INITIALIZER
16089 (struct cmd_ptype_mapping_get_result,
16091 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16092 TOKEN_NUM_INITIALIZER
16093 (struct cmd_ptype_mapping_get_result,
16095 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16096 TOKEN_NUM_INITIALIZER
16097 (struct cmd_ptype_mapping_get_result,
16098 valid_only, UINT8);
16101 cmd_ptype_mapping_get_parsed(
16102 void *parsed_result,
16103 __attribute__((unused)) struct cmdline *cl,
16104 __attribute__((unused)) void *data)
16106 struct cmd_ptype_mapping_get_result *res = parsed_result;
16107 int ret = -ENOTSUP;
16108 #ifdef RTE_LIBRTE_I40E_PMD
16109 int max_ptype_num = 256;
16110 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16115 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16118 #ifdef RTE_LIBRTE_I40E_PMD
16119 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16130 printf("invalid port_id %d\n", res->port_id);
16133 printf("function not implemented\n");
16136 printf("programming error: (%s)\n", strerror(-ret));
16139 #ifdef RTE_LIBRTE_I40E_PMD
16141 for (i = 0; i < count; i++)
16142 printf("%3d\t0x%08x\n",
16143 mapping[i].hw_ptype, mapping[i].sw_ptype);
16148 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16149 .f = cmd_ptype_mapping_get_parsed,
16151 .help_str = "ptype mapping get <port_id> <valid_only>",
16153 (void *)&cmd_ptype_mapping_get_ptype,
16154 (void *)&cmd_ptype_mapping_get_mapping,
16155 (void *)&cmd_ptype_mapping_get_get,
16156 (void *)&cmd_ptype_mapping_get_port_id,
16157 (void *)&cmd_ptype_mapping_get_valid_only,
16162 /* ptype mapping replace */
16164 /* Common result structure for ptype mapping replace */
16165 struct cmd_ptype_mapping_replace_result {
16166 cmdline_fixed_string_t ptype;
16167 cmdline_fixed_string_t mapping;
16168 cmdline_fixed_string_t replace;
16175 /* Common CLI fields for ptype mapping replace */
16176 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16177 TOKEN_STRING_INITIALIZER
16178 (struct cmd_ptype_mapping_replace_result,
16180 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16181 TOKEN_STRING_INITIALIZER
16182 (struct cmd_ptype_mapping_replace_result,
16183 mapping, "mapping");
16184 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16185 TOKEN_STRING_INITIALIZER
16186 (struct cmd_ptype_mapping_replace_result,
16187 replace, "replace");
16188 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16189 TOKEN_NUM_INITIALIZER
16190 (struct cmd_ptype_mapping_replace_result,
16192 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16193 TOKEN_NUM_INITIALIZER
16194 (struct cmd_ptype_mapping_replace_result,
16196 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16197 TOKEN_NUM_INITIALIZER
16198 (struct cmd_ptype_mapping_replace_result,
16200 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16201 TOKEN_NUM_INITIALIZER
16202 (struct cmd_ptype_mapping_replace_result,
16206 cmd_ptype_mapping_replace_parsed(
16207 void *parsed_result,
16208 __attribute__((unused)) struct cmdline *cl,
16209 __attribute__((unused)) void *data)
16211 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16212 int ret = -ENOTSUP;
16214 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16217 #ifdef RTE_LIBRTE_I40E_PMD
16218 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16228 printf("invalid ptype 0x%8x or 0x%8x\n",
16229 res->target, res->pkt_type);
16232 printf("invalid port_id %d\n", res->port_id);
16235 printf("function not implemented\n");
16238 printf("programming error: (%s)\n", strerror(-ret));
16242 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16243 .f = cmd_ptype_mapping_replace_parsed,
16246 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16248 (void *)&cmd_ptype_mapping_replace_ptype,
16249 (void *)&cmd_ptype_mapping_replace_mapping,
16250 (void *)&cmd_ptype_mapping_replace_replace,
16251 (void *)&cmd_ptype_mapping_replace_port_id,
16252 (void *)&cmd_ptype_mapping_replace_target,
16253 (void *)&cmd_ptype_mapping_replace_mask,
16254 (void *)&cmd_ptype_mapping_replace_pkt_type,
16259 /* ptype mapping reset */
16261 /* Common result structure for ptype mapping reset */
16262 struct cmd_ptype_mapping_reset_result {
16263 cmdline_fixed_string_t ptype;
16264 cmdline_fixed_string_t mapping;
16265 cmdline_fixed_string_t reset;
16269 /* Common CLI fields for ptype mapping reset*/
16270 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16271 TOKEN_STRING_INITIALIZER
16272 (struct cmd_ptype_mapping_reset_result,
16274 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16275 TOKEN_STRING_INITIALIZER
16276 (struct cmd_ptype_mapping_reset_result,
16277 mapping, "mapping");
16278 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16279 TOKEN_STRING_INITIALIZER
16280 (struct cmd_ptype_mapping_reset_result,
16282 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16283 TOKEN_NUM_INITIALIZER
16284 (struct cmd_ptype_mapping_reset_result,
16288 cmd_ptype_mapping_reset_parsed(
16289 void *parsed_result,
16290 __attribute__((unused)) struct cmdline *cl,
16291 __attribute__((unused)) void *data)
16293 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16294 int ret = -ENOTSUP;
16296 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16299 #ifdef RTE_LIBRTE_I40E_PMD
16300 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16307 printf("invalid port_id %d\n", res->port_id);
16310 printf("function not implemented\n");
16313 printf("programming error: (%s)\n", strerror(-ret));
16317 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16318 .f = cmd_ptype_mapping_reset_parsed,
16320 .help_str = "ptype mapping reset <port_id>",
16322 (void *)&cmd_ptype_mapping_reset_ptype,
16323 (void *)&cmd_ptype_mapping_reset_mapping,
16324 (void *)&cmd_ptype_mapping_reset_reset,
16325 (void *)&cmd_ptype_mapping_reset_port_id,
16330 /* ptype mapping update */
16332 /* Common result structure for ptype mapping update */
16333 struct cmd_ptype_mapping_update_result {
16334 cmdline_fixed_string_t ptype;
16335 cmdline_fixed_string_t mapping;
16336 cmdline_fixed_string_t reset;
16342 /* Common CLI fields for ptype mapping update*/
16343 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16344 TOKEN_STRING_INITIALIZER
16345 (struct cmd_ptype_mapping_update_result,
16347 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16348 TOKEN_STRING_INITIALIZER
16349 (struct cmd_ptype_mapping_update_result,
16350 mapping, "mapping");
16351 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16352 TOKEN_STRING_INITIALIZER
16353 (struct cmd_ptype_mapping_update_result,
16355 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16356 TOKEN_NUM_INITIALIZER
16357 (struct cmd_ptype_mapping_update_result,
16359 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16360 TOKEN_NUM_INITIALIZER
16361 (struct cmd_ptype_mapping_update_result,
16363 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16364 TOKEN_NUM_INITIALIZER
16365 (struct cmd_ptype_mapping_update_result,
16369 cmd_ptype_mapping_update_parsed(
16370 void *parsed_result,
16371 __attribute__((unused)) struct cmdline *cl,
16372 __attribute__((unused)) void *data)
16374 struct cmd_ptype_mapping_update_result *res = parsed_result;
16375 int ret = -ENOTSUP;
16376 #ifdef RTE_LIBRTE_I40E_PMD
16377 struct rte_pmd_i40e_ptype_mapping mapping;
16379 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16382 #ifdef RTE_LIBRTE_I40E_PMD
16383 mapping.hw_ptype = res->hw_ptype;
16384 mapping.sw_ptype = res->sw_ptype;
16385 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16395 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16398 printf("invalid port_id %d\n", res->port_id);
16401 printf("function not implemented\n");
16404 printf("programming error: (%s)\n", strerror(-ret));
16408 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16409 .f = cmd_ptype_mapping_update_parsed,
16411 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16413 (void *)&cmd_ptype_mapping_update_ptype,
16414 (void *)&cmd_ptype_mapping_update_mapping,
16415 (void *)&cmd_ptype_mapping_update_update,
16416 (void *)&cmd_ptype_mapping_update_port_id,
16417 (void *)&cmd_ptype_mapping_update_hw_ptype,
16418 (void *)&cmd_ptype_mapping_update_sw_ptype,
16423 /* Common result structure for file commands */
16424 struct cmd_cmdfile_result {
16425 cmdline_fixed_string_t load;
16426 cmdline_fixed_string_t filename;
16429 /* Common CLI fields for file commands */
16430 cmdline_parse_token_string_t cmd_load_cmdfile =
16431 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16432 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16433 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16436 cmd_load_from_file_parsed(
16437 void *parsed_result,
16438 __attribute__((unused)) struct cmdline *cl,
16439 __attribute__((unused)) void *data)
16441 struct cmd_cmdfile_result *res = parsed_result;
16443 cmdline_read_from_file(res->filename);
16446 cmdline_parse_inst_t cmd_load_from_file = {
16447 .f = cmd_load_from_file_parsed,
16449 .help_str = "load <filename>",
16451 (void *)&cmd_load_cmdfile,
16452 (void *)&cmd_load_cmdfile_filename,
16457 /* ******************************************************************************** */
16459 /* list of instructions */
16460 cmdline_parse_ctx_t main_ctx[] = {
16461 (cmdline_parse_inst_t *)&cmd_help_brief,
16462 (cmdline_parse_inst_t *)&cmd_help_long,
16463 (cmdline_parse_inst_t *)&cmd_quit,
16464 (cmdline_parse_inst_t *)&cmd_load_from_file,
16465 (cmdline_parse_inst_t *)&cmd_showport,
16466 (cmdline_parse_inst_t *)&cmd_showqueue,
16467 (cmdline_parse_inst_t *)&cmd_showportall,
16468 (cmdline_parse_inst_t *)&cmd_showcfg,
16469 (cmdline_parse_inst_t *)&cmd_start,
16470 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16471 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16472 (cmdline_parse_inst_t *)&cmd_set_link_up,
16473 (cmdline_parse_inst_t *)&cmd_set_link_down,
16474 (cmdline_parse_inst_t *)&cmd_reset,
16475 (cmdline_parse_inst_t *)&cmd_set_numbers,
16476 (cmdline_parse_inst_t *)&cmd_set_log,
16477 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16478 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16479 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16480 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16481 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16482 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16483 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16484 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16485 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16486 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16487 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16488 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16489 (cmdline_parse_inst_t *)&cmd_set_link_check,
16490 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16491 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16492 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16493 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16494 #ifdef RTE_LIBRTE_PMD_BOND
16495 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16496 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16497 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16498 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16499 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16500 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16501 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16502 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16503 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16504 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16505 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16507 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16508 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16509 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16510 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16511 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16512 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16513 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16514 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16515 (cmdline_parse_inst_t *)&cmd_csum_set,
16516 (cmdline_parse_inst_t *)&cmd_csum_show,
16517 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16518 (cmdline_parse_inst_t *)&cmd_tso_set,
16519 (cmdline_parse_inst_t *)&cmd_tso_show,
16520 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16521 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16522 (cmdline_parse_inst_t *)&cmd_gro_enable,
16523 (cmdline_parse_inst_t *)&cmd_gro_flush,
16524 (cmdline_parse_inst_t *)&cmd_gro_show,
16525 (cmdline_parse_inst_t *)&cmd_gso_enable,
16526 (cmdline_parse_inst_t *)&cmd_gso_size,
16527 (cmdline_parse_inst_t *)&cmd_gso_show,
16528 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16529 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16530 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16531 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16532 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16533 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16534 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16535 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16536 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16537 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16538 (cmdline_parse_inst_t *)&cmd_config_dcb,
16539 (cmdline_parse_inst_t *)&cmd_read_reg,
16540 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16541 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16542 (cmdline_parse_inst_t *)&cmd_write_reg,
16543 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16544 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16545 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16546 (cmdline_parse_inst_t *)&cmd_stop,
16547 (cmdline_parse_inst_t *)&cmd_mac_addr,
16548 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16549 (cmdline_parse_inst_t *)&cmd_set_qmap,
16550 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16551 (cmdline_parse_inst_t *)&cmd_operate_port,
16552 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16553 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16554 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16555 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16556 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16557 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16558 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16559 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16560 (cmdline_parse_inst_t *)&cmd_config_mtu,
16561 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16562 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16563 (cmdline_parse_inst_t *)&cmd_config_rss,
16564 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16565 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16566 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16567 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16568 (cmdline_parse_inst_t *)&cmd_showport_reta,
16569 (cmdline_parse_inst_t *)&cmd_config_burst,
16570 (cmdline_parse_inst_t *)&cmd_config_thresh,
16571 (cmdline_parse_inst_t *)&cmd_config_threshold,
16572 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16573 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16574 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16575 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16576 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16577 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16578 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16579 (cmdline_parse_inst_t *)&cmd_global_config,
16580 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16581 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16582 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16583 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16584 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16585 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16586 (cmdline_parse_inst_t *)&cmd_dump,
16587 (cmdline_parse_inst_t *)&cmd_dump_one,
16588 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16589 (cmdline_parse_inst_t *)&cmd_syn_filter,
16590 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16591 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16592 (cmdline_parse_inst_t *)&cmd_flex_filter,
16593 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16594 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16595 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16596 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16597 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16598 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16599 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16600 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16601 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16602 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16603 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16604 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16605 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16606 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16607 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16608 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16609 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16610 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16611 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16612 (cmdline_parse_inst_t *)&cmd_flow,
16613 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16614 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16615 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16616 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16617 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16618 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16619 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16620 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16621 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16622 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16623 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16624 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16625 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16626 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16627 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16628 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16629 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16630 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16631 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16632 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16633 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16634 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16635 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16636 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16637 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16638 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16639 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16640 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16641 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16642 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16643 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16644 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16645 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16646 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16647 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16648 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16649 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16650 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16651 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16652 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16653 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16654 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16655 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16656 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16657 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16658 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16659 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16660 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16661 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16662 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16663 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16665 (cmdline_parse_inst_t *)&cmd_ddp_add,
16666 (cmdline_parse_inst_t *)&cmd_ddp_del,
16667 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16668 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16669 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16670 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16671 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16672 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16673 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16674 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16675 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16676 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16678 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16679 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16680 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16681 (cmdline_parse_inst_t *)&cmd_queue_region,
16682 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16683 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16684 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16685 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16686 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16687 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16688 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16689 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16690 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16691 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16692 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16693 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16694 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16695 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16696 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16697 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16698 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16699 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16700 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16701 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16702 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
16703 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
16704 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16705 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
16709 /* read cmdline commands from file */
16711 cmdline_read_from_file(const char *filename)
16713 struct cmdline *cl;
16715 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16717 printf("Failed to create file based cmdline context: %s\n",
16722 cmdline_interact(cl);
16727 printf("Read CLI commands from %s\n", filename);
16730 /* prompt function, called from main on MASTER lcore */
16734 /* initialize non-constant commands */
16735 cmd_set_fwd_mode_init();
16736 cmd_set_fwd_retry_mode_init();
16738 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16739 if (testpmd_cl == NULL)
16741 cmdline_interact(testpmd_cl);
16742 cmdline_stdin_exit(testpmd_cl);
16748 if (testpmd_cl != NULL)
16749 cmdline_quit(testpmd_cl);
16753 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16755 if (id == (portid_t)RTE_PORT_ALL) {
16758 RTE_ETH_FOREACH_DEV(pid) {
16759 /* check if need_reconfig has been set to 1 */
16760 if (ports[pid].need_reconfig == 0)
16761 ports[pid].need_reconfig = dev;
16762 /* check if need_reconfig_queues has been set to 1 */
16763 if (ports[pid].need_reconfig_queues == 0)
16764 ports[pid].need_reconfig_queues = queue;
16766 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16767 /* check if need_reconfig has been set to 1 */
16768 if (ports[id].need_reconfig == 0)
16769 ports[id].need_reconfig = dev;
16770 /* check if need_reconfig_queues has been set to 1 */
16771 if (ports[id].need_reconfig_queues == 0)
16772 ports[id].need_reconfig_queues = queue;