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 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
775 " Commit tm hierarchy.\n\n"
777 , list_pkt_forwarding_modes()
781 if (show_all || !strcmp(res->section, "ports")) {
787 "----------------\n\n"
789 "port start (port_id|all)\n"
790 " Start all ports or port_id.\n\n"
792 "port stop (port_id|all)\n"
793 " Stop all ports or port_id.\n\n"
795 "port close (port_id|all)\n"
796 " Close all ports or port_id.\n\n"
798 "port attach (ident)\n"
799 " Attach physical or virtual dev by pci address or virtual device name\n\n"
801 "port detach (port_id)\n"
802 " Detach physical or virtual dev by port_id\n\n"
804 "port config (port_id|all)"
805 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
806 " duplex (half|full|auto)\n"
807 " Set speed and duplex for all ports or port_id\n\n"
809 "port config (port_id|all) loopback (mode)\n"
810 " Set loopback mode for all ports or port_id\n\n"
812 "port config all (rxq|txq|rxd|txd) (value)\n"
813 " Set number for rxq/txq/rxd/txd.\n\n"
815 "port config all max-pkt-len (value)\n"
816 " Set the max packet length.\n\n"
818 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
819 "hw-vlan-strip|hw-vlan-extend|drop-en)"
821 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
824 "port config all rss (all|default|ip|tcp|udp|sctp|"
825 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
826 " Set the RSS mode.\n\n"
828 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
829 " Set the RSS redirection table.\n\n"
831 "port config (port_id) dcb vt (on|off) (traffic_class)"
833 " Set the DCB mode.\n\n"
835 "port config all burst (value)\n"
836 " Set the number of packets per burst.\n\n"
838 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
840 " Set the ring prefetch/host/writeback threshold"
841 " for tx/rx queue.\n\n"
843 "port config all (txfreet|txrst|rxfreet) (value)\n"
844 " Set free threshold for rx/tx, or set"
845 " tx rs bit threshold.\n\n"
846 "port config mtu X value\n"
847 " Set the MTU of port X to a given value\n\n"
849 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
850 " Start/stop a rx/tx queue of port X. Only take effect"
851 " when port X is started\n\n"
853 "port (port_id) (rxq|txq) (queue_id) setup\n"
854 " Setup a rx/tx queue of port X.\n\n"
856 "port config (port_id|all) l2-tunnel E-tag ether-type"
858 " Set the value of E-tag ether-type.\n\n"
860 "port config (port_id|all) l2-tunnel E-tag"
861 " (enable|disable)\n"
862 " Enable/disable the E-tag support.\n\n"
864 "port config (port_id) pctype mapping reset\n"
865 " Reset flow type to pctype mapping on a port\n\n"
867 "port config (port_id) pctype mapping update"
868 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
869 " Update a flow type to pctype mapping item on a port\n\n"
871 "port config (port_id) pctype (pctype_id) hash_inset|"
872 "fdir_inset|fdir_flx_inset get|set|clear field\n"
874 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
876 "port config (port_id) pctype (pctype_id) hash_inset|"
877 "fdir_inset|fdir_flx_inset clear all"
878 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
882 if (show_all || !strcmp(res->section, "registers")) {
890 "read reg (port_id) (address)\n"
891 " Display value of a port register.\n\n"
893 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
894 " Display a port register bit field.\n\n"
896 "read regbit (port_id) (address) (bit_x)\n"
897 " Display a single port register bit.\n\n"
899 "write reg (port_id) (address) (value)\n"
900 " Set value of a port register.\n\n"
902 "write regfield (port_id) (address) (bit_x) (bit_y)"
904 " Set bit field of a port register.\n\n"
906 "write regbit (port_id) (address) (bit_x) (value)\n"
907 " Set single bit value of a port register.\n\n"
910 if (show_all || !strcmp(res->section, "filters")) {
918 "ethertype_filter (port_id) (add|del)"
919 " (mac_addr|mac_ignr) (mac_address) ethertype"
920 " (ether_type) (drop|fwd) queue (queue_id)\n"
921 " Add/Del an ethertype filter.\n\n"
923 "2tuple_filter (port_id) (add|del)"
924 " dst_port (dst_port_value) protocol (protocol_value)"
925 " mask (mask_value) tcp_flags (tcp_flags_value)"
926 " priority (prio_value) queue (queue_id)\n"
927 " Add/Del a 2tuple filter.\n\n"
929 "5tuple_filter (port_id) (add|del)"
930 " dst_ip (dst_address) src_ip (src_address)"
931 " dst_port (dst_port_value) src_port (src_port_value)"
932 " protocol (protocol_value)"
933 " mask (mask_value) tcp_flags (tcp_flags_value)"
934 " priority (prio_value) queue (queue_id)\n"
935 " Add/Del a 5tuple filter.\n\n"
937 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
938 " Add/Del syn filter.\n\n"
940 "flex_filter (port_id) (add|del) len (len_value)"
941 " bytes (bytes_value) mask (mask_value)"
942 " priority (prio_value) queue (queue_id)\n"
943 " Add/Del a flex filter.\n\n"
945 "flow_director_filter (port_id) mode IP (add|del|update)"
946 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
947 " src (src_ip_address) dst (dst_ip_address)"
948 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
949 " vlan (vlan_value) flexbytes (flexbytes_value)"
950 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
951 " fd_id (fd_id_value)\n"
952 " Add/Del an IP type flow director filter.\n\n"
954 "flow_director_filter (port_id) mode IP (add|del|update)"
955 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
956 " src (src_ip_address) (src_port)"
957 " dst (dst_ip_address) (dst_port)"
958 " tos (tos_value) ttl (ttl_value)"
959 " vlan (vlan_value) flexbytes (flexbytes_value)"
960 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
961 " fd_id (fd_id_value)\n"
962 " Add/Del an UDP/TCP type flow director filter.\n\n"
964 "flow_director_filter (port_id) mode IP (add|del|update)"
965 " flow (ipv4-sctp|ipv6-sctp)"
966 " src (src_ip_address) (src_port)"
967 " dst (dst_ip_address) (dst_port)"
968 " tag (verification_tag) "
969 " tos (tos_value) ttl (ttl_value)"
971 " flexbytes (flexbytes_value) (drop|fwd)"
972 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
973 " Add/Del a SCTP type flow director filter.\n\n"
975 "flow_director_filter (port_id) mode IP (add|del|update)"
976 " flow l2_payload ether (ethertype)"
977 " flexbytes (flexbytes_value) (drop|fwd)"
978 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
979 " Add/Del a l2 payload type flow director filter.\n\n"
981 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
982 " mac (mac_address) vlan (vlan_value)"
983 " flexbytes (flexbytes_value) (drop|fwd)"
984 " queue (queue_id) fd_id (fd_id_value)\n"
985 " Add/Del a MAC-VLAN flow director filter.\n\n"
987 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
988 " mac (mac_address) vlan (vlan_value)"
989 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
990 " flexbytes (flexbytes_value) (drop|fwd)"
991 " queue (queue_id) fd_id (fd_id_value)\n"
992 " Add/Del a Tunnel flow director filter.\n\n"
994 "flow_director_filter (port_id) mode raw (add|del|update)"
995 " flow (flow_id) (drop|fwd) queue (queue_id)"
996 " fd_id (fd_id_value) packet (packet file name)\n"
997 " Add/Del a raw type flow director filter.\n\n"
999 "flush_flow_director (port_id)\n"
1000 " Flush all flow director entries of a device.\n\n"
1002 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1003 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1004 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1005 " Set flow director IP mask.\n\n"
1007 "flow_director_mask (port_id) mode MAC-VLAN"
1008 " vlan (vlan_value)\n"
1009 " Set flow director MAC-VLAN mask.\n\n"
1011 "flow_director_mask (port_id) mode Tunnel"
1012 " vlan (vlan_value) mac (mac_value)"
1013 " tunnel-type (tunnel_type_value)"
1014 " tunnel-id (tunnel_id_value)\n"
1015 " Set flow director Tunnel mask.\n\n"
1017 "flow_director_flex_mask (port_id)"
1018 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1019 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1021 " Configure mask of flex payload.\n\n"
1023 "flow_director_flex_payload (port_id)"
1024 " (raw|l2|l3|l4) (config)\n"
1025 " Configure flex payload selection.\n\n"
1027 "get_sym_hash_ena_per_port (port_id)\n"
1028 " get symmetric hash enable configuration per port.\n\n"
1030 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1031 " set symmetric hash enable configuration per port"
1032 " to enable or disable.\n\n"
1034 "get_hash_global_config (port_id)\n"
1035 " Get the global configurations of hash filters.\n\n"
1037 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1038 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1039 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1040 " (enable|disable)\n"
1041 " Set the global configurations of hash filters.\n\n"
1043 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1044 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1045 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1046 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1047 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1048 "ipv6-next-header|udp-src-port|udp-dst-port|"
1049 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1050 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1051 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1052 "fld-8th|none) (select|add)\n"
1053 " Set the input set for hash.\n\n"
1055 "set_fdir_input_set (port_id) "
1056 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1058 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1059 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1060 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1061 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1062 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1064 " Set the input set for FDir.\n\n"
1066 "flow validate {port_id}"
1067 " [group {group_id}] [priority {level}]"
1068 " [ingress] [egress]"
1069 " pattern {item} [/ {item} [...]] / end"
1070 " actions {action} [/ {action} [...]] / end\n"
1071 " Check whether a flow rule can be created.\n\n"
1073 "flow create {port_id}"
1074 " [group {group_id}] [priority {level}]"
1075 " [ingress] [egress]"
1076 " pattern {item} [/ {item} [...]] / end"
1077 " actions {action} [/ {action} [...]] / end\n"
1078 " Create a flow rule.\n\n"
1080 "flow destroy {port_id} rule {rule_id} [...]\n"
1081 " Destroy specific flow rules.\n\n"
1083 "flow flush {port_id}\n"
1084 " Destroy all flow rules.\n\n"
1086 "flow query {port_id} {rule_id} {action}\n"
1087 " Query an existing flow rule.\n\n"
1089 "flow list {port_id} [group {group_id}] [...]\n"
1090 " List existing flow rules sorted by priority,"
1091 " filtered by group identifiers.\n\n"
1093 "flow isolate {port_id} {boolean}\n"
1094 " Restrict ingress traffic to the defined"
1100 cmdline_parse_token_string_t cmd_help_long_help =
1101 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1103 cmdline_parse_token_string_t cmd_help_long_section =
1104 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1105 "all#control#display#config#"
1106 "ports#registers#filters");
1108 cmdline_parse_inst_t cmd_help_long = {
1109 .f = cmd_help_long_parsed,
1111 .help_str = "help all|control|display|config|ports|register|filters: "
1114 (void *)&cmd_help_long_help,
1115 (void *)&cmd_help_long_section,
1121 /* *** start/stop/close all ports *** */
1122 struct cmd_operate_port_result {
1123 cmdline_fixed_string_t keyword;
1124 cmdline_fixed_string_t name;
1125 cmdline_fixed_string_t value;
1128 static void cmd_operate_port_parsed(void *parsed_result,
1129 __attribute__((unused)) struct cmdline *cl,
1130 __attribute__((unused)) void *data)
1132 struct cmd_operate_port_result *res = parsed_result;
1134 if (!strcmp(res->name, "start"))
1135 start_port(RTE_PORT_ALL);
1136 else if (!strcmp(res->name, "stop"))
1137 stop_port(RTE_PORT_ALL);
1138 else if (!strcmp(res->name, "close"))
1139 close_port(RTE_PORT_ALL);
1140 else if (!strcmp(res->name, "reset"))
1141 reset_port(RTE_PORT_ALL);
1143 printf("Unknown parameter\n");
1146 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1149 cmdline_parse_token_string_t cmd_operate_port_all_port =
1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1151 "start#stop#close#reset");
1152 cmdline_parse_token_string_t cmd_operate_port_all_all =
1153 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1155 cmdline_parse_inst_t cmd_operate_port = {
1156 .f = cmd_operate_port_parsed,
1158 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1160 (void *)&cmd_operate_port_all_cmd,
1161 (void *)&cmd_operate_port_all_port,
1162 (void *)&cmd_operate_port_all_all,
1167 /* *** start/stop/close specific port *** */
1168 struct cmd_operate_specific_port_result {
1169 cmdline_fixed_string_t keyword;
1170 cmdline_fixed_string_t name;
1174 static void cmd_operate_specific_port_parsed(void *parsed_result,
1175 __attribute__((unused)) struct cmdline *cl,
1176 __attribute__((unused)) void *data)
1178 struct cmd_operate_specific_port_result *res = parsed_result;
1180 if (!strcmp(res->name, "start"))
1181 start_port(res->value);
1182 else if (!strcmp(res->name, "stop"))
1183 stop_port(res->value);
1184 else if (!strcmp(res->name, "close"))
1185 close_port(res->value);
1186 else if (!strcmp(res->name, "reset"))
1187 reset_port(res->value);
1189 printf("Unknown parameter\n");
1192 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1195 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1196 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1197 name, "start#stop#close#reset");
1198 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1199 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1202 cmdline_parse_inst_t cmd_operate_specific_port = {
1203 .f = cmd_operate_specific_port_parsed,
1205 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1207 (void *)&cmd_operate_specific_port_cmd,
1208 (void *)&cmd_operate_specific_port_port,
1209 (void *)&cmd_operate_specific_port_id,
1214 /* *** attach a specified port *** */
1215 struct cmd_operate_attach_port_result {
1216 cmdline_fixed_string_t port;
1217 cmdline_fixed_string_t keyword;
1218 cmdline_fixed_string_t identifier;
1221 static void cmd_operate_attach_port_parsed(void *parsed_result,
1222 __attribute__((unused)) struct cmdline *cl,
1223 __attribute__((unused)) void *data)
1225 struct cmd_operate_attach_port_result *res = parsed_result;
1227 if (!strcmp(res->keyword, "attach"))
1228 attach_port(res->identifier);
1230 printf("Unknown parameter\n");
1233 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1236 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1239 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1240 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1243 cmdline_parse_inst_t cmd_operate_attach_port = {
1244 .f = cmd_operate_attach_port_parsed,
1246 .help_str = "port attach <identifier>: "
1247 "(identifier: pci address or virtual dev name)",
1249 (void *)&cmd_operate_attach_port_port,
1250 (void *)&cmd_operate_attach_port_keyword,
1251 (void *)&cmd_operate_attach_port_identifier,
1256 /* *** detach a specified port *** */
1257 struct cmd_operate_detach_port_result {
1258 cmdline_fixed_string_t port;
1259 cmdline_fixed_string_t keyword;
1263 static void cmd_operate_detach_port_parsed(void *parsed_result,
1264 __attribute__((unused)) struct cmdline *cl,
1265 __attribute__((unused)) void *data)
1267 struct cmd_operate_detach_port_result *res = parsed_result;
1269 if (!strcmp(res->keyword, "detach"))
1270 detach_port(res->port_id);
1272 printf("Unknown parameter\n");
1275 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1278 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1281 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1282 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1285 cmdline_parse_inst_t cmd_operate_detach_port = {
1286 .f = cmd_operate_detach_port_parsed,
1288 .help_str = "port detach <port_id>",
1290 (void *)&cmd_operate_detach_port_port,
1291 (void *)&cmd_operate_detach_port_keyword,
1292 (void *)&cmd_operate_detach_port_port_id,
1297 /* *** configure speed for all ports *** */
1298 struct cmd_config_speed_all {
1299 cmdline_fixed_string_t port;
1300 cmdline_fixed_string_t keyword;
1301 cmdline_fixed_string_t all;
1302 cmdline_fixed_string_t item1;
1303 cmdline_fixed_string_t item2;
1304 cmdline_fixed_string_t value1;
1305 cmdline_fixed_string_t value2;
1309 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1314 if (!strcmp(duplexstr, "half")) {
1315 duplex = ETH_LINK_HALF_DUPLEX;
1316 } else if (!strcmp(duplexstr, "full")) {
1317 duplex = ETH_LINK_FULL_DUPLEX;
1318 } else if (!strcmp(duplexstr, "auto")) {
1319 duplex = ETH_LINK_FULL_DUPLEX;
1321 printf("Unknown duplex parameter\n");
1325 if (!strcmp(speedstr, "10")) {
1326 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1327 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1328 } else if (!strcmp(speedstr, "100")) {
1329 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1330 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1332 if (duplex != ETH_LINK_FULL_DUPLEX) {
1333 printf("Invalid speed/duplex parameters\n");
1336 if (!strcmp(speedstr, "1000")) {
1337 *speed = ETH_LINK_SPEED_1G;
1338 } else if (!strcmp(speedstr, "10000")) {
1339 *speed = ETH_LINK_SPEED_10G;
1340 } else if (!strcmp(speedstr, "25000")) {
1341 *speed = ETH_LINK_SPEED_25G;
1342 } else if (!strcmp(speedstr, "40000")) {
1343 *speed = ETH_LINK_SPEED_40G;
1344 } else if (!strcmp(speedstr, "50000")) {
1345 *speed = ETH_LINK_SPEED_50G;
1346 } else if (!strcmp(speedstr, "100000")) {
1347 *speed = ETH_LINK_SPEED_100G;
1348 } else if (!strcmp(speedstr, "auto")) {
1349 *speed = ETH_LINK_SPEED_AUTONEG;
1351 printf("Unknown speed parameter\n");
1360 cmd_config_speed_all_parsed(void *parsed_result,
1361 __attribute__((unused)) struct cmdline *cl,
1362 __attribute__((unused)) void *data)
1364 struct cmd_config_speed_all *res = parsed_result;
1365 uint32_t link_speed;
1368 if (!all_ports_stopped()) {
1369 printf("Please stop all ports first\n");
1373 if (parse_and_check_speed_duplex(res->value1, res->value2,
1377 RTE_ETH_FOREACH_DEV(pid) {
1378 ports[pid].dev_conf.link_speeds = link_speed;
1381 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1384 cmdline_parse_token_string_t cmd_config_speed_all_port =
1385 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1386 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1389 cmdline_parse_token_string_t cmd_config_speed_all_all =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1391 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1393 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1395 "10#100#1000#10000#25000#40000#50000#100000#auto");
1396 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1397 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1398 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1402 cmdline_parse_inst_t cmd_config_speed_all = {
1403 .f = cmd_config_speed_all_parsed,
1405 .help_str = "port config all speed "
1406 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1409 (void *)&cmd_config_speed_all_port,
1410 (void *)&cmd_config_speed_all_keyword,
1411 (void *)&cmd_config_speed_all_all,
1412 (void *)&cmd_config_speed_all_item1,
1413 (void *)&cmd_config_speed_all_value1,
1414 (void *)&cmd_config_speed_all_item2,
1415 (void *)&cmd_config_speed_all_value2,
1420 /* *** configure speed for specific port *** */
1421 struct cmd_config_speed_specific {
1422 cmdline_fixed_string_t port;
1423 cmdline_fixed_string_t keyword;
1425 cmdline_fixed_string_t item1;
1426 cmdline_fixed_string_t item2;
1427 cmdline_fixed_string_t value1;
1428 cmdline_fixed_string_t value2;
1432 cmd_config_speed_specific_parsed(void *parsed_result,
1433 __attribute__((unused)) struct cmdline *cl,
1434 __attribute__((unused)) void *data)
1436 struct cmd_config_speed_specific *res = parsed_result;
1437 uint32_t link_speed;
1439 if (!all_ports_stopped()) {
1440 printf("Please stop all ports first\n");
1444 if (port_id_is_invalid(res->id, ENABLED_WARN))
1447 if (parse_and_check_speed_duplex(res->value1, res->value2,
1451 ports[res->id].dev_conf.link_speeds = link_speed;
1453 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1457 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1460 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1461 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1463 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1464 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1465 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1468 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1470 "10#100#1000#10000#25000#40000#50000#100000#auto");
1471 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1474 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1478 cmdline_parse_inst_t cmd_config_speed_specific = {
1479 .f = cmd_config_speed_specific_parsed,
1481 .help_str = "port config <port_id> speed "
1482 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1485 (void *)&cmd_config_speed_specific_port,
1486 (void *)&cmd_config_speed_specific_keyword,
1487 (void *)&cmd_config_speed_specific_id,
1488 (void *)&cmd_config_speed_specific_item1,
1489 (void *)&cmd_config_speed_specific_value1,
1490 (void *)&cmd_config_speed_specific_item2,
1491 (void *)&cmd_config_speed_specific_value2,
1496 /* *** configure loopback for all ports *** */
1497 struct cmd_config_loopback_all {
1498 cmdline_fixed_string_t port;
1499 cmdline_fixed_string_t keyword;
1500 cmdline_fixed_string_t all;
1501 cmdline_fixed_string_t item;
1506 cmd_config_loopback_all_parsed(void *parsed_result,
1507 __attribute__((unused)) struct cmdline *cl,
1508 __attribute__((unused)) void *data)
1510 struct cmd_config_loopback_all *res = parsed_result;
1513 if (!all_ports_stopped()) {
1514 printf("Please stop all ports first\n");
1518 RTE_ETH_FOREACH_DEV(pid) {
1519 ports[pid].dev_conf.lpbk_mode = res->mode;
1522 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1525 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1526 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1527 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1528 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1530 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1531 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1532 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1533 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1535 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1536 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1538 cmdline_parse_inst_t cmd_config_loopback_all = {
1539 .f = cmd_config_loopback_all_parsed,
1541 .help_str = "port config all loopback <mode>",
1543 (void *)&cmd_config_loopback_all_port,
1544 (void *)&cmd_config_loopback_all_keyword,
1545 (void *)&cmd_config_loopback_all_all,
1546 (void *)&cmd_config_loopback_all_item,
1547 (void *)&cmd_config_loopback_all_mode,
1552 /* *** configure loopback for specific port *** */
1553 struct cmd_config_loopback_specific {
1554 cmdline_fixed_string_t port;
1555 cmdline_fixed_string_t keyword;
1557 cmdline_fixed_string_t item;
1562 cmd_config_loopback_specific_parsed(void *parsed_result,
1563 __attribute__((unused)) struct cmdline *cl,
1564 __attribute__((unused)) void *data)
1566 struct cmd_config_loopback_specific *res = parsed_result;
1568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1571 if (!port_is_stopped(res->port_id)) {
1572 printf("Please stop port %u first\n", res->port_id);
1576 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1578 cmd_reconfig_device_queue(res->port_id, 1, 1);
1582 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1585 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1588 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1589 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1591 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1592 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1594 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1595 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1598 cmdline_parse_inst_t cmd_config_loopback_specific = {
1599 .f = cmd_config_loopback_specific_parsed,
1601 .help_str = "port config <port_id> loopback <mode>",
1603 (void *)&cmd_config_loopback_specific_port,
1604 (void *)&cmd_config_loopback_specific_keyword,
1605 (void *)&cmd_config_loopback_specific_id,
1606 (void *)&cmd_config_loopback_specific_item,
1607 (void *)&cmd_config_loopback_specific_mode,
1612 /* *** configure txq/rxq, txd/rxd *** */
1613 struct cmd_config_rx_tx {
1614 cmdline_fixed_string_t port;
1615 cmdline_fixed_string_t keyword;
1616 cmdline_fixed_string_t all;
1617 cmdline_fixed_string_t name;
1622 cmd_config_rx_tx_parsed(void *parsed_result,
1623 __attribute__((unused)) struct cmdline *cl,
1624 __attribute__((unused)) void *data)
1626 struct cmd_config_rx_tx *res = parsed_result;
1628 if (!all_ports_stopped()) {
1629 printf("Please stop all ports first\n");
1632 if (!strcmp(res->name, "rxq")) {
1633 if (!res->value && !nb_txq) {
1634 printf("Warning: Either rx or tx queues should be non zero\n");
1637 if (check_nb_rxq(res->value) != 0)
1639 nb_rxq = res->value;
1641 else if (!strcmp(res->name, "txq")) {
1642 if (!res->value && !nb_rxq) {
1643 printf("Warning: Either rx or tx queues should be non zero\n");
1646 if (check_nb_txq(res->value) != 0)
1648 nb_txq = res->value;
1650 else if (!strcmp(res->name, "rxd")) {
1651 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1652 printf("rxd %d invalid - must be > 0 && <= %d\n",
1653 res->value, RTE_TEST_RX_DESC_MAX);
1656 nb_rxd = res->value;
1657 } else if (!strcmp(res->name, "txd")) {
1658 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1659 printf("txd %d invalid - must be > 0 && <= %d\n",
1660 res->value, RTE_TEST_TX_DESC_MAX);
1663 nb_txd = res->value;
1665 printf("Unknown parameter\n");
1673 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1676 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1678 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1680 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1681 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1682 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1683 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1685 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1686 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1688 cmdline_parse_inst_t cmd_config_rx_tx = {
1689 .f = cmd_config_rx_tx_parsed,
1691 .help_str = "port config all rxq|txq|rxd|txd <value>",
1693 (void *)&cmd_config_rx_tx_port,
1694 (void *)&cmd_config_rx_tx_keyword,
1695 (void *)&cmd_config_rx_tx_all,
1696 (void *)&cmd_config_rx_tx_name,
1697 (void *)&cmd_config_rx_tx_value,
1702 /* *** config max packet length *** */
1703 struct cmd_config_max_pkt_len_result {
1704 cmdline_fixed_string_t port;
1705 cmdline_fixed_string_t keyword;
1706 cmdline_fixed_string_t all;
1707 cmdline_fixed_string_t name;
1712 cmd_config_max_pkt_len_parsed(void *parsed_result,
1713 __attribute__((unused)) struct cmdline *cl,
1714 __attribute__((unused)) void *data)
1716 struct cmd_config_max_pkt_len_result *res = parsed_result;
1719 if (!all_ports_stopped()) {
1720 printf("Please stop all ports first\n");
1724 RTE_ETH_FOREACH_DEV(pid) {
1725 struct rte_port *port = &ports[pid];
1726 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1728 if (!strcmp(res->name, "max-pkt-len")) {
1729 if (res->value < ETHER_MIN_LEN) {
1730 printf("max-pkt-len can not be less than %d\n",
1734 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1737 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1738 if (res->value > ETHER_MAX_LEN)
1739 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1741 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1742 port->dev_conf.rxmode.offloads = rx_offloads;
1744 printf("Unknown parameter\n");
1751 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1754 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1755 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1757 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1758 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1760 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1761 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1763 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1766 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1767 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1770 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1771 .f = cmd_config_max_pkt_len_parsed,
1773 .help_str = "port config all max-pkt-len <value>",
1775 (void *)&cmd_config_max_pkt_len_port,
1776 (void *)&cmd_config_max_pkt_len_keyword,
1777 (void *)&cmd_config_max_pkt_len_all,
1778 (void *)&cmd_config_max_pkt_len_name,
1779 (void *)&cmd_config_max_pkt_len_value,
1784 /* *** configure port MTU *** */
1785 struct cmd_config_mtu_result {
1786 cmdline_fixed_string_t port;
1787 cmdline_fixed_string_t keyword;
1788 cmdline_fixed_string_t mtu;
1794 cmd_config_mtu_parsed(void *parsed_result,
1795 __attribute__((unused)) struct cmdline *cl,
1796 __attribute__((unused)) void *data)
1798 struct cmd_config_mtu_result *res = parsed_result;
1800 if (res->value < ETHER_MIN_LEN) {
1801 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1804 port_mtu_set(res->port_id, res->value);
1807 cmdline_parse_token_string_t cmd_config_mtu_port =
1808 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1810 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1811 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1813 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1814 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1816 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1817 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1818 cmdline_parse_token_num_t cmd_config_mtu_value =
1819 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1821 cmdline_parse_inst_t cmd_config_mtu = {
1822 .f = cmd_config_mtu_parsed,
1824 .help_str = "port config mtu <port_id> <value>",
1826 (void *)&cmd_config_mtu_port,
1827 (void *)&cmd_config_mtu_keyword,
1828 (void *)&cmd_config_mtu_mtu,
1829 (void *)&cmd_config_mtu_port_id,
1830 (void *)&cmd_config_mtu_value,
1835 /* *** configure rx mode *** */
1836 struct cmd_config_rx_mode_flag {
1837 cmdline_fixed_string_t port;
1838 cmdline_fixed_string_t keyword;
1839 cmdline_fixed_string_t all;
1840 cmdline_fixed_string_t name;
1841 cmdline_fixed_string_t value;
1845 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1846 __attribute__((unused)) struct cmdline *cl,
1847 __attribute__((unused)) void *data)
1849 struct cmd_config_rx_mode_flag *res = parsed_result;
1852 if (!all_ports_stopped()) {
1853 printf("Please stop all ports first\n");
1857 RTE_ETH_FOREACH_DEV(pid) {
1858 struct rte_port *port;
1859 uint64_t rx_offloads;
1862 rx_offloads = port->dev_conf.rxmode.offloads;
1863 if (!strcmp(res->name, "crc-strip")) {
1864 if (!strcmp(res->value, "on"))
1865 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1866 else if (!strcmp(res->value, "off"))
1867 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1869 printf("Unknown parameter\n");
1872 } else if (!strcmp(res->name, "scatter")) {
1873 if (!strcmp(res->value, "on")) {
1874 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1875 } else if (!strcmp(res->value, "off")) {
1876 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1878 printf("Unknown parameter\n");
1881 } else if (!strcmp(res->name, "rx-cksum")) {
1882 if (!strcmp(res->value, "on"))
1883 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1884 else if (!strcmp(res->value, "off"))
1885 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1887 printf("Unknown parameter\n");
1890 } else if (!strcmp(res->name, "rx-timestamp")) {
1891 if (!strcmp(res->value, "on"))
1892 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1893 else if (!strcmp(res->value, "off"))
1894 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1896 printf("Unknown parameter\n");
1899 } else if (!strcmp(res->name, "hw-vlan")) {
1900 if (!strcmp(res->value, "on")) {
1901 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1902 DEV_RX_OFFLOAD_VLAN_STRIP);
1903 } else if (!strcmp(res->value, "off")) {
1904 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1905 DEV_RX_OFFLOAD_VLAN_STRIP);
1907 printf("Unknown parameter\n");
1910 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1911 if (!strcmp(res->value, "on"))
1912 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1913 else if (!strcmp(res->value, "off"))
1914 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1916 printf("Unknown parameter\n");
1919 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1920 if (!strcmp(res->value, "on"))
1921 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1922 else if (!strcmp(res->value, "off"))
1923 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1925 printf("Unknown parameter\n");
1928 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1929 if (!strcmp(res->value, "on"))
1930 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1931 else if (!strcmp(res->value, "off"))
1932 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1934 printf("Unknown parameter\n");
1937 } else if (!strcmp(res->name, "drop-en")) {
1938 if (!strcmp(res->value, "on"))
1940 else if (!strcmp(res->value, "off"))
1943 printf("Unknown parameter\n");
1947 printf("Unknown parameter\n");
1950 port->dev_conf.rxmode.offloads = rx_offloads;
1955 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1958 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1959 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1960 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1963 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1964 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1965 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1966 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1967 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1968 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1969 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1970 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1973 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1974 .f = cmd_config_rx_mode_flag_parsed,
1976 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1977 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1979 (void *)&cmd_config_rx_mode_flag_port,
1980 (void *)&cmd_config_rx_mode_flag_keyword,
1981 (void *)&cmd_config_rx_mode_flag_all,
1982 (void *)&cmd_config_rx_mode_flag_name,
1983 (void *)&cmd_config_rx_mode_flag_value,
1988 /* *** configure rss *** */
1989 struct cmd_config_rss {
1990 cmdline_fixed_string_t port;
1991 cmdline_fixed_string_t keyword;
1992 cmdline_fixed_string_t all;
1993 cmdline_fixed_string_t name;
1994 cmdline_fixed_string_t value;
1998 cmd_config_rss_parsed(void *parsed_result,
1999 __attribute__((unused)) struct cmdline *cl,
2000 __attribute__((unused)) void *data)
2002 struct cmd_config_rss *res = parsed_result;
2003 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2004 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2008 if (!strcmp(res->value, "all"))
2009 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2010 ETH_RSS_UDP | ETH_RSS_SCTP |
2012 else if (!strcmp(res->value, "ip"))
2013 rss_conf.rss_hf = ETH_RSS_IP;
2014 else if (!strcmp(res->value, "udp"))
2015 rss_conf.rss_hf = ETH_RSS_UDP;
2016 else if (!strcmp(res->value, "tcp"))
2017 rss_conf.rss_hf = ETH_RSS_TCP;
2018 else if (!strcmp(res->value, "sctp"))
2019 rss_conf.rss_hf = ETH_RSS_SCTP;
2020 else if (!strcmp(res->value, "ether"))
2021 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2022 else if (!strcmp(res->value, "port"))
2023 rss_conf.rss_hf = ETH_RSS_PORT;
2024 else if (!strcmp(res->value, "vxlan"))
2025 rss_conf.rss_hf = ETH_RSS_VXLAN;
2026 else if (!strcmp(res->value, "geneve"))
2027 rss_conf.rss_hf = ETH_RSS_GENEVE;
2028 else if (!strcmp(res->value, "nvgre"))
2029 rss_conf.rss_hf = ETH_RSS_NVGRE;
2030 else if (!strcmp(res->value, "none") || !strcmp(res->value, "default"))
2031 rss_conf.rss_hf = 0;
2032 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2033 atoi(res->value) < 64)
2034 rss_conf.rss_hf = 1ULL << atoi(res->value);
2036 printf("Unknown parameter\n");
2039 rss_conf.rss_key = NULL;
2040 /* Update global configuration for RSS types. */
2041 rss_hf = rss_conf.rss_hf;
2042 RTE_ETH_FOREACH_DEV(i) {
2043 if (!strcmp(res->value, "default")) {
2044 rte_eth_dev_info_get(i, &dev_info);
2045 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2047 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2049 printf("Configuration of RSS hash at ethernet port %d "
2050 "failed with error (%d): %s.\n",
2051 i, -diag, strerror(-diag));
2055 cmdline_parse_token_string_t cmd_config_rss_port =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2057 cmdline_parse_token_string_t cmd_config_rss_keyword =
2058 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2059 cmdline_parse_token_string_t cmd_config_rss_all =
2060 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2061 cmdline_parse_token_string_t cmd_config_rss_name =
2062 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2063 cmdline_parse_token_string_t cmd_config_rss_value =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2066 cmdline_parse_inst_t cmd_config_rss = {
2067 .f = cmd_config_rss_parsed,
2069 .help_str = "port config all rss "
2070 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2072 (void *)&cmd_config_rss_port,
2073 (void *)&cmd_config_rss_keyword,
2074 (void *)&cmd_config_rss_all,
2075 (void *)&cmd_config_rss_name,
2076 (void *)&cmd_config_rss_value,
2081 /* *** configure rss hash key *** */
2082 struct cmd_config_rss_hash_key {
2083 cmdline_fixed_string_t port;
2084 cmdline_fixed_string_t config;
2086 cmdline_fixed_string_t rss_hash_key;
2087 cmdline_fixed_string_t rss_type;
2088 cmdline_fixed_string_t key;
2092 hexa_digit_to_value(char hexa_digit)
2094 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2095 return (uint8_t) (hexa_digit - '0');
2096 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2097 return (uint8_t) ((hexa_digit - 'a') + 10);
2098 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2099 return (uint8_t) ((hexa_digit - 'A') + 10);
2100 /* Invalid hexa digit */
2105 parse_and_check_key_hexa_digit(char *key, int idx)
2109 hexa_v = hexa_digit_to_value(key[idx]);
2111 printf("invalid key: character %c at position %d is not a "
2112 "valid hexa digit\n", key[idx], idx);
2117 cmd_config_rss_hash_key_parsed(void *parsed_result,
2118 __attribute__((unused)) struct cmdline *cl,
2119 __attribute__((unused)) void *data)
2121 struct cmd_config_rss_hash_key *res = parsed_result;
2122 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2126 struct rte_eth_dev_info dev_info;
2127 uint8_t hash_key_size;
2130 memset(&dev_info, 0, sizeof(dev_info));
2131 rte_eth_dev_info_get(res->port_id, &dev_info);
2132 if (dev_info.hash_key_size > 0 &&
2133 dev_info.hash_key_size <= sizeof(hash_key))
2134 hash_key_size = dev_info.hash_key_size;
2136 printf("dev_info did not provide a valid hash key size\n");
2139 /* Check the length of the RSS hash key */
2140 key_len = strlen(res->key);
2141 if (key_len != (hash_key_size * 2)) {
2142 printf("key length: %d invalid - key must be a string of %d"
2143 " hexa-decimal numbers\n",
2144 (int) key_len, hash_key_size * 2);
2147 /* Translate RSS hash key into binary representation */
2148 for (i = 0; i < hash_key_size; i++) {
2149 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2152 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2155 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2157 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2161 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2162 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2163 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2164 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2166 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2167 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2168 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2169 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2170 rss_hash_key, "rss-hash-key");
2171 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2172 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2173 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2174 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2175 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2176 "ipv6-tcp-ex#ipv6-udp-ex");
2177 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2178 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2180 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2181 .f = cmd_config_rss_hash_key_parsed,
2183 .help_str = "port config <port_id> rss-hash-key "
2184 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2185 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2186 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2187 "<string of hex digits (variable length, NIC dependent)>",
2189 (void *)&cmd_config_rss_hash_key_port,
2190 (void *)&cmd_config_rss_hash_key_config,
2191 (void *)&cmd_config_rss_hash_key_port_id,
2192 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2193 (void *)&cmd_config_rss_hash_key_rss_type,
2194 (void *)&cmd_config_rss_hash_key_value,
2199 /* *** configure port rxq/txq start/stop *** */
2200 struct cmd_config_rxtx_queue {
2201 cmdline_fixed_string_t port;
2203 cmdline_fixed_string_t rxtxq;
2205 cmdline_fixed_string_t opname;
2209 cmd_config_rxtx_queue_parsed(void *parsed_result,
2210 __attribute__((unused)) struct cmdline *cl,
2211 __attribute__((unused)) void *data)
2213 struct cmd_config_rxtx_queue *res = parsed_result;
2218 if (test_done == 0) {
2219 printf("Please stop forwarding first\n");
2223 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2226 if (port_is_started(res->portid) != 1) {
2227 printf("Please start port %u first\n", res->portid);
2231 if (!strcmp(res->rxtxq, "rxq"))
2233 else if (!strcmp(res->rxtxq, "txq"))
2236 printf("Unknown parameter\n");
2240 if (isrx && rx_queue_id_is_invalid(res->qid))
2242 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2245 if (!strcmp(res->opname, "start"))
2247 else if (!strcmp(res->opname, "stop"))
2250 printf("Unknown parameter\n");
2254 if (isstart && isrx)
2255 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2256 else if (!isstart && isrx)
2257 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2258 else if (isstart && !isrx)
2259 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2261 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2263 if (ret == -ENOTSUP)
2264 printf("Function not supported in PMD driver\n");
2267 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2268 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2269 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2270 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2271 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2273 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2274 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2275 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2276 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2279 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2280 .f = cmd_config_rxtx_queue_parsed,
2282 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2284 (void *)&cmd_config_rxtx_queue_port,
2285 (void *)&cmd_config_rxtx_queue_portid,
2286 (void *)&cmd_config_rxtx_queue_rxtxq,
2287 (void *)&cmd_config_rxtx_queue_qid,
2288 (void *)&cmd_config_rxtx_queue_opname,
2293 /* *** configure port rxq/txq setup *** */
2294 struct cmd_setup_rxtx_queue {
2295 cmdline_fixed_string_t port;
2297 cmdline_fixed_string_t rxtxq;
2299 cmdline_fixed_string_t setup;
2302 /* Common CLI fields for queue setup */
2303 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2304 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2305 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2306 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2307 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2308 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2309 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2310 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2311 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2312 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2315 cmd_setup_rxtx_queue_parsed(
2316 void *parsed_result,
2317 __attribute__((unused)) struct cmdline *cl,
2318 __attribute__((unused)) void *data)
2320 struct cmd_setup_rxtx_queue *res = parsed_result;
2321 struct rte_port *port;
2322 struct rte_mempool *mp;
2323 unsigned int socket_id;
2327 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2330 if (res->portid == (portid_t)RTE_PORT_ALL) {
2331 printf("Invalid port id\n");
2335 if (!strcmp(res->rxtxq, "rxq"))
2337 else if (!strcmp(res->rxtxq, "txq"))
2340 printf("Unknown parameter\n");
2344 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2345 printf("Invalid rx queue\n");
2347 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2348 printf("Invalid tx queue\n");
2352 port = &ports[res->portid];
2354 socket_id = rxring_numa[res->portid];
2355 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2356 socket_id = port->socket_id;
2358 mp = mbuf_pool_find(socket_id);
2360 printf("Failed to setup RX queue: "
2361 "No mempool allocation"
2362 " on the socket %d\n",
2363 rxring_numa[res->portid]);
2366 ret = rte_eth_rx_queue_setup(res->portid,
2373 printf("Failed to setup RX queue\n");
2375 socket_id = txring_numa[res->portid];
2376 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2377 socket_id = port->socket_id;
2379 ret = rte_eth_tx_queue_setup(res->portid,
2385 printf("Failed to setup TX queue\n");
2389 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2390 .f = cmd_setup_rxtx_queue_parsed,
2392 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2394 (void *)&cmd_setup_rxtx_queue_port,
2395 (void *)&cmd_setup_rxtx_queue_portid,
2396 (void *)&cmd_setup_rxtx_queue_rxtxq,
2397 (void *)&cmd_setup_rxtx_queue_qid,
2398 (void *)&cmd_setup_rxtx_queue_setup,
2404 /* *** Configure RSS RETA *** */
2405 struct cmd_config_rss_reta {
2406 cmdline_fixed_string_t port;
2407 cmdline_fixed_string_t keyword;
2409 cmdline_fixed_string_t name;
2410 cmdline_fixed_string_t list_name;
2411 cmdline_fixed_string_t list_of_items;
2415 parse_reta_config(const char *str,
2416 struct rte_eth_rss_reta_entry64 *reta_conf,
2417 uint16_t nb_entries)
2421 uint16_t hash_index, idx, shift;
2424 const char *p, *p0 = str;
2431 unsigned long int_fld[_NUM_FLD];
2432 char *str_fld[_NUM_FLD];
2434 while ((p = strchr(p0,'(')) != NULL) {
2436 if((p0 = strchr(p,')')) == NULL)
2440 if(size >= sizeof(s))
2443 snprintf(s, sizeof(s), "%.*s", size, p);
2444 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2446 for (i = 0; i < _NUM_FLD; i++) {
2448 int_fld[i] = strtoul(str_fld[i], &end, 0);
2449 if (errno != 0 || end == str_fld[i] ||
2454 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2455 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2457 if (hash_index >= nb_entries) {
2458 printf("Invalid RETA hash index=%d\n", hash_index);
2462 idx = hash_index / RTE_RETA_GROUP_SIZE;
2463 shift = hash_index % RTE_RETA_GROUP_SIZE;
2464 reta_conf[idx].mask |= (1ULL << shift);
2465 reta_conf[idx].reta[shift] = nb_queue;
2472 cmd_set_rss_reta_parsed(void *parsed_result,
2473 __attribute__((unused)) struct cmdline *cl,
2474 __attribute__((unused)) void *data)
2477 struct rte_eth_dev_info dev_info;
2478 struct rte_eth_rss_reta_entry64 reta_conf[8];
2479 struct cmd_config_rss_reta *res = parsed_result;
2481 memset(&dev_info, 0, sizeof(dev_info));
2482 rte_eth_dev_info_get(res->port_id, &dev_info);
2483 if (dev_info.reta_size == 0) {
2484 printf("Redirection table size is 0 which is "
2485 "invalid for RSS\n");
2488 printf("The reta size of port %d is %u\n",
2489 res->port_id, dev_info.reta_size);
2490 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2491 printf("Currently do not support more than %u entries of "
2492 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2496 memset(reta_conf, 0, sizeof(reta_conf));
2497 if (!strcmp(res->list_name, "reta")) {
2498 if (parse_reta_config(res->list_of_items, reta_conf,
2499 dev_info.reta_size)) {
2500 printf("Invalid RSS Redirection Table "
2501 "config entered\n");
2504 ret = rte_eth_dev_rss_reta_update(res->port_id,
2505 reta_conf, dev_info.reta_size);
2507 printf("Bad redirection table parameter, "
2508 "return code = %d \n", ret);
2512 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2513 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2514 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2515 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2516 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2517 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2518 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2519 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2520 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2521 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2522 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2523 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2525 cmdline_parse_inst_t cmd_config_rss_reta = {
2526 .f = cmd_set_rss_reta_parsed,
2528 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2530 (void *)&cmd_config_rss_reta_port,
2531 (void *)&cmd_config_rss_reta_keyword,
2532 (void *)&cmd_config_rss_reta_port_id,
2533 (void *)&cmd_config_rss_reta_name,
2534 (void *)&cmd_config_rss_reta_list_name,
2535 (void *)&cmd_config_rss_reta_list_of_items,
2540 /* *** SHOW PORT RETA INFO *** */
2541 struct cmd_showport_reta {
2542 cmdline_fixed_string_t show;
2543 cmdline_fixed_string_t port;
2545 cmdline_fixed_string_t rss;
2546 cmdline_fixed_string_t reta;
2548 cmdline_fixed_string_t list_of_items;
2552 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2553 uint16_t nb_entries,
2557 const char *p, *p0 = str;
2562 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2563 RTE_RETA_GROUP_SIZE;
2566 p = strchr(p0, '(');
2570 p0 = strchr(p, ')');
2574 if (size >= sizeof(s)) {
2575 printf("The string size exceeds the internal buffer size\n");
2578 snprintf(s, sizeof(s), "%.*s", size, p);
2579 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2580 if (ret <= 0 || ret != num) {
2581 printf("The bits of masks do not match the number of "
2582 "reta entries: %u\n", num);
2585 for (i = 0; i < ret; i++)
2586 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2592 cmd_showport_reta_parsed(void *parsed_result,
2593 __attribute__((unused)) struct cmdline *cl,
2594 __attribute__((unused)) void *data)
2596 struct cmd_showport_reta *res = parsed_result;
2597 struct rte_eth_rss_reta_entry64 reta_conf[8];
2598 struct rte_eth_dev_info dev_info;
2599 uint16_t max_reta_size;
2601 memset(&dev_info, 0, sizeof(dev_info));
2602 rte_eth_dev_info_get(res->port_id, &dev_info);
2603 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2604 if (res->size == 0 || res->size > max_reta_size) {
2605 printf("Invalid redirection table size: %u (1-%u)\n",
2606 res->size, max_reta_size);
2610 memset(reta_conf, 0, sizeof(reta_conf));
2611 if (showport_parse_reta_config(reta_conf, res->size,
2612 res->list_of_items) < 0) {
2613 printf("Invalid string: %s for reta masks\n",
2614 res->list_of_items);
2617 port_rss_reta_info(res->port_id, reta_conf, res->size);
2620 cmdline_parse_token_string_t cmd_showport_reta_show =
2621 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2622 cmdline_parse_token_string_t cmd_showport_reta_port =
2623 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2624 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2625 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2626 cmdline_parse_token_string_t cmd_showport_reta_rss =
2627 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2628 cmdline_parse_token_string_t cmd_showport_reta_reta =
2629 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2630 cmdline_parse_token_num_t cmd_showport_reta_size =
2631 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2632 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2633 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2634 list_of_items, NULL);
2636 cmdline_parse_inst_t cmd_showport_reta = {
2637 .f = cmd_showport_reta_parsed,
2639 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2641 (void *)&cmd_showport_reta_show,
2642 (void *)&cmd_showport_reta_port,
2643 (void *)&cmd_showport_reta_port_id,
2644 (void *)&cmd_showport_reta_rss,
2645 (void *)&cmd_showport_reta_reta,
2646 (void *)&cmd_showport_reta_size,
2647 (void *)&cmd_showport_reta_list_of_items,
2652 /* *** Show RSS hash configuration *** */
2653 struct cmd_showport_rss_hash {
2654 cmdline_fixed_string_t show;
2655 cmdline_fixed_string_t port;
2657 cmdline_fixed_string_t rss_hash;
2658 cmdline_fixed_string_t rss_type;
2659 cmdline_fixed_string_t key; /* optional argument */
2662 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2663 __attribute__((unused)) struct cmdline *cl,
2666 struct cmd_showport_rss_hash *res = parsed_result;
2668 port_rss_hash_conf_show(res->port_id, res->rss_type,
2669 show_rss_key != NULL);
2672 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2673 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2674 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2675 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2676 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2677 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2678 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2679 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2681 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2682 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2683 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2684 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2685 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2686 "ipv6-tcp-ex#ipv6-udp-ex");
2687 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2688 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2690 cmdline_parse_inst_t cmd_showport_rss_hash = {
2691 .f = cmd_showport_rss_hash_parsed,
2693 .help_str = "show port <port_id> rss-hash "
2694 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2695 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2696 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2698 (void *)&cmd_showport_rss_hash_show,
2699 (void *)&cmd_showport_rss_hash_port,
2700 (void *)&cmd_showport_rss_hash_port_id,
2701 (void *)&cmd_showport_rss_hash_rss_hash,
2702 (void *)&cmd_showport_rss_hash_rss_hash_info,
2707 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2708 .f = cmd_showport_rss_hash_parsed,
2710 .help_str = "show port <port_id> rss-hash "
2711 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2712 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2713 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2715 (void *)&cmd_showport_rss_hash_show,
2716 (void *)&cmd_showport_rss_hash_port,
2717 (void *)&cmd_showport_rss_hash_port_id,
2718 (void *)&cmd_showport_rss_hash_rss_hash,
2719 (void *)&cmd_showport_rss_hash_rss_hash_info,
2720 (void *)&cmd_showport_rss_hash_rss_key,
2725 /* *** Configure DCB *** */
2726 struct cmd_config_dcb {
2727 cmdline_fixed_string_t port;
2728 cmdline_fixed_string_t config;
2730 cmdline_fixed_string_t dcb;
2731 cmdline_fixed_string_t vt;
2732 cmdline_fixed_string_t vt_en;
2734 cmdline_fixed_string_t pfc;
2735 cmdline_fixed_string_t pfc_en;
2739 cmd_config_dcb_parsed(void *parsed_result,
2740 __attribute__((unused)) struct cmdline *cl,
2741 __attribute__((unused)) void *data)
2743 struct cmd_config_dcb *res = parsed_result;
2744 portid_t port_id = res->port_id;
2745 struct rte_port *port;
2749 port = &ports[port_id];
2750 /** Check if the port is not started **/
2751 if (port->port_status != RTE_PORT_STOPPED) {
2752 printf("Please stop port %d first\n", port_id);
2756 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2757 printf("The invalid number of traffic class,"
2758 " only 4 or 8 allowed.\n");
2762 if (nb_fwd_lcores < res->num_tcs) {
2763 printf("nb_cores shouldn't be less than number of TCs.\n");
2766 if (!strncmp(res->pfc_en, "on", 2))
2771 /* DCB in VT mode */
2772 if (!strncmp(res->vt_en, "on", 2))
2773 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2774 (enum rte_eth_nb_tcs)res->num_tcs,
2777 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2778 (enum rte_eth_nb_tcs)res->num_tcs,
2783 printf("Cannot initialize network ports.\n");
2787 cmd_reconfig_device_queue(port_id, 1, 1);
2790 cmdline_parse_token_string_t cmd_config_dcb_port =
2791 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2792 cmdline_parse_token_string_t cmd_config_dcb_config =
2793 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2794 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2795 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2796 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2797 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2798 cmdline_parse_token_string_t cmd_config_dcb_vt =
2799 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2800 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2801 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2802 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2803 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2804 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2805 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2806 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2807 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2809 cmdline_parse_inst_t cmd_config_dcb = {
2810 .f = cmd_config_dcb_parsed,
2812 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2814 (void *)&cmd_config_dcb_port,
2815 (void *)&cmd_config_dcb_config,
2816 (void *)&cmd_config_dcb_port_id,
2817 (void *)&cmd_config_dcb_dcb,
2818 (void *)&cmd_config_dcb_vt,
2819 (void *)&cmd_config_dcb_vt_en,
2820 (void *)&cmd_config_dcb_num_tcs,
2821 (void *)&cmd_config_dcb_pfc,
2822 (void *)&cmd_config_dcb_pfc_en,
2827 /* *** configure number of packets per burst *** */
2828 struct cmd_config_burst {
2829 cmdline_fixed_string_t port;
2830 cmdline_fixed_string_t keyword;
2831 cmdline_fixed_string_t all;
2832 cmdline_fixed_string_t name;
2837 cmd_config_burst_parsed(void *parsed_result,
2838 __attribute__((unused)) struct cmdline *cl,
2839 __attribute__((unused)) void *data)
2841 struct cmd_config_burst *res = parsed_result;
2842 struct rte_eth_dev_info dev_info;
2843 uint16_t rec_nb_pkts;
2845 if (!all_ports_stopped()) {
2846 printf("Please stop all ports first\n");
2850 if (!strcmp(res->name, "burst")) {
2851 if (res->value == 0) {
2852 /* If user gives a value of zero, query the PMD for
2853 * its recommended Rx burst size. Testpmd uses a single
2854 * size for all ports, so assume all ports are the same
2855 * NIC model and use the values from Port 0.
2857 rte_eth_dev_info_get(0, &dev_info);
2858 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2860 if (rec_nb_pkts == 0) {
2861 printf("PMD does not recommend a burst size.\n"
2862 "User provided value must be between"
2863 " 1 and %d\n", MAX_PKT_BURST);
2865 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2866 printf("PMD recommended burst size of %d"
2867 " exceeds maximum value of %d\n",
2868 rec_nb_pkts, MAX_PKT_BURST);
2871 printf("Using PMD-provided burst value of %d\n",
2873 nb_pkt_per_burst = rec_nb_pkts;
2874 } else if (res->value > MAX_PKT_BURST) {
2875 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2878 nb_pkt_per_burst = res->value;
2880 printf("Unknown parameter\n");
2886 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2889 cmdline_parse_token_string_t cmd_config_burst_port =
2890 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2891 cmdline_parse_token_string_t cmd_config_burst_keyword =
2892 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2893 cmdline_parse_token_string_t cmd_config_burst_all =
2894 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2895 cmdline_parse_token_string_t cmd_config_burst_name =
2896 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2897 cmdline_parse_token_num_t cmd_config_burst_value =
2898 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2900 cmdline_parse_inst_t cmd_config_burst = {
2901 .f = cmd_config_burst_parsed,
2903 .help_str = "port config all burst <value>",
2905 (void *)&cmd_config_burst_port,
2906 (void *)&cmd_config_burst_keyword,
2907 (void *)&cmd_config_burst_all,
2908 (void *)&cmd_config_burst_name,
2909 (void *)&cmd_config_burst_value,
2914 /* *** configure rx/tx queues *** */
2915 struct cmd_config_thresh {
2916 cmdline_fixed_string_t port;
2917 cmdline_fixed_string_t keyword;
2918 cmdline_fixed_string_t all;
2919 cmdline_fixed_string_t name;
2924 cmd_config_thresh_parsed(void *parsed_result,
2925 __attribute__((unused)) struct cmdline *cl,
2926 __attribute__((unused)) void *data)
2928 struct cmd_config_thresh *res = parsed_result;
2930 if (!all_ports_stopped()) {
2931 printf("Please stop all ports first\n");
2935 if (!strcmp(res->name, "txpt"))
2936 tx_pthresh = res->value;
2937 else if(!strcmp(res->name, "txht"))
2938 tx_hthresh = res->value;
2939 else if(!strcmp(res->name, "txwt"))
2940 tx_wthresh = res->value;
2941 else if(!strcmp(res->name, "rxpt"))
2942 rx_pthresh = res->value;
2943 else if(!strcmp(res->name, "rxht"))
2944 rx_hthresh = res->value;
2945 else if(!strcmp(res->name, "rxwt"))
2946 rx_wthresh = res->value;
2948 printf("Unknown parameter\n");
2954 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2957 cmdline_parse_token_string_t cmd_config_thresh_port =
2958 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2959 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2960 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2961 cmdline_parse_token_string_t cmd_config_thresh_all =
2962 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2963 cmdline_parse_token_string_t cmd_config_thresh_name =
2964 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2965 "txpt#txht#txwt#rxpt#rxht#rxwt");
2966 cmdline_parse_token_num_t cmd_config_thresh_value =
2967 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2969 cmdline_parse_inst_t cmd_config_thresh = {
2970 .f = cmd_config_thresh_parsed,
2972 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2974 (void *)&cmd_config_thresh_port,
2975 (void *)&cmd_config_thresh_keyword,
2976 (void *)&cmd_config_thresh_all,
2977 (void *)&cmd_config_thresh_name,
2978 (void *)&cmd_config_thresh_value,
2983 /* *** configure free/rs threshold *** */
2984 struct cmd_config_threshold {
2985 cmdline_fixed_string_t port;
2986 cmdline_fixed_string_t keyword;
2987 cmdline_fixed_string_t all;
2988 cmdline_fixed_string_t name;
2993 cmd_config_threshold_parsed(void *parsed_result,
2994 __attribute__((unused)) struct cmdline *cl,
2995 __attribute__((unused)) void *data)
2997 struct cmd_config_threshold *res = parsed_result;
2999 if (!all_ports_stopped()) {
3000 printf("Please stop all ports first\n");
3004 if (!strcmp(res->name, "txfreet"))
3005 tx_free_thresh = res->value;
3006 else if (!strcmp(res->name, "txrst"))
3007 tx_rs_thresh = res->value;
3008 else if (!strcmp(res->name, "rxfreet"))
3009 rx_free_thresh = res->value;
3011 printf("Unknown parameter\n");
3017 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3020 cmdline_parse_token_string_t cmd_config_threshold_port =
3021 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3022 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3023 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3025 cmdline_parse_token_string_t cmd_config_threshold_all =
3026 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3027 cmdline_parse_token_string_t cmd_config_threshold_name =
3028 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3029 "txfreet#txrst#rxfreet");
3030 cmdline_parse_token_num_t cmd_config_threshold_value =
3031 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3033 cmdline_parse_inst_t cmd_config_threshold = {
3034 .f = cmd_config_threshold_parsed,
3036 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3038 (void *)&cmd_config_threshold_port,
3039 (void *)&cmd_config_threshold_keyword,
3040 (void *)&cmd_config_threshold_all,
3041 (void *)&cmd_config_threshold_name,
3042 (void *)&cmd_config_threshold_value,
3048 struct cmd_stop_result {
3049 cmdline_fixed_string_t stop;
3052 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3053 __attribute__((unused)) struct cmdline *cl,
3054 __attribute__((unused)) void *data)
3056 stop_packet_forwarding();
3059 cmdline_parse_token_string_t cmd_stop_stop =
3060 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3062 cmdline_parse_inst_t cmd_stop = {
3063 .f = cmd_stop_parsed,
3065 .help_str = "stop: Stop packet forwarding",
3067 (void *)&cmd_stop_stop,
3072 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3075 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3076 unsigned int *parsed_items, int check_unique_values)
3078 unsigned int nb_item;
3086 * First parse all items in the list and store their value.
3091 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3093 if ((c >= '0') && (c <= '9')) {
3094 value = (unsigned int) (value * 10 + (c - '0'));
3099 printf("character %c is not a decimal digit\n", c);
3103 printf("No valid value before comma\n");
3106 if (nb_item < max_items) {
3107 parsed_items[nb_item] = value;
3113 if (nb_item >= max_items) {
3114 printf("Number of %s = %u > %u (maximum items)\n",
3115 item_name, nb_item + 1, max_items);
3118 parsed_items[nb_item++] = value;
3119 if (! check_unique_values)
3123 * Then, check that all values in the list are differents.
3124 * No optimization here...
3126 for (i = 0; i < nb_item; i++) {
3127 for (j = i + 1; j < nb_item; j++) {
3128 if (parsed_items[j] == parsed_items[i]) {
3129 printf("duplicated %s %u at index %u and %u\n",
3130 item_name, parsed_items[i], i, j);
3138 struct cmd_set_list_result {
3139 cmdline_fixed_string_t cmd_keyword;
3140 cmdline_fixed_string_t list_name;
3141 cmdline_fixed_string_t list_of_items;
3144 static void cmd_set_list_parsed(void *parsed_result,
3145 __attribute__((unused)) struct cmdline *cl,
3146 __attribute__((unused)) void *data)
3148 struct cmd_set_list_result *res;
3150 unsigned int lcorelist[RTE_MAX_LCORE];
3151 unsigned int portlist[RTE_MAX_ETHPORTS];
3153 unsigned int nb_item;
3155 if (test_done == 0) {
3156 printf("Please stop forwarding first\n");
3160 res = parsed_result;
3161 if (!strcmp(res->list_name, "corelist")) {
3162 nb_item = parse_item_list(res->list_of_items, "core",
3164 parsed_items.lcorelist, 1);
3166 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3171 if (!strcmp(res->list_name, "portlist")) {
3172 nb_item = parse_item_list(res->list_of_items, "port",
3174 parsed_items.portlist, 1);
3176 set_fwd_ports_list(parsed_items.portlist, nb_item);
3182 cmdline_parse_token_string_t cmd_set_list_keyword =
3183 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3185 cmdline_parse_token_string_t cmd_set_list_name =
3186 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3187 "corelist#portlist");
3188 cmdline_parse_token_string_t cmd_set_list_of_items =
3189 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3192 cmdline_parse_inst_t cmd_set_fwd_list = {
3193 .f = cmd_set_list_parsed,
3195 .help_str = "set corelist|portlist <list0[,list1]*>",
3197 (void *)&cmd_set_list_keyword,
3198 (void *)&cmd_set_list_name,
3199 (void *)&cmd_set_list_of_items,
3204 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3206 struct cmd_setmask_result {
3207 cmdline_fixed_string_t set;
3208 cmdline_fixed_string_t mask;
3212 static void cmd_set_mask_parsed(void *parsed_result,
3213 __attribute__((unused)) struct cmdline *cl,
3214 __attribute__((unused)) void *data)
3216 struct cmd_setmask_result *res = parsed_result;
3218 if (test_done == 0) {
3219 printf("Please stop forwarding first\n");
3222 if (!strcmp(res->mask, "coremask")) {
3223 set_fwd_lcores_mask(res->hexavalue);
3225 } else if (!strcmp(res->mask, "portmask")) {
3226 set_fwd_ports_mask(res->hexavalue);
3231 cmdline_parse_token_string_t cmd_setmask_set =
3232 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3233 cmdline_parse_token_string_t cmd_setmask_mask =
3234 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3235 "coremask#portmask");
3236 cmdline_parse_token_num_t cmd_setmask_value =
3237 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3239 cmdline_parse_inst_t cmd_set_fwd_mask = {
3240 .f = cmd_set_mask_parsed,
3242 .help_str = "set coremask|portmask <hexadecimal value>",
3244 (void *)&cmd_setmask_set,
3245 (void *)&cmd_setmask_mask,
3246 (void *)&cmd_setmask_value,
3252 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3254 struct cmd_set_result {
3255 cmdline_fixed_string_t set;
3256 cmdline_fixed_string_t what;
3260 static void cmd_set_parsed(void *parsed_result,
3261 __attribute__((unused)) struct cmdline *cl,
3262 __attribute__((unused)) void *data)
3264 struct cmd_set_result *res = parsed_result;
3265 if (!strcmp(res->what, "nbport")) {
3266 set_fwd_ports_number(res->value);
3268 } else if (!strcmp(res->what, "nbcore")) {
3269 set_fwd_lcores_number(res->value);
3271 } else if (!strcmp(res->what, "burst"))
3272 set_nb_pkt_per_burst(res->value);
3273 else if (!strcmp(res->what, "verbose"))
3274 set_verbose_level(res->value);
3277 cmdline_parse_token_string_t cmd_set_set =
3278 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3279 cmdline_parse_token_string_t cmd_set_what =
3280 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3281 "nbport#nbcore#burst#verbose");
3282 cmdline_parse_token_num_t cmd_set_value =
3283 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3285 cmdline_parse_inst_t cmd_set_numbers = {
3286 .f = cmd_set_parsed,
3288 .help_str = "set nbport|nbcore|burst|verbose <value>",
3290 (void *)&cmd_set_set,
3291 (void *)&cmd_set_what,
3292 (void *)&cmd_set_value,
3297 /* *** SET LOG LEVEL CONFIGURATION *** */
3299 struct cmd_set_log_result {
3300 cmdline_fixed_string_t set;
3301 cmdline_fixed_string_t log;
3302 cmdline_fixed_string_t type;
3307 cmd_set_log_parsed(void *parsed_result,
3308 __attribute__((unused)) struct cmdline *cl,
3309 __attribute__((unused)) void *data)
3311 struct cmd_set_log_result *res;
3314 res = parsed_result;
3315 if (!strcmp(res->type, "global"))
3316 rte_log_set_global_level(res->level);
3318 ret = rte_log_set_level_regexp(res->type, res->level);
3320 printf("Unable to set log level\n");
3324 cmdline_parse_token_string_t cmd_set_log_set =
3325 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3326 cmdline_parse_token_string_t cmd_set_log_log =
3327 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3328 cmdline_parse_token_string_t cmd_set_log_type =
3329 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3330 cmdline_parse_token_num_t cmd_set_log_level =
3331 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3333 cmdline_parse_inst_t cmd_set_log = {
3334 .f = cmd_set_log_parsed,
3336 .help_str = "set log global|<type> <level>",
3338 (void *)&cmd_set_log_set,
3339 (void *)&cmd_set_log_log,
3340 (void *)&cmd_set_log_type,
3341 (void *)&cmd_set_log_level,
3346 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3348 struct cmd_set_txpkts_result {
3349 cmdline_fixed_string_t cmd_keyword;
3350 cmdline_fixed_string_t txpkts;
3351 cmdline_fixed_string_t seg_lengths;
3355 cmd_set_txpkts_parsed(void *parsed_result,
3356 __attribute__((unused)) struct cmdline *cl,
3357 __attribute__((unused)) void *data)
3359 struct cmd_set_txpkts_result *res;
3360 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3361 unsigned int nb_segs;
3363 res = parsed_result;
3364 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3365 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3367 set_tx_pkt_segments(seg_lengths, nb_segs);
3370 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3371 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3372 cmd_keyword, "set");
3373 cmdline_parse_token_string_t cmd_set_txpkts_name =
3374 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3376 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3377 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3380 cmdline_parse_inst_t cmd_set_txpkts = {
3381 .f = cmd_set_txpkts_parsed,
3383 .help_str = "set txpkts <len0[,len1]*>",
3385 (void *)&cmd_set_txpkts_keyword,
3386 (void *)&cmd_set_txpkts_name,
3387 (void *)&cmd_set_txpkts_lengths,
3392 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3394 struct cmd_set_txsplit_result {
3395 cmdline_fixed_string_t cmd_keyword;
3396 cmdline_fixed_string_t txsplit;
3397 cmdline_fixed_string_t mode;
3401 cmd_set_txsplit_parsed(void *parsed_result,
3402 __attribute__((unused)) struct cmdline *cl,
3403 __attribute__((unused)) void *data)
3405 struct cmd_set_txsplit_result *res;
3407 res = parsed_result;
3408 set_tx_pkt_split(res->mode);
3411 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3412 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3413 cmd_keyword, "set");
3414 cmdline_parse_token_string_t cmd_set_txsplit_name =
3415 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3416 txsplit, "txsplit");
3417 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3418 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3421 cmdline_parse_inst_t cmd_set_txsplit = {
3422 .f = cmd_set_txsplit_parsed,
3424 .help_str = "set txsplit on|off|rand",
3426 (void *)&cmd_set_txsplit_keyword,
3427 (void *)&cmd_set_txsplit_name,
3428 (void *)&cmd_set_txsplit_mode,
3433 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3434 struct cmd_rx_vlan_filter_all_result {
3435 cmdline_fixed_string_t rx_vlan;
3436 cmdline_fixed_string_t what;
3437 cmdline_fixed_string_t all;
3442 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3443 __attribute__((unused)) struct cmdline *cl,
3444 __attribute__((unused)) void *data)
3446 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3448 if (!strcmp(res->what, "add"))
3449 rx_vlan_all_filter_set(res->port_id, 1);
3451 rx_vlan_all_filter_set(res->port_id, 0);
3454 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3455 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3456 rx_vlan, "rx_vlan");
3457 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3458 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3460 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3461 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3463 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3464 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3467 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3468 .f = cmd_rx_vlan_filter_all_parsed,
3470 .help_str = "rx_vlan add|rm all <port_id>: "
3471 "Add/Remove all identifiers to/from the set of VLAN "
3472 "identifiers filtered by a port",
3474 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3475 (void *)&cmd_rx_vlan_filter_all_what,
3476 (void *)&cmd_rx_vlan_filter_all_all,
3477 (void *)&cmd_rx_vlan_filter_all_portid,
3482 /* *** VLAN OFFLOAD SET ON A PORT *** */
3483 struct cmd_vlan_offload_result {
3484 cmdline_fixed_string_t vlan;
3485 cmdline_fixed_string_t set;
3486 cmdline_fixed_string_t vlan_type;
3487 cmdline_fixed_string_t what;
3488 cmdline_fixed_string_t on;
3489 cmdline_fixed_string_t port_id;
3493 cmd_vlan_offload_parsed(void *parsed_result,
3494 __attribute__((unused)) struct cmdline *cl,
3495 __attribute__((unused)) void *data)
3498 struct cmd_vlan_offload_result *res = parsed_result;
3501 portid_t port_id = 0;
3505 len = strnlen(str, STR_TOKEN_SIZE);
3507 /* Get port_id first */
3515 tmp = strtoul(str, NULL, 0);
3516 /* If port_id greater that what portid_t can represent, return */
3517 if(tmp >= RTE_MAX_ETHPORTS)
3519 port_id = (portid_t)tmp;
3521 if (!strcmp(res->on, "on"))
3526 if (!strcmp(res->what, "strip"))
3527 rx_vlan_strip_set(port_id, on);
3528 else if(!strcmp(res->what, "stripq")){
3529 uint16_t queue_id = 0;
3531 /* No queue_id, return */
3533 printf("must specify (port,queue_id)\n");
3536 tmp = strtoul(str + i + 1, NULL, 0);
3537 /* If queue_id greater that what 16-bits can represent, return */
3541 queue_id = (uint16_t)tmp;
3542 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3544 else if (!strcmp(res->what, "filter"))
3545 rx_vlan_filter_set(port_id, on);
3547 vlan_extend_set(port_id, on);
3552 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3553 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3555 cmdline_parse_token_string_t cmd_vlan_offload_set =
3556 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3558 cmdline_parse_token_string_t cmd_vlan_offload_what =
3559 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3560 what, "strip#filter#qinq#stripq");
3561 cmdline_parse_token_string_t cmd_vlan_offload_on =
3562 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3564 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3565 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3568 cmdline_parse_inst_t cmd_vlan_offload = {
3569 .f = cmd_vlan_offload_parsed,
3571 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3572 "<port_id[,queue_id]>: "
3573 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3575 (void *)&cmd_vlan_offload_vlan,
3576 (void *)&cmd_vlan_offload_set,
3577 (void *)&cmd_vlan_offload_what,
3578 (void *)&cmd_vlan_offload_on,
3579 (void *)&cmd_vlan_offload_portid,
3584 /* *** VLAN TPID SET ON A PORT *** */
3585 struct cmd_vlan_tpid_result {
3586 cmdline_fixed_string_t vlan;
3587 cmdline_fixed_string_t set;
3588 cmdline_fixed_string_t vlan_type;
3589 cmdline_fixed_string_t what;
3595 cmd_vlan_tpid_parsed(void *parsed_result,
3596 __attribute__((unused)) struct cmdline *cl,
3597 __attribute__((unused)) void *data)
3599 struct cmd_vlan_tpid_result *res = parsed_result;
3600 enum rte_vlan_type vlan_type;
3602 if (!strcmp(res->vlan_type, "inner"))
3603 vlan_type = ETH_VLAN_TYPE_INNER;
3604 else if (!strcmp(res->vlan_type, "outer"))
3605 vlan_type = ETH_VLAN_TYPE_OUTER;
3607 printf("Unknown vlan type\n");
3610 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3613 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3614 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3616 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3617 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3619 cmdline_parse_token_string_t cmd_vlan_type =
3620 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3621 vlan_type, "inner#outer");
3622 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3623 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3625 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3626 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3628 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3629 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3632 cmdline_parse_inst_t cmd_vlan_tpid = {
3633 .f = cmd_vlan_tpid_parsed,
3635 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3636 "Set the VLAN Ether type",
3638 (void *)&cmd_vlan_tpid_vlan,
3639 (void *)&cmd_vlan_tpid_set,
3640 (void *)&cmd_vlan_type,
3641 (void *)&cmd_vlan_tpid_what,
3642 (void *)&cmd_vlan_tpid_tpid,
3643 (void *)&cmd_vlan_tpid_portid,
3648 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3649 struct cmd_rx_vlan_filter_result {
3650 cmdline_fixed_string_t rx_vlan;
3651 cmdline_fixed_string_t what;
3657 cmd_rx_vlan_filter_parsed(void *parsed_result,
3658 __attribute__((unused)) struct cmdline *cl,
3659 __attribute__((unused)) void *data)
3661 struct cmd_rx_vlan_filter_result *res = parsed_result;
3663 if (!strcmp(res->what, "add"))
3664 rx_vft_set(res->port_id, res->vlan_id, 1);
3666 rx_vft_set(res->port_id, res->vlan_id, 0);
3669 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3670 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3671 rx_vlan, "rx_vlan");
3672 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3673 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3675 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3676 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3678 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3679 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3682 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3683 .f = cmd_rx_vlan_filter_parsed,
3685 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3686 "Add/Remove a VLAN identifier to/from the set of VLAN "
3687 "identifiers filtered by a port",
3689 (void *)&cmd_rx_vlan_filter_rx_vlan,
3690 (void *)&cmd_rx_vlan_filter_what,
3691 (void *)&cmd_rx_vlan_filter_vlanid,
3692 (void *)&cmd_rx_vlan_filter_portid,
3697 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3698 struct cmd_tx_vlan_set_result {
3699 cmdline_fixed_string_t tx_vlan;
3700 cmdline_fixed_string_t set;
3706 cmd_tx_vlan_set_parsed(void *parsed_result,
3707 __attribute__((unused)) struct cmdline *cl,
3708 __attribute__((unused)) void *data)
3710 struct cmd_tx_vlan_set_result *res = parsed_result;
3712 if (!port_is_stopped(res->port_id)) {
3713 printf("Please stop port %d first\n", res->port_id);
3717 tx_vlan_set(res->port_id, res->vlan_id);
3719 cmd_reconfig_device_queue(res->port_id, 1, 1);
3722 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3723 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3724 tx_vlan, "tx_vlan");
3725 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3726 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3728 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3729 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3731 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3732 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3735 cmdline_parse_inst_t cmd_tx_vlan_set = {
3736 .f = cmd_tx_vlan_set_parsed,
3738 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3739 "Enable hardware insertion of a single VLAN header "
3740 "with a given TAG Identifier in packets sent on a port",
3742 (void *)&cmd_tx_vlan_set_tx_vlan,
3743 (void *)&cmd_tx_vlan_set_set,
3744 (void *)&cmd_tx_vlan_set_portid,
3745 (void *)&cmd_tx_vlan_set_vlanid,
3750 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3751 struct cmd_tx_vlan_set_qinq_result {
3752 cmdline_fixed_string_t tx_vlan;
3753 cmdline_fixed_string_t set;
3756 uint16_t vlan_id_outer;
3760 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3761 __attribute__((unused)) struct cmdline *cl,
3762 __attribute__((unused)) void *data)
3764 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3766 if (!port_is_stopped(res->port_id)) {
3767 printf("Please stop port %d first\n", res->port_id);
3771 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3773 cmd_reconfig_device_queue(res->port_id, 1, 1);
3776 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3777 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3778 tx_vlan, "tx_vlan");
3779 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3780 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3782 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3783 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3785 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3786 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3788 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3789 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3790 vlan_id_outer, UINT16);
3792 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3793 .f = cmd_tx_vlan_set_qinq_parsed,
3795 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3796 "Enable hardware insertion of double VLAN header "
3797 "with given TAG Identifiers in packets sent on a port",
3799 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3800 (void *)&cmd_tx_vlan_set_qinq_set,
3801 (void *)&cmd_tx_vlan_set_qinq_portid,
3802 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3803 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3808 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3809 struct cmd_tx_vlan_set_pvid_result {
3810 cmdline_fixed_string_t tx_vlan;
3811 cmdline_fixed_string_t set;
3812 cmdline_fixed_string_t pvid;
3815 cmdline_fixed_string_t mode;
3819 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3820 __attribute__((unused)) struct cmdline *cl,
3821 __attribute__((unused)) void *data)
3823 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3825 if (strcmp(res->mode, "on") == 0)
3826 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3828 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3831 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3832 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3833 tx_vlan, "tx_vlan");
3834 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3835 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3837 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3838 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3840 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3841 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3843 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3844 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3846 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3847 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3850 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3851 .f = cmd_tx_vlan_set_pvid_parsed,
3853 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3855 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3856 (void *)&cmd_tx_vlan_set_pvid_set,
3857 (void *)&cmd_tx_vlan_set_pvid_pvid,
3858 (void *)&cmd_tx_vlan_set_pvid_port_id,
3859 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3860 (void *)&cmd_tx_vlan_set_pvid_mode,
3865 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3866 struct cmd_tx_vlan_reset_result {
3867 cmdline_fixed_string_t tx_vlan;
3868 cmdline_fixed_string_t reset;
3873 cmd_tx_vlan_reset_parsed(void *parsed_result,
3874 __attribute__((unused)) struct cmdline *cl,
3875 __attribute__((unused)) void *data)
3877 struct cmd_tx_vlan_reset_result *res = parsed_result;
3879 if (!port_is_stopped(res->port_id)) {
3880 printf("Please stop port %d first\n", res->port_id);
3884 tx_vlan_reset(res->port_id);
3886 cmd_reconfig_device_queue(res->port_id, 1, 1);
3889 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3890 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3891 tx_vlan, "tx_vlan");
3892 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3893 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3895 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3896 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3899 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3900 .f = cmd_tx_vlan_reset_parsed,
3902 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3903 "VLAN header in packets sent on a port",
3905 (void *)&cmd_tx_vlan_reset_tx_vlan,
3906 (void *)&cmd_tx_vlan_reset_reset,
3907 (void *)&cmd_tx_vlan_reset_portid,
3913 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3914 struct cmd_csum_result {
3915 cmdline_fixed_string_t csum;
3916 cmdline_fixed_string_t mode;
3917 cmdline_fixed_string_t proto;
3918 cmdline_fixed_string_t hwsw;
3923 csum_show(int port_id)
3925 struct rte_eth_dev_info dev_info;
3926 uint64_t tx_offloads;
3928 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3929 printf("Parse tunnel is %s\n",
3930 (ports[port_id].parse_tunnel) ? "on" : "off");
3931 printf("IP checksum offload is %s\n",
3932 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3933 printf("UDP checksum offload is %s\n",
3934 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3935 printf("TCP checksum offload is %s\n",
3936 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3937 printf("SCTP checksum offload is %s\n",
3938 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3939 printf("Outer-Ip checksum offload is %s\n",
3940 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3942 /* display warnings if configuration is not supported by the NIC */
3943 rte_eth_dev_info_get(port_id, &dev_info);
3944 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3945 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3946 printf("Warning: hardware IP checksum enabled but not "
3947 "supported by port %d\n", port_id);
3949 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3950 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3951 printf("Warning: hardware UDP checksum enabled but not "
3952 "supported by port %d\n", port_id);
3954 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3955 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3956 printf("Warning: hardware TCP checksum enabled but not "
3957 "supported by port %d\n", port_id);
3959 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3960 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3961 printf("Warning: hardware SCTP checksum enabled but not "
3962 "supported by port %d\n", port_id);
3964 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3965 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3966 printf("Warning: hardware outer IP checksum enabled but not "
3967 "supported by port %d\n", port_id);
3972 cmd_csum_parsed(void *parsed_result,
3973 __attribute__((unused)) struct cmdline *cl,
3974 __attribute__((unused)) void *data)
3976 struct cmd_csum_result *res = parsed_result;
3978 uint64_t csum_offloads = 0;
3979 struct rte_eth_dev_info dev_info;
3981 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3982 printf("invalid port %d\n", res->port_id);
3985 if (!port_is_stopped(res->port_id)) {
3986 printf("Please stop port %d first\n", res->port_id);
3990 rte_eth_dev_info_get(res->port_id, &dev_info);
3991 if (!strcmp(res->mode, "set")) {
3993 if (!strcmp(res->hwsw, "hw"))
3996 if (!strcmp(res->proto, "ip")) {
3997 if (hw == 0 || (dev_info.tx_offload_capa &
3998 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
3999 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4001 printf("IP checksum offload is not supported "
4002 "by port %u\n", res->port_id);
4004 } else if (!strcmp(res->proto, "udp")) {
4005 if (hw == 0 || (dev_info.tx_offload_capa &
4006 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4007 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4009 printf("UDP checksum offload is not supported "
4010 "by port %u\n", res->port_id);
4012 } else if (!strcmp(res->proto, "tcp")) {
4013 if (hw == 0 || (dev_info.tx_offload_capa &
4014 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4015 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4017 printf("TCP checksum offload is not supported "
4018 "by port %u\n", res->port_id);
4020 } else if (!strcmp(res->proto, "sctp")) {
4021 if (hw == 0 || (dev_info.tx_offload_capa &
4022 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4023 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4025 printf("SCTP checksum offload is not supported "
4026 "by port %u\n", res->port_id);
4028 } else if (!strcmp(res->proto, "outer-ip")) {
4029 if (hw == 0 || (dev_info.tx_offload_capa &
4030 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4032 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4034 printf("Outer IP checksum offload is not "
4035 "supported by port %u\n", res->port_id);
4040 ports[res->port_id].dev_conf.txmode.offloads |=
4043 ports[res->port_id].dev_conf.txmode.offloads &=
4047 csum_show(res->port_id);
4049 cmd_reconfig_device_queue(res->port_id, 1, 1);
4052 cmdline_parse_token_string_t cmd_csum_csum =
4053 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4055 cmdline_parse_token_string_t cmd_csum_mode =
4056 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4058 cmdline_parse_token_string_t cmd_csum_proto =
4059 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4060 proto, "ip#tcp#udp#sctp#outer-ip");
4061 cmdline_parse_token_string_t cmd_csum_hwsw =
4062 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4064 cmdline_parse_token_num_t cmd_csum_portid =
4065 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4068 cmdline_parse_inst_t cmd_csum_set = {
4069 .f = cmd_csum_parsed,
4071 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4072 "Enable/Disable hardware calculation of L3/L4 checksum when "
4073 "using csum forward engine",
4075 (void *)&cmd_csum_csum,
4076 (void *)&cmd_csum_mode,
4077 (void *)&cmd_csum_proto,
4078 (void *)&cmd_csum_hwsw,
4079 (void *)&cmd_csum_portid,
4084 cmdline_parse_token_string_t cmd_csum_mode_show =
4085 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4088 cmdline_parse_inst_t cmd_csum_show = {
4089 .f = cmd_csum_parsed,
4091 .help_str = "csum show <port_id>: Show checksum offload configuration",
4093 (void *)&cmd_csum_csum,
4094 (void *)&cmd_csum_mode_show,
4095 (void *)&cmd_csum_portid,
4100 /* Enable/disable tunnel parsing */
4101 struct cmd_csum_tunnel_result {
4102 cmdline_fixed_string_t csum;
4103 cmdline_fixed_string_t parse;
4104 cmdline_fixed_string_t onoff;
4109 cmd_csum_tunnel_parsed(void *parsed_result,
4110 __attribute__((unused)) struct cmdline *cl,
4111 __attribute__((unused)) void *data)
4113 struct cmd_csum_tunnel_result *res = parsed_result;
4115 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4118 if (!strcmp(res->onoff, "on"))
4119 ports[res->port_id].parse_tunnel = 1;
4121 ports[res->port_id].parse_tunnel = 0;
4123 csum_show(res->port_id);
4126 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4127 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4129 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4130 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4131 parse, "parse_tunnel");
4132 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4133 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4135 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4136 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4139 cmdline_parse_inst_t cmd_csum_tunnel = {
4140 .f = cmd_csum_tunnel_parsed,
4142 .help_str = "csum parse_tunnel on|off <port_id>: "
4143 "Enable/Disable parsing of tunnels for csum engine",
4145 (void *)&cmd_csum_tunnel_csum,
4146 (void *)&cmd_csum_tunnel_parse,
4147 (void *)&cmd_csum_tunnel_onoff,
4148 (void *)&cmd_csum_tunnel_portid,
4153 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4154 struct cmd_tso_set_result {
4155 cmdline_fixed_string_t tso;
4156 cmdline_fixed_string_t mode;
4162 cmd_tso_set_parsed(void *parsed_result,
4163 __attribute__((unused)) struct cmdline *cl,
4164 __attribute__((unused)) void *data)
4166 struct cmd_tso_set_result *res = parsed_result;
4167 struct rte_eth_dev_info dev_info;
4169 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4171 if (!port_is_stopped(res->port_id)) {
4172 printf("Please stop port %d first\n", res->port_id);
4176 if (!strcmp(res->mode, "set"))
4177 ports[res->port_id].tso_segsz = res->tso_segsz;
4179 rte_eth_dev_info_get(res->port_id, &dev_info);
4180 if ((ports[res->port_id].tso_segsz != 0) &&
4181 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4182 printf("Error: TSO is not supported by port %d\n",
4187 if (ports[res->port_id].tso_segsz == 0) {
4188 ports[res->port_id].dev_conf.txmode.offloads &=
4189 ~DEV_TX_OFFLOAD_TCP_TSO;
4190 printf("TSO for non-tunneled packets is disabled\n");
4192 ports[res->port_id].dev_conf.txmode.offloads |=
4193 DEV_TX_OFFLOAD_TCP_TSO;
4194 printf("TSO segment size for non-tunneled packets is %d\n",
4195 ports[res->port_id].tso_segsz);
4198 /* display warnings if configuration is not supported by the NIC */
4199 rte_eth_dev_info_get(res->port_id, &dev_info);
4200 if ((ports[res->port_id].tso_segsz != 0) &&
4201 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4202 printf("Warning: TSO enabled but not "
4203 "supported by port %d\n", res->port_id);
4206 cmd_reconfig_device_queue(res->port_id, 1, 1);
4209 cmdline_parse_token_string_t cmd_tso_set_tso =
4210 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4212 cmdline_parse_token_string_t cmd_tso_set_mode =
4213 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4215 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4216 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4218 cmdline_parse_token_num_t cmd_tso_set_portid =
4219 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4222 cmdline_parse_inst_t cmd_tso_set = {
4223 .f = cmd_tso_set_parsed,
4225 .help_str = "tso set <tso_segsz> <port_id>: "
4226 "Set TSO segment size of non-tunneled packets for csum engine "
4229 (void *)&cmd_tso_set_tso,
4230 (void *)&cmd_tso_set_mode,
4231 (void *)&cmd_tso_set_tso_segsz,
4232 (void *)&cmd_tso_set_portid,
4237 cmdline_parse_token_string_t cmd_tso_show_mode =
4238 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4242 cmdline_parse_inst_t cmd_tso_show = {
4243 .f = cmd_tso_set_parsed,
4245 .help_str = "tso show <port_id>: "
4246 "Show TSO segment size of non-tunneled packets for csum engine",
4248 (void *)&cmd_tso_set_tso,
4249 (void *)&cmd_tso_show_mode,
4250 (void *)&cmd_tso_set_portid,
4255 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4256 struct cmd_tunnel_tso_set_result {
4257 cmdline_fixed_string_t tso;
4258 cmdline_fixed_string_t mode;
4263 static struct rte_eth_dev_info
4264 check_tunnel_tso_nic_support(portid_t port_id)
4266 struct rte_eth_dev_info dev_info;
4268 rte_eth_dev_info_get(port_id, &dev_info);
4269 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4270 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4271 "not enabled for port %d\n", port_id);
4272 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4273 printf("Warning: GRE TUNNEL TSO not supported therefore "
4274 "not enabled for port %d\n", port_id);
4275 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4276 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4277 "not enabled for port %d\n", port_id);
4278 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4279 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4280 "not enabled for port %d\n", port_id);
4281 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4282 printf("Warning: IP TUNNEL TSO not supported therefore "
4283 "not enabled for port %d\n", port_id);
4284 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4285 printf("Warning: UDP TUNNEL TSO not supported therefore "
4286 "not enabled for port %d\n", port_id);
4291 cmd_tunnel_tso_set_parsed(void *parsed_result,
4292 __attribute__((unused)) struct cmdline *cl,
4293 __attribute__((unused)) void *data)
4295 struct cmd_tunnel_tso_set_result *res = parsed_result;
4296 struct rte_eth_dev_info dev_info;
4298 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4300 if (!port_is_stopped(res->port_id)) {
4301 printf("Please stop port %d first\n", res->port_id);
4305 if (!strcmp(res->mode, "set"))
4306 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4308 dev_info = check_tunnel_tso_nic_support(res->port_id);
4309 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4310 ports[res->port_id].dev_conf.txmode.offloads &=
4311 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4312 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4313 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4314 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4315 DEV_TX_OFFLOAD_IP_TNL_TSO |
4316 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4317 printf("TSO for tunneled packets is disabled\n");
4319 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4320 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4321 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4322 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4323 DEV_TX_OFFLOAD_IP_TNL_TSO |
4324 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4326 ports[res->port_id].dev_conf.txmode.offloads |=
4327 (tso_offloads & dev_info.tx_offload_capa);
4328 printf("TSO segment size for tunneled packets is %d\n",
4329 ports[res->port_id].tunnel_tso_segsz);
4331 /* Below conditions are needed to make it work:
4332 * (1) tunnel TSO is supported by the NIC;
4333 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4335 * (3) for tunneled pkts with outer L3 of IPv4,
4336 * "csum set outer-ip" must be set to hw, because after tso,
4337 * total_len of outer IP header is changed, and the checksum
4338 * of outer IP header calculated by sw should be wrong; that
4339 * is not necessary for IPv6 tunneled pkts because there's no
4340 * checksum in IP header anymore.
4343 if (!ports[res->port_id].parse_tunnel)
4344 printf("Warning: csum parse_tunnel must be set "
4345 "so that tunneled packets are recognized\n");
4346 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4347 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4348 printf("Warning: csum set outer-ip must be set to hw "
4349 "if outer L3 is IPv4; not necessary for IPv6\n");
4352 cmd_reconfig_device_queue(res->port_id, 1, 1);
4355 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4356 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4358 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4359 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4361 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4362 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4364 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4365 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4368 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4369 .f = cmd_tunnel_tso_set_parsed,
4371 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4372 "Set TSO segment size of tunneled packets for csum engine "
4375 (void *)&cmd_tunnel_tso_set_tso,
4376 (void *)&cmd_tunnel_tso_set_mode,
4377 (void *)&cmd_tunnel_tso_set_tso_segsz,
4378 (void *)&cmd_tunnel_tso_set_portid,
4383 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4384 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4388 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4389 .f = cmd_tunnel_tso_set_parsed,
4391 .help_str = "tunnel_tso show <port_id> "
4392 "Show TSO segment size of tunneled packets for csum engine",
4394 (void *)&cmd_tunnel_tso_set_tso,
4395 (void *)&cmd_tunnel_tso_show_mode,
4396 (void *)&cmd_tunnel_tso_set_portid,
4401 /* *** SET GRO FOR A PORT *** */
4402 struct cmd_gro_enable_result {
4403 cmdline_fixed_string_t cmd_set;
4404 cmdline_fixed_string_t cmd_port;
4405 cmdline_fixed_string_t cmd_keyword;
4406 cmdline_fixed_string_t cmd_onoff;
4411 cmd_gro_enable_parsed(void *parsed_result,
4412 __attribute__((unused)) struct cmdline *cl,
4413 __attribute__((unused)) void *data)
4415 struct cmd_gro_enable_result *res;
4417 res = parsed_result;
4418 if (!strcmp(res->cmd_keyword, "gro"))
4419 setup_gro(res->cmd_onoff, res->cmd_pid);
4422 cmdline_parse_token_string_t cmd_gro_enable_set =
4423 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4425 cmdline_parse_token_string_t cmd_gro_enable_port =
4426 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4427 cmd_keyword, "port");
4428 cmdline_parse_token_num_t cmd_gro_enable_pid =
4429 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4431 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4432 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4433 cmd_keyword, "gro");
4434 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4435 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4436 cmd_onoff, "on#off");
4438 cmdline_parse_inst_t cmd_gro_enable = {
4439 .f = cmd_gro_enable_parsed,
4441 .help_str = "set port <port_id> gro on|off",
4443 (void *)&cmd_gro_enable_set,
4444 (void *)&cmd_gro_enable_port,
4445 (void *)&cmd_gro_enable_pid,
4446 (void *)&cmd_gro_enable_keyword,
4447 (void *)&cmd_gro_enable_onoff,
4452 /* *** DISPLAY GRO CONFIGURATION *** */
4453 struct cmd_gro_show_result {
4454 cmdline_fixed_string_t cmd_show;
4455 cmdline_fixed_string_t cmd_port;
4456 cmdline_fixed_string_t cmd_keyword;
4461 cmd_gro_show_parsed(void *parsed_result,
4462 __attribute__((unused)) struct cmdline *cl,
4463 __attribute__((unused)) void *data)
4465 struct cmd_gro_show_result *res;
4467 res = parsed_result;
4468 if (!strcmp(res->cmd_keyword, "gro"))
4469 show_gro(res->cmd_pid);
4472 cmdline_parse_token_string_t cmd_gro_show_show =
4473 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4475 cmdline_parse_token_string_t cmd_gro_show_port =
4476 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4478 cmdline_parse_token_num_t cmd_gro_show_pid =
4479 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4481 cmdline_parse_token_string_t cmd_gro_show_keyword =
4482 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4483 cmd_keyword, "gro");
4485 cmdline_parse_inst_t cmd_gro_show = {
4486 .f = cmd_gro_show_parsed,
4488 .help_str = "show port <port_id> gro",
4490 (void *)&cmd_gro_show_show,
4491 (void *)&cmd_gro_show_port,
4492 (void *)&cmd_gro_show_pid,
4493 (void *)&cmd_gro_show_keyword,
4498 /* *** SET FLUSH CYCLES FOR GRO *** */
4499 struct cmd_gro_flush_result {
4500 cmdline_fixed_string_t cmd_set;
4501 cmdline_fixed_string_t cmd_keyword;
4502 cmdline_fixed_string_t cmd_flush;
4507 cmd_gro_flush_parsed(void *parsed_result,
4508 __attribute__((unused)) struct cmdline *cl,
4509 __attribute__((unused)) void *data)
4511 struct cmd_gro_flush_result *res;
4513 res = parsed_result;
4514 if ((!strcmp(res->cmd_keyword, "gro")) &&
4515 (!strcmp(res->cmd_flush, "flush")))
4516 setup_gro_flush_cycles(res->cmd_cycles);
4519 cmdline_parse_token_string_t cmd_gro_flush_set =
4520 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4522 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4523 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4524 cmd_keyword, "gro");
4525 cmdline_parse_token_string_t cmd_gro_flush_flush =
4526 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4527 cmd_flush, "flush");
4528 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4529 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4532 cmdline_parse_inst_t cmd_gro_flush = {
4533 .f = cmd_gro_flush_parsed,
4535 .help_str = "set gro flush <cycles>",
4537 (void *)&cmd_gro_flush_set,
4538 (void *)&cmd_gro_flush_keyword,
4539 (void *)&cmd_gro_flush_flush,
4540 (void *)&cmd_gro_flush_cycles,
4545 /* *** ENABLE/DISABLE GSO *** */
4546 struct cmd_gso_enable_result {
4547 cmdline_fixed_string_t cmd_set;
4548 cmdline_fixed_string_t cmd_port;
4549 cmdline_fixed_string_t cmd_keyword;
4550 cmdline_fixed_string_t cmd_mode;
4555 cmd_gso_enable_parsed(void *parsed_result,
4556 __attribute__((unused)) struct cmdline *cl,
4557 __attribute__((unused)) void *data)
4559 struct cmd_gso_enable_result *res;
4561 res = parsed_result;
4562 if (!strcmp(res->cmd_keyword, "gso"))
4563 setup_gso(res->cmd_mode, res->cmd_pid);
4566 cmdline_parse_token_string_t cmd_gso_enable_set =
4567 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4569 cmdline_parse_token_string_t cmd_gso_enable_port =
4570 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4572 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4573 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4574 cmd_keyword, "gso");
4575 cmdline_parse_token_string_t cmd_gso_enable_mode =
4576 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4577 cmd_mode, "on#off");
4578 cmdline_parse_token_num_t cmd_gso_enable_pid =
4579 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4582 cmdline_parse_inst_t cmd_gso_enable = {
4583 .f = cmd_gso_enable_parsed,
4585 .help_str = "set port <port_id> gso on|off",
4587 (void *)&cmd_gso_enable_set,
4588 (void *)&cmd_gso_enable_port,
4589 (void *)&cmd_gso_enable_pid,
4590 (void *)&cmd_gso_enable_keyword,
4591 (void *)&cmd_gso_enable_mode,
4596 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4597 struct cmd_gso_size_result {
4598 cmdline_fixed_string_t cmd_set;
4599 cmdline_fixed_string_t cmd_keyword;
4600 cmdline_fixed_string_t cmd_segsz;
4605 cmd_gso_size_parsed(void *parsed_result,
4606 __attribute__((unused)) struct cmdline *cl,
4607 __attribute__((unused)) void *data)
4609 struct cmd_gso_size_result *res = parsed_result;
4611 if (test_done == 0) {
4612 printf("Before setting GSO segsz, please first"
4613 " stop fowarding\n");
4617 if (!strcmp(res->cmd_keyword, "gso") &&
4618 !strcmp(res->cmd_segsz, "segsz")) {
4619 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4620 printf("gso_size should be larger than %zu."
4621 " Please input a legal value\n",
4622 RTE_GSO_SEG_SIZE_MIN);
4624 gso_max_segment_size = res->cmd_size;
4628 cmdline_parse_token_string_t cmd_gso_size_set =
4629 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4631 cmdline_parse_token_string_t cmd_gso_size_keyword =
4632 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4633 cmd_keyword, "gso");
4634 cmdline_parse_token_string_t cmd_gso_size_segsz =
4635 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4636 cmd_segsz, "segsz");
4637 cmdline_parse_token_num_t cmd_gso_size_size =
4638 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4641 cmdline_parse_inst_t cmd_gso_size = {
4642 .f = cmd_gso_size_parsed,
4644 .help_str = "set gso segsz <length>",
4646 (void *)&cmd_gso_size_set,
4647 (void *)&cmd_gso_size_keyword,
4648 (void *)&cmd_gso_size_segsz,
4649 (void *)&cmd_gso_size_size,
4654 /* *** SHOW GSO CONFIGURATION *** */
4655 struct cmd_gso_show_result {
4656 cmdline_fixed_string_t cmd_show;
4657 cmdline_fixed_string_t cmd_port;
4658 cmdline_fixed_string_t cmd_keyword;
4663 cmd_gso_show_parsed(void *parsed_result,
4664 __attribute__((unused)) struct cmdline *cl,
4665 __attribute__((unused)) void *data)
4667 struct cmd_gso_show_result *res = parsed_result;
4669 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4670 printf("invalid port id %u\n", res->cmd_pid);
4673 if (!strcmp(res->cmd_keyword, "gso")) {
4674 if (gso_ports[res->cmd_pid].enable) {
4675 printf("Max GSO'd packet size: %uB\n"
4676 "Supported GSO types: TCP/IPv4, "
4677 "VxLAN with inner TCP/IPv4 packet, "
4678 "GRE with inner TCP/IPv4 packet\n",
4679 gso_max_segment_size);
4681 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4685 cmdline_parse_token_string_t cmd_gso_show_show =
4686 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4688 cmdline_parse_token_string_t cmd_gso_show_port =
4689 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4691 cmdline_parse_token_string_t cmd_gso_show_keyword =
4692 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4693 cmd_keyword, "gso");
4694 cmdline_parse_token_num_t cmd_gso_show_pid =
4695 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4698 cmdline_parse_inst_t cmd_gso_show = {
4699 .f = cmd_gso_show_parsed,
4701 .help_str = "show port <port_id> gso",
4703 (void *)&cmd_gso_show_show,
4704 (void *)&cmd_gso_show_port,
4705 (void *)&cmd_gso_show_pid,
4706 (void *)&cmd_gso_show_keyword,
4711 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4712 struct cmd_set_flush_rx {
4713 cmdline_fixed_string_t set;
4714 cmdline_fixed_string_t flush_rx;
4715 cmdline_fixed_string_t mode;
4719 cmd_set_flush_rx_parsed(void *parsed_result,
4720 __attribute__((unused)) struct cmdline *cl,
4721 __attribute__((unused)) void *data)
4723 struct cmd_set_flush_rx *res = parsed_result;
4724 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4727 cmdline_parse_token_string_t cmd_setflushrx_set =
4728 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4730 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4731 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4732 flush_rx, "flush_rx");
4733 cmdline_parse_token_string_t cmd_setflushrx_mode =
4734 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4738 cmdline_parse_inst_t cmd_set_flush_rx = {
4739 .f = cmd_set_flush_rx_parsed,
4740 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4743 (void *)&cmd_setflushrx_set,
4744 (void *)&cmd_setflushrx_flush_rx,
4745 (void *)&cmd_setflushrx_mode,
4750 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4751 struct cmd_set_link_check {
4752 cmdline_fixed_string_t set;
4753 cmdline_fixed_string_t link_check;
4754 cmdline_fixed_string_t mode;
4758 cmd_set_link_check_parsed(void *parsed_result,
4759 __attribute__((unused)) struct cmdline *cl,
4760 __attribute__((unused)) void *data)
4762 struct cmd_set_link_check *res = parsed_result;
4763 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4766 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4767 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4769 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4770 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4771 link_check, "link_check");
4772 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4773 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4777 cmdline_parse_inst_t cmd_set_link_check = {
4778 .f = cmd_set_link_check_parsed,
4779 .help_str = "set link_check on|off: Enable/Disable link status check "
4780 "when starting/stopping a port",
4783 (void *)&cmd_setlinkcheck_set,
4784 (void *)&cmd_setlinkcheck_link_check,
4785 (void *)&cmd_setlinkcheck_mode,
4790 /* *** SET NIC BYPASS MODE *** */
4791 struct cmd_set_bypass_mode_result {
4792 cmdline_fixed_string_t set;
4793 cmdline_fixed_string_t bypass;
4794 cmdline_fixed_string_t mode;
4795 cmdline_fixed_string_t value;
4800 cmd_set_bypass_mode_parsed(void *parsed_result,
4801 __attribute__((unused)) struct cmdline *cl,
4802 __attribute__((unused)) void *data)
4804 struct cmd_set_bypass_mode_result *res = parsed_result;
4805 portid_t port_id = res->port_id;
4806 int32_t rc = -EINVAL;
4808 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4809 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4811 if (!strcmp(res->value, "bypass"))
4812 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4813 else if (!strcmp(res->value, "isolate"))
4814 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4816 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4818 /* Set the bypass mode for the relevant port. */
4819 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4822 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4825 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4826 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4828 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4829 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4831 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4832 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4834 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4835 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4836 value, "normal#bypass#isolate");
4837 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4838 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4841 cmdline_parse_inst_t cmd_set_bypass_mode = {
4842 .f = cmd_set_bypass_mode_parsed,
4843 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4844 "Set the NIC bypass mode for port_id",
4847 (void *)&cmd_setbypass_mode_set,
4848 (void *)&cmd_setbypass_mode_bypass,
4849 (void *)&cmd_setbypass_mode_mode,
4850 (void *)&cmd_setbypass_mode_value,
4851 (void *)&cmd_setbypass_mode_port,
4856 /* *** SET NIC BYPASS EVENT *** */
4857 struct cmd_set_bypass_event_result {
4858 cmdline_fixed_string_t set;
4859 cmdline_fixed_string_t bypass;
4860 cmdline_fixed_string_t event;
4861 cmdline_fixed_string_t event_value;
4862 cmdline_fixed_string_t mode;
4863 cmdline_fixed_string_t mode_value;
4868 cmd_set_bypass_event_parsed(void *parsed_result,
4869 __attribute__((unused)) struct cmdline *cl,
4870 __attribute__((unused)) void *data)
4872 int32_t rc = -EINVAL;
4873 struct cmd_set_bypass_event_result *res = parsed_result;
4874 portid_t port_id = res->port_id;
4876 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4877 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4878 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4880 if (!strcmp(res->event_value, "timeout"))
4881 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4882 else if (!strcmp(res->event_value, "os_on"))
4883 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4884 else if (!strcmp(res->event_value, "os_off"))
4885 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4886 else if (!strcmp(res->event_value, "power_on"))
4887 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4888 else if (!strcmp(res->event_value, "power_off"))
4889 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4891 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4893 if (!strcmp(res->mode_value, "bypass"))
4894 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4895 else if (!strcmp(res->mode_value, "isolate"))
4896 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4898 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4900 /* Set the watchdog timeout. */
4901 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4904 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4905 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4909 printf("Failed to set timeout value %u "
4910 "for port %d, errto code: %d.\n",
4911 bypass_timeout, port_id, rc);
4915 /* Set the bypass event to transition to bypass mode. */
4916 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4921 printf("\t Failed to set bypass event for port = %d.\n",
4925 cmdline_parse_token_string_t cmd_setbypass_event_set =
4926 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4928 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4929 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4931 cmdline_parse_token_string_t cmd_setbypass_event_event =
4932 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4934 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4935 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4936 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4937 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4938 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4940 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4941 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4942 mode_value, "normal#bypass#isolate");
4943 cmdline_parse_token_num_t cmd_setbypass_event_port =
4944 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4947 cmdline_parse_inst_t cmd_set_bypass_event = {
4948 .f = cmd_set_bypass_event_parsed,
4949 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4950 "power_off mode normal|bypass|isolate <port_id>: "
4951 "Set the NIC bypass event mode for port_id",
4954 (void *)&cmd_setbypass_event_set,
4955 (void *)&cmd_setbypass_event_bypass,
4956 (void *)&cmd_setbypass_event_event,
4957 (void *)&cmd_setbypass_event_event_value,
4958 (void *)&cmd_setbypass_event_mode,
4959 (void *)&cmd_setbypass_event_mode_value,
4960 (void *)&cmd_setbypass_event_port,
4966 /* *** SET NIC BYPASS TIMEOUT *** */
4967 struct cmd_set_bypass_timeout_result {
4968 cmdline_fixed_string_t set;
4969 cmdline_fixed_string_t bypass;
4970 cmdline_fixed_string_t timeout;
4971 cmdline_fixed_string_t value;
4975 cmd_set_bypass_timeout_parsed(void *parsed_result,
4976 __attribute__((unused)) struct cmdline *cl,
4977 __attribute__((unused)) void *data)
4979 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4981 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4982 if (!strcmp(res->value, "1.5"))
4983 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4984 else if (!strcmp(res->value, "2"))
4985 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4986 else if (!strcmp(res->value, "3"))
4987 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4988 else if (!strcmp(res->value, "4"))
4989 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4990 else if (!strcmp(res->value, "8"))
4991 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4992 else if (!strcmp(res->value, "16"))
4993 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4994 else if (!strcmp(res->value, "32"))
4995 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4997 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5001 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5002 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5004 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5005 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5007 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5008 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5009 timeout, "timeout");
5010 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5011 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5012 value, "0#1.5#2#3#4#8#16#32");
5014 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5015 .f = cmd_set_bypass_timeout_parsed,
5016 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5017 "Set the NIC bypass watchdog timeout in seconds",
5020 (void *)&cmd_setbypass_timeout_set,
5021 (void *)&cmd_setbypass_timeout_bypass,
5022 (void *)&cmd_setbypass_timeout_timeout,
5023 (void *)&cmd_setbypass_timeout_value,
5028 /* *** SHOW NIC BYPASS MODE *** */
5029 struct cmd_show_bypass_config_result {
5030 cmdline_fixed_string_t show;
5031 cmdline_fixed_string_t bypass;
5032 cmdline_fixed_string_t config;
5037 cmd_show_bypass_config_parsed(void *parsed_result,
5038 __attribute__((unused)) struct cmdline *cl,
5039 __attribute__((unused)) void *data)
5041 struct cmd_show_bypass_config_result *res = parsed_result;
5042 portid_t port_id = res->port_id;
5044 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5045 uint32_t event_mode;
5046 uint32_t bypass_mode;
5047 uint32_t timeout = bypass_timeout;
5050 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5051 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5052 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5053 {"UNKNOWN", "normal", "bypass", "isolate"};
5054 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5061 int num_events = (sizeof events) / (sizeof events[0]);
5063 /* Display the bypass mode.*/
5064 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5065 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5069 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5070 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5072 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5075 /* Display the bypass timeout.*/
5076 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5077 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5079 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5081 /* Display the bypass events and associated modes. */
5082 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5084 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5085 printf("\tFailed to get bypass mode for event = %s\n",
5088 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5089 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5091 printf("\tbypass event: %-16s = %s\n", events[i],
5097 printf("\tFailed to get bypass configuration for port = %d\n",
5101 cmdline_parse_token_string_t cmd_showbypass_config_show =
5102 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5104 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5105 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5107 cmdline_parse_token_string_t cmd_showbypass_config_config =
5108 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5110 cmdline_parse_token_num_t cmd_showbypass_config_port =
5111 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5114 cmdline_parse_inst_t cmd_show_bypass_config = {
5115 .f = cmd_show_bypass_config_parsed,
5116 .help_str = "show bypass config <port_id>: "
5117 "Show the NIC bypass config for port_id",
5120 (void *)&cmd_showbypass_config_show,
5121 (void *)&cmd_showbypass_config_bypass,
5122 (void *)&cmd_showbypass_config_config,
5123 (void *)&cmd_showbypass_config_port,
5128 #ifdef RTE_LIBRTE_PMD_BOND
5129 /* *** SET BONDING MODE *** */
5130 struct cmd_set_bonding_mode_result {
5131 cmdline_fixed_string_t set;
5132 cmdline_fixed_string_t bonding;
5133 cmdline_fixed_string_t mode;
5138 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5139 __attribute__((unused)) struct cmdline *cl,
5140 __attribute__((unused)) void *data)
5142 struct cmd_set_bonding_mode_result *res = parsed_result;
5143 portid_t port_id = res->port_id;
5145 /* Set the bonding mode for the relevant port. */
5146 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5147 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5150 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5151 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5153 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5154 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5155 bonding, "bonding");
5156 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5157 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5159 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5160 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5162 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5163 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5166 cmdline_parse_inst_t cmd_set_bonding_mode = {
5167 .f = cmd_set_bonding_mode_parsed,
5168 .help_str = "set bonding mode <mode_value> <port_id>: "
5169 "Set the bonding mode for port_id",
5172 (void *) &cmd_setbonding_mode_set,
5173 (void *) &cmd_setbonding_mode_bonding,
5174 (void *) &cmd_setbonding_mode_mode,
5175 (void *) &cmd_setbonding_mode_value,
5176 (void *) &cmd_setbonding_mode_port,
5181 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5182 struct cmd_set_bonding_lacp_dedicated_queues_result {
5183 cmdline_fixed_string_t set;
5184 cmdline_fixed_string_t bonding;
5185 cmdline_fixed_string_t lacp;
5186 cmdline_fixed_string_t dedicated_queues;
5188 cmdline_fixed_string_t mode;
5191 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5192 __attribute__((unused)) struct cmdline *cl,
5193 __attribute__((unused)) void *data)
5195 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5196 portid_t port_id = res->port_id;
5197 struct rte_port *port;
5199 port = &ports[port_id];
5201 /** Check if the port is not started **/
5202 if (port->port_status != RTE_PORT_STOPPED) {
5203 printf("Please stop port %d first\n", port_id);
5207 if (!strcmp(res->mode, "enable")) {
5208 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5209 printf("Dedicate queues for LACP control packets"
5212 printf("Enabling dedicate queues for LACP control "
5213 "packets on port %d failed\n", port_id);
5214 } else if (!strcmp(res->mode, "disable")) {
5215 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5216 printf("Dedicated queues for LACP control packets "
5219 printf("Disabling dedicated queues for LACP control "
5220 "traffic on port %d failed\n", port_id);
5224 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5225 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5227 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5228 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5229 bonding, "bonding");
5230 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5231 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5233 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5234 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5235 dedicated_queues, "dedicated_queues");
5236 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5237 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5239 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5240 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5241 mode, "enable#disable");
5243 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5244 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5245 .help_str = "set bonding lacp dedicated_queues <port_id> "
5247 "Enable/disable dedicated queues for LACP control traffic for port_id",
5250 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5251 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5252 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5253 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5254 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5255 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5260 /* *** SET BALANCE XMIT POLICY *** */
5261 struct cmd_set_bonding_balance_xmit_policy_result {
5262 cmdline_fixed_string_t set;
5263 cmdline_fixed_string_t bonding;
5264 cmdline_fixed_string_t balance_xmit_policy;
5266 cmdline_fixed_string_t policy;
5269 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5270 __attribute__((unused)) struct cmdline *cl,
5271 __attribute__((unused)) void *data)
5273 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5274 portid_t port_id = res->port_id;
5277 if (!strcmp(res->policy, "l2")) {
5278 policy = BALANCE_XMIT_POLICY_LAYER2;
5279 } else if (!strcmp(res->policy, "l23")) {
5280 policy = BALANCE_XMIT_POLICY_LAYER23;
5281 } else if (!strcmp(res->policy, "l34")) {
5282 policy = BALANCE_XMIT_POLICY_LAYER34;
5284 printf("\t Invalid xmit policy selection");
5288 /* Set the bonding mode for the relevant port. */
5289 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5290 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5295 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5296 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5298 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5299 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5300 bonding, "bonding");
5301 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5302 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5303 balance_xmit_policy, "balance_xmit_policy");
5304 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5305 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5307 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5308 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5309 policy, "l2#l23#l34");
5311 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5312 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5313 .help_str = "set bonding balance_xmit_policy <port_id> "
5315 "Set the bonding balance_xmit_policy for port_id",
5318 (void *)&cmd_setbonding_balance_xmit_policy_set,
5319 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5320 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5321 (void *)&cmd_setbonding_balance_xmit_policy_port,
5322 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5327 /* *** SHOW NIC BONDING CONFIGURATION *** */
5328 struct cmd_show_bonding_config_result {
5329 cmdline_fixed_string_t show;
5330 cmdline_fixed_string_t bonding;
5331 cmdline_fixed_string_t config;
5335 static void cmd_show_bonding_config_parsed(void *parsed_result,
5336 __attribute__((unused)) struct cmdline *cl,
5337 __attribute__((unused)) void *data)
5339 struct cmd_show_bonding_config_result *res = parsed_result;
5340 int bonding_mode, agg_mode;
5341 portid_t slaves[RTE_MAX_ETHPORTS];
5342 int num_slaves, num_active_slaves;
5345 portid_t port_id = res->port_id;
5347 /* Display the bonding mode.*/
5348 bonding_mode = rte_eth_bond_mode_get(port_id);
5349 if (bonding_mode < 0) {
5350 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5353 printf("\tBonding mode: %d\n", bonding_mode);
5355 if (bonding_mode == BONDING_MODE_BALANCE) {
5356 int balance_xmit_policy;
5358 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5359 if (balance_xmit_policy < 0) {
5360 printf("\tFailed to get balance xmit policy for port = %d\n",
5364 printf("\tBalance Xmit Policy: ");
5366 switch (balance_xmit_policy) {
5367 case BALANCE_XMIT_POLICY_LAYER2:
5368 printf("BALANCE_XMIT_POLICY_LAYER2");
5370 case BALANCE_XMIT_POLICY_LAYER23:
5371 printf("BALANCE_XMIT_POLICY_LAYER23");
5373 case BALANCE_XMIT_POLICY_LAYER34:
5374 printf("BALANCE_XMIT_POLICY_LAYER34");
5381 if (bonding_mode == BONDING_MODE_8023AD) {
5382 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5383 printf("\tIEEE802.3AD Aggregator Mode: ");
5386 printf("bandwidth");
5398 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5400 if (num_slaves < 0) {
5401 printf("\tFailed to get slave list for port = %d\n", port_id);
5404 if (num_slaves > 0) {
5405 printf("\tSlaves (%d): [", num_slaves);
5406 for (i = 0; i < num_slaves - 1; i++)
5407 printf("%d ", slaves[i]);
5409 printf("%d]\n", slaves[num_slaves - 1]);
5411 printf("\tSlaves: []\n");
5415 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5418 if (num_active_slaves < 0) {
5419 printf("\tFailed to get active slave list for port = %d\n", port_id);
5422 if (num_active_slaves > 0) {
5423 printf("\tActive Slaves (%d): [", num_active_slaves);
5424 for (i = 0; i < num_active_slaves - 1; i++)
5425 printf("%d ", slaves[i]);
5427 printf("%d]\n", slaves[num_active_slaves - 1]);
5430 printf("\tActive Slaves: []\n");
5434 primary_id = rte_eth_bond_primary_get(port_id);
5435 if (primary_id < 0) {
5436 printf("\tFailed to get primary slave for port = %d\n", port_id);
5439 printf("\tPrimary: [%d]\n", primary_id);
5443 cmdline_parse_token_string_t cmd_showbonding_config_show =
5444 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5446 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5447 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5448 bonding, "bonding");
5449 cmdline_parse_token_string_t cmd_showbonding_config_config =
5450 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5452 cmdline_parse_token_num_t cmd_showbonding_config_port =
5453 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5456 cmdline_parse_inst_t cmd_show_bonding_config = {
5457 .f = cmd_show_bonding_config_parsed,
5458 .help_str = "show bonding config <port_id>: "
5459 "Show the bonding config for port_id",
5462 (void *)&cmd_showbonding_config_show,
5463 (void *)&cmd_showbonding_config_bonding,
5464 (void *)&cmd_showbonding_config_config,
5465 (void *)&cmd_showbonding_config_port,
5470 /* *** SET BONDING PRIMARY *** */
5471 struct cmd_set_bonding_primary_result {
5472 cmdline_fixed_string_t set;
5473 cmdline_fixed_string_t bonding;
5474 cmdline_fixed_string_t primary;
5479 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5480 __attribute__((unused)) struct cmdline *cl,
5481 __attribute__((unused)) void *data)
5483 struct cmd_set_bonding_primary_result *res = parsed_result;
5484 portid_t master_port_id = res->port_id;
5485 portid_t slave_port_id = res->slave_id;
5487 /* Set the primary slave for a bonded device. */
5488 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5489 printf("\t Failed to set primary slave for port = %d.\n",
5496 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5497 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5499 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5500 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5501 bonding, "bonding");
5502 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5503 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5504 primary, "primary");
5505 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5506 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5508 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5509 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5512 cmdline_parse_inst_t cmd_set_bonding_primary = {
5513 .f = cmd_set_bonding_primary_parsed,
5514 .help_str = "set bonding primary <slave_id> <port_id>: "
5515 "Set the primary slave for port_id",
5518 (void *)&cmd_setbonding_primary_set,
5519 (void *)&cmd_setbonding_primary_bonding,
5520 (void *)&cmd_setbonding_primary_primary,
5521 (void *)&cmd_setbonding_primary_slave,
5522 (void *)&cmd_setbonding_primary_port,
5527 /* *** ADD SLAVE *** */
5528 struct cmd_add_bonding_slave_result {
5529 cmdline_fixed_string_t add;
5530 cmdline_fixed_string_t bonding;
5531 cmdline_fixed_string_t slave;
5536 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5537 __attribute__((unused)) struct cmdline *cl,
5538 __attribute__((unused)) void *data)
5540 struct cmd_add_bonding_slave_result *res = parsed_result;
5541 portid_t master_port_id = res->port_id;
5542 portid_t slave_port_id = res->slave_id;
5544 /* add the slave for a bonded device. */
5545 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5546 printf("\t Failed to add slave %d to master port = %d.\n",
5547 slave_port_id, master_port_id);
5551 set_port_slave_flag(slave_port_id);
5554 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5555 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5557 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5558 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5559 bonding, "bonding");
5560 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5561 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5563 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5564 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5566 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5567 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5570 cmdline_parse_inst_t cmd_add_bonding_slave = {
5571 .f = cmd_add_bonding_slave_parsed,
5572 .help_str = "add bonding slave <slave_id> <port_id>: "
5573 "Add a slave device to a bonded device",
5576 (void *)&cmd_addbonding_slave_add,
5577 (void *)&cmd_addbonding_slave_bonding,
5578 (void *)&cmd_addbonding_slave_slave,
5579 (void *)&cmd_addbonding_slave_slaveid,
5580 (void *)&cmd_addbonding_slave_port,
5585 /* *** REMOVE SLAVE *** */
5586 struct cmd_remove_bonding_slave_result {
5587 cmdline_fixed_string_t remove;
5588 cmdline_fixed_string_t bonding;
5589 cmdline_fixed_string_t slave;
5594 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5595 __attribute__((unused)) struct cmdline *cl,
5596 __attribute__((unused)) void *data)
5598 struct cmd_remove_bonding_slave_result *res = parsed_result;
5599 portid_t master_port_id = res->port_id;
5600 portid_t slave_port_id = res->slave_id;
5602 /* remove the slave from a bonded device. */
5603 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5604 printf("\t Failed to remove slave %d from master port = %d.\n",
5605 slave_port_id, master_port_id);
5609 clear_port_slave_flag(slave_port_id);
5612 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5613 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5615 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5616 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5617 bonding, "bonding");
5618 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5619 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5621 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5622 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5624 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5625 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5628 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5629 .f = cmd_remove_bonding_slave_parsed,
5630 .help_str = "remove bonding slave <slave_id> <port_id>: "
5631 "Remove a slave device from a bonded device",
5634 (void *)&cmd_removebonding_slave_remove,
5635 (void *)&cmd_removebonding_slave_bonding,
5636 (void *)&cmd_removebonding_slave_slave,
5637 (void *)&cmd_removebonding_slave_slaveid,
5638 (void *)&cmd_removebonding_slave_port,
5643 /* *** CREATE BONDED DEVICE *** */
5644 struct cmd_create_bonded_device_result {
5645 cmdline_fixed_string_t create;
5646 cmdline_fixed_string_t bonded;
5647 cmdline_fixed_string_t device;
5652 static int bond_dev_num = 0;
5654 static void cmd_create_bonded_device_parsed(void *parsed_result,
5655 __attribute__((unused)) struct cmdline *cl,
5656 __attribute__((unused)) void *data)
5658 struct cmd_create_bonded_device_result *res = parsed_result;
5659 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5662 if (test_done == 0) {
5663 printf("Please stop forwarding first\n");
5667 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5670 /* Create a new bonded device. */
5671 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5673 printf("\t Failed to create bonded device.\n");
5676 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5679 /* Update number of ports */
5680 nb_ports = rte_eth_dev_count_avail();
5681 reconfig(port_id, res->socket);
5682 rte_eth_promiscuous_enable(port_id);
5687 cmdline_parse_token_string_t cmd_createbonded_device_create =
5688 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5690 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5691 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5693 cmdline_parse_token_string_t cmd_createbonded_device_device =
5694 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5696 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5697 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5699 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5700 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5703 cmdline_parse_inst_t cmd_create_bonded_device = {
5704 .f = cmd_create_bonded_device_parsed,
5705 .help_str = "create bonded device <mode> <socket>: "
5706 "Create a new bonded device with specific bonding mode and socket",
5709 (void *)&cmd_createbonded_device_create,
5710 (void *)&cmd_createbonded_device_bonded,
5711 (void *)&cmd_createbonded_device_device,
5712 (void *)&cmd_createbonded_device_mode,
5713 (void *)&cmd_createbonded_device_socket,
5718 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5719 struct cmd_set_bond_mac_addr_result {
5720 cmdline_fixed_string_t set;
5721 cmdline_fixed_string_t bonding;
5722 cmdline_fixed_string_t mac_addr;
5724 struct ether_addr address;
5727 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5728 __attribute__((unused)) struct cmdline *cl,
5729 __attribute__((unused)) void *data)
5731 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5734 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5737 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5739 /* check the return value and print it if is < 0 */
5741 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5744 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5745 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5746 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5749 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5752 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5753 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5755 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5756 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5758 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5759 .f = cmd_set_bond_mac_addr_parsed,
5761 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5763 (void *)&cmd_set_bond_mac_addr_set,
5764 (void *)&cmd_set_bond_mac_addr_bonding,
5765 (void *)&cmd_set_bond_mac_addr_mac,
5766 (void *)&cmd_set_bond_mac_addr_portnum,
5767 (void *)&cmd_set_bond_mac_addr_addr,
5773 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5774 struct cmd_set_bond_mon_period_result {
5775 cmdline_fixed_string_t set;
5776 cmdline_fixed_string_t bonding;
5777 cmdline_fixed_string_t mon_period;
5782 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5783 __attribute__((unused)) struct cmdline *cl,
5784 __attribute__((unused)) void *data)
5786 struct cmd_set_bond_mon_period_result *res = parsed_result;
5789 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5791 /* check the return value and print it if is < 0 */
5793 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5796 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5797 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5799 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5800 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5801 bonding, "bonding");
5802 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5803 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5804 mon_period, "mon_period");
5805 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5806 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5808 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5809 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5812 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5813 .f = cmd_set_bond_mon_period_parsed,
5815 .help_str = "set bonding mon_period <port_id> <period_ms>",
5817 (void *)&cmd_set_bond_mon_period_set,
5818 (void *)&cmd_set_bond_mon_period_bonding,
5819 (void *)&cmd_set_bond_mon_period_mon_period,
5820 (void *)&cmd_set_bond_mon_period_portnum,
5821 (void *)&cmd_set_bond_mon_period_period_ms,
5828 struct cmd_set_bonding_agg_mode_policy_result {
5829 cmdline_fixed_string_t set;
5830 cmdline_fixed_string_t bonding;
5831 cmdline_fixed_string_t agg_mode;
5833 cmdline_fixed_string_t policy;
5838 cmd_set_bonding_agg_mode(void *parsed_result,
5839 __attribute__((unused)) struct cmdline *cl,
5840 __attribute__((unused)) void *data)
5842 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5843 uint8_t policy = AGG_BANDWIDTH;
5845 if (!strcmp(res->policy, "bandwidth"))
5846 policy = AGG_BANDWIDTH;
5847 else if (!strcmp(res->policy, "stable"))
5848 policy = AGG_STABLE;
5849 else if (!strcmp(res->policy, "count"))
5852 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5856 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5857 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5859 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5860 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5861 bonding, "bonding");
5863 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5864 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5865 agg_mode, "agg_mode");
5867 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5868 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5871 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5872 TOKEN_STRING_INITIALIZER(
5873 struct cmd_set_bonding_balance_xmit_policy_result,
5874 policy, "stable#bandwidth#count");
5876 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5877 .f = cmd_set_bonding_agg_mode,
5879 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5881 (void *)&cmd_set_bonding_agg_mode_set,
5882 (void *)&cmd_set_bonding_agg_mode_bonding,
5883 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5884 (void *)&cmd_set_bonding_agg_mode_portnum,
5885 (void *)&cmd_set_bonding_agg_mode_policy_string,
5891 #endif /* RTE_LIBRTE_PMD_BOND */
5893 /* *** SET FORWARDING MODE *** */
5894 struct cmd_set_fwd_mode_result {
5895 cmdline_fixed_string_t set;
5896 cmdline_fixed_string_t fwd;
5897 cmdline_fixed_string_t mode;
5900 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5901 __attribute__((unused)) struct cmdline *cl,
5902 __attribute__((unused)) void *data)
5904 struct cmd_set_fwd_mode_result *res = parsed_result;
5907 set_pkt_forwarding_mode(res->mode);
5910 cmdline_parse_token_string_t cmd_setfwd_set =
5911 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5912 cmdline_parse_token_string_t cmd_setfwd_fwd =
5913 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5914 cmdline_parse_token_string_t cmd_setfwd_mode =
5915 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5916 "" /* defined at init */);
5918 cmdline_parse_inst_t cmd_set_fwd_mode = {
5919 .f = cmd_set_fwd_mode_parsed,
5921 .help_str = NULL, /* defined at init */
5923 (void *)&cmd_setfwd_set,
5924 (void *)&cmd_setfwd_fwd,
5925 (void *)&cmd_setfwd_mode,
5930 static void cmd_set_fwd_mode_init(void)
5933 static char token[128];
5934 static char help[256];
5935 cmdline_parse_token_string_t *token_struct;
5937 modes = list_pkt_forwarding_modes();
5938 snprintf(help, sizeof(help), "set fwd %s: "
5939 "Set packet forwarding mode", modes);
5940 cmd_set_fwd_mode.help_str = help;
5942 /* string token separator is # */
5943 for (c = token; *modes != '\0'; modes++)
5948 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5949 token_struct->string_data.str = token;
5952 /* *** SET RETRY FORWARDING MODE *** */
5953 struct cmd_set_fwd_retry_mode_result {
5954 cmdline_fixed_string_t set;
5955 cmdline_fixed_string_t fwd;
5956 cmdline_fixed_string_t mode;
5957 cmdline_fixed_string_t retry;
5960 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5961 __attribute__((unused)) struct cmdline *cl,
5962 __attribute__((unused)) void *data)
5964 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5967 set_pkt_forwarding_mode(res->mode);
5970 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5971 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5973 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5974 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5976 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5977 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5979 "" /* defined at init */);
5980 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5981 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5984 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5985 .f = cmd_set_fwd_retry_mode_parsed,
5987 .help_str = NULL, /* defined at init */
5989 (void *)&cmd_setfwd_retry_set,
5990 (void *)&cmd_setfwd_retry_fwd,
5991 (void *)&cmd_setfwd_retry_mode,
5992 (void *)&cmd_setfwd_retry_retry,
5997 static void cmd_set_fwd_retry_mode_init(void)
6000 static char token[128];
6001 static char help[256];
6002 cmdline_parse_token_string_t *token_struct;
6004 modes = list_pkt_forwarding_retry_modes();
6005 snprintf(help, sizeof(help), "set fwd %s retry: "
6006 "Set packet forwarding mode with retry", modes);
6007 cmd_set_fwd_retry_mode.help_str = help;
6009 /* string token separator is # */
6010 for (c = token; *modes != '\0'; modes++)
6015 token_struct = (cmdline_parse_token_string_t *)
6016 cmd_set_fwd_retry_mode.tokens[2];
6017 token_struct->string_data.str = token;
6020 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6021 struct cmd_set_burst_tx_retry_result {
6022 cmdline_fixed_string_t set;
6023 cmdline_fixed_string_t burst;
6024 cmdline_fixed_string_t tx;
6025 cmdline_fixed_string_t delay;
6027 cmdline_fixed_string_t retry;
6031 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6032 __attribute__((unused)) struct cmdline *cl,
6033 __attribute__((unused)) void *data)
6035 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6037 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6038 && !strcmp(res->tx, "tx")) {
6039 if (!strcmp(res->delay, "delay"))
6040 burst_tx_delay_time = res->time;
6041 if (!strcmp(res->retry, "retry"))
6042 burst_tx_retry_num = res->retry_num;
6047 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6048 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6049 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6050 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6052 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6053 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6054 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6055 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6056 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6057 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6058 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6059 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6060 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6061 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6063 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6064 .f = cmd_set_burst_tx_retry_parsed,
6065 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6067 (void *)&cmd_set_burst_tx_retry_set,
6068 (void *)&cmd_set_burst_tx_retry_burst,
6069 (void *)&cmd_set_burst_tx_retry_tx,
6070 (void *)&cmd_set_burst_tx_retry_delay,
6071 (void *)&cmd_set_burst_tx_retry_time,
6072 (void *)&cmd_set_burst_tx_retry_retry,
6073 (void *)&cmd_set_burst_tx_retry_retry_num,
6078 /* *** SET PROMISC MODE *** */
6079 struct cmd_set_promisc_mode_result {
6080 cmdline_fixed_string_t set;
6081 cmdline_fixed_string_t promisc;
6082 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6083 uint16_t port_num; /* valid if "allports" argument == 0 */
6084 cmdline_fixed_string_t mode;
6087 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6088 __attribute__((unused)) struct cmdline *cl,
6091 struct cmd_set_promisc_mode_result *res = parsed_result;
6095 if (!strcmp(res->mode, "on"))
6102 RTE_ETH_FOREACH_DEV(i) {
6104 rte_eth_promiscuous_enable(i);
6106 rte_eth_promiscuous_disable(i);
6111 rte_eth_promiscuous_enable(res->port_num);
6113 rte_eth_promiscuous_disable(res->port_num);
6117 cmdline_parse_token_string_t cmd_setpromisc_set =
6118 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6119 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6120 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6122 cmdline_parse_token_string_t cmd_setpromisc_portall =
6123 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6125 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6126 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6128 cmdline_parse_token_string_t cmd_setpromisc_mode =
6129 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6132 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6133 .f = cmd_set_promisc_mode_parsed,
6135 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6137 (void *)&cmd_setpromisc_set,
6138 (void *)&cmd_setpromisc_promisc,
6139 (void *)&cmd_setpromisc_portall,
6140 (void *)&cmd_setpromisc_mode,
6145 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6146 .f = cmd_set_promisc_mode_parsed,
6148 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6150 (void *)&cmd_setpromisc_set,
6151 (void *)&cmd_setpromisc_promisc,
6152 (void *)&cmd_setpromisc_portnum,
6153 (void *)&cmd_setpromisc_mode,
6158 /* *** SET ALLMULTI MODE *** */
6159 struct cmd_set_allmulti_mode_result {
6160 cmdline_fixed_string_t set;
6161 cmdline_fixed_string_t allmulti;
6162 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6163 uint16_t port_num; /* valid if "allports" argument == 0 */
6164 cmdline_fixed_string_t mode;
6167 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6168 __attribute__((unused)) struct cmdline *cl,
6171 struct cmd_set_allmulti_mode_result *res = parsed_result;
6175 if (!strcmp(res->mode, "on"))
6182 RTE_ETH_FOREACH_DEV(i) {
6184 rte_eth_allmulticast_enable(i);
6186 rte_eth_allmulticast_disable(i);
6191 rte_eth_allmulticast_enable(res->port_num);
6193 rte_eth_allmulticast_disable(res->port_num);
6197 cmdline_parse_token_string_t cmd_setallmulti_set =
6198 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6199 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6200 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6202 cmdline_parse_token_string_t cmd_setallmulti_portall =
6203 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6205 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6206 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6208 cmdline_parse_token_string_t cmd_setallmulti_mode =
6209 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6212 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6213 .f = cmd_set_allmulti_mode_parsed,
6215 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6217 (void *)&cmd_setallmulti_set,
6218 (void *)&cmd_setallmulti_allmulti,
6219 (void *)&cmd_setallmulti_portall,
6220 (void *)&cmd_setallmulti_mode,
6225 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6226 .f = cmd_set_allmulti_mode_parsed,
6228 .help_str = "set allmulti <port_id> on|off: "
6229 "Set allmulti mode on port_id",
6231 (void *)&cmd_setallmulti_set,
6232 (void *)&cmd_setallmulti_allmulti,
6233 (void *)&cmd_setallmulti_portnum,
6234 (void *)&cmd_setallmulti_mode,
6239 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6240 struct cmd_link_flow_ctrl_set_result {
6241 cmdline_fixed_string_t set;
6242 cmdline_fixed_string_t flow_ctrl;
6243 cmdline_fixed_string_t rx;
6244 cmdline_fixed_string_t rx_lfc_mode;
6245 cmdline_fixed_string_t tx;
6246 cmdline_fixed_string_t tx_lfc_mode;
6247 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6248 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6249 cmdline_fixed_string_t autoneg_str;
6250 cmdline_fixed_string_t autoneg;
6251 cmdline_fixed_string_t hw_str;
6252 uint32_t high_water;
6253 cmdline_fixed_string_t lw_str;
6255 cmdline_fixed_string_t pt_str;
6256 uint16_t pause_time;
6257 cmdline_fixed_string_t xon_str;
6262 cmdline_parse_token_string_t cmd_lfc_set_set =
6263 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6265 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6266 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6267 flow_ctrl, "flow_ctrl");
6268 cmdline_parse_token_string_t cmd_lfc_set_rx =
6269 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6271 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6272 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6273 rx_lfc_mode, "on#off");
6274 cmdline_parse_token_string_t cmd_lfc_set_tx =
6275 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6277 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6278 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6279 tx_lfc_mode, "on#off");
6280 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6281 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6282 hw_str, "high_water");
6283 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6284 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6285 high_water, UINT32);
6286 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6287 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6288 lw_str, "low_water");
6289 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6290 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6292 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6293 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6294 pt_str, "pause_time");
6295 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6296 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6297 pause_time, UINT16);
6298 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6299 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6300 xon_str, "send_xon");
6301 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6302 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6304 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6305 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6306 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6307 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6308 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6309 mac_ctrl_frame_fwd_mode, "on#off");
6310 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6311 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6312 autoneg_str, "autoneg");
6313 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6314 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6316 cmdline_parse_token_num_t cmd_lfc_set_portid =
6317 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6320 /* forward declaration */
6322 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6325 cmdline_parse_inst_t cmd_link_flow_control_set = {
6326 .f = cmd_link_flow_ctrl_set_parsed,
6328 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6329 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6330 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6332 (void *)&cmd_lfc_set_set,
6333 (void *)&cmd_lfc_set_flow_ctrl,
6334 (void *)&cmd_lfc_set_rx,
6335 (void *)&cmd_lfc_set_rx_mode,
6336 (void *)&cmd_lfc_set_tx,
6337 (void *)&cmd_lfc_set_tx_mode,
6338 (void *)&cmd_lfc_set_high_water,
6339 (void *)&cmd_lfc_set_low_water,
6340 (void *)&cmd_lfc_set_pause_time,
6341 (void *)&cmd_lfc_set_send_xon,
6342 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6343 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6344 (void *)&cmd_lfc_set_autoneg_str,
6345 (void *)&cmd_lfc_set_autoneg,
6346 (void *)&cmd_lfc_set_portid,
6351 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6352 .f = cmd_link_flow_ctrl_set_parsed,
6353 .data = (void *)&cmd_link_flow_control_set_rx,
6354 .help_str = "set flow_ctrl rx on|off <port_id>: "
6355 "Change rx flow control parameter",
6357 (void *)&cmd_lfc_set_set,
6358 (void *)&cmd_lfc_set_flow_ctrl,
6359 (void *)&cmd_lfc_set_rx,
6360 (void *)&cmd_lfc_set_rx_mode,
6361 (void *)&cmd_lfc_set_portid,
6366 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6367 .f = cmd_link_flow_ctrl_set_parsed,
6368 .data = (void *)&cmd_link_flow_control_set_tx,
6369 .help_str = "set flow_ctrl tx on|off <port_id>: "
6370 "Change tx flow control parameter",
6372 (void *)&cmd_lfc_set_set,
6373 (void *)&cmd_lfc_set_flow_ctrl,
6374 (void *)&cmd_lfc_set_tx,
6375 (void *)&cmd_lfc_set_tx_mode,
6376 (void *)&cmd_lfc_set_portid,
6381 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6382 .f = cmd_link_flow_ctrl_set_parsed,
6383 .data = (void *)&cmd_link_flow_control_set_hw,
6384 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6385 "Change high water flow control parameter",
6387 (void *)&cmd_lfc_set_set,
6388 (void *)&cmd_lfc_set_flow_ctrl,
6389 (void *)&cmd_lfc_set_high_water_str,
6390 (void *)&cmd_lfc_set_high_water,
6391 (void *)&cmd_lfc_set_portid,
6396 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6397 .f = cmd_link_flow_ctrl_set_parsed,
6398 .data = (void *)&cmd_link_flow_control_set_lw,
6399 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6400 "Change low water flow control parameter",
6402 (void *)&cmd_lfc_set_set,
6403 (void *)&cmd_lfc_set_flow_ctrl,
6404 (void *)&cmd_lfc_set_low_water_str,
6405 (void *)&cmd_lfc_set_low_water,
6406 (void *)&cmd_lfc_set_portid,
6411 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6412 .f = cmd_link_flow_ctrl_set_parsed,
6413 .data = (void *)&cmd_link_flow_control_set_pt,
6414 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6415 "Change pause time flow control parameter",
6417 (void *)&cmd_lfc_set_set,
6418 (void *)&cmd_lfc_set_flow_ctrl,
6419 (void *)&cmd_lfc_set_pause_time_str,
6420 (void *)&cmd_lfc_set_pause_time,
6421 (void *)&cmd_lfc_set_portid,
6426 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6427 .f = cmd_link_flow_ctrl_set_parsed,
6428 .data = (void *)&cmd_link_flow_control_set_xon,
6429 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6430 "Change send_xon flow control parameter",
6432 (void *)&cmd_lfc_set_set,
6433 (void *)&cmd_lfc_set_flow_ctrl,
6434 (void *)&cmd_lfc_set_send_xon_str,
6435 (void *)&cmd_lfc_set_send_xon,
6436 (void *)&cmd_lfc_set_portid,
6441 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6442 .f = cmd_link_flow_ctrl_set_parsed,
6443 .data = (void *)&cmd_link_flow_control_set_macfwd,
6444 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6445 "Change mac ctrl fwd flow control parameter",
6447 (void *)&cmd_lfc_set_set,
6448 (void *)&cmd_lfc_set_flow_ctrl,
6449 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6450 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6451 (void *)&cmd_lfc_set_portid,
6456 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6457 .f = cmd_link_flow_ctrl_set_parsed,
6458 .data = (void *)&cmd_link_flow_control_set_autoneg,
6459 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6460 "Change autoneg flow control parameter",
6462 (void *)&cmd_lfc_set_set,
6463 (void *)&cmd_lfc_set_flow_ctrl,
6464 (void *)&cmd_lfc_set_autoneg_str,
6465 (void *)&cmd_lfc_set_autoneg,
6466 (void *)&cmd_lfc_set_portid,
6472 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6473 __attribute__((unused)) struct cmdline *cl,
6476 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6477 cmdline_parse_inst_t *cmd = data;
6478 struct rte_eth_fc_conf fc_conf;
6484 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6485 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6486 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6487 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6489 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6490 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6493 /* Partial command line, retrieve current configuration */
6495 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6497 printf("cannot get current flow ctrl parameters, return"
6498 "code = %d\n", ret);
6502 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6503 (fc_conf.mode == RTE_FC_FULL))
6505 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6506 (fc_conf.mode == RTE_FC_FULL))
6510 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6511 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6513 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6514 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6516 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6518 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6519 fc_conf.high_water = res->high_water;
6521 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6522 fc_conf.low_water = res->low_water;
6524 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6525 fc_conf.pause_time = res->pause_time;
6527 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6528 fc_conf.send_xon = res->send_xon;
6530 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6531 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6532 fc_conf.mac_ctrl_frame_fwd = 1;
6534 fc_conf.mac_ctrl_frame_fwd = 0;
6537 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6538 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6540 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6542 printf("bad flow contrl parameter, return code = %d \n", ret);
6545 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6546 struct cmd_priority_flow_ctrl_set_result {
6547 cmdline_fixed_string_t set;
6548 cmdline_fixed_string_t pfc_ctrl;
6549 cmdline_fixed_string_t rx;
6550 cmdline_fixed_string_t rx_pfc_mode;
6551 cmdline_fixed_string_t tx;
6552 cmdline_fixed_string_t tx_pfc_mode;
6553 uint32_t high_water;
6555 uint16_t pause_time;
6561 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6562 __attribute__((unused)) struct cmdline *cl,
6563 __attribute__((unused)) void *data)
6565 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6566 struct rte_eth_pfc_conf pfc_conf;
6567 int rx_fc_enable, tx_fc_enable;
6571 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6572 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6573 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6574 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6576 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6577 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6580 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6581 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6582 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6583 pfc_conf.fc.high_water = res->high_water;
6584 pfc_conf.fc.low_water = res->low_water;
6585 pfc_conf.fc.pause_time = res->pause_time;
6586 pfc_conf.priority = res->priority;
6588 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6590 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6593 cmdline_parse_token_string_t cmd_pfc_set_set =
6594 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6596 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6597 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6598 pfc_ctrl, "pfc_ctrl");
6599 cmdline_parse_token_string_t cmd_pfc_set_rx =
6600 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6602 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6603 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6604 rx_pfc_mode, "on#off");
6605 cmdline_parse_token_string_t cmd_pfc_set_tx =
6606 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6608 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6609 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6610 tx_pfc_mode, "on#off");
6611 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6612 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6613 high_water, UINT32);
6614 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6615 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6617 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6618 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6619 pause_time, UINT16);
6620 cmdline_parse_token_num_t cmd_pfc_set_priority =
6621 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6623 cmdline_parse_token_num_t cmd_pfc_set_portid =
6624 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6627 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6628 .f = cmd_priority_flow_ctrl_set_parsed,
6630 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6631 "<pause_time> <priority> <port_id>: "
6632 "Configure the Ethernet priority flow control",
6634 (void *)&cmd_pfc_set_set,
6635 (void *)&cmd_pfc_set_flow_ctrl,
6636 (void *)&cmd_pfc_set_rx,
6637 (void *)&cmd_pfc_set_rx_mode,
6638 (void *)&cmd_pfc_set_tx,
6639 (void *)&cmd_pfc_set_tx_mode,
6640 (void *)&cmd_pfc_set_high_water,
6641 (void *)&cmd_pfc_set_low_water,
6642 (void *)&cmd_pfc_set_pause_time,
6643 (void *)&cmd_pfc_set_priority,
6644 (void *)&cmd_pfc_set_portid,
6649 /* *** RESET CONFIGURATION *** */
6650 struct cmd_reset_result {
6651 cmdline_fixed_string_t reset;
6652 cmdline_fixed_string_t def;
6655 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6657 __attribute__((unused)) void *data)
6659 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6660 set_def_fwd_config();
6663 cmdline_parse_token_string_t cmd_reset_set =
6664 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6665 cmdline_parse_token_string_t cmd_reset_def =
6666 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6669 cmdline_parse_inst_t cmd_reset = {
6670 .f = cmd_reset_parsed,
6672 .help_str = "set default: Reset default forwarding configuration",
6674 (void *)&cmd_reset_set,
6675 (void *)&cmd_reset_def,
6680 /* *** START FORWARDING *** */
6681 struct cmd_start_result {
6682 cmdline_fixed_string_t start;
6685 cmdline_parse_token_string_t cmd_start_start =
6686 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6688 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6689 __attribute__((unused)) struct cmdline *cl,
6690 __attribute__((unused)) void *data)
6692 start_packet_forwarding(0);
6695 cmdline_parse_inst_t cmd_start = {
6696 .f = cmd_start_parsed,
6698 .help_str = "start: Start packet forwarding",
6700 (void *)&cmd_start_start,
6705 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6706 struct cmd_start_tx_first_result {
6707 cmdline_fixed_string_t start;
6708 cmdline_fixed_string_t tx_first;
6712 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6713 __attribute__((unused)) struct cmdline *cl,
6714 __attribute__((unused)) void *data)
6716 start_packet_forwarding(1);
6719 cmdline_parse_token_string_t cmd_start_tx_first_start =
6720 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6722 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6723 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6724 tx_first, "tx_first");
6726 cmdline_parse_inst_t cmd_start_tx_first = {
6727 .f = cmd_start_tx_first_parsed,
6729 .help_str = "start tx_first: Start packet forwarding, "
6730 "after sending 1 burst of packets",
6732 (void *)&cmd_start_tx_first_start,
6733 (void *)&cmd_start_tx_first_tx_first,
6738 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6739 struct cmd_start_tx_first_n_result {
6740 cmdline_fixed_string_t start;
6741 cmdline_fixed_string_t tx_first;
6746 cmd_start_tx_first_n_parsed(void *parsed_result,
6747 __attribute__((unused)) struct cmdline *cl,
6748 __attribute__((unused)) void *data)
6750 struct cmd_start_tx_first_n_result *res = parsed_result;
6752 start_packet_forwarding(res->tx_num);
6755 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6756 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6758 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6759 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6760 tx_first, "tx_first");
6761 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6762 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6765 cmdline_parse_inst_t cmd_start_tx_first_n = {
6766 .f = cmd_start_tx_first_n_parsed,
6768 .help_str = "start tx_first <num>: "
6769 "packet forwarding, after sending <num> bursts of packets",
6771 (void *)&cmd_start_tx_first_n_start,
6772 (void *)&cmd_start_tx_first_n_tx_first,
6773 (void *)&cmd_start_tx_first_n_tx_num,
6778 /* *** SET LINK UP *** */
6779 struct cmd_set_link_up_result {
6780 cmdline_fixed_string_t set;
6781 cmdline_fixed_string_t link_up;
6782 cmdline_fixed_string_t port;
6786 cmdline_parse_token_string_t cmd_set_link_up_set =
6787 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6788 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6789 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6791 cmdline_parse_token_string_t cmd_set_link_up_port =
6792 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6793 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6794 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6796 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6797 __attribute__((unused)) struct cmdline *cl,
6798 __attribute__((unused)) void *data)
6800 struct cmd_set_link_up_result *res = parsed_result;
6801 dev_set_link_up(res->port_id);
6804 cmdline_parse_inst_t cmd_set_link_up = {
6805 .f = cmd_set_link_up_parsed,
6807 .help_str = "set link-up port <port id>",
6809 (void *)&cmd_set_link_up_set,
6810 (void *)&cmd_set_link_up_link_up,
6811 (void *)&cmd_set_link_up_port,
6812 (void *)&cmd_set_link_up_port_id,
6817 /* *** SET LINK DOWN *** */
6818 struct cmd_set_link_down_result {
6819 cmdline_fixed_string_t set;
6820 cmdline_fixed_string_t link_down;
6821 cmdline_fixed_string_t port;
6825 cmdline_parse_token_string_t cmd_set_link_down_set =
6826 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6827 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6828 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6830 cmdline_parse_token_string_t cmd_set_link_down_port =
6831 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6832 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6833 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6835 static void cmd_set_link_down_parsed(
6836 __attribute__((unused)) void *parsed_result,
6837 __attribute__((unused)) struct cmdline *cl,
6838 __attribute__((unused)) void *data)
6840 struct cmd_set_link_down_result *res = parsed_result;
6841 dev_set_link_down(res->port_id);
6844 cmdline_parse_inst_t cmd_set_link_down = {
6845 .f = cmd_set_link_down_parsed,
6847 .help_str = "set link-down port <port id>",
6849 (void *)&cmd_set_link_down_set,
6850 (void *)&cmd_set_link_down_link_down,
6851 (void *)&cmd_set_link_down_port,
6852 (void *)&cmd_set_link_down_port_id,
6857 /* *** SHOW CFG *** */
6858 struct cmd_showcfg_result {
6859 cmdline_fixed_string_t show;
6860 cmdline_fixed_string_t cfg;
6861 cmdline_fixed_string_t what;
6864 static void cmd_showcfg_parsed(void *parsed_result,
6865 __attribute__((unused)) struct cmdline *cl,
6866 __attribute__((unused)) void *data)
6868 struct cmd_showcfg_result *res = parsed_result;
6869 if (!strcmp(res->what, "rxtx"))
6870 rxtx_config_display();
6871 else if (!strcmp(res->what, "cores"))
6872 fwd_lcores_config_display();
6873 else if (!strcmp(res->what, "fwd"))
6874 pkt_fwd_config_display(&cur_fwd_config);
6875 else if (!strcmp(res->what, "txpkts"))
6876 show_tx_pkt_segments();
6879 cmdline_parse_token_string_t cmd_showcfg_show =
6880 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6881 cmdline_parse_token_string_t cmd_showcfg_port =
6882 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6883 cmdline_parse_token_string_t cmd_showcfg_what =
6884 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6885 "rxtx#cores#fwd#txpkts");
6887 cmdline_parse_inst_t cmd_showcfg = {
6888 .f = cmd_showcfg_parsed,
6890 .help_str = "show config rxtx|cores|fwd|txpkts",
6892 (void *)&cmd_showcfg_show,
6893 (void *)&cmd_showcfg_port,
6894 (void *)&cmd_showcfg_what,
6899 /* *** SHOW ALL PORT INFO *** */
6900 struct cmd_showportall_result {
6901 cmdline_fixed_string_t show;
6902 cmdline_fixed_string_t port;
6903 cmdline_fixed_string_t what;
6904 cmdline_fixed_string_t all;
6907 static void cmd_showportall_parsed(void *parsed_result,
6908 __attribute__((unused)) struct cmdline *cl,
6909 __attribute__((unused)) void *data)
6913 struct cmd_showportall_result *res = parsed_result;
6914 if (!strcmp(res->show, "clear")) {
6915 if (!strcmp(res->what, "stats"))
6916 RTE_ETH_FOREACH_DEV(i)
6918 else if (!strcmp(res->what, "xstats"))
6919 RTE_ETH_FOREACH_DEV(i)
6920 nic_xstats_clear(i);
6921 } else if (!strcmp(res->what, "info"))
6922 RTE_ETH_FOREACH_DEV(i)
6923 port_infos_display(i);
6924 else if (!strcmp(res->what, "stats"))
6925 RTE_ETH_FOREACH_DEV(i)
6926 nic_stats_display(i);
6927 else if (!strcmp(res->what, "xstats"))
6928 RTE_ETH_FOREACH_DEV(i)
6929 nic_xstats_display(i);
6930 else if (!strcmp(res->what, "fdir"))
6931 RTE_ETH_FOREACH_DEV(i)
6933 else if (!strcmp(res->what, "stat_qmap"))
6934 RTE_ETH_FOREACH_DEV(i)
6935 nic_stats_mapping_display(i);
6936 else if (!strcmp(res->what, "dcb_tc"))
6937 RTE_ETH_FOREACH_DEV(i)
6938 port_dcb_info_display(i);
6939 else if (!strcmp(res->what, "cap"))
6940 RTE_ETH_FOREACH_DEV(i)
6941 port_offload_cap_display(i);
6944 cmdline_parse_token_string_t cmd_showportall_show =
6945 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6947 cmdline_parse_token_string_t cmd_showportall_port =
6948 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6949 cmdline_parse_token_string_t cmd_showportall_what =
6950 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6951 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6952 cmdline_parse_token_string_t cmd_showportall_all =
6953 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6954 cmdline_parse_inst_t cmd_showportall = {
6955 .f = cmd_showportall_parsed,
6957 .help_str = "show|clear port "
6958 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6960 (void *)&cmd_showportall_show,
6961 (void *)&cmd_showportall_port,
6962 (void *)&cmd_showportall_what,
6963 (void *)&cmd_showportall_all,
6968 /* *** SHOW PORT INFO *** */
6969 struct cmd_showport_result {
6970 cmdline_fixed_string_t show;
6971 cmdline_fixed_string_t port;
6972 cmdline_fixed_string_t what;
6976 static void cmd_showport_parsed(void *parsed_result,
6977 __attribute__((unused)) struct cmdline *cl,
6978 __attribute__((unused)) void *data)
6980 struct cmd_showport_result *res = parsed_result;
6981 if (!strcmp(res->show, "clear")) {
6982 if (!strcmp(res->what, "stats"))
6983 nic_stats_clear(res->portnum);
6984 else if (!strcmp(res->what, "xstats"))
6985 nic_xstats_clear(res->portnum);
6986 } else if (!strcmp(res->what, "info"))
6987 port_infos_display(res->portnum);
6988 else if (!strcmp(res->what, "stats"))
6989 nic_stats_display(res->portnum);
6990 else if (!strcmp(res->what, "xstats"))
6991 nic_xstats_display(res->portnum);
6992 else if (!strcmp(res->what, "fdir"))
6993 fdir_get_infos(res->portnum);
6994 else if (!strcmp(res->what, "stat_qmap"))
6995 nic_stats_mapping_display(res->portnum);
6996 else if (!strcmp(res->what, "dcb_tc"))
6997 port_dcb_info_display(res->portnum);
6998 else if (!strcmp(res->what, "cap"))
6999 port_offload_cap_display(res->portnum);
7002 cmdline_parse_token_string_t cmd_showport_show =
7003 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7005 cmdline_parse_token_string_t cmd_showport_port =
7006 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7007 cmdline_parse_token_string_t cmd_showport_what =
7008 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7009 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7010 cmdline_parse_token_num_t cmd_showport_portnum =
7011 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7013 cmdline_parse_inst_t cmd_showport = {
7014 .f = cmd_showport_parsed,
7016 .help_str = "show|clear port "
7017 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7020 (void *)&cmd_showport_show,
7021 (void *)&cmd_showport_port,
7022 (void *)&cmd_showport_what,
7023 (void *)&cmd_showport_portnum,
7028 /* *** SHOW QUEUE INFO *** */
7029 struct cmd_showqueue_result {
7030 cmdline_fixed_string_t show;
7031 cmdline_fixed_string_t type;
7032 cmdline_fixed_string_t what;
7038 cmd_showqueue_parsed(void *parsed_result,
7039 __attribute__((unused)) struct cmdline *cl,
7040 __attribute__((unused)) void *data)
7042 struct cmd_showqueue_result *res = parsed_result;
7044 if (!strcmp(res->type, "rxq"))
7045 rx_queue_infos_display(res->portnum, res->queuenum);
7046 else if (!strcmp(res->type, "txq"))
7047 tx_queue_infos_display(res->portnum, res->queuenum);
7050 cmdline_parse_token_string_t cmd_showqueue_show =
7051 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7052 cmdline_parse_token_string_t cmd_showqueue_type =
7053 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7054 cmdline_parse_token_string_t cmd_showqueue_what =
7055 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7056 cmdline_parse_token_num_t cmd_showqueue_portnum =
7057 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7058 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7059 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7061 cmdline_parse_inst_t cmd_showqueue = {
7062 .f = cmd_showqueue_parsed,
7064 .help_str = "show rxq|txq info <port_id> <queue_id>",
7066 (void *)&cmd_showqueue_show,
7067 (void *)&cmd_showqueue_type,
7068 (void *)&cmd_showqueue_what,
7069 (void *)&cmd_showqueue_portnum,
7070 (void *)&cmd_showqueue_queuenum,
7075 /* *** READ PORT REGISTER *** */
7076 struct cmd_read_reg_result {
7077 cmdline_fixed_string_t read;
7078 cmdline_fixed_string_t reg;
7084 cmd_read_reg_parsed(void *parsed_result,
7085 __attribute__((unused)) struct cmdline *cl,
7086 __attribute__((unused)) void *data)
7088 struct cmd_read_reg_result *res = parsed_result;
7089 port_reg_display(res->port_id, res->reg_off);
7092 cmdline_parse_token_string_t cmd_read_reg_read =
7093 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7094 cmdline_parse_token_string_t cmd_read_reg_reg =
7095 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7096 cmdline_parse_token_num_t cmd_read_reg_port_id =
7097 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7098 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7099 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7101 cmdline_parse_inst_t cmd_read_reg = {
7102 .f = cmd_read_reg_parsed,
7104 .help_str = "read reg <port_id> <reg_off>",
7106 (void *)&cmd_read_reg_read,
7107 (void *)&cmd_read_reg_reg,
7108 (void *)&cmd_read_reg_port_id,
7109 (void *)&cmd_read_reg_reg_off,
7114 /* *** READ PORT REGISTER BIT FIELD *** */
7115 struct cmd_read_reg_bit_field_result {
7116 cmdline_fixed_string_t read;
7117 cmdline_fixed_string_t regfield;
7125 cmd_read_reg_bit_field_parsed(void *parsed_result,
7126 __attribute__((unused)) struct cmdline *cl,
7127 __attribute__((unused)) void *data)
7129 struct cmd_read_reg_bit_field_result *res = parsed_result;
7130 port_reg_bit_field_display(res->port_id, res->reg_off,
7131 res->bit1_pos, res->bit2_pos);
7134 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7135 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7137 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7138 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7139 regfield, "regfield");
7140 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7141 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7143 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7144 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7146 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7147 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7149 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7150 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7153 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7154 .f = cmd_read_reg_bit_field_parsed,
7156 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7157 "Read register bit field between bit_x and bit_y included",
7159 (void *)&cmd_read_reg_bit_field_read,
7160 (void *)&cmd_read_reg_bit_field_regfield,
7161 (void *)&cmd_read_reg_bit_field_port_id,
7162 (void *)&cmd_read_reg_bit_field_reg_off,
7163 (void *)&cmd_read_reg_bit_field_bit1_pos,
7164 (void *)&cmd_read_reg_bit_field_bit2_pos,
7169 /* *** READ PORT REGISTER BIT *** */
7170 struct cmd_read_reg_bit_result {
7171 cmdline_fixed_string_t read;
7172 cmdline_fixed_string_t regbit;
7179 cmd_read_reg_bit_parsed(void *parsed_result,
7180 __attribute__((unused)) struct cmdline *cl,
7181 __attribute__((unused)) void *data)
7183 struct cmd_read_reg_bit_result *res = parsed_result;
7184 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7187 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7188 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7189 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7190 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7192 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7193 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7194 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7195 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7196 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7197 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7199 cmdline_parse_inst_t cmd_read_reg_bit = {
7200 .f = cmd_read_reg_bit_parsed,
7202 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7204 (void *)&cmd_read_reg_bit_read,
7205 (void *)&cmd_read_reg_bit_regbit,
7206 (void *)&cmd_read_reg_bit_port_id,
7207 (void *)&cmd_read_reg_bit_reg_off,
7208 (void *)&cmd_read_reg_bit_bit_pos,
7213 /* *** WRITE PORT REGISTER *** */
7214 struct cmd_write_reg_result {
7215 cmdline_fixed_string_t write;
7216 cmdline_fixed_string_t reg;
7223 cmd_write_reg_parsed(void *parsed_result,
7224 __attribute__((unused)) struct cmdline *cl,
7225 __attribute__((unused)) void *data)
7227 struct cmd_write_reg_result *res = parsed_result;
7228 port_reg_set(res->port_id, res->reg_off, res->value);
7231 cmdline_parse_token_string_t cmd_write_reg_write =
7232 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7233 cmdline_parse_token_string_t cmd_write_reg_reg =
7234 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7235 cmdline_parse_token_num_t cmd_write_reg_port_id =
7236 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7237 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7238 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7239 cmdline_parse_token_num_t cmd_write_reg_value =
7240 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7242 cmdline_parse_inst_t cmd_write_reg = {
7243 .f = cmd_write_reg_parsed,
7245 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7247 (void *)&cmd_write_reg_write,
7248 (void *)&cmd_write_reg_reg,
7249 (void *)&cmd_write_reg_port_id,
7250 (void *)&cmd_write_reg_reg_off,
7251 (void *)&cmd_write_reg_value,
7256 /* *** WRITE PORT REGISTER BIT FIELD *** */
7257 struct cmd_write_reg_bit_field_result {
7258 cmdline_fixed_string_t write;
7259 cmdline_fixed_string_t regfield;
7268 cmd_write_reg_bit_field_parsed(void *parsed_result,
7269 __attribute__((unused)) struct cmdline *cl,
7270 __attribute__((unused)) void *data)
7272 struct cmd_write_reg_bit_field_result *res = parsed_result;
7273 port_reg_bit_field_set(res->port_id, res->reg_off,
7274 res->bit1_pos, res->bit2_pos, res->value);
7277 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7278 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7280 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7281 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7282 regfield, "regfield");
7283 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7284 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7286 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7287 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7289 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7290 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7292 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7293 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7295 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7296 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7299 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7300 .f = cmd_write_reg_bit_field_parsed,
7302 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7304 "Set register bit field between bit_x and bit_y included",
7306 (void *)&cmd_write_reg_bit_field_write,
7307 (void *)&cmd_write_reg_bit_field_regfield,
7308 (void *)&cmd_write_reg_bit_field_port_id,
7309 (void *)&cmd_write_reg_bit_field_reg_off,
7310 (void *)&cmd_write_reg_bit_field_bit1_pos,
7311 (void *)&cmd_write_reg_bit_field_bit2_pos,
7312 (void *)&cmd_write_reg_bit_field_value,
7317 /* *** WRITE PORT REGISTER BIT *** */
7318 struct cmd_write_reg_bit_result {
7319 cmdline_fixed_string_t write;
7320 cmdline_fixed_string_t regbit;
7328 cmd_write_reg_bit_parsed(void *parsed_result,
7329 __attribute__((unused)) struct cmdline *cl,
7330 __attribute__((unused)) void *data)
7332 struct cmd_write_reg_bit_result *res = parsed_result;
7333 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7336 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7337 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7339 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7340 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7342 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7343 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7344 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7345 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7346 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7347 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7348 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7349 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7351 cmdline_parse_inst_t cmd_write_reg_bit = {
7352 .f = cmd_write_reg_bit_parsed,
7354 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7357 (void *)&cmd_write_reg_bit_write,
7358 (void *)&cmd_write_reg_bit_regbit,
7359 (void *)&cmd_write_reg_bit_port_id,
7360 (void *)&cmd_write_reg_bit_reg_off,
7361 (void *)&cmd_write_reg_bit_bit_pos,
7362 (void *)&cmd_write_reg_bit_value,
7367 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7368 struct cmd_read_rxd_txd_result {
7369 cmdline_fixed_string_t read;
7370 cmdline_fixed_string_t rxd_txd;
7377 cmd_read_rxd_txd_parsed(void *parsed_result,
7378 __attribute__((unused)) struct cmdline *cl,
7379 __attribute__((unused)) void *data)
7381 struct cmd_read_rxd_txd_result *res = parsed_result;
7383 if (!strcmp(res->rxd_txd, "rxd"))
7384 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7385 else if (!strcmp(res->rxd_txd, "txd"))
7386 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7389 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7390 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7391 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7392 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7394 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7395 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7396 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7397 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7398 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7399 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7401 cmdline_parse_inst_t cmd_read_rxd_txd = {
7402 .f = cmd_read_rxd_txd_parsed,
7404 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7406 (void *)&cmd_read_rxd_txd_read,
7407 (void *)&cmd_read_rxd_txd_rxd_txd,
7408 (void *)&cmd_read_rxd_txd_port_id,
7409 (void *)&cmd_read_rxd_txd_queue_id,
7410 (void *)&cmd_read_rxd_txd_desc_id,
7416 struct cmd_quit_result {
7417 cmdline_fixed_string_t quit;
7420 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7422 __attribute__((unused)) void *data)
7428 cmdline_parse_token_string_t cmd_quit_quit =
7429 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7431 cmdline_parse_inst_t cmd_quit = {
7432 .f = cmd_quit_parsed,
7434 .help_str = "quit: Exit application",
7436 (void *)&cmd_quit_quit,
7441 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7442 struct cmd_mac_addr_result {
7443 cmdline_fixed_string_t mac_addr_cmd;
7444 cmdline_fixed_string_t what;
7446 struct ether_addr address;
7449 static void cmd_mac_addr_parsed(void *parsed_result,
7450 __attribute__((unused)) struct cmdline *cl,
7451 __attribute__((unused)) void *data)
7453 struct cmd_mac_addr_result *res = parsed_result;
7456 if (strcmp(res->what, "add") == 0)
7457 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7458 else if (strcmp(res->what, "set") == 0)
7459 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7462 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7464 /* check the return value and print it if is < 0 */
7466 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7470 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7471 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7473 cmdline_parse_token_string_t cmd_mac_addr_what =
7474 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7476 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7477 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7479 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7480 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7482 cmdline_parse_inst_t cmd_mac_addr = {
7483 .f = cmd_mac_addr_parsed,
7485 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7486 "Add/Remove/Set MAC address on port_id",
7488 (void *)&cmd_mac_addr_cmd,
7489 (void *)&cmd_mac_addr_what,
7490 (void *)&cmd_mac_addr_portnum,
7491 (void *)&cmd_mac_addr_addr,
7496 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7497 struct cmd_eth_peer_result {
7498 cmdline_fixed_string_t set;
7499 cmdline_fixed_string_t eth_peer;
7501 cmdline_fixed_string_t peer_addr;
7504 static void cmd_set_eth_peer_parsed(void *parsed_result,
7505 __attribute__((unused)) struct cmdline *cl,
7506 __attribute__((unused)) void *data)
7508 struct cmd_eth_peer_result *res = parsed_result;
7510 if (test_done == 0) {
7511 printf("Please stop forwarding first\n");
7514 if (!strcmp(res->eth_peer, "eth-peer")) {
7515 set_fwd_eth_peer(res->port_id, res->peer_addr);
7519 cmdline_parse_token_string_t cmd_eth_peer_set =
7520 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7521 cmdline_parse_token_string_t cmd_eth_peer =
7522 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7523 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7524 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7525 cmdline_parse_token_string_t cmd_eth_peer_addr =
7526 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7528 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7529 .f = cmd_set_eth_peer_parsed,
7531 .help_str = "set eth-peer <port_id> <peer_mac>",
7533 (void *)&cmd_eth_peer_set,
7534 (void *)&cmd_eth_peer,
7535 (void *)&cmd_eth_peer_port_id,
7536 (void *)&cmd_eth_peer_addr,
7541 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7542 struct cmd_set_qmap_result {
7543 cmdline_fixed_string_t set;
7544 cmdline_fixed_string_t qmap;
7545 cmdline_fixed_string_t what;
7552 cmd_set_qmap_parsed(void *parsed_result,
7553 __attribute__((unused)) struct cmdline *cl,
7554 __attribute__((unused)) void *data)
7556 struct cmd_set_qmap_result *res = parsed_result;
7557 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7559 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7562 cmdline_parse_token_string_t cmd_setqmap_set =
7563 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7565 cmdline_parse_token_string_t cmd_setqmap_qmap =
7566 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7568 cmdline_parse_token_string_t cmd_setqmap_what =
7569 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7571 cmdline_parse_token_num_t cmd_setqmap_portid =
7572 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7574 cmdline_parse_token_num_t cmd_setqmap_queueid =
7575 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7577 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7578 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7581 cmdline_parse_inst_t cmd_set_qmap = {
7582 .f = cmd_set_qmap_parsed,
7584 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7585 "Set statistics mapping value on tx|rx queue_id of port_id",
7587 (void *)&cmd_setqmap_set,
7588 (void *)&cmd_setqmap_qmap,
7589 (void *)&cmd_setqmap_what,
7590 (void *)&cmd_setqmap_portid,
7591 (void *)&cmd_setqmap_queueid,
7592 (void *)&cmd_setqmap_mapvalue,
7597 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7598 struct cmd_set_xstats_hide_zero_result {
7599 cmdline_fixed_string_t keyword;
7600 cmdline_fixed_string_t name;
7601 cmdline_fixed_string_t on_off;
7605 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7606 __attribute__((unused)) struct cmdline *cl,
7607 __attribute__((unused)) void *data)
7609 struct cmd_set_xstats_hide_zero_result *res;
7610 uint16_t on_off = 0;
7612 res = parsed_result;
7613 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7614 set_xstats_hide_zero(on_off);
7617 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7618 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7620 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7621 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7622 name, "xstats-hide-zero");
7623 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7624 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7627 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7628 .f = cmd_set_xstats_hide_zero_parsed,
7630 .help_str = "set xstats-hide-zero on|off",
7632 (void *)&cmd_set_xstats_hide_zero_keyword,
7633 (void *)&cmd_set_xstats_hide_zero_name,
7634 (void *)&cmd_set_xstats_hide_zero_on_off,
7639 /* *** CONFIGURE UNICAST HASH TABLE *** */
7640 struct cmd_set_uc_hash_table {
7641 cmdline_fixed_string_t set;
7642 cmdline_fixed_string_t port;
7644 cmdline_fixed_string_t what;
7645 struct ether_addr address;
7646 cmdline_fixed_string_t mode;
7650 cmd_set_uc_hash_parsed(void *parsed_result,
7651 __attribute__((unused)) struct cmdline *cl,
7652 __attribute__((unused)) void *data)
7655 struct cmd_set_uc_hash_table *res = parsed_result;
7657 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7659 if (strcmp(res->what, "uta") == 0)
7660 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7661 &res->address,(uint8_t)is_on);
7663 printf("bad unicast hash table parameter, return code = %d \n", ret);
7667 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7668 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7670 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7671 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7673 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7674 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7676 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7677 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7679 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7680 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7682 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7683 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7686 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7687 .f = cmd_set_uc_hash_parsed,
7689 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7691 (void *)&cmd_set_uc_hash_set,
7692 (void *)&cmd_set_uc_hash_port,
7693 (void *)&cmd_set_uc_hash_portid,
7694 (void *)&cmd_set_uc_hash_what,
7695 (void *)&cmd_set_uc_hash_mac,
7696 (void *)&cmd_set_uc_hash_mode,
7701 struct cmd_set_uc_all_hash_table {
7702 cmdline_fixed_string_t set;
7703 cmdline_fixed_string_t port;
7705 cmdline_fixed_string_t what;
7706 cmdline_fixed_string_t value;
7707 cmdline_fixed_string_t mode;
7711 cmd_set_uc_all_hash_parsed(void *parsed_result,
7712 __attribute__((unused)) struct cmdline *cl,
7713 __attribute__((unused)) void *data)
7716 struct cmd_set_uc_all_hash_table *res = parsed_result;
7718 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7720 if ((strcmp(res->what, "uta") == 0) &&
7721 (strcmp(res->value, "all") == 0))
7722 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7724 printf("bad unicast hash table parameter,"
7725 "return code = %d \n", ret);
7728 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7729 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7731 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7732 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7734 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7735 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7737 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7738 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7740 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7741 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7743 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7744 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7747 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7748 .f = cmd_set_uc_all_hash_parsed,
7750 .help_str = "set port <port_id> uta all on|off",
7752 (void *)&cmd_set_uc_all_hash_set,
7753 (void *)&cmd_set_uc_all_hash_port,
7754 (void *)&cmd_set_uc_all_hash_portid,
7755 (void *)&cmd_set_uc_all_hash_what,
7756 (void *)&cmd_set_uc_all_hash_value,
7757 (void *)&cmd_set_uc_all_hash_mode,
7762 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7763 struct cmd_set_vf_macvlan_filter {
7764 cmdline_fixed_string_t set;
7765 cmdline_fixed_string_t port;
7767 cmdline_fixed_string_t vf;
7769 struct ether_addr address;
7770 cmdline_fixed_string_t filter_type;
7771 cmdline_fixed_string_t mode;
7775 cmd_set_vf_macvlan_parsed(void *parsed_result,
7776 __attribute__((unused)) struct cmdline *cl,
7777 __attribute__((unused)) void *data)
7780 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7781 struct rte_eth_mac_filter filter;
7783 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7785 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7787 /* set VF MAC filter */
7791 filter.dst_id = res->vf_id;
7793 if (!strcmp(res->filter_type, "exact-mac"))
7794 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7795 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7796 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7797 else if (!strcmp(res->filter_type, "hashmac"))
7798 filter.filter_type = RTE_MAC_HASH_MATCH;
7799 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7800 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7802 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7805 ret = rte_eth_dev_filter_ctrl(res->port_id,
7806 RTE_ETH_FILTER_MACVLAN,
7810 ret = rte_eth_dev_filter_ctrl(res->port_id,
7811 RTE_ETH_FILTER_MACVLAN,
7812 RTE_ETH_FILTER_DELETE,
7816 printf("bad set MAC hash parameter, return code = %d\n", ret);
7820 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7821 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7823 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7824 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7826 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7827 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7829 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7830 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7832 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7833 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7835 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7836 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7838 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7839 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7840 filter_type, "exact-mac#exact-mac-vlan"
7841 "#hashmac#hashmac-vlan");
7842 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7843 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7846 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7847 .f = cmd_set_vf_macvlan_parsed,
7849 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7850 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7851 "Exact match rule: exact match of MAC or MAC and VLAN; "
7852 "hash match rule: hash match of MAC and exact match of VLAN",
7854 (void *)&cmd_set_vf_macvlan_set,
7855 (void *)&cmd_set_vf_macvlan_port,
7856 (void *)&cmd_set_vf_macvlan_portid,
7857 (void *)&cmd_set_vf_macvlan_vf,
7858 (void *)&cmd_set_vf_macvlan_vf_id,
7859 (void *)&cmd_set_vf_macvlan_mac,
7860 (void *)&cmd_set_vf_macvlan_filter_type,
7861 (void *)&cmd_set_vf_macvlan_mode,
7866 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7867 struct cmd_set_vf_traffic {
7868 cmdline_fixed_string_t set;
7869 cmdline_fixed_string_t port;
7871 cmdline_fixed_string_t vf;
7873 cmdline_fixed_string_t what;
7874 cmdline_fixed_string_t mode;
7878 cmd_set_vf_traffic_parsed(void *parsed_result,
7879 __attribute__((unused)) struct cmdline *cl,
7880 __attribute__((unused)) void *data)
7882 struct cmd_set_vf_traffic *res = parsed_result;
7883 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7884 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7886 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7889 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7890 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7892 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7893 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7895 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7896 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7898 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7899 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7901 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7902 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7904 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7905 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7907 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7908 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7911 cmdline_parse_inst_t cmd_set_vf_traffic = {
7912 .f = cmd_set_vf_traffic_parsed,
7914 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7916 (void *)&cmd_setvf_traffic_set,
7917 (void *)&cmd_setvf_traffic_port,
7918 (void *)&cmd_setvf_traffic_portid,
7919 (void *)&cmd_setvf_traffic_vf,
7920 (void *)&cmd_setvf_traffic_vfid,
7921 (void *)&cmd_setvf_traffic_what,
7922 (void *)&cmd_setvf_traffic_mode,
7927 /* *** CONFIGURE VF RECEIVE MODE *** */
7928 struct cmd_set_vf_rxmode {
7929 cmdline_fixed_string_t set;
7930 cmdline_fixed_string_t port;
7932 cmdline_fixed_string_t vf;
7934 cmdline_fixed_string_t what;
7935 cmdline_fixed_string_t mode;
7936 cmdline_fixed_string_t on;
7940 cmd_set_vf_rxmode_parsed(void *parsed_result,
7941 __attribute__((unused)) struct cmdline *cl,
7942 __attribute__((unused)) void *data)
7945 uint16_t rx_mode = 0;
7946 struct cmd_set_vf_rxmode *res = parsed_result;
7948 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7949 if (!strcmp(res->what,"rxmode")) {
7950 if (!strcmp(res->mode, "AUPE"))
7951 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7952 else if (!strcmp(res->mode, "ROPE"))
7953 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7954 else if (!strcmp(res->mode, "BAM"))
7955 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7956 else if (!strncmp(res->mode, "MPE",3))
7957 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7960 RTE_SET_USED(is_on);
7962 #ifdef RTE_LIBRTE_IXGBE_PMD
7963 if (ret == -ENOTSUP)
7964 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7965 rx_mode, (uint8_t)is_on);
7967 #ifdef RTE_LIBRTE_BNXT_PMD
7968 if (ret == -ENOTSUP)
7969 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7970 rx_mode, (uint8_t)is_on);
7973 printf("bad VF receive mode parameter, return code = %d \n",
7977 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7978 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7980 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7981 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7983 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7984 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7986 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7987 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7989 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7990 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7992 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7993 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7995 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7996 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7997 mode, "AUPE#ROPE#BAM#MPE");
7998 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7999 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8002 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8003 .f = cmd_set_vf_rxmode_parsed,
8005 .help_str = "set port <port_id> vf <vf_id> rxmode "
8006 "AUPE|ROPE|BAM|MPE on|off",
8008 (void *)&cmd_set_vf_rxmode_set,
8009 (void *)&cmd_set_vf_rxmode_port,
8010 (void *)&cmd_set_vf_rxmode_portid,
8011 (void *)&cmd_set_vf_rxmode_vf,
8012 (void *)&cmd_set_vf_rxmode_vfid,
8013 (void *)&cmd_set_vf_rxmode_what,
8014 (void *)&cmd_set_vf_rxmode_mode,
8015 (void *)&cmd_set_vf_rxmode_on,
8020 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8021 struct cmd_vf_mac_addr_result {
8022 cmdline_fixed_string_t mac_addr_cmd;
8023 cmdline_fixed_string_t what;
8024 cmdline_fixed_string_t port;
8026 cmdline_fixed_string_t vf;
8028 struct ether_addr address;
8031 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8032 __attribute__((unused)) struct cmdline *cl,
8033 __attribute__((unused)) void *data)
8035 struct cmd_vf_mac_addr_result *res = parsed_result;
8038 if (strcmp(res->what, "add") != 0)
8041 #ifdef RTE_LIBRTE_I40E_PMD
8042 if (ret == -ENOTSUP)
8043 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8046 #ifdef RTE_LIBRTE_BNXT_PMD
8047 if (ret == -ENOTSUP)
8048 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8053 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8057 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8058 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8059 mac_addr_cmd,"mac_addr");
8060 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8061 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8063 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8064 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8066 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8067 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8069 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8070 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8072 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8073 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8075 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8076 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8079 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8080 .f = cmd_vf_mac_addr_parsed,
8082 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8083 "Add MAC address filtering for a VF on port_id",
8085 (void *)&cmd_vf_mac_addr_cmd,
8086 (void *)&cmd_vf_mac_addr_what,
8087 (void *)&cmd_vf_mac_addr_port,
8088 (void *)&cmd_vf_mac_addr_portnum,
8089 (void *)&cmd_vf_mac_addr_vf,
8090 (void *)&cmd_vf_mac_addr_vfnum,
8091 (void *)&cmd_vf_mac_addr_addr,
8096 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8097 struct cmd_vf_rx_vlan_filter {
8098 cmdline_fixed_string_t rx_vlan;
8099 cmdline_fixed_string_t what;
8101 cmdline_fixed_string_t port;
8103 cmdline_fixed_string_t vf;
8108 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8109 __attribute__((unused)) struct cmdline *cl,
8110 __attribute__((unused)) void *data)
8112 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8115 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8117 #ifdef RTE_LIBRTE_IXGBE_PMD
8118 if (ret == -ENOTSUP)
8119 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8120 res->vlan_id, res->vf_mask, is_add);
8122 #ifdef RTE_LIBRTE_I40E_PMD
8123 if (ret == -ENOTSUP)
8124 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8125 res->vlan_id, res->vf_mask, is_add);
8127 #ifdef RTE_LIBRTE_BNXT_PMD
8128 if (ret == -ENOTSUP)
8129 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8130 res->vlan_id, res->vf_mask, is_add);
8137 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8138 res->vlan_id, res->vf_mask);
8141 printf("invalid port_id %d\n", res->port_id);
8144 printf("function not implemented or supported\n");
8147 printf("programming error: (%s)\n", strerror(-ret));
8151 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8152 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8153 rx_vlan, "rx_vlan");
8154 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8155 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8157 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8158 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8160 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8161 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8163 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8164 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8166 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8167 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8169 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8170 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8173 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8174 .f = cmd_vf_rx_vlan_filter_parsed,
8176 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8177 "(vf_mask = hexadecimal VF mask)",
8179 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8180 (void *)&cmd_vf_rx_vlan_filter_what,
8181 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8182 (void *)&cmd_vf_rx_vlan_filter_port,
8183 (void *)&cmd_vf_rx_vlan_filter_portid,
8184 (void *)&cmd_vf_rx_vlan_filter_vf,
8185 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8190 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8191 struct cmd_queue_rate_limit_result {
8192 cmdline_fixed_string_t set;
8193 cmdline_fixed_string_t port;
8195 cmdline_fixed_string_t queue;
8197 cmdline_fixed_string_t rate;
8201 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8202 __attribute__((unused)) struct cmdline *cl,
8203 __attribute__((unused)) void *data)
8205 struct cmd_queue_rate_limit_result *res = parsed_result;
8208 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8209 && (strcmp(res->queue, "queue") == 0)
8210 && (strcmp(res->rate, "rate") == 0))
8211 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8214 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8218 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8219 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8221 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8222 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8224 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8225 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8227 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8228 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8230 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8231 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8233 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8234 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8236 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8237 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8240 cmdline_parse_inst_t cmd_queue_rate_limit = {
8241 .f = cmd_queue_rate_limit_parsed,
8243 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8244 "Set rate limit for a queue on port_id",
8246 (void *)&cmd_queue_rate_limit_set,
8247 (void *)&cmd_queue_rate_limit_port,
8248 (void *)&cmd_queue_rate_limit_portnum,
8249 (void *)&cmd_queue_rate_limit_queue,
8250 (void *)&cmd_queue_rate_limit_queuenum,
8251 (void *)&cmd_queue_rate_limit_rate,
8252 (void *)&cmd_queue_rate_limit_ratenum,
8257 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8258 struct cmd_vf_rate_limit_result {
8259 cmdline_fixed_string_t set;
8260 cmdline_fixed_string_t port;
8262 cmdline_fixed_string_t vf;
8264 cmdline_fixed_string_t rate;
8266 cmdline_fixed_string_t q_msk;
8270 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8271 __attribute__((unused)) struct cmdline *cl,
8272 __attribute__((unused)) void *data)
8274 struct cmd_vf_rate_limit_result *res = parsed_result;
8277 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8278 && (strcmp(res->vf, "vf") == 0)
8279 && (strcmp(res->rate, "rate") == 0)
8280 && (strcmp(res->q_msk, "queue_mask") == 0))
8281 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8282 res->rate_num, res->q_msk_val);
8284 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8288 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8289 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8291 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8292 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8294 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8295 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8297 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8298 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8300 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8301 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8303 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8304 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8306 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8307 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8309 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8310 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8311 q_msk, "queue_mask");
8312 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8313 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8316 cmdline_parse_inst_t cmd_vf_rate_limit = {
8317 .f = cmd_vf_rate_limit_parsed,
8319 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8320 "queue_mask <queue_mask_value>: "
8321 "Set rate limit for queues of VF on port_id",
8323 (void *)&cmd_vf_rate_limit_set,
8324 (void *)&cmd_vf_rate_limit_port,
8325 (void *)&cmd_vf_rate_limit_portnum,
8326 (void *)&cmd_vf_rate_limit_vf,
8327 (void *)&cmd_vf_rate_limit_vfnum,
8328 (void *)&cmd_vf_rate_limit_rate,
8329 (void *)&cmd_vf_rate_limit_ratenum,
8330 (void *)&cmd_vf_rate_limit_q_msk,
8331 (void *)&cmd_vf_rate_limit_q_msk_val,
8336 /* *** ADD TUNNEL FILTER OF A PORT *** */
8337 struct cmd_tunnel_filter_result {
8338 cmdline_fixed_string_t cmd;
8339 cmdline_fixed_string_t what;
8341 struct ether_addr outer_mac;
8342 struct ether_addr inner_mac;
8343 cmdline_ipaddr_t ip_value;
8344 uint16_t inner_vlan;
8345 cmdline_fixed_string_t tunnel_type;
8346 cmdline_fixed_string_t filter_type;
8352 cmd_tunnel_filter_parsed(void *parsed_result,
8353 __attribute__((unused)) struct cmdline *cl,
8354 __attribute__((unused)) void *data)
8356 struct cmd_tunnel_filter_result *res = parsed_result;
8357 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8360 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8362 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8363 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8364 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8366 if (res->ip_value.family == AF_INET) {
8367 tunnel_filter_conf.ip_addr.ipv4_addr =
8368 res->ip_value.addr.ipv4.s_addr;
8369 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8371 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8372 &(res->ip_value.addr.ipv6),
8373 sizeof(struct in6_addr));
8374 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8377 if (!strcmp(res->filter_type, "imac-ivlan"))
8378 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8379 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8380 tunnel_filter_conf.filter_type =
8381 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8382 else if (!strcmp(res->filter_type, "imac-tenid"))
8383 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8384 else if (!strcmp(res->filter_type, "imac"))
8385 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8386 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8387 tunnel_filter_conf.filter_type =
8388 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8389 else if (!strcmp(res->filter_type, "oip"))
8390 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8391 else if (!strcmp(res->filter_type, "iip"))
8392 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8394 printf("The filter type is not supported");
8398 if (!strcmp(res->tunnel_type, "vxlan"))
8399 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8400 else if (!strcmp(res->tunnel_type, "nvgre"))
8401 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8402 else if (!strcmp(res->tunnel_type, "ipingre"))
8403 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8405 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8409 tunnel_filter_conf.tenant_id = res->tenant_id;
8410 tunnel_filter_conf.queue_id = res->queue_num;
8411 if (!strcmp(res->what, "add"))
8412 ret = rte_eth_dev_filter_ctrl(res->port_id,
8413 RTE_ETH_FILTER_TUNNEL,
8415 &tunnel_filter_conf);
8417 ret = rte_eth_dev_filter_ctrl(res->port_id,
8418 RTE_ETH_FILTER_TUNNEL,
8419 RTE_ETH_FILTER_DELETE,
8420 &tunnel_filter_conf);
8422 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8426 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8427 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8428 cmd, "tunnel_filter");
8429 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8430 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8432 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8433 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8435 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8436 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8438 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8439 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8441 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8442 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8443 inner_vlan, UINT16);
8444 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8445 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8447 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8448 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8449 tunnel_type, "vxlan#nvgre#ipingre");
8451 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8452 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8453 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8454 "imac#omac-imac-tenid");
8455 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8456 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8458 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8459 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8462 cmdline_parse_inst_t cmd_tunnel_filter = {
8463 .f = cmd_tunnel_filter_parsed,
8465 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8466 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8467 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8468 "<queue_id>: Add/Rm tunnel filter of a port",
8470 (void *)&cmd_tunnel_filter_cmd,
8471 (void *)&cmd_tunnel_filter_what,
8472 (void *)&cmd_tunnel_filter_port_id,
8473 (void *)&cmd_tunnel_filter_outer_mac,
8474 (void *)&cmd_tunnel_filter_inner_mac,
8475 (void *)&cmd_tunnel_filter_ip_value,
8476 (void *)&cmd_tunnel_filter_innner_vlan,
8477 (void *)&cmd_tunnel_filter_tunnel_type,
8478 (void *)&cmd_tunnel_filter_filter_type,
8479 (void *)&cmd_tunnel_filter_tenant_id,
8480 (void *)&cmd_tunnel_filter_queue_num,
8485 /* *** CONFIGURE TUNNEL UDP PORT *** */
8486 struct cmd_tunnel_udp_config {
8487 cmdline_fixed_string_t cmd;
8488 cmdline_fixed_string_t what;
8494 cmd_tunnel_udp_config_parsed(void *parsed_result,
8495 __attribute__((unused)) struct cmdline *cl,
8496 __attribute__((unused)) void *data)
8498 struct cmd_tunnel_udp_config *res = parsed_result;
8499 struct rte_eth_udp_tunnel tunnel_udp;
8502 tunnel_udp.udp_port = res->udp_port;
8504 if (!strcmp(res->cmd, "rx_vxlan_port"))
8505 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8507 if (!strcmp(res->what, "add"))
8508 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8511 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8515 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8518 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8519 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8520 cmd, "rx_vxlan_port");
8521 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8522 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8524 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8525 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8527 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8528 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8531 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8532 .f = cmd_tunnel_udp_config_parsed,
8534 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8535 "Add/Remove a tunneling UDP port filter",
8537 (void *)&cmd_tunnel_udp_config_cmd,
8538 (void *)&cmd_tunnel_udp_config_what,
8539 (void *)&cmd_tunnel_udp_config_udp_port,
8540 (void *)&cmd_tunnel_udp_config_port_id,
8545 /* *** GLOBAL CONFIG *** */
8546 struct cmd_global_config_result {
8547 cmdline_fixed_string_t cmd;
8549 cmdline_fixed_string_t cfg_type;
8554 cmd_global_config_parsed(void *parsed_result,
8555 __attribute__((unused)) struct cmdline *cl,
8556 __attribute__((unused)) void *data)
8558 struct cmd_global_config_result *res = parsed_result;
8559 struct rte_eth_global_cfg conf;
8562 memset(&conf, 0, sizeof(conf));
8563 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8564 conf.cfg.gre_key_len = res->len;
8565 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8566 RTE_ETH_FILTER_SET, &conf);
8568 printf("Global config error\n");
8571 cmdline_parse_token_string_t cmd_global_config_cmd =
8572 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8574 cmdline_parse_token_num_t cmd_global_config_port_id =
8575 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8577 cmdline_parse_token_string_t cmd_global_config_type =
8578 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8579 cfg_type, "gre-key-len");
8580 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8581 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8584 cmdline_parse_inst_t cmd_global_config = {
8585 .f = cmd_global_config_parsed,
8586 .data = (void *)NULL,
8587 .help_str = "global_config <port_id> gre-key-len <key_len>",
8589 (void *)&cmd_global_config_cmd,
8590 (void *)&cmd_global_config_port_id,
8591 (void *)&cmd_global_config_type,
8592 (void *)&cmd_global_config_gre_key_len,
8597 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8598 struct cmd_set_mirror_mask_result {
8599 cmdline_fixed_string_t set;
8600 cmdline_fixed_string_t port;
8602 cmdline_fixed_string_t mirror;
8604 cmdline_fixed_string_t what;
8605 cmdline_fixed_string_t value;
8606 cmdline_fixed_string_t dstpool;
8608 cmdline_fixed_string_t on;
8611 cmdline_parse_token_string_t cmd_mirror_mask_set =
8612 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8614 cmdline_parse_token_string_t cmd_mirror_mask_port =
8615 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8617 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8618 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8620 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8621 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8622 mirror, "mirror-rule");
8623 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8624 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8626 cmdline_parse_token_string_t cmd_mirror_mask_what =
8627 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8628 what, "pool-mirror-up#pool-mirror-down"
8630 cmdline_parse_token_string_t cmd_mirror_mask_value =
8631 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8633 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8634 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8635 dstpool, "dst-pool");
8636 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8637 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8639 cmdline_parse_token_string_t cmd_mirror_mask_on =
8640 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8644 cmd_set_mirror_mask_parsed(void *parsed_result,
8645 __attribute__((unused)) struct cmdline *cl,
8646 __attribute__((unused)) void *data)
8649 struct cmd_set_mirror_mask_result *res = parsed_result;
8650 struct rte_eth_mirror_conf mr_conf;
8652 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8654 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8656 mr_conf.dst_pool = res->dstpool_id;
8658 if (!strcmp(res->what, "pool-mirror-up")) {
8659 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8660 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8661 } else if (!strcmp(res->what, "pool-mirror-down")) {
8662 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8663 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8664 } else if (!strcmp(res->what, "vlan-mirror")) {
8665 mr_conf.rule_type = ETH_MIRROR_VLAN;
8666 nb_item = parse_item_list(res->value, "vlan",
8667 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8671 for (i = 0; i < nb_item; i++) {
8672 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8673 printf("Invalid vlan_id: must be < 4096\n");
8677 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8678 mr_conf.vlan.vlan_mask |= 1ULL << i;
8682 if (!strcmp(res->on, "on"))
8683 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8686 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8689 printf("mirror rule add error: (%s)\n", strerror(-ret));
8692 cmdline_parse_inst_t cmd_set_mirror_mask = {
8693 .f = cmd_set_mirror_mask_parsed,
8695 .help_str = "set port <port_id> mirror-rule <rule_id> "
8696 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8697 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8699 (void *)&cmd_mirror_mask_set,
8700 (void *)&cmd_mirror_mask_port,
8701 (void *)&cmd_mirror_mask_portid,
8702 (void *)&cmd_mirror_mask_mirror,
8703 (void *)&cmd_mirror_mask_ruleid,
8704 (void *)&cmd_mirror_mask_what,
8705 (void *)&cmd_mirror_mask_value,
8706 (void *)&cmd_mirror_mask_dstpool,
8707 (void *)&cmd_mirror_mask_poolid,
8708 (void *)&cmd_mirror_mask_on,
8713 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8714 struct cmd_set_mirror_link_result {
8715 cmdline_fixed_string_t set;
8716 cmdline_fixed_string_t port;
8718 cmdline_fixed_string_t mirror;
8720 cmdline_fixed_string_t what;
8721 cmdline_fixed_string_t dstpool;
8723 cmdline_fixed_string_t on;
8726 cmdline_parse_token_string_t cmd_mirror_link_set =
8727 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8729 cmdline_parse_token_string_t cmd_mirror_link_port =
8730 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8732 cmdline_parse_token_num_t cmd_mirror_link_portid =
8733 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8735 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8736 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8737 mirror, "mirror-rule");
8738 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8739 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8741 cmdline_parse_token_string_t cmd_mirror_link_what =
8742 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8743 what, "uplink-mirror#downlink-mirror");
8744 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8745 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8746 dstpool, "dst-pool");
8747 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8748 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8750 cmdline_parse_token_string_t cmd_mirror_link_on =
8751 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8755 cmd_set_mirror_link_parsed(void *parsed_result,
8756 __attribute__((unused)) struct cmdline *cl,
8757 __attribute__((unused)) void *data)
8760 struct cmd_set_mirror_link_result *res = parsed_result;
8761 struct rte_eth_mirror_conf mr_conf;
8763 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8764 if (!strcmp(res->what, "uplink-mirror"))
8765 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8767 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8769 mr_conf.dst_pool = res->dstpool_id;
8771 if (!strcmp(res->on, "on"))
8772 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8775 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8778 /* check the return value and print it if is < 0 */
8780 printf("mirror rule add error: (%s)\n", strerror(-ret));
8784 cmdline_parse_inst_t cmd_set_mirror_link = {
8785 .f = cmd_set_mirror_link_parsed,
8787 .help_str = "set port <port_id> mirror-rule <rule_id> "
8788 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8790 (void *)&cmd_mirror_link_set,
8791 (void *)&cmd_mirror_link_port,
8792 (void *)&cmd_mirror_link_portid,
8793 (void *)&cmd_mirror_link_mirror,
8794 (void *)&cmd_mirror_link_ruleid,
8795 (void *)&cmd_mirror_link_what,
8796 (void *)&cmd_mirror_link_dstpool,
8797 (void *)&cmd_mirror_link_poolid,
8798 (void *)&cmd_mirror_link_on,
8803 /* *** RESET VM MIRROR RULE *** */
8804 struct cmd_rm_mirror_rule_result {
8805 cmdline_fixed_string_t reset;
8806 cmdline_fixed_string_t port;
8808 cmdline_fixed_string_t mirror;
8812 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8813 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8815 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8816 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8818 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8819 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8821 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8822 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8823 mirror, "mirror-rule");
8824 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8825 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8829 cmd_reset_mirror_rule_parsed(void *parsed_result,
8830 __attribute__((unused)) struct cmdline *cl,
8831 __attribute__((unused)) void *data)
8834 struct cmd_set_mirror_link_result *res = parsed_result;
8836 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8838 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8841 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8842 .f = cmd_reset_mirror_rule_parsed,
8844 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8846 (void *)&cmd_rm_mirror_rule_reset,
8847 (void *)&cmd_rm_mirror_rule_port,
8848 (void *)&cmd_rm_mirror_rule_portid,
8849 (void *)&cmd_rm_mirror_rule_mirror,
8850 (void *)&cmd_rm_mirror_rule_ruleid,
8855 /* ******************************************************************************** */
8857 struct cmd_dump_result {
8858 cmdline_fixed_string_t dump;
8862 dump_struct_sizes(void)
8864 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8865 DUMP_SIZE(struct rte_mbuf);
8866 DUMP_SIZE(struct rte_mempool);
8867 DUMP_SIZE(struct rte_ring);
8871 static void cmd_dump_parsed(void *parsed_result,
8872 __attribute__((unused)) struct cmdline *cl,
8873 __attribute__((unused)) void *data)
8875 struct cmd_dump_result *res = parsed_result;
8877 if (!strcmp(res->dump, "dump_physmem"))
8878 rte_dump_physmem_layout(stdout);
8879 else if (!strcmp(res->dump, "dump_memzone"))
8880 rte_memzone_dump(stdout);
8881 else if (!strcmp(res->dump, "dump_struct_sizes"))
8882 dump_struct_sizes();
8883 else if (!strcmp(res->dump, "dump_ring"))
8884 rte_ring_list_dump(stdout);
8885 else if (!strcmp(res->dump, "dump_mempool"))
8886 rte_mempool_list_dump(stdout);
8887 else if (!strcmp(res->dump, "dump_devargs"))
8888 rte_devargs_dump(stdout);
8889 else if (!strcmp(res->dump, "dump_log_types"))
8890 rte_log_dump(stdout);
8893 cmdline_parse_token_string_t cmd_dump_dump =
8894 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8897 "dump_struct_sizes#"
8903 cmdline_parse_inst_t cmd_dump = {
8904 .f = cmd_dump_parsed, /* function to call */
8905 .data = NULL, /* 2nd arg of func */
8906 .help_str = "Dump status",
8907 .tokens = { /* token list, NULL terminated */
8908 (void *)&cmd_dump_dump,
8913 /* ******************************************************************************** */
8915 struct cmd_dump_one_result {
8916 cmdline_fixed_string_t dump;
8917 cmdline_fixed_string_t name;
8920 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8921 __attribute__((unused)) void *data)
8923 struct cmd_dump_one_result *res = parsed_result;
8925 if (!strcmp(res->dump, "dump_ring")) {
8927 r = rte_ring_lookup(res->name);
8929 cmdline_printf(cl, "Cannot find ring\n");
8932 rte_ring_dump(stdout, r);
8933 } else if (!strcmp(res->dump, "dump_mempool")) {
8934 struct rte_mempool *mp;
8935 mp = rte_mempool_lookup(res->name);
8937 cmdline_printf(cl, "Cannot find mempool\n");
8940 rte_mempool_dump(stdout, mp);
8944 cmdline_parse_token_string_t cmd_dump_one_dump =
8945 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8946 "dump_ring#dump_mempool");
8948 cmdline_parse_token_string_t cmd_dump_one_name =
8949 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8951 cmdline_parse_inst_t cmd_dump_one = {
8952 .f = cmd_dump_one_parsed, /* function to call */
8953 .data = NULL, /* 2nd arg of func */
8954 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8955 .tokens = { /* token list, NULL terminated */
8956 (void *)&cmd_dump_one_dump,
8957 (void *)&cmd_dump_one_name,
8962 /* *** Add/Del syn filter *** */
8963 struct cmd_syn_filter_result {
8964 cmdline_fixed_string_t filter;
8966 cmdline_fixed_string_t ops;
8967 cmdline_fixed_string_t priority;
8968 cmdline_fixed_string_t high;
8969 cmdline_fixed_string_t queue;
8974 cmd_syn_filter_parsed(void *parsed_result,
8975 __attribute__((unused)) struct cmdline *cl,
8976 __attribute__((unused)) void *data)
8978 struct cmd_syn_filter_result *res = parsed_result;
8979 struct rte_eth_syn_filter syn_filter;
8982 ret = rte_eth_dev_filter_supported(res->port_id,
8983 RTE_ETH_FILTER_SYN);
8985 printf("syn filter is not supported on port %u.\n",
8990 memset(&syn_filter, 0, sizeof(syn_filter));
8992 if (!strcmp(res->ops, "add")) {
8993 if (!strcmp(res->high, "high"))
8994 syn_filter.hig_pri = 1;
8996 syn_filter.hig_pri = 0;
8998 syn_filter.queue = res->queue_id;
8999 ret = rte_eth_dev_filter_ctrl(res->port_id,
9004 ret = rte_eth_dev_filter_ctrl(res->port_id,
9006 RTE_ETH_FILTER_DELETE,
9010 printf("syn filter programming error: (%s)\n",
9014 cmdline_parse_token_string_t cmd_syn_filter_filter =
9015 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9016 filter, "syn_filter");
9017 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9018 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9020 cmdline_parse_token_string_t cmd_syn_filter_ops =
9021 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9023 cmdline_parse_token_string_t cmd_syn_filter_priority =
9024 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9025 priority, "priority");
9026 cmdline_parse_token_string_t cmd_syn_filter_high =
9027 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9029 cmdline_parse_token_string_t cmd_syn_filter_queue =
9030 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9032 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9033 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9036 cmdline_parse_inst_t cmd_syn_filter = {
9037 .f = cmd_syn_filter_parsed,
9039 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9040 "<queue_id>: Add/Delete syn filter",
9042 (void *)&cmd_syn_filter_filter,
9043 (void *)&cmd_syn_filter_port_id,
9044 (void *)&cmd_syn_filter_ops,
9045 (void *)&cmd_syn_filter_priority,
9046 (void *)&cmd_syn_filter_high,
9047 (void *)&cmd_syn_filter_queue,
9048 (void *)&cmd_syn_filter_queue_id,
9053 /* *** queue region set *** */
9054 struct cmd_queue_region_result {
9055 cmdline_fixed_string_t set;
9056 cmdline_fixed_string_t port;
9058 cmdline_fixed_string_t cmd;
9059 cmdline_fixed_string_t region;
9061 cmdline_fixed_string_t queue_start_index;
9063 cmdline_fixed_string_t queue_num;
9064 uint8_t queue_num_value;
9068 cmd_queue_region_parsed(void *parsed_result,
9069 __attribute__((unused)) struct cmdline *cl,
9070 __attribute__((unused)) void *data)
9072 struct cmd_queue_region_result *res = parsed_result;
9074 #ifdef RTE_LIBRTE_I40E_PMD
9075 struct rte_pmd_i40e_queue_region_conf region_conf;
9076 enum rte_pmd_i40e_queue_region_op op_type;
9079 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9082 #ifdef RTE_LIBRTE_I40E_PMD
9083 memset(®ion_conf, 0, sizeof(region_conf));
9084 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9085 region_conf.region_id = res->region_id;
9086 region_conf.queue_num = res->queue_num_value;
9087 region_conf.queue_start_index = res->queue_id;
9089 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9090 op_type, ®ion_conf);
9097 printf("function not implemented or supported\n");
9100 printf("queue region config error: (%s)\n", strerror(-ret));
9104 cmdline_parse_token_string_t cmd_queue_region_set =
9105 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9107 cmdline_parse_token_string_t cmd_queue_region_port =
9108 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9109 cmdline_parse_token_num_t cmd_queue_region_port_id =
9110 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9112 cmdline_parse_token_string_t cmd_queue_region_cmd =
9113 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9114 cmd, "queue-region");
9115 cmdline_parse_token_string_t cmd_queue_region_id =
9116 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9117 region, "region_id");
9118 cmdline_parse_token_num_t cmd_queue_region_index =
9119 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9121 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9122 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9123 queue_start_index, "queue_start_index");
9124 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9125 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9127 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9128 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9129 queue_num, "queue_num");
9130 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9131 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9132 queue_num_value, UINT8);
9134 cmdline_parse_inst_t cmd_queue_region = {
9135 .f = cmd_queue_region_parsed,
9137 .help_str = "set port <port_id> queue-region region_id <value> "
9138 "queue_start_index <value> queue_num <value>: Set a queue region",
9140 (void *)&cmd_queue_region_set,
9141 (void *)&cmd_queue_region_port,
9142 (void *)&cmd_queue_region_port_id,
9143 (void *)&cmd_queue_region_cmd,
9144 (void *)&cmd_queue_region_id,
9145 (void *)&cmd_queue_region_index,
9146 (void *)&cmd_queue_region_queue_start_index,
9147 (void *)&cmd_queue_region_queue_id,
9148 (void *)&cmd_queue_region_queue_num,
9149 (void *)&cmd_queue_region_queue_num_value,
9154 /* *** queue region and flowtype set *** */
9155 struct cmd_region_flowtype_result {
9156 cmdline_fixed_string_t set;
9157 cmdline_fixed_string_t port;
9159 cmdline_fixed_string_t cmd;
9160 cmdline_fixed_string_t region;
9162 cmdline_fixed_string_t flowtype;
9163 uint8_t flowtype_id;
9167 cmd_region_flowtype_parsed(void *parsed_result,
9168 __attribute__((unused)) struct cmdline *cl,
9169 __attribute__((unused)) void *data)
9171 struct cmd_region_flowtype_result *res = parsed_result;
9173 #ifdef RTE_LIBRTE_I40E_PMD
9174 struct rte_pmd_i40e_queue_region_conf region_conf;
9175 enum rte_pmd_i40e_queue_region_op op_type;
9178 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9181 #ifdef RTE_LIBRTE_I40E_PMD
9182 memset(®ion_conf, 0, sizeof(region_conf));
9184 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9185 region_conf.region_id = res->region_id;
9186 region_conf.hw_flowtype = res->flowtype_id;
9188 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9189 op_type, ®ion_conf);
9196 printf("function not implemented or supported\n");
9199 printf("region flowtype config error: (%s)\n", strerror(-ret));
9203 cmdline_parse_token_string_t cmd_region_flowtype_set =
9204 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9206 cmdline_parse_token_string_t cmd_region_flowtype_port =
9207 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9209 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9210 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9212 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9213 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9214 cmd, "queue-region");
9215 cmdline_parse_token_string_t cmd_region_flowtype_index =
9216 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9217 region, "region_id");
9218 cmdline_parse_token_num_t cmd_region_flowtype_id =
9219 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9221 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9222 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9223 flowtype, "flowtype");
9224 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9225 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9226 flowtype_id, UINT8);
9227 cmdline_parse_inst_t cmd_region_flowtype = {
9228 .f = cmd_region_flowtype_parsed,
9230 .help_str = "set port <port_id> queue-region region_id <value> "
9231 "flowtype <value>: Set a flowtype region index",
9233 (void *)&cmd_region_flowtype_set,
9234 (void *)&cmd_region_flowtype_port,
9235 (void *)&cmd_region_flowtype_port_index,
9236 (void *)&cmd_region_flowtype_cmd,
9237 (void *)&cmd_region_flowtype_index,
9238 (void *)&cmd_region_flowtype_id,
9239 (void *)&cmd_region_flowtype_flow_index,
9240 (void *)&cmd_region_flowtype_flow_id,
9245 /* *** User Priority (UP) to queue region (region_id) set *** */
9246 struct cmd_user_priority_region_result {
9247 cmdline_fixed_string_t set;
9248 cmdline_fixed_string_t port;
9250 cmdline_fixed_string_t cmd;
9251 cmdline_fixed_string_t user_priority;
9252 uint8_t user_priority_id;
9253 cmdline_fixed_string_t region;
9258 cmd_user_priority_region_parsed(void *parsed_result,
9259 __attribute__((unused)) struct cmdline *cl,
9260 __attribute__((unused)) void *data)
9262 struct cmd_user_priority_region_result *res = parsed_result;
9264 #ifdef RTE_LIBRTE_I40E_PMD
9265 struct rte_pmd_i40e_queue_region_conf region_conf;
9266 enum rte_pmd_i40e_queue_region_op op_type;
9269 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9272 #ifdef RTE_LIBRTE_I40E_PMD
9273 memset(®ion_conf, 0, sizeof(region_conf));
9274 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9275 region_conf.user_priority = res->user_priority_id;
9276 region_conf.region_id = res->region_id;
9278 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9279 op_type, ®ion_conf);
9286 printf("function not implemented or supported\n");
9289 printf("user_priority region config error: (%s)\n",
9294 cmdline_parse_token_string_t cmd_user_priority_region_set =
9295 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9297 cmdline_parse_token_string_t cmd_user_priority_region_port =
9298 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9300 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9301 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9303 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9304 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9305 cmd, "queue-region");
9306 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9307 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9308 user_priority, "UP");
9309 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9310 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9311 user_priority_id, UINT8);
9312 cmdline_parse_token_string_t cmd_user_priority_region_region =
9313 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9314 region, "region_id");
9315 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9316 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9319 cmdline_parse_inst_t cmd_user_priority_region = {
9320 .f = cmd_user_priority_region_parsed,
9322 .help_str = "set port <port_id> queue-region UP <value> "
9323 "region_id <value>: Set the mapping of User Priority (UP) "
9324 "to queue region (region_id) ",
9326 (void *)&cmd_user_priority_region_set,
9327 (void *)&cmd_user_priority_region_port,
9328 (void *)&cmd_user_priority_region_port_index,
9329 (void *)&cmd_user_priority_region_cmd,
9330 (void *)&cmd_user_priority_region_UP,
9331 (void *)&cmd_user_priority_region_UP_id,
9332 (void *)&cmd_user_priority_region_region,
9333 (void *)&cmd_user_priority_region_region_id,
9338 /* *** flush all queue region related configuration *** */
9339 struct cmd_flush_queue_region_result {
9340 cmdline_fixed_string_t set;
9341 cmdline_fixed_string_t port;
9343 cmdline_fixed_string_t cmd;
9344 cmdline_fixed_string_t flush;
9345 cmdline_fixed_string_t what;
9349 cmd_flush_queue_region_parsed(void *parsed_result,
9350 __attribute__((unused)) struct cmdline *cl,
9351 __attribute__((unused)) void *data)
9353 struct cmd_flush_queue_region_result *res = parsed_result;
9355 #ifdef RTE_LIBRTE_I40E_PMD
9356 struct rte_pmd_i40e_queue_region_conf region_conf;
9357 enum rte_pmd_i40e_queue_region_op op_type;
9360 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9363 #ifdef RTE_LIBRTE_I40E_PMD
9364 memset(®ion_conf, 0, sizeof(region_conf));
9366 if (strcmp(res->what, "on") == 0)
9367 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9369 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9371 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9372 op_type, ®ion_conf);
9379 printf("function not implemented or supported\n");
9382 printf("queue region config flush error: (%s)\n",
9387 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9388 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9390 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9391 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9393 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9394 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9396 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9397 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9398 cmd, "queue-region");
9399 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9400 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9402 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9403 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9406 cmdline_parse_inst_t cmd_flush_queue_region = {
9407 .f = cmd_flush_queue_region_parsed,
9409 .help_str = "set port <port_id> queue-region flush on|off"
9410 ": flush all queue region related configuration",
9412 (void *)&cmd_flush_queue_region_set,
9413 (void *)&cmd_flush_queue_region_port,
9414 (void *)&cmd_flush_queue_region_port_index,
9415 (void *)&cmd_flush_queue_region_cmd,
9416 (void *)&cmd_flush_queue_region_flush,
9417 (void *)&cmd_flush_queue_region_what,
9422 /* *** get all queue region related configuration info *** */
9423 struct cmd_show_queue_region_info {
9424 cmdline_fixed_string_t show;
9425 cmdline_fixed_string_t port;
9427 cmdline_fixed_string_t cmd;
9431 cmd_show_queue_region_info_parsed(void *parsed_result,
9432 __attribute__((unused)) struct cmdline *cl,
9433 __attribute__((unused)) void *data)
9435 struct cmd_show_queue_region_info *res = parsed_result;
9437 #ifdef RTE_LIBRTE_I40E_PMD
9438 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9439 enum rte_pmd_i40e_queue_region_op op_type;
9442 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9445 #ifdef RTE_LIBRTE_I40E_PMD
9446 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9448 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9450 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9451 op_type, &rte_pmd_regions);
9453 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9460 printf("function not implemented or supported\n");
9463 printf("queue region config info show error: (%s)\n",
9468 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9469 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9471 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9472 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9474 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9475 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9477 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9478 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9479 cmd, "queue-region");
9481 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9482 .f = cmd_show_queue_region_info_parsed,
9484 .help_str = "show port <port_id> queue-region"
9485 ": show all queue region related configuration info",
9487 (void *)&cmd_show_queue_region_info_get,
9488 (void *)&cmd_show_queue_region_info_port,
9489 (void *)&cmd_show_queue_region_info_port_index,
9490 (void *)&cmd_show_queue_region_info_cmd,
9495 /* *** ADD/REMOVE A 2tuple FILTER *** */
9496 struct cmd_2tuple_filter_result {
9497 cmdline_fixed_string_t filter;
9499 cmdline_fixed_string_t ops;
9500 cmdline_fixed_string_t dst_port;
9501 uint16_t dst_port_value;
9502 cmdline_fixed_string_t protocol;
9503 uint8_t protocol_value;
9504 cmdline_fixed_string_t mask;
9506 cmdline_fixed_string_t tcp_flags;
9507 uint8_t tcp_flags_value;
9508 cmdline_fixed_string_t priority;
9509 uint8_t priority_value;
9510 cmdline_fixed_string_t queue;
9515 cmd_2tuple_filter_parsed(void *parsed_result,
9516 __attribute__((unused)) struct cmdline *cl,
9517 __attribute__((unused)) void *data)
9519 struct rte_eth_ntuple_filter filter;
9520 struct cmd_2tuple_filter_result *res = parsed_result;
9523 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9525 printf("ntuple filter is not supported on port %u.\n",
9530 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9532 filter.flags = RTE_2TUPLE_FLAGS;
9533 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9534 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9535 filter.proto = res->protocol_value;
9536 filter.priority = res->priority_value;
9537 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9538 printf("nonzero tcp_flags is only meaningful"
9539 " when protocol is TCP.\n");
9542 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9543 printf("invalid TCP flags.\n");
9547 if (res->tcp_flags_value != 0) {
9548 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9549 filter.tcp_flags = res->tcp_flags_value;
9552 /* need convert to big endian. */
9553 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9554 filter.queue = res->queue_id;
9556 if (!strcmp(res->ops, "add"))
9557 ret = rte_eth_dev_filter_ctrl(res->port_id,
9558 RTE_ETH_FILTER_NTUPLE,
9562 ret = rte_eth_dev_filter_ctrl(res->port_id,
9563 RTE_ETH_FILTER_NTUPLE,
9564 RTE_ETH_FILTER_DELETE,
9567 printf("2tuple filter programming error: (%s)\n",
9572 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9573 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9574 filter, "2tuple_filter");
9575 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9576 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9578 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9579 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9581 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9582 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9583 dst_port, "dst_port");
9584 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9585 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9586 dst_port_value, UINT16);
9587 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9588 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9589 protocol, "protocol");
9590 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9591 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9592 protocol_value, UINT8);
9593 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9594 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9596 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9597 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9599 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9600 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9601 tcp_flags, "tcp_flags");
9602 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9603 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9604 tcp_flags_value, UINT8);
9605 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9606 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9607 priority, "priority");
9608 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9609 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9610 priority_value, UINT8);
9611 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9612 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9614 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9615 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9618 cmdline_parse_inst_t cmd_2tuple_filter = {
9619 .f = cmd_2tuple_filter_parsed,
9621 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9622 "<value> mask <value> tcp_flags <value> priority <value> queue "
9623 "<queue_id>: Add a 2tuple filter",
9625 (void *)&cmd_2tuple_filter_filter,
9626 (void *)&cmd_2tuple_filter_port_id,
9627 (void *)&cmd_2tuple_filter_ops,
9628 (void *)&cmd_2tuple_filter_dst_port,
9629 (void *)&cmd_2tuple_filter_dst_port_value,
9630 (void *)&cmd_2tuple_filter_protocol,
9631 (void *)&cmd_2tuple_filter_protocol_value,
9632 (void *)&cmd_2tuple_filter_mask,
9633 (void *)&cmd_2tuple_filter_mask_value,
9634 (void *)&cmd_2tuple_filter_tcp_flags,
9635 (void *)&cmd_2tuple_filter_tcp_flags_value,
9636 (void *)&cmd_2tuple_filter_priority,
9637 (void *)&cmd_2tuple_filter_priority_value,
9638 (void *)&cmd_2tuple_filter_queue,
9639 (void *)&cmd_2tuple_filter_queue_id,
9644 /* *** ADD/REMOVE A 5tuple FILTER *** */
9645 struct cmd_5tuple_filter_result {
9646 cmdline_fixed_string_t filter;
9648 cmdline_fixed_string_t ops;
9649 cmdline_fixed_string_t dst_ip;
9650 cmdline_ipaddr_t dst_ip_value;
9651 cmdline_fixed_string_t src_ip;
9652 cmdline_ipaddr_t src_ip_value;
9653 cmdline_fixed_string_t dst_port;
9654 uint16_t dst_port_value;
9655 cmdline_fixed_string_t src_port;
9656 uint16_t src_port_value;
9657 cmdline_fixed_string_t protocol;
9658 uint8_t protocol_value;
9659 cmdline_fixed_string_t mask;
9661 cmdline_fixed_string_t tcp_flags;
9662 uint8_t tcp_flags_value;
9663 cmdline_fixed_string_t priority;
9664 uint8_t priority_value;
9665 cmdline_fixed_string_t queue;
9670 cmd_5tuple_filter_parsed(void *parsed_result,
9671 __attribute__((unused)) struct cmdline *cl,
9672 __attribute__((unused)) void *data)
9674 struct rte_eth_ntuple_filter filter;
9675 struct cmd_5tuple_filter_result *res = parsed_result;
9678 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9680 printf("ntuple filter is not supported on port %u.\n",
9685 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9687 filter.flags = RTE_5TUPLE_FLAGS;
9688 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9689 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9690 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9691 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9692 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9693 filter.proto = res->protocol_value;
9694 filter.priority = res->priority_value;
9695 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9696 printf("nonzero tcp_flags is only meaningful"
9697 " when protocol is TCP.\n");
9700 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9701 printf("invalid TCP flags.\n");
9705 if (res->tcp_flags_value != 0) {
9706 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9707 filter.tcp_flags = res->tcp_flags_value;
9710 if (res->dst_ip_value.family == AF_INET)
9711 /* no need to convert, already big endian. */
9712 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9714 if (filter.dst_ip_mask == 0) {
9715 printf("can not support ipv6 involved compare.\n");
9721 if (res->src_ip_value.family == AF_INET)
9722 /* no need to convert, already big endian. */
9723 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9725 if (filter.src_ip_mask == 0) {
9726 printf("can not support ipv6 involved compare.\n");
9731 /* need convert to big endian. */
9732 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9733 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9734 filter.queue = res->queue_id;
9736 if (!strcmp(res->ops, "add"))
9737 ret = rte_eth_dev_filter_ctrl(res->port_id,
9738 RTE_ETH_FILTER_NTUPLE,
9742 ret = rte_eth_dev_filter_ctrl(res->port_id,
9743 RTE_ETH_FILTER_NTUPLE,
9744 RTE_ETH_FILTER_DELETE,
9747 printf("5tuple filter programming error: (%s)\n",
9751 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9752 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9753 filter, "5tuple_filter");
9754 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9755 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9757 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9758 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9760 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9761 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9763 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9764 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9766 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9767 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9769 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9770 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9772 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9773 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9774 dst_port, "dst_port");
9775 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9776 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9777 dst_port_value, UINT16);
9778 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9779 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9780 src_port, "src_port");
9781 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9782 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9783 src_port_value, UINT16);
9784 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9785 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9786 protocol, "protocol");
9787 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9788 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9789 protocol_value, UINT8);
9790 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9791 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9793 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9794 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9796 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9797 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9798 tcp_flags, "tcp_flags");
9799 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9800 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9801 tcp_flags_value, UINT8);
9802 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9803 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9804 priority, "priority");
9805 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9806 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9807 priority_value, UINT8);
9808 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9809 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9811 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9812 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9815 cmdline_parse_inst_t cmd_5tuple_filter = {
9816 .f = cmd_5tuple_filter_parsed,
9818 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9819 "src_ip <value> dst_port <value> src_port <value> "
9820 "protocol <value> mask <value> tcp_flags <value> "
9821 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9823 (void *)&cmd_5tuple_filter_filter,
9824 (void *)&cmd_5tuple_filter_port_id,
9825 (void *)&cmd_5tuple_filter_ops,
9826 (void *)&cmd_5tuple_filter_dst_ip,
9827 (void *)&cmd_5tuple_filter_dst_ip_value,
9828 (void *)&cmd_5tuple_filter_src_ip,
9829 (void *)&cmd_5tuple_filter_src_ip_value,
9830 (void *)&cmd_5tuple_filter_dst_port,
9831 (void *)&cmd_5tuple_filter_dst_port_value,
9832 (void *)&cmd_5tuple_filter_src_port,
9833 (void *)&cmd_5tuple_filter_src_port_value,
9834 (void *)&cmd_5tuple_filter_protocol,
9835 (void *)&cmd_5tuple_filter_protocol_value,
9836 (void *)&cmd_5tuple_filter_mask,
9837 (void *)&cmd_5tuple_filter_mask_value,
9838 (void *)&cmd_5tuple_filter_tcp_flags,
9839 (void *)&cmd_5tuple_filter_tcp_flags_value,
9840 (void *)&cmd_5tuple_filter_priority,
9841 (void *)&cmd_5tuple_filter_priority_value,
9842 (void *)&cmd_5tuple_filter_queue,
9843 (void *)&cmd_5tuple_filter_queue_id,
9848 /* *** ADD/REMOVE A flex FILTER *** */
9849 struct cmd_flex_filter_result {
9850 cmdline_fixed_string_t filter;
9851 cmdline_fixed_string_t ops;
9853 cmdline_fixed_string_t len;
9855 cmdline_fixed_string_t bytes;
9856 cmdline_fixed_string_t bytes_value;
9857 cmdline_fixed_string_t mask;
9858 cmdline_fixed_string_t mask_value;
9859 cmdline_fixed_string_t priority;
9860 uint8_t priority_value;
9861 cmdline_fixed_string_t queue;
9865 static int xdigit2val(unsigned char c)
9870 else if (isupper(c))
9878 cmd_flex_filter_parsed(void *parsed_result,
9879 __attribute__((unused)) struct cmdline *cl,
9880 __attribute__((unused)) void *data)
9883 struct rte_eth_flex_filter filter;
9884 struct cmd_flex_filter_result *res = parsed_result;
9885 char *bytes_ptr, *mask_ptr;
9886 uint16_t len, i, j = 0;
9891 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9892 printf("the len exceed the max length 128\n");
9895 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9896 filter.len = res->len_value;
9897 filter.priority = res->priority_value;
9898 filter.queue = res->queue_id;
9899 bytes_ptr = res->bytes_value;
9900 mask_ptr = res->mask_value;
9902 /* translate bytes string to array. */
9903 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9904 (bytes_ptr[1] == 'X')))
9906 len = strnlen(bytes_ptr, res->len_value * 2);
9907 if (len == 0 || (len % 8 != 0)) {
9908 printf("please check len and bytes input\n");
9911 for (i = 0; i < len; i++) {
9913 if (isxdigit(c) == 0) {
9914 /* invalid characters. */
9915 printf("invalid input\n");
9918 val = xdigit2val(c);
9921 filter.bytes[j] = byte;
9922 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9929 /* translate mask string to uint8_t array. */
9930 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9931 (mask_ptr[1] == 'X')))
9933 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9935 printf("invalid input\n");
9940 for (i = 0; i < len; i++) {
9942 if (isxdigit(c) == 0) {
9943 /* invalid characters. */
9944 printf("invalid input\n");
9947 val = xdigit2val(c);
9950 filter.mask[j] = byte;
9951 printf("mask[%d]:%02x ", j, filter.mask[j]);
9959 if (!strcmp(res->ops, "add"))
9960 ret = rte_eth_dev_filter_ctrl(res->port_id,
9961 RTE_ETH_FILTER_FLEXIBLE,
9965 ret = rte_eth_dev_filter_ctrl(res->port_id,
9966 RTE_ETH_FILTER_FLEXIBLE,
9967 RTE_ETH_FILTER_DELETE,
9971 printf("flex filter setting error: (%s)\n", strerror(-ret));
9974 cmdline_parse_token_string_t cmd_flex_filter_filter =
9975 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9976 filter, "flex_filter");
9977 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9978 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9980 cmdline_parse_token_string_t cmd_flex_filter_ops =
9981 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9983 cmdline_parse_token_string_t cmd_flex_filter_len =
9984 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9986 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9987 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9989 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9990 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9992 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9993 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9995 cmdline_parse_token_string_t cmd_flex_filter_mask =
9996 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9998 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9999 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10001 cmdline_parse_token_string_t cmd_flex_filter_priority =
10002 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10003 priority, "priority");
10004 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10005 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10006 priority_value, UINT8);
10007 cmdline_parse_token_string_t cmd_flex_filter_queue =
10008 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10010 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10011 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10013 cmdline_parse_inst_t cmd_flex_filter = {
10014 .f = cmd_flex_filter_parsed,
10016 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10017 "<value> mask <value> priority <value> queue <queue_id>: "
10018 "Add/Del a flex filter",
10020 (void *)&cmd_flex_filter_filter,
10021 (void *)&cmd_flex_filter_port_id,
10022 (void *)&cmd_flex_filter_ops,
10023 (void *)&cmd_flex_filter_len,
10024 (void *)&cmd_flex_filter_len_value,
10025 (void *)&cmd_flex_filter_bytes,
10026 (void *)&cmd_flex_filter_bytes_value,
10027 (void *)&cmd_flex_filter_mask,
10028 (void *)&cmd_flex_filter_mask_value,
10029 (void *)&cmd_flex_filter_priority,
10030 (void *)&cmd_flex_filter_priority_value,
10031 (void *)&cmd_flex_filter_queue,
10032 (void *)&cmd_flex_filter_queue_id,
10037 /* *** Filters Control *** */
10039 /* *** deal with ethertype filter *** */
10040 struct cmd_ethertype_filter_result {
10041 cmdline_fixed_string_t filter;
10043 cmdline_fixed_string_t ops;
10044 cmdline_fixed_string_t mac;
10045 struct ether_addr mac_addr;
10046 cmdline_fixed_string_t ethertype;
10047 uint16_t ethertype_value;
10048 cmdline_fixed_string_t drop;
10049 cmdline_fixed_string_t queue;
10053 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10054 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10055 filter, "ethertype_filter");
10056 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10057 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10059 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10060 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10062 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10063 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10064 mac, "mac_addr#mac_ignr");
10065 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10066 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10068 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10069 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10070 ethertype, "ethertype");
10071 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10072 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10073 ethertype_value, UINT16);
10074 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10075 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10077 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10078 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10080 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10081 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10085 cmd_ethertype_filter_parsed(void *parsed_result,
10086 __attribute__((unused)) struct cmdline *cl,
10087 __attribute__((unused)) void *data)
10089 struct cmd_ethertype_filter_result *res = parsed_result;
10090 struct rte_eth_ethertype_filter filter;
10093 ret = rte_eth_dev_filter_supported(res->port_id,
10094 RTE_ETH_FILTER_ETHERTYPE);
10096 printf("ethertype filter is not supported on port %u.\n",
10101 memset(&filter, 0, sizeof(filter));
10102 if (!strcmp(res->mac, "mac_addr")) {
10103 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10104 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10105 sizeof(struct ether_addr));
10107 if (!strcmp(res->drop, "drop"))
10108 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10109 filter.ether_type = res->ethertype_value;
10110 filter.queue = res->queue_id;
10112 if (!strcmp(res->ops, "add"))
10113 ret = rte_eth_dev_filter_ctrl(res->port_id,
10114 RTE_ETH_FILTER_ETHERTYPE,
10115 RTE_ETH_FILTER_ADD,
10118 ret = rte_eth_dev_filter_ctrl(res->port_id,
10119 RTE_ETH_FILTER_ETHERTYPE,
10120 RTE_ETH_FILTER_DELETE,
10123 printf("ethertype filter programming error: (%s)\n",
10127 cmdline_parse_inst_t cmd_ethertype_filter = {
10128 .f = cmd_ethertype_filter_parsed,
10130 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10131 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10132 "Add or delete an ethertype filter entry",
10134 (void *)&cmd_ethertype_filter_filter,
10135 (void *)&cmd_ethertype_filter_port_id,
10136 (void *)&cmd_ethertype_filter_ops,
10137 (void *)&cmd_ethertype_filter_mac,
10138 (void *)&cmd_ethertype_filter_mac_addr,
10139 (void *)&cmd_ethertype_filter_ethertype,
10140 (void *)&cmd_ethertype_filter_ethertype_value,
10141 (void *)&cmd_ethertype_filter_drop,
10142 (void *)&cmd_ethertype_filter_queue,
10143 (void *)&cmd_ethertype_filter_queue_id,
10148 /* *** deal with flow director filter *** */
10149 struct cmd_flow_director_result {
10150 cmdline_fixed_string_t flow_director_filter;
10152 cmdline_fixed_string_t mode;
10153 cmdline_fixed_string_t mode_value;
10154 cmdline_fixed_string_t ops;
10155 cmdline_fixed_string_t flow;
10156 cmdline_fixed_string_t flow_type;
10157 cmdline_fixed_string_t ether;
10158 uint16_t ether_type;
10159 cmdline_fixed_string_t src;
10160 cmdline_ipaddr_t ip_src;
10162 cmdline_fixed_string_t dst;
10163 cmdline_ipaddr_t ip_dst;
10165 cmdline_fixed_string_t verify_tag;
10166 uint32_t verify_tag_value;
10167 cmdline_fixed_string_t tos;
10169 cmdline_fixed_string_t proto;
10170 uint8_t proto_value;
10171 cmdline_fixed_string_t ttl;
10173 cmdline_fixed_string_t vlan;
10174 uint16_t vlan_value;
10175 cmdline_fixed_string_t flexbytes;
10176 cmdline_fixed_string_t flexbytes_value;
10177 cmdline_fixed_string_t pf_vf;
10178 cmdline_fixed_string_t drop;
10179 cmdline_fixed_string_t queue;
10181 cmdline_fixed_string_t fd_id;
10182 uint32_t fd_id_value;
10183 cmdline_fixed_string_t mac;
10184 struct ether_addr mac_addr;
10185 cmdline_fixed_string_t tunnel;
10186 cmdline_fixed_string_t tunnel_type;
10187 cmdline_fixed_string_t tunnel_id;
10188 uint32_t tunnel_id_value;
10189 cmdline_fixed_string_t packet;
10194 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10197 const char *p, *p0 = q_arg;
10199 unsigned long int_fld;
10200 char *str_fld[max_num];
10205 p = strchr(p0, '(');
10209 p0 = strchr(p, ')');
10214 if (size >= sizeof(s))
10217 snprintf(s, sizeof(s), "%.*s", size, p);
10218 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10219 if (ret < 0 || ret > max_num)
10221 for (i = 0; i < ret; i++) {
10223 int_fld = strtoul(str_fld[i], &end, 0);
10224 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10226 flexbytes[i] = (uint8_t)int_fld;
10232 str2flowtype(char *string)
10235 static const struct {
10238 } flowtype_str[] = {
10239 {"raw", RTE_ETH_FLOW_RAW},
10240 {"ipv4", RTE_ETH_FLOW_IPV4},
10241 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10242 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10243 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10244 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10245 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10246 {"ipv6", RTE_ETH_FLOW_IPV6},
10247 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10248 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10249 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10250 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10251 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10252 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10255 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10256 if (!strcmp(flowtype_str[i].str, string))
10257 return flowtype_str[i].type;
10260 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10261 return (uint16_t)atoi(string);
10263 return RTE_ETH_FLOW_UNKNOWN;
10266 static enum rte_eth_fdir_tunnel_type
10267 str2fdir_tunneltype(char *string)
10271 static const struct {
10273 enum rte_eth_fdir_tunnel_type type;
10274 } tunneltype_str[] = {
10275 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10276 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10279 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10280 if (!strcmp(tunneltype_str[i].str, string))
10281 return tunneltype_str[i].type;
10283 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10286 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10288 if ((ip_addr).family == AF_INET) \
10289 (ip) = (ip_addr).addr.ipv4.s_addr; \
10291 printf("invalid parameter.\n"); \
10296 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10298 if ((ip_addr).family == AF_INET6) \
10299 rte_memcpy(&(ip), \
10300 &((ip_addr).addr.ipv6), \
10301 sizeof(struct in6_addr)); \
10303 printf("invalid parameter.\n"); \
10309 cmd_flow_director_filter_parsed(void *parsed_result,
10310 __attribute__((unused)) struct cmdline *cl,
10311 __attribute__((unused)) void *data)
10313 struct cmd_flow_director_result *res = parsed_result;
10314 struct rte_eth_fdir_filter entry;
10315 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10317 unsigned long vf_id;
10320 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10322 printf("flow director is not supported on port %u.\n",
10326 memset(flexbytes, 0, sizeof(flexbytes));
10327 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10329 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10330 if (strcmp(res->mode_value, "MAC-VLAN")) {
10331 printf("Please set mode to MAC-VLAN.\n");
10334 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10335 if (strcmp(res->mode_value, "Tunnel")) {
10336 printf("Please set mode to Tunnel.\n");
10340 if (!strcmp(res->mode_value, "raw")) {
10341 #ifdef RTE_LIBRTE_I40E_PMD
10342 struct rte_pmd_i40e_flow_type_mapping
10343 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10344 struct rte_pmd_i40e_pkt_template_conf conf;
10345 uint16_t flow_type = str2flowtype(res->flow_type);
10346 uint16_t i, port = res->port_id;
10349 memset(&conf, 0, sizeof(conf));
10351 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10352 printf("Invalid flow type specified.\n");
10355 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10359 if (mapping[flow_type].pctype == 0ULL) {
10360 printf("Invalid flow type specified.\n");
10363 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10364 if (mapping[flow_type].pctype & (1ULL << i)) {
10365 conf.input.pctype = i;
10370 conf.input.packet = open_file(res->filepath,
10371 &conf.input.length);
10372 if (!conf.input.packet)
10374 if (!strcmp(res->drop, "drop"))
10375 conf.action.behavior =
10376 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10378 conf.action.behavior =
10379 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10380 conf.action.report_status =
10381 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10382 conf.action.rx_queue = res->queue_id;
10383 conf.soft_id = res->fd_id_value;
10384 add = strcmp(res->ops, "del") ? 1 : 0;
10385 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10389 printf("flow director config error: (%s)\n",
10391 close_file(conf.input.packet);
10394 } else if (strcmp(res->mode_value, "IP")) {
10395 printf("Please set mode to IP or raw.\n");
10398 entry.input.flow_type = str2flowtype(res->flow_type);
10401 ret = parse_flexbytes(res->flexbytes_value,
10403 RTE_ETH_FDIR_MAX_FLEXLEN);
10405 printf("error: Cannot parse flexbytes input.\n");
10409 switch (entry.input.flow_type) {
10410 case RTE_ETH_FLOW_FRAG_IPV4:
10411 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10412 entry.input.flow.ip4_flow.proto = res->proto_value;
10414 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10415 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10416 IPV4_ADDR_TO_UINT(res->ip_dst,
10417 entry.input.flow.ip4_flow.dst_ip);
10418 IPV4_ADDR_TO_UINT(res->ip_src,
10419 entry.input.flow.ip4_flow.src_ip);
10420 entry.input.flow.ip4_flow.tos = res->tos_value;
10421 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10422 /* need convert to big endian. */
10423 entry.input.flow.udp4_flow.dst_port =
10424 rte_cpu_to_be_16(res->port_dst);
10425 entry.input.flow.udp4_flow.src_port =
10426 rte_cpu_to_be_16(res->port_src);
10428 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10429 IPV4_ADDR_TO_UINT(res->ip_dst,
10430 entry.input.flow.sctp4_flow.ip.dst_ip);
10431 IPV4_ADDR_TO_UINT(res->ip_src,
10432 entry.input.flow.sctp4_flow.ip.src_ip);
10433 entry.input.flow.ip4_flow.tos = res->tos_value;
10434 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10435 /* need convert to big endian. */
10436 entry.input.flow.sctp4_flow.dst_port =
10437 rte_cpu_to_be_16(res->port_dst);
10438 entry.input.flow.sctp4_flow.src_port =
10439 rte_cpu_to_be_16(res->port_src);
10440 entry.input.flow.sctp4_flow.verify_tag =
10441 rte_cpu_to_be_32(res->verify_tag_value);
10443 case RTE_ETH_FLOW_FRAG_IPV6:
10444 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10445 entry.input.flow.ipv6_flow.proto = res->proto_value;
10447 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10448 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10449 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10450 entry.input.flow.ipv6_flow.dst_ip);
10451 IPV6_ADDR_TO_ARRAY(res->ip_src,
10452 entry.input.flow.ipv6_flow.src_ip);
10453 entry.input.flow.ipv6_flow.tc = res->tos_value;
10454 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10455 /* need convert to big endian. */
10456 entry.input.flow.udp6_flow.dst_port =
10457 rte_cpu_to_be_16(res->port_dst);
10458 entry.input.flow.udp6_flow.src_port =
10459 rte_cpu_to_be_16(res->port_src);
10461 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10462 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10463 entry.input.flow.sctp6_flow.ip.dst_ip);
10464 IPV6_ADDR_TO_ARRAY(res->ip_src,
10465 entry.input.flow.sctp6_flow.ip.src_ip);
10466 entry.input.flow.ipv6_flow.tc = res->tos_value;
10467 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10468 /* need convert to big endian. */
10469 entry.input.flow.sctp6_flow.dst_port =
10470 rte_cpu_to_be_16(res->port_dst);
10471 entry.input.flow.sctp6_flow.src_port =
10472 rte_cpu_to_be_16(res->port_src);
10473 entry.input.flow.sctp6_flow.verify_tag =
10474 rte_cpu_to_be_32(res->verify_tag_value);
10476 case RTE_ETH_FLOW_L2_PAYLOAD:
10477 entry.input.flow.l2_flow.ether_type =
10478 rte_cpu_to_be_16(res->ether_type);
10484 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10485 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10487 sizeof(struct ether_addr));
10489 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10490 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10492 sizeof(struct ether_addr));
10493 entry.input.flow.tunnel_flow.tunnel_type =
10494 str2fdir_tunneltype(res->tunnel_type);
10495 entry.input.flow.tunnel_flow.tunnel_id =
10496 rte_cpu_to_be_32(res->tunnel_id_value);
10499 rte_memcpy(entry.input.flow_ext.flexbytes,
10501 RTE_ETH_FDIR_MAX_FLEXLEN);
10503 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10505 entry.action.flex_off = 0; /*use 0 by default */
10506 if (!strcmp(res->drop, "drop"))
10507 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10509 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10511 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10512 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10513 if (!strcmp(res->pf_vf, "pf"))
10514 entry.input.flow_ext.is_vf = 0;
10515 else if (!strncmp(res->pf_vf, "vf", 2)) {
10516 struct rte_eth_dev_info dev_info;
10518 memset(&dev_info, 0, sizeof(dev_info));
10519 rte_eth_dev_info_get(res->port_id, &dev_info);
10521 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10522 if (errno != 0 || *end != '\0' ||
10523 vf_id >= dev_info.max_vfs) {
10524 printf("invalid parameter %s.\n", res->pf_vf);
10527 entry.input.flow_ext.is_vf = 1;
10528 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10530 printf("invalid parameter %s.\n", res->pf_vf);
10535 /* set to report FD ID by default */
10536 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10537 entry.action.rx_queue = res->queue_id;
10538 entry.soft_id = res->fd_id_value;
10539 if (!strcmp(res->ops, "add"))
10540 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10541 RTE_ETH_FILTER_ADD, &entry);
10542 else if (!strcmp(res->ops, "del"))
10543 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10544 RTE_ETH_FILTER_DELETE, &entry);
10546 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10547 RTE_ETH_FILTER_UPDATE, &entry);
10549 printf("flow director programming error: (%s)\n",
10553 cmdline_parse_token_string_t cmd_flow_director_filter =
10554 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10555 flow_director_filter, "flow_director_filter");
10556 cmdline_parse_token_num_t cmd_flow_director_port_id =
10557 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10559 cmdline_parse_token_string_t cmd_flow_director_ops =
10560 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10561 ops, "add#del#update");
10562 cmdline_parse_token_string_t cmd_flow_director_flow =
10563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10565 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10568 cmdline_parse_token_string_t cmd_flow_director_ether =
10569 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10571 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10572 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10573 ether_type, UINT16);
10574 cmdline_parse_token_string_t cmd_flow_director_src =
10575 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10577 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10578 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10580 cmdline_parse_token_num_t cmd_flow_director_port_src =
10581 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10583 cmdline_parse_token_string_t cmd_flow_director_dst =
10584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10586 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10587 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10589 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10590 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10592 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10593 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10594 verify_tag, "verify_tag");
10595 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10596 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10597 verify_tag_value, UINT32);
10598 cmdline_parse_token_string_t cmd_flow_director_tos =
10599 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10601 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10602 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10604 cmdline_parse_token_string_t cmd_flow_director_proto =
10605 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10607 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10608 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10609 proto_value, UINT8);
10610 cmdline_parse_token_string_t cmd_flow_director_ttl =
10611 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10613 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10614 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10616 cmdline_parse_token_string_t cmd_flow_director_vlan =
10617 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10619 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10620 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10621 vlan_value, UINT16);
10622 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10623 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10624 flexbytes, "flexbytes");
10625 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10626 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10627 flexbytes_value, NULL);
10628 cmdline_parse_token_string_t cmd_flow_director_drop =
10629 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10631 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10632 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10634 cmdline_parse_token_string_t cmd_flow_director_queue =
10635 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10637 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10638 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10640 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10641 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10643 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10644 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10645 fd_id_value, UINT32);
10647 cmdline_parse_token_string_t cmd_flow_director_mode =
10648 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10650 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10653 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10654 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10655 mode_value, "MAC-VLAN");
10656 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10657 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10658 mode_value, "Tunnel");
10659 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10661 mode_value, "raw");
10662 cmdline_parse_token_string_t cmd_flow_director_mac =
10663 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10665 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10666 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10668 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10669 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10671 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10672 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10673 tunnel_type, "NVGRE#VxLAN");
10674 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10675 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10676 tunnel_id, "tunnel-id");
10677 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10678 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10679 tunnel_id_value, UINT32);
10680 cmdline_parse_token_string_t cmd_flow_director_packet =
10681 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10683 cmdline_parse_token_string_t cmd_flow_director_filepath =
10684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10687 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10688 .f = cmd_flow_director_filter_parsed,
10690 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10691 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10692 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10693 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10694 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10695 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10696 "fd_id <fd_id_value>: "
10697 "Add or delete an ip flow director entry on NIC",
10699 (void *)&cmd_flow_director_filter,
10700 (void *)&cmd_flow_director_port_id,
10701 (void *)&cmd_flow_director_mode,
10702 (void *)&cmd_flow_director_mode_ip,
10703 (void *)&cmd_flow_director_ops,
10704 (void *)&cmd_flow_director_flow,
10705 (void *)&cmd_flow_director_flow_type,
10706 (void *)&cmd_flow_director_src,
10707 (void *)&cmd_flow_director_ip_src,
10708 (void *)&cmd_flow_director_dst,
10709 (void *)&cmd_flow_director_ip_dst,
10710 (void *)&cmd_flow_director_tos,
10711 (void *)&cmd_flow_director_tos_value,
10712 (void *)&cmd_flow_director_proto,
10713 (void *)&cmd_flow_director_proto_value,
10714 (void *)&cmd_flow_director_ttl,
10715 (void *)&cmd_flow_director_ttl_value,
10716 (void *)&cmd_flow_director_vlan,
10717 (void *)&cmd_flow_director_vlan_value,
10718 (void *)&cmd_flow_director_flexbytes,
10719 (void *)&cmd_flow_director_flexbytes_value,
10720 (void *)&cmd_flow_director_drop,
10721 (void *)&cmd_flow_director_pf_vf,
10722 (void *)&cmd_flow_director_queue,
10723 (void *)&cmd_flow_director_queue_id,
10724 (void *)&cmd_flow_director_fd_id,
10725 (void *)&cmd_flow_director_fd_id_value,
10730 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10731 .f = cmd_flow_director_filter_parsed,
10733 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10734 "director entry on NIC",
10736 (void *)&cmd_flow_director_filter,
10737 (void *)&cmd_flow_director_port_id,
10738 (void *)&cmd_flow_director_mode,
10739 (void *)&cmd_flow_director_mode_ip,
10740 (void *)&cmd_flow_director_ops,
10741 (void *)&cmd_flow_director_flow,
10742 (void *)&cmd_flow_director_flow_type,
10743 (void *)&cmd_flow_director_src,
10744 (void *)&cmd_flow_director_ip_src,
10745 (void *)&cmd_flow_director_port_src,
10746 (void *)&cmd_flow_director_dst,
10747 (void *)&cmd_flow_director_ip_dst,
10748 (void *)&cmd_flow_director_port_dst,
10749 (void *)&cmd_flow_director_tos,
10750 (void *)&cmd_flow_director_tos_value,
10751 (void *)&cmd_flow_director_ttl,
10752 (void *)&cmd_flow_director_ttl_value,
10753 (void *)&cmd_flow_director_vlan,
10754 (void *)&cmd_flow_director_vlan_value,
10755 (void *)&cmd_flow_director_flexbytes,
10756 (void *)&cmd_flow_director_flexbytes_value,
10757 (void *)&cmd_flow_director_drop,
10758 (void *)&cmd_flow_director_pf_vf,
10759 (void *)&cmd_flow_director_queue,
10760 (void *)&cmd_flow_director_queue_id,
10761 (void *)&cmd_flow_director_fd_id,
10762 (void *)&cmd_flow_director_fd_id_value,
10767 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10768 .f = cmd_flow_director_filter_parsed,
10770 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10771 "director entry on NIC",
10773 (void *)&cmd_flow_director_filter,
10774 (void *)&cmd_flow_director_port_id,
10775 (void *)&cmd_flow_director_mode,
10776 (void *)&cmd_flow_director_mode_ip,
10777 (void *)&cmd_flow_director_ops,
10778 (void *)&cmd_flow_director_flow,
10779 (void *)&cmd_flow_director_flow_type,
10780 (void *)&cmd_flow_director_src,
10781 (void *)&cmd_flow_director_ip_src,
10782 (void *)&cmd_flow_director_port_src,
10783 (void *)&cmd_flow_director_dst,
10784 (void *)&cmd_flow_director_ip_dst,
10785 (void *)&cmd_flow_director_port_dst,
10786 (void *)&cmd_flow_director_verify_tag,
10787 (void *)&cmd_flow_director_verify_tag_value,
10788 (void *)&cmd_flow_director_tos,
10789 (void *)&cmd_flow_director_tos_value,
10790 (void *)&cmd_flow_director_ttl,
10791 (void *)&cmd_flow_director_ttl_value,
10792 (void *)&cmd_flow_director_vlan,
10793 (void *)&cmd_flow_director_vlan_value,
10794 (void *)&cmd_flow_director_flexbytes,
10795 (void *)&cmd_flow_director_flexbytes_value,
10796 (void *)&cmd_flow_director_drop,
10797 (void *)&cmd_flow_director_pf_vf,
10798 (void *)&cmd_flow_director_queue,
10799 (void *)&cmd_flow_director_queue_id,
10800 (void *)&cmd_flow_director_fd_id,
10801 (void *)&cmd_flow_director_fd_id_value,
10806 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10807 .f = cmd_flow_director_filter_parsed,
10809 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10810 "director entry on NIC",
10812 (void *)&cmd_flow_director_filter,
10813 (void *)&cmd_flow_director_port_id,
10814 (void *)&cmd_flow_director_mode,
10815 (void *)&cmd_flow_director_mode_ip,
10816 (void *)&cmd_flow_director_ops,
10817 (void *)&cmd_flow_director_flow,
10818 (void *)&cmd_flow_director_flow_type,
10819 (void *)&cmd_flow_director_ether,
10820 (void *)&cmd_flow_director_ether_type,
10821 (void *)&cmd_flow_director_flexbytes,
10822 (void *)&cmd_flow_director_flexbytes_value,
10823 (void *)&cmd_flow_director_drop,
10824 (void *)&cmd_flow_director_pf_vf,
10825 (void *)&cmd_flow_director_queue,
10826 (void *)&cmd_flow_director_queue_id,
10827 (void *)&cmd_flow_director_fd_id,
10828 (void *)&cmd_flow_director_fd_id_value,
10833 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10834 .f = cmd_flow_director_filter_parsed,
10836 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10837 "director entry on NIC",
10839 (void *)&cmd_flow_director_filter,
10840 (void *)&cmd_flow_director_port_id,
10841 (void *)&cmd_flow_director_mode,
10842 (void *)&cmd_flow_director_mode_mac_vlan,
10843 (void *)&cmd_flow_director_ops,
10844 (void *)&cmd_flow_director_mac,
10845 (void *)&cmd_flow_director_mac_addr,
10846 (void *)&cmd_flow_director_vlan,
10847 (void *)&cmd_flow_director_vlan_value,
10848 (void *)&cmd_flow_director_flexbytes,
10849 (void *)&cmd_flow_director_flexbytes_value,
10850 (void *)&cmd_flow_director_drop,
10851 (void *)&cmd_flow_director_queue,
10852 (void *)&cmd_flow_director_queue_id,
10853 (void *)&cmd_flow_director_fd_id,
10854 (void *)&cmd_flow_director_fd_id_value,
10859 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10860 .f = cmd_flow_director_filter_parsed,
10862 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10863 "director entry on NIC",
10865 (void *)&cmd_flow_director_filter,
10866 (void *)&cmd_flow_director_port_id,
10867 (void *)&cmd_flow_director_mode,
10868 (void *)&cmd_flow_director_mode_tunnel,
10869 (void *)&cmd_flow_director_ops,
10870 (void *)&cmd_flow_director_mac,
10871 (void *)&cmd_flow_director_mac_addr,
10872 (void *)&cmd_flow_director_vlan,
10873 (void *)&cmd_flow_director_vlan_value,
10874 (void *)&cmd_flow_director_tunnel,
10875 (void *)&cmd_flow_director_tunnel_type,
10876 (void *)&cmd_flow_director_tunnel_id,
10877 (void *)&cmd_flow_director_tunnel_id_value,
10878 (void *)&cmd_flow_director_flexbytes,
10879 (void *)&cmd_flow_director_flexbytes_value,
10880 (void *)&cmd_flow_director_drop,
10881 (void *)&cmd_flow_director_queue,
10882 (void *)&cmd_flow_director_queue_id,
10883 (void *)&cmd_flow_director_fd_id,
10884 (void *)&cmd_flow_director_fd_id_value,
10889 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10890 .f = cmd_flow_director_filter_parsed,
10892 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10893 "director entry on NIC",
10895 (void *)&cmd_flow_director_filter,
10896 (void *)&cmd_flow_director_port_id,
10897 (void *)&cmd_flow_director_mode,
10898 (void *)&cmd_flow_director_mode_raw,
10899 (void *)&cmd_flow_director_ops,
10900 (void *)&cmd_flow_director_flow,
10901 (void *)&cmd_flow_director_flow_type,
10902 (void *)&cmd_flow_director_drop,
10903 (void *)&cmd_flow_director_queue,
10904 (void *)&cmd_flow_director_queue_id,
10905 (void *)&cmd_flow_director_fd_id,
10906 (void *)&cmd_flow_director_fd_id_value,
10907 (void *)&cmd_flow_director_packet,
10908 (void *)&cmd_flow_director_filepath,
10913 struct cmd_flush_flow_director_result {
10914 cmdline_fixed_string_t flush_flow_director;
10918 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10919 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10920 flush_flow_director, "flush_flow_director");
10921 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10922 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10926 cmd_flush_flow_director_parsed(void *parsed_result,
10927 __attribute__((unused)) struct cmdline *cl,
10928 __attribute__((unused)) void *data)
10930 struct cmd_flow_director_result *res = parsed_result;
10933 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10935 printf("flow director is not supported on port %u.\n",
10940 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10941 RTE_ETH_FILTER_FLUSH, NULL);
10943 printf("flow director table flushing error: (%s)\n",
10947 cmdline_parse_inst_t cmd_flush_flow_director = {
10948 .f = cmd_flush_flow_director_parsed,
10950 .help_str = "flush_flow_director <port_id>: "
10951 "Flush all flow director entries of a device on NIC",
10953 (void *)&cmd_flush_flow_director_flush,
10954 (void *)&cmd_flush_flow_director_port_id,
10959 /* *** deal with flow director mask *** */
10960 struct cmd_flow_director_mask_result {
10961 cmdline_fixed_string_t flow_director_mask;
10963 cmdline_fixed_string_t mode;
10964 cmdline_fixed_string_t mode_value;
10965 cmdline_fixed_string_t vlan;
10966 uint16_t vlan_mask;
10967 cmdline_fixed_string_t src_mask;
10968 cmdline_ipaddr_t ipv4_src;
10969 cmdline_ipaddr_t ipv6_src;
10971 cmdline_fixed_string_t dst_mask;
10972 cmdline_ipaddr_t ipv4_dst;
10973 cmdline_ipaddr_t ipv6_dst;
10975 cmdline_fixed_string_t mac;
10976 uint8_t mac_addr_byte_mask;
10977 cmdline_fixed_string_t tunnel_id;
10978 uint32_t tunnel_id_mask;
10979 cmdline_fixed_string_t tunnel_type;
10980 uint8_t tunnel_type_mask;
10984 cmd_flow_director_mask_parsed(void *parsed_result,
10985 __attribute__((unused)) struct cmdline *cl,
10986 __attribute__((unused)) void *data)
10988 struct cmd_flow_director_mask_result *res = parsed_result;
10989 struct rte_eth_fdir_masks *mask;
10990 struct rte_port *port;
10992 port = &ports[res->port_id];
10993 /** Check if the port is not started **/
10994 if (port->port_status != RTE_PORT_STOPPED) {
10995 printf("Please stop port %d first\n", res->port_id);
10999 mask = &port->dev_conf.fdir_conf.mask;
11001 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11002 if (strcmp(res->mode_value, "MAC-VLAN")) {
11003 printf("Please set mode to MAC-VLAN.\n");
11007 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11008 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11009 if (strcmp(res->mode_value, "Tunnel")) {
11010 printf("Please set mode to Tunnel.\n");
11014 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11015 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11016 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11017 mask->tunnel_type_mask = res->tunnel_type_mask;
11019 if (strcmp(res->mode_value, "IP")) {
11020 printf("Please set mode to IP.\n");
11024 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11025 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11026 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11027 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11028 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11029 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11030 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11033 cmd_reconfig_device_queue(res->port_id, 1, 1);
11036 cmdline_parse_token_string_t cmd_flow_director_mask =
11037 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11038 flow_director_mask, "flow_director_mask");
11039 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11040 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11042 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11043 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11045 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11046 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11047 vlan_mask, UINT16);
11048 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11049 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11050 src_mask, "src_mask");
11051 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11052 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11054 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11055 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11057 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11058 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11060 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11061 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11062 dst_mask, "dst_mask");
11063 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11064 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11066 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11067 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11069 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11070 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11073 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11074 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11076 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11077 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11079 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11080 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11081 mode_value, "MAC-VLAN");
11082 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11083 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11084 mode_value, "Tunnel");
11085 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11086 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11088 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11089 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11090 mac_addr_byte_mask, UINT8);
11091 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11092 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11093 tunnel_type, "tunnel-type");
11094 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11095 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11096 tunnel_type_mask, UINT8);
11097 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11098 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11099 tunnel_id, "tunnel-id");
11100 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11101 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11102 tunnel_id_mask, UINT32);
11104 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11105 .f = cmd_flow_director_mask_parsed,
11107 .help_str = "flow_director_mask ... : "
11108 "Set IP mode flow director's mask on NIC",
11110 (void *)&cmd_flow_director_mask,
11111 (void *)&cmd_flow_director_mask_port_id,
11112 (void *)&cmd_flow_director_mask_mode,
11113 (void *)&cmd_flow_director_mask_mode_ip,
11114 (void *)&cmd_flow_director_mask_vlan,
11115 (void *)&cmd_flow_director_mask_vlan_value,
11116 (void *)&cmd_flow_director_mask_src,
11117 (void *)&cmd_flow_director_mask_ipv4_src,
11118 (void *)&cmd_flow_director_mask_ipv6_src,
11119 (void *)&cmd_flow_director_mask_port_src,
11120 (void *)&cmd_flow_director_mask_dst,
11121 (void *)&cmd_flow_director_mask_ipv4_dst,
11122 (void *)&cmd_flow_director_mask_ipv6_dst,
11123 (void *)&cmd_flow_director_mask_port_dst,
11128 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11129 .f = cmd_flow_director_mask_parsed,
11131 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11132 "flow director's mask on NIC",
11134 (void *)&cmd_flow_director_mask,
11135 (void *)&cmd_flow_director_mask_port_id,
11136 (void *)&cmd_flow_director_mask_mode,
11137 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11138 (void *)&cmd_flow_director_mask_vlan,
11139 (void *)&cmd_flow_director_mask_vlan_value,
11144 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11145 .f = cmd_flow_director_mask_parsed,
11147 .help_str = "flow_director_mask ... : Set tunnel mode "
11148 "flow director's mask on NIC",
11150 (void *)&cmd_flow_director_mask,
11151 (void *)&cmd_flow_director_mask_port_id,
11152 (void *)&cmd_flow_director_mask_mode,
11153 (void *)&cmd_flow_director_mask_mode_tunnel,
11154 (void *)&cmd_flow_director_mask_vlan,
11155 (void *)&cmd_flow_director_mask_vlan_value,
11156 (void *)&cmd_flow_director_mask_mac,
11157 (void *)&cmd_flow_director_mask_mac_value,
11158 (void *)&cmd_flow_director_mask_tunnel_type,
11159 (void *)&cmd_flow_director_mask_tunnel_type_value,
11160 (void *)&cmd_flow_director_mask_tunnel_id,
11161 (void *)&cmd_flow_director_mask_tunnel_id_value,
11166 /* *** deal with flow director mask on flexible payload *** */
11167 struct cmd_flow_director_flex_mask_result {
11168 cmdline_fixed_string_t flow_director_flexmask;
11170 cmdline_fixed_string_t flow;
11171 cmdline_fixed_string_t flow_type;
11172 cmdline_fixed_string_t mask;
11176 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11177 __attribute__((unused)) struct cmdline *cl,
11178 __attribute__((unused)) void *data)
11180 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11181 struct rte_eth_fdir_info fdir_info;
11182 struct rte_eth_fdir_flex_mask flex_mask;
11183 struct rte_port *port;
11184 uint64_t flow_type_mask;
11188 port = &ports[res->port_id];
11189 /** Check if the port is not started **/
11190 if (port->port_status != RTE_PORT_STOPPED) {
11191 printf("Please stop port %d first\n", res->port_id);
11195 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11196 ret = parse_flexbytes(res->mask,
11198 RTE_ETH_FDIR_MAX_FLEXLEN);
11200 printf("error: Cannot parse mask input.\n");
11204 memset(&fdir_info, 0, sizeof(fdir_info));
11205 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11206 RTE_ETH_FILTER_INFO, &fdir_info);
11208 printf("Cannot get FDir filter info\n");
11212 if (!strcmp(res->flow_type, "none")) {
11213 /* means don't specify the flow type */
11214 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11215 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11216 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11217 0, sizeof(struct rte_eth_fdir_flex_mask));
11218 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11219 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11221 sizeof(struct rte_eth_fdir_flex_mask));
11222 cmd_reconfig_device_queue(res->port_id, 1, 1);
11225 flow_type_mask = fdir_info.flow_types_mask[0];
11226 if (!strcmp(res->flow_type, "all")) {
11227 if (!flow_type_mask) {
11228 printf("No flow type supported\n");
11231 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11232 if (flow_type_mask & (1ULL << i)) {
11233 flex_mask.flow_type = i;
11234 fdir_set_flex_mask(res->port_id, &flex_mask);
11237 cmd_reconfig_device_queue(res->port_id, 1, 1);
11240 flex_mask.flow_type = str2flowtype(res->flow_type);
11241 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11242 printf("Flow type %s not supported on port %d\n",
11243 res->flow_type, res->port_id);
11246 fdir_set_flex_mask(res->port_id, &flex_mask);
11247 cmd_reconfig_device_queue(res->port_id, 1, 1);
11250 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11252 flow_director_flexmask,
11253 "flow_director_flex_mask");
11254 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11255 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11257 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11260 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11262 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11263 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11264 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11268 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11269 .f = cmd_flow_director_flex_mask_parsed,
11271 .help_str = "flow_director_flex_mask ... : "
11272 "Set flow director's flex mask on NIC",
11274 (void *)&cmd_flow_director_flexmask,
11275 (void *)&cmd_flow_director_flexmask_port_id,
11276 (void *)&cmd_flow_director_flexmask_flow,
11277 (void *)&cmd_flow_director_flexmask_flow_type,
11278 (void *)&cmd_flow_director_flexmask_mask,
11283 /* *** deal with flow director flexible payload configuration *** */
11284 struct cmd_flow_director_flexpayload_result {
11285 cmdline_fixed_string_t flow_director_flexpayload;
11287 cmdline_fixed_string_t payload_layer;
11288 cmdline_fixed_string_t payload_cfg;
11292 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11295 const char *p, *p0 = q_arg;
11297 unsigned long int_fld;
11298 char *str_fld[max_num];
11303 p = strchr(p0, '(');
11307 p0 = strchr(p, ')');
11312 if (size >= sizeof(s))
11315 snprintf(s, sizeof(s), "%.*s", size, p);
11316 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11317 if (ret < 0 || ret > max_num)
11319 for (i = 0; i < ret; i++) {
11321 int_fld = strtoul(str_fld[i], &end, 0);
11322 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11324 offsets[i] = (uint16_t)int_fld;
11330 cmd_flow_director_flxpld_parsed(void *parsed_result,
11331 __attribute__((unused)) struct cmdline *cl,
11332 __attribute__((unused)) void *data)
11334 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11335 struct rte_eth_flex_payload_cfg flex_cfg;
11336 struct rte_port *port;
11339 port = &ports[res->port_id];
11340 /** Check if the port is not started **/
11341 if (port->port_status != RTE_PORT_STOPPED) {
11342 printf("Please stop port %d first\n", res->port_id);
11346 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11348 if (!strcmp(res->payload_layer, "raw"))
11349 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11350 else if (!strcmp(res->payload_layer, "l2"))
11351 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11352 else if (!strcmp(res->payload_layer, "l3"))
11353 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11354 else if (!strcmp(res->payload_layer, "l4"))
11355 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11357 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11358 RTE_ETH_FDIR_MAX_FLEXLEN);
11360 printf("error: Cannot parse flex payload input.\n");
11364 fdir_set_flex_payload(res->port_id, &flex_cfg);
11365 cmd_reconfig_device_queue(res->port_id, 1, 1);
11368 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11369 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11370 flow_director_flexpayload,
11371 "flow_director_flex_payload");
11372 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11373 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11375 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11377 payload_layer, "raw#l2#l3#l4");
11378 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11379 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11380 payload_cfg, NULL);
11382 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11383 .f = cmd_flow_director_flxpld_parsed,
11385 .help_str = "flow_director_flexpayload ... : "
11386 "Set flow director's flex payload on NIC",
11388 (void *)&cmd_flow_director_flexpayload,
11389 (void *)&cmd_flow_director_flexpayload_port_id,
11390 (void *)&cmd_flow_director_flexpayload_payload_layer,
11391 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11396 /* Generic flow interface command. */
11397 extern cmdline_parse_inst_t cmd_flow;
11399 /* *** Classification Filters Control *** */
11400 /* *** Get symmetric hash enable per port *** */
11401 struct cmd_get_sym_hash_ena_per_port_result {
11402 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11407 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11408 __rte_unused struct cmdline *cl,
11409 __rte_unused void *data)
11411 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11412 struct rte_eth_hash_filter_info info;
11415 if (rte_eth_dev_filter_supported(res->port_id,
11416 RTE_ETH_FILTER_HASH) < 0) {
11417 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11422 memset(&info, 0, sizeof(info));
11423 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11424 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11425 RTE_ETH_FILTER_GET, &info);
11428 printf("Cannot get symmetric hash enable per port "
11429 "on port %u\n", res->port_id);
11433 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11434 "enabled" : "disabled", res->port_id);
11437 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11438 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11439 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11440 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11441 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11444 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11445 .f = cmd_get_sym_hash_per_port_parsed,
11447 .help_str = "get_sym_hash_ena_per_port <port_id>",
11449 (void *)&cmd_get_sym_hash_ena_per_port_all,
11450 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11455 /* *** Set symmetric hash enable per port *** */
11456 struct cmd_set_sym_hash_ena_per_port_result {
11457 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11458 cmdline_fixed_string_t enable;
11463 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11464 __rte_unused struct cmdline *cl,
11465 __rte_unused void *data)
11467 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11468 struct rte_eth_hash_filter_info info;
11471 if (rte_eth_dev_filter_supported(res->port_id,
11472 RTE_ETH_FILTER_HASH) < 0) {
11473 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11478 memset(&info, 0, sizeof(info));
11479 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11480 if (!strcmp(res->enable, "enable"))
11481 info.info.enable = 1;
11482 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11483 RTE_ETH_FILTER_SET, &info);
11485 printf("Cannot set symmetric hash enable per port on "
11486 "port %u\n", res->port_id);
11489 printf("Symmetric hash has been set to %s on port %u\n",
11490 res->enable, res->port_id);
11493 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11494 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11495 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11496 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11497 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11499 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11500 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11501 enable, "enable#disable");
11503 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11504 .f = cmd_set_sym_hash_per_port_parsed,
11506 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11508 (void *)&cmd_set_sym_hash_ena_per_port_all,
11509 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11510 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11515 /* Get global config of hash function */
11516 struct cmd_get_hash_global_config_result {
11517 cmdline_fixed_string_t get_hash_global_config;
11522 flowtype_to_str(uint16_t ftype)
11528 } ftype_table[] = {
11529 {"ipv4", RTE_ETH_FLOW_IPV4},
11530 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11531 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11532 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11533 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11534 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11535 {"ipv6", RTE_ETH_FLOW_IPV6},
11536 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11537 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11538 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11539 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11540 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11541 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11542 {"port", RTE_ETH_FLOW_PORT},
11543 {"vxlan", RTE_ETH_FLOW_VXLAN},
11544 {"geneve", RTE_ETH_FLOW_GENEVE},
11545 {"nvgre", RTE_ETH_FLOW_NVGRE},
11548 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11549 if (ftype_table[i].ftype == ftype)
11550 return ftype_table[i].str;
11557 cmd_get_hash_global_config_parsed(void *parsed_result,
11558 __rte_unused struct cmdline *cl,
11559 __rte_unused void *data)
11561 struct cmd_get_hash_global_config_result *res = parsed_result;
11562 struct rte_eth_hash_filter_info info;
11563 uint32_t idx, offset;
11568 if (rte_eth_dev_filter_supported(res->port_id,
11569 RTE_ETH_FILTER_HASH) < 0) {
11570 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11575 memset(&info, 0, sizeof(info));
11576 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11577 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11578 RTE_ETH_FILTER_GET, &info);
11580 printf("Cannot get hash global configurations by port %d\n",
11585 switch (info.info.global_conf.hash_func) {
11586 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11587 printf("Hash function is Toeplitz\n");
11589 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11590 printf("Hash function is Simple XOR\n");
11593 printf("Unknown hash function\n");
11597 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11598 idx = i / UINT64_BIT;
11599 offset = i % UINT64_BIT;
11600 if (!(info.info.global_conf.valid_bit_mask[idx] &
11603 str = flowtype_to_str(i);
11606 printf("Symmetric hash is %s globally for flow type %s "
11608 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11609 (1ULL << offset)) ? "enabled" : "disabled"), str,
11614 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11615 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11616 get_hash_global_config, "get_hash_global_config");
11617 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11618 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11621 cmdline_parse_inst_t cmd_get_hash_global_config = {
11622 .f = cmd_get_hash_global_config_parsed,
11624 .help_str = "get_hash_global_config <port_id>",
11626 (void *)&cmd_get_hash_global_config_all,
11627 (void *)&cmd_get_hash_global_config_port_id,
11632 /* Set global config of hash function */
11633 struct cmd_set_hash_global_config_result {
11634 cmdline_fixed_string_t set_hash_global_config;
11636 cmdline_fixed_string_t hash_func;
11637 cmdline_fixed_string_t flow_type;
11638 cmdline_fixed_string_t enable;
11642 cmd_set_hash_global_config_parsed(void *parsed_result,
11643 __rte_unused struct cmdline *cl,
11644 __rte_unused void *data)
11646 struct cmd_set_hash_global_config_result *res = parsed_result;
11647 struct rte_eth_hash_filter_info info;
11648 uint32_t ftype, idx, offset;
11651 if (rte_eth_dev_filter_supported(res->port_id,
11652 RTE_ETH_FILTER_HASH) < 0) {
11653 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11657 memset(&info, 0, sizeof(info));
11658 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11659 if (!strcmp(res->hash_func, "toeplitz"))
11660 info.info.global_conf.hash_func =
11661 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11662 else if (!strcmp(res->hash_func, "simple_xor"))
11663 info.info.global_conf.hash_func =
11664 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11665 else if (!strcmp(res->hash_func, "default"))
11666 info.info.global_conf.hash_func =
11667 RTE_ETH_HASH_FUNCTION_DEFAULT;
11669 ftype = str2flowtype(res->flow_type);
11670 idx = ftype / UINT64_BIT;
11671 offset = ftype % UINT64_BIT;
11672 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11673 if (!strcmp(res->enable, "enable"))
11674 info.info.global_conf.sym_hash_enable_mask[idx] |=
11676 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11677 RTE_ETH_FILTER_SET, &info);
11679 printf("Cannot set global hash configurations by port %d\n",
11682 printf("Global hash configurations have been set "
11683 "succcessfully by port %d\n", res->port_id);
11686 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11687 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11688 set_hash_global_config, "set_hash_global_config");
11689 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11690 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11692 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11693 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11694 hash_func, "toeplitz#simple_xor#default");
11695 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11696 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11698 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11699 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11700 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11701 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11702 enable, "enable#disable");
11704 cmdline_parse_inst_t cmd_set_hash_global_config = {
11705 .f = cmd_set_hash_global_config_parsed,
11707 .help_str = "set_hash_global_config <port_id> "
11708 "toeplitz|simple_xor|default "
11709 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11710 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11711 "l2_payload enable|disable",
11713 (void *)&cmd_set_hash_global_config_all,
11714 (void *)&cmd_set_hash_global_config_port_id,
11715 (void *)&cmd_set_hash_global_config_hash_func,
11716 (void *)&cmd_set_hash_global_config_flow_type,
11717 (void *)&cmd_set_hash_global_config_enable,
11722 /* Set hash input set */
11723 struct cmd_set_hash_input_set_result {
11724 cmdline_fixed_string_t set_hash_input_set;
11726 cmdline_fixed_string_t flow_type;
11727 cmdline_fixed_string_t inset_field;
11728 cmdline_fixed_string_t select;
11731 static enum rte_eth_input_set_field
11732 str2inset(char *string)
11736 static const struct {
11738 enum rte_eth_input_set_field inset;
11739 } inset_table[] = {
11740 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11741 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11742 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11743 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11744 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11745 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11746 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11747 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11748 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11749 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11750 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11751 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11752 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11753 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11754 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11755 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11756 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11757 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11758 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11759 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11760 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11761 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11762 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11763 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11764 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11765 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11766 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11767 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11768 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11769 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11770 {"none", RTE_ETH_INPUT_SET_NONE},
11773 for (i = 0; i < RTE_DIM(inset_table); i++) {
11774 if (!strcmp(string, inset_table[i].str))
11775 return inset_table[i].inset;
11778 return RTE_ETH_INPUT_SET_UNKNOWN;
11782 cmd_set_hash_input_set_parsed(void *parsed_result,
11783 __rte_unused struct cmdline *cl,
11784 __rte_unused void *data)
11786 struct cmd_set_hash_input_set_result *res = parsed_result;
11787 struct rte_eth_hash_filter_info info;
11789 memset(&info, 0, sizeof(info));
11790 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11791 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11792 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11793 info.info.input_set_conf.inset_size = 1;
11794 if (!strcmp(res->select, "select"))
11795 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11796 else if (!strcmp(res->select, "add"))
11797 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11798 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11799 RTE_ETH_FILTER_SET, &info);
11802 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11803 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11804 set_hash_input_set, "set_hash_input_set");
11805 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11806 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11808 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11809 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11811 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11812 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11814 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11815 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11816 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11817 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11818 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11820 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11821 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11822 select, "select#add");
11824 cmdline_parse_inst_t cmd_set_hash_input_set = {
11825 .f = cmd_set_hash_input_set_parsed,
11827 .help_str = "set_hash_input_set <port_id> "
11828 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11829 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11830 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11831 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11832 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11833 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11834 "fld-7th|fld-8th|none select|add",
11836 (void *)&cmd_set_hash_input_set_cmd,
11837 (void *)&cmd_set_hash_input_set_port_id,
11838 (void *)&cmd_set_hash_input_set_flow_type,
11839 (void *)&cmd_set_hash_input_set_field,
11840 (void *)&cmd_set_hash_input_set_select,
11845 /* Set flow director input set */
11846 struct cmd_set_fdir_input_set_result {
11847 cmdline_fixed_string_t set_fdir_input_set;
11849 cmdline_fixed_string_t flow_type;
11850 cmdline_fixed_string_t inset_field;
11851 cmdline_fixed_string_t select;
11855 cmd_set_fdir_input_set_parsed(void *parsed_result,
11856 __rte_unused struct cmdline *cl,
11857 __rte_unused void *data)
11859 struct cmd_set_fdir_input_set_result *res = parsed_result;
11860 struct rte_eth_fdir_filter_info info;
11862 memset(&info, 0, sizeof(info));
11863 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11864 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11865 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11866 info.info.input_set_conf.inset_size = 1;
11867 if (!strcmp(res->select, "select"))
11868 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11869 else if (!strcmp(res->select, "add"))
11870 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11871 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11872 RTE_ETH_FILTER_SET, &info);
11875 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11876 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11877 set_fdir_input_set, "set_fdir_input_set");
11878 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11879 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11881 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11882 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11884 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11885 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11886 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11887 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11889 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11890 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11891 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11892 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11893 "sctp-veri-tag#none");
11894 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11895 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11896 select, "select#add");
11898 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11899 .f = cmd_set_fdir_input_set_parsed,
11901 .help_str = "set_fdir_input_set <port_id> "
11902 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11903 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11904 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11905 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11906 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11907 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11908 "sctp-veri-tag|none select|add",
11910 (void *)&cmd_set_fdir_input_set_cmd,
11911 (void *)&cmd_set_fdir_input_set_port_id,
11912 (void *)&cmd_set_fdir_input_set_flow_type,
11913 (void *)&cmd_set_fdir_input_set_field,
11914 (void *)&cmd_set_fdir_input_set_select,
11919 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11920 struct cmd_mcast_addr_result {
11921 cmdline_fixed_string_t mcast_addr_cmd;
11922 cmdline_fixed_string_t what;
11924 struct ether_addr mc_addr;
11927 static void cmd_mcast_addr_parsed(void *parsed_result,
11928 __attribute__((unused)) struct cmdline *cl,
11929 __attribute__((unused)) void *data)
11931 struct cmd_mcast_addr_result *res = parsed_result;
11933 if (!is_multicast_ether_addr(&res->mc_addr)) {
11934 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11935 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11936 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11937 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11940 if (strcmp(res->what, "add") == 0)
11941 mcast_addr_add(res->port_num, &res->mc_addr);
11943 mcast_addr_remove(res->port_num, &res->mc_addr);
11946 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11947 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11948 mcast_addr_cmd, "mcast_addr");
11949 cmdline_parse_token_string_t cmd_mcast_addr_what =
11950 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11952 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11953 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11954 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11955 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11957 cmdline_parse_inst_t cmd_mcast_addr = {
11958 .f = cmd_mcast_addr_parsed,
11960 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11961 "Add/Remove multicast MAC address on port_id",
11963 (void *)&cmd_mcast_addr_cmd,
11964 (void *)&cmd_mcast_addr_what,
11965 (void *)&cmd_mcast_addr_portnum,
11966 (void *)&cmd_mcast_addr_addr,
11971 /* l2 tunnel config
11972 * only support E-tag now.
11975 /* Ether type config */
11976 struct cmd_config_l2_tunnel_eth_type_result {
11977 cmdline_fixed_string_t port;
11978 cmdline_fixed_string_t config;
11979 cmdline_fixed_string_t all;
11981 cmdline_fixed_string_t l2_tunnel;
11982 cmdline_fixed_string_t l2_tunnel_type;
11983 cmdline_fixed_string_t eth_type;
11984 uint16_t eth_type_val;
11987 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11988 TOKEN_STRING_INITIALIZER
11989 (struct cmd_config_l2_tunnel_eth_type_result,
11991 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11992 TOKEN_STRING_INITIALIZER
11993 (struct cmd_config_l2_tunnel_eth_type_result,
11995 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11996 TOKEN_STRING_INITIALIZER
11997 (struct cmd_config_l2_tunnel_eth_type_result,
11999 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12000 TOKEN_NUM_INITIALIZER
12001 (struct cmd_config_l2_tunnel_eth_type_result,
12003 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12004 TOKEN_STRING_INITIALIZER
12005 (struct cmd_config_l2_tunnel_eth_type_result,
12006 l2_tunnel, "l2-tunnel");
12007 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_config_l2_tunnel_eth_type_result,
12010 l2_tunnel_type, "E-tag");
12011 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12012 TOKEN_STRING_INITIALIZER
12013 (struct cmd_config_l2_tunnel_eth_type_result,
12014 eth_type, "ether-type");
12015 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12016 TOKEN_NUM_INITIALIZER
12017 (struct cmd_config_l2_tunnel_eth_type_result,
12018 eth_type_val, UINT16);
12020 static enum rte_eth_tunnel_type
12021 str2fdir_l2_tunnel_type(char *string)
12025 static const struct {
12027 enum rte_eth_tunnel_type type;
12028 } l2_tunnel_type_str[] = {
12029 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12032 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12033 if (!strcmp(l2_tunnel_type_str[i].str, string))
12034 return l2_tunnel_type_str[i].type;
12036 return RTE_TUNNEL_TYPE_NONE;
12039 /* ether type config for all ports */
12041 cmd_config_l2_tunnel_eth_type_all_parsed
12042 (void *parsed_result,
12043 __attribute__((unused)) struct cmdline *cl,
12044 __attribute__((unused)) void *data)
12046 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12047 struct rte_eth_l2_tunnel_conf entry;
12050 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12051 entry.ether_type = res->eth_type_val;
12053 RTE_ETH_FOREACH_DEV(pid) {
12054 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12058 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12059 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12061 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12063 (void *)&cmd_config_l2_tunnel_eth_type_port,
12064 (void *)&cmd_config_l2_tunnel_eth_type_config,
12065 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12066 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12067 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12068 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12069 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12074 /* ether type config for a specific port */
12076 cmd_config_l2_tunnel_eth_type_specific_parsed(
12077 void *parsed_result,
12078 __attribute__((unused)) struct cmdline *cl,
12079 __attribute__((unused)) void *data)
12081 struct cmd_config_l2_tunnel_eth_type_result *res =
12083 struct rte_eth_l2_tunnel_conf entry;
12085 if (port_id_is_invalid(res->id, ENABLED_WARN))
12088 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12089 entry.ether_type = res->eth_type_val;
12091 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12094 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12095 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12097 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12099 (void *)&cmd_config_l2_tunnel_eth_type_port,
12100 (void *)&cmd_config_l2_tunnel_eth_type_config,
12101 (void *)&cmd_config_l2_tunnel_eth_type_id,
12102 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12103 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12104 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12105 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12110 /* Enable/disable l2 tunnel */
12111 struct cmd_config_l2_tunnel_en_dis_result {
12112 cmdline_fixed_string_t port;
12113 cmdline_fixed_string_t config;
12114 cmdline_fixed_string_t all;
12116 cmdline_fixed_string_t l2_tunnel;
12117 cmdline_fixed_string_t l2_tunnel_type;
12118 cmdline_fixed_string_t en_dis;
12121 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12122 TOKEN_STRING_INITIALIZER
12123 (struct cmd_config_l2_tunnel_en_dis_result,
12125 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12126 TOKEN_STRING_INITIALIZER
12127 (struct cmd_config_l2_tunnel_en_dis_result,
12129 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12130 TOKEN_STRING_INITIALIZER
12131 (struct cmd_config_l2_tunnel_en_dis_result,
12133 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12134 TOKEN_NUM_INITIALIZER
12135 (struct cmd_config_l2_tunnel_en_dis_result,
12137 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12138 TOKEN_STRING_INITIALIZER
12139 (struct cmd_config_l2_tunnel_en_dis_result,
12140 l2_tunnel, "l2-tunnel");
12141 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12142 TOKEN_STRING_INITIALIZER
12143 (struct cmd_config_l2_tunnel_en_dis_result,
12144 l2_tunnel_type, "E-tag");
12145 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12146 TOKEN_STRING_INITIALIZER
12147 (struct cmd_config_l2_tunnel_en_dis_result,
12148 en_dis, "enable#disable");
12150 /* enable/disable l2 tunnel for all ports */
12152 cmd_config_l2_tunnel_en_dis_all_parsed(
12153 void *parsed_result,
12154 __attribute__((unused)) struct cmdline *cl,
12155 __attribute__((unused)) void *data)
12157 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12158 struct rte_eth_l2_tunnel_conf entry;
12162 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12164 if (!strcmp("enable", res->en_dis))
12169 RTE_ETH_FOREACH_DEV(pid) {
12170 rte_eth_dev_l2_tunnel_offload_set(pid,
12172 ETH_L2_TUNNEL_ENABLE_MASK,
12177 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12178 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12180 .help_str = "port config all l2-tunnel E-tag enable|disable",
12182 (void *)&cmd_config_l2_tunnel_en_dis_port,
12183 (void *)&cmd_config_l2_tunnel_en_dis_config,
12184 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12185 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12186 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12187 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12192 /* enable/disable l2 tunnel for a port */
12194 cmd_config_l2_tunnel_en_dis_specific_parsed(
12195 void *parsed_result,
12196 __attribute__((unused)) struct cmdline *cl,
12197 __attribute__((unused)) void *data)
12199 struct cmd_config_l2_tunnel_en_dis_result *res =
12201 struct rte_eth_l2_tunnel_conf entry;
12203 if (port_id_is_invalid(res->id, ENABLED_WARN))
12206 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12208 if (!strcmp("enable", res->en_dis))
12209 rte_eth_dev_l2_tunnel_offload_set(res->id,
12211 ETH_L2_TUNNEL_ENABLE_MASK,
12214 rte_eth_dev_l2_tunnel_offload_set(res->id,
12216 ETH_L2_TUNNEL_ENABLE_MASK,
12220 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12221 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12223 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12225 (void *)&cmd_config_l2_tunnel_en_dis_port,
12226 (void *)&cmd_config_l2_tunnel_en_dis_config,
12227 (void *)&cmd_config_l2_tunnel_en_dis_id,
12228 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12229 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12230 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12235 /* E-tag configuration */
12237 /* Common result structure for all E-tag configuration */
12238 struct cmd_config_e_tag_result {
12239 cmdline_fixed_string_t e_tag;
12240 cmdline_fixed_string_t set;
12241 cmdline_fixed_string_t insertion;
12242 cmdline_fixed_string_t stripping;
12243 cmdline_fixed_string_t forwarding;
12244 cmdline_fixed_string_t filter;
12245 cmdline_fixed_string_t add;
12246 cmdline_fixed_string_t del;
12247 cmdline_fixed_string_t on;
12248 cmdline_fixed_string_t off;
12249 cmdline_fixed_string_t on_off;
12250 cmdline_fixed_string_t port_tag_id;
12251 uint32_t port_tag_id_val;
12252 cmdline_fixed_string_t e_tag_id;
12253 uint16_t e_tag_id_val;
12254 cmdline_fixed_string_t dst_pool;
12255 uint8_t dst_pool_val;
12256 cmdline_fixed_string_t port;
12258 cmdline_fixed_string_t vf;
12262 /* Common CLI fields for all E-tag configuration */
12263 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12264 TOKEN_STRING_INITIALIZER
12265 (struct cmd_config_e_tag_result,
12267 cmdline_parse_token_string_t cmd_config_e_tag_set =
12268 TOKEN_STRING_INITIALIZER
12269 (struct cmd_config_e_tag_result,
12271 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12272 TOKEN_STRING_INITIALIZER
12273 (struct cmd_config_e_tag_result,
12274 insertion, "insertion");
12275 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12276 TOKEN_STRING_INITIALIZER
12277 (struct cmd_config_e_tag_result,
12278 stripping, "stripping");
12279 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12280 TOKEN_STRING_INITIALIZER
12281 (struct cmd_config_e_tag_result,
12282 forwarding, "forwarding");
12283 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12284 TOKEN_STRING_INITIALIZER
12285 (struct cmd_config_e_tag_result,
12287 cmdline_parse_token_string_t cmd_config_e_tag_add =
12288 TOKEN_STRING_INITIALIZER
12289 (struct cmd_config_e_tag_result,
12291 cmdline_parse_token_string_t cmd_config_e_tag_del =
12292 TOKEN_STRING_INITIALIZER
12293 (struct cmd_config_e_tag_result,
12295 cmdline_parse_token_string_t cmd_config_e_tag_on =
12296 TOKEN_STRING_INITIALIZER
12297 (struct cmd_config_e_tag_result,
12299 cmdline_parse_token_string_t cmd_config_e_tag_off =
12300 TOKEN_STRING_INITIALIZER
12301 (struct cmd_config_e_tag_result,
12303 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12304 TOKEN_STRING_INITIALIZER
12305 (struct cmd_config_e_tag_result,
12307 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12308 TOKEN_STRING_INITIALIZER
12309 (struct cmd_config_e_tag_result,
12310 port_tag_id, "port-tag-id");
12311 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12312 TOKEN_NUM_INITIALIZER
12313 (struct cmd_config_e_tag_result,
12314 port_tag_id_val, UINT32);
12315 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12316 TOKEN_STRING_INITIALIZER
12317 (struct cmd_config_e_tag_result,
12318 e_tag_id, "e-tag-id");
12319 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12320 TOKEN_NUM_INITIALIZER
12321 (struct cmd_config_e_tag_result,
12322 e_tag_id_val, UINT16);
12323 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12324 TOKEN_STRING_INITIALIZER
12325 (struct cmd_config_e_tag_result,
12326 dst_pool, "dst-pool");
12327 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12328 TOKEN_NUM_INITIALIZER
12329 (struct cmd_config_e_tag_result,
12330 dst_pool_val, UINT8);
12331 cmdline_parse_token_string_t cmd_config_e_tag_port =
12332 TOKEN_STRING_INITIALIZER
12333 (struct cmd_config_e_tag_result,
12335 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12336 TOKEN_NUM_INITIALIZER
12337 (struct cmd_config_e_tag_result,
12339 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12340 TOKEN_STRING_INITIALIZER
12341 (struct cmd_config_e_tag_result,
12343 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12344 TOKEN_NUM_INITIALIZER
12345 (struct cmd_config_e_tag_result,
12348 /* E-tag insertion configuration */
12350 cmd_config_e_tag_insertion_en_parsed(
12351 void *parsed_result,
12352 __attribute__((unused)) struct cmdline *cl,
12353 __attribute__((unused)) void *data)
12355 struct cmd_config_e_tag_result *res =
12357 struct rte_eth_l2_tunnel_conf entry;
12359 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12362 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12363 entry.tunnel_id = res->port_tag_id_val;
12364 entry.vf_id = res->vf_id;
12365 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12367 ETH_L2_TUNNEL_INSERTION_MASK,
12372 cmd_config_e_tag_insertion_dis_parsed(
12373 void *parsed_result,
12374 __attribute__((unused)) struct cmdline *cl,
12375 __attribute__((unused)) void *data)
12377 struct cmd_config_e_tag_result *res =
12379 struct rte_eth_l2_tunnel_conf entry;
12381 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12384 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12385 entry.vf_id = res->vf_id;
12387 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12389 ETH_L2_TUNNEL_INSERTION_MASK,
12393 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12394 .f = cmd_config_e_tag_insertion_en_parsed,
12396 .help_str = "E-tag ... : E-tag insertion enable",
12398 (void *)&cmd_config_e_tag_e_tag,
12399 (void *)&cmd_config_e_tag_set,
12400 (void *)&cmd_config_e_tag_insertion,
12401 (void *)&cmd_config_e_tag_on,
12402 (void *)&cmd_config_e_tag_port_tag_id,
12403 (void *)&cmd_config_e_tag_port_tag_id_val,
12404 (void *)&cmd_config_e_tag_port,
12405 (void *)&cmd_config_e_tag_port_id,
12406 (void *)&cmd_config_e_tag_vf,
12407 (void *)&cmd_config_e_tag_vf_id,
12412 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12413 .f = cmd_config_e_tag_insertion_dis_parsed,
12415 .help_str = "E-tag ... : E-tag insertion disable",
12417 (void *)&cmd_config_e_tag_e_tag,
12418 (void *)&cmd_config_e_tag_set,
12419 (void *)&cmd_config_e_tag_insertion,
12420 (void *)&cmd_config_e_tag_off,
12421 (void *)&cmd_config_e_tag_port,
12422 (void *)&cmd_config_e_tag_port_id,
12423 (void *)&cmd_config_e_tag_vf,
12424 (void *)&cmd_config_e_tag_vf_id,
12429 /* E-tag stripping configuration */
12431 cmd_config_e_tag_stripping_parsed(
12432 void *parsed_result,
12433 __attribute__((unused)) struct cmdline *cl,
12434 __attribute__((unused)) void *data)
12436 struct cmd_config_e_tag_result *res =
12438 struct rte_eth_l2_tunnel_conf entry;
12440 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12443 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12445 if (!strcmp(res->on_off, "on"))
12446 rte_eth_dev_l2_tunnel_offload_set
12449 ETH_L2_TUNNEL_STRIPPING_MASK,
12452 rte_eth_dev_l2_tunnel_offload_set
12455 ETH_L2_TUNNEL_STRIPPING_MASK,
12459 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12460 .f = cmd_config_e_tag_stripping_parsed,
12462 .help_str = "E-tag ... : E-tag stripping enable/disable",
12464 (void *)&cmd_config_e_tag_e_tag,
12465 (void *)&cmd_config_e_tag_set,
12466 (void *)&cmd_config_e_tag_stripping,
12467 (void *)&cmd_config_e_tag_on_off,
12468 (void *)&cmd_config_e_tag_port,
12469 (void *)&cmd_config_e_tag_port_id,
12474 /* E-tag forwarding configuration */
12476 cmd_config_e_tag_forwarding_parsed(
12477 void *parsed_result,
12478 __attribute__((unused)) struct cmdline *cl,
12479 __attribute__((unused)) void *data)
12481 struct cmd_config_e_tag_result *res = parsed_result;
12482 struct rte_eth_l2_tunnel_conf entry;
12484 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12487 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12489 if (!strcmp(res->on_off, "on"))
12490 rte_eth_dev_l2_tunnel_offload_set
12493 ETH_L2_TUNNEL_FORWARDING_MASK,
12496 rte_eth_dev_l2_tunnel_offload_set
12499 ETH_L2_TUNNEL_FORWARDING_MASK,
12503 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12504 .f = cmd_config_e_tag_forwarding_parsed,
12506 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12508 (void *)&cmd_config_e_tag_e_tag,
12509 (void *)&cmd_config_e_tag_set,
12510 (void *)&cmd_config_e_tag_forwarding,
12511 (void *)&cmd_config_e_tag_on_off,
12512 (void *)&cmd_config_e_tag_port,
12513 (void *)&cmd_config_e_tag_port_id,
12518 /* E-tag filter configuration */
12520 cmd_config_e_tag_filter_add_parsed(
12521 void *parsed_result,
12522 __attribute__((unused)) struct cmdline *cl,
12523 __attribute__((unused)) void *data)
12525 struct cmd_config_e_tag_result *res = parsed_result;
12526 struct rte_eth_l2_tunnel_conf entry;
12529 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12532 if (res->e_tag_id_val > 0x3fff) {
12533 printf("e-tag-id must be equal or less than 0x3fff.\n");
12537 ret = rte_eth_dev_filter_supported(res->port_id,
12538 RTE_ETH_FILTER_L2_TUNNEL);
12540 printf("E-tag filter is not supported on port %u.\n",
12545 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12546 entry.tunnel_id = res->e_tag_id_val;
12547 entry.pool = res->dst_pool_val;
12549 ret = rte_eth_dev_filter_ctrl(res->port_id,
12550 RTE_ETH_FILTER_L2_TUNNEL,
12551 RTE_ETH_FILTER_ADD,
12554 printf("E-tag filter programming error: (%s)\n",
12558 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12559 .f = cmd_config_e_tag_filter_add_parsed,
12561 .help_str = "E-tag ... : E-tag filter add",
12563 (void *)&cmd_config_e_tag_e_tag,
12564 (void *)&cmd_config_e_tag_set,
12565 (void *)&cmd_config_e_tag_filter,
12566 (void *)&cmd_config_e_tag_add,
12567 (void *)&cmd_config_e_tag_e_tag_id,
12568 (void *)&cmd_config_e_tag_e_tag_id_val,
12569 (void *)&cmd_config_e_tag_dst_pool,
12570 (void *)&cmd_config_e_tag_dst_pool_val,
12571 (void *)&cmd_config_e_tag_port,
12572 (void *)&cmd_config_e_tag_port_id,
12578 cmd_config_e_tag_filter_del_parsed(
12579 void *parsed_result,
12580 __attribute__((unused)) struct cmdline *cl,
12581 __attribute__((unused)) void *data)
12583 struct cmd_config_e_tag_result *res = parsed_result;
12584 struct rte_eth_l2_tunnel_conf entry;
12587 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12590 if (res->e_tag_id_val > 0x3fff) {
12591 printf("e-tag-id must be less than 0x3fff.\n");
12595 ret = rte_eth_dev_filter_supported(res->port_id,
12596 RTE_ETH_FILTER_L2_TUNNEL);
12598 printf("E-tag filter is not supported on port %u.\n",
12603 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12604 entry.tunnel_id = res->e_tag_id_val;
12606 ret = rte_eth_dev_filter_ctrl(res->port_id,
12607 RTE_ETH_FILTER_L2_TUNNEL,
12608 RTE_ETH_FILTER_DELETE,
12611 printf("E-tag filter programming error: (%s)\n",
12615 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12616 .f = cmd_config_e_tag_filter_del_parsed,
12618 .help_str = "E-tag ... : E-tag filter delete",
12620 (void *)&cmd_config_e_tag_e_tag,
12621 (void *)&cmd_config_e_tag_set,
12622 (void *)&cmd_config_e_tag_filter,
12623 (void *)&cmd_config_e_tag_del,
12624 (void *)&cmd_config_e_tag_e_tag_id,
12625 (void *)&cmd_config_e_tag_e_tag_id_val,
12626 (void *)&cmd_config_e_tag_port,
12627 (void *)&cmd_config_e_tag_port_id,
12632 /* vf vlan anti spoof configuration */
12634 /* Common result structure for vf vlan anti spoof */
12635 struct cmd_vf_vlan_anti_spoof_result {
12636 cmdline_fixed_string_t set;
12637 cmdline_fixed_string_t vf;
12638 cmdline_fixed_string_t vlan;
12639 cmdline_fixed_string_t antispoof;
12642 cmdline_fixed_string_t on_off;
12645 /* Common CLI fields for vf vlan anti spoof enable disable */
12646 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12647 TOKEN_STRING_INITIALIZER
12648 (struct cmd_vf_vlan_anti_spoof_result,
12650 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12651 TOKEN_STRING_INITIALIZER
12652 (struct cmd_vf_vlan_anti_spoof_result,
12654 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12655 TOKEN_STRING_INITIALIZER
12656 (struct cmd_vf_vlan_anti_spoof_result,
12658 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12659 TOKEN_STRING_INITIALIZER
12660 (struct cmd_vf_vlan_anti_spoof_result,
12661 antispoof, "antispoof");
12662 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12663 TOKEN_NUM_INITIALIZER
12664 (struct cmd_vf_vlan_anti_spoof_result,
12666 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12667 TOKEN_NUM_INITIALIZER
12668 (struct cmd_vf_vlan_anti_spoof_result,
12670 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12671 TOKEN_STRING_INITIALIZER
12672 (struct cmd_vf_vlan_anti_spoof_result,
12676 cmd_set_vf_vlan_anti_spoof_parsed(
12677 void *parsed_result,
12678 __attribute__((unused)) struct cmdline *cl,
12679 __attribute__((unused)) void *data)
12681 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12682 int ret = -ENOTSUP;
12684 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12686 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12689 #ifdef RTE_LIBRTE_IXGBE_PMD
12690 if (ret == -ENOTSUP)
12691 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12692 res->vf_id, is_on);
12694 #ifdef RTE_LIBRTE_I40E_PMD
12695 if (ret == -ENOTSUP)
12696 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12697 res->vf_id, is_on);
12699 #ifdef RTE_LIBRTE_BNXT_PMD
12700 if (ret == -ENOTSUP)
12701 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12702 res->vf_id, is_on);
12709 printf("invalid vf_id %d\n", res->vf_id);
12712 printf("invalid port_id %d\n", res->port_id);
12715 printf("function not implemented\n");
12718 printf("programming error: (%s)\n", strerror(-ret));
12722 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12723 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12725 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12727 (void *)&cmd_vf_vlan_anti_spoof_set,
12728 (void *)&cmd_vf_vlan_anti_spoof_vf,
12729 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12730 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12731 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12732 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12733 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12738 /* vf mac anti spoof configuration */
12740 /* Common result structure for vf mac anti spoof */
12741 struct cmd_vf_mac_anti_spoof_result {
12742 cmdline_fixed_string_t set;
12743 cmdline_fixed_string_t vf;
12744 cmdline_fixed_string_t mac;
12745 cmdline_fixed_string_t antispoof;
12748 cmdline_fixed_string_t on_off;
12751 /* Common CLI fields for vf mac anti spoof enable disable */
12752 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12753 TOKEN_STRING_INITIALIZER
12754 (struct cmd_vf_mac_anti_spoof_result,
12756 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12757 TOKEN_STRING_INITIALIZER
12758 (struct cmd_vf_mac_anti_spoof_result,
12760 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12761 TOKEN_STRING_INITIALIZER
12762 (struct cmd_vf_mac_anti_spoof_result,
12764 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12765 TOKEN_STRING_INITIALIZER
12766 (struct cmd_vf_mac_anti_spoof_result,
12767 antispoof, "antispoof");
12768 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12769 TOKEN_NUM_INITIALIZER
12770 (struct cmd_vf_mac_anti_spoof_result,
12772 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12773 TOKEN_NUM_INITIALIZER
12774 (struct cmd_vf_mac_anti_spoof_result,
12776 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12777 TOKEN_STRING_INITIALIZER
12778 (struct cmd_vf_mac_anti_spoof_result,
12782 cmd_set_vf_mac_anti_spoof_parsed(
12783 void *parsed_result,
12784 __attribute__((unused)) struct cmdline *cl,
12785 __attribute__((unused)) void *data)
12787 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12788 int ret = -ENOTSUP;
12790 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12792 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12795 #ifdef RTE_LIBRTE_IXGBE_PMD
12796 if (ret == -ENOTSUP)
12797 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12798 res->vf_id, is_on);
12800 #ifdef RTE_LIBRTE_I40E_PMD
12801 if (ret == -ENOTSUP)
12802 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12803 res->vf_id, is_on);
12805 #ifdef RTE_LIBRTE_BNXT_PMD
12806 if (ret == -ENOTSUP)
12807 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12808 res->vf_id, is_on);
12815 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12818 printf("invalid port_id %d\n", res->port_id);
12821 printf("function not implemented\n");
12824 printf("programming error: (%s)\n", strerror(-ret));
12828 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12829 .f = cmd_set_vf_mac_anti_spoof_parsed,
12831 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12833 (void *)&cmd_vf_mac_anti_spoof_set,
12834 (void *)&cmd_vf_mac_anti_spoof_vf,
12835 (void *)&cmd_vf_mac_anti_spoof_mac,
12836 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12837 (void *)&cmd_vf_mac_anti_spoof_port_id,
12838 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12839 (void *)&cmd_vf_mac_anti_spoof_on_off,
12844 /* vf vlan strip queue configuration */
12846 /* Common result structure for vf mac anti spoof */
12847 struct cmd_vf_vlan_stripq_result {
12848 cmdline_fixed_string_t set;
12849 cmdline_fixed_string_t vf;
12850 cmdline_fixed_string_t vlan;
12851 cmdline_fixed_string_t stripq;
12854 cmdline_fixed_string_t on_off;
12857 /* Common CLI fields for vf vlan strip enable disable */
12858 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12859 TOKEN_STRING_INITIALIZER
12860 (struct cmd_vf_vlan_stripq_result,
12862 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12863 TOKEN_STRING_INITIALIZER
12864 (struct cmd_vf_vlan_stripq_result,
12866 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12867 TOKEN_STRING_INITIALIZER
12868 (struct cmd_vf_vlan_stripq_result,
12870 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12871 TOKEN_STRING_INITIALIZER
12872 (struct cmd_vf_vlan_stripq_result,
12874 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12875 TOKEN_NUM_INITIALIZER
12876 (struct cmd_vf_vlan_stripq_result,
12878 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12879 TOKEN_NUM_INITIALIZER
12880 (struct cmd_vf_vlan_stripq_result,
12882 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12883 TOKEN_STRING_INITIALIZER
12884 (struct cmd_vf_vlan_stripq_result,
12888 cmd_set_vf_vlan_stripq_parsed(
12889 void *parsed_result,
12890 __attribute__((unused)) struct cmdline *cl,
12891 __attribute__((unused)) void *data)
12893 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12894 int ret = -ENOTSUP;
12896 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12898 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12901 #ifdef RTE_LIBRTE_IXGBE_PMD
12902 if (ret == -ENOTSUP)
12903 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12904 res->vf_id, is_on);
12906 #ifdef RTE_LIBRTE_I40E_PMD
12907 if (ret == -ENOTSUP)
12908 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12909 res->vf_id, is_on);
12911 #ifdef RTE_LIBRTE_BNXT_PMD
12912 if (ret == -ENOTSUP)
12913 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12914 res->vf_id, is_on);
12921 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12924 printf("invalid port_id %d\n", res->port_id);
12927 printf("function not implemented\n");
12930 printf("programming error: (%s)\n", strerror(-ret));
12934 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12935 .f = cmd_set_vf_vlan_stripq_parsed,
12937 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12939 (void *)&cmd_vf_vlan_stripq_set,
12940 (void *)&cmd_vf_vlan_stripq_vf,
12941 (void *)&cmd_vf_vlan_stripq_vlan,
12942 (void *)&cmd_vf_vlan_stripq_stripq,
12943 (void *)&cmd_vf_vlan_stripq_port_id,
12944 (void *)&cmd_vf_vlan_stripq_vf_id,
12945 (void *)&cmd_vf_vlan_stripq_on_off,
12950 /* vf vlan insert configuration */
12952 /* Common result structure for vf vlan insert */
12953 struct cmd_vf_vlan_insert_result {
12954 cmdline_fixed_string_t set;
12955 cmdline_fixed_string_t vf;
12956 cmdline_fixed_string_t vlan;
12957 cmdline_fixed_string_t insert;
12963 /* Common CLI fields for vf vlan insert enable disable */
12964 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12965 TOKEN_STRING_INITIALIZER
12966 (struct cmd_vf_vlan_insert_result,
12968 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12969 TOKEN_STRING_INITIALIZER
12970 (struct cmd_vf_vlan_insert_result,
12972 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12973 TOKEN_STRING_INITIALIZER
12974 (struct cmd_vf_vlan_insert_result,
12976 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12977 TOKEN_STRING_INITIALIZER
12978 (struct cmd_vf_vlan_insert_result,
12980 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12981 TOKEN_NUM_INITIALIZER
12982 (struct cmd_vf_vlan_insert_result,
12984 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12985 TOKEN_NUM_INITIALIZER
12986 (struct cmd_vf_vlan_insert_result,
12988 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12989 TOKEN_NUM_INITIALIZER
12990 (struct cmd_vf_vlan_insert_result,
12994 cmd_set_vf_vlan_insert_parsed(
12995 void *parsed_result,
12996 __attribute__((unused)) struct cmdline *cl,
12997 __attribute__((unused)) void *data)
12999 struct cmd_vf_vlan_insert_result *res = parsed_result;
13000 int ret = -ENOTSUP;
13002 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13005 #ifdef RTE_LIBRTE_IXGBE_PMD
13006 if (ret == -ENOTSUP)
13007 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13010 #ifdef RTE_LIBRTE_I40E_PMD
13011 if (ret == -ENOTSUP)
13012 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13015 #ifdef RTE_LIBRTE_BNXT_PMD
13016 if (ret == -ENOTSUP)
13017 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13025 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13028 printf("invalid port_id %d\n", res->port_id);
13031 printf("function not implemented\n");
13034 printf("programming error: (%s)\n", strerror(-ret));
13038 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13039 .f = cmd_set_vf_vlan_insert_parsed,
13041 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13043 (void *)&cmd_vf_vlan_insert_set,
13044 (void *)&cmd_vf_vlan_insert_vf,
13045 (void *)&cmd_vf_vlan_insert_vlan,
13046 (void *)&cmd_vf_vlan_insert_insert,
13047 (void *)&cmd_vf_vlan_insert_port_id,
13048 (void *)&cmd_vf_vlan_insert_vf_id,
13049 (void *)&cmd_vf_vlan_insert_vlan_id,
13054 /* tx loopback configuration */
13056 /* Common result structure for tx loopback */
13057 struct cmd_tx_loopback_result {
13058 cmdline_fixed_string_t set;
13059 cmdline_fixed_string_t tx;
13060 cmdline_fixed_string_t loopback;
13062 cmdline_fixed_string_t on_off;
13065 /* Common CLI fields for tx loopback enable disable */
13066 cmdline_parse_token_string_t cmd_tx_loopback_set =
13067 TOKEN_STRING_INITIALIZER
13068 (struct cmd_tx_loopback_result,
13070 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13071 TOKEN_STRING_INITIALIZER
13072 (struct cmd_tx_loopback_result,
13074 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13075 TOKEN_STRING_INITIALIZER
13076 (struct cmd_tx_loopback_result,
13077 loopback, "loopback");
13078 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13079 TOKEN_NUM_INITIALIZER
13080 (struct cmd_tx_loopback_result,
13082 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13083 TOKEN_STRING_INITIALIZER
13084 (struct cmd_tx_loopback_result,
13088 cmd_set_tx_loopback_parsed(
13089 void *parsed_result,
13090 __attribute__((unused)) struct cmdline *cl,
13091 __attribute__((unused)) void *data)
13093 struct cmd_tx_loopback_result *res = parsed_result;
13094 int ret = -ENOTSUP;
13096 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13098 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13101 #ifdef RTE_LIBRTE_IXGBE_PMD
13102 if (ret == -ENOTSUP)
13103 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13105 #ifdef RTE_LIBRTE_I40E_PMD
13106 if (ret == -ENOTSUP)
13107 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13109 #ifdef RTE_LIBRTE_BNXT_PMD
13110 if (ret == -ENOTSUP)
13111 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13113 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13114 if (ret == -ENOTSUP)
13115 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13122 printf("invalid is_on %d\n", is_on);
13125 printf("invalid port_id %d\n", res->port_id);
13128 printf("function not implemented\n");
13131 printf("programming error: (%s)\n", strerror(-ret));
13135 cmdline_parse_inst_t cmd_set_tx_loopback = {
13136 .f = cmd_set_tx_loopback_parsed,
13138 .help_str = "set tx loopback <port_id> on|off",
13140 (void *)&cmd_tx_loopback_set,
13141 (void *)&cmd_tx_loopback_tx,
13142 (void *)&cmd_tx_loopback_loopback,
13143 (void *)&cmd_tx_loopback_port_id,
13144 (void *)&cmd_tx_loopback_on_off,
13149 /* all queues drop enable configuration */
13151 /* Common result structure for all queues drop enable */
13152 struct cmd_all_queues_drop_en_result {
13153 cmdline_fixed_string_t set;
13154 cmdline_fixed_string_t all;
13155 cmdline_fixed_string_t queues;
13156 cmdline_fixed_string_t drop;
13158 cmdline_fixed_string_t on_off;
13161 /* Common CLI fields for tx loopback enable disable */
13162 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13163 TOKEN_STRING_INITIALIZER
13164 (struct cmd_all_queues_drop_en_result,
13166 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13167 TOKEN_STRING_INITIALIZER
13168 (struct cmd_all_queues_drop_en_result,
13170 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13171 TOKEN_STRING_INITIALIZER
13172 (struct cmd_all_queues_drop_en_result,
13174 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13175 TOKEN_STRING_INITIALIZER
13176 (struct cmd_all_queues_drop_en_result,
13178 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13179 TOKEN_NUM_INITIALIZER
13180 (struct cmd_all_queues_drop_en_result,
13182 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13183 TOKEN_STRING_INITIALIZER
13184 (struct cmd_all_queues_drop_en_result,
13188 cmd_set_all_queues_drop_en_parsed(
13189 void *parsed_result,
13190 __attribute__((unused)) struct cmdline *cl,
13191 __attribute__((unused)) void *data)
13193 struct cmd_all_queues_drop_en_result *res = parsed_result;
13194 int ret = -ENOTSUP;
13195 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13197 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13200 #ifdef RTE_LIBRTE_IXGBE_PMD
13201 if (ret == -ENOTSUP)
13202 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13204 #ifdef RTE_LIBRTE_BNXT_PMD
13205 if (ret == -ENOTSUP)
13206 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13212 printf("invalid is_on %d\n", is_on);
13215 printf("invalid port_id %d\n", res->port_id);
13218 printf("function not implemented\n");
13221 printf("programming error: (%s)\n", strerror(-ret));
13225 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13226 .f = cmd_set_all_queues_drop_en_parsed,
13228 .help_str = "set all queues drop <port_id> on|off",
13230 (void *)&cmd_all_queues_drop_en_set,
13231 (void *)&cmd_all_queues_drop_en_all,
13232 (void *)&cmd_all_queues_drop_en_queues,
13233 (void *)&cmd_all_queues_drop_en_drop,
13234 (void *)&cmd_all_queues_drop_en_port_id,
13235 (void *)&cmd_all_queues_drop_en_on_off,
13240 /* vf split drop enable configuration */
13242 /* Common result structure for vf split drop enable */
13243 struct cmd_vf_split_drop_en_result {
13244 cmdline_fixed_string_t set;
13245 cmdline_fixed_string_t vf;
13246 cmdline_fixed_string_t split;
13247 cmdline_fixed_string_t drop;
13250 cmdline_fixed_string_t on_off;
13253 /* Common CLI fields for vf split drop enable disable */
13254 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13255 TOKEN_STRING_INITIALIZER
13256 (struct cmd_vf_split_drop_en_result,
13258 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13259 TOKEN_STRING_INITIALIZER
13260 (struct cmd_vf_split_drop_en_result,
13262 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13263 TOKEN_STRING_INITIALIZER
13264 (struct cmd_vf_split_drop_en_result,
13266 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13267 TOKEN_STRING_INITIALIZER
13268 (struct cmd_vf_split_drop_en_result,
13270 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13271 TOKEN_NUM_INITIALIZER
13272 (struct cmd_vf_split_drop_en_result,
13274 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13275 TOKEN_NUM_INITIALIZER
13276 (struct cmd_vf_split_drop_en_result,
13278 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13279 TOKEN_STRING_INITIALIZER
13280 (struct cmd_vf_split_drop_en_result,
13284 cmd_set_vf_split_drop_en_parsed(
13285 void *parsed_result,
13286 __attribute__((unused)) struct cmdline *cl,
13287 __attribute__((unused)) void *data)
13289 struct cmd_vf_split_drop_en_result *res = parsed_result;
13290 int ret = -ENOTSUP;
13291 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13293 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13296 #ifdef RTE_LIBRTE_IXGBE_PMD
13297 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13304 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13307 printf("invalid port_id %d\n", res->port_id);
13310 printf("not supported on port %d\n", res->port_id);
13313 printf("programming error: (%s)\n", strerror(-ret));
13317 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13318 .f = cmd_set_vf_split_drop_en_parsed,
13320 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13322 (void *)&cmd_vf_split_drop_en_set,
13323 (void *)&cmd_vf_split_drop_en_vf,
13324 (void *)&cmd_vf_split_drop_en_split,
13325 (void *)&cmd_vf_split_drop_en_drop,
13326 (void *)&cmd_vf_split_drop_en_port_id,
13327 (void *)&cmd_vf_split_drop_en_vf_id,
13328 (void *)&cmd_vf_split_drop_en_on_off,
13333 /* vf mac address configuration */
13335 /* Common result structure for vf mac address */
13336 struct cmd_set_vf_mac_addr_result {
13337 cmdline_fixed_string_t set;
13338 cmdline_fixed_string_t vf;
13339 cmdline_fixed_string_t mac;
13340 cmdline_fixed_string_t addr;
13343 struct ether_addr mac_addr;
13347 /* Common CLI fields for vf split drop enable disable */
13348 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13349 TOKEN_STRING_INITIALIZER
13350 (struct cmd_set_vf_mac_addr_result,
13352 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13353 TOKEN_STRING_INITIALIZER
13354 (struct cmd_set_vf_mac_addr_result,
13356 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13357 TOKEN_STRING_INITIALIZER
13358 (struct cmd_set_vf_mac_addr_result,
13360 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13361 TOKEN_STRING_INITIALIZER
13362 (struct cmd_set_vf_mac_addr_result,
13364 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13365 TOKEN_NUM_INITIALIZER
13366 (struct cmd_set_vf_mac_addr_result,
13368 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13369 TOKEN_NUM_INITIALIZER
13370 (struct cmd_set_vf_mac_addr_result,
13372 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13373 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13377 cmd_set_vf_mac_addr_parsed(
13378 void *parsed_result,
13379 __attribute__((unused)) struct cmdline *cl,
13380 __attribute__((unused)) void *data)
13382 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13383 int ret = -ENOTSUP;
13385 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13388 #ifdef RTE_LIBRTE_IXGBE_PMD
13389 if (ret == -ENOTSUP)
13390 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13393 #ifdef RTE_LIBRTE_I40E_PMD
13394 if (ret == -ENOTSUP)
13395 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13398 #ifdef RTE_LIBRTE_BNXT_PMD
13399 if (ret == -ENOTSUP)
13400 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13408 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13411 printf("invalid port_id %d\n", res->port_id);
13414 printf("function not implemented\n");
13417 printf("programming error: (%s)\n", strerror(-ret));
13421 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13422 .f = cmd_set_vf_mac_addr_parsed,
13424 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13426 (void *)&cmd_set_vf_mac_addr_set,
13427 (void *)&cmd_set_vf_mac_addr_vf,
13428 (void *)&cmd_set_vf_mac_addr_mac,
13429 (void *)&cmd_set_vf_mac_addr_addr,
13430 (void *)&cmd_set_vf_mac_addr_port_id,
13431 (void *)&cmd_set_vf_mac_addr_vf_id,
13432 (void *)&cmd_set_vf_mac_addr_mac_addr,
13437 /* MACsec configuration */
13439 /* Common result structure for MACsec offload enable */
13440 struct cmd_macsec_offload_on_result {
13441 cmdline_fixed_string_t set;
13442 cmdline_fixed_string_t macsec;
13443 cmdline_fixed_string_t offload;
13445 cmdline_fixed_string_t on;
13446 cmdline_fixed_string_t encrypt;
13447 cmdline_fixed_string_t en_on_off;
13448 cmdline_fixed_string_t replay_protect;
13449 cmdline_fixed_string_t rp_on_off;
13452 /* Common CLI fields for MACsec offload disable */
13453 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13454 TOKEN_STRING_INITIALIZER
13455 (struct cmd_macsec_offload_on_result,
13457 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13458 TOKEN_STRING_INITIALIZER
13459 (struct cmd_macsec_offload_on_result,
13461 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13462 TOKEN_STRING_INITIALIZER
13463 (struct cmd_macsec_offload_on_result,
13464 offload, "offload");
13465 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13466 TOKEN_NUM_INITIALIZER
13467 (struct cmd_macsec_offload_on_result,
13469 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13470 TOKEN_STRING_INITIALIZER
13471 (struct cmd_macsec_offload_on_result,
13473 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13474 TOKEN_STRING_INITIALIZER
13475 (struct cmd_macsec_offload_on_result,
13476 encrypt, "encrypt");
13477 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13478 TOKEN_STRING_INITIALIZER
13479 (struct cmd_macsec_offload_on_result,
13480 en_on_off, "on#off");
13481 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13482 TOKEN_STRING_INITIALIZER
13483 (struct cmd_macsec_offload_on_result,
13484 replay_protect, "replay-protect");
13485 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13486 TOKEN_STRING_INITIALIZER
13487 (struct cmd_macsec_offload_on_result,
13488 rp_on_off, "on#off");
13491 cmd_set_macsec_offload_on_parsed(
13492 void *parsed_result,
13493 __attribute__((unused)) struct cmdline *cl,
13494 __attribute__((unused)) void *data)
13496 struct cmd_macsec_offload_on_result *res = parsed_result;
13497 int ret = -ENOTSUP;
13498 portid_t port_id = res->port_id;
13499 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13500 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13501 struct rte_eth_dev_info dev_info;
13503 if (port_id_is_invalid(port_id, ENABLED_WARN))
13505 if (!port_is_stopped(port_id)) {
13506 printf("Please stop port %d first\n", port_id);
13510 rte_eth_dev_info_get(port_id, &dev_info);
13511 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13512 #ifdef RTE_LIBRTE_IXGBE_PMD
13513 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13521 ports[port_id].dev_conf.txmode.offloads |=
13522 DEV_TX_OFFLOAD_MACSEC_INSERT;
13523 cmd_reconfig_device_queue(port_id, 1, 1);
13526 printf("invalid port_id %d\n", port_id);
13529 printf("not supported on port %d\n", port_id);
13532 printf("programming error: (%s)\n", strerror(-ret));
13536 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13537 .f = cmd_set_macsec_offload_on_parsed,
13539 .help_str = "set macsec offload <port_id> on "
13540 "encrypt on|off replay-protect on|off",
13542 (void *)&cmd_macsec_offload_on_set,
13543 (void *)&cmd_macsec_offload_on_macsec,
13544 (void *)&cmd_macsec_offload_on_offload,
13545 (void *)&cmd_macsec_offload_on_port_id,
13546 (void *)&cmd_macsec_offload_on_on,
13547 (void *)&cmd_macsec_offload_on_encrypt,
13548 (void *)&cmd_macsec_offload_on_en_on_off,
13549 (void *)&cmd_macsec_offload_on_replay_protect,
13550 (void *)&cmd_macsec_offload_on_rp_on_off,
13555 /* Common result structure for MACsec offload disable */
13556 struct cmd_macsec_offload_off_result {
13557 cmdline_fixed_string_t set;
13558 cmdline_fixed_string_t macsec;
13559 cmdline_fixed_string_t offload;
13561 cmdline_fixed_string_t off;
13564 /* Common CLI fields for MACsec offload disable */
13565 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13566 TOKEN_STRING_INITIALIZER
13567 (struct cmd_macsec_offload_off_result,
13569 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13570 TOKEN_STRING_INITIALIZER
13571 (struct cmd_macsec_offload_off_result,
13573 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13574 TOKEN_STRING_INITIALIZER
13575 (struct cmd_macsec_offload_off_result,
13576 offload, "offload");
13577 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13578 TOKEN_NUM_INITIALIZER
13579 (struct cmd_macsec_offload_off_result,
13581 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13582 TOKEN_STRING_INITIALIZER
13583 (struct cmd_macsec_offload_off_result,
13587 cmd_set_macsec_offload_off_parsed(
13588 void *parsed_result,
13589 __attribute__((unused)) struct cmdline *cl,
13590 __attribute__((unused)) void *data)
13592 struct cmd_macsec_offload_off_result *res = parsed_result;
13593 int ret = -ENOTSUP;
13594 struct rte_eth_dev_info dev_info;
13595 portid_t port_id = res->port_id;
13597 if (port_id_is_invalid(port_id, ENABLED_WARN))
13599 if (!port_is_stopped(port_id)) {
13600 printf("Please stop port %d first\n", port_id);
13604 rte_eth_dev_info_get(port_id, &dev_info);
13605 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13606 #ifdef RTE_LIBRTE_IXGBE_PMD
13607 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13612 ports[port_id].dev_conf.txmode.offloads &=
13613 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13614 cmd_reconfig_device_queue(port_id, 1, 1);
13617 printf("invalid port_id %d\n", port_id);
13620 printf("not supported on port %d\n", port_id);
13623 printf("programming error: (%s)\n", strerror(-ret));
13627 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13628 .f = cmd_set_macsec_offload_off_parsed,
13630 .help_str = "set macsec offload <port_id> off",
13632 (void *)&cmd_macsec_offload_off_set,
13633 (void *)&cmd_macsec_offload_off_macsec,
13634 (void *)&cmd_macsec_offload_off_offload,
13635 (void *)&cmd_macsec_offload_off_port_id,
13636 (void *)&cmd_macsec_offload_off_off,
13641 /* Common result structure for MACsec secure connection configure */
13642 struct cmd_macsec_sc_result {
13643 cmdline_fixed_string_t set;
13644 cmdline_fixed_string_t macsec;
13645 cmdline_fixed_string_t sc;
13646 cmdline_fixed_string_t tx_rx;
13648 struct ether_addr mac;
13652 /* Common CLI fields for MACsec secure connection configure */
13653 cmdline_parse_token_string_t cmd_macsec_sc_set =
13654 TOKEN_STRING_INITIALIZER
13655 (struct cmd_macsec_sc_result,
13657 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13658 TOKEN_STRING_INITIALIZER
13659 (struct cmd_macsec_sc_result,
13661 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13662 TOKEN_STRING_INITIALIZER
13663 (struct cmd_macsec_sc_result,
13665 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13666 TOKEN_STRING_INITIALIZER
13667 (struct cmd_macsec_sc_result,
13669 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13670 TOKEN_NUM_INITIALIZER
13671 (struct cmd_macsec_sc_result,
13673 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13674 TOKEN_ETHERADDR_INITIALIZER
13675 (struct cmd_macsec_sc_result,
13677 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13678 TOKEN_NUM_INITIALIZER
13679 (struct cmd_macsec_sc_result,
13683 cmd_set_macsec_sc_parsed(
13684 void *parsed_result,
13685 __attribute__((unused)) struct cmdline *cl,
13686 __attribute__((unused)) void *data)
13688 struct cmd_macsec_sc_result *res = parsed_result;
13689 int ret = -ENOTSUP;
13690 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13692 #ifdef RTE_LIBRTE_IXGBE_PMD
13694 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13695 res->mac.addr_bytes) :
13696 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13697 res->mac.addr_bytes, res->pi);
13699 RTE_SET_USED(is_tx);
13705 printf("invalid port_id %d\n", res->port_id);
13708 printf("not supported on port %d\n", res->port_id);
13711 printf("programming error: (%s)\n", strerror(-ret));
13715 cmdline_parse_inst_t cmd_set_macsec_sc = {
13716 .f = cmd_set_macsec_sc_parsed,
13718 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13720 (void *)&cmd_macsec_sc_set,
13721 (void *)&cmd_macsec_sc_macsec,
13722 (void *)&cmd_macsec_sc_sc,
13723 (void *)&cmd_macsec_sc_tx_rx,
13724 (void *)&cmd_macsec_sc_port_id,
13725 (void *)&cmd_macsec_sc_mac,
13726 (void *)&cmd_macsec_sc_pi,
13731 /* Common result structure for MACsec secure connection configure */
13732 struct cmd_macsec_sa_result {
13733 cmdline_fixed_string_t set;
13734 cmdline_fixed_string_t macsec;
13735 cmdline_fixed_string_t sa;
13736 cmdline_fixed_string_t tx_rx;
13741 cmdline_fixed_string_t key;
13744 /* Common CLI fields for MACsec secure connection configure */
13745 cmdline_parse_token_string_t cmd_macsec_sa_set =
13746 TOKEN_STRING_INITIALIZER
13747 (struct cmd_macsec_sa_result,
13749 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13750 TOKEN_STRING_INITIALIZER
13751 (struct cmd_macsec_sa_result,
13753 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13754 TOKEN_STRING_INITIALIZER
13755 (struct cmd_macsec_sa_result,
13757 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13758 TOKEN_STRING_INITIALIZER
13759 (struct cmd_macsec_sa_result,
13761 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13762 TOKEN_NUM_INITIALIZER
13763 (struct cmd_macsec_sa_result,
13765 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13766 TOKEN_NUM_INITIALIZER
13767 (struct cmd_macsec_sa_result,
13769 cmdline_parse_token_num_t cmd_macsec_sa_an =
13770 TOKEN_NUM_INITIALIZER
13771 (struct cmd_macsec_sa_result,
13773 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13774 TOKEN_NUM_INITIALIZER
13775 (struct cmd_macsec_sa_result,
13777 cmdline_parse_token_string_t cmd_macsec_sa_key =
13778 TOKEN_STRING_INITIALIZER
13779 (struct cmd_macsec_sa_result,
13783 cmd_set_macsec_sa_parsed(
13784 void *parsed_result,
13785 __attribute__((unused)) struct cmdline *cl,
13786 __attribute__((unused)) void *data)
13788 struct cmd_macsec_sa_result *res = parsed_result;
13789 int ret = -ENOTSUP;
13790 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13791 uint8_t key[16] = { 0 };
13797 key_len = strlen(res->key) / 2;
13801 for (i = 0; i < key_len; i++) {
13802 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13805 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13808 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13811 #ifdef RTE_LIBRTE_IXGBE_PMD
13813 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13814 res->idx, res->an, res->pn, key) :
13815 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13816 res->idx, res->an, res->pn, key);
13818 RTE_SET_USED(is_tx);
13825 printf("invalid idx %d or an %d\n", res->idx, res->an);
13828 printf("invalid port_id %d\n", res->port_id);
13831 printf("not supported on port %d\n", res->port_id);
13834 printf("programming error: (%s)\n", strerror(-ret));
13838 cmdline_parse_inst_t cmd_set_macsec_sa = {
13839 .f = cmd_set_macsec_sa_parsed,
13841 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13843 (void *)&cmd_macsec_sa_set,
13844 (void *)&cmd_macsec_sa_macsec,
13845 (void *)&cmd_macsec_sa_sa,
13846 (void *)&cmd_macsec_sa_tx_rx,
13847 (void *)&cmd_macsec_sa_port_id,
13848 (void *)&cmd_macsec_sa_idx,
13849 (void *)&cmd_macsec_sa_an,
13850 (void *)&cmd_macsec_sa_pn,
13851 (void *)&cmd_macsec_sa_key,
13856 /* VF unicast promiscuous mode configuration */
13858 /* Common result structure for VF unicast promiscuous mode */
13859 struct cmd_vf_promisc_result {
13860 cmdline_fixed_string_t set;
13861 cmdline_fixed_string_t vf;
13862 cmdline_fixed_string_t promisc;
13865 cmdline_fixed_string_t on_off;
13868 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13869 cmdline_parse_token_string_t cmd_vf_promisc_set =
13870 TOKEN_STRING_INITIALIZER
13871 (struct cmd_vf_promisc_result,
13873 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13874 TOKEN_STRING_INITIALIZER
13875 (struct cmd_vf_promisc_result,
13877 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13878 TOKEN_STRING_INITIALIZER
13879 (struct cmd_vf_promisc_result,
13880 promisc, "promisc");
13881 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13882 TOKEN_NUM_INITIALIZER
13883 (struct cmd_vf_promisc_result,
13885 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13886 TOKEN_NUM_INITIALIZER
13887 (struct cmd_vf_promisc_result,
13889 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13890 TOKEN_STRING_INITIALIZER
13891 (struct cmd_vf_promisc_result,
13895 cmd_set_vf_promisc_parsed(
13896 void *parsed_result,
13897 __attribute__((unused)) struct cmdline *cl,
13898 __attribute__((unused)) void *data)
13900 struct cmd_vf_promisc_result *res = parsed_result;
13901 int ret = -ENOTSUP;
13903 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13908 #ifdef RTE_LIBRTE_I40E_PMD
13909 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13910 res->vf_id, is_on);
13917 printf("invalid vf_id %d\n", res->vf_id);
13920 printf("invalid port_id %d\n", res->port_id);
13923 printf("function not implemented\n");
13926 printf("programming error: (%s)\n", strerror(-ret));
13930 cmdline_parse_inst_t cmd_set_vf_promisc = {
13931 .f = cmd_set_vf_promisc_parsed,
13933 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13934 "Set unicast promiscuous mode for a VF from the PF",
13936 (void *)&cmd_vf_promisc_set,
13937 (void *)&cmd_vf_promisc_vf,
13938 (void *)&cmd_vf_promisc_promisc,
13939 (void *)&cmd_vf_promisc_port_id,
13940 (void *)&cmd_vf_promisc_vf_id,
13941 (void *)&cmd_vf_promisc_on_off,
13946 /* VF multicast promiscuous mode configuration */
13948 /* Common result structure for VF multicast promiscuous mode */
13949 struct cmd_vf_allmulti_result {
13950 cmdline_fixed_string_t set;
13951 cmdline_fixed_string_t vf;
13952 cmdline_fixed_string_t allmulti;
13955 cmdline_fixed_string_t on_off;
13958 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13959 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13960 TOKEN_STRING_INITIALIZER
13961 (struct cmd_vf_allmulti_result,
13963 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13964 TOKEN_STRING_INITIALIZER
13965 (struct cmd_vf_allmulti_result,
13967 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13968 TOKEN_STRING_INITIALIZER
13969 (struct cmd_vf_allmulti_result,
13970 allmulti, "allmulti");
13971 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13972 TOKEN_NUM_INITIALIZER
13973 (struct cmd_vf_allmulti_result,
13975 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13976 TOKEN_NUM_INITIALIZER
13977 (struct cmd_vf_allmulti_result,
13979 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13980 TOKEN_STRING_INITIALIZER
13981 (struct cmd_vf_allmulti_result,
13985 cmd_set_vf_allmulti_parsed(
13986 void *parsed_result,
13987 __attribute__((unused)) struct cmdline *cl,
13988 __attribute__((unused)) void *data)
13990 struct cmd_vf_allmulti_result *res = parsed_result;
13991 int ret = -ENOTSUP;
13993 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13995 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13998 #ifdef RTE_LIBRTE_I40E_PMD
13999 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14000 res->vf_id, is_on);
14007 printf("invalid vf_id %d\n", res->vf_id);
14010 printf("invalid port_id %d\n", res->port_id);
14013 printf("function not implemented\n");
14016 printf("programming error: (%s)\n", strerror(-ret));
14020 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14021 .f = cmd_set_vf_allmulti_parsed,
14023 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14024 "Set multicast promiscuous mode for a VF from the PF",
14026 (void *)&cmd_vf_allmulti_set,
14027 (void *)&cmd_vf_allmulti_vf,
14028 (void *)&cmd_vf_allmulti_allmulti,
14029 (void *)&cmd_vf_allmulti_port_id,
14030 (void *)&cmd_vf_allmulti_vf_id,
14031 (void *)&cmd_vf_allmulti_on_off,
14036 /* vf broadcast mode configuration */
14038 /* Common result structure for vf broadcast */
14039 struct cmd_set_vf_broadcast_result {
14040 cmdline_fixed_string_t set;
14041 cmdline_fixed_string_t vf;
14042 cmdline_fixed_string_t broadcast;
14045 cmdline_fixed_string_t on_off;
14048 /* Common CLI fields for vf broadcast enable disable */
14049 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14050 TOKEN_STRING_INITIALIZER
14051 (struct cmd_set_vf_broadcast_result,
14053 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14054 TOKEN_STRING_INITIALIZER
14055 (struct cmd_set_vf_broadcast_result,
14057 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14058 TOKEN_STRING_INITIALIZER
14059 (struct cmd_set_vf_broadcast_result,
14060 broadcast, "broadcast");
14061 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14062 TOKEN_NUM_INITIALIZER
14063 (struct cmd_set_vf_broadcast_result,
14065 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14066 TOKEN_NUM_INITIALIZER
14067 (struct cmd_set_vf_broadcast_result,
14069 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14070 TOKEN_STRING_INITIALIZER
14071 (struct cmd_set_vf_broadcast_result,
14075 cmd_set_vf_broadcast_parsed(
14076 void *parsed_result,
14077 __attribute__((unused)) struct cmdline *cl,
14078 __attribute__((unused)) void *data)
14080 struct cmd_set_vf_broadcast_result *res = parsed_result;
14081 int ret = -ENOTSUP;
14083 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14085 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14088 #ifdef RTE_LIBRTE_I40E_PMD
14089 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14090 res->vf_id, is_on);
14097 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14100 printf("invalid port_id %d\n", res->port_id);
14103 printf("function not implemented\n");
14106 printf("programming error: (%s)\n", strerror(-ret));
14110 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14111 .f = cmd_set_vf_broadcast_parsed,
14113 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14115 (void *)&cmd_set_vf_broadcast_set,
14116 (void *)&cmd_set_vf_broadcast_vf,
14117 (void *)&cmd_set_vf_broadcast_broadcast,
14118 (void *)&cmd_set_vf_broadcast_port_id,
14119 (void *)&cmd_set_vf_broadcast_vf_id,
14120 (void *)&cmd_set_vf_broadcast_on_off,
14125 /* vf vlan tag configuration */
14127 /* Common result structure for vf vlan tag */
14128 struct cmd_set_vf_vlan_tag_result {
14129 cmdline_fixed_string_t set;
14130 cmdline_fixed_string_t vf;
14131 cmdline_fixed_string_t vlan;
14132 cmdline_fixed_string_t tag;
14135 cmdline_fixed_string_t on_off;
14138 /* Common CLI fields for vf vlan tag enable disable */
14139 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14140 TOKEN_STRING_INITIALIZER
14141 (struct cmd_set_vf_vlan_tag_result,
14143 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14144 TOKEN_STRING_INITIALIZER
14145 (struct cmd_set_vf_vlan_tag_result,
14147 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14148 TOKEN_STRING_INITIALIZER
14149 (struct cmd_set_vf_vlan_tag_result,
14151 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14152 TOKEN_STRING_INITIALIZER
14153 (struct cmd_set_vf_vlan_tag_result,
14155 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14156 TOKEN_NUM_INITIALIZER
14157 (struct cmd_set_vf_vlan_tag_result,
14159 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14160 TOKEN_NUM_INITIALIZER
14161 (struct cmd_set_vf_vlan_tag_result,
14163 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14164 TOKEN_STRING_INITIALIZER
14165 (struct cmd_set_vf_vlan_tag_result,
14169 cmd_set_vf_vlan_tag_parsed(
14170 void *parsed_result,
14171 __attribute__((unused)) struct cmdline *cl,
14172 __attribute__((unused)) void *data)
14174 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14175 int ret = -ENOTSUP;
14177 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14179 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14182 #ifdef RTE_LIBRTE_I40E_PMD
14183 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14184 res->vf_id, is_on);
14191 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14194 printf("invalid port_id %d\n", res->port_id);
14197 printf("function not implemented\n");
14200 printf("programming error: (%s)\n", strerror(-ret));
14204 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14205 .f = cmd_set_vf_vlan_tag_parsed,
14207 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14209 (void *)&cmd_set_vf_vlan_tag_set,
14210 (void *)&cmd_set_vf_vlan_tag_vf,
14211 (void *)&cmd_set_vf_vlan_tag_vlan,
14212 (void *)&cmd_set_vf_vlan_tag_tag,
14213 (void *)&cmd_set_vf_vlan_tag_port_id,
14214 (void *)&cmd_set_vf_vlan_tag_vf_id,
14215 (void *)&cmd_set_vf_vlan_tag_on_off,
14220 /* Common definition of VF and TC TX bandwidth configuration */
14221 struct cmd_vf_tc_bw_result {
14222 cmdline_fixed_string_t set;
14223 cmdline_fixed_string_t vf;
14224 cmdline_fixed_string_t tc;
14225 cmdline_fixed_string_t tx;
14226 cmdline_fixed_string_t min_bw;
14227 cmdline_fixed_string_t max_bw;
14228 cmdline_fixed_string_t strict_link_prio;
14233 cmdline_fixed_string_t bw_list;
14237 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14238 TOKEN_STRING_INITIALIZER
14239 (struct cmd_vf_tc_bw_result,
14241 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14242 TOKEN_STRING_INITIALIZER
14243 (struct cmd_vf_tc_bw_result,
14245 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14246 TOKEN_STRING_INITIALIZER
14247 (struct cmd_vf_tc_bw_result,
14249 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14250 TOKEN_STRING_INITIALIZER
14251 (struct cmd_vf_tc_bw_result,
14253 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14254 TOKEN_STRING_INITIALIZER
14255 (struct cmd_vf_tc_bw_result,
14256 strict_link_prio, "strict-link-priority");
14257 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14258 TOKEN_STRING_INITIALIZER
14259 (struct cmd_vf_tc_bw_result,
14260 min_bw, "min-bandwidth");
14261 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14262 TOKEN_STRING_INITIALIZER
14263 (struct cmd_vf_tc_bw_result,
14264 max_bw, "max-bandwidth");
14265 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14266 TOKEN_NUM_INITIALIZER
14267 (struct cmd_vf_tc_bw_result,
14269 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14270 TOKEN_NUM_INITIALIZER
14271 (struct cmd_vf_tc_bw_result,
14273 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14274 TOKEN_NUM_INITIALIZER
14275 (struct cmd_vf_tc_bw_result,
14277 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14278 TOKEN_NUM_INITIALIZER
14279 (struct cmd_vf_tc_bw_result,
14281 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14282 TOKEN_STRING_INITIALIZER
14283 (struct cmd_vf_tc_bw_result,
14285 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14286 TOKEN_NUM_INITIALIZER
14287 (struct cmd_vf_tc_bw_result,
14290 /* VF max bandwidth setting */
14292 cmd_vf_max_bw_parsed(
14293 void *parsed_result,
14294 __attribute__((unused)) struct cmdline *cl,
14295 __attribute__((unused)) void *data)
14297 struct cmd_vf_tc_bw_result *res = parsed_result;
14298 int ret = -ENOTSUP;
14300 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14303 #ifdef RTE_LIBRTE_I40E_PMD
14304 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14305 res->vf_id, res->bw);
14312 printf("invalid vf_id %d or bandwidth %d\n",
14313 res->vf_id, res->bw);
14316 printf("invalid port_id %d\n", res->port_id);
14319 printf("function not implemented\n");
14322 printf("programming error: (%s)\n", strerror(-ret));
14326 cmdline_parse_inst_t cmd_vf_max_bw = {
14327 .f = cmd_vf_max_bw_parsed,
14329 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14331 (void *)&cmd_vf_tc_bw_set,
14332 (void *)&cmd_vf_tc_bw_vf,
14333 (void *)&cmd_vf_tc_bw_tx,
14334 (void *)&cmd_vf_tc_bw_max_bw,
14335 (void *)&cmd_vf_tc_bw_port_id,
14336 (void *)&cmd_vf_tc_bw_vf_id,
14337 (void *)&cmd_vf_tc_bw_bw,
14343 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14348 const char *p, *p0 = str;
14355 p = strchr(p0, '(');
14357 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14361 p0 = strchr(p, ')');
14363 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14367 if (size >= sizeof(s)) {
14368 printf("The string size exceeds the internal buffer size\n");
14371 snprintf(s, sizeof(s), "%.*s", size, p);
14372 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14374 printf("Failed to get the bandwidth list. ");
14378 for (i = 0; i < ret; i++)
14379 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14384 /* TC min bandwidth setting */
14386 cmd_vf_tc_min_bw_parsed(
14387 void *parsed_result,
14388 __attribute__((unused)) struct cmdline *cl,
14389 __attribute__((unused)) void *data)
14391 struct cmd_vf_tc_bw_result *res = parsed_result;
14394 int ret = -ENOTSUP;
14396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14399 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14403 #ifdef RTE_LIBRTE_I40E_PMD
14404 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14412 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14415 printf("invalid port_id %d\n", res->port_id);
14418 printf("function not implemented\n");
14421 printf("programming error: (%s)\n", strerror(-ret));
14425 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14426 .f = cmd_vf_tc_min_bw_parsed,
14428 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14429 " <bw1, bw2, ...>",
14431 (void *)&cmd_vf_tc_bw_set,
14432 (void *)&cmd_vf_tc_bw_vf,
14433 (void *)&cmd_vf_tc_bw_tc,
14434 (void *)&cmd_vf_tc_bw_tx,
14435 (void *)&cmd_vf_tc_bw_min_bw,
14436 (void *)&cmd_vf_tc_bw_port_id,
14437 (void *)&cmd_vf_tc_bw_vf_id,
14438 (void *)&cmd_vf_tc_bw_bw_list,
14444 cmd_tc_min_bw_parsed(
14445 void *parsed_result,
14446 __attribute__((unused)) struct cmdline *cl,
14447 __attribute__((unused)) void *data)
14449 struct cmd_vf_tc_bw_result *res = parsed_result;
14450 struct rte_port *port;
14453 int ret = -ENOTSUP;
14455 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14458 port = &ports[res->port_id];
14459 /** Check if the port is not started **/
14460 if (port->port_status != RTE_PORT_STOPPED) {
14461 printf("Please stop port %d first\n", res->port_id);
14465 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14469 #ifdef RTE_LIBRTE_IXGBE_PMD
14470 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14477 printf("invalid bandwidth\n");
14480 printf("invalid port_id %d\n", res->port_id);
14483 printf("function not implemented\n");
14486 printf("programming error: (%s)\n", strerror(-ret));
14490 cmdline_parse_inst_t cmd_tc_min_bw = {
14491 .f = cmd_tc_min_bw_parsed,
14493 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14495 (void *)&cmd_vf_tc_bw_set,
14496 (void *)&cmd_vf_tc_bw_tc,
14497 (void *)&cmd_vf_tc_bw_tx,
14498 (void *)&cmd_vf_tc_bw_min_bw,
14499 (void *)&cmd_vf_tc_bw_port_id,
14500 (void *)&cmd_vf_tc_bw_bw_list,
14505 /* TC max bandwidth setting */
14507 cmd_vf_tc_max_bw_parsed(
14508 void *parsed_result,
14509 __attribute__((unused)) struct cmdline *cl,
14510 __attribute__((unused)) void *data)
14512 struct cmd_vf_tc_bw_result *res = parsed_result;
14513 int ret = -ENOTSUP;
14515 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14518 #ifdef RTE_LIBRTE_I40E_PMD
14519 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14520 res->tc_no, res->bw);
14527 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14528 res->vf_id, res->tc_no, res->bw);
14531 printf("invalid port_id %d\n", res->port_id);
14534 printf("function not implemented\n");
14537 printf("programming error: (%s)\n", strerror(-ret));
14541 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14542 .f = cmd_vf_tc_max_bw_parsed,
14544 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14547 (void *)&cmd_vf_tc_bw_set,
14548 (void *)&cmd_vf_tc_bw_vf,
14549 (void *)&cmd_vf_tc_bw_tc,
14550 (void *)&cmd_vf_tc_bw_tx,
14551 (void *)&cmd_vf_tc_bw_max_bw,
14552 (void *)&cmd_vf_tc_bw_port_id,
14553 (void *)&cmd_vf_tc_bw_vf_id,
14554 (void *)&cmd_vf_tc_bw_tc_no,
14555 (void *)&cmd_vf_tc_bw_bw,
14561 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14563 /* *** Set Port default Traffic Management Hierarchy *** */
14564 struct cmd_set_port_tm_hierarchy_default_result {
14565 cmdline_fixed_string_t set;
14566 cmdline_fixed_string_t port;
14567 cmdline_fixed_string_t tm;
14568 cmdline_fixed_string_t hierarchy;
14569 cmdline_fixed_string_t def;
14573 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14574 TOKEN_STRING_INITIALIZER(
14575 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14576 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14577 TOKEN_STRING_INITIALIZER(
14578 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14579 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14580 TOKEN_STRING_INITIALIZER(
14581 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14582 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14583 TOKEN_STRING_INITIALIZER(
14584 struct cmd_set_port_tm_hierarchy_default_result,
14585 hierarchy, "hierarchy");
14586 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14587 TOKEN_STRING_INITIALIZER(
14588 struct cmd_set_port_tm_hierarchy_default_result,
14590 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14591 TOKEN_NUM_INITIALIZER(
14592 struct cmd_set_port_tm_hierarchy_default_result,
14595 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14596 __attribute__((unused)) struct cmdline *cl,
14597 __attribute__((unused)) void *data)
14599 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14600 struct rte_port *p;
14601 portid_t port_id = res->port_id;
14603 if (port_id_is_invalid(port_id, ENABLED_WARN))
14606 p = &ports[port_id];
14609 if (p->softport.tm_flag == 0) {
14610 printf(" tm not enabled on port %u (error)\n", port_id);
14614 /* Forward mode: tm */
14615 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14616 printf(" tm mode not enabled(error)\n");
14620 /* Set the default tm hierarchy */
14621 p->softport.tm.default_hierarchy_enable = 1;
14624 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14625 .f = cmd_set_port_tm_hierarchy_default_parsed,
14627 .help_str = "set port tm hierarchy default <port_id>",
14629 (void *)&cmd_set_port_tm_hierarchy_default_set,
14630 (void *)&cmd_set_port_tm_hierarchy_default_port,
14631 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14632 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14633 (void *)&cmd_set_port_tm_hierarchy_default_default,
14634 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14640 /* Strict link priority scheduling mode setting */
14642 cmd_strict_link_prio_parsed(
14643 void *parsed_result,
14644 __attribute__((unused)) struct cmdline *cl,
14645 __attribute__((unused)) void *data)
14647 struct cmd_vf_tc_bw_result *res = parsed_result;
14648 int ret = -ENOTSUP;
14650 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14653 #ifdef RTE_LIBRTE_I40E_PMD
14654 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14661 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14664 printf("invalid port_id %d\n", res->port_id);
14667 printf("function not implemented\n");
14670 printf("programming error: (%s)\n", strerror(-ret));
14674 cmdline_parse_inst_t cmd_strict_link_prio = {
14675 .f = cmd_strict_link_prio_parsed,
14677 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14679 (void *)&cmd_vf_tc_bw_set,
14680 (void *)&cmd_vf_tc_bw_tx,
14681 (void *)&cmd_vf_tc_bw_strict_link_prio,
14682 (void *)&cmd_vf_tc_bw_port_id,
14683 (void *)&cmd_vf_tc_bw_tc_map,
14688 /* Load dynamic device personalization*/
14689 struct cmd_ddp_add_result {
14690 cmdline_fixed_string_t ddp;
14691 cmdline_fixed_string_t add;
14696 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14697 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14698 cmdline_parse_token_string_t cmd_ddp_add_add =
14699 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14700 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14701 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14702 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14703 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14706 cmd_ddp_add_parsed(
14707 void *parsed_result,
14708 __attribute__((unused)) struct cmdline *cl,
14709 __attribute__((unused)) void *data)
14711 struct cmd_ddp_add_result *res = parsed_result;
14717 int ret = -ENOTSUP;
14719 if (!all_ports_stopped()) {
14720 printf("Please stop all ports first\n");
14724 filepath = strdup(res->filepath);
14725 if (filepath == NULL) {
14726 printf("Failed to allocate memory\n");
14729 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14731 buff = open_file(file_fld[0], &size);
14733 free((void *)filepath);
14737 #ifdef RTE_LIBRTE_I40E_PMD
14738 if (ret == -ENOTSUP)
14739 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14741 RTE_PMD_I40E_PKG_OP_WR_ADD);
14744 if (ret == -EEXIST)
14745 printf("Profile has already existed.\n");
14747 printf("Failed to load profile.\n");
14748 else if (file_num == 2)
14749 save_file(file_fld[1], buff, size);
14752 free((void *)filepath);
14755 cmdline_parse_inst_t cmd_ddp_add = {
14756 .f = cmd_ddp_add_parsed,
14758 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14760 (void *)&cmd_ddp_add_ddp,
14761 (void *)&cmd_ddp_add_add,
14762 (void *)&cmd_ddp_add_port_id,
14763 (void *)&cmd_ddp_add_filepath,
14768 /* Delete dynamic device personalization*/
14769 struct cmd_ddp_del_result {
14770 cmdline_fixed_string_t ddp;
14771 cmdline_fixed_string_t del;
14776 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14777 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14778 cmdline_parse_token_string_t cmd_ddp_del_del =
14779 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14780 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14781 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14782 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14783 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14786 cmd_ddp_del_parsed(
14787 void *parsed_result,
14788 __attribute__((unused)) struct cmdline *cl,
14789 __attribute__((unused)) void *data)
14791 struct cmd_ddp_del_result *res = parsed_result;
14794 int ret = -ENOTSUP;
14796 if (!all_ports_stopped()) {
14797 printf("Please stop all ports first\n");
14801 buff = open_file(res->filepath, &size);
14805 #ifdef RTE_LIBRTE_I40E_PMD
14806 if (ret == -ENOTSUP)
14807 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14809 RTE_PMD_I40E_PKG_OP_WR_DEL);
14812 if (ret == -EACCES)
14813 printf("Profile does not exist.\n");
14815 printf("Failed to delete profile.\n");
14820 cmdline_parse_inst_t cmd_ddp_del = {
14821 .f = cmd_ddp_del_parsed,
14823 .help_str = "ddp del <port_id> <backup_profile_path>",
14825 (void *)&cmd_ddp_del_ddp,
14826 (void *)&cmd_ddp_del_del,
14827 (void *)&cmd_ddp_del_port_id,
14828 (void *)&cmd_ddp_del_filepath,
14833 /* Get dynamic device personalization profile info */
14834 struct cmd_ddp_info_result {
14835 cmdline_fixed_string_t ddp;
14836 cmdline_fixed_string_t get;
14837 cmdline_fixed_string_t info;
14841 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14842 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14843 cmdline_parse_token_string_t cmd_ddp_info_get =
14844 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14845 cmdline_parse_token_string_t cmd_ddp_info_info =
14846 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14847 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14848 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14851 cmd_ddp_info_parsed(
14852 void *parsed_result,
14853 __attribute__((unused)) struct cmdline *cl,
14854 __attribute__((unused)) void *data)
14856 struct cmd_ddp_info_result *res = parsed_result;
14859 int ret = -ENOTSUP;
14860 #ifdef RTE_LIBRTE_I40E_PMD
14863 uint32_t buff_size = 0;
14864 struct rte_pmd_i40e_profile_info info;
14865 uint32_t dev_num = 0;
14866 struct rte_pmd_i40e_ddp_device_id *devs;
14867 uint32_t proto_num = 0;
14868 struct rte_pmd_i40e_proto_info *proto = NULL;
14869 uint32_t pctype_num = 0;
14870 struct rte_pmd_i40e_ptype_info *pctype;
14871 uint32_t ptype_num = 0;
14872 struct rte_pmd_i40e_ptype_info *ptype;
14877 pkg = open_file(res->filepath, &pkg_size);
14881 #ifdef RTE_LIBRTE_I40E_PMD
14882 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14883 (uint8_t *)&info, sizeof(info),
14884 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14886 printf("Global Track id: 0x%x\n", info.track_id);
14887 printf("Global Version: %d.%d.%d.%d\n",
14888 info.version.major,
14889 info.version.minor,
14890 info.version.update,
14891 info.version.draft);
14892 printf("Global Package name: %s\n\n", info.name);
14895 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14896 (uint8_t *)&info, sizeof(info),
14897 RTE_PMD_I40E_PKG_INFO_HEADER);
14899 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14900 printf("i40e Profile Version: %d.%d.%d.%d\n",
14901 info.version.major,
14902 info.version.minor,
14903 info.version.update,
14904 info.version.draft);
14905 printf("i40e Profile name: %s\n\n", info.name);
14908 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14909 (uint8_t *)&buff_size, sizeof(buff_size),
14910 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14911 if (!ret && buff_size) {
14912 buff = (uint8_t *)malloc(buff_size);
14914 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14916 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14918 printf("Package Notes:\n%s\n\n", buff);
14923 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14924 (uint8_t *)&dev_num, sizeof(dev_num),
14925 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14926 if (!ret && dev_num) {
14927 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14928 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14930 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14931 (uint8_t *)devs, buff_size,
14932 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14934 printf("List of supported devices:\n");
14935 for (i = 0; i < dev_num; i++) {
14936 printf(" %04X:%04X %04X:%04X\n",
14937 devs[i].vendor_dev_id >> 16,
14938 devs[i].vendor_dev_id & 0xFFFF,
14939 devs[i].sub_vendor_dev_id >> 16,
14940 devs[i].sub_vendor_dev_id & 0xFFFF);
14948 /* get information about protocols and packet types */
14949 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14950 (uint8_t *)&proto_num, sizeof(proto_num),
14951 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14952 if (ret || !proto_num)
14953 goto no_print_return;
14955 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14956 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14958 goto no_print_return;
14960 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14962 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14964 printf("List of used protocols:\n");
14965 for (i = 0; i < proto_num; i++)
14966 printf(" %2u: %s\n", proto[i].proto_id,
14970 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14971 (uint8_t *)&pctype_num, sizeof(pctype_num),
14972 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14973 if (ret || !pctype_num)
14974 goto no_print_pctypes;
14976 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14977 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14979 goto no_print_pctypes;
14981 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14983 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14986 goto no_print_pctypes;
14989 printf("List of defined packet classification types:\n");
14990 for (i = 0; i < pctype_num; i++) {
14991 printf(" %2u:", pctype[i].ptype_id);
14992 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14993 proto_id = pctype[i].protocols[j];
14994 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14995 for (n = 0; n < proto_num; n++) {
14996 if (proto[n].proto_id == proto_id) {
14997 printf(" %s", proto[n].name);
15010 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15012 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15013 if (ret || !ptype_num)
15014 goto no_print_return;
15016 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15017 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15019 goto no_print_return;
15021 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15023 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15026 goto no_print_return;
15028 printf("List of defined packet types:\n");
15029 for (i = 0; i < ptype_num; i++) {
15030 printf(" %2u:", ptype[i].ptype_id);
15031 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15032 proto_id = ptype[i].protocols[j];
15033 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15034 for (n = 0; n < proto_num; n++) {
15035 if (proto[n].proto_id == proto_id) {
15036 printf(" %s", proto[n].name);
15052 if (ret == -ENOTSUP)
15053 printf("Function not supported in PMD driver\n");
15057 cmdline_parse_inst_t cmd_ddp_get_info = {
15058 .f = cmd_ddp_info_parsed,
15060 .help_str = "ddp get info <profile_path>",
15062 (void *)&cmd_ddp_info_ddp,
15063 (void *)&cmd_ddp_info_get,
15064 (void *)&cmd_ddp_info_info,
15065 (void *)&cmd_ddp_info_filepath,
15070 /* Get dynamic device personalization profile info list*/
15071 #define PROFILE_INFO_SIZE 48
15072 #define MAX_PROFILE_NUM 16
15074 struct cmd_ddp_get_list_result {
15075 cmdline_fixed_string_t ddp;
15076 cmdline_fixed_string_t get;
15077 cmdline_fixed_string_t list;
15081 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15082 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15083 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15084 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15085 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15086 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15087 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15088 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15091 cmd_ddp_get_list_parsed(
15092 __attribute__((unused)) void *parsed_result,
15093 __attribute__((unused)) struct cmdline *cl,
15094 __attribute__((unused)) void *data)
15096 #ifdef RTE_LIBRTE_I40E_PMD
15097 struct cmd_ddp_get_list_result *res = parsed_result;
15098 struct rte_pmd_i40e_profile_list *p_list;
15099 struct rte_pmd_i40e_profile_info *p_info;
15104 int ret = -ENOTSUP;
15106 #ifdef RTE_LIBRTE_I40E_PMD
15107 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15108 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15110 printf("%s: Failed to malloc buffer\n", __func__);
15112 if (ret == -ENOTSUP)
15113 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15114 (uint8_t *)p_list, size);
15117 p_num = p_list->p_count;
15118 printf("Profile number is: %d\n\n", p_num);
15120 for (i = 0; i < p_num; i++) {
15121 p_info = &p_list->p_info[i];
15122 printf("Profile %d:\n", i);
15123 printf("Track id: 0x%x\n", p_info->track_id);
15124 printf("Version: %d.%d.%d.%d\n",
15125 p_info->version.major,
15126 p_info->version.minor,
15127 p_info->version.update,
15128 p_info->version.draft);
15129 printf("Profile name: %s\n\n", p_info->name);
15137 printf("Failed to get ddp list\n");
15140 cmdline_parse_inst_t cmd_ddp_get_list = {
15141 .f = cmd_ddp_get_list_parsed,
15143 .help_str = "ddp get list <port_id>",
15145 (void *)&cmd_ddp_get_list_ddp,
15146 (void *)&cmd_ddp_get_list_get,
15147 (void *)&cmd_ddp_get_list_list,
15148 (void *)&cmd_ddp_get_list_port_id,
15153 /* Configure input set */
15154 struct cmd_cfg_input_set_result {
15155 cmdline_fixed_string_t port;
15156 cmdline_fixed_string_t cfg;
15158 cmdline_fixed_string_t pctype;
15160 cmdline_fixed_string_t inset_type;
15161 cmdline_fixed_string_t opt;
15162 cmdline_fixed_string_t field;
15167 cmd_cfg_input_set_parsed(
15168 __attribute__((unused)) void *parsed_result,
15169 __attribute__((unused)) struct cmdline *cl,
15170 __attribute__((unused)) void *data)
15172 #ifdef RTE_LIBRTE_I40E_PMD
15173 struct cmd_cfg_input_set_result *res = parsed_result;
15174 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15175 struct rte_pmd_i40e_inset inset;
15177 int ret = -ENOTSUP;
15179 if (!all_ports_stopped()) {
15180 printf("Please stop all ports first\n");
15184 #ifdef RTE_LIBRTE_I40E_PMD
15185 if (!strcmp(res->inset_type, "hash_inset"))
15186 inset_type = INSET_HASH;
15187 else if (!strcmp(res->inset_type, "fdir_inset"))
15188 inset_type = INSET_FDIR;
15189 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15190 inset_type = INSET_FDIR_FLX;
15191 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15192 &inset, inset_type);
15194 printf("Failed to get input set.\n");
15198 if (!strcmp(res->opt, "get")) {
15199 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15202 printf("Field index %d is enabled.\n", res->field_idx);
15204 printf("Field index %d is disabled.\n", res->field_idx);
15206 } else if (!strcmp(res->opt, "set"))
15207 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15209 else if (!strcmp(res->opt, "clear"))
15210 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15213 printf("Failed to configure input set field.\n");
15217 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15218 &inset, inset_type);
15220 printf("Failed to set input set.\n");
15225 if (ret == -ENOTSUP)
15226 printf("Function not supported\n");
15229 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15230 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15232 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15233 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15235 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15236 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15238 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15239 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15241 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15242 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15244 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15245 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15247 "hash_inset#fdir_inset#fdir_flx_inset");
15248 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15249 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15250 opt, "get#set#clear");
15251 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15252 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15254 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15255 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15258 cmdline_parse_inst_t cmd_cfg_input_set = {
15259 .f = cmd_cfg_input_set_parsed,
15261 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15262 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15264 (void *)&cmd_cfg_input_set_port,
15265 (void *)&cmd_cfg_input_set_cfg,
15266 (void *)&cmd_cfg_input_set_port_id,
15267 (void *)&cmd_cfg_input_set_pctype,
15268 (void *)&cmd_cfg_input_set_pctype_id,
15269 (void *)&cmd_cfg_input_set_inset_type,
15270 (void *)&cmd_cfg_input_set_opt,
15271 (void *)&cmd_cfg_input_set_field,
15272 (void *)&cmd_cfg_input_set_field_idx,
15277 /* Clear input set */
15278 struct cmd_clear_input_set_result {
15279 cmdline_fixed_string_t port;
15280 cmdline_fixed_string_t cfg;
15282 cmdline_fixed_string_t pctype;
15284 cmdline_fixed_string_t inset_type;
15285 cmdline_fixed_string_t clear;
15286 cmdline_fixed_string_t all;
15290 cmd_clear_input_set_parsed(
15291 __attribute__((unused)) void *parsed_result,
15292 __attribute__((unused)) struct cmdline *cl,
15293 __attribute__((unused)) void *data)
15295 #ifdef RTE_LIBRTE_I40E_PMD
15296 struct cmd_clear_input_set_result *res = parsed_result;
15297 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15298 struct rte_pmd_i40e_inset inset;
15300 int ret = -ENOTSUP;
15302 if (!all_ports_stopped()) {
15303 printf("Please stop all ports first\n");
15307 #ifdef RTE_LIBRTE_I40E_PMD
15308 if (!strcmp(res->inset_type, "hash_inset"))
15309 inset_type = INSET_HASH;
15310 else if (!strcmp(res->inset_type, "fdir_inset"))
15311 inset_type = INSET_FDIR;
15312 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15313 inset_type = INSET_FDIR_FLX;
15315 memset(&inset, 0, sizeof(inset));
15317 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15318 &inset, inset_type);
15320 printf("Failed to clear input set.\n");
15326 if (ret == -ENOTSUP)
15327 printf("Function not supported\n");
15330 cmdline_parse_token_string_t cmd_clear_input_set_port =
15331 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15333 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15334 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15336 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15337 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15339 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15340 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15342 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15343 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15345 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15346 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15348 "hash_inset#fdir_inset#fdir_flx_inset");
15349 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15350 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15352 cmdline_parse_token_string_t cmd_clear_input_set_all =
15353 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15356 cmdline_parse_inst_t cmd_clear_input_set = {
15357 .f = cmd_clear_input_set_parsed,
15359 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15360 "fdir_inset|fdir_flx_inset clear all",
15362 (void *)&cmd_clear_input_set_port,
15363 (void *)&cmd_clear_input_set_cfg,
15364 (void *)&cmd_clear_input_set_port_id,
15365 (void *)&cmd_clear_input_set_pctype,
15366 (void *)&cmd_clear_input_set_pctype_id,
15367 (void *)&cmd_clear_input_set_inset_type,
15368 (void *)&cmd_clear_input_set_clear,
15369 (void *)&cmd_clear_input_set_all,
15374 /* show vf stats */
15376 /* Common result structure for show vf stats */
15377 struct cmd_show_vf_stats_result {
15378 cmdline_fixed_string_t show;
15379 cmdline_fixed_string_t vf;
15380 cmdline_fixed_string_t stats;
15385 /* Common CLI fields show vf stats*/
15386 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15387 TOKEN_STRING_INITIALIZER
15388 (struct cmd_show_vf_stats_result,
15390 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15391 TOKEN_STRING_INITIALIZER
15392 (struct cmd_show_vf_stats_result,
15394 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15395 TOKEN_STRING_INITIALIZER
15396 (struct cmd_show_vf_stats_result,
15398 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15399 TOKEN_NUM_INITIALIZER
15400 (struct cmd_show_vf_stats_result,
15402 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15403 TOKEN_NUM_INITIALIZER
15404 (struct cmd_show_vf_stats_result,
15408 cmd_show_vf_stats_parsed(
15409 void *parsed_result,
15410 __attribute__((unused)) struct cmdline *cl,
15411 __attribute__((unused)) void *data)
15413 struct cmd_show_vf_stats_result *res = parsed_result;
15414 struct rte_eth_stats stats;
15415 int ret = -ENOTSUP;
15416 static const char *nic_stats_border = "########################";
15418 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15421 memset(&stats, 0, sizeof(stats));
15423 #ifdef RTE_LIBRTE_I40E_PMD
15424 if (ret == -ENOTSUP)
15425 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15429 #ifdef RTE_LIBRTE_BNXT_PMD
15430 if (ret == -ENOTSUP)
15431 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15440 printf("invalid vf_id %d\n", res->vf_id);
15443 printf("invalid port_id %d\n", res->port_id);
15446 printf("function not implemented\n");
15449 printf("programming error: (%s)\n", strerror(-ret));
15452 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15453 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15455 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15457 stats.ipackets, stats.imissed, stats.ibytes);
15458 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15459 printf(" RX-nombuf: %-10"PRIu64"\n",
15461 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15463 stats.opackets, stats.oerrors, stats.obytes);
15465 printf(" %s############################%s\n",
15466 nic_stats_border, nic_stats_border);
15469 cmdline_parse_inst_t cmd_show_vf_stats = {
15470 .f = cmd_show_vf_stats_parsed,
15472 .help_str = "show vf stats <port_id> <vf_id>",
15474 (void *)&cmd_show_vf_stats_show,
15475 (void *)&cmd_show_vf_stats_vf,
15476 (void *)&cmd_show_vf_stats_stats,
15477 (void *)&cmd_show_vf_stats_port_id,
15478 (void *)&cmd_show_vf_stats_vf_id,
15483 /* clear vf stats */
15485 /* Common result structure for clear vf stats */
15486 struct cmd_clear_vf_stats_result {
15487 cmdline_fixed_string_t clear;
15488 cmdline_fixed_string_t vf;
15489 cmdline_fixed_string_t stats;
15494 /* Common CLI fields clear vf stats*/
15495 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15496 TOKEN_STRING_INITIALIZER
15497 (struct cmd_clear_vf_stats_result,
15499 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15500 TOKEN_STRING_INITIALIZER
15501 (struct cmd_clear_vf_stats_result,
15503 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15504 TOKEN_STRING_INITIALIZER
15505 (struct cmd_clear_vf_stats_result,
15507 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15508 TOKEN_NUM_INITIALIZER
15509 (struct cmd_clear_vf_stats_result,
15511 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15512 TOKEN_NUM_INITIALIZER
15513 (struct cmd_clear_vf_stats_result,
15517 cmd_clear_vf_stats_parsed(
15518 void *parsed_result,
15519 __attribute__((unused)) struct cmdline *cl,
15520 __attribute__((unused)) void *data)
15522 struct cmd_clear_vf_stats_result *res = parsed_result;
15523 int ret = -ENOTSUP;
15525 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15528 #ifdef RTE_LIBRTE_I40E_PMD
15529 if (ret == -ENOTSUP)
15530 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15533 #ifdef RTE_LIBRTE_BNXT_PMD
15534 if (ret == -ENOTSUP)
15535 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15543 printf("invalid vf_id %d\n", res->vf_id);
15546 printf("invalid port_id %d\n", res->port_id);
15549 printf("function not implemented\n");
15552 printf("programming error: (%s)\n", strerror(-ret));
15556 cmdline_parse_inst_t cmd_clear_vf_stats = {
15557 .f = cmd_clear_vf_stats_parsed,
15559 .help_str = "clear vf stats <port_id> <vf_id>",
15561 (void *)&cmd_clear_vf_stats_clear,
15562 (void *)&cmd_clear_vf_stats_vf,
15563 (void *)&cmd_clear_vf_stats_stats,
15564 (void *)&cmd_clear_vf_stats_port_id,
15565 (void *)&cmd_clear_vf_stats_vf_id,
15570 /* port config pctype mapping reset */
15572 /* Common result structure for port config pctype mapping reset */
15573 struct cmd_pctype_mapping_reset_result {
15574 cmdline_fixed_string_t port;
15575 cmdline_fixed_string_t config;
15577 cmdline_fixed_string_t pctype;
15578 cmdline_fixed_string_t mapping;
15579 cmdline_fixed_string_t reset;
15582 /* Common CLI fields for port config pctype mapping reset*/
15583 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15584 TOKEN_STRING_INITIALIZER
15585 (struct cmd_pctype_mapping_reset_result,
15587 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15588 TOKEN_STRING_INITIALIZER
15589 (struct cmd_pctype_mapping_reset_result,
15591 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15592 TOKEN_NUM_INITIALIZER
15593 (struct cmd_pctype_mapping_reset_result,
15595 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15596 TOKEN_STRING_INITIALIZER
15597 (struct cmd_pctype_mapping_reset_result,
15599 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15600 TOKEN_STRING_INITIALIZER
15601 (struct cmd_pctype_mapping_reset_result,
15602 mapping, "mapping");
15603 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15604 TOKEN_STRING_INITIALIZER
15605 (struct cmd_pctype_mapping_reset_result,
15609 cmd_pctype_mapping_reset_parsed(
15610 void *parsed_result,
15611 __attribute__((unused)) struct cmdline *cl,
15612 __attribute__((unused)) void *data)
15614 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15615 int ret = -ENOTSUP;
15617 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15620 #ifdef RTE_LIBRTE_I40E_PMD
15621 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15628 printf("invalid port_id %d\n", res->port_id);
15631 printf("function not implemented\n");
15634 printf("programming error: (%s)\n", strerror(-ret));
15638 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15639 .f = cmd_pctype_mapping_reset_parsed,
15641 .help_str = "port config <port_id> pctype mapping reset",
15643 (void *)&cmd_pctype_mapping_reset_port,
15644 (void *)&cmd_pctype_mapping_reset_config,
15645 (void *)&cmd_pctype_mapping_reset_port_id,
15646 (void *)&cmd_pctype_mapping_reset_pctype,
15647 (void *)&cmd_pctype_mapping_reset_mapping,
15648 (void *)&cmd_pctype_mapping_reset_reset,
15653 /* show port pctype mapping */
15655 /* Common result structure for show port pctype mapping */
15656 struct cmd_pctype_mapping_get_result {
15657 cmdline_fixed_string_t show;
15658 cmdline_fixed_string_t port;
15660 cmdline_fixed_string_t pctype;
15661 cmdline_fixed_string_t mapping;
15664 /* Common CLI fields for pctype mapping get */
15665 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15666 TOKEN_STRING_INITIALIZER
15667 (struct cmd_pctype_mapping_get_result,
15669 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15670 TOKEN_STRING_INITIALIZER
15671 (struct cmd_pctype_mapping_get_result,
15673 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15674 TOKEN_NUM_INITIALIZER
15675 (struct cmd_pctype_mapping_get_result,
15677 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15678 TOKEN_STRING_INITIALIZER
15679 (struct cmd_pctype_mapping_get_result,
15681 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15682 TOKEN_STRING_INITIALIZER
15683 (struct cmd_pctype_mapping_get_result,
15684 mapping, "mapping");
15687 cmd_pctype_mapping_get_parsed(
15688 void *parsed_result,
15689 __attribute__((unused)) struct cmdline *cl,
15690 __attribute__((unused)) void *data)
15692 struct cmd_pctype_mapping_get_result *res = parsed_result;
15693 int ret = -ENOTSUP;
15694 #ifdef RTE_LIBRTE_I40E_PMD
15695 struct rte_pmd_i40e_flow_type_mapping
15696 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15697 int i, j, first_pctype;
15700 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15703 #ifdef RTE_LIBRTE_I40E_PMD
15704 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15711 printf("invalid port_id %d\n", res->port_id);
15714 printf("function not implemented\n");
15717 printf("programming error: (%s)\n", strerror(-ret));
15721 #ifdef RTE_LIBRTE_I40E_PMD
15722 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15723 if (mapping[i].pctype != 0ULL) {
15726 printf("pctype: ");
15727 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15728 if (mapping[i].pctype & (1ULL << j)) {
15729 printf(first_pctype ?
15730 "%02d" : ",%02d", j);
15734 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15740 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15741 .f = cmd_pctype_mapping_get_parsed,
15743 .help_str = "show port <port_id> pctype mapping",
15745 (void *)&cmd_pctype_mapping_get_show,
15746 (void *)&cmd_pctype_mapping_get_port,
15747 (void *)&cmd_pctype_mapping_get_port_id,
15748 (void *)&cmd_pctype_mapping_get_pctype,
15749 (void *)&cmd_pctype_mapping_get_mapping,
15754 /* port config pctype mapping update */
15756 /* Common result structure for port config pctype mapping update */
15757 struct cmd_pctype_mapping_update_result {
15758 cmdline_fixed_string_t port;
15759 cmdline_fixed_string_t config;
15761 cmdline_fixed_string_t pctype;
15762 cmdline_fixed_string_t mapping;
15763 cmdline_fixed_string_t update;
15764 cmdline_fixed_string_t pctype_list;
15765 uint16_t flow_type;
15768 /* Common CLI fields for pctype mapping update*/
15769 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15770 TOKEN_STRING_INITIALIZER
15771 (struct cmd_pctype_mapping_update_result,
15773 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15774 TOKEN_STRING_INITIALIZER
15775 (struct cmd_pctype_mapping_update_result,
15777 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15778 TOKEN_NUM_INITIALIZER
15779 (struct cmd_pctype_mapping_update_result,
15781 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15782 TOKEN_STRING_INITIALIZER
15783 (struct cmd_pctype_mapping_update_result,
15785 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15786 TOKEN_STRING_INITIALIZER
15787 (struct cmd_pctype_mapping_update_result,
15788 mapping, "mapping");
15789 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15790 TOKEN_STRING_INITIALIZER
15791 (struct cmd_pctype_mapping_update_result,
15793 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15794 TOKEN_STRING_INITIALIZER
15795 (struct cmd_pctype_mapping_update_result,
15796 pctype_list, NULL);
15797 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15798 TOKEN_NUM_INITIALIZER
15799 (struct cmd_pctype_mapping_update_result,
15800 flow_type, UINT16);
15803 cmd_pctype_mapping_update_parsed(
15804 void *parsed_result,
15805 __attribute__((unused)) struct cmdline *cl,
15806 __attribute__((unused)) void *data)
15808 struct cmd_pctype_mapping_update_result *res = parsed_result;
15809 int ret = -ENOTSUP;
15810 #ifdef RTE_LIBRTE_I40E_PMD
15811 struct rte_pmd_i40e_flow_type_mapping mapping;
15813 unsigned int nb_item;
15814 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15817 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15820 #ifdef RTE_LIBRTE_I40E_PMD
15821 nb_item = parse_item_list(res->pctype_list, "pctypes",
15822 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15823 mapping.flow_type = res->flow_type;
15824 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15825 mapping.pctype |= (1ULL << pctype_list[i]);
15826 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15836 printf("invalid pctype or flow type\n");
15839 printf("invalid port_id %d\n", res->port_id);
15842 printf("function not implemented\n");
15845 printf("programming error: (%s)\n", strerror(-ret));
15849 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15850 .f = cmd_pctype_mapping_update_parsed,
15852 .help_str = "port config <port_id> pctype mapping update"
15853 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15855 (void *)&cmd_pctype_mapping_update_port,
15856 (void *)&cmd_pctype_mapping_update_config,
15857 (void *)&cmd_pctype_mapping_update_port_id,
15858 (void *)&cmd_pctype_mapping_update_pctype,
15859 (void *)&cmd_pctype_mapping_update_mapping,
15860 (void *)&cmd_pctype_mapping_update_update,
15861 (void *)&cmd_pctype_mapping_update_pc_type,
15862 (void *)&cmd_pctype_mapping_update_flow_type,
15867 /* ptype mapping get */
15869 /* Common result structure for ptype mapping get */
15870 struct cmd_ptype_mapping_get_result {
15871 cmdline_fixed_string_t ptype;
15872 cmdline_fixed_string_t mapping;
15873 cmdline_fixed_string_t get;
15875 uint8_t valid_only;
15878 /* Common CLI fields for ptype mapping get */
15879 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15880 TOKEN_STRING_INITIALIZER
15881 (struct cmd_ptype_mapping_get_result,
15883 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15884 TOKEN_STRING_INITIALIZER
15885 (struct cmd_ptype_mapping_get_result,
15886 mapping, "mapping");
15887 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15888 TOKEN_STRING_INITIALIZER
15889 (struct cmd_ptype_mapping_get_result,
15891 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15892 TOKEN_NUM_INITIALIZER
15893 (struct cmd_ptype_mapping_get_result,
15895 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15896 TOKEN_NUM_INITIALIZER
15897 (struct cmd_ptype_mapping_get_result,
15898 valid_only, UINT8);
15901 cmd_ptype_mapping_get_parsed(
15902 void *parsed_result,
15903 __attribute__((unused)) struct cmdline *cl,
15904 __attribute__((unused)) void *data)
15906 struct cmd_ptype_mapping_get_result *res = parsed_result;
15907 int ret = -ENOTSUP;
15908 #ifdef RTE_LIBRTE_I40E_PMD
15909 int max_ptype_num = 256;
15910 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15915 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15918 #ifdef RTE_LIBRTE_I40E_PMD
15919 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15930 printf("invalid port_id %d\n", res->port_id);
15933 printf("function not implemented\n");
15936 printf("programming error: (%s)\n", strerror(-ret));
15939 #ifdef RTE_LIBRTE_I40E_PMD
15941 for (i = 0; i < count; i++)
15942 printf("%3d\t0x%08x\n",
15943 mapping[i].hw_ptype, mapping[i].sw_ptype);
15948 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15949 .f = cmd_ptype_mapping_get_parsed,
15951 .help_str = "ptype mapping get <port_id> <valid_only>",
15953 (void *)&cmd_ptype_mapping_get_ptype,
15954 (void *)&cmd_ptype_mapping_get_mapping,
15955 (void *)&cmd_ptype_mapping_get_get,
15956 (void *)&cmd_ptype_mapping_get_port_id,
15957 (void *)&cmd_ptype_mapping_get_valid_only,
15962 /* ptype mapping replace */
15964 /* Common result structure for ptype mapping replace */
15965 struct cmd_ptype_mapping_replace_result {
15966 cmdline_fixed_string_t ptype;
15967 cmdline_fixed_string_t mapping;
15968 cmdline_fixed_string_t replace;
15975 /* Common CLI fields for ptype mapping replace */
15976 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15977 TOKEN_STRING_INITIALIZER
15978 (struct cmd_ptype_mapping_replace_result,
15980 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15981 TOKEN_STRING_INITIALIZER
15982 (struct cmd_ptype_mapping_replace_result,
15983 mapping, "mapping");
15984 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15985 TOKEN_STRING_INITIALIZER
15986 (struct cmd_ptype_mapping_replace_result,
15987 replace, "replace");
15988 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15989 TOKEN_NUM_INITIALIZER
15990 (struct cmd_ptype_mapping_replace_result,
15992 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15993 TOKEN_NUM_INITIALIZER
15994 (struct cmd_ptype_mapping_replace_result,
15996 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15997 TOKEN_NUM_INITIALIZER
15998 (struct cmd_ptype_mapping_replace_result,
16000 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16001 TOKEN_NUM_INITIALIZER
16002 (struct cmd_ptype_mapping_replace_result,
16006 cmd_ptype_mapping_replace_parsed(
16007 void *parsed_result,
16008 __attribute__((unused)) struct cmdline *cl,
16009 __attribute__((unused)) void *data)
16011 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16012 int ret = -ENOTSUP;
16014 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16017 #ifdef RTE_LIBRTE_I40E_PMD
16018 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16028 printf("invalid ptype 0x%8x or 0x%8x\n",
16029 res->target, res->pkt_type);
16032 printf("invalid port_id %d\n", res->port_id);
16035 printf("function not implemented\n");
16038 printf("programming error: (%s)\n", strerror(-ret));
16042 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16043 .f = cmd_ptype_mapping_replace_parsed,
16046 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16048 (void *)&cmd_ptype_mapping_replace_ptype,
16049 (void *)&cmd_ptype_mapping_replace_mapping,
16050 (void *)&cmd_ptype_mapping_replace_replace,
16051 (void *)&cmd_ptype_mapping_replace_port_id,
16052 (void *)&cmd_ptype_mapping_replace_target,
16053 (void *)&cmd_ptype_mapping_replace_mask,
16054 (void *)&cmd_ptype_mapping_replace_pkt_type,
16059 /* ptype mapping reset */
16061 /* Common result structure for ptype mapping reset */
16062 struct cmd_ptype_mapping_reset_result {
16063 cmdline_fixed_string_t ptype;
16064 cmdline_fixed_string_t mapping;
16065 cmdline_fixed_string_t reset;
16069 /* Common CLI fields for ptype mapping reset*/
16070 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16071 TOKEN_STRING_INITIALIZER
16072 (struct cmd_ptype_mapping_reset_result,
16074 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16075 TOKEN_STRING_INITIALIZER
16076 (struct cmd_ptype_mapping_reset_result,
16077 mapping, "mapping");
16078 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16079 TOKEN_STRING_INITIALIZER
16080 (struct cmd_ptype_mapping_reset_result,
16082 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16083 TOKEN_NUM_INITIALIZER
16084 (struct cmd_ptype_mapping_reset_result,
16088 cmd_ptype_mapping_reset_parsed(
16089 void *parsed_result,
16090 __attribute__((unused)) struct cmdline *cl,
16091 __attribute__((unused)) void *data)
16093 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16094 int ret = -ENOTSUP;
16096 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16099 #ifdef RTE_LIBRTE_I40E_PMD
16100 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16107 printf("invalid port_id %d\n", res->port_id);
16110 printf("function not implemented\n");
16113 printf("programming error: (%s)\n", strerror(-ret));
16117 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16118 .f = cmd_ptype_mapping_reset_parsed,
16120 .help_str = "ptype mapping reset <port_id>",
16122 (void *)&cmd_ptype_mapping_reset_ptype,
16123 (void *)&cmd_ptype_mapping_reset_mapping,
16124 (void *)&cmd_ptype_mapping_reset_reset,
16125 (void *)&cmd_ptype_mapping_reset_port_id,
16130 /* ptype mapping update */
16132 /* Common result structure for ptype mapping update */
16133 struct cmd_ptype_mapping_update_result {
16134 cmdline_fixed_string_t ptype;
16135 cmdline_fixed_string_t mapping;
16136 cmdline_fixed_string_t reset;
16142 /* Common CLI fields for ptype mapping update*/
16143 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16144 TOKEN_STRING_INITIALIZER
16145 (struct cmd_ptype_mapping_update_result,
16147 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16148 TOKEN_STRING_INITIALIZER
16149 (struct cmd_ptype_mapping_update_result,
16150 mapping, "mapping");
16151 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16152 TOKEN_STRING_INITIALIZER
16153 (struct cmd_ptype_mapping_update_result,
16155 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16156 TOKEN_NUM_INITIALIZER
16157 (struct cmd_ptype_mapping_update_result,
16159 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16160 TOKEN_NUM_INITIALIZER
16161 (struct cmd_ptype_mapping_update_result,
16163 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16164 TOKEN_NUM_INITIALIZER
16165 (struct cmd_ptype_mapping_update_result,
16169 cmd_ptype_mapping_update_parsed(
16170 void *parsed_result,
16171 __attribute__((unused)) struct cmdline *cl,
16172 __attribute__((unused)) void *data)
16174 struct cmd_ptype_mapping_update_result *res = parsed_result;
16175 int ret = -ENOTSUP;
16176 #ifdef RTE_LIBRTE_I40E_PMD
16177 struct rte_pmd_i40e_ptype_mapping mapping;
16179 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16182 #ifdef RTE_LIBRTE_I40E_PMD
16183 mapping.hw_ptype = res->hw_ptype;
16184 mapping.sw_ptype = res->sw_ptype;
16185 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16195 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16198 printf("invalid port_id %d\n", res->port_id);
16201 printf("function not implemented\n");
16204 printf("programming error: (%s)\n", strerror(-ret));
16208 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16209 .f = cmd_ptype_mapping_update_parsed,
16211 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16213 (void *)&cmd_ptype_mapping_update_ptype,
16214 (void *)&cmd_ptype_mapping_update_mapping,
16215 (void *)&cmd_ptype_mapping_update_update,
16216 (void *)&cmd_ptype_mapping_update_port_id,
16217 (void *)&cmd_ptype_mapping_update_hw_ptype,
16218 (void *)&cmd_ptype_mapping_update_sw_ptype,
16223 /* Common result structure for file commands */
16224 struct cmd_cmdfile_result {
16225 cmdline_fixed_string_t load;
16226 cmdline_fixed_string_t filename;
16229 /* Common CLI fields for file commands */
16230 cmdline_parse_token_string_t cmd_load_cmdfile =
16231 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16232 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16233 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16236 cmd_load_from_file_parsed(
16237 void *parsed_result,
16238 __attribute__((unused)) struct cmdline *cl,
16239 __attribute__((unused)) void *data)
16241 struct cmd_cmdfile_result *res = parsed_result;
16243 cmdline_read_from_file(res->filename);
16246 cmdline_parse_inst_t cmd_load_from_file = {
16247 .f = cmd_load_from_file_parsed,
16249 .help_str = "load <filename>",
16251 (void *)&cmd_load_cmdfile,
16252 (void *)&cmd_load_cmdfile_filename,
16257 /* ******************************************************************************** */
16259 /* list of instructions */
16260 cmdline_parse_ctx_t main_ctx[] = {
16261 (cmdline_parse_inst_t *)&cmd_help_brief,
16262 (cmdline_parse_inst_t *)&cmd_help_long,
16263 (cmdline_parse_inst_t *)&cmd_quit,
16264 (cmdline_parse_inst_t *)&cmd_load_from_file,
16265 (cmdline_parse_inst_t *)&cmd_showport,
16266 (cmdline_parse_inst_t *)&cmd_showqueue,
16267 (cmdline_parse_inst_t *)&cmd_showportall,
16268 (cmdline_parse_inst_t *)&cmd_showcfg,
16269 (cmdline_parse_inst_t *)&cmd_start,
16270 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16271 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16272 (cmdline_parse_inst_t *)&cmd_set_link_up,
16273 (cmdline_parse_inst_t *)&cmd_set_link_down,
16274 (cmdline_parse_inst_t *)&cmd_reset,
16275 (cmdline_parse_inst_t *)&cmd_set_numbers,
16276 (cmdline_parse_inst_t *)&cmd_set_log,
16277 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16278 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16279 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16280 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16281 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16282 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16283 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16284 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16285 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16286 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16287 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16288 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16289 (cmdline_parse_inst_t *)&cmd_set_link_check,
16290 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16291 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16292 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16293 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16294 #ifdef RTE_LIBRTE_PMD_BOND
16295 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16296 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16297 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16298 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16299 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16300 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16301 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16302 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16303 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16304 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16305 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16307 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16308 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16309 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16310 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16311 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16312 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16313 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16314 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16315 (cmdline_parse_inst_t *)&cmd_csum_set,
16316 (cmdline_parse_inst_t *)&cmd_csum_show,
16317 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16318 (cmdline_parse_inst_t *)&cmd_tso_set,
16319 (cmdline_parse_inst_t *)&cmd_tso_show,
16320 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16321 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16322 (cmdline_parse_inst_t *)&cmd_gro_enable,
16323 (cmdline_parse_inst_t *)&cmd_gro_flush,
16324 (cmdline_parse_inst_t *)&cmd_gro_show,
16325 (cmdline_parse_inst_t *)&cmd_gso_enable,
16326 (cmdline_parse_inst_t *)&cmd_gso_size,
16327 (cmdline_parse_inst_t *)&cmd_gso_show,
16328 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16329 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16330 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16331 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16332 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16333 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16334 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16335 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16336 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16337 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16338 (cmdline_parse_inst_t *)&cmd_config_dcb,
16339 (cmdline_parse_inst_t *)&cmd_read_reg,
16340 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16341 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16342 (cmdline_parse_inst_t *)&cmd_write_reg,
16343 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16344 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16345 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16346 (cmdline_parse_inst_t *)&cmd_stop,
16347 (cmdline_parse_inst_t *)&cmd_mac_addr,
16348 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16349 (cmdline_parse_inst_t *)&cmd_set_qmap,
16350 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16351 (cmdline_parse_inst_t *)&cmd_operate_port,
16352 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16353 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16354 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16355 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16356 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16357 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16358 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16359 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16360 (cmdline_parse_inst_t *)&cmd_config_mtu,
16361 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16362 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16363 (cmdline_parse_inst_t *)&cmd_config_rss,
16364 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16365 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16366 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16367 (cmdline_parse_inst_t *)&cmd_showport_reta,
16368 (cmdline_parse_inst_t *)&cmd_config_burst,
16369 (cmdline_parse_inst_t *)&cmd_config_thresh,
16370 (cmdline_parse_inst_t *)&cmd_config_threshold,
16371 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16372 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16373 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16374 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16375 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16376 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16377 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16378 (cmdline_parse_inst_t *)&cmd_global_config,
16379 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16380 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16381 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16382 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16383 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16384 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16385 (cmdline_parse_inst_t *)&cmd_dump,
16386 (cmdline_parse_inst_t *)&cmd_dump_one,
16387 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16388 (cmdline_parse_inst_t *)&cmd_syn_filter,
16389 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16390 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16391 (cmdline_parse_inst_t *)&cmd_flex_filter,
16392 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16393 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16394 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16395 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16396 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16397 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16398 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16399 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16400 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16401 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16402 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16403 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16404 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16405 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16406 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16407 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16408 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16409 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16410 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16411 (cmdline_parse_inst_t *)&cmd_flow,
16412 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16413 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16414 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16415 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16416 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16417 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16418 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16419 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16420 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16421 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16422 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16423 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16424 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16425 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16426 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16427 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16428 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16429 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16430 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16431 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16432 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16433 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16434 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16435 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16436 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16437 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16438 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16439 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16440 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16441 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16442 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16443 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16444 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16445 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16446 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16447 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16448 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16449 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16450 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16451 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16452 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16453 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16454 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16455 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16456 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16457 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16458 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16459 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16460 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16461 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16462 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16464 (cmdline_parse_inst_t *)&cmd_ddp_add,
16465 (cmdline_parse_inst_t *)&cmd_ddp_del,
16466 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16467 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16468 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16469 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16470 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16471 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16472 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16473 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16474 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16475 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16477 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16478 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16479 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16480 (cmdline_parse_inst_t *)&cmd_queue_region,
16481 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16482 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16483 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16484 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16485 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16486 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16487 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16488 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16489 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16490 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16491 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16492 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16493 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16494 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16495 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16496 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16497 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16498 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16499 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16500 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16501 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16505 /* read cmdline commands from file */
16507 cmdline_read_from_file(const char *filename)
16509 struct cmdline *cl;
16511 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16513 printf("Failed to create file based cmdline context: %s\n",
16518 cmdline_interact(cl);
16523 printf("Read CLI commands from %s\n", filename);
16526 /* prompt function, called from main on MASTER lcore */
16530 /* initialize non-constant commands */
16531 cmd_set_fwd_mode_init();
16532 cmd_set_fwd_retry_mode_init();
16534 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16535 if (testpmd_cl == NULL)
16537 cmdline_interact(testpmd_cl);
16538 cmdline_stdin_exit(testpmd_cl);
16544 if (testpmd_cl != NULL)
16545 cmdline_quit(testpmd_cl);
16549 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16551 if (id == (portid_t)RTE_PORT_ALL) {
16554 RTE_ETH_FOREACH_DEV(pid) {
16555 /* check if need_reconfig has been set to 1 */
16556 if (ports[pid].need_reconfig == 0)
16557 ports[pid].need_reconfig = dev;
16558 /* check if need_reconfig_queues has been set to 1 */
16559 if (ports[pid].need_reconfig_queues == 0)
16560 ports[pid].need_reconfig_queues = queue;
16562 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16563 /* check if need_reconfig has been set to 1 */
16564 if (ports[id].need_reconfig == 0)
16565 ports[id].need_reconfig = dev;
16566 /* check if need_reconfig_queues has been set to 1 */
16567 if (ports[id].need_reconfig_queues == 0)
16568 ports[id].need_reconfig_queues = queue;