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 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
778 " Commit tm hierarchy.\n\n"
780 , list_pkt_forwarding_modes()
784 if (show_all || !strcmp(res->section, "ports")) {
790 "----------------\n\n"
792 "port start (port_id|all)\n"
793 " Start all ports or port_id.\n\n"
795 "port stop (port_id|all)\n"
796 " Stop all ports or port_id.\n\n"
798 "port close (port_id|all)\n"
799 " Close all ports or port_id.\n\n"
801 "port attach (ident)\n"
802 " Attach physical or virtual dev by pci address or virtual device name\n\n"
804 "port detach (port_id)\n"
805 " Detach physical or virtual dev by port_id\n\n"
807 "port config (port_id|all)"
808 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
809 " duplex (half|full|auto)\n"
810 " Set speed and duplex for all ports or port_id\n\n"
812 "port config (port_id|all) loopback (mode)\n"
813 " Set loopback mode for all ports or port_id\n\n"
815 "port config all (rxq|txq|rxd|txd) (value)\n"
816 " Set number for rxq/txq/rxd/txd.\n\n"
818 "port config all max-pkt-len (value)\n"
819 " Set the max packet length.\n\n"
821 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
822 "hw-vlan-strip|hw-vlan-extend|drop-en)"
824 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
827 "port config all rss (all|default|ip|tcp|udp|sctp|"
828 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
829 " Set the RSS mode.\n\n"
831 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
832 " Set the RSS redirection table.\n\n"
834 "port config (port_id) dcb vt (on|off) (traffic_class)"
836 " Set the DCB mode.\n\n"
838 "port config all burst (value)\n"
839 " Set the number of packets per burst.\n\n"
841 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
843 " Set the ring prefetch/host/writeback threshold"
844 " for tx/rx queue.\n\n"
846 "port config all (txfreet|txrst|rxfreet) (value)\n"
847 " Set free threshold for rx/tx, or set"
848 " tx rs bit threshold.\n\n"
849 "port config mtu X value\n"
850 " Set the MTU of port X to a given value\n\n"
852 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
853 " Set a rx/tx queue's ring size configuration, the new"
854 " value will take effect after command that (re-)start the port"
855 " or command that setup the specific queue\n\n"
857 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
858 " Start/stop a rx/tx queue of port X. Only take effect"
859 " when port X is started\n\n"
861 "port (port_id) (rxq|txq) (queue_id) setup\n"
862 " Setup a rx/tx queue of port X.\n\n"
864 "port config (port_id|all) l2-tunnel E-tag ether-type"
866 " Set the value of E-tag ether-type.\n\n"
868 "port config (port_id|all) l2-tunnel E-tag"
869 " (enable|disable)\n"
870 " Enable/disable the E-tag support.\n\n"
872 "port config (port_id) pctype mapping reset\n"
873 " Reset flow type to pctype mapping on a port\n\n"
875 "port config (port_id) pctype mapping update"
876 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
877 " Update a flow type to pctype mapping item on a port\n\n"
879 "port config (port_id) pctype (pctype_id) hash_inset|"
880 "fdir_inset|fdir_flx_inset get|set|clear field\n"
882 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
884 "port config (port_id) pctype (pctype_id) hash_inset|"
885 "fdir_inset|fdir_flx_inset clear all"
886 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
888 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
889 " Add/remove UDP tunnel port for tunneling offload\n\n"
893 if (show_all || !strcmp(res->section, "registers")) {
901 "read reg (port_id) (address)\n"
902 " Display value of a port register.\n\n"
904 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
905 " Display a port register bit field.\n\n"
907 "read regbit (port_id) (address) (bit_x)\n"
908 " Display a single port register bit.\n\n"
910 "write reg (port_id) (address) (value)\n"
911 " Set value of a port register.\n\n"
913 "write regfield (port_id) (address) (bit_x) (bit_y)"
915 " Set bit field of a port register.\n\n"
917 "write regbit (port_id) (address) (bit_x) (value)\n"
918 " Set single bit value of a port register.\n\n"
921 if (show_all || !strcmp(res->section, "filters")) {
929 "ethertype_filter (port_id) (add|del)"
930 " (mac_addr|mac_ignr) (mac_address) ethertype"
931 " (ether_type) (drop|fwd) queue (queue_id)\n"
932 " Add/Del an ethertype filter.\n\n"
934 "2tuple_filter (port_id) (add|del)"
935 " dst_port (dst_port_value) protocol (protocol_value)"
936 " mask (mask_value) tcp_flags (tcp_flags_value)"
937 " priority (prio_value) queue (queue_id)\n"
938 " Add/Del a 2tuple filter.\n\n"
940 "5tuple_filter (port_id) (add|del)"
941 " dst_ip (dst_address) src_ip (src_address)"
942 " dst_port (dst_port_value) src_port (src_port_value)"
943 " protocol (protocol_value)"
944 " mask (mask_value) tcp_flags (tcp_flags_value)"
945 " priority (prio_value) queue (queue_id)\n"
946 " Add/Del a 5tuple filter.\n\n"
948 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
949 " Add/Del syn filter.\n\n"
951 "flex_filter (port_id) (add|del) len (len_value)"
952 " bytes (bytes_value) mask (mask_value)"
953 " priority (prio_value) queue (queue_id)\n"
954 " Add/Del a flex filter.\n\n"
956 "flow_director_filter (port_id) mode IP (add|del|update)"
957 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
958 " src (src_ip_address) dst (dst_ip_address)"
959 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
960 " vlan (vlan_value) flexbytes (flexbytes_value)"
961 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
962 " fd_id (fd_id_value)\n"
963 " Add/Del an IP type flow director filter.\n\n"
965 "flow_director_filter (port_id) mode IP (add|del|update)"
966 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
967 " src (src_ip_address) (src_port)"
968 " dst (dst_ip_address) (dst_port)"
969 " tos (tos_value) ttl (ttl_value)"
970 " vlan (vlan_value) flexbytes (flexbytes_value)"
971 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
972 " fd_id (fd_id_value)\n"
973 " Add/Del an UDP/TCP type flow director filter.\n\n"
975 "flow_director_filter (port_id) mode IP (add|del|update)"
976 " flow (ipv4-sctp|ipv6-sctp)"
977 " src (src_ip_address) (src_port)"
978 " dst (dst_ip_address) (dst_port)"
979 " tag (verification_tag) "
980 " tos (tos_value) ttl (ttl_value)"
982 " flexbytes (flexbytes_value) (drop|fwd)"
983 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
984 " Add/Del a SCTP type flow director filter.\n\n"
986 "flow_director_filter (port_id) mode IP (add|del|update)"
987 " flow l2_payload ether (ethertype)"
988 " flexbytes (flexbytes_value) (drop|fwd)"
989 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
990 " Add/Del a l2 payload type flow director filter.\n\n"
992 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
993 " mac (mac_address) vlan (vlan_value)"
994 " flexbytes (flexbytes_value) (drop|fwd)"
995 " queue (queue_id) fd_id (fd_id_value)\n"
996 " Add/Del a MAC-VLAN flow director filter.\n\n"
998 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
999 " mac (mac_address) vlan (vlan_value)"
1000 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1001 " flexbytes (flexbytes_value) (drop|fwd)"
1002 " queue (queue_id) fd_id (fd_id_value)\n"
1003 " Add/Del a Tunnel flow director filter.\n\n"
1005 "flow_director_filter (port_id) mode raw (add|del|update)"
1006 " flow (flow_id) (drop|fwd) queue (queue_id)"
1007 " fd_id (fd_id_value) packet (packet file name)\n"
1008 " Add/Del a raw type flow director filter.\n\n"
1010 "flush_flow_director (port_id)\n"
1011 " Flush all flow director entries of a device.\n\n"
1013 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1014 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1015 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1016 " Set flow director IP mask.\n\n"
1018 "flow_director_mask (port_id) mode MAC-VLAN"
1019 " vlan (vlan_value)\n"
1020 " Set flow director MAC-VLAN mask.\n\n"
1022 "flow_director_mask (port_id) mode Tunnel"
1023 " vlan (vlan_value) mac (mac_value)"
1024 " tunnel-type (tunnel_type_value)"
1025 " tunnel-id (tunnel_id_value)\n"
1026 " Set flow director Tunnel mask.\n\n"
1028 "flow_director_flex_mask (port_id)"
1029 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1030 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1032 " Configure mask of flex payload.\n\n"
1034 "flow_director_flex_payload (port_id)"
1035 " (raw|l2|l3|l4) (config)\n"
1036 " Configure flex payload selection.\n\n"
1038 "get_sym_hash_ena_per_port (port_id)\n"
1039 " get symmetric hash enable configuration per port.\n\n"
1041 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1042 " set symmetric hash enable configuration per port"
1043 " to enable or disable.\n\n"
1045 "get_hash_global_config (port_id)\n"
1046 " Get the global configurations of hash filters.\n\n"
1048 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1049 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1050 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1051 " (enable|disable)\n"
1052 " Set the global configurations of hash filters.\n\n"
1054 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1055 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1056 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1057 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1058 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1059 "ipv6-next-header|udp-src-port|udp-dst-port|"
1060 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1061 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1062 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1063 "fld-8th|none) (select|add)\n"
1064 " Set the input set for hash.\n\n"
1066 "set_fdir_input_set (port_id) "
1067 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1068 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1069 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1070 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1071 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1072 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1073 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1075 " Set the input set for FDir.\n\n"
1077 "flow validate {port_id}"
1078 " [group {group_id}] [priority {level}]"
1079 " [ingress] [egress]"
1080 " pattern {item} [/ {item} [...]] / end"
1081 " actions {action} [/ {action} [...]] / end\n"
1082 " Check whether a flow rule can be created.\n\n"
1084 "flow create {port_id}"
1085 " [group {group_id}] [priority {level}]"
1086 " [ingress] [egress]"
1087 " pattern {item} [/ {item} [...]] / end"
1088 " actions {action} [/ {action} [...]] / end\n"
1089 " Create a flow rule.\n\n"
1091 "flow destroy {port_id} rule {rule_id} [...]\n"
1092 " Destroy specific flow rules.\n\n"
1094 "flow flush {port_id}\n"
1095 " Destroy all flow rules.\n\n"
1097 "flow query {port_id} {rule_id} {action}\n"
1098 " Query an existing flow rule.\n\n"
1100 "flow list {port_id} [group {group_id}] [...]\n"
1101 " List existing flow rules sorted by priority,"
1102 " filtered by group identifiers.\n\n"
1104 "flow isolate {port_id} {boolean}\n"
1105 " Restrict ingress traffic to the defined"
1111 cmdline_parse_token_string_t cmd_help_long_help =
1112 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1114 cmdline_parse_token_string_t cmd_help_long_section =
1115 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1116 "all#control#display#config#"
1117 "ports#registers#filters");
1119 cmdline_parse_inst_t cmd_help_long = {
1120 .f = cmd_help_long_parsed,
1122 .help_str = "help all|control|display|config|ports|register|filters: "
1125 (void *)&cmd_help_long_help,
1126 (void *)&cmd_help_long_section,
1132 /* *** start/stop/close all ports *** */
1133 struct cmd_operate_port_result {
1134 cmdline_fixed_string_t keyword;
1135 cmdline_fixed_string_t name;
1136 cmdline_fixed_string_t value;
1139 static void cmd_operate_port_parsed(void *parsed_result,
1140 __attribute__((unused)) struct cmdline *cl,
1141 __attribute__((unused)) void *data)
1143 struct cmd_operate_port_result *res = parsed_result;
1145 if (!strcmp(res->name, "start"))
1146 start_port(RTE_PORT_ALL);
1147 else if (!strcmp(res->name, "stop"))
1148 stop_port(RTE_PORT_ALL);
1149 else if (!strcmp(res->name, "close"))
1150 close_port(RTE_PORT_ALL);
1151 else if (!strcmp(res->name, "reset"))
1152 reset_port(RTE_PORT_ALL);
1154 printf("Unknown parameter\n");
1157 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1158 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1160 cmdline_parse_token_string_t cmd_operate_port_all_port =
1161 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1162 "start#stop#close#reset");
1163 cmdline_parse_token_string_t cmd_operate_port_all_all =
1164 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1166 cmdline_parse_inst_t cmd_operate_port = {
1167 .f = cmd_operate_port_parsed,
1169 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1171 (void *)&cmd_operate_port_all_cmd,
1172 (void *)&cmd_operate_port_all_port,
1173 (void *)&cmd_operate_port_all_all,
1178 /* *** start/stop/close specific port *** */
1179 struct cmd_operate_specific_port_result {
1180 cmdline_fixed_string_t keyword;
1181 cmdline_fixed_string_t name;
1185 static void cmd_operate_specific_port_parsed(void *parsed_result,
1186 __attribute__((unused)) struct cmdline *cl,
1187 __attribute__((unused)) void *data)
1189 struct cmd_operate_specific_port_result *res = parsed_result;
1191 if (!strcmp(res->name, "start"))
1192 start_port(res->value);
1193 else if (!strcmp(res->name, "stop"))
1194 stop_port(res->value);
1195 else if (!strcmp(res->name, "close"))
1196 close_port(res->value);
1197 else if (!strcmp(res->name, "reset"))
1198 reset_port(res->value);
1200 printf("Unknown parameter\n");
1203 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1204 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1206 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1207 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1208 name, "start#stop#close#reset");
1209 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1210 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1213 cmdline_parse_inst_t cmd_operate_specific_port = {
1214 .f = cmd_operate_specific_port_parsed,
1216 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1218 (void *)&cmd_operate_specific_port_cmd,
1219 (void *)&cmd_operate_specific_port_port,
1220 (void *)&cmd_operate_specific_port_id,
1225 /* *** attach a specified port *** */
1226 struct cmd_operate_attach_port_result {
1227 cmdline_fixed_string_t port;
1228 cmdline_fixed_string_t keyword;
1229 cmdline_fixed_string_t identifier;
1232 static void cmd_operate_attach_port_parsed(void *parsed_result,
1233 __attribute__((unused)) struct cmdline *cl,
1234 __attribute__((unused)) void *data)
1236 struct cmd_operate_attach_port_result *res = parsed_result;
1238 if (!strcmp(res->keyword, "attach"))
1239 attach_port(res->identifier);
1241 printf("Unknown parameter\n");
1244 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1245 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1247 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1248 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1250 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1251 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1254 cmdline_parse_inst_t cmd_operate_attach_port = {
1255 .f = cmd_operate_attach_port_parsed,
1257 .help_str = "port attach <identifier>: "
1258 "(identifier: pci address or virtual dev name)",
1260 (void *)&cmd_operate_attach_port_port,
1261 (void *)&cmd_operate_attach_port_keyword,
1262 (void *)&cmd_operate_attach_port_identifier,
1267 /* *** detach a specified port *** */
1268 struct cmd_operate_detach_port_result {
1269 cmdline_fixed_string_t port;
1270 cmdline_fixed_string_t keyword;
1274 static void cmd_operate_detach_port_parsed(void *parsed_result,
1275 __attribute__((unused)) struct cmdline *cl,
1276 __attribute__((unused)) void *data)
1278 struct cmd_operate_detach_port_result *res = parsed_result;
1280 if (!strcmp(res->keyword, "detach"))
1281 detach_port(res->port_id);
1283 printf("Unknown parameter\n");
1286 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1287 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1289 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1290 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1292 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1293 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1296 cmdline_parse_inst_t cmd_operate_detach_port = {
1297 .f = cmd_operate_detach_port_parsed,
1299 .help_str = "port detach <port_id>",
1301 (void *)&cmd_operate_detach_port_port,
1302 (void *)&cmd_operate_detach_port_keyword,
1303 (void *)&cmd_operate_detach_port_port_id,
1308 /* *** configure speed for all ports *** */
1309 struct cmd_config_speed_all {
1310 cmdline_fixed_string_t port;
1311 cmdline_fixed_string_t keyword;
1312 cmdline_fixed_string_t all;
1313 cmdline_fixed_string_t item1;
1314 cmdline_fixed_string_t item2;
1315 cmdline_fixed_string_t value1;
1316 cmdline_fixed_string_t value2;
1320 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1325 if (!strcmp(duplexstr, "half")) {
1326 duplex = ETH_LINK_HALF_DUPLEX;
1327 } else if (!strcmp(duplexstr, "full")) {
1328 duplex = ETH_LINK_FULL_DUPLEX;
1329 } else if (!strcmp(duplexstr, "auto")) {
1330 duplex = ETH_LINK_FULL_DUPLEX;
1332 printf("Unknown duplex parameter\n");
1336 if (!strcmp(speedstr, "10")) {
1337 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1338 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1339 } else if (!strcmp(speedstr, "100")) {
1340 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1341 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1343 if (duplex != ETH_LINK_FULL_DUPLEX) {
1344 printf("Invalid speed/duplex parameters\n");
1347 if (!strcmp(speedstr, "1000")) {
1348 *speed = ETH_LINK_SPEED_1G;
1349 } else if (!strcmp(speedstr, "10000")) {
1350 *speed = ETH_LINK_SPEED_10G;
1351 } else if (!strcmp(speedstr, "25000")) {
1352 *speed = ETH_LINK_SPEED_25G;
1353 } else if (!strcmp(speedstr, "40000")) {
1354 *speed = ETH_LINK_SPEED_40G;
1355 } else if (!strcmp(speedstr, "50000")) {
1356 *speed = ETH_LINK_SPEED_50G;
1357 } else if (!strcmp(speedstr, "100000")) {
1358 *speed = ETH_LINK_SPEED_100G;
1359 } else if (!strcmp(speedstr, "auto")) {
1360 *speed = ETH_LINK_SPEED_AUTONEG;
1362 printf("Unknown speed parameter\n");
1371 cmd_config_speed_all_parsed(void *parsed_result,
1372 __attribute__((unused)) struct cmdline *cl,
1373 __attribute__((unused)) void *data)
1375 struct cmd_config_speed_all *res = parsed_result;
1376 uint32_t link_speed;
1379 if (!all_ports_stopped()) {
1380 printf("Please stop all ports first\n");
1384 if (parse_and_check_speed_duplex(res->value1, res->value2,
1388 RTE_ETH_FOREACH_DEV(pid) {
1389 ports[pid].dev_conf.link_speeds = link_speed;
1392 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1395 cmdline_parse_token_string_t cmd_config_speed_all_port =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1397 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1398 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1400 cmdline_parse_token_string_t cmd_config_speed_all_all =
1401 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1402 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1403 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1404 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1406 "10#100#1000#10000#25000#40000#50000#100000#auto");
1407 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1409 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1410 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1413 cmdline_parse_inst_t cmd_config_speed_all = {
1414 .f = cmd_config_speed_all_parsed,
1416 .help_str = "port config all speed "
1417 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1420 (void *)&cmd_config_speed_all_port,
1421 (void *)&cmd_config_speed_all_keyword,
1422 (void *)&cmd_config_speed_all_all,
1423 (void *)&cmd_config_speed_all_item1,
1424 (void *)&cmd_config_speed_all_value1,
1425 (void *)&cmd_config_speed_all_item2,
1426 (void *)&cmd_config_speed_all_value2,
1431 /* *** configure speed for specific port *** */
1432 struct cmd_config_speed_specific {
1433 cmdline_fixed_string_t port;
1434 cmdline_fixed_string_t keyword;
1436 cmdline_fixed_string_t item1;
1437 cmdline_fixed_string_t item2;
1438 cmdline_fixed_string_t value1;
1439 cmdline_fixed_string_t value2;
1443 cmd_config_speed_specific_parsed(void *parsed_result,
1444 __attribute__((unused)) struct cmdline *cl,
1445 __attribute__((unused)) void *data)
1447 struct cmd_config_speed_specific *res = parsed_result;
1448 uint32_t link_speed;
1450 if (!all_ports_stopped()) {
1451 printf("Please stop all ports first\n");
1455 if (port_id_is_invalid(res->id, ENABLED_WARN))
1458 if (parse_and_check_speed_duplex(res->value1, res->value2,
1462 ports[res->id].dev_conf.link_speeds = link_speed;
1464 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1468 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1471 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1474 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1475 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1476 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1477 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1479 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1481 "10#100#1000#10000#25000#40000#50000#100000#auto");
1482 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1483 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1485 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1489 cmdline_parse_inst_t cmd_config_speed_specific = {
1490 .f = cmd_config_speed_specific_parsed,
1492 .help_str = "port config <port_id> speed "
1493 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1496 (void *)&cmd_config_speed_specific_port,
1497 (void *)&cmd_config_speed_specific_keyword,
1498 (void *)&cmd_config_speed_specific_id,
1499 (void *)&cmd_config_speed_specific_item1,
1500 (void *)&cmd_config_speed_specific_value1,
1501 (void *)&cmd_config_speed_specific_item2,
1502 (void *)&cmd_config_speed_specific_value2,
1507 /* *** configure loopback for all ports *** */
1508 struct cmd_config_loopback_all {
1509 cmdline_fixed_string_t port;
1510 cmdline_fixed_string_t keyword;
1511 cmdline_fixed_string_t all;
1512 cmdline_fixed_string_t item;
1517 cmd_config_loopback_all_parsed(void *parsed_result,
1518 __attribute__((unused)) struct cmdline *cl,
1519 __attribute__((unused)) void *data)
1521 struct cmd_config_loopback_all *res = parsed_result;
1524 if (!all_ports_stopped()) {
1525 printf("Please stop all ports first\n");
1529 RTE_ETH_FOREACH_DEV(pid) {
1530 ports[pid].dev_conf.lpbk_mode = res->mode;
1533 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1536 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1537 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1538 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1539 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1541 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1542 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1543 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1544 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1546 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1547 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1549 cmdline_parse_inst_t cmd_config_loopback_all = {
1550 .f = cmd_config_loopback_all_parsed,
1552 .help_str = "port config all loopback <mode>",
1554 (void *)&cmd_config_loopback_all_port,
1555 (void *)&cmd_config_loopback_all_keyword,
1556 (void *)&cmd_config_loopback_all_all,
1557 (void *)&cmd_config_loopback_all_item,
1558 (void *)&cmd_config_loopback_all_mode,
1563 /* *** configure loopback for specific port *** */
1564 struct cmd_config_loopback_specific {
1565 cmdline_fixed_string_t port;
1566 cmdline_fixed_string_t keyword;
1568 cmdline_fixed_string_t item;
1573 cmd_config_loopback_specific_parsed(void *parsed_result,
1574 __attribute__((unused)) struct cmdline *cl,
1575 __attribute__((unused)) void *data)
1577 struct cmd_config_loopback_specific *res = parsed_result;
1579 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1582 if (!port_is_stopped(res->port_id)) {
1583 printf("Please stop port %u first\n", res->port_id);
1587 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1589 cmd_reconfig_device_queue(res->port_id, 1, 1);
1593 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1594 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1596 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1597 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1599 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1600 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1602 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1603 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1605 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1606 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1609 cmdline_parse_inst_t cmd_config_loopback_specific = {
1610 .f = cmd_config_loopback_specific_parsed,
1612 .help_str = "port config <port_id> loopback <mode>",
1614 (void *)&cmd_config_loopback_specific_port,
1615 (void *)&cmd_config_loopback_specific_keyword,
1616 (void *)&cmd_config_loopback_specific_id,
1617 (void *)&cmd_config_loopback_specific_item,
1618 (void *)&cmd_config_loopback_specific_mode,
1623 /* *** configure txq/rxq, txd/rxd *** */
1624 struct cmd_config_rx_tx {
1625 cmdline_fixed_string_t port;
1626 cmdline_fixed_string_t keyword;
1627 cmdline_fixed_string_t all;
1628 cmdline_fixed_string_t name;
1633 cmd_config_rx_tx_parsed(void *parsed_result,
1634 __attribute__((unused)) struct cmdline *cl,
1635 __attribute__((unused)) void *data)
1637 struct cmd_config_rx_tx *res = parsed_result;
1639 if (!all_ports_stopped()) {
1640 printf("Please stop all ports first\n");
1643 if (!strcmp(res->name, "rxq")) {
1644 if (!res->value && !nb_txq) {
1645 printf("Warning: Either rx or tx queues should be non zero\n");
1648 if (check_nb_rxq(res->value) != 0)
1650 nb_rxq = res->value;
1652 else if (!strcmp(res->name, "txq")) {
1653 if (!res->value && !nb_rxq) {
1654 printf("Warning: Either rx or tx queues should be non zero\n");
1657 if (check_nb_txq(res->value) != 0)
1659 nb_txq = res->value;
1661 else if (!strcmp(res->name, "rxd")) {
1662 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1663 printf("rxd %d invalid - must be > 0 && <= %d\n",
1664 res->value, RTE_TEST_RX_DESC_MAX);
1667 nb_rxd = res->value;
1668 } else if (!strcmp(res->name, "txd")) {
1669 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1670 printf("txd %d invalid - must be > 0 && <= %d\n",
1671 res->value, RTE_TEST_TX_DESC_MAX);
1674 nb_txd = res->value;
1676 printf("Unknown parameter\n");
1684 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1687 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1688 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1689 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1690 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1691 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1692 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1693 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1696 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1697 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1699 cmdline_parse_inst_t cmd_config_rx_tx = {
1700 .f = cmd_config_rx_tx_parsed,
1702 .help_str = "port config all rxq|txq|rxd|txd <value>",
1704 (void *)&cmd_config_rx_tx_port,
1705 (void *)&cmd_config_rx_tx_keyword,
1706 (void *)&cmd_config_rx_tx_all,
1707 (void *)&cmd_config_rx_tx_name,
1708 (void *)&cmd_config_rx_tx_value,
1713 /* *** config max packet length *** */
1714 struct cmd_config_max_pkt_len_result {
1715 cmdline_fixed_string_t port;
1716 cmdline_fixed_string_t keyword;
1717 cmdline_fixed_string_t all;
1718 cmdline_fixed_string_t name;
1723 cmd_config_max_pkt_len_parsed(void *parsed_result,
1724 __attribute__((unused)) struct cmdline *cl,
1725 __attribute__((unused)) void *data)
1727 struct cmd_config_max_pkt_len_result *res = parsed_result;
1730 if (!all_ports_stopped()) {
1731 printf("Please stop all ports first\n");
1735 RTE_ETH_FOREACH_DEV(pid) {
1736 struct rte_port *port = &ports[pid];
1737 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1739 if (!strcmp(res->name, "max-pkt-len")) {
1740 if (res->value < ETHER_MIN_LEN) {
1741 printf("max-pkt-len can not be less than %d\n",
1745 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1748 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1749 if (res->value > ETHER_MAX_LEN)
1750 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1752 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1753 port->dev_conf.rxmode.offloads = rx_offloads;
1755 printf("Unknown parameter\n");
1762 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1765 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1768 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1771 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1772 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1774 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1775 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1777 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1778 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1781 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1782 .f = cmd_config_max_pkt_len_parsed,
1784 .help_str = "port config all max-pkt-len <value>",
1786 (void *)&cmd_config_max_pkt_len_port,
1787 (void *)&cmd_config_max_pkt_len_keyword,
1788 (void *)&cmd_config_max_pkt_len_all,
1789 (void *)&cmd_config_max_pkt_len_name,
1790 (void *)&cmd_config_max_pkt_len_value,
1795 /* *** configure port MTU *** */
1796 struct cmd_config_mtu_result {
1797 cmdline_fixed_string_t port;
1798 cmdline_fixed_string_t keyword;
1799 cmdline_fixed_string_t mtu;
1805 cmd_config_mtu_parsed(void *parsed_result,
1806 __attribute__((unused)) struct cmdline *cl,
1807 __attribute__((unused)) void *data)
1809 struct cmd_config_mtu_result *res = parsed_result;
1811 if (res->value < ETHER_MIN_LEN) {
1812 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1815 port_mtu_set(res->port_id, res->value);
1818 cmdline_parse_token_string_t cmd_config_mtu_port =
1819 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1821 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1822 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1824 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1825 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1827 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1828 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1829 cmdline_parse_token_num_t cmd_config_mtu_value =
1830 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1832 cmdline_parse_inst_t cmd_config_mtu = {
1833 .f = cmd_config_mtu_parsed,
1835 .help_str = "port config mtu <port_id> <value>",
1837 (void *)&cmd_config_mtu_port,
1838 (void *)&cmd_config_mtu_keyword,
1839 (void *)&cmd_config_mtu_mtu,
1840 (void *)&cmd_config_mtu_port_id,
1841 (void *)&cmd_config_mtu_value,
1846 /* *** configure rx mode *** */
1847 struct cmd_config_rx_mode_flag {
1848 cmdline_fixed_string_t port;
1849 cmdline_fixed_string_t keyword;
1850 cmdline_fixed_string_t all;
1851 cmdline_fixed_string_t name;
1852 cmdline_fixed_string_t value;
1856 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1857 __attribute__((unused)) struct cmdline *cl,
1858 __attribute__((unused)) void *data)
1860 struct cmd_config_rx_mode_flag *res = parsed_result;
1863 if (!all_ports_stopped()) {
1864 printf("Please stop all ports first\n");
1868 RTE_ETH_FOREACH_DEV(pid) {
1869 struct rte_port *port;
1870 uint64_t rx_offloads;
1873 rx_offloads = port->dev_conf.rxmode.offloads;
1874 if (!strcmp(res->name, "crc-strip")) {
1875 if (!strcmp(res->value, "on"))
1876 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1877 else if (!strcmp(res->value, "off"))
1878 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1880 printf("Unknown parameter\n");
1883 } else if (!strcmp(res->name, "scatter")) {
1884 if (!strcmp(res->value, "on")) {
1885 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1886 } else if (!strcmp(res->value, "off")) {
1887 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1889 printf("Unknown parameter\n");
1892 } else if (!strcmp(res->name, "rx-cksum")) {
1893 if (!strcmp(res->value, "on"))
1894 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1895 else if (!strcmp(res->value, "off"))
1896 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1898 printf("Unknown parameter\n");
1901 } else if (!strcmp(res->name, "rx-timestamp")) {
1902 if (!strcmp(res->value, "on"))
1903 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1904 else if (!strcmp(res->value, "off"))
1905 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1907 printf("Unknown parameter\n");
1910 } else if (!strcmp(res->name, "hw-vlan")) {
1911 if (!strcmp(res->value, "on")) {
1912 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1913 DEV_RX_OFFLOAD_VLAN_STRIP);
1914 } else if (!strcmp(res->value, "off")) {
1915 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1916 DEV_RX_OFFLOAD_VLAN_STRIP);
1918 printf("Unknown parameter\n");
1921 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1922 if (!strcmp(res->value, "on"))
1923 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1924 else if (!strcmp(res->value, "off"))
1925 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1927 printf("Unknown parameter\n");
1930 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1931 if (!strcmp(res->value, "on"))
1932 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1933 else if (!strcmp(res->value, "off"))
1934 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1936 printf("Unknown parameter\n");
1939 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1940 if (!strcmp(res->value, "on"))
1941 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1942 else if (!strcmp(res->value, "off"))
1943 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1945 printf("Unknown parameter\n");
1948 } else if (!strcmp(res->name, "drop-en")) {
1949 if (!strcmp(res->value, "on"))
1951 else if (!strcmp(res->value, "off"))
1954 printf("Unknown parameter\n");
1958 printf("Unknown parameter\n");
1961 port->dev_conf.rxmode.offloads = rx_offloads;
1966 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1969 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1970 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1971 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1972 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1974 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1975 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1976 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1977 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1978 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1979 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1980 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1981 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1984 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1985 .f = cmd_config_rx_mode_flag_parsed,
1987 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1988 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1990 (void *)&cmd_config_rx_mode_flag_port,
1991 (void *)&cmd_config_rx_mode_flag_keyword,
1992 (void *)&cmd_config_rx_mode_flag_all,
1993 (void *)&cmd_config_rx_mode_flag_name,
1994 (void *)&cmd_config_rx_mode_flag_value,
1999 /* *** configure rss *** */
2000 struct cmd_config_rss {
2001 cmdline_fixed_string_t port;
2002 cmdline_fixed_string_t keyword;
2003 cmdline_fixed_string_t all;
2004 cmdline_fixed_string_t name;
2005 cmdline_fixed_string_t value;
2009 cmd_config_rss_parsed(void *parsed_result,
2010 __attribute__((unused)) struct cmdline *cl,
2011 __attribute__((unused)) void *data)
2013 struct cmd_config_rss *res = parsed_result;
2014 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2015 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2016 int use_default = 0;
2017 int all_updated = 1;
2021 if (!strcmp(res->value, "all"))
2022 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2023 ETH_RSS_UDP | ETH_RSS_SCTP |
2025 else if (!strcmp(res->value, "ip"))
2026 rss_conf.rss_hf = ETH_RSS_IP;
2027 else if (!strcmp(res->value, "udp"))
2028 rss_conf.rss_hf = ETH_RSS_UDP;
2029 else if (!strcmp(res->value, "tcp"))
2030 rss_conf.rss_hf = ETH_RSS_TCP;
2031 else if (!strcmp(res->value, "sctp"))
2032 rss_conf.rss_hf = ETH_RSS_SCTP;
2033 else if (!strcmp(res->value, "ether"))
2034 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2035 else if (!strcmp(res->value, "port"))
2036 rss_conf.rss_hf = ETH_RSS_PORT;
2037 else if (!strcmp(res->value, "vxlan"))
2038 rss_conf.rss_hf = ETH_RSS_VXLAN;
2039 else if (!strcmp(res->value, "geneve"))
2040 rss_conf.rss_hf = ETH_RSS_GENEVE;
2041 else if (!strcmp(res->value, "nvgre"))
2042 rss_conf.rss_hf = ETH_RSS_NVGRE;
2043 else if (!strcmp(res->value, "none"))
2044 rss_conf.rss_hf = 0;
2045 else if (!strcmp(res->value, "default"))
2047 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2048 atoi(res->value) < 64)
2049 rss_conf.rss_hf = 1ULL << atoi(res->value);
2051 printf("Unknown parameter\n");
2054 rss_conf.rss_key = NULL;
2055 /* Update global configuration for RSS types. */
2056 RTE_ETH_FOREACH_DEV(i) {
2058 rte_eth_dev_info_get(i, &dev_info);
2059 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2061 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2064 printf("Configuration of RSS hash at ethernet port %d "
2065 "failed with error (%d): %s.\n",
2066 i, -diag, strerror(-diag));
2069 if (all_updated && !use_default)
2070 rss_hf = rss_conf.rss_hf;
2073 cmdline_parse_token_string_t cmd_config_rss_port =
2074 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2075 cmdline_parse_token_string_t cmd_config_rss_keyword =
2076 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2077 cmdline_parse_token_string_t cmd_config_rss_all =
2078 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2079 cmdline_parse_token_string_t cmd_config_rss_name =
2080 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2081 cmdline_parse_token_string_t cmd_config_rss_value =
2082 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2084 cmdline_parse_inst_t cmd_config_rss = {
2085 .f = cmd_config_rss_parsed,
2087 .help_str = "port config all rss "
2088 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2090 (void *)&cmd_config_rss_port,
2091 (void *)&cmd_config_rss_keyword,
2092 (void *)&cmd_config_rss_all,
2093 (void *)&cmd_config_rss_name,
2094 (void *)&cmd_config_rss_value,
2099 /* *** configure rss hash key *** */
2100 struct cmd_config_rss_hash_key {
2101 cmdline_fixed_string_t port;
2102 cmdline_fixed_string_t config;
2104 cmdline_fixed_string_t rss_hash_key;
2105 cmdline_fixed_string_t rss_type;
2106 cmdline_fixed_string_t key;
2110 hexa_digit_to_value(char hexa_digit)
2112 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2113 return (uint8_t) (hexa_digit - '0');
2114 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2115 return (uint8_t) ((hexa_digit - 'a') + 10);
2116 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2117 return (uint8_t) ((hexa_digit - 'A') + 10);
2118 /* Invalid hexa digit */
2123 parse_and_check_key_hexa_digit(char *key, int idx)
2127 hexa_v = hexa_digit_to_value(key[idx]);
2129 printf("invalid key: character %c at position %d is not a "
2130 "valid hexa digit\n", key[idx], idx);
2135 cmd_config_rss_hash_key_parsed(void *parsed_result,
2136 __attribute__((unused)) struct cmdline *cl,
2137 __attribute__((unused)) void *data)
2139 struct cmd_config_rss_hash_key *res = parsed_result;
2140 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2144 struct rte_eth_dev_info dev_info;
2145 uint8_t hash_key_size;
2148 memset(&dev_info, 0, sizeof(dev_info));
2149 rte_eth_dev_info_get(res->port_id, &dev_info);
2150 if (dev_info.hash_key_size > 0 &&
2151 dev_info.hash_key_size <= sizeof(hash_key))
2152 hash_key_size = dev_info.hash_key_size;
2154 printf("dev_info did not provide a valid hash key size\n");
2157 /* Check the length of the RSS hash key */
2158 key_len = strlen(res->key);
2159 if (key_len != (hash_key_size * 2)) {
2160 printf("key length: %d invalid - key must be a string of %d"
2161 " hexa-decimal numbers\n",
2162 (int) key_len, hash_key_size * 2);
2165 /* Translate RSS hash key into binary representation */
2166 for (i = 0; i < hash_key_size; i++) {
2167 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2170 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2173 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2175 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2179 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2180 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2181 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2182 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2184 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2185 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2186 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2187 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2188 rss_hash_key, "rss-hash-key");
2189 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2190 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2191 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2192 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2193 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2194 "ipv6-tcp-ex#ipv6-udp-ex");
2195 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2196 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2198 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2199 .f = cmd_config_rss_hash_key_parsed,
2201 .help_str = "port config <port_id> rss-hash-key "
2202 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2203 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2204 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2205 "<string of hex digits (variable length, NIC dependent)>",
2207 (void *)&cmd_config_rss_hash_key_port,
2208 (void *)&cmd_config_rss_hash_key_config,
2209 (void *)&cmd_config_rss_hash_key_port_id,
2210 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2211 (void *)&cmd_config_rss_hash_key_rss_type,
2212 (void *)&cmd_config_rss_hash_key_value,
2217 /* *** configure port rxq/txq ring size *** */
2218 struct cmd_config_rxtx_ring_size {
2219 cmdline_fixed_string_t port;
2220 cmdline_fixed_string_t config;
2222 cmdline_fixed_string_t rxtxq;
2224 cmdline_fixed_string_t rsize;
2229 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2230 __attribute__((unused)) struct cmdline *cl,
2231 __attribute__((unused)) void *data)
2233 struct cmd_config_rxtx_ring_size *res = parsed_result;
2234 struct rte_port *port;
2237 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2240 if (res->portid == (portid_t)RTE_PORT_ALL) {
2241 printf("Invalid port id\n");
2245 port = &ports[res->portid];
2247 if (!strcmp(res->rxtxq, "rxq"))
2249 else if (!strcmp(res->rxtxq, "txq"))
2252 printf("Unknown parameter\n");
2256 if (isrx && rx_queue_id_is_invalid(res->qid))
2258 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2261 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2262 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2268 port->nb_rx_desc[res->qid] = res->size;
2270 port->nb_tx_desc[res->qid] = res->size;
2272 cmd_reconfig_device_queue(res->portid, 0, 1);
2275 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2276 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2278 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2279 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2281 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2282 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2284 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2287 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2288 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2290 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2291 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2292 rsize, "ring_size");
2293 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2294 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2297 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2298 .f = cmd_config_rxtx_ring_size_parsed,
2300 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2302 (void *)&cmd_config_rxtx_ring_size_port,
2303 (void *)&cmd_config_rxtx_ring_size_config,
2304 (void *)&cmd_config_rxtx_ring_size_portid,
2305 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2306 (void *)&cmd_config_rxtx_ring_size_qid,
2307 (void *)&cmd_config_rxtx_ring_size_rsize,
2308 (void *)&cmd_config_rxtx_ring_size_size,
2313 /* *** configure port rxq/txq start/stop *** */
2314 struct cmd_config_rxtx_queue {
2315 cmdline_fixed_string_t port;
2317 cmdline_fixed_string_t rxtxq;
2319 cmdline_fixed_string_t opname;
2323 cmd_config_rxtx_queue_parsed(void *parsed_result,
2324 __attribute__((unused)) struct cmdline *cl,
2325 __attribute__((unused)) void *data)
2327 struct cmd_config_rxtx_queue *res = parsed_result;
2332 if (test_done == 0) {
2333 printf("Please stop forwarding first\n");
2337 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2340 if (port_is_started(res->portid) != 1) {
2341 printf("Please start port %u first\n", res->portid);
2345 if (!strcmp(res->rxtxq, "rxq"))
2347 else if (!strcmp(res->rxtxq, "txq"))
2350 printf("Unknown parameter\n");
2354 if (isrx && rx_queue_id_is_invalid(res->qid))
2356 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2359 if (!strcmp(res->opname, "start"))
2361 else if (!strcmp(res->opname, "stop"))
2364 printf("Unknown parameter\n");
2368 if (isstart && isrx)
2369 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2370 else if (!isstart && isrx)
2371 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2372 else if (isstart && !isrx)
2373 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2375 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2377 if (ret == -ENOTSUP)
2378 printf("Function not supported in PMD driver\n");
2381 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2382 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2383 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2384 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2385 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2386 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2387 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2388 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2389 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2390 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2393 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2394 .f = cmd_config_rxtx_queue_parsed,
2396 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2398 (void *)&cmd_config_rxtx_queue_port,
2399 (void *)&cmd_config_rxtx_queue_portid,
2400 (void *)&cmd_config_rxtx_queue_rxtxq,
2401 (void *)&cmd_config_rxtx_queue_qid,
2402 (void *)&cmd_config_rxtx_queue_opname,
2407 /* *** configure port rxq/txq setup *** */
2408 struct cmd_setup_rxtx_queue {
2409 cmdline_fixed_string_t port;
2411 cmdline_fixed_string_t rxtxq;
2413 cmdline_fixed_string_t setup;
2416 /* Common CLI fields for queue setup */
2417 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2418 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2419 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2420 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2421 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2422 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2423 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2424 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2425 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2426 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2429 cmd_setup_rxtx_queue_parsed(
2430 void *parsed_result,
2431 __attribute__((unused)) struct cmdline *cl,
2432 __attribute__((unused)) void *data)
2434 struct cmd_setup_rxtx_queue *res = parsed_result;
2435 struct rte_port *port;
2436 struct rte_mempool *mp;
2437 unsigned int socket_id;
2441 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2444 if (res->portid == (portid_t)RTE_PORT_ALL) {
2445 printf("Invalid port id\n");
2449 if (!strcmp(res->rxtxq, "rxq"))
2451 else if (!strcmp(res->rxtxq, "txq"))
2454 printf("Unknown parameter\n");
2458 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2459 printf("Invalid rx queue\n");
2461 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2462 printf("Invalid tx queue\n");
2466 port = &ports[res->portid];
2468 socket_id = rxring_numa[res->portid];
2469 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2470 socket_id = port->socket_id;
2472 mp = mbuf_pool_find(socket_id);
2474 printf("Failed to setup RX queue: "
2475 "No mempool allocation"
2476 " on the socket %d\n",
2477 rxring_numa[res->portid]);
2480 ret = rte_eth_rx_queue_setup(res->portid,
2482 port->nb_rx_desc[res->qid],
2484 &port->rx_conf[res->qid],
2487 printf("Failed to setup RX queue\n");
2489 socket_id = txring_numa[res->portid];
2490 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2491 socket_id = port->socket_id;
2493 ret = rte_eth_tx_queue_setup(res->portid,
2495 port->nb_tx_desc[res->qid],
2497 &port->tx_conf[res->qid]);
2499 printf("Failed to setup TX queue\n");
2503 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2504 .f = cmd_setup_rxtx_queue_parsed,
2506 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2508 (void *)&cmd_setup_rxtx_queue_port,
2509 (void *)&cmd_setup_rxtx_queue_portid,
2510 (void *)&cmd_setup_rxtx_queue_rxtxq,
2511 (void *)&cmd_setup_rxtx_queue_qid,
2512 (void *)&cmd_setup_rxtx_queue_setup,
2518 /* *** Configure RSS RETA *** */
2519 struct cmd_config_rss_reta {
2520 cmdline_fixed_string_t port;
2521 cmdline_fixed_string_t keyword;
2523 cmdline_fixed_string_t name;
2524 cmdline_fixed_string_t list_name;
2525 cmdline_fixed_string_t list_of_items;
2529 parse_reta_config(const char *str,
2530 struct rte_eth_rss_reta_entry64 *reta_conf,
2531 uint16_t nb_entries)
2535 uint16_t hash_index, idx, shift;
2538 const char *p, *p0 = str;
2545 unsigned long int_fld[_NUM_FLD];
2546 char *str_fld[_NUM_FLD];
2548 while ((p = strchr(p0,'(')) != NULL) {
2550 if((p0 = strchr(p,')')) == NULL)
2554 if(size >= sizeof(s))
2557 snprintf(s, sizeof(s), "%.*s", size, p);
2558 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2560 for (i = 0; i < _NUM_FLD; i++) {
2562 int_fld[i] = strtoul(str_fld[i], &end, 0);
2563 if (errno != 0 || end == str_fld[i] ||
2568 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2569 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2571 if (hash_index >= nb_entries) {
2572 printf("Invalid RETA hash index=%d\n", hash_index);
2576 idx = hash_index / RTE_RETA_GROUP_SIZE;
2577 shift = hash_index % RTE_RETA_GROUP_SIZE;
2578 reta_conf[idx].mask |= (1ULL << shift);
2579 reta_conf[idx].reta[shift] = nb_queue;
2586 cmd_set_rss_reta_parsed(void *parsed_result,
2587 __attribute__((unused)) struct cmdline *cl,
2588 __attribute__((unused)) void *data)
2591 struct rte_eth_dev_info dev_info;
2592 struct rte_eth_rss_reta_entry64 reta_conf[8];
2593 struct cmd_config_rss_reta *res = parsed_result;
2595 memset(&dev_info, 0, sizeof(dev_info));
2596 rte_eth_dev_info_get(res->port_id, &dev_info);
2597 if (dev_info.reta_size == 0) {
2598 printf("Redirection table size is 0 which is "
2599 "invalid for RSS\n");
2602 printf("The reta size of port %d is %u\n",
2603 res->port_id, dev_info.reta_size);
2604 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2605 printf("Currently do not support more than %u entries of "
2606 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2610 memset(reta_conf, 0, sizeof(reta_conf));
2611 if (!strcmp(res->list_name, "reta")) {
2612 if (parse_reta_config(res->list_of_items, reta_conf,
2613 dev_info.reta_size)) {
2614 printf("Invalid RSS Redirection Table "
2615 "config entered\n");
2618 ret = rte_eth_dev_rss_reta_update(res->port_id,
2619 reta_conf, dev_info.reta_size);
2621 printf("Bad redirection table parameter, "
2622 "return code = %d \n", ret);
2626 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2627 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2628 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2629 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2630 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2631 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2632 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2633 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2634 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2635 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2636 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2637 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2639 cmdline_parse_inst_t cmd_config_rss_reta = {
2640 .f = cmd_set_rss_reta_parsed,
2642 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2644 (void *)&cmd_config_rss_reta_port,
2645 (void *)&cmd_config_rss_reta_keyword,
2646 (void *)&cmd_config_rss_reta_port_id,
2647 (void *)&cmd_config_rss_reta_name,
2648 (void *)&cmd_config_rss_reta_list_name,
2649 (void *)&cmd_config_rss_reta_list_of_items,
2654 /* *** SHOW PORT RETA INFO *** */
2655 struct cmd_showport_reta {
2656 cmdline_fixed_string_t show;
2657 cmdline_fixed_string_t port;
2659 cmdline_fixed_string_t rss;
2660 cmdline_fixed_string_t reta;
2662 cmdline_fixed_string_t list_of_items;
2666 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2667 uint16_t nb_entries,
2671 const char *p, *p0 = str;
2676 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2677 RTE_RETA_GROUP_SIZE;
2680 p = strchr(p0, '(');
2684 p0 = strchr(p, ')');
2688 if (size >= sizeof(s)) {
2689 printf("The string size exceeds the internal buffer size\n");
2692 snprintf(s, sizeof(s), "%.*s", size, p);
2693 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2694 if (ret <= 0 || ret != num) {
2695 printf("The bits of masks do not match the number of "
2696 "reta entries: %u\n", num);
2699 for (i = 0; i < ret; i++)
2700 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2706 cmd_showport_reta_parsed(void *parsed_result,
2707 __attribute__((unused)) struct cmdline *cl,
2708 __attribute__((unused)) void *data)
2710 struct cmd_showport_reta *res = parsed_result;
2711 struct rte_eth_rss_reta_entry64 reta_conf[8];
2712 struct rte_eth_dev_info dev_info;
2713 uint16_t max_reta_size;
2715 memset(&dev_info, 0, sizeof(dev_info));
2716 rte_eth_dev_info_get(res->port_id, &dev_info);
2717 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2718 if (res->size == 0 || res->size > max_reta_size) {
2719 printf("Invalid redirection table size: %u (1-%u)\n",
2720 res->size, max_reta_size);
2724 memset(reta_conf, 0, sizeof(reta_conf));
2725 if (showport_parse_reta_config(reta_conf, res->size,
2726 res->list_of_items) < 0) {
2727 printf("Invalid string: %s for reta masks\n",
2728 res->list_of_items);
2731 port_rss_reta_info(res->port_id, reta_conf, res->size);
2734 cmdline_parse_token_string_t cmd_showport_reta_show =
2735 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2736 cmdline_parse_token_string_t cmd_showport_reta_port =
2737 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2738 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2739 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2740 cmdline_parse_token_string_t cmd_showport_reta_rss =
2741 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2742 cmdline_parse_token_string_t cmd_showport_reta_reta =
2743 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2744 cmdline_parse_token_num_t cmd_showport_reta_size =
2745 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2746 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2747 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2748 list_of_items, NULL);
2750 cmdline_parse_inst_t cmd_showport_reta = {
2751 .f = cmd_showport_reta_parsed,
2753 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2755 (void *)&cmd_showport_reta_show,
2756 (void *)&cmd_showport_reta_port,
2757 (void *)&cmd_showport_reta_port_id,
2758 (void *)&cmd_showport_reta_rss,
2759 (void *)&cmd_showport_reta_reta,
2760 (void *)&cmd_showport_reta_size,
2761 (void *)&cmd_showport_reta_list_of_items,
2766 /* *** Show RSS hash configuration *** */
2767 struct cmd_showport_rss_hash {
2768 cmdline_fixed_string_t show;
2769 cmdline_fixed_string_t port;
2771 cmdline_fixed_string_t rss_hash;
2772 cmdline_fixed_string_t rss_type;
2773 cmdline_fixed_string_t key; /* optional argument */
2776 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2777 __attribute__((unused)) struct cmdline *cl,
2780 struct cmd_showport_rss_hash *res = parsed_result;
2782 port_rss_hash_conf_show(res->port_id, res->rss_type,
2783 show_rss_key != NULL);
2786 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2787 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2788 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2789 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2790 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2791 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2792 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2793 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2795 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2796 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2797 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2798 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2799 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2800 "ipv6-tcp-ex#ipv6-udp-ex");
2801 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2802 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2804 cmdline_parse_inst_t cmd_showport_rss_hash = {
2805 .f = cmd_showport_rss_hash_parsed,
2807 .help_str = "show port <port_id> rss-hash "
2808 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2809 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2810 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2812 (void *)&cmd_showport_rss_hash_show,
2813 (void *)&cmd_showport_rss_hash_port,
2814 (void *)&cmd_showport_rss_hash_port_id,
2815 (void *)&cmd_showport_rss_hash_rss_hash,
2816 (void *)&cmd_showport_rss_hash_rss_hash_info,
2821 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2822 .f = cmd_showport_rss_hash_parsed,
2824 .help_str = "show port <port_id> rss-hash "
2825 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2826 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2827 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2829 (void *)&cmd_showport_rss_hash_show,
2830 (void *)&cmd_showport_rss_hash_port,
2831 (void *)&cmd_showport_rss_hash_port_id,
2832 (void *)&cmd_showport_rss_hash_rss_hash,
2833 (void *)&cmd_showport_rss_hash_rss_hash_info,
2834 (void *)&cmd_showport_rss_hash_rss_key,
2839 /* *** Configure DCB *** */
2840 struct cmd_config_dcb {
2841 cmdline_fixed_string_t port;
2842 cmdline_fixed_string_t config;
2844 cmdline_fixed_string_t dcb;
2845 cmdline_fixed_string_t vt;
2846 cmdline_fixed_string_t vt_en;
2848 cmdline_fixed_string_t pfc;
2849 cmdline_fixed_string_t pfc_en;
2853 cmd_config_dcb_parsed(void *parsed_result,
2854 __attribute__((unused)) struct cmdline *cl,
2855 __attribute__((unused)) void *data)
2857 struct cmd_config_dcb *res = parsed_result;
2858 portid_t port_id = res->port_id;
2859 struct rte_port *port;
2863 port = &ports[port_id];
2864 /** Check if the port is not started **/
2865 if (port->port_status != RTE_PORT_STOPPED) {
2866 printf("Please stop port %d first\n", port_id);
2870 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2871 printf("The invalid number of traffic class,"
2872 " only 4 or 8 allowed.\n");
2876 if (nb_fwd_lcores < res->num_tcs) {
2877 printf("nb_cores shouldn't be less than number of TCs.\n");
2880 if (!strncmp(res->pfc_en, "on", 2))
2885 /* DCB in VT mode */
2886 if (!strncmp(res->vt_en, "on", 2))
2887 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2888 (enum rte_eth_nb_tcs)res->num_tcs,
2891 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2892 (enum rte_eth_nb_tcs)res->num_tcs,
2897 printf("Cannot initialize network ports.\n");
2901 cmd_reconfig_device_queue(port_id, 1, 1);
2904 cmdline_parse_token_string_t cmd_config_dcb_port =
2905 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2906 cmdline_parse_token_string_t cmd_config_dcb_config =
2907 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2908 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2909 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2910 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2911 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2912 cmdline_parse_token_string_t cmd_config_dcb_vt =
2913 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2914 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2915 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2916 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2917 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2918 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2919 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2920 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2921 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2923 cmdline_parse_inst_t cmd_config_dcb = {
2924 .f = cmd_config_dcb_parsed,
2926 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2928 (void *)&cmd_config_dcb_port,
2929 (void *)&cmd_config_dcb_config,
2930 (void *)&cmd_config_dcb_port_id,
2931 (void *)&cmd_config_dcb_dcb,
2932 (void *)&cmd_config_dcb_vt,
2933 (void *)&cmd_config_dcb_vt_en,
2934 (void *)&cmd_config_dcb_num_tcs,
2935 (void *)&cmd_config_dcb_pfc,
2936 (void *)&cmd_config_dcb_pfc_en,
2941 /* *** configure number of packets per burst *** */
2942 struct cmd_config_burst {
2943 cmdline_fixed_string_t port;
2944 cmdline_fixed_string_t keyword;
2945 cmdline_fixed_string_t all;
2946 cmdline_fixed_string_t name;
2951 cmd_config_burst_parsed(void *parsed_result,
2952 __attribute__((unused)) struct cmdline *cl,
2953 __attribute__((unused)) void *data)
2955 struct cmd_config_burst *res = parsed_result;
2956 struct rte_eth_dev_info dev_info;
2957 uint16_t rec_nb_pkts;
2959 if (!all_ports_stopped()) {
2960 printf("Please stop all ports first\n");
2964 if (!strcmp(res->name, "burst")) {
2965 if (res->value == 0) {
2966 /* If user gives a value of zero, query the PMD for
2967 * its recommended Rx burst size. Testpmd uses a single
2968 * size for all ports, so assume all ports are the same
2969 * NIC model and use the values from Port 0.
2971 rte_eth_dev_info_get(0, &dev_info);
2972 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2974 if (rec_nb_pkts == 0) {
2975 printf("PMD does not recommend a burst size.\n"
2976 "User provided value must be between"
2977 " 1 and %d\n", MAX_PKT_BURST);
2979 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2980 printf("PMD recommended burst size of %d"
2981 " exceeds maximum value of %d\n",
2982 rec_nb_pkts, MAX_PKT_BURST);
2985 printf("Using PMD-provided burst value of %d\n",
2987 nb_pkt_per_burst = rec_nb_pkts;
2988 } else if (res->value > MAX_PKT_BURST) {
2989 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2992 nb_pkt_per_burst = res->value;
2994 printf("Unknown parameter\n");
3000 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3003 cmdline_parse_token_string_t cmd_config_burst_port =
3004 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3005 cmdline_parse_token_string_t cmd_config_burst_keyword =
3006 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3007 cmdline_parse_token_string_t cmd_config_burst_all =
3008 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3009 cmdline_parse_token_string_t cmd_config_burst_name =
3010 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3011 cmdline_parse_token_num_t cmd_config_burst_value =
3012 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3014 cmdline_parse_inst_t cmd_config_burst = {
3015 .f = cmd_config_burst_parsed,
3017 .help_str = "port config all burst <value>",
3019 (void *)&cmd_config_burst_port,
3020 (void *)&cmd_config_burst_keyword,
3021 (void *)&cmd_config_burst_all,
3022 (void *)&cmd_config_burst_name,
3023 (void *)&cmd_config_burst_value,
3028 /* *** configure rx/tx queues *** */
3029 struct cmd_config_thresh {
3030 cmdline_fixed_string_t port;
3031 cmdline_fixed_string_t keyword;
3032 cmdline_fixed_string_t all;
3033 cmdline_fixed_string_t name;
3038 cmd_config_thresh_parsed(void *parsed_result,
3039 __attribute__((unused)) struct cmdline *cl,
3040 __attribute__((unused)) void *data)
3042 struct cmd_config_thresh *res = parsed_result;
3044 if (!all_ports_stopped()) {
3045 printf("Please stop all ports first\n");
3049 if (!strcmp(res->name, "txpt"))
3050 tx_pthresh = res->value;
3051 else if(!strcmp(res->name, "txht"))
3052 tx_hthresh = res->value;
3053 else if(!strcmp(res->name, "txwt"))
3054 tx_wthresh = res->value;
3055 else if(!strcmp(res->name, "rxpt"))
3056 rx_pthresh = res->value;
3057 else if(!strcmp(res->name, "rxht"))
3058 rx_hthresh = res->value;
3059 else if(!strcmp(res->name, "rxwt"))
3060 rx_wthresh = res->value;
3062 printf("Unknown parameter\n");
3068 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3071 cmdline_parse_token_string_t cmd_config_thresh_port =
3072 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3073 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3074 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3075 cmdline_parse_token_string_t cmd_config_thresh_all =
3076 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3077 cmdline_parse_token_string_t cmd_config_thresh_name =
3078 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3079 "txpt#txht#txwt#rxpt#rxht#rxwt");
3080 cmdline_parse_token_num_t cmd_config_thresh_value =
3081 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3083 cmdline_parse_inst_t cmd_config_thresh = {
3084 .f = cmd_config_thresh_parsed,
3086 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3088 (void *)&cmd_config_thresh_port,
3089 (void *)&cmd_config_thresh_keyword,
3090 (void *)&cmd_config_thresh_all,
3091 (void *)&cmd_config_thresh_name,
3092 (void *)&cmd_config_thresh_value,
3097 /* *** configure free/rs threshold *** */
3098 struct cmd_config_threshold {
3099 cmdline_fixed_string_t port;
3100 cmdline_fixed_string_t keyword;
3101 cmdline_fixed_string_t all;
3102 cmdline_fixed_string_t name;
3107 cmd_config_threshold_parsed(void *parsed_result,
3108 __attribute__((unused)) struct cmdline *cl,
3109 __attribute__((unused)) void *data)
3111 struct cmd_config_threshold *res = parsed_result;
3113 if (!all_ports_stopped()) {
3114 printf("Please stop all ports first\n");
3118 if (!strcmp(res->name, "txfreet"))
3119 tx_free_thresh = res->value;
3120 else if (!strcmp(res->name, "txrst"))
3121 tx_rs_thresh = res->value;
3122 else if (!strcmp(res->name, "rxfreet"))
3123 rx_free_thresh = res->value;
3125 printf("Unknown parameter\n");
3131 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3134 cmdline_parse_token_string_t cmd_config_threshold_port =
3135 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3136 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3137 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3139 cmdline_parse_token_string_t cmd_config_threshold_all =
3140 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3141 cmdline_parse_token_string_t cmd_config_threshold_name =
3142 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3143 "txfreet#txrst#rxfreet");
3144 cmdline_parse_token_num_t cmd_config_threshold_value =
3145 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3147 cmdline_parse_inst_t cmd_config_threshold = {
3148 .f = cmd_config_threshold_parsed,
3150 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3152 (void *)&cmd_config_threshold_port,
3153 (void *)&cmd_config_threshold_keyword,
3154 (void *)&cmd_config_threshold_all,
3155 (void *)&cmd_config_threshold_name,
3156 (void *)&cmd_config_threshold_value,
3162 struct cmd_stop_result {
3163 cmdline_fixed_string_t stop;
3166 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3167 __attribute__((unused)) struct cmdline *cl,
3168 __attribute__((unused)) void *data)
3170 stop_packet_forwarding();
3173 cmdline_parse_token_string_t cmd_stop_stop =
3174 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3176 cmdline_parse_inst_t cmd_stop = {
3177 .f = cmd_stop_parsed,
3179 .help_str = "stop: Stop packet forwarding",
3181 (void *)&cmd_stop_stop,
3186 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3189 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3190 unsigned int *parsed_items, int check_unique_values)
3192 unsigned int nb_item;
3200 * First parse all items in the list and store their value.
3205 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3207 if ((c >= '0') && (c <= '9')) {
3208 value = (unsigned int) (value * 10 + (c - '0'));
3213 printf("character %c is not a decimal digit\n", c);
3217 printf("No valid value before comma\n");
3220 if (nb_item < max_items) {
3221 parsed_items[nb_item] = value;
3227 if (nb_item >= max_items) {
3228 printf("Number of %s = %u > %u (maximum items)\n",
3229 item_name, nb_item + 1, max_items);
3232 parsed_items[nb_item++] = value;
3233 if (! check_unique_values)
3237 * Then, check that all values in the list are differents.
3238 * No optimization here...
3240 for (i = 0; i < nb_item; i++) {
3241 for (j = i + 1; j < nb_item; j++) {
3242 if (parsed_items[j] == parsed_items[i]) {
3243 printf("duplicated %s %u at index %u and %u\n",
3244 item_name, parsed_items[i], i, j);
3252 struct cmd_set_list_result {
3253 cmdline_fixed_string_t cmd_keyword;
3254 cmdline_fixed_string_t list_name;
3255 cmdline_fixed_string_t list_of_items;
3258 static void cmd_set_list_parsed(void *parsed_result,
3259 __attribute__((unused)) struct cmdline *cl,
3260 __attribute__((unused)) void *data)
3262 struct cmd_set_list_result *res;
3264 unsigned int lcorelist[RTE_MAX_LCORE];
3265 unsigned int portlist[RTE_MAX_ETHPORTS];
3267 unsigned int nb_item;
3269 if (test_done == 0) {
3270 printf("Please stop forwarding first\n");
3274 res = parsed_result;
3275 if (!strcmp(res->list_name, "corelist")) {
3276 nb_item = parse_item_list(res->list_of_items, "core",
3278 parsed_items.lcorelist, 1);
3280 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3285 if (!strcmp(res->list_name, "portlist")) {
3286 nb_item = parse_item_list(res->list_of_items, "port",
3288 parsed_items.portlist, 1);
3290 set_fwd_ports_list(parsed_items.portlist, nb_item);
3296 cmdline_parse_token_string_t cmd_set_list_keyword =
3297 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3299 cmdline_parse_token_string_t cmd_set_list_name =
3300 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3301 "corelist#portlist");
3302 cmdline_parse_token_string_t cmd_set_list_of_items =
3303 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3306 cmdline_parse_inst_t cmd_set_fwd_list = {
3307 .f = cmd_set_list_parsed,
3309 .help_str = "set corelist|portlist <list0[,list1]*>",
3311 (void *)&cmd_set_list_keyword,
3312 (void *)&cmd_set_list_name,
3313 (void *)&cmd_set_list_of_items,
3318 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3320 struct cmd_setmask_result {
3321 cmdline_fixed_string_t set;
3322 cmdline_fixed_string_t mask;
3326 static void cmd_set_mask_parsed(void *parsed_result,
3327 __attribute__((unused)) struct cmdline *cl,
3328 __attribute__((unused)) void *data)
3330 struct cmd_setmask_result *res = parsed_result;
3332 if (test_done == 0) {
3333 printf("Please stop forwarding first\n");
3336 if (!strcmp(res->mask, "coremask")) {
3337 set_fwd_lcores_mask(res->hexavalue);
3339 } else if (!strcmp(res->mask, "portmask")) {
3340 set_fwd_ports_mask(res->hexavalue);
3345 cmdline_parse_token_string_t cmd_setmask_set =
3346 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3347 cmdline_parse_token_string_t cmd_setmask_mask =
3348 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3349 "coremask#portmask");
3350 cmdline_parse_token_num_t cmd_setmask_value =
3351 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3353 cmdline_parse_inst_t cmd_set_fwd_mask = {
3354 .f = cmd_set_mask_parsed,
3356 .help_str = "set coremask|portmask <hexadecimal value>",
3358 (void *)&cmd_setmask_set,
3359 (void *)&cmd_setmask_mask,
3360 (void *)&cmd_setmask_value,
3366 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3368 struct cmd_set_result {
3369 cmdline_fixed_string_t set;
3370 cmdline_fixed_string_t what;
3374 static void cmd_set_parsed(void *parsed_result,
3375 __attribute__((unused)) struct cmdline *cl,
3376 __attribute__((unused)) void *data)
3378 struct cmd_set_result *res = parsed_result;
3379 if (!strcmp(res->what, "nbport")) {
3380 set_fwd_ports_number(res->value);
3382 } else if (!strcmp(res->what, "nbcore")) {
3383 set_fwd_lcores_number(res->value);
3385 } else if (!strcmp(res->what, "burst"))
3386 set_nb_pkt_per_burst(res->value);
3387 else if (!strcmp(res->what, "verbose"))
3388 set_verbose_level(res->value);
3391 cmdline_parse_token_string_t cmd_set_set =
3392 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3393 cmdline_parse_token_string_t cmd_set_what =
3394 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3395 "nbport#nbcore#burst#verbose");
3396 cmdline_parse_token_num_t cmd_set_value =
3397 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3399 cmdline_parse_inst_t cmd_set_numbers = {
3400 .f = cmd_set_parsed,
3402 .help_str = "set nbport|nbcore|burst|verbose <value>",
3404 (void *)&cmd_set_set,
3405 (void *)&cmd_set_what,
3406 (void *)&cmd_set_value,
3411 /* *** SET LOG LEVEL CONFIGURATION *** */
3413 struct cmd_set_log_result {
3414 cmdline_fixed_string_t set;
3415 cmdline_fixed_string_t log;
3416 cmdline_fixed_string_t type;
3421 cmd_set_log_parsed(void *parsed_result,
3422 __attribute__((unused)) struct cmdline *cl,
3423 __attribute__((unused)) void *data)
3425 struct cmd_set_log_result *res;
3428 res = parsed_result;
3429 if (!strcmp(res->type, "global"))
3430 rte_log_set_global_level(res->level);
3432 ret = rte_log_set_level_regexp(res->type, res->level);
3434 printf("Unable to set log level\n");
3438 cmdline_parse_token_string_t cmd_set_log_set =
3439 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3440 cmdline_parse_token_string_t cmd_set_log_log =
3441 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3442 cmdline_parse_token_string_t cmd_set_log_type =
3443 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3444 cmdline_parse_token_num_t cmd_set_log_level =
3445 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3447 cmdline_parse_inst_t cmd_set_log = {
3448 .f = cmd_set_log_parsed,
3450 .help_str = "set log global|<type> <level>",
3452 (void *)&cmd_set_log_set,
3453 (void *)&cmd_set_log_log,
3454 (void *)&cmd_set_log_type,
3455 (void *)&cmd_set_log_level,
3460 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3462 struct cmd_set_txpkts_result {
3463 cmdline_fixed_string_t cmd_keyword;
3464 cmdline_fixed_string_t txpkts;
3465 cmdline_fixed_string_t seg_lengths;
3469 cmd_set_txpkts_parsed(void *parsed_result,
3470 __attribute__((unused)) struct cmdline *cl,
3471 __attribute__((unused)) void *data)
3473 struct cmd_set_txpkts_result *res;
3474 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3475 unsigned int nb_segs;
3477 res = parsed_result;
3478 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3479 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3481 set_tx_pkt_segments(seg_lengths, nb_segs);
3484 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3485 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3486 cmd_keyword, "set");
3487 cmdline_parse_token_string_t cmd_set_txpkts_name =
3488 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3490 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3491 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3494 cmdline_parse_inst_t cmd_set_txpkts = {
3495 .f = cmd_set_txpkts_parsed,
3497 .help_str = "set txpkts <len0[,len1]*>",
3499 (void *)&cmd_set_txpkts_keyword,
3500 (void *)&cmd_set_txpkts_name,
3501 (void *)&cmd_set_txpkts_lengths,
3506 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3508 struct cmd_set_txsplit_result {
3509 cmdline_fixed_string_t cmd_keyword;
3510 cmdline_fixed_string_t txsplit;
3511 cmdline_fixed_string_t mode;
3515 cmd_set_txsplit_parsed(void *parsed_result,
3516 __attribute__((unused)) struct cmdline *cl,
3517 __attribute__((unused)) void *data)
3519 struct cmd_set_txsplit_result *res;
3521 res = parsed_result;
3522 set_tx_pkt_split(res->mode);
3525 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3526 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3527 cmd_keyword, "set");
3528 cmdline_parse_token_string_t cmd_set_txsplit_name =
3529 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3530 txsplit, "txsplit");
3531 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3532 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3535 cmdline_parse_inst_t cmd_set_txsplit = {
3536 .f = cmd_set_txsplit_parsed,
3538 .help_str = "set txsplit on|off|rand",
3540 (void *)&cmd_set_txsplit_keyword,
3541 (void *)&cmd_set_txsplit_name,
3542 (void *)&cmd_set_txsplit_mode,
3547 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3548 struct cmd_rx_vlan_filter_all_result {
3549 cmdline_fixed_string_t rx_vlan;
3550 cmdline_fixed_string_t what;
3551 cmdline_fixed_string_t all;
3556 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3557 __attribute__((unused)) struct cmdline *cl,
3558 __attribute__((unused)) void *data)
3560 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3562 if (!strcmp(res->what, "add"))
3563 rx_vlan_all_filter_set(res->port_id, 1);
3565 rx_vlan_all_filter_set(res->port_id, 0);
3568 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3569 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3570 rx_vlan, "rx_vlan");
3571 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3572 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3574 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3575 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3577 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3578 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3581 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3582 .f = cmd_rx_vlan_filter_all_parsed,
3584 .help_str = "rx_vlan add|rm all <port_id>: "
3585 "Add/Remove all identifiers to/from the set of VLAN "
3586 "identifiers filtered by a port",
3588 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3589 (void *)&cmd_rx_vlan_filter_all_what,
3590 (void *)&cmd_rx_vlan_filter_all_all,
3591 (void *)&cmd_rx_vlan_filter_all_portid,
3596 /* *** VLAN OFFLOAD SET ON A PORT *** */
3597 struct cmd_vlan_offload_result {
3598 cmdline_fixed_string_t vlan;
3599 cmdline_fixed_string_t set;
3600 cmdline_fixed_string_t vlan_type;
3601 cmdline_fixed_string_t what;
3602 cmdline_fixed_string_t on;
3603 cmdline_fixed_string_t port_id;
3607 cmd_vlan_offload_parsed(void *parsed_result,
3608 __attribute__((unused)) struct cmdline *cl,
3609 __attribute__((unused)) void *data)
3612 struct cmd_vlan_offload_result *res = parsed_result;
3615 portid_t port_id = 0;
3619 len = strnlen(str, STR_TOKEN_SIZE);
3621 /* Get port_id first */
3629 tmp = strtoul(str, NULL, 0);
3630 /* If port_id greater that what portid_t can represent, return */
3631 if(tmp >= RTE_MAX_ETHPORTS)
3633 port_id = (portid_t)tmp;
3635 if (!strcmp(res->on, "on"))
3640 if (!strcmp(res->what, "strip"))
3641 rx_vlan_strip_set(port_id, on);
3642 else if(!strcmp(res->what, "stripq")){
3643 uint16_t queue_id = 0;
3645 /* No queue_id, return */
3647 printf("must specify (port,queue_id)\n");
3650 tmp = strtoul(str + i + 1, NULL, 0);
3651 /* If queue_id greater that what 16-bits can represent, return */
3655 queue_id = (uint16_t)tmp;
3656 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3658 else if (!strcmp(res->what, "filter"))
3659 rx_vlan_filter_set(port_id, on);
3661 vlan_extend_set(port_id, on);
3666 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3667 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3669 cmdline_parse_token_string_t cmd_vlan_offload_set =
3670 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3672 cmdline_parse_token_string_t cmd_vlan_offload_what =
3673 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3674 what, "strip#filter#qinq#stripq");
3675 cmdline_parse_token_string_t cmd_vlan_offload_on =
3676 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3678 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3679 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3682 cmdline_parse_inst_t cmd_vlan_offload = {
3683 .f = cmd_vlan_offload_parsed,
3685 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3686 "<port_id[,queue_id]>: "
3687 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3689 (void *)&cmd_vlan_offload_vlan,
3690 (void *)&cmd_vlan_offload_set,
3691 (void *)&cmd_vlan_offload_what,
3692 (void *)&cmd_vlan_offload_on,
3693 (void *)&cmd_vlan_offload_portid,
3698 /* *** VLAN TPID SET ON A PORT *** */
3699 struct cmd_vlan_tpid_result {
3700 cmdline_fixed_string_t vlan;
3701 cmdline_fixed_string_t set;
3702 cmdline_fixed_string_t vlan_type;
3703 cmdline_fixed_string_t what;
3709 cmd_vlan_tpid_parsed(void *parsed_result,
3710 __attribute__((unused)) struct cmdline *cl,
3711 __attribute__((unused)) void *data)
3713 struct cmd_vlan_tpid_result *res = parsed_result;
3714 enum rte_vlan_type vlan_type;
3716 if (!strcmp(res->vlan_type, "inner"))
3717 vlan_type = ETH_VLAN_TYPE_INNER;
3718 else if (!strcmp(res->vlan_type, "outer"))
3719 vlan_type = ETH_VLAN_TYPE_OUTER;
3721 printf("Unknown vlan type\n");
3724 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3727 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3728 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3730 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3731 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3733 cmdline_parse_token_string_t cmd_vlan_type =
3734 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3735 vlan_type, "inner#outer");
3736 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3737 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3739 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3740 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3742 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3743 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3746 cmdline_parse_inst_t cmd_vlan_tpid = {
3747 .f = cmd_vlan_tpid_parsed,
3749 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3750 "Set the VLAN Ether type",
3752 (void *)&cmd_vlan_tpid_vlan,
3753 (void *)&cmd_vlan_tpid_set,
3754 (void *)&cmd_vlan_type,
3755 (void *)&cmd_vlan_tpid_what,
3756 (void *)&cmd_vlan_tpid_tpid,
3757 (void *)&cmd_vlan_tpid_portid,
3762 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3763 struct cmd_rx_vlan_filter_result {
3764 cmdline_fixed_string_t rx_vlan;
3765 cmdline_fixed_string_t what;
3771 cmd_rx_vlan_filter_parsed(void *parsed_result,
3772 __attribute__((unused)) struct cmdline *cl,
3773 __attribute__((unused)) void *data)
3775 struct cmd_rx_vlan_filter_result *res = parsed_result;
3777 if (!strcmp(res->what, "add"))
3778 rx_vft_set(res->port_id, res->vlan_id, 1);
3780 rx_vft_set(res->port_id, res->vlan_id, 0);
3783 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3784 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3785 rx_vlan, "rx_vlan");
3786 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3787 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3789 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3790 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3792 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3793 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3796 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3797 .f = cmd_rx_vlan_filter_parsed,
3799 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3800 "Add/Remove a VLAN identifier to/from the set of VLAN "
3801 "identifiers filtered by a port",
3803 (void *)&cmd_rx_vlan_filter_rx_vlan,
3804 (void *)&cmd_rx_vlan_filter_what,
3805 (void *)&cmd_rx_vlan_filter_vlanid,
3806 (void *)&cmd_rx_vlan_filter_portid,
3811 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3812 struct cmd_tx_vlan_set_result {
3813 cmdline_fixed_string_t tx_vlan;
3814 cmdline_fixed_string_t set;
3820 cmd_tx_vlan_set_parsed(void *parsed_result,
3821 __attribute__((unused)) struct cmdline *cl,
3822 __attribute__((unused)) void *data)
3824 struct cmd_tx_vlan_set_result *res = parsed_result;
3826 if (!port_is_stopped(res->port_id)) {
3827 printf("Please stop port %d first\n", res->port_id);
3831 tx_vlan_set(res->port_id, res->vlan_id);
3833 cmd_reconfig_device_queue(res->port_id, 1, 1);
3836 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3837 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3838 tx_vlan, "tx_vlan");
3839 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3840 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3842 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3843 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3845 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3846 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3849 cmdline_parse_inst_t cmd_tx_vlan_set = {
3850 .f = cmd_tx_vlan_set_parsed,
3852 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3853 "Enable hardware insertion of a single VLAN header "
3854 "with a given TAG Identifier in packets sent on a port",
3856 (void *)&cmd_tx_vlan_set_tx_vlan,
3857 (void *)&cmd_tx_vlan_set_set,
3858 (void *)&cmd_tx_vlan_set_portid,
3859 (void *)&cmd_tx_vlan_set_vlanid,
3864 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3865 struct cmd_tx_vlan_set_qinq_result {
3866 cmdline_fixed_string_t tx_vlan;
3867 cmdline_fixed_string_t set;
3870 uint16_t vlan_id_outer;
3874 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3875 __attribute__((unused)) struct cmdline *cl,
3876 __attribute__((unused)) void *data)
3878 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3880 if (!port_is_stopped(res->port_id)) {
3881 printf("Please stop port %d first\n", res->port_id);
3885 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3887 cmd_reconfig_device_queue(res->port_id, 1, 1);
3890 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3891 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3892 tx_vlan, "tx_vlan");
3893 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3894 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3896 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3897 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3899 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3900 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3902 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3903 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3904 vlan_id_outer, UINT16);
3906 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3907 .f = cmd_tx_vlan_set_qinq_parsed,
3909 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3910 "Enable hardware insertion of double VLAN header "
3911 "with given TAG Identifiers in packets sent on a port",
3913 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3914 (void *)&cmd_tx_vlan_set_qinq_set,
3915 (void *)&cmd_tx_vlan_set_qinq_portid,
3916 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3917 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3922 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3923 struct cmd_tx_vlan_set_pvid_result {
3924 cmdline_fixed_string_t tx_vlan;
3925 cmdline_fixed_string_t set;
3926 cmdline_fixed_string_t pvid;
3929 cmdline_fixed_string_t mode;
3933 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3934 __attribute__((unused)) struct cmdline *cl,
3935 __attribute__((unused)) void *data)
3937 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3939 if (strcmp(res->mode, "on") == 0)
3940 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3942 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3945 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3946 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3947 tx_vlan, "tx_vlan");
3948 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3949 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3951 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3952 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3954 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3955 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3957 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3958 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3960 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3961 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3964 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3965 .f = cmd_tx_vlan_set_pvid_parsed,
3967 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3969 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3970 (void *)&cmd_tx_vlan_set_pvid_set,
3971 (void *)&cmd_tx_vlan_set_pvid_pvid,
3972 (void *)&cmd_tx_vlan_set_pvid_port_id,
3973 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3974 (void *)&cmd_tx_vlan_set_pvid_mode,
3979 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3980 struct cmd_tx_vlan_reset_result {
3981 cmdline_fixed_string_t tx_vlan;
3982 cmdline_fixed_string_t reset;
3987 cmd_tx_vlan_reset_parsed(void *parsed_result,
3988 __attribute__((unused)) struct cmdline *cl,
3989 __attribute__((unused)) void *data)
3991 struct cmd_tx_vlan_reset_result *res = parsed_result;
3993 if (!port_is_stopped(res->port_id)) {
3994 printf("Please stop port %d first\n", res->port_id);
3998 tx_vlan_reset(res->port_id);
4000 cmd_reconfig_device_queue(res->port_id, 1, 1);
4003 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4004 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4005 tx_vlan, "tx_vlan");
4006 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4007 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4009 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4010 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4013 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4014 .f = cmd_tx_vlan_reset_parsed,
4016 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4017 "VLAN header in packets sent on a port",
4019 (void *)&cmd_tx_vlan_reset_tx_vlan,
4020 (void *)&cmd_tx_vlan_reset_reset,
4021 (void *)&cmd_tx_vlan_reset_portid,
4027 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4028 struct cmd_csum_result {
4029 cmdline_fixed_string_t csum;
4030 cmdline_fixed_string_t mode;
4031 cmdline_fixed_string_t proto;
4032 cmdline_fixed_string_t hwsw;
4037 csum_show(int port_id)
4039 struct rte_eth_dev_info dev_info;
4040 uint64_t tx_offloads;
4042 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4043 printf("Parse tunnel is %s\n",
4044 (ports[port_id].parse_tunnel) ? "on" : "off");
4045 printf("IP checksum offload is %s\n",
4046 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4047 printf("UDP checksum offload is %s\n",
4048 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4049 printf("TCP checksum offload is %s\n",
4050 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4051 printf("SCTP checksum offload is %s\n",
4052 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4053 printf("Outer-Ip checksum offload is %s\n",
4054 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4056 /* display warnings if configuration is not supported by the NIC */
4057 rte_eth_dev_info_get(port_id, &dev_info);
4058 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4059 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4060 printf("Warning: hardware IP checksum enabled but not "
4061 "supported by port %d\n", port_id);
4063 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4064 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4065 printf("Warning: hardware UDP checksum enabled but not "
4066 "supported by port %d\n", port_id);
4068 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4069 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4070 printf("Warning: hardware TCP checksum enabled but not "
4071 "supported by port %d\n", port_id);
4073 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4074 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4075 printf("Warning: hardware SCTP checksum enabled but not "
4076 "supported by port %d\n", port_id);
4078 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4079 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4080 printf("Warning: hardware outer IP checksum enabled but not "
4081 "supported by port %d\n", port_id);
4086 cmd_csum_parsed(void *parsed_result,
4087 __attribute__((unused)) struct cmdline *cl,
4088 __attribute__((unused)) void *data)
4090 struct cmd_csum_result *res = parsed_result;
4092 uint64_t csum_offloads = 0;
4093 struct rte_eth_dev_info dev_info;
4095 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4096 printf("invalid port %d\n", res->port_id);
4099 if (!port_is_stopped(res->port_id)) {
4100 printf("Please stop port %d first\n", res->port_id);
4104 rte_eth_dev_info_get(res->port_id, &dev_info);
4105 if (!strcmp(res->mode, "set")) {
4107 if (!strcmp(res->hwsw, "hw"))
4110 if (!strcmp(res->proto, "ip")) {
4111 if (hw == 0 || (dev_info.tx_offload_capa &
4112 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4113 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4115 printf("IP checksum offload is not supported "
4116 "by port %u\n", res->port_id);
4118 } else if (!strcmp(res->proto, "udp")) {
4119 if (hw == 0 || (dev_info.tx_offload_capa &
4120 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4121 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4123 printf("UDP checksum offload is not supported "
4124 "by port %u\n", res->port_id);
4126 } else if (!strcmp(res->proto, "tcp")) {
4127 if (hw == 0 || (dev_info.tx_offload_capa &
4128 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4129 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4131 printf("TCP checksum offload is not supported "
4132 "by port %u\n", res->port_id);
4134 } else if (!strcmp(res->proto, "sctp")) {
4135 if (hw == 0 || (dev_info.tx_offload_capa &
4136 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4137 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4139 printf("SCTP checksum offload is not supported "
4140 "by port %u\n", res->port_id);
4142 } else if (!strcmp(res->proto, "outer-ip")) {
4143 if (hw == 0 || (dev_info.tx_offload_capa &
4144 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4146 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4148 printf("Outer IP checksum offload is not "
4149 "supported by port %u\n", res->port_id);
4154 ports[res->port_id].dev_conf.txmode.offloads |=
4157 ports[res->port_id].dev_conf.txmode.offloads &=
4161 csum_show(res->port_id);
4163 cmd_reconfig_device_queue(res->port_id, 1, 1);
4166 cmdline_parse_token_string_t cmd_csum_csum =
4167 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4169 cmdline_parse_token_string_t cmd_csum_mode =
4170 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4172 cmdline_parse_token_string_t cmd_csum_proto =
4173 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4174 proto, "ip#tcp#udp#sctp#outer-ip");
4175 cmdline_parse_token_string_t cmd_csum_hwsw =
4176 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4178 cmdline_parse_token_num_t cmd_csum_portid =
4179 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4182 cmdline_parse_inst_t cmd_csum_set = {
4183 .f = cmd_csum_parsed,
4185 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4186 "Enable/Disable hardware calculation of L3/L4 checksum when "
4187 "using csum forward engine",
4189 (void *)&cmd_csum_csum,
4190 (void *)&cmd_csum_mode,
4191 (void *)&cmd_csum_proto,
4192 (void *)&cmd_csum_hwsw,
4193 (void *)&cmd_csum_portid,
4198 cmdline_parse_token_string_t cmd_csum_mode_show =
4199 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4202 cmdline_parse_inst_t cmd_csum_show = {
4203 .f = cmd_csum_parsed,
4205 .help_str = "csum show <port_id>: Show checksum offload configuration",
4207 (void *)&cmd_csum_csum,
4208 (void *)&cmd_csum_mode_show,
4209 (void *)&cmd_csum_portid,
4214 /* Enable/disable tunnel parsing */
4215 struct cmd_csum_tunnel_result {
4216 cmdline_fixed_string_t csum;
4217 cmdline_fixed_string_t parse;
4218 cmdline_fixed_string_t onoff;
4223 cmd_csum_tunnel_parsed(void *parsed_result,
4224 __attribute__((unused)) struct cmdline *cl,
4225 __attribute__((unused)) void *data)
4227 struct cmd_csum_tunnel_result *res = parsed_result;
4229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4232 if (!strcmp(res->onoff, "on"))
4233 ports[res->port_id].parse_tunnel = 1;
4235 ports[res->port_id].parse_tunnel = 0;
4237 csum_show(res->port_id);
4240 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4241 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4243 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4244 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4245 parse, "parse_tunnel");
4246 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4247 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4249 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4250 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4253 cmdline_parse_inst_t cmd_csum_tunnel = {
4254 .f = cmd_csum_tunnel_parsed,
4256 .help_str = "csum parse_tunnel on|off <port_id>: "
4257 "Enable/Disable parsing of tunnels for csum engine",
4259 (void *)&cmd_csum_tunnel_csum,
4260 (void *)&cmd_csum_tunnel_parse,
4261 (void *)&cmd_csum_tunnel_onoff,
4262 (void *)&cmd_csum_tunnel_portid,
4267 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4268 struct cmd_tso_set_result {
4269 cmdline_fixed_string_t tso;
4270 cmdline_fixed_string_t mode;
4276 cmd_tso_set_parsed(void *parsed_result,
4277 __attribute__((unused)) struct cmdline *cl,
4278 __attribute__((unused)) void *data)
4280 struct cmd_tso_set_result *res = parsed_result;
4281 struct rte_eth_dev_info dev_info;
4283 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4285 if (!port_is_stopped(res->port_id)) {
4286 printf("Please stop port %d first\n", res->port_id);
4290 if (!strcmp(res->mode, "set"))
4291 ports[res->port_id].tso_segsz = res->tso_segsz;
4293 rte_eth_dev_info_get(res->port_id, &dev_info);
4294 if ((ports[res->port_id].tso_segsz != 0) &&
4295 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4296 printf("Error: TSO is not supported by port %d\n",
4301 if (ports[res->port_id].tso_segsz == 0) {
4302 ports[res->port_id].dev_conf.txmode.offloads &=
4303 ~DEV_TX_OFFLOAD_TCP_TSO;
4304 printf("TSO for non-tunneled packets is disabled\n");
4306 ports[res->port_id].dev_conf.txmode.offloads |=
4307 DEV_TX_OFFLOAD_TCP_TSO;
4308 printf("TSO segment size for non-tunneled packets is %d\n",
4309 ports[res->port_id].tso_segsz);
4312 /* display warnings if configuration is not supported by the NIC */
4313 rte_eth_dev_info_get(res->port_id, &dev_info);
4314 if ((ports[res->port_id].tso_segsz != 0) &&
4315 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4316 printf("Warning: TSO enabled but not "
4317 "supported by port %d\n", res->port_id);
4320 cmd_reconfig_device_queue(res->port_id, 1, 1);
4323 cmdline_parse_token_string_t cmd_tso_set_tso =
4324 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4326 cmdline_parse_token_string_t cmd_tso_set_mode =
4327 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4329 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4330 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4332 cmdline_parse_token_num_t cmd_tso_set_portid =
4333 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4336 cmdline_parse_inst_t cmd_tso_set = {
4337 .f = cmd_tso_set_parsed,
4339 .help_str = "tso set <tso_segsz> <port_id>: "
4340 "Set TSO segment size of non-tunneled packets for csum engine "
4343 (void *)&cmd_tso_set_tso,
4344 (void *)&cmd_tso_set_mode,
4345 (void *)&cmd_tso_set_tso_segsz,
4346 (void *)&cmd_tso_set_portid,
4351 cmdline_parse_token_string_t cmd_tso_show_mode =
4352 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4356 cmdline_parse_inst_t cmd_tso_show = {
4357 .f = cmd_tso_set_parsed,
4359 .help_str = "tso show <port_id>: "
4360 "Show TSO segment size of non-tunneled packets for csum engine",
4362 (void *)&cmd_tso_set_tso,
4363 (void *)&cmd_tso_show_mode,
4364 (void *)&cmd_tso_set_portid,
4369 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4370 struct cmd_tunnel_tso_set_result {
4371 cmdline_fixed_string_t tso;
4372 cmdline_fixed_string_t mode;
4377 static struct rte_eth_dev_info
4378 check_tunnel_tso_nic_support(portid_t port_id)
4380 struct rte_eth_dev_info dev_info;
4382 rte_eth_dev_info_get(port_id, &dev_info);
4383 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4384 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4385 "not enabled for port %d\n", port_id);
4386 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4387 printf("Warning: GRE TUNNEL TSO not supported therefore "
4388 "not enabled for port %d\n", port_id);
4389 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4390 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4391 "not enabled for port %d\n", port_id);
4392 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4393 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4394 "not enabled for port %d\n", port_id);
4395 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4396 printf("Warning: IP TUNNEL TSO not supported therefore "
4397 "not enabled for port %d\n", port_id);
4398 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4399 printf("Warning: UDP TUNNEL TSO not supported therefore "
4400 "not enabled for port %d\n", port_id);
4405 cmd_tunnel_tso_set_parsed(void *parsed_result,
4406 __attribute__((unused)) struct cmdline *cl,
4407 __attribute__((unused)) void *data)
4409 struct cmd_tunnel_tso_set_result *res = parsed_result;
4410 struct rte_eth_dev_info dev_info;
4412 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4414 if (!port_is_stopped(res->port_id)) {
4415 printf("Please stop port %d first\n", res->port_id);
4419 if (!strcmp(res->mode, "set"))
4420 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4422 dev_info = check_tunnel_tso_nic_support(res->port_id);
4423 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4424 ports[res->port_id].dev_conf.txmode.offloads &=
4425 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4426 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4427 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4428 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4429 DEV_TX_OFFLOAD_IP_TNL_TSO |
4430 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4431 printf("TSO for tunneled packets is disabled\n");
4433 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4434 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4435 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4436 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4437 DEV_TX_OFFLOAD_IP_TNL_TSO |
4438 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4440 ports[res->port_id].dev_conf.txmode.offloads |=
4441 (tso_offloads & dev_info.tx_offload_capa);
4442 printf("TSO segment size for tunneled packets is %d\n",
4443 ports[res->port_id].tunnel_tso_segsz);
4445 /* Below conditions are needed to make it work:
4446 * (1) tunnel TSO is supported by the NIC;
4447 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4449 * (3) for tunneled pkts with outer L3 of IPv4,
4450 * "csum set outer-ip" must be set to hw, because after tso,
4451 * total_len of outer IP header is changed, and the checksum
4452 * of outer IP header calculated by sw should be wrong; that
4453 * is not necessary for IPv6 tunneled pkts because there's no
4454 * checksum in IP header anymore.
4457 if (!ports[res->port_id].parse_tunnel)
4458 printf("Warning: csum parse_tunnel must be set "
4459 "so that tunneled packets are recognized\n");
4460 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4461 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4462 printf("Warning: csum set outer-ip must be set to hw "
4463 "if outer L3 is IPv4; not necessary for IPv6\n");
4466 cmd_reconfig_device_queue(res->port_id, 1, 1);
4469 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4470 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4472 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4473 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4475 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4476 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4478 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4479 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4482 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4483 .f = cmd_tunnel_tso_set_parsed,
4485 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4486 "Set TSO segment size of tunneled packets for csum engine "
4489 (void *)&cmd_tunnel_tso_set_tso,
4490 (void *)&cmd_tunnel_tso_set_mode,
4491 (void *)&cmd_tunnel_tso_set_tso_segsz,
4492 (void *)&cmd_tunnel_tso_set_portid,
4497 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4498 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4502 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4503 .f = cmd_tunnel_tso_set_parsed,
4505 .help_str = "tunnel_tso show <port_id> "
4506 "Show TSO segment size of tunneled packets for csum engine",
4508 (void *)&cmd_tunnel_tso_set_tso,
4509 (void *)&cmd_tunnel_tso_show_mode,
4510 (void *)&cmd_tunnel_tso_set_portid,
4515 /* *** SET GRO FOR A PORT *** */
4516 struct cmd_gro_enable_result {
4517 cmdline_fixed_string_t cmd_set;
4518 cmdline_fixed_string_t cmd_port;
4519 cmdline_fixed_string_t cmd_keyword;
4520 cmdline_fixed_string_t cmd_onoff;
4525 cmd_gro_enable_parsed(void *parsed_result,
4526 __attribute__((unused)) struct cmdline *cl,
4527 __attribute__((unused)) void *data)
4529 struct cmd_gro_enable_result *res;
4531 res = parsed_result;
4532 if (!strcmp(res->cmd_keyword, "gro"))
4533 setup_gro(res->cmd_onoff, res->cmd_pid);
4536 cmdline_parse_token_string_t cmd_gro_enable_set =
4537 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4539 cmdline_parse_token_string_t cmd_gro_enable_port =
4540 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4541 cmd_keyword, "port");
4542 cmdline_parse_token_num_t cmd_gro_enable_pid =
4543 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4545 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4546 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4547 cmd_keyword, "gro");
4548 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4549 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4550 cmd_onoff, "on#off");
4552 cmdline_parse_inst_t cmd_gro_enable = {
4553 .f = cmd_gro_enable_parsed,
4555 .help_str = "set port <port_id> gro on|off",
4557 (void *)&cmd_gro_enable_set,
4558 (void *)&cmd_gro_enable_port,
4559 (void *)&cmd_gro_enable_pid,
4560 (void *)&cmd_gro_enable_keyword,
4561 (void *)&cmd_gro_enable_onoff,
4566 /* *** DISPLAY GRO CONFIGURATION *** */
4567 struct cmd_gro_show_result {
4568 cmdline_fixed_string_t cmd_show;
4569 cmdline_fixed_string_t cmd_port;
4570 cmdline_fixed_string_t cmd_keyword;
4575 cmd_gro_show_parsed(void *parsed_result,
4576 __attribute__((unused)) struct cmdline *cl,
4577 __attribute__((unused)) void *data)
4579 struct cmd_gro_show_result *res;
4581 res = parsed_result;
4582 if (!strcmp(res->cmd_keyword, "gro"))
4583 show_gro(res->cmd_pid);
4586 cmdline_parse_token_string_t cmd_gro_show_show =
4587 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4589 cmdline_parse_token_string_t cmd_gro_show_port =
4590 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4592 cmdline_parse_token_num_t cmd_gro_show_pid =
4593 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4595 cmdline_parse_token_string_t cmd_gro_show_keyword =
4596 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4597 cmd_keyword, "gro");
4599 cmdline_parse_inst_t cmd_gro_show = {
4600 .f = cmd_gro_show_parsed,
4602 .help_str = "show port <port_id> gro",
4604 (void *)&cmd_gro_show_show,
4605 (void *)&cmd_gro_show_port,
4606 (void *)&cmd_gro_show_pid,
4607 (void *)&cmd_gro_show_keyword,
4612 /* *** SET FLUSH CYCLES FOR GRO *** */
4613 struct cmd_gro_flush_result {
4614 cmdline_fixed_string_t cmd_set;
4615 cmdline_fixed_string_t cmd_keyword;
4616 cmdline_fixed_string_t cmd_flush;
4621 cmd_gro_flush_parsed(void *parsed_result,
4622 __attribute__((unused)) struct cmdline *cl,
4623 __attribute__((unused)) void *data)
4625 struct cmd_gro_flush_result *res;
4627 res = parsed_result;
4628 if ((!strcmp(res->cmd_keyword, "gro")) &&
4629 (!strcmp(res->cmd_flush, "flush")))
4630 setup_gro_flush_cycles(res->cmd_cycles);
4633 cmdline_parse_token_string_t cmd_gro_flush_set =
4634 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4636 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4637 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4638 cmd_keyword, "gro");
4639 cmdline_parse_token_string_t cmd_gro_flush_flush =
4640 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4641 cmd_flush, "flush");
4642 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4643 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4646 cmdline_parse_inst_t cmd_gro_flush = {
4647 .f = cmd_gro_flush_parsed,
4649 .help_str = "set gro flush <cycles>",
4651 (void *)&cmd_gro_flush_set,
4652 (void *)&cmd_gro_flush_keyword,
4653 (void *)&cmd_gro_flush_flush,
4654 (void *)&cmd_gro_flush_cycles,
4659 /* *** ENABLE/DISABLE GSO *** */
4660 struct cmd_gso_enable_result {
4661 cmdline_fixed_string_t cmd_set;
4662 cmdline_fixed_string_t cmd_port;
4663 cmdline_fixed_string_t cmd_keyword;
4664 cmdline_fixed_string_t cmd_mode;
4669 cmd_gso_enable_parsed(void *parsed_result,
4670 __attribute__((unused)) struct cmdline *cl,
4671 __attribute__((unused)) void *data)
4673 struct cmd_gso_enable_result *res;
4675 res = parsed_result;
4676 if (!strcmp(res->cmd_keyword, "gso"))
4677 setup_gso(res->cmd_mode, res->cmd_pid);
4680 cmdline_parse_token_string_t cmd_gso_enable_set =
4681 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4683 cmdline_parse_token_string_t cmd_gso_enable_port =
4684 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4686 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4687 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4688 cmd_keyword, "gso");
4689 cmdline_parse_token_string_t cmd_gso_enable_mode =
4690 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4691 cmd_mode, "on#off");
4692 cmdline_parse_token_num_t cmd_gso_enable_pid =
4693 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4696 cmdline_parse_inst_t cmd_gso_enable = {
4697 .f = cmd_gso_enable_parsed,
4699 .help_str = "set port <port_id> gso on|off",
4701 (void *)&cmd_gso_enable_set,
4702 (void *)&cmd_gso_enable_port,
4703 (void *)&cmd_gso_enable_pid,
4704 (void *)&cmd_gso_enable_keyword,
4705 (void *)&cmd_gso_enable_mode,
4710 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4711 struct cmd_gso_size_result {
4712 cmdline_fixed_string_t cmd_set;
4713 cmdline_fixed_string_t cmd_keyword;
4714 cmdline_fixed_string_t cmd_segsz;
4719 cmd_gso_size_parsed(void *parsed_result,
4720 __attribute__((unused)) struct cmdline *cl,
4721 __attribute__((unused)) void *data)
4723 struct cmd_gso_size_result *res = parsed_result;
4725 if (test_done == 0) {
4726 printf("Before setting GSO segsz, please first"
4727 " stop fowarding\n");
4731 if (!strcmp(res->cmd_keyword, "gso") &&
4732 !strcmp(res->cmd_segsz, "segsz")) {
4733 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4734 printf("gso_size should be larger than %zu."
4735 " Please input a legal value\n",
4736 RTE_GSO_SEG_SIZE_MIN);
4738 gso_max_segment_size = res->cmd_size;
4742 cmdline_parse_token_string_t cmd_gso_size_set =
4743 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4745 cmdline_parse_token_string_t cmd_gso_size_keyword =
4746 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4747 cmd_keyword, "gso");
4748 cmdline_parse_token_string_t cmd_gso_size_segsz =
4749 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4750 cmd_segsz, "segsz");
4751 cmdline_parse_token_num_t cmd_gso_size_size =
4752 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4755 cmdline_parse_inst_t cmd_gso_size = {
4756 .f = cmd_gso_size_parsed,
4758 .help_str = "set gso segsz <length>",
4760 (void *)&cmd_gso_size_set,
4761 (void *)&cmd_gso_size_keyword,
4762 (void *)&cmd_gso_size_segsz,
4763 (void *)&cmd_gso_size_size,
4768 /* *** SHOW GSO CONFIGURATION *** */
4769 struct cmd_gso_show_result {
4770 cmdline_fixed_string_t cmd_show;
4771 cmdline_fixed_string_t cmd_port;
4772 cmdline_fixed_string_t cmd_keyword;
4777 cmd_gso_show_parsed(void *parsed_result,
4778 __attribute__((unused)) struct cmdline *cl,
4779 __attribute__((unused)) void *data)
4781 struct cmd_gso_show_result *res = parsed_result;
4783 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4784 printf("invalid port id %u\n", res->cmd_pid);
4787 if (!strcmp(res->cmd_keyword, "gso")) {
4788 if (gso_ports[res->cmd_pid].enable) {
4789 printf("Max GSO'd packet size: %uB\n"
4790 "Supported GSO types: TCP/IPv4, "
4791 "VxLAN with inner TCP/IPv4 packet, "
4792 "GRE with inner TCP/IPv4 packet\n",
4793 gso_max_segment_size);
4795 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4799 cmdline_parse_token_string_t cmd_gso_show_show =
4800 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4802 cmdline_parse_token_string_t cmd_gso_show_port =
4803 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4805 cmdline_parse_token_string_t cmd_gso_show_keyword =
4806 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4807 cmd_keyword, "gso");
4808 cmdline_parse_token_num_t cmd_gso_show_pid =
4809 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4812 cmdline_parse_inst_t cmd_gso_show = {
4813 .f = cmd_gso_show_parsed,
4815 .help_str = "show port <port_id> gso",
4817 (void *)&cmd_gso_show_show,
4818 (void *)&cmd_gso_show_port,
4819 (void *)&cmd_gso_show_pid,
4820 (void *)&cmd_gso_show_keyword,
4825 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4826 struct cmd_set_flush_rx {
4827 cmdline_fixed_string_t set;
4828 cmdline_fixed_string_t flush_rx;
4829 cmdline_fixed_string_t mode;
4833 cmd_set_flush_rx_parsed(void *parsed_result,
4834 __attribute__((unused)) struct cmdline *cl,
4835 __attribute__((unused)) void *data)
4837 struct cmd_set_flush_rx *res = parsed_result;
4838 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4841 cmdline_parse_token_string_t cmd_setflushrx_set =
4842 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4844 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4845 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4846 flush_rx, "flush_rx");
4847 cmdline_parse_token_string_t cmd_setflushrx_mode =
4848 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4852 cmdline_parse_inst_t cmd_set_flush_rx = {
4853 .f = cmd_set_flush_rx_parsed,
4854 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4857 (void *)&cmd_setflushrx_set,
4858 (void *)&cmd_setflushrx_flush_rx,
4859 (void *)&cmd_setflushrx_mode,
4864 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4865 struct cmd_set_link_check {
4866 cmdline_fixed_string_t set;
4867 cmdline_fixed_string_t link_check;
4868 cmdline_fixed_string_t mode;
4872 cmd_set_link_check_parsed(void *parsed_result,
4873 __attribute__((unused)) struct cmdline *cl,
4874 __attribute__((unused)) void *data)
4876 struct cmd_set_link_check *res = parsed_result;
4877 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4880 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4883 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4884 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4885 link_check, "link_check");
4886 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4887 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4891 cmdline_parse_inst_t cmd_set_link_check = {
4892 .f = cmd_set_link_check_parsed,
4893 .help_str = "set link_check on|off: Enable/Disable link status check "
4894 "when starting/stopping a port",
4897 (void *)&cmd_setlinkcheck_set,
4898 (void *)&cmd_setlinkcheck_link_check,
4899 (void *)&cmd_setlinkcheck_mode,
4904 /* *** SET NIC BYPASS MODE *** */
4905 struct cmd_set_bypass_mode_result {
4906 cmdline_fixed_string_t set;
4907 cmdline_fixed_string_t bypass;
4908 cmdline_fixed_string_t mode;
4909 cmdline_fixed_string_t value;
4914 cmd_set_bypass_mode_parsed(void *parsed_result,
4915 __attribute__((unused)) struct cmdline *cl,
4916 __attribute__((unused)) void *data)
4918 struct cmd_set_bypass_mode_result *res = parsed_result;
4919 portid_t port_id = res->port_id;
4920 int32_t rc = -EINVAL;
4922 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4923 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4925 if (!strcmp(res->value, "bypass"))
4926 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4927 else if (!strcmp(res->value, "isolate"))
4928 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4930 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4932 /* Set the bypass mode for the relevant port. */
4933 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4936 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4939 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4940 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4942 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4943 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4945 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4946 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4948 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4949 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4950 value, "normal#bypass#isolate");
4951 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4952 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4955 cmdline_parse_inst_t cmd_set_bypass_mode = {
4956 .f = cmd_set_bypass_mode_parsed,
4957 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4958 "Set the NIC bypass mode for port_id",
4961 (void *)&cmd_setbypass_mode_set,
4962 (void *)&cmd_setbypass_mode_bypass,
4963 (void *)&cmd_setbypass_mode_mode,
4964 (void *)&cmd_setbypass_mode_value,
4965 (void *)&cmd_setbypass_mode_port,
4970 /* *** SET NIC BYPASS EVENT *** */
4971 struct cmd_set_bypass_event_result {
4972 cmdline_fixed_string_t set;
4973 cmdline_fixed_string_t bypass;
4974 cmdline_fixed_string_t event;
4975 cmdline_fixed_string_t event_value;
4976 cmdline_fixed_string_t mode;
4977 cmdline_fixed_string_t mode_value;
4982 cmd_set_bypass_event_parsed(void *parsed_result,
4983 __attribute__((unused)) struct cmdline *cl,
4984 __attribute__((unused)) void *data)
4986 int32_t rc = -EINVAL;
4987 struct cmd_set_bypass_event_result *res = parsed_result;
4988 portid_t port_id = res->port_id;
4990 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4991 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4992 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4994 if (!strcmp(res->event_value, "timeout"))
4995 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4996 else if (!strcmp(res->event_value, "os_on"))
4997 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4998 else if (!strcmp(res->event_value, "os_off"))
4999 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5000 else if (!strcmp(res->event_value, "power_on"))
5001 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5002 else if (!strcmp(res->event_value, "power_off"))
5003 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5005 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5007 if (!strcmp(res->mode_value, "bypass"))
5008 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5009 else if (!strcmp(res->mode_value, "isolate"))
5010 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5012 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5014 /* Set the watchdog timeout. */
5015 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5018 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5019 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5023 printf("Failed to set timeout value %u "
5024 "for port %d, errto code: %d.\n",
5025 bypass_timeout, port_id, rc);
5029 /* Set the bypass event to transition to bypass mode. */
5030 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5035 printf("\t Failed to set bypass event for port = %d.\n",
5039 cmdline_parse_token_string_t cmd_setbypass_event_set =
5040 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5042 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5043 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5045 cmdline_parse_token_string_t cmd_setbypass_event_event =
5046 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5048 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5049 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5050 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5051 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5052 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5054 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5055 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5056 mode_value, "normal#bypass#isolate");
5057 cmdline_parse_token_num_t cmd_setbypass_event_port =
5058 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5061 cmdline_parse_inst_t cmd_set_bypass_event = {
5062 .f = cmd_set_bypass_event_parsed,
5063 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5064 "power_off mode normal|bypass|isolate <port_id>: "
5065 "Set the NIC bypass event mode for port_id",
5068 (void *)&cmd_setbypass_event_set,
5069 (void *)&cmd_setbypass_event_bypass,
5070 (void *)&cmd_setbypass_event_event,
5071 (void *)&cmd_setbypass_event_event_value,
5072 (void *)&cmd_setbypass_event_mode,
5073 (void *)&cmd_setbypass_event_mode_value,
5074 (void *)&cmd_setbypass_event_port,
5080 /* *** SET NIC BYPASS TIMEOUT *** */
5081 struct cmd_set_bypass_timeout_result {
5082 cmdline_fixed_string_t set;
5083 cmdline_fixed_string_t bypass;
5084 cmdline_fixed_string_t timeout;
5085 cmdline_fixed_string_t value;
5089 cmd_set_bypass_timeout_parsed(void *parsed_result,
5090 __attribute__((unused)) struct cmdline *cl,
5091 __attribute__((unused)) void *data)
5093 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5095 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5096 if (!strcmp(res->value, "1.5"))
5097 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5098 else if (!strcmp(res->value, "2"))
5099 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5100 else if (!strcmp(res->value, "3"))
5101 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5102 else if (!strcmp(res->value, "4"))
5103 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5104 else if (!strcmp(res->value, "8"))
5105 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5106 else if (!strcmp(res->value, "16"))
5107 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5108 else if (!strcmp(res->value, "32"))
5109 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5111 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5115 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5116 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5118 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5119 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5121 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5123 timeout, "timeout");
5124 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5125 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5126 value, "0#1.5#2#3#4#8#16#32");
5128 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5129 .f = cmd_set_bypass_timeout_parsed,
5130 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5131 "Set the NIC bypass watchdog timeout in seconds",
5134 (void *)&cmd_setbypass_timeout_set,
5135 (void *)&cmd_setbypass_timeout_bypass,
5136 (void *)&cmd_setbypass_timeout_timeout,
5137 (void *)&cmd_setbypass_timeout_value,
5142 /* *** SHOW NIC BYPASS MODE *** */
5143 struct cmd_show_bypass_config_result {
5144 cmdline_fixed_string_t show;
5145 cmdline_fixed_string_t bypass;
5146 cmdline_fixed_string_t config;
5151 cmd_show_bypass_config_parsed(void *parsed_result,
5152 __attribute__((unused)) struct cmdline *cl,
5153 __attribute__((unused)) void *data)
5155 struct cmd_show_bypass_config_result *res = parsed_result;
5156 portid_t port_id = res->port_id;
5158 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5159 uint32_t event_mode;
5160 uint32_t bypass_mode;
5161 uint32_t timeout = bypass_timeout;
5164 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5165 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5166 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5167 {"UNKNOWN", "normal", "bypass", "isolate"};
5168 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5175 int num_events = (sizeof events) / (sizeof events[0]);
5177 /* Display the bypass mode.*/
5178 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5179 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5183 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5184 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5186 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5189 /* Display the bypass timeout.*/
5190 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5191 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5193 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5195 /* Display the bypass events and associated modes. */
5196 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5198 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5199 printf("\tFailed to get bypass mode for event = %s\n",
5202 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5203 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5205 printf("\tbypass event: %-16s = %s\n", events[i],
5211 printf("\tFailed to get bypass configuration for port = %d\n",
5215 cmdline_parse_token_string_t cmd_showbypass_config_show =
5216 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5218 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5219 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5221 cmdline_parse_token_string_t cmd_showbypass_config_config =
5222 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5224 cmdline_parse_token_num_t cmd_showbypass_config_port =
5225 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5228 cmdline_parse_inst_t cmd_show_bypass_config = {
5229 .f = cmd_show_bypass_config_parsed,
5230 .help_str = "show bypass config <port_id>: "
5231 "Show the NIC bypass config for port_id",
5234 (void *)&cmd_showbypass_config_show,
5235 (void *)&cmd_showbypass_config_bypass,
5236 (void *)&cmd_showbypass_config_config,
5237 (void *)&cmd_showbypass_config_port,
5242 #ifdef RTE_LIBRTE_PMD_BOND
5243 /* *** SET BONDING MODE *** */
5244 struct cmd_set_bonding_mode_result {
5245 cmdline_fixed_string_t set;
5246 cmdline_fixed_string_t bonding;
5247 cmdline_fixed_string_t mode;
5252 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5253 __attribute__((unused)) struct cmdline *cl,
5254 __attribute__((unused)) void *data)
5256 struct cmd_set_bonding_mode_result *res = parsed_result;
5257 portid_t port_id = res->port_id;
5259 /* Set the bonding mode for the relevant port. */
5260 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5261 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5264 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5265 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5267 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5268 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5269 bonding, "bonding");
5270 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5271 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5273 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5274 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5276 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5277 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5280 cmdline_parse_inst_t cmd_set_bonding_mode = {
5281 .f = cmd_set_bonding_mode_parsed,
5282 .help_str = "set bonding mode <mode_value> <port_id>: "
5283 "Set the bonding mode for port_id",
5286 (void *) &cmd_setbonding_mode_set,
5287 (void *) &cmd_setbonding_mode_bonding,
5288 (void *) &cmd_setbonding_mode_mode,
5289 (void *) &cmd_setbonding_mode_value,
5290 (void *) &cmd_setbonding_mode_port,
5295 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5296 struct cmd_set_bonding_lacp_dedicated_queues_result {
5297 cmdline_fixed_string_t set;
5298 cmdline_fixed_string_t bonding;
5299 cmdline_fixed_string_t lacp;
5300 cmdline_fixed_string_t dedicated_queues;
5302 cmdline_fixed_string_t mode;
5305 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5306 __attribute__((unused)) struct cmdline *cl,
5307 __attribute__((unused)) void *data)
5309 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5310 portid_t port_id = res->port_id;
5311 struct rte_port *port;
5313 port = &ports[port_id];
5315 /** Check if the port is not started **/
5316 if (port->port_status != RTE_PORT_STOPPED) {
5317 printf("Please stop port %d first\n", port_id);
5321 if (!strcmp(res->mode, "enable")) {
5322 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5323 printf("Dedicate queues for LACP control packets"
5326 printf("Enabling dedicate queues for LACP control "
5327 "packets on port %d failed\n", port_id);
5328 } else if (!strcmp(res->mode, "disable")) {
5329 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5330 printf("Dedicated queues for LACP control packets "
5333 printf("Disabling dedicated queues for LACP control "
5334 "traffic on port %d failed\n", port_id);
5338 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5339 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5341 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5342 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5343 bonding, "bonding");
5344 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5345 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5347 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5348 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5349 dedicated_queues, "dedicated_queues");
5350 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5351 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5353 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5354 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5355 mode, "enable#disable");
5357 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5358 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5359 .help_str = "set bonding lacp dedicated_queues <port_id> "
5361 "Enable/disable dedicated queues for LACP control traffic for port_id",
5364 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5365 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5366 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5367 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5368 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5369 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5374 /* *** SET BALANCE XMIT POLICY *** */
5375 struct cmd_set_bonding_balance_xmit_policy_result {
5376 cmdline_fixed_string_t set;
5377 cmdline_fixed_string_t bonding;
5378 cmdline_fixed_string_t balance_xmit_policy;
5380 cmdline_fixed_string_t policy;
5383 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5384 __attribute__((unused)) struct cmdline *cl,
5385 __attribute__((unused)) void *data)
5387 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5388 portid_t port_id = res->port_id;
5391 if (!strcmp(res->policy, "l2")) {
5392 policy = BALANCE_XMIT_POLICY_LAYER2;
5393 } else if (!strcmp(res->policy, "l23")) {
5394 policy = BALANCE_XMIT_POLICY_LAYER23;
5395 } else if (!strcmp(res->policy, "l34")) {
5396 policy = BALANCE_XMIT_POLICY_LAYER34;
5398 printf("\t Invalid xmit policy selection");
5402 /* Set the bonding mode for the relevant port. */
5403 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5404 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5409 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5410 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5412 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5413 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5414 bonding, "bonding");
5415 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5416 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5417 balance_xmit_policy, "balance_xmit_policy");
5418 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5419 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5421 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5422 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5423 policy, "l2#l23#l34");
5425 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5426 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5427 .help_str = "set bonding balance_xmit_policy <port_id> "
5429 "Set the bonding balance_xmit_policy for port_id",
5432 (void *)&cmd_setbonding_balance_xmit_policy_set,
5433 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5434 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5435 (void *)&cmd_setbonding_balance_xmit_policy_port,
5436 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5441 /* *** SHOW NIC BONDING CONFIGURATION *** */
5442 struct cmd_show_bonding_config_result {
5443 cmdline_fixed_string_t show;
5444 cmdline_fixed_string_t bonding;
5445 cmdline_fixed_string_t config;
5449 static void cmd_show_bonding_config_parsed(void *parsed_result,
5450 __attribute__((unused)) struct cmdline *cl,
5451 __attribute__((unused)) void *data)
5453 struct cmd_show_bonding_config_result *res = parsed_result;
5454 int bonding_mode, agg_mode;
5455 portid_t slaves[RTE_MAX_ETHPORTS];
5456 int num_slaves, num_active_slaves;
5459 portid_t port_id = res->port_id;
5461 /* Display the bonding mode.*/
5462 bonding_mode = rte_eth_bond_mode_get(port_id);
5463 if (bonding_mode < 0) {
5464 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5467 printf("\tBonding mode: %d\n", bonding_mode);
5469 if (bonding_mode == BONDING_MODE_BALANCE) {
5470 int balance_xmit_policy;
5472 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5473 if (balance_xmit_policy < 0) {
5474 printf("\tFailed to get balance xmit policy for port = %d\n",
5478 printf("\tBalance Xmit Policy: ");
5480 switch (balance_xmit_policy) {
5481 case BALANCE_XMIT_POLICY_LAYER2:
5482 printf("BALANCE_XMIT_POLICY_LAYER2");
5484 case BALANCE_XMIT_POLICY_LAYER23:
5485 printf("BALANCE_XMIT_POLICY_LAYER23");
5487 case BALANCE_XMIT_POLICY_LAYER34:
5488 printf("BALANCE_XMIT_POLICY_LAYER34");
5495 if (bonding_mode == BONDING_MODE_8023AD) {
5496 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5497 printf("\tIEEE802.3AD Aggregator Mode: ");
5500 printf("bandwidth");
5512 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5514 if (num_slaves < 0) {
5515 printf("\tFailed to get slave list for port = %d\n", port_id);
5518 if (num_slaves > 0) {
5519 printf("\tSlaves (%d): [", num_slaves);
5520 for (i = 0; i < num_slaves - 1; i++)
5521 printf("%d ", slaves[i]);
5523 printf("%d]\n", slaves[num_slaves - 1]);
5525 printf("\tSlaves: []\n");
5529 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5532 if (num_active_slaves < 0) {
5533 printf("\tFailed to get active slave list for port = %d\n", port_id);
5536 if (num_active_slaves > 0) {
5537 printf("\tActive Slaves (%d): [", num_active_slaves);
5538 for (i = 0; i < num_active_slaves - 1; i++)
5539 printf("%d ", slaves[i]);
5541 printf("%d]\n", slaves[num_active_slaves - 1]);
5544 printf("\tActive Slaves: []\n");
5548 primary_id = rte_eth_bond_primary_get(port_id);
5549 if (primary_id < 0) {
5550 printf("\tFailed to get primary slave for port = %d\n", port_id);
5553 printf("\tPrimary: [%d]\n", primary_id);
5557 cmdline_parse_token_string_t cmd_showbonding_config_show =
5558 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5560 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5561 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5562 bonding, "bonding");
5563 cmdline_parse_token_string_t cmd_showbonding_config_config =
5564 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5566 cmdline_parse_token_num_t cmd_showbonding_config_port =
5567 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5570 cmdline_parse_inst_t cmd_show_bonding_config = {
5571 .f = cmd_show_bonding_config_parsed,
5572 .help_str = "show bonding config <port_id>: "
5573 "Show the bonding config for port_id",
5576 (void *)&cmd_showbonding_config_show,
5577 (void *)&cmd_showbonding_config_bonding,
5578 (void *)&cmd_showbonding_config_config,
5579 (void *)&cmd_showbonding_config_port,
5584 /* *** SET BONDING PRIMARY *** */
5585 struct cmd_set_bonding_primary_result {
5586 cmdline_fixed_string_t set;
5587 cmdline_fixed_string_t bonding;
5588 cmdline_fixed_string_t primary;
5593 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5594 __attribute__((unused)) struct cmdline *cl,
5595 __attribute__((unused)) void *data)
5597 struct cmd_set_bonding_primary_result *res = parsed_result;
5598 portid_t master_port_id = res->port_id;
5599 portid_t slave_port_id = res->slave_id;
5601 /* Set the primary slave for a bonded device. */
5602 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5603 printf("\t Failed to set primary slave for port = %d.\n",
5610 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5613 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5615 bonding, "bonding");
5616 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5617 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5618 primary, "primary");
5619 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5620 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5622 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5623 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5626 cmdline_parse_inst_t cmd_set_bonding_primary = {
5627 .f = cmd_set_bonding_primary_parsed,
5628 .help_str = "set bonding primary <slave_id> <port_id>: "
5629 "Set the primary slave for port_id",
5632 (void *)&cmd_setbonding_primary_set,
5633 (void *)&cmd_setbonding_primary_bonding,
5634 (void *)&cmd_setbonding_primary_primary,
5635 (void *)&cmd_setbonding_primary_slave,
5636 (void *)&cmd_setbonding_primary_port,
5641 /* *** ADD SLAVE *** */
5642 struct cmd_add_bonding_slave_result {
5643 cmdline_fixed_string_t add;
5644 cmdline_fixed_string_t bonding;
5645 cmdline_fixed_string_t slave;
5650 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5651 __attribute__((unused)) struct cmdline *cl,
5652 __attribute__((unused)) void *data)
5654 struct cmd_add_bonding_slave_result *res = parsed_result;
5655 portid_t master_port_id = res->port_id;
5656 portid_t slave_port_id = res->slave_id;
5658 /* add the slave for a bonded device. */
5659 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5660 printf("\t Failed to add slave %d to master port = %d.\n",
5661 slave_port_id, master_port_id);
5665 set_port_slave_flag(slave_port_id);
5668 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5669 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5671 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5672 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5673 bonding, "bonding");
5674 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5675 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5677 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5678 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5680 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5681 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5684 cmdline_parse_inst_t cmd_add_bonding_slave = {
5685 .f = cmd_add_bonding_slave_parsed,
5686 .help_str = "add bonding slave <slave_id> <port_id>: "
5687 "Add a slave device to a bonded device",
5690 (void *)&cmd_addbonding_slave_add,
5691 (void *)&cmd_addbonding_slave_bonding,
5692 (void *)&cmd_addbonding_slave_slave,
5693 (void *)&cmd_addbonding_slave_slaveid,
5694 (void *)&cmd_addbonding_slave_port,
5699 /* *** REMOVE SLAVE *** */
5700 struct cmd_remove_bonding_slave_result {
5701 cmdline_fixed_string_t remove;
5702 cmdline_fixed_string_t bonding;
5703 cmdline_fixed_string_t slave;
5708 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5709 __attribute__((unused)) struct cmdline *cl,
5710 __attribute__((unused)) void *data)
5712 struct cmd_remove_bonding_slave_result *res = parsed_result;
5713 portid_t master_port_id = res->port_id;
5714 portid_t slave_port_id = res->slave_id;
5716 /* remove the slave from a bonded device. */
5717 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5718 printf("\t Failed to remove slave %d from master port = %d.\n",
5719 slave_port_id, master_port_id);
5723 clear_port_slave_flag(slave_port_id);
5726 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5727 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5729 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5730 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5731 bonding, "bonding");
5732 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5733 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5735 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5736 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5738 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5739 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5742 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5743 .f = cmd_remove_bonding_slave_parsed,
5744 .help_str = "remove bonding slave <slave_id> <port_id>: "
5745 "Remove a slave device from a bonded device",
5748 (void *)&cmd_removebonding_slave_remove,
5749 (void *)&cmd_removebonding_slave_bonding,
5750 (void *)&cmd_removebonding_slave_slave,
5751 (void *)&cmd_removebonding_slave_slaveid,
5752 (void *)&cmd_removebonding_slave_port,
5757 /* *** CREATE BONDED DEVICE *** */
5758 struct cmd_create_bonded_device_result {
5759 cmdline_fixed_string_t create;
5760 cmdline_fixed_string_t bonded;
5761 cmdline_fixed_string_t device;
5766 static int bond_dev_num = 0;
5768 static void cmd_create_bonded_device_parsed(void *parsed_result,
5769 __attribute__((unused)) struct cmdline *cl,
5770 __attribute__((unused)) void *data)
5772 struct cmd_create_bonded_device_result *res = parsed_result;
5773 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5776 if (test_done == 0) {
5777 printf("Please stop forwarding first\n");
5781 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5784 /* Create a new bonded device. */
5785 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5787 printf("\t Failed to create bonded device.\n");
5790 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5793 /* Update number of ports */
5794 nb_ports = rte_eth_dev_count_avail();
5795 reconfig(port_id, res->socket);
5796 rte_eth_promiscuous_enable(port_id);
5801 cmdline_parse_token_string_t cmd_createbonded_device_create =
5802 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5804 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5805 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5807 cmdline_parse_token_string_t cmd_createbonded_device_device =
5808 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5810 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5811 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5813 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5814 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5817 cmdline_parse_inst_t cmd_create_bonded_device = {
5818 .f = cmd_create_bonded_device_parsed,
5819 .help_str = "create bonded device <mode> <socket>: "
5820 "Create a new bonded device with specific bonding mode and socket",
5823 (void *)&cmd_createbonded_device_create,
5824 (void *)&cmd_createbonded_device_bonded,
5825 (void *)&cmd_createbonded_device_device,
5826 (void *)&cmd_createbonded_device_mode,
5827 (void *)&cmd_createbonded_device_socket,
5832 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5833 struct cmd_set_bond_mac_addr_result {
5834 cmdline_fixed_string_t set;
5835 cmdline_fixed_string_t bonding;
5836 cmdline_fixed_string_t mac_addr;
5838 struct ether_addr address;
5841 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5842 __attribute__((unused)) struct cmdline *cl,
5843 __attribute__((unused)) void *data)
5845 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5848 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5851 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5853 /* check the return value and print it if is < 0 */
5855 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5858 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5859 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5860 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5861 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5863 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5864 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5866 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5867 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5869 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5870 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5872 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5873 .f = cmd_set_bond_mac_addr_parsed,
5875 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5877 (void *)&cmd_set_bond_mac_addr_set,
5878 (void *)&cmd_set_bond_mac_addr_bonding,
5879 (void *)&cmd_set_bond_mac_addr_mac,
5880 (void *)&cmd_set_bond_mac_addr_portnum,
5881 (void *)&cmd_set_bond_mac_addr_addr,
5887 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5888 struct cmd_set_bond_mon_period_result {
5889 cmdline_fixed_string_t set;
5890 cmdline_fixed_string_t bonding;
5891 cmdline_fixed_string_t mon_period;
5896 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5897 __attribute__((unused)) struct cmdline *cl,
5898 __attribute__((unused)) void *data)
5900 struct cmd_set_bond_mon_period_result *res = parsed_result;
5903 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5905 /* check the return value and print it if is < 0 */
5907 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5910 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5911 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5913 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5915 bonding, "bonding");
5916 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5917 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5918 mon_period, "mon_period");
5919 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5920 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5922 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5923 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5926 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5927 .f = cmd_set_bond_mon_period_parsed,
5929 .help_str = "set bonding mon_period <port_id> <period_ms>",
5931 (void *)&cmd_set_bond_mon_period_set,
5932 (void *)&cmd_set_bond_mon_period_bonding,
5933 (void *)&cmd_set_bond_mon_period_mon_period,
5934 (void *)&cmd_set_bond_mon_period_portnum,
5935 (void *)&cmd_set_bond_mon_period_period_ms,
5942 struct cmd_set_bonding_agg_mode_policy_result {
5943 cmdline_fixed_string_t set;
5944 cmdline_fixed_string_t bonding;
5945 cmdline_fixed_string_t agg_mode;
5947 cmdline_fixed_string_t policy;
5952 cmd_set_bonding_agg_mode(void *parsed_result,
5953 __attribute__((unused)) struct cmdline *cl,
5954 __attribute__((unused)) void *data)
5956 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5957 uint8_t policy = AGG_BANDWIDTH;
5959 if (!strcmp(res->policy, "bandwidth"))
5960 policy = AGG_BANDWIDTH;
5961 else if (!strcmp(res->policy, "stable"))
5962 policy = AGG_STABLE;
5963 else if (!strcmp(res->policy, "count"))
5966 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5970 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5971 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5973 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5974 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5975 bonding, "bonding");
5977 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5978 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5979 agg_mode, "agg_mode");
5981 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5982 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5985 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5986 TOKEN_STRING_INITIALIZER(
5987 struct cmd_set_bonding_balance_xmit_policy_result,
5988 policy, "stable#bandwidth#count");
5990 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5991 .f = cmd_set_bonding_agg_mode,
5993 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5995 (void *)&cmd_set_bonding_agg_mode_set,
5996 (void *)&cmd_set_bonding_agg_mode_bonding,
5997 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5998 (void *)&cmd_set_bonding_agg_mode_portnum,
5999 (void *)&cmd_set_bonding_agg_mode_policy_string,
6005 #endif /* RTE_LIBRTE_PMD_BOND */
6007 /* *** SET FORWARDING MODE *** */
6008 struct cmd_set_fwd_mode_result {
6009 cmdline_fixed_string_t set;
6010 cmdline_fixed_string_t fwd;
6011 cmdline_fixed_string_t mode;
6014 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6015 __attribute__((unused)) struct cmdline *cl,
6016 __attribute__((unused)) void *data)
6018 struct cmd_set_fwd_mode_result *res = parsed_result;
6021 set_pkt_forwarding_mode(res->mode);
6024 cmdline_parse_token_string_t cmd_setfwd_set =
6025 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6026 cmdline_parse_token_string_t cmd_setfwd_fwd =
6027 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6028 cmdline_parse_token_string_t cmd_setfwd_mode =
6029 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6030 "" /* defined at init */);
6032 cmdline_parse_inst_t cmd_set_fwd_mode = {
6033 .f = cmd_set_fwd_mode_parsed,
6035 .help_str = NULL, /* defined at init */
6037 (void *)&cmd_setfwd_set,
6038 (void *)&cmd_setfwd_fwd,
6039 (void *)&cmd_setfwd_mode,
6044 static void cmd_set_fwd_mode_init(void)
6047 static char token[128];
6048 static char help[256];
6049 cmdline_parse_token_string_t *token_struct;
6051 modes = list_pkt_forwarding_modes();
6052 snprintf(help, sizeof(help), "set fwd %s: "
6053 "Set packet forwarding mode", modes);
6054 cmd_set_fwd_mode.help_str = help;
6056 /* string token separator is # */
6057 for (c = token; *modes != '\0'; modes++)
6062 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6063 token_struct->string_data.str = token;
6066 /* *** SET RETRY FORWARDING MODE *** */
6067 struct cmd_set_fwd_retry_mode_result {
6068 cmdline_fixed_string_t set;
6069 cmdline_fixed_string_t fwd;
6070 cmdline_fixed_string_t mode;
6071 cmdline_fixed_string_t retry;
6074 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6075 __attribute__((unused)) struct cmdline *cl,
6076 __attribute__((unused)) void *data)
6078 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6081 set_pkt_forwarding_mode(res->mode);
6084 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6085 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6087 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6088 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6090 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6091 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6093 "" /* defined at init */);
6094 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6095 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6098 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6099 .f = cmd_set_fwd_retry_mode_parsed,
6101 .help_str = NULL, /* defined at init */
6103 (void *)&cmd_setfwd_retry_set,
6104 (void *)&cmd_setfwd_retry_fwd,
6105 (void *)&cmd_setfwd_retry_mode,
6106 (void *)&cmd_setfwd_retry_retry,
6111 static void cmd_set_fwd_retry_mode_init(void)
6114 static char token[128];
6115 static char help[256];
6116 cmdline_parse_token_string_t *token_struct;
6118 modes = list_pkt_forwarding_retry_modes();
6119 snprintf(help, sizeof(help), "set fwd %s retry: "
6120 "Set packet forwarding mode with retry", modes);
6121 cmd_set_fwd_retry_mode.help_str = help;
6123 /* string token separator is # */
6124 for (c = token; *modes != '\0'; modes++)
6129 token_struct = (cmdline_parse_token_string_t *)
6130 cmd_set_fwd_retry_mode.tokens[2];
6131 token_struct->string_data.str = token;
6134 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6135 struct cmd_set_burst_tx_retry_result {
6136 cmdline_fixed_string_t set;
6137 cmdline_fixed_string_t burst;
6138 cmdline_fixed_string_t tx;
6139 cmdline_fixed_string_t delay;
6141 cmdline_fixed_string_t retry;
6145 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6146 __attribute__((unused)) struct cmdline *cl,
6147 __attribute__((unused)) void *data)
6149 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6151 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6152 && !strcmp(res->tx, "tx")) {
6153 if (!strcmp(res->delay, "delay"))
6154 burst_tx_delay_time = res->time;
6155 if (!strcmp(res->retry, "retry"))
6156 burst_tx_retry_num = res->retry_num;
6161 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6162 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6163 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6164 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6166 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6167 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6168 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6169 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6170 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6171 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6172 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6173 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6174 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6175 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6177 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6178 .f = cmd_set_burst_tx_retry_parsed,
6179 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6181 (void *)&cmd_set_burst_tx_retry_set,
6182 (void *)&cmd_set_burst_tx_retry_burst,
6183 (void *)&cmd_set_burst_tx_retry_tx,
6184 (void *)&cmd_set_burst_tx_retry_delay,
6185 (void *)&cmd_set_burst_tx_retry_time,
6186 (void *)&cmd_set_burst_tx_retry_retry,
6187 (void *)&cmd_set_burst_tx_retry_retry_num,
6192 /* *** SET PROMISC MODE *** */
6193 struct cmd_set_promisc_mode_result {
6194 cmdline_fixed_string_t set;
6195 cmdline_fixed_string_t promisc;
6196 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6197 uint16_t port_num; /* valid if "allports" argument == 0 */
6198 cmdline_fixed_string_t mode;
6201 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6202 __attribute__((unused)) struct cmdline *cl,
6205 struct cmd_set_promisc_mode_result *res = parsed_result;
6209 if (!strcmp(res->mode, "on"))
6216 RTE_ETH_FOREACH_DEV(i) {
6218 rte_eth_promiscuous_enable(i);
6220 rte_eth_promiscuous_disable(i);
6225 rte_eth_promiscuous_enable(res->port_num);
6227 rte_eth_promiscuous_disable(res->port_num);
6231 cmdline_parse_token_string_t cmd_setpromisc_set =
6232 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6233 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6234 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6236 cmdline_parse_token_string_t cmd_setpromisc_portall =
6237 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6239 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6240 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6242 cmdline_parse_token_string_t cmd_setpromisc_mode =
6243 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6246 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6247 .f = cmd_set_promisc_mode_parsed,
6249 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6251 (void *)&cmd_setpromisc_set,
6252 (void *)&cmd_setpromisc_promisc,
6253 (void *)&cmd_setpromisc_portall,
6254 (void *)&cmd_setpromisc_mode,
6259 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6260 .f = cmd_set_promisc_mode_parsed,
6262 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6264 (void *)&cmd_setpromisc_set,
6265 (void *)&cmd_setpromisc_promisc,
6266 (void *)&cmd_setpromisc_portnum,
6267 (void *)&cmd_setpromisc_mode,
6272 /* *** SET ALLMULTI MODE *** */
6273 struct cmd_set_allmulti_mode_result {
6274 cmdline_fixed_string_t set;
6275 cmdline_fixed_string_t allmulti;
6276 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6277 uint16_t port_num; /* valid if "allports" argument == 0 */
6278 cmdline_fixed_string_t mode;
6281 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6282 __attribute__((unused)) struct cmdline *cl,
6285 struct cmd_set_allmulti_mode_result *res = parsed_result;
6289 if (!strcmp(res->mode, "on"))
6296 RTE_ETH_FOREACH_DEV(i) {
6298 rte_eth_allmulticast_enable(i);
6300 rte_eth_allmulticast_disable(i);
6305 rte_eth_allmulticast_enable(res->port_num);
6307 rte_eth_allmulticast_disable(res->port_num);
6311 cmdline_parse_token_string_t cmd_setallmulti_set =
6312 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6313 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6314 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6316 cmdline_parse_token_string_t cmd_setallmulti_portall =
6317 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6319 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6320 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6322 cmdline_parse_token_string_t cmd_setallmulti_mode =
6323 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6326 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6327 .f = cmd_set_allmulti_mode_parsed,
6329 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6331 (void *)&cmd_setallmulti_set,
6332 (void *)&cmd_setallmulti_allmulti,
6333 (void *)&cmd_setallmulti_portall,
6334 (void *)&cmd_setallmulti_mode,
6339 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6340 .f = cmd_set_allmulti_mode_parsed,
6342 .help_str = "set allmulti <port_id> on|off: "
6343 "Set allmulti mode on port_id",
6345 (void *)&cmd_setallmulti_set,
6346 (void *)&cmd_setallmulti_allmulti,
6347 (void *)&cmd_setallmulti_portnum,
6348 (void *)&cmd_setallmulti_mode,
6353 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6354 struct cmd_link_flow_ctrl_set_result {
6355 cmdline_fixed_string_t set;
6356 cmdline_fixed_string_t flow_ctrl;
6357 cmdline_fixed_string_t rx;
6358 cmdline_fixed_string_t rx_lfc_mode;
6359 cmdline_fixed_string_t tx;
6360 cmdline_fixed_string_t tx_lfc_mode;
6361 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6362 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6363 cmdline_fixed_string_t autoneg_str;
6364 cmdline_fixed_string_t autoneg;
6365 cmdline_fixed_string_t hw_str;
6366 uint32_t high_water;
6367 cmdline_fixed_string_t lw_str;
6369 cmdline_fixed_string_t pt_str;
6370 uint16_t pause_time;
6371 cmdline_fixed_string_t xon_str;
6376 cmdline_parse_token_string_t cmd_lfc_set_set =
6377 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6379 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6380 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6381 flow_ctrl, "flow_ctrl");
6382 cmdline_parse_token_string_t cmd_lfc_set_rx =
6383 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6385 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6386 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6387 rx_lfc_mode, "on#off");
6388 cmdline_parse_token_string_t cmd_lfc_set_tx =
6389 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6391 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6392 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6393 tx_lfc_mode, "on#off");
6394 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6395 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6396 hw_str, "high_water");
6397 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6398 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6399 high_water, UINT32);
6400 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6401 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6402 lw_str, "low_water");
6403 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6404 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6406 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6407 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6408 pt_str, "pause_time");
6409 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6410 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6411 pause_time, UINT16);
6412 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6413 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6414 xon_str, "send_xon");
6415 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6416 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6418 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6419 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6420 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6421 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6423 mac_ctrl_frame_fwd_mode, "on#off");
6424 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6426 autoneg_str, "autoneg");
6427 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6430 cmdline_parse_token_num_t cmd_lfc_set_portid =
6431 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6434 /* forward declaration */
6436 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6439 cmdline_parse_inst_t cmd_link_flow_control_set = {
6440 .f = cmd_link_flow_ctrl_set_parsed,
6442 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6443 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6444 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6446 (void *)&cmd_lfc_set_set,
6447 (void *)&cmd_lfc_set_flow_ctrl,
6448 (void *)&cmd_lfc_set_rx,
6449 (void *)&cmd_lfc_set_rx_mode,
6450 (void *)&cmd_lfc_set_tx,
6451 (void *)&cmd_lfc_set_tx_mode,
6452 (void *)&cmd_lfc_set_high_water,
6453 (void *)&cmd_lfc_set_low_water,
6454 (void *)&cmd_lfc_set_pause_time,
6455 (void *)&cmd_lfc_set_send_xon,
6456 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6457 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6458 (void *)&cmd_lfc_set_autoneg_str,
6459 (void *)&cmd_lfc_set_autoneg,
6460 (void *)&cmd_lfc_set_portid,
6465 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6466 .f = cmd_link_flow_ctrl_set_parsed,
6467 .data = (void *)&cmd_link_flow_control_set_rx,
6468 .help_str = "set flow_ctrl rx on|off <port_id>: "
6469 "Change rx flow control parameter",
6471 (void *)&cmd_lfc_set_set,
6472 (void *)&cmd_lfc_set_flow_ctrl,
6473 (void *)&cmd_lfc_set_rx,
6474 (void *)&cmd_lfc_set_rx_mode,
6475 (void *)&cmd_lfc_set_portid,
6480 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6481 .f = cmd_link_flow_ctrl_set_parsed,
6482 .data = (void *)&cmd_link_flow_control_set_tx,
6483 .help_str = "set flow_ctrl tx on|off <port_id>: "
6484 "Change tx flow control parameter",
6486 (void *)&cmd_lfc_set_set,
6487 (void *)&cmd_lfc_set_flow_ctrl,
6488 (void *)&cmd_lfc_set_tx,
6489 (void *)&cmd_lfc_set_tx_mode,
6490 (void *)&cmd_lfc_set_portid,
6495 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6496 .f = cmd_link_flow_ctrl_set_parsed,
6497 .data = (void *)&cmd_link_flow_control_set_hw,
6498 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6499 "Change high water flow control parameter",
6501 (void *)&cmd_lfc_set_set,
6502 (void *)&cmd_lfc_set_flow_ctrl,
6503 (void *)&cmd_lfc_set_high_water_str,
6504 (void *)&cmd_lfc_set_high_water,
6505 (void *)&cmd_lfc_set_portid,
6510 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6511 .f = cmd_link_flow_ctrl_set_parsed,
6512 .data = (void *)&cmd_link_flow_control_set_lw,
6513 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6514 "Change low water flow control parameter",
6516 (void *)&cmd_lfc_set_set,
6517 (void *)&cmd_lfc_set_flow_ctrl,
6518 (void *)&cmd_lfc_set_low_water_str,
6519 (void *)&cmd_lfc_set_low_water,
6520 (void *)&cmd_lfc_set_portid,
6525 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6526 .f = cmd_link_flow_ctrl_set_parsed,
6527 .data = (void *)&cmd_link_flow_control_set_pt,
6528 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6529 "Change pause time flow control parameter",
6531 (void *)&cmd_lfc_set_set,
6532 (void *)&cmd_lfc_set_flow_ctrl,
6533 (void *)&cmd_lfc_set_pause_time_str,
6534 (void *)&cmd_lfc_set_pause_time,
6535 (void *)&cmd_lfc_set_portid,
6540 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6541 .f = cmd_link_flow_ctrl_set_parsed,
6542 .data = (void *)&cmd_link_flow_control_set_xon,
6543 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6544 "Change send_xon flow control parameter",
6546 (void *)&cmd_lfc_set_set,
6547 (void *)&cmd_lfc_set_flow_ctrl,
6548 (void *)&cmd_lfc_set_send_xon_str,
6549 (void *)&cmd_lfc_set_send_xon,
6550 (void *)&cmd_lfc_set_portid,
6555 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6556 .f = cmd_link_flow_ctrl_set_parsed,
6557 .data = (void *)&cmd_link_flow_control_set_macfwd,
6558 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6559 "Change mac ctrl fwd flow control parameter",
6561 (void *)&cmd_lfc_set_set,
6562 (void *)&cmd_lfc_set_flow_ctrl,
6563 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6564 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6565 (void *)&cmd_lfc_set_portid,
6570 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6571 .f = cmd_link_flow_ctrl_set_parsed,
6572 .data = (void *)&cmd_link_flow_control_set_autoneg,
6573 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6574 "Change autoneg flow control parameter",
6576 (void *)&cmd_lfc_set_set,
6577 (void *)&cmd_lfc_set_flow_ctrl,
6578 (void *)&cmd_lfc_set_autoneg_str,
6579 (void *)&cmd_lfc_set_autoneg,
6580 (void *)&cmd_lfc_set_portid,
6586 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6587 __attribute__((unused)) struct cmdline *cl,
6590 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6591 cmdline_parse_inst_t *cmd = data;
6592 struct rte_eth_fc_conf fc_conf;
6598 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6599 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6600 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6601 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6603 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6604 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6607 /* Partial command line, retrieve current configuration */
6609 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6611 printf("cannot get current flow ctrl parameters, return"
6612 "code = %d\n", ret);
6616 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6617 (fc_conf.mode == RTE_FC_FULL))
6619 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6620 (fc_conf.mode == RTE_FC_FULL))
6624 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6625 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6627 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6628 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6630 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6632 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6633 fc_conf.high_water = res->high_water;
6635 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6636 fc_conf.low_water = res->low_water;
6638 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6639 fc_conf.pause_time = res->pause_time;
6641 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6642 fc_conf.send_xon = res->send_xon;
6644 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6645 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6646 fc_conf.mac_ctrl_frame_fwd = 1;
6648 fc_conf.mac_ctrl_frame_fwd = 0;
6651 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6652 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6654 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6656 printf("bad flow contrl parameter, return code = %d \n", ret);
6659 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6660 struct cmd_priority_flow_ctrl_set_result {
6661 cmdline_fixed_string_t set;
6662 cmdline_fixed_string_t pfc_ctrl;
6663 cmdline_fixed_string_t rx;
6664 cmdline_fixed_string_t rx_pfc_mode;
6665 cmdline_fixed_string_t tx;
6666 cmdline_fixed_string_t tx_pfc_mode;
6667 uint32_t high_water;
6669 uint16_t pause_time;
6675 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6676 __attribute__((unused)) struct cmdline *cl,
6677 __attribute__((unused)) void *data)
6679 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6680 struct rte_eth_pfc_conf pfc_conf;
6681 int rx_fc_enable, tx_fc_enable;
6685 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6686 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6687 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6688 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6690 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6691 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6694 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6695 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6696 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6697 pfc_conf.fc.high_water = res->high_water;
6698 pfc_conf.fc.low_water = res->low_water;
6699 pfc_conf.fc.pause_time = res->pause_time;
6700 pfc_conf.priority = res->priority;
6702 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6704 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6707 cmdline_parse_token_string_t cmd_pfc_set_set =
6708 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6710 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6711 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6712 pfc_ctrl, "pfc_ctrl");
6713 cmdline_parse_token_string_t cmd_pfc_set_rx =
6714 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6716 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6717 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6718 rx_pfc_mode, "on#off");
6719 cmdline_parse_token_string_t cmd_pfc_set_tx =
6720 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6722 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6723 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6724 tx_pfc_mode, "on#off");
6725 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6726 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6727 high_water, UINT32);
6728 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6729 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6731 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6732 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6733 pause_time, UINT16);
6734 cmdline_parse_token_num_t cmd_pfc_set_priority =
6735 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6737 cmdline_parse_token_num_t cmd_pfc_set_portid =
6738 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6741 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6742 .f = cmd_priority_flow_ctrl_set_parsed,
6744 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6745 "<pause_time> <priority> <port_id>: "
6746 "Configure the Ethernet priority flow control",
6748 (void *)&cmd_pfc_set_set,
6749 (void *)&cmd_pfc_set_flow_ctrl,
6750 (void *)&cmd_pfc_set_rx,
6751 (void *)&cmd_pfc_set_rx_mode,
6752 (void *)&cmd_pfc_set_tx,
6753 (void *)&cmd_pfc_set_tx_mode,
6754 (void *)&cmd_pfc_set_high_water,
6755 (void *)&cmd_pfc_set_low_water,
6756 (void *)&cmd_pfc_set_pause_time,
6757 (void *)&cmd_pfc_set_priority,
6758 (void *)&cmd_pfc_set_portid,
6763 /* *** RESET CONFIGURATION *** */
6764 struct cmd_reset_result {
6765 cmdline_fixed_string_t reset;
6766 cmdline_fixed_string_t def;
6769 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6771 __attribute__((unused)) void *data)
6773 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6774 set_def_fwd_config();
6777 cmdline_parse_token_string_t cmd_reset_set =
6778 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6779 cmdline_parse_token_string_t cmd_reset_def =
6780 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6783 cmdline_parse_inst_t cmd_reset = {
6784 .f = cmd_reset_parsed,
6786 .help_str = "set default: Reset default forwarding configuration",
6788 (void *)&cmd_reset_set,
6789 (void *)&cmd_reset_def,
6794 /* *** START FORWARDING *** */
6795 struct cmd_start_result {
6796 cmdline_fixed_string_t start;
6799 cmdline_parse_token_string_t cmd_start_start =
6800 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6802 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6803 __attribute__((unused)) struct cmdline *cl,
6804 __attribute__((unused)) void *data)
6806 start_packet_forwarding(0);
6809 cmdline_parse_inst_t cmd_start = {
6810 .f = cmd_start_parsed,
6812 .help_str = "start: Start packet forwarding",
6814 (void *)&cmd_start_start,
6819 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6820 struct cmd_start_tx_first_result {
6821 cmdline_fixed_string_t start;
6822 cmdline_fixed_string_t tx_first;
6826 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6827 __attribute__((unused)) struct cmdline *cl,
6828 __attribute__((unused)) void *data)
6830 start_packet_forwarding(1);
6833 cmdline_parse_token_string_t cmd_start_tx_first_start =
6834 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6836 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6837 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6838 tx_first, "tx_first");
6840 cmdline_parse_inst_t cmd_start_tx_first = {
6841 .f = cmd_start_tx_first_parsed,
6843 .help_str = "start tx_first: Start packet forwarding, "
6844 "after sending 1 burst of packets",
6846 (void *)&cmd_start_tx_first_start,
6847 (void *)&cmd_start_tx_first_tx_first,
6852 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6853 struct cmd_start_tx_first_n_result {
6854 cmdline_fixed_string_t start;
6855 cmdline_fixed_string_t tx_first;
6860 cmd_start_tx_first_n_parsed(void *parsed_result,
6861 __attribute__((unused)) struct cmdline *cl,
6862 __attribute__((unused)) void *data)
6864 struct cmd_start_tx_first_n_result *res = parsed_result;
6866 start_packet_forwarding(res->tx_num);
6869 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6870 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6872 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6873 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6874 tx_first, "tx_first");
6875 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6876 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6879 cmdline_parse_inst_t cmd_start_tx_first_n = {
6880 .f = cmd_start_tx_first_n_parsed,
6882 .help_str = "start tx_first <num>: "
6883 "packet forwarding, after sending <num> bursts of packets",
6885 (void *)&cmd_start_tx_first_n_start,
6886 (void *)&cmd_start_tx_first_n_tx_first,
6887 (void *)&cmd_start_tx_first_n_tx_num,
6892 /* *** SET LINK UP *** */
6893 struct cmd_set_link_up_result {
6894 cmdline_fixed_string_t set;
6895 cmdline_fixed_string_t link_up;
6896 cmdline_fixed_string_t port;
6900 cmdline_parse_token_string_t cmd_set_link_up_set =
6901 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6902 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6903 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6905 cmdline_parse_token_string_t cmd_set_link_up_port =
6906 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6907 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6908 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6910 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6911 __attribute__((unused)) struct cmdline *cl,
6912 __attribute__((unused)) void *data)
6914 struct cmd_set_link_up_result *res = parsed_result;
6915 dev_set_link_up(res->port_id);
6918 cmdline_parse_inst_t cmd_set_link_up = {
6919 .f = cmd_set_link_up_parsed,
6921 .help_str = "set link-up port <port id>",
6923 (void *)&cmd_set_link_up_set,
6924 (void *)&cmd_set_link_up_link_up,
6925 (void *)&cmd_set_link_up_port,
6926 (void *)&cmd_set_link_up_port_id,
6931 /* *** SET LINK DOWN *** */
6932 struct cmd_set_link_down_result {
6933 cmdline_fixed_string_t set;
6934 cmdline_fixed_string_t link_down;
6935 cmdline_fixed_string_t port;
6939 cmdline_parse_token_string_t cmd_set_link_down_set =
6940 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6941 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6942 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6944 cmdline_parse_token_string_t cmd_set_link_down_port =
6945 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6946 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6947 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6949 static void cmd_set_link_down_parsed(
6950 __attribute__((unused)) void *parsed_result,
6951 __attribute__((unused)) struct cmdline *cl,
6952 __attribute__((unused)) void *data)
6954 struct cmd_set_link_down_result *res = parsed_result;
6955 dev_set_link_down(res->port_id);
6958 cmdline_parse_inst_t cmd_set_link_down = {
6959 .f = cmd_set_link_down_parsed,
6961 .help_str = "set link-down port <port id>",
6963 (void *)&cmd_set_link_down_set,
6964 (void *)&cmd_set_link_down_link_down,
6965 (void *)&cmd_set_link_down_port,
6966 (void *)&cmd_set_link_down_port_id,
6971 /* *** SHOW CFG *** */
6972 struct cmd_showcfg_result {
6973 cmdline_fixed_string_t show;
6974 cmdline_fixed_string_t cfg;
6975 cmdline_fixed_string_t what;
6978 static void cmd_showcfg_parsed(void *parsed_result,
6979 __attribute__((unused)) struct cmdline *cl,
6980 __attribute__((unused)) void *data)
6982 struct cmd_showcfg_result *res = parsed_result;
6983 if (!strcmp(res->what, "rxtx"))
6984 rxtx_config_display();
6985 else if (!strcmp(res->what, "cores"))
6986 fwd_lcores_config_display();
6987 else if (!strcmp(res->what, "fwd"))
6988 pkt_fwd_config_display(&cur_fwd_config);
6989 else if (!strcmp(res->what, "txpkts"))
6990 show_tx_pkt_segments();
6993 cmdline_parse_token_string_t cmd_showcfg_show =
6994 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6995 cmdline_parse_token_string_t cmd_showcfg_port =
6996 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6997 cmdline_parse_token_string_t cmd_showcfg_what =
6998 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6999 "rxtx#cores#fwd#txpkts");
7001 cmdline_parse_inst_t cmd_showcfg = {
7002 .f = cmd_showcfg_parsed,
7004 .help_str = "show config rxtx|cores|fwd|txpkts",
7006 (void *)&cmd_showcfg_show,
7007 (void *)&cmd_showcfg_port,
7008 (void *)&cmd_showcfg_what,
7013 /* *** SHOW ALL PORT INFO *** */
7014 struct cmd_showportall_result {
7015 cmdline_fixed_string_t show;
7016 cmdline_fixed_string_t port;
7017 cmdline_fixed_string_t what;
7018 cmdline_fixed_string_t all;
7021 static void cmd_showportall_parsed(void *parsed_result,
7022 __attribute__((unused)) struct cmdline *cl,
7023 __attribute__((unused)) void *data)
7027 struct cmd_showportall_result *res = parsed_result;
7028 if (!strcmp(res->show, "clear")) {
7029 if (!strcmp(res->what, "stats"))
7030 RTE_ETH_FOREACH_DEV(i)
7032 else if (!strcmp(res->what, "xstats"))
7033 RTE_ETH_FOREACH_DEV(i)
7034 nic_xstats_clear(i);
7035 } else if (!strcmp(res->what, "info"))
7036 RTE_ETH_FOREACH_DEV(i)
7037 port_infos_display(i);
7038 else if (!strcmp(res->what, "stats"))
7039 RTE_ETH_FOREACH_DEV(i)
7040 nic_stats_display(i);
7041 else if (!strcmp(res->what, "xstats"))
7042 RTE_ETH_FOREACH_DEV(i)
7043 nic_xstats_display(i);
7044 else if (!strcmp(res->what, "fdir"))
7045 RTE_ETH_FOREACH_DEV(i)
7047 else if (!strcmp(res->what, "stat_qmap"))
7048 RTE_ETH_FOREACH_DEV(i)
7049 nic_stats_mapping_display(i);
7050 else if (!strcmp(res->what, "dcb_tc"))
7051 RTE_ETH_FOREACH_DEV(i)
7052 port_dcb_info_display(i);
7053 else if (!strcmp(res->what, "cap"))
7054 RTE_ETH_FOREACH_DEV(i)
7055 port_offload_cap_display(i);
7058 cmdline_parse_token_string_t cmd_showportall_show =
7059 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7061 cmdline_parse_token_string_t cmd_showportall_port =
7062 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7063 cmdline_parse_token_string_t cmd_showportall_what =
7064 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7065 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7066 cmdline_parse_token_string_t cmd_showportall_all =
7067 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7068 cmdline_parse_inst_t cmd_showportall = {
7069 .f = cmd_showportall_parsed,
7071 .help_str = "show|clear port "
7072 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7074 (void *)&cmd_showportall_show,
7075 (void *)&cmd_showportall_port,
7076 (void *)&cmd_showportall_what,
7077 (void *)&cmd_showportall_all,
7082 /* *** SHOW PORT INFO *** */
7083 struct cmd_showport_result {
7084 cmdline_fixed_string_t show;
7085 cmdline_fixed_string_t port;
7086 cmdline_fixed_string_t what;
7090 static void cmd_showport_parsed(void *parsed_result,
7091 __attribute__((unused)) struct cmdline *cl,
7092 __attribute__((unused)) void *data)
7094 struct cmd_showport_result *res = parsed_result;
7095 if (!strcmp(res->show, "clear")) {
7096 if (!strcmp(res->what, "stats"))
7097 nic_stats_clear(res->portnum);
7098 else if (!strcmp(res->what, "xstats"))
7099 nic_xstats_clear(res->portnum);
7100 } else if (!strcmp(res->what, "info"))
7101 port_infos_display(res->portnum);
7102 else if (!strcmp(res->what, "stats"))
7103 nic_stats_display(res->portnum);
7104 else if (!strcmp(res->what, "xstats"))
7105 nic_xstats_display(res->portnum);
7106 else if (!strcmp(res->what, "fdir"))
7107 fdir_get_infos(res->portnum);
7108 else if (!strcmp(res->what, "stat_qmap"))
7109 nic_stats_mapping_display(res->portnum);
7110 else if (!strcmp(res->what, "dcb_tc"))
7111 port_dcb_info_display(res->portnum);
7112 else if (!strcmp(res->what, "cap"))
7113 port_offload_cap_display(res->portnum);
7116 cmdline_parse_token_string_t cmd_showport_show =
7117 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7119 cmdline_parse_token_string_t cmd_showport_port =
7120 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7121 cmdline_parse_token_string_t cmd_showport_what =
7122 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7123 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7124 cmdline_parse_token_num_t cmd_showport_portnum =
7125 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7127 cmdline_parse_inst_t cmd_showport = {
7128 .f = cmd_showport_parsed,
7130 .help_str = "show|clear port "
7131 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7134 (void *)&cmd_showport_show,
7135 (void *)&cmd_showport_port,
7136 (void *)&cmd_showport_what,
7137 (void *)&cmd_showport_portnum,
7142 /* *** SHOW QUEUE INFO *** */
7143 struct cmd_showqueue_result {
7144 cmdline_fixed_string_t show;
7145 cmdline_fixed_string_t type;
7146 cmdline_fixed_string_t what;
7152 cmd_showqueue_parsed(void *parsed_result,
7153 __attribute__((unused)) struct cmdline *cl,
7154 __attribute__((unused)) void *data)
7156 struct cmd_showqueue_result *res = parsed_result;
7158 if (!strcmp(res->type, "rxq"))
7159 rx_queue_infos_display(res->portnum, res->queuenum);
7160 else if (!strcmp(res->type, "txq"))
7161 tx_queue_infos_display(res->portnum, res->queuenum);
7164 cmdline_parse_token_string_t cmd_showqueue_show =
7165 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7166 cmdline_parse_token_string_t cmd_showqueue_type =
7167 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7168 cmdline_parse_token_string_t cmd_showqueue_what =
7169 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7170 cmdline_parse_token_num_t cmd_showqueue_portnum =
7171 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7172 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7173 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7175 cmdline_parse_inst_t cmd_showqueue = {
7176 .f = cmd_showqueue_parsed,
7178 .help_str = "show rxq|txq info <port_id> <queue_id>",
7180 (void *)&cmd_showqueue_show,
7181 (void *)&cmd_showqueue_type,
7182 (void *)&cmd_showqueue_what,
7183 (void *)&cmd_showqueue_portnum,
7184 (void *)&cmd_showqueue_queuenum,
7189 /* *** READ PORT REGISTER *** */
7190 struct cmd_read_reg_result {
7191 cmdline_fixed_string_t read;
7192 cmdline_fixed_string_t reg;
7198 cmd_read_reg_parsed(void *parsed_result,
7199 __attribute__((unused)) struct cmdline *cl,
7200 __attribute__((unused)) void *data)
7202 struct cmd_read_reg_result *res = parsed_result;
7203 port_reg_display(res->port_id, res->reg_off);
7206 cmdline_parse_token_string_t cmd_read_reg_read =
7207 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7208 cmdline_parse_token_string_t cmd_read_reg_reg =
7209 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7210 cmdline_parse_token_num_t cmd_read_reg_port_id =
7211 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7212 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7213 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7215 cmdline_parse_inst_t cmd_read_reg = {
7216 .f = cmd_read_reg_parsed,
7218 .help_str = "read reg <port_id> <reg_off>",
7220 (void *)&cmd_read_reg_read,
7221 (void *)&cmd_read_reg_reg,
7222 (void *)&cmd_read_reg_port_id,
7223 (void *)&cmd_read_reg_reg_off,
7228 /* *** READ PORT REGISTER BIT FIELD *** */
7229 struct cmd_read_reg_bit_field_result {
7230 cmdline_fixed_string_t read;
7231 cmdline_fixed_string_t regfield;
7239 cmd_read_reg_bit_field_parsed(void *parsed_result,
7240 __attribute__((unused)) struct cmdline *cl,
7241 __attribute__((unused)) void *data)
7243 struct cmd_read_reg_bit_field_result *res = parsed_result;
7244 port_reg_bit_field_display(res->port_id, res->reg_off,
7245 res->bit1_pos, res->bit2_pos);
7248 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7249 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7251 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7252 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7253 regfield, "regfield");
7254 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7255 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7257 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7258 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7260 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7261 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7263 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7264 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7267 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7268 .f = cmd_read_reg_bit_field_parsed,
7270 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7271 "Read register bit field between bit_x and bit_y included",
7273 (void *)&cmd_read_reg_bit_field_read,
7274 (void *)&cmd_read_reg_bit_field_regfield,
7275 (void *)&cmd_read_reg_bit_field_port_id,
7276 (void *)&cmd_read_reg_bit_field_reg_off,
7277 (void *)&cmd_read_reg_bit_field_bit1_pos,
7278 (void *)&cmd_read_reg_bit_field_bit2_pos,
7283 /* *** READ PORT REGISTER BIT *** */
7284 struct cmd_read_reg_bit_result {
7285 cmdline_fixed_string_t read;
7286 cmdline_fixed_string_t regbit;
7293 cmd_read_reg_bit_parsed(void *parsed_result,
7294 __attribute__((unused)) struct cmdline *cl,
7295 __attribute__((unused)) void *data)
7297 struct cmd_read_reg_bit_result *res = parsed_result;
7298 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7301 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7302 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7303 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7304 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7306 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7307 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7308 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7309 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7310 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7311 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7313 cmdline_parse_inst_t cmd_read_reg_bit = {
7314 .f = cmd_read_reg_bit_parsed,
7316 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7318 (void *)&cmd_read_reg_bit_read,
7319 (void *)&cmd_read_reg_bit_regbit,
7320 (void *)&cmd_read_reg_bit_port_id,
7321 (void *)&cmd_read_reg_bit_reg_off,
7322 (void *)&cmd_read_reg_bit_bit_pos,
7327 /* *** WRITE PORT REGISTER *** */
7328 struct cmd_write_reg_result {
7329 cmdline_fixed_string_t write;
7330 cmdline_fixed_string_t reg;
7337 cmd_write_reg_parsed(void *parsed_result,
7338 __attribute__((unused)) struct cmdline *cl,
7339 __attribute__((unused)) void *data)
7341 struct cmd_write_reg_result *res = parsed_result;
7342 port_reg_set(res->port_id, res->reg_off, res->value);
7345 cmdline_parse_token_string_t cmd_write_reg_write =
7346 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7347 cmdline_parse_token_string_t cmd_write_reg_reg =
7348 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7349 cmdline_parse_token_num_t cmd_write_reg_port_id =
7350 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7351 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7352 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7353 cmdline_parse_token_num_t cmd_write_reg_value =
7354 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7356 cmdline_parse_inst_t cmd_write_reg = {
7357 .f = cmd_write_reg_parsed,
7359 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7361 (void *)&cmd_write_reg_write,
7362 (void *)&cmd_write_reg_reg,
7363 (void *)&cmd_write_reg_port_id,
7364 (void *)&cmd_write_reg_reg_off,
7365 (void *)&cmd_write_reg_value,
7370 /* *** WRITE PORT REGISTER BIT FIELD *** */
7371 struct cmd_write_reg_bit_field_result {
7372 cmdline_fixed_string_t write;
7373 cmdline_fixed_string_t regfield;
7382 cmd_write_reg_bit_field_parsed(void *parsed_result,
7383 __attribute__((unused)) struct cmdline *cl,
7384 __attribute__((unused)) void *data)
7386 struct cmd_write_reg_bit_field_result *res = parsed_result;
7387 port_reg_bit_field_set(res->port_id, res->reg_off,
7388 res->bit1_pos, res->bit2_pos, res->value);
7391 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7392 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7394 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7395 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7396 regfield, "regfield");
7397 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7398 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7400 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7401 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7403 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7404 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7406 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7407 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7409 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7410 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7413 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7414 .f = cmd_write_reg_bit_field_parsed,
7416 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7418 "Set register bit field between bit_x and bit_y included",
7420 (void *)&cmd_write_reg_bit_field_write,
7421 (void *)&cmd_write_reg_bit_field_regfield,
7422 (void *)&cmd_write_reg_bit_field_port_id,
7423 (void *)&cmd_write_reg_bit_field_reg_off,
7424 (void *)&cmd_write_reg_bit_field_bit1_pos,
7425 (void *)&cmd_write_reg_bit_field_bit2_pos,
7426 (void *)&cmd_write_reg_bit_field_value,
7431 /* *** WRITE PORT REGISTER BIT *** */
7432 struct cmd_write_reg_bit_result {
7433 cmdline_fixed_string_t write;
7434 cmdline_fixed_string_t regbit;
7442 cmd_write_reg_bit_parsed(void *parsed_result,
7443 __attribute__((unused)) struct cmdline *cl,
7444 __attribute__((unused)) void *data)
7446 struct cmd_write_reg_bit_result *res = parsed_result;
7447 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7450 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7451 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7453 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7454 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7456 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7457 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7458 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7459 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7460 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7461 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7462 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7463 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7465 cmdline_parse_inst_t cmd_write_reg_bit = {
7466 .f = cmd_write_reg_bit_parsed,
7468 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7471 (void *)&cmd_write_reg_bit_write,
7472 (void *)&cmd_write_reg_bit_regbit,
7473 (void *)&cmd_write_reg_bit_port_id,
7474 (void *)&cmd_write_reg_bit_reg_off,
7475 (void *)&cmd_write_reg_bit_bit_pos,
7476 (void *)&cmd_write_reg_bit_value,
7481 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7482 struct cmd_read_rxd_txd_result {
7483 cmdline_fixed_string_t read;
7484 cmdline_fixed_string_t rxd_txd;
7491 cmd_read_rxd_txd_parsed(void *parsed_result,
7492 __attribute__((unused)) struct cmdline *cl,
7493 __attribute__((unused)) void *data)
7495 struct cmd_read_rxd_txd_result *res = parsed_result;
7497 if (!strcmp(res->rxd_txd, "rxd"))
7498 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7499 else if (!strcmp(res->rxd_txd, "txd"))
7500 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7503 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7504 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7505 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7506 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7508 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7509 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7510 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7511 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7512 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7513 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7515 cmdline_parse_inst_t cmd_read_rxd_txd = {
7516 .f = cmd_read_rxd_txd_parsed,
7518 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7520 (void *)&cmd_read_rxd_txd_read,
7521 (void *)&cmd_read_rxd_txd_rxd_txd,
7522 (void *)&cmd_read_rxd_txd_port_id,
7523 (void *)&cmd_read_rxd_txd_queue_id,
7524 (void *)&cmd_read_rxd_txd_desc_id,
7530 struct cmd_quit_result {
7531 cmdline_fixed_string_t quit;
7534 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7536 __attribute__((unused)) void *data)
7542 cmdline_parse_token_string_t cmd_quit_quit =
7543 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7545 cmdline_parse_inst_t cmd_quit = {
7546 .f = cmd_quit_parsed,
7548 .help_str = "quit: Exit application",
7550 (void *)&cmd_quit_quit,
7555 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7556 struct cmd_mac_addr_result {
7557 cmdline_fixed_string_t mac_addr_cmd;
7558 cmdline_fixed_string_t what;
7560 struct ether_addr address;
7563 static void cmd_mac_addr_parsed(void *parsed_result,
7564 __attribute__((unused)) struct cmdline *cl,
7565 __attribute__((unused)) void *data)
7567 struct cmd_mac_addr_result *res = parsed_result;
7570 if (strcmp(res->what, "add") == 0)
7571 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7572 else if (strcmp(res->what, "set") == 0)
7573 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7576 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7578 /* check the return value and print it if is < 0 */
7580 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7584 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7585 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7587 cmdline_parse_token_string_t cmd_mac_addr_what =
7588 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7590 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7591 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7593 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7594 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7596 cmdline_parse_inst_t cmd_mac_addr = {
7597 .f = cmd_mac_addr_parsed,
7599 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7600 "Add/Remove/Set MAC address on port_id",
7602 (void *)&cmd_mac_addr_cmd,
7603 (void *)&cmd_mac_addr_what,
7604 (void *)&cmd_mac_addr_portnum,
7605 (void *)&cmd_mac_addr_addr,
7610 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7611 struct cmd_eth_peer_result {
7612 cmdline_fixed_string_t set;
7613 cmdline_fixed_string_t eth_peer;
7615 cmdline_fixed_string_t peer_addr;
7618 static void cmd_set_eth_peer_parsed(void *parsed_result,
7619 __attribute__((unused)) struct cmdline *cl,
7620 __attribute__((unused)) void *data)
7622 struct cmd_eth_peer_result *res = parsed_result;
7624 if (test_done == 0) {
7625 printf("Please stop forwarding first\n");
7628 if (!strcmp(res->eth_peer, "eth-peer")) {
7629 set_fwd_eth_peer(res->port_id, res->peer_addr);
7633 cmdline_parse_token_string_t cmd_eth_peer_set =
7634 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7635 cmdline_parse_token_string_t cmd_eth_peer =
7636 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7637 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7638 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7639 cmdline_parse_token_string_t cmd_eth_peer_addr =
7640 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7642 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7643 .f = cmd_set_eth_peer_parsed,
7645 .help_str = "set eth-peer <port_id> <peer_mac>",
7647 (void *)&cmd_eth_peer_set,
7648 (void *)&cmd_eth_peer,
7649 (void *)&cmd_eth_peer_port_id,
7650 (void *)&cmd_eth_peer_addr,
7655 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7656 struct cmd_set_qmap_result {
7657 cmdline_fixed_string_t set;
7658 cmdline_fixed_string_t qmap;
7659 cmdline_fixed_string_t what;
7666 cmd_set_qmap_parsed(void *parsed_result,
7667 __attribute__((unused)) struct cmdline *cl,
7668 __attribute__((unused)) void *data)
7670 struct cmd_set_qmap_result *res = parsed_result;
7671 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7673 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7676 cmdline_parse_token_string_t cmd_setqmap_set =
7677 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7679 cmdline_parse_token_string_t cmd_setqmap_qmap =
7680 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7682 cmdline_parse_token_string_t cmd_setqmap_what =
7683 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7685 cmdline_parse_token_num_t cmd_setqmap_portid =
7686 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7688 cmdline_parse_token_num_t cmd_setqmap_queueid =
7689 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7691 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7692 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7695 cmdline_parse_inst_t cmd_set_qmap = {
7696 .f = cmd_set_qmap_parsed,
7698 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7699 "Set statistics mapping value on tx|rx queue_id of port_id",
7701 (void *)&cmd_setqmap_set,
7702 (void *)&cmd_setqmap_qmap,
7703 (void *)&cmd_setqmap_what,
7704 (void *)&cmd_setqmap_portid,
7705 (void *)&cmd_setqmap_queueid,
7706 (void *)&cmd_setqmap_mapvalue,
7711 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7712 struct cmd_set_xstats_hide_zero_result {
7713 cmdline_fixed_string_t keyword;
7714 cmdline_fixed_string_t name;
7715 cmdline_fixed_string_t on_off;
7719 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7720 __attribute__((unused)) struct cmdline *cl,
7721 __attribute__((unused)) void *data)
7723 struct cmd_set_xstats_hide_zero_result *res;
7724 uint16_t on_off = 0;
7726 res = parsed_result;
7727 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7728 set_xstats_hide_zero(on_off);
7731 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7732 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7734 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7735 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7736 name, "xstats-hide-zero");
7737 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7738 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7741 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7742 .f = cmd_set_xstats_hide_zero_parsed,
7744 .help_str = "set xstats-hide-zero on|off",
7746 (void *)&cmd_set_xstats_hide_zero_keyword,
7747 (void *)&cmd_set_xstats_hide_zero_name,
7748 (void *)&cmd_set_xstats_hide_zero_on_off,
7753 /* *** CONFIGURE UNICAST HASH TABLE *** */
7754 struct cmd_set_uc_hash_table {
7755 cmdline_fixed_string_t set;
7756 cmdline_fixed_string_t port;
7758 cmdline_fixed_string_t what;
7759 struct ether_addr address;
7760 cmdline_fixed_string_t mode;
7764 cmd_set_uc_hash_parsed(void *parsed_result,
7765 __attribute__((unused)) struct cmdline *cl,
7766 __attribute__((unused)) void *data)
7769 struct cmd_set_uc_hash_table *res = parsed_result;
7771 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7773 if (strcmp(res->what, "uta") == 0)
7774 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7775 &res->address,(uint8_t)is_on);
7777 printf("bad unicast hash table parameter, return code = %d \n", ret);
7781 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7782 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7784 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7785 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7787 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7788 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7790 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7791 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7793 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7794 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7796 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7797 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7800 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7801 .f = cmd_set_uc_hash_parsed,
7803 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7805 (void *)&cmd_set_uc_hash_set,
7806 (void *)&cmd_set_uc_hash_port,
7807 (void *)&cmd_set_uc_hash_portid,
7808 (void *)&cmd_set_uc_hash_what,
7809 (void *)&cmd_set_uc_hash_mac,
7810 (void *)&cmd_set_uc_hash_mode,
7815 struct cmd_set_uc_all_hash_table {
7816 cmdline_fixed_string_t set;
7817 cmdline_fixed_string_t port;
7819 cmdline_fixed_string_t what;
7820 cmdline_fixed_string_t value;
7821 cmdline_fixed_string_t mode;
7825 cmd_set_uc_all_hash_parsed(void *parsed_result,
7826 __attribute__((unused)) struct cmdline *cl,
7827 __attribute__((unused)) void *data)
7830 struct cmd_set_uc_all_hash_table *res = parsed_result;
7832 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7834 if ((strcmp(res->what, "uta") == 0) &&
7835 (strcmp(res->value, "all") == 0))
7836 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7838 printf("bad unicast hash table parameter,"
7839 "return code = %d \n", ret);
7842 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7843 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7845 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7846 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7848 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7849 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7851 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7852 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7854 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7855 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7857 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7858 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7861 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7862 .f = cmd_set_uc_all_hash_parsed,
7864 .help_str = "set port <port_id> uta all on|off",
7866 (void *)&cmd_set_uc_all_hash_set,
7867 (void *)&cmd_set_uc_all_hash_port,
7868 (void *)&cmd_set_uc_all_hash_portid,
7869 (void *)&cmd_set_uc_all_hash_what,
7870 (void *)&cmd_set_uc_all_hash_value,
7871 (void *)&cmd_set_uc_all_hash_mode,
7876 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7877 struct cmd_set_vf_macvlan_filter {
7878 cmdline_fixed_string_t set;
7879 cmdline_fixed_string_t port;
7881 cmdline_fixed_string_t vf;
7883 struct ether_addr address;
7884 cmdline_fixed_string_t filter_type;
7885 cmdline_fixed_string_t mode;
7889 cmd_set_vf_macvlan_parsed(void *parsed_result,
7890 __attribute__((unused)) struct cmdline *cl,
7891 __attribute__((unused)) void *data)
7894 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7895 struct rte_eth_mac_filter filter;
7897 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7899 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7901 /* set VF MAC filter */
7905 filter.dst_id = res->vf_id;
7907 if (!strcmp(res->filter_type, "exact-mac"))
7908 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7909 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7910 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7911 else if (!strcmp(res->filter_type, "hashmac"))
7912 filter.filter_type = RTE_MAC_HASH_MATCH;
7913 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7914 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7916 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7919 ret = rte_eth_dev_filter_ctrl(res->port_id,
7920 RTE_ETH_FILTER_MACVLAN,
7924 ret = rte_eth_dev_filter_ctrl(res->port_id,
7925 RTE_ETH_FILTER_MACVLAN,
7926 RTE_ETH_FILTER_DELETE,
7930 printf("bad set MAC hash parameter, return code = %d\n", ret);
7934 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7935 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7937 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7938 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7940 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7941 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7943 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7944 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7946 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7947 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7949 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7950 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7952 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7953 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7954 filter_type, "exact-mac#exact-mac-vlan"
7955 "#hashmac#hashmac-vlan");
7956 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7957 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7960 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7961 .f = cmd_set_vf_macvlan_parsed,
7963 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7964 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7965 "Exact match rule: exact match of MAC or MAC and VLAN; "
7966 "hash match rule: hash match of MAC and exact match of VLAN",
7968 (void *)&cmd_set_vf_macvlan_set,
7969 (void *)&cmd_set_vf_macvlan_port,
7970 (void *)&cmd_set_vf_macvlan_portid,
7971 (void *)&cmd_set_vf_macvlan_vf,
7972 (void *)&cmd_set_vf_macvlan_vf_id,
7973 (void *)&cmd_set_vf_macvlan_mac,
7974 (void *)&cmd_set_vf_macvlan_filter_type,
7975 (void *)&cmd_set_vf_macvlan_mode,
7980 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7981 struct cmd_set_vf_traffic {
7982 cmdline_fixed_string_t set;
7983 cmdline_fixed_string_t port;
7985 cmdline_fixed_string_t vf;
7987 cmdline_fixed_string_t what;
7988 cmdline_fixed_string_t mode;
7992 cmd_set_vf_traffic_parsed(void *parsed_result,
7993 __attribute__((unused)) struct cmdline *cl,
7994 __attribute__((unused)) void *data)
7996 struct cmd_set_vf_traffic *res = parsed_result;
7997 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7998 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8000 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8003 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8004 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8006 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8007 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8009 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8010 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8012 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8013 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8015 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8016 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8018 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8019 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8021 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8022 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8025 cmdline_parse_inst_t cmd_set_vf_traffic = {
8026 .f = cmd_set_vf_traffic_parsed,
8028 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8030 (void *)&cmd_setvf_traffic_set,
8031 (void *)&cmd_setvf_traffic_port,
8032 (void *)&cmd_setvf_traffic_portid,
8033 (void *)&cmd_setvf_traffic_vf,
8034 (void *)&cmd_setvf_traffic_vfid,
8035 (void *)&cmd_setvf_traffic_what,
8036 (void *)&cmd_setvf_traffic_mode,
8041 /* *** CONFIGURE VF RECEIVE MODE *** */
8042 struct cmd_set_vf_rxmode {
8043 cmdline_fixed_string_t set;
8044 cmdline_fixed_string_t port;
8046 cmdline_fixed_string_t vf;
8048 cmdline_fixed_string_t what;
8049 cmdline_fixed_string_t mode;
8050 cmdline_fixed_string_t on;
8054 cmd_set_vf_rxmode_parsed(void *parsed_result,
8055 __attribute__((unused)) struct cmdline *cl,
8056 __attribute__((unused)) void *data)
8059 uint16_t rx_mode = 0;
8060 struct cmd_set_vf_rxmode *res = parsed_result;
8062 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8063 if (!strcmp(res->what,"rxmode")) {
8064 if (!strcmp(res->mode, "AUPE"))
8065 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8066 else if (!strcmp(res->mode, "ROPE"))
8067 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8068 else if (!strcmp(res->mode, "BAM"))
8069 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8070 else if (!strncmp(res->mode, "MPE",3))
8071 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8074 RTE_SET_USED(is_on);
8076 #ifdef RTE_LIBRTE_IXGBE_PMD
8077 if (ret == -ENOTSUP)
8078 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8079 rx_mode, (uint8_t)is_on);
8081 #ifdef RTE_LIBRTE_BNXT_PMD
8082 if (ret == -ENOTSUP)
8083 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8084 rx_mode, (uint8_t)is_on);
8087 printf("bad VF receive mode parameter, return code = %d \n",
8091 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8092 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8094 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8095 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8097 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8098 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8100 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8101 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8103 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8104 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8106 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8107 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8109 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8110 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8111 mode, "AUPE#ROPE#BAM#MPE");
8112 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8113 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8116 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8117 .f = cmd_set_vf_rxmode_parsed,
8119 .help_str = "set port <port_id> vf <vf_id> rxmode "
8120 "AUPE|ROPE|BAM|MPE on|off",
8122 (void *)&cmd_set_vf_rxmode_set,
8123 (void *)&cmd_set_vf_rxmode_port,
8124 (void *)&cmd_set_vf_rxmode_portid,
8125 (void *)&cmd_set_vf_rxmode_vf,
8126 (void *)&cmd_set_vf_rxmode_vfid,
8127 (void *)&cmd_set_vf_rxmode_what,
8128 (void *)&cmd_set_vf_rxmode_mode,
8129 (void *)&cmd_set_vf_rxmode_on,
8134 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8135 struct cmd_vf_mac_addr_result {
8136 cmdline_fixed_string_t mac_addr_cmd;
8137 cmdline_fixed_string_t what;
8138 cmdline_fixed_string_t port;
8140 cmdline_fixed_string_t vf;
8142 struct ether_addr address;
8145 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8146 __attribute__((unused)) struct cmdline *cl,
8147 __attribute__((unused)) void *data)
8149 struct cmd_vf_mac_addr_result *res = parsed_result;
8152 if (strcmp(res->what, "add") != 0)
8155 #ifdef RTE_LIBRTE_I40E_PMD
8156 if (ret == -ENOTSUP)
8157 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8160 #ifdef RTE_LIBRTE_BNXT_PMD
8161 if (ret == -ENOTSUP)
8162 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8167 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8171 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8172 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8173 mac_addr_cmd,"mac_addr");
8174 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8175 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8177 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8178 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8180 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8181 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8183 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8184 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8186 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8187 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8189 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8190 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8193 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8194 .f = cmd_vf_mac_addr_parsed,
8196 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8197 "Add MAC address filtering for a VF on port_id",
8199 (void *)&cmd_vf_mac_addr_cmd,
8200 (void *)&cmd_vf_mac_addr_what,
8201 (void *)&cmd_vf_mac_addr_port,
8202 (void *)&cmd_vf_mac_addr_portnum,
8203 (void *)&cmd_vf_mac_addr_vf,
8204 (void *)&cmd_vf_mac_addr_vfnum,
8205 (void *)&cmd_vf_mac_addr_addr,
8210 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8211 struct cmd_vf_rx_vlan_filter {
8212 cmdline_fixed_string_t rx_vlan;
8213 cmdline_fixed_string_t what;
8215 cmdline_fixed_string_t port;
8217 cmdline_fixed_string_t vf;
8222 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8223 __attribute__((unused)) struct cmdline *cl,
8224 __attribute__((unused)) void *data)
8226 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8229 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8231 #ifdef RTE_LIBRTE_IXGBE_PMD
8232 if (ret == -ENOTSUP)
8233 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8234 res->vlan_id, res->vf_mask, is_add);
8236 #ifdef RTE_LIBRTE_I40E_PMD
8237 if (ret == -ENOTSUP)
8238 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8239 res->vlan_id, res->vf_mask, is_add);
8241 #ifdef RTE_LIBRTE_BNXT_PMD
8242 if (ret == -ENOTSUP)
8243 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8244 res->vlan_id, res->vf_mask, is_add);
8251 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8252 res->vlan_id, res->vf_mask);
8255 printf("invalid port_id %d\n", res->port_id);
8258 printf("function not implemented or supported\n");
8261 printf("programming error: (%s)\n", strerror(-ret));
8265 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8266 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8267 rx_vlan, "rx_vlan");
8268 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8269 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8271 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8272 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8274 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8275 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8277 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8278 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8280 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8281 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8283 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8284 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8287 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8288 .f = cmd_vf_rx_vlan_filter_parsed,
8290 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8291 "(vf_mask = hexadecimal VF mask)",
8293 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8294 (void *)&cmd_vf_rx_vlan_filter_what,
8295 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8296 (void *)&cmd_vf_rx_vlan_filter_port,
8297 (void *)&cmd_vf_rx_vlan_filter_portid,
8298 (void *)&cmd_vf_rx_vlan_filter_vf,
8299 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8304 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8305 struct cmd_queue_rate_limit_result {
8306 cmdline_fixed_string_t set;
8307 cmdline_fixed_string_t port;
8309 cmdline_fixed_string_t queue;
8311 cmdline_fixed_string_t rate;
8315 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8316 __attribute__((unused)) struct cmdline *cl,
8317 __attribute__((unused)) void *data)
8319 struct cmd_queue_rate_limit_result *res = parsed_result;
8322 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8323 && (strcmp(res->queue, "queue") == 0)
8324 && (strcmp(res->rate, "rate") == 0))
8325 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8328 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8332 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8333 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8335 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8336 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8338 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8339 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8341 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8342 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8344 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8345 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8347 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8348 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8350 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8351 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8354 cmdline_parse_inst_t cmd_queue_rate_limit = {
8355 .f = cmd_queue_rate_limit_parsed,
8357 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8358 "Set rate limit for a queue on port_id",
8360 (void *)&cmd_queue_rate_limit_set,
8361 (void *)&cmd_queue_rate_limit_port,
8362 (void *)&cmd_queue_rate_limit_portnum,
8363 (void *)&cmd_queue_rate_limit_queue,
8364 (void *)&cmd_queue_rate_limit_queuenum,
8365 (void *)&cmd_queue_rate_limit_rate,
8366 (void *)&cmd_queue_rate_limit_ratenum,
8371 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8372 struct cmd_vf_rate_limit_result {
8373 cmdline_fixed_string_t set;
8374 cmdline_fixed_string_t port;
8376 cmdline_fixed_string_t vf;
8378 cmdline_fixed_string_t rate;
8380 cmdline_fixed_string_t q_msk;
8384 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8385 __attribute__((unused)) struct cmdline *cl,
8386 __attribute__((unused)) void *data)
8388 struct cmd_vf_rate_limit_result *res = parsed_result;
8391 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8392 && (strcmp(res->vf, "vf") == 0)
8393 && (strcmp(res->rate, "rate") == 0)
8394 && (strcmp(res->q_msk, "queue_mask") == 0))
8395 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8396 res->rate_num, res->q_msk_val);
8398 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8402 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8403 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8405 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8406 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8408 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8409 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8411 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8412 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8414 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8415 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8417 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8418 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8420 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8421 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8423 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8424 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8425 q_msk, "queue_mask");
8426 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8427 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8430 cmdline_parse_inst_t cmd_vf_rate_limit = {
8431 .f = cmd_vf_rate_limit_parsed,
8433 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8434 "queue_mask <queue_mask_value>: "
8435 "Set rate limit for queues of VF on port_id",
8437 (void *)&cmd_vf_rate_limit_set,
8438 (void *)&cmd_vf_rate_limit_port,
8439 (void *)&cmd_vf_rate_limit_portnum,
8440 (void *)&cmd_vf_rate_limit_vf,
8441 (void *)&cmd_vf_rate_limit_vfnum,
8442 (void *)&cmd_vf_rate_limit_rate,
8443 (void *)&cmd_vf_rate_limit_ratenum,
8444 (void *)&cmd_vf_rate_limit_q_msk,
8445 (void *)&cmd_vf_rate_limit_q_msk_val,
8450 /* *** ADD TUNNEL FILTER OF A PORT *** */
8451 struct cmd_tunnel_filter_result {
8452 cmdline_fixed_string_t cmd;
8453 cmdline_fixed_string_t what;
8455 struct ether_addr outer_mac;
8456 struct ether_addr inner_mac;
8457 cmdline_ipaddr_t ip_value;
8458 uint16_t inner_vlan;
8459 cmdline_fixed_string_t tunnel_type;
8460 cmdline_fixed_string_t filter_type;
8466 cmd_tunnel_filter_parsed(void *parsed_result,
8467 __attribute__((unused)) struct cmdline *cl,
8468 __attribute__((unused)) void *data)
8470 struct cmd_tunnel_filter_result *res = parsed_result;
8471 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8474 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8476 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8477 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8478 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8480 if (res->ip_value.family == AF_INET) {
8481 tunnel_filter_conf.ip_addr.ipv4_addr =
8482 res->ip_value.addr.ipv4.s_addr;
8483 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8485 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8486 &(res->ip_value.addr.ipv6),
8487 sizeof(struct in6_addr));
8488 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8491 if (!strcmp(res->filter_type, "imac-ivlan"))
8492 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8493 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8494 tunnel_filter_conf.filter_type =
8495 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8496 else if (!strcmp(res->filter_type, "imac-tenid"))
8497 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8498 else if (!strcmp(res->filter_type, "imac"))
8499 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8500 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8501 tunnel_filter_conf.filter_type =
8502 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8503 else if (!strcmp(res->filter_type, "oip"))
8504 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8505 else if (!strcmp(res->filter_type, "iip"))
8506 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8508 printf("The filter type is not supported");
8512 if (!strcmp(res->tunnel_type, "vxlan"))
8513 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8514 else if (!strcmp(res->tunnel_type, "nvgre"))
8515 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8516 else if (!strcmp(res->tunnel_type, "ipingre"))
8517 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8519 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8523 tunnel_filter_conf.tenant_id = res->tenant_id;
8524 tunnel_filter_conf.queue_id = res->queue_num;
8525 if (!strcmp(res->what, "add"))
8526 ret = rte_eth_dev_filter_ctrl(res->port_id,
8527 RTE_ETH_FILTER_TUNNEL,
8529 &tunnel_filter_conf);
8531 ret = rte_eth_dev_filter_ctrl(res->port_id,
8532 RTE_ETH_FILTER_TUNNEL,
8533 RTE_ETH_FILTER_DELETE,
8534 &tunnel_filter_conf);
8536 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8540 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8541 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8542 cmd, "tunnel_filter");
8543 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8544 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8546 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8547 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8549 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8550 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8552 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8553 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8555 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8556 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8557 inner_vlan, UINT16);
8558 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8559 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8561 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8562 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8563 tunnel_type, "vxlan#nvgre#ipingre");
8565 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8566 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8567 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8568 "imac#omac-imac-tenid");
8569 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8570 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8572 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8573 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8576 cmdline_parse_inst_t cmd_tunnel_filter = {
8577 .f = cmd_tunnel_filter_parsed,
8579 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8580 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8581 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8582 "<queue_id>: Add/Rm tunnel filter of a port",
8584 (void *)&cmd_tunnel_filter_cmd,
8585 (void *)&cmd_tunnel_filter_what,
8586 (void *)&cmd_tunnel_filter_port_id,
8587 (void *)&cmd_tunnel_filter_outer_mac,
8588 (void *)&cmd_tunnel_filter_inner_mac,
8589 (void *)&cmd_tunnel_filter_ip_value,
8590 (void *)&cmd_tunnel_filter_innner_vlan,
8591 (void *)&cmd_tunnel_filter_tunnel_type,
8592 (void *)&cmd_tunnel_filter_filter_type,
8593 (void *)&cmd_tunnel_filter_tenant_id,
8594 (void *)&cmd_tunnel_filter_queue_num,
8599 /* *** CONFIGURE TUNNEL UDP PORT *** */
8600 struct cmd_tunnel_udp_config {
8601 cmdline_fixed_string_t cmd;
8602 cmdline_fixed_string_t what;
8608 cmd_tunnel_udp_config_parsed(void *parsed_result,
8609 __attribute__((unused)) struct cmdline *cl,
8610 __attribute__((unused)) void *data)
8612 struct cmd_tunnel_udp_config *res = parsed_result;
8613 struct rte_eth_udp_tunnel tunnel_udp;
8616 tunnel_udp.udp_port = res->udp_port;
8618 if (!strcmp(res->cmd, "rx_vxlan_port"))
8619 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8621 if (!strcmp(res->what, "add"))
8622 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8625 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8629 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8632 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8633 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8634 cmd, "rx_vxlan_port");
8635 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8636 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8638 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8639 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8641 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8642 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8645 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8646 .f = cmd_tunnel_udp_config_parsed,
8648 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8649 "Add/Remove a tunneling UDP port filter",
8651 (void *)&cmd_tunnel_udp_config_cmd,
8652 (void *)&cmd_tunnel_udp_config_what,
8653 (void *)&cmd_tunnel_udp_config_udp_port,
8654 (void *)&cmd_tunnel_udp_config_port_id,
8659 struct cmd_config_tunnel_udp_port {
8660 cmdline_fixed_string_t port;
8661 cmdline_fixed_string_t config;
8663 cmdline_fixed_string_t udp_tunnel_port;
8664 cmdline_fixed_string_t action;
8665 cmdline_fixed_string_t tunnel_type;
8670 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8671 __attribute__((unused)) struct cmdline *cl,
8672 __attribute__((unused)) void *data)
8674 struct cmd_config_tunnel_udp_port *res = parsed_result;
8675 struct rte_eth_udp_tunnel tunnel_udp;
8678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8681 tunnel_udp.udp_port = res->udp_port;
8683 if (!strcmp(res->tunnel_type, "vxlan")) {
8684 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8685 } else if (!strcmp(res->tunnel_type, "geneve")) {
8686 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8688 printf("Invalid tunnel type\n");
8692 if (!strcmp(res->action, "add"))
8693 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8696 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8700 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8703 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8704 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8706 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8707 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8709 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8710 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8712 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8713 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8716 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8717 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8719 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8720 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8722 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8723 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8726 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8727 .f = cmd_cfg_tunnel_udp_port_parsed,
8729 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8731 (void *)&cmd_config_tunnel_udp_port_port,
8732 (void *)&cmd_config_tunnel_udp_port_config,
8733 (void *)&cmd_config_tunnel_udp_port_port_id,
8734 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8735 (void *)&cmd_config_tunnel_udp_port_action,
8736 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8737 (void *)&cmd_config_tunnel_udp_port_value,
8742 /* *** GLOBAL CONFIG *** */
8743 struct cmd_global_config_result {
8744 cmdline_fixed_string_t cmd;
8746 cmdline_fixed_string_t cfg_type;
8751 cmd_global_config_parsed(void *parsed_result,
8752 __attribute__((unused)) struct cmdline *cl,
8753 __attribute__((unused)) void *data)
8755 struct cmd_global_config_result *res = parsed_result;
8756 struct rte_eth_global_cfg conf;
8759 memset(&conf, 0, sizeof(conf));
8760 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8761 conf.cfg.gre_key_len = res->len;
8762 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8763 RTE_ETH_FILTER_SET, &conf);
8765 printf("Global config error\n");
8768 cmdline_parse_token_string_t cmd_global_config_cmd =
8769 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8771 cmdline_parse_token_num_t cmd_global_config_port_id =
8772 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8774 cmdline_parse_token_string_t cmd_global_config_type =
8775 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8776 cfg_type, "gre-key-len");
8777 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8778 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8781 cmdline_parse_inst_t cmd_global_config = {
8782 .f = cmd_global_config_parsed,
8783 .data = (void *)NULL,
8784 .help_str = "global_config <port_id> gre-key-len <key_len>",
8786 (void *)&cmd_global_config_cmd,
8787 (void *)&cmd_global_config_port_id,
8788 (void *)&cmd_global_config_type,
8789 (void *)&cmd_global_config_gre_key_len,
8794 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8795 struct cmd_set_mirror_mask_result {
8796 cmdline_fixed_string_t set;
8797 cmdline_fixed_string_t port;
8799 cmdline_fixed_string_t mirror;
8801 cmdline_fixed_string_t what;
8802 cmdline_fixed_string_t value;
8803 cmdline_fixed_string_t dstpool;
8805 cmdline_fixed_string_t on;
8808 cmdline_parse_token_string_t cmd_mirror_mask_set =
8809 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8811 cmdline_parse_token_string_t cmd_mirror_mask_port =
8812 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8814 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8815 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8817 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8818 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8819 mirror, "mirror-rule");
8820 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8821 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8823 cmdline_parse_token_string_t cmd_mirror_mask_what =
8824 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8825 what, "pool-mirror-up#pool-mirror-down"
8827 cmdline_parse_token_string_t cmd_mirror_mask_value =
8828 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8830 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8831 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8832 dstpool, "dst-pool");
8833 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8834 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8836 cmdline_parse_token_string_t cmd_mirror_mask_on =
8837 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8841 cmd_set_mirror_mask_parsed(void *parsed_result,
8842 __attribute__((unused)) struct cmdline *cl,
8843 __attribute__((unused)) void *data)
8846 struct cmd_set_mirror_mask_result *res = parsed_result;
8847 struct rte_eth_mirror_conf mr_conf;
8849 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8851 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8853 mr_conf.dst_pool = res->dstpool_id;
8855 if (!strcmp(res->what, "pool-mirror-up")) {
8856 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8857 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8858 } else if (!strcmp(res->what, "pool-mirror-down")) {
8859 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8860 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8861 } else if (!strcmp(res->what, "vlan-mirror")) {
8862 mr_conf.rule_type = ETH_MIRROR_VLAN;
8863 nb_item = parse_item_list(res->value, "vlan",
8864 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8868 for (i = 0; i < nb_item; i++) {
8869 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8870 printf("Invalid vlan_id: must be < 4096\n");
8874 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8875 mr_conf.vlan.vlan_mask |= 1ULL << i;
8879 if (!strcmp(res->on, "on"))
8880 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8883 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8886 printf("mirror rule add error: (%s)\n", strerror(-ret));
8889 cmdline_parse_inst_t cmd_set_mirror_mask = {
8890 .f = cmd_set_mirror_mask_parsed,
8892 .help_str = "set port <port_id> mirror-rule <rule_id> "
8893 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8894 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8896 (void *)&cmd_mirror_mask_set,
8897 (void *)&cmd_mirror_mask_port,
8898 (void *)&cmd_mirror_mask_portid,
8899 (void *)&cmd_mirror_mask_mirror,
8900 (void *)&cmd_mirror_mask_ruleid,
8901 (void *)&cmd_mirror_mask_what,
8902 (void *)&cmd_mirror_mask_value,
8903 (void *)&cmd_mirror_mask_dstpool,
8904 (void *)&cmd_mirror_mask_poolid,
8905 (void *)&cmd_mirror_mask_on,
8910 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8911 struct cmd_set_mirror_link_result {
8912 cmdline_fixed_string_t set;
8913 cmdline_fixed_string_t port;
8915 cmdline_fixed_string_t mirror;
8917 cmdline_fixed_string_t what;
8918 cmdline_fixed_string_t dstpool;
8920 cmdline_fixed_string_t on;
8923 cmdline_parse_token_string_t cmd_mirror_link_set =
8924 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8926 cmdline_parse_token_string_t cmd_mirror_link_port =
8927 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8929 cmdline_parse_token_num_t cmd_mirror_link_portid =
8930 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8932 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8933 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8934 mirror, "mirror-rule");
8935 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8936 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8938 cmdline_parse_token_string_t cmd_mirror_link_what =
8939 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8940 what, "uplink-mirror#downlink-mirror");
8941 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8942 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8943 dstpool, "dst-pool");
8944 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8945 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8947 cmdline_parse_token_string_t cmd_mirror_link_on =
8948 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8952 cmd_set_mirror_link_parsed(void *parsed_result,
8953 __attribute__((unused)) struct cmdline *cl,
8954 __attribute__((unused)) void *data)
8957 struct cmd_set_mirror_link_result *res = parsed_result;
8958 struct rte_eth_mirror_conf mr_conf;
8960 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8961 if (!strcmp(res->what, "uplink-mirror"))
8962 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8964 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8966 mr_conf.dst_pool = res->dstpool_id;
8968 if (!strcmp(res->on, "on"))
8969 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8972 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8975 /* check the return value and print it if is < 0 */
8977 printf("mirror rule add error: (%s)\n", strerror(-ret));
8981 cmdline_parse_inst_t cmd_set_mirror_link = {
8982 .f = cmd_set_mirror_link_parsed,
8984 .help_str = "set port <port_id> mirror-rule <rule_id> "
8985 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8987 (void *)&cmd_mirror_link_set,
8988 (void *)&cmd_mirror_link_port,
8989 (void *)&cmd_mirror_link_portid,
8990 (void *)&cmd_mirror_link_mirror,
8991 (void *)&cmd_mirror_link_ruleid,
8992 (void *)&cmd_mirror_link_what,
8993 (void *)&cmd_mirror_link_dstpool,
8994 (void *)&cmd_mirror_link_poolid,
8995 (void *)&cmd_mirror_link_on,
9000 /* *** RESET VM MIRROR RULE *** */
9001 struct cmd_rm_mirror_rule_result {
9002 cmdline_fixed_string_t reset;
9003 cmdline_fixed_string_t port;
9005 cmdline_fixed_string_t mirror;
9009 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9010 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9012 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9013 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9015 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9016 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9018 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9019 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9020 mirror, "mirror-rule");
9021 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9022 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9026 cmd_reset_mirror_rule_parsed(void *parsed_result,
9027 __attribute__((unused)) struct cmdline *cl,
9028 __attribute__((unused)) void *data)
9031 struct cmd_set_mirror_link_result *res = parsed_result;
9033 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9035 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9038 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9039 .f = cmd_reset_mirror_rule_parsed,
9041 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9043 (void *)&cmd_rm_mirror_rule_reset,
9044 (void *)&cmd_rm_mirror_rule_port,
9045 (void *)&cmd_rm_mirror_rule_portid,
9046 (void *)&cmd_rm_mirror_rule_mirror,
9047 (void *)&cmd_rm_mirror_rule_ruleid,
9052 /* ******************************************************************************** */
9054 struct cmd_dump_result {
9055 cmdline_fixed_string_t dump;
9059 dump_struct_sizes(void)
9061 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9062 DUMP_SIZE(struct rte_mbuf);
9063 DUMP_SIZE(struct rte_mempool);
9064 DUMP_SIZE(struct rte_ring);
9068 static void cmd_dump_parsed(void *parsed_result,
9069 __attribute__((unused)) struct cmdline *cl,
9070 __attribute__((unused)) void *data)
9072 struct cmd_dump_result *res = parsed_result;
9074 if (!strcmp(res->dump, "dump_physmem"))
9075 rte_dump_physmem_layout(stdout);
9076 else if (!strcmp(res->dump, "dump_memzone"))
9077 rte_memzone_dump(stdout);
9078 else if (!strcmp(res->dump, "dump_struct_sizes"))
9079 dump_struct_sizes();
9080 else if (!strcmp(res->dump, "dump_ring"))
9081 rte_ring_list_dump(stdout);
9082 else if (!strcmp(res->dump, "dump_mempool"))
9083 rte_mempool_list_dump(stdout);
9084 else if (!strcmp(res->dump, "dump_devargs"))
9085 rte_devargs_dump(stdout);
9086 else if (!strcmp(res->dump, "dump_log_types"))
9087 rte_log_dump(stdout);
9090 cmdline_parse_token_string_t cmd_dump_dump =
9091 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9094 "dump_struct_sizes#"
9100 cmdline_parse_inst_t cmd_dump = {
9101 .f = cmd_dump_parsed, /* function to call */
9102 .data = NULL, /* 2nd arg of func */
9103 .help_str = "Dump status",
9104 .tokens = { /* token list, NULL terminated */
9105 (void *)&cmd_dump_dump,
9110 /* ******************************************************************************** */
9112 struct cmd_dump_one_result {
9113 cmdline_fixed_string_t dump;
9114 cmdline_fixed_string_t name;
9117 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9118 __attribute__((unused)) void *data)
9120 struct cmd_dump_one_result *res = parsed_result;
9122 if (!strcmp(res->dump, "dump_ring")) {
9124 r = rte_ring_lookup(res->name);
9126 cmdline_printf(cl, "Cannot find ring\n");
9129 rte_ring_dump(stdout, r);
9130 } else if (!strcmp(res->dump, "dump_mempool")) {
9131 struct rte_mempool *mp;
9132 mp = rte_mempool_lookup(res->name);
9134 cmdline_printf(cl, "Cannot find mempool\n");
9137 rte_mempool_dump(stdout, mp);
9141 cmdline_parse_token_string_t cmd_dump_one_dump =
9142 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9143 "dump_ring#dump_mempool");
9145 cmdline_parse_token_string_t cmd_dump_one_name =
9146 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9148 cmdline_parse_inst_t cmd_dump_one = {
9149 .f = cmd_dump_one_parsed, /* function to call */
9150 .data = NULL, /* 2nd arg of func */
9151 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9152 .tokens = { /* token list, NULL terminated */
9153 (void *)&cmd_dump_one_dump,
9154 (void *)&cmd_dump_one_name,
9159 /* *** Add/Del syn filter *** */
9160 struct cmd_syn_filter_result {
9161 cmdline_fixed_string_t filter;
9163 cmdline_fixed_string_t ops;
9164 cmdline_fixed_string_t priority;
9165 cmdline_fixed_string_t high;
9166 cmdline_fixed_string_t queue;
9171 cmd_syn_filter_parsed(void *parsed_result,
9172 __attribute__((unused)) struct cmdline *cl,
9173 __attribute__((unused)) void *data)
9175 struct cmd_syn_filter_result *res = parsed_result;
9176 struct rte_eth_syn_filter syn_filter;
9179 ret = rte_eth_dev_filter_supported(res->port_id,
9180 RTE_ETH_FILTER_SYN);
9182 printf("syn filter is not supported on port %u.\n",
9187 memset(&syn_filter, 0, sizeof(syn_filter));
9189 if (!strcmp(res->ops, "add")) {
9190 if (!strcmp(res->high, "high"))
9191 syn_filter.hig_pri = 1;
9193 syn_filter.hig_pri = 0;
9195 syn_filter.queue = res->queue_id;
9196 ret = rte_eth_dev_filter_ctrl(res->port_id,
9201 ret = rte_eth_dev_filter_ctrl(res->port_id,
9203 RTE_ETH_FILTER_DELETE,
9207 printf("syn filter programming error: (%s)\n",
9211 cmdline_parse_token_string_t cmd_syn_filter_filter =
9212 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9213 filter, "syn_filter");
9214 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9215 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9217 cmdline_parse_token_string_t cmd_syn_filter_ops =
9218 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9220 cmdline_parse_token_string_t cmd_syn_filter_priority =
9221 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9222 priority, "priority");
9223 cmdline_parse_token_string_t cmd_syn_filter_high =
9224 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9226 cmdline_parse_token_string_t cmd_syn_filter_queue =
9227 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9229 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9230 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9233 cmdline_parse_inst_t cmd_syn_filter = {
9234 .f = cmd_syn_filter_parsed,
9236 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9237 "<queue_id>: Add/Delete syn filter",
9239 (void *)&cmd_syn_filter_filter,
9240 (void *)&cmd_syn_filter_port_id,
9241 (void *)&cmd_syn_filter_ops,
9242 (void *)&cmd_syn_filter_priority,
9243 (void *)&cmd_syn_filter_high,
9244 (void *)&cmd_syn_filter_queue,
9245 (void *)&cmd_syn_filter_queue_id,
9250 /* *** queue region set *** */
9251 struct cmd_queue_region_result {
9252 cmdline_fixed_string_t set;
9253 cmdline_fixed_string_t port;
9255 cmdline_fixed_string_t cmd;
9256 cmdline_fixed_string_t region;
9258 cmdline_fixed_string_t queue_start_index;
9260 cmdline_fixed_string_t queue_num;
9261 uint8_t queue_num_value;
9265 cmd_queue_region_parsed(void *parsed_result,
9266 __attribute__((unused)) struct cmdline *cl,
9267 __attribute__((unused)) void *data)
9269 struct cmd_queue_region_result *res = parsed_result;
9271 #ifdef RTE_LIBRTE_I40E_PMD
9272 struct rte_pmd_i40e_queue_region_conf region_conf;
9273 enum rte_pmd_i40e_queue_region_op op_type;
9276 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9279 #ifdef RTE_LIBRTE_I40E_PMD
9280 memset(®ion_conf, 0, sizeof(region_conf));
9281 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9282 region_conf.region_id = res->region_id;
9283 region_conf.queue_num = res->queue_num_value;
9284 region_conf.queue_start_index = res->queue_id;
9286 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9287 op_type, ®ion_conf);
9294 printf("function not implemented or supported\n");
9297 printf("queue region config error: (%s)\n", strerror(-ret));
9301 cmdline_parse_token_string_t cmd_queue_region_set =
9302 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9304 cmdline_parse_token_string_t cmd_queue_region_port =
9305 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9306 cmdline_parse_token_num_t cmd_queue_region_port_id =
9307 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9309 cmdline_parse_token_string_t cmd_queue_region_cmd =
9310 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9311 cmd, "queue-region");
9312 cmdline_parse_token_string_t cmd_queue_region_id =
9313 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9314 region, "region_id");
9315 cmdline_parse_token_num_t cmd_queue_region_index =
9316 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9318 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9319 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9320 queue_start_index, "queue_start_index");
9321 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9322 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9324 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9325 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9326 queue_num, "queue_num");
9327 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9328 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9329 queue_num_value, UINT8);
9331 cmdline_parse_inst_t cmd_queue_region = {
9332 .f = cmd_queue_region_parsed,
9334 .help_str = "set port <port_id> queue-region region_id <value> "
9335 "queue_start_index <value> queue_num <value>: Set a queue region",
9337 (void *)&cmd_queue_region_set,
9338 (void *)&cmd_queue_region_port,
9339 (void *)&cmd_queue_region_port_id,
9340 (void *)&cmd_queue_region_cmd,
9341 (void *)&cmd_queue_region_id,
9342 (void *)&cmd_queue_region_index,
9343 (void *)&cmd_queue_region_queue_start_index,
9344 (void *)&cmd_queue_region_queue_id,
9345 (void *)&cmd_queue_region_queue_num,
9346 (void *)&cmd_queue_region_queue_num_value,
9351 /* *** queue region and flowtype set *** */
9352 struct cmd_region_flowtype_result {
9353 cmdline_fixed_string_t set;
9354 cmdline_fixed_string_t port;
9356 cmdline_fixed_string_t cmd;
9357 cmdline_fixed_string_t region;
9359 cmdline_fixed_string_t flowtype;
9360 uint8_t flowtype_id;
9364 cmd_region_flowtype_parsed(void *parsed_result,
9365 __attribute__((unused)) struct cmdline *cl,
9366 __attribute__((unused)) void *data)
9368 struct cmd_region_flowtype_result *res = parsed_result;
9370 #ifdef RTE_LIBRTE_I40E_PMD
9371 struct rte_pmd_i40e_queue_region_conf region_conf;
9372 enum rte_pmd_i40e_queue_region_op op_type;
9375 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9378 #ifdef RTE_LIBRTE_I40E_PMD
9379 memset(®ion_conf, 0, sizeof(region_conf));
9381 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9382 region_conf.region_id = res->region_id;
9383 region_conf.hw_flowtype = res->flowtype_id;
9385 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9386 op_type, ®ion_conf);
9393 printf("function not implemented or supported\n");
9396 printf("region flowtype config error: (%s)\n", strerror(-ret));
9400 cmdline_parse_token_string_t cmd_region_flowtype_set =
9401 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9403 cmdline_parse_token_string_t cmd_region_flowtype_port =
9404 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9406 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9407 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9409 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9410 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9411 cmd, "queue-region");
9412 cmdline_parse_token_string_t cmd_region_flowtype_index =
9413 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9414 region, "region_id");
9415 cmdline_parse_token_num_t cmd_region_flowtype_id =
9416 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9418 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9419 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9420 flowtype, "flowtype");
9421 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9422 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9423 flowtype_id, UINT8);
9424 cmdline_parse_inst_t cmd_region_flowtype = {
9425 .f = cmd_region_flowtype_parsed,
9427 .help_str = "set port <port_id> queue-region region_id <value> "
9428 "flowtype <value>: Set a flowtype region index",
9430 (void *)&cmd_region_flowtype_set,
9431 (void *)&cmd_region_flowtype_port,
9432 (void *)&cmd_region_flowtype_port_index,
9433 (void *)&cmd_region_flowtype_cmd,
9434 (void *)&cmd_region_flowtype_index,
9435 (void *)&cmd_region_flowtype_id,
9436 (void *)&cmd_region_flowtype_flow_index,
9437 (void *)&cmd_region_flowtype_flow_id,
9442 /* *** User Priority (UP) to queue region (region_id) set *** */
9443 struct cmd_user_priority_region_result {
9444 cmdline_fixed_string_t set;
9445 cmdline_fixed_string_t port;
9447 cmdline_fixed_string_t cmd;
9448 cmdline_fixed_string_t user_priority;
9449 uint8_t user_priority_id;
9450 cmdline_fixed_string_t region;
9455 cmd_user_priority_region_parsed(void *parsed_result,
9456 __attribute__((unused)) struct cmdline *cl,
9457 __attribute__((unused)) void *data)
9459 struct cmd_user_priority_region_result *res = parsed_result;
9461 #ifdef RTE_LIBRTE_I40E_PMD
9462 struct rte_pmd_i40e_queue_region_conf region_conf;
9463 enum rte_pmd_i40e_queue_region_op op_type;
9466 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9469 #ifdef RTE_LIBRTE_I40E_PMD
9470 memset(®ion_conf, 0, sizeof(region_conf));
9471 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9472 region_conf.user_priority = res->user_priority_id;
9473 region_conf.region_id = res->region_id;
9475 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9476 op_type, ®ion_conf);
9483 printf("function not implemented or supported\n");
9486 printf("user_priority region config error: (%s)\n",
9491 cmdline_parse_token_string_t cmd_user_priority_region_set =
9492 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9494 cmdline_parse_token_string_t cmd_user_priority_region_port =
9495 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9497 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9498 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9500 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9501 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9502 cmd, "queue-region");
9503 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9504 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9505 user_priority, "UP");
9506 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9507 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9508 user_priority_id, UINT8);
9509 cmdline_parse_token_string_t cmd_user_priority_region_region =
9510 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9511 region, "region_id");
9512 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9513 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9516 cmdline_parse_inst_t cmd_user_priority_region = {
9517 .f = cmd_user_priority_region_parsed,
9519 .help_str = "set port <port_id> queue-region UP <value> "
9520 "region_id <value>: Set the mapping of User Priority (UP) "
9521 "to queue region (region_id) ",
9523 (void *)&cmd_user_priority_region_set,
9524 (void *)&cmd_user_priority_region_port,
9525 (void *)&cmd_user_priority_region_port_index,
9526 (void *)&cmd_user_priority_region_cmd,
9527 (void *)&cmd_user_priority_region_UP,
9528 (void *)&cmd_user_priority_region_UP_id,
9529 (void *)&cmd_user_priority_region_region,
9530 (void *)&cmd_user_priority_region_region_id,
9535 /* *** flush all queue region related configuration *** */
9536 struct cmd_flush_queue_region_result {
9537 cmdline_fixed_string_t set;
9538 cmdline_fixed_string_t port;
9540 cmdline_fixed_string_t cmd;
9541 cmdline_fixed_string_t flush;
9542 cmdline_fixed_string_t what;
9546 cmd_flush_queue_region_parsed(void *parsed_result,
9547 __attribute__((unused)) struct cmdline *cl,
9548 __attribute__((unused)) void *data)
9550 struct cmd_flush_queue_region_result *res = parsed_result;
9552 #ifdef RTE_LIBRTE_I40E_PMD
9553 struct rte_pmd_i40e_queue_region_conf region_conf;
9554 enum rte_pmd_i40e_queue_region_op op_type;
9557 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9560 #ifdef RTE_LIBRTE_I40E_PMD
9561 memset(®ion_conf, 0, sizeof(region_conf));
9563 if (strcmp(res->what, "on") == 0)
9564 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9566 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9568 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9569 op_type, ®ion_conf);
9576 printf("function not implemented or supported\n");
9579 printf("queue region config flush error: (%s)\n",
9584 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9585 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9587 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9588 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9590 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9591 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9593 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9594 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9595 cmd, "queue-region");
9596 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9597 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9599 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9600 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9603 cmdline_parse_inst_t cmd_flush_queue_region = {
9604 .f = cmd_flush_queue_region_parsed,
9606 .help_str = "set port <port_id> queue-region flush on|off"
9607 ": flush all queue region related configuration",
9609 (void *)&cmd_flush_queue_region_set,
9610 (void *)&cmd_flush_queue_region_port,
9611 (void *)&cmd_flush_queue_region_port_index,
9612 (void *)&cmd_flush_queue_region_cmd,
9613 (void *)&cmd_flush_queue_region_flush,
9614 (void *)&cmd_flush_queue_region_what,
9619 /* *** get all queue region related configuration info *** */
9620 struct cmd_show_queue_region_info {
9621 cmdline_fixed_string_t show;
9622 cmdline_fixed_string_t port;
9624 cmdline_fixed_string_t cmd;
9628 cmd_show_queue_region_info_parsed(void *parsed_result,
9629 __attribute__((unused)) struct cmdline *cl,
9630 __attribute__((unused)) void *data)
9632 struct cmd_show_queue_region_info *res = parsed_result;
9634 #ifdef RTE_LIBRTE_I40E_PMD
9635 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9636 enum rte_pmd_i40e_queue_region_op op_type;
9639 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9642 #ifdef RTE_LIBRTE_I40E_PMD
9643 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9645 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9647 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9648 op_type, &rte_pmd_regions);
9650 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9657 printf("function not implemented or supported\n");
9660 printf("queue region config info show error: (%s)\n",
9665 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9666 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9668 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9669 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9671 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9672 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9674 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9675 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9676 cmd, "queue-region");
9678 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9679 .f = cmd_show_queue_region_info_parsed,
9681 .help_str = "show port <port_id> queue-region"
9682 ": show all queue region related configuration info",
9684 (void *)&cmd_show_queue_region_info_get,
9685 (void *)&cmd_show_queue_region_info_port,
9686 (void *)&cmd_show_queue_region_info_port_index,
9687 (void *)&cmd_show_queue_region_info_cmd,
9692 /* *** ADD/REMOVE A 2tuple FILTER *** */
9693 struct cmd_2tuple_filter_result {
9694 cmdline_fixed_string_t filter;
9696 cmdline_fixed_string_t ops;
9697 cmdline_fixed_string_t dst_port;
9698 uint16_t dst_port_value;
9699 cmdline_fixed_string_t protocol;
9700 uint8_t protocol_value;
9701 cmdline_fixed_string_t mask;
9703 cmdline_fixed_string_t tcp_flags;
9704 uint8_t tcp_flags_value;
9705 cmdline_fixed_string_t priority;
9706 uint8_t priority_value;
9707 cmdline_fixed_string_t queue;
9712 cmd_2tuple_filter_parsed(void *parsed_result,
9713 __attribute__((unused)) struct cmdline *cl,
9714 __attribute__((unused)) void *data)
9716 struct rte_eth_ntuple_filter filter;
9717 struct cmd_2tuple_filter_result *res = parsed_result;
9720 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9722 printf("ntuple filter is not supported on port %u.\n",
9727 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9729 filter.flags = RTE_2TUPLE_FLAGS;
9730 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9731 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9732 filter.proto = res->protocol_value;
9733 filter.priority = res->priority_value;
9734 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9735 printf("nonzero tcp_flags is only meaningful"
9736 " when protocol is TCP.\n");
9739 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9740 printf("invalid TCP flags.\n");
9744 if (res->tcp_flags_value != 0) {
9745 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9746 filter.tcp_flags = res->tcp_flags_value;
9749 /* need convert to big endian. */
9750 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9751 filter.queue = res->queue_id;
9753 if (!strcmp(res->ops, "add"))
9754 ret = rte_eth_dev_filter_ctrl(res->port_id,
9755 RTE_ETH_FILTER_NTUPLE,
9759 ret = rte_eth_dev_filter_ctrl(res->port_id,
9760 RTE_ETH_FILTER_NTUPLE,
9761 RTE_ETH_FILTER_DELETE,
9764 printf("2tuple filter programming error: (%s)\n",
9769 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9770 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9771 filter, "2tuple_filter");
9772 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9773 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9775 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9776 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9778 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9779 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9780 dst_port, "dst_port");
9781 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9782 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9783 dst_port_value, UINT16);
9784 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9785 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9786 protocol, "protocol");
9787 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9788 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9789 protocol_value, UINT8);
9790 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9791 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9793 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9794 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9796 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9797 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9798 tcp_flags, "tcp_flags");
9799 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9800 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9801 tcp_flags_value, UINT8);
9802 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9803 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9804 priority, "priority");
9805 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9806 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9807 priority_value, UINT8);
9808 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9809 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9811 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9812 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9815 cmdline_parse_inst_t cmd_2tuple_filter = {
9816 .f = cmd_2tuple_filter_parsed,
9818 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9819 "<value> mask <value> tcp_flags <value> priority <value> queue "
9820 "<queue_id>: Add a 2tuple filter",
9822 (void *)&cmd_2tuple_filter_filter,
9823 (void *)&cmd_2tuple_filter_port_id,
9824 (void *)&cmd_2tuple_filter_ops,
9825 (void *)&cmd_2tuple_filter_dst_port,
9826 (void *)&cmd_2tuple_filter_dst_port_value,
9827 (void *)&cmd_2tuple_filter_protocol,
9828 (void *)&cmd_2tuple_filter_protocol_value,
9829 (void *)&cmd_2tuple_filter_mask,
9830 (void *)&cmd_2tuple_filter_mask_value,
9831 (void *)&cmd_2tuple_filter_tcp_flags,
9832 (void *)&cmd_2tuple_filter_tcp_flags_value,
9833 (void *)&cmd_2tuple_filter_priority,
9834 (void *)&cmd_2tuple_filter_priority_value,
9835 (void *)&cmd_2tuple_filter_queue,
9836 (void *)&cmd_2tuple_filter_queue_id,
9841 /* *** ADD/REMOVE A 5tuple FILTER *** */
9842 struct cmd_5tuple_filter_result {
9843 cmdline_fixed_string_t filter;
9845 cmdline_fixed_string_t ops;
9846 cmdline_fixed_string_t dst_ip;
9847 cmdline_ipaddr_t dst_ip_value;
9848 cmdline_fixed_string_t src_ip;
9849 cmdline_ipaddr_t src_ip_value;
9850 cmdline_fixed_string_t dst_port;
9851 uint16_t dst_port_value;
9852 cmdline_fixed_string_t src_port;
9853 uint16_t src_port_value;
9854 cmdline_fixed_string_t protocol;
9855 uint8_t protocol_value;
9856 cmdline_fixed_string_t mask;
9858 cmdline_fixed_string_t tcp_flags;
9859 uint8_t tcp_flags_value;
9860 cmdline_fixed_string_t priority;
9861 uint8_t priority_value;
9862 cmdline_fixed_string_t queue;
9867 cmd_5tuple_filter_parsed(void *parsed_result,
9868 __attribute__((unused)) struct cmdline *cl,
9869 __attribute__((unused)) void *data)
9871 struct rte_eth_ntuple_filter filter;
9872 struct cmd_5tuple_filter_result *res = parsed_result;
9875 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9877 printf("ntuple filter is not supported on port %u.\n",
9882 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9884 filter.flags = RTE_5TUPLE_FLAGS;
9885 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9886 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9887 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9888 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9889 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9890 filter.proto = res->protocol_value;
9891 filter.priority = res->priority_value;
9892 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9893 printf("nonzero tcp_flags is only meaningful"
9894 " when protocol is TCP.\n");
9897 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9898 printf("invalid TCP flags.\n");
9902 if (res->tcp_flags_value != 0) {
9903 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9904 filter.tcp_flags = res->tcp_flags_value;
9907 if (res->dst_ip_value.family == AF_INET)
9908 /* no need to convert, already big endian. */
9909 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9911 if (filter.dst_ip_mask == 0) {
9912 printf("can not support ipv6 involved compare.\n");
9918 if (res->src_ip_value.family == AF_INET)
9919 /* no need to convert, already big endian. */
9920 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9922 if (filter.src_ip_mask == 0) {
9923 printf("can not support ipv6 involved compare.\n");
9928 /* need convert to big endian. */
9929 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9930 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9931 filter.queue = res->queue_id;
9933 if (!strcmp(res->ops, "add"))
9934 ret = rte_eth_dev_filter_ctrl(res->port_id,
9935 RTE_ETH_FILTER_NTUPLE,
9939 ret = rte_eth_dev_filter_ctrl(res->port_id,
9940 RTE_ETH_FILTER_NTUPLE,
9941 RTE_ETH_FILTER_DELETE,
9944 printf("5tuple filter programming error: (%s)\n",
9948 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9949 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9950 filter, "5tuple_filter");
9951 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9952 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9954 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9955 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9957 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9958 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9960 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9961 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9963 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9964 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9966 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9967 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9969 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9970 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9971 dst_port, "dst_port");
9972 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9973 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9974 dst_port_value, UINT16);
9975 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9976 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9977 src_port, "src_port");
9978 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9979 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9980 src_port_value, UINT16);
9981 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9982 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9983 protocol, "protocol");
9984 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9985 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9986 protocol_value, UINT8);
9987 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9988 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9990 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9991 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9993 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9994 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9995 tcp_flags, "tcp_flags");
9996 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9997 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9998 tcp_flags_value, UINT8);
9999 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10000 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10001 priority, "priority");
10002 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10003 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10004 priority_value, UINT8);
10005 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10006 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10008 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10009 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10012 cmdline_parse_inst_t cmd_5tuple_filter = {
10013 .f = cmd_5tuple_filter_parsed,
10015 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10016 "src_ip <value> dst_port <value> src_port <value> "
10017 "protocol <value> mask <value> tcp_flags <value> "
10018 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10020 (void *)&cmd_5tuple_filter_filter,
10021 (void *)&cmd_5tuple_filter_port_id,
10022 (void *)&cmd_5tuple_filter_ops,
10023 (void *)&cmd_5tuple_filter_dst_ip,
10024 (void *)&cmd_5tuple_filter_dst_ip_value,
10025 (void *)&cmd_5tuple_filter_src_ip,
10026 (void *)&cmd_5tuple_filter_src_ip_value,
10027 (void *)&cmd_5tuple_filter_dst_port,
10028 (void *)&cmd_5tuple_filter_dst_port_value,
10029 (void *)&cmd_5tuple_filter_src_port,
10030 (void *)&cmd_5tuple_filter_src_port_value,
10031 (void *)&cmd_5tuple_filter_protocol,
10032 (void *)&cmd_5tuple_filter_protocol_value,
10033 (void *)&cmd_5tuple_filter_mask,
10034 (void *)&cmd_5tuple_filter_mask_value,
10035 (void *)&cmd_5tuple_filter_tcp_flags,
10036 (void *)&cmd_5tuple_filter_tcp_flags_value,
10037 (void *)&cmd_5tuple_filter_priority,
10038 (void *)&cmd_5tuple_filter_priority_value,
10039 (void *)&cmd_5tuple_filter_queue,
10040 (void *)&cmd_5tuple_filter_queue_id,
10045 /* *** ADD/REMOVE A flex FILTER *** */
10046 struct cmd_flex_filter_result {
10047 cmdline_fixed_string_t filter;
10048 cmdline_fixed_string_t ops;
10050 cmdline_fixed_string_t len;
10052 cmdline_fixed_string_t bytes;
10053 cmdline_fixed_string_t bytes_value;
10054 cmdline_fixed_string_t mask;
10055 cmdline_fixed_string_t mask_value;
10056 cmdline_fixed_string_t priority;
10057 uint8_t priority_value;
10058 cmdline_fixed_string_t queue;
10062 static int xdigit2val(unsigned char c)
10067 else if (isupper(c))
10068 val = c - 'A' + 10;
10070 val = c - 'a' + 10;
10075 cmd_flex_filter_parsed(void *parsed_result,
10076 __attribute__((unused)) struct cmdline *cl,
10077 __attribute__((unused)) void *data)
10080 struct rte_eth_flex_filter filter;
10081 struct cmd_flex_filter_result *res = parsed_result;
10082 char *bytes_ptr, *mask_ptr;
10083 uint16_t len, i, j = 0;
10088 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10089 printf("the len exceed the max length 128\n");
10092 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10093 filter.len = res->len_value;
10094 filter.priority = res->priority_value;
10095 filter.queue = res->queue_id;
10096 bytes_ptr = res->bytes_value;
10097 mask_ptr = res->mask_value;
10099 /* translate bytes string to array. */
10100 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10101 (bytes_ptr[1] == 'X')))
10103 len = strnlen(bytes_ptr, res->len_value * 2);
10104 if (len == 0 || (len % 8 != 0)) {
10105 printf("please check len and bytes input\n");
10108 for (i = 0; i < len; i++) {
10110 if (isxdigit(c) == 0) {
10111 /* invalid characters. */
10112 printf("invalid input\n");
10115 val = xdigit2val(c);
10118 filter.bytes[j] = byte;
10119 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10126 /* translate mask string to uint8_t array. */
10127 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10128 (mask_ptr[1] == 'X')))
10130 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10132 printf("invalid input\n");
10137 for (i = 0; i < len; i++) {
10139 if (isxdigit(c) == 0) {
10140 /* invalid characters. */
10141 printf("invalid input\n");
10144 val = xdigit2val(c);
10147 filter.mask[j] = byte;
10148 printf("mask[%d]:%02x ", j, filter.mask[j]);
10156 if (!strcmp(res->ops, "add"))
10157 ret = rte_eth_dev_filter_ctrl(res->port_id,
10158 RTE_ETH_FILTER_FLEXIBLE,
10159 RTE_ETH_FILTER_ADD,
10162 ret = rte_eth_dev_filter_ctrl(res->port_id,
10163 RTE_ETH_FILTER_FLEXIBLE,
10164 RTE_ETH_FILTER_DELETE,
10168 printf("flex filter setting error: (%s)\n", strerror(-ret));
10171 cmdline_parse_token_string_t cmd_flex_filter_filter =
10172 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10173 filter, "flex_filter");
10174 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10175 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10177 cmdline_parse_token_string_t cmd_flex_filter_ops =
10178 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10180 cmdline_parse_token_string_t cmd_flex_filter_len =
10181 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10183 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10184 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10186 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10187 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10189 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10190 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10191 bytes_value, NULL);
10192 cmdline_parse_token_string_t cmd_flex_filter_mask =
10193 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10195 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10196 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10198 cmdline_parse_token_string_t cmd_flex_filter_priority =
10199 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10200 priority, "priority");
10201 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10202 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10203 priority_value, UINT8);
10204 cmdline_parse_token_string_t cmd_flex_filter_queue =
10205 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10207 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10208 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10210 cmdline_parse_inst_t cmd_flex_filter = {
10211 .f = cmd_flex_filter_parsed,
10213 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10214 "<value> mask <value> priority <value> queue <queue_id>: "
10215 "Add/Del a flex filter",
10217 (void *)&cmd_flex_filter_filter,
10218 (void *)&cmd_flex_filter_port_id,
10219 (void *)&cmd_flex_filter_ops,
10220 (void *)&cmd_flex_filter_len,
10221 (void *)&cmd_flex_filter_len_value,
10222 (void *)&cmd_flex_filter_bytes,
10223 (void *)&cmd_flex_filter_bytes_value,
10224 (void *)&cmd_flex_filter_mask,
10225 (void *)&cmd_flex_filter_mask_value,
10226 (void *)&cmd_flex_filter_priority,
10227 (void *)&cmd_flex_filter_priority_value,
10228 (void *)&cmd_flex_filter_queue,
10229 (void *)&cmd_flex_filter_queue_id,
10234 /* *** Filters Control *** */
10236 /* *** deal with ethertype filter *** */
10237 struct cmd_ethertype_filter_result {
10238 cmdline_fixed_string_t filter;
10240 cmdline_fixed_string_t ops;
10241 cmdline_fixed_string_t mac;
10242 struct ether_addr mac_addr;
10243 cmdline_fixed_string_t ethertype;
10244 uint16_t ethertype_value;
10245 cmdline_fixed_string_t drop;
10246 cmdline_fixed_string_t queue;
10250 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10251 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10252 filter, "ethertype_filter");
10253 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10254 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10256 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10257 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10259 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10260 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10261 mac, "mac_addr#mac_ignr");
10262 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10263 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10265 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10266 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10267 ethertype, "ethertype");
10268 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10269 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10270 ethertype_value, UINT16);
10271 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10272 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10274 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10275 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10277 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10278 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10282 cmd_ethertype_filter_parsed(void *parsed_result,
10283 __attribute__((unused)) struct cmdline *cl,
10284 __attribute__((unused)) void *data)
10286 struct cmd_ethertype_filter_result *res = parsed_result;
10287 struct rte_eth_ethertype_filter filter;
10290 ret = rte_eth_dev_filter_supported(res->port_id,
10291 RTE_ETH_FILTER_ETHERTYPE);
10293 printf("ethertype filter is not supported on port %u.\n",
10298 memset(&filter, 0, sizeof(filter));
10299 if (!strcmp(res->mac, "mac_addr")) {
10300 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10301 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10302 sizeof(struct ether_addr));
10304 if (!strcmp(res->drop, "drop"))
10305 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10306 filter.ether_type = res->ethertype_value;
10307 filter.queue = res->queue_id;
10309 if (!strcmp(res->ops, "add"))
10310 ret = rte_eth_dev_filter_ctrl(res->port_id,
10311 RTE_ETH_FILTER_ETHERTYPE,
10312 RTE_ETH_FILTER_ADD,
10315 ret = rte_eth_dev_filter_ctrl(res->port_id,
10316 RTE_ETH_FILTER_ETHERTYPE,
10317 RTE_ETH_FILTER_DELETE,
10320 printf("ethertype filter programming error: (%s)\n",
10324 cmdline_parse_inst_t cmd_ethertype_filter = {
10325 .f = cmd_ethertype_filter_parsed,
10327 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10328 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10329 "Add or delete an ethertype filter entry",
10331 (void *)&cmd_ethertype_filter_filter,
10332 (void *)&cmd_ethertype_filter_port_id,
10333 (void *)&cmd_ethertype_filter_ops,
10334 (void *)&cmd_ethertype_filter_mac,
10335 (void *)&cmd_ethertype_filter_mac_addr,
10336 (void *)&cmd_ethertype_filter_ethertype,
10337 (void *)&cmd_ethertype_filter_ethertype_value,
10338 (void *)&cmd_ethertype_filter_drop,
10339 (void *)&cmd_ethertype_filter_queue,
10340 (void *)&cmd_ethertype_filter_queue_id,
10345 /* *** deal with flow director filter *** */
10346 struct cmd_flow_director_result {
10347 cmdline_fixed_string_t flow_director_filter;
10349 cmdline_fixed_string_t mode;
10350 cmdline_fixed_string_t mode_value;
10351 cmdline_fixed_string_t ops;
10352 cmdline_fixed_string_t flow;
10353 cmdline_fixed_string_t flow_type;
10354 cmdline_fixed_string_t ether;
10355 uint16_t ether_type;
10356 cmdline_fixed_string_t src;
10357 cmdline_ipaddr_t ip_src;
10359 cmdline_fixed_string_t dst;
10360 cmdline_ipaddr_t ip_dst;
10362 cmdline_fixed_string_t verify_tag;
10363 uint32_t verify_tag_value;
10364 cmdline_fixed_string_t tos;
10366 cmdline_fixed_string_t proto;
10367 uint8_t proto_value;
10368 cmdline_fixed_string_t ttl;
10370 cmdline_fixed_string_t vlan;
10371 uint16_t vlan_value;
10372 cmdline_fixed_string_t flexbytes;
10373 cmdline_fixed_string_t flexbytes_value;
10374 cmdline_fixed_string_t pf_vf;
10375 cmdline_fixed_string_t drop;
10376 cmdline_fixed_string_t queue;
10378 cmdline_fixed_string_t fd_id;
10379 uint32_t fd_id_value;
10380 cmdline_fixed_string_t mac;
10381 struct ether_addr mac_addr;
10382 cmdline_fixed_string_t tunnel;
10383 cmdline_fixed_string_t tunnel_type;
10384 cmdline_fixed_string_t tunnel_id;
10385 uint32_t tunnel_id_value;
10386 cmdline_fixed_string_t packet;
10391 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10394 const char *p, *p0 = q_arg;
10396 unsigned long int_fld;
10397 char *str_fld[max_num];
10402 p = strchr(p0, '(');
10406 p0 = strchr(p, ')');
10411 if (size >= sizeof(s))
10414 snprintf(s, sizeof(s), "%.*s", size, p);
10415 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10416 if (ret < 0 || ret > max_num)
10418 for (i = 0; i < ret; i++) {
10420 int_fld = strtoul(str_fld[i], &end, 0);
10421 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10423 flexbytes[i] = (uint8_t)int_fld;
10429 str2flowtype(char *string)
10432 static const struct {
10435 } flowtype_str[] = {
10436 {"raw", RTE_ETH_FLOW_RAW},
10437 {"ipv4", RTE_ETH_FLOW_IPV4},
10438 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10439 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10440 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10441 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10442 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10443 {"ipv6", RTE_ETH_FLOW_IPV6},
10444 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10445 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10446 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10447 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10448 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10449 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10452 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10453 if (!strcmp(flowtype_str[i].str, string))
10454 return flowtype_str[i].type;
10457 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10458 return (uint16_t)atoi(string);
10460 return RTE_ETH_FLOW_UNKNOWN;
10463 static enum rte_eth_fdir_tunnel_type
10464 str2fdir_tunneltype(char *string)
10468 static const struct {
10470 enum rte_eth_fdir_tunnel_type type;
10471 } tunneltype_str[] = {
10472 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10473 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10476 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10477 if (!strcmp(tunneltype_str[i].str, string))
10478 return tunneltype_str[i].type;
10480 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10483 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10485 if ((ip_addr).family == AF_INET) \
10486 (ip) = (ip_addr).addr.ipv4.s_addr; \
10488 printf("invalid parameter.\n"); \
10493 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10495 if ((ip_addr).family == AF_INET6) \
10496 rte_memcpy(&(ip), \
10497 &((ip_addr).addr.ipv6), \
10498 sizeof(struct in6_addr)); \
10500 printf("invalid parameter.\n"); \
10506 cmd_flow_director_filter_parsed(void *parsed_result,
10507 __attribute__((unused)) struct cmdline *cl,
10508 __attribute__((unused)) void *data)
10510 struct cmd_flow_director_result *res = parsed_result;
10511 struct rte_eth_fdir_filter entry;
10512 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10514 unsigned long vf_id;
10517 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10519 printf("flow director is not supported on port %u.\n",
10523 memset(flexbytes, 0, sizeof(flexbytes));
10524 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10526 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10527 if (strcmp(res->mode_value, "MAC-VLAN")) {
10528 printf("Please set mode to MAC-VLAN.\n");
10531 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10532 if (strcmp(res->mode_value, "Tunnel")) {
10533 printf("Please set mode to Tunnel.\n");
10537 if (!strcmp(res->mode_value, "raw")) {
10538 #ifdef RTE_LIBRTE_I40E_PMD
10539 struct rte_pmd_i40e_flow_type_mapping
10540 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10541 struct rte_pmd_i40e_pkt_template_conf conf;
10542 uint16_t flow_type = str2flowtype(res->flow_type);
10543 uint16_t i, port = res->port_id;
10546 memset(&conf, 0, sizeof(conf));
10548 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10549 printf("Invalid flow type specified.\n");
10552 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10556 if (mapping[flow_type].pctype == 0ULL) {
10557 printf("Invalid flow type specified.\n");
10560 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10561 if (mapping[flow_type].pctype & (1ULL << i)) {
10562 conf.input.pctype = i;
10567 conf.input.packet = open_file(res->filepath,
10568 &conf.input.length);
10569 if (!conf.input.packet)
10571 if (!strcmp(res->drop, "drop"))
10572 conf.action.behavior =
10573 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10575 conf.action.behavior =
10576 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10577 conf.action.report_status =
10578 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10579 conf.action.rx_queue = res->queue_id;
10580 conf.soft_id = res->fd_id_value;
10581 add = strcmp(res->ops, "del") ? 1 : 0;
10582 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10586 printf("flow director config error: (%s)\n",
10588 close_file(conf.input.packet);
10591 } else if (strcmp(res->mode_value, "IP")) {
10592 printf("Please set mode to IP or raw.\n");
10595 entry.input.flow_type = str2flowtype(res->flow_type);
10598 ret = parse_flexbytes(res->flexbytes_value,
10600 RTE_ETH_FDIR_MAX_FLEXLEN);
10602 printf("error: Cannot parse flexbytes input.\n");
10606 switch (entry.input.flow_type) {
10607 case RTE_ETH_FLOW_FRAG_IPV4:
10608 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10609 entry.input.flow.ip4_flow.proto = res->proto_value;
10611 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10612 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10613 IPV4_ADDR_TO_UINT(res->ip_dst,
10614 entry.input.flow.ip4_flow.dst_ip);
10615 IPV4_ADDR_TO_UINT(res->ip_src,
10616 entry.input.flow.ip4_flow.src_ip);
10617 entry.input.flow.ip4_flow.tos = res->tos_value;
10618 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10619 /* need convert to big endian. */
10620 entry.input.flow.udp4_flow.dst_port =
10621 rte_cpu_to_be_16(res->port_dst);
10622 entry.input.flow.udp4_flow.src_port =
10623 rte_cpu_to_be_16(res->port_src);
10625 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10626 IPV4_ADDR_TO_UINT(res->ip_dst,
10627 entry.input.flow.sctp4_flow.ip.dst_ip);
10628 IPV4_ADDR_TO_UINT(res->ip_src,
10629 entry.input.flow.sctp4_flow.ip.src_ip);
10630 entry.input.flow.ip4_flow.tos = res->tos_value;
10631 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10632 /* need convert to big endian. */
10633 entry.input.flow.sctp4_flow.dst_port =
10634 rte_cpu_to_be_16(res->port_dst);
10635 entry.input.flow.sctp4_flow.src_port =
10636 rte_cpu_to_be_16(res->port_src);
10637 entry.input.flow.sctp4_flow.verify_tag =
10638 rte_cpu_to_be_32(res->verify_tag_value);
10640 case RTE_ETH_FLOW_FRAG_IPV6:
10641 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10642 entry.input.flow.ipv6_flow.proto = res->proto_value;
10644 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10645 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10646 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10647 entry.input.flow.ipv6_flow.dst_ip);
10648 IPV6_ADDR_TO_ARRAY(res->ip_src,
10649 entry.input.flow.ipv6_flow.src_ip);
10650 entry.input.flow.ipv6_flow.tc = res->tos_value;
10651 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10652 /* need convert to big endian. */
10653 entry.input.flow.udp6_flow.dst_port =
10654 rte_cpu_to_be_16(res->port_dst);
10655 entry.input.flow.udp6_flow.src_port =
10656 rte_cpu_to_be_16(res->port_src);
10658 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10659 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10660 entry.input.flow.sctp6_flow.ip.dst_ip);
10661 IPV6_ADDR_TO_ARRAY(res->ip_src,
10662 entry.input.flow.sctp6_flow.ip.src_ip);
10663 entry.input.flow.ipv6_flow.tc = res->tos_value;
10664 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10665 /* need convert to big endian. */
10666 entry.input.flow.sctp6_flow.dst_port =
10667 rte_cpu_to_be_16(res->port_dst);
10668 entry.input.flow.sctp6_flow.src_port =
10669 rte_cpu_to_be_16(res->port_src);
10670 entry.input.flow.sctp6_flow.verify_tag =
10671 rte_cpu_to_be_32(res->verify_tag_value);
10673 case RTE_ETH_FLOW_L2_PAYLOAD:
10674 entry.input.flow.l2_flow.ether_type =
10675 rte_cpu_to_be_16(res->ether_type);
10681 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10682 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10684 sizeof(struct ether_addr));
10686 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10687 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10689 sizeof(struct ether_addr));
10690 entry.input.flow.tunnel_flow.tunnel_type =
10691 str2fdir_tunneltype(res->tunnel_type);
10692 entry.input.flow.tunnel_flow.tunnel_id =
10693 rte_cpu_to_be_32(res->tunnel_id_value);
10696 rte_memcpy(entry.input.flow_ext.flexbytes,
10698 RTE_ETH_FDIR_MAX_FLEXLEN);
10700 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10702 entry.action.flex_off = 0; /*use 0 by default */
10703 if (!strcmp(res->drop, "drop"))
10704 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10706 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10708 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10709 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10710 if (!strcmp(res->pf_vf, "pf"))
10711 entry.input.flow_ext.is_vf = 0;
10712 else if (!strncmp(res->pf_vf, "vf", 2)) {
10713 struct rte_eth_dev_info dev_info;
10715 memset(&dev_info, 0, sizeof(dev_info));
10716 rte_eth_dev_info_get(res->port_id, &dev_info);
10718 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10719 if (errno != 0 || *end != '\0' ||
10720 vf_id >= dev_info.max_vfs) {
10721 printf("invalid parameter %s.\n", res->pf_vf);
10724 entry.input.flow_ext.is_vf = 1;
10725 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10727 printf("invalid parameter %s.\n", res->pf_vf);
10732 /* set to report FD ID by default */
10733 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10734 entry.action.rx_queue = res->queue_id;
10735 entry.soft_id = res->fd_id_value;
10736 if (!strcmp(res->ops, "add"))
10737 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10738 RTE_ETH_FILTER_ADD, &entry);
10739 else if (!strcmp(res->ops, "del"))
10740 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10741 RTE_ETH_FILTER_DELETE, &entry);
10743 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10744 RTE_ETH_FILTER_UPDATE, &entry);
10746 printf("flow director programming error: (%s)\n",
10750 cmdline_parse_token_string_t cmd_flow_director_filter =
10751 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10752 flow_director_filter, "flow_director_filter");
10753 cmdline_parse_token_num_t cmd_flow_director_port_id =
10754 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10756 cmdline_parse_token_string_t cmd_flow_director_ops =
10757 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10758 ops, "add#del#update");
10759 cmdline_parse_token_string_t cmd_flow_director_flow =
10760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10762 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10763 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10765 cmdline_parse_token_string_t cmd_flow_director_ether =
10766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10768 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10769 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10770 ether_type, UINT16);
10771 cmdline_parse_token_string_t cmd_flow_director_src =
10772 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10774 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10775 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10777 cmdline_parse_token_num_t cmd_flow_director_port_src =
10778 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10780 cmdline_parse_token_string_t cmd_flow_director_dst =
10781 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10783 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10784 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10786 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10787 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10789 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10791 verify_tag, "verify_tag");
10792 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10793 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10794 verify_tag_value, UINT32);
10795 cmdline_parse_token_string_t cmd_flow_director_tos =
10796 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10798 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10799 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10801 cmdline_parse_token_string_t cmd_flow_director_proto =
10802 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10804 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10805 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10806 proto_value, UINT8);
10807 cmdline_parse_token_string_t cmd_flow_director_ttl =
10808 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10810 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10811 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10813 cmdline_parse_token_string_t cmd_flow_director_vlan =
10814 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10816 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10817 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10818 vlan_value, UINT16);
10819 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10820 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10821 flexbytes, "flexbytes");
10822 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10824 flexbytes_value, NULL);
10825 cmdline_parse_token_string_t cmd_flow_director_drop =
10826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10828 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10829 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10831 cmdline_parse_token_string_t cmd_flow_director_queue =
10832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10834 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10835 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10837 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10838 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10840 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10841 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10842 fd_id_value, UINT32);
10844 cmdline_parse_token_string_t cmd_flow_director_mode =
10845 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10847 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10848 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10850 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10851 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10852 mode_value, "MAC-VLAN");
10853 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10854 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10855 mode_value, "Tunnel");
10856 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10857 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10858 mode_value, "raw");
10859 cmdline_parse_token_string_t cmd_flow_director_mac =
10860 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10862 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10863 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10865 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10866 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10868 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10870 tunnel_type, "NVGRE#VxLAN");
10871 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10873 tunnel_id, "tunnel-id");
10874 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10875 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10876 tunnel_id_value, UINT32);
10877 cmdline_parse_token_string_t cmd_flow_director_packet =
10878 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10880 cmdline_parse_token_string_t cmd_flow_director_filepath =
10881 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10884 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10885 .f = cmd_flow_director_filter_parsed,
10887 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10888 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10889 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10890 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10891 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10892 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10893 "fd_id <fd_id_value>: "
10894 "Add or delete an ip flow director entry on NIC",
10896 (void *)&cmd_flow_director_filter,
10897 (void *)&cmd_flow_director_port_id,
10898 (void *)&cmd_flow_director_mode,
10899 (void *)&cmd_flow_director_mode_ip,
10900 (void *)&cmd_flow_director_ops,
10901 (void *)&cmd_flow_director_flow,
10902 (void *)&cmd_flow_director_flow_type,
10903 (void *)&cmd_flow_director_src,
10904 (void *)&cmd_flow_director_ip_src,
10905 (void *)&cmd_flow_director_dst,
10906 (void *)&cmd_flow_director_ip_dst,
10907 (void *)&cmd_flow_director_tos,
10908 (void *)&cmd_flow_director_tos_value,
10909 (void *)&cmd_flow_director_proto,
10910 (void *)&cmd_flow_director_proto_value,
10911 (void *)&cmd_flow_director_ttl,
10912 (void *)&cmd_flow_director_ttl_value,
10913 (void *)&cmd_flow_director_vlan,
10914 (void *)&cmd_flow_director_vlan_value,
10915 (void *)&cmd_flow_director_flexbytes,
10916 (void *)&cmd_flow_director_flexbytes_value,
10917 (void *)&cmd_flow_director_drop,
10918 (void *)&cmd_flow_director_pf_vf,
10919 (void *)&cmd_flow_director_queue,
10920 (void *)&cmd_flow_director_queue_id,
10921 (void *)&cmd_flow_director_fd_id,
10922 (void *)&cmd_flow_director_fd_id_value,
10927 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10928 .f = cmd_flow_director_filter_parsed,
10930 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10931 "director entry on NIC",
10933 (void *)&cmd_flow_director_filter,
10934 (void *)&cmd_flow_director_port_id,
10935 (void *)&cmd_flow_director_mode,
10936 (void *)&cmd_flow_director_mode_ip,
10937 (void *)&cmd_flow_director_ops,
10938 (void *)&cmd_flow_director_flow,
10939 (void *)&cmd_flow_director_flow_type,
10940 (void *)&cmd_flow_director_src,
10941 (void *)&cmd_flow_director_ip_src,
10942 (void *)&cmd_flow_director_port_src,
10943 (void *)&cmd_flow_director_dst,
10944 (void *)&cmd_flow_director_ip_dst,
10945 (void *)&cmd_flow_director_port_dst,
10946 (void *)&cmd_flow_director_tos,
10947 (void *)&cmd_flow_director_tos_value,
10948 (void *)&cmd_flow_director_ttl,
10949 (void *)&cmd_flow_director_ttl_value,
10950 (void *)&cmd_flow_director_vlan,
10951 (void *)&cmd_flow_director_vlan_value,
10952 (void *)&cmd_flow_director_flexbytes,
10953 (void *)&cmd_flow_director_flexbytes_value,
10954 (void *)&cmd_flow_director_drop,
10955 (void *)&cmd_flow_director_pf_vf,
10956 (void *)&cmd_flow_director_queue,
10957 (void *)&cmd_flow_director_queue_id,
10958 (void *)&cmd_flow_director_fd_id,
10959 (void *)&cmd_flow_director_fd_id_value,
10964 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10965 .f = cmd_flow_director_filter_parsed,
10967 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10968 "director entry on NIC",
10970 (void *)&cmd_flow_director_filter,
10971 (void *)&cmd_flow_director_port_id,
10972 (void *)&cmd_flow_director_mode,
10973 (void *)&cmd_flow_director_mode_ip,
10974 (void *)&cmd_flow_director_ops,
10975 (void *)&cmd_flow_director_flow,
10976 (void *)&cmd_flow_director_flow_type,
10977 (void *)&cmd_flow_director_src,
10978 (void *)&cmd_flow_director_ip_src,
10979 (void *)&cmd_flow_director_port_src,
10980 (void *)&cmd_flow_director_dst,
10981 (void *)&cmd_flow_director_ip_dst,
10982 (void *)&cmd_flow_director_port_dst,
10983 (void *)&cmd_flow_director_verify_tag,
10984 (void *)&cmd_flow_director_verify_tag_value,
10985 (void *)&cmd_flow_director_tos,
10986 (void *)&cmd_flow_director_tos_value,
10987 (void *)&cmd_flow_director_ttl,
10988 (void *)&cmd_flow_director_ttl_value,
10989 (void *)&cmd_flow_director_vlan,
10990 (void *)&cmd_flow_director_vlan_value,
10991 (void *)&cmd_flow_director_flexbytes,
10992 (void *)&cmd_flow_director_flexbytes_value,
10993 (void *)&cmd_flow_director_drop,
10994 (void *)&cmd_flow_director_pf_vf,
10995 (void *)&cmd_flow_director_queue,
10996 (void *)&cmd_flow_director_queue_id,
10997 (void *)&cmd_flow_director_fd_id,
10998 (void *)&cmd_flow_director_fd_id_value,
11003 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11004 .f = cmd_flow_director_filter_parsed,
11006 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11007 "director entry on NIC",
11009 (void *)&cmd_flow_director_filter,
11010 (void *)&cmd_flow_director_port_id,
11011 (void *)&cmd_flow_director_mode,
11012 (void *)&cmd_flow_director_mode_ip,
11013 (void *)&cmd_flow_director_ops,
11014 (void *)&cmd_flow_director_flow,
11015 (void *)&cmd_flow_director_flow_type,
11016 (void *)&cmd_flow_director_ether,
11017 (void *)&cmd_flow_director_ether_type,
11018 (void *)&cmd_flow_director_flexbytes,
11019 (void *)&cmd_flow_director_flexbytes_value,
11020 (void *)&cmd_flow_director_drop,
11021 (void *)&cmd_flow_director_pf_vf,
11022 (void *)&cmd_flow_director_queue,
11023 (void *)&cmd_flow_director_queue_id,
11024 (void *)&cmd_flow_director_fd_id,
11025 (void *)&cmd_flow_director_fd_id_value,
11030 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11031 .f = cmd_flow_director_filter_parsed,
11033 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11034 "director entry on NIC",
11036 (void *)&cmd_flow_director_filter,
11037 (void *)&cmd_flow_director_port_id,
11038 (void *)&cmd_flow_director_mode,
11039 (void *)&cmd_flow_director_mode_mac_vlan,
11040 (void *)&cmd_flow_director_ops,
11041 (void *)&cmd_flow_director_mac,
11042 (void *)&cmd_flow_director_mac_addr,
11043 (void *)&cmd_flow_director_vlan,
11044 (void *)&cmd_flow_director_vlan_value,
11045 (void *)&cmd_flow_director_flexbytes,
11046 (void *)&cmd_flow_director_flexbytes_value,
11047 (void *)&cmd_flow_director_drop,
11048 (void *)&cmd_flow_director_queue,
11049 (void *)&cmd_flow_director_queue_id,
11050 (void *)&cmd_flow_director_fd_id,
11051 (void *)&cmd_flow_director_fd_id_value,
11056 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11057 .f = cmd_flow_director_filter_parsed,
11059 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11060 "director entry on NIC",
11062 (void *)&cmd_flow_director_filter,
11063 (void *)&cmd_flow_director_port_id,
11064 (void *)&cmd_flow_director_mode,
11065 (void *)&cmd_flow_director_mode_tunnel,
11066 (void *)&cmd_flow_director_ops,
11067 (void *)&cmd_flow_director_mac,
11068 (void *)&cmd_flow_director_mac_addr,
11069 (void *)&cmd_flow_director_vlan,
11070 (void *)&cmd_flow_director_vlan_value,
11071 (void *)&cmd_flow_director_tunnel,
11072 (void *)&cmd_flow_director_tunnel_type,
11073 (void *)&cmd_flow_director_tunnel_id,
11074 (void *)&cmd_flow_director_tunnel_id_value,
11075 (void *)&cmd_flow_director_flexbytes,
11076 (void *)&cmd_flow_director_flexbytes_value,
11077 (void *)&cmd_flow_director_drop,
11078 (void *)&cmd_flow_director_queue,
11079 (void *)&cmd_flow_director_queue_id,
11080 (void *)&cmd_flow_director_fd_id,
11081 (void *)&cmd_flow_director_fd_id_value,
11086 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11087 .f = cmd_flow_director_filter_parsed,
11089 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11090 "director entry on NIC",
11092 (void *)&cmd_flow_director_filter,
11093 (void *)&cmd_flow_director_port_id,
11094 (void *)&cmd_flow_director_mode,
11095 (void *)&cmd_flow_director_mode_raw,
11096 (void *)&cmd_flow_director_ops,
11097 (void *)&cmd_flow_director_flow,
11098 (void *)&cmd_flow_director_flow_type,
11099 (void *)&cmd_flow_director_drop,
11100 (void *)&cmd_flow_director_queue,
11101 (void *)&cmd_flow_director_queue_id,
11102 (void *)&cmd_flow_director_fd_id,
11103 (void *)&cmd_flow_director_fd_id_value,
11104 (void *)&cmd_flow_director_packet,
11105 (void *)&cmd_flow_director_filepath,
11110 struct cmd_flush_flow_director_result {
11111 cmdline_fixed_string_t flush_flow_director;
11115 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11116 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11117 flush_flow_director, "flush_flow_director");
11118 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11119 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11123 cmd_flush_flow_director_parsed(void *parsed_result,
11124 __attribute__((unused)) struct cmdline *cl,
11125 __attribute__((unused)) void *data)
11127 struct cmd_flow_director_result *res = parsed_result;
11130 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11132 printf("flow director is not supported on port %u.\n",
11137 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11138 RTE_ETH_FILTER_FLUSH, NULL);
11140 printf("flow director table flushing error: (%s)\n",
11144 cmdline_parse_inst_t cmd_flush_flow_director = {
11145 .f = cmd_flush_flow_director_parsed,
11147 .help_str = "flush_flow_director <port_id>: "
11148 "Flush all flow director entries of a device on NIC",
11150 (void *)&cmd_flush_flow_director_flush,
11151 (void *)&cmd_flush_flow_director_port_id,
11156 /* *** deal with flow director mask *** */
11157 struct cmd_flow_director_mask_result {
11158 cmdline_fixed_string_t flow_director_mask;
11160 cmdline_fixed_string_t mode;
11161 cmdline_fixed_string_t mode_value;
11162 cmdline_fixed_string_t vlan;
11163 uint16_t vlan_mask;
11164 cmdline_fixed_string_t src_mask;
11165 cmdline_ipaddr_t ipv4_src;
11166 cmdline_ipaddr_t ipv6_src;
11168 cmdline_fixed_string_t dst_mask;
11169 cmdline_ipaddr_t ipv4_dst;
11170 cmdline_ipaddr_t ipv6_dst;
11172 cmdline_fixed_string_t mac;
11173 uint8_t mac_addr_byte_mask;
11174 cmdline_fixed_string_t tunnel_id;
11175 uint32_t tunnel_id_mask;
11176 cmdline_fixed_string_t tunnel_type;
11177 uint8_t tunnel_type_mask;
11181 cmd_flow_director_mask_parsed(void *parsed_result,
11182 __attribute__((unused)) struct cmdline *cl,
11183 __attribute__((unused)) void *data)
11185 struct cmd_flow_director_mask_result *res = parsed_result;
11186 struct rte_eth_fdir_masks *mask;
11187 struct rte_port *port;
11189 port = &ports[res->port_id];
11190 /** Check if the port is not started **/
11191 if (port->port_status != RTE_PORT_STOPPED) {
11192 printf("Please stop port %d first\n", res->port_id);
11196 mask = &port->dev_conf.fdir_conf.mask;
11198 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11199 if (strcmp(res->mode_value, "MAC-VLAN")) {
11200 printf("Please set mode to MAC-VLAN.\n");
11204 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11205 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11206 if (strcmp(res->mode_value, "Tunnel")) {
11207 printf("Please set mode to Tunnel.\n");
11211 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11212 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11213 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11214 mask->tunnel_type_mask = res->tunnel_type_mask;
11216 if (strcmp(res->mode_value, "IP")) {
11217 printf("Please set mode to IP.\n");
11221 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11222 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11223 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11224 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11225 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11226 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11227 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11230 cmd_reconfig_device_queue(res->port_id, 1, 1);
11233 cmdline_parse_token_string_t cmd_flow_director_mask =
11234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11235 flow_director_mask, "flow_director_mask");
11236 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11237 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11239 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11242 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11243 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11244 vlan_mask, UINT16);
11245 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11247 src_mask, "src_mask");
11248 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11249 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11251 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11252 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11254 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11255 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11257 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11259 dst_mask, "dst_mask");
11260 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11261 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11263 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11264 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11266 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11267 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11270 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11273 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11276 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11278 mode_value, "MAC-VLAN");
11279 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11281 mode_value, "Tunnel");
11282 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11285 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11286 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11287 mac_addr_byte_mask, UINT8);
11288 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11290 tunnel_type, "tunnel-type");
11291 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11292 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11293 tunnel_type_mask, UINT8);
11294 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11296 tunnel_id, "tunnel-id");
11297 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11298 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11299 tunnel_id_mask, UINT32);
11301 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11302 .f = cmd_flow_director_mask_parsed,
11304 .help_str = "flow_director_mask ... : "
11305 "Set IP mode flow director's mask on NIC",
11307 (void *)&cmd_flow_director_mask,
11308 (void *)&cmd_flow_director_mask_port_id,
11309 (void *)&cmd_flow_director_mask_mode,
11310 (void *)&cmd_flow_director_mask_mode_ip,
11311 (void *)&cmd_flow_director_mask_vlan,
11312 (void *)&cmd_flow_director_mask_vlan_value,
11313 (void *)&cmd_flow_director_mask_src,
11314 (void *)&cmd_flow_director_mask_ipv4_src,
11315 (void *)&cmd_flow_director_mask_ipv6_src,
11316 (void *)&cmd_flow_director_mask_port_src,
11317 (void *)&cmd_flow_director_mask_dst,
11318 (void *)&cmd_flow_director_mask_ipv4_dst,
11319 (void *)&cmd_flow_director_mask_ipv6_dst,
11320 (void *)&cmd_flow_director_mask_port_dst,
11325 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11326 .f = cmd_flow_director_mask_parsed,
11328 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11329 "flow director's mask on NIC",
11331 (void *)&cmd_flow_director_mask,
11332 (void *)&cmd_flow_director_mask_port_id,
11333 (void *)&cmd_flow_director_mask_mode,
11334 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11335 (void *)&cmd_flow_director_mask_vlan,
11336 (void *)&cmd_flow_director_mask_vlan_value,
11341 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11342 .f = cmd_flow_director_mask_parsed,
11344 .help_str = "flow_director_mask ... : Set tunnel mode "
11345 "flow director's mask on NIC",
11347 (void *)&cmd_flow_director_mask,
11348 (void *)&cmd_flow_director_mask_port_id,
11349 (void *)&cmd_flow_director_mask_mode,
11350 (void *)&cmd_flow_director_mask_mode_tunnel,
11351 (void *)&cmd_flow_director_mask_vlan,
11352 (void *)&cmd_flow_director_mask_vlan_value,
11353 (void *)&cmd_flow_director_mask_mac,
11354 (void *)&cmd_flow_director_mask_mac_value,
11355 (void *)&cmd_flow_director_mask_tunnel_type,
11356 (void *)&cmd_flow_director_mask_tunnel_type_value,
11357 (void *)&cmd_flow_director_mask_tunnel_id,
11358 (void *)&cmd_flow_director_mask_tunnel_id_value,
11363 /* *** deal with flow director mask on flexible payload *** */
11364 struct cmd_flow_director_flex_mask_result {
11365 cmdline_fixed_string_t flow_director_flexmask;
11367 cmdline_fixed_string_t flow;
11368 cmdline_fixed_string_t flow_type;
11369 cmdline_fixed_string_t mask;
11373 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11374 __attribute__((unused)) struct cmdline *cl,
11375 __attribute__((unused)) void *data)
11377 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11378 struct rte_eth_fdir_info fdir_info;
11379 struct rte_eth_fdir_flex_mask flex_mask;
11380 struct rte_port *port;
11381 uint64_t flow_type_mask;
11385 port = &ports[res->port_id];
11386 /** Check if the port is not started **/
11387 if (port->port_status != RTE_PORT_STOPPED) {
11388 printf("Please stop port %d first\n", res->port_id);
11392 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11393 ret = parse_flexbytes(res->mask,
11395 RTE_ETH_FDIR_MAX_FLEXLEN);
11397 printf("error: Cannot parse mask input.\n");
11401 memset(&fdir_info, 0, sizeof(fdir_info));
11402 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11403 RTE_ETH_FILTER_INFO, &fdir_info);
11405 printf("Cannot get FDir filter info\n");
11409 if (!strcmp(res->flow_type, "none")) {
11410 /* means don't specify the flow type */
11411 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11412 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11413 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11414 0, sizeof(struct rte_eth_fdir_flex_mask));
11415 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11416 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11418 sizeof(struct rte_eth_fdir_flex_mask));
11419 cmd_reconfig_device_queue(res->port_id, 1, 1);
11422 flow_type_mask = fdir_info.flow_types_mask[0];
11423 if (!strcmp(res->flow_type, "all")) {
11424 if (!flow_type_mask) {
11425 printf("No flow type supported\n");
11428 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11429 if (flow_type_mask & (1ULL << i)) {
11430 flex_mask.flow_type = i;
11431 fdir_set_flex_mask(res->port_id, &flex_mask);
11434 cmd_reconfig_device_queue(res->port_id, 1, 1);
11437 flex_mask.flow_type = str2flowtype(res->flow_type);
11438 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11439 printf("Flow type %s not supported on port %d\n",
11440 res->flow_type, res->port_id);
11443 fdir_set_flex_mask(res->port_id, &flex_mask);
11444 cmd_reconfig_device_queue(res->port_id, 1, 1);
11447 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11449 flow_director_flexmask,
11450 "flow_director_flex_mask");
11451 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11452 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11454 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11455 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11457 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11458 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11459 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11460 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11461 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11462 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11465 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11466 .f = cmd_flow_director_flex_mask_parsed,
11468 .help_str = "flow_director_flex_mask ... : "
11469 "Set flow director's flex mask on NIC",
11471 (void *)&cmd_flow_director_flexmask,
11472 (void *)&cmd_flow_director_flexmask_port_id,
11473 (void *)&cmd_flow_director_flexmask_flow,
11474 (void *)&cmd_flow_director_flexmask_flow_type,
11475 (void *)&cmd_flow_director_flexmask_mask,
11480 /* *** deal with flow director flexible payload configuration *** */
11481 struct cmd_flow_director_flexpayload_result {
11482 cmdline_fixed_string_t flow_director_flexpayload;
11484 cmdline_fixed_string_t payload_layer;
11485 cmdline_fixed_string_t payload_cfg;
11489 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11492 const char *p, *p0 = q_arg;
11494 unsigned long int_fld;
11495 char *str_fld[max_num];
11500 p = strchr(p0, '(');
11504 p0 = strchr(p, ')');
11509 if (size >= sizeof(s))
11512 snprintf(s, sizeof(s), "%.*s", size, p);
11513 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11514 if (ret < 0 || ret > max_num)
11516 for (i = 0; i < ret; i++) {
11518 int_fld = strtoul(str_fld[i], &end, 0);
11519 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11521 offsets[i] = (uint16_t)int_fld;
11527 cmd_flow_director_flxpld_parsed(void *parsed_result,
11528 __attribute__((unused)) struct cmdline *cl,
11529 __attribute__((unused)) void *data)
11531 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11532 struct rte_eth_flex_payload_cfg flex_cfg;
11533 struct rte_port *port;
11536 port = &ports[res->port_id];
11537 /** Check if the port is not started **/
11538 if (port->port_status != RTE_PORT_STOPPED) {
11539 printf("Please stop port %d first\n", res->port_id);
11543 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11545 if (!strcmp(res->payload_layer, "raw"))
11546 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11547 else if (!strcmp(res->payload_layer, "l2"))
11548 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11549 else if (!strcmp(res->payload_layer, "l3"))
11550 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11551 else if (!strcmp(res->payload_layer, "l4"))
11552 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11554 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11555 RTE_ETH_FDIR_MAX_FLEXLEN);
11557 printf("error: Cannot parse flex payload input.\n");
11561 fdir_set_flex_payload(res->port_id, &flex_cfg);
11562 cmd_reconfig_device_queue(res->port_id, 1, 1);
11565 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11567 flow_director_flexpayload,
11568 "flow_director_flex_payload");
11569 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11570 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11572 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11574 payload_layer, "raw#l2#l3#l4");
11575 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11576 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11577 payload_cfg, NULL);
11579 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11580 .f = cmd_flow_director_flxpld_parsed,
11582 .help_str = "flow_director_flexpayload ... : "
11583 "Set flow director's flex payload on NIC",
11585 (void *)&cmd_flow_director_flexpayload,
11586 (void *)&cmd_flow_director_flexpayload_port_id,
11587 (void *)&cmd_flow_director_flexpayload_payload_layer,
11588 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11593 /* Generic flow interface command. */
11594 extern cmdline_parse_inst_t cmd_flow;
11596 /* *** Classification Filters Control *** */
11597 /* *** Get symmetric hash enable per port *** */
11598 struct cmd_get_sym_hash_ena_per_port_result {
11599 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11604 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11605 __rte_unused struct cmdline *cl,
11606 __rte_unused void *data)
11608 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11609 struct rte_eth_hash_filter_info info;
11612 if (rte_eth_dev_filter_supported(res->port_id,
11613 RTE_ETH_FILTER_HASH) < 0) {
11614 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11619 memset(&info, 0, sizeof(info));
11620 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11621 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11622 RTE_ETH_FILTER_GET, &info);
11625 printf("Cannot get symmetric hash enable per port "
11626 "on port %u\n", res->port_id);
11630 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11631 "enabled" : "disabled", res->port_id);
11634 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11635 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11636 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11637 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11638 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11641 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11642 .f = cmd_get_sym_hash_per_port_parsed,
11644 .help_str = "get_sym_hash_ena_per_port <port_id>",
11646 (void *)&cmd_get_sym_hash_ena_per_port_all,
11647 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11652 /* *** Set symmetric hash enable per port *** */
11653 struct cmd_set_sym_hash_ena_per_port_result {
11654 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11655 cmdline_fixed_string_t enable;
11660 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11661 __rte_unused struct cmdline *cl,
11662 __rte_unused void *data)
11664 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11665 struct rte_eth_hash_filter_info info;
11668 if (rte_eth_dev_filter_supported(res->port_id,
11669 RTE_ETH_FILTER_HASH) < 0) {
11670 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11675 memset(&info, 0, sizeof(info));
11676 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11677 if (!strcmp(res->enable, "enable"))
11678 info.info.enable = 1;
11679 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11680 RTE_ETH_FILTER_SET, &info);
11682 printf("Cannot set symmetric hash enable per port on "
11683 "port %u\n", res->port_id);
11686 printf("Symmetric hash has been set to %s on port %u\n",
11687 res->enable, res->port_id);
11690 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11691 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11692 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11693 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11694 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11696 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11697 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11698 enable, "enable#disable");
11700 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11701 .f = cmd_set_sym_hash_per_port_parsed,
11703 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11705 (void *)&cmd_set_sym_hash_ena_per_port_all,
11706 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11707 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11712 /* Get global config of hash function */
11713 struct cmd_get_hash_global_config_result {
11714 cmdline_fixed_string_t get_hash_global_config;
11719 flowtype_to_str(uint16_t ftype)
11725 } ftype_table[] = {
11726 {"ipv4", RTE_ETH_FLOW_IPV4},
11727 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11728 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11729 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11730 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11731 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11732 {"ipv6", RTE_ETH_FLOW_IPV6},
11733 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11734 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11735 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11736 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11737 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11738 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11739 {"port", RTE_ETH_FLOW_PORT},
11740 {"vxlan", RTE_ETH_FLOW_VXLAN},
11741 {"geneve", RTE_ETH_FLOW_GENEVE},
11742 {"nvgre", RTE_ETH_FLOW_NVGRE},
11745 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11746 if (ftype_table[i].ftype == ftype)
11747 return ftype_table[i].str;
11754 cmd_get_hash_global_config_parsed(void *parsed_result,
11755 __rte_unused struct cmdline *cl,
11756 __rte_unused void *data)
11758 struct cmd_get_hash_global_config_result *res = parsed_result;
11759 struct rte_eth_hash_filter_info info;
11760 uint32_t idx, offset;
11765 if (rte_eth_dev_filter_supported(res->port_id,
11766 RTE_ETH_FILTER_HASH) < 0) {
11767 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11772 memset(&info, 0, sizeof(info));
11773 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11774 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11775 RTE_ETH_FILTER_GET, &info);
11777 printf("Cannot get hash global configurations by port %d\n",
11782 switch (info.info.global_conf.hash_func) {
11783 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11784 printf("Hash function is Toeplitz\n");
11786 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11787 printf("Hash function is Simple XOR\n");
11790 printf("Unknown hash function\n");
11794 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11795 idx = i / UINT64_BIT;
11796 offset = i % UINT64_BIT;
11797 if (!(info.info.global_conf.valid_bit_mask[idx] &
11800 str = flowtype_to_str(i);
11803 printf("Symmetric hash is %s globally for flow type %s "
11805 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11806 (1ULL << offset)) ? "enabled" : "disabled"), str,
11811 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11812 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11813 get_hash_global_config, "get_hash_global_config");
11814 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11815 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11818 cmdline_parse_inst_t cmd_get_hash_global_config = {
11819 .f = cmd_get_hash_global_config_parsed,
11821 .help_str = "get_hash_global_config <port_id>",
11823 (void *)&cmd_get_hash_global_config_all,
11824 (void *)&cmd_get_hash_global_config_port_id,
11829 /* Set global config of hash function */
11830 struct cmd_set_hash_global_config_result {
11831 cmdline_fixed_string_t set_hash_global_config;
11833 cmdline_fixed_string_t hash_func;
11834 cmdline_fixed_string_t flow_type;
11835 cmdline_fixed_string_t enable;
11839 cmd_set_hash_global_config_parsed(void *parsed_result,
11840 __rte_unused struct cmdline *cl,
11841 __rte_unused void *data)
11843 struct cmd_set_hash_global_config_result *res = parsed_result;
11844 struct rte_eth_hash_filter_info info;
11845 uint32_t ftype, idx, offset;
11848 if (rte_eth_dev_filter_supported(res->port_id,
11849 RTE_ETH_FILTER_HASH) < 0) {
11850 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11854 memset(&info, 0, sizeof(info));
11855 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11856 if (!strcmp(res->hash_func, "toeplitz"))
11857 info.info.global_conf.hash_func =
11858 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11859 else if (!strcmp(res->hash_func, "simple_xor"))
11860 info.info.global_conf.hash_func =
11861 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11862 else if (!strcmp(res->hash_func, "default"))
11863 info.info.global_conf.hash_func =
11864 RTE_ETH_HASH_FUNCTION_DEFAULT;
11866 ftype = str2flowtype(res->flow_type);
11867 idx = ftype / UINT64_BIT;
11868 offset = ftype % UINT64_BIT;
11869 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11870 if (!strcmp(res->enable, "enable"))
11871 info.info.global_conf.sym_hash_enable_mask[idx] |=
11873 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11874 RTE_ETH_FILTER_SET, &info);
11876 printf("Cannot set global hash configurations by port %d\n",
11879 printf("Global hash configurations have been set "
11880 "succcessfully by port %d\n", res->port_id);
11883 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11884 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11885 set_hash_global_config, "set_hash_global_config");
11886 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11887 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11889 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11890 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11891 hash_func, "toeplitz#simple_xor#default");
11892 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11893 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11895 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11896 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11897 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11898 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11899 enable, "enable#disable");
11901 cmdline_parse_inst_t cmd_set_hash_global_config = {
11902 .f = cmd_set_hash_global_config_parsed,
11904 .help_str = "set_hash_global_config <port_id> "
11905 "toeplitz|simple_xor|default "
11906 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11907 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11908 "l2_payload enable|disable",
11910 (void *)&cmd_set_hash_global_config_all,
11911 (void *)&cmd_set_hash_global_config_port_id,
11912 (void *)&cmd_set_hash_global_config_hash_func,
11913 (void *)&cmd_set_hash_global_config_flow_type,
11914 (void *)&cmd_set_hash_global_config_enable,
11919 /* Set hash input set */
11920 struct cmd_set_hash_input_set_result {
11921 cmdline_fixed_string_t set_hash_input_set;
11923 cmdline_fixed_string_t flow_type;
11924 cmdline_fixed_string_t inset_field;
11925 cmdline_fixed_string_t select;
11928 static enum rte_eth_input_set_field
11929 str2inset(char *string)
11933 static const struct {
11935 enum rte_eth_input_set_field inset;
11936 } inset_table[] = {
11937 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11938 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11939 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11940 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11941 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11942 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11943 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11944 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11945 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11946 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11947 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11948 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11949 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11950 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11951 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11952 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11953 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11954 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11955 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11956 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11957 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11958 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11959 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11960 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11961 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11962 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11963 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11964 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11965 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11966 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11967 {"none", RTE_ETH_INPUT_SET_NONE},
11970 for (i = 0; i < RTE_DIM(inset_table); i++) {
11971 if (!strcmp(string, inset_table[i].str))
11972 return inset_table[i].inset;
11975 return RTE_ETH_INPUT_SET_UNKNOWN;
11979 cmd_set_hash_input_set_parsed(void *parsed_result,
11980 __rte_unused struct cmdline *cl,
11981 __rte_unused void *data)
11983 struct cmd_set_hash_input_set_result *res = parsed_result;
11984 struct rte_eth_hash_filter_info info;
11986 memset(&info, 0, sizeof(info));
11987 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11988 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11989 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11990 info.info.input_set_conf.inset_size = 1;
11991 if (!strcmp(res->select, "select"))
11992 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11993 else if (!strcmp(res->select, "add"))
11994 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11995 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11996 RTE_ETH_FILTER_SET, &info);
11999 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12000 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12001 set_hash_input_set, "set_hash_input_set");
12002 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12003 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12005 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12006 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12008 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12009 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12011 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12012 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12013 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12014 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12015 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12017 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12018 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12019 select, "select#add");
12021 cmdline_parse_inst_t cmd_set_hash_input_set = {
12022 .f = cmd_set_hash_input_set_parsed,
12024 .help_str = "set_hash_input_set <port_id> "
12025 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12026 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12027 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12028 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12029 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12030 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12031 "fld-7th|fld-8th|none select|add",
12033 (void *)&cmd_set_hash_input_set_cmd,
12034 (void *)&cmd_set_hash_input_set_port_id,
12035 (void *)&cmd_set_hash_input_set_flow_type,
12036 (void *)&cmd_set_hash_input_set_field,
12037 (void *)&cmd_set_hash_input_set_select,
12042 /* Set flow director input set */
12043 struct cmd_set_fdir_input_set_result {
12044 cmdline_fixed_string_t set_fdir_input_set;
12046 cmdline_fixed_string_t flow_type;
12047 cmdline_fixed_string_t inset_field;
12048 cmdline_fixed_string_t select;
12052 cmd_set_fdir_input_set_parsed(void *parsed_result,
12053 __rte_unused struct cmdline *cl,
12054 __rte_unused void *data)
12056 struct cmd_set_fdir_input_set_result *res = parsed_result;
12057 struct rte_eth_fdir_filter_info info;
12059 memset(&info, 0, sizeof(info));
12060 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12061 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12062 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12063 info.info.input_set_conf.inset_size = 1;
12064 if (!strcmp(res->select, "select"))
12065 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12066 else if (!strcmp(res->select, "add"))
12067 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12068 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12069 RTE_ETH_FILTER_SET, &info);
12072 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12073 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12074 set_fdir_input_set, "set_fdir_input_set");
12075 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12076 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12078 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12079 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12081 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12082 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12083 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12084 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12086 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12087 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12088 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12089 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12090 "sctp-veri-tag#none");
12091 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12092 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12093 select, "select#add");
12095 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12096 .f = cmd_set_fdir_input_set_parsed,
12098 .help_str = "set_fdir_input_set <port_id> "
12099 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12100 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12101 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12102 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12103 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12104 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12105 "sctp-veri-tag|none select|add",
12107 (void *)&cmd_set_fdir_input_set_cmd,
12108 (void *)&cmd_set_fdir_input_set_port_id,
12109 (void *)&cmd_set_fdir_input_set_flow_type,
12110 (void *)&cmd_set_fdir_input_set_field,
12111 (void *)&cmd_set_fdir_input_set_select,
12116 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12117 struct cmd_mcast_addr_result {
12118 cmdline_fixed_string_t mcast_addr_cmd;
12119 cmdline_fixed_string_t what;
12121 struct ether_addr mc_addr;
12124 static void cmd_mcast_addr_parsed(void *parsed_result,
12125 __attribute__((unused)) struct cmdline *cl,
12126 __attribute__((unused)) void *data)
12128 struct cmd_mcast_addr_result *res = parsed_result;
12130 if (!is_multicast_ether_addr(&res->mc_addr)) {
12131 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12132 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12133 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12134 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12137 if (strcmp(res->what, "add") == 0)
12138 mcast_addr_add(res->port_num, &res->mc_addr);
12140 mcast_addr_remove(res->port_num, &res->mc_addr);
12143 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12144 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12145 mcast_addr_cmd, "mcast_addr");
12146 cmdline_parse_token_string_t cmd_mcast_addr_what =
12147 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12149 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12150 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12151 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12152 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12154 cmdline_parse_inst_t cmd_mcast_addr = {
12155 .f = cmd_mcast_addr_parsed,
12157 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12158 "Add/Remove multicast MAC address on port_id",
12160 (void *)&cmd_mcast_addr_cmd,
12161 (void *)&cmd_mcast_addr_what,
12162 (void *)&cmd_mcast_addr_portnum,
12163 (void *)&cmd_mcast_addr_addr,
12168 /* l2 tunnel config
12169 * only support E-tag now.
12172 /* Ether type config */
12173 struct cmd_config_l2_tunnel_eth_type_result {
12174 cmdline_fixed_string_t port;
12175 cmdline_fixed_string_t config;
12176 cmdline_fixed_string_t all;
12178 cmdline_fixed_string_t l2_tunnel;
12179 cmdline_fixed_string_t l2_tunnel_type;
12180 cmdline_fixed_string_t eth_type;
12181 uint16_t eth_type_val;
12184 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12185 TOKEN_STRING_INITIALIZER
12186 (struct cmd_config_l2_tunnel_eth_type_result,
12188 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12189 TOKEN_STRING_INITIALIZER
12190 (struct cmd_config_l2_tunnel_eth_type_result,
12192 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12193 TOKEN_STRING_INITIALIZER
12194 (struct cmd_config_l2_tunnel_eth_type_result,
12196 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12197 TOKEN_NUM_INITIALIZER
12198 (struct cmd_config_l2_tunnel_eth_type_result,
12200 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12201 TOKEN_STRING_INITIALIZER
12202 (struct cmd_config_l2_tunnel_eth_type_result,
12203 l2_tunnel, "l2-tunnel");
12204 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12205 TOKEN_STRING_INITIALIZER
12206 (struct cmd_config_l2_tunnel_eth_type_result,
12207 l2_tunnel_type, "E-tag");
12208 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12209 TOKEN_STRING_INITIALIZER
12210 (struct cmd_config_l2_tunnel_eth_type_result,
12211 eth_type, "ether-type");
12212 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12213 TOKEN_NUM_INITIALIZER
12214 (struct cmd_config_l2_tunnel_eth_type_result,
12215 eth_type_val, UINT16);
12217 static enum rte_eth_tunnel_type
12218 str2fdir_l2_tunnel_type(char *string)
12222 static const struct {
12224 enum rte_eth_tunnel_type type;
12225 } l2_tunnel_type_str[] = {
12226 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12229 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12230 if (!strcmp(l2_tunnel_type_str[i].str, string))
12231 return l2_tunnel_type_str[i].type;
12233 return RTE_TUNNEL_TYPE_NONE;
12236 /* ether type config for all ports */
12238 cmd_config_l2_tunnel_eth_type_all_parsed
12239 (void *parsed_result,
12240 __attribute__((unused)) struct cmdline *cl,
12241 __attribute__((unused)) void *data)
12243 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12244 struct rte_eth_l2_tunnel_conf entry;
12247 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12248 entry.ether_type = res->eth_type_val;
12250 RTE_ETH_FOREACH_DEV(pid) {
12251 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12255 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12256 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12258 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12260 (void *)&cmd_config_l2_tunnel_eth_type_port,
12261 (void *)&cmd_config_l2_tunnel_eth_type_config,
12262 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12263 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12264 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12265 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12266 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12271 /* ether type config for a specific port */
12273 cmd_config_l2_tunnel_eth_type_specific_parsed(
12274 void *parsed_result,
12275 __attribute__((unused)) struct cmdline *cl,
12276 __attribute__((unused)) void *data)
12278 struct cmd_config_l2_tunnel_eth_type_result *res =
12280 struct rte_eth_l2_tunnel_conf entry;
12282 if (port_id_is_invalid(res->id, ENABLED_WARN))
12285 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12286 entry.ether_type = res->eth_type_val;
12288 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12291 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12292 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12294 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12296 (void *)&cmd_config_l2_tunnel_eth_type_port,
12297 (void *)&cmd_config_l2_tunnel_eth_type_config,
12298 (void *)&cmd_config_l2_tunnel_eth_type_id,
12299 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12300 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12301 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12302 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12307 /* Enable/disable l2 tunnel */
12308 struct cmd_config_l2_tunnel_en_dis_result {
12309 cmdline_fixed_string_t port;
12310 cmdline_fixed_string_t config;
12311 cmdline_fixed_string_t all;
12313 cmdline_fixed_string_t l2_tunnel;
12314 cmdline_fixed_string_t l2_tunnel_type;
12315 cmdline_fixed_string_t en_dis;
12318 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12319 TOKEN_STRING_INITIALIZER
12320 (struct cmd_config_l2_tunnel_en_dis_result,
12322 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12323 TOKEN_STRING_INITIALIZER
12324 (struct cmd_config_l2_tunnel_en_dis_result,
12326 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12327 TOKEN_STRING_INITIALIZER
12328 (struct cmd_config_l2_tunnel_en_dis_result,
12330 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12331 TOKEN_NUM_INITIALIZER
12332 (struct cmd_config_l2_tunnel_en_dis_result,
12334 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12335 TOKEN_STRING_INITIALIZER
12336 (struct cmd_config_l2_tunnel_en_dis_result,
12337 l2_tunnel, "l2-tunnel");
12338 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12339 TOKEN_STRING_INITIALIZER
12340 (struct cmd_config_l2_tunnel_en_dis_result,
12341 l2_tunnel_type, "E-tag");
12342 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12343 TOKEN_STRING_INITIALIZER
12344 (struct cmd_config_l2_tunnel_en_dis_result,
12345 en_dis, "enable#disable");
12347 /* enable/disable l2 tunnel for all ports */
12349 cmd_config_l2_tunnel_en_dis_all_parsed(
12350 void *parsed_result,
12351 __attribute__((unused)) struct cmdline *cl,
12352 __attribute__((unused)) void *data)
12354 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12355 struct rte_eth_l2_tunnel_conf entry;
12359 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12361 if (!strcmp("enable", res->en_dis))
12366 RTE_ETH_FOREACH_DEV(pid) {
12367 rte_eth_dev_l2_tunnel_offload_set(pid,
12369 ETH_L2_TUNNEL_ENABLE_MASK,
12374 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12375 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12377 .help_str = "port config all l2-tunnel E-tag enable|disable",
12379 (void *)&cmd_config_l2_tunnel_en_dis_port,
12380 (void *)&cmd_config_l2_tunnel_en_dis_config,
12381 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12382 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12383 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12384 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12389 /* enable/disable l2 tunnel for a port */
12391 cmd_config_l2_tunnel_en_dis_specific_parsed(
12392 void *parsed_result,
12393 __attribute__((unused)) struct cmdline *cl,
12394 __attribute__((unused)) void *data)
12396 struct cmd_config_l2_tunnel_en_dis_result *res =
12398 struct rte_eth_l2_tunnel_conf entry;
12400 if (port_id_is_invalid(res->id, ENABLED_WARN))
12403 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12405 if (!strcmp("enable", res->en_dis))
12406 rte_eth_dev_l2_tunnel_offload_set(res->id,
12408 ETH_L2_TUNNEL_ENABLE_MASK,
12411 rte_eth_dev_l2_tunnel_offload_set(res->id,
12413 ETH_L2_TUNNEL_ENABLE_MASK,
12417 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12418 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12420 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12422 (void *)&cmd_config_l2_tunnel_en_dis_port,
12423 (void *)&cmd_config_l2_tunnel_en_dis_config,
12424 (void *)&cmd_config_l2_tunnel_en_dis_id,
12425 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12426 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12427 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12432 /* E-tag configuration */
12434 /* Common result structure for all E-tag configuration */
12435 struct cmd_config_e_tag_result {
12436 cmdline_fixed_string_t e_tag;
12437 cmdline_fixed_string_t set;
12438 cmdline_fixed_string_t insertion;
12439 cmdline_fixed_string_t stripping;
12440 cmdline_fixed_string_t forwarding;
12441 cmdline_fixed_string_t filter;
12442 cmdline_fixed_string_t add;
12443 cmdline_fixed_string_t del;
12444 cmdline_fixed_string_t on;
12445 cmdline_fixed_string_t off;
12446 cmdline_fixed_string_t on_off;
12447 cmdline_fixed_string_t port_tag_id;
12448 uint32_t port_tag_id_val;
12449 cmdline_fixed_string_t e_tag_id;
12450 uint16_t e_tag_id_val;
12451 cmdline_fixed_string_t dst_pool;
12452 uint8_t dst_pool_val;
12453 cmdline_fixed_string_t port;
12455 cmdline_fixed_string_t vf;
12459 /* Common CLI fields for all E-tag configuration */
12460 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12461 TOKEN_STRING_INITIALIZER
12462 (struct cmd_config_e_tag_result,
12464 cmdline_parse_token_string_t cmd_config_e_tag_set =
12465 TOKEN_STRING_INITIALIZER
12466 (struct cmd_config_e_tag_result,
12468 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_config_e_tag_result,
12471 insertion, "insertion");
12472 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12473 TOKEN_STRING_INITIALIZER
12474 (struct cmd_config_e_tag_result,
12475 stripping, "stripping");
12476 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_config_e_tag_result,
12479 forwarding, "forwarding");
12480 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12481 TOKEN_STRING_INITIALIZER
12482 (struct cmd_config_e_tag_result,
12484 cmdline_parse_token_string_t cmd_config_e_tag_add =
12485 TOKEN_STRING_INITIALIZER
12486 (struct cmd_config_e_tag_result,
12488 cmdline_parse_token_string_t cmd_config_e_tag_del =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_config_e_tag_result,
12492 cmdline_parse_token_string_t cmd_config_e_tag_on =
12493 TOKEN_STRING_INITIALIZER
12494 (struct cmd_config_e_tag_result,
12496 cmdline_parse_token_string_t cmd_config_e_tag_off =
12497 TOKEN_STRING_INITIALIZER
12498 (struct cmd_config_e_tag_result,
12500 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12501 TOKEN_STRING_INITIALIZER
12502 (struct cmd_config_e_tag_result,
12504 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12505 TOKEN_STRING_INITIALIZER
12506 (struct cmd_config_e_tag_result,
12507 port_tag_id, "port-tag-id");
12508 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12509 TOKEN_NUM_INITIALIZER
12510 (struct cmd_config_e_tag_result,
12511 port_tag_id_val, UINT32);
12512 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12513 TOKEN_STRING_INITIALIZER
12514 (struct cmd_config_e_tag_result,
12515 e_tag_id, "e-tag-id");
12516 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12517 TOKEN_NUM_INITIALIZER
12518 (struct cmd_config_e_tag_result,
12519 e_tag_id_val, UINT16);
12520 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12521 TOKEN_STRING_INITIALIZER
12522 (struct cmd_config_e_tag_result,
12523 dst_pool, "dst-pool");
12524 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12525 TOKEN_NUM_INITIALIZER
12526 (struct cmd_config_e_tag_result,
12527 dst_pool_val, UINT8);
12528 cmdline_parse_token_string_t cmd_config_e_tag_port =
12529 TOKEN_STRING_INITIALIZER
12530 (struct cmd_config_e_tag_result,
12532 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12533 TOKEN_NUM_INITIALIZER
12534 (struct cmd_config_e_tag_result,
12536 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12537 TOKEN_STRING_INITIALIZER
12538 (struct cmd_config_e_tag_result,
12540 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12541 TOKEN_NUM_INITIALIZER
12542 (struct cmd_config_e_tag_result,
12545 /* E-tag insertion configuration */
12547 cmd_config_e_tag_insertion_en_parsed(
12548 void *parsed_result,
12549 __attribute__((unused)) struct cmdline *cl,
12550 __attribute__((unused)) void *data)
12552 struct cmd_config_e_tag_result *res =
12554 struct rte_eth_l2_tunnel_conf entry;
12556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12559 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12560 entry.tunnel_id = res->port_tag_id_val;
12561 entry.vf_id = res->vf_id;
12562 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12564 ETH_L2_TUNNEL_INSERTION_MASK,
12569 cmd_config_e_tag_insertion_dis_parsed(
12570 void *parsed_result,
12571 __attribute__((unused)) struct cmdline *cl,
12572 __attribute__((unused)) void *data)
12574 struct cmd_config_e_tag_result *res =
12576 struct rte_eth_l2_tunnel_conf entry;
12578 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12581 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12582 entry.vf_id = res->vf_id;
12584 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12586 ETH_L2_TUNNEL_INSERTION_MASK,
12590 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12591 .f = cmd_config_e_tag_insertion_en_parsed,
12593 .help_str = "E-tag ... : E-tag insertion enable",
12595 (void *)&cmd_config_e_tag_e_tag,
12596 (void *)&cmd_config_e_tag_set,
12597 (void *)&cmd_config_e_tag_insertion,
12598 (void *)&cmd_config_e_tag_on,
12599 (void *)&cmd_config_e_tag_port_tag_id,
12600 (void *)&cmd_config_e_tag_port_tag_id_val,
12601 (void *)&cmd_config_e_tag_port,
12602 (void *)&cmd_config_e_tag_port_id,
12603 (void *)&cmd_config_e_tag_vf,
12604 (void *)&cmd_config_e_tag_vf_id,
12609 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12610 .f = cmd_config_e_tag_insertion_dis_parsed,
12612 .help_str = "E-tag ... : E-tag insertion disable",
12614 (void *)&cmd_config_e_tag_e_tag,
12615 (void *)&cmd_config_e_tag_set,
12616 (void *)&cmd_config_e_tag_insertion,
12617 (void *)&cmd_config_e_tag_off,
12618 (void *)&cmd_config_e_tag_port,
12619 (void *)&cmd_config_e_tag_port_id,
12620 (void *)&cmd_config_e_tag_vf,
12621 (void *)&cmd_config_e_tag_vf_id,
12626 /* E-tag stripping configuration */
12628 cmd_config_e_tag_stripping_parsed(
12629 void *parsed_result,
12630 __attribute__((unused)) struct cmdline *cl,
12631 __attribute__((unused)) void *data)
12633 struct cmd_config_e_tag_result *res =
12635 struct rte_eth_l2_tunnel_conf entry;
12637 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12640 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12642 if (!strcmp(res->on_off, "on"))
12643 rte_eth_dev_l2_tunnel_offload_set
12646 ETH_L2_TUNNEL_STRIPPING_MASK,
12649 rte_eth_dev_l2_tunnel_offload_set
12652 ETH_L2_TUNNEL_STRIPPING_MASK,
12656 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12657 .f = cmd_config_e_tag_stripping_parsed,
12659 .help_str = "E-tag ... : E-tag stripping enable/disable",
12661 (void *)&cmd_config_e_tag_e_tag,
12662 (void *)&cmd_config_e_tag_set,
12663 (void *)&cmd_config_e_tag_stripping,
12664 (void *)&cmd_config_e_tag_on_off,
12665 (void *)&cmd_config_e_tag_port,
12666 (void *)&cmd_config_e_tag_port_id,
12671 /* E-tag forwarding configuration */
12673 cmd_config_e_tag_forwarding_parsed(
12674 void *parsed_result,
12675 __attribute__((unused)) struct cmdline *cl,
12676 __attribute__((unused)) void *data)
12678 struct cmd_config_e_tag_result *res = parsed_result;
12679 struct rte_eth_l2_tunnel_conf entry;
12681 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12684 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12686 if (!strcmp(res->on_off, "on"))
12687 rte_eth_dev_l2_tunnel_offload_set
12690 ETH_L2_TUNNEL_FORWARDING_MASK,
12693 rte_eth_dev_l2_tunnel_offload_set
12696 ETH_L2_TUNNEL_FORWARDING_MASK,
12700 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12701 .f = cmd_config_e_tag_forwarding_parsed,
12703 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12705 (void *)&cmd_config_e_tag_e_tag,
12706 (void *)&cmd_config_e_tag_set,
12707 (void *)&cmd_config_e_tag_forwarding,
12708 (void *)&cmd_config_e_tag_on_off,
12709 (void *)&cmd_config_e_tag_port,
12710 (void *)&cmd_config_e_tag_port_id,
12715 /* E-tag filter configuration */
12717 cmd_config_e_tag_filter_add_parsed(
12718 void *parsed_result,
12719 __attribute__((unused)) struct cmdline *cl,
12720 __attribute__((unused)) void *data)
12722 struct cmd_config_e_tag_result *res = parsed_result;
12723 struct rte_eth_l2_tunnel_conf entry;
12726 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12729 if (res->e_tag_id_val > 0x3fff) {
12730 printf("e-tag-id must be equal or less than 0x3fff.\n");
12734 ret = rte_eth_dev_filter_supported(res->port_id,
12735 RTE_ETH_FILTER_L2_TUNNEL);
12737 printf("E-tag filter is not supported on port %u.\n",
12742 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12743 entry.tunnel_id = res->e_tag_id_val;
12744 entry.pool = res->dst_pool_val;
12746 ret = rte_eth_dev_filter_ctrl(res->port_id,
12747 RTE_ETH_FILTER_L2_TUNNEL,
12748 RTE_ETH_FILTER_ADD,
12751 printf("E-tag filter programming error: (%s)\n",
12755 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12756 .f = cmd_config_e_tag_filter_add_parsed,
12758 .help_str = "E-tag ... : E-tag filter add",
12760 (void *)&cmd_config_e_tag_e_tag,
12761 (void *)&cmd_config_e_tag_set,
12762 (void *)&cmd_config_e_tag_filter,
12763 (void *)&cmd_config_e_tag_add,
12764 (void *)&cmd_config_e_tag_e_tag_id,
12765 (void *)&cmd_config_e_tag_e_tag_id_val,
12766 (void *)&cmd_config_e_tag_dst_pool,
12767 (void *)&cmd_config_e_tag_dst_pool_val,
12768 (void *)&cmd_config_e_tag_port,
12769 (void *)&cmd_config_e_tag_port_id,
12775 cmd_config_e_tag_filter_del_parsed(
12776 void *parsed_result,
12777 __attribute__((unused)) struct cmdline *cl,
12778 __attribute__((unused)) void *data)
12780 struct cmd_config_e_tag_result *res = parsed_result;
12781 struct rte_eth_l2_tunnel_conf entry;
12784 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12787 if (res->e_tag_id_val > 0x3fff) {
12788 printf("e-tag-id must be less than 0x3fff.\n");
12792 ret = rte_eth_dev_filter_supported(res->port_id,
12793 RTE_ETH_FILTER_L2_TUNNEL);
12795 printf("E-tag filter is not supported on port %u.\n",
12800 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12801 entry.tunnel_id = res->e_tag_id_val;
12803 ret = rte_eth_dev_filter_ctrl(res->port_id,
12804 RTE_ETH_FILTER_L2_TUNNEL,
12805 RTE_ETH_FILTER_DELETE,
12808 printf("E-tag filter programming error: (%s)\n",
12812 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12813 .f = cmd_config_e_tag_filter_del_parsed,
12815 .help_str = "E-tag ... : E-tag filter delete",
12817 (void *)&cmd_config_e_tag_e_tag,
12818 (void *)&cmd_config_e_tag_set,
12819 (void *)&cmd_config_e_tag_filter,
12820 (void *)&cmd_config_e_tag_del,
12821 (void *)&cmd_config_e_tag_e_tag_id,
12822 (void *)&cmd_config_e_tag_e_tag_id_val,
12823 (void *)&cmd_config_e_tag_port,
12824 (void *)&cmd_config_e_tag_port_id,
12829 /* vf vlan anti spoof configuration */
12831 /* Common result structure for vf vlan anti spoof */
12832 struct cmd_vf_vlan_anti_spoof_result {
12833 cmdline_fixed_string_t set;
12834 cmdline_fixed_string_t vf;
12835 cmdline_fixed_string_t vlan;
12836 cmdline_fixed_string_t antispoof;
12839 cmdline_fixed_string_t on_off;
12842 /* Common CLI fields for vf vlan anti spoof enable disable */
12843 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12844 TOKEN_STRING_INITIALIZER
12845 (struct cmd_vf_vlan_anti_spoof_result,
12847 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12848 TOKEN_STRING_INITIALIZER
12849 (struct cmd_vf_vlan_anti_spoof_result,
12851 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12852 TOKEN_STRING_INITIALIZER
12853 (struct cmd_vf_vlan_anti_spoof_result,
12855 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12856 TOKEN_STRING_INITIALIZER
12857 (struct cmd_vf_vlan_anti_spoof_result,
12858 antispoof, "antispoof");
12859 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12860 TOKEN_NUM_INITIALIZER
12861 (struct cmd_vf_vlan_anti_spoof_result,
12863 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12864 TOKEN_NUM_INITIALIZER
12865 (struct cmd_vf_vlan_anti_spoof_result,
12867 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12868 TOKEN_STRING_INITIALIZER
12869 (struct cmd_vf_vlan_anti_spoof_result,
12873 cmd_set_vf_vlan_anti_spoof_parsed(
12874 void *parsed_result,
12875 __attribute__((unused)) struct cmdline *cl,
12876 __attribute__((unused)) void *data)
12878 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12879 int ret = -ENOTSUP;
12881 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12886 #ifdef RTE_LIBRTE_IXGBE_PMD
12887 if (ret == -ENOTSUP)
12888 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12889 res->vf_id, is_on);
12891 #ifdef RTE_LIBRTE_I40E_PMD
12892 if (ret == -ENOTSUP)
12893 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12894 res->vf_id, is_on);
12896 #ifdef RTE_LIBRTE_BNXT_PMD
12897 if (ret == -ENOTSUP)
12898 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12899 res->vf_id, is_on);
12906 printf("invalid vf_id %d\n", res->vf_id);
12909 printf("invalid port_id %d\n", res->port_id);
12912 printf("function not implemented\n");
12915 printf("programming error: (%s)\n", strerror(-ret));
12919 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12920 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12922 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12924 (void *)&cmd_vf_vlan_anti_spoof_set,
12925 (void *)&cmd_vf_vlan_anti_spoof_vf,
12926 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12927 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12928 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12929 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12930 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12935 /* vf mac anti spoof configuration */
12937 /* Common result structure for vf mac anti spoof */
12938 struct cmd_vf_mac_anti_spoof_result {
12939 cmdline_fixed_string_t set;
12940 cmdline_fixed_string_t vf;
12941 cmdline_fixed_string_t mac;
12942 cmdline_fixed_string_t antispoof;
12945 cmdline_fixed_string_t on_off;
12948 /* Common CLI fields for vf mac anti spoof enable disable */
12949 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12950 TOKEN_STRING_INITIALIZER
12951 (struct cmd_vf_mac_anti_spoof_result,
12953 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12954 TOKEN_STRING_INITIALIZER
12955 (struct cmd_vf_mac_anti_spoof_result,
12957 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12958 TOKEN_STRING_INITIALIZER
12959 (struct cmd_vf_mac_anti_spoof_result,
12961 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12962 TOKEN_STRING_INITIALIZER
12963 (struct cmd_vf_mac_anti_spoof_result,
12964 antispoof, "antispoof");
12965 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12966 TOKEN_NUM_INITIALIZER
12967 (struct cmd_vf_mac_anti_spoof_result,
12969 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12970 TOKEN_NUM_INITIALIZER
12971 (struct cmd_vf_mac_anti_spoof_result,
12973 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12974 TOKEN_STRING_INITIALIZER
12975 (struct cmd_vf_mac_anti_spoof_result,
12979 cmd_set_vf_mac_anti_spoof_parsed(
12980 void *parsed_result,
12981 __attribute__((unused)) struct cmdline *cl,
12982 __attribute__((unused)) void *data)
12984 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12985 int ret = -ENOTSUP;
12987 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12989 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12992 #ifdef RTE_LIBRTE_IXGBE_PMD
12993 if (ret == -ENOTSUP)
12994 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12995 res->vf_id, is_on);
12997 #ifdef RTE_LIBRTE_I40E_PMD
12998 if (ret == -ENOTSUP)
12999 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13000 res->vf_id, is_on);
13002 #ifdef RTE_LIBRTE_BNXT_PMD
13003 if (ret == -ENOTSUP)
13004 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13005 res->vf_id, is_on);
13012 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13015 printf("invalid port_id %d\n", res->port_id);
13018 printf("function not implemented\n");
13021 printf("programming error: (%s)\n", strerror(-ret));
13025 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13026 .f = cmd_set_vf_mac_anti_spoof_parsed,
13028 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13030 (void *)&cmd_vf_mac_anti_spoof_set,
13031 (void *)&cmd_vf_mac_anti_spoof_vf,
13032 (void *)&cmd_vf_mac_anti_spoof_mac,
13033 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13034 (void *)&cmd_vf_mac_anti_spoof_port_id,
13035 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13036 (void *)&cmd_vf_mac_anti_spoof_on_off,
13041 /* vf vlan strip queue configuration */
13043 /* Common result structure for vf mac anti spoof */
13044 struct cmd_vf_vlan_stripq_result {
13045 cmdline_fixed_string_t set;
13046 cmdline_fixed_string_t vf;
13047 cmdline_fixed_string_t vlan;
13048 cmdline_fixed_string_t stripq;
13051 cmdline_fixed_string_t on_off;
13054 /* Common CLI fields for vf vlan strip enable disable */
13055 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13056 TOKEN_STRING_INITIALIZER
13057 (struct cmd_vf_vlan_stripq_result,
13059 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13060 TOKEN_STRING_INITIALIZER
13061 (struct cmd_vf_vlan_stripq_result,
13063 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13064 TOKEN_STRING_INITIALIZER
13065 (struct cmd_vf_vlan_stripq_result,
13067 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13068 TOKEN_STRING_INITIALIZER
13069 (struct cmd_vf_vlan_stripq_result,
13071 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13072 TOKEN_NUM_INITIALIZER
13073 (struct cmd_vf_vlan_stripq_result,
13075 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13076 TOKEN_NUM_INITIALIZER
13077 (struct cmd_vf_vlan_stripq_result,
13079 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13080 TOKEN_STRING_INITIALIZER
13081 (struct cmd_vf_vlan_stripq_result,
13085 cmd_set_vf_vlan_stripq_parsed(
13086 void *parsed_result,
13087 __attribute__((unused)) struct cmdline *cl,
13088 __attribute__((unused)) void *data)
13090 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13091 int ret = -ENOTSUP;
13093 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13095 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13098 #ifdef RTE_LIBRTE_IXGBE_PMD
13099 if (ret == -ENOTSUP)
13100 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13101 res->vf_id, is_on);
13103 #ifdef RTE_LIBRTE_I40E_PMD
13104 if (ret == -ENOTSUP)
13105 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13106 res->vf_id, is_on);
13108 #ifdef RTE_LIBRTE_BNXT_PMD
13109 if (ret == -ENOTSUP)
13110 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13111 res->vf_id, is_on);
13118 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13121 printf("invalid port_id %d\n", res->port_id);
13124 printf("function not implemented\n");
13127 printf("programming error: (%s)\n", strerror(-ret));
13131 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13132 .f = cmd_set_vf_vlan_stripq_parsed,
13134 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13136 (void *)&cmd_vf_vlan_stripq_set,
13137 (void *)&cmd_vf_vlan_stripq_vf,
13138 (void *)&cmd_vf_vlan_stripq_vlan,
13139 (void *)&cmd_vf_vlan_stripq_stripq,
13140 (void *)&cmd_vf_vlan_stripq_port_id,
13141 (void *)&cmd_vf_vlan_stripq_vf_id,
13142 (void *)&cmd_vf_vlan_stripq_on_off,
13147 /* vf vlan insert configuration */
13149 /* Common result structure for vf vlan insert */
13150 struct cmd_vf_vlan_insert_result {
13151 cmdline_fixed_string_t set;
13152 cmdline_fixed_string_t vf;
13153 cmdline_fixed_string_t vlan;
13154 cmdline_fixed_string_t insert;
13160 /* Common CLI fields for vf vlan insert enable disable */
13161 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13162 TOKEN_STRING_INITIALIZER
13163 (struct cmd_vf_vlan_insert_result,
13165 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13166 TOKEN_STRING_INITIALIZER
13167 (struct cmd_vf_vlan_insert_result,
13169 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13170 TOKEN_STRING_INITIALIZER
13171 (struct cmd_vf_vlan_insert_result,
13173 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13174 TOKEN_STRING_INITIALIZER
13175 (struct cmd_vf_vlan_insert_result,
13177 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13178 TOKEN_NUM_INITIALIZER
13179 (struct cmd_vf_vlan_insert_result,
13181 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13182 TOKEN_NUM_INITIALIZER
13183 (struct cmd_vf_vlan_insert_result,
13185 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13186 TOKEN_NUM_INITIALIZER
13187 (struct cmd_vf_vlan_insert_result,
13191 cmd_set_vf_vlan_insert_parsed(
13192 void *parsed_result,
13193 __attribute__((unused)) struct cmdline *cl,
13194 __attribute__((unused)) void *data)
13196 struct cmd_vf_vlan_insert_result *res = parsed_result;
13197 int ret = -ENOTSUP;
13199 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13202 #ifdef RTE_LIBRTE_IXGBE_PMD
13203 if (ret == -ENOTSUP)
13204 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13207 #ifdef RTE_LIBRTE_I40E_PMD
13208 if (ret == -ENOTSUP)
13209 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13212 #ifdef RTE_LIBRTE_BNXT_PMD
13213 if (ret == -ENOTSUP)
13214 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13222 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13225 printf("invalid port_id %d\n", res->port_id);
13228 printf("function not implemented\n");
13231 printf("programming error: (%s)\n", strerror(-ret));
13235 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13236 .f = cmd_set_vf_vlan_insert_parsed,
13238 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13240 (void *)&cmd_vf_vlan_insert_set,
13241 (void *)&cmd_vf_vlan_insert_vf,
13242 (void *)&cmd_vf_vlan_insert_vlan,
13243 (void *)&cmd_vf_vlan_insert_insert,
13244 (void *)&cmd_vf_vlan_insert_port_id,
13245 (void *)&cmd_vf_vlan_insert_vf_id,
13246 (void *)&cmd_vf_vlan_insert_vlan_id,
13251 /* tx loopback configuration */
13253 /* Common result structure for tx loopback */
13254 struct cmd_tx_loopback_result {
13255 cmdline_fixed_string_t set;
13256 cmdline_fixed_string_t tx;
13257 cmdline_fixed_string_t loopback;
13259 cmdline_fixed_string_t on_off;
13262 /* Common CLI fields for tx loopback enable disable */
13263 cmdline_parse_token_string_t cmd_tx_loopback_set =
13264 TOKEN_STRING_INITIALIZER
13265 (struct cmd_tx_loopback_result,
13267 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13268 TOKEN_STRING_INITIALIZER
13269 (struct cmd_tx_loopback_result,
13271 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13272 TOKEN_STRING_INITIALIZER
13273 (struct cmd_tx_loopback_result,
13274 loopback, "loopback");
13275 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13276 TOKEN_NUM_INITIALIZER
13277 (struct cmd_tx_loopback_result,
13279 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13280 TOKEN_STRING_INITIALIZER
13281 (struct cmd_tx_loopback_result,
13285 cmd_set_tx_loopback_parsed(
13286 void *parsed_result,
13287 __attribute__((unused)) struct cmdline *cl,
13288 __attribute__((unused)) void *data)
13290 struct cmd_tx_loopback_result *res = parsed_result;
13291 int ret = -ENOTSUP;
13293 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13295 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13298 #ifdef RTE_LIBRTE_IXGBE_PMD
13299 if (ret == -ENOTSUP)
13300 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13302 #ifdef RTE_LIBRTE_I40E_PMD
13303 if (ret == -ENOTSUP)
13304 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13306 #ifdef RTE_LIBRTE_BNXT_PMD
13307 if (ret == -ENOTSUP)
13308 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13310 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13311 if (ret == -ENOTSUP)
13312 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13319 printf("invalid is_on %d\n", is_on);
13322 printf("invalid port_id %d\n", res->port_id);
13325 printf("function not implemented\n");
13328 printf("programming error: (%s)\n", strerror(-ret));
13332 cmdline_parse_inst_t cmd_set_tx_loopback = {
13333 .f = cmd_set_tx_loopback_parsed,
13335 .help_str = "set tx loopback <port_id> on|off",
13337 (void *)&cmd_tx_loopback_set,
13338 (void *)&cmd_tx_loopback_tx,
13339 (void *)&cmd_tx_loopback_loopback,
13340 (void *)&cmd_tx_loopback_port_id,
13341 (void *)&cmd_tx_loopback_on_off,
13346 /* all queues drop enable configuration */
13348 /* Common result structure for all queues drop enable */
13349 struct cmd_all_queues_drop_en_result {
13350 cmdline_fixed_string_t set;
13351 cmdline_fixed_string_t all;
13352 cmdline_fixed_string_t queues;
13353 cmdline_fixed_string_t drop;
13355 cmdline_fixed_string_t on_off;
13358 /* Common CLI fields for tx loopback enable disable */
13359 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13360 TOKEN_STRING_INITIALIZER
13361 (struct cmd_all_queues_drop_en_result,
13363 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13364 TOKEN_STRING_INITIALIZER
13365 (struct cmd_all_queues_drop_en_result,
13367 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13368 TOKEN_STRING_INITIALIZER
13369 (struct cmd_all_queues_drop_en_result,
13371 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13372 TOKEN_STRING_INITIALIZER
13373 (struct cmd_all_queues_drop_en_result,
13375 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13376 TOKEN_NUM_INITIALIZER
13377 (struct cmd_all_queues_drop_en_result,
13379 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13380 TOKEN_STRING_INITIALIZER
13381 (struct cmd_all_queues_drop_en_result,
13385 cmd_set_all_queues_drop_en_parsed(
13386 void *parsed_result,
13387 __attribute__((unused)) struct cmdline *cl,
13388 __attribute__((unused)) void *data)
13390 struct cmd_all_queues_drop_en_result *res = parsed_result;
13391 int ret = -ENOTSUP;
13392 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13397 #ifdef RTE_LIBRTE_IXGBE_PMD
13398 if (ret == -ENOTSUP)
13399 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13401 #ifdef RTE_LIBRTE_BNXT_PMD
13402 if (ret == -ENOTSUP)
13403 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13409 printf("invalid is_on %d\n", is_on);
13412 printf("invalid port_id %d\n", res->port_id);
13415 printf("function not implemented\n");
13418 printf("programming error: (%s)\n", strerror(-ret));
13422 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13423 .f = cmd_set_all_queues_drop_en_parsed,
13425 .help_str = "set all queues drop <port_id> on|off",
13427 (void *)&cmd_all_queues_drop_en_set,
13428 (void *)&cmd_all_queues_drop_en_all,
13429 (void *)&cmd_all_queues_drop_en_queues,
13430 (void *)&cmd_all_queues_drop_en_drop,
13431 (void *)&cmd_all_queues_drop_en_port_id,
13432 (void *)&cmd_all_queues_drop_en_on_off,
13437 /* vf split drop enable configuration */
13439 /* Common result structure for vf split drop enable */
13440 struct cmd_vf_split_drop_en_result {
13441 cmdline_fixed_string_t set;
13442 cmdline_fixed_string_t vf;
13443 cmdline_fixed_string_t split;
13444 cmdline_fixed_string_t drop;
13447 cmdline_fixed_string_t on_off;
13450 /* Common CLI fields for vf split drop enable disable */
13451 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13452 TOKEN_STRING_INITIALIZER
13453 (struct cmd_vf_split_drop_en_result,
13455 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13456 TOKEN_STRING_INITIALIZER
13457 (struct cmd_vf_split_drop_en_result,
13459 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13460 TOKEN_STRING_INITIALIZER
13461 (struct cmd_vf_split_drop_en_result,
13463 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13464 TOKEN_STRING_INITIALIZER
13465 (struct cmd_vf_split_drop_en_result,
13467 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13468 TOKEN_NUM_INITIALIZER
13469 (struct cmd_vf_split_drop_en_result,
13471 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13472 TOKEN_NUM_INITIALIZER
13473 (struct cmd_vf_split_drop_en_result,
13475 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13476 TOKEN_STRING_INITIALIZER
13477 (struct cmd_vf_split_drop_en_result,
13481 cmd_set_vf_split_drop_en_parsed(
13482 void *parsed_result,
13483 __attribute__((unused)) struct cmdline *cl,
13484 __attribute__((unused)) void *data)
13486 struct cmd_vf_split_drop_en_result *res = parsed_result;
13487 int ret = -ENOTSUP;
13488 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13490 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13493 #ifdef RTE_LIBRTE_IXGBE_PMD
13494 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13501 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13504 printf("invalid port_id %d\n", res->port_id);
13507 printf("not supported on port %d\n", res->port_id);
13510 printf("programming error: (%s)\n", strerror(-ret));
13514 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13515 .f = cmd_set_vf_split_drop_en_parsed,
13517 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13519 (void *)&cmd_vf_split_drop_en_set,
13520 (void *)&cmd_vf_split_drop_en_vf,
13521 (void *)&cmd_vf_split_drop_en_split,
13522 (void *)&cmd_vf_split_drop_en_drop,
13523 (void *)&cmd_vf_split_drop_en_port_id,
13524 (void *)&cmd_vf_split_drop_en_vf_id,
13525 (void *)&cmd_vf_split_drop_en_on_off,
13530 /* vf mac address configuration */
13532 /* Common result structure for vf mac address */
13533 struct cmd_set_vf_mac_addr_result {
13534 cmdline_fixed_string_t set;
13535 cmdline_fixed_string_t vf;
13536 cmdline_fixed_string_t mac;
13537 cmdline_fixed_string_t addr;
13540 struct ether_addr mac_addr;
13544 /* Common CLI fields for vf split drop enable disable */
13545 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13546 TOKEN_STRING_INITIALIZER
13547 (struct cmd_set_vf_mac_addr_result,
13549 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13550 TOKEN_STRING_INITIALIZER
13551 (struct cmd_set_vf_mac_addr_result,
13553 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13554 TOKEN_STRING_INITIALIZER
13555 (struct cmd_set_vf_mac_addr_result,
13557 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13558 TOKEN_STRING_INITIALIZER
13559 (struct cmd_set_vf_mac_addr_result,
13561 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13562 TOKEN_NUM_INITIALIZER
13563 (struct cmd_set_vf_mac_addr_result,
13565 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13566 TOKEN_NUM_INITIALIZER
13567 (struct cmd_set_vf_mac_addr_result,
13569 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13570 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13574 cmd_set_vf_mac_addr_parsed(
13575 void *parsed_result,
13576 __attribute__((unused)) struct cmdline *cl,
13577 __attribute__((unused)) void *data)
13579 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13580 int ret = -ENOTSUP;
13582 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13585 #ifdef RTE_LIBRTE_IXGBE_PMD
13586 if (ret == -ENOTSUP)
13587 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13590 #ifdef RTE_LIBRTE_I40E_PMD
13591 if (ret == -ENOTSUP)
13592 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13595 #ifdef RTE_LIBRTE_BNXT_PMD
13596 if (ret == -ENOTSUP)
13597 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13605 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13608 printf("invalid port_id %d\n", res->port_id);
13611 printf("function not implemented\n");
13614 printf("programming error: (%s)\n", strerror(-ret));
13618 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13619 .f = cmd_set_vf_mac_addr_parsed,
13621 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13623 (void *)&cmd_set_vf_mac_addr_set,
13624 (void *)&cmd_set_vf_mac_addr_vf,
13625 (void *)&cmd_set_vf_mac_addr_mac,
13626 (void *)&cmd_set_vf_mac_addr_addr,
13627 (void *)&cmd_set_vf_mac_addr_port_id,
13628 (void *)&cmd_set_vf_mac_addr_vf_id,
13629 (void *)&cmd_set_vf_mac_addr_mac_addr,
13634 /* MACsec configuration */
13636 /* Common result structure for MACsec offload enable */
13637 struct cmd_macsec_offload_on_result {
13638 cmdline_fixed_string_t set;
13639 cmdline_fixed_string_t macsec;
13640 cmdline_fixed_string_t offload;
13642 cmdline_fixed_string_t on;
13643 cmdline_fixed_string_t encrypt;
13644 cmdline_fixed_string_t en_on_off;
13645 cmdline_fixed_string_t replay_protect;
13646 cmdline_fixed_string_t rp_on_off;
13649 /* Common CLI fields for MACsec offload disable */
13650 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13651 TOKEN_STRING_INITIALIZER
13652 (struct cmd_macsec_offload_on_result,
13654 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13655 TOKEN_STRING_INITIALIZER
13656 (struct cmd_macsec_offload_on_result,
13658 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13659 TOKEN_STRING_INITIALIZER
13660 (struct cmd_macsec_offload_on_result,
13661 offload, "offload");
13662 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13663 TOKEN_NUM_INITIALIZER
13664 (struct cmd_macsec_offload_on_result,
13666 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13667 TOKEN_STRING_INITIALIZER
13668 (struct cmd_macsec_offload_on_result,
13670 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13671 TOKEN_STRING_INITIALIZER
13672 (struct cmd_macsec_offload_on_result,
13673 encrypt, "encrypt");
13674 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13675 TOKEN_STRING_INITIALIZER
13676 (struct cmd_macsec_offload_on_result,
13677 en_on_off, "on#off");
13678 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13679 TOKEN_STRING_INITIALIZER
13680 (struct cmd_macsec_offload_on_result,
13681 replay_protect, "replay-protect");
13682 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13683 TOKEN_STRING_INITIALIZER
13684 (struct cmd_macsec_offload_on_result,
13685 rp_on_off, "on#off");
13688 cmd_set_macsec_offload_on_parsed(
13689 void *parsed_result,
13690 __attribute__((unused)) struct cmdline *cl,
13691 __attribute__((unused)) void *data)
13693 struct cmd_macsec_offload_on_result *res = parsed_result;
13694 int ret = -ENOTSUP;
13695 portid_t port_id = res->port_id;
13696 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13697 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13698 struct rte_eth_dev_info dev_info;
13700 if (port_id_is_invalid(port_id, ENABLED_WARN))
13702 if (!port_is_stopped(port_id)) {
13703 printf("Please stop port %d first\n", port_id);
13707 rte_eth_dev_info_get(port_id, &dev_info);
13708 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13709 #ifdef RTE_LIBRTE_IXGBE_PMD
13710 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13718 ports[port_id].dev_conf.txmode.offloads |=
13719 DEV_TX_OFFLOAD_MACSEC_INSERT;
13720 cmd_reconfig_device_queue(port_id, 1, 1);
13723 printf("invalid port_id %d\n", port_id);
13726 printf("not supported on port %d\n", port_id);
13729 printf("programming error: (%s)\n", strerror(-ret));
13733 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13734 .f = cmd_set_macsec_offload_on_parsed,
13736 .help_str = "set macsec offload <port_id> on "
13737 "encrypt on|off replay-protect on|off",
13739 (void *)&cmd_macsec_offload_on_set,
13740 (void *)&cmd_macsec_offload_on_macsec,
13741 (void *)&cmd_macsec_offload_on_offload,
13742 (void *)&cmd_macsec_offload_on_port_id,
13743 (void *)&cmd_macsec_offload_on_on,
13744 (void *)&cmd_macsec_offload_on_encrypt,
13745 (void *)&cmd_macsec_offload_on_en_on_off,
13746 (void *)&cmd_macsec_offload_on_replay_protect,
13747 (void *)&cmd_macsec_offload_on_rp_on_off,
13752 /* Common result structure for MACsec offload disable */
13753 struct cmd_macsec_offload_off_result {
13754 cmdline_fixed_string_t set;
13755 cmdline_fixed_string_t macsec;
13756 cmdline_fixed_string_t offload;
13758 cmdline_fixed_string_t off;
13761 /* Common CLI fields for MACsec offload disable */
13762 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13763 TOKEN_STRING_INITIALIZER
13764 (struct cmd_macsec_offload_off_result,
13766 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13767 TOKEN_STRING_INITIALIZER
13768 (struct cmd_macsec_offload_off_result,
13770 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13771 TOKEN_STRING_INITIALIZER
13772 (struct cmd_macsec_offload_off_result,
13773 offload, "offload");
13774 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13775 TOKEN_NUM_INITIALIZER
13776 (struct cmd_macsec_offload_off_result,
13778 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13779 TOKEN_STRING_INITIALIZER
13780 (struct cmd_macsec_offload_off_result,
13784 cmd_set_macsec_offload_off_parsed(
13785 void *parsed_result,
13786 __attribute__((unused)) struct cmdline *cl,
13787 __attribute__((unused)) void *data)
13789 struct cmd_macsec_offload_off_result *res = parsed_result;
13790 int ret = -ENOTSUP;
13791 struct rte_eth_dev_info dev_info;
13792 portid_t port_id = res->port_id;
13794 if (port_id_is_invalid(port_id, ENABLED_WARN))
13796 if (!port_is_stopped(port_id)) {
13797 printf("Please stop port %d first\n", port_id);
13801 rte_eth_dev_info_get(port_id, &dev_info);
13802 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13803 #ifdef RTE_LIBRTE_IXGBE_PMD
13804 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13809 ports[port_id].dev_conf.txmode.offloads &=
13810 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13811 cmd_reconfig_device_queue(port_id, 1, 1);
13814 printf("invalid port_id %d\n", port_id);
13817 printf("not supported on port %d\n", port_id);
13820 printf("programming error: (%s)\n", strerror(-ret));
13824 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13825 .f = cmd_set_macsec_offload_off_parsed,
13827 .help_str = "set macsec offload <port_id> off",
13829 (void *)&cmd_macsec_offload_off_set,
13830 (void *)&cmd_macsec_offload_off_macsec,
13831 (void *)&cmd_macsec_offload_off_offload,
13832 (void *)&cmd_macsec_offload_off_port_id,
13833 (void *)&cmd_macsec_offload_off_off,
13838 /* Common result structure for MACsec secure connection configure */
13839 struct cmd_macsec_sc_result {
13840 cmdline_fixed_string_t set;
13841 cmdline_fixed_string_t macsec;
13842 cmdline_fixed_string_t sc;
13843 cmdline_fixed_string_t tx_rx;
13845 struct ether_addr mac;
13849 /* Common CLI fields for MACsec secure connection configure */
13850 cmdline_parse_token_string_t cmd_macsec_sc_set =
13851 TOKEN_STRING_INITIALIZER
13852 (struct cmd_macsec_sc_result,
13854 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13855 TOKEN_STRING_INITIALIZER
13856 (struct cmd_macsec_sc_result,
13858 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13859 TOKEN_STRING_INITIALIZER
13860 (struct cmd_macsec_sc_result,
13862 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13863 TOKEN_STRING_INITIALIZER
13864 (struct cmd_macsec_sc_result,
13866 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13867 TOKEN_NUM_INITIALIZER
13868 (struct cmd_macsec_sc_result,
13870 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13871 TOKEN_ETHERADDR_INITIALIZER
13872 (struct cmd_macsec_sc_result,
13874 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13875 TOKEN_NUM_INITIALIZER
13876 (struct cmd_macsec_sc_result,
13880 cmd_set_macsec_sc_parsed(
13881 void *parsed_result,
13882 __attribute__((unused)) struct cmdline *cl,
13883 __attribute__((unused)) void *data)
13885 struct cmd_macsec_sc_result *res = parsed_result;
13886 int ret = -ENOTSUP;
13887 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13889 #ifdef RTE_LIBRTE_IXGBE_PMD
13891 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13892 res->mac.addr_bytes) :
13893 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13894 res->mac.addr_bytes, res->pi);
13896 RTE_SET_USED(is_tx);
13902 printf("invalid port_id %d\n", res->port_id);
13905 printf("not supported on port %d\n", res->port_id);
13908 printf("programming error: (%s)\n", strerror(-ret));
13912 cmdline_parse_inst_t cmd_set_macsec_sc = {
13913 .f = cmd_set_macsec_sc_parsed,
13915 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13917 (void *)&cmd_macsec_sc_set,
13918 (void *)&cmd_macsec_sc_macsec,
13919 (void *)&cmd_macsec_sc_sc,
13920 (void *)&cmd_macsec_sc_tx_rx,
13921 (void *)&cmd_macsec_sc_port_id,
13922 (void *)&cmd_macsec_sc_mac,
13923 (void *)&cmd_macsec_sc_pi,
13928 /* Common result structure for MACsec secure connection configure */
13929 struct cmd_macsec_sa_result {
13930 cmdline_fixed_string_t set;
13931 cmdline_fixed_string_t macsec;
13932 cmdline_fixed_string_t sa;
13933 cmdline_fixed_string_t tx_rx;
13938 cmdline_fixed_string_t key;
13941 /* Common CLI fields for MACsec secure connection configure */
13942 cmdline_parse_token_string_t cmd_macsec_sa_set =
13943 TOKEN_STRING_INITIALIZER
13944 (struct cmd_macsec_sa_result,
13946 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13947 TOKEN_STRING_INITIALIZER
13948 (struct cmd_macsec_sa_result,
13950 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13951 TOKEN_STRING_INITIALIZER
13952 (struct cmd_macsec_sa_result,
13954 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13955 TOKEN_STRING_INITIALIZER
13956 (struct cmd_macsec_sa_result,
13958 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13959 TOKEN_NUM_INITIALIZER
13960 (struct cmd_macsec_sa_result,
13962 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13963 TOKEN_NUM_INITIALIZER
13964 (struct cmd_macsec_sa_result,
13966 cmdline_parse_token_num_t cmd_macsec_sa_an =
13967 TOKEN_NUM_INITIALIZER
13968 (struct cmd_macsec_sa_result,
13970 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13971 TOKEN_NUM_INITIALIZER
13972 (struct cmd_macsec_sa_result,
13974 cmdline_parse_token_string_t cmd_macsec_sa_key =
13975 TOKEN_STRING_INITIALIZER
13976 (struct cmd_macsec_sa_result,
13980 cmd_set_macsec_sa_parsed(
13981 void *parsed_result,
13982 __attribute__((unused)) struct cmdline *cl,
13983 __attribute__((unused)) void *data)
13985 struct cmd_macsec_sa_result *res = parsed_result;
13986 int ret = -ENOTSUP;
13987 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13988 uint8_t key[16] = { 0 };
13994 key_len = strlen(res->key) / 2;
13998 for (i = 0; i < key_len; i++) {
13999 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14002 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14005 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14008 #ifdef RTE_LIBRTE_IXGBE_PMD
14010 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14011 res->idx, res->an, res->pn, key) :
14012 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14013 res->idx, res->an, res->pn, key);
14015 RTE_SET_USED(is_tx);
14022 printf("invalid idx %d or an %d\n", res->idx, res->an);
14025 printf("invalid port_id %d\n", res->port_id);
14028 printf("not supported on port %d\n", res->port_id);
14031 printf("programming error: (%s)\n", strerror(-ret));
14035 cmdline_parse_inst_t cmd_set_macsec_sa = {
14036 .f = cmd_set_macsec_sa_parsed,
14038 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14040 (void *)&cmd_macsec_sa_set,
14041 (void *)&cmd_macsec_sa_macsec,
14042 (void *)&cmd_macsec_sa_sa,
14043 (void *)&cmd_macsec_sa_tx_rx,
14044 (void *)&cmd_macsec_sa_port_id,
14045 (void *)&cmd_macsec_sa_idx,
14046 (void *)&cmd_macsec_sa_an,
14047 (void *)&cmd_macsec_sa_pn,
14048 (void *)&cmd_macsec_sa_key,
14053 /* VF unicast promiscuous mode configuration */
14055 /* Common result structure for VF unicast promiscuous mode */
14056 struct cmd_vf_promisc_result {
14057 cmdline_fixed_string_t set;
14058 cmdline_fixed_string_t vf;
14059 cmdline_fixed_string_t promisc;
14062 cmdline_fixed_string_t on_off;
14065 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14066 cmdline_parse_token_string_t cmd_vf_promisc_set =
14067 TOKEN_STRING_INITIALIZER
14068 (struct cmd_vf_promisc_result,
14070 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14071 TOKEN_STRING_INITIALIZER
14072 (struct cmd_vf_promisc_result,
14074 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14075 TOKEN_STRING_INITIALIZER
14076 (struct cmd_vf_promisc_result,
14077 promisc, "promisc");
14078 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14079 TOKEN_NUM_INITIALIZER
14080 (struct cmd_vf_promisc_result,
14082 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14083 TOKEN_NUM_INITIALIZER
14084 (struct cmd_vf_promisc_result,
14086 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14087 TOKEN_STRING_INITIALIZER
14088 (struct cmd_vf_promisc_result,
14092 cmd_set_vf_promisc_parsed(
14093 void *parsed_result,
14094 __attribute__((unused)) struct cmdline *cl,
14095 __attribute__((unused)) void *data)
14097 struct cmd_vf_promisc_result *res = parsed_result;
14098 int ret = -ENOTSUP;
14100 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14102 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14105 #ifdef RTE_LIBRTE_I40E_PMD
14106 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14107 res->vf_id, is_on);
14114 printf("invalid vf_id %d\n", res->vf_id);
14117 printf("invalid port_id %d\n", res->port_id);
14120 printf("function not implemented\n");
14123 printf("programming error: (%s)\n", strerror(-ret));
14127 cmdline_parse_inst_t cmd_set_vf_promisc = {
14128 .f = cmd_set_vf_promisc_parsed,
14130 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14131 "Set unicast promiscuous mode for a VF from the PF",
14133 (void *)&cmd_vf_promisc_set,
14134 (void *)&cmd_vf_promisc_vf,
14135 (void *)&cmd_vf_promisc_promisc,
14136 (void *)&cmd_vf_promisc_port_id,
14137 (void *)&cmd_vf_promisc_vf_id,
14138 (void *)&cmd_vf_promisc_on_off,
14143 /* VF multicast promiscuous mode configuration */
14145 /* Common result structure for VF multicast promiscuous mode */
14146 struct cmd_vf_allmulti_result {
14147 cmdline_fixed_string_t set;
14148 cmdline_fixed_string_t vf;
14149 cmdline_fixed_string_t allmulti;
14152 cmdline_fixed_string_t on_off;
14155 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14156 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14157 TOKEN_STRING_INITIALIZER
14158 (struct cmd_vf_allmulti_result,
14160 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14161 TOKEN_STRING_INITIALIZER
14162 (struct cmd_vf_allmulti_result,
14164 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14165 TOKEN_STRING_INITIALIZER
14166 (struct cmd_vf_allmulti_result,
14167 allmulti, "allmulti");
14168 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14169 TOKEN_NUM_INITIALIZER
14170 (struct cmd_vf_allmulti_result,
14172 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14173 TOKEN_NUM_INITIALIZER
14174 (struct cmd_vf_allmulti_result,
14176 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14177 TOKEN_STRING_INITIALIZER
14178 (struct cmd_vf_allmulti_result,
14182 cmd_set_vf_allmulti_parsed(
14183 void *parsed_result,
14184 __attribute__((unused)) struct cmdline *cl,
14185 __attribute__((unused)) void *data)
14187 struct cmd_vf_allmulti_result *res = parsed_result;
14188 int ret = -ENOTSUP;
14190 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14192 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14195 #ifdef RTE_LIBRTE_I40E_PMD
14196 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14197 res->vf_id, is_on);
14204 printf("invalid vf_id %d\n", res->vf_id);
14207 printf("invalid port_id %d\n", res->port_id);
14210 printf("function not implemented\n");
14213 printf("programming error: (%s)\n", strerror(-ret));
14217 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14218 .f = cmd_set_vf_allmulti_parsed,
14220 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14221 "Set multicast promiscuous mode for a VF from the PF",
14223 (void *)&cmd_vf_allmulti_set,
14224 (void *)&cmd_vf_allmulti_vf,
14225 (void *)&cmd_vf_allmulti_allmulti,
14226 (void *)&cmd_vf_allmulti_port_id,
14227 (void *)&cmd_vf_allmulti_vf_id,
14228 (void *)&cmd_vf_allmulti_on_off,
14233 /* vf broadcast mode configuration */
14235 /* Common result structure for vf broadcast */
14236 struct cmd_set_vf_broadcast_result {
14237 cmdline_fixed_string_t set;
14238 cmdline_fixed_string_t vf;
14239 cmdline_fixed_string_t broadcast;
14242 cmdline_fixed_string_t on_off;
14245 /* Common CLI fields for vf broadcast enable disable */
14246 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14247 TOKEN_STRING_INITIALIZER
14248 (struct cmd_set_vf_broadcast_result,
14250 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14251 TOKEN_STRING_INITIALIZER
14252 (struct cmd_set_vf_broadcast_result,
14254 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14255 TOKEN_STRING_INITIALIZER
14256 (struct cmd_set_vf_broadcast_result,
14257 broadcast, "broadcast");
14258 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14259 TOKEN_NUM_INITIALIZER
14260 (struct cmd_set_vf_broadcast_result,
14262 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14263 TOKEN_NUM_INITIALIZER
14264 (struct cmd_set_vf_broadcast_result,
14266 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14267 TOKEN_STRING_INITIALIZER
14268 (struct cmd_set_vf_broadcast_result,
14272 cmd_set_vf_broadcast_parsed(
14273 void *parsed_result,
14274 __attribute__((unused)) struct cmdline *cl,
14275 __attribute__((unused)) void *data)
14277 struct cmd_set_vf_broadcast_result *res = parsed_result;
14278 int ret = -ENOTSUP;
14280 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14282 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14285 #ifdef RTE_LIBRTE_I40E_PMD
14286 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14287 res->vf_id, is_on);
14294 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14297 printf("invalid port_id %d\n", res->port_id);
14300 printf("function not implemented\n");
14303 printf("programming error: (%s)\n", strerror(-ret));
14307 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14308 .f = cmd_set_vf_broadcast_parsed,
14310 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14312 (void *)&cmd_set_vf_broadcast_set,
14313 (void *)&cmd_set_vf_broadcast_vf,
14314 (void *)&cmd_set_vf_broadcast_broadcast,
14315 (void *)&cmd_set_vf_broadcast_port_id,
14316 (void *)&cmd_set_vf_broadcast_vf_id,
14317 (void *)&cmd_set_vf_broadcast_on_off,
14322 /* vf vlan tag configuration */
14324 /* Common result structure for vf vlan tag */
14325 struct cmd_set_vf_vlan_tag_result {
14326 cmdline_fixed_string_t set;
14327 cmdline_fixed_string_t vf;
14328 cmdline_fixed_string_t vlan;
14329 cmdline_fixed_string_t tag;
14332 cmdline_fixed_string_t on_off;
14335 /* Common CLI fields for vf vlan tag enable disable */
14336 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14337 TOKEN_STRING_INITIALIZER
14338 (struct cmd_set_vf_vlan_tag_result,
14340 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14341 TOKEN_STRING_INITIALIZER
14342 (struct cmd_set_vf_vlan_tag_result,
14344 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14345 TOKEN_STRING_INITIALIZER
14346 (struct cmd_set_vf_vlan_tag_result,
14348 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14349 TOKEN_STRING_INITIALIZER
14350 (struct cmd_set_vf_vlan_tag_result,
14352 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14353 TOKEN_NUM_INITIALIZER
14354 (struct cmd_set_vf_vlan_tag_result,
14356 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14357 TOKEN_NUM_INITIALIZER
14358 (struct cmd_set_vf_vlan_tag_result,
14360 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14361 TOKEN_STRING_INITIALIZER
14362 (struct cmd_set_vf_vlan_tag_result,
14366 cmd_set_vf_vlan_tag_parsed(
14367 void *parsed_result,
14368 __attribute__((unused)) struct cmdline *cl,
14369 __attribute__((unused)) void *data)
14371 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14372 int ret = -ENOTSUP;
14374 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14376 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14379 #ifdef RTE_LIBRTE_I40E_PMD
14380 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14381 res->vf_id, is_on);
14388 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14391 printf("invalid port_id %d\n", res->port_id);
14394 printf("function not implemented\n");
14397 printf("programming error: (%s)\n", strerror(-ret));
14401 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14402 .f = cmd_set_vf_vlan_tag_parsed,
14404 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14406 (void *)&cmd_set_vf_vlan_tag_set,
14407 (void *)&cmd_set_vf_vlan_tag_vf,
14408 (void *)&cmd_set_vf_vlan_tag_vlan,
14409 (void *)&cmd_set_vf_vlan_tag_tag,
14410 (void *)&cmd_set_vf_vlan_tag_port_id,
14411 (void *)&cmd_set_vf_vlan_tag_vf_id,
14412 (void *)&cmd_set_vf_vlan_tag_on_off,
14417 /* Common definition of VF and TC TX bandwidth configuration */
14418 struct cmd_vf_tc_bw_result {
14419 cmdline_fixed_string_t set;
14420 cmdline_fixed_string_t vf;
14421 cmdline_fixed_string_t tc;
14422 cmdline_fixed_string_t tx;
14423 cmdline_fixed_string_t min_bw;
14424 cmdline_fixed_string_t max_bw;
14425 cmdline_fixed_string_t strict_link_prio;
14430 cmdline_fixed_string_t bw_list;
14434 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14435 TOKEN_STRING_INITIALIZER
14436 (struct cmd_vf_tc_bw_result,
14438 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14439 TOKEN_STRING_INITIALIZER
14440 (struct cmd_vf_tc_bw_result,
14442 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14443 TOKEN_STRING_INITIALIZER
14444 (struct cmd_vf_tc_bw_result,
14446 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14447 TOKEN_STRING_INITIALIZER
14448 (struct cmd_vf_tc_bw_result,
14450 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14451 TOKEN_STRING_INITIALIZER
14452 (struct cmd_vf_tc_bw_result,
14453 strict_link_prio, "strict-link-priority");
14454 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14455 TOKEN_STRING_INITIALIZER
14456 (struct cmd_vf_tc_bw_result,
14457 min_bw, "min-bandwidth");
14458 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14459 TOKEN_STRING_INITIALIZER
14460 (struct cmd_vf_tc_bw_result,
14461 max_bw, "max-bandwidth");
14462 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14463 TOKEN_NUM_INITIALIZER
14464 (struct cmd_vf_tc_bw_result,
14466 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14467 TOKEN_NUM_INITIALIZER
14468 (struct cmd_vf_tc_bw_result,
14470 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14471 TOKEN_NUM_INITIALIZER
14472 (struct cmd_vf_tc_bw_result,
14474 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14475 TOKEN_NUM_INITIALIZER
14476 (struct cmd_vf_tc_bw_result,
14478 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14479 TOKEN_STRING_INITIALIZER
14480 (struct cmd_vf_tc_bw_result,
14482 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14483 TOKEN_NUM_INITIALIZER
14484 (struct cmd_vf_tc_bw_result,
14487 /* VF max bandwidth setting */
14489 cmd_vf_max_bw_parsed(
14490 void *parsed_result,
14491 __attribute__((unused)) struct cmdline *cl,
14492 __attribute__((unused)) void *data)
14494 struct cmd_vf_tc_bw_result *res = parsed_result;
14495 int ret = -ENOTSUP;
14497 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14500 #ifdef RTE_LIBRTE_I40E_PMD
14501 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14502 res->vf_id, res->bw);
14509 printf("invalid vf_id %d or bandwidth %d\n",
14510 res->vf_id, res->bw);
14513 printf("invalid port_id %d\n", res->port_id);
14516 printf("function not implemented\n");
14519 printf("programming error: (%s)\n", strerror(-ret));
14523 cmdline_parse_inst_t cmd_vf_max_bw = {
14524 .f = cmd_vf_max_bw_parsed,
14526 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14528 (void *)&cmd_vf_tc_bw_set,
14529 (void *)&cmd_vf_tc_bw_vf,
14530 (void *)&cmd_vf_tc_bw_tx,
14531 (void *)&cmd_vf_tc_bw_max_bw,
14532 (void *)&cmd_vf_tc_bw_port_id,
14533 (void *)&cmd_vf_tc_bw_vf_id,
14534 (void *)&cmd_vf_tc_bw_bw,
14540 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14545 const char *p, *p0 = str;
14552 p = strchr(p0, '(');
14554 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14558 p0 = strchr(p, ')');
14560 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14564 if (size >= sizeof(s)) {
14565 printf("The string size exceeds the internal buffer size\n");
14568 snprintf(s, sizeof(s), "%.*s", size, p);
14569 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14571 printf("Failed to get the bandwidth list. ");
14575 for (i = 0; i < ret; i++)
14576 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14581 /* TC min bandwidth setting */
14583 cmd_vf_tc_min_bw_parsed(
14584 void *parsed_result,
14585 __attribute__((unused)) struct cmdline *cl,
14586 __attribute__((unused)) void *data)
14588 struct cmd_vf_tc_bw_result *res = parsed_result;
14591 int ret = -ENOTSUP;
14593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14596 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14600 #ifdef RTE_LIBRTE_I40E_PMD
14601 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14609 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14612 printf("invalid port_id %d\n", res->port_id);
14615 printf("function not implemented\n");
14618 printf("programming error: (%s)\n", strerror(-ret));
14622 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14623 .f = cmd_vf_tc_min_bw_parsed,
14625 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14626 " <bw1, bw2, ...>",
14628 (void *)&cmd_vf_tc_bw_set,
14629 (void *)&cmd_vf_tc_bw_vf,
14630 (void *)&cmd_vf_tc_bw_tc,
14631 (void *)&cmd_vf_tc_bw_tx,
14632 (void *)&cmd_vf_tc_bw_min_bw,
14633 (void *)&cmd_vf_tc_bw_port_id,
14634 (void *)&cmd_vf_tc_bw_vf_id,
14635 (void *)&cmd_vf_tc_bw_bw_list,
14641 cmd_tc_min_bw_parsed(
14642 void *parsed_result,
14643 __attribute__((unused)) struct cmdline *cl,
14644 __attribute__((unused)) void *data)
14646 struct cmd_vf_tc_bw_result *res = parsed_result;
14647 struct rte_port *port;
14650 int ret = -ENOTSUP;
14652 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14655 port = &ports[res->port_id];
14656 /** Check if the port is not started **/
14657 if (port->port_status != RTE_PORT_STOPPED) {
14658 printf("Please stop port %d first\n", res->port_id);
14662 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14666 #ifdef RTE_LIBRTE_IXGBE_PMD
14667 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14674 printf("invalid bandwidth\n");
14677 printf("invalid port_id %d\n", res->port_id);
14680 printf("function not implemented\n");
14683 printf("programming error: (%s)\n", strerror(-ret));
14687 cmdline_parse_inst_t cmd_tc_min_bw = {
14688 .f = cmd_tc_min_bw_parsed,
14690 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14692 (void *)&cmd_vf_tc_bw_set,
14693 (void *)&cmd_vf_tc_bw_tc,
14694 (void *)&cmd_vf_tc_bw_tx,
14695 (void *)&cmd_vf_tc_bw_min_bw,
14696 (void *)&cmd_vf_tc_bw_port_id,
14697 (void *)&cmd_vf_tc_bw_bw_list,
14702 /* TC max bandwidth setting */
14704 cmd_vf_tc_max_bw_parsed(
14705 void *parsed_result,
14706 __attribute__((unused)) struct cmdline *cl,
14707 __attribute__((unused)) void *data)
14709 struct cmd_vf_tc_bw_result *res = parsed_result;
14710 int ret = -ENOTSUP;
14712 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14715 #ifdef RTE_LIBRTE_I40E_PMD
14716 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14717 res->tc_no, res->bw);
14724 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14725 res->vf_id, res->tc_no, res->bw);
14728 printf("invalid port_id %d\n", res->port_id);
14731 printf("function not implemented\n");
14734 printf("programming error: (%s)\n", strerror(-ret));
14738 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14739 .f = cmd_vf_tc_max_bw_parsed,
14741 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14744 (void *)&cmd_vf_tc_bw_set,
14745 (void *)&cmd_vf_tc_bw_vf,
14746 (void *)&cmd_vf_tc_bw_tc,
14747 (void *)&cmd_vf_tc_bw_tx,
14748 (void *)&cmd_vf_tc_bw_max_bw,
14749 (void *)&cmd_vf_tc_bw_port_id,
14750 (void *)&cmd_vf_tc_bw_vf_id,
14751 (void *)&cmd_vf_tc_bw_tc_no,
14752 (void *)&cmd_vf_tc_bw_bw,
14758 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14760 /* *** Set Port default Traffic Management Hierarchy *** */
14761 struct cmd_set_port_tm_hierarchy_default_result {
14762 cmdline_fixed_string_t set;
14763 cmdline_fixed_string_t port;
14764 cmdline_fixed_string_t tm;
14765 cmdline_fixed_string_t hierarchy;
14766 cmdline_fixed_string_t def;
14770 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14771 TOKEN_STRING_INITIALIZER(
14772 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14773 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14774 TOKEN_STRING_INITIALIZER(
14775 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14776 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14777 TOKEN_STRING_INITIALIZER(
14778 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14779 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14780 TOKEN_STRING_INITIALIZER(
14781 struct cmd_set_port_tm_hierarchy_default_result,
14782 hierarchy, "hierarchy");
14783 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14784 TOKEN_STRING_INITIALIZER(
14785 struct cmd_set_port_tm_hierarchy_default_result,
14787 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14788 TOKEN_NUM_INITIALIZER(
14789 struct cmd_set_port_tm_hierarchy_default_result,
14792 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14793 __attribute__((unused)) struct cmdline *cl,
14794 __attribute__((unused)) void *data)
14796 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14797 struct rte_port *p;
14798 portid_t port_id = res->port_id;
14800 if (port_id_is_invalid(port_id, ENABLED_WARN))
14803 p = &ports[port_id];
14806 if (p->softport.tm_flag == 0) {
14807 printf(" tm not enabled on port %u (error)\n", port_id);
14811 /* Forward mode: tm */
14812 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14813 printf(" tm mode not enabled(error)\n");
14817 /* Set the default tm hierarchy */
14818 p->softport.tm.default_hierarchy_enable = 1;
14821 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14822 .f = cmd_set_port_tm_hierarchy_default_parsed,
14824 .help_str = "set port tm hierarchy default <port_id>",
14826 (void *)&cmd_set_port_tm_hierarchy_default_set,
14827 (void *)&cmd_set_port_tm_hierarchy_default_port,
14828 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14829 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14830 (void *)&cmd_set_port_tm_hierarchy_default_default,
14831 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14837 /* Strict link priority scheduling mode setting */
14839 cmd_strict_link_prio_parsed(
14840 void *parsed_result,
14841 __attribute__((unused)) struct cmdline *cl,
14842 __attribute__((unused)) void *data)
14844 struct cmd_vf_tc_bw_result *res = parsed_result;
14845 int ret = -ENOTSUP;
14847 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14850 #ifdef RTE_LIBRTE_I40E_PMD
14851 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14858 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14861 printf("invalid port_id %d\n", res->port_id);
14864 printf("function not implemented\n");
14867 printf("programming error: (%s)\n", strerror(-ret));
14871 cmdline_parse_inst_t cmd_strict_link_prio = {
14872 .f = cmd_strict_link_prio_parsed,
14874 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14876 (void *)&cmd_vf_tc_bw_set,
14877 (void *)&cmd_vf_tc_bw_tx,
14878 (void *)&cmd_vf_tc_bw_strict_link_prio,
14879 (void *)&cmd_vf_tc_bw_port_id,
14880 (void *)&cmd_vf_tc_bw_tc_map,
14885 /* Load dynamic device personalization*/
14886 struct cmd_ddp_add_result {
14887 cmdline_fixed_string_t ddp;
14888 cmdline_fixed_string_t add;
14893 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14894 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14895 cmdline_parse_token_string_t cmd_ddp_add_add =
14896 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14897 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14898 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14899 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14900 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14903 cmd_ddp_add_parsed(
14904 void *parsed_result,
14905 __attribute__((unused)) struct cmdline *cl,
14906 __attribute__((unused)) void *data)
14908 struct cmd_ddp_add_result *res = parsed_result;
14914 int ret = -ENOTSUP;
14916 if (!all_ports_stopped()) {
14917 printf("Please stop all ports first\n");
14921 filepath = strdup(res->filepath);
14922 if (filepath == NULL) {
14923 printf("Failed to allocate memory\n");
14926 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14928 buff = open_file(file_fld[0], &size);
14930 free((void *)filepath);
14934 #ifdef RTE_LIBRTE_I40E_PMD
14935 if (ret == -ENOTSUP)
14936 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14938 RTE_PMD_I40E_PKG_OP_WR_ADD);
14941 if (ret == -EEXIST)
14942 printf("Profile has already existed.\n");
14944 printf("Failed to load profile.\n");
14945 else if (file_num == 2)
14946 save_file(file_fld[1], buff, size);
14949 free((void *)filepath);
14952 cmdline_parse_inst_t cmd_ddp_add = {
14953 .f = cmd_ddp_add_parsed,
14955 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14957 (void *)&cmd_ddp_add_ddp,
14958 (void *)&cmd_ddp_add_add,
14959 (void *)&cmd_ddp_add_port_id,
14960 (void *)&cmd_ddp_add_filepath,
14965 /* Delete dynamic device personalization*/
14966 struct cmd_ddp_del_result {
14967 cmdline_fixed_string_t ddp;
14968 cmdline_fixed_string_t del;
14973 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14974 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14975 cmdline_parse_token_string_t cmd_ddp_del_del =
14976 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14977 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14978 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14979 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14980 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14983 cmd_ddp_del_parsed(
14984 void *parsed_result,
14985 __attribute__((unused)) struct cmdline *cl,
14986 __attribute__((unused)) void *data)
14988 struct cmd_ddp_del_result *res = parsed_result;
14991 int ret = -ENOTSUP;
14993 if (!all_ports_stopped()) {
14994 printf("Please stop all ports first\n");
14998 buff = open_file(res->filepath, &size);
15002 #ifdef RTE_LIBRTE_I40E_PMD
15003 if (ret == -ENOTSUP)
15004 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15006 RTE_PMD_I40E_PKG_OP_WR_DEL);
15009 if (ret == -EACCES)
15010 printf("Profile does not exist.\n");
15012 printf("Failed to delete profile.\n");
15017 cmdline_parse_inst_t cmd_ddp_del = {
15018 .f = cmd_ddp_del_parsed,
15020 .help_str = "ddp del <port_id> <backup_profile_path>",
15022 (void *)&cmd_ddp_del_ddp,
15023 (void *)&cmd_ddp_del_del,
15024 (void *)&cmd_ddp_del_port_id,
15025 (void *)&cmd_ddp_del_filepath,
15030 /* Get dynamic device personalization profile info */
15031 struct cmd_ddp_info_result {
15032 cmdline_fixed_string_t ddp;
15033 cmdline_fixed_string_t get;
15034 cmdline_fixed_string_t info;
15038 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15039 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15040 cmdline_parse_token_string_t cmd_ddp_info_get =
15041 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15042 cmdline_parse_token_string_t cmd_ddp_info_info =
15043 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15044 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15045 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15048 cmd_ddp_info_parsed(
15049 void *parsed_result,
15050 __attribute__((unused)) struct cmdline *cl,
15051 __attribute__((unused)) void *data)
15053 struct cmd_ddp_info_result *res = parsed_result;
15056 int ret = -ENOTSUP;
15057 #ifdef RTE_LIBRTE_I40E_PMD
15060 uint32_t buff_size = 0;
15061 struct rte_pmd_i40e_profile_info info;
15062 uint32_t dev_num = 0;
15063 struct rte_pmd_i40e_ddp_device_id *devs;
15064 uint32_t proto_num = 0;
15065 struct rte_pmd_i40e_proto_info *proto = NULL;
15066 uint32_t pctype_num = 0;
15067 struct rte_pmd_i40e_ptype_info *pctype;
15068 uint32_t ptype_num = 0;
15069 struct rte_pmd_i40e_ptype_info *ptype;
15074 pkg = open_file(res->filepath, &pkg_size);
15078 #ifdef RTE_LIBRTE_I40E_PMD
15079 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15080 (uint8_t *)&info, sizeof(info),
15081 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15083 printf("Global Track id: 0x%x\n", info.track_id);
15084 printf("Global Version: %d.%d.%d.%d\n",
15085 info.version.major,
15086 info.version.minor,
15087 info.version.update,
15088 info.version.draft);
15089 printf("Global Package name: %s\n\n", info.name);
15092 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15093 (uint8_t *)&info, sizeof(info),
15094 RTE_PMD_I40E_PKG_INFO_HEADER);
15096 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15097 printf("i40e Profile Version: %d.%d.%d.%d\n",
15098 info.version.major,
15099 info.version.minor,
15100 info.version.update,
15101 info.version.draft);
15102 printf("i40e Profile name: %s\n\n", info.name);
15105 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15106 (uint8_t *)&buff_size, sizeof(buff_size),
15107 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15108 if (!ret && buff_size) {
15109 buff = (uint8_t *)malloc(buff_size);
15111 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15113 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15115 printf("Package Notes:\n%s\n\n", buff);
15120 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15121 (uint8_t *)&dev_num, sizeof(dev_num),
15122 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15123 if (!ret && dev_num) {
15124 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15125 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15127 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15128 (uint8_t *)devs, buff_size,
15129 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15131 printf("List of supported devices:\n");
15132 for (i = 0; i < dev_num; i++) {
15133 printf(" %04X:%04X %04X:%04X\n",
15134 devs[i].vendor_dev_id >> 16,
15135 devs[i].vendor_dev_id & 0xFFFF,
15136 devs[i].sub_vendor_dev_id >> 16,
15137 devs[i].sub_vendor_dev_id & 0xFFFF);
15145 /* get information about protocols and packet types */
15146 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15147 (uint8_t *)&proto_num, sizeof(proto_num),
15148 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15149 if (ret || !proto_num)
15150 goto no_print_return;
15152 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15153 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15155 goto no_print_return;
15157 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15159 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15161 printf("List of used protocols:\n");
15162 for (i = 0; i < proto_num; i++)
15163 printf(" %2u: %s\n", proto[i].proto_id,
15167 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15168 (uint8_t *)&pctype_num, sizeof(pctype_num),
15169 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15170 if (ret || !pctype_num)
15171 goto no_print_pctypes;
15173 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15174 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15176 goto no_print_pctypes;
15178 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15180 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15183 goto no_print_pctypes;
15186 printf("List of defined packet classification types:\n");
15187 for (i = 0; i < pctype_num; i++) {
15188 printf(" %2u:", pctype[i].ptype_id);
15189 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15190 proto_id = pctype[i].protocols[j];
15191 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15192 for (n = 0; n < proto_num; n++) {
15193 if (proto[n].proto_id == proto_id) {
15194 printf(" %s", proto[n].name);
15207 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15209 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15210 if (ret || !ptype_num)
15211 goto no_print_return;
15213 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15214 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15216 goto no_print_return;
15218 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15220 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15223 goto no_print_return;
15225 printf("List of defined packet types:\n");
15226 for (i = 0; i < ptype_num; i++) {
15227 printf(" %2u:", ptype[i].ptype_id);
15228 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15229 proto_id = ptype[i].protocols[j];
15230 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15231 for (n = 0; n < proto_num; n++) {
15232 if (proto[n].proto_id == proto_id) {
15233 printf(" %s", proto[n].name);
15249 if (ret == -ENOTSUP)
15250 printf("Function not supported in PMD driver\n");
15254 cmdline_parse_inst_t cmd_ddp_get_info = {
15255 .f = cmd_ddp_info_parsed,
15257 .help_str = "ddp get info <profile_path>",
15259 (void *)&cmd_ddp_info_ddp,
15260 (void *)&cmd_ddp_info_get,
15261 (void *)&cmd_ddp_info_info,
15262 (void *)&cmd_ddp_info_filepath,
15267 /* Get dynamic device personalization profile info list*/
15268 #define PROFILE_INFO_SIZE 48
15269 #define MAX_PROFILE_NUM 16
15271 struct cmd_ddp_get_list_result {
15272 cmdline_fixed_string_t ddp;
15273 cmdline_fixed_string_t get;
15274 cmdline_fixed_string_t list;
15278 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15279 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15280 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15281 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15282 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15283 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15284 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15285 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15288 cmd_ddp_get_list_parsed(
15289 __attribute__((unused)) void *parsed_result,
15290 __attribute__((unused)) struct cmdline *cl,
15291 __attribute__((unused)) void *data)
15293 #ifdef RTE_LIBRTE_I40E_PMD
15294 struct cmd_ddp_get_list_result *res = parsed_result;
15295 struct rte_pmd_i40e_profile_list *p_list;
15296 struct rte_pmd_i40e_profile_info *p_info;
15301 int ret = -ENOTSUP;
15303 #ifdef RTE_LIBRTE_I40E_PMD
15304 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15305 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15307 printf("%s: Failed to malloc buffer\n", __func__);
15309 if (ret == -ENOTSUP)
15310 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15311 (uint8_t *)p_list, size);
15314 p_num = p_list->p_count;
15315 printf("Profile number is: %d\n\n", p_num);
15317 for (i = 0; i < p_num; i++) {
15318 p_info = &p_list->p_info[i];
15319 printf("Profile %d:\n", i);
15320 printf("Track id: 0x%x\n", p_info->track_id);
15321 printf("Version: %d.%d.%d.%d\n",
15322 p_info->version.major,
15323 p_info->version.minor,
15324 p_info->version.update,
15325 p_info->version.draft);
15326 printf("Profile name: %s\n\n", p_info->name);
15334 printf("Failed to get ddp list\n");
15337 cmdline_parse_inst_t cmd_ddp_get_list = {
15338 .f = cmd_ddp_get_list_parsed,
15340 .help_str = "ddp get list <port_id>",
15342 (void *)&cmd_ddp_get_list_ddp,
15343 (void *)&cmd_ddp_get_list_get,
15344 (void *)&cmd_ddp_get_list_list,
15345 (void *)&cmd_ddp_get_list_port_id,
15350 /* Configure input set */
15351 struct cmd_cfg_input_set_result {
15352 cmdline_fixed_string_t port;
15353 cmdline_fixed_string_t cfg;
15355 cmdline_fixed_string_t pctype;
15357 cmdline_fixed_string_t inset_type;
15358 cmdline_fixed_string_t opt;
15359 cmdline_fixed_string_t field;
15364 cmd_cfg_input_set_parsed(
15365 __attribute__((unused)) void *parsed_result,
15366 __attribute__((unused)) struct cmdline *cl,
15367 __attribute__((unused)) void *data)
15369 #ifdef RTE_LIBRTE_I40E_PMD
15370 struct cmd_cfg_input_set_result *res = parsed_result;
15371 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15372 struct rte_pmd_i40e_inset inset;
15374 int ret = -ENOTSUP;
15376 if (!all_ports_stopped()) {
15377 printf("Please stop all ports first\n");
15381 #ifdef RTE_LIBRTE_I40E_PMD
15382 if (!strcmp(res->inset_type, "hash_inset"))
15383 inset_type = INSET_HASH;
15384 else if (!strcmp(res->inset_type, "fdir_inset"))
15385 inset_type = INSET_FDIR;
15386 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15387 inset_type = INSET_FDIR_FLX;
15388 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15389 &inset, inset_type);
15391 printf("Failed to get input set.\n");
15395 if (!strcmp(res->opt, "get")) {
15396 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15399 printf("Field index %d is enabled.\n", res->field_idx);
15401 printf("Field index %d is disabled.\n", res->field_idx);
15403 } else if (!strcmp(res->opt, "set"))
15404 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15406 else if (!strcmp(res->opt, "clear"))
15407 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15410 printf("Failed to configure input set field.\n");
15414 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15415 &inset, inset_type);
15417 printf("Failed to set input set.\n");
15422 if (ret == -ENOTSUP)
15423 printf("Function not supported\n");
15426 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15427 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15429 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15430 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15432 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15433 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15435 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15436 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15438 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15439 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15441 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15442 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15444 "hash_inset#fdir_inset#fdir_flx_inset");
15445 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15446 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15447 opt, "get#set#clear");
15448 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15449 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15451 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15452 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15455 cmdline_parse_inst_t cmd_cfg_input_set = {
15456 .f = cmd_cfg_input_set_parsed,
15458 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15459 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15461 (void *)&cmd_cfg_input_set_port,
15462 (void *)&cmd_cfg_input_set_cfg,
15463 (void *)&cmd_cfg_input_set_port_id,
15464 (void *)&cmd_cfg_input_set_pctype,
15465 (void *)&cmd_cfg_input_set_pctype_id,
15466 (void *)&cmd_cfg_input_set_inset_type,
15467 (void *)&cmd_cfg_input_set_opt,
15468 (void *)&cmd_cfg_input_set_field,
15469 (void *)&cmd_cfg_input_set_field_idx,
15474 /* Clear input set */
15475 struct cmd_clear_input_set_result {
15476 cmdline_fixed_string_t port;
15477 cmdline_fixed_string_t cfg;
15479 cmdline_fixed_string_t pctype;
15481 cmdline_fixed_string_t inset_type;
15482 cmdline_fixed_string_t clear;
15483 cmdline_fixed_string_t all;
15487 cmd_clear_input_set_parsed(
15488 __attribute__((unused)) void *parsed_result,
15489 __attribute__((unused)) struct cmdline *cl,
15490 __attribute__((unused)) void *data)
15492 #ifdef RTE_LIBRTE_I40E_PMD
15493 struct cmd_clear_input_set_result *res = parsed_result;
15494 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15495 struct rte_pmd_i40e_inset inset;
15497 int ret = -ENOTSUP;
15499 if (!all_ports_stopped()) {
15500 printf("Please stop all ports first\n");
15504 #ifdef RTE_LIBRTE_I40E_PMD
15505 if (!strcmp(res->inset_type, "hash_inset"))
15506 inset_type = INSET_HASH;
15507 else if (!strcmp(res->inset_type, "fdir_inset"))
15508 inset_type = INSET_FDIR;
15509 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15510 inset_type = INSET_FDIR_FLX;
15512 memset(&inset, 0, sizeof(inset));
15514 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15515 &inset, inset_type);
15517 printf("Failed to clear input set.\n");
15523 if (ret == -ENOTSUP)
15524 printf("Function not supported\n");
15527 cmdline_parse_token_string_t cmd_clear_input_set_port =
15528 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15530 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15531 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15533 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15534 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15536 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15537 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15539 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15540 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15542 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15543 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15545 "hash_inset#fdir_inset#fdir_flx_inset");
15546 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15547 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15549 cmdline_parse_token_string_t cmd_clear_input_set_all =
15550 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15553 cmdline_parse_inst_t cmd_clear_input_set = {
15554 .f = cmd_clear_input_set_parsed,
15556 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15557 "fdir_inset|fdir_flx_inset clear all",
15559 (void *)&cmd_clear_input_set_port,
15560 (void *)&cmd_clear_input_set_cfg,
15561 (void *)&cmd_clear_input_set_port_id,
15562 (void *)&cmd_clear_input_set_pctype,
15563 (void *)&cmd_clear_input_set_pctype_id,
15564 (void *)&cmd_clear_input_set_inset_type,
15565 (void *)&cmd_clear_input_set_clear,
15566 (void *)&cmd_clear_input_set_all,
15571 /* show vf stats */
15573 /* Common result structure for show vf stats */
15574 struct cmd_show_vf_stats_result {
15575 cmdline_fixed_string_t show;
15576 cmdline_fixed_string_t vf;
15577 cmdline_fixed_string_t stats;
15582 /* Common CLI fields show vf stats*/
15583 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15584 TOKEN_STRING_INITIALIZER
15585 (struct cmd_show_vf_stats_result,
15587 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15588 TOKEN_STRING_INITIALIZER
15589 (struct cmd_show_vf_stats_result,
15591 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15592 TOKEN_STRING_INITIALIZER
15593 (struct cmd_show_vf_stats_result,
15595 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15596 TOKEN_NUM_INITIALIZER
15597 (struct cmd_show_vf_stats_result,
15599 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15600 TOKEN_NUM_INITIALIZER
15601 (struct cmd_show_vf_stats_result,
15605 cmd_show_vf_stats_parsed(
15606 void *parsed_result,
15607 __attribute__((unused)) struct cmdline *cl,
15608 __attribute__((unused)) void *data)
15610 struct cmd_show_vf_stats_result *res = parsed_result;
15611 struct rte_eth_stats stats;
15612 int ret = -ENOTSUP;
15613 static const char *nic_stats_border = "########################";
15615 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15618 memset(&stats, 0, sizeof(stats));
15620 #ifdef RTE_LIBRTE_I40E_PMD
15621 if (ret == -ENOTSUP)
15622 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15626 #ifdef RTE_LIBRTE_BNXT_PMD
15627 if (ret == -ENOTSUP)
15628 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15637 printf("invalid vf_id %d\n", res->vf_id);
15640 printf("invalid port_id %d\n", res->port_id);
15643 printf("function not implemented\n");
15646 printf("programming error: (%s)\n", strerror(-ret));
15649 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15650 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15652 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15654 stats.ipackets, stats.imissed, stats.ibytes);
15655 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15656 printf(" RX-nombuf: %-10"PRIu64"\n",
15658 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15660 stats.opackets, stats.oerrors, stats.obytes);
15662 printf(" %s############################%s\n",
15663 nic_stats_border, nic_stats_border);
15666 cmdline_parse_inst_t cmd_show_vf_stats = {
15667 .f = cmd_show_vf_stats_parsed,
15669 .help_str = "show vf stats <port_id> <vf_id>",
15671 (void *)&cmd_show_vf_stats_show,
15672 (void *)&cmd_show_vf_stats_vf,
15673 (void *)&cmd_show_vf_stats_stats,
15674 (void *)&cmd_show_vf_stats_port_id,
15675 (void *)&cmd_show_vf_stats_vf_id,
15680 /* clear vf stats */
15682 /* Common result structure for clear vf stats */
15683 struct cmd_clear_vf_stats_result {
15684 cmdline_fixed_string_t clear;
15685 cmdline_fixed_string_t vf;
15686 cmdline_fixed_string_t stats;
15691 /* Common CLI fields clear vf stats*/
15692 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15693 TOKEN_STRING_INITIALIZER
15694 (struct cmd_clear_vf_stats_result,
15696 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15697 TOKEN_STRING_INITIALIZER
15698 (struct cmd_clear_vf_stats_result,
15700 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15701 TOKEN_STRING_INITIALIZER
15702 (struct cmd_clear_vf_stats_result,
15704 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15705 TOKEN_NUM_INITIALIZER
15706 (struct cmd_clear_vf_stats_result,
15708 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15709 TOKEN_NUM_INITIALIZER
15710 (struct cmd_clear_vf_stats_result,
15714 cmd_clear_vf_stats_parsed(
15715 void *parsed_result,
15716 __attribute__((unused)) struct cmdline *cl,
15717 __attribute__((unused)) void *data)
15719 struct cmd_clear_vf_stats_result *res = parsed_result;
15720 int ret = -ENOTSUP;
15722 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15725 #ifdef RTE_LIBRTE_I40E_PMD
15726 if (ret == -ENOTSUP)
15727 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15730 #ifdef RTE_LIBRTE_BNXT_PMD
15731 if (ret == -ENOTSUP)
15732 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15740 printf("invalid vf_id %d\n", res->vf_id);
15743 printf("invalid port_id %d\n", res->port_id);
15746 printf("function not implemented\n");
15749 printf("programming error: (%s)\n", strerror(-ret));
15753 cmdline_parse_inst_t cmd_clear_vf_stats = {
15754 .f = cmd_clear_vf_stats_parsed,
15756 .help_str = "clear vf stats <port_id> <vf_id>",
15758 (void *)&cmd_clear_vf_stats_clear,
15759 (void *)&cmd_clear_vf_stats_vf,
15760 (void *)&cmd_clear_vf_stats_stats,
15761 (void *)&cmd_clear_vf_stats_port_id,
15762 (void *)&cmd_clear_vf_stats_vf_id,
15767 /* port config pctype mapping reset */
15769 /* Common result structure for port config pctype mapping reset */
15770 struct cmd_pctype_mapping_reset_result {
15771 cmdline_fixed_string_t port;
15772 cmdline_fixed_string_t config;
15774 cmdline_fixed_string_t pctype;
15775 cmdline_fixed_string_t mapping;
15776 cmdline_fixed_string_t reset;
15779 /* Common CLI fields for port config pctype mapping reset*/
15780 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15781 TOKEN_STRING_INITIALIZER
15782 (struct cmd_pctype_mapping_reset_result,
15784 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15785 TOKEN_STRING_INITIALIZER
15786 (struct cmd_pctype_mapping_reset_result,
15788 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15789 TOKEN_NUM_INITIALIZER
15790 (struct cmd_pctype_mapping_reset_result,
15792 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15793 TOKEN_STRING_INITIALIZER
15794 (struct cmd_pctype_mapping_reset_result,
15796 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15797 TOKEN_STRING_INITIALIZER
15798 (struct cmd_pctype_mapping_reset_result,
15799 mapping, "mapping");
15800 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15801 TOKEN_STRING_INITIALIZER
15802 (struct cmd_pctype_mapping_reset_result,
15806 cmd_pctype_mapping_reset_parsed(
15807 void *parsed_result,
15808 __attribute__((unused)) struct cmdline *cl,
15809 __attribute__((unused)) void *data)
15811 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15812 int ret = -ENOTSUP;
15814 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15817 #ifdef RTE_LIBRTE_I40E_PMD
15818 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15825 printf("invalid port_id %d\n", res->port_id);
15828 printf("function not implemented\n");
15831 printf("programming error: (%s)\n", strerror(-ret));
15835 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15836 .f = cmd_pctype_mapping_reset_parsed,
15838 .help_str = "port config <port_id> pctype mapping reset",
15840 (void *)&cmd_pctype_mapping_reset_port,
15841 (void *)&cmd_pctype_mapping_reset_config,
15842 (void *)&cmd_pctype_mapping_reset_port_id,
15843 (void *)&cmd_pctype_mapping_reset_pctype,
15844 (void *)&cmd_pctype_mapping_reset_mapping,
15845 (void *)&cmd_pctype_mapping_reset_reset,
15850 /* show port pctype mapping */
15852 /* Common result structure for show port pctype mapping */
15853 struct cmd_pctype_mapping_get_result {
15854 cmdline_fixed_string_t show;
15855 cmdline_fixed_string_t port;
15857 cmdline_fixed_string_t pctype;
15858 cmdline_fixed_string_t mapping;
15861 /* Common CLI fields for pctype mapping get */
15862 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15863 TOKEN_STRING_INITIALIZER
15864 (struct cmd_pctype_mapping_get_result,
15866 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15867 TOKEN_STRING_INITIALIZER
15868 (struct cmd_pctype_mapping_get_result,
15870 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15871 TOKEN_NUM_INITIALIZER
15872 (struct cmd_pctype_mapping_get_result,
15874 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15875 TOKEN_STRING_INITIALIZER
15876 (struct cmd_pctype_mapping_get_result,
15878 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15879 TOKEN_STRING_INITIALIZER
15880 (struct cmd_pctype_mapping_get_result,
15881 mapping, "mapping");
15884 cmd_pctype_mapping_get_parsed(
15885 void *parsed_result,
15886 __attribute__((unused)) struct cmdline *cl,
15887 __attribute__((unused)) void *data)
15889 struct cmd_pctype_mapping_get_result *res = parsed_result;
15890 int ret = -ENOTSUP;
15891 #ifdef RTE_LIBRTE_I40E_PMD
15892 struct rte_pmd_i40e_flow_type_mapping
15893 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15894 int i, j, first_pctype;
15897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15900 #ifdef RTE_LIBRTE_I40E_PMD
15901 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15908 printf("invalid port_id %d\n", res->port_id);
15911 printf("function not implemented\n");
15914 printf("programming error: (%s)\n", strerror(-ret));
15918 #ifdef RTE_LIBRTE_I40E_PMD
15919 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15920 if (mapping[i].pctype != 0ULL) {
15923 printf("pctype: ");
15924 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15925 if (mapping[i].pctype & (1ULL << j)) {
15926 printf(first_pctype ?
15927 "%02d" : ",%02d", j);
15931 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15937 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15938 .f = cmd_pctype_mapping_get_parsed,
15940 .help_str = "show port <port_id> pctype mapping",
15942 (void *)&cmd_pctype_mapping_get_show,
15943 (void *)&cmd_pctype_mapping_get_port,
15944 (void *)&cmd_pctype_mapping_get_port_id,
15945 (void *)&cmd_pctype_mapping_get_pctype,
15946 (void *)&cmd_pctype_mapping_get_mapping,
15951 /* port config pctype mapping update */
15953 /* Common result structure for port config pctype mapping update */
15954 struct cmd_pctype_mapping_update_result {
15955 cmdline_fixed_string_t port;
15956 cmdline_fixed_string_t config;
15958 cmdline_fixed_string_t pctype;
15959 cmdline_fixed_string_t mapping;
15960 cmdline_fixed_string_t update;
15961 cmdline_fixed_string_t pctype_list;
15962 uint16_t flow_type;
15965 /* Common CLI fields for pctype mapping update*/
15966 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15967 TOKEN_STRING_INITIALIZER
15968 (struct cmd_pctype_mapping_update_result,
15970 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15971 TOKEN_STRING_INITIALIZER
15972 (struct cmd_pctype_mapping_update_result,
15974 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15975 TOKEN_NUM_INITIALIZER
15976 (struct cmd_pctype_mapping_update_result,
15978 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15979 TOKEN_STRING_INITIALIZER
15980 (struct cmd_pctype_mapping_update_result,
15982 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15983 TOKEN_STRING_INITIALIZER
15984 (struct cmd_pctype_mapping_update_result,
15985 mapping, "mapping");
15986 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15987 TOKEN_STRING_INITIALIZER
15988 (struct cmd_pctype_mapping_update_result,
15990 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15991 TOKEN_STRING_INITIALIZER
15992 (struct cmd_pctype_mapping_update_result,
15993 pctype_list, NULL);
15994 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15995 TOKEN_NUM_INITIALIZER
15996 (struct cmd_pctype_mapping_update_result,
15997 flow_type, UINT16);
16000 cmd_pctype_mapping_update_parsed(
16001 void *parsed_result,
16002 __attribute__((unused)) struct cmdline *cl,
16003 __attribute__((unused)) void *data)
16005 struct cmd_pctype_mapping_update_result *res = parsed_result;
16006 int ret = -ENOTSUP;
16007 #ifdef RTE_LIBRTE_I40E_PMD
16008 struct rte_pmd_i40e_flow_type_mapping mapping;
16010 unsigned int nb_item;
16011 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16014 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16017 #ifdef RTE_LIBRTE_I40E_PMD
16018 nb_item = parse_item_list(res->pctype_list, "pctypes",
16019 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16020 mapping.flow_type = res->flow_type;
16021 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16022 mapping.pctype |= (1ULL << pctype_list[i]);
16023 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16033 printf("invalid pctype or flow type\n");
16036 printf("invalid port_id %d\n", res->port_id);
16039 printf("function not implemented\n");
16042 printf("programming error: (%s)\n", strerror(-ret));
16046 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16047 .f = cmd_pctype_mapping_update_parsed,
16049 .help_str = "port config <port_id> pctype mapping update"
16050 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16052 (void *)&cmd_pctype_mapping_update_port,
16053 (void *)&cmd_pctype_mapping_update_config,
16054 (void *)&cmd_pctype_mapping_update_port_id,
16055 (void *)&cmd_pctype_mapping_update_pctype,
16056 (void *)&cmd_pctype_mapping_update_mapping,
16057 (void *)&cmd_pctype_mapping_update_update,
16058 (void *)&cmd_pctype_mapping_update_pc_type,
16059 (void *)&cmd_pctype_mapping_update_flow_type,
16064 /* ptype mapping get */
16066 /* Common result structure for ptype mapping get */
16067 struct cmd_ptype_mapping_get_result {
16068 cmdline_fixed_string_t ptype;
16069 cmdline_fixed_string_t mapping;
16070 cmdline_fixed_string_t get;
16072 uint8_t valid_only;
16075 /* Common CLI fields for ptype mapping get */
16076 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16077 TOKEN_STRING_INITIALIZER
16078 (struct cmd_ptype_mapping_get_result,
16080 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16081 TOKEN_STRING_INITIALIZER
16082 (struct cmd_ptype_mapping_get_result,
16083 mapping, "mapping");
16084 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16085 TOKEN_STRING_INITIALIZER
16086 (struct cmd_ptype_mapping_get_result,
16088 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16089 TOKEN_NUM_INITIALIZER
16090 (struct cmd_ptype_mapping_get_result,
16092 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16093 TOKEN_NUM_INITIALIZER
16094 (struct cmd_ptype_mapping_get_result,
16095 valid_only, UINT8);
16098 cmd_ptype_mapping_get_parsed(
16099 void *parsed_result,
16100 __attribute__((unused)) struct cmdline *cl,
16101 __attribute__((unused)) void *data)
16103 struct cmd_ptype_mapping_get_result *res = parsed_result;
16104 int ret = -ENOTSUP;
16105 #ifdef RTE_LIBRTE_I40E_PMD
16106 int max_ptype_num = 256;
16107 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16112 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16115 #ifdef RTE_LIBRTE_I40E_PMD
16116 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16127 printf("invalid port_id %d\n", res->port_id);
16130 printf("function not implemented\n");
16133 printf("programming error: (%s)\n", strerror(-ret));
16136 #ifdef RTE_LIBRTE_I40E_PMD
16138 for (i = 0; i < count; i++)
16139 printf("%3d\t0x%08x\n",
16140 mapping[i].hw_ptype, mapping[i].sw_ptype);
16145 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16146 .f = cmd_ptype_mapping_get_parsed,
16148 .help_str = "ptype mapping get <port_id> <valid_only>",
16150 (void *)&cmd_ptype_mapping_get_ptype,
16151 (void *)&cmd_ptype_mapping_get_mapping,
16152 (void *)&cmd_ptype_mapping_get_get,
16153 (void *)&cmd_ptype_mapping_get_port_id,
16154 (void *)&cmd_ptype_mapping_get_valid_only,
16159 /* ptype mapping replace */
16161 /* Common result structure for ptype mapping replace */
16162 struct cmd_ptype_mapping_replace_result {
16163 cmdline_fixed_string_t ptype;
16164 cmdline_fixed_string_t mapping;
16165 cmdline_fixed_string_t replace;
16172 /* Common CLI fields for ptype mapping replace */
16173 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16174 TOKEN_STRING_INITIALIZER
16175 (struct cmd_ptype_mapping_replace_result,
16177 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16178 TOKEN_STRING_INITIALIZER
16179 (struct cmd_ptype_mapping_replace_result,
16180 mapping, "mapping");
16181 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16182 TOKEN_STRING_INITIALIZER
16183 (struct cmd_ptype_mapping_replace_result,
16184 replace, "replace");
16185 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16186 TOKEN_NUM_INITIALIZER
16187 (struct cmd_ptype_mapping_replace_result,
16189 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16190 TOKEN_NUM_INITIALIZER
16191 (struct cmd_ptype_mapping_replace_result,
16193 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16194 TOKEN_NUM_INITIALIZER
16195 (struct cmd_ptype_mapping_replace_result,
16197 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16198 TOKEN_NUM_INITIALIZER
16199 (struct cmd_ptype_mapping_replace_result,
16203 cmd_ptype_mapping_replace_parsed(
16204 void *parsed_result,
16205 __attribute__((unused)) struct cmdline *cl,
16206 __attribute__((unused)) void *data)
16208 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16209 int ret = -ENOTSUP;
16211 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16214 #ifdef RTE_LIBRTE_I40E_PMD
16215 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16225 printf("invalid ptype 0x%8x or 0x%8x\n",
16226 res->target, res->pkt_type);
16229 printf("invalid port_id %d\n", res->port_id);
16232 printf("function not implemented\n");
16235 printf("programming error: (%s)\n", strerror(-ret));
16239 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16240 .f = cmd_ptype_mapping_replace_parsed,
16243 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16245 (void *)&cmd_ptype_mapping_replace_ptype,
16246 (void *)&cmd_ptype_mapping_replace_mapping,
16247 (void *)&cmd_ptype_mapping_replace_replace,
16248 (void *)&cmd_ptype_mapping_replace_port_id,
16249 (void *)&cmd_ptype_mapping_replace_target,
16250 (void *)&cmd_ptype_mapping_replace_mask,
16251 (void *)&cmd_ptype_mapping_replace_pkt_type,
16256 /* ptype mapping reset */
16258 /* Common result structure for ptype mapping reset */
16259 struct cmd_ptype_mapping_reset_result {
16260 cmdline_fixed_string_t ptype;
16261 cmdline_fixed_string_t mapping;
16262 cmdline_fixed_string_t reset;
16266 /* Common CLI fields for ptype mapping reset*/
16267 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16268 TOKEN_STRING_INITIALIZER
16269 (struct cmd_ptype_mapping_reset_result,
16271 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16272 TOKEN_STRING_INITIALIZER
16273 (struct cmd_ptype_mapping_reset_result,
16274 mapping, "mapping");
16275 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16276 TOKEN_STRING_INITIALIZER
16277 (struct cmd_ptype_mapping_reset_result,
16279 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16280 TOKEN_NUM_INITIALIZER
16281 (struct cmd_ptype_mapping_reset_result,
16285 cmd_ptype_mapping_reset_parsed(
16286 void *parsed_result,
16287 __attribute__((unused)) struct cmdline *cl,
16288 __attribute__((unused)) void *data)
16290 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16291 int ret = -ENOTSUP;
16293 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16296 #ifdef RTE_LIBRTE_I40E_PMD
16297 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16304 printf("invalid port_id %d\n", res->port_id);
16307 printf("function not implemented\n");
16310 printf("programming error: (%s)\n", strerror(-ret));
16314 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16315 .f = cmd_ptype_mapping_reset_parsed,
16317 .help_str = "ptype mapping reset <port_id>",
16319 (void *)&cmd_ptype_mapping_reset_ptype,
16320 (void *)&cmd_ptype_mapping_reset_mapping,
16321 (void *)&cmd_ptype_mapping_reset_reset,
16322 (void *)&cmd_ptype_mapping_reset_port_id,
16327 /* ptype mapping update */
16329 /* Common result structure for ptype mapping update */
16330 struct cmd_ptype_mapping_update_result {
16331 cmdline_fixed_string_t ptype;
16332 cmdline_fixed_string_t mapping;
16333 cmdline_fixed_string_t reset;
16339 /* Common CLI fields for ptype mapping update*/
16340 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16341 TOKEN_STRING_INITIALIZER
16342 (struct cmd_ptype_mapping_update_result,
16344 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16345 TOKEN_STRING_INITIALIZER
16346 (struct cmd_ptype_mapping_update_result,
16347 mapping, "mapping");
16348 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16349 TOKEN_STRING_INITIALIZER
16350 (struct cmd_ptype_mapping_update_result,
16352 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16353 TOKEN_NUM_INITIALIZER
16354 (struct cmd_ptype_mapping_update_result,
16356 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16357 TOKEN_NUM_INITIALIZER
16358 (struct cmd_ptype_mapping_update_result,
16360 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16361 TOKEN_NUM_INITIALIZER
16362 (struct cmd_ptype_mapping_update_result,
16366 cmd_ptype_mapping_update_parsed(
16367 void *parsed_result,
16368 __attribute__((unused)) struct cmdline *cl,
16369 __attribute__((unused)) void *data)
16371 struct cmd_ptype_mapping_update_result *res = parsed_result;
16372 int ret = -ENOTSUP;
16373 #ifdef RTE_LIBRTE_I40E_PMD
16374 struct rte_pmd_i40e_ptype_mapping mapping;
16376 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16379 #ifdef RTE_LIBRTE_I40E_PMD
16380 mapping.hw_ptype = res->hw_ptype;
16381 mapping.sw_ptype = res->sw_ptype;
16382 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16392 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16395 printf("invalid port_id %d\n", res->port_id);
16398 printf("function not implemented\n");
16401 printf("programming error: (%s)\n", strerror(-ret));
16405 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16406 .f = cmd_ptype_mapping_update_parsed,
16408 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16410 (void *)&cmd_ptype_mapping_update_ptype,
16411 (void *)&cmd_ptype_mapping_update_mapping,
16412 (void *)&cmd_ptype_mapping_update_update,
16413 (void *)&cmd_ptype_mapping_update_port_id,
16414 (void *)&cmd_ptype_mapping_update_hw_ptype,
16415 (void *)&cmd_ptype_mapping_update_sw_ptype,
16420 /* Common result structure for file commands */
16421 struct cmd_cmdfile_result {
16422 cmdline_fixed_string_t load;
16423 cmdline_fixed_string_t filename;
16426 /* Common CLI fields for file commands */
16427 cmdline_parse_token_string_t cmd_load_cmdfile =
16428 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16429 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16430 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16433 cmd_load_from_file_parsed(
16434 void *parsed_result,
16435 __attribute__((unused)) struct cmdline *cl,
16436 __attribute__((unused)) void *data)
16438 struct cmd_cmdfile_result *res = parsed_result;
16440 cmdline_read_from_file(res->filename);
16443 cmdline_parse_inst_t cmd_load_from_file = {
16444 .f = cmd_load_from_file_parsed,
16446 .help_str = "load <filename>",
16448 (void *)&cmd_load_cmdfile,
16449 (void *)&cmd_load_cmdfile_filename,
16454 /* ******************************************************************************** */
16456 /* list of instructions */
16457 cmdline_parse_ctx_t main_ctx[] = {
16458 (cmdline_parse_inst_t *)&cmd_help_brief,
16459 (cmdline_parse_inst_t *)&cmd_help_long,
16460 (cmdline_parse_inst_t *)&cmd_quit,
16461 (cmdline_parse_inst_t *)&cmd_load_from_file,
16462 (cmdline_parse_inst_t *)&cmd_showport,
16463 (cmdline_parse_inst_t *)&cmd_showqueue,
16464 (cmdline_parse_inst_t *)&cmd_showportall,
16465 (cmdline_parse_inst_t *)&cmd_showcfg,
16466 (cmdline_parse_inst_t *)&cmd_start,
16467 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16468 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16469 (cmdline_parse_inst_t *)&cmd_set_link_up,
16470 (cmdline_parse_inst_t *)&cmd_set_link_down,
16471 (cmdline_parse_inst_t *)&cmd_reset,
16472 (cmdline_parse_inst_t *)&cmd_set_numbers,
16473 (cmdline_parse_inst_t *)&cmd_set_log,
16474 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16475 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16476 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16477 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16478 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16479 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16480 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16481 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16482 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16483 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16484 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16485 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16486 (cmdline_parse_inst_t *)&cmd_set_link_check,
16487 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16488 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16489 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16490 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16491 #ifdef RTE_LIBRTE_PMD_BOND
16492 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16493 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16494 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16495 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16496 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16497 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16498 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16499 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16500 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16501 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16502 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16504 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16505 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16506 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16507 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16508 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16509 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16510 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16511 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16512 (cmdline_parse_inst_t *)&cmd_csum_set,
16513 (cmdline_parse_inst_t *)&cmd_csum_show,
16514 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16515 (cmdline_parse_inst_t *)&cmd_tso_set,
16516 (cmdline_parse_inst_t *)&cmd_tso_show,
16517 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16518 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16519 (cmdline_parse_inst_t *)&cmd_gro_enable,
16520 (cmdline_parse_inst_t *)&cmd_gro_flush,
16521 (cmdline_parse_inst_t *)&cmd_gro_show,
16522 (cmdline_parse_inst_t *)&cmd_gso_enable,
16523 (cmdline_parse_inst_t *)&cmd_gso_size,
16524 (cmdline_parse_inst_t *)&cmd_gso_show,
16525 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16526 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16527 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16528 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16529 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16530 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16531 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16532 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16533 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16534 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16535 (cmdline_parse_inst_t *)&cmd_config_dcb,
16536 (cmdline_parse_inst_t *)&cmd_read_reg,
16537 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16538 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16539 (cmdline_parse_inst_t *)&cmd_write_reg,
16540 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16541 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16542 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16543 (cmdline_parse_inst_t *)&cmd_stop,
16544 (cmdline_parse_inst_t *)&cmd_mac_addr,
16545 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16546 (cmdline_parse_inst_t *)&cmd_set_qmap,
16547 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16548 (cmdline_parse_inst_t *)&cmd_operate_port,
16549 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16550 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16551 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16552 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16553 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16554 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16555 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16556 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16557 (cmdline_parse_inst_t *)&cmd_config_mtu,
16558 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16559 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16560 (cmdline_parse_inst_t *)&cmd_config_rss,
16561 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16562 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16563 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16564 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16565 (cmdline_parse_inst_t *)&cmd_showport_reta,
16566 (cmdline_parse_inst_t *)&cmd_config_burst,
16567 (cmdline_parse_inst_t *)&cmd_config_thresh,
16568 (cmdline_parse_inst_t *)&cmd_config_threshold,
16569 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16570 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16571 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16572 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16573 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16574 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16575 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16576 (cmdline_parse_inst_t *)&cmd_global_config,
16577 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16578 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16579 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16580 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16581 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16582 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16583 (cmdline_parse_inst_t *)&cmd_dump,
16584 (cmdline_parse_inst_t *)&cmd_dump_one,
16585 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16586 (cmdline_parse_inst_t *)&cmd_syn_filter,
16587 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16588 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16589 (cmdline_parse_inst_t *)&cmd_flex_filter,
16590 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16591 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16592 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16593 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16594 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16595 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16596 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16597 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16598 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16599 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16600 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16601 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16602 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16603 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16604 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16605 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16606 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16607 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16608 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16609 (cmdline_parse_inst_t *)&cmd_flow,
16610 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16611 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16612 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16613 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16614 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16615 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16616 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16617 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16618 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16619 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16620 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16621 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16622 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16623 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16624 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16625 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16626 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16627 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16628 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16629 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16630 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16631 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16632 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16633 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16634 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16635 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16636 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16637 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16638 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16639 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16640 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16641 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16642 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16643 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16644 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16645 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16646 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16647 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16648 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16649 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16650 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16651 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16652 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16653 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16654 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16655 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16656 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16657 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16658 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16659 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16660 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16662 (cmdline_parse_inst_t *)&cmd_ddp_add,
16663 (cmdline_parse_inst_t *)&cmd_ddp_del,
16664 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16665 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16666 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16667 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16668 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16669 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16670 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16671 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16672 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16673 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16675 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16676 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16677 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16678 (cmdline_parse_inst_t *)&cmd_queue_region,
16679 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16680 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16681 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16682 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16683 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16684 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16685 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16686 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16687 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16688 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16689 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16690 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16691 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16692 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16693 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16694 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16695 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16696 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16697 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16698 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16699 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
16700 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16701 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
16705 /* read cmdline commands from file */
16707 cmdline_read_from_file(const char *filename)
16709 struct cmdline *cl;
16711 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16713 printf("Failed to create file based cmdline context: %s\n",
16718 cmdline_interact(cl);
16723 printf("Read CLI commands from %s\n", filename);
16726 /* prompt function, called from main on MASTER lcore */
16730 /* initialize non-constant commands */
16731 cmd_set_fwd_mode_init();
16732 cmd_set_fwd_retry_mode_init();
16734 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16735 if (testpmd_cl == NULL)
16737 cmdline_interact(testpmd_cl);
16738 cmdline_stdin_exit(testpmd_cl);
16744 if (testpmd_cl != NULL)
16745 cmdline_quit(testpmd_cl);
16749 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16751 if (id == (portid_t)RTE_PORT_ALL) {
16754 RTE_ETH_FOREACH_DEV(pid) {
16755 /* check if need_reconfig has been set to 1 */
16756 if (ports[pid].need_reconfig == 0)
16757 ports[pid].need_reconfig = dev;
16758 /* check if need_reconfig_queues has been set to 1 */
16759 if (ports[pid].need_reconfig_queues == 0)
16760 ports[pid].need_reconfig_queues = queue;
16762 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16763 /* check if need_reconfig has been set to 1 */
16764 if (ports[id].need_reconfig == 0)
16765 ports[id].need_reconfig = dev;
16766 /* check if need_reconfig_queues has been set to 1 */
16767 if (ports[id].need_reconfig_queues == 0)
16768 ports[id].need_reconfig_queues = queue;