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 config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
850 " Set a rx/tx queue's ring size configuration, the new"
851 " value will take effect after command that (re-)start the port"
852 " or command that setup the specific queue\n\n"
854 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
855 " Start/stop a rx/tx queue of port X. Only take effect"
856 " when port X is started\n\n"
858 "port (port_id) (rxq|txq) (queue_id) setup\n"
859 " Setup a rx/tx queue of port X.\n\n"
861 "port config (port_id|all) l2-tunnel E-tag ether-type"
863 " Set the value of E-tag ether-type.\n\n"
865 "port config (port_id|all) l2-tunnel E-tag"
866 " (enable|disable)\n"
867 " Enable/disable the E-tag support.\n\n"
869 "port config (port_id) pctype mapping reset\n"
870 " Reset flow type to pctype mapping on a port\n\n"
872 "port config (port_id) pctype mapping update"
873 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
874 " Update a flow type to pctype mapping item on a port\n\n"
876 "port config (port_id) pctype (pctype_id) hash_inset|"
877 "fdir_inset|fdir_flx_inset get|set|clear field\n"
879 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
881 "port config (port_id) pctype (pctype_id) hash_inset|"
882 "fdir_inset|fdir_flx_inset clear all"
883 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
885 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
886 " Add/remove UDP tunnel port for tunneling offload\n\n"
890 if (show_all || !strcmp(res->section, "registers")) {
898 "read reg (port_id) (address)\n"
899 " Display value of a port register.\n\n"
901 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
902 " Display a port register bit field.\n\n"
904 "read regbit (port_id) (address) (bit_x)\n"
905 " Display a single port register bit.\n\n"
907 "write reg (port_id) (address) (value)\n"
908 " Set value of a port register.\n\n"
910 "write regfield (port_id) (address) (bit_x) (bit_y)"
912 " Set bit field of a port register.\n\n"
914 "write regbit (port_id) (address) (bit_x) (value)\n"
915 " Set single bit value of a port register.\n\n"
918 if (show_all || !strcmp(res->section, "filters")) {
926 "ethertype_filter (port_id) (add|del)"
927 " (mac_addr|mac_ignr) (mac_address) ethertype"
928 " (ether_type) (drop|fwd) queue (queue_id)\n"
929 " Add/Del an ethertype filter.\n\n"
931 "2tuple_filter (port_id) (add|del)"
932 " dst_port (dst_port_value) protocol (protocol_value)"
933 " mask (mask_value) tcp_flags (tcp_flags_value)"
934 " priority (prio_value) queue (queue_id)\n"
935 " Add/Del a 2tuple filter.\n\n"
937 "5tuple_filter (port_id) (add|del)"
938 " dst_ip (dst_address) src_ip (src_address)"
939 " dst_port (dst_port_value) src_port (src_port_value)"
940 " protocol (protocol_value)"
941 " mask (mask_value) tcp_flags (tcp_flags_value)"
942 " priority (prio_value) queue (queue_id)\n"
943 " Add/Del a 5tuple filter.\n\n"
945 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
946 " Add/Del syn filter.\n\n"
948 "flex_filter (port_id) (add|del) len (len_value)"
949 " bytes (bytes_value) mask (mask_value)"
950 " priority (prio_value) queue (queue_id)\n"
951 " Add/Del a flex filter.\n\n"
953 "flow_director_filter (port_id) mode IP (add|del|update)"
954 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
955 " src (src_ip_address) dst (dst_ip_address)"
956 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
957 " vlan (vlan_value) flexbytes (flexbytes_value)"
958 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
959 " fd_id (fd_id_value)\n"
960 " Add/Del an IP type flow director filter.\n\n"
962 "flow_director_filter (port_id) mode IP (add|del|update)"
963 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
964 " src (src_ip_address) (src_port)"
965 " dst (dst_ip_address) (dst_port)"
966 " tos (tos_value) ttl (ttl_value)"
967 " vlan (vlan_value) flexbytes (flexbytes_value)"
968 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
969 " fd_id (fd_id_value)\n"
970 " Add/Del an UDP/TCP type flow director filter.\n\n"
972 "flow_director_filter (port_id) mode IP (add|del|update)"
973 " flow (ipv4-sctp|ipv6-sctp)"
974 " src (src_ip_address) (src_port)"
975 " dst (dst_ip_address) (dst_port)"
976 " tag (verification_tag) "
977 " tos (tos_value) ttl (ttl_value)"
979 " flexbytes (flexbytes_value) (drop|fwd)"
980 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
981 " Add/Del a SCTP type flow director filter.\n\n"
983 "flow_director_filter (port_id) mode IP (add|del|update)"
984 " flow l2_payload ether (ethertype)"
985 " flexbytes (flexbytes_value) (drop|fwd)"
986 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
987 " Add/Del a l2 payload type flow director filter.\n\n"
989 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
990 " mac (mac_address) vlan (vlan_value)"
991 " flexbytes (flexbytes_value) (drop|fwd)"
992 " queue (queue_id) fd_id (fd_id_value)\n"
993 " Add/Del a MAC-VLAN flow director filter.\n\n"
995 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
996 " mac (mac_address) vlan (vlan_value)"
997 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
998 " flexbytes (flexbytes_value) (drop|fwd)"
999 " queue (queue_id) fd_id (fd_id_value)\n"
1000 " Add/Del a Tunnel flow director filter.\n\n"
1002 "flow_director_filter (port_id) mode raw (add|del|update)"
1003 " flow (flow_id) (drop|fwd) queue (queue_id)"
1004 " fd_id (fd_id_value) packet (packet file name)\n"
1005 " Add/Del a raw type flow director filter.\n\n"
1007 "flush_flow_director (port_id)\n"
1008 " Flush all flow director entries of a device.\n\n"
1010 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1011 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1012 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1013 " Set flow director IP mask.\n\n"
1015 "flow_director_mask (port_id) mode MAC-VLAN"
1016 " vlan (vlan_value)\n"
1017 " Set flow director MAC-VLAN mask.\n\n"
1019 "flow_director_mask (port_id) mode Tunnel"
1020 " vlan (vlan_value) mac (mac_value)"
1021 " tunnel-type (tunnel_type_value)"
1022 " tunnel-id (tunnel_id_value)\n"
1023 " Set flow director Tunnel mask.\n\n"
1025 "flow_director_flex_mask (port_id)"
1026 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1027 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1029 " Configure mask of flex payload.\n\n"
1031 "flow_director_flex_payload (port_id)"
1032 " (raw|l2|l3|l4) (config)\n"
1033 " Configure flex payload selection.\n\n"
1035 "get_sym_hash_ena_per_port (port_id)\n"
1036 " get symmetric hash enable configuration per port.\n\n"
1038 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1039 " set symmetric hash enable configuration per port"
1040 " to enable or disable.\n\n"
1042 "get_hash_global_config (port_id)\n"
1043 " Get the global configurations of hash filters.\n\n"
1045 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1046 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1047 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1048 " (enable|disable)\n"
1049 " Set the global configurations of hash filters.\n\n"
1051 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1052 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1053 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1054 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1055 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1056 "ipv6-next-header|udp-src-port|udp-dst-port|"
1057 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1058 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1059 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1060 "fld-8th|none) (select|add)\n"
1061 " Set the input set for hash.\n\n"
1063 "set_fdir_input_set (port_id) "
1064 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1065 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1066 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1067 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1068 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1069 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1070 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1072 " Set the input set for FDir.\n\n"
1074 "flow validate {port_id}"
1075 " [group {group_id}] [priority {level}]"
1076 " [ingress] [egress]"
1077 " pattern {item} [/ {item} [...]] / end"
1078 " actions {action} [/ {action} [...]] / end\n"
1079 " Check whether a flow rule can be created.\n\n"
1081 "flow create {port_id}"
1082 " [group {group_id}] [priority {level}]"
1083 " [ingress] [egress]"
1084 " pattern {item} [/ {item} [...]] / end"
1085 " actions {action} [/ {action} [...]] / end\n"
1086 " Create a flow rule.\n\n"
1088 "flow destroy {port_id} rule {rule_id} [...]\n"
1089 " Destroy specific flow rules.\n\n"
1091 "flow flush {port_id}\n"
1092 " Destroy all flow rules.\n\n"
1094 "flow query {port_id} {rule_id} {action}\n"
1095 " Query an existing flow rule.\n\n"
1097 "flow list {port_id} [group {group_id}] [...]\n"
1098 " List existing flow rules sorted by priority,"
1099 " filtered by group identifiers.\n\n"
1101 "flow isolate {port_id} {boolean}\n"
1102 " Restrict ingress traffic to the defined"
1108 cmdline_parse_token_string_t cmd_help_long_help =
1109 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1111 cmdline_parse_token_string_t cmd_help_long_section =
1112 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1113 "all#control#display#config#"
1114 "ports#registers#filters");
1116 cmdline_parse_inst_t cmd_help_long = {
1117 .f = cmd_help_long_parsed,
1119 .help_str = "help all|control|display|config|ports|register|filters: "
1122 (void *)&cmd_help_long_help,
1123 (void *)&cmd_help_long_section,
1129 /* *** start/stop/close all ports *** */
1130 struct cmd_operate_port_result {
1131 cmdline_fixed_string_t keyword;
1132 cmdline_fixed_string_t name;
1133 cmdline_fixed_string_t value;
1136 static void cmd_operate_port_parsed(void *parsed_result,
1137 __attribute__((unused)) struct cmdline *cl,
1138 __attribute__((unused)) void *data)
1140 struct cmd_operate_port_result *res = parsed_result;
1142 if (!strcmp(res->name, "start"))
1143 start_port(RTE_PORT_ALL);
1144 else if (!strcmp(res->name, "stop"))
1145 stop_port(RTE_PORT_ALL);
1146 else if (!strcmp(res->name, "close"))
1147 close_port(RTE_PORT_ALL);
1148 else if (!strcmp(res->name, "reset"))
1149 reset_port(RTE_PORT_ALL);
1151 printf("Unknown parameter\n");
1154 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1155 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1157 cmdline_parse_token_string_t cmd_operate_port_all_port =
1158 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1159 "start#stop#close#reset");
1160 cmdline_parse_token_string_t cmd_operate_port_all_all =
1161 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1163 cmdline_parse_inst_t cmd_operate_port = {
1164 .f = cmd_operate_port_parsed,
1166 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1168 (void *)&cmd_operate_port_all_cmd,
1169 (void *)&cmd_operate_port_all_port,
1170 (void *)&cmd_operate_port_all_all,
1175 /* *** start/stop/close specific port *** */
1176 struct cmd_operate_specific_port_result {
1177 cmdline_fixed_string_t keyword;
1178 cmdline_fixed_string_t name;
1182 static void cmd_operate_specific_port_parsed(void *parsed_result,
1183 __attribute__((unused)) struct cmdline *cl,
1184 __attribute__((unused)) void *data)
1186 struct cmd_operate_specific_port_result *res = parsed_result;
1188 if (!strcmp(res->name, "start"))
1189 start_port(res->value);
1190 else if (!strcmp(res->name, "stop"))
1191 stop_port(res->value);
1192 else if (!strcmp(res->name, "close"))
1193 close_port(res->value);
1194 else if (!strcmp(res->name, "reset"))
1195 reset_port(res->value);
1197 printf("Unknown parameter\n");
1200 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1201 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1203 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1204 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1205 name, "start#stop#close#reset");
1206 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1207 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1210 cmdline_parse_inst_t cmd_operate_specific_port = {
1211 .f = cmd_operate_specific_port_parsed,
1213 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1215 (void *)&cmd_operate_specific_port_cmd,
1216 (void *)&cmd_operate_specific_port_port,
1217 (void *)&cmd_operate_specific_port_id,
1222 /* *** attach a specified port *** */
1223 struct cmd_operate_attach_port_result {
1224 cmdline_fixed_string_t port;
1225 cmdline_fixed_string_t keyword;
1226 cmdline_fixed_string_t identifier;
1229 static void cmd_operate_attach_port_parsed(void *parsed_result,
1230 __attribute__((unused)) struct cmdline *cl,
1231 __attribute__((unused)) void *data)
1233 struct cmd_operate_attach_port_result *res = parsed_result;
1235 if (!strcmp(res->keyword, "attach"))
1236 attach_port(res->identifier);
1238 printf("Unknown parameter\n");
1241 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1242 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1244 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1245 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1247 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1248 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1251 cmdline_parse_inst_t cmd_operate_attach_port = {
1252 .f = cmd_operate_attach_port_parsed,
1254 .help_str = "port attach <identifier>: "
1255 "(identifier: pci address or virtual dev name)",
1257 (void *)&cmd_operate_attach_port_port,
1258 (void *)&cmd_operate_attach_port_keyword,
1259 (void *)&cmd_operate_attach_port_identifier,
1264 /* *** detach a specified port *** */
1265 struct cmd_operate_detach_port_result {
1266 cmdline_fixed_string_t port;
1267 cmdline_fixed_string_t keyword;
1271 static void cmd_operate_detach_port_parsed(void *parsed_result,
1272 __attribute__((unused)) struct cmdline *cl,
1273 __attribute__((unused)) void *data)
1275 struct cmd_operate_detach_port_result *res = parsed_result;
1277 if (!strcmp(res->keyword, "detach"))
1278 detach_port(res->port_id);
1280 printf("Unknown parameter\n");
1283 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1284 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1286 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1287 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1289 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1290 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1293 cmdline_parse_inst_t cmd_operate_detach_port = {
1294 .f = cmd_operate_detach_port_parsed,
1296 .help_str = "port detach <port_id>",
1298 (void *)&cmd_operate_detach_port_port,
1299 (void *)&cmd_operate_detach_port_keyword,
1300 (void *)&cmd_operate_detach_port_port_id,
1305 /* *** configure speed for all ports *** */
1306 struct cmd_config_speed_all {
1307 cmdline_fixed_string_t port;
1308 cmdline_fixed_string_t keyword;
1309 cmdline_fixed_string_t all;
1310 cmdline_fixed_string_t item1;
1311 cmdline_fixed_string_t item2;
1312 cmdline_fixed_string_t value1;
1313 cmdline_fixed_string_t value2;
1317 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1322 if (!strcmp(duplexstr, "half")) {
1323 duplex = ETH_LINK_HALF_DUPLEX;
1324 } else if (!strcmp(duplexstr, "full")) {
1325 duplex = ETH_LINK_FULL_DUPLEX;
1326 } else if (!strcmp(duplexstr, "auto")) {
1327 duplex = ETH_LINK_FULL_DUPLEX;
1329 printf("Unknown duplex parameter\n");
1333 if (!strcmp(speedstr, "10")) {
1334 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1335 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1336 } else if (!strcmp(speedstr, "100")) {
1337 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1338 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1340 if (duplex != ETH_LINK_FULL_DUPLEX) {
1341 printf("Invalid speed/duplex parameters\n");
1344 if (!strcmp(speedstr, "1000")) {
1345 *speed = ETH_LINK_SPEED_1G;
1346 } else if (!strcmp(speedstr, "10000")) {
1347 *speed = ETH_LINK_SPEED_10G;
1348 } else if (!strcmp(speedstr, "25000")) {
1349 *speed = ETH_LINK_SPEED_25G;
1350 } else if (!strcmp(speedstr, "40000")) {
1351 *speed = ETH_LINK_SPEED_40G;
1352 } else if (!strcmp(speedstr, "50000")) {
1353 *speed = ETH_LINK_SPEED_50G;
1354 } else if (!strcmp(speedstr, "100000")) {
1355 *speed = ETH_LINK_SPEED_100G;
1356 } else if (!strcmp(speedstr, "auto")) {
1357 *speed = ETH_LINK_SPEED_AUTONEG;
1359 printf("Unknown speed parameter\n");
1368 cmd_config_speed_all_parsed(void *parsed_result,
1369 __attribute__((unused)) struct cmdline *cl,
1370 __attribute__((unused)) void *data)
1372 struct cmd_config_speed_all *res = parsed_result;
1373 uint32_t link_speed;
1376 if (!all_ports_stopped()) {
1377 printf("Please stop all ports first\n");
1381 if (parse_and_check_speed_duplex(res->value1, res->value2,
1385 RTE_ETH_FOREACH_DEV(pid) {
1386 ports[pid].dev_conf.link_speeds = link_speed;
1389 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1392 cmdline_parse_token_string_t cmd_config_speed_all_port =
1393 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1394 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1395 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1397 cmdline_parse_token_string_t cmd_config_speed_all_all =
1398 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1399 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1400 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1401 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1403 "10#100#1000#10000#25000#40000#50000#100000#auto");
1404 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1406 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1407 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1410 cmdline_parse_inst_t cmd_config_speed_all = {
1411 .f = cmd_config_speed_all_parsed,
1413 .help_str = "port config all speed "
1414 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1417 (void *)&cmd_config_speed_all_port,
1418 (void *)&cmd_config_speed_all_keyword,
1419 (void *)&cmd_config_speed_all_all,
1420 (void *)&cmd_config_speed_all_item1,
1421 (void *)&cmd_config_speed_all_value1,
1422 (void *)&cmd_config_speed_all_item2,
1423 (void *)&cmd_config_speed_all_value2,
1428 /* *** configure speed for specific port *** */
1429 struct cmd_config_speed_specific {
1430 cmdline_fixed_string_t port;
1431 cmdline_fixed_string_t keyword;
1433 cmdline_fixed_string_t item1;
1434 cmdline_fixed_string_t item2;
1435 cmdline_fixed_string_t value1;
1436 cmdline_fixed_string_t value2;
1440 cmd_config_speed_specific_parsed(void *parsed_result,
1441 __attribute__((unused)) struct cmdline *cl,
1442 __attribute__((unused)) void *data)
1444 struct cmd_config_speed_specific *res = parsed_result;
1445 uint32_t link_speed;
1447 if (!all_ports_stopped()) {
1448 printf("Please stop all ports first\n");
1452 if (port_id_is_invalid(res->id, ENABLED_WARN))
1455 if (parse_and_check_speed_duplex(res->value1, res->value2,
1459 ports[res->id].dev_conf.link_speeds = link_speed;
1461 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1465 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1468 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1471 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1472 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1473 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1474 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1476 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1477 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1478 "10#100#1000#10000#25000#40000#50000#100000#auto");
1479 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1482 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1483 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1486 cmdline_parse_inst_t cmd_config_speed_specific = {
1487 .f = cmd_config_speed_specific_parsed,
1489 .help_str = "port config <port_id> speed "
1490 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1493 (void *)&cmd_config_speed_specific_port,
1494 (void *)&cmd_config_speed_specific_keyword,
1495 (void *)&cmd_config_speed_specific_id,
1496 (void *)&cmd_config_speed_specific_item1,
1497 (void *)&cmd_config_speed_specific_value1,
1498 (void *)&cmd_config_speed_specific_item2,
1499 (void *)&cmd_config_speed_specific_value2,
1504 /* *** configure loopback for all ports *** */
1505 struct cmd_config_loopback_all {
1506 cmdline_fixed_string_t port;
1507 cmdline_fixed_string_t keyword;
1508 cmdline_fixed_string_t all;
1509 cmdline_fixed_string_t item;
1514 cmd_config_loopback_all_parsed(void *parsed_result,
1515 __attribute__((unused)) struct cmdline *cl,
1516 __attribute__((unused)) void *data)
1518 struct cmd_config_loopback_all *res = parsed_result;
1521 if (!all_ports_stopped()) {
1522 printf("Please stop all ports first\n");
1526 RTE_ETH_FOREACH_DEV(pid) {
1527 ports[pid].dev_conf.lpbk_mode = res->mode;
1530 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1533 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1534 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1535 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1536 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1538 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1539 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1540 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1541 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1543 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1544 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1546 cmdline_parse_inst_t cmd_config_loopback_all = {
1547 .f = cmd_config_loopback_all_parsed,
1549 .help_str = "port config all loopback <mode>",
1551 (void *)&cmd_config_loopback_all_port,
1552 (void *)&cmd_config_loopback_all_keyword,
1553 (void *)&cmd_config_loopback_all_all,
1554 (void *)&cmd_config_loopback_all_item,
1555 (void *)&cmd_config_loopback_all_mode,
1560 /* *** configure loopback for specific port *** */
1561 struct cmd_config_loopback_specific {
1562 cmdline_fixed_string_t port;
1563 cmdline_fixed_string_t keyword;
1565 cmdline_fixed_string_t item;
1570 cmd_config_loopback_specific_parsed(void *parsed_result,
1571 __attribute__((unused)) struct cmdline *cl,
1572 __attribute__((unused)) void *data)
1574 struct cmd_config_loopback_specific *res = parsed_result;
1576 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1579 if (!port_is_stopped(res->port_id)) {
1580 printf("Please stop port %u first\n", res->port_id);
1584 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1586 cmd_reconfig_device_queue(res->port_id, 1, 1);
1590 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1591 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1593 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1594 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1596 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1597 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1599 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1600 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1602 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1603 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1606 cmdline_parse_inst_t cmd_config_loopback_specific = {
1607 .f = cmd_config_loopback_specific_parsed,
1609 .help_str = "port config <port_id> loopback <mode>",
1611 (void *)&cmd_config_loopback_specific_port,
1612 (void *)&cmd_config_loopback_specific_keyword,
1613 (void *)&cmd_config_loopback_specific_id,
1614 (void *)&cmd_config_loopback_specific_item,
1615 (void *)&cmd_config_loopback_specific_mode,
1620 /* *** configure txq/rxq, txd/rxd *** */
1621 struct cmd_config_rx_tx {
1622 cmdline_fixed_string_t port;
1623 cmdline_fixed_string_t keyword;
1624 cmdline_fixed_string_t all;
1625 cmdline_fixed_string_t name;
1630 cmd_config_rx_tx_parsed(void *parsed_result,
1631 __attribute__((unused)) struct cmdline *cl,
1632 __attribute__((unused)) void *data)
1634 struct cmd_config_rx_tx *res = parsed_result;
1636 if (!all_ports_stopped()) {
1637 printf("Please stop all ports first\n");
1640 if (!strcmp(res->name, "rxq")) {
1641 if (!res->value && !nb_txq) {
1642 printf("Warning: Either rx or tx queues should be non zero\n");
1645 if (check_nb_rxq(res->value) != 0)
1647 nb_rxq = res->value;
1649 else if (!strcmp(res->name, "txq")) {
1650 if (!res->value && !nb_rxq) {
1651 printf("Warning: Either rx or tx queues should be non zero\n");
1654 if (check_nb_txq(res->value) != 0)
1656 nb_txq = res->value;
1658 else if (!strcmp(res->name, "rxd")) {
1659 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1660 printf("rxd %d invalid - must be > 0 && <= %d\n",
1661 res->value, RTE_TEST_RX_DESC_MAX);
1664 nb_rxd = res->value;
1665 } else if (!strcmp(res->name, "txd")) {
1666 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1667 printf("txd %d invalid - must be > 0 && <= %d\n",
1668 res->value, RTE_TEST_TX_DESC_MAX);
1671 nb_txd = res->value;
1673 printf("Unknown parameter\n");
1681 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1684 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1685 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1686 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1688 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1689 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1690 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1691 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1693 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1694 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1696 cmdline_parse_inst_t cmd_config_rx_tx = {
1697 .f = cmd_config_rx_tx_parsed,
1699 .help_str = "port config all rxq|txq|rxd|txd <value>",
1701 (void *)&cmd_config_rx_tx_port,
1702 (void *)&cmd_config_rx_tx_keyword,
1703 (void *)&cmd_config_rx_tx_all,
1704 (void *)&cmd_config_rx_tx_name,
1705 (void *)&cmd_config_rx_tx_value,
1710 /* *** config max packet length *** */
1711 struct cmd_config_max_pkt_len_result {
1712 cmdline_fixed_string_t port;
1713 cmdline_fixed_string_t keyword;
1714 cmdline_fixed_string_t all;
1715 cmdline_fixed_string_t name;
1720 cmd_config_max_pkt_len_parsed(void *parsed_result,
1721 __attribute__((unused)) struct cmdline *cl,
1722 __attribute__((unused)) void *data)
1724 struct cmd_config_max_pkt_len_result *res = parsed_result;
1727 if (!all_ports_stopped()) {
1728 printf("Please stop all ports first\n");
1732 RTE_ETH_FOREACH_DEV(pid) {
1733 struct rte_port *port = &ports[pid];
1734 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1736 if (!strcmp(res->name, "max-pkt-len")) {
1737 if (res->value < ETHER_MIN_LEN) {
1738 printf("max-pkt-len can not be less than %d\n",
1742 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1745 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1746 if (res->value > ETHER_MAX_LEN)
1747 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1749 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1750 port->dev_conf.rxmode.offloads = rx_offloads;
1752 printf("Unknown parameter\n");
1759 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1762 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1763 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1765 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1768 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1771 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1772 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1774 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1775 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1778 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1779 .f = cmd_config_max_pkt_len_parsed,
1781 .help_str = "port config all max-pkt-len <value>",
1783 (void *)&cmd_config_max_pkt_len_port,
1784 (void *)&cmd_config_max_pkt_len_keyword,
1785 (void *)&cmd_config_max_pkt_len_all,
1786 (void *)&cmd_config_max_pkt_len_name,
1787 (void *)&cmd_config_max_pkt_len_value,
1792 /* *** configure port MTU *** */
1793 struct cmd_config_mtu_result {
1794 cmdline_fixed_string_t port;
1795 cmdline_fixed_string_t keyword;
1796 cmdline_fixed_string_t mtu;
1802 cmd_config_mtu_parsed(void *parsed_result,
1803 __attribute__((unused)) struct cmdline *cl,
1804 __attribute__((unused)) void *data)
1806 struct cmd_config_mtu_result *res = parsed_result;
1808 if (res->value < ETHER_MIN_LEN) {
1809 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1812 port_mtu_set(res->port_id, res->value);
1815 cmdline_parse_token_string_t cmd_config_mtu_port =
1816 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1818 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1819 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1821 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1822 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1824 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1825 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1826 cmdline_parse_token_num_t cmd_config_mtu_value =
1827 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1829 cmdline_parse_inst_t cmd_config_mtu = {
1830 .f = cmd_config_mtu_parsed,
1832 .help_str = "port config mtu <port_id> <value>",
1834 (void *)&cmd_config_mtu_port,
1835 (void *)&cmd_config_mtu_keyword,
1836 (void *)&cmd_config_mtu_mtu,
1837 (void *)&cmd_config_mtu_port_id,
1838 (void *)&cmd_config_mtu_value,
1843 /* *** configure rx mode *** */
1844 struct cmd_config_rx_mode_flag {
1845 cmdline_fixed_string_t port;
1846 cmdline_fixed_string_t keyword;
1847 cmdline_fixed_string_t all;
1848 cmdline_fixed_string_t name;
1849 cmdline_fixed_string_t value;
1853 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1854 __attribute__((unused)) struct cmdline *cl,
1855 __attribute__((unused)) void *data)
1857 struct cmd_config_rx_mode_flag *res = parsed_result;
1860 if (!all_ports_stopped()) {
1861 printf("Please stop all ports first\n");
1865 RTE_ETH_FOREACH_DEV(pid) {
1866 struct rte_port *port;
1867 uint64_t rx_offloads;
1870 rx_offloads = port->dev_conf.rxmode.offloads;
1871 if (!strcmp(res->name, "crc-strip")) {
1872 if (!strcmp(res->value, "on"))
1873 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1874 else if (!strcmp(res->value, "off"))
1875 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1877 printf("Unknown parameter\n");
1880 } else if (!strcmp(res->name, "scatter")) {
1881 if (!strcmp(res->value, "on")) {
1882 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1883 } else if (!strcmp(res->value, "off")) {
1884 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1886 printf("Unknown parameter\n");
1889 } else if (!strcmp(res->name, "rx-cksum")) {
1890 if (!strcmp(res->value, "on"))
1891 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1892 else if (!strcmp(res->value, "off"))
1893 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1895 printf("Unknown parameter\n");
1898 } else if (!strcmp(res->name, "rx-timestamp")) {
1899 if (!strcmp(res->value, "on"))
1900 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1901 else if (!strcmp(res->value, "off"))
1902 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1904 printf("Unknown parameter\n");
1907 } else if (!strcmp(res->name, "hw-vlan")) {
1908 if (!strcmp(res->value, "on")) {
1909 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1910 DEV_RX_OFFLOAD_VLAN_STRIP);
1911 } else if (!strcmp(res->value, "off")) {
1912 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1913 DEV_RX_OFFLOAD_VLAN_STRIP);
1915 printf("Unknown parameter\n");
1918 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1919 if (!strcmp(res->value, "on"))
1920 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1921 else if (!strcmp(res->value, "off"))
1922 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1924 printf("Unknown parameter\n");
1927 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1928 if (!strcmp(res->value, "on"))
1929 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1930 else if (!strcmp(res->value, "off"))
1931 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1933 printf("Unknown parameter\n");
1936 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1937 if (!strcmp(res->value, "on"))
1938 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1939 else if (!strcmp(res->value, "off"))
1940 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1942 printf("Unknown parameter\n");
1945 } else if (!strcmp(res->name, "drop-en")) {
1946 if (!strcmp(res->value, "on"))
1948 else if (!strcmp(res->value, "off"))
1951 printf("Unknown parameter\n");
1955 printf("Unknown parameter\n");
1958 port->dev_conf.rxmode.offloads = rx_offloads;
1963 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1966 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1968 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1971 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1972 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1973 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1974 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1975 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1976 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1977 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1978 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1981 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1982 .f = cmd_config_rx_mode_flag_parsed,
1984 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1985 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1987 (void *)&cmd_config_rx_mode_flag_port,
1988 (void *)&cmd_config_rx_mode_flag_keyword,
1989 (void *)&cmd_config_rx_mode_flag_all,
1990 (void *)&cmd_config_rx_mode_flag_name,
1991 (void *)&cmd_config_rx_mode_flag_value,
1996 /* *** configure rss *** */
1997 struct cmd_config_rss {
1998 cmdline_fixed_string_t port;
1999 cmdline_fixed_string_t keyword;
2000 cmdline_fixed_string_t all;
2001 cmdline_fixed_string_t name;
2002 cmdline_fixed_string_t value;
2006 cmd_config_rss_parsed(void *parsed_result,
2007 __attribute__((unused)) struct cmdline *cl,
2008 __attribute__((unused)) void *data)
2010 struct cmd_config_rss *res = parsed_result;
2011 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2012 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2016 if (!strcmp(res->value, "all"))
2017 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2018 ETH_RSS_UDP | ETH_RSS_SCTP |
2020 else if (!strcmp(res->value, "ip"))
2021 rss_conf.rss_hf = ETH_RSS_IP;
2022 else if (!strcmp(res->value, "udp"))
2023 rss_conf.rss_hf = ETH_RSS_UDP;
2024 else if (!strcmp(res->value, "tcp"))
2025 rss_conf.rss_hf = ETH_RSS_TCP;
2026 else if (!strcmp(res->value, "sctp"))
2027 rss_conf.rss_hf = ETH_RSS_SCTP;
2028 else if (!strcmp(res->value, "ether"))
2029 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2030 else if (!strcmp(res->value, "port"))
2031 rss_conf.rss_hf = ETH_RSS_PORT;
2032 else if (!strcmp(res->value, "vxlan"))
2033 rss_conf.rss_hf = ETH_RSS_VXLAN;
2034 else if (!strcmp(res->value, "geneve"))
2035 rss_conf.rss_hf = ETH_RSS_GENEVE;
2036 else if (!strcmp(res->value, "nvgre"))
2037 rss_conf.rss_hf = ETH_RSS_NVGRE;
2038 else if (!strcmp(res->value, "none") || !strcmp(res->value, "default"))
2039 rss_conf.rss_hf = 0;
2040 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2041 atoi(res->value) < 64)
2042 rss_conf.rss_hf = 1ULL << atoi(res->value);
2044 printf("Unknown parameter\n");
2047 rss_conf.rss_key = NULL;
2048 /* Update global configuration for RSS types. */
2049 rss_hf = rss_conf.rss_hf;
2050 RTE_ETH_FOREACH_DEV(i) {
2051 if (!strcmp(res->value, "default")) {
2052 rte_eth_dev_info_get(i, &dev_info);
2053 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2055 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2057 printf("Configuration of RSS hash at ethernet port %d "
2058 "failed with error (%d): %s.\n",
2059 i, -diag, strerror(-diag));
2063 cmdline_parse_token_string_t cmd_config_rss_port =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2065 cmdline_parse_token_string_t cmd_config_rss_keyword =
2066 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2067 cmdline_parse_token_string_t cmd_config_rss_all =
2068 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2069 cmdline_parse_token_string_t cmd_config_rss_name =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2071 cmdline_parse_token_string_t cmd_config_rss_value =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2074 cmdline_parse_inst_t cmd_config_rss = {
2075 .f = cmd_config_rss_parsed,
2077 .help_str = "port config all rss "
2078 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2080 (void *)&cmd_config_rss_port,
2081 (void *)&cmd_config_rss_keyword,
2082 (void *)&cmd_config_rss_all,
2083 (void *)&cmd_config_rss_name,
2084 (void *)&cmd_config_rss_value,
2089 /* *** configure rss hash key *** */
2090 struct cmd_config_rss_hash_key {
2091 cmdline_fixed_string_t port;
2092 cmdline_fixed_string_t config;
2094 cmdline_fixed_string_t rss_hash_key;
2095 cmdline_fixed_string_t rss_type;
2096 cmdline_fixed_string_t key;
2100 hexa_digit_to_value(char hexa_digit)
2102 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2103 return (uint8_t) (hexa_digit - '0');
2104 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2105 return (uint8_t) ((hexa_digit - 'a') + 10);
2106 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2107 return (uint8_t) ((hexa_digit - 'A') + 10);
2108 /* Invalid hexa digit */
2113 parse_and_check_key_hexa_digit(char *key, int idx)
2117 hexa_v = hexa_digit_to_value(key[idx]);
2119 printf("invalid key: character %c at position %d is not a "
2120 "valid hexa digit\n", key[idx], idx);
2125 cmd_config_rss_hash_key_parsed(void *parsed_result,
2126 __attribute__((unused)) struct cmdline *cl,
2127 __attribute__((unused)) void *data)
2129 struct cmd_config_rss_hash_key *res = parsed_result;
2130 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2134 struct rte_eth_dev_info dev_info;
2135 uint8_t hash_key_size;
2138 memset(&dev_info, 0, sizeof(dev_info));
2139 rte_eth_dev_info_get(res->port_id, &dev_info);
2140 if (dev_info.hash_key_size > 0 &&
2141 dev_info.hash_key_size <= sizeof(hash_key))
2142 hash_key_size = dev_info.hash_key_size;
2144 printf("dev_info did not provide a valid hash key size\n");
2147 /* Check the length of the RSS hash key */
2148 key_len = strlen(res->key);
2149 if (key_len != (hash_key_size * 2)) {
2150 printf("key length: %d invalid - key must be a string of %d"
2151 " hexa-decimal numbers\n",
2152 (int) key_len, hash_key_size * 2);
2155 /* Translate RSS hash key into binary representation */
2156 for (i = 0; i < hash_key_size; i++) {
2157 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2160 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2163 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2165 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2169 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2170 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2171 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2172 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2174 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2175 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2176 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2177 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2178 rss_hash_key, "rss-hash-key");
2179 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2180 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2181 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2182 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2183 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2184 "ipv6-tcp-ex#ipv6-udp-ex");
2185 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2186 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2188 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2189 .f = cmd_config_rss_hash_key_parsed,
2191 .help_str = "port config <port_id> rss-hash-key "
2192 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2193 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2194 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2195 "<string of hex digits (variable length, NIC dependent)>",
2197 (void *)&cmd_config_rss_hash_key_port,
2198 (void *)&cmd_config_rss_hash_key_config,
2199 (void *)&cmd_config_rss_hash_key_port_id,
2200 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2201 (void *)&cmd_config_rss_hash_key_rss_type,
2202 (void *)&cmd_config_rss_hash_key_value,
2207 /* *** configure port rxq/txq ring size *** */
2208 struct cmd_config_rxtx_ring_size {
2209 cmdline_fixed_string_t port;
2210 cmdline_fixed_string_t config;
2212 cmdline_fixed_string_t rxtxq;
2214 cmdline_fixed_string_t rsize;
2219 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2220 __attribute__((unused)) struct cmdline *cl,
2221 __attribute__((unused)) void *data)
2223 struct cmd_config_rxtx_ring_size *res = parsed_result;
2224 struct rte_port *port;
2227 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2230 if (res->portid == (portid_t)RTE_PORT_ALL) {
2231 printf("Invalid port id\n");
2235 port = &ports[res->portid];
2237 if (!strcmp(res->rxtxq, "rxq"))
2239 else if (!strcmp(res->rxtxq, "txq"))
2242 printf("Unknown parameter\n");
2246 if (isrx && rx_queue_id_is_invalid(res->qid))
2248 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2251 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2252 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2258 port->nb_rx_desc[res->qid] = res->size;
2260 port->nb_tx_desc[res->qid] = res->size;
2262 cmd_reconfig_device_queue(res->portid, 0, 1);
2265 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2268 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2269 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2271 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2272 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2274 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2275 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2277 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2278 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2280 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2281 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2282 rsize, "ring_size");
2283 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2284 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2287 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2288 .f = cmd_config_rxtx_ring_size_parsed,
2290 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2292 (void *)&cmd_config_rxtx_ring_size_port,
2293 (void *)&cmd_config_rxtx_ring_size_config,
2294 (void *)&cmd_config_rxtx_ring_size_portid,
2295 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2296 (void *)&cmd_config_rxtx_ring_size_qid,
2297 (void *)&cmd_config_rxtx_ring_size_rsize,
2298 (void *)&cmd_config_rxtx_ring_size_size,
2303 /* *** configure port rxq/txq start/stop *** */
2304 struct cmd_config_rxtx_queue {
2305 cmdline_fixed_string_t port;
2307 cmdline_fixed_string_t rxtxq;
2309 cmdline_fixed_string_t opname;
2313 cmd_config_rxtx_queue_parsed(void *parsed_result,
2314 __attribute__((unused)) struct cmdline *cl,
2315 __attribute__((unused)) void *data)
2317 struct cmd_config_rxtx_queue *res = parsed_result;
2322 if (test_done == 0) {
2323 printf("Please stop forwarding first\n");
2327 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2330 if (port_is_started(res->portid) != 1) {
2331 printf("Please start port %u first\n", res->portid);
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))
2346 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2349 if (!strcmp(res->opname, "start"))
2351 else if (!strcmp(res->opname, "stop"))
2354 printf("Unknown parameter\n");
2358 if (isstart && isrx)
2359 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2360 else if (!isstart && isrx)
2361 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2362 else if (isstart && !isrx)
2363 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2365 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2367 if (ret == -ENOTSUP)
2368 printf("Function not supported in PMD driver\n");
2371 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2372 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2373 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2374 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2375 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2376 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2377 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2378 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2379 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2380 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2383 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2384 .f = cmd_config_rxtx_queue_parsed,
2386 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2388 (void *)&cmd_config_rxtx_queue_port,
2389 (void *)&cmd_config_rxtx_queue_portid,
2390 (void *)&cmd_config_rxtx_queue_rxtxq,
2391 (void *)&cmd_config_rxtx_queue_qid,
2392 (void *)&cmd_config_rxtx_queue_opname,
2397 /* *** configure port rxq/txq setup *** */
2398 struct cmd_setup_rxtx_queue {
2399 cmdline_fixed_string_t port;
2401 cmdline_fixed_string_t rxtxq;
2403 cmdline_fixed_string_t setup;
2406 /* Common CLI fields for queue setup */
2407 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2408 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2409 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2410 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2411 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2412 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2413 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2414 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2415 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2416 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2419 cmd_setup_rxtx_queue_parsed(
2420 void *parsed_result,
2421 __attribute__((unused)) struct cmdline *cl,
2422 __attribute__((unused)) void *data)
2424 struct cmd_setup_rxtx_queue *res = parsed_result;
2425 struct rte_port *port;
2426 struct rte_mempool *mp;
2427 unsigned int socket_id;
2431 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2434 if (res->portid == (portid_t)RTE_PORT_ALL) {
2435 printf("Invalid port id\n");
2439 if (!strcmp(res->rxtxq, "rxq"))
2441 else if (!strcmp(res->rxtxq, "txq"))
2444 printf("Unknown parameter\n");
2448 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2449 printf("Invalid rx queue\n");
2451 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2452 printf("Invalid tx queue\n");
2456 port = &ports[res->portid];
2458 socket_id = rxring_numa[res->portid];
2459 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2460 socket_id = port->socket_id;
2462 mp = mbuf_pool_find(socket_id);
2464 printf("Failed to setup RX queue: "
2465 "No mempool allocation"
2466 " on the socket %d\n",
2467 rxring_numa[res->portid]);
2470 ret = rte_eth_rx_queue_setup(res->portid,
2472 port->nb_rx_desc[res->qid],
2474 &port->rx_conf[res->qid],
2477 printf("Failed to setup RX queue\n");
2479 socket_id = txring_numa[res->portid];
2480 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2481 socket_id = port->socket_id;
2483 ret = rte_eth_tx_queue_setup(res->portid,
2485 port->nb_tx_desc[res->qid],
2487 &port->tx_conf[res->qid]);
2489 printf("Failed to setup TX queue\n");
2493 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2494 .f = cmd_setup_rxtx_queue_parsed,
2496 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2498 (void *)&cmd_setup_rxtx_queue_port,
2499 (void *)&cmd_setup_rxtx_queue_portid,
2500 (void *)&cmd_setup_rxtx_queue_rxtxq,
2501 (void *)&cmd_setup_rxtx_queue_qid,
2502 (void *)&cmd_setup_rxtx_queue_setup,
2508 /* *** Configure RSS RETA *** */
2509 struct cmd_config_rss_reta {
2510 cmdline_fixed_string_t port;
2511 cmdline_fixed_string_t keyword;
2513 cmdline_fixed_string_t name;
2514 cmdline_fixed_string_t list_name;
2515 cmdline_fixed_string_t list_of_items;
2519 parse_reta_config(const char *str,
2520 struct rte_eth_rss_reta_entry64 *reta_conf,
2521 uint16_t nb_entries)
2525 uint16_t hash_index, idx, shift;
2528 const char *p, *p0 = str;
2535 unsigned long int_fld[_NUM_FLD];
2536 char *str_fld[_NUM_FLD];
2538 while ((p = strchr(p0,'(')) != NULL) {
2540 if((p0 = strchr(p,')')) == NULL)
2544 if(size >= sizeof(s))
2547 snprintf(s, sizeof(s), "%.*s", size, p);
2548 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2550 for (i = 0; i < _NUM_FLD; i++) {
2552 int_fld[i] = strtoul(str_fld[i], &end, 0);
2553 if (errno != 0 || end == str_fld[i] ||
2558 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2559 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2561 if (hash_index >= nb_entries) {
2562 printf("Invalid RETA hash index=%d\n", hash_index);
2566 idx = hash_index / RTE_RETA_GROUP_SIZE;
2567 shift = hash_index % RTE_RETA_GROUP_SIZE;
2568 reta_conf[idx].mask |= (1ULL << shift);
2569 reta_conf[idx].reta[shift] = nb_queue;
2576 cmd_set_rss_reta_parsed(void *parsed_result,
2577 __attribute__((unused)) struct cmdline *cl,
2578 __attribute__((unused)) void *data)
2581 struct rte_eth_dev_info dev_info;
2582 struct rte_eth_rss_reta_entry64 reta_conf[8];
2583 struct cmd_config_rss_reta *res = parsed_result;
2585 memset(&dev_info, 0, sizeof(dev_info));
2586 rte_eth_dev_info_get(res->port_id, &dev_info);
2587 if (dev_info.reta_size == 0) {
2588 printf("Redirection table size is 0 which is "
2589 "invalid for RSS\n");
2592 printf("The reta size of port %d is %u\n",
2593 res->port_id, dev_info.reta_size);
2594 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2595 printf("Currently do not support more than %u entries of "
2596 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2600 memset(reta_conf, 0, sizeof(reta_conf));
2601 if (!strcmp(res->list_name, "reta")) {
2602 if (parse_reta_config(res->list_of_items, reta_conf,
2603 dev_info.reta_size)) {
2604 printf("Invalid RSS Redirection Table "
2605 "config entered\n");
2608 ret = rte_eth_dev_rss_reta_update(res->port_id,
2609 reta_conf, dev_info.reta_size);
2611 printf("Bad redirection table parameter, "
2612 "return code = %d \n", ret);
2616 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2617 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2618 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2619 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2620 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2621 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2622 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2623 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2624 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2625 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2626 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2627 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2629 cmdline_parse_inst_t cmd_config_rss_reta = {
2630 .f = cmd_set_rss_reta_parsed,
2632 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2634 (void *)&cmd_config_rss_reta_port,
2635 (void *)&cmd_config_rss_reta_keyword,
2636 (void *)&cmd_config_rss_reta_port_id,
2637 (void *)&cmd_config_rss_reta_name,
2638 (void *)&cmd_config_rss_reta_list_name,
2639 (void *)&cmd_config_rss_reta_list_of_items,
2644 /* *** SHOW PORT RETA INFO *** */
2645 struct cmd_showport_reta {
2646 cmdline_fixed_string_t show;
2647 cmdline_fixed_string_t port;
2649 cmdline_fixed_string_t rss;
2650 cmdline_fixed_string_t reta;
2652 cmdline_fixed_string_t list_of_items;
2656 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2657 uint16_t nb_entries,
2661 const char *p, *p0 = str;
2666 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2667 RTE_RETA_GROUP_SIZE;
2670 p = strchr(p0, '(');
2674 p0 = strchr(p, ')');
2678 if (size >= sizeof(s)) {
2679 printf("The string size exceeds the internal buffer size\n");
2682 snprintf(s, sizeof(s), "%.*s", size, p);
2683 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2684 if (ret <= 0 || ret != num) {
2685 printf("The bits of masks do not match the number of "
2686 "reta entries: %u\n", num);
2689 for (i = 0; i < ret; i++)
2690 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2696 cmd_showport_reta_parsed(void *parsed_result,
2697 __attribute__((unused)) struct cmdline *cl,
2698 __attribute__((unused)) void *data)
2700 struct cmd_showport_reta *res = parsed_result;
2701 struct rte_eth_rss_reta_entry64 reta_conf[8];
2702 struct rte_eth_dev_info dev_info;
2703 uint16_t max_reta_size;
2705 memset(&dev_info, 0, sizeof(dev_info));
2706 rte_eth_dev_info_get(res->port_id, &dev_info);
2707 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2708 if (res->size == 0 || res->size > max_reta_size) {
2709 printf("Invalid redirection table size: %u (1-%u)\n",
2710 res->size, max_reta_size);
2714 memset(reta_conf, 0, sizeof(reta_conf));
2715 if (showport_parse_reta_config(reta_conf, res->size,
2716 res->list_of_items) < 0) {
2717 printf("Invalid string: %s for reta masks\n",
2718 res->list_of_items);
2721 port_rss_reta_info(res->port_id, reta_conf, res->size);
2724 cmdline_parse_token_string_t cmd_showport_reta_show =
2725 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2726 cmdline_parse_token_string_t cmd_showport_reta_port =
2727 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2728 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2729 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2730 cmdline_parse_token_string_t cmd_showport_reta_rss =
2731 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2732 cmdline_parse_token_string_t cmd_showport_reta_reta =
2733 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2734 cmdline_parse_token_num_t cmd_showport_reta_size =
2735 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2736 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2737 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2738 list_of_items, NULL);
2740 cmdline_parse_inst_t cmd_showport_reta = {
2741 .f = cmd_showport_reta_parsed,
2743 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2745 (void *)&cmd_showport_reta_show,
2746 (void *)&cmd_showport_reta_port,
2747 (void *)&cmd_showport_reta_port_id,
2748 (void *)&cmd_showport_reta_rss,
2749 (void *)&cmd_showport_reta_reta,
2750 (void *)&cmd_showport_reta_size,
2751 (void *)&cmd_showport_reta_list_of_items,
2756 /* *** Show RSS hash configuration *** */
2757 struct cmd_showport_rss_hash {
2758 cmdline_fixed_string_t show;
2759 cmdline_fixed_string_t port;
2761 cmdline_fixed_string_t rss_hash;
2762 cmdline_fixed_string_t rss_type;
2763 cmdline_fixed_string_t key; /* optional argument */
2766 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2767 __attribute__((unused)) struct cmdline *cl,
2770 struct cmd_showport_rss_hash *res = parsed_result;
2772 port_rss_hash_conf_show(res->port_id, res->rss_type,
2773 show_rss_key != NULL);
2776 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2777 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2778 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2779 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2780 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2781 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2782 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2783 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2785 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2786 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2787 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2788 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2789 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2790 "ipv6-tcp-ex#ipv6-udp-ex");
2791 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2792 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2794 cmdline_parse_inst_t cmd_showport_rss_hash = {
2795 .f = cmd_showport_rss_hash_parsed,
2797 .help_str = "show port <port_id> rss-hash "
2798 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2799 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2800 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2802 (void *)&cmd_showport_rss_hash_show,
2803 (void *)&cmd_showport_rss_hash_port,
2804 (void *)&cmd_showport_rss_hash_port_id,
2805 (void *)&cmd_showport_rss_hash_rss_hash,
2806 (void *)&cmd_showport_rss_hash_rss_hash_info,
2811 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2812 .f = cmd_showport_rss_hash_parsed,
2814 .help_str = "show port <port_id> rss-hash "
2815 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2816 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2817 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2819 (void *)&cmd_showport_rss_hash_show,
2820 (void *)&cmd_showport_rss_hash_port,
2821 (void *)&cmd_showport_rss_hash_port_id,
2822 (void *)&cmd_showport_rss_hash_rss_hash,
2823 (void *)&cmd_showport_rss_hash_rss_hash_info,
2824 (void *)&cmd_showport_rss_hash_rss_key,
2829 /* *** Configure DCB *** */
2830 struct cmd_config_dcb {
2831 cmdline_fixed_string_t port;
2832 cmdline_fixed_string_t config;
2834 cmdline_fixed_string_t dcb;
2835 cmdline_fixed_string_t vt;
2836 cmdline_fixed_string_t vt_en;
2838 cmdline_fixed_string_t pfc;
2839 cmdline_fixed_string_t pfc_en;
2843 cmd_config_dcb_parsed(void *parsed_result,
2844 __attribute__((unused)) struct cmdline *cl,
2845 __attribute__((unused)) void *data)
2847 struct cmd_config_dcb *res = parsed_result;
2848 portid_t port_id = res->port_id;
2849 struct rte_port *port;
2853 port = &ports[port_id];
2854 /** Check if the port is not started **/
2855 if (port->port_status != RTE_PORT_STOPPED) {
2856 printf("Please stop port %d first\n", port_id);
2860 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2861 printf("The invalid number of traffic class,"
2862 " only 4 or 8 allowed.\n");
2866 if (nb_fwd_lcores < res->num_tcs) {
2867 printf("nb_cores shouldn't be less than number of TCs.\n");
2870 if (!strncmp(res->pfc_en, "on", 2))
2875 /* DCB in VT mode */
2876 if (!strncmp(res->vt_en, "on", 2))
2877 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2878 (enum rte_eth_nb_tcs)res->num_tcs,
2881 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2882 (enum rte_eth_nb_tcs)res->num_tcs,
2887 printf("Cannot initialize network ports.\n");
2891 cmd_reconfig_device_queue(port_id, 1, 1);
2894 cmdline_parse_token_string_t cmd_config_dcb_port =
2895 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2896 cmdline_parse_token_string_t cmd_config_dcb_config =
2897 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2898 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2899 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2900 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2901 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2902 cmdline_parse_token_string_t cmd_config_dcb_vt =
2903 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2904 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2905 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2906 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2907 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2908 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2909 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2910 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2911 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2913 cmdline_parse_inst_t cmd_config_dcb = {
2914 .f = cmd_config_dcb_parsed,
2916 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2918 (void *)&cmd_config_dcb_port,
2919 (void *)&cmd_config_dcb_config,
2920 (void *)&cmd_config_dcb_port_id,
2921 (void *)&cmd_config_dcb_dcb,
2922 (void *)&cmd_config_dcb_vt,
2923 (void *)&cmd_config_dcb_vt_en,
2924 (void *)&cmd_config_dcb_num_tcs,
2925 (void *)&cmd_config_dcb_pfc,
2926 (void *)&cmd_config_dcb_pfc_en,
2931 /* *** configure number of packets per burst *** */
2932 struct cmd_config_burst {
2933 cmdline_fixed_string_t port;
2934 cmdline_fixed_string_t keyword;
2935 cmdline_fixed_string_t all;
2936 cmdline_fixed_string_t name;
2941 cmd_config_burst_parsed(void *parsed_result,
2942 __attribute__((unused)) struct cmdline *cl,
2943 __attribute__((unused)) void *data)
2945 struct cmd_config_burst *res = parsed_result;
2946 struct rte_eth_dev_info dev_info;
2947 uint16_t rec_nb_pkts;
2949 if (!all_ports_stopped()) {
2950 printf("Please stop all ports first\n");
2954 if (!strcmp(res->name, "burst")) {
2955 if (res->value == 0) {
2956 /* If user gives a value of zero, query the PMD for
2957 * its recommended Rx burst size. Testpmd uses a single
2958 * size for all ports, so assume all ports are the same
2959 * NIC model and use the values from Port 0.
2961 rte_eth_dev_info_get(0, &dev_info);
2962 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2964 if (rec_nb_pkts == 0) {
2965 printf("PMD does not recommend a burst size.\n"
2966 "User provided value must be between"
2967 " 1 and %d\n", MAX_PKT_BURST);
2969 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2970 printf("PMD recommended burst size of %d"
2971 " exceeds maximum value of %d\n",
2972 rec_nb_pkts, MAX_PKT_BURST);
2975 printf("Using PMD-provided burst value of %d\n",
2977 nb_pkt_per_burst = rec_nb_pkts;
2978 } else if (res->value > MAX_PKT_BURST) {
2979 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2982 nb_pkt_per_burst = res->value;
2984 printf("Unknown parameter\n");
2990 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2993 cmdline_parse_token_string_t cmd_config_burst_port =
2994 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2995 cmdline_parse_token_string_t cmd_config_burst_keyword =
2996 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2997 cmdline_parse_token_string_t cmd_config_burst_all =
2998 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2999 cmdline_parse_token_string_t cmd_config_burst_name =
3000 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3001 cmdline_parse_token_num_t cmd_config_burst_value =
3002 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3004 cmdline_parse_inst_t cmd_config_burst = {
3005 .f = cmd_config_burst_parsed,
3007 .help_str = "port config all burst <value>",
3009 (void *)&cmd_config_burst_port,
3010 (void *)&cmd_config_burst_keyword,
3011 (void *)&cmd_config_burst_all,
3012 (void *)&cmd_config_burst_name,
3013 (void *)&cmd_config_burst_value,
3018 /* *** configure rx/tx queues *** */
3019 struct cmd_config_thresh {
3020 cmdline_fixed_string_t port;
3021 cmdline_fixed_string_t keyword;
3022 cmdline_fixed_string_t all;
3023 cmdline_fixed_string_t name;
3028 cmd_config_thresh_parsed(void *parsed_result,
3029 __attribute__((unused)) struct cmdline *cl,
3030 __attribute__((unused)) void *data)
3032 struct cmd_config_thresh *res = parsed_result;
3034 if (!all_ports_stopped()) {
3035 printf("Please stop all ports first\n");
3039 if (!strcmp(res->name, "txpt"))
3040 tx_pthresh = res->value;
3041 else if(!strcmp(res->name, "txht"))
3042 tx_hthresh = res->value;
3043 else if(!strcmp(res->name, "txwt"))
3044 tx_wthresh = res->value;
3045 else if(!strcmp(res->name, "rxpt"))
3046 rx_pthresh = res->value;
3047 else if(!strcmp(res->name, "rxht"))
3048 rx_hthresh = res->value;
3049 else if(!strcmp(res->name, "rxwt"))
3050 rx_wthresh = res->value;
3052 printf("Unknown parameter\n");
3058 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3061 cmdline_parse_token_string_t cmd_config_thresh_port =
3062 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3063 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3064 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3065 cmdline_parse_token_string_t cmd_config_thresh_all =
3066 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3067 cmdline_parse_token_string_t cmd_config_thresh_name =
3068 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3069 "txpt#txht#txwt#rxpt#rxht#rxwt");
3070 cmdline_parse_token_num_t cmd_config_thresh_value =
3071 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3073 cmdline_parse_inst_t cmd_config_thresh = {
3074 .f = cmd_config_thresh_parsed,
3076 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3078 (void *)&cmd_config_thresh_port,
3079 (void *)&cmd_config_thresh_keyword,
3080 (void *)&cmd_config_thresh_all,
3081 (void *)&cmd_config_thresh_name,
3082 (void *)&cmd_config_thresh_value,
3087 /* *** configure free/rs threshold *** */
3088 struct cmd_config_threshold {
3089 cmdline_fixed_string_t port;
3090 cmdline_fixed_string_t keyword;
3091 cmdline_fixed_string_t all;
3092 cmdline_fixed_string_t name;
3097 cmd_config_threshold_parsed(void *parsed_result,
3098 __attribute__((unused)) struct cmdline *cl,
3099 __attribute__((unused)) void *data)
3101 struct cmd_config_threshold *res = parsed_result;
3103 if (!all_ports_stopped()) {
3104 printf("Please stop all ports first\n");
3108 if (!strcmp(res->name, "txfreet"))
3109 tx_free_thresh = res->value;
3110 else if (!strcmp(res->name, "txrst"))
3111 tx_rs_thresh = res->value;
3112 else if (!strcmp(res->name, "rxfreet"))
3113 rx_free_thresh = res->value;
3115 printf("Unknown parameter\n");
3121 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3124 cmdline_parse_token_string_t cmd_config_threshold_port =
3125 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3126 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3127 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3129 cmdline_parse_token_string_t cmd_config_threshold_all =
3130 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3131 cmdline_parse_token_string_t cmd_config_threshold_name =
3132 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3133 "txfreet#txrst#rxfreet");
3134 cmdline_parse_token_num_t cmd_config_threshold_value =
3135 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3137 cmdline_parse_inst_t cmd_config_threshold = {
3138 .f = cmd_config_threshold_parsed,
3140 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3142 (void *)&cmd_config_threshold_port,
3143 (void *)&cmd_config_threshold_keyword,
3144 (void *)&cmd_config_threshold_all,
3145 (void *)&cmd_config_threshold_name,
3146 (void *)&cmd_config_threshold_value,
3152 struct cmd_stop_result {
3153 cmdline_fixed_string_t stop;
3156 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3157 __attribute__((unused)) struct cmdline *cl,
3158 __attribute__((unused)) void *data)
3160 stop_packet_forwarding();
3163 cmdline_parse_token_string_t cmd_stop_stop =
3164 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3166 cmdline_parse_inst_t cmd_stop = {
3167 .f = cmd_stop_parsed,
3169 .help_str = "stop: Stop packet forwarding",
3171 (void *)&cmd_stop_stop,
3176 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3179 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3180 unsigned int *parsed_items, int check_unique_values)
3182 unsigned int nb_item;
3190 * First parse all items in the list and store their value.
3195 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3197 if ((c >= '0') && (c <= '9')) {
3198 value = (unsigned int) (value * 10 + (c - '0'));
3203 printf("character %c is not a decimal digit\n", c);
3207 printf("No valid value before comma\n");
3210 if (nb_item < max_items) {
3211 parsed_items[nb_item] = value;
3217 if (nb_item >= max_items) {
3218 printf("Number of %s = %u > %u (maximum items)\n",
3219 item_name, nb_item + 1, max_items);
3222 parsed_items[nb_item++] = value;
3223 if (! check_unique_values)
3227 * Then, check that all values in the list are differents.
3228 * No optimization here...
3230 for (i = 0; i < nb_item; i++) {
3231 for (j = i + 1; j < nb_item; j++) {
3232 if (parsed_items[j] == parsed_items[i]) {
3233 printf("duplicated %s %u at index %u and %u\n",
3234 item_name, parsed_items[i], i, j);
3242 struct cmd_set_list_result {
3243 cmdline_fixed_string_t cmd_keyword;
3244 cmdline_fixed_string_t list_name;
3245 cmdline_fixed_string_t list_of_items;
3248 static void cmd_set_list_parsed(void *parsed_result,
3249 __attribute__((unused)) struct cmdline *cl,
3250 __attribute__((unused)) void *data)
3252 struct cmd_set_list_result *res;
3254 unsigned int lcorelist[RTE_MAX_LCORE];
3255 unsigned int portlist[RTE_MAX_ETHPORTS];
3257 unsigned int nb_item;
3259 if (test_done == 0) {
3260 printf("Please stop forwarding first\n");
3264 res = parsed_result;
3265 if (!strcmp(res->list_name, "corelist")) {
3266 nb_item = parse_item_list(res->list_of_items, "core",
3268 parsed_items.lcorelist, 1);
3270 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3275 if (!strcmp(res->list_name, "portlist")) {
3276 nb_item = parse_item_list(res->list_of_items, "port",
3278 parsed_items.portlist, 1);
3280 set_fwd_ports_list(parsed_items.portlist, nb_item);
3286 cmdline_parse_token_string_t cmd_set_list_keyword =
3287 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3289 cmdline_parse_token_string_t cmd_set_list_name =
3290 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3291 "corelist#portlist");
3292 cmdline_parse_token_string_t cmd_set_list_of_items =
3293 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3296 cmdline_parse_inst_t cmd_set_fwd_list = {
3297 .f = cmd_set_list_parsed,
3299 .help_str = "set corelist|portlist <list0[,list1]*>",
3301 (void *)&cmd_set_list_keyword,
3302 (void *)&cmd_set_list_name,
3303 (void *)&cmd_set_list_of_items,
3308 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3310 struct cmd_setmask_result {
3311 cmdline_fixed_string_t set;
3312 cmdline_fixed_string_t mask;
3316 static void cmd_set_mask_parsed(void *parsed_result,
3317 __attribute__((unused)) struct cmdline *cl,
3318 __attribute__((unused)) void *data)
3320 struct cmd_setmask_result *res = parsed_result;
3322 if (test_done == 0) {
3323 printf("Please stop forwarding first\n");
3326 if (!strcmp(res->mask, "coremask")) {
3327 set_fwd_lcores_mask(res->hexavalue);
3329 } else if (!strcmp(res->mask, "portmask")) {
3330 set_fwd_ports_mask(res->hexavalue);
3335 cmdline_parse_token_string_t cmd_setmask_set =
3336 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3337 cmdline_parse_token_string_t cmd_setmask_mask =
3338 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3339 "coremask#portmask");
3340 cmdline_parse_token_num_t cmd_setmask_value =
3341 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3343 cmdline_parse_inst_t cmd_set_fwd_mask = {
3344 .f = cmd_set_mask_parsed,
3346 .help_str = "set coremask|portmask <hexadecimal value>",
3348 (void *)&cmd_setmask_set,
3349 (void *)&cmd_setmask_mask,
3350 (void *)&cmd_setmask_value,
3356 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3358 struct cmd_set_result {
3359 cmdline_fixed_string_t set;
3360 cmdline_fixed_string_t what;
3364 static void cmd_set_parsed(void *parsed_result,
3365 __attribute__((unused)) struct cmdline *cl,
3366 __attribute__((unused)) void *data)
3368 struct cmd_set_result *res = parsed_result;
3369 if (!strcmp(res->what, "nbport")) {
3370 set_fwd_ports_number(res->value);
3372 } else if (!strcmp(res->what, "nbcore")) {
3373 set_fwd_lcores_number(res->value);
3375 } else if (!strcmp(res->what, "burst"))
3376 set_nb_pkt_per_burst(res->value);
3377 else if (!strcmp(res->what, "verbose"))
3378 set_verbose_level(res->value);
3381 cmdline_parse_token_string_t cmd_set_set =
3382 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3383 cmdline_parse_token_string_t cmd_set_what =
3384 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3385 "nbport#nbcore#burst#verbose");
3386 cmdline_parse_token_num_t cmd_set_value =
3387 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3389 cmdline_parse_inst_t cmd_set_numbers = {
3390 .f = cmd_set_parsed,
3392 .help_str = "set nbport|nbcore|burst|verbose <value>",
3394 (void *)&cmd_set_set,
3395 (void *)&cmd_set_what,
3396 (void *)&cmd_set_value,
3401 /* *** SET LOG LEVEL CONFIGURATION *** */
3403 struct cmd_set_log_result {
3404 cmdline_fixed_string_t set;
3405 cmdline_fixed_string_t log;
3406 cmdline_fixed_string_t type;
3411 cmd_set_log_parsed(void *parsed_result,
3412 __attribute__((unused)) struct cmdline *cl,
3413 __attribute__((unused)) void *data)
3415 struct cmd_set_log_result *res;
3418 res = parsed_result;
3419 if (!strcmp(res->type, "global"))
3420 rte_log_set_global_level(res->level);
3422 ret = rte_log_set_level_regexp(res->type, res->level);
3424 printf("Unable to set log level\n");
3428 cmdline_parse_token_string_t cmd_set_log_set =
3429 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3430 cmdline_parse_token_string_t cmd_set_log_log =
3431 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3432 cmdline_parse_token_string_t cmd_set_log_type =
3433 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3434 cmdline_parse_token_num_t cmd_set_log_level =
3435 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3437 cmdline_parse_inst_t cmd_set_log = {
3438 .f = cmd_set_log_parsed,
3440 .help_str = "set log global|<type> <level>",
3442 (void *)&cmd_set_log_set,
3443 (void *)&cmd_set_log_log,
3444 (void *)&cmd_set_log_type,
3445 (void *)&cmd_set_log_level,
3450 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3452 struct cmd_set_txpkts_result {
3453 cmdline_fixed_string_t cmd_keyword;
3454 cmdline_fixed_string_t txpkts;
3455 cmdline_fixed_string_t seg_lengths;
3459 cmd_set_txpkts_parsed(void *parsed_result,
3460 __attribute__((unused)) struct cmdline *cl,
3461 __attribute__((unused)) void *data)
3463 struct cmd_set_txpkts_result *res;
3464 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3465 unsigned int nb_segs;
3467 res = parsed_result;
3468 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3469 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3471 set_tx_pkt_segments(seg_lengths, nb_segs);
3474 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3475 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3476 cmd_keyword, "set");
3477 cmdline_parse_token_string_t cmd_set_txpkts_name =
3478 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3480 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3481 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3484 cmdline_parse_inst_t cmd_set_txpkts = {
3485 .f = cmd_set_txpkts_parsed,
3487 .help_str = "set txpkts <len0[,len1]*>",
3489 (void *)&cmd_set_txpkts_keyword,
3490 (void *)&cmd_set_txpkts_name,
3491 (void *)&cmd_set_txpkts_lengths,
3496 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3498 struct cmd_set_txsplit_result {
3499 cmdline_fixed_string_t cmd_keyword;
3500 cmdline_fixed_string_t txsplit;
3501 cmdline_fixed_string_t mode;
3505 cmd_set_txsplit_parsed(void *parsed_result,
3506 __attribute__((unused)) struct cmdline *cl,
3507 __attribute__((unused)) void *data)
3509 struct cmd_set_txsplit_result *res;
3511 res = parsed_result;
3512 set_tx_pkt_split(res->mode);
3515 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3516 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3517 cmd_keyword, "set");
3518 cmdline_parse_token_string_t cmd_set_txsplit_name =
3519 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3520 txsplit, "txsplit");
3521 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3522 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3525 cmdline_parse_inst_t cmd_set_txsplit = {
3526 .f = cmd_set_txsplit_parsed,
3528 .help_str = "set txsplit on|off|rand",
3530 (void *)&cmd_set_txsplit_keyword,
3531 (void *)&cmd_set_txsplit_name,
3532 (void *)&cmd_set_txsplit_mode,
3537 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3538 struct cmd_rx_vlan_filter_all_result {
3539 cmdline_fixed_string_t rx_vlan;
3540 cmdline_fixed_string_t what;
3541 cmdline_fixed_string_t all;
3546 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3547 __attribute__((unused)) struct cmdline *cl,
3548 __attribute__((unused)) void *data)
3550 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3552 if (!strcmp(res->what, "add"))
3553 rx_vlan_all_filter_set(res->port_id, 1);
3555 rx_vlan_all_filter_set(res->port_id, 0);
3558 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3559 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3560 rx_vlan, "rx_vlan");
3561 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3562 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3564 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3565 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3567 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3568 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3571 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3572 .f = cmd_rx_vlan_filter_all_parsed,
3574 .help_str = "rx_vlan add|rm all <port_id>: "
3575 "Add/Remove all identifiers to/from the set of VLAN "
3576 "identifiers filtered by a port",
3578 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3579 (void *)&cmd_rx_vlan_filter_all_what,
3580 (void *)&cmd_rx_vlan_filter_all_all,
3581 (void *)&cmd_rx_vlan_filter_all_portid,
3586 /* *** VLAN OFFLOAD SET ON A PORT *** */
3587 struct cmd_vlan_offload_result {
3588 cmdline_fixed_string_t vlan;
3589 cmdline_fixed_string_t set;
3590 cmdline_fixed_string_t vlan_type;
3591 cmdline_fixed_string_t what;
3592 cmdline_fixed_string_t on;
3593 cmdline_fixed_string_t port_id;
3597 cmd_vlan_offload_parsed(void *parsed_result,
3598 __attribute__((unused)) struct cmdline *cl,
3599 __attribute__((unused)) void *data)
3602 struct cmd_vlan_offload_result *res = parsed_result;
3605 portid_t port_id = 0;
3609 len = strnlen(str, STR_TOKEN_SIZE);
3611 /* Get port_id first */
3619 tmp = strtoul(str, NULL, 0);
3620 /* If port_id greater that what portid_t can represent, return */
3621 if(tmp >= RTE_MAX_ETHPORTS)
3623 port_id = (portid_t)tmp;
3625 if (!strcmp(res->on, "on"))
3630 if (!strcmp(res->what, "strip"))
3631 rx_vlan_strip_set(port_id, on);
3632 else if(!strcmp(res->what, "stripq")){
3633 uint16_t queue_id = 0;
3635 /* No queue_id, return */
3637 printf("must specify (port,queue_id)\n");
3640 tmp = strtoul(str + i + 1, NULL, 0);
3641 /* If queue_id greater that what 16-bits can represent, return */
3645 queue_id = (uint16_t)tmp;
3646 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3648 else if (!strcmp(res->what, "filter"))
3649 rx_vlan_filter_set(port_id, on);
3651 vlan_extend_set(port_id, on);
3656 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3657 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3659 cmdline_parse_token_string_t cmd_vlan_offload_set =
3660 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3662 cmdline_parse_token_string_t cmd_vlan_offload_what =
3663 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3664 what, "strip#filter#qinq#stripq");
3665 cmdline_parse_token_string_t cmd_vlan_offload_on =
3666 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3668 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3669 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3672 cmdline_parse_inst_t cmd_vlan_offload = {
3673 .f = cmd_vlan_offload_parsed,
3675 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3676 "<port_id[,queue_id]>: "
3677 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3679 (void *)&cmd_vlan_offload_vlan,
3680 (void *)&cmd_vlan_offload_set,
3681 (void *)&cmd_vlan_offload_what,
3682 (void *)&cmd_vlan_offload_on,
3683 (void *)&cmd_vlan_offload_portid,
3688 /* *** VLAN TPID SET ON A PORT *** */
3689 struct cmd_vlan_tpid_result {
3690 cmdline_fixed_string_t vlan;
3691 cmdline_fixed_string_t set;
3692 cmdline_fixed_string_t vlan_type;
3693 cmdline_fixed_string_t what;
3699 cmd_vlan_tpid_parsed(void *parsed_result,
3700 __attribute__((unused)) struct cmdline *cl,
3701 __attribute__((unused)) void *data)
3703 struct cmd_vlan_tpid_result *res = parsed_result;
3704 enum rte_vlan_type vlan_type;
3706 if (!strcmp(res->vlan_type, "inner"))
3707 vlan_type = ETH_VLAN_TYPE_INNER;
3708 else if (!strcmp(res->vlan_type, "outer"))
3709 vlan_type = ETH_VLAN_TYPE_OUTER;
3711 printf("Unknown vlan type\n");
3714 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3717 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3718 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3720 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3721 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3723 cmdline_parse_token_string_t cmd_vlan_type =
3724 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3725 vlan_type, "inner#outer");
3726 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3727 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3729 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3730 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3732 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3733 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3736 cmdline_parse_inst_t cmd_vlan_tpid = {
3737 .f = cmd_vlan_tpid_parsed,
3739 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3740 "Set the VLAN Ether type",
3742 (void *)&cmd_vlan_tpid_vlan,
3743 (void *)&cmd_vlan_tpid_set,
3744 (void *)&cmd_vlan_type,
3745 (void *)&cmd_vlan_tpid_what,
3746 (void *)&cmd_vlan_tpid_tpid,
3747 (void *)&cmd_vlan_tpid_portid,
3752 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3753 struct cmd_rx_vlan_filter_result {
3754 cmdline_fixed_string_t rx_vlan;
3755 cmdline_fixed_string_t what;
3761 cmd_rx_vlan_filter_parsed(void *parsed_result,
3762 __attribute__((unused)) struct cmdline *cl,
3763 __attribute__((unused)) void *data)
3765 struct cmd_rx_vlan_filter_result *res = parsed_result;
3767 if (!strcmp(res->what, "add"))
3768 rx_vft_set(res->port_id, res->vlan_id, 1);
3770 rx_vft_set(res->port_id, res->vlan_id, 0);
3773 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3774 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3775 rx_vlan, "rx_vlan");
3776 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3777 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3779 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3780 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3782 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3783 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3786 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3787 .f = cmd_rx_vlan_filter_parsed,
3789 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3790 "Add/Remove a VLAN identifier to/from the set of VLAN "
3791 "identifiers filtered by a port",
3793 (void *)&cmd_rx_vlan_filter_rx_vlan,
3794 (void *)&cmd_rx_vlan_filter_what,
3795 (void *)&cmd_rx_vlan_filter_vlanid,
3796 (void *)&cmd_rx_vlan_filter_portid,
3801 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3802 struct cmd_tx_vlan_set_result {
3803 cmdline_fixed_string_t tx_vlan;
3804 cmdline_fixed_string_t set;
3810 cmd_tx_vlan_set_parsed(void *parsed_result,
3811 __attribute__((unused)) struct cmdline *cl,
3812 __attribute__((unused)) void *data)
3814 struct cmd_tx_vlan_set_result *res = parsed_result;
3816 if (!port_is_stopped(res->port_id)) {
3817 printf("Please stop port %d first\n", res->port_id);
3821 tx_vlan_set(res->port_id, res->vlan_id);
3823 cmd_reconfig_device_queue(res->port_id, 1, 1);
3826 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3827 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3828 tx_vlan, "tx_vlan");
3829 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3830 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3832 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3833 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3835 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3836 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3839 cmdline_parse_inst_t cmd_tx_vlan_set = {
3840 .f = cmd_tx_vlan_set_parsed,
3842 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3843 "Enable hardware insertion of a single VLAN header "
3844 "with a given TAG Identifier in packets sent on a port",
3846 (void *)&cmd_tx_vlan_set_tx_vlan,
3847 (void *)&cmd_tx_vlan_set_set,
3848 (void *)&cmd_tx_vlan_set_portid,
3849 (void *)&cmd_tx_vlan_set_vlanid,
3854 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3855 struct cmd_tx_vlan_set_qinq_result {
3856 cmdline_fixed_string_t tx_vlan;
3857 cmdline_fixed_string_t set;
3860 uint16_t vlan_id_outer;
3864 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3865 __attribute__((unused)) struct cmdline *cl,
3866 __attribute__((unused)) void *data)
3868 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3870 if (!port_is_stopped(res->port_id)) {
3871 printf("Please stop port %d first\n", res->port_id);
3875 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3877 cmd_reconfig_device_queue(res->port_id, 1, 1);
3880 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3881 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3882 tx_vlan, "tx_vlan");
3883 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3884 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3886 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3887 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3889 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3890 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3892 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3893 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3894 vlan_id_outer, UINT16);
3896 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3897 .f = cmd_tx_vlan_set_qinq_parsed,
3899 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3900 "Enable hardware insertion of double VLAN header "
3901 "with given TAG Identifiers in packets sent on a port",
3903 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3904 (void *)&cmd_tx_vlan_set_qinq_set,
3905 (void *)&cmd_tx_vlan_set_qinq_portid,
3906 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3907 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3912 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3913 struct cmd_tx_vlan_set_pvid_result {
3914 cmdline_fixed_string_t tx_vlan;
3915 cmdline_fixed_string_t set;
3916 cmdline_fixed_string_t pvid;
3919 cmdline_fixed_string_t mode;
3923 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3924 __attribute__((unused)) struct cmdline *cl,
3925 __attribute__((unused)) void *data)
3927 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3929 if (strcmp(res->mode, "on") == 0)
3930 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3932 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3935 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3936 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3937 tx_vlan, "tx_vlan");
3938 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3939 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3941 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3942 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3944 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3945 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3947 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3948 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3950 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3951 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3954 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3955 .f = cmd_tx_vlan_set_pvid_parsed,
3957 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3959 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3960 (void *)&cmd_tx_vlan_set_pvid_set,
3961 (void *)&cmd_tx_vlan_set_pvid_pvid,
3962 (void *)&cmd_tx_vlan_set_pvid_port_id,
3963 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3964 (void *)&cmd_tx_vlan_set_pvid_mode,
3969 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3970 struct cmd_tx_vlan_reset_result {
3971 cmdline_fixed_string_t tx_vlan;
3972 cmdline_fixed_string_t reset;
3977 cmd_tx_vlan_reset_parsed(void *parsed_result,
3978 __attribute__((unused)) struct cmdline *cl,
3979 __attribute__((unused)) void *data)
3981 struct cmd_tx_vlan_reset_result *res = parsed_result;
3983 if (!port_is_stopped(res->port_id)) {
3984 printf("Please stop port %d first\n", res->port_id);
3988 tx_vlan_reset(res->port_id);
3990 cmd_reconfig_device_queue(res->port_id, 1, 1);
3993 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3994 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3995 tx_vlan, "tx_vlan");
3996 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3997 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3999 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4000 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4003 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4004 .f = cmd_tx_vlan_reset_parsed,
4006 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4007 "VLAN header in packets sent on a port",
4009 (void *)&cmd_tx_vlan_reset_tx_vlan,
4010 (void *)&cmd_tx_vlan_reset_reset,
4011 (void *)&cmd_tx_vlan_reset_portid,
4017 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4018 struct cmd_csum_result {
4019 cmdline_fixed_string_t csum;
4020 cmdline_fixed_string_t mode;
4021 cmdline_fixed_string_t proto;
4022 cmdline_fixed_string_t hwsw;
4027 csum_show(int port_id)
4029 struct rte_eth_dev_info dev_info;
4030 uint64_t tx_offloads;
4032 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4033 printf("Parse tunnel is %s\n",
4034 (ports[port_id].parse_tunnel) ? "on" : "off");
4035 printf("IP checksum offload is %s\n",
4036 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4037 printf("UDP checksum offload is %s\n",
4038 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4039 printf("TCP checksum offload is %s\n",
4040 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4041 printf("SCTP checksum offload is %s\n",
4042 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4043 printf("Outer-Ip checksum offload is %s\n",
4044 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4046 /* display warnings if configuration is not supported by the NIC */
4047 rte_eth_dev_info_get(port_id, &dev_info);
4048 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4049 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4050 printf("Warning: hardware IP checksum enabled but not "
4051 "supported by port %d\n", port_id);
4053 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4054 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4055 printf("Warning: hardware UDP checksum enabled but not "
4056 "supported by port %d\n", port_id);
4058 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4059 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4060 printf("Warning: hardware TCP checksum enabled but not "
4061 "supported by port %d\n", port_id);
4063 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4064 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4065 printf("Warning: hardware SCTP checksum enabled but not "
4066 "supported by port %d\n", port_id);
4068 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4069 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4070 printf("Warning: hardware outer IP checksum enabled but not "
4071 "supported by port %d\n", port_id);
4076 cmd_csum_parsed(void *parsed_result,
4077 __attribute__((unused)) struct cmdline *cl,
4078 __attribute__((unused)) void *data)
4080 struct cmd_csum_result *res = parsed_result;
4082 uint64_t csum_offloads = 0;
4083 struct rte_eth_dev_info dev_info;
4085 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4086 printf("invalid port %d\n", res->port_id);
4089 if (!port_is_stopped(res->port_id)) {
4090 printf("Please stop port %d first\n", res->port_id);
4094 rte_eth_dev_info_get(res->port_id, &dev_info);
4095 if (!strcmp(res->mode, "set")) {
4097 if (!strcmp(res->hwsw, "hw"))
4100 if (!strcmp(res->proto, "ip")) {
4101 if (hw == 0 || (dev_info.tx_offload_capa &
4102 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4103 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4105 printf("IP checksum offload is not supported "
4106 "by port %u\n", res->port_id);
4108 } else if (!strcmp(res->proto, "udp")) {
4109 if (hw == 0 || (dev_info.tx_offload_capa &
4110 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4111 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4113 printf("UDP checksum offload is not supported "
4114 "by port %u\n", res->port_id);
4116 } else if (!strcmp(res->proto, "tcp")) {
4117 if (hw == 0 || (dev_info.tx_offload_capa &
4118 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4119 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4121 printf("TCP checksum offload is not supported "
4122 "by port %u\n", res->port_id);
4124 } else if (!strcmp(res->proto, "sctp")) {
4125 if (hw == 0 || (dev_info.tx_offload_capa &
4126 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4127 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4129 printf("SCTP checksum offload is not supported "
4130 "by port %u\n", res->port_id);
4132 } else if (!strcmp(res->proto, "outer-ip")) {
4133 if (hw == 0 || (dev_info.tx_offload_capa &
4134 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4136 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4138 printf("Outer IP checksum offload is not "
4139 "supported by port %u\n", res->port_id);
4144 ports[res->port_id].dev_conf.txmode.offloads |=
4147 ports[res->port_id].dev_conf.txmode.offloads &=
4151 csum_show(res->port_id);
4153 cmd_reconfig_device_queue(res->port_id, 1, 1);
4156 cmdline_parse_token_string_t cmd_csum_csum =
4157 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4159 cmdline_parse_token_string_t cmd_csum_mode =
4160 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4162 cmdline_parse_token_string_t cmd_csum_proto =
4163 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4164 proto, "ip#tcp#udp#sctp#outer-ip");
4165 cmdline_parse_token_string_t cmd_csum_hwsw =
4166 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4168 cmdline_parse_token_num_t cmd_csum_portid =
4169 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4172 cmdline_parse_inst_t cmd_csum_set = {
4173 .f = cmd_csum_parsed,
4175 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4176 "Enable/Disable hardware calculation of L3/L4 checksum when "
4177 "using csum forward engine",
4179 (void *)&cmd_csum_csum,
4180 (void *)&cmd_csum_mode,
4181 (void *)&cmd_csum_proto,
4182 (void *)&cmd_csum_hwsw,
4183 (void *)&cmd_csum_portid,
4188 cmdline_parse_token_string_t cmd_csum_mode_show =
4189 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4192 cmdline_parse_inst_t cmd_csum_show = {
4193 .f = cmd_csum_parsed,
4195 .help_str = "csum show <port_id>: Show checksum offload configuration",
4197 (void *)&cmd_csum_csum,
4198 (void *)&cmd_csum_mode_show,
4199 (void *)&cmd_csum_portid,
4204 /* Enable/disable tunnel parsing */
4205 struct cmd_csum_tunnel_result {
4206 cmdline_fixed_string_t csum;
4207 cmdline_fixed_string_t parse;
4208 cmdline_fixed_string_t onoff;
4213 cmd_csum_tunnel_parsed(void *parsed_result,
4214 __attribute__((unused)) struct cmdline *cl,
4215 __attribute__((unused)) void *data)
4217 struct cmd_csum_tunnel_result *res = parsed_result;
4219 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4222 if (!strcmp(res->onoff, "on"))
4223 ports[res->port_id].parse_tunnel = 1;
4225 ports[res->port_id].parse_tunnel = 0;
4227 csum_show(res->port_id);
4230 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4231 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4233 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4234 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4235 parse, "parse_tunnel");
4236 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4237 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4239 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4240 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4243 cmdline_parse_inst_t cmd_csum_tunnel = {
4244 .f = cmd_csum_tunnel_parsed,
4246 .help_str = "csum parse_tunnel on|off <port_id>: "
4247 "Enable/Disable parsing of tunnels for csum engine",
4249 (void *)&cmd_csum_tunnel_csum,
4250 (void *)&cmd_csum_tunnel_parse,
4251 (void *)&cmd_csum_tunnel_onoff,
4252 (void *)&cmd_csum_tunnel_portid,
4257 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4258 struct cmd_tso_set_result {
4259 cmdline_fixed_string_t tso;
4260 cmdline_fixed_string_t mode;
4266 cmd_tso_set_parsed(void *parsed_result,
4267 __attribute__((unused)) struct cmdline *cl,
4268 __attribute__((unused)) void *data)
4270 struct cmd_tso_set_result *res = parsed_result;
4271 struct rte_eth_dev_info dev_info;
4273 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4275 if (!port_is_stopped(res->port_id)) {
4276 printf("Please stop port %d first\n", res->port_id);
4280 if (!strcmp(res->mode, "set"))
4281 ports[res->port_id].tso_segsz = res->tso_segsz;
4283 rte_eth_dev_info_get(res->port_id, &dev_info);
4284 if ((ports[res->port_id].tso_segsz != 0) &&
4285 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4286 printf("Error: TSO is not supported by port %d\n",
4291 if (ports[res->port_id].tso_segsz == 0) {
4292 ports[res->port_id].dev_conf.txmode.offloads &=
4293 ~DEV_TX_OFFLOAD_TCP_TSO;
4294 printf("TSO for non-tunneled packets is disabled\n");
4296 ports[res->port_id].dev_conf.txmode.offloads |=
4297 DEV_TX_OFFLOAD_TCP_TSO;
4298 printf("TSO segment size for non-tunneled packets is %d\n",
4299 ports[res->port_id].tso_segsz);
4302 /* display warnings if configuration is not supported by the NIC */
4303 rte_eth_dev_info_get(res->port_id, &dev_info);
4304 if ((ports[res->port_id].tso_segsz != 0) &&
4305 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4306 printf("Warning: TSO enabled but not "
4307 "supported by port %d\n", res->port_id);
4310 cmd_reconfig_device_queue(res->port_id, 1, 1);
4313 cmdline_parse_token_string_t cmd_tso_set_tso =
4314 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4316 cmdline_parse_token_string_t cmd_tso_set_mode =
4317 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4319 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4320 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4322 cmdline_parse_token_num_t cmd_tso_set_portid =
4323 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4326 cmdline_parse_inst_t cmd_tso_set = {
4327 .f = cmd_tso_set_parsed,
4329 .help_str = "tso set <tso_segsz> <port_id>: "
4330 "Set TSO segment size of non-tunneled packets for csum engine "
4333 (void *)&cmd_tso_set_tso,
4334 (void *)&cmd_tso_set_mode,
4335 (void *)&cmd_tso_set_tso_segsz,
4336 (void *)&cmd_tso_set_portid,
4341 cmdline_parse_token_string_t cmd_tso_show_mode =
4342 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4346 cmdline_parse_inst_t cmd_tso_show = {
4347 .f = cmd_tso_set_parsed,
4349 .help_str = "tso show <port_id>: "
4350 "Show TSO segment size of non-tunneled packets for csum engine",
4352 (void *)&cmd_tso_set_tso,
4353 (void *)&cmd_tso_show_mode,
4354 (void *)&cmd_tso_set_portid,
4359 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4360 struct cmd_tunnel_tso_set_result {
4361 cmdline_fixed_string_t tso;
4362 cmdline_fixed_string_t mode;
4367 static struct rte_eth_dev_info
4368 check_tunnel_tso_nic_support(portid_t port_id)
4370 struct rte_eth_dev_info dev_info;
4372 rte_eth_dev_info_get(port_id, &dev_info);
4373 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4374 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4375 "not enabled for port %d\n", port_id);
4376 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4377 printf("Warning: GRE TUNNEL TSO not supported therefore "
4378 "not enabled for port %d\n", port_id);
4379 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4380 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4381 "not enabled for port %d\n", port_id);
4382 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4383 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4384 "not enabled for port %d\n", port_id);
4385 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4386 printf("Warning: IP TUNNEL TSO not supported therefore "
4387 "not enabled for port %d\n", port_id);
4388 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4389 printf("Warning: UDP TUNNEL TSO not supported therefore "
4390 "not enabled for port %d\n", port_id);
4395 cmd_tunnel_tso_set_parsed(void *parsed_result,
4396 __attribute__((unused)) struct cmdline *cl,
4397 __attribute__((unused)) void *data)
4399 struct cmd_tunnel_tso_set_result *res = parsed_result;
4400 struct rte_eth_dev_info dev_info;
4402 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4404 if (!port_is_stopped(res->port_id)) {
4405 printf("Please stop port %d first\n", res->port_id);
4409 if (!strcmp(res->mode, "set"))
4410 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4412 dev_info = check_tunnel_tso_nic_support(res->port_id);
4413 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4414 ports[res->port_id].dev_conf.txmode.offloads &=
4415 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4416 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4417 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4418 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4419 DEV_TX_OFFLOAD_IP_TNL_TSO |
4420 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4421 printf("TSO for tunneled packets is disabled\n");
4423 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4424 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4425 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4426 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4427 DEV_TX_OFFLOAD_IP_TNL_TSO |
4428 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4430 ports[res->port_id].dev_conf.txmode.offloads |=
4431 (tso_offloads & dev_info.tx_offload_capa);
4432 printf("TSO segment size for tunneled packets is %d\n",
4433 ports[res->port_id].tunnel_tso_segsz);
4435 /* Below conditions are needed to make it work:
4436 * (1) tunnel TSO is supported by the NIC;
4437 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4439 * (3) for tunneled pkts with outer L3 of IPv4,
4440 * "csum set outer-ip" must be set to hw, because after tso,
4441 * total_len of outer IP header is changed, and the checksum
4442 * of outer IP header calculated by sw should be wrong; that
4443 * is not necessary for IPv6 tunneled pkts because there's no
4444 * checksum in IP header anymore.
4447 if (!ports[res->port_id].parse_tunnel)
4448 printf("Warning: csum parse_tunnel must be set "
4449 "so that tunneled packets are recognized\n");
4450 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4451 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4452 printf("Warning: csum set outer-ip must be set to hw "
4453 "if outer L3 is IPv4; not necessary for IPv6\n");
4456 cmd_reconfig_device_queue(res->port_id, 1, 1);
4459 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4460 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4462 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4463 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4465 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4466 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4468 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4469 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4472 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4473 .f = cmd_tunnel_tso_set_parsed,
4475 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4476 "Set TSO segment size of tunneled packets for csum engine "
4479 (void *)&cmd_tunnel_tso_set_tso,
4480 (void *)&cmd_tunnel_tso_set_mode,
4481 (void *)&cmd_tunnel_tso_set_tso_segsz,
4482 (void *)&cmd_tunnel_tso_set_portid,
4487 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4488 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4492 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4493 .f = cmd_tunnel_tso_set_parsed,
4495 .help_str = "tunnel_tso show <port_id> "
4496 "Show TSO segment size of tunneled packets for csum engine",
4498 (void *)&cmd_tunnel_tso_set_tso,
4499 (void *)&cmd_tunnel_tso_show_mode,
4500 (void *)&cmd_tunnel_tso_set_portid,
4505 /* *** SET GRO FOR A PORT *** */
4506 struct cmd_gro_enable_result {
4507 cmdline_fixed_string_t cmd_set;
4508 cmdline_fixed_string_t cmd_port;
4509 cmdline_fixed_string_t cmd_keyword;
4510 cmdline_fixed_string_t cmd_onoff;
4515 cmd_gro_enable_parsed(void *parsed_result,
4516 __attribute__((unused)) struct cmdline *cl,
4517 __attribute__((unused)) void *data)
4519 struct cmd_gro_enable_result *res;
4521 res = parsed_result;
4522 if (!strcmp(res->cmd_keyword, "gro"))
4523 setup_gro(res->cmd_onoff, res->cmd_pid);
4526 cmdline_parse_token_string_t cmd_gro_enable_set =
4527 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4529 cmdline_parse_token_string_t cmd_gro_enable_port =
4530 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4531 cmd_keyword, "port");
4532 cmdline_parse_token_num_t cmd_gro_enable_pid =
4533 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4535 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4536 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4537 cmd_keyword, "gro");
4538 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4539 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4540 cmd_onoff, "on#off");
4542 cmdline_parse_inst_t cmd_gro_enable = {
4543 .f = cmd_gro_enable_parsed,
4545 .help_str = "set port <port_id> gro on|off",
4547 (void *)&cmd_gro_enable_set,
4548 (void *)&cmd_gro_enable_port,
4549 (void *)&cmd_gro_enable_pid,
4550 (void *)&cmd_gro_enable_keyword,
4551 (void *)&cmd_gro_enable_onoff,
4556 /* *** DISPLAY GRO CONFIGURATION *** */
4557 struct cmd_gro_show_result {
4558 cmdline_fixed_string_t cmd_show;
4559 cmdline_fixed_string_t cmd_port;
4560 cmdline_fixed_string_t cmd_keyword;
4565 cmd_gro_show_parsed(void *parsed_result,
4566 __attribute__((unused)) struct cmdline *cl,
4567 __attribute__((unused)) void *data)
4569 struct cmd_gro_show_result *res;
4571 res = parsed_result;
4572 if (!strcmp(res->cmd_keyword, "gro"))
4573 show_gro(res->cmd_pid);
4576 cmdline_parse_token_string_t cmd_gro_show_show =
4577 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4579 cmdline_parse_token_string_t cmd_gro_show_port =
4580 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4582 cmdline_parse_token_num_t cmd_gro_show_pid =
4583 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4585 cmdline_parse_token_string_t cmd_gro_show_keyword =
4586 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4587 cmd_keyword, "gro");
4589 cmdline_parse_inst_t cmd_gro_show = {
4590 .f = cmd_gro_show_parsed,
4592 .help_str = "show port <port_id> gro",
4594 (void *)&cmd_gro_show_show,
4595 (void *)&cmd_gro_show_port,
4596 (void *)&cmd_gro_show_pid,
4597 (void *)&cmd_gro_show_keyword,
4602 /* *** SET FLUSH CYCLES FOR GRO *** */
4603 struct cmd_gro_flush_result {
4604 cmdline_fixed_string_t cmd_set;
4605 cmdline_fixed_string_t cmd_keyword;
4606 cmdline_fixed_string_t cmd_flush;
4611 cmd_gro_flush_parsed(void *parsed_result,
4612 __attribute__((unused)) struct cmdline *cl,
4613 __attribute__((unused)) void *data)
4615 struct cmd_gro_flush_result *res;
4617 res = parsed_result;
4618 if ((!strcmp(res->cmd_keyword, "gro")) &&
4619 (!strcmp(res->cmd_flush, "flush")))
4620 setup_gro_flush_cycles(res->cmd_cycles);
4623 cmdline_parse_token_string_t cmd_gro_flush_set =
4624 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4626 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4627 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4628 cmd_keyword, "gro");
4629 cmdline_parse_token_string_t cmd_gro_flush_flush =
4630 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4631 cmd_flush, "flush");
4632 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4633 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4636 cmdline_parse_inst_t cmd_gro_flush = {
4637 .f = cmd_gro_flush_parsed,
4639 .help_str = "set gro flush <cycles>",
4641 (void *)&cmd_gro_flush_set,
4642 (void *)&cmd_gro_flush_keyword,
4643 (void *)&cmd_gro_flush_flush,
4644 (void *)&cmd_gro_flush_cycles,
4649 /* *** ENABLE/DISABLE GSO *** */
4650 struct cmd_gso_enable_result {
4651 cmdline_fixed_string_t cmd_set;
4652 cmdline_fixed_string_t cmd_port;
4653 cmdline_fixed_string_t cmd_keyword;
4654 cmdline_fixed_string_t cmd_mode;
4659 cmd_gso_enable_parsed(void *parsed_result,
4660 __attribute__((unused)) struct cmdline *cl,
4661 __attribute__((unused)) void *data)
4663 struct cmd_gso_enable_result *res;
4665 res = parsed_result;
4666 if (!strcmp(res->cmd_keyword, "gso"))
4667 setup_gso(res->cmd_mode, res->cmd_pid);
4670 cmdline_parse_token_string_t cmd_gso_enable_set =
4671 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4673 cmdline_parse_token_string_t cmd_gso_enable_port =
4674 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4676 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4677 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4678 cmd_keyword, "gso");
4679 cmdline_parse_token_string_t cmd_gso_enable_mode =
4680 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4681 cmd_mode, "on#off");
4682 cmdline_parse_token_num_t cmd_gso_enable_pid =
4683 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4686 cmdline_parse_inst_t cmd_gso_enable = {
4687 .f = cmd_gso_enable_parsed,
4689 .help_str = "set port <port_id> gso on|off",
4691 (void *)&cmd_gso_enable_set,
4692 (void *)&cmd_gso_enable_port,
4693 (void *)&cmd_gso_enable_pid,
4694 (void *)&cmd_gso_enable_keyword,
4695 (void *)&cmd_gso_enable_mode,
4700 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4701 struct cmd_gso_size_result {
4702 cmdline_fixed_string_t cmd_set;
4703 cmdline_fixed_string_t cmd_keyword;
4704 cmdline_fixed_string_t cmd_segsz;
4709 cmd_gso_size_parsed(void *parsed_result,
4710 __attribute__((unused)) struct cmdline *cl,
4711 __attribute__((unused)) void *data)
4713 struct cmd_gso_size_result *res = parsed_result;
4715 if (test_done == 0) {
4716 printf("Before setting GSO segsz, please first"
4717 " stop fowarding\n");
4721 if (!strcmp(res->cmd_keyword, "gso") &&
4722 !strcmp(res->cmd_segsz, "segsz")) {
4723 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4724 printf("gso_size should be larger than %zu."
4725 " Please input a legal value\n",
4726 RTE_GSO_SEG_SIZE_MIN);
4728 gso_max_segment_size = res->cmd_size;
4732 cmdline_parse_token_string_t cmd_gso_size_set =
4733 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4735 cmdline_parse_token_string_t cmd_gso_size_keyword =
4736 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4737 cmd_keyword, "gso");
4738 cmdline_parse_token_string_t cmd_gso_size_segsz =
4739 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4740 cmd_segsz, "segsz");
4741 cmdline_parse_token_num_t cmd_gso_size_size =
4742 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4745 cmdline_parse_inst_t cmd_gso_size = {
4746 .f = cmd_gso_size_parsed,
4748 .help_str = "set gso segsz <length>",
4750 (void *)&cmd_gso_size_set,
4751 (void *)&cmd_gso_size_keyword,
4752 (void *)&cmd_gso_size_segsz,
4753 (void *)&cmd_gso_size_size,
4758 /* *** SHOW GSO CONFIGURATION *** */
4759 struct cmd_gso_show_result {
4760 cmdline_fixed_string_t cmd_show;
4761 cmdline_fixed_string_t cmd_port;
4762 cmdline_fixed_string_t cmd_keyword;
4767 cmd_gso_show_parsed(void *parsed_result,
4768 __attribute__((unused)) struct cmdline *cl,
4769 __attribute__((unused)) void *data)
4771 struct cmd_gso_show_result *res = parsed_result;
4773 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4774 printf("invalid port id %u\n", res->cmd_pid);
4777 if (!strcmp(res->cmd_keyword, "gso")) {
4778 if (gso_ports[res->cmd_pid].enable) {
4779 printf("Max GSO'd packet size: %uB\n"
4780 "Supported GSO types: TCP/IPv4, "
4781 "VxLAN with inner TCP/IPv4 packet, "
4782 "GRE with inner TCP/IPv4 packet\n",
4783 gso_max_segment_size);
4785 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4789 cmdline_parse_token_string_t cmd_gso_show_show =
4790 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4792 cmdline_parse_token_string_t cmd_gso_show_port =
4793 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4795 cmdline_parse_token_string_t cmd_gso_show_keyword =
4796 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4797 cmd_keyword, "gso");
4798 cmdline_parse_token_num_t cmd_gso_show_pid =
4799 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4802 cmdline_parse_inst_t cmd_gso_show = {
4803 .f = cmd_gso_show_parsed,
4805 .help_str = "show port <port_id> gso",
4807 (void *)&cmd_gso_show_show,
4808 (void *)&cmd_gso_show_port,
4809 (void *)&cmd_gso_show_pid,
4810 (void *)&cmd_gso_show_keyword,
4815 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4816 struct cmd_set_flush_rx {
4817 cmdline_fixed_string_t set;
4818 cmdline_fixed_string_t flush_rx;
4819 cmdline_fixed_string_t mode;
4823 cmd_set_flush_rx_parsed(void *parsed_result,
4824 __attribute__((unused)) struct cmdline *cl,
4825 __attribute__((unused)) void *data)
4827 struct cmd_set_flush_rx *res = parsed_result;
4828 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4831 cmdline_parse_token_string_t cmd_setflushrx_set =
4832 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4834 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4835 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4836 flush_rx, "flush_rx");
4837 cmdline_parse_token_string_t cmd_setflushrx_mode =
4838 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4842 cmdline_parse_inst_t cmd_set_flush_rx = {
4843 .f = cmd_set_flush_rx_parsed,
4844 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4847 (void *)&cmd_setflushrx_set,
4848 (void *)&cmd_setflushrx_flush_rx,
4849 (void *)&cmd_setflushrx_mode,
4854 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4855 struct cmd_set_link_check {
4856 cmdline_fixed_string_t set;
4857 cmdline_fixed_string_t link_check;
4858 cmdline_fixed_string_t mode;
4862 cmd_set_link_check_parsed(void *parsed_result,
4863 __attribute__((unused)) struct cmdline *cl,
4864 __attribute__((unused)) void *data)
4866 struct cmd_set_link_check *res = parsed_result;
4867 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4870 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4871 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4873 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4874 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4875 link_check, "link_check");
4876 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4877 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4881 cmdline_parse_inst_t cmd_set_link_check = {
4882 .f = cmd_set_link_check_parsed,
4883 .help_str = "set link_check on|off: Enable/Disable link status check "
4884 "when starting/stopping a port",
4887 (void *)&cmd_setlinkcheck_set,
4888 (void *)&cmd_setlinkcheck_link_check,
4889 (void *)&cmd_setlinkcheck_mode,
4894 /* *** SET NIC BYPASS MODE *** */
4895 struct cmd_set_bypass_mode_result {
4896 cmdline_fixed_string_t set;
4897 cmdline_fixed_string_t bypass;
4898 cmdline_fixed_string_t mode;
4899 cmdline_fixed_string_t value;
4904 cmd_set_bypass_mode_parsed(void *parsed_result,
4905 __attribute__((unused)) struct cmdline *cl,
4906 __attribute__((unused)) void *data)
4908 struct cmd_set_bypass_mode_result *res = parsed_result;
4909 portid_t port_id = res->port_id;
4910 int32_t rc = -EINVAL;
4912 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4913 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4915 if (!strcmp(res->value, "bypass"))
4916 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4917 else if (!strcmp(res->value, "isolate"))
4918 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4920 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4922 /* Set the bypass mode for the relevant port. */
4923 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4926 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4929 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4930 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4932 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4933 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4935 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4936 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4938 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4939 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4940 value, "normal#bypass#isolate");
4941 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4942 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4945 cmdline_parse_inst_t cmd_set_bypass_mode = {
4946 .f = cmd_set_bypass_mode_parsed,
4947 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4948 "Set the NIC bypass mode for port_id",
4951 (void *)&cmd_setbypass_mode_set,
4952 (void *)&cmd_setbypass_mode_bypass,
4953 (void *)&cmd_setbypass_mode_mode,
4954 (void *)&cmd_setbypass_mode_value,
4955 (void *)&cmd_setbypass_mode_port,
4960 /* *** SET NIC BYPASS EVENT *** */
4961 struct cmd_set_bypass_event_result {
4962 cmdline_fixed_string_t set;
4963 cmdline_fixed_string_t bypass;
4964 cmdline_fixed_string_t event;
4965 cmdline_fixed_string_t event_value;
4966 cmdline_fixed_string_t mode;
4967 cmdline_fixed_string_t mode_value;
4972 cmd_set_bypass_event_parsed(void *parsed_result,
4973 __attribute__((unused)) struct cmdline *cl,
4974 __attribute__((unused)) void *data)
4976 int32_t rc = -EINVAL;
4977 struct cmd_set_bypass_event_result *res = parsed_result;
4978 portid_t port_id = res->port_id;
4980 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4981 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4982 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4984 if (!strcmp(res->event_value, "timeout"))
4985 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4986 else if (!strcmp(res->event_value, "os_on"))
4987 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4988 else if (!strcmp(res->event_value, "os_off"))
4989 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4990 else if (!strcmp(res->event_value, "power_on"))
4991 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4992 else if (!strcmp(res->event_value, "power_off"))
4993 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4995 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4997 if (!strcmp(res->mode_value, "bypass"))
4998 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4999 else if (!strcmp(res->mode_value, "isolate"))
5000 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5002 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5004 /* Set the watchdog timeout. */
5005 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5008 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5009 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5013 printf("Failed to set timeout value %u "
5014 "for port %d, errto code: %d.\n",
5015 bypass_timeout, port_id, rc);
5019 /* Set the bypass event to transition to bypass mode. */
5020 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5025 printf("\t Failed to set bypass event for port = %d.\n",
5029 cmdline_parse_token_string_t cmd_setbypass_event_set =
5030 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5032 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5033 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5035 cmdline_parse_token_string_t cmd_setbypass_event_event =
5036 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5038 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5039 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5040 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5041 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5042 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5044 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5045 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5046 mode_value, "normal#bypass#isolate");
5047 cmdline_parse_token_num_t cmd_setbypass_event_port =
5048 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5051 cmdline_parse_inst_t cmd_set_bypass_event = {
5052 .f = cmd_set_bypass_event_parsed,
5053 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5054 "power_off mode normal|bypass|isolate <port_id>: "
5055 "Set the NIC bypass event mode for port_id",
5058 (void *)&cmd_setbypass_event_set,
5059 (void *)&cmd_setbypass_event_bypass,
5060 (void *)&cmd_setbypass_event_event,
5061 (void *)&cmd_setbypass_event_event_value,
5062 (void *)&cmd_setbypass_event_mode,
5063 (void *)&cmd_setbypass_event_mode_value,
5064 (void *)&cmd_setbypass_event_port,
5070 /* *** SET NIC BYPASS TIMEOUT *** */
5071 struct cmd_set_bypass_timeout_result {
5072 cmdline_fixed_string_t set;
5073 cmdline_fixed_string_t bypass;
5074 cmdline_fixed_string_t timeout;
5075 cmdline_fixed_string_t value;
5079 cmd_set_bypass_timeout_parsed(void *parsed_result,
5080 __attribute__((unused)) struct cmdline *cl,
5081 __attribute__((unused)) void *data)
5083 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5085 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5086 if (!strcmp(res->value, "1.5"))
5087 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5088 else if (!strcmp(res->value, "2"))
5089 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5090 else if (!strcmp(res->value, "3"))
5091 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5092 else if (!strcmp(res->value, "4"))
5093 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5094 else if (!strcmp(res->value, "8"))
5095 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5096 else if (!strcmp(res->value, "16"))
5097 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5098 else if (!strcmp(res->value, "32"))
5099 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5101 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5105 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5106 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5108 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5109 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5111 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5112 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5113 timeout, "timeout");
5114 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5115 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5116 value, "0#1.5#2#3#4#8#16#32");
5118 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5119 .f = cmd_set_bypass_timeout_parsed,
5120 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5121 "Set the NIC bypass watchdog timeout in seconds",
5124 (void *)&cmd_setbypass_timeout_set,
5125 (void *)&cmd_setbypass_timeout_bypass,
5126 (void *)&cmd_setbypass_timeout_timeout,
5127 (void *)&cmd_setbypass_timeout_value,
5132 /* *** SHOW NIC BYPASS MODE *** */
5133 struct cmd_show_bypass_config_result {
5134 cmdline_fixed_string_t show;
5135 cmdline_fixed_string_t bypass;
5136 cmdline_fixed_string_t config;
5141 cmd_show_bypass_config_parsed(void *parsed_result,
5142 __attribute__((unused)) struct cmdline *cl,
5143 __attribute__((unused)) void *data)
5145 struct cmd_show_bypass_config_result *res = parsed_result;
5146 portid_t port_id = res->port_id;
5148 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5149 uint32_t event_mode;
5150 uint32_t bypass_mode;
5151 uint32_t timeout = bypass_timeout;
5154 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5155 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5156 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5157 {"UNKNOWN", "normal", "bypass", "isolate"};
5158 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5165 int num_events = (sizeof events) / (sizeof events[0]);
5167 /* Display the bypass mode.*/
5168 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5169 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5173 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5174 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5176 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5179 /* Display the bypass timeout.*/
5180 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5181 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5183 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5185 /* Display the bypass events and associated modes. */
5186 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5188 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5189 printf("\tFailed to get bypass mode for event = %s\n",
5192 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5193 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5195 printf("\tbypass event: %-16s = %s\n", events[i],
5201 printf("\tFailed to get bypass configuration for port = %d\n",
5205 cmdline_parse_token_string_t cmd_showbypass_config_show =
5206 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5208 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5209 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5211 cmdline_parse_token_string_t cmd_showbypass_config_config =
5212 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5214 cmdline_parse_token_num_t cmd_showbypass_config_port =
5215 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5218 cmdline_parse_inst_t cmd_show_bypass_config = {
5219 .f = cmd_show_bypass_config_parsed,
5220 .help_str = "show bypass config <port_id>: "
5221 "Show the NIC bypass config for port_id",
5224 (void *)&cmd_showbypass_config_show,
5225 (void *)&cmd_showbypass_config_bypass,
5226 (void *)&cmd_showbypass_config_config,
5227 (void *)&cmd_showbypass_config_port,
5232 #ifdef RTE_LIBRTE_PMD_BOND
5233 /* *** SET BONDING MODE *** */
5234 struct cmd_set_bonding_mode_result {
5235 cmdline_fixed_string_t set;
5236 cmdline_fixed_string_t bonding;
5237 cmdline_fixed_string_t mode;
5242 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5243 __attribute__((unused)) struct cmdline *cl,
5244 __attribute__((unused)) void *data)
5246 struct cmd_set_bonding_mode_result *res = parsed_result;
5247 portid_t port_id = res->port_id;
5249 /* Set the bonding mode for the relevant port. */
5250 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5251 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5254 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5255 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5257 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5258 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5259 bonding, "bonding");
5260 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5261 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5263 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5264 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5266 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5267 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5270 cmdline_parse_inst_t cmd_set_bonding_mode = {
5271 .f = cmd_set_bonding_mode_parsed,
5272 .help_str = "set bonding mode <mode_value> <port_id>: "
5273 "Set the bonding mode for port_id",
5276 (void *) &cmd_setbonding_mode_set,
5277 (void *) &cmd_setbonding_mode_bonding,
5278 (void *) &cmd_setbonding_mode_mode,
5279 (void *) &cmd_setbonding_mode_value,
5280 (void *) &cmd_setbonding_mode_port,
5285 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5286 struct cmd_set_bonding_lacp_dedicated_queues_result {
5287 cmdline_fixed_string_t set;
5288 cmdline_fixed_string_t bonding;
5289 cmdline_fixed_string_t lacp;
5290 cmdline_fixed_string_t dedicated_queues;
5292 cmdline_fixed_string_t mode;
5295 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5296 __attribute__((unused)) struct cmdline *cl,
5297 __attribute__((unused)) void *data)
5299 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5300 portid_t port_id = res->port_id;
5301 struct rte_port *port;
5303 port = &ports[port_id];
5305 /** Check if the port is not started **/
5306 if (port->port_status != RTE_PORT_STOPPED) {
5307 printf("Please stop port %d first\n", port_id);
5311 if (!strcmp(res->mode, "enable")) {
5312 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5313 printf("Dedicate queues for LACP control packets"
5316 printf("Enabling dedicate queues for LACP control "
5317 "packets on port %d failed\n", port_id);
5318 } else if (!strcmp(res->mode, "disable")) {
5319 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5320 printf("Dedicated queues for LACP control packets "
5323 printf("Disabling dedicated queues for LACP control "
5324 "traffic on port %d failed\n", port_id);
5328 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5329 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5331 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5332 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5333 bonding, "bonding");
5334 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5335 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5337 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5338 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5339 dedicated_queues, "dedicated_queues");
5340 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5341 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5343 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5344 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5345 mode, "enable#disable");
5347 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5348 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5349 .help_str = "set bonding lacp dedicated_queues <port_id> "
5351 "Enable/disable dedicated queues for LACP control traffic for port_id",
5354 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5355 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5356 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5357 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5358 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5359 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5364 /* *** SET BALANCE XMIT POLICY *** */
5365 struct cmd_set_bonding_balance_xmit_policy_result {
5366 cmdline_fixed_string_t set;
5367 cmdline_fixed_string_t bonding;
5368 cmdline_fixed_string_t balance_xmit_policy;
5370 cmdline_fixed_string_t policy;
5373 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5374 __attribute__((unused)) struct cmdline *cl,
5375 __attribute__((unused)) void *data)
5377 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5378 portid_t port_id = res->port_id;
5381 if (!strcmp(res->policy, "l2")) {
5382 policy = BALANCE_XMIT_POLICY_LAYER2;
5383 } else if (!strcmp(res->policy, "l23")) {
5384 policy = BALANCE_XMIT_POLICY_LAYER23;
5385 } else if (!strcmp(res->policy, "l34")) {
5386 policy = BALANCE_XMIT_POLICY_LAYER34;
5388 printf("\t Invalid xmit policy selection");
5392 /* Set the bonding mode for the relevant port. */
5393 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5394 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5399 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5400 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5402 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5403 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5404 bonding, "bonding");
5405 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5406 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5407 balance_xmit_policy, "balance_xmit_policy");
5408 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5409 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5411 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5412 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5413 policy, "l2#l23#l34");
5415 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5416 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5417 .help_str = "set bonding balance_xmit_policy <port_id> "
5419 "Set the bonding balance_xmit_policy for port_id",
5422 (void *)&cmd_setbonding_balance_xmit_policy_set,
5423 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5424 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5425 (void *)&cmd_setbonding_balance_xmit_policy_port,
5426 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5431 /* *** SHOW NIC BONDING CONFIGURATION *** */
5432 struct cmd_show_bonding_config_result {
5433 cmdline_fixed_string_t show;
5434 cmdline_fixed_string_t bonding;
5435 cmdline_fixed_string_t config;
5439 static void cmd_show_bonding_config_parsed(void *parsed_result,
5440 __attribute__((unused)) struct cmdline *cl,
5441 __attribute__((unused)) void *data)
5443 struct cmd_show_bonding_config_result *res = parsed_result;
5444 int bonding_mode, agg_mode;
5445 portid_t slaves[RTE_MAX_ETHPORTS];
5446 int num_slaves, num_active_slaves;
5449 portid_t port_id = res->port_id;
5451 /* Display the bonding mode.*/
5452 bonding_mode = rte_eth_bond_mode_get(port_id);
5453 if (bonding_mode < 0) {
5454 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5457 printf("\tBonding mode: %d\n", bonding_mode);
5459 if (bonding_mode == BONDING_MODE_BALANCE) {
5460 int balance_xmit_policy;
5462 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5463 if (balance_xmit_policy < 0) {
5464 printf("\tFailed to get balance xmit policy for port = %d\n",
5468 printf("\tBalance Xmit Policy: ");
5470 switch (balance_xmit_policy) {
5471 case BALANCE_XMIT_POLICY_LAYER2:
5472 printf("BALANCE_XMIT_POLICY_LAYER2");
5474 case BALANCE_XMIT_POLICY_LAYER23:
5475 printf("BALANCE_XMIT_POLICY_LAYER23");
5477 case BALANCE_XMIT_POLICY_LAYER34:
5478 printf("BALANCE_XMIT_POLICY_LAYER34");
5485 if (bonding_mode == BONDING_MODE_8023AD) {
5486 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5487 printf("\tIEEE802.3AD Aggregator Mode: ");
5490 printf("bandwidth");
5502 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5504 if (num_slaves < 0) {
5505 printf("\tFailed to get slave list for port = %d\n", port_id);
5508 if (num_slaves > 0) {
5509 printf("\tSlaves (%d): [", num_slaves);
5510 for (i = 0; i < num_slaves - 1; i++)
5511 printf("%d ", slaves[i]);
5513 printf("%d]\n", slaves[num_slaves - 1]);
5515 printf("\tSlaves: []\n");
5519 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5522 if (num_active_slaves < 0) {
5523 printf("\tFailed to get active slave list for port = %d\n", port_id);
5526 if (num_active_slaves > 0) {
5527 printf("\tActive Slaves (%d): [", num_active_slaves);
5528 for (i = 0; i < num_active_slaves - 1; i++)
5529 printf("%d ", slaves[i]);
5531 printf("%d]\n", slaves[num_active_slaves - 1]);
5534 printf("\tActive Slaves: []\n");
5538 primary_id = rte_eth_bond_primary_get(port_id);
5539 if (primary_id < 0) {
5540 printf("\tFailed to get primary slave for port = %d\n", port_id);
5543 printf("\tPrimary: [%d]\n", primary_id);
5547 cmdline_parse_token_string_t cmd_showbonding_config_show =
5548 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5550 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5551 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5552 bonding, "bonding");
5553 cmdline_parse_token_string_t cmd_showbonding_config_config =
5554 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5556 cmdline_parse_token_num_t cmd_showbonding_config_port =
5557 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5560 cmdline_parse_inst_t cmd_show_bonding_config = {
5561 .f = cmd_show_bonding_config_parsed,
5562 .help_str = "show bonding config <port_id>: "
5563 "Show the bonding config for port_id",
5566 (void *)&cmd_showbonding_config_show,
5567 (void *)&cmd_showbonding_config_bonding,
5568 (void *)&cmd_showbonding_config_config,
5569 (void *)&cmd_showbonding_config_port,
5574 /* *** SET BONDING PRIMARY *** */
5575 struct cmd_set_bonding_primary_result {
5576 cmdline_fixed_string_t set;
5577 cmdline_fixed_string_t bonding;
5578 cmdline_fixed_string_t primary;
5583 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5584 __attribute__((unused)) struct cmdline *cl,
5585 __attribute__((unused)) void *data)
5587 struct cmd_set_bonding_primary_result *res = parsed_result;
5588 portid_t master_port_id = res->port_id;
5589 portid_t slave_port_id = res->slave_id;
5591 /* Set the primary slave for a bonded device. */
5592 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5593 printf("\t Failed to set primary slave for port = %d.\n",
5600 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5601 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5603 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5605 bonding, "bonding");
5606 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5607 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5608 primary, "primary");
5609 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5610 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5612 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5613 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5616 cmdline_parse_inst_t cmd_set_bonding_primary = {
5617 .f = cmd_set_bonding_primary_parsed,
5618 .help_str = "set bonding primary <slave_id> <port_id>: "
5619 "Set the primary slave for port_id",
5622 (void *)&cmd_setbonding_primary_set,
5623 (void *)&cmd_setbonding_primary_bonding,
5624 (void *)&cmd_setbonding_primary_primary,
5625 (void *)&cmd_setbonding_primary_slave,
5626 (void *)&cmd_setbonding_primary_port,
5631 /* *** ADD SLAVE *** */
5632 struct cmd_add_bonding_slave_result {
5633 cmdline_fixed_string_t add;
5634 cmdline_fixed_string_t bonding;
5635 cmdline_fixed_string_t slave;
5640 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5641 __attribute__((unused)) struct cmdline *cl,
5642 __attribute__((unused)) void *data)
5644 struct cmd_add_bonding_slave_result *res = parsed_result;
5645 portid_t master_port_id = res->port_id;
5646 portid_t slave_port_id = res->slave_id;
5648 /* add the slave for a bonded device. */
5649 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5650 printf("\t Failed to add slave %d to master port = %d.\n",
5651 slave_port_id, master_port_id);
5655 set_port_slave_flag(slave_port_id);
5658 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5659 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5661 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5662 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5663 bonding, "bonding");
5664 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5665 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5667 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5668 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5670 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5671 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5674 cmdline_parse_inst_t cmd_add_bonding_slave = {
5675 .f = cmd_add_bonding_slave_parsed,
5676 .help_str = "add bonding slave <slave_id> <port_id>: "
5677 "Add a slave device to a bonded device",
5680 (void *)&cmd_addbonding_slave_add,
5681 (void *)&cmd_addbonding_slave_bonding,
5682 (void *)&cmd_addbonding_slave_slave,
5683 (void *)&cmd_addbonding_slave_slaveid,
5684 (void *)&cmd_addbonding_slave_port,
5689 /* *** REMOVE SLAVE *** */
5690 struct cmd_remove_bonding_slave_result {
5691 cmdline_fixed_string_t remove;
5692 cmdline_fixed_string_t bonding;
5693 cmdline_fixed_string_t slave;
5698 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5699 __attribute__((unused)) struct cmdline *cl,
5700 __attribute__((unused)) void *data)
5702 struct cmd_remove_bonding_slave_result *res = parsed_result;
5703 portid_t master_port_id = res->port_id;
5704 portid_t slave_port_id = res->slave_id;
5706 /* remove the slave from a bonded device. */
5707 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5708 printf("\t Failed to remove slave %d from master port = %d.\n",
5709 slave_port_id, master_port_id);
5713 clear_port_slave_flag(slave_port_id);
5716 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5717 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5719 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5720 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5721 bonding, "bonding");
5722 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5723 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5725 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5726 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5728 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5729 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5732 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5733 .f = cmd_remove_bonding_slave_parsed,
5734 .help_str = "remove bonding slave <slave_id> <port_id>: "
5735 "Remove a slave device from a bonded device",
5738 (void *)&cmd_removebonding_slave_remove,
5739 (void *)&cmd_removebonding_slave_bonding,
5740 (void *)&cmd_removebonding_slave_slave,
5741 (void *)&cmd_removebonding_slave_slaveid,
5742 (void *)&cmd_removebonding_slave_port,
5747 /* *** CREATE BONDED DEVICE *** */
5748 struct cmd_create_bonded_device_result {
5749 cmdline_fixed_string_t create;
5750 cmdline_fixed_string_t bonded;
5751 cmdline_fixed_string_t device;
5756 static int bond_dev_num = 0;
5758 static void cmd_create_bonded_device_parsed(void *parsed_result,
5759 __attribute__((unused)) struct cmdline *cl,
5760 __attribute__((unused)) void *data)
5762 struct cmd_create_bonded_device_result *res = parsed_result;
5763 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5766 if (test_done == 0) {
5767 printf("Please stop forwarding first\n");
5771 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5774 /* Create a new bonded device. */
5775 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5777 printf("\t Failed to create bonded device.\n");
5780 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5783 /* Update number of ports */
5784 nb_ports = rte_eth_dev_count_avail();
5785 reconfig(port_id, res->socket);
5786 rte_eth_promiscuous_enable(port_id);
5791 cmdline_parse_token_string_t cmd_createbonded_device_create =
5792 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5794 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5795 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5797 cmdline_parse_token_string_t cmd_createbonded_device_device =
5798 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5800 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5801 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5803 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5804 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5807 cmdline_parse_inst_t cmd_create_bonded_device = {
5808 .f = cmd_create_bonded_device_parsed,
5809 .help_str = "create bonded device <mode> <socket>: "
5810 "Create a new bonded device with specific bonding mode and socket",
5813 (void *)&cmd_createbonded_device_create,
5814 (void *)&cmd_createbonded_device_bonded,
5815 (void *)&cmd_createbonded_device_device,
5816 (void *)&cmd_createbonded_device_mode,
5817 (void *)&cmd_createbonded_device_socket,
5822 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5823 struct cmd_set_bond_mac_addr_result {
5824 cmdline_fixed_string_t set;
5825 cmdline_fixed_string_t bonding;
5826 cmdline_fixed_string_t mac_addr;
5828 struct ether_addr address;
5831 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5832 __attribute__((unused)) struct cmdline *cl,
5833 __attribute__((unused)) void *data)
5835 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5838 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5841 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5843 /* check the return value and print it if is < 0 */
5845 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5848 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5849 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5850 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5851 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5853 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5854 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5856 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5857 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5859 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5860 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5862 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5863 .f = cmd_set_bond_mac_addr_parsed,
5865 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5867 (void *)&cmd_set_bond_mac_addr_set,
5868 (void *)&cmd_set_bond_mac_addr_bonding,
5869 (void *)&cmd_set_bond_mac_addr_mac,
5870 (void *)&cmd_set_bond_mac_addr_portnum,
5871 (void *)&cmd_set_bond_mac_addr_addr,
5877 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5878 struct cmd_set_bond_mon_period_result {
5879 cmdline_fixed_string_t set;
5880 cmdline_fixed_string_t bonding;
5881 cmdline_fixed_string_t mon_period;
5886 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5887 __attribute__((unused)) struct cmdline *cl,
5888 __attribute__((unused)) void *data)
5890 struct cmd_set_bond_mon_period_result *res = parsed_result;
5893 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5895 /* check the return value and print it if is < 0 */
5897 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5900 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5901 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5903 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5904 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5905 bonding, "bonding");
5906 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5907 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5908 mon_period, "mon_period");
5909 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5910 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5912 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5913 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5916 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5917 .f = cmd_set_bond_mon_period_parsed,
5919 .help_str = "set bonding mon_period <port_id> <period_ms>",
5921 (void *)&cmd_set_bond_mon_period_set,
5922 (void *)&cmd_set_bond_mon_period_bonding,
5923 (void *)&cmd_set_bond_mon_period_mon_period,
5924 (void *)&cmd_set_bond_mon_period_portnum,
5925 (void *)&cmd_set_bond_mon_period_period_ms,
5932 struct cmd_set_bonding_agg_mode_policy_result {
5933 cmdline_fixed_string_t set;
5934 cmdline_fixed_string_t bonding;
5935 cmdline_fixed_string_t agg_mode;
5937 cmdline_fixed_string_t policy;
5942 cmd_set_bonding_agg_mode(void *parsed_result,
5943 __attribute__((unused)) struct cmdline *cl,
5944 __attribute__((unused)) void *data)
5946 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5947 uint8_t policy = AGG_BANDWIDTH;
5949 if (!strcmp(res->policy, "bandwidth"))
5950 policy = AGG_BANDWIDTH;
5951 else if (!strcmp(res->policy, "stable"))
5952 policy = AGG_STABLE;
5953 else if (!strcmp(res->policy, "count"))
5956 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5960 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5961 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5963 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5964 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5965 bonding, "bonding");
5967 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5968 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5969 agg_mode, "agg_mode");
5971 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5972 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5975 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5976 TOKEN_STRING_INITIALIZER(
5977 struct cmd_set_bonding_balance_xmit_policy_result,
5978 policy, "stable#bandwidth#count");
5980 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5981 .f = cmd_set_bonding_agg_mode,
5983 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5985 (void *)&cmd_set_bonding_agg_mode_set,
5986 (void *)&cmd_set_bonding_agg_mode_bonding,
5987 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5988 (void *)&cmd_set_bonding_agg_mode_portnum,
5989 (void *)&cmd_set_bonding_agg_mode_policy_string,
5995 #endif /* RTE_LIBRTE_PMD_BOND */
5997 /* *** SET FORWARDING MODE *** */
5998 struct cmd_set_fwd_mode_result {
5999 cmdline_fixed_string_t set;
6000 cmdline_fixed_string_t fwd;
6001 cmdline_fixed_string_t mode;
6004 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6005 __attribute__((unused)) struct cmdline *cl,
6006 __attribute__((unused)) void *data)
6008 struct cmd_set_fwd_mode_result *res = parsed_result;
6011 set_pkt_forwarding_mode(res->mode);
6014 cmdline_parse_token_string_t cmd_setfwd_set =
6015 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6016 cmdline_parse_token_string_t cmd_setfwd_fwd =
6017 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6018 cmdline_parse_token_string_t cmd_setfwd_mode =
6019 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6020 "" /* defined at init */);
6022 cmdline_parse_inst_t cmd_set_fwd_mode = {
6023 .f = cmd_set_fwd_mode_parsed,
6025 .help_str = NULL, /* defined at init */
6027 (void *)&cmd_setfwd_set,
6028 (void *)&cmd_setfwd_fwd,
6029 (void *)&cmd_setfwd_mode,
6034 static void cmd_set_fwd_mode_init(void)
6037 static char token[128];
6038 static char help[256];
6039 cmdline_parse_token_string_t *token_struct;
6041 modes = list_pkt_forwarding_modes();
6042 snprintf(help, sizeof(help), "set fwd %s: "
6043 "Set packet forwarding mode", modes);
6044 cmd_set_fwd_mode.help_str = help;
6046 /* string token separator is # */
6047 for (c = token; *modes != '\0'; modes++)
6052 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6053 token_struct->string_data.str = token;
6056 /* *** SET RETRY FORWARDING MODE *** */
6057 struct cmd_set_fwd_retry_mode_result {
6058 cmdline_fixed_string_t set;
6059 cmdline_fixed_string_t fwd;
6060 cmdline_fixed_string_t mode;
6061 cmdline_fixed_string_t retry;
6064 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6065 __attribute__((unused)) struct cmdline *cl,
6066 __attribute__((unused)) void *data)
6068 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6071 set_pkt_forwarding_mode(res->mode);
6074 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6075 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6077 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6078 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6080 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6081 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6083 "" /* defined at init */);
6084 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6085 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6088 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6089 .f = cmd_set_fwd_retry_mode_parsed,
6091 .help_str = NULL, /* defined at init */
6093 (void *)&cmd_setfwd_retry_set,
6094 (void *)&cmd_setfwd_retry_fwd,
6095 (void *)&cmd_setfwd_retry_mode,
6096 (void *)&cmd_setfwd_retry_retry,
6101 static void cmd_set_fwd_retry_mode_init(void)
6104 static char token[128];
6105 static char help[256];
6106 cmdline_parse_token_string_t *token_struct;
6108 modes = list_pkt_forwarding_retry_modes();
6109 snprintf(help, sizeof(help), "set fwd %s retry: "
6110 "Set packet forwarding mode with retry", modes);
6111 cmd_set_fwd_retry_mode.help_str = help;
6113 /* string token separator is # */
6114 for (c = token; *modes != '\0'; modes++)
6119 token_struct = (cmdline_parse_token_string_t *)
6120 cmd_set_fwd_retry_mode.tokens[2];
6121 token_struct->string_data.str = token;
6124 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6125 struct cmd_set_burst_tx_retry_result {
6126 cmdline_fixed_string_t set;
6127 cmdline_fixed_string_t burst;
6128 cmdline_fixed_string_t tx;
6129 cmdline_fixed_string_t delay;
6131 cmdline_fixed_string_t retry;
6135 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6136 __attribute__((unused)) struct cmdline *cl,
6137 __attribute__((unused)) void *data)
6139 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6141 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6142 && !strcmp(res->tx, "tx")) {
6143 if (!strcmp(res->delay, "delay"))
6144 burst_tx_delay_time = res->time;
6145 if (!strcmp(res->retry, "retry"))
6146 burst_tx_retry_num = res->retry_num;
6151 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6152 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6153 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6154 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6156 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6157 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6158 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6159 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6160 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6161 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6162 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6163 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6164 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6165 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6167 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6168 .f = cmd_set_burst_tx_retry_parsed,
6169 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6171 (void *)&cmd_set_burst_tx_retry_set,
6172 (void *)&cmd_set_burst_tx_retry_burst,
6173 (void *)&cmd_set_burst_tx_retry_tx,
6174 (void *)&cmd_set_burst_tx_retry_delay,
6175 (void *)&cmd_set_burst_tx_retry_time,
6176 (void *)&cmd_set_burst_tx_retry_retry,
6177 (void *)&cmd_set_burst_tx_retry_retry_num,
6182 /* *** SET PROMISC MODE *** */
6183 struct cmd_set_promisc_mode_result {
6184 cmdline_fixed_string_t set;
6185 cmdline_fixed_string_t promisc;
6186 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6187 uint16_t port_num; /* valid if "allports" argument == 0 */
6188 cmdline_fixed_string_t mode;
6191 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6192 __attribute__((unused)) struct cmdline *cl,
6195 struct cmd_set_promisc_mode_result *res = parsed_result;
6199 if (!strcmp(res->mode, "on"))
6206 RTE_ETH_FOREACH_DEV(i) {
6208 rte_eth_promiscuous_enable(i);
6210 rte_eth_promiscuous_disable(i);
6215 rte_eth_promiscuous_enable(res->port_num);
6217 rte_eth_promiscuous_disable(res->port_num);
6221 cmdline_parse_token_string_t cmd_setpromisc_set =
6222 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6223 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6224 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6226 cmdline_parse_token_string_t cmd_setpromisc_portall =
6227 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6229 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6230 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6232 cmdline_parse_token_string_t cmd_setpromisc_mode =
6233 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6236 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6237 .f = cmd_set_promisc_mode_parsed,
6239 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6241 (void *)&cmd_setpromisc_set,
6242 (void *)&cmd_setpromisc_promisc,
6243 (void *)&cmd_setpromisc_portall,
6244 (void *)&cmd_setpromisc_mode,
6249 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6250 .f = cmd_set_promisc_mode_parsed,
6252 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6254 (void *)&cmd_setpromisc_set,
6255 (void *)&cmd_setpromisc_promisc,
6256 (void *)&cmd_setpromisc_portnum,
6257 (void *)&cmd_setpromisc_mode,
6262 /* *** SET ALLMULTI MODE *** */
6263 struct cmd_set_allmulti_mode_result {
6264 cmdline_fixed_string_t set;
6265 cmdline_fixed_string_t allmulti;
6266 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6267 uint16_t port_num; /* valid if "allports" argument == 0 */
6268 cmdline_fixed_string_t mode;
6271 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6272 __attribute__((unused)) struct cmdline *cl,
6275 struct cmd_set_allmulti_mode_result *res = parsed_result;
6279 if (!strcmp(res->mode, "on"))
6286 RTE_ETH_FOREACH_DEV(i) {
6288 rte_eth_allmulticast_enable(i);
6290 rte_eth_allmulticast_disable(i);
6295 rte_eth_allmulticast_enable(res->port_num);
6297 rte_eth_allmulticast_disable(res->port_num);
6301 cmdline_parse_token_string_t cmd_setallmulti_set =
6302 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6303 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6304 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6306 cmdline_parse_token_string_t cmd_setallmulti_portall =
6307 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6309 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6310 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6312 cmdline_parse_token_string_t cmd_setallmulti_mode =
6313 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6316 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6317 .f = cmd_set_allmulti_mode_parsed,
6319 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6321 (void *)&cmd_setallmulti_set,
6322 (void *)&cmd_setallmulti_allmulti,
6323 (void *)&cmd_setallmulti_portall,
6324 (void *)&cmd_setallmulti_mode,
6329 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6330 .f = cmd_set_allmulti_mode_parsed,
6332 .help_str = "set allmulti <port_id> on|off: "
6333 "Set allmulti mode on port_id",
6335 (void *)&cmd_setallmulti_set,
6336 (void *)&cmd_setallmulti_allmulti,
6337 (void *)&cmd_setallmulti_portnum,
6338 (void *)&cmd_setallmulti_mode,
6343 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6344 struct cmd_link_flow_ctrl_set_result {
6345 cmdline_fixed_string_t set;
6346 cmdline_fixed_string_t flow_ctrl;
6347 cmdline_fixed_string_t rx;
6348 cmdline_fixed_string_t rx_lfc_mode;
6349 cmdline_fixed_string_t tx;
6350 cmdline_fixed_string_t tx_lfc_mode;
6351 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6352 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6353 cmdline_fixed_string_t autoneg_str;
6354 cmdline_fixed_string_t autoneg;
6355 cmdline_fixed_string_t hw_str;
6356 uint32_t high_water;
6357 cmdline_fixed_string_t lw_str;
6359 cmdline_fixed_string_t pt_str;
6360 uint16_t pause_time;
6361 cmdline_fixed_string_t xon_str;
6366 cmdline_parse_token_string_t cmd_lfc_set_set =
6367 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6369 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6370 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6371 flow_ctrl, "flow_ctrl");
6372 cmdline_parse_token_string_t cmd_lfc_set_rx =
6373 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6375 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6376 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6377 rx_lfc_mode, "on#off");
6378 cmdline_parse_token_string_t cmd_lfc_set_tx =
6379 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6381 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6382 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6383 tx_lfc_mode, "on#off");
6384 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6385 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6386 hw_str, "high_water");
6387 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6388 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6389 high_water, UINT32);
6390 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6391 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6392 lw_str, "low_water");
6393 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6394 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6396 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6397 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6398 pt_str, "pause_time");
6399 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6400 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6401 pause_time, UINT16);
6402 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6403 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6404 xon_str, "send_xon");
6405 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6406 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6408 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6409 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6410 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6411 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6412 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6413 mac_ctrl_frame_fwd_mode, "on#off");
6414 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6415 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6416 autoneg_str, "autoneg");
6417 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6418 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6420 cmdline_parse_token_num_t cmd_lfc_set_portid =
6421 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6424 /* forward declaration */
6426 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6429 cmdline_parse_inst_t cmd_link_flow_control_set = {
6430 .f = cmd_link_flow_ctrl_set_parsed,
6432 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6433 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6434 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6436 (void *)&cmd_lfc_set_set,
6437 (void *)&cmd_lfc_set_flow_ctrl,
6438 (void *)&cmd_lfc_set_rx,
6439 (void *)&cmd_lfc_set_rx_mode,
6440 (void *)&cmd_lfc_set_tx,
6441 (void *)&cmd_lfc_set_tx_mode,
6442 (void *)&cmd_lfc_set_high_water,
6443 (void *)&cmd_lfc_set_low_water,
6444 (void *)&cmd_lfc_set_pause_time,
6445 (void *)&cmd_lfc_set_send_xon,
6446 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6447 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6448 (void *)&cmd_lfc_set_autoneg_str,
6449 (void *)&cmd_lfc_set_autoneg,
6450 (void *)&cmd_lfc_set_portid,
6455 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6456 .f = cmd_link_flow_ctrl_set_parsed,
6457 .data = (void *)&cmd_link_flow_control_set_rx,
6458 .help_str = "set flow_ctrl rx on|off <port_id>: "
6459 "Change rx flow control parameter",
6461 (void *)&cmd_lfc_set_set,
6462 (void *)&cmd_lfc_set_flow_ctrl,
6463 (void *)&cmd_lfc_set_rx,
6464 (void *)&cmd_lfc_set_rx_mode,
6465 (void *)&cmd_lfc_set_portid,
6470 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6471 .f = cmd_link_flow_ctrl_set_parsed,
6472 .data = (void *)&cmd_link_flow_control_set_tx,
6473 .help_str = "set flow_ctrl tx on|off <port_id>: "
6474 "Change tx flow control parameter",
6476 (void *)&cmd_lfc_set_set,
6477 (void *)&cmd_lfc_set_flow_ctrl,
6478 (void *)&cmd_lfc_set_tx,
6479 (void *)&cmd_lfc_set_tx_mode,
6480 (void *)&cmd_lfc_set_portid,
6485 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6486 .f = cmd_link_flow_ctrl_set_parsed,
6487 .data = (void *)&cmd_link_flow_control_set_hw,
6488 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6489 "Change high water flow control parameter",
6491 (void *)&cmd_lfc_set_set,
6492 (void *)&cmd_lfc_set_flow_ctrl,
6493 (void *)&cmd_lfc_set_high_water_str,
6494 (void *)&cmd_lfc_set_high_water,
6495 (void *)&cmd_lfc_set_portid,
6500 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6501 .f = cmd_link_flow_ctrl_set_parsed,
6502 .data = (void *)&cmd_link_flow_control_set_lw,
6503 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6504 "Change low water flow control parameter",
6506 (void *)&cmd_lfc_set_set,
6507 (void *)&cmd_lfc_set_flow_ctrl,
6508 (void *)&cmd_lfc_set_low_water_str,
6509 (void *)&cmd_lfc_set_low_water,
6510 (void *)&cmd_lfc_set_portid,
6515 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6516 .f = cmd_link_flow_ctrl_set_parsed,
6517 .data = (void *)&cmd_link_flow_control_set_pt,
6518 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6519 "Change pause time flow control parameter",
6521 (void *)&cmd_lfc_set_set,
6522 (void *)&cmd_lfc_set_flow_ctrl,
6523 (void *)&cmd_lfc_set_pause_time_str,
6524 (void *)&cmd_lfc_set_pause_time,
6525 (void *)&cmd_lfc_set_portid,
6530 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6531 .f = cmd_link_flow_ctrl_set_parsed,
6532 .data = (void *)&cmd_link_flow_control_set_xon,
6533 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6534 "Change send_xon flow control parameter",
6536 (void *)&cmd_lfc_set_set,
6537 (void *)&cmd_lfc_set_flow_ctrl,
6538 (void *)&cmd_lfc_set_send_xon_str,
6539 (void *)&cmd_lfc_set_send_xon,
6540 (void *)&cmd_lfc_set_portid,
6545 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6546 .f = cmd_link_flow_ctrl_set_parsed,
6547 .data = (void *)&cmd_link_flow_control_set_macfwd,
6548 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6549 "Change mac ctrl fwd flow control parameter",
6551 (void *)&cmd_lfc_set_set,
6552 (void *)&cmd_lfc_set_flow_ctrl,
6553 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6554 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6555 (void *)&cmd_lfc_set_portid,
6560 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6561 .f = cmd_link_flow_ctrl_set_parsed,
6562 .data = (void *)&cmd_link_flow_control_set_autoneg,
6563 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6564 "Change autoneg flow control parameter",
6566 (void *)&cmd_lfc_set_set,
6567 (void *)&cmd_lfc_set_flow_ctrl,
6568 (void *)&cmd_lfc_set_autoneg_str,
6569 (void *)&cmd_lfc_set_autoneg,
6570 (void *)&cmd_lfc_set_portid,
6576 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6577 __attribute__((unused)) struct cmdline *cl,
6580 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6581 cmdline_parse_inst_t *cmd = data;
6582 struct rte_eth_fc_conf fc_conf;
6588 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6589 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6590 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6591 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6593 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6594 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6597 /* Partial command line, retrieve current configuration */
6599 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6601 printf("cannot get current flow ctrl parameters, return"
6602 "code = %d\n", ret);
6606 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6607 (fc_conf.mode == RTE_FC_FULL))
6609 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6610 (fc_conf.mode == RTE_FC_FULL))
6614 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6615 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6617 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6618 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6620 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6622 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6623 fc_conf.high_water = res->high_water;
6625 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6626 fc_conf.low_water = res->low_water;
6628 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6629 fc_conf.pause_time = res->pause_time;
6631 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6632 fc_conf.send_xon = res->send_xon;
6634 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6635 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6636 fc_conf.mac_ctrl_frame_fwd = 1;
6638 fc_conf.mac_ctrl_frame_fwd = 0;
6641 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6642 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6644 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6646 printf("bad flow contrl parameter, return code = %d \n", ret);
6649 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6650 struct cmd_priority_flow_ctrl_set_result {
6651 cmdline_fixed_string_t set;
6652 cmdline_fixed_string_t pfc_ctrl;
6653 cmdline_fixed_string_t rx;
6654 cmdline_fixed_string_t rx_pfc_mode;
6655 cmdline_fixed_string_t tx;
6656 cmdline_fixed_string_t tx_pfc_mode;
6657 uint32_t high_water;
6659 uint16_t pause_time;
6665 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6666 __attribute__((unused)) struct cmdline *cl,
6667 __attribute__((unused)) void *data)
6669 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6670 struct rte_eth_pfc_conf pfc_conf;
6671 int rx_fc_enable, tx_fc_enable;
6675 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6676 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6677 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6678 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6680 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6681 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6684 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6685 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6686 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6687 pfc_conf.fc.high_water = res->high_water;
6688 pfc_conf.fc.low_water = res->low_water;
6689 pfc_conf.fc.pause_time = res->pause_time;
6690 pfc_conf.priority = res->priority;
6692 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6694 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6697 cmdline_parse_token_string_t cmd_pfc_set_set =
6698 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6700 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6701 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6702 pfc_ctrl, "pfc_ctrl");
6703 cmdline_parse_token_string_t cmd_pfc_set_rx =
6704 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6706 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6707 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6708 rx_pfc_mode, "on#off");
6709 cmdline_parse_token_string_t cmd_pfc_set_tx =
6710 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6712 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6713 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6714 tx_pfc_mode, "on#off");
6715 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6716 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6717 high_water, UINT32);
6718 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6719 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6721 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6722 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6723 pause_time, UINT16);
6724 cmdline_parse_token_num_t cmd_pfc_set_priority =
6725 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6727 cmdline_parse_token_num_t cmd_pfc_set_portid =
6728 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6731 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6732 .f = cmd_priority_flow_ctrl_set_parsed,
6734 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6735 "<pause_time> <priority> <port_id>: "
6736 "Configure the Ethernet priority flow control",
6738 (void *)&cmd_pfc_set_set,
6739 (void *)&cmd_pfc_set_flow_ctrl,
6740 (void *)&cmd_pfc_set_rx,
6741 (void *)&cmd_pfc_set_rx_mode,
6742 (void *)&cmd_pfc_set_tx,
6743 (void *)&cmd_pfc_set_tx_mode,
6744 (void *)&cmd_pfc_set_high_water,
6745 (void *)&cmd_pfc_set_low_water,
6746 (void *)&cmd_pfc_set_pause_time,
6747 (void *)&cmd_pfc_set_priority,
6748 (void *)&cmd_pfc_set_portid,
6753 /* *** RESET CONFIGURATION *** */
6754 struct cmd_reset_result {
6755 cmdline_fixed_string_t reset;
6756 cmdline_fixed_string_t def;
6759 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6761 __attribute__((unused)) void *data)
6763 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6764 set_def_fwd_config();
6767 cmdline_parse_token_string_t cmd_reset_set =
6768 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6769 cmdline_parse_token_string_t cmd_reset_def =
6770 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6773 cmdline_parse_inst_t cmd_reset = {
6774 .f = cmd_reset_parsed,
6776 .help_str = "set default: Reset default forwarding configuration",
6778 (void *)&cmd_reset_set,
6779 (void *)&cmd_reset_def,
6784 /* *** START FORWARDING *** */
6785 struct cmd_start_result {
6786 cmdline_fixed_string_t start;
6789 cmdline_parse_token_string_t cmd_start_start =
6790 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6792 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6793 __attribute__((unused)) struct cmdline *cl,
6794 __attribute__((unused)) void *data)
6796 start_packet_forwarding(0);
6799 cmdline_parse_inst_t cmd_start = {
6800 .f = cmd_start_parsed,
6802 .help_str = "start: Start packet forwarding",
6804 (void *)&cmd_start_start,
6809 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6810 struct cmd_start_tx_first_result {
6811 cmdline_fixed_string_t start;
6812 cmdline_fixed_string_t tx_first;
6816 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6817 __attribute__((unused)) struct cmdline *cl,
6818 __attribute__((unused)) void *data)
6820 start_packet_forwarding(1);
6823 cmdline_parse_token_string_t cmd_start_tx_first_start =
6824 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6826 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6827 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6828 tx_first, "tx_first");
6830 cmdline_parse_inst_t cmd_start_tx_first = {
6831 .f = cmd_start_tx_first_parsed,
6833 .help_str = "start tx_first: Start packet forwarding, "
6834 "after sending 1 burst of packets",
6836 (void *)&cmd_start_tx_first_start,
6837 (void *)&cmd_start_tx_first_tx_first,
6842 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6843 struct cmd_start_tx_first_n_result {
6844 cmdline_fixed_string_t start;
6845 cmdline_fixed_string_t tx_first;
6850 cmd_start_tx_first_n_parsed(void *parsed_result,
6851 __attribute__((unused)) struct cmdline *cl,
6852 __attribute__((unused)) void *data)
6854 struct cmd_start_tx_first_n_result *res = parsed_result;
6856 start_packet_forwarding(res->tx_num);
6859 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6860 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6862 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6863 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6864 tx_first, "tx_first");
6865 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6866 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6869 cmdline_parse_inst_t cmd_start_tx_first_n = {
6870 .f = cmd_start_tx_first_n_parsed,
6872 .help_str = "start tx_first <num>: "
6873 "packet forwarding, after sending <num> bursts of packets",
6875 (void *)&cmd_start_tx_first_n_start,
6876 (void *)&cmd_start_tx_first_n_tx_first,
6877 (void *)&cmd_start_tx_first_n_tx_num,
6882 /* *** SET LINK UP *** */
6883 struct cmd_set_link_up_result {
6884 cmdline_fixed_string_t set;
6885 cmdline_fixed_string_t link_up;
6886 cmdline_fixed_string_t port;
6890 cmdline_parse_token_string_t cmd_set_link_up_set =
6891 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6892 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6893 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6895 cmdline_parse_token_string_t cmd_set_link_up_port =
6896 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6897 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6898 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6900 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6901 __attribute__((unused)) struct cmdline *cl,
6902 __attribute__((unused)) void *data)
6904 struct cmd_set_link_up_result *res = parsed_result;
6905 dev_set_link_up(res->port_id);
6908 cmdline_parse_inst_t cmd_set_link_up = {
6909 .f = cmd_set_link_up_parsed,
6911 .help_str = "set link-up port <port id>",
6913 (void *)&cmd_set_link_up_set,
6914 (void *)&cmd_set_link_up_link_up,
6915 (void *)&cmd_set_link_up_port,
6916 (void *)&cmd_set_link_up_port_id,
6921 /* *** SET LINK DOWN *** */
6922 struct cmd_set_link_down_result {
6923 cmdline_fixed_string_t set;
6924 cmdline_fixed_string_t link_down;
6925 cmdline_fixed_string_t port;
6929 cmdline_parse_token_string_t cmd_set_link_down_set =
6930 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6931 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6932 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6934 cmdline_parse_token_string_t cmd_set_link_down_port =
6935 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6936 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6937 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6939 static void cmd_set_link_down_parsed(
6940 __attribute__((unused)) void *parsed_result,
6941 __attribute__((unused)) struct cmdline *cl,
6942 __attribute__((unused)) void *data)
6944 struct cmd_set_link_down_result *res = parsed_result;
6945 dev_set_link_down(res->port_id);
6948 cmdline_parse_inst_t cmd_set_link_down = {
6949 .f = cmd_set_link_down_parsed,
6951 .help_str = "set link-down port <port id>",
6953 (void *)&cmd_set_link_down_set,
6954 (void *)&cmd_set_link_down_link_down,
6955 (void *)&cmd_set_link_down_port,
6956 (void *)&cmd_set_link_down_port_id,
6961 /* *** SHOW CFG *** */
6962 struct cmd_showcfg_result {
6963 cmdline_fixed_string_t show;
6964 cmdline_fixed_string_t cfg;
6965 cmdline_fixed_string_t what;
6968 static void cmd_showcfg_parsed(void *parsed_result,
6969 __attribute__((unused)) struct cmdline *cl,
6970 __attribute__((unused)) void *data)
6972 struct cmd_showcfg_result *res = parsed_result;
6973 if (!strcmp(res->what, "rxtx"))
6974 rxtx_config_display();
6975 else if (!strcmp(res->what, "cores"))
6976 fwd_lcores_config_display();
6977 else if (!strcmp(res->what, "fwd"))
6978 pkt_fwd_config_display(&cur_fwd_config);
6979 else if (!strcmp(res->what, "txpkts"))
6980 show_tx_pkt_segments();
6983 cmdline_parse_token_string_t cmd_showcfg_show =
6984 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6985 cmdline_parse_token_string_t cmd_showcfg_port =
6986 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6987 cmdline_parse_token_string_t cmd_showcfg_what =
6988 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6989 "rxtx#cores#fwd#txpkts");
6991 cmdline_parse_inst_t cmd_showcfg = {
6992 .f = cmd_showcfg_parsed,
6994 .help_str = "show config rxtx|cores|fwd|txpkts",
6996 (void *)&cmd_showcfg_show,
6997 (void *)&cmd_showcfg_port,
6998 (void *)&cmd_showcfg_what,
7003 /* *** SHOW ALL PORT INFO *** */
7004 struct cmd_showportall_result {
7005 cmdline_fixed_string_t show;
7006 cmdline_fixed_string_t port;
7007 cmdline_fixed_string_t what;
7008 cmdline_fixed_string_t all;
7011 static void cmd_showportall_parsed(void *parsed_result,
7012 __attribute__((unused)) struct cmdline *cl,
7013 __attribute__((unused)) void *data)
7017 struct cmd_showportall_result *res = parsed_result;
7018 if (!strcmp(res->show, "clear")) {
7019 if (!strcmp(res->what, "stats"))
7020 RTE_ETH_FOREACH_DEV(i)
7022 else if (!strcmp(res->what, "xstats"))
7023 RTE_ETH_FOREACH_DEV(i)
7024 nic_xstats_clear(i);
7025 } else if (!strcmp(res->what, "info"))
7026 RTE_ETH_FOREACH_DEV(i)
7027 port_infos_display(i);
7028 else if (!strcmp(res->what, "stats"))
7029 RTE_ETH_FOREACH_DEV(i)
7030 nic_stats_display(i);
7031 else if (!strcmp(res->what, "xstats"))
7032 RTE_ETH_FOREACH_DEV(i)
7033 nic_xstats_display(i);
7034 else if (!strcmp(res->what, "fdir"))
7035 RTE_ETH_FOREACH_DEV(i)
7037 else if (!strcmp(res->what, "stat_qmap"))
7038 RTE_ETH_FOREACH_DEV(i)
7039 nic_stats_mapping_display(i);
7040 else if (!strcmp(res->what, "dcb_tc"))
7041 RTE_ETH_FOREACH_DEV(i)
7042 port_dcb_info_display(i);
7043 else if (!strcmp(res->what, "cap"))
7044 RTE_ETH_FOREACH_DEV(i)
7045 port_offload_cap_display(i);
7048 cmdline_parse_token_string_t cmd_showportall_show =
7049 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7051 cmdline_parse_token_string_t cmd_showportall_port =
7052 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7053 cmdline_parse_token_string_t cmd_showportall_what =
7054 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7055 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7056 cmdline_parse_token_string_t cmd_showportall_all =
7057 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7058 cmdline_parse_inst_t cmd_showportall = {
7059 .f = cmd_showportall_parsed,
7061 .help_str = "show|clear port "
7062 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7064 (void *)&cmd_showportall_show,
7065 (void *)&cmd_showportall_port,
7066 (void *)&cmd_showportall_what,
7067 (void *)&cmd_showportall_all,
7072 /* *** SHOW PORT INFO *** */
7073 struct cmd_showport_result {
7074 cmdline_fixed_string_t show;
7075 cmdline_fixed_string_t port;
7076 cmdline_fixed_string_t what;
7080 static void cmd_showport_parsed(void *parsed_result,
7081 __attribute__((unused)) struct cmdline *cl,
7082 __attribute__((unused)) void *data)
7084 struct cmd_showport_result *res = parsed_result;
7085 if (!strcmp(res->show, "clear")) {
7086 if (!strcmp(res->what, "stats"))
7087 nic_stats_clear(res->portnum);
7088 else if (!strcmp(res->what, "xstats"))
7089 nic_xstats_clear(res->portnum);
7090 } else if (!strcmp(res->what, "info"))
7091 port_infos_display(res->portnum);
7092 else if (!strcmp(res->what, "stats"))
7093 nic_stats_display(res->portnum);
7094 else if (!strcmp(res->what, "xstats"))
7095 nic_xstats_display(res->portnum);
7096 else if (!strcmp(res->what, "fdir"))
7097 fdir_get_infos(res->portnum);
7098 else if (!strcmp(res->what, "stat_qmap"))
7099 nic_stats_mapping_display(res->portnum);
7100 else if (!strcmp(res->what, "dcb_tc"))
7101 port_dcb_info_display(res->portnum);
7102 else if (!strcmp(res->what, "cap"))
7103 port_offload_cap_display(res->portnum);
7106 cmdline_parse_token_string_t cmd_showport_show =
7107 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7109 cmdline_parse_token_string_t cmd_showport_port =
7110 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7111 cmdline_parse_token_string_t cmd_showport_what =
7112 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7113 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7114 cmdline_parse_token_num_t cmd_showport_portnum =
7115 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7117 cmdline_parse_inst_t cmd_showport = {
7118 .f = cmd_showport_parsed,
7120 .help_str = "show|clear port "
7121 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7124 (void *)&cmd_showport_show,
7125 (void *)&cmd_showport_port,
7126 (void *)&cmd_showport_what,
7127 (void *)&cmd_showport_portnum,
7132 /* *** SHOW QUEUE INFO *** */
7133 struct cmd_showqueue_result {
7134 cmdline_fixed_string_t show;
7135 cmdline_fixed_string_t type;
7136 cmdline_fixed_string_t what;
7142 cmd_showqueue_parsed(void *parsed_result,
7143 __attribute__((unused)) struct cmdline *cl,
7144 __attribute__((unused)) void *data)
7146 struct cmd_showqueue_result *res = parsed_result;
7148 if (!strcmp(res->type, "rxq"))
7149 rx_queue_infos_display(res->portnum, res->queuenum);
7150 else if (!strcmp(res->type, "txq"))
7151 tx_queue_infos_display(res->portnum, res->queuenum);
7154 cmdline_parse_token_string_t cmd_showqueue_show =
7155 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7156 cmdline_parse_token_string_t cmd_showqueue_type =
7157 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7158 cmdline_parse_token_string_t cmd_showqueue_what =
7159 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7160 cmdline_parse_token_num_t cmd_showqueue_portnum =
7161 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7162 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7163 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7165 cmdline_parse_inst_t cmd_showqueue = {
7166 .f = cmd_showqueue_parsed,
7168 .help_str = "show rxq|txq info <port_id> <queue_id>",
7170 (void *)&cmd_showqueue_show,
7171 (void *)&cmd_showqueue_type,
7172 (void *)&cmd_showqueue_what,
7173 (void *)&cmd_showqueue_portnum,
7174 (void *)&cmd_showqueue_queuenum,
7179 /* *** READ PORT REGISTER *** */
7180 struct cmd_read_reg_result {
7181 cmdline_fixed_string_t read;
7182 cmdline_fixed_string_t reg;
7188 cmd_read_reg_parsed(void *parsed_result,
7189 __attribute__((unused)) struct cmdline *cl,
7190 __attribute__((unused)) void *data)
7192 struct cmd_read_reg_result *res = parsed_result;
7193 port_reg_display(res->port_id, res->reg_off);
7196 cmdline_parse_token_string_t cmd_read_reg_read =
7197 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7198 cmdline_parse_token_string_t cmd_read_reg_reg =
7199 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7200 cmdline_parse_token_num_t cmd_read_reg_port_id =
7201 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7202 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7203 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7205 cmdline_parse_inst_t cmd_read_reg = {
7206 .f = cmd_read_reg_parsed,
7208 .help_str = "read reg <port_id> <reg_off>",
7210 (void *)&cmd_read_reg_read,
7211 (void *)&cmd_read_reg_reg,
7212 (void *)&cmd_read_reg_port_id,
7213 (void *)&cmd_read_reg_reg_off,
7218 /* *** READ PORT REGISTER BIT FIELD *** */
7219 struct cmd_read_reg_bit_field_result {
7220 cmdline_fixed_string_t read;
7221 cmdline_fixed_string_t regfield;
7229 cmd_read_reg_bit_field_parsed(void *parsed_result,
7230 __attribute__((unused)) struct cmdline *cl,
7231 __attribute__((unused)) void *data)
7233 struct cmd_read_reg_bit_field_result *res = parsed_result;
7234 port_reg_bit_field_display(res->port_id, res->reg_off,
7235 res->bit1_pos, res->bit2_pos);
7238 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7239 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7241 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7242 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7243 regfield, "regfield");
7244 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7245 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7247 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7248 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7250 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7251 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7253 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7254 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7257 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7258 .f = cmd_read_reg_bit_field_parsed,
7260 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7261 "Read register bit field between bit_x and bit_y included",
7263 (void *)&cmd_read_reg_bit_field_read,
7264 (void *)&cmd_read_reg_bit_field_regfield,
7265 (void *)&cmd_read_reg_bit_field_port_id,
7266 (void *)&cmd_read_reg_bit_field_reg_off,
7267 (void *)&cmd_read_reg_bit_field_bit1_pos,
7268 (void *)&cmd_read_reg_bit_field_bit2_pos,
7273 /* *** READ PORT REGISTER BIT *** */
7274 struct cmd_read_reg_bit_result {
7275 cmdline_fixed_string_t read;
7276 cmdline_fixed_string_t regbit;
7283 cmd_read_reg_bit_parsed(void *parsed_result,
7284 __attribute__((unused)) struct cmdline *cl,
7285 __attribute__((unused)) void *data)
7287 struct cmd_read_reg_bit_result *res = parsed_result;
7288 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7291 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7292 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7293 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7294 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7296 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7297 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7298 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7299 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7300 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7301 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7303 cmdline_parse_inst_t cmd_read_reg_bit = {
7304 .f = cmd_read_reg_bit_parsed,
7306 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7308 (void *)&cmd_read_reg_bit_read,
7309 (void *)&cmd_read_reg_bit_regbit,
7310 (void *)&cmd_read_reg_bit_port_id,
7311 (void *)&cmd_read_reg_bit_reg_off,
7312 (void *)&cmd_read_reg_bit_bit_pos,
7317 /* *** WRITE PORT REGISTER *** */
7318 struct cmd_write_reg_result {
7319 cmdline_fixed_string_t write;
7320 cmdline_fixed_string_t reg;
7327 cmd_write_reg_parsed(void *parsed_result,
7328 __attribute__((unused)) struct cmdline *cl,
7329 __attribute__((unused)) void *data)
7331 struct cmd_write_reg_result *res = parsed_result;
7332 port_reg_set(res->port_id, res->reg_off, res->value);
7335 cmdline_parse_token_string_t cmd_write_reg_write =
7336 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7337 cmdline_parse_token_string_t cmd_write_reg_reg =
7338 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7339 cmdline_parse_token_num_t cmd_write_reg_port_id =
7340 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7341 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7342 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7343 cmdline_parse_token_num_t cmd_write_reg_value =
7344 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7346 cmdline_parse_inst_t cmd_write_reg = {
7347 .f = cmd_write_reg_parsed,
7349 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7351 (void *)&cmd_write_reg_write,
7352 (void *)&cmd_write_reg_reg,
7353 (void *)&cmd_write_reg_port_id,
7354 (void *)&cmd_write_reg_reg_off,
7355 (void *)&cmd_write_reg_value,
7360 /* *** WRITE PORT REGISTER BIT FIELD *** */
7361 struct cmd_write_reg_bit_field_result {
7362 cmdline_fixed_string_t write;
7363 cmdline_fixed_string_t regfield;
7372 cmd_write_reg_bit_field_parsed(void *parsed_result,
7373 __attribute__((unused)) struct cmdline *cl,
7374 __attribute__((unused)) void *data)
7376 struct cmd_write_reg_bit_field_result *res = parsed_result;
7377 port_reg_bit_field_set(res->port_id, res->reg_off,
7378 res->bit1_pos, res->bit2_pos, res->value);
7381 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7382 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7384 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7385 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7386 regfield, "regfield");
7387 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7388 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7390 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7391 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7393 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7394 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7396 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7397 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7399 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7400 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7403 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7404 .f = cmd_write_reg_bit_field_parsed,
7406 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7408 "Set register bit field between bit_x and bit_y included",
7410 (void *)&cmd_write_reg_bit_field_write,
7411 (void *)&cmd_write_reg_bit_field_regfield,
7412 (void *)&cmd_write_reg_bit_field_port_id,
7413 (void *)&cmd_write_reg_bit_field_reg_off,
7414 (void *)&cmd_write_reg_bit_field_bit1_pos,
7415 (void *)&cmd_write_reg_bit_field_bit2_pos,
7416 (void *)&cmd_write_reg_bit_field_value,
7421 /* *** WRITE PORT REGISTER BIT *** */
7422 struct cmd_write_reg_bit_result {
7423 cmdline_fixed_string_t write;
7424 cmdline_fixed_string_t regbit;
7432 cmd_write_reg_bit_parsed(void *parsed_result,
7433 __attribute__((unused)) struct cmdline *cl,
7434 __attribute__((unused)) void *data)
7436 struct cmd_write_reg_bit_result *res = parsed_result;
7437 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7440 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7441 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7443 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7444 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7446 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7447 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7448 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7449 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7450 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7451 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7452 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7453 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7455 cmdline_parse_inst_t cmd_write_reg_bit = {
7456 .f = cmd_write_reg_bit_parsed,
7458 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7461 (void *)&cmd_write_reg_bit_write,
7462 (void *)&cmd_write_reg_bit_regbit,
7463 (void *)&cmd_write_reg_bit_port_id,
7464 (void *)&cmd_write_reg_bit_reg_off,
7465 (void *)&cmd_write_reg_bit_bit_pos,
7466 (void *)&cmd_write_reg_bit_value,
7471 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7472 struct cmd_read_rxd_txd_result {
7473 cmdline_fixed_string_t read;
7474 cmdline_fixed_string_t rxd_txd;
7481 cmd_read_rxd_txd_parsed(void *parsed_result,
7482 __attribute__((unused)) struct cmdline *cl,
7483 __attribute__((unused)) void *data)
7485 struct cmd_read_rxd_txd_result *res = parsed_result;
7487 if (!strcmp(res->rxd_txd, "rxd"))
7488 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7489 else if (!strcmp(res->rxd_txd, "txd"))
7490 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7493 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7494 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7495 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7496 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7498 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7499 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7500 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7501 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7502 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7503 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7505 cmdline_parse_inst_t cmd_read_rxd_txd = {
7506 .f = cmd_read_rxd_txd_parsed,
7508 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7510 (void *)&cmd_read_rxd_txd_read,
7511 (void *)&cmd_read_rxd_txd_rxd_txd,
7512 (void *)&cmd_read_rxd_txd_port_id,
7513 (void *)&cmd_read_rxd_txd_queue_id,
7514 (void *)&cmd_read_rxd_txd_desc_id,
7520 struct cmd_quit_result {
7521 cmdline_fixed_string_t quit;
7524 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7526 __attribute__((unused)) void *data)
7532 cmdline_parse_token_string_t cmd_quit_quit =
7533 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7535 cmdline_parse_inst_t cmd_quit = {
7536 .f = cmd_quit_parsed,
7538 .help_str = "quit: Exit application",
7540 (void *)&cmd_quit_quit,
7545 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7546 struct cmd_mac_addr_result {
7547 cmdline_fixed_string_t mac_addr_cmd;
7548 cmdline_fixed_string_t what;
7550 struct ether_addr address;
7553 static void cmd_mac_addr_parsed(void *parsed_result,
7554 __attribute__((unused)) struct cmdline *cl,
7555 __attribute__((unused)) void *data)
7557 struct cmd_mac_addr_result *res = parsed_result;
7560 if (strcmp(res->what, "add") == 0)
7561 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7562 else if (strcmp(res->what, "set") == 0)
7563 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7566 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7568 /* check the return value and print it if is < 0 */
7570 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7574 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7575 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7577 cmdline_parse_token_string_t cmd_mac_addr_what =
7578 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7580 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7581 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7583 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7584 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7586 cmdline_parse_inst_t cmd_mac_addr = {
7587 .f = cmd_mac_addr_parsed,
7589 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7590 "Add/Remove/Set MAC address on port_id",
7592 (void *)&cmd_mac_addr_cmd,
7593 (void *)&cmd_mac_addr_what,
7594 (void *)&cmd_mac_addr_portnum,
7595 (void *)&cmd_mac_addr_addr,
7600 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7601 struct cmd_eth_peer_result {
7602 cmdline_fixed_string_t set;
7603 cmdline_fixed_string_t eth_peer;
7605 cmdline_fixed_string_t peer_addr;
7608 static void cmd_set_eth_peer_parsed(void *parsed_result,
7609 __attribute__((unused)) struct cmdline *cl,
7610 __attribute__((unused)) void *data)
7612 struct cmd_eth_peer_result *res = parsed_result;
7614 if (test_done == 0) {
7615 printf("Please stop forwarding first\n");
7618 if (!strcmp(res->eth_peer, "eth-peer")) {
7619 set_fwd_eth_peer(res->port_id, res->peer_addr);
7623 cmdline_parse_token_string_t cmd_eth_peer_set =
7624 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7625 cmdline_parse_token_string_t cmd_eth_peer =
7626 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7627 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7628 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7629 cmdline_parse_token_string_t cmd_eth_peer_addr =
7630 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7632 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7633 .f = cmd_set_eth_peer_parsed,
7635 .help_str = "set eth-peer <port_id> <peer_mac>",
7637 (void *)&cmd_eth_peer_set,
7638 (void *)&cmd_eth_peer,
7639 (void *)&cmd_eth_peer_port_id,
7640 (void *)&cmd_eth_peer_addr,
7645 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7646 struct cmd_set_qmap_result {
7647 cmdline_fixed_string_t set;
7648 cmdline_fixed_string_t qmap;
7649 cmdline_fixed_string_t what;
7656 cmd_set_qmap_parsed(void *parsed_result,
7657 __attribute__((unused)) struct cmdline *cl,
7658 __attribute__((unused)) void *data)
7660 struct cmd_set_qmap_result *res = parsed_result;
7661 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7663 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7666 cmdline_parse_token_string_t cmd_setqmap_set =
7667 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7669 cmdline_parse_token_string_t cmd_setqmap_qmap =
7670 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7672 cmdline_parse_token_string_t cmd_setqmap_what =
7673 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7675 cmdline_parse_token_num_t cmd_setqmap_portid =
7676 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7678 cmdline_parse_token_num_t cmd_setqmap_queueid =
7679 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7681 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7682 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7685 cmdline_parse_inst_t cmd_set_qmap = {
7686 .f = cmd_set_qmap_parsed,
7688 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7689 "Set statistics mapping value on tx|rx queue_id of port_id",
7691 (void *)&cmd_setqmap_set,
7692 (void *)&cmd_setqmap_qmap,
7693 (void *)&cmd_setqmap_what,
7694 (void *)&cmd_setqmap_portid,
7695 (void *)&cmd_setqmap_queueid,
7696 (void *)&cmd_setqmap_mapvalue,
7701 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7702 struct cmd_set_xstats_hide_zero_result {
7703 cmdline_fixed_string_t keyword;
7704 cmdline_fixed_string_t name;
7705 cmdline_fixed_string_t on_off;
7709 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7710 __attribute__((unused)) struct cmdline *cl,
7711 __attribute__((unused)) void *data)
7713 struct cmd_set_xstats_hide_zero_result *res;
7714 uint16_t on_off = 0;
7716 res = parsed_result;
7717 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7718 set_xstats_hide_zero(on_off);
7721 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7722 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7724 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7725 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7726 name, "xstats-hide-zero");
7727 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7728 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7731 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7732 .f = cmd_set_xstats_hide_zero_parsed,
7734 .help_str = "set xstats-hide-zero on|off",
7736 (void *)&cmd_set_xstats_hide_zero_keyword,
7737 (void *)&cmd_set_xstats_hide_zero_name,
7738 (void *)&cmd_set_xstats_hide_zero_on_off,
7743 /* *** CONFIGURE UNICAST HASH TABLE *** */
7744 struct cmd_set_uc_hash_table {
7745 cmdline_fixed_string_t set;
7746 cmdline_fixed_string_t port;
7748 cmdline_fixed_string_t what;
7749 struct ether_addr address;
7750 cmdline_fixed_string_t mode;
7754 cmd_set_uc_hash_parsed(void *parsed_result,
7755 __attribute__((unused)) struct cmdline *cl,
7756 __attribute__((unused)) void *data)
7759 struct cmd_set_uc_hash_table *res = parsed_result;
7761 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7763 if (strcmp(res->what, "uta") == 0)
7764 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7765 &res->address,(uint8_t)is_on);
7767 printf("bad unicast hash table parameter, return code = %d \n", ret);
7771 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7772 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7774 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7775 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7777 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7778 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7780 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7781 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7783 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7784 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7786 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7787 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7790 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7791 .f = cmd_set_uc_hash_parsed,
7793 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7795 (void *)&cmd_set_uc_hash_set,
7796 (void *)&cmd_set_uc_hash_port,
7797 (void *)&cmd_set_uc_hash_portid,
7798 (void *)&cmd_set_uc_hash_what,
7799 (void *)&cmd_set_uc_hash_mac,
7800 (void *)&cmd_set_uc_hash_mode,
7805 struct cmd_set_uc_all_hash_table {
7806 cmdline_fixed_string_t set;
7807 cmdline_fixed_string_t port;
7809 cmdline_fixed_string_t what;
7810 cmdline_fixed_string_t value;
7811 cmdline_fixed_string_t mode;
7815 cmd_set_uc_all_hash_parsed(void *parsed_result,
7816 __attribute__((unused)) struct cmdline *cl,
7817 __attribute__((unused)) void *data)
7820 struct cmd_set_uc_all_hash_table *res = parsed_result;
7822 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7824 if ((strcmp(res->what, "uta") == 0) &&
7825 (strcmp(res->value, "all") == 0))
7826 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7828 printf("bad unicast hash table parameter,"
7829 "return code = %d \n", ret);
7832 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7833 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7835 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7836 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7838 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7839 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7841 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7842 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7844 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7845 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7847 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7848 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7851 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7852 .f = cmd_set_uc_all_hash_parsed,
7854 .help_str = "set port <port_id> uta all on|off",
7856 (void *)&cmd_set_uc_all_hash_set,
7857 (void *)&cmd_set_uc_all_hash_port,
7858 (void *)&cmd_set_uc_all_hash_portid,
7859 (void *)&cmd_set_uc_all_hash_what,
7860 (void *)&cmd_set_uc_all_hash_value,
7861 (void *)&cmd_set_uc_all_hash_mode,
7866 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7867 struct cmd_set_vf_macvlan_filter {
7868 cmdline_fixed_string_t set;
7869 cmdline_fixed_string_t port;
7871 cmdline_fixed_string_t vf;
7873 struct ether_addr address;
7874 cmdline_fixed_string_t filter_type;
7875 cmdline_fixed_string_t mode;
7879 cmd_set_vf_macvlan_parsed(void *parsed_result,
7880 __attribute__((unused)) struct cmdline *cl,
7881 __attribute__((unused)) void *data)
7884 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7885 struct rte_eth_mac_filter filter;
7887 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7889 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7891 /* set VF MAC filter */
7895 filter.dst_id = res->vf_id;
7897 if (!strcmp(res->filter_type, "exact-mac"))
7898 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7899 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7900 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7901 else if (!strcmp(res->filter_type, "hashmac"))
7902 filter.filter_type = RTE_MAC_HASH_MATCH;
7903 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7904 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7906 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7909 ret = rte_eth_dev_filter_ctrl(res->port_id,
7910 RTE_ETH_FILTER_MACVLAN,
7914 ret = rte_eth_dev_filter_ctrl(res->port_id,
7915 RTE_ETH_FILTER_MACVLAN,
7916 RTE_ETH_FILTER_DELETE,
7920 printf("bad set MAC hash parameter, return code = %d\n", ret);
7924 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7925 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7927 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7928 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7930 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7931 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7933 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7934 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7936 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7937 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7939 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7940 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7942 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7943 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7944 filter_type, "exact-mac#exact-mac-vlan"
7945 "#hashmac#hashmac-vlan");
7946 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7947 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7950 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7951 .f = cmd_set_vf_macvlan_parsed,
7953 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7954 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7955 "Exact match rule: exact match of MAC or MAC and VLAN; "
7956 "hash match rule: hash match of MAC and exact match of VLAN",
7958 (void *)&cmd_set_vf_macvlan_set,
7959 (void *)&cmd_set_vf_macvlan_port,
7960 (void *)&cmd_set_vf_macvlan_portid,
7961 (void *)&cmd_set_vf_macvlan_vf,
7962 (void *)&cmd_set_vf_macvlan_vf_id,
7963 (void *)&cmd_set_vf_macvlan_mac,
7964 (void *)&cmd_set_vf_macvlan_filter_type,
7965 (void *)&cmd_set_vf_macvlan_mode,
7970 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7971 struct cmd_set_vf_traffic {
7972 cmdline_fixed_string_t set;
7973 cmdline_fixed_string_t port;
7975 cmdline_fixed_string_t vf;
7977 cmdline_fixed_string_t what;
7978 cmdline_fixed_string_t mode;
7982 cmd_set_vf_traffic_parsed(void *parsed_result,
7983 __attribute__((unused)) struct cmdline *cl,
7984 __attribute__((unused)) void *data)
7986 struct cmd_set_vf_traffic *res = parsed_result;
7987 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7988 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7990 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7993 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7994 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7996 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7997 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7999 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8000 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8002 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8003 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8005 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8006 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8008 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8009 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8011 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8012 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8015 cmdline_parse_inst_t cmd_set_vf_traffic = {
8016 .f = cmd_set_vf_traffic_parsed,
8018 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8020 (void *)&cmd_setvf_traffic_set,
8021 (void *)&cmd_setvf_traffic_port,
8022 (void *)&cmd_setvf_traffic_portid,
8023 (void *)&cmd_setvf_traffic_vf,
8024 (void *)&cmd_setvf_traffic_vfid,
8025 (void *)&cmd_setvf_traffic_what,
8026 (void *)&cmd_setvf_traffic_mode,
8031 /* *** CONFIGURE VF RECEIVE MODE *** */
8032 struct cmd_set_vf_rxmode {
8033 cmdline_fixed_string_t set;
8034 cmdline_fixed_string_t port;
8036 cmdline_fixed_string_t vf;
8038 cmdline_fixed_string_t what;
8039 cmdline_fixed_string_t mode;
8040 cmdline_fixed_string_t on;
8044 cmd_set_vf_rxmode_parsed(void *parsed_result,
8045 __attribute__((unused)) struct cmdline *cl,
8046 __attribute__((unused)) void *data)
8049 uint16_t rx_mode = 0;
8050 struct cmd_set_vf_rxmode *res = parsed_result;
8052 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8053 if (!strcmp(res->what,"rxmode")) {
8054 if (!strcmp(res->mode, "AUPE"))
8055 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8056 else if (!strcmp(res->mode, "ROPE"))
8057 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8058 else if (!strcmp(res->mode, "BAM"))
8059 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8060 else if (!strncmp(res->mode, "MPE",3))
8061 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8064 RTE_SET_USED(is_on);
8066 #ifdef RTE_LIBRTE_IXGBE_PMD
8067 if (ret == -ENOTSUP)
8068 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8069 rx_mode, (uint8_t)is_on);
8071 #ifdef RTE_LIBRTE_BNXT_PMD
8072 if (ret == -ENOTSUP)
8073 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8074 rx_mode, (uint8_t)is_on);
8077 printf("bad VF receive mode parameter, return code = %d \n",
8081 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8082 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8084 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8085 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8087 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8088 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8090 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8091 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8093 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8094 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8096 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8097 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8099 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8100 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8101 mode, "AUPE#ROPE#BAM#MPE");
8102 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8103 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8106 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8107 .f = cmd_set_vf_rxmode_parsed,
8109 .help_str = "set port <port_id> vf <vf_id> rxmode "
8110 "AUPE|ROPE|BAM|MPE on|off",
8112 (void *)&cmd_set_vf_rxmode_set,
8113 (void *)&cmd_set_vf_rxmode_port,
8114 (void *)&cmd_set_vf_rxmode_portid,
8115 (void *)&cmd_set_vf_rxmode_vf,
8116 (void *)&cmd_set_vf_rxmode_vfid,
8117 (void *)&cmd_set_vf_rxmode_what,
8118 (void *)&cmd_set_vf_rxmode_mode,
8119 (void *)&cmd_set_vf_rxmode_on,
8124 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8125 struct cmd_vf_mac_addr_result {
8126 cmdline_fixed_string_t mac_addr_cmd;
8127 cmdline_fixed_string_t what;
8128 cmdline_fixed_string_t port;
8130 cmdline_fixed_string_t vf;
8132 struct ether_addr address;
8135 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8136 __attribute__((unused)) struct cmdline *cl,
8137 __attribute__((unused)) void *data)
8139 struct cmd_vf_mac_addr_result *res = parsed_result;
8142 if (strcmp(res->what, "add") != 0)
8145 #ifdef RTE_LIBRTE_I40E_PMD
8146 if (ret == -ENOTSUP)
8147 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8150 #ifdef RTE_LIBRTE_BNXT_PMD
8151 if (ret == -ENOTSUP)
8152 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8157 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8161 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8162 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8163 mac_addr_cmd,"mac_addr");
8164 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8165 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8167 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8168 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8170 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8171 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8173 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8174 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8176 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8177 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8179 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8180 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8183 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8184 .f = cmd_vf_mac_addr_parsed,
8186 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8187 "Add MAC address filtering for a VF on port_id",
8189 (void *)&cmd_vf_mac_addr_cmd,
8190 (void *)&cmd_vf_mac_addr_what,
8191 (void *)&cmd_vf_mac_addr_port,
8192 (void *)&cmd_vf_mac_addr_portnum,
8193 (void *)&cmd_vf_mac_addr_vf,
8194 (void *)&cmd_vf_mac_addr_vfnum,
8195 (void *)&cmd_vf_mac_addr_addr,
8200 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8201 struct cmd_vf_rx_vlan_filter {
8202 cmdline_fixed_string_t rx_vlan;
8203 cmdline_fixed_string_t what;
8205 cmdline_fixed_string_t port;
8207 cmdline_fixed_string_t vf;
8212 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8213 __attribute__((unused)) struct cmdline *cl,
8214 __attribute__((unused)) void *data)
8216 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8219 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8221 #ifdef RTE_LIBRTE_IXGBE_PMD
8222 if (ret == -ENOTSUP)
8223 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8224 res->vlan_id, res->vf_mask, is_add);
8226 #ifdef RTE_LIBRTE_I40E_PMD
8227 if (ret == -ENOTSUP)
8228 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8229 res->vlan_id, res->vf_mask, is_add);
8231 #ifdef RTE_LIBRTE_BNXT_PMD
8232 if (ret == -ENOTSUP)
8233 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8234 res->vlan_id, res->vf_mask, is_add);
8241 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8242 res->vlan_id, res->vf_mask);
8245 printf("invalid port_id %d\n", res->port_id);
8248 printf("function not implemented or supported\n");
8251 printf("programming error: (%s)\n", strerror(-ret));
8255 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8256 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8257 rx_vlan, "rx_vlan");
8258 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8259 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8261 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8262 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8264 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8265 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8267 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8268 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8270 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8271 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8273 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8274 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8277 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8278 .f = cmd_vf_rx_vlan_filter_parsed,
8280 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8281 "(vf_mask = hexadecimal VF mask)",
8283 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8284 (void *)&cmd_vf_rx_vlan_filter_what,
8285 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8286 (void *)&cmd_vf_rx_vlan_filter_port,
8287 (void *)&cmd_vf_rx_vlan_filter_portid,
8288 (void *)&cmd_vf_rx_vlan_filter_vf,
8289 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8294 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8295 struct cmd_queue_rate_limit_result {
8296 cmdline_fixed_string_t set;
8297 cmdline_fixed_string_t port;
8299 cmdline_fixed_string_t queue;
8301 cmdline_fixed_string_t rate;
8305 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8306 __attribute__((unused)) struct cmdline *cl,
8307 __attribute__((unused)) void *data)
8309 struct cmd_queue_rate_limit_result *res = parsed_result;
8312 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8313 && (strcmp(res->queue, "queue") == 0)
8314 && (strcmp(res->rate, "rate") == 0))
8315 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8318 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8322 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8323 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8325 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8326 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8328 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8329 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8331 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8332 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8334 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8335 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8337 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8338 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8340 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8341 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8344 cmdline_parse_inst_t cmd_queue_rate_limit = {
8345 .f = cmd_queue_rate_limit_parsed,
8347 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8348 "Set rate limit for a queue on port_id",
8350 (void *)&cmd_queue_rate_limit_set,
8351 (void *)&cmd_queue_rate_limit_port,
8352 (void *)&cmd_queue_rate_limit_portnum,
8353 (void *)&cmd_queue_rate_limit_queue,
8354 (void *)&cmd_queue_rate_limit_queuenum,
8355 (void *)&cmd_queue_rate_limit_rate,
8356 (void *)&cmd_queue_rate_limit_ratenum,
8361 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8362 struct cmd_vf_rate_limit_result {
8363 cmdline_fixed_string_t set;
8364 cmdline_fixed_string_t port;
8366 cmdline_fixed_string_t vf;
8368 cmdline_fixed_string_t rate;
8370 cmdline_fixed_string_t q_msk;
8374 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8375 __attribute__((unused)) struct cmdline *cl,
8376 __attribute__((unused)) void *data)
8378 struct cmd_vf_rate_limit_result *res = parsed_result;
8381 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8382 && (strcmp(res->vf, "vf") == 0)
8383 && (strcmp(res->rate, "rate") == 0)
8384 && (strcmp(res->q_msk, "queue_mask") == 0))
8385 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8386 res->rate_num, res->q_msk_val);
8388 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8392 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8393 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8395 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8396 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8398 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8399 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8401 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8402 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8404 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8405 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8407 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8408 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8410 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8411 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8413 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8414 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8415 q_msk, "queue_mask");
8416 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8417 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8420 cmdline_parse_inst_t cmd_vf_rate_limit = {
8421 .f = cmd_vf_rate_limit_parsed,
8423 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8424 "queue_mask <queue_mask_value>: "
8425 "Set rate limit for queues of VF on port_id",
8427 (void *)&cmd_vf_rate_limit_set,
8428 (void *)&cmd_vf_rate_limit_port,
8429 (void *)&cmd_vf_rate_limit_portnum,
8430 (void *)&cmd_vf_rate_limit_vf,
8431 (void *)&cmd_vf_rate_limit_vfnum,
8432 (void *)&cmd_vf_rate_limit_rate,
8433 (void *)&cmd_vf_rate_limit_ratenum,
8434 (void *)&cmd_vf_rate_limit_q_msk,
8435 (void *)&cmd_vf_rate_limit_q_msk_val,
8440 /* *** ADD TUNNEL FILTER OF A PORT *** */
8441 struct cmd_tunnel_filter_result {
8442 cmdline_fixed_string_t cmd;
8443 cmdline_fixed_string_t what;
8445 struct ether_addr outer_mac;
8446 struct ether_addr inner_mac;
8447 cmdline_ipaddr_t ip_value;
8448 uint16_t inner_vlan;
8449 cmdline_fixed_string_t tunnel_type;
8450 cmdline_fixed_string_t filter_type;
8456 cmd_tunnel_filter_parsed(void *parsed_result,
8457 __attribute__((unused)) struct cmdline *cl,
8458 __attribute__((unused)) void *data)
8460 struct cmd_tunnel_filter_result *res = parsed_result;
8461 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8464 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8466 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8467 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8468 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8470 if (res->ip_value.family == AF_INET) {
8471 tunnel_filter_conf.ip_addr.ipv4_addr =
8472 res->ip_value.addr.ipv4.s_addr;
8473 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8475 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8476 &(res->ip_value.addr.ipv6),
8477 sizeof(struct in6_addr));
8478 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8481 if (!strcmp(res->filter_type, "imac-ivlan"))
8482 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8483 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8484 tunnel_filter_conf.filter_type =
8485 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8486 else if (!strcmp(res->filter_type, "imac-tenid"))
8487 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8488 else if (!strcmp(res->filter_type, "imac"))
8489 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8490 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8491 tunnel_filter_conf.filter_type =
8492 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8493 else if (!strcmp(res->filter_type, "oip"))
8494 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8495 else if (!strcmp(res->filter_type, "iip"))
8496 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8498 printf("The filter type is not supported");
8502 if (!strcmp(res->tunnel_type, "vxlan"))
8503 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8504 else if (!strcmp(res->tunnel_type, "nvgre"))
8505 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8506 else if (!strcmp(res->tunnel_type, "ipingre"))
8507 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8509 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8513 tunnel_filter_conf.tenant_id = res->tenant_id;
8514 tunnel_filter_conf.queue_id = res->queue_num;
8515 if (!strcmp(res->what, "add"))
8516 ret = rte_eth_dev_filter_ctrl(res->port_id,
8517 RTE_ETH_FILTER_TUNNEL,
8519 &tunnel_filter_conf);
8521 ret = rte_eth_dev_filter_ctrl(res->port_id,
8522 RTE_ETH_FILTER_TUNNEL,
8523 RTE_ETH_FILTER_DELETE,
8524 &tunnel_filter_conf);
8526 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8530 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8531 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8532 cmd, "tunnel_filter");
8533 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8534 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8536 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8537 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8539 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8540 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8542 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8543 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8545 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8546 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8547 inner_vlan, UINT16);
8548 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8549 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8551 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8552 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8553 tunnel_type, "vxlan#nvgre#ipingre");
8555 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8556 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8557 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8558 "imac#omac-imac-tenid");
8559 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8560 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8562 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8563 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8566 cmdline_parse_inst_t cmd_tunnel_filter = {
8567 .f = cmd_tunnel_filter_parsed,
8569 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8570 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8571 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8572 "<queue_id>: Add/Rm tunnel filter of a port",
8574 (void *)&cmd_tunnel_filter_cmd,
8575 (void *)&cmd_tunnel_filter_what,
8576 (void *)&cmd_tunnel_filter_port_id,
8577 (void *)&cmd_tunnel_filter_outer_mac,
8578 (void *)&cmd_tunnel_filter_inner_mac,
8579 (void *)&cmd_tunnel_filter_ip_value,
8580 (void *)&cmd_tunnel_filter_innner_vlan,
8581 (void *)&cmd_tunnel_filter_tunnel_type,
8582 (void *)&cmd_tunnel_filter_filter_type,
8583 (void *)&cmd_tunnel_filter_tenant_id,
8584 (void *)&cmd_tunnel_filter_queue_num,
8589 /* *** CONFIGURE TUNNEL UDP PORT *** */
8590 struct cmd_tunnel_udp_config {
8591 cmdline_fixed_string_t cmd;
8592 cmdline_fixed_string_t what;
8598 cmd_tunnel_udp_config_parsed(void *parsed_result,
8599 __attribute__((unused)) struct cmdline *cl,
8600 __attribute__((unused)) void *data)
8602 struct cmd_tunnel_udp_config *res = parsed_result;
8603 struct rte_eth_udp_tunnel tunnel_udp;
8606 tunnel_udp.udp_port = res->udp_port;
8608 if (!strcmp(res->cmd, "rx_vxlan_port"))
8609 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8611 if (!strcmp(res->what, "add"))
8612 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8615 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8619 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8622 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8623 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8624 cmd, "rx_vxlan_port");
8625 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8626 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8628 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8629 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8631 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8632 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8635 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8636 .f = cmd_tunnel_udp_config_parsed,
8638 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8639 "Add/Remove a tunneling UDP port filter",
8641 (void *)&cmd_tunnel_udp_config_cmd,
8642 (void *)&cmd_tunnel_udp_config_what,
8643 (void *)&cmd_tunnel_udp_config_udp_port,
8644 (void *)&cmd_tunnel_udp_config_port_id,
8649 struct cmd_config_tunnel_udp_port {
8650 cmdline_fixed_string_t port;
8651 cmdline_fixed_string_t config;
8653 cmdline_fixed_string_t udp_tunnel_port;
8654 cmdline_fixed_string_t action;
8655 cmdline_fixed_string_t tunnel_type;
8660 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8661 __attribute__((unused)) struct cmdline *cl,
8662 __attribute__((unused)) void *data)
8664 struct cmd_config_tunnel_udp_port *res = parsed_result;
8665 struct rte_eth_udp_tunnel tunnel_udp;
8668 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8671 tunnel_udp.udp_port = res->udp_port;
8673 if (!strcmp(res->tunnel_type, "vxlan")) {
8674 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8675 } else if (!strcmp(res->tunnel_type, "geneve")) {
8676 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8678 printf("Invalid tunnel type\n");
8682 if (!strcmp(res->action, "add"))
8683 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8686 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8690 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8693 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8694 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8696 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8697 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8699 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8700 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8702 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8703 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8706 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8707 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8709 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8710 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8712 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8713 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8716 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8717 .f = cmd_cfg_tunnel_udp_port_parsed,
8719 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8721 (void *)&cmd_config_tunnel_udp_port_port,
8722 (void *)&cmd_config_tunnel_udp_port_config,
8723 (void *)&cmd_config_tunnel_udp_port_port_id,
8724 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8725 (void *)&cmd_config_tunnel_udp_port_action,
8726 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8727 (void *)&cmd_config_tunnel_udp_port_value,
8732 /* *** GLOBAL CONFIG *** */
8733 struct cmd_global_config_result {
8734 cmdline_fixed_string_t cmd;
8736 cmdline_fixed_string_t cfg_type;
8741 cmd_global_config_parsed(void *parsed_result,
8742 __attribute__((unused)) struct cmdline *cl,
8743 __attribute__((unused)) void *data)
8745 struct cmd_global_config_result *res = parsed_result;
8746 struct rte_eth_global_cfg conf;
8749 memset(&conf, 0, sizeof(conf));
8750 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8751 conf.cfg.gre_key_len = res->len;
8752 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8753 RTE_ETH_FILTER_SET, &conf);
8755 printf("Global config error\n");
8758 cmdline_parse_token_string_t cmd_global_config_cmd =
8759 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8761 cmdline_parse_token_num_t cmd_global_config_port_id =
8762 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8764 cmdline_parse_token_string_t cmd_global_config_type =
8765 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8766 cfg_type, "gre-key-len");
8767 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8768 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8771 cmdline_parse_inst_t cmd_global_config = {
8772 .f = cmd_global_config_parsed,
8773 .data = (void *)NULL,
8774 .help_str = "global_config <port_id> gre-key-len <key_len>",
8776 (void *)&cmd_global_config_cmd,
8777 (void *)&cmd_global_config_port_id,
8778 (void *)&cmd_global_config_type,
8779 (void *)&cmd_global_config_gre_key_len,
8784 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8785 struct cmd_set_mirror_mask_result {
8786 cmdline_fixed_string_t set;
8787 cmdline_fixed_string_t port;
8789 cmdline_fixed_string_t mirror;
8791 cmdline_fixed_string_t what;
8792 cmdline_fixed_string_t value;
8793 cmdline_fixed_string_t dstpool;
8795 cmdline_fixed_string_t on;
8798 cmdline_parse_token_string_t cmd_mirror_mask_set =
8799 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8801 cmdline_parse_token_string_t cmd_mirror_mask_port =
8802 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8804 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8805 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8807 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8808 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8809 mirror, "mirror-rule");
8810 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8811 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8813 cmdline_parse_token_string_t cmd_mirror_mask_what =
8814 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8815 what, "pool-mirror-up#pool-mirror-down"
8817 cmdline_parse_token_string_t cmd_mirror_mask_value =
8818 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8820 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8821 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8822 dstpool, "dst-pool");
8823 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8824 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8826 cmdline_parse_token_string_t cmd_mirror_mask_on =
8827 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8831 cmd_set_mirror_mask_parsed(void *parsed_result,
8832 __attribute__((unused)) struct cmdline *cl,
8833 __attribute__((unused)) void *data)
8836 struct cmd_set_mirror_mask_result *res = parsed_result;
8837 struct rte_eth_mirror_conf mr_conf;
8839 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8841 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8843 mr_conf.dst_pool = res->dstpool_id;
8845 if (!strcmp(res->what, "pool-mirror-up")) {
8846 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8847 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8848 } else if (!strcmp(res->what, "pool-mirror-down")) {
8849 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8850 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8851 } else if (!strcmp(res->what, "vlan-mirror")) {
8852 mr_conf.rule_type = ETH_MIRROR_VLAN;
8853 nb_item = parse_item_list(res->value, "vlan",
8854 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8858 for (i = 0; i < nb_item; i++) {
8859 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8860 printf("Invalid vlan_id: must be < 4096\n");
8864 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8865 mr_conf.vlan.vlan_mask |= 1ULL << i;
8869 if (!strcmp(res->on, "on"))
8870 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8873 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8876 printf("mirror rule add error: (%s)\n", strerror(-ret));
8879 cmdline_parse_inst_t cmd_set_mirror_mask = {
8880 .f = cmd_set_mirror_mask_parsed,
8882 .help_str = "set port <port_id> mirror-rule <rule_id> "
8883 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8884 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8886 (void *)&cmd_mirror_mask_set,
8887 (void *)&cmd_mirror_mask_port,
8888 (void *)&cmd_mirror_mask_portid,
8889 (void *)&cmd_mirror_mask_mirror,
8890 (void *)&cmd_mirror_mask_ruleid,
8891 (void *)&cmd_mirror_mask_what,
8892 (void *)&cmd_mirror_mask_value,
8893 (void *)&cmd_mirror_mask_dstpool,
8894 (void *)&cmd_mirror_mask_poolid,
8895 (void *)&cmd_mirror_mask_on,
8900 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8901 struct cmd_set_mirror_link_result {
8902 cmdline_fixed_string_t set;
8903 cmdline_fixed_string_t port;
8905 cmdline_fixed_string_t mirror;
8907 cmdline_fixed_string_t what;
8908 cmdline_fixed_string_t dstpool;
8910 cmdline_fixed_string_t on;
8913 cmdline_parse_token_string_t cmd_mirror_link_set =
8914 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8916 cmdline_parse_token_string_t cmd_mirror_link_port =
8917 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8919 cmdline_parse_token_num_t cmd_mirror_link_portid =
8920 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8922 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8923 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8924 mirror, "mirror-rule");
8925 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8926 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8928 cmdline_parse_token_string_t cmd_mirror_link_what =
8929 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8930 what, "uplink-mirror#downlink-mirror");
8931 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8932 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8933 dstpool, "dst-pool");
8934 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8935 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8937 cmdline_parse_token_string_t cmd_mirror_link_on =
8938 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8942 cmd_set_mirror_link_parsed(void *parsed_result,
8943 __attribute__((unused)) struct cmdline *cl,
8944 __attribute__((unused)) void *data)
8947 struct cmd_set_mirror_link_result *res = parsed_result;
8948 struct rte_eth_mirror_conf mr_conf;
8950 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8951 if (!strcmp(res->what, "uplink-mirror"))
8952 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8954 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8956 mr_conf.dst_pool = res->dstpool_id;
8958 if (!strcmp(res->on, "on"))
8959 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8962 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8965 /* check the return value and print it if is < 0 */
8967 printf("mirror rule add error: (%s)\n", strerror(-ret));
8971 cmdline_parse_inst_t cmd_set_mirror_link = {
8972 .f = cmd_set_mirror_link_parsed,
8974 .help_str = "set port <port_id> mirror-rule <rule_id> "
8975 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8977 (void *)&cmd_mirror_link_set,
8978 (void *)&cmd_mirror_link_port,
8979 (void *)&cmd_mirror_link_portid,
8980 (void *)&cmd_mirror_link_mirror,
8981 (void *)&cmd_mirror_link_ruleid,
8982 (void *)&cmd_mirror_link_what,
8983 (void *)&cmd_mirror_link_dstpool,
8984 (void *)&cmd_mirror_link_poolid,
8985 (void *)&cmd_mirror_link_on,
8990 /* *** RESET VM MIRROR RULE *** */
8991 struct cmd_rm_mirror_rule_result {
8992 cmdline_fixed_string_t reset;
8993 cmdline_fixed_string_t port;
8995 cmdline_fixed_string_t mirror;
8999 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9000 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9002 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9003 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9005 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9006 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9008 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9009 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9010 mirror, "mirror-rule");
9011 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9012 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9016 cmd_reset_mirror_rule_parsed(void *parsed_result,
9017 __attribute__((unused)) struct cmdline *cl,
9018 __attribute__((unused)) void *data)
9021 struct cmd_set_mirror_link_result *res = parsed_result;
9023 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9025 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9028 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9029 .f = cmd_reset_mirror_rule_parsed,
9031 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9033 (void *)&cmd_rm_mirror_rule_reset,
9034 (void *)&cmd_rm_mirror_rule_port,
9035 (void *)&cmd_rm_mirror_rule_portid,
9036 (void *)&cmd_rm_mirror_rule_mirror,
9037 (void *)&cmd_rm_mirror_rule_ruleid,
9042 /* ******************************************************************************** */
9044 struct cmd_dump_result {
9045 cmdline_fixed_string_t dump;
9049 dump_struct_sizes(void)
9051 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9052 DUMP_SIZE(struct rte_mbuf);
9053 DUMP_SIZE(struct rte_mempool);
9054 DUMP_SIZE(struct rte_ring);
9058 static void cmd_dump_parsed(void *parsed_result,
9059 __attribute__((unused)) struct cmdline *cl,
9060 __attribute__((unused)) void *data)
9062 struct cmd_dump_result *res = parsed_result;
9064 if (!strcmp(res->dump, "dump_physmem"))
9065 rte_dump_physmem_layout(stdout);
9066 else if (!strcmp(res->dump, "dump_memzone"))
9067 rte_memzone_dump(stdout);
9068 else if (!strcmp(res->dump, "dump_struct_sizes"))
9069 dump_struct_sizes();
9070 else if (!strcmp(res->dump, "dump_ring"))
9071 rte_ring_list_dump(stdout);
9072 else if (!strcmp(res->dump, "dump_mempool"))
9073 rte_mempool_list_dump(stdout);
9074 else if (!strcmp(res->dump, "dump_devargs"))
9075 rte_devargs_dump(stdout);
9076 else if (!strcmp(res->dump, "dump_log_types"))
9077 rte_log_dump(stdout);
9080 cmdline_parse_token_string_t cmd_dump_dump =
9081 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9084 "dump_struct_sizes#"
9090 cmdline_parse_inst_t cmd_dump = {
9091 .f = cmd_dump_parsed, /* function to call */
9092 .data = NULL, /* 2nd arg of func */
9093 .help_str = "Dump status",
9094 .tokens = { /* token list, NULL terminated */
9095 (void *)&cmd_dump_dump,
9100 /* ******************************************************************************** */
9102 struct cmd_dump_one_result {
9103 cmdline_fixed_string_t dump;
9104 cmdline_fixed_string_t name;
9107 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9108 __attribute__((unused)) void *data)
9110 struct cmd_dump_one_result *res = parsed_result;
9112 if (!strcmp(res->dump, "dump_ring")) {
9114 r = rte_ring_lookup(res->name);
9116 cmdline_printf(cl, "Cannot find ring\n");
9119 rte_ring_dump(stdout, r);
9120 } else if (!strcmp(res->dump, "dump_mempool")) {
9121 struct rte_mempool *mp;
9122 mp = rte_mempool_lookup(res->name);
9124 cmdline_printf(cl, "Cannot find mempool\n");
9127 rte_mempool_dump(stdout, mp);
9131 cmdline_parse_token_string_t cmd_dump_one_dump =
9132 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9133 "dump_ring#dump_mempool");
9135 cmdline_parse_token_string_t cmd_dump_one_name =
9136 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9138 cmdline_parse_inst_t cmd_dump_one = {
9139 .f = cmd_dump_one_parsed, /* function to call */
9140 .data = NULL, /* 2nd arg of func */
9141 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9142 .tokens = { /* token list, NULL terminated */
9143 (void *)&cmd_dump_one_dump,
9144 (void *)&cmd_dump_one_name,
9149 /* *** Add/Del syn filter *** */
9150 struct cmd_syn_filter_result {
9151 cmdline_fixed_string_t filter;
9153 cmdline_fixed_string_t ops;
9154 cmdline_fixed_string_t priority;
9155 cmdline_fixed_string_t high;
9156 cmdline_fixed_string_t queue;
9161 cmd_syn_filter_parsed(void *parsed_result,
9162 __attribute__((unused)) struct cmdline *cl,
9163 __attribute__((unused)) void *data)
9165 struct cmd_syn_filter_result *res = parsed_result;
9166 struct rte_eth_syn_filter syn_filter;
9169 ret = rte_eth_dev_filter_supported(res->port_id,
9170 RTE_ETH_FILTER_SYN);
9172 printf("syn filter is not supported on port %u.\n",
9177 memset(&syn_filter, 0, sizeof(syn_filter));
9179 if (!strcmp(res->ops, "add")) {
9180 if (!strcmp(res->high, "high"))
9181 syn_filter.hig_pri = 1;
9183 syn_filter.hig_pri = 0;
9185 syn_filter.queue = res->queue_id;
9186 ret = rte_eth_dev_filter_ctrl(res->port_id,
9191 ret = rte_eth_dev_filter_ctrl(res->port_id,
9193 RTE_ETH_FILTER_DELETE,
9197 printf("syn filter programming error: (%s)\n",
9201 cmdline_parse_token_string_t cmd_syn_filter_filter =
9202 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9203 filter, "syn_filter");
9204 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9205 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9207 cmdline_parse_token_string_t cmd_syn_filter_ops =
9208 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9210 cmdline_parse_token_string_t cmd_syn_filter_priority =
9211 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9212 priority, "priority");
9213 cmdline_parse_token_string_t cmd_syn_filter_high =
9214 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9216 cmdline_parse_token_string_t cmd_syn_filter_queue =
9217 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9219 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9220 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9223 cmdline_parse_inst_t cmd_syn_filter = {
9224 .f = cmd_syn_filter_parsed,
9226 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9227 "<queue_id>: Add/Delete syn filter",
9229 (void *)&cmd_syn_filter_filter,
9230 (void *)&cmd_syn_filter_port_id,
9231 (void *)&cmd_syn_filter_ops,
9232 (void *)&cmd_syn_filter_priority,
9233 (void *)&cmd_syn_filter_high,
9234 (void *)&cmd_syn_filter_queue,
9235 (void *)&cmd_syn_filter_queue_id,
9240 /* *** queue region set *** */
9241 struct cmd_queue_region_result {
9242 cmdline_fixed_string_t set;
9243 cmdline_fixed_string_t port;
9245 cmdline_fixed_string_t cmd;
9246 cmdline_fixed_string_t region;
9248 cmdline_fixed_string_t queue_start_index;
9250 cmdline_fixed_string_t queue_num;
9251 uint8_t queue_num_value;
9255 cmd_queue_region_parsed(void *parsed_result,
9256 __attribute__((unused)) struct cmdline *cl,
9257 __attribute__((unused)) void *data)
9259 struct cmd_queue_region_result *res = parsed_result;
9261 #ifdef RTE_LIBRTE_I40E_PMD
9262 struct rte_pmd_i40e_queue_region_conf region_conf;
9263 enum rte_pmd_i40e_queue_region_op op_type;
9266 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9269 #ifdef RTE_LIBRTE_I40E_PMD
9270 memset(®ion_conf, 0, sizeof(region_conf));
9271 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9272 region_conf.region_id = res->region_id;
9273 region_conf.queue_num = res->queue_num_value;
9274 region_conf.queue_start_index = res->queue_id;
9276 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9277 op_type, ®ion_conf);
9284 printf("function not implemented or supported\n");
9287 printf("queue region config error: (%s)\n", strerror(-ret));
9291 cmdline_parse_token_string_t cmd_queue_region_set =
9292 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9294 cmdline_parse_token_string_t cmd_queue_region_port =
9295 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9296 cmdline_parse_token_num_t cmd_queue_region_port_id =
9297 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9299 cmdline_parse_token_string_t cmd_queue_region_cmd =
9300 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9301 cmd, "queue-region");
9302 cmdline_parse_token_string_t cmd_queue_region_id =
9303 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9304 region, "region_id");
9305 cmdline_parse_token_num_t cmd_queue_region_index =
9306 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9308 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9309 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9310 queue_start_index, "queue_start_index");
9311 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9312 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9314 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9315 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9316 queue_num, "queue_num");
9317 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9318 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9319 queue_num_value, UINT8);
9321 cmdline_parse_inst_t cmd_queue_region = {
9322 .f = cmd_queue_region_parsed,
9324 .help_str = "set port <port_id> queue-region region_id <value> "
9325 "queue_start_index <value> queue_num <value>: Set a queue region",
9327 (void *)&cmd_queue_region_set,
9328 (void *)&cmd_queue_region_port,
9329 (void *)&cmd_queue_region_port_id,
9330 (void *)&cmd_queue_region_cmd,
9331 (void *)&cmd_queue_region_id,
9332 (void *)&cmd_queue_region_index,
9333 (void *)&cmd_queue_region_queue_start_index,
9334 (void *)&cmd_queue_region_queue_id,
9335 (void *)&cmd_queue_region_queue_num,
9336 (void *)&cmd_queue_region_queue_num_value,
9341 /* *** queue region and flowtype set *** */
9342 struct cmd_region_flowtype_result {
9343 cmdline_fixed_string_t set;
9344 cmdline_fixed_string_t port;
9346 cmdline_fixed_string_t cmd;
9347 cmdline_fixed_string_t region;
9349 cmdline_fixed_string_t flowtype;
9350 uint8_t flowtype_id;
9354 cmd_region_flowtype_parsed(void *parsed_result,
9355 __attribute__((unused)) struct cmdline *cl,
9356 __attribute__((unused)) void *data)
9358 struct cmd_region_flowtype_result *res = parsed_result;
9360 #ifdef RTE_LIBRTE_I40E_PMD
9361 struct rte_pmd_i40e_queue_region_conf region_conf;
9362 enum rte_pmd_i40e_queue_region_op op_type;
9365 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9368 #ifdef RTE_LIBRTE_I40E_PMD
9369 memset(®ion_conf, 0, sizeof(region_conf));
9371 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9372 region_conf.region_id = res->region_id;
9373 region_conf.hw_flowtype = res->flowtype_id;
9375 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9376 op_type, ®ion_conf);
9383 printf("function not implemented or supported\n");
9386 printf("region flowtype config error: (%s)\n", strerror(-ret));
9390 cmdline_parse_token_string_t cmd_region_flowtype_set =
9391 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9393 cmdline_parse_token_string_t cmd_region_flowtype_port =
9394 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9396 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9397 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9399 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9400 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9401 cmd, "queue-region");
9402 cmdline_parse_token_string_t cmd_region_flowtype_index =
9403 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9404 region, "region_id");
9405 cmdline_parse_token_num_t cmd_region_flowtype_id =
9406 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9408 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9409 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9410 flowtype, "flowtype");
9411 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9412 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9413 flowtype_id, UINT8);
9414 cmdline_parse_inst_t cmd_region_flowtype = {
9415 .f = cmd_region_flowtype_parsed,
9417 .help_str = "set port <port_id> queue-region region_id <value> "
9418 "flowtype <value>: Set a flowtype region index",
9420 (void *)&cmd_region_flowtype_set,
9421 (void *)&cmd_region_flowtype_port,
9422 (void *)&cmd_region_flowtype_port_index,
9423 (void *)&cmd_region_flowtype_cmd,
9424 (void *)&cmd_region_flowtype_index,
9425 (void *)&cmd_region_flowtype_id,
9426 (void *)&cmd_region_flowtype_flow_index,
9427 (void *)&cmd_region_flowtype_flow_id,
9432 /* *** User Priority (UP) to queue region (region_id) set *** */
9433 struct cmd_user_priority_region_result {
9434 cmdline_fixed_string_t set;
9435 cmdline_fixed_string_t port;
9437 cmdline_fixed_string_t cmd;
9438 cmdline_fixed_string_t user_priority;
9439 uint8_t user_priority_id;
9440 cmdline_fixed_string_t region;
9445 cmd_user_priority_region_parsed(void *parsed_result,
9446 __attribute__((unused)) struct cmdline *cl,
9447 __attribute__((unused)) void *data)
9449 struct cmd_user_priority_region_result *res = parsed_result;
9451 #ifdef RTE_LIBRTE_I40E_PMD
9452 struct rte_pmd_i40e_queue_region_conf region_conf;
9453 enum rte_pmd_i40e_queue_region_op op_type;
9456 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9459 #ifdef RTE_LIBRTE_I40E_PMD
9460 memset(®ion_conf, 0, sizeof(region_conf));
9461 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9462 region_conf.user_priority = res->user_priority_id;
9463 region_conf.region_id = res->region_id;
9465 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9466 op_type, ®ion_conf);
9473 printf("function not implemented or supported\n");
9476 printf("user_priority region config error: (%s)\n",
9481 cmdline_parse_token_string_t cmd_user_priority_region_set =
9482 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9484 cmdline_parse_token_string_t cmd_user_priority_region_port =
9485 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9487 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9488 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9490 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9491 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9492 cmd, "queue-region");
9493 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9494 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9495 user_priority, "UP");
9496 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9497 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9498 user_priority_id, UINT8);
9499 cmdline_parse_token_string_t cmd_user_priority_region_region =
9500 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9501 region, "region_id");
9502 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9503 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9506 cmdline_parse_inst_t cmd_user_priority_region = {
9507 .f = cmd_user_priority_region_parsed,
9509 .help_str = "set port <port_id> queue-region UP <value> "
9510 "region_id <value>: Set the mapping of User Priority (UP) "
9511 "to queue region (region_id) ",
9513 (void *)&cmd_user_priority_region_set,
9514 (void *)&cmd_user_priority_region_port,
9515 (void *)&cmd_user_priority_region_port_index,
9516 (void *)&cmd_user_priority_region_cmd,
9517 (void *)&cmd_user_priority_region_UP,
9518 (void *)&cmd_user_priority_region_UP_id,
9519 (void *)&cmd_user_priority_region_region,
9520 (void *)&cmd_user_priority_region_region_id,
9525 /* *** flush all queue region related configuration *** */
9526 struct cmd_flush_queue_region_result {
9527 cmdline_fixed_string_t set;
9528 cmdline_fixed_string_t port;
9530 cmdline_fixed_string_t cmd;
9531 cmdline_fixed_string_t flush;
9532 cmdline_fixed_string_t what;
9536 cmd_flush_queue_region_parsed(void *parsed_result,
9537 __attribute__((unused)) struct cmdline *cl,
9538 __attribute__((unused)) void *data)
9540 struct cmd_flush_queue_region_result *res = parsed_result;
9542 #ifdef RTE_LIBRTE_I40E_PMD
9543 struct rte_pmd_i40e_queue_region_conf region_conf;
9544 enum rte_pmd_i40e_queue_region_op op_type;
9547 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9550 #ifdef RTE_LIBRTE_I40E_PMD
9551 memset(®ion_conf, 0, sizeof(region_conf));
9553 if (strcmp(res->what, "on") == 0)
9554 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9556 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9558 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9559 op_type, ®ion_conf);
9566 printf("function not implemented or supported\n");
9569 printf("queue region config flush error: (%s)\n",
9574 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9575 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9577 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9578 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9580 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9581 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9583 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9584 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9585 cmd, "queue-region");
9586 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9587 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9589 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9590 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9593 cmdline_parse_inst_t cmd_flush_queue_region = {
9594 .f = cmd_flush_queue_region_parsed,
9596 .help_str = "set port <port_id> queue-region flush on|off"
9597 ": flush all queue region related configuration",
9599 (void *)&cmd_flush_queue_region_set,
9600 (void *)&cmd_flush_queue_region_port,
9601 (void *)&cmd_flush_queue_region_port_index,
9602 (void *)&cmd_flush_queue_region_cmd,
9603 (void *)&cmd_flush_queue_region_flush,
9604 (void *)&cmd_flush_queue_region_what,
9609 /* *** get all queue region related configuration info *** */
9610 struct cmd_show_queue_region_info {
9611 cmdline_fixed_string_t show;
9612 cmdline_fixed_string_t port;
9614 cmdline_fixed_string_t cmd;
9618 cmd_show_queue_region_info_parsed(void *parsed_result,
9619 __attribute__((unused)) struct cmdline *cl,
9620 __attribute__((unused)) void *data)
9622 struct cmd_show_queue_region_info *res = parsed_result;
9624 #ifdef RTE_LIBRTE_I40E_PMD
9625 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9626 enum rte_pmd_i40e_queue_region_op op_type;
9629 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9632 #ifdef RTE_LIBRTE_I40E_PMD
9633 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9635 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9637 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9638 op_type, &rte_pmd_regions);
9640 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9647 printf("function not implemented or supported\n");
9650 printf("queue region config info show error: (%s)\n",
9655 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9656 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9658 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9659 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9661 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9662 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9664 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9665 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9666 cmd, "queue-region");
9668 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9669 .f = cmd_show_queue_region_info_parsed,
9671 .help_str = "show port <port_id> queue-region"
9672 ": show all queue region related configuration info",
9674 (void *)&cmd_show_queue_region_info_get,
9675 (void *)&cmd_show_queue_region_info_port,
9676 (void *)&cmd_show_queue_region_info_port_index,
9677 (void *)&cmd_show_queue_region_info_cmd,
9682 /* *** ADD/REMOVE A 2tuple FILTER *** */
9683 struct cmd_2tuple_filter_result {
9684 cmdline_fixed_string_t filter;
9686 cmdline_fixed_string_t ops;
9687 cmdline_fixed_string_t dst_port;
9688 uint16_t dst_port_value;
9689 cmdline_fixed_string_t protocol;
9690 uint8_t protocol_value;
9691 cmdline_fixed_string_t mask;
9693 cmdline_fixed_string_t tcp_flags;
9694 uint8_t tcp_flags_value;
9695 cmdline_fixed_string_t priority;
9696 uint8_t priority_value;
9697 cmdline_fixed_string_t queue;
9702 cmd_2tuple_filter_parsed(void *parsed_result,
9703 __attribute__((unused)) struct cmdline *cl,
9704 __attribute__((unused)) void *data)
9706 struct rte_eth_ntuple_filter filter;
9707 struct cmd_2tuple_filter_result *res = parsed_result;
9710 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9712 printf("ntuple filter is not supported on port %u.\n",
9717 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9719 filter.flags = RTE_2TUPLE_FLAGS;
9720 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9721 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9722 filter.proto = res->protocol_value;
9723 filter.priority = res->priority_value;
9724 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9725 printf("nonzero tcp_flags is only meaningful"
9726 " when protocol is TCP.\n");
9729 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9730 printf("invalid TCP flags.\n");
9734 if (res->tcp_flags_value != 0) {
9735 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9736 filter.tcp_flags = res->tcp_flags_value;
9739 /* need convert to big endian. */
9740 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9741 filter.queue = res->queue_id;
9743 if (!strcmp(res->ops, "add"))
9744 ret = rte_eth_dev_filter_ctrl(res->port_id,
9745 RTE_ETH_FILTER_NTUPLE,
9749 ret = rte_eth_dev_filter_ctrl(res->port_id,
9750 RTE_ETH_FILTER_NTUPLE,
9751 RTE_ETH_FILTER_DELETE,
9754 printf("2tuple filter programming error: (%s)\n",
9759 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9760 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9761 filter, "2tuple_filter");
9762 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9763 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9765 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9766 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9768 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9769 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9770 dst_port, "dst_port");
9771 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9772 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9773 dst_port_value, UINT16);
9774 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9775 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9776 protocol, "protocol");
9777 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9778 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9779 protocol_value, UINT8);
9780 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9781 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9783 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9784 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9786 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9787 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9788 tcp_flags, "tcp_flags");
9789 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9790 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9791 tcp_flags_value, UINT8);
9792 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9793 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9794 priority, "priority");
9795 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9796 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9797 priority_value, UINT8);
9798 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9799 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9801 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9802 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9805 cmdline_parse_inst_t cmd_2tuple_filter = {
9806 .f = cmd_2tuple_filter_parsed,
9808 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9809 "<value> mask <value> tcp_flags <value> priority <value> queue "
9810 "<queue_id>: Add a 2tuple filter",
9812 (void *)&cmd_2tuple_filter_filter,
9813 (void *)&cmd_2tuple_filter_port_id,
9814 (void *)&cmd_2tuple_filter_ops,
9815 (void *)&cmd_2tuple_filter_dst_port,
9816 (void *)&cmd_2tuple_filter_dst_port_value,
9817 (void *)&cmd_2tuple_filter_protocol,
9818 (void *)&cmd_2tuple_filter_protocol_value,
9819 (void *)&cmd_2tuple_filter_mask,
9820 (void *)&cmd_2tuple_filter_mask_value,
9821 (void *)&cmd_2tuple_filter_tcp_flags,
9822 (void *)&cmd_2tuple_filter_tcp_flags_value,
9823 (void *)&cmd_2tuple_filter_priority,
9824 (void *)&cmd_2tuple_filter_priority_value,
9825 (void *)&cmd_2tuple_filter_queue,
9826 (void *)&cmd_2tuple_filter_queue_id,
9831 /* *** ADD/REMOVE A 5tuple FILTER *** */
9832 struct cmd_5tuple_filter_result {
9833 cmdline_fixed_string_t filter;
9835 cmdline_fixed_string_t ops;
9836 cmdline_fixed_string_t dst_ip;
9837 cmdline_ipaddr_t dst_ip_value;
9838 cmdline_fixed_string_t src_ip;
9839 cmdline_ipaddr_t src_ip_value;
9840 cmdline_fixed_string_t dst_port;
9841 uint16_t dst_port_value;
9842 cmdline_fixed_string_t src_port;
9843 uint16_t src_port_value;
9844 cmdline_fixed_string_t protocol;
9845 uint8_t protocol_value;
9846 cmdline_fixed_string_t mask;
9848 cmdline_fixed_string_t tcp_flags;
9849 uint8_t tcp_flags_value;
9850 cmdline_fixed_string_t priority;
9851 uint8_t priority_value;
9852 cmdline_fixed_string_t queue;
9857 cmd_5tuple_filter_parsed(void *parsed_result,
9858 __attribute__((unused)) struct cmdline *cl,
9859 __attribute__((unused)) void *data)
9861 struct rte_eth_ntuple_filter filter;
9862 struct cmd_5tuple_filter_result *res = parsed_result;
9865 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9867 printf("ntuple filter is not supported on port %u.\n",
9872 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9874 filter.flags = RTE_5TUPLE_FLAGS;
9875 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9876 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9877 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9878 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9879 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9880 filter.proto = res->protocol_value;
9881 filter.priority = res->priority_value;
9882 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9883 printf("nonzero tcp_flags is only meaningful"
9884 " when protocol is TCP.\n");
9887 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9888 printf("invalid TCP flags.\n");
9892 if (res->tcp_flags_value != 0) {
9893 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9894 filter.tcp_flags = res->tcp_flags_value;
9897 if (res->dst_ip_value.family == AF_INET)
9898 /* no need to convert, already big endian. */
9899 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9901 if (filter.dst_ip_mask == 0) {
9902 printf("can not support ipv6 involved compare.\n");
9908 if (res->src_ip_value.family == AF_INET)
9909 /* no need to convert, already big endian. */
9910 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9912 if (filter.src_ip_mask == 0) {
9913 printf("can not support ipv6 involved compare.\n");
9918 /* need convert to big endian. */
9919 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9920 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9921 filter.queue = res->queue_id;
9923 if (!strcmp(res->ops, "add"))
9924 ret = rte_eth_dev_filter_ctrl(res->port_id,
9925 RTE_ETH_FILTER_NTUPLE,
9929 ret = rte_eth_dev_filter_ctrl(res->port_id,
9930 RTE_ETH_FILTER_NTUPLE,
9931 RTE_ETH_FILTER_DELETE,
9934 printf("5tuple filter programming error: (%s)\n",
9938 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9939 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9940 filter, "5tuple_filter");
9941 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9942 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9944 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9945 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9947 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9948 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9950 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9951 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9953 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9954 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9956 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9957 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9959 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9960 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9961 dst_port, "dst_port");
9962 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9963 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9964 dst_port_value, UINT16);
9965 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9966 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9967 src_port, "src_port");
9968 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9969 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9970 src_port_value, UINT16);
9971 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9972 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9973 protocol, "protocol");
9974 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9975 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9976 protocol_value, UINT8);
9977 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9978 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9980 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9981 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9983 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9984 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9985 tcp_flags, "tcp_flags");
9986 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9987 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9988 tcp_flags_value, UINT8);
9989 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9990 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9991 priority, "priority");
9992 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9993 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9994 priority_value, UINT8);
9995 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9996 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9998 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9999 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10002 cmdline_parse_inst_t cmd_5tuple_filter = {
10003 .f = cmd_5tuple_filter_parsed,
10005 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10006 "src_ip <value> dst_port <value> src_port <value> "
10007 "protocol <value> mask <value> tcp_flags <value> "
10008 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10010 (void *)&cmd_5tuple_filter_filter,
10011 (void *)&cmd_5tuple_filter_port_id,
10012 (void *)&cmd_5tuple_filter_ops,
10013 (void *)&cmd_5tuple_filter_dst_ip,
10014 (void *)&cmd_5tuple_filter_dst_ip_value,
10015 (void *)&cmd_5tuple_filter_src_ip,
10016 (void *)&cmd_5tuple_filter_src_ip_value,
10017 (void *)&cmd_5tuple_filter_dst_port,
10018 (void *)&cmd_5tuple_filter_dst_port_value,
10019 (void *)&cmd_5tuple_filter_src_port,
10020 (void *)&cmd_5tuple_filter_src_port_value,
10021 (void *)&cmd_5tuple_filter_protocol,
10022 (void *)&cmd_5tuple_filter_protocol_value,
10023 (void *)&cmd_5tuple_filter_mask,
10024 (void *)&cmd_5tuple_filter_mask_value,
10025 (void *)&cmd_5tuple_filter_tcp_flags,
10026 (void *)&cmd_5tuple_filter_tcp_flags_value,
10027 (void *)&cmd_5tuple_filter_priority,
10028 (void *)&cmd_5tuple_filter_priority_value,
10029 (void *)&cmd_5tuple_filter_queue,
10030 (void *)&cmd_5tuple_filter_queue_id,
10035 /* *** ADD/REMOVE A flex FILTER *** */
10036 struct cmd_flex_filter_result {
10037 cmdline_fixed_string_t filter;
10038 cmdline_fixed_string_t ops;
10040 cmdline_fixed_string_t len;
10042 cmdline_fixed_string_t bytes;
10043 cmdline_fixed_string_t bytes_value;
10044 cmdline_fixed_string_t mask;
10045 cmdline_fixed_string_t mask_value;
10046 cmdline_fixed_string_t priority;
10047 uint8_t priority_value;
10048 cmdline_fixed_string_t queue;
10052 static int xdigit2val(unsigned char c)
10057 else if (isupper(c))
10058 val = c - 'A' + 10;
10060 val = c - 'a' + 10;
10065 cmd_flex_filter_parsed(void *parsed_result,
10066 __attribute__((unused)) struct cmdline *cl,
10067 __attribute__((unused)) void *data)
10070 struct rte_eth_flex_filter filter;
10071 struct cmd_flex_filter_result *res = parsed_result;
10072 char *bytes_ptr, *mask_ptr;
10073 uint16_t len, i, j = 0;
10078 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10079 printf("the len exceed the max length 128\n");
10082 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10083 filter.len = res->len_value;
10084 filter.priority = res->priority_value;
10085 filter.queue = res->queue_id;
10086 bytes_ptr = res->bytes_value;
10087 mask_ptr = res->mask_value;
10089 /* translate bytes string to array. */
10090 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10091 (bytes_ptr[1] == 'X')))
10093 len = strnlen(bytes_ptr, res->len_value * 2);
10094 if (len == 0 || (len % 8 != 0)) {
10095 printf("please check len and bytes input\n");
10098 for (i = 0; i < len; i++) {
10100 if (isxdigit(c) == 0) {
10101 /* invalid characters. */
10102 printf("invalid input\n");
10105 val = xdigit2val(c);
10108 filter.bytes[j] = byte;
10109 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10116 /* translate mask string to uint8_t array. */
10117 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10118 (mask_ptr[1] == 'X')))
10120 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10122 printf("invalid input\n");
10127 for (i = 0; i < len; i++) {
10129 if (isxdigit(c) == 0) {
10130 /* invalid characters. */
10131 printf("invalid input\n");
10134 val = xdigit2val(c);
10137 filter.mask[j] = byte;
10138 printf("mask[%d]:%02x ", j, filter.mask[j]);
10146 if (!strcmp(res->ops, "add"))
10147 ret = rte_eth_dev_filter_ctrl(res->port_id,
10148 RTE_ETH_FILTER_FLEXIBLE,
10149 RTE_ETH_FILTER_ADD,
10152 ret = rte_eth_dev_filter_ctrl(res->port_id,
10153 RTE_ETH_FILTER_FLEXIBLE,
10154 RTE_ETH_FILTER_DELETE,
10158 printf("flex filter setting error: (%s)\n", strerror(-ret));
10161 cmdline_parse_token_string_t cmd_flex_filter_filter =
10162 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10163 filter, "flex_filter");
10164 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10165 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10167 cmdline_parse_token_string_t cmd_flex_filter_ops =
10168 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10170 cmdline_parse_token_string_t cmd_flex_filter_len =
10171 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10173 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10174 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10176 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10177 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10179 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10180 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10181 bytes_value, NULL);
10182 cmdline_parse_token_string_t cmd_flex_filter_mask =
10183 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10185 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10186 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10188 cmdline_parse_token_string_t cmd_flex_filter_priority =
10189 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10190 priority, "priority");
10191 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10192 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10193 priority_value, UINT8);
10194 cmdline_parse_token_string_t cmd_flex_filter_queue =
10195 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10197 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10198 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10200 cmdline_parse_inst_t cmd_flex_filter = {
10201 .f = cmd_flex_filter_parsed,
10203 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10204 "<value> mask <value> priority <value> queue <queue_id>: "
10205 "Add/Del a flex filter",
10207 (void *)&cmd_flex_filter_filter,
10208 (void *)&cmd_flex_filter_port_id,
10209 (void *)&cmd_flex_filter_ops,
10210 (void *)&cmd_flex_filter_len,
10211 (void *)&cmd_flex_filter_len_value,
10212 (void *)&cmd_flex_filter_bytes,
10213 (void *)&cmd_flex_filter_bytes_value,
10214 (void *)&cmd_flex_filter_mask,
10215 (void *)&cmd_flex_filter_mask_value,
10216 (void *)&cmd_flex_filter_priority,
10217 (void *)&cmd_flex_filter_priority_value,
10218 (void *)&cmd_flex_filter_queue,
10219 (void *)&cmd_flex_filter_queue_id,
10224 /* *** Filters Control *** */
10226 /* *** deal with ethertype filter *** */
10227 struct cmd_ethertype_filter_result {
10228 cmdline_fixed_string_t filter;
10230 cmdline_fixed_string_t ops;
10231 cmdline_fixed_string_t mac;
10232 struct ether_addr mac_addr;
10233 cmdline_fixed_string_t ethertype;
10234 uint16_t ethertype_value;
10235 cmdline_fixed_string_t drop;
10236 cmdline_fixed_string_t queue;
10240 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10241 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10242 filter, "ethertype_filter");
10243 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10244 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10246 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10247 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10249 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10250 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10251 mac, "mac_addr#mac_ignr");
10252 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10253 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10255 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10256 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10257 ethertype, "ethertype");
10258 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10259 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10260 ethertype_value, UINT16);
10261 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10262 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10264 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10265 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10267 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10268 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10272 cmd_ethertype_filter_parsed(void *parsed_result,
10273 __attribute__((unused)) struct cmdline *cl,
10274 __attribute__((unused)) void *data)
10276 struct cmd_ethertype_filter_result *res = parsed_result;
10277 struct rte_eth_ethertype_filter filter;
10280 ret = rte_eth_dev_filter_supported(res->port_id,
10281 RTE_ETH_FILTER_ETHERTYPE);
10283 printf("ethertype filter is not supported on port %u.\n",
10288 memset(&filter, 0, sizeof(filter));
10289 if (!strcmp(res->mac, "mac_addr")) {
10290 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10291 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10292 sizeof(struct ether_addr));
10294 if (!strcmp(res->drop, "drop"))
10295 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10296 filter.ether_type = res->ethertype_value;
10297 filter.queue = res->queue_id;
10299 if (!strcmp(res->ops, "add"))
10300 ret = rte_eth_dev_filter_ctrl(res->port_id,
10301 RTE_ETH_FILTER_ETHERTYPE,
10302 RTE_ETH_FILTER_ADD,
10305 ret = rte_eth_dev_filter_ctrl(res->port_id,
10306 RTE_ETH_FILTER_ETHERTYPE,
10307 RTE_ETH_FILTER_DELETE,
10310 printf("ethertype filter programming error: (%s)\n",
10314 cmdline_parse_inst_t cmd_ethertype_filter = {
10315 .f = cmd_ethertype_filter_parsed,
10317 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10318 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10319 "Add or delete an ethertype filter entry",
10321 (void *)&cmd_ethertype_filter_filter,
10322 (void *)&cmd_ethertype_filter_port_id,
10323 (void *)&cmd_ethertype_filter_ops,
10324 (void *)&cmd_ethertype_filter_mac,
10325 (void *)&cmd_ethertype_filter_mac_addr,
10326 (void *)&cmd_ethertype_filter_ethertype,
10327 (void *)&cmd_ethertype_filter_ethertype_value,
10328 (void *)&cmd_ethertype_filter_drop,
10329 (void *)&cmd_ethertype_filter_queue,
10330 (void *)&cmd_ethertype_filter_queue_id,
10335 /* *** deal with flow director filter *** */
10336 struct cmd_flow_director_result {
10337 cmdline_fixed_string_t flow_director_filter;
10339 cmdline_fixed_string_t mode;
10340 cmdline_fixed_string_t mode_value;
10341 cmdline_fixed_string_t ops;
10342 cmdline_fixed_string_t flow;
10343 cmdline_fixed_string_t flow_type;
10344 cmdline_fixed_string_t ether;
10345 uint16_t ether_type;
10346 cmdline_fixed_string_t src;
10347 cmdline_ipaddr_t ip_src;
10349 cmdline_fixed_string_t dst;
10350 cmdline_ipaddr_t ip_dst;
10352 cmdline_fixed_string_t verify_tag;
10353 uint32_t verify_tag_value;
10354 cmdline_fixed_string_t tos;
10356 cmdline_fixed_string_t proto;
10357 uint8_t proto_value;
10358 cmdline_fixed_string_t ttl;
10360 cmdline_fixed_string_t vlan;
10361 uint16_t vlan_value;
10362 cmdline_fixed_string_t flexbytes;
10363 cmdline_fixed_string_t flexbytes_value;
10364 cmdline_fixed_string_t pf_vf;
10365 cmdline_fixed_string_t drop;
10366 cmdline_fixed_string_t queue;
10368 cmdline_fixed_string_t fd_id;
10369 uint32_t fd_id_value;
10370 cmdline_fixed_string_t mac;
10371 struct ether_addr mac_addr;
10372 cmdline_fixed_string_t tunnel;
10373 cmdline_fixed_string_t tunnel_type;
10374 cmdline_fixed_string_t tunnel_id;
10375 uint32_t tunnel_id_value;
10376 cmdline_fixed_string_t packet;
10381 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10384 const char *p, *p0 = q_arg;
10386 unsigned long int_fld;
10387 char *str_fld[max_num];
10392 p = strchr(p0, '(');
10396 p0 = strchr(p, ')');
10401 if (size >= sizeof(s))
10404 snprintf(s, sizeof(s), "%.*s", size, p);
10405 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10406 if (ret < 0 || ret > max_num)
10408 for (i = 0; i < ret; i++) {
10410 int_fld = strtoul(str_fld[i], &end, 0);
10411 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10413 flexbytes[i] = (uint8_t)int_fld;
10419 str2flowtype(char *string)
10422 static const struct {
10425 } flowtype_str[] = {
10426 {"raw", RTE_ETH_FLOW_RAW},
10427 {"ipv4", RTE_ETH_FLOW_IPV4},
10428 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10429 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10430 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10431 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10432 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10433 {"ipv6", RTE_ETH_FLOW_IPV6},
10434 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10435 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10436 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10437 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10438 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10439 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10442 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10443 if (!strcmp(flowtype_str[i].str, string))
10444 return flowtype_str[i].type;
10447 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10448 return (uint16_t)atoi(string);
10450 return RTE_ETH_FLOW_UNKNOWN;
10453 static enum rte_eth_fdir_tunnel_type
10454 str2fdir_tunneltype(char *string)
10458 static const struct {
10460 enum rte_eth_fdir_tunnel_type type;
10461 } tunneltype_str[] = {
10462 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10463 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10466 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10467 if (!strcmp(tunneltype_str[i].str, string))
10468 return tunneltype_str[i].type;
10470 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10473 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10475 if ((ip_addr).family == AF_INET) \
10476 (ip) = (ip_addr).addr.ipv4.s_addr; \
10478 printf("invalid parameter.\n"); \
10483 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10485 if ((ip_addr).family == AF_INET6) \
10486 rte_memcpy(&(ip), \
10487 &((ip_addr).addr.ipv6), \
10488 sizeof(struct in6_addr)); \
10490 printf("invalid parameter.\n"); \
10496 cmd_flow_director_filter_parsed(void *parsed_result,
10497 __attribute__((unused)) struct cmdline *cl,
10498 __attribute__((unused)) void *data)
10500 struct cmd_flow_director_result *res = parsed_result;
10501 struct rte_eth_fdir_filter entry;
10502 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10504 unsigned long vf_id;
10507 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10509 printf("flow director is not supported on port %u.\n",
10513 memset(flexbytes, 0, sizeof(flexbytes));
10514 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10516 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10517 if (strcmp(res->mode_value, "MAC-VLAN")) {
10518 printf("Please set mode to MAC-VLAN.\n");
10521 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10522 if (strcmp(res->mode_value, "Tunnel")) {
10523 printf("Please set mode to Tunnel.\n");
10527 if (!strcmp(res->mode_value, "raw")) {
10528 #ifdef RTE_LIBRTE_I40E_PMD
10529 struct rte_pmd_i40e_flow_type_mapping
10530 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10531 struct rte_pmd_i40e_pkt_template_conf conf;
10532 uint16_t flow_type = str2flowtype(res->flow_type);
10533 uint16_t i, port = res->port_id;
10536 memset(&conf, 0, sizeof(conf));
10538 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10539 printf("Invalid flow type specified.\n");
10542 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10546 if (mapping[flow_type].pctype == 0ULL) {
10547 printf("Invalid flow type specified.\n");
10550 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10551 if (mapping[flow_type].pctype & (1ULL << i)) {
10552 conf.input.pctype = i;
10557 conf.input.packet = open_file(res->filepath,
10558 &conf.input.length);
10559 if (!conf.input.packet)
10561 if (!strcmp(res->drop, "drop"))
10562 conf.action.behavior =
10563 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10565 conf.action.behavior =
10566 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10567 conf.action.report_status =
10568 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10569 conf.action.rx_queue = res->queue_id;
10570 conf.soft_id = res->fd_id_value;
10571 add = strcmp(res->ops, "del") ? 1 : 0;
10572 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10576 printf("flow director config error: (%s)\n",
10578 close_file(conf.input.packet);
10581 } else if (strcmp(res->mode_value, "IP")) {
10582 printf("Please set mode to IP or raw.\n");
10585 entry.input.flow_type = str2flowtype(res->flow_type);
10588 ret = parse_flexbytes(res->flexbytes_value,
10590 RTE_ETH_FDIR_MAX_FLEXLEN);
10592 printf("error: Cannot parse flexbytes input.\n");
10596 switch (entry.input.flow_type) {
10597 case RTE_ETH_FLOW_FRAG_IPV4:
10598 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10599 entry.input.flow.ip4_flow.proto = res->proto_value;
10601 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10602 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10603 IPV4_ADDR_TO_UINT(res->ip_dst,
10604 entry.input.flow.ip4_flow.dst_ip);
10605 IPV4_ADDR_TO_UINT(res->ip_src,
10606 entry.input.flow.ip4_flow.src_ip);
10607 entry.input.flow.ip4_flow.tos = res->tos_value;
10608 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10609 /* need convert to big endian. */
10610 entry.input.flow.udp4_flow.dst_port =
10611 rte_cpu_to_be_16(res->port_dst);
10612 entry.input.flow.udp4_flow.src_port =
10613 rte_cpu_to_be_16(res->port_src);
10615 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10616 IPV4_ADDR_TO_UINT(res->ip_dst,
10617 entry.input.flow.sctp4_flow.ip.dst_ip);
10618 IPV4_ADDR_TO_UINT(res->ip_src,
10619 entry.input.flow.sctp4_flow.ip.src_ip);
10620 entry.input.flow.ip4_flow.tos = res->tos_value;
10621 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10622 /* need convert to big endian. */
10623 entry.input.flow.sctp4_flow.dst_port =
10624 rte_cpu_to_be_16(res->port_dst);
10625 entry.input.flow.sctp4_flow.src_port =
10626 rte_cpu_to_be_16(res->port_src);
10627 entry.input.flow.sctp4_flow.verify_tag =
10628 rte_cpu_to_be_32(res->verify_tag_value);
10630 case RTE_ETH_FLOW_FRAG_IPV6:
10631 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10632 entry.input.flow.ipv6_flow.proto = res->proto_value;
10634 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10635 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10636 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10637 entry.input.flow.ipv6_flow.dst_ip);
10638 IPV6_ADDR_TO_ARRAY(res->ip_src,
10639 entry.input.flow.ipv6_flow.src_ip);
10640 entry.input.flow.ipv6_flow.tc = res->tos_value;
10641 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10642 /* need convert to big endian. */
10643 entry.input.flow.udp6_flow.dst_port =
10644 rte_cpu_to_be_16(res->port_dst);
10645 entry.input.flow.udp6_flow.src_port =
10646 rte_cpu_to_be_16(res->port_src);
10648 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10649 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10650 entry.input.flow.sctp6_flow.ip.dst_ip);
10651 IPV6_ADDR_TO_ARRAY(res->ip_src,
10652 entry.input.flow.sctp6_flow.ip.src_ip);
10653 entry.input.flow.ipv6_flow.tc = res->tos_value;
10654 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10655 /* need convert to big endian. */
10656 entry.input.flow.sctp6_flow.dst_port =
10657 rte_cpu_to_be_16(res->port_dst);
10658 entry.input.flow.sctp6_flow.src_port =
10659 rte_cpu_to_be_16(res->port_src);
10660 entry.input.flow.sctp6_flow.verify_tag =
10661 rte_cpu_to_be_32(res->verify_tag_value);
10663 case RTE_ETH_FLOW_L2_PAYLOAD:
10664 entry.input.flow.l2_flow.ether_type =
10665 rte_cpu_to_be_16(res->ether_type);
10671 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10672 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10674 sizeof(struct ether_addr));
10676 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10677 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10679 sizeof(struct ether_addr));
10680 entry.input.flow.tunnel_flow.tunnel_type =
10681 str2fdir_tunneltype(res->tunnel_type);
10682 entry.input.flow.tunnel_flow.tunnel_id =
10683 rte_cpu_to_be_32(res->tunnel_id_value);
10686 rte_memcpy(entry.input.flow_ext.flexbytes,
10688 RTE_ETH_FDIR_MAX_FLEXLEN);
10690 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10692 entry.action.flex_off = 0; /*use 0 by default */
10693 if (!strcmp(res->drop, "drop"))
10694 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10696 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10698 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10699 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10700 if (!strcmp(res->pf_vf, "pf"))
10701 entry.input.flow_ext.is_vf = 0;
10702 else if (!strncmp(res->pf_vf, "vf", 2)) {
10703 struct rte_eth_dev_info dev_info;
10705 memset(&dev_info, 0, sizeof(dev_info));
10706 rte_eth_dev_info_get(res->port_id, &dev_info);
10708 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10709 if (errno != 0 || *end != '\0' ||
10710 vf_id >= dev_info.max_vfs) {
10711 printf("invalid parameter %s.\n", res->pf_vf);
10714 entry.input.flow_ext.is_vf = 1;
10715 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10717 printf("invalid parameter %s.\n", res->pf_vf);
10722 /* set to report FD ID by default */
10723 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10724 entry.action.rx_queue = res->queue_id;
10725 entry.soft_id = res->fd_id_value;
10726 if (!strcmp(res->ops, "add"))
10727 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10728 RTE_ETH_FILTER_ADD, &entry);
10729 else if (!strcmp(res->ops, "del"))
10730 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10731 RTE_ETH_FILTER_DELETE, &entry);
10733 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10734 RTE_ETH_FILTER_UPDATE, &entry);
10736 printf("flow director programming error: (%s)\n",
10740 cmdline_parse_token_string_t cmd_flow_director_filter =
10741 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10742 flow_director_filter, "flow_director_filter");
10743 cmdline_parse_token_num_t cmd_flow_director_port_id =
10744 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10746 cmdline_parse_token_string_t cmd_flow_director_ops =
10747 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10748 ops, "add#del#update");
10749 cmdline_parse_token_string_t cmd_flow_director_flow =
10750 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10752 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10753 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10755 cmdline_parse_token_string_t cmd_flow_director_ether =
10756 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10758 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10759 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10760 ether_type, UINT16);
10761 cmdline_parse_token_string_t cmd_flow_director_src =
10762 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10764 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10765 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10767 cmdline_parse_token_num_t cmd_flow_director_port_src =
10768 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10770 cmdline_parse_token_string_t cmd_flow_director_dst =
10771 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10773 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10774 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10776 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10777 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10779 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10780 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10781 verify_tag, "verify_tag");
10782 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10783 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10784 verify_tag_value, UINT32);
10785 cmdline_parse_token_string_t cmd_flow_director_tos =
10786 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10788 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10789 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10791 cmdline_parse_token_string_t cmd_flow_director_proto =
10792 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10794 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10795 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10796 proto_value, UINT8);
10797 cmdline_parse_token_string_t cmd_flow_director_ttl =
10798 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10800 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10801 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10803 cmdline_parse_token_string_t cmd_flow_director_vlan =
10804 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10806 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10807 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10808 vlan_value, UINT16);
10809 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10811 flexbytes, "flexbytes");
10812 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10813 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10814 flexbytes_value, NULL);
10815 cmdline_parse_token_string_t cmd_flow_director_drop =
10816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10818 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10821 cmdline_parse_token_string_t cmd_flow_director_queue =
10822 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10824 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10825 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10827 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10830 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10831 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10832 fd_id_value, UINT32);
10834 cmdline_parse_token_string_t cmd_flow_director_mode =
10835 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10837 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10838 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10840 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10841 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10842 mode_value, "MAC-VLAN");
10843 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10844 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10845 mode_value, "Tunnel");
10846 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10847 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10848 mode_value, "raw");
10849 cmdline_parse_token_string_t cmd_flow_director_mac =
10850 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10852 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10853 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10855 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10858 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10860 tunnel_type, "NVGRE#VxLAN");
10861 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10863 tunnel_id, "tunnel-id");
10864 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10865 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10866 tunnel_id_value, UINT32);
10867 cmdline_parse_token_string_t cmd_flow_director_packet =
10868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10870 cmdline_parse_token_string_t cmd_flow_director_filepath =
10871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10874 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10875 .f = cmd_flow_director_filter_parsed,
10877 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10878 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10879 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10880 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10881 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10882 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10883 "fd_id <fd_id_value>: "
10884 "Add or delete an ip flow director entry on NIC",
10886 (void *)&cmd_flow_director_filter,
10887 (void *)&cmd_flow_director_port_id,
10888 (void *)&cmd_flow_director_mode,
10889 (void *)&cmd_flow_director_mode_ip,
10890 (void *)&cmd_flow_director_ops,
10891 (void *)&cmd_flow_director_flow,
10892 (void *)&cmd_flow_director_flow_type,
10893 (void *)&cmd_flow_director_src,
10894 (void *)&cmd_flow_director_ip_src,
10895 (void *)&cmd_flow_director_dst,
10896 (void *)&cmd_flow_director_ip_dst,
10897 (void *)&cmd_flow_director_tos,
10898 (void *)&cmd_flow_director_tos_value,
10899 (void *)&cmd_flow_director_proto,
10900 (void *)&cmd_flow_director_proto_value,
10901 (void *)&cmd_flow_director_ttl,
10902 (void *)&cmd_flow_director_ttl_value,
10903 (void *)&cmd_flow_director_vlan,
10904 (void *)&cmd_flow_director_vlan_value,
10905 (void *)&cmd_flow_director_flexbytes,
10906 (void *)&cmd_flow_director_flexbytes_value,
10907 (void *)&cmd_flow_director_drop,
10908 (void *)&cmd_flow_director_pf_vf,
10909 (void *)&cmd_flow_director_queue,
10910 (void *)&cmd_flow_director_queue_id,
10911 (void *)&cmd_flow_director_fd_id,
10912 (void *)&cmd_flow_director_fd_id_value,
10917 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10918 .f = cmd_flow_director_filter_parsed,
10920 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10921 "director entry on NIC",
10923 (void *)&cmd_flow_director_filter,
10924 (void *)&cmd_flow_director_port_id,
10925 (void *)&cmd_flow_director_mode,
10926 (void *)&cmd_flow_director_mode_ip,
10927 (void *)&cmd_flow_director_ops,
10928 (void *)&cmd_flow_director_flow,
10929 (void *)&cmd_flow_director_flow_type,
10930 (void *)&cmd_flow_director_src,
10931 (void *)&cmd_flow_director_ip_src,
10932 (void *)&cmd_flow_director_port_src,
10933 (void *)&cmd_flow_director_dst,
10934 (void *)&cmd_flow_director_ip_dst,
10935 (void *)&cmd_flow_director_port_dst,
10936 (void *)&cmd_flow_director_tos,
10937 (void *)&cmd_flow_director_tos_value,
10938 (void *)&cmd_flow_director_ttl,
10939 (void *)&cmd_flow_director_ttl_value,
10940 (void *)&cmd_flow_director_vlan,
10941 (void *)&cmd_flow_director_vlan_value,
10942 (void *)&cmd_flow_director_flexbytes,
10943 (void *)&cmd_flow_director_flexbytes_value,
10944 (void *)&cmd_flow_director_drop,
10945 (void *)&cmd_flow_director_pf_vf,
10946 (void *)&cmd_flow_director_queue,
10947 (void *)&cmd_flow_director_queue_id,
10948 (void *)&cmd_flow_director_fd_id,
10949 (void *)&cmd_flow_director_fd_id_value,
10954 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10955 .f = cmd_flow_director_filter_parsed,
10957 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10958 "director entry on NIC",
10960 (void *)&cmd_flow_director_filter,
10961 (void *)&cmd_flow_director_port_id,
10962 (void *)&cmd_flow_director_mode,
10963 (void *)&cmd_flow_director_mode_ip,
10964 (void *)&cmd_flow_director_ops,
10965 (void *)&cmd_flow_director_flow,
10966 (void *)&cmd_flow_director_flow_type,
10967 (void *)&cmd_flow_director_src,
10968 (void *)&cmd_flow_director_ip_src,
10969 (void *)&cmd_flow_director_port_src,
10970 (void *)&cmd_flow_director_dst,
10971 (void *)&cmd_flow_director_ip_dst,
10972 (void *)&cmd_flow_director_port_dst,
10973 (void *)&cmd_flow_director_verify_tag,
10974 (void *)&cmd_flow_director_verify_tag_value,
10975 (void *)&cmd_flow_director_tos,
10976 (void *)&cmd_flow_director_tos_value,
10977 (void *)&cmd_flow_director_ttl,
10978 (void *)&cmd_flow_director_ttl_value,
10979 (void *)&cmd_flow_director_vlan,
10980 (void *)&cmd_flow_director_vlan_value,
10981 (void *)&cmd_flow_director_flexbytes,
10982 (void *)&cmd_flow_director_flexbytes_value,
10983 (void *)&cmd_flow_director_drop,
10984 (void *)&cmd_flow_director_pf_vf,
10985 (void *)&cmd_flow_director_queue,
10986 (void *)&cmd_flow_director_queue_id,
10987 (void *)&cmd_flow_director_fd_id,
10988 (void *)&cmd_flow_director_fd_id_value,
10993 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10994 .f = cmd_flow_director_filter_parsed,
10996 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10997 "director entry on NIC",
10999 (void *)&cmd_flow_director_filter,
11000 (void *)&cmd_flow_director_port_id,
11001 (void *)&cmd_flow_director_mode,
11002 (void *)&cmd_flow_director_mode_ip,
11003 (void *)&cmd_flow_director_ops,
11004 (void *)&cmd_flow_director_flow,
11005 (void *)&cmd_flow_director_flow_type,
11006 (void *)&cmd_flow_director_ether,
11007 (void *)&cmd_flow_director_ether_type,
11008 (void *)&cmd_flow_director_flexbytes,
11009 (void *)&cmd_flow_director_flexbytes_value,
11010 (void *)&cmd_flow_director_drop,
11011 (void *)&cmd_flow_director_pf_vf,
11012 (void *)&cmd_flow_director_queue,
11013 (void *)&cmd_flow_director_queue_id,
11014 (void *)&cmd_flow_director_fd_id,
11015 (void *)&cmd_flow_director_fd_id_value,
11020 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11021 .f = cmd_flow_director_filter_parsed,
11023 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11024 "director entry on NIC",
11026 (void *)&cmd_flow_director_filter,
11027 (void *)&cmd_flow_director_port_id,
11028 (void *)&cmd_flow_director_mode,
11029 (void *)&cmd_flow_director_mode_mac_vlan,
11030 (void *)&cmd_flow_director_ops,
11031 (void *)&cmd_flow_director_mac,
11032 (void *)&cmd_flow_director_mac_addr,
11033 (void *)&cmd_flow_director_vlan,
11034 (void *)&cmd_flow_director_vlan_value,
11035 (void *)&cmd_flow_director_flexbytes,
11036 (void *)&cmd_flow_director_flexbytes_value,
11037 (void *)&cmd_flow_director_drop,
11038 (void *)&cmd_flow_director_queue,
11039 (void *)&cmd_flow_director_queue_id,
11040 (void *)&cmd_flow_director_fd_id,
11041 (void *)&cmd_flow_director_fd_id_value,
11046 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11047 .f = cmd_flow_director_filter_parsed,
11049 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11050 "director entry on NIC",
11052 (void *)&cmd_flow_director_filter,
11053 (void *)&cmd_flow_director_port_id,
11054 (void *)&cmd_flow_director_mode,
11055 (void *)&cmd_flow_director_mode_tunnel,
11056 (void *)&cmd_flow_director_ops,
11057 (void *)&cmd_flow_director_mac,
11058 (void *)&cmd_flow_director_mac_addr,
11059 (void *)&cmd_flow_director_vlan,
11060 (void *)&cmd_flow_director_vlan_value,
11061 (void *)&cmd_flow_director_tunnel,
11062 (void *)&cmd_flow_director_tunnel_type,
11063 (void *)&cmd_flow_director_tunnel_id,
11064 (void *)&cmd_flow_director_tunnel_id_value,
11065 (void *)&cmd_flow_director_flexbytes,
11066 (void *)&cmd_flow_director_flexbytes_value,
11067 (void *)&cmd_flow_director_drop,
11068 (void *)&cmd_flow_director_queue,
11069 (void *)&cmd_flow_director_queue_id,
11070 (void *)&cmd_flow_director_fd_id,
11071 (void *)&cmd_flow_director_fd_id_value,
11076 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11077 .f = cmd_flow_director_filter_parsed,
11079 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11080 "director entry on NIC",
11082 (void *)&cmd_flow_director_filter,
11083 (void *)&cmd_flow_director_port_id,
11084 (void *)&cmd_flow_director_mode,
11085 (void *)&cmd_flow_director_mode_raw,
11086 (void *)&cmd_flow_director_ops,
11087 (void *)&cmd_flow_director_flow,
11088 (void *)&cmd_flow_director_flow_type,
11089 (void *)&cmd_flow_director_drop,
11090 (void *)&cmd_flow_director_queue,
11091 (void *)&cmd_flow_director_queue_id,
11092 (void *)&cmd_flow_director_fd_id,
11093 (void *)&cmd_flow_director_fd_id_value,
11094 (void *)&cmd_flow_director_packet,
11095 (void *)&cmd_flow_director_filepath,
11100 struct cmd_flush_flow_director_result {
11101 cmdline_fixed_string_t flush_flow_director;
11105 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11106 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11107 flush_flow_director, "flush_flow_director");
11108 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11109 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11113 cmd_flush_flow_director_parsed(void *parsed_result,
11114 __attribute__((unused)) struct cmdline *cl,
11115 __attribute__((unused)) void *data)
11117 struct cmd_flow_director_result *res = parsed_result;
11120 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11122 printf("flow director is not supported on port %u.\n",
11127 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11128 RTE_ETH_FILTER_FLUSH, NULL);
11130 printf("flow director table flushing error: (%s)\n",
11134 cmdline_parse_inst_t cmd_flush_flow_director = {
11135 .f = cmd_flush_flow_director_parsed,
11137 .help_str = "flush_flow_director <port_id>: "
11138 "Flush all flow director entries of a device on NIC",
11140 (void *)&cmd_flush_flow_director_flush,
11141 (void *)&cmd_flush_flow_director_port_id,
11146 /* *** deal with flow director mask *** */
11147 struct cmd_flow_director_mask_result {
11148 cmdline_fixed_string_t flow_director_mask;
11150 cmdline_fixed_string_t mode;
11151 cmdline_fixed_string_t mode_value;
11152 cmdline_fixed_string_t vlan;
11153 uint16_t vlan_mask;
11154 cmdline_fixed_string_t src_mask;
11155 cmdline_ipaddr_t ipv4_src;
11156 cmdline_ipaddr_t ipv6_src;
11158 cmdline_fixed_string_t dst_mask;
11159 cmdline_ipaddr_t ipv4_dst;
11160 cmdline_ipaddr_t ipv6_dst;
11162 cmdline_fixed_string_t mac;
11163 uint8_t mac_addr_byte_mask;
11164 cmdline_fixed_string_t tunnel_id;
11165 uint32_t tunnel_id_mask;
11166 cmdline_fixed_string_t tunnel_type;
11167 uint8_t tunnel_type_mask;
11171 cmd_flow_director_mask_parsed(void *parsed_result,
11172 __attribute__((unused)) struct cmdline *cl,
11173 __attribute__((unused)) void *data)
11175 struct cmd_flow_director_mask_result *res = parsed_result;
11176 struct rte_eth_fdir_masks *mask;
11177 struct rte_port *port;
11179 port = &ports[res->port_id];
11180 /** Check if the port is not started **/
11181 if (port->port_status != RTE_PORT_STOPPED) {
11182 printf("Please stop port %d first\n", res->port_id);
11186 mask = &port->dev_conf.fdir_conf.mask;
11188 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11189 if (strcmp(res->mode_value, "MAC-VLAN")) {
11190 printf("Please set mode to MAC-VLAN.\n");
11194 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11195 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11196 if (strcmp(res->mode_value, "Tunnel")) {
11197 printf("Please set mode to Tunnel.\n");
11201 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11202 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11203 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11204 mask->tunnel_type_mask = res->tunnel_type_mask;
11206 if (strcmp(res->mode_value, "IP")) {
11207 printf("Please set mode to IP.\n");
11211 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11212 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11213 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11214 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11215 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11216 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11217 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11220 cmd_reconfig_device_queue(res->port_id, 1, 1);
11223 cmdline_parse_token_string_t cmd_flow_director_mask =
11224 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11225 flow_director_mask, "flow_director_mask");
11226 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11227 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11229 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11232 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11233 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11234 vlan_mask, UINT16);
11235 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11237 src_mask, "src_mask");
11238 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11239 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11241 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11242 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11244 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11245 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11247 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11249 dst_mask, "dst_mask");
11250 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11251 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11253 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11254 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11256 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11257 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11260 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11263 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11266 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11268 mode_value, "MAC-VLAN");
11269 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11271 mode_value, "Tunnel");
11272 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11273 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11275 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11276 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11277 mac_addr_byte_mask, UINT8);
11278 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11279 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11280 tunnel_type, "tunnel-type");
11281 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11282 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11283 tunnel_type_mask, UINT8);
11284 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11286 tunnel_id, "tunnel-id");
11287 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11288 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11289 tunnel_id_mask, UINT32);
11291 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11292 .f = cmd_flow_director_mask_parsed,
11294 .help_str = "flow_director_mask ... : "
11295 "Set IP mode flow director's mask on NIC",
11297 (void *)&cmd_flow_director_mask,
11298 (void *)&cmd_flow_director_mask_port_id,
11299 (void *)&cmd_flow_director_mask_mode,
11300 (void *)&cmd_flow_director_mask_mode_ip,
11301 (void *)&cmd_flow_director_mask_vlan,
11302 (void *)&cmd_flow_director_mask_vlan_value,
11303 (void *)&cmd_flow_director_mask_src,
11304 (void *)&cmd_flow_director_mask_ipv4_src,
11305 (void *)&cmd_flow_director_mask_ipv6_src,
11306 (void *)&cmd_flow_director_mask_port_src,
11307 (void *)&cmd_flow_director_mask_dst,
11308 (void *)&cmd_flow_director_mask_ipv4_dst,
11309 (void *)&cmd_flow_director_mask_ipv6_dst,
11310 (void *)&cmd_flow_director_mask_port_dst,
11315 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11316 .f = cmd_flow_director_mask_parsed,
11318 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11319 "flow director's mask on NIC",
11321 (void *)&cmd_flow_director_mask,
11322 (void *)&cmd_flow_director_mask_port_id,
11323 (void *)&cmd_flow_director_mask_mode,
11324 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11325 (void *)&cmd_flow_director_mask_vlan,
11326 (void *)&cmd_flow_director_mask_vlan_value,
11331 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11332 .f = cmd_flow_director_mask_parsed,
11334 .help_str = "flow_director_mask ... : Set tunnel mode "
11335 "flow director's mask on NIC",
11337 (void *)&cmd_flow_director_mask,
11338 (void *)&cmd_flow_director_mask_port_id,
11339 (void *)&cmd_flow_director_mask_mode,
11340 (void *)&cmd_flow_director_mask_mode_tunnel,
11341 (void *)&cmd_flow_director_mask_vlan,
11342 (void *)&cmd_flow_director_mask_vlan_value,
11343 (void *)&cmd_flow_director_mask_mac,
11344 (void *)&cmd_flow_director_mask_mac_value,
11345 (void *)&cmd_flow_director_mask_tunnel_type,
11346 (void *)&cmd_flow_director_mask_tunnel_type_value,
11347 (void *)&cmd_flow_director_mask_tunnel_id,
11348 (void *)&cmd_flow_director_mask_tunnel_id_value,
11353 /* *** deal with flow director mask on flexible payload *** */
11354 struct cmd_flow_director_flex_mask_result {
11355 cmdline_fixed_string_t flow_director_flexmask;
11357 cmdline_fixed_string_t flow;
11358 cmdline_fixed_string_t flow_type;
11359 cmdline_fixed_string_t mask;
11363 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11364 __attribute__((unused)) struct cmdline *cl,
11365 __attribute__((unused)) void *data)
11367 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11368 struct rte_eth_fdir_info fdir_info;
11369 struct rte_eth_fdir_flex_mask flex_mask;
11370 struct rte_port *port;
11371 uint64_t flow_type_mask;
11375 port = &ports[res->port_id];
11376 /** Check if the port is not started **/
11377 if (port->port_status != RTE_PORT_STOPPED) {
11378 printf("Please stop port %d first\n", res->port_id);
11382 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11383 ret = parse_flexbytes(res->mask,
11385 RTE_ETH_FDIR_MAX_FLEXLEN);
11387 printf("error: Cannot parse mask input.\n");
11391 memset(&fdir_info, 0, sizeof(fdir_info));
11392 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11393 RTE_ETH_FILTER_INFO, &fdir_info);
11395 printf("Cannot get FDir filter info\n");
11399 if (!strcmp(res->flow_type, "none")) {
11400 /* means don't specify the flow type */
11401 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11402 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11403 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11404 0, sizeof(struct rte_eth_fdir_flex_mask));
11405 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11406 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11408 sizeof(struct rte_eth_fdir_flex_mask));
11409 cmd_reconfig_device_queue(res->port_id, 1, 1);
11412 flow_type_mask = fdir_info.flow_types_mask[0];
11413 if (!strcmp(res->flow_type, "all")) {
11414 if (!flow_type_mask) {
11415 printf("No flow type supported\n");
11418 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11419 if (flow_type_mask & (1ULL << i)) {
11420 flex_mask.flow_type = i;
11421 fdir_set_flex_mask(res->port_id, &flex_mask);
11424 cmd_reconfig_device_queue(res->port_id, 1, 1);
11427 flex_mask.flow_type = str2flowtype(res->flow_type);
11428 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11429 printf("Flow type %s not supported on port %d\n",
11430 res->flow_type, res->port_id);
11433 fdir_set_flex_mask(res->port_id, &flex_mask);
11434 cmd_reconfig_device_queue(res->port_id, 1, 1);
11437 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11439 flow_director_flexmask,
11440 "flow_director_flex_mask");
11441 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11442 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11444 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11445 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11447 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11449 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11450 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11451 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11452 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11455 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11456 .f = cmd_flow_director_flex_mask_parsed,
11458 .help_str = "flow_director_flex_mask ... : "
11459 "Set flow director's flex mask on NIC",
11461 (void *)&cmd_flow_director_flexmask,
11462 (void *)&cmd_flow_director_flexmask_port_id,
11463 (void *)&cmd_flow_director_flexmask_flow,
11464 (void *)&cmd_flow_director_flexmask_flow_type,
11465 (void *)&cmd_flow_director_flexmask_mask,
11470 /* *** deal with flow director flexible payload configuration *** */
11471 struct cmd_flow_director_flexpayload_result {
11472 cmdline_fixed_string_t flow_director_flexpayload;
11474 cmdline_fixed_string_t payload_layer;
11475 cmdline_fixed_string_t payload_cfg;
11479 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11482 const char *p, *p0 = q_arg;
11484 unsigned long int_fld;
11485 char *str_fld[max_num];
11490 p = strchr(p0, '(');
11494 p0 = strchr(p, ')');
11499 if (size >= sizeof(s))
11502 snprintf(s, sizeof(s), "%.*s", size, p);
11503 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11504 if (ret < 0 || ret > max_num)
11506 for (i = 0; i < ret; i++) {
11508 int_fld = strtoul(str_fld[i], &end, 0);
11509 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11511 offsets[i] = (uint16_t)int_fld;
11517 cmd_flow_director_flxpld_parsed(void *parsed_result,
11518 __attribute__((unused)) struct cmdline *cl,
11519 __attribute__((unused)) void *data)
11521 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11522 struct rte_eth_flex_payload_cfg flex_cfg;
11523 struct rte_port *port;
11526 port = &ports[res->port_id];
11527 /** Check if the port is not started **/
11528 if (port->port_status != RTE_PORT_STOPPED) {
11529 printf("Please stop port %d first\n", res->port_id);
11533 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11535 if (!strcmp(res->payload_layer, "raw"))
11536 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11537 else if (!strcmp(res->payload_layer, "l2"))
11538 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11539 else if (!strcmp(res->payload_layer, "l3"))
11540 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11541 else if (!strcmp(res->payload_layer, "l4"))
11542 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11544 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11545 RTE_ETH_FDIR_MAX_FLEXLEN);
11547 printf("error: Cannot parse flex payload input.\n");
11551 fdir_set_flex_payload(res->port_id, &flex_cfg);
11552 cmd_reconfig_device_queue(res->port_id, 1, 1);
11555 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11556 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11557 flow_director_flexpayload,
11558 "flow_director_flex_payload");
11559 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11560 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11562 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11564 payload_layer, "raw#l2#l3#l4");
11565 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11567 payload_cfg, NULL);
11569 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11570 .f = cmd_flow_director_flxpld_parsed,
11572 .help_str = "flow_director_flexpayload ... : "
11573 "Set flow director's flex payload on NIC",
11575 (void *)&cmd_flow_director_flexpayload,
11576 (void *)&cmd_flow_director_flexpayload_port_id,
11577 (void *)&cmd_flow_director_flexpayload_payload_layer,
11578 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11583 /* Generic flow interface command. */
11584 extern cmdline_parse_inst_t cmd_flow;
11586 /* *** Classification Filters Control *** */
11587 /* *** Get symmetric hash enable per port *** */
11588 struct cmd_get_sym_hash_ena_per_port_result {
11589 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11594 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11595 __rte_unused struct cmdline *cl,
11596 __rte_unused void *data)
11598 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11599 struct rte_eth_hash_filter_info info;
11602 if (rte_eth_dev_filter_supported(res->port_id,
11603 RTE_ETH_FILTER_HASH) < 0) {
11604 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11609 memset(&info, 0, sizeof(info));
11610 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11611 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11612 RTE_ETH_FILTER_GET, &info);
11615 printf("Cannot get symmetric hash enable per port "
11616 "on port %u\n", res->port_id);
11620 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11621 "enabled" : "disabled", res->port_id);
11624 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11625 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11626 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11627 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11628 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11631 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11632 .f = cmd_get_sym_hash_per_port_parsed,
11634 .help_str = "get_sym_hash_ena_per_port <port_id>",
11636 (void *)&cmd_get_sym_hash_ena_per_port_all,
11637 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11642 /* *** Set symmetric hash enable per port *** */
11643 struct cmd_set_sym_hash_ena_per_port_result {
11644 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11645 cmdline_fixed_string_t enable;
11650 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11651 __rte_unused struct cmdline *cl,
11652 __rte_unused void *data)
11654 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11655 struct rte_eth_hash_filter_info info;
11658 if (rte_eth_dev_filter_supported(res->port_id,
11659 RTE_ETH_FILTER_HASH) < 0) {
11660 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11665 memset(&info, 0, sizeof(info));
11666 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11667 if (!strcmp(res->enable, "enable"))
11668 info.info.enable = 1;
11669 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11670 RTE_ETH_FILTER_SET, &info);
11672 printf("Cannot set symmetric hash enable per port on "
11673 "port %u\n", res->port_id);
11676 printf("Symmetric hash has been set to %s on port %u\n",
11677 res->enable, res->port_id);
11680 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11681 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11682 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11683 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11684 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11686 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11687 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11688 enable, "enable#disable");
11690 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11691 .f = cmd_set_sym_hash_per_port_parsed,
11693 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11695 (void *)&cmd_set_sym_hash_ena_per_port_all,
11696 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11697 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11702 /* Get global config of hash function */
11703 struct cmd_get_hash_global_config_result {
11704 cmdline_fixed_string_t get_hash_global_config;
11709 flowtype_to_str(uint16_t ftype)
11715 } ftype_table[] = {
11716 {"ipv4", RTE_ETH_FLOW_IPV4},
11717 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11718 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11719 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11720 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11721 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11722 {"ipv6", RTE_ETH_FLOW_IPV6},
11723 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11724 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11725 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11726 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11727 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11728 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11729 {"port", RTE_ETH_FLOW_PORT},
11730 {"vxlan", RTE_ETH_FLOW_VXLAN},
11731 {"geneve", RTE_ETH_FLOW_GENEVE},
11732 {"nvgre", RTE_ETH_FLOW_NVGRE},
11735 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11736 if (ftype_table[i].ftype == ftype)
11737 return ftype_table[i].str;
11744 cmd_get_hash_global_config_parsed(void *parsed_result,
11745 __rte_unused struct cmdline *cl,
11746 __rte_unused void *data)
11748 struct cmd_get_hash_global_config_result *res = parsed_result;
11749 struct rte_eth_hash_filter_info info;
11750 uint32_t idx, offset;
11755 if (rte_eth_dev_filter_supported(res->port_id,
11756 RTE_ETH_FILTER_HASH) < 0) {
11757 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11762 memset(&info, 0, sizeof(info));
11763 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11764 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11765 RTE_ETH_FILTER_GET, &info);
11767 printf("Cannot get hash global configurations by port %d\n",
11772 switch (info.info.global_conf.hash_func) {
11773 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11774 printf("Hash function is Toeplitz\n");
11776 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11777 printf("Hash function is Simple XOR\n");
11780 printf("Unknown hash function\n");
11784 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11785 idx = i / UINT64_BIT;
11786 offset = i % UINT64_BIT;
11787 if (!(info.info.global_conf.valid_bit_mask[idx] &
11790 str = flowtype_to_str(i);
11793 printf("Symmetric hash is %s globally for flow type %s "
11795 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11796 (1ULL << offset)) ? "enabled" : "disabled"), str,
11801 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11802 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11803 get_hash_global_config, "get_hash_global_config");
11804 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11805 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11808 cmdline_parse_inst_t cmd_get_hash_global_config = {
11809 .f = cmd_get_hash_global_config_parsed,
11811 .help_str = "get_hash_global_config <port_id>",
11813 (void *)&cmd_get_hash_global_config_all,
11814 (void *)&cmd_get_hash_global_config_port_id,
11819 /* Set global config of hash function */
11820 struct cmd_set_hash_global_config_result {
11821 cmdline_fixed_string_t set_hash_global_config;
11823 cmdline_fixed_string_t hash_func;
11824 cmdline_fixed_string_t flow_type;
11825 cmdline_fixed_string_t enable;
11829 cmd_set_hash_global_config_parsed(void *parsed_result,
11830 __rte_unused struct cmdline *cl,
11831 __rte_unused void *data)
11833 struct cmd_set_hash_global_config_result *res = parsed_result;
11834 struct rte_eth_hash_filter_info info;
11835 uint32_t ftype, idx, offset;
11838 if (rte_eth_dev_filter_supported(res->port_id,
11839 RTE_ETH_FILTER_HASH) < 0) {
11840 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11844 memset(&info, 0, sizeof(info));
11845 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11846 if (!strcmp(res->hash_func, "toeplitz"))
11847 info.info.global_conf.hash_func =
11848 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11849 else if (!strcmp(res->hash_func, "simple_xor"))
11850 info.info.global_conf.hash_func =
11851 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11852 else if (!strcmp(res->hash_func, "default"))
11853 info.info.global_conf.hash_func =
11854 RTE_ETH_HASH_FUNCTION_DEFAULT;
11856 ftype = str2flowtype(res->flow_type);
11857 idx = ftype / UINT64_BIT;
11858 offset = ftype % UINT64_BIT;
11859 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11860 if (!strcmp(res->enable, "enable"))
11861 info.info.global_conf.sym_hash_enable_mask[idx] |=
11863 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11864 RTE_ETH_FILTER_SET, &info);
11866 printf("Cannot set global hash configurations by port %d\n",
11869 printf("Global hash configurations have been set "
11870 "succcessfully by port %d\n", res->port_id);
11873 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11874 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11875 set_hash_global_config, "set_hash_global_config");
11876 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11877 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11879 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11880 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11881 hash_func, "toeplitz#simple_xor#default");
11882 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11883 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11885 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11886 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11887 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11888 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11889 enable, "enable#disable");
11891 cmdline_parse_inst_t cmd_set_hash_global_config = {
11892 .f = cmd_set_hash_global_config_parsed,
11894 .help_str = "set_hash_global_config <port_id> "
11895 "toeplitz|simple_xor|default "
11896 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11897 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11898 "l2_payload enable|disable",
11900 (void *)&cmd_set_hash_global_config_all,
11901 (void *)&cmd_set_hash_global_config_port_id,
11902 (void *)&cmd_set_hash_global_config_hash_func,
11903 (void *)&cmd_set_hash_global_config_flow_type,
11904 (void *)&cmd_set_hash_global_config_enable,
11909 /* Set hash input set */
11910 struct cmd_set_hash_input_set_result {
11911 cmdline_fixed_string_t set_hash_input_set;
11913 cmdline_fixed_string_t flow_type;
11914 cmdline_fixed_string_t inset_field;
11915 cmdline_fixed_string_t select;
11918 static enum rte_eth_input_set_field
11919 str2inset(char *string)
11923 static const struct {
11925 enum rte_eth_input_set_field inset;
11926 } inset_table[] = {
11927 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11928 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11929 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11930 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11931 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11932 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11933 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11934 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11935 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11936 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11937 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11938 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11939 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11940 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11941 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11942 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11943 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11944 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11945 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11946 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11947 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11948 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11949 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11950 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11951 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11952 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11953 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11954 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11955 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11956 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11957 {"none", RTE_ETH_INPUT_SET_NONE},
11960 for (i = 0; i < RTE_DIM(inset_table); i++) {
11961 if (!strcmp(string, inset_table[i].str))
11962 return inset_table[i].inset;
11965 return RTE_ETH_INPUT_SET_UNKNOWN;
11969 cmd_set_hash_input_set_parsed(void *parsed_result,
11970 __rte_unused struct cmdline *cl,
11971 __rte_unused void *data)
11973 struct cmd_set_hash_input_set_result *res = parsed_result;
11974 struct rte_eth_hash_filter_info info;
11976 memset(&info, 0, sizeof(info));
11977 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11978 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11979 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11980 info.info.input_set_conf.inset_size = 1;
11981 if (!strcmp(res->select, "select"))
11982 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11983 else if (!strcmp(res->select, "add"))
11984 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11985 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11986 RTE_ETH_FILTER_SET, &info);
11989 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11990 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11991 set_hash_input_set, "set_hash_input_set");
11992 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11993 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11995 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11996 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11998 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11999 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12001 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12002 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12003 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12004 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12005 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12007 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12008 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12009 select, "select#add");
12011 cmdline_parse_inst_t cmd_set_hash_input_set = {
12012 .f = cmd_set_hash_input_set_parsed,
12014 .help_str = "set_hash_input_set <port_id> "
12015 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12016 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12017 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12018 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12019 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12020 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12021 "fld-7th|fld-8th|none select|add",
12023 (void *)&cmd_set_hash_input_set_cmd,
12024 (void *)&cmd_set_hash_input_set_port_id,
12025 (void *)&cmd_set_hash_input_set_flow_type,
12026 (void *)&cmd_set_hash_input_set_field,
12027 (void *)&cmd_set_hash_input_set_select,
12032 /* Set flow director input set */
12033 struct cmd_set_fdir_input_set_result {
12034 cmdline_fixed_string_t set_fdir_input_set;
12036 cmdline_fixed_string_t flow_type;
12037 cmdline_fixed_string_t inset_field;
12038 cmdline_fixed_string_t select;
12042 cmd_set_fdir_input_set_parsed(void *parsed_result,
12043 __rte_unused struct cmdline *cl,
12044 __rte_unused void *data)
12046 struct cmd_set_fdir_input_set_result *res = parsed_result;
12047 struct rte_eth_fdir_filter_info info;
12049 memset(&info, 0, sizeof(info));
12050 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12051 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12052 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12053 info.info.input_set_conf.inset_size = 1;
12054 if (!strcmp(res->select, "select"))
12055 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12056 else if (!strcmp(res->select, "add"))
12057 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12058 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12059 RTE_ETH_FILTER_SET, &info);
12062 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12063 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12064 set_fdir_input_set, "set_fdir_input_set");
12065 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12066 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12068 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12069 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12071 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12072 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12073 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12074 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12076 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12077 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12078 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12079 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12080 "sctp-veri-tag#none");
12081 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12082 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12083 select, "select#add");
12085 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12086 .f = cmd_set_fdir_input_set_parsed,
12088 .help_str = "set_fdir_input_set <port_id> "
12089 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12090 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12091 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12092 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12093 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12094 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12095 "sctp-veri-tag|none select|add",
12097 (void *)&cmd_set_fdir_input_set_cmd,
12098 (void *)&cmd_set_fdir_input_set_port_id,
12099 (void *)&cmd_set_fdir_input_set_flow_type,
12100 (void *)&cmd_set_fdir_input_set_field,
12101 (void *)&cmd_set_fdir_input_set_select,
12106 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12107 struct cmd_mcast_addr_result {
12108 cmdline_fixed_string_t mcast_addr_cmd;
12109 cmdline_fixed_string_t what;
12111 struct ether_addr mc_addr;
12114 static void cmd_mcast_addr_parsed(void *parsed_result,
12115 __attribute__((unused)) struct cmdline *cl,
12116 __attribute__((unused)) void *data)
12118 struct cmd_mcast_addr_result *res = parsed_result;
12120 if (!is_multicast_ether_addr(&res->mc_addr)) {
12121 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12122 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12123 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12124 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12127 if (strcmp(res->what, "add") == 0)
12128 mcast_addr_add(res->port_num, &res->mc_addr);
12130 mcast_addr_remove(res->port_num, &res->mc_addr);
12133 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12134 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12135 mcast_addr_cmd, "mcast_addr");
12136 cmdline_parse_token_string_t cmd_mcast_addr_what =
12137 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12139 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12140 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12141 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12142 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12144 cmdline_parse_inst_t cmd_mcast_addr = {
12145 .f = cmd_mcast_addr_parsed,
12147 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12148 "Add/Remove multicast MAC address on port_id",
12150 (void *)&cmd_mcast_addr_cmd,
12151 (void *)&cmd_mcast_addr_what,
12152 (void *)&cmd_mcast_addr_portnum,
12153 (void *)&cmd_mcast_addr_addr,
12158 /* l2 tunnel config
12159 * only support E-tag now.
12162 /* Ether type config */
12163 struct cmd_config_l2_tunnel_eth_type_result {
12164 cmdline_fixed_string_t port;
12165 cmdline_fixed_string_t config;
12166 cmdline_fixed_string_t all;
12168 cmdline_fixed_string_t l2_tunnel;
12169 cmdline_fixed_string_t l2_tunnel_type;
12170 cmdline_fixed_string_t eth_type;
12171 uint16_t eth_type_val;
12174 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12175 TOKEN_STRING_INITIALIZER
12176 (struct cmd_config_l2_tunnel_eth_type_result,
12178 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12179 TOKEN_STRING_INITIALIZER
12180 (struct cmd_config_l2_tunnel_eth_type_result,
12182 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12183 TOKEN_STRING_INITIALIZER
12184 (struct cmd_config_l2_tunnel_eth_type_result,
12186 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12187 TOKEN_NUM_INITIALIZER
12188 (struct cmd_config_l2_tunnel_eth_type_result,
12190 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12191 TOKEN_STRING_INITIALIZER
12192 (struct cmd_config_l2_tunnel_eth_type_result,
12193 l2_tunnel, "l2-tunnel");
12194 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12195 TOKEN_STRING_INITIALIZER
12196 (struct cmd_config_l2_tunnel_eth_type_result,
12197 l2_tunnel_type, "E-tag");
12198 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12199 TOKEN_STRING_INITIALIZER
12200 (struct cmd_config_l2_tunnel_eth_type_result,
12201 eth_type, "ether-type");
12202 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12203 TOKEN_NUM_INITIALIZER
12204 (struct cmd_config_l2_tunnel_eth_type_result,
12205 eth_type_val, UINT16);
12207 static enum rte_eth_tunnel_type
12208 str2fdir_l2_tunnel_type(char *string)
12212 static const struct {
12214 enum rte_eth_tunnel_type type;
12215 } l2_tunnel_type_str[] = {
12216 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12219 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12220 if (!strcmp(l2_tunnel_type_str[i].str, string))
12221 return l2_tunnel_type_str[i].type;
12223 return RTE_TUNNEL_TYPE_NONE;
12226 /* ether type config for all ports */
12228 cmd_config_l2_tunnel_eth_type_all_parsed
12229 (void *parsed_result,
12230 __attribute__((unused)) struct cmdline *cl,
12231 __attribute__((unused)) void *data)
12233 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12234 struct rte_eth_l2_tunnel_conf entry;
12237 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12238 entry.ether_type = res->eth_type_val;
12240 RTE_ETH_FOREACH_DEV(pid) {
12241 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12245 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12246 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12248 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12250 (void *)&cmd_config_l2_tunnel_eth_type_port,
12251 (void *)&cmd_config_l2_tunnel_eth_type_config,
12252 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12253 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12254 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12255 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12256 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12261 /* ether type config for a specific port */
12263 cmd_config_l2_tunnel_eth_type_specific_parsed(
12264 void *parsed_result,
12265 __attribute__((unused)) struct cmdline *cl,
12266 __attribute__((unused)) void *data)
12268 struct cmd_config_l2_tunnel_eth_type_result *res =
12270 struct rte_eth_l2_tunnel_conf entry;
12272 if (port_id_is_invalid(res->id, ENABLED_WARN))
12275 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12276 entry.ether_type = res->eth_type_val;
12278 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12281 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12282 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12284 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12286 (void *)&cmd_config_l2_tunnel_eth_type_port,
12287 (void *)&cmd_config_l2_tunnel_eth_type_config,
12288 (void *)&cmd_config_l2_tunnel_eth_type_id,
12289 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12290 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12291 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12292 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12297 /* Enable/disable l2 tunnel */
12298 struct cmd_config_l2_tunnel_en_dis_result {
12299 cmdline_fixed_string_t port;
12300 cmdline_fixed_string_t config;
12301 cmdline_fixed_string_t all;
12303 cmdline_fixed_string_t l2_tunnel;
12304 cmdline_fixed_string_t l2_tunnel_type;
12305 cmdline_fixed_string_t en_dis;
12308 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12309 TOKEN_STRING_INITIALIZER
12310 (struct cmd_config_l2_tunnel_en_dis_result,
12312 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12313 TOKEN_STRING_INITIALIZER
12314 (struct cmd_config_l2_tunnel_en_dis_result,
12316 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12317 TOKEN_STRING_INITIALIZER
12318 (struct cmd_config_l2_tunnel_en_dis_result,
12320 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12321 TOKEN_NUM_INITIALIZER
12322 (struct cmd_config_l2_tunnel_en_dis_result,
12324 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12325 TOKEN_STRING_INITIALIZER
12326 (struct cmd_config_l2_tunnel_en_dis_result,
12327 l2_tunnel, "l2-tunnel");
12328 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12329 TOKEN_STRING_INITIALIZER
12330 (struct cmd_config_l2_tunnel_en_dis_result,
12331 l2_tunnel_type, "E-tag");
12332 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12333 TOKEN_STRING_INITIALIZER
12334 (struct cmd_config_l2_tunnel_en_dis_result,
12335 en_dis, "enable#disable");
12337 /* enable/disable l2 tunnel for all ports */
12339 cmd_config_l2_tunnel_en_dis_all_parsed(
12340 void *parsed_result,
12341 __attribute__((unused)) struct cmdline *cl,
12342 __attribute__((unused)) void *data)
12344 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12345 struct rte_eth_l2_tunnel_conf entry;
12349 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12351 if (!strcmp("enable", res->en_dis))
12356 RTE_ETH_FOREACH_DEV(pid) {
12357 rte_eth_dev_l2_tunnel_offload_set(pid,
12359 ETH_L2_TUNNEL_ENABLE_MASK,
12364 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12365 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12367 .help_str = "port config all l2-tunnel E-tag enable|disable",
12369 (void *)&cmd_config_l2_tunnel_en_dis_port,
12370 (void *)&cmd_config_l2_tunnel_en_dis_config,
12371 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12372 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12373 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12374 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12379 /* enable/disable l2 tunnel for a port */
12381 cmd_config_l2_tunnel_en_dis_specific_parsed(
12382 void *parsed_result,
12383 __attribute__((unused)) struct cmdline *cl,
12384 __attribute__((unused)) void *data)
12386 struct cmd_config_l2_tunnel_en_dis_result *res =
12388 struct rte_eth_l2_tunnel_conf entry;
12390 if (port_id_is_invalid(res->id, ENABLED_WARN))
12393 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12395 if (!strcmp("enable", res->en_dis))
12396 rte_eth_dev_l2_tunnel_offload_set(res->id,
12398 ETH_L2_TUNNEL_ENABLE_MASK,
12401 rte_eth_dev_l2_tunnel_offload_set(res->id,
12403 ETH_L2_TUNNEL_ENABLE_MASK,
12407 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12408 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12410 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12412 (void *)&cmd_config_l2_tunnel_en_dis_port,
12413 (void *)&cmd_config_l2_tunnel_en_dis_config,
12414 (void *)&cmd_config_l2_tunnel_en_dis_id,
12415 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12416 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12417 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12422 /* E-tag configuration */
12424 /* Common result structure for all E-tag configuration */
12425 struct cmd_config_e_tag_result {
12426 cmdline_fixed_string_t e_tag;
12427 cmdline_fixed_string_t set;
12428 cmdline_fixed_string_t insertion;
12429 cmdline_fixed_string_t stripping;
12430 cmdline_fixed_string_t forwarding;
12431 cmdline_fixed_string_t filter;
12432 cmdline_fixed_string_t add;
12433 cmdline_fixed_string_t del;
12434 cmdline_fixed_string_t on;
12435 cmdline_fixed_string_t off;
12436 cmdline_fixed_string_t on_off;
12437 cmdline_fixed_string_t port_tag_id;
12438 uint32_t port_tag_id_val;
12439 cmdline_fixed_string_t e_tag_id;
12440 uint16_t e_tag_id_val;
12441 cmdline_fixed_string_t dst_pool;
12442 uint8_t dst_pool_val;
12443 cmdline_fixed_string_t port;
12445 cmdline_fixed_string_t vf;
12449 /* Common CLI fields for all E-tag configuration */
12450 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12451 TOKEN_STRING_INITIALIZER
12452 (struct cmd_config_e_tag_result,
12454 cmdline_parse_token_string_t cmd_config_e_tag_set =
12455 TOKEN_STRING_INITIALIZER
12456 (struct cmd_config_e_tag_result,
12458 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12459 TOKEN_STRING_INITIALIZER
12460 (struct cmd_config_e_tag_result,
12461 insertion, "insertion");
12462 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12463 TOKEN_STRING_INITIALIZER
12464 (struct cmd_config_e_tag_result,
12465 stripping, "stripping");
12466 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12467 TOKEN_STRING_INITIALIZER
12468 (struct cmd_config_e_tag_result,
12469 forwarding, "forwarding");
12470 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12471 TOKEN_STRING_INITIALIZER
12472 (struct cmd_config_e_tag_result,
12474 cmdline_parse_token_string_t cmd_config_e_tag_add =
12475 TOKEN_STRING_INITIALIZER
12476 (struct cmd_config_e_tag_result,
12478 cmdline_parse_token_string_t cmd_config_e_tag_del =
12479 TOKEN_STRING_INITIALIZER
12480 (struct cmd_config_e_tag_result,
12482 cmdline_parse_token_string_t cmd_config_e_tag_on =
12483 TOKEN_STRING_INITIALIZER
12484 (struct cmd_config_e_tag_result,
12486 cmdline_parse_token_string_t cmd_config_e_tag_off =
12487 TOKEN_STRING_INITIALIZER
12488 (struct cmd_config_e_tag_result,
12490 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12491 TOKEN_STRING_INITIALIZER
12492 (struct cmd_config_e_tag_result,
12494 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12495 TOKEN_STRING_INITIALIZER
12496 (struct cmd_config_e_tag_result,
12497 port_tag_id, "port-tag-id");
12498 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12499 TOKEN_NUM_INITIALIZER
12500 (struct cmd_config_e_tag_result,
12501 port_tag_id_val, UINT32);
12502 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12503 TOKEN_STRING_INITIALIZER
12504 (struct cmd_config_e_tag_result,
12505 e_tag_id, "e-tag-id");
12506 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12507 TOKEN_NUM_INITIALIZER
12508 (struct cmd_config_e_tag_result,
12509 e_tag_id_val, UINT16);
12510 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12511 TOKEN_STRING_INITIALIZER
12512 (struct cmd_config_e_tag_result,
12513 dst_pool, "dst-pool");
12514 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12515 TOKEN_NUM_INITIALIZER
12516 (struct cmd_config_e_tag_result,
12517 dst_pool_val, UINT8);
12518 cmdline_parse_token_string_t cmd_config_e_tag_port =
12519 TOKEN_STRING_INITIALIZER
12520 (struct cmd_config_e_tag_result,
12522 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12523 TOKEN_NUM_INITIALIZER
12524 (struct cmd_config_e_tag_result,
12526 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12527 TOKEN_STRING_INITIALIZER
12528 (struct cmd_config_e_tag_result,
12530 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12531 TOKEN_NUM_INITIALIZER
12532 (struct cmd_config_e_tag_result,
12535 /* E-tag insertion configuration */
12537 cmd_config_e_tag_insertion_en_parsed(
12538 void *parsed_result,
12539 __attribute__((unused)) struct cmdline *cl,
12540 __attribute__((unused)) void *data)
12542 struct cmd_config_e_tag_result *res =
12544 struct rte_eth_l2_tunnel_conf entry;
12546 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12549 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12550 entry.tunnel_id = res->port_tag_id_val;
12551 entry.vf_id = res->vf_id;
12552 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12554 ETH_L2_TUNNEL_INSERTION_MASK,
12559 cmd_config_e_tag_insertion_dis_parsed(
12560 void *parsed_result,
12561 __attribute__((unused)) struct cmdline *cl,
12562 __attribute__((unused)) void *data)
12564 struct cmd_config_e_tag_result *res =
12566 struct rte_eth_l2_tunnel_conf entry;
12568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12571 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12572 entry.vf_id = res->vf_id;
12574 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12576 ETH_L2_TUNNEL_INSERTION_MASK,
12580 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12581 .f = cmd_config_e_tag_insertion_en_parsed,
12583 .help_str = "E-tag ... : E-tag insertion enable",
12585 (void *)&cmd_config_e_tag_e_tag,
12586 (void *)&cmd_config_e_tag_set,
12587 (void *)&cmd_config_e_tag_insertion,
12588 (void *)&cmd_config_e_tag_on,
12589 (void *)&cmd_config_e_tag_port_tag_id,
12590 (void *)&cmd_config_e_tag_port_tag_id_val,
12591 (void *)&cmd_config_e_tag_port,
12592 (void *)&cmd_config_e_tag_port_id,
12593 (void *)&cmd_config_e_tag_vf,
12594 (void *)&cmd_config_e_tag_vf_id,
12599 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12600 .f = cmd_config_e_tag_insertion_dis_parsed,
12602 .help_str = "E-tag ... : E-tag insertion disable",
12604 (void *)&cmd_config_e_tag_e_tag,
12605 (void *)&cmd_config_e_tag_set,
12606 (void *)&cmd_config_e_tag_insertion,
12607 (void *)&cmd_config_e_tag_off,
12608 (void *)&cmd_config_e_tag_port,
12609 (void *)&cmd_config_e_tag_port_id,
12610 (void *)&cmd_config_e_tag_vf,
12611 (void *)&cmd_config_e_tag_vf_id,
12616 /* E-tag stripping configuration */
12618 cmd_config_e_tag_stripping_parsed(
12619 void *parsed_result,
12620 __attribute__((unused)) struct cmdline *cl,
12621 __attribute__((unused)) void *data)
12623 struct cmd_config_e_tag_result *res =
12625 struct rte_eth_l2_tunnel_conf entry;
12627 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12630 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12632 if (!strcmp(res->on_off, "on"))
12633 rte_eth_dev_l2_tunnel_offload_set
12636 ETH_L2_TUNNEL_STRIPPING_MASK,
12639 rte_eth_dev_l2_tunnel_offload_set
12642 ETH_L2_TUNNEL_STRIPPING_MASK,
12646 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12647 .f = cmd_config_e_tag_stripping_parsed,
12649 .help_str = "E-tag ... : E-tag stripping enable/disable",
12651 (void *)&cmd_config_e_tag_e_tag,
12652 (void *)&cmd_config_e_tag_set,
12653 (void *)&cmd_config_e_tag_stripping,
12654 (void *)&cmd_config_e_tag_on_off,
12655 (void *)&cmd_config_e_tag_port,
12656 (void *)&cmd_config_e_tag_port_id,
12661 /* E-tag forwarding configuration */
12663 cmd_config_e_tag_forwarding_parsed(
12664 void *parsed_result,
12665 __attribute__((unused)) struct cmdline *cl,
12666 __attribute__((unused)) void *data)
12668 struct cmd_config_e_tag_result *res = parsed_result;
12669 struct rte_eth_l2_tunnel_conf entry;
12671 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12674 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12676 if (!strcmp(res->on_off, "on"))
12677 rte_eth_dev_l2_tunnel_offload_set
12680 ETH_L2_TUNNEL_FORWARDING_MASK,
12683 rte_eth_dev_l2_tunnel_offload_set
12686 ETH_L2_TUNNEL_FORWARDING_MASK,
12690 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12691 .f = cmd_config_e_tag_forwarding_parsed,
12693 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12695 (void *)&cmd_config_e_tag_e_tag,
12696 (void *)&cmd_config_e_tag_set,
12697 (void *)&cmd_config_e_tag_forwarding,
12698 (void *)&cmd_config_e_tag_on_off,
12699 (void *)&cmd_config_e_tag_port,
12700 (void *)&cmd_config_e_tag_port_id,
12705 /* E-tag filter configuration */
12707 cmd_config_e_tag_filter_add_parsed(
12708 void *parsed_result,
12709 __attribute__((unused)) struct cmdline *cl,
12710 __attribute__((unused)) void *data)
12712 struct cmd_config_e_tag_result *res = parsed_result;
12713 struct rte_eth_l2_tunnel_conf entry;
12716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12719 if (res->e_tag_id_val > 0x3fff) {
12720 printf("e-tag-id must be equal or less than 0x3fff.\n");
12724 ret = rte_eth_dev_filter_supported(res->port_id,
12725 RTE_ETH_FILTER_L2_TUNNEL);
12727 printf("E-tag filter is not supported on port %u.\n",
12732 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12733 entry.tunnel_id = res->e_tag_id_val;
12734 entry.pool = res->dst_pool_val;
12736 ret = rte_eth_dev_filter_ctrl(res->port_id,
12737 RTE_ETH_FILTER_L2_TUNNEL,
12738 RTE_ETH_FILTER_ADD,
12741 printf("E-tag filter programming error: (%s)\n",
12745 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12746 .f = cmd_config_e_tag_filter_add_parsed,
12748 .help_str = "E-tag ... : E-tag filter add",
12750 (void *)&cmd_config_e_tag_e_tag,
12751 (void *)&cmd_config_e_tag_set,
12752 (void *)&cmd_config_e_tag_filter,
12753 (void *)&cmd_config_e_tag_add,
12754 (void *)&cmd_config_e_tag_e_tag_id,
12755 (void *)&cmd_config_e_tag_e_tag_id_val,
12756 (void *)&cmd_config_e_tag_dst_pool,
12757 (void *)&cmd_config_e_tag_dst_pool_val,
12758 (void *)&cmd_config_e_tag_port,
12759 (void *)&cmd_config_e_tag_port_id,
12765 cmd_config_e_tag_filter_del_parsed(
12766 void *parsed_result,
12767 __attribute__((unused)) struct cmdline *cl,
12768 __attribute__((unused)) void *data)
12770 struct cmd_config_e_tag_result *res = parsed_result;
12771 struct rte_eth_l2_tunnel_conf entry;
12774 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12777 if (res->e_tag_id_val > 0x3fff) {
12778 printf("e-tag-id must be less than 0x3fff.\n");
12782 ret = rte_eth_dev_filter_supported(res->port_id,
12783 RTE_ETH_FILTER_L2_TUNNEL);
12785 printf("E-tag filter is not supported on port %u.\n",
12790 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12791 entry.tunnel_id = res->e_tag_id_val;
12793 ret = rte_eth_dev_filter_ctrl(res->port_id,
12794 RTE_ETH_FILTER_L2_TUNNEL,
12795 RTE_ETH_FILTER_DELETE,
12798 printf("E-tag filter programming error: (%s)\n",
12802 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12803 .f = cmd_config_e_tag_filter_del_parsed,
12805 .help_str = "E-tag ... : E-tag filter delete",
12807 (void *)&cmd_config_e_tag_e_tag,
12808 (void *)&cmd_config_e_tag_set,
12809 (void *)&cmd_config_e_tag_filter,
12810 (void *)&cmd_config_e_tag_del,
12811 (void *)&cmd_config_e_tag_e_tag_id,
12812 (void *)&cmd_config_e_tag_e_tag_id_val,
12813 (void *)&cmd_config_e_tag_port,
12814 (void *)&cmd_config_e_tag_port_id,
12819 /* vf vlan anti spoof configuration */
12821 /* Common result structure for vf vlan anti spoof */
12822 struct cmd_vf_vlan_anti_spoof_result {
12823 cmdline_fixed_string_t set;
12824 cmdline_fixed_string_t vf;
12825 cmdline_fixed_string_t vlan;
12826 cmdline_fixed_string_t antispoof;
12829 cmdline_fixed_string_t on_off;
12832 /* Common CLI fields for vf vlan anti spoof enable disable */
12833 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12834 TOKEN_STRING_INITIALIZER
12835 (struct cmd_vf_vlan_anti_spoof_result,
12837 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12838 TOKEN_STRING_INITIALIZER
12839 (struct cmd_vf_vlan_anti_spoof_result,
12841 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12842 TOKEN_STRING_INITIALIZER
12843 (struct cmd_vf_vlan_anti_spoof_result,
12845 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12846 TOKEN_STRING_INITIALIZER
12847 (struct cmd_vf_vlan_anti_spoof_result,
12848 antispoof, "antispoof");
12849 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12850 TOKEN_NUM_INITIALIZER
12851 (struct cmd_vf_vlan_anti_spoof_result,
12853 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12854 TOKEN_NUM_INITIALIZER
12855 (struct cmd_vf_vlan_anti_spoof_result,
12857 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12858 TOKEN_STRING_INITIALIZER
12859 (struct cmd_vf_vlan_anti_spoof_result,
12863 cmd_set_vf_vlan_anti_spoof_parsed(
12864 void *parsed_result,
12865 __attribute__((unused)) struct cmdline *cl,
12866 __attribute__((unused)) void *data)
12868 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12869 int ret = -ENOTSUP;
12871 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12873 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12876 #ifdef RTE_LIBRTE_IXGBE_PMD
12877 if (ret == -ENOTSUP)
12878 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12879 res->vf_id, is_on);
12881 #ifdef RTE_LIBRTE_I40E_PMD
12882 if (ret == -ENOTSUP)
12883 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12884 res->vf_id, is_on);
12886 #ifdef RTE_LIBRTE_BNXT_PMD
12887 if (ret == -ENOTSUP)
12888 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12889 res->vf_id, is_on);
12896 printf("invalid vf_id %d\n", res->vf_id);
12899 printf("invalid port_id %d\n", res->port_id);
12902 printf("function not implemented\n");
12905 printf("programming error: (%s)\n", strerror(-ret));
12909 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12910 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12912 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12914 (void *)&cmd_vf_vlan_anti_spoof_set,
12915 (void *)&cmd_vf_vlan_anti_spoof_vf,
12916 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12917 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12918 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12919 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12920 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12925 /* vf mac anti spoof configuration */
12927 /* Common result structure for vf mac anti spoof */
12928 struct cmd_vf_mac_anti_spoof_result {
12929 cmdline_fixed_string_t set;
12930 cmdline_fixed_string_t vf;
12931 cmdline_fixed_string_t mac;
12932 cmdline_fixed_string_t antispoof;
12935 cmdline_fixed_string_t on_off;
12938 /* Common CLI fields for vf mac anti spoof enable disable */
12939 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12940 TOKEN_STRING_INITIALIZER
12941 (struct cmd_vf_mac_anti_spoof_result,
12943 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12944 TOKEN_STRING_INITIALIZER
12945 (struct cmd_vf_mac_anti_spoof_result,
12947 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12948 TOKEN_STRING_INITIALIZER
12949 (struct cmd_vf_mac_anti_spoof_result,
12951 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12952 TOKEN_STRING_INITIALIZER
12953 (struct cmd_vf_mac_anti_spoof_result,
12954 antispoof, "antispoof");
12955 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12956 TOKEN_NUM_INITIALIZER
12957 (struct cmd_vf_mac_anti_spoof_result,
12959 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12960 TOKEN_NUM_INITIALIZER
12961 (struct cmd_vf_mac_anti_spoof_result,
12963 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12964 TOKEN_STRING_INITIALIZER
12965 (struct cmd_vf_mac_anti_spoof_result,
12969 cmd_set_vf_mac_anti_spoof_parsed(
12970 void *parsed_result,
12971 __attribute__((unused)) struct cmdline *cl,
12972 __attribute__((unused)) void *data)
12974 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12975 int ret = -ENOTSUP;
12977 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12979 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12982 #ifdef RTE_LIBRTE_IXGBE_PMD
12983 if (ret == -ENOTSUP)
12984 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12985 res->vf_id, is_on);
12987 #ifdef RTE_LIBRTE_I40E_PMD
12988 if (ret == -ENOTSUP)
12989 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12990 res->vf_id, is_on);
12992 #ifdef RTE_LIBRTE_BNXT_PMD
12993 if (ret == -ENOTSUP)
12994 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12995 res->vf_id, is_on);
13002 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13005 printf("invalid port_id %d\n", res->port_id);
13008 printf("function not implemented\n");
13011 printf("programming error: (%s)\n", strerror(-ret));
13015 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13016 .f = cmd_set_vf_mac_anti_spoof_parsed,
13018 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13020 (void *)&cmd_vf_mac_anti_spoof_set,
13021 (void *)&cmd_vf_mac_anti_spoof_vf,
13022 (void *)&cmd_vf_mac_anti_spoof_mac,
13023 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13024 (void *)&cmd_vf_mac_anti_spoof_port_id,
13025 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13026 (void *)&cmd_vf_mac_anti_spoof_on_off,
13031 /* vf vlan strip queue configuration */
13033 /* Common result structure for vf mac anti spoof */
13034 struct cmd_vf_vlan_stripq_result {
13035 cmdline_fixed_string_t set;
13036 cmdline_fixed_string_t vf;
13037 cmdline_fixed_string_t vlan;
13038 cmdline_fixed_string_t stripq;
13041 cmdline_fixed_string_t on_off;
13044 /* Common CLI fields for vf vlan strip enable disable */
13045 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13046 TOKEN_STRING_INITIALIZER
13047 (struct cmd_vf_vlan_stripq_result,
13049 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13050 TOKEN_STRING_INITIALIZER
13051 (struct cmd_vf_vlan_stripq_result,
13053 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13054 TOKEN_STRING_INITIALIZER
13055 (struct cmd_vf_vlan_stripq_result,
13057 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13058 TOKEN_STRING_INITIALIZER
13059 (struct cmd_vf_vlan_stripq_result,
13061 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13062 TOKEN_NUM_INITIALIZER
13063 (struct cmd_vf_vlan_stripq_result,
13065 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13066 TOKEN_NUM_INITIALIZER
13067 (struct cmd_vf_vlan_stripq_result,
13069 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13070 TOKEN_STRING_INITIALIZER
13071 (struct cmd_vf_vlan_stripq_result,
13075 cmd_set_vf_vlan_stripq_parsed(
13076 void *parsed_result,
13077 __attribute__((unused)) struct cmdline *cl,
13078 __attribute__((unused)) void *data)
13080 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13081 int ret = -ENOTSUP;
13083 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13085 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13088 #ifdef RTE_LIBRTE_IXGBE_PMD
13089 if (ret == -ENOTSUP)
13090 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13091 res->vf_id, is_on);
13093 #ifdef RTE_LIBRTE_I40E_PMD
13094 if (ret == -ENOTSUP)
13095 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13096 res->vf_id, is_on);
13098 #ifdef RTE_LIBRTE_BNXT_PMD
13099 if (ret == -ENOTSUP)
13100 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13101 res->vf_id, is_on);
13108 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13111 printf("invalid port_id %d\n", res->port_id);
13114 printf("function not implemented\n");
13117 printf("programming error: (%s)\n", strerror(-ret));
13121 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13122 .f = cmd_set_vf_vlan_stripq_parsed,
13124 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13126 (void *)&cmd_vf_vlan_stripq_set,
13127 (void *)&cmd_vf_vlan_stripq_vf,
13128 (void *)&cmd_vf_vlan_stripq_vlan,
13129 (void *)&cmd_vf_vlan_stripq_stripq,
13130 (void *)&cmd_vf_vlan_stripq_port_id,
13131 (void *)&cmd_vf_vlan_stripq_vf_id,
13132 (void *)&cmd_vf_vlan_stripq_on_off,
13137 /* vf vlan insert configuration */
13139 /* Common result structure for vf vlan insert */
13140 struct cmd_vf_vlan_insert_result {
13141 cmdline_fixed_string_t set;
13142 cmdline_fixed_string_t vf;
13143 cmdline_fixed_string_t vlan;
13144 cmdline_fixed_string_t insert;
13150 /* Common CLI fields for vf vlan insert enable disable */
13151 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13152 TOKEN_STRING_INITIALIZER
13153 (struct cmd_vf_vlan_insert_result,
13155 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13156 TOKEN_STRING_INITIALIZER
13157 (struct cmd_vf_vlan_insert_result,
13159 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13160 TOKEN_STRING_INITIALIZER
13161 (struct cmd_vf_vlan_insert_result,
13163 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13164 TOKEN_STRING_INITIALIZER
13165 (struct cmd_vf_vlan_insert_result,
13167 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13168 TOKEN_NUM_INITIALIZER
13169 (struct cmd_vf_vlan_insert_result,
13171 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13172 TOKEN_NUM_INITIALIZER
13173 (struct cmd_vf_vlan_insert_result,
13175 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13176 TOKEN_NUM_INITIALIZER
13177 (struct cmd_vf_vlan_insert_result,
13181 cmd_set_vf_vlan_insert_parsed(
13182 void *parsed_result,
13183 __attribute__((unused)) struct cmdline *cl,
13184 __attribute__((unused)) void *data)
13186 struct cmd_vf_vlan_insert_result *res = parsed_result;
13187 int ret = -ENOTSUP;
13189 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13192 #ifdef RTE_LIBRTE_IXGBE_PMD
13193 if (ret == -ENOTSUP)
13194 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13197 #ifdef RTE_LIBRTE_I40E_PMD
13198 if (ret == -ENOTSUP)
13199 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13202 #ifdef RTE_LIBRTE_BNXT_PMD
13203 if (ret == -ENOTSUP)
13204 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13212 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
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_vf_vlan_insert = {
13226 .f = cmd_set_vf_vlan_insert_parsed,
13228 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13230 (void *)&cmd_vf_vlan_insert_set,
13231 (void *)&cmd_vf_vlan_insert_vf,
13232 (void *)&cmd_vf_vlan_insert_vlan,
13233 (void *)&cmd_vf_vlan_insert_insert,
13234 (void *)&cmd_vf_vlan_insert_port_id,
13235 (void *)&cmd_vf_vlan_insert_vf_id,
13236 (void *)&cmd_vf_vlan_insert_vlan_id,
13241 /* tx loopback configuration */
13243 /* Common result structure for tx loopback */
13244 struct cmd_tx_loopback_result {
13245 cmdline_fixed_string_t set;
13246 cmdline_fixed_string_t tx;
13247 cmdline_fixed_string_t loopback;
13249 cmdline_fixed_string_t on_off;
13252 /* Common CLI fields for tx loopback enable disable */
13253 cmdline_parse_token_string_t cmd_tx_loopback_set =
13254 TOKEN_STRING_INITIALIZER
13255 (struct cmd_tx_loopback_result,
13257 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13258 TOKEN_STRING_INITIALIZER
13259 (struct cmd_tx_loopback_result,
13261 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13262 TOKEN_STRING_INITIALIZER
13263 (struct cmd_tx_loopback_result,
13264 loopback, "loopback");
13265 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13266 TOKEN_NUM_INITIALIZER
13267 (struct cmd_tx_loopback_result,
13269 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13270 TOKEN_STRING_INITIALIZER
13271 (struct cmd_tx_loopback_result,
13275 cmd_set_tx_loopback_parsed(
13276 void *parsed_result,
13277 __attribute__((unused)) struct cmdline *cl,
13278 __attribute__((unused)) void *data)
13280 struct cmd_tx_loopback_result *res = parsed_result;
13281 int ret = -ENOTSUP;
13283 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13285 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13288 #ifdef RTE_LIBRTE_IXGBE_PMD
13289 if (ret == -ENOTSUP)
13290 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13292 #ifdef RTE_LIBRTE_I40E_PMD
13293 if (ret == -ENOTSUP)
13294 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13296 #ifdef RTE_LIBRTE_BNXT_PMD
13297 if (ret == -ENOTSUP)
13298 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13300 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13301 if (ret == -ENOTSUP)
13302 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13309 printf("invalid is_on %d\n", is_on);
13312 printf("invalid port_id %d\n", res->port_id);
13315 printf("function not implemented\n");
13318 printf("programming error: (%s)\n", strerror(-ret));
13322 cmdline_parse_inst_t cmd_set_tx_loopback = {
13323 .f = cmd_set_tx_loopback_parsed,
13325 .help_str = "set tx loopback <port_id> on|off",
13327 (void *)&cmd_tx_loopback_set,
13328 (void *)&cmd_tx_loopback_tx,
13329 (void *)&cmd_tx_loopback_loopback,
13330 (void *)&cmd_tx_loopback_port_id,
13331 (void *)&cmd_tx_loopback_on_off,
13336 /* all queues drop enable configuration */
13338 /* Common result structure for all queues drop enable */
13339 struct cmd_all_queues_drop_en_result {
13340 cmdline_fixed_string_t set;
13341 cmdline_fixed_string_t all;
13342 cmdline_fixed_string_t queues;
13343 cmdline_fixed_string_t drop;
13345 cmdline_fixed_string_t on_off;
13348 /* Common CLI fields for tx loopback enable disable */
13349 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13350 TOKEN_STRING_INITIALIZER
13351 (struct cmd_all_queues_drop_en_result,
13353 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13354 TOKEN_STRING_INITIALIZER
13355 (struct cmd_all_queues_drop_en_result,
13357 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13358 TOKEN_STRING_INITIALIZER
13359 (struct cmd_all_queues_drop_en_result,
13361 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13362 TOKEN_STRING_INITIALIZER
13363 (struct cmd_all_queues_drop_en_result,
13365 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13366 TOKEN_NUM_INITIALIZER
13367 (struct cmd_all_queues_drop_en_result,
13369 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13370 TOKEN_STRING_INITIALIZER
13371 (struct cmd_all_queues_drop_en_result,
13375 cmd_set_all_queues_drop_en_parsed(
13376 void *parsed_result,
13377 __attribute__((unused)) struct cmdline *cl,
13378 __attribute__((unused)) void *data)
13380 struct cmd_all_queues_drop_en_result *res = parsed_result;
13381 int ret = -ENOTSUP;
13382 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13384 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13387 #ifdef RTE_LIBRTE_IXGBE_PMD
13388 if (ret == -ENOTSUP)
13389 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13391 #ifdef RTE_LIBRTE_BNXT_PMD
13392 if (ret == -ENOTSUP)
13393 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13399 printf("invalid is_on %d\n", is_on);
13402 printf("invalid port_id %d\n", res->port_id);
13405 printf("function not implemented\n");
13408 printf("programming error: (%s)\n", strerror(-ret));
13412 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13413 .f = cmd_set_all_queues_drop_en_parsed,
13415 .help_str = "set all queues drop <port_id> on|off",
13417 (void *)&cmd_all_queues_drop_en_set,
13418 (void *)&cmd_all_queues_drop_en_all,
13419 (void *)&cmd_all_queues_drop_en_queues,
13420 (void *)&cmd_all_queues_drop_en_drop,
13421 (void *)&cmd_all_queues_drop_en_port_id,
13422 (void *)&cmd_all_queues_drop_en_on_off,
13427 /* vf split drop enable configuration */
13429 /* Common result structure for vf split drop enable */
13430 struct cmd_vf_split_drop_en_result {
13431 cmdline_fixed_string_t set;
13432 cmdline_fixed_string_t vf;
13433 cmdline_fixed_string_t split;
13434 cmdline_fixed_string_t drop;
13437 cmdline_fixed_string_t on_off;
13440 /* Common CLI fields for vf split drop enable disable */
13441 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13442 TOKEN_STRING_INITIALIZER
13443 (struct cmd_vf_split_drop_en_result,
13445 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13446 TOKEN_STRING_INITIALIZER
13447 (struct cmd_vf_split_drop_en_result,
13449 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13450 TOKEN_STRING_INITIALIZER
13451 (struct cmd_vf_split_drop_en_result,
13453 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13454 TOKEN_STRING_INITIALIZER
13455 (struct cmd_vf_split_drop_en_result,
13457 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13458 TOKEN_NUM_INITIALIZER
13459 (struct cmd_vf_split_drop_en_result,
13461 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13462 TOKEN_NUM_INITIALIZER
13463 (struct cmd_vf_split_drop_en_result,
13465 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13466 TOKEN_STRING_INITIALIZER
13467 (struct cmd_vf_split_drop_en_result,
13471 cmd_set_vf_split_drop_en_parsed(
13472 void *parsed_result,
13473 __attribute__((unused)) struct cmdline *cl,
13474 __attribute__((unused)) void *data)
13476 struct cmd_vf_split_drop_en_result *res = parsed_result;
13477 int ret = -ENOTSUP;
13478 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13480 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13483 #ifdef RTE_LIBRTE_IXGBE_PMD
13484 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13491 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13494 printf("invalid port_id %d\n", res->port_id);
13497 printf("not supported on port %d\n", res->port_id);
13500 printf("programming error: (%s)\n", strerror(-ret));
13504 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13505 .f = cmd_set_vf_split_drop_en_parsed,
13507 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13509 (void *)&cmd_vf_split_drop_en_set,
13510 (void *)&cmd_vf_split_drop_en_vf,
13511 (void *)&cmd_vf_split_drop_en_split,
13512 (void *)&cmd_vf_split_drop_en_drop,
13513 (void *)&cmd_vf_split_drop_en_port_id,
13514 (void *)&cmd_vf_split_drop_en_vf_id,
13515 (void *)&cmd_vf_split_drop_en_on_off,
13520 /* vf mac address configuration */
13522 /* Common result structure for vf mac address */
13523 struct cmd_set_vf_mac_addr_result {
13524 cmdline_fixed_string_t set;
13525 cmdline_fixed_string_t vf;
13526 cmdline_fixed_string_t mac;
13527 cmdline_fixed_string_t addr;
13530 struct ether_addr mac_addr;
13534 /* Common CLI fields for vf split drop enable disable */
13535 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13536 TOKEN_STRING_INITIALIZER
13537 (struct cmd_set_vf_mac_addr_result,
13539 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13540 TOKEN_STRING_INITIALIZER
13541 (struct cmd_set_vf_mac_addr_result,
13543 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13544 TOKEN_STRING_INITIALIZER
13545 (struct cmd_set_vf_mac_addr_result,
13547 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13548 TOKEN_STRING_INITIALIZER
13549 (struct cmd_set_vf_mac_addr_result,
13551 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13552 TOKEN_NUM_INITIALIZER
13553 (struct cmd_set_vf_mac_addr_result,
13555 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13556 TOKEN_NUM_INITIALIZER
13557 (struct cmd_set_vf_mac_addr_result,
13559 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13560 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13564 cmd_set_vf_mac_addr_parsed(
13565 void *parsed_result,
13566 __attribute__((unused)) struct cmdline *cl,
13567 __attribute__((unused)) void *data)
13569 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13570 int ret = -ENOTSUP;
13572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13575 #ifdef RTE_LIBRTE_IXGBE_PMD
13576 if (ret == -ENOTSUP)
13577 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13580 #ifdef RTE_LIBRTE_I40E_PMD
13581 if (ret == -ENOTSUP)
13582 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13585 #ifdef RTE_LIBRTE_BNXT_PMD
13586 if (ret == -ENOTSUP)
13587 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13595 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13598 printf("invalid port_id %d\n", res->port_id);
13601 printf("function not implemented\n");
13604 printf("programming error: (%s)\n", strerror(-ret));
13608 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13609 .f = cmd_set_vf_mac_addr_parsed,
13611 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13613 (void *)&cmd_set_vf_mac_addr_set,
13614 (void *)&cmd_set_vf_mac_addr_vf,
13615 (void *)&cmd_set_vf_mac_addr_mac,
13616 (void *)&cmd_set_vf_mac_addr_addr,
13617 (void *)&cmd_set_vf_mac_addr_port_id,
13618 (void *)&cmd_set_vf_mac_addr_vf_id,
13619 (void *)&cmd_set_vf_mac_addr_mac_addr,
13624 /* MACsec configuration */
13626 /* Common result structure for MACsec offload enable */
13627 struct cmd_macsec_offload_on_result {
13628 cmdline_fixed_string_t set;
13629 cmdline_fixed_string_t macsec;
13630 cmdline_fixed_string_t offload;
13632 cmdline_fixed_string_t on;
13633 cmdline_fixed_string_t encrypt;
13634 cmdline_fixed_string_t en_on_off;
13635 cmdline_fixed_string_t replay_protect;
13636 cmdline_fixed_string_t rp_on_off;
13639 /* Common CLI fields for MACsec offload disable */
13640 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13641 TOKEN_STRING_INITIALIZER
13642 (struct cmd_macsec_offload_on_result,
13644 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13645 TOKEN_STRING_INITIALIZER
13646 (struct cmd_macsec_offload_on_result,
13648 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13649 TOKEN_STRING_INITIALIZER
13650 (struct cmd_macsec_offload_on_result,
13651 offload, "offload");
13652 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13653 TOKEN_NUM_INITIALIZER
13654 (struct cmd_macsec_offload_on_result,
13656 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13657 TOKEN_STRING_INITIALIZER
13658 (struct cmd_macsec_offload_on_result,
13660 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13661 TOKEN_STRING_INITIALIZER
13662 (struct cmd_macsec_offload_on_result,
13663 encrypt, "encrypt");
13664 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13665 TOKEN_STRING_INITIALIZER
13666 (struct cmd_macsec_offload_on_result,
13667 en_on_off, "on#off");
13668 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13669 TOKEN_STRING_INITIALIZER
13670 (struct cmd_macsec_offload_on_result,
13671 replay_protect, "replay-protect");
13672 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13673 TOKEN_STRING_INITIALIZER
13674 (struct cmd_macsec_offload_on_result,
13675 rp_on_off, "on#off");
13678 cmd_set_macsec_offload_on_parsed(
13679 void *parsed_result,
13680 __attribute__((unused)) struct cmdline *cl,
13681 __attribute__((unused)) void *data)
13683 struct cmd_macsec_offload_on_result *res = parsed_result;
13684 int ret = -ENOTSUP;
13685 portid_t port_id = res->port_id;
13686 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13687 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13688 struct rte_eth_dev_info dev_info;
13690 if (port_id_is_invalid(port_id, ENABLED_WARN))
13692 if (!port_is_stopped(port_id)) {
13693 printf("Please stop port %d first\n", port_id);
13697 rte_eth_dev_info_get(port_id, &dev_info);
13698 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13699 #ifdef RTE_LIBRTE_IXGBE_PMD
13700 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13708 ports[port_id].dev_conf.txmode.offloads |=
13709 DEV_TX_OFFLOAD_MACSEC_INSERT;
13710 cmd_reconfig_device_queue(port_id, 1, 1);
13713 printf("invalid port_id %d\n", port_id);
13716 printf("not supported on port %d\n", port_id);
13719 printf("programming error: (%s)\n", strerror(-ret));
13723 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13724 .f = cmd_set_macsec_offload_on_parsed,
13726 .help_str = "set macsec offload <port_id> on "
13727 "encrypt on|off replay-protect on|off",
13729 (void *)&cmd_macsec_offload_on_set,
13730 (void *)&cmd_macsec_offload_on_macsec,
13731 (void *)&cmd_macsec_offload_on_offload,
13732 (void *)&cmd_macsec_offload_on_port_id,
13733 (void *)&cmd_macsec_offload_on_on,
13734 (void *)&cmd_macsec_offload_on_encrypt,
13735 (void *)&cmd_macsec_offload_on_en_on_off,
13736 (void *)&cmd_macsec_offload_on_replay_protect,
13737 (void *)&cmd_macsec_offload_on_rp_on_off,
13742 /* Common result structure for MACsec offload disable */
13743 struct cmd_macsec_offload_off_result {
13744 cmdline_fixed_string_t set;
13745 cmdline_fixed_string_t macsec;
13746 cmdline_fixed_string_t offload;
13748 cmdline_fixed_string_t off;
13751 /* Common CLI fields for MACsec offload disable */
13752 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13753 TOKEN_STRING_INITIALIZER
13754 (struct cmd_macsec_offload_off_result,
13756 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13757 TOKEN_STRING_INITIALIZER
13758 (struct cmd_macsec_offload_off_result,
13760 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13761 TOKEN_STRING_INITIALIZER
13762 (struct cmd_macsec_offload_off_result,
13763 offload, "offload");
13764 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13765 TOKEN_NUM_INITIALIZER
13766 (struct cmd_macsec_offload_off_result,
13768 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13769 TOKEN_STRING_INITIALIZER
13770 (struct cmd_macsec_offload_off_result,
13774 cmd_set_macsec_offload_off_parsed(
13775 void *parsed_result,
13776 __attribute__((unused)) struct cmdline *cl,
13777 __attribute__((unused)) void *data)
13779 struct cmd_macsec_offload_off_result *res = parsed_result;
13780 int ret = -ENOTSUP;
13781 struct rte_eth_dev_info dev_info;
13782 portid_t port_id = res->port_id;
13784 if (port_id_is_invalid(port_id, ENABLED_WARN))
13786 if (!port_is_stopped(port_id)) {
13787 printf("Please stop port %d first\n", port_id);
13791 rte_eth_dev_info_get(port_id, &dev_info);
13792 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13793 #ifdef RTE_LIBRTE_IXGBE_PMD
13794 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13799 ports[port_id].dev_conf.txmode.offloads &=
13800 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13801 cmd_reconfig_device_queue(port_id, 1, 1);
13804 printf("invalid port_id %d\n", port_id);
13807 printf("not supported on port %d\n", port_id);
13810 printf("programming error: (%s)\n", strerror(-ret));
13814 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13815 .f = cmd_set_macsec_offload_off_parsed,
13817 .help_str = "set macsec offload <port_id> off",
13819 (void *)&cmd_macsec_offload_off_set,
13820 (void *)&cmd_macsec_offload_off_macsec,
13821 (void *)&cmd_macsec_offload_off_offload,
13822 (void *)&cmd_macsec_offload_off_port_id,
13823 (void *)&cmd_macsec_offload_off_off,
13828 /* Common result structure for MACsec secure connection configure */
13829 struct cmd_macsec_sc_result {
13830 cmdline_fixed_string_t set;
13831 cmdline_fixed_string_t macsec;
13832 cmdline_fixed_string_t sc;
13833 cmdline_fixed_string_t tx_rx;
13835 struct ether_addr mac;
13839 /* Common CLI fields for MACsec secure connection configure */
13840 cmdline_parse_token_string_t cmd_macsec_sc_set =
13841 TOKEN_STRING_INITIALIZER
13842 (struct cmd_macsec_sc_result,
13844 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13845 TOKEN_STRING_INITIALIZER
13846 (struct cmd_macsec_sc_result,
13848 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13849 TOKEN_STRING_INITIALIZER
13850 (struct cmd_macsec_sc_result,
13852 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13853 TOKEN_STRING_INITIALIZER
13854 (struct cmd_macsec_sc_result,
13856 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13857 TOKEN_NUM_INITIALIZER
13858 (struct cmd_macsec_sc_result,
13860 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13861 TOKEN_ETHERADDR_INITIALIZER
13862 (struct cmd_macsec_sc_result,
13864 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13865 TOKEN_NUM_INITIALIZER
13866 (struct cmd_macsec_sc_result,
13870 cmd_set_macsec_sc_parsed(
13871 void *parsed_result,
13872 __attribute__((unused)) struct cmdline *cl,
13873 __attribute__((unused)) void *data)
13875 struct cmd_macsec_sc_result *res = parsed_result;
13876 int ret = -ENOTSUP;
13877 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13879 #ifdef RTE_LIBRTE_IXGBE_PMD
13881 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13882 res->mac.addr_bytes) :
13883 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13884 res->mac.addr_bytes, res->pi);
13886 RTE_SET_USED(is_tx);
13892 printf("invalid port_id %d\n", res->port_id);
13895 printf("not supported on port %d\n", res->port_id);
13898 printf("programming error: (%s)\n", strerror(-ret));
13902 cmdline_parse_inst_t cmd_set_macsec_sc = {
13903 .f = cmd_set_macsec_sc_parsed,
13905 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13907 (void *)&cmd_macsec_sc_set,
13908 (void *)&cmd_macsec_sc_macsec,
13909 (void *)&cmd_macsec_sc_sc,
13910 (void *)&cmd_macsec_sc_tx_rx,
13911 (void *)&cmd_macsec_sc_port_id,
13912 (void *)&cmd_macsec_sc_mac,
13913 (void *)&cmd_macsec_sc_pi,
13918 /* Common result structure for MACsec secure connection configure */
13919 struct cmd_macsec_sa_result {
13920 cmdline_fixed_string_t set;
13921 cmdline_fixed_string_t macsec;
13922 cmdline_fixed_string_t sa;
13923 cmdline_fixed_string_t tx_rx;
13928 cmdline_fixed_string_t key;
13931 /* Common CLI fields for MACsec secure connection configure */
13932 cmdline_parse_token_string_t cmd_macsec_sa_set =
13933 TOKEN_STRING_INITIALIZER
13934 (struct cmd_macsec_sa_result,
13936 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13937 TOKEN_STRING_INITIALIZER
13938 (struct cmd_macsec_sa_result,
13940 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13941 TOKEN_STRING_INITIALIZER
13942 (struct cmd_macsec_sa_result,
13944 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13945 TOKEN_STRING_INITIALIZER
13946 (struct cmd_macsec_sa_result,
13948 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13949 TOKEN_NUM_INITIALIZER
13950 (struct cmd_macsec_sa_result,
13952 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13953 TOKEN_NUM_INITIALIZER
13954 (struct cmd_macsec_sa_result,
13956 cmdline_parse_token_num_t cmd_macsec_sa_an =
13957 TOKEN_NUM_INITIALIZER
13958 (struct cmd_macsec_sa_result,
13960 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13961 TOKEN_NUM_INITIALIZER
13962 (struct cmd_macsec_sa_result,
13964 cmdline_parse_token_string_t cmd_macsec_sa_key =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_macsec_sa_result,
13970 cmd_set_macsec_sa_parsed(
13971 void *parsed_result,
13972 __attribute__((unused)) struct cmdline *cl,
13973 __attribute__((unused)) void *data)
13975 struct cmd_macsec_sa_result *res = parsed_result;
13976 int ret = -ENOTSUP;
13977 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13978 uint8_t key[16] = { 0 };
13984 key_len = strlen(res->key) / 2;
13988 for (i = 0; i < key_len; i++) {
13989 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13992 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13995 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13998 #ifdef RTE_LIBRTE_IXGBE_PMD
14000 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14001 res->idx, res->an, res->pn, key) :
14002 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14003 res->idx, res->an, res->pn, key);
14005 RTE_SET_USED(is_tx);
14012 printf("invalid idx %d or an %d\n", res->idx, res->an);
14015 printf("invalid port_id %d\n", res->port_id);
14018 printf("not supported on port %d\n", res->port_id);
14021 printf("programming error: (%s)\n", strerror(-ret));
14025 cmdline_parse_inst_t cmd_set_macsec_sa = {
14026 .f = cmd_set_macsec_sa_parsed,
14028 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14030 (void *)&cmd_macsec_sa_set,
14031 (void *)&cmd_macsec_sa_macsec,
14032 (void *)&cmd_macsec_sa_sa,
14033 (void *)&cmd_macsec_sa_tx_rx,
14034 (void *)&cmd_macsec_sa_port_id,
14035 (void *)&cmd_macsec_sa_idx,
14036 (void *)&cmd_macsec_sa_an,
14037 (void *)&cmd_macsec_sa_pn,
14038 (void *)&cmd_macsec_sa_key,
14043 /* VF unicast promiscuous mode configuration */
14045 /* Common result structure for VF unicast promiscuous mode */
14046 struct cmd_vf_promisc_result {
14047 cmdline_fixed_string_t set;
14048 cmdline_fixed_string_t vf;
14049 cmdline_fixed_string_t promisc;
14052 cmdline_fixed_string_t on_off;
14055 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14056 cmdline_parse_token_string_t cmd_vf_promisc_set =
14057 TOKEN_STRING_INITIALIZER
14058 (struct cmd_vf_promisc_result,
14060 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14061 TOKEN_STRING_INITIALIZER
14062 (struct cmd_vf_promisc_result,
14064 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14065 TOKEN_STRING_INITIALIZER
14066 (struct cmd_vf_promisc_result,
14067 promisc, "promisc");
14068 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14069 TOKEN_NUM_INITIALIZER
14070 (struct cmd_vf_promisc_result,
14072 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14073 TOKEN_NUM_INITIALIZER
14074 (struct cmd_vf_promisc_result,
14076 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14077 TOKEN_STRING_INITIALIZER
14078 (struct cmd_vf_promisc_result,
14082 cmd_set_vf_promisc_parsed(
14083 void *parsed_result,
14084 __attribute__((unused)) struct cmdline *cl,
14085 __attribute__((unused)) void *data)
14087 struct cmd_vf_promisc_result *res = parsed_result;
14088 int ret = -ENOTSUP;
14090 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14095 #ifdef RTE_LIBRTE_I40E_PMD
14096 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14097 res->vf_id, is_on);
14104 printf("invalid vf_id %d\n", res->vf_id);
14107 printf("invalid port_id %d\n", res->port_id);
14110 printf("function not implemented\n");
14113 printf("programming error: (%s)\n", strerror(-ret));
14117 cmdline_parse_inst_t cmd_set_vf_promisc = {
14118 .f = cmd_set_vf_promisc_parsed,
14120 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14121 "Set unicast promiscuous mode for a VF from the PF",
14123 (void *)&cmd_vf_promisc_set,
14124 (void *)&cmd_vf_promisc_vf,
14125 (void *)&cmd_vf_promisc_promisc,
14126 (void *)&cmd_vf_promisc_port_id,
14127 (void *)&cmd_vf_promisc_vf_id,
14128 (void *)&cmd_vf_promisc_on_off,
14133 /* VF multicast promiscuous mode configuration */
14135 /* Common result structure for VF multicast promiscuous mode */
14136 struct cmd_vf_allmulti_result {
14137 cmdline_fixed_string_t set;
14138 cmdline_fixed_string_t vf;
14139 cmdline_fixed_string_t allmulti;
14142 cmdline_fixed_string_t on_off;
14145 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14146 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14147 TOKEN_STRING_INITIALIZER
14148 (struct cmd_vf_allmulti_result,
14150 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14151 TOKEN_STRING_INITIALIZER
14152 (struct cmd_vf_allmulti_result,
14154 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14155 TOKEN_STRING_INITIALIZER
14156 (struct cmd_vf_allmulti_result,
14157 allmulti, "allmulti");
14158 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14159 TOKEN_NUM_INITIALIZER
14160 (struct cmd_vf_allmulti_result,
14162 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14163 TOKEN_NUM_INITIALIZER
14164 (struct cmd_vf_allmulti_result,
14166 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14167 TOKEN_STRING_INITIALIZER
14168 (struct cmd_vf_allmulti_result,
14172 cmd_set_vf_allmulti_parsed(
14173 void *parsed_result,
14174 __attribute__((unused)) struct cmdline *cl,
14175 __attribute__((unused)) void *data)
14177 struct cmd_vf_allmulti_result *res = parsed_result;
14178 int ret = -ENOTSUP;
14180 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14182 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14185 #ifdef RTE_LIBRTE_I40E_PMD
14186 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14187 res->vf_id, is_on);
14194 printf("invalid vf_id %d\n", res->vf_id);
14197 printf("invalid port_id %d\n", res->port_id);
14200 printf("function not implemented\n");
14203 printf("programming error: (%s)\n", strerror(-ret));
14207 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14208 .f = cmd_set_vf_allmulti_parsed,
14210 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14211 "Set multicast promiscuous mode for a VF from the PF",
14213 (void *)&cmd_vf_allmulti_set,
14214 (void *)&cmd_vf_allmulti_vf,
14215 (void *)&cmd_vf_allmulti_allmulti,
14216 (void *)&cmd_vf_allmulti_port_id,
14217 (void *)&cmd_vf_allmulti_vf_id,
14218 (void *)&cmd_vf_allmulti_on_off,
14223 /* vf broadcast mode configuration */
14225 /* Common result structure for vf broadcast */
14226 struct cmd_set_vf_broadcast_result {
14227 cmdline_fixed_string_t set;
14228 cmdline_fixed_string_t vf;
14229 cmdline_fixed_string_t broadcast;
14232 cmdline_fixed_string_t on_off;
14235 /* Common CLI fields for vf broadcast enable disable */
14236 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14237 TOKEN_STRING_INITIALIZER
14238 (struct cmd_set_vf_broadcast_result,
14240 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14241 TOKEN_STRING_INITIALIZER
14242 (struct cmd_set_vf_broadcast_result,
14244 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14245 TOKEN_STRING_INITIALIZER
14246 (struct cmd_set_vf_broadcast_result,
14247 broadcast, "broadcast");
14248 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14249 TOKEN_NUM_INITIALIZER
14250 (struct cmd_set_vf_broadcast_result,
14252 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14253 TOKEN_NUM_INITIALIZER
14254 (struct cmd_set_vf_broadcast_result,
14256 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14257 TOKEN_STRING_INITIALIZER
14258 (struct cmd_set_vf_broadcast_result,
14262 cmd_set_vf_broadcast_parsed(
14263 void *parsed_result,
14264 __attribute__((unused)) struct cmdline *cl,
14265 __attribute__((unused)) void *data)
14267 struct cmd_set_vf_broadcast_result *res = parsed_result;
14268 int ret = -ENOTSUP;
14270 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14272 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14275 #ifdef RTE_LIBRTE_I40E_PMD
14276 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14277 res->vf_id, is_on);
14284 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14287 printf("invalid port_id %d\n", res->port_id);
14290 printf("function not implemented\n");
14293 printf("programming error: (%s)\n", strerror(-ret));
14297 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14298 .f = cmd_set_vf_broadcast_parsed,
14300 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14302 (void *)&cmd_set_vf_broadcast_set,
14303 (void *)&cmd_set_vf_broadcast_vf,
14304 (void *)&cmd_set_vf_broadcast_broadcast,
14305 (void *)&cmd_set_vf_broadcast_port_id,
14306 (void *)&cmd_set_vf_broadcast_vf_id,
14307 (void *)&cmd_set_vf_broadcast_on_off,
14312 /* vf vlan tag configuration */
14314 /* Common result structure for vf vlan tag */
14315 struct cmd_set_vf_vlan_tag_result {
14316 cmdline_fixed_string_t set;
14317 cmdline_fixed_string_t vf;
14318 cmdline_fixed_string_t vlan;
14319 cmdline_fixed_string_t tag;
14322 cmdline_fixed_string_t on_off;
14325 /* Common CLI fields for vf vlan tag enable disable */
14326 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14327 TOKEN_STRING_INITIALIZER
14328 (struct cmd_set_vf_vlan_tag_result,
14330 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14331 TOKEN_STRING_INITIALIZER
14332 (struct cmd_set_vf_vlan_tag_result,
14334 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14335 TOKEN_STRING_INITIALIZER
14336 (struct cmd_set_vf_vlan_tag_result,
14338 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14339 TOKEN_STRING_INITIALIZER
14340 (struct cmd_set_vf_vlan_tag_result,
14342 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14343 TOKEN_NUM_INITIALIZER
14344 (struct cmd_set_vf_vlan_tag_result,
14346 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14347 TOKEN_NUM_INITIALIZER
14348 (struct cmd_set_vf_vlan_tag_result,
14350 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14351 TOKEN_STRING_INITIALIZER
14352 (struct cmd_set_vf_vlan_tag_result,
14356 cmd_set_vf_vlan_tag_parsed(
14357 void *parsed_result,
14358 __attribute__((unused)) struct cmdline *cl,
14359 __attribute__((unused)) void *data)
14361 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14362 int ret = -ENOTSUP;
14364 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14366 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14369 #ifdef RTE_LIBRTE_I40E_PMD
14370 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14371 res->vf_id, is_on);
14378 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14381 printf("invalid port_id %d\n", res->port_id);
14384 printf("function not implemented\n");
14387 printf("programming error: (%s)\n", strerror(-ret));
14391 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14392 .f = cmd_set_vf_vlan_tag_parsed,
14394 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14396 (void *)&cmd_set_vf_vlan_tag_set,
14397 (void *)&cmd_set_vf_vlan_tag_vf,
14398 (void *)&cmd_set_vf_vlan_tag_vlan,
14399 (void *)&cmd_set_vf_vlan_tag_tag,
14400 (void *)&cmd_set_vf_vlan_tag_port_id,
14401 (void *)&cmd_set_vf_vlan_tag_vf_id,
14402 (void *)&cmd_set_vf_vlan_tag_on_off,
14407 /* Common definition of VF and TC TX bandwidth configuration */
14408 struct cmd_vf_tc_bw_result {
14409 cmdline_fixed_string_t set;
14410 cmdline_fixed_string_t vf;
14411 cmdline_fixed_string_t tc;
14412 cmdline_fixed_string_t tx;
14413 cmdline_fixed_string_t min_bw;
14414 cmdline_fixed_string_t max_bw;
14415 cmdline_fixed_string_t strict_link_prio;
14420 cmdline_fixed_string_t bw_list;
14424 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14425 TOKEN_STRING_INITIALIZER
14426 (struct cmd_vf_tc_bw_result,
14428 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14429 TOKEN_STRING_INITIALIZER
14430 (struct cmd_vf_tc_bw_result,
14432 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14433 TOKEN_STRING_INITIALIZER
14434 (struct cmd_vf_tc_bw_result,
14436 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14437 TOKEN_STRING_INITIALIZER
14438 (struct cmd_vf_tc_bw_result,
14440 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14441 TOKEN_STRING_INITIALIZER
14442 (struct cmd_vf_tc_bw_result,
14443 strict_link_prio, "strict-link-priority");
14444 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14445 TOKEN_STRING_INITIALIZER
14446 (struct cmd_vf_tc_bw_result,
14447 min_bw, "min-bandwidth");
14448 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14449 TOKEN_STRING_INITIALIZER
14450 (struct cmd_vf_tc_bw_result,
14451 max_bw, "max-bandwidth");
14452 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14453 TOKEN_NUM_INITIALIZER
14454 (struct cmd_vf_tc_bw_result,
14456 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14457 TOKEN_NUM_INITIALIZER
14458 (struct cmd_vf_tc_bw_result,
14460 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14461 TOKEN_NUM_INITIALIZER
14462 (struct cmd_vf_tc_bw_result,
14464 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14465 TOKEN_NUM_INITIALIZER
14466 (struct cmd_vf_tc_bw_result,
14468 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14469 TOKEN_STRING_INITIALIZER
14470 (struct cmd_vf_tc_bw_result,
14472 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14473 TOKEN_NUM_INITIALIZER
14474 (struct cmd_vf_tc_bw_result,
14477 /* VF max bandwidth setting */
14479 cmd_vf_max_bw_parsed(
14480 void *parsed_result,
14481 __attribute__((unused)) struct cmdline *cl,
14482 __attribute__((unused)) void *data)
14484 struct cmd_vf_tc_bw_result *res = parsed_result;
14485 int ret = -ENOTSUP;
14487 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14490 #ifdef RTE_LIBRTE_I40E_PMD
14491 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14492 res->vf_id, res->bw);
14499 printf("invalid vf_id %d or bandwidth %d\n",
14500 res->vf_id, res->bw);
14503 printf("invalid port_id %d\n", res->port_id);
14506 printf("function not implemented\n");
14509 printf("programming error: (%s)\n", strerror(-ret));
14513 cmdline_parse_inst_t cmd_vf_max_bw = {
14514 .f = cmd_vf_max_bw_parsed,
14516 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14518 (void *)&cmd_vf_tc_bw_set,
14519 (void *)&cmd_vf_tc_bw_vf,
14520 (void *)&cmd_vf_tc_bw_tx,
14521 (void *)&cmd_vf_tc_bw_max_bw,
14522 (void *)&cmd_vf_tc_bw_port_id,
14523 (void *)&cmd_vf_tc_bw_vf_id,
14524 (void *)&cmd_vf_tc_bw_bw,
14530 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14535 const char *p, *p0 = str;
14542 p = strchr(p0, '(');
14544 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14548 p0 = strchr(p, ')');
14550 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14554 if (size >= sizeof(s)) {
14555 printf("The string size exceeds the internal buffer size\n");
14558 snprintf(s, sizeof(s), "%.*s", size, p);
14559 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14561 printf("Failed to get the bandwidth list. ");
14565 for (i = 0; i < ret; i++)
14566 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14571 /* TC min bandwidth setting */
14573 cmd_vf_tc_min_bw_parsed(
14574 void *parsed_result,
14575 __attribute__((unused)) struct cmdline *cl,
14576 __attribute__((unused)) void *data)
14578 struct cmd_vf_tc_bw_result *res = parsed_result;
14581 int ret = -ENOTSUP;
14583 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14586 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14590 #ifdef RTE_LIBRTE_I40E_PMD
14591 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14599 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14602 printf("invalid port_id %d\n", res->port_id);
14605 printf("function not implemented\n");
14608 printf("programming error: (%s)\n", strerror(-ret));
14612 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14613 .f = cmd_vf_tc_min_bw_parsed,
14615 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14616 " <bw1, bw2, ...>",
14618 (void *)&cmd_vf_tc_bw_set,
14619 (void *)&cmd_vf_tc_bw_vf,
14620 (void *)&cmd_vf_tc_bw_tc,
14621 (void *)&cmd_vf_tc_bw_tx,
14622 (void *)&cmd_vf_tc_bw_min_bw,
14623 (void *)&cmd_vf_tc_bw_port_id,
14624 (void *)&cmd_vf_tc_bw_vf_id,
14625 (void *)&cmd_vf_tc_bw_bw_list,
14631 cmd_tc_min_bw_parsed(
14632 void *parsed_result,
14633 __attribute__((unused)) struct cmdline *cl,
14634 __attribute__((unused)) void *data)
14636 struct cmd_vf_tc_bw_result *res = parsed_result;
14637 struct rte_port *port;
14640 int ret = -ENOTSUP;
14642 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14645 port = &ports[res->port_id];
14646 /** Check if the port is not started **/
14647 if (port->port_status != RTE_PORT_STOPPED) {
14648 printf("Please stop port %d first\n", res->port_id);
14652 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14656 #ifdef RTE_LIBRTE_IXGBE_PMD
14657 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14664 printf("invalid bandwidth\n");
14667 printf("invalid port_id %d\n", res->port_id);
14670 printf("function not implemented\n");
14673 printf("programming error: (%s)\n", strerror(-ret));
14677 cmdline_parse_inst_t cmd_tc_min_bw = {
14678 .f = cmd_tc_min_bw_parsed,
14680 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14682 (void *)&cmd_vf_tc_bw_set,
14683 (void *)&cmd_vf_tc_bw_tc,
14684 (void *)&cmd_vf_tc_bw_tx,
14685 (void *)&cmd_vf_tc_bw_min_bw,
14686 (void *)&cmd_vf_tc_bw_port_id,
14687 (void *)&cmd_vf_tc_bw_bw_list,
14692 /* TC max bandwidth setting */
14694 cmd_vf_tc_max_bw_parsed(
14695 void *parsed_result,
14696 __attribute__((unused)) struct cmdline *cl,
14697 __attribute__((unused)) void *data)
14699 struct cmd_vf_tc_bw_result *res = parsed_result;
14700 int ret = -ENOTSUP;
14702 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14705 #ifdef RTE_LIBRTE_I40E_PMD
14706 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14707 res->tc_no, res->bw);
14714 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14715 res->vf_id, res->tc_no, res->bw);
14718 printf("invalid port_id %d\n", res->port_id);
14721 printf("function not implemented\n");
14724 printf("programming error: (%s)\n", strerror(-ret));
14728 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14729 .f = cmd_vf_tc_max_bw_parsed,
14731 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14734 (void *)&cmd_vf_tc_bw_set,
14735 (void *)&cmd_vf_tc_bw_vf,
14736 (void *)&cmd_vf_tc_bw_tc,
14737 (void *)&cmd_vf_tc_bw_tx,
14738 (void *)&cmd_vf_tc_bw_max_bw,
14739 (void *)&cmd_vf_tc_bw_port_id,
14740 (void *)&cmd_vf_tc_bw_vf_id,
14741 (void *)&cmd_vf_tc_bw_tc_no,
14742 (void *)&cmd_vf_tc_bw_bw,
14748 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14750 /* *** Set Port default Traffic Management Hierarchy *** */
14751 struct cmd_set_port_tm_hierarchy_default_result {
14752 cmdline_fixed_string_t set;
14753 cmdline_fixed_string_t port;
14754 cmdline_fixed_string_t tm;
14755 cmdline_fixed_string_t hierarchy;
14756 cmdline_fixed_string_t def;
14760 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14761 TOKEN_STRING_INITIALIZER(
14762 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14763 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14764 TOKEN_STRING_INITIALIZER(
14765 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14766 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14767 TOKEN_STRING_INITIALIZER(
14768 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14769 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14770 TOKEN_STRING_INITIALIZER(
14771 struct cmd_set_port_tm_hierarchy_default_result,
14772 hierarchy, "hierarchy");
14773 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14774 TOKEN_STRING_INITIALIZER(
14775 struct cmd_set_port_tm_hierarchy_default_result,
14777 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14778 TOKEN_NUM_INITIALIZER(
14779 struct cmd_set_port_tm_hierarchy_default_result,
14782 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14783 __attribute__((unused)) struct cmdline *cl,
14784 __attribute__((unused)) void *data)
14786 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14787 struct rte_port *p;
14788 portid_t port_id = res->port_id;
14790 if (port_id_is_invalid(port_id, ENABLED_WARN))
14793 p = &ports[port_id];
14796 if (p->softport.tm_flag == 0) {
14797 printf(" tm not enabled on port %u (error)\n", port_id);
14801 /* Forward mode: tm */
14802 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14803 printf(" tm mode not enabled(error)\n");
14807 /* Set the default tm hierarchy */
14808 p->softport.tm.default_hierarchy_enable = 1;
14811 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14812 .f = cmd_set_port_tm_hierarchy_default_parsed,
14814 .help_str = "set port tm hierarchy default <port_id>",
14816 (void *)&cmd_set_port_tm_hierarchy_default_set,
14817 (void *)&cmd_set_port_tm_hierarchy_default_port,
14818 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14819 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14820 (void *)&cmd_set_port_tm_hierarchy_default_default,
14821 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14827 /* Strict link priority scheduling mode setting */
14829 cmd_strict_link_prio_parsed(
14830 void *parsed_result,
14831 __attribute__((unused)) struct cmdline *cl,
14832 __attribute__((unused)) void *data)
14834 struct cmd_vf_tc_bw_result *res = parsed_result;
14835 int ret = -ENOTSUP;
14837 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14840 #ifdef RTE_LIBRTE_I40E_PMD
14841 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14848 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14851 printf("invalid port_id %d\n", res->port_id);
14854 printf("function not implemented\n");
14857 printf("programming error: (%s)\n", strerror(-ret));
14861 cmdline_parse_inst_t cmd_strict_link_prio = {
14862 .f = cmd_strict_link_prio_parsed,
14864 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14866 (void *)&cmd_vf_tc_bw_set,
14867 (void *)&cmd_vf_tc_bw_tx,
14868 (void *)&cmd_vf_tc_bw_strict_link_prio,
14869 (void *)&cmd_vf_tc_bw_port_id,
14870 (void *)&cmd_vf_tc_bw_tc_map,
14875 /* Load dynamic device personalization*/
14876 struct cmd_ddp_add_result {
14877 cmdline_fixed_string_t ddp;
14878 cmdline_fixed_string_t add;
14883 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14884 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14885 cmdline_parse_token_string_t cmd_ddp_add_add =
14886 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14887 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14888 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14889 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14890 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14893 cmd_ddp_add_parsed(
14894 void *parsed_result,
14895 __attribute__((unused)) struct cmdline *cl,
14896 __attribute__((unused)) void *data)
14898 struct cmd_ddp_add_result *res = parsed_result;
14904 int ret = -ENOTSUP;
14906 if (!all_ports_stopped()) {
14907 printf("Please stop all ports first\n");
14911 filepath = strdup(res->filepath);
14912 if (filepath == NULL) {
14913 printf("Failed to allocate memory\n");
14916 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14918 buff = open_file(file_fld[0], &size);
14920 free((void *)filepath);
14924 #ifdef RTE_LIBRTE_I40E_PMD
14925 if (ret == -ENOTSUP)
14926 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14928 RTE_PMD_I40E_PKG_OP_WR_ADD);
14931 if (ret == -EEXIST)
14932 printf("Profile has already existed.\n");
14934 printf("Failed to load profile.\n");
14935 else if (file_num == 2)
14936 save_file(file_fld[1], buff, size);
14939 free((void *)filepath);
14942 cmdline_parse_inst_t cmd_ddp_add = {
14943 .f = cmd_ddp_add_parsed,
14945 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14947 (void *)&cmd_ddp_add_ddp,
14948 (void *)&cmd_ddp_add_add,
14949 (void *)&cmd_ddp_add_port_id,
14950 (void *)&cmd_ddp_add_filepath,
14955 /* Delete dynamic device personalization*/
14956 struct cmd_ddp_del_result {
14957 cmdline_fixed_string_t ddp;
14958 cmdline_fixed_string_t del;
14963 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14964 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14965 cmdline_parse_token_string_t cmd_ddp_del_del =
14966 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14967 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14968 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14969 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14970 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14973 cmd_ddp_del_parsed(
14974 void *parsed_result,
14975 __attribute__((unused)) struct cmdline *cl,
14976 __attribute__((unused)) void *data)
14978 struct cmd_ddp_del_result *res = parsed_result;
14981 int ret = -ENOTSUP;
14983 if (!all_ports_stopped()) {
14984 printf("Please stop all ports first\n");
14988 buff = open_file(res->filepath, &size);
14992 #ifdef RTE_LIBRTE_I40E_PMD
14993 if (ret == -ENOTSUP)
14994 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14996 RTE_PMD_I40E_PKG_OP_WR_DEL);
14999 if (ret == -EACCES)
15000 printf("Profile does not exist.\n");
15002 printf("Failed to delete profile.\n");
15007 cmdline_parse_inst_t cmd_ddp_del = {
15008 .f = cmd_ddp_del_parsed,
15010 .help_str = "ddp del <port_id> <backup_profile_path>",
15012 (void *)&cmd_ddp_del_ddp,
15013 (void *)&cmd_ddp_del_del,
15014 (void *)&cmd_ddp_del_port_id,
15015 (void *)&cmd_ddp_del_filepath,
15020 /* Get dynamic device personalization profile info */
15021 struct cmd_ddp_info_result {
15022 cmdline_fixed_string_t ddp;
15023 cmdline_fixed_string_t get;
15024 cmdline_fixed_string_t info;
15028 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15029 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15030 cmdline_parse_token_string_t cmd_ddp_info_get =
15031 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15032 cmdline_parse_token_string_t cmd_ddp_info_info =
15033 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15034 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15035 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15038 cmd_ddp_info_parsed(
15039 void *parsed_result,
15040 __attribute__((unused)) struct cmdline *cl,
15041 __attribute__((unused)) void *data)
15043 struct cmd_ddp_info_result *res = parsed_result;
15046 int ret = -ENOTSUP;
15047 #ifdef RTE_LIBRTE_I40E_PMD
15050 uint32_t buff_size = 0;
15051 struct rte_pmd_i40e_profile_info info;
15052 uint32_t dev_num = 0;
15053 struct rte_pmd_i40e_ddp_device_id *devs;
15054 uint32_t proto_num = 0;
15055 struct rte_pmd_i40e_proto_info *proto = NULL;
15056 uint32_t pctype_num = 0;
15057 struct rte_pmd_i40e_ptype_info *pctype;
15058 uint32_t ptype_num = 0;
15059 struct rte_pmd_i40e_ptype_info *ptype;
15064 pkg = open_file(res->filepath, &pkg_size);
15068 #ifdef RTE_LIBRTE_I40E_PMD
15069 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15070 (uint8_t *)&info, sizeof(info),
15071 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15073 printf("Global Track id: 0x%x\n", info.track_id);
15074 printf("Global Version: %d.%d.%d.%d\n",
15075 info.version.major,
15076 info.version.minor,
15077 info.version.update,
15078 info.version.draft);
15079 printf("Global Package name: %s\n\n", info.name);
15082 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15083 (uint8_t *)&info, sizeof(info),
15084 RTE_PMD_I40E_PKG_INFO_HEADER);
15086 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15087 printf("i40e Profile Version: %d.%d.%d.%d\n",
15088 info.version.major,
15089 info.version.minor,
15090 info.version.update,
15091 info.version.draft);
15092 printf("i40e Profile name: %s\n\n", info.name);
15095 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15096 (uint8_t *)&buff_size, sizeof(buff_size),
15097 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15098 if (!ret && buff_size) {
15099 buff = (uint8_t *)malloc(buff_size);
15101 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15103 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15105 printf("Package Notes:\n%s\n\n", buff);
15110 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15111 (uint8_t *)&dev_num, sizeof(dev_num),
15112 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15113 if (!ret && dev_num) {
15114 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15115 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15117 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15118 (uint8_t *)devs, buff_size,
15119 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15121 printf("List of supported devices:\n");
15122 for (i = 0; i < dev_num; i++) {
15123 printf(" %04X:%04X %04X:%04X\n",
15124 devs[i].vendor_dev_id >> 16,
15125 devs[i].vendor_dev_id & 0xFFFF,
15126 devs[i].sub_vendor_dev_id >> 16,
15127 devs[i].sub_vendor_dev_id & 0xFFFF);
15135 /* get information about protocols and packet types */
15136 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15137 (uint8_t *)&proto_num, sizeof(proto_num),
15138 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15139 if (ret || !proto_num)
15140 goto no_print_return;
15142 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15143 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15145 goto no_print_return;
15147 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15149 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15151 printf("List of used protocols:\n");
15152 for (i = 0; i < proto_num; i++)
15153 printf(" %2u: %s\n", proto[i].proto_id,
15157 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15158 (uint8_t *)&pctype_num, sizeof(pctype_num),
15159 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15160 if (ret || !pctype_num)
15161 goto no_print_pctypes;
15163 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15164 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15166 goto no_print_pctypes;
15168 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15170 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15173 goto no_print_pctypes;
15176 printf("List of defined packet classification types:\n");
15177 for (i = 0; i < pctype_num; i++) {
15178 printf(" %2u:", pctype[i].ptype_id);
15179 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15180 proto_id = pctype[i].protocols[j];
15181 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15182 for (n = 0; n < proto_num; n++) {
15183 if (proto[n].proto_id == proto_id) {
15184 printf(" %s", proto[n].name);
15197 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15199 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15200 if (ret || !ptype_num)
15201 goto no_print_return;
15203 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15204 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15206 goto no_print_return;
15208 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15210 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15213 goto no_print_return;
15215 printf("List of defined packet types:\n");
15216 for (i = 0; i < ptype_num; i++) {
15217 printf(" %2u:", ptype[i].ptype_id);
15218 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15219 proto_id = ptype[i].protocols[j];
15220 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15221 for (n = 0; n < proto_num; n++) {
15222 if (proto[n].proto_id == proto_id) {
15223 printf(" %s", proto[n].name);
15239 if (ret == -ENOTSUP)
15240 printf("Function not supported in PMD driver\n");
15244 cmdline_parse_inst_t cmd_ddp_get_info = {
15245 .f = cmd_ddp_info_parsed,
15247 .help_str = "ddp get info <profile_path>",
15249 (void *)&cmd_ddp_info_ddp,
15250 (void *)&cmd_ddp_info_get,
15251 (void *)&cmd_ddp_info_info,
15252 (void *)&cmd_ddp_info_filepath,
15257 /* Get dynamic device personalization profile info list*/
15258 #define PROFILE_INFO_SIZE 48
15259 #define MAX_PROFILE_NUM 16
15261 struct cmd_ddp_get_list_result {
15262 cmdline_fixed_string_t ddp;
15263 cmdline_fixed_string_t get;
15264 cmdline_fixed_string_t list;
15268 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15269 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15270 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15271 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15272 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15273 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15274 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15275 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15278 cmd_ddp_get_list_parsed(
15279 __attribute__((unused)) void *parsed_result,
15280 __attribute__((unused)) struct cmdline *cl,
15281 __attribute__((unused)) void *data)
15283 #ifdef RTE_LIBRTE_I40E_PMD
15284 struct cmd_ddp_get_list_result *res = parsed_result;
15285 struct rte_pmd_i40e_profile_list *p_list;
15286 struct rte_pmd_i40e_profile_info *p_info;
15291 int ret = -ENOTSUP;
15293 #ifdef RTE_LIBRTE_I40E_PMD
15294 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15295 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15297 printf("%s: Failed to malloc buffer\n", __func__);
15299 if (ret == -ENOTSUP)
15300 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15301 (uint8_t *)p_list, size);
15304 p_num = p_list->p_count;
15305 printf("Profile number is: %d\n\n", p_num);
15307 for (i = 0; i < p_num; i++) {
15308 p_info = &p_list->p_info[i];
15309 printf("Profile %d:\n", i);
15310 printf("Track id: 0x%x\n", p_info->track_id);
15311 printf("Version: %d.%d.%d.%d\n",
15312 p_info->version.major,
15313 p_info->version.minor,
15314 p_info->version.update,
15315 p_info->version.draft);
15316 printf("Profile name: %s\n\n", p_info->name);
15324 printf("Failed to get ddp list\n");
15327 cmdline_parse_inst_t cmd_ddp_get_list = {
15328 .f = cmd_ddp_get_list_parsed,
15330 .help_str = "ddp get list <port_id>",
15332 (void *)&cmd_ddp_get_list_ddp,
15333 (void *)&cmd_ddp_get_list_get,
15334 (void *)&cmd_ddp_get_list_list,
15335 (void *)&cmd_ddp_get_list_port_id,
15340 /* Configure input set */
15341 struct cmd_cfg_input_set_result {
15342 cmdline_fixed_string_t port;
15343 cmdline_fixed_string_t cfg;
15345 cmdline_fixed_string_t pctype;
15347 cmdline_fixed_string_t inset_type;
15348 cmdline_fixed_string_t opt;
15349 cmdline_fixed_string_t field;
15354 cmd_cfg_input_set_parsed(
15355 __attribute__((unused)) void *parsed_result,
15356 __attribute__((unused)) struct cmdline *cl,
15357 __attribute__((unused)) void *data)
15359 #ifdef RTE_LIBRTE_I40E_PMD
15360 struct cmd_cfg_input_set_result *res = parsed_result;
15361 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15362 struct rte_pmd_i40e_inset inset;
15364 int ret = -ENOTSUP;
15366 if (!all_ports_stopped()) {
15367 printf("Please stop all ports first\n");
15371 #ifdef RTE_LIBRTE_I40E_PMD
15372 if (!strcmp(res->inset_type, "hash_inset"))
15373 inset_type = INSET_HASH;
15374 else if (!strcmp(res->inset_type, "fdir_inset"))
15375 inset_type = INSET_FDIR;
15376 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15377 inset_type = INSET_FDIR_FLX;
15378 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15379 &inset, inset_type);
15381 printf("Failed to get input set.\n");
15385 if (!strcmp(res->opt, "get")) {
15386 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15389 printf("Field index %d is enabled.\n", res->field_idx);
15391 printf("Field index %d is disabled.\n", res->field_idx);
15393 } else if (!strcmp(res->opt, "set"))
15394 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15396 else if (!strcmp(res->opt, "clear"))
15397 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15400 printf("Failed to configure input set field.\n");
15404 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15405 &inset, inset_type);
15407 printf("Failed to set input set.\n");
15412 if (ret == -ENOTSUP)
15413 printf("Function not supported\n");
15416 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15417 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15419 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15420 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15422 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15423 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15425 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15426 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15428 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15429 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15431 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15432 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15434 "hash_inset#fdir_inset#fdir_flx_inset");
15435 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15436 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15437 opt, "get#set#clear");
15438 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15439 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15441 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15442 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15445 cmdline_parse_inst_t cmd_cfg_input_set = {
15446 .f = cmd_cfg_input_set_parsed,
15448 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15449 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15451 (void *)&cmd_cfg_input_set_port,
15452 (void *)&cmd_cfg_input_set_cfg,
15453 (void *)&cmd_cfg_input_set_port_id,
15454 (void *)&cmd_cfg_input_set_pctype,
15455 (void *)&cmd_cfg_input_set_pctype_id,
15456 (void *)&cmd_cfg_input_set_inset_type,
15457 (void *)&cmd_cfg_input_set_opt,
15458 (void *)&cmd_cfg_input_set_field,
15459 (void *)&cmd_cfg_input_set_field_idx,
15464 /* Clear input set */
15465 struct cmd_clear_input_set_result {
15466 cmdline_fixed_string_t port;
15467 cmdline_fixed_string_t cfg;
15469 cmdline_fixed_string_t pctype;
15471 cmdline_fixed_string_t inset_type;
15472 cmdline_fixed_string_t clear;
15473 cmdline_fixed_string_t all;
15477 cmd_clear_input_set_parsed(
15478 __attribute__((unused)) void *parsed_result,
15479 __attribute__((unused)) struct cmdline *cl,
15480 __attribute__((unused)) void *data)
15482 #ifdef RTE_LIBRTE_I40E_PMD
15483 struct cmd_clear_input_set_result *res = parsed_result;
15484 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15485 struct rte_pmd_i40e_inset inset;
15487 int ret = -ENOTSUP;
15489 if (!all_ports_stopped()) {
15490 printf("Please stop all ports first\n");
15494 #ifdef RTE_LIBRTE_I40E_PMD
15495 if (!strcmp(res->inset_type, "hash_inset"))
15496 inset_type = INSET_HASH;
15497 else if (!strcmp(res->inset_type, "fdir_inset"))
15498 inset_type = INSET_FDIR;
15499 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15500 inset_type = INSET_FDIR_FLX;
15502 memset(&inset, 0, sizeof(inset));
15504 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15505 &inset, inset_type);
15507 printf("Failed to clear input set.\n");
15513 if (ret == -ENOTSUP)
15514 printf("Function not supported\n");
15517 cmdline_parse_token_string_t cmd_clear_input_set_port =
15518 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15520 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15521 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15523 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15524 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15526 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15527 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15529 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15530 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15532 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15533 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15535 "hash_inset#fdir_inset#fdir_flx_inset");
15536 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15537 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15539 cmdline_parse_token_string_t cmd_clear_input_set_all =
15540 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15543 cmdline_parse_inst_t cmd_clear_input_set = {
15544 .f = cmd_clear_input_set_parsed,
15546 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15547 "fdir_inset|fdir_flx_inset clear all",
15549 (void *)&cmd_clear_input_set_port,
15550 (void *)&cmd_clear_input_set_cfg,
15551 (void *)&cmd_clear_input_set_port_id,
15552 (void *)&cmd_clear_input_set_pctype,
15553 (void *)&cmd_clear_input_set_pctype_id,
15554 (void *)&cmd_clear_input_set_inset_type,
15555 (void *)&cmd_clear_input_set_clear,
15556 (void *)&cmd_clear_input_set_all,
15561 /* show vf stats */
15563 /* Common result structure for show vf stats */
15564 struct cmd_show_vf_stats_result {
15565 cmdline_fixed_string_t show;
15566 cmdline_fixed_string_t vf;
15567 cmdline_fixed_string_t stats;
15572 /* Common CLI fields show vf stats*/
15573 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15574 TOKEN_STRING_INITIALIZER
15575 (struct cmd_show_vf_stats_result,
15577 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15578 TOKEN_STRING_INITIALIZER
15579 (struct cmd_show_vf_stats_result,
15581 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15582 TOKEN_STRING_INITIALIZER
15583 (struct cmd_show_vf_stats_result,
15585 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15586 TOKEN_NUM_INITIALIZER
15587 (struct cmd_show_vf_stats_result,
15589 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15590 TOKEN_NUM_INITIALIZER
15591 (struct cmd_show_vf_stats_result,
15595 cmd_show_vf_stats_parsed(
15596 void *parsed_result,
15597 __attribute__((unused)) struct cmdline *cl,
15598 __attribute__((unused)) void *data)
15600 struct cmd_show_vf_stats_result *res = parsed_result;
15601 struct rte_eth_stats stats;
15602 int ret = -ENOTSUP;
15603 static const char *nic_stats_border = "########################";
15605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15608 memset(&stats, 0, sizeof(stats));
15610 #ifdef RTE_LIBRTE_I40E_PMD
15611 if (ret == -ENOTSUP)
15612 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15616 #ifdef RTE_LIBRTE_BNXT_PMD
15617 if (ret == -ENOTSUP)
15618 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15627 printf("invalid vf_id %d\n", res->vf_id);
15630 printf("invalid port_id %d\n", res->port_id);
15633 printf("function not implemented\n");
15636 printf("programming error: (%s)\n", strerror(-ret));
15639 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15640 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15642 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15644 stats.ipackets, stats.imissed, stats.ibytes);
15645 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15646 printf(" RX-nombuf: %-10"PRIu64"\n",
15648 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15650 stats.opackets, stats.oerrors, stats.obytes);
15652 printf(" %s############################%s\n",
15653 nic_stats_border, nic_stats_border);
15656 cmdline_parse_inst_t cmd_show_vf_stats = {
15657 .f = cmd_show_vf_stats_parsed,
15659 .help_str = "show vf stats <port_id> <vf_id>",
15661 (void *)&cmd_show_vf_stats_show,
15662 (void *)&cmd_show_vf_stats_vf,
15663 (void *)&cmd_show_vf_stats_stats,
15664 (void *)&cmd_show_vf_stats_port_id,
15665 (void *)&cmd_show_vf_stats_vf_id,
15670 /* clear vf stats */
15672 /* Common result structure for clear vf stats */
15673 struct cmd_clear_vf_stats_result {
15674 cmdline_fixed_string_t clear;
15675 cmdline_fixed_string_t vf;
15676 cmdline_fixed_string_t stats;
15681 /* Common CLI fields clear vf stats*/
15682 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15683 TOKEN_STRING_INITIALIZER
15684 (struct cmd_clear_vf_stats_result,
15686 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15687 TOKEN_STRING_INITIALIZER
15688 (struct cmd_clear_vf_stats_result,
15690 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15691 TOKEN_STRING_INITIALIZER
15692 (struct cmd_clear_vf_stats_result,
15694 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15695 TOKEN_NUM_INITIALIZER
15696 (struct cmd_clear_vf_stats_result,
15698 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15699 TOKEN_NUM_INITIALIZER
15700 (struct cmd_clear_vf_stats_result,
15704 cmd_clear_vf_stats_parsed(
15705 void *parsed_result,
15706 __attribute__((unused)) struct cmdline *cl,
15707 __attribute__((unused)) void *data)
15709 struct cmd_clear_vf_stats_result *res = parsed_result;
15710 int ret = -ENOTSUP;
15712 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15715 #ifdef RTE_LIBRTE_I40E_PMD
15716 if (ret == -ENOTSUP)
15717 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15720 #ifdef RTE_LIBRTE_BNXT_PMD
15721 if (ret == -ENOTSUP)
15722 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15730 printf("invalid vf_id %d\n", res->vf_id);
15733 printf("invalid port_id %d\n", res->port_id);
15736 printf("function not implemented\n");
15739 printf("programming error: (%s)\n", strerror(-ret));
15743 cmdline_parse_inst_t cmd_clear_vf_stats = {
15744 .f = cmd_clear_vf_stats_parsed,
15746 .help_str = "clear vf stats <port_id> <vf_id>",
15748 (void *)&cmd_clear_vf_stats_clear,
15749 (void *)&cmd_clear_vf_stats_vf,
15750 (void *)&cmd_clear_vf_stats_stats,
15751 (void *)&cmd_clear_vf_stats_port_id,
15752 (void *)&cmd_clear_vf_stats_vf_id,
15757 /* port config pctype mapping reset */
15759 /* Common result structure for port config pctype mapping reset */
15760 struct cmd_pctype_mapping_reset_result {
15761 cmdline_fixed_string_t port;
15762 cmdline_fixed_string_t config;
15764 cmdline_fixed_string_t pctype;
15765 cmdline_fixed_string_t mapping;
15766 cmdline_fixed_string_t reset;
15769 /* Common CLI fields for port config pctype mapping reset*/
15770 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15771 TOKEN_STRING_INITIALIZER
15772 (struct cmd_pctype_mapping_reset_result,
15774 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15775 TOKEN_STRING_INITIALIZER
15776 (struct cmd_pctype_mapping_reset_result,
15778 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15779 TOKEN_NUM_INITIALIZER
15780 (struct cmd_pctype_mapping_reset_result,
15782 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15783 TOKEN_STRING_INITIALIZER
15784 (struct cmd_pctype_mapping_reset_result,
15786 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15787 TOKEN_STRING_INITIALIZER
15788 (struct cmd_pctype_mapping_reset_result,
15789 mapping, "mapping");
15790 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15791 TOKEN_STRING_INITIALIZER
15792 (struct cmd_pctype_mapping_reset_result,
15796 cmd_pctype_mapping_reset_parsed(
15797 void *parsed_result,
15798 __attribute__((unused)) struct cmdline *cl,
15799 __attribute__((unused)) void *data)
15801 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15802 int ret = -ENOTSUP;
15804 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15807 #ifdef RTE_LIBRTE_I40E_PMD
15808 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15815 printf("invalid port_id %d\n", res->port_id);
15818 printf("function not implemented\n");
15821 printf("programming error: (%s)\n", strerror(-ret));
15825 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15826 .f = cmd_pctype_mapping_reset_parsed,
15828 .help_str = "port config <port_id> pctype mapping reset",
15830 (void *)&cmd_pctype_mapping_reset_port,
15831 (void *)&cmd_pctype_mapping_reset_config,
15832 (void *)&cmd_pctype_mapping_reset_port_id,
15833 (void *)&cmd_pctype_mapping_reset_pctype,
15834 (void *)&cmd_pctype_mapping_reset_mapping,
15835 (void *)&cmd_pctype_mapping_reset_reset,
15840 /* show port pctype mapping */
15842 /* Common result structure for show port pctype mapping */
15843 struct cmd_pctype_mapping_get_result {
15844 cmdline_fixed_string_t show;
15845 cmdline_fixed_string_t port;
15847 cmdline_fixed_string_t pctype;
15848 cmdline_fixed_string_t mapping;
15851 /* Common CLI fields for pctype mapping get */
15852 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15853 TOKEN_STRING_INITIALIZER
15854 (struct cmd_pctype_mapping_get_result,
15856 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15857 TOKEN_STRING_INITIALIZER
15858 (struct cmd_pctype_mapping_get_result,
15860 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15861 TOKEN_NUM_INITIALIZER
15862 (struct cmd_pctype_mapping_get_result,
15864 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15865 TOKEN_STRING_INITIALIZER
15866 (struct cmd_pctype_mapping_get_result,
15868 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15869 TOKEN_STRING_INITIALIZER
15870 (struct cmd_pctype_mapping_get_result,
15871 mapping, "mapping");
15874 cmd_pctype_mapping_get_parsed(
15875 void *parsed_result,
15876 __attribute__((unused)) struct cmdline *cl,
15877 __attribute__((unused)) void *data)
15879 struct cmd_pctype_mapping_get_result *res = parsed_result;
15880 int ret = -ENOTSUP;
15881 #ifdef RTE_LIBRTE_I40E_PMD
15882 struct rte_pmd_i40e_flow_type_mapping
15883 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15884 int i, j, first_pctype;
15887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15890 #ifdef RTE_LIBRTE_I40E_PMD
15891 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15898 printf("invalid port_id %d\n", res->port_id);
15901 printf("function not implemented\n");
15904 printf("programming error: (%s)\n", strerror(-ret));
15908 #ifdef RTE_LIBRTE_I40E_PMD
15909 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15910 if (mapping[i].pctype != 0ULL) {
15913 printf("pctype: ");
15914 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15915 if (mapping[i].pctype & (1ULL << j)) {
15916 printf(first_pctype ?
15917 "%02d" : ",%02d", j);
15921 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15927 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15928 .f = cmd_pctype_mapping_get_parsed,
15930 .help_str = "show port <port_id> pctype mapping",
15932 (void *)&cmd_pctype_mapping_get_show,
15933 (void *)&cmd_pctype_mapping_get_port,
15934 (void *)&cmd_pctype_mapping_get_port_id,
15935 (void *)&cmd_pctype_mapping_get_pctype,
15936 (void *)&cmd_pctype_mapping_get_mapping,
15941 /* port config pctype mapping update */
15943 /* Common result structure for port config pctype mapping update */
15944 struct cmd_pctype_mapping_update_result {
15945 cmdline_fixed_string_t port;
15946 cmdline_fixed_string_t config;
15948 cmdline_fixed_string_t pctype;
15949 cmdline_fixed_string_t mapping;
15950 cmdline_fixed_string_t update;
15951 cmdline_fixed_string_t pctype_list;
15952 uint16_t flow_type;
15955 /* Common CLI fields for pctype mapping update*/
15956 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15957 TOKEN_STRING_INITIALIZER
15958 (struct cmd_pctype_mapping_update_result,
15960 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15961 TOKEN_STRING_INITIALIZER
15962 (struct cmd_pctype_mapping_update_result,
15964 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15965 TOKEN_NUM_INITIALIZER
15966 (struct cmd_pctype_mapping_update_result,
15968 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15969 TOKEN_STRING_INITIALIZER
15970 (struct cmd_pctype_mapping_update_result,
15972 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15973 TOKEN_STRING_INITIALIZER
15974 (struct cmd_pctype_mapping_update_result,
15975 mapping, "mapping");
15976 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15977 TOKEN_STRING_INITIALIZER
15978 (struct cmd_pctype_mapping_update_result,
15980 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15981 TOKEN_STRING_INITIALIZER
15982 (struct cmd_pctype_mapping_update_result,
15983 pctype_list, NULL);
15984 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15985 TOKEN_NUM_INITIALIZER
15986 (struct cmd_pctype_mapping_update_result,
15987 flow_type, UINT16);
15990 cmd_pctype_mapping_update_parsed(
15991 void *parsed_result,
15992 __attribute__((unused)) struct cmdline *cl,
15993 __attribute__((unused)) void *data)
15995 struct cmd_pctype_mapping_update_result *res = parsed_result;
15996 int ret = -ENOTSUP;
15997 #ifdef RTE_LIBRTE_I40E_PMD
15998 struct rte_pmd_i40e_flow_type_mapping mapping;
16000 unsigned int nb_item;
16001 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16004 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16007 #ifdef RTE_LIBRTE_I40E_PMD
16008 nb_item = parse_item_list(res->pctype_list, "pctypes",
16009 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16010 mapping.flow_type = res->flow_type;
16011 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16012 mapping.pctype |= (1ULL << pctype_list[i]);
16013 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16023 printf("invalid pctype or flow type\n");
16026 printf("invalid port_id %d\n", res->port_id);
16029 printf("function not implemented\n");
16032 printf("programming error: (%s)\n", strerror(-ret));
16036 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16037 .f = cmd_pctype_mapping_update_parsed,
16039 .help_str = "port config <port_id> pctype mapping update"
16040 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16042 (void *)&cmd_pctype_mapping_update_port,
16043 (void *)&cmd_pctype_mapping_update_config,
16044 (void *)&cmd_pctype_mapping_update_port_id,
16045 (void *)&cmd_pctype_mapping_update_pctype,
16046 (void *)&cmd_pctype_mapping_update_mapping,
16047 (void *)&cmd_pctype_mapping_update_update,
16048 (void *)&cmd_pctype_mapping_update_pc_type,
16049 (void *)&cmd_pctype_mapping_update_flow_type,
16054 /* ptype mapping get */
16056 /* Common result structure for ptype mapping get */
16057 struct cmd_ptype_mapping_get_result {
16058 cmdline_fixed_string_t ptype;
16059 cmdline_fixed_string_t mapping;
16060 cmdline_fixed_string_t get;
16062 uint8_t valid_only;
16065 /* Common CLI fields for ptype mapping get */
16066 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16067 TOKEN_STRING_INITIALIZER
16068 (struct cmd_ptype_mapping_get_result,
16070 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16071 TOKEN_STRING_INITIALIZER
16072 (struct cmd_ptype_mapping_get_result,
16073 mapping, "mapping");
16074 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16075 TOKEN_STRING_INITIALIZER
16076 (struct cmd_ptype_mapping_get_result,
16078 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16079 TOKEN_NUM_INITIALIZER
16080 (struct cmd_ptype_mapping_get_result,
16082 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16083 TOKEN_NUM_INITIALIZER
16084 (struct cmd_ptype_mapping_get_result,
16085 valid_only, UINT8);
16088 cmd_ptype_mapping_get_parsed(
16089 void *parsed_result,
16090 __attribute__((unused)) struct cmdline *cl,
16091 __attribute__((unused)) void *data)
16093 struct cmd_ptype_mapping_get_result *res = parsed_result;
16094 int ret = -ENOTSUP;
16095 #ifdef RTE_LIBRTE_I40E_PMD
16096 int max_ptype_num = 256;
16097 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16102 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16105 #ifdef RTE_LIBRTE_I40E_PMD
16106 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16117 printf("invalid port_id %d\n", res->port_id);
16120 printf("function not implemented\n");
16123 printf("programming error: (%s)\n", strerror(-ret));
16126 #ifdef RTE_LIBRTE_I40E_PMD
16128 for (i = 0; i < count; i++)
16129 printf("%3d\t0x%08x\n",
16130 mapping[i].hw_ptype, mapping[i].sw_ptype);
16135 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16136 .f = cmd_ptype_mapping_get_parsed,
16138 .help_str = "ptype mapping get <port_id> <valid_only>",
16140 (void *)&cmd_ptype_mapping_get_ptype,
16141 (void *)&cmd_ptype_mapping_get_mapping,
16142 (void *)&cmd_ptype_mapping_get_get,
16143 (void *)&cmd_ptype_mapping_get_port_id,
16144 (void *)&cmd_ptype_mapping_get_valid_only,
16149 /* ptype mapping replace */
16151 /* Common result structure for ptype mapping replace */
16152 struct cmd_ptype_mapping_replace_result {
16153 cmdline_fixed_string_t ptype;
16154 cmdline_fixed_string_t mapping;
16155 cmdline_fixed_string_t replace;
16162 /* Common CLI fields for ptype mapping replace */
16163 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16164 TOKEN_STRING_INITIALIZER
16165 (struct cmd_ptype_mapping_replace_result,
16167 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16168 TOKEN_STRING_INITIALIZER
16169 (struct cmd_ptype_mapping_replace_result,
16170 mapping, "mapping");
16171 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16172 TOKEN_STRING_INITIALIZER
16173 (struct cmd_ptype_mapping_replace_result,
16174 replace, "replace");
16175 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16176 TOKEN_NUM_INITIALIZER
16177 (struct cmd_ptype_mapping_replace_result,
16179 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16180 TOKEN_NUM_INITIALIZER
16181 (struct cmd_ptype_mapping_replace_result,
16183 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16184 TOKEN_NUM_INITIALIZER
16185 (struct cmd_ptype_mapping_replace_result,
16187 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16188 TOKEN_NUM_INITIALIZER
16189 (struct cmd_ptype_mapping_replace_result,
16193 cmd_ptype_mapping_replace_parsed(
16194 void *parsed_result,
16195 __attribute__((unused)) struct cmdline *cl,
16196 __attribute__((unused)) void *data)
16198 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16199 int ret = -ENOTSUP;
16201 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16204 #ifdef RTE_LIBRTE_I40E_PMD
16205 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16215 printf("invalid ptype 0x%8x or 0x%8x\n",
16216 res->target, res->pkt_type);
16219 printf("invalid port_id %d\n", res->port_id);
16222 printf("function not implemented\n");
16225 printf("programming error: (%s)\n", strerror(-ret));
16229 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16230 .f = cmd_ptype_mapping_replace_parsed,
16233 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16235 (void *)&cmd_ptype_mapping_replace_ptype,
16236 (void *)&cmd_ptype_mapping_replace_mapping,
16237 (void *)&cmd_ptype_mapping_replace_replace,
16238 (void *)&cmd_ptype_mapping_replace_port_id,
16239 (void *)&cmd_ptype_mapping_replace_target,
16240 (void *)&cmd_ptype_mapping_replace_mask,
16241 (void *)&cmd_ptype_mapping_replace_pkt_type,
16246 /* ptype mapping reset */
16248 /* Common result structure for ptype mapping reset */
16249 struct cmd_ptype_mapping_reset_result {
16250 cmdline_fixed_string_t ptype;
16251 cmdline_fixed_string_t mapping;
16252 cmdline_fixed_string_t reset;
16256 /* Common CLI fields for ptype mapping reset*/
16257 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16258 TOKEN_STRING_INITIALIZER
16259 (struct cmd_ptype_mapping_reset_result,
16261 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16262 TOKEN_STRING_INITIALIZER
16263 (struct cmd_ptype_mapping_reset_result,
16264 mapping, "mapping");
16265 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16266 TOKEN_STRING_INITIALIZER
16267 (struct cmd_ptype_mapping_reset_result,
16269 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16270 TOKEN_NUM_INITIALIZER
16271 (struct cmd_ptype_mapping_reset_result,
16275 cmd_ptype_mapping_reset_parsed(
16276 void *parsed_result,
16277 __attribute__((unused)) struct cmdline *cl,
16278 __attribute__((unused)) void *data)
16280 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16281 int ret = -ENOTSUP;
16283 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16286 #ifdef RTE_LIBRTE_I40E_PMD
16287 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16294 printf("invalid port_id %d\n", res->port_id);
16297 printf("function not implemented\n");
16300 printf("programming error: (%s)\n", strerror(-ret));
16304 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16305 .f = cmd_ptype_mapping_reset_parsed,
16307 .help_str = "ptype mapping reset <port_id>",
16309 (void *)&cmd_ptype_mapping_reset_ptype,
16310 (void *)&cmd_ptype_mapping_reset_mapping,
16311 (void *)&cmd_ptype_mapping_reset_reset,
16312 (void *)&cmd_ptype_mapping_reset_port_id,
16317 /* ptype mapping update */
16319 /* Common result structure for ptype mapping update */
16320 struct cmd_ptype_mapping_update_result {
16321 cmdline_fixed_string_t ptype;
16322 cmdline_fixed_string_t mapping;
16323 cmdline_fixed_string_t reset;
16329 /* Common CLI fields for ptype mapping update*/
16330 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16331 TOKEN_STRING_INITIALIZER
16332 (struct cmd_ptype_mapping_update_result,
16334 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16335 TOKEN_STRING_INITIALIZER
16336 (struct cmd_ptype_mapping_update_result,
16337 mapping, "mapping");
16338 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16339 TOKEN_STRING_INITIALIZER
16340 (struct cmd_ptype_mapping_update_result,
16342 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16343 TOKEN_NUM_INITIALIZER
16344 (struct cmd_ptype_mapping_update_result,
16346 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16347 TOKEN_NUM_INITIALIZER
16348 (struct cmd_ptype_mapping_update_result,
16350 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16351 TOKEN_NUM_INITIALIZER
16352 (struct cmd_ptype_mapping_update_result,
16356 cmd_ptype_mapping_update_parsed(
16357 void *parsed_result,
16358 __attribute__((unused)) struct cmdline *cl,
16359 __attribute__((unused)) void *data)
16361 struct cmd_ptype_mapping_update_result *res = parsed_result;
16362 int ret = -ENOTSUP;
16363 #ifdef RTE_LIBRTE_I40E_PMD
16364 struct rte_pmd_i40e_ptype_mapping mapping;
16366 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16369 #ifdef RTE_LIBRTE_I40E_PMD
16370 mapping.hw_ptype = res->hw_ptype;
16371 mapping.sw_ptype = res->sw_ptype;
16372 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16382 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16385 printf("invalid port_id %d\n", res->port_id);
16388 printf("function not implemented\n");
16391 printf("programming error: (%s)\n", strerror(-ret));
16395 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16396 .f = cmd_ptype_mapping_update_parsed,
16398 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16400 (void *)&cmd_ptype_mapping_update_ptype,
16401 (void *)&cmd_ptype_mapping_update_mapping,
16402 (void *)&cmd_ptype_mapping_update_update,
16403 (void *)&cmd_ptype_mapping_update_port_id,
16404 (void *)&cmd_ptype_mapping_update_hw_ptype,
16405 (void *)&cmd_ptype_mapping_update_sw_ptype,
16410 /* Common result structure for file commands */
16411 struct cmd_cmdfile_result {
16412 cmdline_fixed_string_t load;
16413 cmdline_fixed_string_t filename;
16416 /* Common CLI fields for file commands */
16417 cmdline_parse_token_string_t cmd_load_cmdfile =
16418 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16419 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16420 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16423 cmd_load_from_file_parsed(
16424 void *parsed_result,
16425 __attribute__((unused)) struct cmdline *cl,
16426 __attribute__((unused)) void *data)
16428 struct cmd_cmdfile_result *res = parsed_result;
16430 cmdline_read_from_file(res->filename);
16433 cmdline_parse_inst_t cmd_load_from_file = {
16434 .f = cmd_load_from_file_parsed,
16436 .help_str = "load <filename>",
16438 (void *)&cmd_load_cmdfile,
16439 (void *)&cmd_load_cmdfile_filename,
16444 /* ******************************************************************************** */
16446 /* list of instructions */
16447 cmdline_parse_ctx_t main_ctx[] = {
16448 (cmdline_parse_inst_t *)&cmd_help_brief,
16449 (cmdline_parse_inst_t *)&cmd_help_long,
16450 (cmdline_parse_inst_t *)&cmd_quit,
16451 (cmdline_parse_inst_t *)&cmd_load_from_file,
16452 (cmdline_parse_inst_t *)&cmd_showport,
16453 (cmdline_parse_inst_t *)&cmd_showqueue,
16454 (cmdline_parse_inst_t *)&cmd_showportall,
16455 (cmdline_parse_inst_t *)&cmd_showcfg,
16456 (cmdline_parse_inst_t *)&cmd_start,
16457 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16458 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16459 (cmdline_parse_inst_t *)&cmd_set_link_up,
16460 (cmdline_parse_inst_t *)&cmd_set_link_down,
16461 (cmdline_parse_inst_t *)&cmd_reset,
16462 (cmdline_parse_inst_t *)&cmd_set_numbers,
16463 (cmdline_parse_inst_t *)&cmd_set_log,
16464 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16465 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16466 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16467 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16468 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16469 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16470 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16471 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16472 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16473 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16474 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16475 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16476 (cmdline_parse_inst_t *)&cmd_set_link_check,
16477 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16478 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16479 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16480 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16481 #ifdef RTE_LIBRTE_PMD_BOND
16482 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16483 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16484 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16485 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16486 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16487 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16488 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16489 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16490 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16491 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16492 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16494 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16495 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16496 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16497 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16498 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16499 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16500 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16501 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16502 (cmdline_parse_inst_t *)&cmd_csum_set,
16503 (cmdline_parse_inst_t *)&cmd_csum_show,
16504 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16505 (cmdline_parse_inst_t *)&cmd_tso_set,
16506 (cmdline_parse_inst_t *)&cmd_tso_show,
16507 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16508 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16509 (cmdline_parse_inst_t *)&cmd_gro_enable,
16510 (cmdline_parse_inst_t *)&cmd_gro_flush,
16511 (cmdline_parse_inst_t *)&cmd_gro_show,
16512 (cmdline_parse_inst_t *)&cmd_gso_enable,
16513 (cmdline_parse_inst_t *)&cmd_gso_size,
16514 (cmdline_parse_inst_t *)&cmd_gso_show,
16515 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16516 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16517 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16518 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16519 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16520 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16521 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16522 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16523 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16524 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16525 (cmdline_parse_inst_t *)&cmd_config_dcb,
16526 (cmdline_parse_inst_t *)&cmd_read_reg,
16527 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16528 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16529 (cmdline_parse_inst_t *)&cmd_write_reg,
16530 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16531 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16532 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16533 (cmdline_parse_inst_t *)&cmd_stop,
16534 (cmdline_parse_inst_t *)&cmd_mac_addr,
16535 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16536 (cmdline_parse_inst_t *)&cmd_set_qmap,
16537 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16538 (cmdline_parse_inst_t *)&cmd_operate_port,
16539 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16540 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16541 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16542 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16543 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16544 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16545 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16546 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16547 (cmdline_parse_inst_t *)&cmd_config_mtu,
16548 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16549 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16550 (cmdline_parse_inst_t *)&cmd_config_rss,
16551 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16552 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16553 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16554 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16555 (cmdline_parse_inst_t *)&cmd_showport_reta,
16556 (cmdline_parse_inst_t *)&cmd_config_burst,
16557 (cmdline_parse_inst_t *)&cmd_config_thresh,
16558 (cmdline_parse_inst_t *)&cmd_config_threshold,
16559 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16560 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16561 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16562 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16563 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16564 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16565 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16566 (cmdline_parse_inst_t *)&cmd_global_config,
16567 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16568 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16569 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16570 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16571 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16572 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16573 (cmdline_parse_inst_t *)&cmd_dump,
16574 (cmdline_parse_inst_t *)&cmd_dump_one,
16575 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16576 (cmdline_parse_inst_t *)&cmd_syn_filter,
16577 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16578 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16579 (cmdline_parse_inst_t *)&cmd_flex_filter,
16580 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16581 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16582 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16583 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16584 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16585 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16586 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16587 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16588 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16589 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16590 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16591 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16592 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16593 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16594 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16595 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16596 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16597 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16598 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16599 (cmdline_parse_inst_t *)&cmd_flow,
16600 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16601 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16602 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16603 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16604 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16605 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16606 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16607 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16608 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16609 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16610 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16611 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16612 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16613 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16614 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16615 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16616 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16617 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16618 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16619 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16620 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16621 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16622 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16623 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16624 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16625 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16626 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16627 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16628 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16629 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16630 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16631 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16632 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16633 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16634 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16635 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16636 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16637 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16638 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16639 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16640 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16641 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16642 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16643 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16644 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16645 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16646 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16647 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16648 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16649 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16650 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16652 (cmdline_parse_inst_t *)&cmd_ddp_add,
16653 (cmdline_parse_inst_t *)&cmd_ddp_del,
16654 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16655 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16656 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16657 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16658 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16659 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16660 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16661 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16662 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16663 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16665 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16666 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16667 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16668 (cmdline_parse_inst_t *)&cmd_queue_region,
16669 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16670 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16671 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16672 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16673 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16674 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16675 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16676 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16677 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16678 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16679 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16680 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16681 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16682 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16683 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16684 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16685 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16686 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16687 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16688 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16689 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16690 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
16694 /* read cmdline commands from file */
16696 cmdline_read_from_file(const char *filename)
16698 struct cmdline *cl;
16700 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16702 printf("Failed to create file based cmdline context: %s\n",
16707 cmdline_interact(cl);
16712 printf("Read CLI commands from %s\n", filename);
16715 /* prompt function, called from main on MASTER lcore */
16719 /* initialize non-constant commands */
16720 cmd_set_fwd_mode_init();
16721 cmd_set_fwd_retry_mode_init();
16723 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16724 if (testpmd_cl == NULL)
16726 cmdline_interact(testpmd_cl);
16727 cmdline_stdin_exit(testpmd_cl);
16733 if (testpmd_cl != NULL)
16734 cmdline_quit(testpmd_cl);
16738 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16740 if (id == (portid_t)RTE_PORT_ALL) {
16743 RTE_ETH_FOREACH_DEV(pid) {
16744 /* check if need_reconfig has been set to 1 */
16745 if (ports[pid].need_reconfig == 0)
16746 ports[pid].need_reconfig = dev;
16747 /* check if need_reconfig_queues has been set to 1 */
16748 if (ports[pid].need_reconfig_queues == 0)
16749 ports[pid].need_reconfig_queues = queue;
16751 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16752 /* check if need_reconfig has been set to 1 */
16753 if (ports[id].need_reconfig == 0)
16754 ports[id].need_reconfig = dev;
16755 /* check if need_reconfig_queues has been set to 1 */
16756 if (ports[id].need_reconfig_queues == 0)
16757 ports[id].need_reconfig_queues = queue;