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, };
2013 int use_default = 0;
2014 int all_updated = 1;
2018 if (!strcmp(res->value, "all"))
2019 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2020 ETH_RSS_UDP | ETH_RSS_SCTP |
2022 else if (!strcmp(res->value, "ip"))
2023 rss_conf.rss_hf = ETH_RSS_IP;
2024 else if (!strcmp(res->value, "udp"))
2025 rss_conf.rss_hf = ETH_RSS_UDP;
2026 else if (!strcmp(res->value, "tcp"))
2027 rss_conf.rss_hf = ETH_RSS_TCP;
2028 else if (!strcmp(res->value, "sctp"))
2029 rss_conf.rss_hf = ETH_RSS_SCTP;
2030 else if (!strcmp(res->value, "ether"))
2031 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2032 else if (!strcmp(res->value, "port"))
2033 rss_conf.rss_hf = ETH_RSS_PORT;
2034 else if (!strcmp(res->value, "vxlan"))
2035 rss_conf.rss_hf = ETH_RSS_VXLAN;
2036 else if (!strcmp(res->value, "geneve"))
2037 rss_conf.rss_hf = ETH_RSS_GENEVE;
2038 else if (!strcmp(res->value, "nvgre"))
2039 rss_conf.rss_hf = ETH_RSS_NVGRE;
2040 else if (!strcmp(res->value, "none"))
2041 rss_conf.rss_hf = 0;
2042 else if (!strcmp(res->value, "default"))
2044 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2045 atoi(res->value) < 64)
2046 rss_conf.rss_hf = 1ULL << atoi(res->value);
2048 printf("Unknown parameter\n");
2051 rss_conf.rss_key = NULL;
2052 /* Update global configuration for RSS types. */
2053 RTE_ETH_FOREACH_DEV(i) {
2055 rte_eth_dev_info_get(i, &dev_info);
2056 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2058 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2061 printf("Configuration of RSS hash at ethernet port %d "
2062 "failed with error (%d): %s.\n",
2063 i, -diag, strerror(-diag));
2066 if (all_updated && !use_default)
2067 rss_hf = rss_conf.rss_hf;
2070 cmdline_parse_token_string_t cmd_config_rss_port =
2071 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2072 cmdline_parse_token_string_t cmd_config_rss_keyword =
2073 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2074 cmdline_parse_token_string_t cmd_config_rss_all =
2075 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2076 cmdline_parse_token_string_t cmd_config_rss_name =
2077 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2078 cmdline_parse_token_string_t cmd_config_rss_value =
2079 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2081 cmdline_parse_inst_t cmd_config_rss = {
2082 .f = cmd_config_rss_parsed,
2084 .help_str = "port config all rss "
2085 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2087 (void *)&cmd_config_rss_port,
2088 (void *)&cmd_config_rss_keyword,
2089 (void *)&cmd_config_rss_all,
2090 (void *)&cmd_config_rss_name,
2091 (void *)&cmd_config_rss_value,
2096 /* *** configure rss hash key *** */
2097 struct cmd_config_rss_hash_key {
2098 cmdline_fixed_string_t port;
2099 cmdline_fixed_string_t config;
2101 cmdline_fixed_string_t rss_hash_key;
2102 cmdline_fixed_string_t rss_type;
2103 cmdline_fixed_string_t key;
2107 hexa_digit_to_value(char hexa_digit)
2109 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2110 return (uint8_t) (hexa_digit - '0');
2111 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2112 return (uint8_t) ((hexa_digit - 'a') + 10);
2113 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2114 return (uint8_t) ((hexa_digit - 'A') + 10);
2115 /* Invalid hexa digit */
2120 parse_and_check_key_hexa_digit(char *key, int idx)
2124 hexa_v = hexa_digit_to_value(key[idx]);
2126 printf("invalid key: character %c at position %d is not a "
2127 "valid hexa digit\n", key[idx], idx);
2132 cmd_config_rss_hash_key_parsed(void *parsed_result,
2133 __attribute__((unused)) struct cmdline *cl,
2134 __attribute__((unused)) void *data)
2136 struct cmd_config_rss_hash_key *res = parsed_result;
2137 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2141 struct rte_eth_dev_info dev_info;
2142 uint8_t hash_key_size;
2145 memset(&dev_info, 0, sizeof(dev_info));
2146 rte_eth_dev_info_get(res->port_id, &dev_info);
2147 if (dev_info.hash_key_size > 0 &&
2148 dev_info.hash_key_size <= sizeof(hash_key))
2149 hash_key_size = dev_info.hash_key_size;
2151 printf("dev_info did not provide a valid hash key size\n");
2154 /* Check the length of the RSS hash key */
2155 key_len = strlen(res->key);
2156 if (key_len != (hash_key_size * 2)) {
2157 printf("key length: %d invalid - key must be a string of %d"
2158 " hexa-decimal numbers\n",
2159 (int) key_len, hash_key_size * 2);
2162 /* Translate RSS hash key into binary representation */
2163 for (i = 0; i < hash_key_size; i++) {
2164 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2167 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2170 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2172 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2176 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2177 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2178 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2179 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2181 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2182 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2183 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2184 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2185 rss_hash_key, "rss-hash-key");
2186 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2187 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2188 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2189 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2190 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2191 "ipv6-tcp-ex#ipv6-udp-ex");
2192 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2193 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2195 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2196 .f = cmd_config_rss_hash_key_parsed,
2198 .help_str = "port config <port_id> rss-hash-key "
2199 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2200 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2201 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2202 "<string of hex digits (variable length, NIC dependent)>",
2204 (void *)&cmd_config_rss_hash_key_port,
2205 (void *)&cmd_config_rss_hash_key_config,
2206 (void *)&cmd_config_rss_hash_key_port_id,
2207 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2208 (void *)&cmd_config_rss_hash_key_rss_type,
2209 (void *)&cmd_config_rss_hash_key_value,
2214 /* *** configure port rxq/txq ring size *** */
2215 struct cmd_config_rxtx_ring_size {
2216 cmdline_fixed_string_t port;
2217 cmdline_fixed_string_t config;
2219 cmdline_fixed_string_t rxtxq;
2221 cmdline_fixed_string_t rsize;
2226 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2227 __attribute__((unused)) struct cmdline *cl,
2228 __attribute__((unused)) void *data)
2230 struct cmd_config_rxtx_ring_size *res = parsed_result;
2231 struct rte_port *port;
2234 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2237 if (res->portid == (portid_t)RTE_PORT_ALL) {
2238 printf("Invalid port id\n");
2242 port = &ports[res->portid];
2244 if (!strcmp(res->rxtxq, "rxq"))
2246 else if (!strcmp(res->rxtxq, "txq"))
2249 printf("Unknown parameter\n");
2253 if (isrx && rx_queue_id_is_invalid(res->qid))
2255 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2258 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2259 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2265 port->nb_rx_desc[res->qid] = res->size;
2267 port->nb_tx_desc[res->qid] = res->size;
2269 cmd_reconfig_device_queue(res->portid, 0, 1);
2272 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2273 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2275 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2276 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2278 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2279 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2281 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2282 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2284 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2285 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2287 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2288 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2289 rsize, "ring_size");
2290 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2291 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2294 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2295 .f = cmd_config_rxtx_ring_size_parsed,
2297 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2299 (void *)&cmd_config_rxtx_ring_size_port,
2300 (void *)&cmd_config_rxtx_ring_size_config,
2301 (void *)&cmd_config_rxtx_ring_size_portid,
2302 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2303 (void *)&cmd_config_rxtx_ring_size_qid,
2304 (void *)&cmd_config_rxtx_ring_size_rsize,
2305 (void *)&cmd_config_rxtx_ring_size_size,
2310 /* *** configure port rxq/txq start/stop *** */
2311 struct cmd_config_rxtx_queue {
2312 cmdline_fixed_string_t port;
2314 cmdline_fixed_string_t rxtxq;
2316 cmdline_fixed_string_t opname;
2320 cmd_config_rxtx_queue_parsed(void *parsed_result,
2321 __attribute__((unused)) struct cmdline *cl,
2322 __attribute__((unused)) void *data)
2324 struct cmd_config_rxtx_queue *res = parsed_result;
2329 if (test_done == 0) {
2330 printf("Please stop forwarding first\n");
2334 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2337 if (port_is_started(res->portid) != 1) {
2338 printf("Please start port %u first\n", res->portid);
2342 if (!strcmp(res->rxtxq, "rxq"))
2344 else if (!strcmp(res->rxtxq, "txq"))
2347 printf("Unknown parameter\n");
2351 if (isrx && rx_queue_id_is_invalid(res->qid))
2353 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2356 if (!strcmp(res->opname, "start"))
2358 else if (!strcmp(res->opname, "stop"))
2361 printf("Unknown parameter\n");
2365 if (isstart && isrx)
2366 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2367 else if (!isstart && isrx)
2368 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2369 else if (isstart && !isrx)
2370 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2372 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2374 if (ret == -ENOTSUP)
2375 printf("Function not supported in PMD driver\n");
2378 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2379 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2380 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2381 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2382 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2384 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2385 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2386 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2387 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2390 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2391 .f = cmd_config_rxtx_queue_parsed,
2393 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2395 (void *)&cmd_config_rxtx_queue_port,
2396 (void *)&cmd_config_rxtx_queue_portid,
2397 (void *)&cmd_config_rxtx_queue_rxtxq,
2398 (void *)&cmd_config_rxtx_queue_qid,
2399 (void *)&cmd_config_rxtx_queue_opname,
2404 /* *** configure port rxq/txq setup *** */
2405 struct cmd_setup_rxtx_queue {
2406 cmdline_fixed_string_t port;
2408 cmdline_fixed_string_t rxtxq;
2410 cmdline_fixed_string_t setup;
2413 /* Common CLI fields for queue setup */
2414 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2415 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2416 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2417 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2418 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2419 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2420 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2421 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2422 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2423 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2426 cmd_setup_rxtx_queue_parsed(
2427 void *parsed_result,
2428 __attribute__((unused)) struct cmdline *cl,
2429 __attribute__((unused)) void *data)
2431 struct cmd_setup_rxtx_queue *res = parsed_result;
2432 struct rte_port *port;
2433 struct rte_mempool *mp;
2434 unsigned int socket_id;
2438 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2441 if (res->portid == (portid_t)RTE_PORT_ALL) {
2442 printf("Invalid port id\n");
2446 if (!strcmp(res->rxtxq, "rxq"))
2448 else if (!strcmp(res->rxtxq, "txq"))
2451 printf("Unknown parameter\n");
2455 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2456 printf("Invalid rx queue\n");
2458 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2459 printf("Invalid tx queue\n");
2463 port = &ports[res->portid];
2465 socket_id = rxring_numa[res->portid];
2466 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2467 socket_id = port->socket_id;
2469 mp = mbuf_pool_find(socket_id);
2471 printf("Failed to setup RX queue: "
2472 "No mempool allocation"
2473 " on the socket %d\n",
2474 rxring_numa[res->portid]);
2477 ret = rte_eth_rx_queue_setup(res->portid,
2479 port->nb_rx_desc[res->qid],
2481 &port->rx_conf[res->qid],
2484 printf("Failed to setup RX queue\n");
2486 socket_id = txring_numa[res->portid];
2487 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2488 socket_id = port->socket_id;
2490 ret = rte_eth_tx_queue_setup(res->portid,
2492 port->nb_tx_desc[res->qid],
2494 &port->tx_conf[res->qid]);
2496 printf("Failed to setup TX queue\n");
2500 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2501 .f = cmd_setup_rxtx_queue_parsed,
2503 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2505 (void *)&cmd_setup_rxtx_queue_port,
2506 (void *)&cmd_setup_rxtx_queue_portid,
2507 (void *)&cmd_setup_rxtx_queue_rxtxq,
2508 (void *)&cmd_setup_rxtx_queue_qid,
2509 (void *)&cmd_setup_rxtx_queue_setup,
2515 /* *** Configure RSS RETA *** */
2516 struct cmd_config_rss_reta {
2517 cmdline_fixed_string_t port;
2518 cmdline_fixed_string_t keyword;
2520 cmdline_fixed_string_t name;
2521 cmdline_fixed_string_t list_name;
2522 cmdline_fixed_string_t list_of_items;
2526 parse_reta_config(const char *str,
2527 struct rte_eth_rss_reta_entry64 *reta_conf,
2528 uint16_t nb_entries)
2532 uint16_t hash_index, idx, shift;
2535 const char *p, *p0 = str;
2542 unsigned long int_fld[_NUM_FLD];
2543 char *str_fld[_NUM_FLD];
2545 while ((p = strchr(p0,'(')) != NULL) {
2547 if((p0 = strchr(p,')')) == NULL)
2551 if(size >= sizeof(s))
2554 snprintf(s, sizeof(s), "%.*s", size, p);
2555 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2557 for (i = 0; i < _NUM_FLD; i++) {
2559 int_fld[i] = strtoul(str_fld[i], &end, 0);
2560 if (errno != 0 || end == str_fld[i] ||
2565 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2566 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2568 if (hash_index >= nb_entries) {
2569 printf("Invalid RETA hash index=%d\n", hash_index);
2573 idx = hash_index / RTE_RETA_GROUP_SIZE;
2574 shift = hash_index % RTE_RETA_GROUP_SIZE;
2575 reta_conf[idx].mask |= (1ULL << shift);
2576 reta_conf[idx].reta[shift] = nb_queue;
2583 cmd_set_rss_reta_parsed(void *parsed_result,
2584 __attribute__((unused)) struct cmdline *cl,
2585 __attribute__((unused)) void *data)
2588 struct rte_eth_dev_info dev_info;
2589 struct rte_eth_rss_reta_entry64 reta_conf[8];
2590 struct cmd_config_rss_reta *res = parsed_result;
2592 memset(&dev_info, 0, sizeof(dev_info));
2593 rte_eth_dev_info_get(res->port_id, &dev_info);
2594 if (dev_info.reta_size == 0) {
2595 printf("Redirection table size is 0 which is "
2596 "invalid for RSS\n");
2599 printf("The reta size of port %d is %u\n",
2600 res->port_id, dev_info.reta_size);
2601 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2602 printf("Currently do not support more than %u entries of "
2603 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2607 memset(reta_conf, 0, sizeof(reta_conf));
2608 if (!strcmp(res->list_name, "reta")) {
2609 if (parse_reta_config(res->list_of_items, reta_conf,
2610 dev_info.reta_size)) {
2611 printf("Invalid RSS Redirection Table "
2612 "config entered\n");
2615 ret = rte_eth_dev_rss_reta_update(res->port_id,
2616 reta_conf, dev_info.reta_size);
2618 printf("Bad redirection table parameter, "
2619 "return code = %d \n", ret);
2623 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2624 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2625 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2626 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2627 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2628 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2629 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2630 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2631 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2632 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2633 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2634 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2636 cmdline_parse_inst_t cmd_config_rss_reta = {
2637 .f = cmd_set_rss_reta_parsed,
2639 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2641 (void *)&cmd_config_rss_reta_port,
2642 (void *)&cmd_config_rss_reta_keyword,
2643 (void *)&cmd_config_rss_reta_port_id,
2644 (void *)&cmd_config_rss_reta_name,
2645 (void *)&cmd_config_rss_reta_list_name,
2646 (void *)&cmd_config_rss_reta_list_of_items,
2651 /* *** SHOW PORT RETA INFO *** */
2652 struct cmd_showport_reta {
2653 cmdline_fixed_string_t show;
2654 cmdline_fixed_string_t port;
2656 cmdline_fixed_string_t rss;
2657 cmdline_fixed_string_t reta;
2659 cmdline_fixed_string_t list_of_items;
2663 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2664 uint16_t nb_entries,
2668 const char *p, *p0 = str;
2673 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2674 RTE_RETA_GROUP_SIZE;
2677 p = strchr(p0, '(');
2681 p0 = strchr(p, ')');
2685 if (size >= sizeof(s)) {
2686 printf("The string size exceeds the internal buffer size\n");
2689 snprintf(s, sizeof(s), "%.*s", size, p);
2690 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2691 if (ret <= 0 || ret != num) {
2692 printf("The bits of masks do not match the number of "
2693 "reta entries: %u\n", num);
2696 for (i = 0; i < ret; i++)
2697 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2703 cmd_showport_reta_parsed(void *parsed_result,
2704 __attribute__((unused)) struct cmdline *cl,
2705 __attribute__((unused)) void *data)
2707 struct cmd_showport_reta *res = parsed_result;
2708 struct rte_eth_rss_reta_entry64 reta_conf[8];
2709 struct rte_eth_dev_info dev_info;
2710 uint16_t max_reta_size;
2712 memset(&dev_info, 0, sizeof(dev_info));
2713 rte_eth_dev_info_get(res->port_id, &dev_info);
2714 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2715 if (res->size == 0 || res->size > max_reta_size) {
2716 printf("Invalid redirection table size: %u (1-%u)\n",
2717 res->size, max_reta_size);
2721 memset(reta_conf, 0, sizeof(reta_conf));
2722 if (showport_parse_reta_config(reta_conf, res->size,
2723 res->list_of_items) < 0) {
2724 printf("Invalid string: %s for reta masks\n",
2725 res->list_of_items);
2728 port_rss_reta_info(res->port_id, reta_conf, res->size);
2731 cmdline_parse_token_string_t cmd_showport_reta_show =
2732 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2733 cmdline_parse_token_string_t cmd_showport_reta_port =
2734 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2735 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2736 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2737 cmdline_parse_token_string_t cmd_showport_reta_rss =
2738 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2739 cmdline_parse_token_string_t cmd_showport_reta_reta =
2740 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2741 cmdline_parse_token_num_t cmd_showport_reta_size =
2742 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2743 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2744 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2745 list_of_items, NULL);
2747 cmdline_parse_inst_t cmd_showport_reta = {
2748 .f = cmd_showport_reta_parsed,
2750 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2752 (void *)&cmd_showport_reta_show,
2753 (void *)&cmd_showport_reta_port,
2754 (void *)&cmd_showport_reta_port_id,
2755 (void *)&cmd_showport_reta_rss,
2756 (void *)&cmd_showport_reta_reta,
2757 (void *)&cmd_showport_reta_size,
2758 (void *)&cmd_showport_reta_list_of_items,
2763 /* *** Show RSS hash configuration *** */
2764 struct cmd_showport_rss_hash {
2765 cmdline_fixed_string_t show;
2766 cmdline_fixed_string_t port;
2768 cmdline_fixed_string_t rss_hash;
2769 cmdline_fixed_string_t rss_type;
2770 cmdline_fixed_string_t key; /* optional argument */
2773 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2774 __attribute__((unused)) struct cmdline *cl,
2777 struct cmd_showport_rss_hash *res = parsed_result;
2779 port_rss_hash_conf_show(res->port_id, res->rss_type,
2780 show_rss_key != NULL);
2783 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2784 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2785 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2786 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2787 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2788 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2789 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2790 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2792 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2793 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2794 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2795 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2796 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2797 "ipv6-tcp-ex#ipv6-udp-ex");
2798 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2799 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2801 cmdline_parse_inst_t cmd_showport_rss_hash = {
2802 .f = cmd_showport_rss_hash_parsed,
2804 .help_str = "show port <port_id> rss-hash "
2805 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2806 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2807 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2809 (void *)&cmd_showport_rss_hash_show,
2810 (void *)&cmd_showport_rss_hash_port,
2811 (void *)&cmd_showport_rss_hash_port_id,
2812 (void *)&cmd_showport_rss_hash_rss_hash,
2813 (void *)&cmd_showport_rss_hash_rss_hash_info,
2818 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2819 .f = cmd_showport_rss_hash_parsed,
2821 .help_str = "show port <port_id> rss-hash "
2822 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2823 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2824 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2826 (void *)&cmd_showport_rss_hash_show,
2827 (void *)&cmd_showport_rss_hash_port,
2828 (void *)&cmd_showport_rss_hash_port_id,
2829 (void *)&cmd_showport_rss_hash_rss_hash,
2830 (void *)&cmd_showport_rss_hash_rss_hash_info,
2831 (void *)&cmd_showport_rss_hash_rss_key,
2836 /* *** Configure DCB *** */
2837 struct cmd_config_dcb {
2838 cmdline_fixed_string_t port;
2839 cmdline_fixed_string_t config;
2841 cmdline_fixed_string_t dcb;
2842 cmdline_fixed_string_t vt;
2843 cmdline_fixed_string_t vt_en;
2845 cmdline_fixed_string_t pfc;
2846 cmdline_fixed_string_t pfc_en;
2850 cmd_config_dcb_parsed(void *parsed_result,
2851 __attribute__((unused)) struct cmdline *cl,
2852 __attribute__((unused)) void *data)
2854 struct cmd_config_dcb *res = parsed_result;
2855 portid_t port_id = res->port_id;
2856 struct rte_port *port;
2860 port = &ports[port_id];
2861 /** Check if the port is not started **/
2862 if (port->port_status != RTE_PORT_STOPPED) {
2863 printf("Please stop port %d first\n", port_id);
2867 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2868 printf("The invalid number of traffic class,"
2869 " only 4 or 8 allowed.\n");
2873 if (nb_fwd_lcores < res->num_tcs) {
2874 printf("nb_cores shouldn't be less than number of TCs.\n");
2877 if (!strncmp(res->pfc_en, "on", 2))
2882 /* DCB in VT mode */
2883 if (!strncmp(res->vt_en, "on", 2))
2884 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2885 (enum rte_eth_nb_tcs)res->num_tcs,
2888 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2889 (enum rte_eth_nb_tcs)res->num_tcs,
2894 printf("Cannot initialize network ports.\n");
2898 cmd_reconfig_device_queue(port_id, 1, 1);
2901 cmdline_parse_token_string_t cmd_config_dcb_port =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2903 cmdline_parse_token_string_t cmd_config_dcb_config =
2904 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2905 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2906 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2907 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2908 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2909 cmdline_parse_token_string_t cmd_config_dcb_vt =
2910 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2911 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2912 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2913 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2914 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2915 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2916 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2917 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2918 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2920 cmdline_parse_inst_t cmd_config_dcb = {
2921 .f = cmd_config_dcb_parsed,
2923 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2925 (void *)&cmd_config_dcb_port,
2926 (void *)&cmd_config_dcb_config,
2927 (void *)&cmd_config_dcb_port_id,
2928 (void *)&cmd_config_dcb_dcb,
2929 (void *)&cmd_config_dcb_vt,
2930 (void *)&cmd_config_dcb_vt_en,
2931 (void *)&cmd_config_dcb_num_tcs,
2932 (void *)&cmd_config_dcb_pfc,
2933 (void *)&cmd_config_dcb_pfc_en,
2938 /* *** configure number of packets per burst *** */
2939 struct cmd_config_burst {
2940 cmdline_fixed_string_t port;
2941 cmdline_fixed_string_t keyword;
2942 cmdline_fixed_string_t all;
2943 cmdline_fixed_string_t name;
2948 cmd_config_burst_parsed(void *parsed_result,
2949 __attribute__((unused)) struct cmdline *cl,
2950 __attribute__((unused)) void *data)
2952 struct cmd_config_burst *res = parsed_result;
2953 struct rte_eth_dev_info dev_info;
2954 uint16_t rec_nb_pkts;
2956 if (!all_ports_stopped()) {
2957 printf("Please stop all ports first\n");
2961 if (!strcmp(res->name, "burst")) {
2962 if (res->value == 0) {
2963 /* If user gives a value of zero, query the PMD for
2964 * its recommended Rx burst size. Testpmd uses a single
2965 * size for all ports, so assume all ports are the same
2966 * NIC model and use the values from Port 0.
2968 rte_eth_dev_info_get(0, &dev_info);
2969 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2971 if (rec_nb_pkts == 0) {
2972 printf("PMD does not recommend a burst size.\n"
2973 "User provided value must be between"
2974 " 1 and %d\n", MAX_PKT_BURST);
2976 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2977 printf("PMD recommended burst size of %d"
2978 " exceeds maximum value of %d\n",
2979 rec_nb_pkts, MAX_PKT_BURST);
2982 printf("Using PMD-provided burst value of %d\n",
2984 nb_pkt_per_burst = rec_nb_pkts;
2985 } else if (res->value > MAX_PKT_BURST) {
2986 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2989 nb_pkt_per_burst = res->value;
2991 printf("Unknown parameter\n");
2997 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3000 cmdline_parse_token_string_t cmd_config_burst_port =
3001 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3002 cmdline_parse_token_string_t cmd_config_burst_keyword =
3003 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3004 cmdline_parse_token_string_t cmd_config_burst_all =
3005 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3006 cmdline_parse_token_string_t cmd_config_burst_name =
3007 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3008 cmdline_parse_token_num_t cmd_config_burst_value =
3009 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3011 cmdline_parse_inst_t cmd_config_burst = {
3012 .f = cmd_config_burst_parsed,
3014 .help_str = "port config all burst <value>",
3016 (void *)&cmd_config_burst_port,
3017 (void *)&cmd_config_burst_keyword,
3018 (void *)&cmd_config_burst_all,
3019 (void *)&cmd_config_burst_name,
3020 (void *)&cmd_config_burst_value,
3025 /* *** configure rx/tx queues *** */
3026 struct cmd_config_thresh {
3027 cmdline_fixed_string_t port;
3028 cmdline_fixed_string_t keyword;
3029 cmdline_fixed_string_t all;
3030 cmdline_fixed_string_t name;
3035 cmd_config_thresh_parsed(void *parsed_result,
3036 __attribute__((unused)) struct cmdline *cl,
3037 __attribute__((unused)) void *data)
3039 struct cmd_config_thresh *res = parsed_result;
3041 if (!all_ports_stopped()) {
3042 printf("Please stop all ports first\n");
3046 if (!strcmp(res->name, "txpt"))
3047 tx_pthresh = res->value;
3048 else if(!strcmp(res->name, "txht"))
3049 tx_hthresh = res->value;
3050 else if(!strcmp(res->name, "txwt"))
3051 tx_wthresh = res->value;
3052 else if(!strcmp(res->name, "rxpt"))
3053 rx_pthresh = res->value;
3054 else if(!strcmp(res->name, "rxht"))
3055 rx_hthresh = res->value;
3056 else if(!strcmp(res->name, "rxwt"))
3057 rx_wthresh = res->value;
3059 printf("Unknown parameter\n");
3065 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3068 cmdline_parse_token_string_t cmd_config_thresh_port =
3069 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3070 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3071 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3072 cmdline_parse_token_string_t cmd_config_thresh_all =
3073 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3074 cmdline_parse_token_string_t cmd_config_thresh_name =
3075 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3076 "txpt#txht#txwt#rxpt#rxht#rxwt");
3077 cmdline_parse_token_num_t cmd_config_thresh_value =
3078 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3080 cmdline_parse_inst_t cmd_config_thresh = {
3081 .f = cmd_config_thresh_parsed,
3083 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3085 (void *)&cmd_config_thresh_port,
3086 (void *)&cmd_config_thresh_keyword,
3087 (void *)&cmd_config_thresh_all,
3088 (void *)&cmd_config_thresh_name,
3089 (void *)&cmd_config_thresh_value,
3094 /* *** configure free/rs threshold *** */
3095 struct cmd_config_threshold {
3096 cmdline_fixed_string_t port;
3097 cmdline_fixed_string_t keyword;
3098 cmdline_fixed_string_t all;
3099 cmdline_fixed_string_t name;
3104 cmd_config_threshold_parsed(void *parsed_result,
3105 __attribute__((unused)) struct cmdline *cl,
3106 __attribute__((unused)) void *data)
3108 struct cmd_config_threshold *res = parsed_result;
3110 if (!all_ports_stopped()) {
3111 printf("Please stop all ports first\n");
3115 if (!strcmp(res->name, "txfreet"))
3116 tx_free_thresh = res->value;
3117 else if (!strcmp(res->name, "txrst"))
3118 tx_rs_thresh = res->value;
3119 else if (!strcmp(res->name, "rxfreet"))
3120 rx_free_thresh = res->value;
3122 printf("Unknown parameter\n");
3128 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3131 cmdline_parse_token_string_t cmd_config_threshold_port =
3132 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3133 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3134 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3136 cmdline_parse_token_string_t cmd_config_threshold_all =
3137 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3138 cmdline_parse_token_string_t cmd_config_threshold_name =
3139 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3140 "txfreet#txrst#rxfreet");
3141 cmdline_parse_token_num_t cmd_config_threshold_value =
3142 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3144 cmdline_parse_inst_t cmd_config_threshold = {
3145 .f = cmd_config_threshold_parsed,
3147 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3149 (void *)&cmd_config_threshold_port,
3150 (void *)&cmd_config_threshold_keyword,
3151 (void *)&cmd_config_threshold_all,
3152 (void *)&cmd_config_threshold_name,
3153 (void *)&cmd_config_threshold_value,
3159 struct cmd_stop_result {
3160 cmdline_fixed_string_t stop;
3163 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3164 __attribute__((unused)) struct cmdline *cl,
3165 __attribute__((unused)) void *data)
3167 stop_packet_forwarding();
3170 cmdline_parse_token_string_t cmd_stop_stop =
3171 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3173 cmdline_parse_inst_t cmd_stop = {
3174 .f = cmd_stop_parsed,
3176 .help_str = "stop: Stop packet forwarding",
3178 (void *)&cmd_stop_stop,
3183 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3186 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3187 unsigned int *parsed_items, int check_unique_values)
3189 unsigned int nb_item;
3197 * First parse all items in the list and store their value.
3202 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3204 if ((c >= '0') && (c <= '9')) {
3205 value = (unsigned int) (value * 10 + (c - '0'));
3210 printf("character %c is not a decimal digit\n", c);
3214 printf("No valid value before comma\n");
3217 if (nb_item < max_items) {
3218 parsed_items[nb_item] = value;
3224 if (nb_item >= max_items) {
3225 printf("Number of %s = %u > %u (maximum items)\n",
3226 item_name, nb_item + 1, max_items);
3229 parsed_items[nb_item++] = value;
3230 if (! check_unique_values)
3234 * Then, check that all values in the list are differents.
3235 * No optimization here...
3237 for (i = 0; i < nb_item; i++) {
3238 for (j = i + 1; j < nb_item; j++) {
3239 if (parsed_items[j] == parsed_items[i]) {
3240 printf("duplicated %s %u at index %u and %u\n",
3241 item_name, parsed_items[i], i, j);
3249 struct cmd_set_list_result {
3250 cmdline_fixed_string_t cmd_keyword;
3251 cmdline_fixed_string_t list_name;
3252 cmdline_fixed_string_t list_of_items;
3255 static void cmd_set_list_parsed(void *parsed_result,
3256 __attribute__((unused)) struct cmdline *cl,
3257 __attribute__((unused)) void *data)
3259 struct cmd_set_list_result *res;
3261 unsigned int lcorelist[RTE_MAX_LCORE];
3262 unsigned int portlist[RTE_MAX_ETHPORTS];
3264 unsigned int nb_item;
3266 if (test_done == 0) {
3267 printf("Please stop forwarding first\n");
3271 res = parsed_result;
3272 if (!strcmp(res->list_name, "corelist")) {
3273 nb_item = parse_item_list(res->list_of_items, "core",
3275 parsed_items.lcorelist, 1);
3277 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3282 if (!strcmp(res->list_name, "portlist")) {
3283 nb_item = parse_item_list(res->list_of_items, "port",
3285 parsed_items.portlist, 1);
3287 set_fwd_ports_list(parsed_items.portlist, nb_item);
3293 cmdline_parse_token_string_t cmd_set_list_keyword =
3294 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3296 cmdline_parse_token_string_t cmd_set_list_name =
3297 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3298 "corelist#portlist");
3299 cmdline_parse_token_string_t cmd_set_list_of_items =
3300 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3303 cmdline_parse_inst_t cmd_set_fwd_list = {
3304 .f = cmd_set_list_parsed,
3306 .help_str = "set corelist|portlist <list0[,list1]*>",
3308 (void *)&cmd_set_list_keyword,
3309 (void *)&cmd_set_list_name,
3310 (void *)&cmd_set_list_of_items,
3315 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3317 struct cmd_setmask_result {
3318 cmdline_fixed_string_t set;
3319 cmdline_fixed_string_t mask;
3323 static void cmd_set_mask_parsed(void *parsed_result,
3324 __attribute__((unused)) struct cmdline *cl,
3325 __attribute__((unused)) void *data)
3327 struct cmd_setmask_result *res = parsed_result;
3329 if (test_done == 0) {
3330 printf("Please stop forwarding first\n");
3333 if (!strcmp(res->mask, "coremask")) {
3334 set_fwd_lcores_mask(res->hexavalue);
3336 } else if (!strcmp(res->mask, "portmask")) {
3337 set_fwd_ports_mask(res->hexavalue);
3342 cmdline_parse_token_string_t cmd_setmask_set =
3343 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3344 cmdline_parse_token_string_t cmd_setmask_mask =
3345 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3346 "coremask#portmask");
3347 cmdline_parse_token_num_t cmd_setmask_value =
3348 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3350 cmdline_parse_inst_t cmd_set_fwd_mask = {
3351 .f = cmd_set_mask_parsed,
3353 .help_str = "set coremask|portmask <hexadecimal value>",
3355 (void *)&cmd_setmask_set,
3356 (void *)&cmd_setmask_mask,
3357 (void *)&cmd_setmask_value,
3363 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3365 struct cmd_set_result {
3366 cmdline_fixed_string_t set;
3367 cmdline_fixed_string_t what;
3371 static void cmd_set_parsed(void *parsed_result,
3372 __attribute__((unused)) struct cmdline *cl,
3373 __attribute__((unused)) void *data)
3375 struct cmd_set_result *res = parsed_result;
3376 if (!strcmp(res->what, "nbport")) {
3377 set_fwd_ports_number(res->value);
3379 } else if (!strcmp(res->what, "nbcore")) {
3380 set_fwd_lcores_number(res->value);
3382 } else if (!strcmp(res->what, "burst"))
3383 set_nb_pkt_per_burst(res->value);
3384 else if (!strcmp(res->what, "verbose"))
3385 set_verbose_level(res->value);
3388 cmdline_parse_token_string_t cmd_set_set =
3389 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3390 cmdline_parse_token_string_t cmd_set_what =
3391 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3392 "nbport#nbcore#burst#verbose");
3393 cmdline_parse_token_num_t cmd_set_value =
3394 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3396 cmdline_parse_inst_t cmd_set_numbers = {
3397 .f = cmd_set_parsed,
3399 .help_str = "set nbport|nbcore|burst|verbose <value>",
3401 (void *)&cmd_set_set,
3402 (void *)&cmd_set_what,
3403 (void *)&cmd_set_value,
3408 /* *** SET LOG LEVEL CONFIGURATION *** */
3410 struct cmd_set_log_result {
3411 cmdline_fixed_string_t set;
3412 cmdline_fixed_string_t log;
3413 cmdline_fixed_string_t type;
3418 cmd_set_log_parsed(void *parsed_result,
3419 __attribute__((unused)) struct cmdline *cl,
3420 __attribute__((unused)) void *data)
3422 struct cmd_set_log_result *res;
3425 res = parsed_result;
3426 if (!strcmp(res->type, "global"))
3427 rte_log_set_global_level(res->level);
3429 ret = rte_log_set_level_regexp(res->type, res->level);
3431 printf("Unable to set log level\n");
3435 cmdline_parse_token_string_t cmd_set_log_set =
3436 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3437 cmdline_parse_token_string_t cmd_set_log_log =
3438 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3439 cmdline_parse_token_string_t cmd_set_log_type =
3440 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3441 cmdline_parse_token_num_t cmd_set_log_level =
3442 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3444 cmdline_parse_inst_t cmd_set_log = {
3445 .f = cmd_set_log_parsed,
3447 .help_str = "set log global|<type> <level>",
3449 (void *)&cmd_set_log_set,
3450 (void *)&cmd_set_log_log,
3451 (void *)&cmd_set_log_type,
3452 (void *)&cmd_set_log_level,
3457 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3459 struct cmd_set_txpkts_result {
3460 cmdline_fixed_string_t cmd_keyword;
3461 cmdline_fixed_string_t txpkts;
3462 cmdline_fixed_string_t seg_lengths;
3466 cmd_set_txpkts_parsed(void *parsed_result,
3467 __attribute__((unused)) struct cmdline *cl,
3468 __attribute__((unused)) void *data)
3470 struct cmd_set_txpkts_result *res;
3471 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3472 unsigned int nb_segs;
3474 res = parsed_result;
3475 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3476 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3478 set_tx_pkt_segments(seg_lengths, nb_segs);
3481 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3482 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3483 cmd_keyword, "set");
3484 cmdline_parse_token_string_t cmd_set_txpkts_name =
3485 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3487 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3488 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3491 cmdline_parse_inst_t cmd_set_txpkts = {
3492 .f = cmd_set_txpkts_parsed,
3494 .help_str = "set txpkts <len0[,len1]*>",
3496 (void *)&cmd_set_txpkts_keyword,
3497 (void *)&cmd_set_txpkts_name,
3498 (void *)&cmd_set_txpkts_lengths,
3503 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3505 struct cmd_set_txsplit_result {
3506 cmdline_fixed_string_t cmd_keyword;
3507 cmdline_fixed_string_t txsplit;
3508 cmdline_fixed_string_t mode;
3512 cmd_set_txsplit_parsed(void *parsed_result,
3513 __attribute__((unused)) struct cmdline *cl,
3514 __attribute__((unused)) void *data)
3516 struct cmd_set_txsplit_result *res;
3518 res = parsed_result;
3519 set_tx_pkt_split(res->mode);
3522 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3523 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3524 cmd_keyword, "set");
3525 cmdline_parse_token_string_t cmd_set_txsplit_name =
3526 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3527 txsplit, "txsplit");
3528 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3529 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3532 cmdline_parse_inst_t cmd_set_txsplit = {
3533 .f = cmd_set_txsplit_parsed,
3535 .help_str = "set txsplit on|off|rand",
3537 (void *)&cmd_set_txsplit_keyword,
3538 (void *)&cmd_set_txsplit_name,
3539 (void *)&cmd_set_txsplit_mode,
3544 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3545 struct cmd_rx_vlan_filter_all_result {
3546 cmdline_fixed_string_t rx_vlan;
3547 cmdline_fixed_string_t what;
3548 cmdline_fixed_string_t all;
3553 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3554 __attribute__((unused)) struct cmdline *cl,
3555 __attribute__((unused)) void *data)
3557 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3559 if (!strcmp(res->what, "add"))
3560 rx_vlan_all_filter_set(res->port_id, 1);
3562 rx_vlan_all_filter_set(res->port_id, 0);
3565 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3566 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3567 rx_vlan, "rx_vlan");
3568 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3569 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3571 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3572 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3574 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3575 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3578 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3579 .f = cmd_rx_vlan_filter_all_parsed,
3581 .help_str = "rx_vlan add|rm all <port_id>: "
3582 "Add/Remove all identifiers to/from the set of VLAN "
3583 "identifiers filtered by a port",
3585 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3586 (void *)&cmd_rx_vlan_filter_all_what,
3587 (void *)&cmd_rx_vlan_filter_all_all,
3588 (void *)&cmd_rx_vlan_filter_all_portid,
3593 /* *** VLAN OFFLOAD SET ON A PORT *** */
3594 struct cmd_vlan_offload_result {
3595 cmdline_fixed_string_t vlan;
3596 cmdline_fixed_string_t set;
3597 cmdline_fixed_string_t vlan_type;
3598 cmdline_fixed_string_t what;
3599 cmdline_fixed_string_t on;
3600 cmdline_fixed_string_t port_id;
3604 cmd_vlan_offload_parsed(void *parsed_result,
3605 __attribute__((unused)) struct cmdline *cl,
3606 __attribute__((unused)) void *data)
3609 struct cmd_vlan_offload_result *res = parsed_result;
3612 portid_t port_id = 0;
3616 len = strnlen(str, STR_TOKEN_SIZE);
3618 /* Get port_id first */
3626 tmp = strtoul(str, NULL, 0);
3627 /* If port_id greater that what portid_t can represent, return */
3628 if(tmp >= RTE_MAX_ETHPORTS)
3630 port_id = (portid_t)tmp;
3632 if (!strcmp(res->on, "on"))
3637 if (!strcmp(res->what, "strip"))
3638 rx_vlan_strip_set(port_id, on);
3639 else if(!strcmp(res->what, "stripq")){
3640 uint16_t queue_id = 0;
3642 /* No queue_id, return */
3644 printf("must specify (port,queue_id)\n");
3647 tmp = strtoul(str + i + 1, NULL, 0);
3648 /* If queue_id greater that what 16-bits can represent, return */
3652 queue_id = (uint16_t)tmp;
3653 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3655 else if (!strcmp(res->what, "filter"))
3656 rx_vlan_filter_set(port_id, on);
3658 vlan_extend_set(port_id, on);
3663 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3664 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3666 cmdline_parse_token_string_t cmd_vlan_offload_set =
3667 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3669 cmdline_parse_token_string_t cmd_vlan_offload_what =
3670 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3671 what, "strip#filter#qinq#stripq");
3672 cmdline_parse_token_string_t cmd_vlan_offload_on =
3673 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3675 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3676 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3679 cmdline_parse_inst_t cmd_vlan_offload = {
3680 .f = cmd_vlan_offload_parsed,
3682 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3683 "<port_id[,queue_id]>: "
3684 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3686 (void *)&cmd_vlan_offload_vlan,
3687 (void *)&cmd_vlan_offload_set,
3688 (void *)&cmd_vlan_offload_what,
3689 (void *)&cmd_vlan_offload_on,
3690 (void *)&cmd_vlan_offload_portid,
3695 /* *** VLAN TPID SET ON A PORT *** */
3696 struct cmd_vlan_tpid_result {
3697 cmdline_fixed_string_t vlan;
3698 cmdline_fixed_string_t set;
3699 cmdline_fixed_string_t vlan_type;
3700 cmdline_fixed_string_t what;
3706 cmd_vlan_tpid_parsed(void *parsed_result,
3707 __attribute__((unused)) struct cmdline *cl,
3708 __attribute__((unused)) void *data)
3710 struct cmd_vlan_tpid_result *res = parsed_result;
3711 enum rte_vlan_type vlan_type;
3713 if (!strcmp(res->vlan_type, "inner"))
3714 vlan_type = ETH_VLAN_TYPE_INNER;
3715 else if (!strcmp(res->vlan_type, "outer"))
3716 vlan_type = ETH_VLAN_TYPE_OUTER;
3718 printf("Unknown vlan type\n");
3721 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3724 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3725 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3727 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3728 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3730 cmdline_parse_token_string_t cmd_vlan_type =
3731 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3732 vlan_type, "inner#outer");
3733 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3734 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3736 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3737 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3739 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3740 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3743 cmdline_parse_inst_t cmd_vlan_tpid = {
3744 .f = cmd_vlan_tpid_parsed,
3746 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3747 "Set the VLAN Ether type",
3749 (void *)&cmd_vlan_tpid_vlan,
3750 (void *)&cmd_vlan_tpid_set,
3751 (void *)&cmd_vlan_type,
3752 (void *)&cmd_vlan_tpid_what,
3753 (void *)&cmd_vlan_tpid_tpid,
3754 (void *)&cmd_vlan_tpid_portid,
3759 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3760 struct cmd_rx_vlan_filter_result {
3761 cmdline_fixed_string_t rx_vlan;
3762 cmdline_fixed_string_t what;
3768 cmd_rx_vlan_filter_parsed(void *parsed_result,
3769 __attribute__((unused)) struct cmdline *cl,
3770 __attribute__((unused)) void *data)
3772 struct cmd_rx_vlan_filter_result *res = parsed_result;
3774 if (!strcmp(res->what, "add"))
3775 rx_vft_set(res->port_id, res->vlan_id, 1);
3777 rx_vft_set(res->port_id, res->vlan_id, 0);
3780 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3781 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3782 rx_vlan, "rx_vlan");
3783 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3784 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3786 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3787 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3789 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3790 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3793 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3794 .f = cmd_rx_vlan_filter_parsed,
3796 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3797 "Add/Remove a VLAN identifier to/from the set of VLAN "
3798 "identifiers filtered by a port",
3800 (void *)&cmd_rx_vlan_filter_rx_vlan,
3801 (void *)&cmd_rx_vlan_filter_what,
3802 (void *)&cmd_rx_vlan_filter_vlanid,
3803 (void *)&cmd_rx_vlan_filter_portid,
3808 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3809 struct cmd_tx_vlan_set_result {
3810 cmdline_fixed_string_t tx_vlan;
3811 cmdline_fixed_string_t set;
3817 cmd_tx_vlan_set_parsed(void *parsed_result,
3818 __attribute__((unused)) struct cmdline *cl,
3819 __attribute__((unused)) void *data)
3821 struct cmd_tx_vlan_set_result *res = parsed_result;
3823 if (!port_is_stopped(res->port_id)) {
3824 printf("Please stop port %d first\n", res->port_id);
3828 tx_vlan_set(res->port_id, res->vlan_id);
3830 cmd_reconfig_device_queue(res->port_id, 1, 1);
3833 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3834 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3835 tx_vlan, "tx_vlan");
3836 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3837 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3839 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3840 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3842 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3843 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3846 cmdline_parse_inst_t cmd_tx_vlan_set = {
3847 .f = cmd_tx_vlan_set_parsed,
3849 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3850 "Enable hardware insertion of a single VLAN header "
3851 "with a given TAG Identifier in packets sent on a port",
3853 (void *)&cmd_tx_vlan_set_tx_vlan,
3854 (void *)&cmd_tx_vlan_set_set,
3855 (void *)&cmd_tx_vlan_set_portid,
3856 (void *)&cmd_tx_vlan_set_vlanid,
3861 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3862 struct cmd_tx_vlan_set_qinq_result {
3863 cmdline_fixed_string_t tx_vlan;
3864 cmdline_fixed_string_t set;
3867 uint16_t vlan_id_outer;
3871 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3872 __attribute__((unused)) struct cmdline *cl,
3873 __attribute__((unused)) void *data)
3875 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3877 if (!port_is_stopped(res->port_id)) {
3878 printf("Please stop port %d first\n", res->port_id);
3882 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3884 cmd_reconfig_device_queue(res->port_id, 1, 1);
3887 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3888 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3889 tx_vlan, "tx_vlan");
3890 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3891 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3893 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3894 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3896 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3897 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3899 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3900 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3901 vlan_id_outer, UINT16);
3903 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3904 .f = cmd_tx_vlan_set_qinq_parsed,
3906 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3907 "Enable hardware insertion of double VLAN header "
3908 "with given TAG Identifiers in packets sent on a port",
3910 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3911 (void *)&cmd_tx_vlan_set_qinq_set,
3912 (void *)&cmd_tx_vlan_set_qinq_portid,
3913 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3914 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3919 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3920 struct cmd_tx_vlan_set_pvid_result {
3921 cmdline_fixed_string_t tx_vlan;
3922 cmdline_fixed_string_t set;
3923 cmdline_fixed_string_t pvid;
3926 cmdline_fixed_string_t mode;
3930 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3931 __attribute__((unused)) struct cmdline *cl,
3932 __attribute__((unused)) void *data)
3934 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3936 if (strcmp(res->mode, "on") == 0)
3937 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3939 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3942 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3943 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3944 tx_vlan, "tx_vlan");
3945 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3946 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3948 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3949 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3951 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3952 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3954 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3955 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3957 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3958 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3961 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3962 .f = cmd_tx_vlan_set_pvid_parsed,
3964 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3966 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3967 (void *)&cmd_tx_vlan_set_pvid_set,
3968 (void *)&cmd_tx_vlan_set_pvid_pvid,
3969 (void *)&cmd_tx_vlan_set_pvid_port_id,
3970 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3971 (void *)&cmd_tx_vlan_set_pvid_mode,
3976 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3977 struct cmd_tx_vlan_reset_result {
3978 cmdline_fixed_string_t tx_vlan;
3979 cmdline_fixed_string_t reset;
3984 cmd_tx_vlan_reset_parsed(void *parsed_result,
3985 __attribute__((unused)) struct cmdline *cl,
3986 __attribute__((unused)) void *data)
3988 struct cmd_tx_vlan_reset_result *res = parsed_result;
3990 if (!port_is_stopped(res->port_id)) {
3991 printf("Please stop port %d first\n", res->port_id);
3995 tx_vlan_reset(res->port_id);
3997 cmd_reconfig_device_queue(res->port_id, 1, 1);
4000 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4001 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4002 tx_vlan, "tx_vlan");
4003 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4004 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4006 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4007 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4010 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4011 .f = cmd_tx_vlan_reset_parsed,
4013 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4014 "VLAN header in packets sent on a port",
4016 (void *)&cmd_tx_vlan_reset_tx_vlan,
4017 (void *)&cmd_tx_vlan_reset_reset,
4018 (void *)&cmd_tx_vlan_reset_portid,
4024 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4025 struct cmd_csum_result {
4026 cmdline_fixed_string_t csum;
4027 cmdline_fixed_string_t mode;
4028 cmdline_fixed_string_t proto;
4029 cmdline_fixed_string_t hwsw;
4034 csum_show(int port_id)
4036 struct rte_eth_dev_info dev_info;
4037 uint64_t tx_offloads;
4039 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4040 printf("Parse tunnel is %s\n",
4041 (ports[port_id].parse_tunnel) ? "on" : "off");
4042 printf("IP checksum offload is %s\n",
4043 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4044 printf("UDP checksum offload is %s\n",
4045 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4046 printf("TCP checksum offload is %s\n",
4047 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4048 printf("SCTP checksum offload is %s\n",
4049 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4050 printf("Outer-Ip checksum offload is %s\n",
4051 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4053 /* display warnings if configuration is not supported by the NIC */
4054 rte_eth_dev_info_get(port_id, &dev_info);
4055 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4056 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4057 printf("Warning: hardware IP checksum enabled but not "
4058 "supported by port %d\n", port_id);
4060 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4061 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4062 printf("Warning: hardware UDP checksum enabled but not "
4063 "supported by port %d\n", port_id);
4065 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4066 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4067 printf("Warning: hardware TCP checksum enabled but not "
4068 "supported by port %d\n", port_id);
4070 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4071 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4072 printf("Warning: hardware SCTP checksum enabled but not "
4073 "supported by port %d\n", port_id);
4075 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4076 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4077 printf("Warning: hardware outer IP checksum enabled but not "
4078 "supported by port %d\n", port_id);
4083 cmd_csum_parsed(void *parsed_result,
4084 __attribute__((unused)) struct cmdline *cl,
4085 __attribute__((unused)) void *data)
4087 struct cmd_csum_result *res = parsed_result;
4089 uint64_t csum_offloads = 0;
4090 struct rte_eth_dev_info dev_info;
4092 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4093 printf("invalid port %d\n", res->port_id);
4096 if (!port_is_stopped(res->port_id)) {
4097 printf("Please stop port %d first\n", res->port_id);
4101 rte_eth_dev_info_get(res->port_id, &dev_info);
4102 if (!strcmp(res->mode, "set")) {
4104 if (!strcmp(res->hwsw, "hw"))
4107 if (!strcmp(res->proto, "ip")) {
4108 if (hw == 0 || (dev_info.tx_offload_capa &
4109 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4110 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4112 printf("IP checksum offload is not supported "
4113 "by port %u\n", res->port_id);
4115 } else if (!strcmp(res->proto, "udp")) {
4116 if (hw == 0 || (dev_info.tx_offload_capa &
4117 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4118 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4120 printf("UDP checksum offload is not supported "
4121 "by port %u\n", res->port_id);
4123 } else if (!strcmp(res->proto, "tcp")) {
4124 if (hw == 0 || (dev_info.tx_offload_capa &
4125 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4126 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4128 printf("TCP checksum offload is not supported "
4129 "by port %u\n", res->port_id);
4131 } else if (!strcmp(res->proto, "sctp")) {
4132 if (hw == 0 || (dev_info.tx_offload_capa &
4133 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4134 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4136 printf("SCTP checksum offload is not supported "
4137 "by port %u\n", res->port_id);
4139 } else if (!strcmp(res->proto, "outer-ip")) {
4140 if (hw == 0 || (dev_info.tx_offload_capa &
4141 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4143 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4145 printf("Outer IP checksum offload is not "
4146 "supported by port %u\n", res->port_id);
4151 ports[res->port_id].dev_conf.txmode.offloads |=
4154 ports[res->port_id].dev_conf.txmode.offloads &=
4158 csum_show(res->port_id);
4160 cmd_reconfig_device_queue(res->port_id, 1, 1);
4163 cmdline_parse_token_string_t cmd_csum_csum =
4164 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4166 cmdline_parse_token_string_t cmd_csum_mode =
4167 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4169 cmdline_parse_token_string_t cmd_csum_proto =
4170 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4171 proto, "ip#tcp#udp#sctp#outer-ip");
4172 cmdline_parse_token_string_t cmd_csum_hwsw =
4173 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4175 cmdline_parse_token_num_t cmd_csum_portid =
4176 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4179 cmdline_parse_inst_t cmd_csum_set = {
4180 .f = cmd_csum_parsed,
4182 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4183 "Enable/Disable hardware calculation of L3/L4 checksum when "
4184 "using csum forward engine",
4186 (void *)&cmd_csum_csum,
4187 (void *)&cmd_csum_mode,
4188 (void *)&cmd_csum_proto,
4189 (void *)&cmd_csum_hwsw,
4190 (void *)&cmd_csum_portid,
4195 cmdline_parse_token_string_t cmd_csum_mode_show =
4196 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4199 cmdline_parse_inst_t cmd_csum_show = {
4200 .f = cmd_csum_parsed,
4202 .help_str = "csum show <port_id>: Show checksum offload configuration",
4204 (void *)&cmd_csum_csum,
4205 (void *)&cmd_csum_mode_show,
4206 (void *)&cmd_csum_portid,
4211 /* Enable/disable tunnel parsing */
4212 struct cmd_csum_tunnel_result {
4213 cmdline_fixed_string_t csum;
4214 cmdline_fixed_string_t parse;
4215 cmdline_fixed_string_t onoff;
4220 cmd_csum_tunnel_parsed(void *parsed_result,
4221 __attribute__((unused)) struct cmdline *cl,
4222 __attribute__((unused)) void *data)
4224 struct cmd_csum_tunnel_result *res = parsed_result;
4226 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4229 if (!strcmp(res->onoff, "on"))
4230 ports[res->port_id].parse_tunnel = 1;
4232 ports[res->port_id].parse_tunnel = 0;
4234 csum_show(res->port_id);
4237 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4238 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4240 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4241 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4242 parse, "parse_tunnel");
4243 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4244 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4246 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4247 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4250 cmdline_parse_inst_t cmd_csum_tunnel = {
4251 .f = cmd_csum_tunnel_parsed,
4253 .help_str = "csum parse_tunnel on|off <port_id>: "
4254 "Enable/Disable parsing of tunnels for csum engine",
4256 (void *)&cmd_csum_tunnel_csum,
4257 (void *)&cmd_csum_tunnel_parse,
4258 (void *)&cmd_csum_tunnel_onoff,
4259 (void *)&cmd_csum_tunnel_portid,
4264 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4265 struct cmd_tso_set_result {
4266 cmdline_fixed_string_t tso;
4267 cmdline_fixed_string_t mode;
4273 cmd_tso_set_parsed(void *parsed_result,
4274 __attribute__((unused)) struct cmdline *cl,
4275 __attribute__((unused)) void *data)
4277 struct cmd_tso_set_result *res = parsed_result;
4278 struct rte_eth_dev_info dev_info;
4280 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4282 if (!port_is_stopped(res->port_id)) {
4283 printf("Please stop port %d first\n", res->port_id);
4287 if (!strcmp(res->mode, "set"))
4288 ports[res->port_id].tso_segsz = res->tso_segsz;
4290 rte_eth_dev_info_get(res->port_id, &dev_info);
4291 if ((ports[res->port_id].tso_segsz != 0) &&
4292 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4293 printf("Error: TSO is not supported by port %d\n",
4298 if (ports[res->port_id].tso_segsz == 0) {
4299 ports[res->port_id].dev_conf.txmode.offloads &=
4300 ~DEV_TX_OFFLOAD_TCP_TSO;
4301 printf("TSO for non-tunneled packets is disabled\n");
4303 ports[res->port_id].dev_conf.txmode.offloads |=
4304 DEV_TX_OFFLOAD_TCP_TSO;
4305 printf("TSO segment size for non-tunneled packets is %d\n",
4306 ports[res->port_id].tso_segsz);
4309 /* display warnings if configuration is not supported by the NIC */
4310 rte_eth_dev_info_get(res->port_id, &dev_info);
4311 if ((ports[res->port_id].tso_segsz != 0) &&
4312 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4313 printf("Warning: TSO enabled but not "
4314 "supported by port %d\n", res->port_id);
4317 cmd_reconfig_device_queue(res->port_id, 1, 1);
4320 cmdline_parse_token_string_t cmd_tso_set_tso =
4321 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4323 cmdline_parse_token_string_t cmd_tso_set_mode =
4324 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4326 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4327 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4329 cmdline_parse_token_num_t cmd_tso_set_portid =
4330 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4333 cmdline_parse_inst_t cmd_tso_set = {
4334 .f = cmd_tso_set_parsed,
4336 .help_str = "tso set <tso_segsz> <port_id>: "
4337 "Set TSO segment size of non-tunneled packets for csum engine "
4340 (void *)&cmd_tso_set_tso,
4341 (void *)&cmd_tso_set_mode,
4342 (void *)&cmd_tso_set_tso_segsz,
4343 (void *)&cmd_tso_set_portid,
4348 cmdline_parse_token_string_t cmd_tso_show_mode =
4349 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4353 cmdline_parse_inst_t cmd_tso_show = {
4354 .f = cmd_tso_set_parsed,
4356 .help_str = "tso show <port_id>: "
4357 "Show TSO segment size of non-tunneled packets for csum engine",
4359 (void *)&cmd_tso_set_tso,
4360 (void *)&cmd_tso_show_mode,
4361 (void *)&cmd_tso_set_portid,
4366 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4367 struct cmd_tunnel_tso_set_result {
4368 cmdline_fixed_string_t tso;
4369 cmdline_fixed_string_t mode;
4374 static struct rte_eth_dev_info
4375 check_tunnel_tso_nic_support(portid_t port_id)
4377 struct rte_eth_dev_info dev_info;
4379 rte_eth_dev_info_get(port_id, &dev_info);
4380 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4381 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4382 "not enabled for port %d\n", port_id);
4383 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4384 printf("Warning: GRE TUNNEL TSO not supported therefore "
4385 "not enabled for port %d\n", port_id);
4386 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4387 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4388 "not enabled for port %d\n", port_id);
4389 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4390 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4391 "not enabled for port %d\n", port_id);
4392 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4393 printf("Warning: IP TUNNEL TSO not supported therefore "
4394 "not enabled for port %d\n", port_id);
4395 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4396 printf("Warning: UDP TUNNEL TSO not supported therefore "
4397 "not enabled for port %d\n", port_id);
4402 cmd_tunnel_tso_set_parsed(void *parsed_result,
4403 __attribute__((unused)) struct cmdline *cl,
4404 __attribute__((unused)) void *data)
4406 struct cmd_tunnel_tso_set_result *res = parsed_result;
4407 struct rte_eth_dev_info dev_info;
4409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4411 if (!port_is_stopped(res->port_id)) {
4412 printf("Please stop port %d first\n", res->port_id);
4416 if (!strcmp(res->mode, "set"))
4417 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4419 dev_info = check_tunnel_tso_nic_support(res->port_id);
4420 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4421 ports[res->port_id].dev_conf.txmode.offloads &=
4422 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4423 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4424 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4425 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4426 DEV_TX_OFFLOAD_IP_TNL_TSO |
4427 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4428 printf("TSO for tunneled packets is disabled\n");
4430 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4431 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4432 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4433 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4434 DEV_TX_OFFLOAD_IP_TNL_TSO |
4435 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4437 ports[res->port_id].dev_conf.txmode.offloads |=
4438 (tso_offloads & dev_info.tx_offload_capa);
4439 printf("TSO segment size for tunneled packets is %d\n",
4440 ports[res->port_id].tunnel_tso_segsz);
4442 /* Below conditions are needed to make it work:
4443 * (1) tunnel TSO is supported by the NIC;
4444 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4446 * (3) for tunneled pkts with outer L3 of IPv4,
4447 * "csum set outer-ip" must be set to hw, because after tso,
4448 * total_len of outer IP header is changed, and the checksum
4449 * of outer IP header calculated by sw should be wrong; that
4450 * is not necessary for IPv6 tunneled pkts because there's no
4451 * checksum in IP header anymore.
4454 if (!ports[res->port_id].parse_tunnel)
4455 printf("Warning: csum parse_tunnel must be set "
4456 "so that tunneled packets are recognized\n");
4457 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4458 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4459 printf("Warning: csum set outer-ip must be set to hw "
4460 "if outer L3 is IPv4; not necessary for IPv6\n");
4463 cmd_reconfig_device_queue(res->port_id, 1, 1);
4466 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4467 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4469 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4470 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4472 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4473 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4475 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4476 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4479 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4480 .f = cmd_tunnel_tso_set_parsed,
4482 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4483 "Set TSO segment size of tunneled packets for csum engine "
4486 (void *)&cmd_tunnel_tso_set_tso,
4487 (void *)&cmd_tunnel_tso_set_mode,
4488 (void *)&cmd_tunnel_tso_set_tso_segsz,
4489 (void *)&cmd_tunnel_tso_set_portid,
4494 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4495 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4499 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4500 .f = cmd_tunnel_tso_set_parsed,
4502 .help_str = "tunnel_tso show <port_id> "
4503 "Show TSO segment size of tunneled packets for csum engine",
4505 (void *)&cmd_tunnel_tso_set_tso,
4506 (void *)&cmd_tunnel_tso_show_mode,
4507 (void *)&cmd_tunnel_tso_set_portid,
4512 /* *** SET GRO FOR A PORT *** */
4513 struct cmd_gro_enable_result {
4514 cmdline_fixed_string_t cmd_set;
4515 cmdline_fixed_string_t cmd_port;
4516 cmdline_fixed_string_t cmd_keyword;
4517 cmdline_fixed_string_t cmd_onoff;
4522 cmd_gro_enable_parsed(void *parsed_result,
4523 __attribute__((unused)) struct cmdline *cl,
4524 __attribute__((unused)) void *data)
4526 struct cmd_gro_enable_result *res;
4528 res = parsed_result;
4529 if (!strcmp(res->cmd_keyword, "gro"))
4530 setup_gro(res->cmd_onoff, res->cmd_pid);
4533 cmdline_parse_token_string_t cmd_gro_enable_set =
4534 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4536 cmdline_parse_token_string_t cmd_gro_enable_port =
4537 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4538 cmd_keyword, "port");
4539 cmdline_parse_token_num_t cmd_gro_enable_pid =
4540 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4542 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4543 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4544 cmd_keyword, "gro");
4545 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4546 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4547 cmd_onoff, "on#off");
4549 cmdline_parse_inst_t cmd_gro_enable = {
4550 .f = cmd_gro_enable_parsed,
4552 .help_str = "set port <port_id> gro on|off",
4554 (void *)&cmd_gro_enable_set,
4555 (void *)&cmd_gro_enable_port,
4556 (void *)&cmd_gro_enable_pid,
4557 (void *)&cmd_gro_enable_keyword,
4558 (void *)&cmd_gro_enable_onoff,
4563 /* *** DISPLAY GRO CONFIGURATION *** */
4564 struct cmd_gro_show_result {
4565 cmdline_fixed_string_t cmd_show;
4566 cmdline_fixed_string_t cmd_port;
4567 cmdline_fixed_string_t cmd_keyword;
4572 cmd_gro_show_parsed(void *parsed_result,
4573 __attribute__((unused)) struct cmdline *cl,
4574 __attribute__((unused)) void *data)
4576 struct cmd_gro_show_result *res;
4578 res = parsed_result;
4579 if (!strcmp(res->cmd_keyword, "gro"))
4580 show_gro(res->cmd_pid);
4583 cmdline_parse_token_string_t cmd_gro_show_show =
4584 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4586 cmdline_parse_token_string_t cmd_gro_show_port =
4587 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4589 cmdline_parse_token_num_t cmd_gro_show_pid =
4590 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4592 cmdline_parse_token_string_t cmd_gro_show_keyword =
4593 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4594 cmd_keyword, "gro");
4596 cmdline_parse_inst_t cmd_gro_show = {
4597 .f = cmd_gro_show_parsed,
4599 .help_str = "show port <port_id> gro",
4601 (void *)&cmd_gro_show_show,
4602 (void *)&cmd_gro_show_port,
4603 (void *)&cmd_gro_show_pid,
4604 (void *)&cmd_gro_show_keyword,
4609 /* *** SET FLUSH CYCLES FOR GRO *** */
4610 struct cmd_gro_flush_result {
4611 cmdline_fixed_string_t cmd_set;
4612 cmdline_fixed_string_t cmd_keyword;
4613 cmdline_fixed_string_t cmd_flush;
4618 cmd_gro_flush_parsed(void *parsed_result,
4619 __attribute__((unused)) struct cmdline *cl,
4620 __attribute__((unused)) void *data)
4622 struct cmd_gro_flush_result *res;
4624 res = parsed_result;
4625 if ((!strcmp(res->cmd_keyword, "gro")) &&
4626 (!strcmp(res->cmd_flush, "flush")))
4627 setup_gro_flush_cycles(res->cmd_cycles);
4630 cmdline_parse_token_string_t cmd_gro_flush_set =
4631 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4633 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4634 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4635 cmd_keyword, "gro");
4636 cmdline_parse_token_string_t cmd_gro_flush_flush =
4637 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4638 cmd_flush, "flush");
4639 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4640 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4643 cmdline_parse_inst_t cmd_gro_flush = {
4644 .f = cmd_gro_flush_parsed,
4646 .help_str = "set gro flush <cycles>",
4648 (void *)&cmd_gro_flush_set,
4649 (void *)&cmd_gro_flush_keyword,
4650 (void *)&cmd_gro_flush_flush,
4651 (void *)&cmd_gro_flush_cycles,
4656 /* *** ENABLE/DISABLE GSO *** */
4657 struct cmd_gso_enable_result {
4658 cmdline_fixed_string_t cmd_set;
4659 cmdline_fixed_string_t cmd_port;
4660 cmdline_fixed_string_t cmd_keyword;
4661 cmdline_fixed_string_t cmd_mode;
4666 cmd_gso_enable_parsed(void *parsed_result,
4667 __attribute__((unused)) struct cmdline *cl,
4668 __attribute__((unused)) void *data)
4670 struct cmd_gso_enable_result *res;
4672 res = parsed_result;
4673 if (!strcmp(res->cmd_keyword, "gso"))
4674 setup_gso(res->cmd_mode, res->cmd_pid);
4677 cmdline_parse_token_string_t cmd_gso_enable_set =
4678 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4680 cmdline_parse_token_string_t cmd_gso_enable_port =
4681 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4683 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4684 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4685 cmd_keyword, "gso");
4686 cmdline_parse_token_string_t cmd_gso_enable_mode =
4687 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4688 cmd_mode, "on#off");
4689 cmdline_parse_token_num_t cmd_gso_enable_pid =
4690 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4693 cmdline_parse_inst_t cmd_gso_enable = {
4694 .f = cmd_gso_enable_parsed,
4696 .help_str = "set port <port_id> gso on|off",
4698 (void *)&cmd_gso_enable_set,
4699 (void *)&cmd_gso_enable_port,
4700 (void *)&cmd_gso_enable_pid,
4701 (void *)&cmd_gso_enable_keyword,
4702 (void *)&cmd_gso_enable_mode,
4707 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4708 struct cmd_gso_size_result {
4709 cmdline_fixed_string_t cmd_set;
4710 cmdline_fixed_string_t cmd_keyword;
4711 cmdline_fixed_string_t cmd_segsz;
4716 cmd_gso_size_parsed(void *parsed_result,
4717 __attribute__((unused)) struct cmdline *cl,
4718 __attribute__((unused)) void *data)
4720 struct cmd_gso_size_result *res = parsed_result;
4722 if (test_done == 0) {
4723 printf("Before setting GSO segsz, please first"
4724 " stop fowarding\n");
4728 if (!strcmp(res->cmd_keyword, "gso") &&
4729 !strcmp(res->cmd_segsz, "segsz")) {
4730 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4731 printf("gso_size should be larger than %zu."
4732 " Please input a legal value\n",
4733 RTE_GSO_SEG_SIZE_MIN);
4735 gso_max_segment_size = res->cmd_size;
4739 cmdline_parse_token_string_t cmd_gso_size_set =
4740 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4742 cmdline_parse_token_string_t cmd_gso_size_keyword =
4743 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4744 cmd_keyword, "gso");
4745 cmdline_parse_token_string_t cmd_gso_size_segsz =
4746 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4747 cmd_segsz, "segsz");
4748 cmdline_parse_token_num_t cmd_gso_size_size =
4749 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4752 cmdline_parse_inst_t cmd_gso_size = {
4753 .f = cmd_gso_size_parsed,
4755 .help_str = "set gso segsz <length>",
4757 (void *)&cmd_gso_size_set,
4758 (void *)&cmd_gso_size_keyword,
4759 (void *)&cmd_gso_size_segsz,
4760 (void *)&cmd_gso_size_size,
4765 /* *** SHOW GSO CONFIGURATION *** */
4766 struct cmd_gso_show_result {
4767 cmdline_fixed_string_t cmd_show;
4768 cmdline_fixed_string_t cmd_port;
4769 cmdline_fixed_string_t cmd_keyword;
4774 cmd_gso_show_parsed(void *parsed_result,
4775 __attribute__((unused)) struct cmdline *cl,
4776 __attribute__((unused)) void *data)
4778 struct cmd_gso_show_result *res = parsed_result;
4780 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4781 printf("invalid port id %u\n", res->cmd_pid);
4784 if (!strcmp(res->cmd_keyword, "gso")) {
4785 if (gso_ports[res->cmd_pid].enable) {
4786 printf("Max GSO'd packet size: %uB\n"
4787 "Supported GSO types: TCP/IPv4, "
4788 "VxLAN with inner TCP/IPv4 packet, "
4789 "GRE with inner TCP/IPv4 packet\n",
4790 gso_max_segment_size);
4792 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4796 cmdline_parse_token_string_t cmd_gso_show_show =
4797 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4799 cmdline_parse_token_string_t cmd_gso_show_port =
4800 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4802 cmdline_parse_token_string_t cmd_gso_show_keyword =
4803 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4804 cmd_keyword, "gso");
4805 cmdline_parse_token_num_t cmd_gso_show_pid =
4806 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4809 cmdline_parse_inst_t cmd_gso_show = {
4810 .f = cmd_gso_show_parsed,
4812 .help_str = "show port <port_id> gso",
4814 (void *)&cmd_gso_show_show,
4815 (void *)&cmd_gso_show_port,
4816 (void *)&cmd_gso_show_pid,
4817 (void *)&cmd_gso_show_keyword,
4822 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4823 struct cmd_set_flush_rx {
4824 cmdline_fixed_string_t set;
4825 cmdline_fixed_string_t flush_rx;
4826 cmdline_fixed_string_t mode;
4830 cmd_set_flush_rx_parsed(void *parsed_result,
4831 __attribute__((unused)) struct cmdline *cl,
4832 __attribute__((unused)) void *data)
4834 struct cmd_set_flush_rx *res = parsed_result;
4835 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4838 cmdline_parse_token_string_t cmd_setflushrx_set =
4839 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4841 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4842 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4843 flush_rx, "flush_rx");
4844 cmdline_parse_token_string_t cmd_setflushrx_mode =
4845 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4849 cmdline_parse_inst_t cmd_set_flush_rx = {
4850 .f = cmd_set_flush_rx_parsed,
4851 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4854 (void *)&cmd_setflushrx_set,
4855 (void *)&cmd_setflushrx_flush_rx,
4856 (void *)&cmd_setflushrx_mode,
4861 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4862 struct cmd_set_link_check {
4863 cmdline_fixed_string_t set;
4864 cmdline_fixed_string_t link_check;
4865 cmdline_fixed_string_t mode;
4869 cmd_set_link_check_parsed(void *parsed_result,
4870 __attribute__((unused)) struct cmdline *cl,
4871 __attribute__((unused)) void *data)
4873 struct cmd_set_link_check *res = parsed_result;
4874 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4877 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4878 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4880 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4882 link_check, "link_check");
4883 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4884 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4888 cmdline_parse_inst_t cmd_set_link_check = {
4889 .f = cmd_set_link_check_parsed,
4890 .help_str = "set link_check on|off: Enable/Disable link status check "
4891 "when starting/stopping a port",
4894 (void *)&cmd_setlinkcheck_set,
4895 (void *)&cmd_setlinkcheck_link_check,
4896 (void *)&cmd_setlinkcheck_mode,
4901 /* *** SET NIC BYPASS MODE *** */
4902 struct cmd_set_bypass_mode_result {
4903 cmdline_fixed_string_t set;
4904 cmdline_fixed_string_t bypass;
4905 cmdline_fixed_string_t mode;
4906 cmdline_fixed_string_t value;
4911 cmd_set_bypass_mode_parsed(void *parsed_result,
4912 __attribute__((unused)) struct cmdline *cl,
4913 __attribute__((unused)) void *data)
4915 struct cmd_set_bypass_mode_result *res = parsed_result;
4916 portid_t port_id = res->port_id;
4917 int32_t rc = -EINVAL;
4919 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4920 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4922 if (!strcmp(res->value, "bypass"))
4923 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4924 else if (!strcmp(res->value, "isolate"))
4925 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4927 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4929 /* Set the bypass mode for the relevant port. */
4930 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4933 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4936 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4937 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4939 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4940 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4942 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4943 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4945 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4946 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4947 value, "normal#bypass#isolate");
4948 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4949 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4952 cmdline_parse_inst_t cmd_set_bypass_mode = {
4953 .f = cmd_set_bypass_mode_parsed,
4954 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4955 "Set the NIC bypass mode for port_id",
4958 (void *)&cmd_setbypass_mode_set,
4959 (void *)&cmd_setbypass_mode_bypass,
4960 (void *)&cmd_setbypass_mode_mode,
4961 (void *)&cmd_setbypass_mode_value,
4962 (void *)&cmd_setbypass_mode_port,
4967 /* *** SET NIC BYPASS EVENT *** */
4968 struct cmd_set_bypass_event_result {
4969 cmdline_fixed_string_t set;
4970 cmdline_fixed_string_t bypass;
4971 cmdline_fixed_string_t event;
4972 cmdline_fixed_string_t event_value;
4973 cmdline_fixed_string_t mode;
4974 cmdline_fixed_string_t mode_value;
4979 cmd_set_bypass_event_parsed(void *parsed_result,
4980 __attribute__((unused)) struct cmdline *cl,
4981 __attribute__((unused)) void *data)
4983 int32_t rc = -EINVAL;
4984 struct cmd_set_bypass_event_result *res = parsed_result;
4985 portid_t port_id = res->port_id;
4987 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4988 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4989 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4991 if (!strcmp(res->event_value, "timeout"))
4992 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4993 else if (!strcmp(res->event_value, "os_on"))
4994 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4995 else if (!strcmp(res->event_value, "os_off"))
4996 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4997 else if (!strcmp(res->event_value, "power_on"))
4998 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4999 else if (!strcmp(res->event_value, "power_off"))
5000 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5002 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5004 if (!strcmp(res->mode_value, "bypass"))
5005 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5006 else if (!strcmp(res->mode_value, "isolate"))
5007 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5009 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5011 /* Set the watchdog timeout. */
5012 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5015 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5016 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5020 printf("Failed to set timeout value %u "
5021 "for port %d, errto code: %d.\n",
5022 bypass_timeout, port_id, rc);
5026 /* Set the bypass event to transition to bypass mode. */
5027 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5032 printf("\t Failed to set bypass event for port = %d.\n",
5036 cmdline_parse_token_string_t cmd_setbypass_event_set =
5037 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5039 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5040 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5042 cmdline_parse_token_string_t cmd_setbypass_event_event =
5043 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5045 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5046 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5047 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5048 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5049 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5051 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5052 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5053 mode_value, "normal#bypass#isolate");
5054 cmdline_parse_token_num_t cmd_setbypass_event_port =
5055 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5058 cmdline_parse_inst_t cmd_set_bypass_event = {
5059 .f = cmd_set_bypass_event_parsed,
5060 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5061 "power_off mode normal|bypass|isolate <port_id>: "
5062 "Set the NIC bypass event mode for port_id",
5065 (void *)&cmd_setbypass_event_set,
5066 (void *)&cmd_setbypass_event_bypass,
5067 (void *)&cmd_setbypass_event_event,
5068 (void *)&cmd_setbypass_event_event_value,
5069 (void *)&cmd_setbypass_event_mode,
5070 (void *)&cmd_setbypass_event_mode_value,
5071 (void *)&cmd_setbypass_event_port,
5077 /* *** SET NIC BYPASS TIMEOUT *** */
5078 struct cmd_set_bypass_timeout_result {
5079 cmdline_fixed_string_t set;
5080 cmdline_fixed_string_t bypass;
5081 cmdline_fixed_string_t timeout;
5082 cmdline_fixed_string_t value;
5086 cmd_set_bypass_timeout_parsed(void *parsed_result,
5087 __attribute__((unused)) struct cmdline *cl,
5088 __attribute__((unused)) void *data)
5090 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5092 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5093 if (!strcmp(res->value, "1.5"))
5094 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5095 else if (!strcmp(res->value, "2"))
5096 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5097 else if (!strcmp(res->value, "3"))
5098 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5099 else if (!strcmp(res->value, "4"))
5100 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5101 else if (!strcmp(res->value, "8"))
5102 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5103 else if (!strcmp(res->value, "16"))
5104 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5105 else if (!strcmp(res->value, "32"))
5106 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5108 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5112 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5113 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5115 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5116 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5118 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5119 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5120 timeout, "timeout");
5121 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5123 value, "0#1.5#2#3#4#8#16#32");
5125 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5126 .f = cmd_set_bypass_timeout_parsed,
5127 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5128 "Set the NIC bypass watchdog timeout in seconds",
5131 (void *)&cmd_setbypass_timeout_set,
5132 (void *)&cmd_setbypass_timeout_bypass,
5133 (void *)&cmd_setbypass_timeout_timeout,
5134 (void *)&cmd_setbypass_timeout_value,
5139 /* *** SHOW NIC BYPASS MODE *** */
5140 struct cmd_show_bypass_config_result {
5141 cmdline_fixed_string_t show;
5142 cmdline_fixed_string_t bypass;
5143 cmdline_fixed_string_t config;
5148 cmd_show_bypass_config_parsed(void *parsed_result,
5149 __attribute__((unused)) struct cmdline *cl,
5150 __attribute__((unused)) void *data)
5152 struct cmd_show_bypass_config_result *res = parsed_result;
5153 portid_t port_id = res->port_id;
5155 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5156 uint32_t event_mode;
5157 uint32_t bypass_mode;
5158 uint32_t timeout = bypass_timeout;
5161 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5162 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5163 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5164 {"UNKNOWN", "normal", "bypass", "isolate"};
5165 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5172 int num_events = (sizeof events) / (sizeof events[0]);
5174 /* Display the bypass mode.*/
5175 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5176 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5180 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5181 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5183 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5186 /* Display the bypass timeout.*/
5187 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5188 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5190 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5192 /* Display the bypass events and associated modes. */
5193 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5195 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5196 printf("\tFailed to get bypass mode for event = %s\n",
5199 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5200 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5202 printf("\tbypass event: %-16s = %s\n", events[i],
5208 printf("\tFailed to get bypass configuration for port = %d\n",
5212 cmdline_parse_token_string_t cmd_showbypass_config_show =
5213 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5215 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5216 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5218 cmdline_parse_token_string_t cmd_showbypass_config_config =
5219 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5221 cmdline_parse_token_num_t cmd_showbypass_config_port =
5222 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5225 cmdline_parse_inst_t cmd_show_bypass_config = {
5226 .f = cmd_show_bypass_config_parsed,
5227 .help_str = "show bypass config <port_id>: "
5228 "Show the NIC bypass config for port_id",
5231 (void *)&cmd_showbypass_config_show,
5232 (void *)&cmd_showbypass_config_bypass,
5233 (void *)&cmd_showbypass_config_config,
5234 (void *)&cmd_showbypass_config_port,
5239 #ifdef RTE_LIBRTE_PMD_BOND
5240 /* *** SET BONDING MODE *** */
5241 struct cmd_set_bonding_mode_result {
5242 cmdline_fixed_string_t set;
5243 cmdline_fixed_string_t bonding;
5244 cmdline_fixed_string_t mode;
5249 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5250 __attribute__((unused)) struct cmdline *cl,
5251 __attribute__((unused)) void *data)
5253 struct cmd_set_bonding_mode_result *res = parsed_result;
5254 portid_t port_id = res->port_id;
5256 /* Set the bonding mode for the relevant port. */
5257 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5258 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5261 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5262 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5264 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5265 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5266 bonding, "bonding");
5267 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5268 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5270 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5271 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5273 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5274 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5277 cmdline_parse_inst_t cmd_set_bonding_mode = {
5278 .f = cmd_set_bonding_mode_parsed,
5279 .help_str = "set bonding mode <mode_value> <port_id>: "
5280 "Set the bonding mode for port_id",
5283 (void *) &cmd_setbonding_mode_set,
5284 (void *) &cmd_setbonding_mode_bonding,
5285 (void *) &cmd_setbonding_mode_mode,
5286 (void *) &cmd_setbonding_mode_value,
5287 (void *) &cmd_setbonding_mode_port,
5292 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5293 struct cmd_set_bonding_lacp_dedicated_queues_result {
5294 cmdline_fixed_string_t set;
5295 cmdline_fixed_string_t bonding;
5296 cmdline_fixed_string_t lacp;
5297 cmdline_fixed_string_t dedicated_queues;
5299 cmdline_fixed_string_t mode;
5302 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5303 __attribute__((unused)) struct cmdline *cl,
5304 __attribute__((unused)) void *data)
5306 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5307 portid_t port_id = res->port_id;
5308 struct rte_port *port;
5310 port = &ports[port_id];
5312 /** Check if the port is not started **/
5313 if (port->port_status != RTE_PORT_STOPPED) {
5314 printf("Please stop port %d first\n", port_id);
5318 if (!strcmp(res->mode, "enable")) {
5319 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5320 printf("Dedicate queues for LACP control packets"
5323 printf("Enabling dedicate queues for LACP control "
5324 "packets on port %d failed\n", port_id);
5325 } else if (!strcmp(res->mode, "disable")) {
5326 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5327 printf("Dedicated queues for LACP control packets "
5330 printf("Disabling dedicated queues for LACP control "
5331 "traffic on port %d failed\n", port_id);
5335 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5336 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5338 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5339 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5340 bonding, "bonding");
5341 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5342 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5344 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5345 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5346 dedicated_queues, "dedicated_queues");
5347 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5348 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5350 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5351 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5352 mode, "enable#disable");
5354 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5355 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5356 .help_str = "set bonding lacp dedicated_queues <port_id> "
5358 "Enable/disable dedicated queues for LACP control traffic for port_id",
5361 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5362 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5363 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5364 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5365 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5366 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5371 /* *** SET BALANCE XMIT POLICY *** */
5372 struct cmd_set_bonding_balance_xmit_policy_result {
5373 cmdline_fixed_string_t set;
5374 cmdline_fixed_string_t bonding;
5375 cmdline_fixed_string_t balance_xmit_policy;
5377 cmdline_fixed_string_t policy;
5380 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5381 __attribute__((unused)) struct cmdline *cl,
5382 __attribute__((unused)) void *data)
5384 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5385 portid_t port_id = res->port_id;
5388 if (!strcmp(res->policy, "l2")) {
5389 policy = BALANCE_XMIT_POLICY_LAYER2;
5390 } else if (!strcmp(res->policy, "l23")) {
5391 policy = BALANCE_XMIT_POLICY_LAYER23;
5392 } else if (!strcmp(res->policy, "l34")) {
5393 policy = BALANCE_XMIT_POLICY_LAYER34;
5395 printf("\t Invalid xmit policy selection");
5399 /* Set the bonding mode for the relevant port. */
5400 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5401 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5406 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5407 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5409 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5410 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5411 bonding, "bonding");
5412 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5413 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5414 balance_xmit_policy, "balance_xmit_policy");
5415 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5416 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5418 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5419 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5420 policy, "l2#l23#l34");
5422 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5423 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5424 .help_str = "set bonding balance_xmit_policy <port_id> "
5426 "Set the bonding balance_xmit_policy for port_id",
5429 (void *)&cmd_setbonding_balance_xmit_policy_set,
5430 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5431 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5432 (void *)&cmd_setbonding_balance_xmit_policy_port,
5433 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5438 /* *** SHOW NIC BONDING CONFIGURATION *** */
5439 struct cmd_show_bonding_config_result {
5440 cmdline_fixed_string_t show;
5441 cmdline_fixed_string_t bonding;
5442 cmdline_fixed_string_t config;
5446 static void cmd_show_bonding_config_parsed(void *parsed_result,
5447 __attribute__((unused)) struct cmdline *cl,
5448 __attribute__((unused)) void *data)
5450 struct cmd_show_bonding_config_result *res = parsed_result;
5451 int bonding_mode, agg_mode;
5452 portid_t slaves[RTE_MAX_ETHPORTS];
5453 int num_slaves, num_active_slaves;
5456 portid_t port_id = res->port_id;
5458 /* Display the bonding mode.*/
5459 bonding_mode = rte_eth_bond_mode_get(port_id);
5460 if (bonding_mode < 0) {
5461 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5464 printf("\tBonding mode: %d\n", bonding_mode);
5466 if (bonding_mode == BONDING_MODE_BALANCE) {
5467 int balance_xmit_policy;
5469 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5470 if (balance_xmit_policy < 0) {
5471 printf("\tFailed to get balance xmit policy for port = %d\n",
5475 printf("\tBalance Xmit Policy: ");
5477 switch (balance_xmit_policy) {
5478 case BALANCE_XMIT_POLICY_LAYER2:
5479 printf("BALANCE_XMIT_POLICY_LAYER2");
5481 case BALANCE_XMIT_POLICY_LAYER23:
5482 printf("BALANCE_XMIT_POLICY_LAYER23");
5484 case BALANCE_XMIT_POLICY_LAYER34:
5485 printf("BALANCE_XMIT_POLICY_LAYER34");
5492 if (bonding_mode == BONDING_MODE_8023AD) {
5493 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5494 printf("\tIEEE802.3AD Aggregator Mode: ");
5497 printf("bandwidth");
5509 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5511 if (num_slaves < 0) {
5512 printf("\tFailed to get slave list for port = %d\n", port_id);
5515 if (num_slaves > 0) {
5516 printf("\tSlaves (%d): [", num_slaves);
5517 for (i = 0; i < num_slaves - 1; i++)
5518 printf("%d ", slaves[i]);
5520 printf("%d]\n", slaves[num_slaves - 1]);
5522 printf("\tSlaves: []\n");
5526 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5529 if (num_active_slaves < 0) {
5530 printf("\tFailed to get active slave list for port = %d\n", port_id);
5533 if (num_active_slaves > 0) {
5534 printf("\tActive Slaves (%d): [", num_active_slaves);
5535 for (i = 0; i < num_active_slaves - 1; i++)
5536 printf("%d ", slaves[i]);
5538 printf("%d]\n", slaves[num_active_slaves - 1]);
5541 printf("\tActive Slaves: []\n");
5545 primary_id = rte_eth_bond_primary_get(port_id);
5546 if (primary_id < 0) {
5547 printf("\tFailed to get primary slave for port = %d\n", port_id);
5550 printf("\tPrimary: [%d]\n", primary_id);
5554 cmdline_parse_token_string_t cmd_showbonding_config_show =
5555 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5557 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5558 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5559 bonding, "bonding");
5560 cmdline_parse_token_string_t cmd_showbonding_config_config =
5561 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5563 cmdline_parse_token_num_t cmd_showbonding_config_port =
5564 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5567 cmdline_parse_inst_t cmd_show_bonding_config = {
5568 .f = cmd_show_bonding_config_parsed,
5569 .help_str = "show bonding config <port_id>: "
5570 "Show the bonding config for port_id",
5573 (void *)&cmd_showbonding_config_show,
5574 (void *)&cmd_showbonding_config_bonding,
5575 (void *)&cmd_showbonding_config_config,
5576 (void *)&cmd_showbonding_config_port,
5581 /* *** SET BONDING PRIMARY *** */
5582 struct cmd_set_bonding_primary_result {
5583 cmdline_fixed_string_t set;
5584 cmdline_fixed_string_t bonding;
5585 cmdline_fixed_string_t primary;
5590 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5591 __attribute__((unused)) struct cmdline *cl,
5592 __attribute__((unused)) void *data)
5594 struct cmd_set_bonding_primary_result *res = parsed_result;
5595 portid_t master_port_id = res->port_id;
5596 portid_t slave_port_id = res->slave_id;
5598 /* Set the primary slave for a bonded device. */
5599 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5600 printf("\t Failed to set primary slave for port = %d.\n",
5607 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5608 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5610 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5612 bonding, "bonding");
5613 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5615 primary, "primary");
5616 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5617 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5619 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5620 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5623 cmdline_parse_inst_t cmd_set_bonding_primary = {
5624 .f = cmd_set_bonding_primary_parsed,
5625 .help_str = "set bonding primary <slave_id> <port_id>: "
5626 "Set the primary slave for port_id",
5629 (void *)&cmd_setbonding_primary_set,
5630 (void *)&cmd_setbonding_primary_bonding,
5631 (void *)&cmd_setbonding_primary_primary,
5632 (void *)&cmd_setbonding_primary_slave,
5633 (void *)&cmd_setbonding_primary_port,
5638 /* *** ADD SLAVE *** */
5639 struct cmd_add_bonding_slave_result {
5640 cmdline_fixed_string_t add;
5641 cmdline_fixed_string_t bonding;
5642 cmdline_fixed_string_t slave;
5647 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5648 __attribute__((unused)) struct cmdline *cl,
5649 __attribute__((unused)) void *data)
5651 struct cmd_add_bonding_slave_result *res = parsed_result;
5652 portid_t master_port_id = res->port_id;
5653 portid_t slave_port_id = res->slave_id;
5655 /* add the slave for a bonded device. */
5656 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5657 printf("\t Failed to add slave %d to master port = %d.\n",
5658 slave_port_id, master_port_id);
5662 set_port_slave_flag(slave_port_id);
5665 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5666 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5668 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5669 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5670 bonding, "bonding");
5671 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5672 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5674 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5675 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5677 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5678 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5681 cmdline_parse_inst_t cmd_add_bonding_slave = {
5682 .f = cmd_add_bonding_slave_parsed,
5683 .help_str = "add bonding slave <slave_id> <port_id>: "
5684 "Add a slave device to a bonded device",
5687 (void *)&cmd_addbonding_slave_add,
5688 (void *)&cmd_addbonding_slave_bonding,
5689 (void *)&cmd_addbonding_slave_slave,
5690 (void *)&cmd_addbonding_slave_slaveid,
5691 (void *)&cmd_addbonding_slave_port,
5696 /* *** REMOVE SLAVE *** */
5697 struct cmd_remove_bonding_slave_result {
5698 cmdline_fixed_string_t remove;
5699 cmdline_fixed_string_t bonding;
5700 cmdline_fixed_string_t slave;
5705 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5706 __attribute__((unused)) struct cmdline *cl,
5707 __attribute__((unused)) void *data)
5709 struct cmd_remove_bonding_slave_result *res = parsed_result;
5710 portid_t master_port_id = res->port_id;
5711 portid_t slave_port_id = res->slave_id;
5713 /* remove the slave from a bonded device. */
5714 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5715 printf("\t Failed to remove slave %d from master port = %d.\n",
5716 slave_port_id, master_port_id);
5720 clear_port_slave_flag(slave_port_id);
5723 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5724 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5726 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5727 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5728 bonding, "bonding");
5729 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5730 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5732 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5733 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5735 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5736 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5739 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5740 .f = cmd_remove_bonding_slave_parsed,
5741 .help_str = "remove bonding slave <slave_id> <port_id>: "
5742 "Remove a slave device from a bonded device",
5745 (void *)&cmd_removebonding_slave_remove,
5746 (void *)&cmd_removebonding_slave_bonding,
5747 (void *)&cmd_removebonding_slave_slave,
5748 (void *)&cmd_removebonding_slave_slaveid,
5749 (void *)&cmd_removebonding_slave_port,
5754 /* *** CREATE BONDED DEVICE *** */
5755 struct cmd_create_bonded_device_result {
5756 cmdline_fixed_string_t create;
5757 cmdline_fixed_string_t bonded;
5758 cmdline_fixed_string_t device;
5763 static int bond_dev_num = 0;
5765 static void cmd_create_bonded_device_parsed(void *parsed_result,
5766 __attribute__((unused)) struct cmdline *cl,
5767 __attribute__((unused)) void *data)
5769 struct cmd_create_bonded_device_result *res = parsed_result;
5770 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5773 if (test_done == 0) {
5774 printf("Please stop forwarding first\n");
5778 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5781 /* Create a new bonded device. */
5782 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5784 printf("\t Failed to create bonded device.\n");
5787 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5790 /* Update number of ports */
5791 nb_ports = rte_eth_dev_count_avail();
5792 reconfig(port_id, res->socket);
5793 rte_eth_promiscuous_enable(port_id);
5798 cmdline_parse_token_string_t cmd_createbonded_device_create =
5799 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5801 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5802 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5804 cmdline_parse_token_string_t cmd_createbonded_device_device =
5805 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5807 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5808 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5810 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5811 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5814 cmdline_parse_inst_t cmd_create_bonded_device = {
5815 .f = cmd_create_bonded_device_parsed,
5816 .help_str = "create bonded device <mode> <socket>: "
5817 "Create a new bonded device with specific bonding mode and socket",
5820 (void *)&cmd_createbonded_device_create,
5821 (void *)&cmd_createbonded_device_bonded,
5822 (void *)&cmd_createbonded_device_device,
5823 (void *)&cmd_createbonded_device_mode,
5824 (void *)&cmd_createbonded_device_socket,
5829 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5830 struct cmd_set_bond_mac_addr_result {
5831 cmdline_fixed_string_t set;
5832 cmdline_fixed_string_t bonding;
5833 cmdline_fixed_string_t mac_addr;
5835 struct ether_addr address;
5838 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5839 __attribute__((unused)) struct cmdline *cl,
5840 __attribute__((unused)) void *data)
5842 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5845 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5848 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5850 /* check the return value and print it if is < 0 */
5852 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5855 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5856 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5857 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5858 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5860 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5861 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5863 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5864 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5866 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5867 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5869 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5870 .f = cmd_set_bond_mac_addr_parsed,
5872 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5874 (void *)&cmd_set_bond_mac_addr_set,
5875 (void *)&cmd_set_bond_mac_addr_bonding,
5876 (void *)&cmd_set_bond_mac_addr_mac,
5877 (void *)&cmd_set_bond_mac_addr_portnum,
5878 (void *)&cmd_set_bond_mac_addr_addr,
5884 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5885 struct cmd_set_bond_mon_period_result {
5886 cmdline_fixed_string_t set;
5887 cmdline_fixed_string_t bonding;
5888 cmdline_fixed_string_t mon_period;
5893 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5894 __attribute__((unused)) struct cmdline *cl,
5895 __attribute__((unused)) void *data)
5897 struct cmd_set_bond_mon_period_result *res = parsed_result;
5900 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5902 /* check the return value and print it if is < 0 */
5904 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5907 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5908 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5910 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5911 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5912 bonding, "bonding");
5913 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5915 mon_period, "mon_period");
5916 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5917 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5919 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5920 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5923 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5924 .f = cmd_set_bond_mon_period_parsed,
5926 .help_str = "set bonding mon_period <port_id> <period_ms>",
5928 (void *)&cmd_set_bond_mon_period_set,
5929 (void *)&cmd_set_bond_mon_period_bonding,
5930 (void *)&cmd_set_bond_mon_period_mon_period,
5931 (void *)&cmd_set_bond_mon_period_portnum,
5932 (void *)&cmd_set_bond_mon_period_period_ms,
5939 struct cmd_set_bonding_agg_mode_policy_result {
5940 cmdline_fixed_string_t set;
5941 cmdline_fixed_string_t bonding;
5942 cmdline_fixed_string_t agg_mode;
5944 cmdline_fixed_string_t policy;
5949 cmd_set_bonding_agg_mode(void *parsed_result,
5950 __attribute__((unused)) struct cmdline *cl,
5951 __attribute__((unused)) void *data)
5953 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5954 uint8_t policy = AGG_BANDWIDTH;
5956 if (!strcmp(res->policy, "bandwidth"))
5957 policy = AGG_BANDWIDTH;
5958 else if (!strcmp(res->policy, "stable"))
5959 policy = AGG_STABLE;
5960 else if (!strcmp(res->policy, "count"))
5963 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5967 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5968 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5970 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5971 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5972 bonding, "bonding");
5974 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5975 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5976 agg_mode, "agg_mode");
5978 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5979 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5982 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5983 TOKEN_STRING_INITIALIZER(
5984 struct cmd_set_bonding_balance_xmit_policy_result,
5985 policy, "stable#bandwidth#count");
5987 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5988 .f = cmd_set_bonding_agg_mode,
5990 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5992 (void *)&cmd_set_bonding_agg_mode_set,
5993 (void *)&cmd_set_bonding_agg_mode_bonding,
5994 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5995 (void *)&cmd_set_bonding_agg_mode_portnum,
5996 (void *)&cmd_set_bonding_agg_mode_policy_string,
6002 #endif /* RTE_LIBRTE_PMD_BOND */
6004 /* *** SET FORWARDING MODE *** */
6005 struct cmd_set_fwd_mode_result {
6006 cmdline_fixed_string_t set;
6007 cmdline_fixed_string_t fwd;
6008 cmdline_fixed_string_t mode;
6011 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6012 __attribute__((unused)) struct cmdline *cl,
6013 __attribute__((unused)) void *data)
6015 struct cmd_set_fwd_mode_result *res = parsed_result;
6018 set_pkt_forwarding_mode(res->mode);
6021 cmdline_parse_token_string_t cmd_setfwd_set =
6022 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6023 cmdline_parse_token_string_t cmd_setfwd_fwd =
6024 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6025 cmdline_parse_token_string_t cmd_setfwd_mode =
6026 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6027 "" /* defined at init */);
6029 cmdline_parse_inst_t cmd_set_fwd_mode = {
6030 .f = cmd_set_fwd_mode_parsed,
6032 .help_str = NULL, /* defined at init */
6034 (void *)&cmd_setfwd_set,
6035 (void *)&cmd_setfwd_fwd,
6036 (void *)&cmd_setfwd_mode,
6041 static void cmd_set_fwd_mode_init(void)
6044 static char token[128];
6045 static char help[256];
6046 cmdline_parse_token_string_t *token_struct;
6048 modes = list_pkt_forwarding_modes();
6049 snprintf(help, sizeof(help), "set fwd %s: "
6050 "Set packet forwarding mode", modes);
6051 cmd_set_fwd_mode.help_str = help;
6053 /* string token separator is # */
6054 for (c = token; *modes != '\0'; modes++)
6059 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6060 token_struct->string_data.str = token;
6063 /* *** SET RETRY FORWARDING MODE *** */
6064 struct cmd_set_fwd_retry_mode_result {
6065 cmdline_fixed_string_t set;
6066 cmdline_fixed_string_t fwd;
6067 cmdline_fixed_string_t mode;
6068 cmdline_fixed_string_t retry;
6071 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6072 __attribute__((unused)) struct cmdline *cl,
6073 __attribute__((unused)) void *data)
6075 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6078 set_pkt_forwarding_mode(res->mode);
6081 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6082 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6084 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6085 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6087 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6088 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6090 "" /* defined at init */);
6091 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6092 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6095 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6096 .f = cmd_set_fwd_retry_mode_parsed,
6098 .help_str = NULL, /* defined at init */
6100 (void *)&cmd_setfwd_retry_set,
6101 (void *)&cmd_setfwd_retry_fwd,
6102 (void *)&cmd_setfwd_retry_mode,
6103 (void *)&cmd_setfwd_retry_retry,
6108 static void cmd_set_fwd_retry_mode_init(void)
6111 static char token[128];
6112 static char help[256];
6113 cmdline_parse_token_string_t *token_struct;
6115 modes = list_pkt_forwarding_retry_modes();
6116 snprintf(help, sizeof(help), "set fwd %s retry: "
6117 "Set packet forwarding mode with retry", modes);
6118 cmd_set_fwd_retry_mode.help_str = help;
6120 /* string token separator is # */
6121 for (c = token; *modes != '\0'; modes++)
6126 token_struct = (cmdline_parse_token_string_t *)
6127 cmd_set_fwd_retry_mode.tokens[2];
6128 token_struct->string_data.str = token;
6131 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6132 struct cmd_set_burst_tx_retry_result {
6133 cmdline_fixed_string_t set;
6134 cmdline_fixed_string_t burst;
6135 cmdline_fixed_string_t tx;
6136 cmdline_fixed_string_t delay;
6138 cmdline_fixed_string_t retry;
6142 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6143 __attribute__((unused)) struct cmdline *cl,
6144 __attribute__((unused)) void *data)
6146 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6148 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6149 && !strcmp(res->tx, "tx")) {
6150 if (!strcmp(res->delay, "delay"))
6151 burst_tx_delay_time = res->time;
6152 if (!strcmp(res->retry, "retry"))
6153 burst_tx_retry_num = res->retry_num;
6158 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6159 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6160 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6161 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6163 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6164 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6165 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6166 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6167 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6168 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6169 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6170 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6171 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6172 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6174 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6175 .f = cmd_set_burst_tx_retry_parsed,
6176 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6178 (void *)&cmd_set_burst_tx_retry_set,
6179 (void *)&cmd_set_burst_tx_retry_burst,
6180 (void *)&cmd_set_burst_tx_retry_tx,
6181 (void *)&cmd_set_burst_tx_retry_delay,
6182 (void *)&cmd_set_burst_tx_retry_time,
6183 (void *)&cmd_set_burst_tx_retry_retry,
6184 (void *)&cmd_set_burst_tx_retry_retry_num,
6189 /* *** SET PROMISC MODE *** */
6190 struct cmd_set_promisc_mode_result {
6191 cmdline_fixed_string_t set;
6192 cmdline_fixed_string_t promisc;
6193 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6194 uint16_t port_num; /* valid if "allports" argument == 0 */
6195 cmdline_fixed_string_t mode;
6198 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6199 __attribute__((unused)) struct cmdline *cl,
6202 struct cmd_set_promisc_mode_result *res = parsed_result;
6206 if (!strcmp(res->mode, "on"))
6213 RTE_ETH_FOREACH_DEV(i) {
6215 rte_eth_promiscuous_enable(i);
6217 rte_eth_promiscuous_disable(i);
6222 rte_eth_promiscuous_enable(res->port_num);
6224 rte_eth_promiscuous_disable(res->port_num);
6228 cmdline_parse_token_string_t cmd_setpromisc_set =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6230 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6231 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6233 cmdline_parse_token_string_t cmd_setpromisc_portall =
6234 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6236 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6237 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6239 cmdline_parse_token_string_t cmd_setpromisc_mode =
6240 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6243 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6244 .f = cmd_set_promisc_mode_parsed,
6246 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6248 (void *)&cmd_setpromisc_set,
6249 (void *)&cmd_setpromisc_promisc,
6250 (void *)&cmd_setpromisc_portall,
6251 (void *)&cmd_setpromisc_mode,
6256 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6257 .f = cmd_set_promisc_mode_parsed,
6259 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6261 (void *)&cmd_setpromisc_set,
6262 (void *)&cmd_setpromisc_promisc,
6263 (void *)&cmd_setpromisc_portnum,
6264 (void *)&cmd_setpromisc_mode,
6269 /* *** SET ALLMULTI MODE *** */
6270 struct cmd_set_allmulti_mode_result {
6271 cmdline_fixed_string_t set;
6272 cmdline_fixed_string_t allmulti;
6273 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6274 uint16_t port_num; /* valid if "allports" argument == 0 */
6275 cmdline_fixed_string_t mode;
6278 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6279 __attribute__((unused)) struct cmdline *cl,
6282 struct cmd_set_allmulti_mode_result *res = parsed_result;
6286 if (!strcmp(res->mode, "on"))
6293 RTE_ETH_FOREACH_DEV(i) {
6295 rte_eth_allmulticast_enable(i);
6297 rte_eth_allmulticast_disable(i);
6302 rte_eth_allmulticast_enable(res->port_num);
6304 rte_eth_allmulticast_disable(res->port_num);
6308 cmdline_parse_token_string_t cmd_setallmulti_set =
6309 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6310 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6311 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6313 cmdline_parse_token_string_t cmd_setallmulti_portall =
6314 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6316 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6317 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6319 cmdline_parse_token_string_t cmd_setallmulti_mode =
6320 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6323 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6324 .f = cmd_set_allmulti_mode_parsed,
6326 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6328 (void *)&cmd_setallmulti_set,
6329 (void *)&cmd_setallmulti_allmulti,
6330 (void *)&cmd_setallmulti_portall,
6331 (void *)&cmd_setallmulti_mode,
6336 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6337 .f = cmd_set_allmulti_mode_parsed,
6339 .help_str = "set allmulti <port_id> on|off: "
6340 "Set allmulti mode on port_id",
6342 (void *)&cmd_setallmulti_set,
6343 (void *)&cmd_setallmulti_allmulti,
6344 (void *)&cmd_setallmulti_portnum,
6345 (void *)&cmd_setallmulti_mode,
6350 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6351 struct cmd_link_flow_ctrl_set_result {
6352 cmdline_fixed_string_t set;
6353 cmdline_fixed_string_t flow_ctrl;
6354 cmdline_fixed_string_t rx;
6355 cmdline_fixed_string_t rx_lfc_mode;
6356 cmdline_fixed_string_t tx;
6357 cmdline_fixed_string_t tx_lfc_mode;
6358 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6359 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6360 cmdline_fixed_string_t autoneg_str;
6361 cmdline_fixed_string_t autoneg;
6362 cmdline_fixed_string_t hw_str;
6363 uint32_t high_water;
6364 cmdline_fixed_string_t lw_str;
6366 cmdline_fixed_string_t pt_str;
6367 uint16_t pause_time;
6368 cmdline_fixed_string_t xon_str;
6373 cmdline_parse_token_string_t cmd_lfc_set_set =
6374 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6376 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6377 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6378 flow_ctrl, "flow_ctrl");
6379 cmdline_parse_token_string_t cmd_lfc_set_rx =
6380 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6382 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6383 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6384 rx_lfc_mode, "on#off");
6385 cmdline_parse_token_string_t cmd_lfc_set_tx =
6386 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6388 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6389 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6390 tx_lfc_mode, "on#off");
6391 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6392 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6393 hw_str, "high_water");
6394 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6395 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6396 high_water, UINT32);
6397 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6398 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6399 lw_str, "low_water");
6400 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6401 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6403 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6404 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6405 pt_str, "pause_time");
6406 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6407 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6408 pause_time, UINT16);
6409 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6410 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6411 xon_str, "send_xon");
6412 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6413 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6415 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6416 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6417 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6418 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6419 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6420 mac_ctrl_frame_fwd_mode, "on#off");
6421 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6423 autoneg_str, "autoneg");
6424 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6427 cmdline_parse_token_num_t cmd_lfc_set_portid =
6428 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6431 /* forward declaration */
6433 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6436 cmdline_parse_inst_t cmd_link_flow_control_set = {
6437 .f = cmd_link_flow_ctrl_set_parsed,
6439 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6440 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6441 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6443 (void *)&cmd_lfc_set_set,
6444 (void *)&cmd_lfc_set_flow_ctrl,
6445 (void *)&cmd_lfc_set_rx,
6446 (void *)&cmd_lfc_set_rx_mode,
6447 (void *)&cmd_lfc_set_tx,
6448 (void *)&cmd_lfc_set_tx_mode,
6449 (void *)&cmd_lfc_set_high_water,
6450 (void *)&cmd_lfc_set_low_water,
6451 (void *)&cmd_lfc_set_pause_time,
6452 (void *)&cmd_lfc_set_send_xon,
6453 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6454 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6455 (void *)&cmd_lfc_set_autoneg_str,
6456 (void *)&cmd_lfc_set_autoneg,
6457 (void *)&cmd_lfc_set_portid,
6462 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6463 .f = cmd_link_flow_ctrl_set_parsed,
6464 .data = (void *)&cmd_link_flow_control_set_rx,
6465 .help_str = "set flow_ctrl rx on|off <port_id>: "
6466 "Change rx flow control parameter",
6468 (void *)&cmd_lfc_set_set,
6469 (void *)&cmd_lfc_set_flow_ctrl,
6470 (void *)&cmd_lfc_set_rx,
6471 (void *)&cmd_lfc_set_rx_mode,
6472 (void *)&cmd_lfc_set_portid,
6477 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6478 .f = cmd_link_flow_ctrl_set_parsed,
6479 .data = (void *)&cmd_link_flow_control_set_tx,
6480 .help_str = "set flow_ctrl tx on|off <port_id>: "
6481 "Change tx flow control parameter",
6483 (void *)&cmd_lfc_set_set,
6484 (void *)&cmd_lfc_set_flow_ctrl,
6485 (void *)&cmd_lfc_set_tx,
6486 (void *)&cmd_lfc_set_tx_mode,
6487 (void *)&cmd_lfc_set_portid,
6492 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6493 .f = cmd_link_flow_ctrl_set_parsed,
6494 .data = (void *)&cmd_link_flow_control_set_hw,
6495 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6496 "Change high water flow control parameter",
6498 (void *)&cmd_lfc_set_set,
6499 (void *)&cmd_lfc_set_flow_ctrl,
6500 (void *)&cmd_lfc_set_high_water_str,
6501 (void *)&cmd_lfc_set_high_water,
6502 (void *)&cmd_lfc_set_portid,
6507 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6508 .f = cmd_link_flow_ctrl_set_parsed,
6509 .data = (void *)&cmd_link_flow_control_set_lw,
6510 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6511 "Change low water flow control parameter",
6513 (void *)&cmd_lfc_set_set,
6514 (void *)&cmd_lfc_set_flow_ctrl,
6515 (void *)&cmd_lfc_set_low_water_str,
6516 (void *)&cmd_lfc_set_low_water,
6517 (void *)&cmd_lfc_set_portid,
6522 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6523 .f = cmd_link_flow_ctrl_set_parsed,
6524 .data = (void *)&cmd_link_flow_control_set_pt,
6525 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6526 "Change pause time flow control parameter",
6528 (void *)&cmd_lfc_set_set,
6529 (void *)&cmd_lfc_set_flow_ctrl,
6530 (void *)&cmd_lfc_set_pause_time_str,
6531 (void *)&cmd_lfc_set_pause_time,
6532 (void *)&cmd_lfc_set_portid,
6537 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6538 .f = cmd_link_flow_ctrl_set_parsed,
6539 .data = (void *)&cmd_link_flow_control_set_xon,
6540 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6541 "Change send_xon flow control parameter",
6543 (void *)&cmd_lfc_set_set,
6544 (void *)&cmd_lfc_set_flow_ctrl,
6545 (void *)&cmd_lfc_set_send_xon_str,
6546 (void *)&cmd_lfc_set_send_xon,
6547 (void *)&cmd_lfc_set_portid,
6552 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6553 .f = cmd_link_flow_ctrl_set_parsed,
6554 .data = (void *)&cmd_link_flow_control_set_macfwd,
6555 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6556 "Change mac ctrl fwd flow control parameter",
6558 (void *)&cmd_lfc_set_set,
6559 (void *)&cmd_lfc_set_flow_ctrl,
6560 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6561 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6562 (void *)&cmd_lfc_set_portid,
6567 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6568 .f = cmd_link_flow_ctrl_set_parsed,
6569 .data = (void *)&cmd_link_flow_control_set_autoneg,
6570 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6571 "Change autoneg flow control parameter",
6573 (void *)&cmd_lfc_set_set,
6574 (void *)&cmd_lfc_set_flow_ctrl,
6575 (void *)&cmd_lfc_set_autoneg_str,
6576 (void *)&cmd_lfc_set_autoneg,
6577 (void *)&cmd_lfc_set_portid,
6583 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6584 __attribute__((unused)) struct cmdline *cl,
6587 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6588 cmdline_parse_inst_t *cmd = data;
6589 struct rte_eth_fc_conf fc_conf;
6595 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6596 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6597 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6598 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6600 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6601 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6604 /* Partial command line, retrieve current configuration */
6606 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6608 printf("cannot get current flow ctrl parameters, return"
6609 "code = %d\n", ret);
6613 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6614 (fc_conf.mode == RTE_FC_FULL))
6616 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6617 (fc_conf.mode == RTE_FC_FULL))
6621 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6622 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6624 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6625 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6627 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6629 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6630 fc_conf.high_water = res->high_water;
6632 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6633 fc_conf.low_water = res->low_water;
6635 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6636 fc_conf.pause_time = res->pause_time;
6638 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6639 fc_conf.send_xon = res->send_xon;
6641 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6642 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6643 fc_conf.mac_ctrl_frame_fwd = 1;
6645 fc_conf.mac_ctrl_frame_fwd = 0;
6648 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6649 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6651 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6653 printf("bad flow contrl parameter, return code = %d \n", ret);
6656 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6657 struct cmd_priority_flow_ctrl_set_result {
6658 cmdline_fixed_string_t set;
6659 cmdline_fixed_string_t pfc_ctrl;
6660 cmdline_fixed_string_t rx;
6661 cmdline_fixed_string_t rx_pfc_mode;
6662 cmdline_fixed_string_t tx;
6663 cmdline_fixed_string_t tx_pfc_mode;
6664 uint32_t high_water;
6666 uint16_t pause_time;
6672 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6673 __attribute__((unused)) struct cmdline *cl,
6674 __attribute__((unused)) void *data)
6676 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6677 struct rte_eth_pfc_conf pfc_conf;
6678 int rx_fc_enable, tx_fc_enable;
6682 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6683 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6684 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6685 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6687 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6688 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6691 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6692 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6693 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6694 pfc_conf.fc.high_water = res->high_water;
6695 pfc_conf.fc.low_water = res->low_water;
6696 pfc_conf.fc.pause_time = res->pause_time;
6697 pfc_conf.priority = res->priority;
6699 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6701 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6704 cmdline_parse_token_string_t cmd_pfc_set_set =
6705 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6707 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6708 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6709 pfc_ctrl, "pfc_ctrl");
6710 cmdline_parse_token_string_t cmd_pfc_set_rx =
6711 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6713 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6714 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6715 rx_pfc_mode, "on#off");
6716 cmdline_parse_token_string_t cmd_pfc_set_tx =
6717 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6719 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6720 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6721 tx_pfc_mode, "on#off");
6722 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6723 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6724 high_water, UINT32);
6725 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6726 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6728 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6729 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6730 pause_time, UINT16);
6731 cmdline_parse_token_num_t cmd_pfc_set_priority =
6732 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6734 cmdline_parse_token_num_t cmd_pfc_set_portid =
6735 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6738 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6739 .f = cmd_priority_flow_ctrl_set_parsed,
6741 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6742 "<pause_time> <priority> <port_id>: "
6743 "Configure the Ethernet priority flow control",
6745 (void *)&cmd_pfc_set_set,
6746 (void *)&cmd_pfc_set_flow_ctrl,
6747 (void *)&cmd_pfc_set_rx,
6748 (void *)&cmd_pfc_set_rx_mode,
6749 (void *)&cmd_pfc_set_tx,
6750 (void *)&cmd_pfc_set_tx_mode,
6751 (void *)&cmd_pfc_set_high_water,
6752 (void *)&cmd_pfc_set_low_water,
6753 (void *)&cmd_pfc_set_pause_time,
6754 (void *)&cmd_pfc_set_priority,
6755 (void *)&cmd_pfc_set_portid,
6760 /* *** RESET CONFIGURATION *** */
6761 struct cmd_reset_result {
6762 cmdline_fixed_string_t reset;
6763 cmdline_fixed_string_t def;
6766 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6768 __attribute__((unused)) void *data)
6770 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6771 set_def_fwd_config();
6774 cmdline_parse_token_string_t cmd_reset_set =
6775 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6776 cmdline_parse_token_string_t cmd_reset_def =
6777 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6780 cmdline_parse_inst_t cmd_reset = {
6781 .f = cmd_reset_parsed,
6783 .help_str = "set default: Reset default forwarding configuration",
6785 (void *)&cmd_reset_set,
6786 (void *)&cmd_reset_def,
6791 /* *** START FORWARDING *** */
6792 struct cmd_start_result {
6793 cmdline_fixed_string_t start;
6796 cmdline_parse_token_string_t cmd_start_start =
6797 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6799 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6800 __attribute__((unused)) struct cmdline *cl,
6801 __attribute__((unused)) void *data)
6803 start_packet_forwarding(0);
6806 cmdline_parse_inst_t cmd_start = {
6807 .f = cmd_start_parsed,
6809 .help_str = "start: Start packet forwarding",
6811 (void *)&cmd_start_start,
6816 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6817 struct cmd_start_tx_first_result {
6818 cmdline_fixed_string_t start;
6819 cmdline_fixed_string_t tx_first;
6823 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6824 __attribute__((unused)) struct cmdline *cl,
6825 __attribute__((unused)) void *data)
6827 start_packet_forwarding(1);
6830 cmdline_parse_token_string_t cmd_start_tx_first_start =
6831 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6833 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6834 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6835 tx_first, "tx_first");
6837 cmdline_parse_inst_t cmd_start_tx_first = {
6838 .f = cmd_start_tx_first_parsed,
6840 .help_str = "start tx_first: Start packet forwarding, "
6841 "after sending 1 burst of packets",
6843 (void *)&cmd_start_tx_first_start,
6844 (void *)&cmd_start_tx_first_tx_first,
6849 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6850 struct cmd_start_tx_first_n_result {
6851 cmdline_fixed_string_t start;
6852 cmdline_fixed_string_t tx_first;
6857 cmd_start_tx_first_n_parsed(void *parsed_result,
6858 __attribute__((unused)) struct cmdline *cl,
6859 __attribute__((unused)) void *data)
6861 struct cmd_start_tx_first_n_result *res = parsed_result;
6863 start_packet_forwarding(res->tx_num);
6866 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6867 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6869 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6870 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6871 tx_first, "tx_first");
6872 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6873 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6876 cmdline_parse_inst_t cmd_start_tx_first_n = {
6877 .f = cmd_start_tx_first_n_parsed,
6879 .help_str = "start tx_first <num>: "
6880 "packet forwarding, after sending <num> bursts of packets",
6882 (void *)&cmd_start_tx_first_n_start,
6883 (void *)&cmd_start_tx_first_n_tx_first,
6884 (void *)&cmd_start_tx_first_n_tx_num,
6889 /* *** SET LINK UP *** */
6890 struct cmd_set_link_up_result {
6891 cmdline_fixed_string_t set;
6892 cmdline_fixed_string_t link_up;
6893 cmdline_fixed_string_t port;
6897 cmdline_parse_token_string_t cmd_set_link_up_set =
6898 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6899 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6900 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6902 cmdline_parse_token_string_t cmd_set_link_up_port =
6903 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6904 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6905 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6907 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6908 __attribute__((unused)) struct cmdline *cl,
6909 __attribute__((unused)) void *data)
6911 struct cmd_set_link_up_result *res = parsed_result;
6912 dev_set_link_up(res->port_id);
6915 cmdline_parse_inst_t cmd_set_link_up = {
6916 .f = cmd_set_link_up_parsed,
6918 .help_str = "set link-up port <port id>",
6920 (void *)&cmd_set_link_up_set,
6921 (void *)&cmd_set_link_up_link_up,
6922 (void *)&cmd_set_link_up_port,
6923 (void *)&cmd_set_link_up_port_id,
6928 /* *** SET LINK DOWN *** */
6929 struct cmd_set_link_down_result {
6930 cmdline_fixed_string_t set;
6931 cmdline_fixed_string_t link_down;
6932 cmdline_fixed_string_t port;
6936 cmdline_parse_token_string_t cmd_set_link_down_set =
6937 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6938 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6939 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6941 cmdline_parse_token_string_t cmd_set_link_down_port =
6942 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6943 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6944 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6946 static void cmd_set_link_down_parsed(
6947 __attribute__((unused)) void *parsed_result,
6948 __attribute__((unused)) struct cmdline *cl,
6949 __attribute__((unused)) void *data)
6951 struct cmd_set_link_down_result *res = parsed_result;
6952 dev_set_link_down(res->port_id);
6955 cmdline_parse_inst_t cmd_set_link_down = {
6956 .f = cmd_set_link_down_parsed,
6958 .help_str = "set link-down port <port id>",
6960 (void *)&cmd_set_link_down_set,
6961 (void *)&cmd_set_link_down_link_down,
6962 (void *)&cmd_set_link_down_port,
6963 (void *)&cmd_set_link_down_port_id,
6968 /* *** SHOW CFG *** */
6969 struct cmd_showcfg_result {
6970 cmdline_fixed_string_t show;
6971 cmdline_fixed_string_t cfg;
6972 cmdline_fixed_string_t what;
6975 static void cmd_showcfg_parsed(void *parsed_result,
6976 __attribute__((unused)) struct cmdline *cl,
6977 __attribute__((unused)) void *data)
6979 struct cmd_showcfg_result *res = parsed_result;
6980 if (!strcmp(res->what, "rxtx"))
6981 rxtx_config_display();
6982 else if (!strcmp(res->what, "cores"))
6983 fwd_lcores_config_display();
6984 else if (!strcmp(res->what, "fwd"))
6985 pkt_fwd_config_display(&cur_fwd_config);
6986 else if (!strcmp(res->what, "txpkts"))
6987 show_tx_pkt_segments();
6990 cmdline_parse_token_string_t cmd_showcfg_show =
6991 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6992 cmdline_parse_token_string_t cmd_showcfg_port =
6993 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6994 cmdline_parse_token_string_t cmd_showcfg_what =
6995 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6996 "rxtx#cores#fwd#txpkts");
6998 cmdline_parse_inst_t cmd_showcfg = {
6999 .f = cmd_showcfg_parsed,
7001 .help_str = "show config rxtx|cores|fwd|txpkts",
7003 (void *)&cmd_showcfg_show,
7004 (void *)&cmd_showcfg_port,
7005 (void *)&cmd_showcfg_what,
7010 /* *** SHOW ALL PORT INFO *** */
7011 struct cmd_showportall_result {
7012 cmdline_fixed_string_t show;
7013 cmdline_fixed_string_t port;
7014 cmdline_fixed_string_t what;
7015 cmdline_fixed_string_t all;
7018 static void cmd_showportall_parsed(void *parsed_result,
7019 __attribute__((unused)) struct cmdline *cl,
7020 __attribute__((unused)) void *data)
7024 struct cmd_showportall_result *res = parsed_result;
7025 if (!strcmp(res->show, "clear")) {
7026 if (!strcmp(res->what, "stats"))
7027 RTE_ETH_FOREACH_DEV(i)
7029 else if (!strcmp(res->what, "xstats"))
7030 RTE_ETH_FOREACH_DEV(i)
7031 nic_xstats_clear(i);
7032 } else if (!strcmp(res->what, "info"))
7033 RTE_ETH_FOREACH_DEV(i)
7034 port_infos_display(i);
7035 else if (!strcmp(res->what, "stats"))
7036 RTE_ETH_FOREACH_DEV(i)
7037 nic_stats_display(i);
7038 else if (!strcmp(res->what, "xstats"))
7039 RTE_ETH_FOREACH_DEV(i)
7040 nic_xstats_display(i);
7041 else if (!strcmp(res->what, "fdir"))
7042 RTE_ETH_FOREACH_DEV(i)
7044 else if (!strcmp(res->what, "stat_qmap"))
7045 RTE_ETH_FOREACH_DEV(i)
7046 nic_stats_mapping_display(i);
7047 else if (!strcmp(res->what, "dcb_tc"))
7048 RTE_ETH_FOREACH_DEV(i)
7049 port_dcb_info_display(i);
7050 else if (!strcmp(res->what, "cap"))
7051 RTE_ETH_FOREACH_DEV(i)
7052 port_offload_cap_display(i);
7055 cmdline_parse_token_string_t cmd_showportall_show =
7056 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7058 cmdline_parse_token_string_t cmd_showportall_port =
7059 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7060 cmdline_parse_token_string_t cmd_showportall_what =
7061 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7062 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7063 cmdline_parse_token_string_t cmd_showportall_all =
7064 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7065 cmdline_parse_inst_t cmd_showportall = {
7066 .f = cmd_showportall_parsed,
7068 .help_str = "show|clear port "
7069 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7071 (void *)&cmd_showportall_show,
7072 (void *)&cmd_showportall_port,
7073 (void *)&cmd_showportall_what,
7074 (void *)&cmd_showportall_all,
7079 /* *** SHOW PORT INFO *** */
7080 struct cmd_showport_result {
7081 cmdline_fixed_string_t show;
7082 cmdline_fixed_string_t port;
7083 cmdline_fixed_string_t what;
7087 static void cmd_showport_parsed(void *parsed_result,
7088 __attribute__((unused)) struct cmdline *cl,
7089 __attribute__((unused)) void *data)
7091 struct cmd_showport_result *res = parsed_result;
7092 if (!strcmp(res->show, "clear")) {
7093 if (!strcmp(res->what, "stats"))
7094 nic_stats_clear(res->portnum);
7095 else if (!strcmp(res->what, "xstats"))
7096 nic_xstats_clear(res->portnum);
7097 } else if (!strcmp(res->what, "info"))
7098 port_infos_display(res->portnum);
7099 else if (!strcmp(res->what, "stats"))
7100 nic_stats_display(res->portnum);
7101 else if (!strcmp(res->what, "xstats"))
7102 nic_xstats_display(res->portnum);
7103 else if (!strcmp(res->what, "fdir"))
7104 fdir_get_infos(res->portnum);
7105 else if (!strcmp(res->what, "stat_qmap"))
7106 nic_stats_mapping_display(res->portnum);
7107 else if (!strcmp(res->what, "dcb_tc"))
7108 port_dcb_info_display(res->portnum);
7109 else if (!strcmp(res->what, "cap"))
7110 port_offload_cap_display(res->portnum);
7113 cmdline_parse_token_string_t cmd_showport_show =
7114 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7116 cmdline_parse_token_string_t cmd_showport_port =
7117 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7118 cmdline_parse_token_string_t cmd_showport_what =
7119 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7120 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7121 cmdline_parse_token_num_t cmd_showport_portnum =
7122 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7124 cmdline_parse_inst_t cmd_showport = {
7125 .f = cmd_showport_parsed,
7127 .help_str = "show|clear port "
7128 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7131 (void *)&cmd_showport_show,
7132 (void *)&cmd_showport_port,
7133 (void *)&cmd_showport_what,
7134 (void *)&cmd_showport_portnum,
7139 /* *** SHOW QUEUE INFO *** */
7140 struct cmd_showqueue_result {
7141 cmdline_fixed_string_t show;
7142 cmdline_fixed_string_t type;
7143 cmdline_fixed_string_t what;
7149 cmd_showqueue_parsed(void *parsed_result,
7150 __attribute__((unused)) struct cmdline *cl,
7151 __attribute__((unused)) void *data)
7153 struct cmd_showqueue_result *res = parsed_result;
7155 if (!strcmp(res->type, "rxq"))
7156 rx_queue_infos_display(res->portnum, res->queuenum);
7157 else if (!strcmp(res->type, "txq"))
7158 tx_queue_infos_display(res->portnum, res->queuenum);
7161 cmdline_parse_token_string_t cmd_showqueue_show =
7162 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7163 cmdline_parse_token_string_t cmd_showqueue_type =
7164 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7165 cmdline_parse_token_string_t cmd_showqueue_what =
7166 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7167 cmdline_parse_token_num_t cmd_showqueue_portnum =
7168 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7169 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7170 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7172 cmdline_parse_inst_t cmd_showqueue = {
7173 .f = cmd_showqueue_parsed,
7175 .help_str = "show rxq|txq info <port_id> <queue_id>",
7177 (void *)&cmd_showqueue_show,
7178 (void *)&cmd_showqueue_type,
7179 (void *)&cmd_showqueue_what,
7180 (void *)&cmd_showqueue_portnum,
7181 (void *)&cmd_showqueue_queuenum,
7186 /* *** READ PORT REGISTER *** */
7187 struct cmd_read_reg_result {
7188 cmdline_fixed_string_t read;
7189 cmdline_fixed_string_t reg;
7195 cmd_read_reg_parsed(void *parsed_result,
7196 __attribute__((unused)) struct cmdline *cl,
7197 __attribute__((unused)) void *data)
7199 struct cmd_read_reg_result *res = parsed_result;
7200 port_reg_display(res->port_id, res->reg_off);
7203 cmdline_parse_token_string_t cmd_read_reg_read =
7204 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7205 cmdline_parse_token_string_t cmd_read_reg_reg =
7206 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7207 cmdline_parse_token_num_t cmd_read_reg_port_id =
7208 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7209 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7210 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7212 cmdline_parse_inst_t cmd_read_reg = {
7213 .f = cmd_read_reg_parsed,
7215 .help_str = "read reg <port_id> <reg_off>",
7217 (void *)&cmd_read_reg_read,
7218 (void *)&cmd_read_reg_reg,
7219 (void *)&cmd_read_reg_port_id,
7220 (void *)&cmd_read_reg_reg_off,
7225 /* *** READ PORT REGISTER BIT FIELD *** */
7226 struct cmd_read_reg_bit_field_result {
7227 cmdline_fixed_string_t read;
7228 cmdline_fixed_string_t regfield;
7236 cmd_read_reg_bit_field_parsed(void *parsed_result,
7237 __attribute__((unused)) struct cmdline *cl,
7238 __attribute__((unused)) void *data)
7240 struct cmd_read_reg_bit_field_result *res = parsed_result;
7241 port_reg_bit_field_display(res->port_id, res->reg_off,
7242 res->bit1_pos, res->bit2_pos);
7245 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7246 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7248 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7249 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7250 regfield, "regfield");
7251 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7252 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7254 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7255 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7257 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7258 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7260 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7261 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7264 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7265 .f = cmd_read_reg_bit_field_parsed,
7267 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7268 "Read register bit field between bit_x and bit_y included",
7270 (void *)&cmd_read_reg_bit_field_read,
7271 (void *)&cmd_read_reg_bit_field_regfield,
7272 (void *)&cmd_read_reg_bit_field_port_id,
7273 (void *)&cmd_read_reg_bit_field_reg_off,
7274 (void *)&cmd_read_reg_bit_field_bit1_pos,
7275 (void *)&cmd_read_reg_bit_field_bit2_pos,
7280 /* *** READ PORT REGISTER BIT *** */
7281 struct cmd_read_reg_bit_result {
7282 cmdline_fixed_string_t read;
7283 cmdline_fixed_string_t regbit;
7290 cmd_read_reg_bit_parsed(void *parsed_result,
7291 __attribute__((unused)) struct cmdline *cl,
7292 __attribute__((unused)) void *data)
7294 struct cmd_read_reg_bit_result *res = parsed_result;
7295 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7298 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7299 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7300 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7301 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7303 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7304 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7305 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7306 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7307 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7308 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7310 cmdline_parse_inst_t cmd_read_reg_bit = {
7311 .f = cmd_read_reg_bit_parsed,
7313 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7315 (void *)&cmd_read_reg_bit_read,
7316 (void *)&cmd_read_reg_bit_regbit,
7317 (void *)&cmd_read_reg_bit_port_id,
7318 (void *)&cmd_read_reg_bit_reg_off,
7319 (void *)&cmd_read_reg_bit_bit_pos,
7324 /* *** WRITE PORT REGISTER *** */
7325 struct cmd_write_reg_result {
7326 cmdline_fixed_string_t write;
7327 cmdline_fixed_string_t reg;
7334 cmd_write_reg_parsed(void *parsed_result,
7335 __attribute__((unused)) struct cmdline *cl,
7336 __attribute__((unused)) void *data)
7338 struct cmd_write_reg_result *res = parsed_result;
7339 port_reg_set(res->port_id, res->reg_off, res->value);
7342 cmdline_parse_token_string_t cmd_write_reg_write =
7343 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7344 cmdline_parse_token_string_t cmd_write_reg_reg =
7345 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7346 cmdline_parse_token_num_t cmd_write_reg_port_id =
7347 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7348 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7349 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7350 cmdline_parse_token_num_t cmd_write_reg_value =
7351 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7353 cmdline_parse_inst_t cmd_write_reg = {
7354 .f = cmd_write_reg_parsed,
7356 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7358 (void *)&cmd_write_reg_write,
7359 (void *)&cmd_write_reg_reg,
7360 (void *)&cmd_write_reg_port_id,
7361 (void *)&cmd_write_reg_reg_off,
7362 (void *)&cmd_write_reg_value,
7367 /* *** WRITE PORT REGISTER BIT FIELD *** */
7368 struct cmd_write_reg_bit_field_result {
7369 cmdline_fixed_string_t write;
7370 cmdline_fixed_string_t regfield;
7379 cmd_write_reg_bit_field_parsed(void *parsed_result,
7380 __attribute__((unused)) struct cmdline *cl,
7381 __attribute__((unused)) void *data)
7383 struct cmd_write_reg_bit_field_result *res = parsed_result;
7384 port_reg_bit_field_set(res->port_id, res->reg_off,
7385 res->bit1_pos, res->bit2_pos, res->value);
7388 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7389 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7391 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7392 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7393 regfield, "regfield");
7394 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7395 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7397 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7398 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7400 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7401 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7403 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7404 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7406 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7407 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7410 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7411 .f = cmd_write_reg_bit_field_parsed,
7413 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7415 "Set register bit field between bit_x and bit_y included",
7417 (void *)&cmd_write_reg_bit_field_write,
7418 (void *)&cmd_write_reg_bit_field_regfield,
7419 (void *)&cmd_write_reg_bit_field_port_id,
7420 (void *)&cmd_write_reg_bit_field_reg_off,
7421 (void *)&cmd_write_reg_bit_field_bit1_pos,
7422 (void *)&cmd_write_reg_bit_field_bit2_pos,
7423 (void *)&cmd_write_reg_bit_field_value,
7428 /* *** WRITE PORT REGISTER BIT *** */
7429 struct cmd_write_reg_bit_result {
7430 cmdline_fixed_string_t write;
7431 cmdline_fixed_string_t regbit;
7439 cmd_write_reg_bit_parsed(void *parsed_result,
7440 __attribute__((unused)) struct cmdline *cl,
7441 __attribute__((unused)) void *data)
7443 struct cmd_write_reg_bit_result *res = parsed_result;
7444 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7447 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7448 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7450 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7451 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7453 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7454 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7455 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7456 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7457 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7458 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7459 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7460 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7462 cmdline_parse_inst_t cmd_write_reg_bit = {
7463 .f = cmd_write_reg_bit_parsed,
7465 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7468 (void *)&cmd_write_reg_bit_write,
7469 (void *)&cmd_write_reg_bit_regbit,
7470 (void *)&cmd_write_reg_bit_port_id,
7471 (void *)&cmd_write_reg_bit_reg_off,
7472 (void *)&cmd_write_reg_bit_bit_pos,
7473 (void *)&cmd_write_reg_bit_value,
7478 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7479 struct cmd_read_rxd_txd_result {
7480 cmdline_fixed_string_t read;
7481 cmdline_fixed_string_t rxd_txd;
7488 cmd_read_rxd_txd_parsed(void *parsed_result,
7489 __attribute__((unused)) struct cmdline *cl,
7490 __attribute__((unused)) void *data)
7492 struct cmd_read_rxd_txd_result *res = parsed_result;
7494 if (!strcmp(res->rxd_txd, "rxd"))
7495 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7496 else if (!strcmp(res->rxd_txd, "txd"))
7497 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7500 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7501 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7502 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7503 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7505 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7506 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7507 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7508 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7509 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7510 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7512 cmdline_parse_inst_t cmd_read_rxd_txd = {
7513 .f = cmd_read_rxd_txd_parsed,
7515 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7517 (void *)&cmd_read_rxd_txd_read,
7518 (void *)&cmd_read_rxd_txd_rxd_txd,
7519 (void *)&cmd_read_rxd_txd_port_id,
7520 (void *)&cmd_read_rxd_txd_queue_id,
7521 (void *)&cmd_read_rxd_txd_desc_id,
7527 struct cmd_quit_result {
7528 cmdline_fixed_string_t quit;
7531 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7533 __attribute__((unused)) void *data)
7539 cmdline_parse_token_string_t cmd_quit_quit =
7540 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7542 cmdline_parse_inst_t cmd_quit = {
7543 .f = cmd_quit_parsed,
7545 .help_str = "quit: Exit application",
7547 (void *)&cmd_quit_quit,
7552 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7553 struct cmd_mac_addr_result {
7554 cmdline_fixed_string_t mac_addr_cmd;
7555 cmdline_fixed_string_t what;
7557 struct ether_addr address;
7560 static void cmd_mac_addr_parsed(void *parsed_result,
7561 __attribute__((unused)) struct cmdline *cl,
7562 __attribute__((unused)) void *data)
7564 struct cmd_mac_addr_result *res = parsed_result;
7567 if (strcmp(res->what, "add") == 0)
7568 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7569 else if (strcmp(res->what, "set") == 0)
7570 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7573 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7575 /* check the return value and print it if is < 0 */
7577 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7581 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7582 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7584 cmdline_parse_token_string_t cmd_mac_addr_what =
7585 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7587 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7588 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7590 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7591 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7593 cmdline_parse_inst_t cmd_mac_addr = {
7594 .f = cmd_mac_addr_parsed,
7596 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7597 "Add/Remove/Set MAC address on port_id",
7599 (void *)&cmd_mac_addr_cmd,
7600 (void *)&cmd_mac_addr_what,
7601 (void *)&cmd_mac_addr_portnum,
7602 (void *)&cmd_mac_addr_addr,
7607 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7608 struct cmd_eth_peer_result {
7609 cmdline_fixed_string_t set;
7610 cmdline_fixed_string_t eth_peer;
7612 cmdline_fixed_string_t peer_addr;
7615 static void cmd_set_eth_peer_parsed(void *parsed_result,
7616 __attribute__((unused)) struct cmdline *cl,
7617 __attribute__((unused)) void *data)
7619 struct cmd_eth_peer_result *res = parsed_result;
7621 if (test_done == 0) {
7622 printf("Please stop forwarding first\n");
7625 if (!strcmp(res->eth_peer, "eth-peer")) {
7626 set_fwd_eth_peer(res->port_id, res->peer_addr);
7630 cmdline_parse_token_string_t cmd_eth_peer_set =
7631 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7632 cmdline_parse_token_string_t cmd_eth_peer =
7633 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7634 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7635 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7636 cmdline_parse_token_string_t cmd_eth_peer_addr =
7637 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7639 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7640 .f = cmd_set_eth_peer_parsed,
7642 .help_str = "set eth-peer <port_id> <peer_mac>",
7644 (void *)&cmd_eth_peer_set,
7645 (void *)&cmd_eth_peer,
7646 (void *)&cmd_eth_peer_port_id,
7647 (void *)&cmd_eth_peer_addr,
7652 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7653 struct cmd_set_qmap_result {
7654 cmdline_fixed_string_t set;
7655 cmdline_fixed_string_t qmap;
7656 cmdline_fixed_string_t what;
7663 cmd_set_qmap_parsed(void *parsed_result,
7664 __attribute__((unused)) struct cmdline *cl,
7665 __attribute__((unused)) void *data)
7667 struct cmd_set_qmap_result *res = parsed_result;
7668 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7670 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7673 cmdline_parse_token_string_t cmd_setqmap_set =
7674 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7676 cmdline_parse_token_string_t cmd_setqmap_qmap =
7677 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7679 cmdline_parse_token_string_t cmd_setqmap_what =
7680 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7682 cmdline_parse_token_num_t cmd_setqmap_portid =
7683 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7685 cmdline_parse_token_num_t cmd_setqmap_queueid =
7686 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7688 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7689 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7692 cmdline_parse_inst_t cmd_set_qmap = {
7693 .f = cmd_set_qmap_parsed,
7695 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7696 "Set statistics mapping value on tx|rx queue_id of port_id",
7698 (void *)&cmd_setqmap_set,
7699 (void *)&cmd_setqmap_qmap,
7700 (void *)&cmd_setqmap_what,
7701 (void *)&cmd_setqmap_portid,
7702 (void *)&cmd_setqmap_queueid,
7703 (void *)&cmd_setqmap_mapvalue,
7708 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7709 struct cmd_set_xstats_hide_zero_result {
7710 cmdline_fixed_string_t keyword;
7711 cmdline_fixed_string_t name;
7712 cmdline_fixed_string_t on_off;
7716 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7717 __attribute__((unused)) struct cmdline *cl,
7718 __attribute__((unused)) void *data)
7720 struct cmd_set_xstats_hide_zero_result *res;
7721 uint16_t on_off = 0;
7723 res = parsed_result;
7724 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7725 set_xstats_hide_zero(on_off);
7728 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7729 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7731 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7732 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7733 name, "xstats-hide-zero");
7734 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7735 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7738 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7739 .f = cmd_set_xstats_hide_zero_parsed,
7741 .help_str = "set xstats-hide-zero on|off",
7743 (void *)&cmd_set_xstats_hide_zero_keyword,
7744 (void *)&cmd_set_xstats_hide_zero_name,
7745 (void *)&cmd_set_xstats_hide_zero_on_off,
7750 /* *** CONFIGURE UNICAST HASH TABLE *** */
7751 struct cmd_set_uc_hash_table {
7752 cmdline_fixed_string_t set;
7753 cmdline_fixed_string_t port;
7755 cmdline_fixed_string_t what;
7756 struct ether_addr address;
7757 cmdline_fixed_string_t mode;
7761 cmd_set_uc_hash_parsed(void *parsed_result,
7762 __attribute__((unused)) struct cmdline *cl,
7763 __attribute__((unused)) void *data)
7766 struct cmd_set_uc_hash_table *res = parsed_result;
7768 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7770 if (strcmp(res->what, "uta") == 0)
7771 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7772 &res->address,(uint8_t)is_on);
7774 printf("bad unicast hash table parameter, return code = %d \n", ret);
7778 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7779 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7781 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7782 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7784 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7785 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7787 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7788 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7790 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7791 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7793 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7794 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7797 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7798 .f = cmd_set_uc_hash_parsed,
7800 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7802 (void *)&cmd_set_uc_hash_set,
7803 (void *)&cmd_set_uc_hash_port,
7804 (void *)&cmd_set_uc_hash_portid,
7805 (void *)&cmd_set_uc_hash_what,
7806 (void *)&cmd_set_uc_hash_mac,
7807 (void *)&cmd_set_uc_hash_mode,
7812 struct cmd_set_uc_all_hash_table {
7813 cmdline_fixed_string_t set;
7814 cmdline_fixed_string_t port;
7816 cmdline_fixed_string_t what;
7817 cmdline_fixed_string_t value;
7818 cmdline_fixed_string_t mode;
7822 cmd_set_uc_all_hash_parsed(void *parsed_result,
7823 __attribute__((unused)) struct cmdline *cl,
7824 __attribute__((unused)) void *data)
7827 struct cmd_set_uc_all_hash_table *res = parsed_result;
7829 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7831 if ((strcmp(res->what, "uta") == 0) &&
7832 (strcmp(res->value, "all") == 0))
7833 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7835 printf("bad unicast hash table parameter,"
7836 "return code = %d \n", ret);
7839 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7840 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7842 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7843 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7845 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7846 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7848 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7849 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7851 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7852 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7854 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7855 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7858 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7859 .f = cmd_set_uc_all_hash_parsed,
7861 .help_str = "set port <port_id> uta all on|off",
7863 (void *)&cmd_set_uc_all_hash_set,
7864 (void *)&cmd_set_uc_all_hash_port,
7865 (void *)&cmd_set_uc_all_hash_portid,
7866 (void *)&cmd_set_uc_all_hash_what,
7867 (void *)&cmd_set_uc_all_hash_value,
7868 (void *)&cmd_set_uc_all_hash_mode,
7873 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7874 struct cmd_set_vf_macvlan_filter {
7875 cmdline_fixed_string_t set;
7876 cmdline_fixed_string_t port;
7878 cmdline_fixed_string_t vf;
7880 struct ether_addr address;
7881 cmdline_fixed_string_t filter_type;
7882 cmdline_fixed_string_t mode;
7886 cmd_set_vf_macvlan_parsed(void *parsed_result,
7887 __attribute__((unused)) struct cmdline *cl,
7888 __attribute__((unused)) void *data)
7891 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7892 struct rte_eth_mac_filter filter;
7894 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7896 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7898 /* set VF MAC filter */
7902 filter.dst_id = res->vf_id;
7904 if (!strcmp(res->filter_type, "exact-mac"))
7905 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7906 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7907 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7908 else if (!strcmp(res->filter_type, "hashmac"))
7909 filter.filter_type = RTE_MAC_HASH_MATCH;
7910 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7911 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7913 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7916 ret = rte_eth_dev_filter_ctrl(res->port_id,
7917 RTE_ETH_FILTER_MACVLAN,
7921 ret = rte_eth_dev_filter_ctrl(res->port_id,
7922 RTE_ETH_FILTER_MACVLAN,
7923 RTE_ETH_FILTER_DELETE,
7927 printf("bad set MAC hash parameter, return code = %d\n", ret);
7931 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7932 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7934 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7935 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7937 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7938 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7940 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7941 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7943 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7944 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7946 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7947 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7949 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7950 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7951 filter_type, "exact-mac#exact-mac-vlan"
7952 "#hashmac#hashmac-vlan");
7953 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7954 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7957 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7958 .f = cmd_set_vf_macvlan_parsed,
7960 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7961 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7962 "Exact match rule: exact match of MAC or MAC and VLAN; "
7963 "hash match rule: hash match of MAC and exact match of VLAN",
7965 (void *)&cmd_set_vf_macvlan_set,
7966 (void *)&cmd_set_vf_macvlan_port,
7967 (void *)&cmd_set_vf_macvlan_portid,
7968 (void *)&cmd_set_vf_macvlan_vf,
7969 (void *)&cmd_set_vf_macvlan_vf_id,
7970 (void *)&cmd_set_vf_macvlan_mac,
7971 (void *)&cmd_set_vf_macvlan_filter_type,
7972 (void *)&cmd_set_vf_macvlan_mode,
7977 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7978 struct cmd_set_vf_traffic {
7979 cmdline_fixed_string_t set;
7980 cmdline_fixed_string_t port;
7982 cmdline_fixed_string_t vf;
7984 cmdline_fixed_string_t what;
7985 cmdline_fixed_string_t mode;
7989 cmd_set_vf_traffic_parsed(void *parsed_result,
7990 __attribute__((unused)) struct cmdline *cl,
7991 __attribute__((unused)) void *data)
7993 struct cmd_set_vf_traffic *res = parsed_result;
7994 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7995 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7997 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8000 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8001 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8003 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8004 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8006 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8007 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8009 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8010 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8012 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8013 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8015 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8016 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8018 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8019 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8022 cmdline_parse_inst_t cmd_set_vf_traffic = {
8023 .f = cmd_set_vf_traffic_parsed,
8025 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8027 (void *)&cmd_setvf_traffic_set,
8028 (void *)&cmd_setvf_traffic_port,
8029 (void *)&cmd_setvf_traffic_portid,
8030 (void *)&cmd_setvf_traffic_vf,
8031 (void *)&cmd_setvf_traffic_vfid,
8032 (void *)&cmd_setvf_traffic_what,
8033 (void *)&cmd_setvf_traffic_mode,
8038 /* *** CONFIGURE VF RECEIVE MODE *** */
8039 struct cmd_set_vf_rxmode {
8040 cmdline_fixed_string_t set;
8041 cmdline_fixed_string_t port;
8043 cmdline_fixed_string_t vf;
8045 cmdline_fixed_string_t what;
8046 cmdline_fixed_string_t mode;
8047 cmdline_fixed_string_t on;
8051 cmd_set_vf_rxmode_parsed(void *parsed_result,
8052 __attribute__((unused)) struct cmdline *cl,
8053 __attribute__((unused)) void *data)
8056 uint16_t rx_mode = 0;
8057 struct cmd_set_vf_rxmode *res = parsed_result;
8059 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8060 if (!strcmp(res->what,"rxmode")) {
8061 if (!strcmp(res->mode, "AUPE"))
8062 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8063 else if (!strcmp(res->mode, "ROPE"))
8064 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8065 else if (!strcmp(res->mode, "BAM"))
8066 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8067 else if (!strncmp(res->mode, "MPE",3))
8068 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8071 RTE_SET_USED(is_on);
8073 #ifdef RTE_LIBRTE_IXGBE_PMD
8074 if (ret == -ENOTSUP)
8075 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8076 rx_mode, (uint8_t)is_on);
8078 #ifdef RTE_LIBRTE_BNXT_PMD
8079 if (ret == -ENOTSUP)
8080 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8081 rx_mode, (uint8_t)is_on);
8084 printf("bad VF receive mode parameter, return code = %d \n",
8088 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8089 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8091 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8092 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8094 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8095 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8097 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8098 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8100 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8101 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8103 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8104 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8106 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8107 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8108 mode, "AUPE#ROPE#BAM#MPE");
8109 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8110 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8113 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8114 .f = cmd_set_vf_rxmode_parsed,
8116 .help_str = "set port <port_id> vf <vf_id> rxmode "
8117 "AUPE|ROPE|BAM|MPE on|off",
8119 (void *)&cmd_set_vf_rxmode_set,
8120 (void *)&cmd_set_vf_rxmode_port,
8121 (void *)&cmd_set_vf_rxmode_portid,
8122 (void *)&cmd_set_vf_rxmode_vf,
8123 (void *)&cmd_set_vf_rxmode_vfid,
8124 (void *)&cmd_set_vf_rxmode_what,
8125 (void *)&cmd_set_vf_rxmode_mode,
8126 (void *)&cmd_set_vf_rxmode_on,
8131 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8132 struct cmd_vf_mac_addr_result {
8133 cmdline_fixed_string_t mac_addr_cmd;
8134 cmdline_fixed_string_t what;
8135 cmdline_fixed_string_t port;
8137 cmdline_fixed_string_t vf;
8139 struct ether_addr address;
8142 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8143 __attribute__((unused)) struct cmdline *cl,
8144 __attribute__((unused)) void *data)
8146 struct cmd_vf_mac_addr_result *res = parsed_result;
8149 if (strcmp(res->what, "add") != 0)
8152 #ifdef RTE_LIBRTE_I40E_PMD
8153 if (ret == -ENOTSUP)
8154 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8157 #ifdef RTE_LIBRTE_BNXT_PMD
8158 if (ret == -ENOTSUP)
8159 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8164 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8168 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8169 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8170 mac_addr_cmd,"mac_addr");
8171 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8172 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8174 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8175 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8177 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8178 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8180 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8181 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8183 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8184 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8186 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8187 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8190 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8191 .f = cmd_vf_mac_addr_parsed,
8193 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8194 "Add MAC address filtering for a VF on port_id",
8196 (void *)&cmd_vf_mac_addr_cmd,
8197 (void *)&cmd_vf_mac_addr_what,
8198 (void *)&cmd_vf_mac_addr_port,
8199 (void *)&cmd_vf_mac_addr_portnum,
8200 (void *)&cmd_vf_mac_addr_vf,
8201 (void *)&cmd_vf_mac_addr_vfnum,
8202 (void *)&cmd_vf_mac_addr_addr,
8207 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8208 struct cmd_vf_rx_vlan_filter {
8209 cmdline_fixed_string_t rx_vlan;
8210 cmdline_fixed_string_t what;
8212 cmdline_fixed_string_t port;
8214 cmdline_fixed_string_t vf;
8219 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8220 __attribute__((unused)) struct cmdline *cl,
8221 __attribute__((unused)) void *data)
8223 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8226 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8228 #ifdef RTE_LIBRTE_IXGBE_PMD
8229 if (ret == -ENOTSUP)
8230 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8231 res->vlan_id, res->vf_mask, is_add);
8233 #ifdef RTE_LIBRTE_I40E_PMD
8234 if (ret == -ENOTSUP)
8235 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8236 res->vlan_id, res->vf_mask, is_add);
8238 #ifdef RTE_LIBRTE_BNXT_PMD
8239 if (ret == -ENOTSUP)
8240 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8241 res->vlan_id, res->vf_mask, is_add);
8248 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8249 res->vlan_id, res->vf_mask);
8252 printf("invalid port_id %d\n", res->port_id);
8255 printf("function not implemented or supported\n");
8258 printf("programming error: (%s)\n", strerror(-ret));
8262 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8263 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8264 rx_vlan, "rx_vlan");
8265 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8266 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8268 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8269 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8271 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8272 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8274 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8275 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8277 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8278 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8280 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8281 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8284 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8285 .f = cmd_vf_rx_vlan_filter_parsed,
8287 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8288 "(vf_mask = hexadecimal VF mask)",
8290 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8291 (void *)&cmd_vf_rx_vlan_filter_what,
8292 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8293 (void *)&cmd_vf_rx_vlan_filter_port,
8294 (void *)&cmd_vf_rx_vlan_filter_portid,
8295 (void *)&cmd_vf_rx_vlan_filter_vf,
8296 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8301 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8302 struct cmd_queue_rate_limit_result {
8303 cmdline_fixed_string_t set;
8304 cmdline_fixed_string_t port;
8306 cmdline_fixed_string_t queue;
8308 cmdline_fixed_string_t rate;
8312 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8313 __attribute__((unused)) struct cmdline *cl,
8314 __attribute__((unused)) void *data)
8316 struct cmd_queue_rate_limit_result *res = parsed_result;
8319 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8320 && (strcmp(res->queue, "queue") == 0)
8321 && (strcmp(res->rate, "rate") == 0))
8322 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8325 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8329 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8330 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8332 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8333 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8335 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8336 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8338 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8339 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8341 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8342 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8344 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8345 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8347 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8348 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8351 cmdline_parse_inst_t cmd_queue_rate_limit = {
8352 .f = cmd_queue_rate_limit_parsed,
8354 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8355 "Set rate limit for a queue on port_id",
8357 (void *)&cmd_queue_rate_limit_set,
8358 (void *)&cmd_queue_rate_limit_port,
8359 (void *)&cmd_queue_rate_limit_portnum,
8360 (void *)&cmd_queue_rate_limit_queue,
8361 (void *)&cmd_queue_rate_limit_queuenum,
8362 (void *)&cmd_queue_rate_limit_rate,
8363 (void *)&cmd_queue_rate_limit_ratenum,
8368 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8369 struct cmd_vf_rate_limit_result {
8370 cmdline_fixed_string_t set;
8371 cmdline_fixed_string_t port;
8373 cmdline_fixed_string_t vf;
8375 cmdline_fixed_string_t rate;
8377 cmdline_fixed_string_t q_msk;
8381 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8382 __attribute__((unused)) struct cmdline *cl,
8383 __attribute__((unused)) void *data)
8385 struct cmd_vf_rate_limit_result *res = parsed_result;
8388 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8389 && (strcmp(res->vf, "vf") == 0)
8390 && (strcmp(res->rate, "rate") == 0)
8391 && (strcmp(res->q_msk, "queue_mask") == 0))
8392 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8393 res->rate_num, res->q_msk_val);
8395 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8399 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8400 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8402 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8403 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8405 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8406 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8408 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8409 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8411 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8412 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8414 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8415 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8417 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8418 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8420 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8421 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8422 q_msk, "queue_mask");
8423 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8424 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8427 cmdline_parse_inst_t cmd_vf_rate_limit = {
8428 .f = cmd_vf_rate_limit_parsed,
8430 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8431 "queue_mask <queue_mask_value>: "
8432 "Set rate limit for queues of VF on port_id",
8434 (void *)&cmd_vf_rate_limit_set,
8435 (void *)&cmd_vf_rate_limit_port,
8436 (void *)&cmd_vf_rate_limit_portnum,
8437 (void *)&cmd_vf_rate_limit_vf,
8438 (void *)&cmd_vf_rate_limit_vfnum,
8439 (void *)&cmd_vf_rate_limit_rate,
8440 (void *)&cmd_vf_rate_limit_ratenum,
8441 (void *)&cmd_vf_rate_limit_q_msk,
8442 (void *)&cmd_vf_rate_limit_q_msk_val,
8447 /* *** ADD TUNNEL FILTER OF A PORT *** */
8448 struct cmd_tunnel_filter_result {
8449 cmdline_fixed_string_t cmd;
8450 cmdline_fixed_string_t what;
8452 struct ether_addr outer_mac;
8453 struct ether_addr inner_mac;
8454 cmdline_ipaddr_t ip_value;
8455 uint16_t inner_vlan;
8456 cmdline_fixed_string_t tunnel_type;
8457 cmdline_fixed_string_t filter_type;
8463 cmd_tunnel_filter_parsed(void *parsed_result,
8464 __attribute__((unused)) struct cmdline *cl,
8465 __attribute__((unused)) void *data)
8467 struct cmd_tunnel_filter_result *res = parsed_result;
8468 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8471 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8473 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8474 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8475 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8477 if (res->ip_value.family == AF_INET) {
8478 tunnel_filter_conf.ip_addr.ipv4_addr =
8479 res->ip_value.addr.ipv4.s_addr;
8480 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8482 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8483 &(res->ip_value.addr.ipv6),
8484 sizeof(struct in6_addr));
8485 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8488 if (!strcmp(res->filter_type, "imac-ivlan"))
8489 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8490 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8491 tunnel_filter_conf.filter_type =
8492 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8493 else if (!strcmp(res->filter_type, "imac-tenid"))
8494 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8495 else if (!strcmp(res->filter_type, "imac"))
8496 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8497 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8498 tunnel_filter_conf.filter_type =
8499 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8500 else if (!strcmp(res->filter_type, "oip"))
8501 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8502 else if (!strcmp(res->filter_type, "iip"))
8503 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8505 printf("The filter type is not supported");
8509 if (!strcmp(res->tunnel_type, "vxlan"))
8510 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8511 else if (!strcmp(res->tunnel_type, "nvgre"))
8512 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8513 else if (!strcmp(res->tunnel_type, "ipingre"))
8514 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8516 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8520 tunnel_filter_conf.tenant_id = res->tenant_id;
8521 tunnel_filter_conf.queue_id = res->queue_num;
8522 if (!strcmp(res->what, "add"))
8523 ret = rte_eth_dev_filter_ctrl(res->port_id,
8524 RTE_ETH_FILTER_TUNNEL,
8526 &tunnel_filter_conf);
8528 ret = rte_eth_dev_filter_ctrl(res->port_id,
8529 RTE_ETH_FILTER_TUNNEL,
8530 RTE_ETH_FILTER_DELETE,
8531 &tunnel_filter_conf);
8533 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8537 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8538 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8539 cmd, "tunnel_filter");
8540 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8541 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8543 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8544 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8546 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8547 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8549 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8550 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8552 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8553 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8554 inner_vlan, UINT16);
8555 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8556 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8558 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8559 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8560 tunnel_type, "vxlan#nvgre#ipingre");
8562 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8563 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8564 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8565 "imac#omac-imac-tenid");
8566 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8567 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8569 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8570 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8573 cmdline_parse_inst_t cmd_tunnel_filter = {
8574 .f = cmd_tunnel_filter_parsed,
8576 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8577 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8578 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8579 "<queue_id>: Add/Rm tunnel filter of a port",
8581 (void *)&cmd_tunnel_filter_cmd,
8582 (void *)&cmd_tunnel_filter_what,
8583 (void *)&cmd_tunnel_filter_port_id,
8584 (void *)&cmd_tunnel_filter_outer_mac,
8585 (void *)&cmd_tunnel_filter_inner_mac,
8586 (void *)&cmd_tunnel_filter_ip_value,
8587 (void *)&cmd_tunnel_filter_innner_vlan,
8588 (void *)&cmd_tunnel_filter_tunnel_type,
8589 (void *)&cmd_tunnel_filter_filter_type,
8590 (void *)&cmd_tunnel_filter_tenant_id,
8591 (void *)&cmd_tunnel_filter_queue_num,
8596 /* *** CONFIGURE TUNNEL UDP PORT *** */
8597 struct cmd_tunnel_udp_config {
8598 cmdline_fixed_string_t cmd;
8599 cmdline_fixed_string_t what;
8605 cmd_tunnel_udp_config_parsed(void *parsed_result,
8606 __attribute__((unused)) struct cmdline *cl,
8607 __attribute__((unused)) void *data)
8609 struct cmd_tunnel_udp_config *res = parsed_result;
8610 struct rte_eth_udp_tunnel tunnel_udp;
8613 tunnel_udp.udp_port = res->udp_port;
8615 if (!strcmp(res->cmd, "rx_vxlan_port"))
8616 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8618 if (!strcmp(res->what, "add"))
8619 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8622 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8626 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8629 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8630 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8631 cmd, "rx_vxlan_port");
8632 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8633 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8635 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8636 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8638 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8639 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8642 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8643 .f = cmd_tunnel_udp_config_parsed,
8645 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8646 "Add/Remove a tunneling UDP port filter",
8648 (void *)&cmd_tunnel_udp_config_cmd,
8649 (void *)&cmd_tunnel_udp_config_what,
8650 (void *)&cmd_tunnel_udp_config_udp_port,
8651 (void *)&cmd_tunnel_udp_config_port_id,
8656 struct cmd_config_tunnel_udp_port {
8657 cmdline_fixed_string_t port;
8658 cmdline_fixed_string_t config;
8660 cmdline_fixed_string_t udp_tunnel_port;
8661 cmdline_fixed_string_t action;
8662 cmdline_fixed_string_t tunnel_type;
8667 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8668 __attribute__((unused)) struct cmdline *cl,
8669 __attribute__((unused)) void *data)
8671 struct cmd_config_tunnel_udp_port *res = parsed_result;
8672 struct rte_eth_udp_tunnel tunnel_udp;
8675 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8678 tunnel_udp.udp_port = res->udp_port;
8680 if (!strcmp(res->tunnel_type, "vxlan")) {
8681 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8682 } else if (!strcmp(res->tunnel_type, "geneve")) {
8683 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8685 printf("Invalid tunnel type\n");
8689 if (!strcmp(res->action, "add"))
8690 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8693 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8697 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8700 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8701 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8703 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8704 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8706 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8707 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8709 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8710 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8713 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8714 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8716 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8717 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8719 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8720 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8723 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8724 .f = cmd_cfg_tunnel_udp_port_parsed,
8726 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8728 (void *)&cmd_config_tunnel_udp_port_port,
8729 (void *)&cmd_config_tunnel_udp_port_config,
8730 (void *)&cmd_config_tunnel_udp_port_port_id,
8731 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8732 (void *)&cmd_config_tunnel_udp_port_action,
8733 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8734 (void *)&cmd_config_tunnel_udp_port_value,
8739 /* *** GLOBAL CONFIG *** */
8740 struct cmd_global_config_result {
8741 cmdline_fixed_string_t cmd;
8743 cmdline_fixed_string_t cfg_type;
8748 cmd_global_config_parsed(void *parsed_result,
8749 __attribute__((unused)) struct cmdline *cl,
8750 __attribute__((unused)) void *data)
8752 struct cmd_global_config_result *res = parsed_result;
8753 struct rte_eth_global_cfg conf;
8756 memset(&conf, 0, sizeof(conf));
8757 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8758 conf.cfg.gre_key_len = res->len;
8759 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8760 RTE_ETH_FILTER_SET, &conf);
8762 printf("Global config error\n");
8765 cmdline_parse_token_string_t cmd_global_config_cmd =
8766 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8768 cmdline_parse_token_num_t cmd_global_config_port_id =
8769 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8771 cmdline_parse_token_string_t cmd_global_config_type =
8772 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8773 cfg_type, "gre-key-len");
8774 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8775 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8778 cmdline_parse_inst_t cmd_global_config = {
8779 .f = cmd_global_config_parsed,
8780 .data = (void *)NULL,
8781 .help_str = "global_config <port_id> gre-key-len <key_len>",
8783 (void *)&cmd_global_config_cmd,
8784 (void *)&cmd_global_config_port_id,
8785 (void *)&cmd_global_config_type,
8786 (void *)&cmd_global_config_gre_key_len,
8791 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8792 struct cmd_set_mirror_mask_result {
8793 cmdline_fixed_string_t set;
8794 cmdline_fixed_string_t port;
8796 cmdline_fixed_string_t mirror;
8798 cmdline_fixed_string_t what;
8799 cmdline_fixed_string_t value;
8800 cmdline_fixed_string_t dstpool;
8802 cmdline_fixed_string_t on;
8805 cmdline_parse_token_string_t cmd_mirror_mask_set =
8806 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8808 cmdline_parse_token_string_t cmd_mirror_mask_port =
8809 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8811 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8812 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8814 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8815 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8816 mirror, "mirror-rule");
8817 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8818 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8820 cmdline_parse_token_string_t cmd_mirror_mask_what =
8821 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8822 what, "pool-mirror-up#pool-mirror-down"
8824 cmdline_parse_token_string_t cmd_mirror_mask_value =
8825 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8827 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8828 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8829 dstpool, "dst-pool");
8830 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8831 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8833 cmdline_parse_token_string_t cmd_mirror_mask_on =
8834 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8838 cmd_set_mirror_mask_parsed(void *parsed_result,
8839 __attribute__((unused)) struct cmdline *cl,
8840 __attribute__((unused)) void *data)
8843 struct cmd_set_mirror_mask_result *res = parsed_result;
8844 struct rte_eth_mirror_conf mr_conf;
8846 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8848 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8850 mr_conf.dst_pool = res->dstpool_id;
8852 if (!strcmp(res->what, "pool-mirror-up")) {
8853 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8854 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8855 } else if (!strcmp(res->what, "pool-mirror-down")) {
8856 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8857 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8858 } else if (!strcmp(res->what, "vlan-mirror")) {
8859 mr_conf.rule_type = ETH_MIRROR_VLAN;
8860 nb_item = parse_item_list(res->value, "vlan",
8861 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8865 for (i = 0; i < nb_item; i++) {
8866 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8867 printf("Invalid vlan_id: must be < 4096\n");
8871 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8872 mr_conf.vlan.vlan_mask |= 1ULL << i;
8876 if (!strcmp(res->on, "on"))
8877 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8880 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8883 printf("mirror rule add error: (%s)\n", strerror(-ret));
8886 cmdline_parse_inst_t cmd_set_mirror_mask = {
8887 .f = cmd_set_mirror_mask_parsed,
8889 .help_str = "set port <port_id> mirror-rule <rule_id> "
8890 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8891 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8893 (void *)&cmd_mirror_mask_set,
8894 (void *)&cmd_mirror_mask_port,
8895 (void *)&cmd_mirror_mask_portid,
8896 (void *)&cmd_mirror_mask_mirror,
8897 (void *)&cmd_mirror_mask_ruleid,
8898 (void *)&cmd_mirror_mask_what,
8899 (void *)&cmd_mirror_mask_value,
8900 (void *)&cmd_mirror_mask_dstpool,
8901 (void *)&cmd_mirror_mask_poolid,
8902 (void *)&cmd_mirror_mask_on,
8907 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8908 struct cmd_set_mirror_link_result {
8909 cmdline_fixed_string_t set;
8910 cmdline_fixed_string_t port;
8912 cmdline_fixed_string_t mirror;
8914 cmdline_fixed_string_t what;
8915 cmdline_fixed_string_t dstpool;
8917 cmdline_fixed_string_t on;
8920 cmdline_parse_token_string_t cmd_mirror_link_set =
8921 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8923 cmdline_parse_token_string_t cmd_mirror_link_port =
8924 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8926 cmdline_parse_token_num_t cmd_mirror_link_portid =
8927 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8929 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8930 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8931 mirror, "mirror-rule");
8932 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8933 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8935 cmdline_parse_token_string_t cmd_mirror_link_what =
8936 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8937 what, "uplink-mirror#downlink-mirror");
8938 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8939 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8940 dstpool, "dst-pool");
8941 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8942 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8944 cmdline_parse_token_string_t cmd_mirror_link_on =
8945 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8949 cmd_set_mirror_link_parsed(void *parsed_result,
8950 __attribute__((unused)) struct cmdline *cl,
8951 __attribute__((unused)) void *data)
8954 struct cmd_set_mirror_link_result *res = parsed_result;
8955 struct rte_eth_mirror_conf mr_conf;
8957 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8958 if (!strcmp(res->what, "uplink-mirror"))
8959 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8961 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8963 mr_conf.dst_pool = res->dstpool_id;
8965 if (!strcmp(res->on, "on"))
8966 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8969 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8972 /* check the return value and print it if is < 0 */
8974 printf("mirror rule add error: (%s)\n", strerror(-ret));
8978 cmdline_parse_inst_t cmd_set_mirror_link = {
8979 .f = cmd_set_mirror_link_parsed,
8981 .help_str = "set port <port_id> mirror-rule <rule_id> "
8982 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8984 (void *)&cmd_mirror_link_set,
8985 (void *)&cmd_mirror_link_port,
8986 (void *)&cmd_mirror_link_portid,
8987 (void *)&cmd_mirror_link_mirror,
8988 (void *)&cmd_mirror_link_ruleid,
8989 (void *)&cmd_mirror_link_what,
8990 (void *)&cmd_mirror_link_dstpool,
8991 (void *)&cmd_mirror_link_poolid,
8992 (void *)&cmd_mirror_link_on,
8997 /* *** RESET VM MIRROR RULE *** */
8998 struct cmd_rm_mirror_rule_result {
8999 cmdline_fixed_string_t reset;
9000 cmdline_fixed_string_t port;
9002 cmdline_fixed_string_t mirror;
9006 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9007 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9009 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9010 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9012 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9013 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9015 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9016 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9017 mirror, "mirror-rule");
9018 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9019 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9023 cmd_reset_mirror_rule_parsed(void *parsed_result,
9024 __attribute__((unused)) struct cmdline *cl,
9025 __attribute__((unused)) void *data)
9028 struct cmd_set_mirror_link_result *res = parsed_result;
9030 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9032 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9035 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9036 .f = cmd_reset_mirror_rule_parsed,
9038 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9040 (void *)&cmd_rm_mirror_rule_reset,
9041 (void *)&cmd_rm_mirror_rule_port,
9042 (void *)&cmd_rm_mirror_rule_portid,
9043 (void *)&cmd_rm_mirror_rule_mirror,
9044 (void *)&cmd_rm_mirror_rule_ruleid,
9049 /* ******************************************************************************** */
9051 struct cmd_dump_result {
9052 cmdline_fixed_string_t dump;
9056 dump_struct_sizes(void)
9058 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9059 DUMP_SIZE(struct rte_mbuf);
9060 DUMP_SIZE(struct rte_mempool);
9061 DUMP_SIZE(struct rte_ring);
9065 static void cmd_dump_parsed(void *parsed_result,
9066 __attribute__((unused)) struct cmdline *cl,
9067 __attribute__((unused)) void *data)
9069 struct cmd_dump_result *res = parsed_result;
9071 if (!strcmp(res->dump, "dump_physmem"))
9072 rte_dump_physmem_layout(stdout);
9073 else if (!strcmp(res->dump, "dump_memzone"))
9074 rte_memzone_dump(stdout);
9075 else if (!strcmp(res->dump, "dump_struct_sizes"))
9076 dump_struct_sizes();
9077 else if (!strcmp(res->dump, "dump_ring"))
9078 rte_ring_list_dump(stdout);
9079 else if (!strcmp(res->dump, "dump_mempool"))
9080 rte_mempool_list_dump(stdout);
9081 else if (!strcmp(res->dump, "dump_devargs"))
9082 rte_devargs_dump(stdout);
9083 else if (!strcmp(res->dump, "dump_log_types"))
9084 rte_log_dump(stdout);
9087 cmdline_parse_token_string_t cmd_dump_dump =
9088 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9091 "dump_struct_sizes#"
9097 cmdline_parse_inst_t cmd_dump = {
9098 .f = cmd_dump_parsed, /* function to call */
9099 .data = NULL, /* 2nd arg of func */
9100 .help_str = "Dump status",
9101 .tokens = { /* token list, NULL terminated */
9102 (void *)&cmd_dump_dump,
9107 /* ******************************************************************************** */
9109 struct cmd_dump_one_result {
9110 cmdline_fixed_string_t dump;
9111 cmdline_fixed_string_t name;
9114 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9115 __attribute__((unused)) void *data)
9117 struct cmd_dump_one_result *res = parsed_result;
9119 if (!strcmp(res->dump, "dump_ring")) {
9121 r = rte_ring_lookup(res->name);
9123 cmdline_printf(cl, "Cannot find ring\n");
9126 rte_ring_dump(stdout, r);
9127 } else if (!strcmp(res->dump, "dump_mempool")) {
9128 struct rte_mempool *mp;
9129 mp = rte_mempool_lookup(res->name);
9131 cmdline_printf(cl, "Cannot find mempool\n");
9134 rte_mempool_dump(stdout, mp);
9138 cmdline_parse_token_string_t cmd_dump_one_dump =
9139 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9140 "dump_ring#dump_mempool");
9142 cmdline_parse_token_string_t cmd_dump_one_name =
9143 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9145 cmdline_parse_inst_t cmd_dump_one = {
9146 .f = cmd_dump_one_parsed, /* function to call */
9147 .data = NULL, /* 2nd arg of func */
9148 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9149 .tokens = { /* token list, NULL terminated */
9150 (void *)&cmd_dump_one_dump,
9151 (void *)&cmd_dump_one_name,
9156 /* *** Add/Del syn filter *** */
9157 struct cmd_syn_filter_result {
9158 cmdline_fixed_string_t filter;
9160 cmdline_fixed_string_t ops;
9161 cmdline_fixed_string_t priority;
9162 cmdline_fixed_string_t high;
9163 cmdline_fixed_string_t queue;
9168 cmd_syn_filter_parsed(void *parsed_result,
9169 __attribute__((unused)) struct cmdline *cl,
9170 __attribute__((unused)) void *data)
9172 struct cmd_syn_filter_result *res = parsed_result;
9173 struct rte_eth_syn_filter syn_filter;
9176 ret = rte_eth_dev_filter_supported(res->port_id,
9177 RTE_ETH_FILTER_SYN);
9179 printf("syn filter is not supported on port %u.\n",
9184 memset(&syn_filter, 0, sizeof(syn_filter));
9186 if (!strcmp(res->ops, "add")) {
9187 if (!strcmp(res->high, "high"))
9188 syn_filter.hig_pri = 1;
9190 syn_filter.hig_pri = 0;
9192 syn_filter.queue = res->queue_id;
9193 ret = rte_eth_dev_filter_ctrl(res->port_id,
9198 ret = rte_eth_dev_filter_ctrl(res->port_id,
9200 RTE_ETH_FILTER_DELETE,
9204 printf("syn filter programming error: (%s)\n",
9208 cmdline_parse_token_string_t cmd_syn_filter_filter =
9209 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9210 filter, "syn_filter");
9211 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9212 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9214 cmdline_parse_token_string_t cmd_syn_filter_ops =
9215 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9217 cmdline_parse_token_string_t cmd_syn_filter_priority =
9218 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9219 priority, "priority");
9220 cmdline_parse_token_string_t cmd_syn_filter_high =
9221 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9223 cmdline_parse_token_string_t cmd_syn_filter_queue =
9224 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9226 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9227 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9230 cmdline_parse_inst_t cmd_syn_filter = {
9231 .f = cmd_syn_filter_parsed,
9233 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9234 "<queue_id>: Add/Delete syn filter",
9236 (void *)&cmd_syn_filter_filter,
9237 (void *)&cmd_syn_filter_port_id,
9238 (void *)&cmd_syn_filter_ops,
9239 (void *)&cmd_syn_filter_priority,
9240 (void *)&cmd_syn_filter_high,
9241 (void *)&cmd_syn_filter_queue,
9242 (void *)&cmd_syn_filter_queue_id,
9247 /* *** queue region set *** */
9248 struct cmd_queue_region_result {
9249 cmdline_fixed_string_t set;
9250 cmdline_fixed_string_t port;
9252 cmdline_fixed_string_t cmd;
9253 cmdline_fixed_string_t region;
9255 cmdline_fixed_string_t queue_start_index;
9257 cmdline_fixed_string_t queue_num;
9258 uint8_t queue_num_value;
9262 cmd_queue_region_parsed(void *parsed_result,
9263 __attribute__((unused)) struct cmdline *cl,
9264 __attribute__((unused)) void *data)
9266 struct cmd_queue_region_result *res = parsed_result;
9268 #ifdef RTE_LIBRTE_I40E_PMD
9269 struct rte_pmd_i40e_queue_region_conf region_conf;
9270 enum rte_pmd_i40e_queue_region_op op_type;
9273 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9276 #ifdef RTE_LIBRTE_I40E_PMD
9277 memset(®ion_conf, 0, sizeof(region_conf));
9278 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9279 region_conf.region_id = res->region_id;
9280 region_conf.queue_num = res->queue_num_value;
9281 region_conf.queue_start_index = res->queue_id;
9283 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9284 op_type, ®ion_conf);
9291 printf("function not implemented or supported\n");
9294 printf("queue region config error: (%s)\n", strerror(-ret));
9298 cmdline_parse_token_string_t cmd_queue_region_set =
9299 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9301 cmdline_parse_token_string_t cmd_queue_region_port =
9302 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9303 cmdline_parse_token_num_t cmd_queue_region_port_id =
9304 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9306 cmdline_parse_token_string_t cmd_queue_region_cmd =
9307 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9308 cmd, "queue-region");
9309 cmdline_parse_token_string_t cmd_queue_region_id =
9310 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9311 region, "region_id");
9312 cmdline_parse_token_num_t cmd_queue_region_index =
9313 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9315 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9316 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9317 queue_start_index, "queue_start_index");
9318 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9319 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9321 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9322 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9323 queue_num, "queue_num");
9324 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9325 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9326 queue_num_value, UINT8);
9328 cmdline_parse_inst_t cmd_queue_region = {
9329 .f = cmd_queue_region_parsed,
9331 .help_str = "set port <port_id> queue-region region_id <value> "
9332 "queue_start_index <value> queue_num <value>: Set a queue region",
9334 (void *)&cmd_queue_region_set,
9335 (void *)&cmd_queue_region_port,
9336 (void *)&cmd_queue_region_port_id,
9337 (void *)&cmd_queue_region_cmd,
9338 (void *)&cmd_queue_region_id,
9339 (void *)&cmd_queue_region_index,
9340 (void *)&cmd_queue_region_queue_start_index,
9341 (void *)&cmd_queue_region_queue_id,
9342 (void *)&cmd_queue_region_queue_num,
9343 (void *)&cmd_queue_region_queue_num_value,
9348 /* *** queue region and flowtype set *** */
9349 struct cmd_region_flowtype_result {
9350 cmdline_fixed_string_t set;
9351 cmdline_fixed_string_t port;
9353 cmdline_fixed_string_t cmd;
9354 cmdline_fixed_string_t region;
9356 cmdline_fixed_string_t flowtype;
9357 uint8_t flowtype_id;
9361 cmd_region_flowtype_parsed(void *parsed_result,
9362 __attribute__((unused)) struct cmdline *cl,
9363 __attribute__((unused)) void *data)
9365 struct cmd_region_flowtype_result *res = parsed_result;
9367 #ifdef RTE_LIBRTE_I40E_PMD
9368 struct rte_pmd_i40e_queue_region_conf region_conf;
9369 enum rte_pmd_i40e_queue_region_op op_type;
9372 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9375 #ifdef RTE_LIBRTE_I40E_PMD
9376 memset(®ion_conf, 0, sizeof(region_conf));
9378 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9379 region_conf.region_id = res->region_id;
9380 region_conf.hw_flowtype = res->flowtype_id;
9382 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9383 op_type, ®ion_conf);
9390 printf("function not implemented or supported\n");
9393 printf("region flowtype config error: (%s)\n", strerror(-ret));
9397 cmdline_parse_token_string_t cmd_region_flowtype_set =
9398 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9400 cmdline_parse_token_string_t cmd_region_flowtype_port =
9401 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9403 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9404 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9406 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9407 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9408 cmd, "queue-region");
9409 cmdline_parse_token_string_t cmd_region_flowtype_index =
9410 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9411 region, "region_id");
9412 cmdline_parse_token_num_t cmd_region_flowtype_id =
9413 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9415 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9416 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9417 flowtype, "flowtype");
9418 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9419 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9420 flowtype_id, UINT8);
9421 cmdline_parse_inst_t cmd_region_flowtype = {
9422 .f = cmd_region_flowtype_parsed,
9424 .help_str = "set port <port_id> queue-region region_id <value> "
9425 "flowtype <value>: Set a flowtype region index",
9427 (void *)&cmd_region_flowtype_set,
9428 (void *)&cmd_region_flowtype_port,
9429 (void *)&cmd_region_flowtype_port_index,
9430 (void *)&cmd_region_flowtype_cmd,
9431 (void *)&cmd_region_flowtype_index,
9432 (void *)&cmd_region_flowtype_id,
9433 (void *)&cmd_region_flowtype_flow_index,
9434 (void *)&cmd_region_flowtype_flow_id,
9439 /* *** User Priority (UP) to queue region (region_id) set *** */
9440 struct cmd_user_priority_region_result {
9441 cmdline_fixed_string_t set;
9442 cmdline_fixed_string_t port;
9444 cmdline_fixed_string_t cmd;
9445 cmdline_fixed_string_t user_priority;
9446 uint8_t user_priority_id;
9447 cmdline_fixed_string_t region;
9452 cmd_user_priority_region_parsed(void *parsed_result,
9453 __attribute__((unused)) struct cmdline *cl,
9454 __attribute__((unused)) void *data)
9456 struct cmd_user_priority_region_result *res = parsed_result;
9458 #ifdef RTE_LIBRTE_I40E_PMD
9459 struct rte_pmd_i40e_queue_region_conf region_conf;
9460 enum rte_pmd_i40e_queue_region_op op_type;
9463 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9466 #ifdef RTE_LIBRTE_I40E_PMD
9467 memset(®ion_conf, 0, sizeof(region_conf));
9468 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9469 region_conf.user_priority = res->user_priority_id;
9470 region_conf.region_id = res->region_id;
9472 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9473 op_type, ®ion_conf);
9480 printf("function not implemented or supported\n");
9483 printf("user_priority region config error: (%s)\n",
9488 cmdline_parse_token_string_t cmd_user_priority_region_set =
9489 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9491 cmdline_parse_token_string_t cmd_user_priority_region_port =
9492 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9494 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9495 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9497 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9498 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9499 cmd, "queue-region");
9500 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9501 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9502 user_priority, "UP");
9503 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9504 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9505 user_priority_id, UINT8);
9506 cmdline_parse_token_string_t cmd_user_priority_region_region =
9507 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9508 region, "region_id");
9509 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9510 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9513 cmdline_parse_inst_t cmd_user_priority_region = {
9514 .f = cmd_user_priority_region_parsed,
9516 .help_str = "set port <port_id> queue-region UP <value> "
9517 "region_id <value>: Set the mapping of User Priority (UP) "
9518 "to queue region (region_id) ",
9520 (void *)&cmd_user_priority_region_set,
9521 (void *)&cmd_user_priority_region_port,
9522 (void *)&cmd_user_priority_region_port_index,
9523 (void *)&cmd_user_priority_region_cmd,
9524 (void *)&cmd_user_priority_region_UP,
9525 (void *)&cmd_user_priority_region_UP_id,
9526 (void *)&cmd_user_priority_region_region,
9527 (void *)&cmd_user_priority_region_region_id,
9532 /* *** flush all queue region related configuration *** */
9533 struct cmd_flush_queue_region_result {
9534 cmdline_fixed_string_t set;
9535 cmdline_fixed_string_t port;
9537 cmdline_fixed_string_t cmd;
9538 cmdline_fixed_string_t flush;
9539 cmdline_fixed_string_t what;
9543 cmd_flush_queue_region_parsed(void *parsed_result,
9544 __attribute__((unused)) struct cmdline *cl,
9545 __attribute__((unused)) void *data)
9547 struct cmd_flush_queue_region_result *res = parsed_result;
9549 #ifdef RTE_LIBRTE_I40E_PMD
9550 struct rte_pmd_i40e_queue_region_conf region_conf;
9551 enum rte_pmd_i40e_queue_region_op op_type;
9554 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9557 #ifdef RTE_LIBRTE_I40E_PMD
9558 memset(®ion_conf, 0, sizeof(region_conf));
9560 if (strcmp(res->what, "on") == 0)
9561 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9563 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9565 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9566 op_type, ®ion_conf);
9573 printf("function not implemented or supported\n");
9576 printf("queue region config flush error: (%s)\n",
9581 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9582 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9584 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9585 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9587 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9588 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9590 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9591 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9592 cmd, "queue-region");
9593 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9594 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9596 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9597 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9600 cmdline_parse_inst_t cmd_flush_queue_region = {
9601 .f = cmd_flush_queue_region_parsed,
9603 .help_str = "set port <port_id> queue-region flush on|off"
9604 ": flush all queue region related configuration",
9606 (void *)&cmd_flush_queue_region_set,
9607 (void *)&cmd_flush_queue_region_port,
9608 (void *)&cmd_flush_queue_region_port_index,
9609 (void *)&cmd_flush_queue_region_cmd,
9610 (void *)&cmd_flush_queue_region_flush,
9611 (void *)&cmd_flush_queue_region_what,
9616 /* *** get all queue region related configuration info *** */
9617 struct cmd_show_queue_region_info {
9618 cmdline_fixed_string_t show;
9619 cmdline_fixed_string_t port;
9621 cmdline_fixed_string_t cmd;
9625 cmd_show_queue_region_info_parsed(void *parsed_result,
9626 __attribute__((unused)) struct cmdline *cl,
9627 __attribute__((unused)) void *data)
9629 struct cmd_show_queue_region_info *res = parsed_result;
9631 #ifdef RTE_LIBRTE_I40E_PMD
9632 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9633 enum rte_pmd_i40e_queue_region_op op_type;
9636 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9639 #ifdef RTE_LIBRTE_I40E_PMD
9640 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9642 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9644 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9645 op_type, &rte_pmd_regions);
9647 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9654 printf("function not implemented or supported\n");
9657 printf("queue region config info show error: (%s)\n",
9662 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9663 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9665 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9666 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9668 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9669 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9671 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9672 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9673 cmd, "queue-region");
9675 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9676 .f = cmd_show_queue_region_info_parsed,
9678 .help_str = "show port <port_id> queue-region"
9679 ": show all queue region related configuration info",
9681 (void *)&cmd_show_queue_region_info_get,
9682 (void *)&cmd_show_queue_region_info_port,
9683 (void *)&cmd_show_queue_region_info_port_index,
9684 (void *)&cmd_show_queue_region_info_cmd,
9689 /* *** ADD/REMOVE A 2tuple FILTER *** */
9690 struct cmd_2tuple_filter_result {
9691 cmdline_fixed_string_t filter;
9693 cmdline_fixed_string_t ops;
9694 cmdline_fixed_string_t dst_port;
9695 uint16_t dst_port_value;
9696 cmdline_fixed_string_t protocol;
9697 uint8_t protocol_value;
9698 cmdline_fixed_string_t mask;
9700 cmdline_fixed_string_t tcp_flags;
9701 uint8_t tcp_flags_value;
9702 cmdline_fixed_string_t priority;
9703 uint8_t priority_value;
9704 cmdline_fixed_string_t queue;
9709 cmd_2tuple_filter_parsed(void *parsed_result,
9710 __attribute__((unused)) struct cmdline *cl,
9711 __attribute__((unused)) void *data)
9713 struct rte_eth_ntuple_filter filter;
9714 struct cmd_2tuple_filter_result *res = parsed_result;
9717 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9719 printf("ntuple filter is not supported on port %u.\n",
9724 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9726 filter.flags = RTE_2TUPLE_FLAGS;
9727 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9728 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9729 filter.proto = res->protocol_value;
9730 filter.priority = res->priority_value;
9731 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9732 printf("nonzero tcp_flags is only meaningful"
9733 " when protocol is TCP.\n");
9736 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9737 printf("invalid TCP flags.\n");
9741 if (res->tcp_flags_value != 0) {
9742 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9743 filter.tcp_flags = res->tcp_flags_value;
9746 /* need convert to big endian. */
9747 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9748 filter.queue = res->queue_id;
9750 if (!strcmp(res->ops, "add"))
9751 ret = rte_eth_dev_filter_ctrl(res->port_id,
9752 RTE_ETH_FILTER_NTUPLE,
9756 ret = rte_eth_dev_filter_ctrl(res->port_id,
9757 RTE_ETH_FILTER_NTUPLE,
9758 RTE_ETH_FILTER_DELETE,
9761 printf("2tuple filter programming error: (%s)\n",
9766 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9767 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9768 filter, "2tuple_filter");
9769 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9770 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9772 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9773 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9775 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9776 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9777 dst_port, "dst_port");
9778 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9779 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9780 dst_port_value, UINT16);
9781 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9782 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9783 protocol, "protocol");
9784 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9785 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9786 protocol_value, UINT8);
9787 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9788 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9790 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9791 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9793 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9794 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9795 tcp_flags, "tcp_flags");
9796 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9797 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9798 tcp_flags_value, UINT8);
9799 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9800 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9801 priority, "priority");
9802 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9803 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9804 priority_value, UINT8);
9805 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9806 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9808 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9809 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9812 cmdline_parse_inst_t cmd_2tuple_filter = {
9813 .f = cmd_2tuple_filter_parsed,
9815 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9816 "<value> mask <value> tcp_flags <value> priority <value> queue "
9817 "<queue_id>: Add a 2tuple filter",
9819 (void *)&cmd_2tuple_filter_filter,
9820 (void *)&cmd_2tuple_filter_port_id,
9821 (void *)&cmd_2tuple_filter_ops,
9822 (void *)&cmd_2tuple_filter_dst_port,
9823 (void *)&cmd_2tuple_filter_dst_port_value,
9824 (void *)&cmd_2tuple_filter_protocol,
9825 (void *)&cmd_2tuple_filter_protocol_value,
9826 (void *)&cmd_2tuple_filter_mask,
9827 (void *)&cmd_2tuple_filter_mask_value,
9828 (void *)&cmd_2tuple_filter_tcp_flags,
9829 (void *)&cmd_2tuple_filter_tcp_flags_value,
9830 (void *)&cmd_2tuple_filter_priority,
9831 (void *)&cmd_2tuple_filter_priority_value,
9832 (void *)&cmd_2tuple_filter_queue,
9833 (void *)&cmd_2tuple_filter_queue_id,
9838 /* *** ADD/REMOVE A 5tuple FILTER *** */
9839 struct cmd_5tuple_filter_result {
9840 cmdline_fixed_string_t filter;
9842 cmdline_fixed_string_t ops;
9843 cmdline_fixed_string_t dst_ip;
9844 cmdline_ipaddr_t dst_ip_value;
9845 cmdline_fixed_string_t src_ip;
9846 cmdline_ipaddr_t src_ip_value;
9847 cmdline_fixed_string_t dst_port;
9848 uint16_t dst_port_value;
9849 cmdline_fixed_string_t src_port;
9850 uint16_t src_port_value;
9851 cmdline_fixed_string_t protocol;
9852 uint8_t protocol_value;
9853 cmdline_fixed_string_t mask;
9855 cmdline_fixed_string_t tcp_flags;
9856 uint8_t tcp_flags_value;
9857 cmdline_fixed_string_t priority;
9858 uint8_t priority_value;
9859 cmdline_fixed_string_t queue;
9864 cmd_5tuple_filter_parsed(void *parsed_result,
9865 __attribute__((unused)) struct cmdline *cl,
9866 __attribute__((unused)) void *data)
9868 struct rte_eth_ntuple_filter filter;
9869 struct cmd_5tuple_filter_result *res = parsed_result;
9872 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9874 printf("ntuple filter is not supported on port %u.\n",
9879 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9881 filter.flags = RTE_5TUPLE_FLAGS;
9882 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9883 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9884 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9885 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9886 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9887 filter.proto = res->protocol_value;
9888 filter.priority = res->priority_value;
9889 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9890 printf("nonzero tcp_flags is only meaningful"
9891 " when protocol is TCP.\n");
9894 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9895 printf("invalid TCP flags.\n");
9899 if (res->tcp_flags_value != 0) {
9900 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9901 filter.tcp_flags = res->tcp_flags_value;
9904 if (res->dst_ip_value.family == AF_INET)
9905 /* no need to convert, already big endian. */
9906 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9908 if (filter.dst_ip_mask == 0) {
9909 printf("can not support ipv6 involved compare.\n");
9915 if (res->src_ip_value.family == AF_INET)
9916 /* no need to convert, already big endian. */
9917 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9919 if (filter.src_ip_mask == 0) {
9920 printf("can not support ipv6 involved compare.\n");
9925 /* need convert to big endian. */
9926 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9927 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9928 filter.queue = res->queue_id;
9930 if (!strcmp(res->ops, "add"))
9931 ret = rte_eth_dev_filter_ctrl(res->port_id,
9932 RTE_ETH_FILTER_NTUPLE,
9936 ret = rte_eth_dev_filter_ctrl(res->port_id,
9937 RTE_ETH_FILTER_NTUPLE,
9938 RTE_ETH_FILTER_DELETE,
9941 printf("5tuple filter programming error: (%s)\n",
9945 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9946 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9947 filter, "5tuple_filter");
9948 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9949 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9951 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9952 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9954 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9955 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9957 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9958 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9960 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9961 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9963 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9964 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9966 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9967 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9968 dst_port, "dst_port");
9969 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9970 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9971 dst_port_value, UINT16);
9972 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9973 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9974 src_port, "src_port");
9975 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9976 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9977 src_port_value, UINT16);
9978 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9979 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9980 protocol, "protocol");
9981 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9982 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9983 protocol_value, UINT8);
9984 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9985 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9987 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9988 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9990 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9991 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9992 tcp_flags, "tcp_flags");
9993 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9994 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9995 tcp_flags_value, UINT8);
9996 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9997 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9998 priority, "priority");
9999 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10000 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10001 priority_value, UINT8);
10002 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10003 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10005 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10006 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10009 cmdline_parse_inst_t cmd_5tuple_filter = {
10010 .f = cmd_5tuple_filter_parsed,
10012 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10013 "src_ip <value> dst_port <value> src_port <value> "
10014 "protocol <value> mask <value> tcp_flags <value> "
10015 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10017 (void *)&cmd_5tuple_filter_filter,
10018 (void *)&cmd_5tuple_filter_port_id,
10019 (void *)&cmd_5tuple_filter_ops,
10020 (void *)&cmd_5tuple_filter_dst_ip,
10021 (void *)&cmd_5tuple_filter_dst_ip_value,
10022 (void *)&cmd_5tuple_filter_src_ip,
10023 (void *)&cmd_5tuple_filter_src_ip_value,
10024 (void *)&cmd_5tuple_filter_dst_port,
10025 (void *)&cmd_5tuple_filter_dst_port_value,
10026 (void *)&cmd_5tuple_filter_src_port,
10027 (void *)&cmd_5tuple_filter_src_port_value,
10028 (void *)&cmd_5tuple_filter_protocol,
10029 (void *)&cmd_5tuple_filter_protocol_value,
10030 (void *)&cmd_5tuple_filter_mask,
10031 (void *)&cmd_5tuple_filter_mask_value,
10032 (void *)&cmd_5tuple_filter_tcp_flags,
10033 (void *)&cmd_5tuple_filter_tcp_flags_value,
10034 (void *)&cmd_5tuple_filter_priority,
10035 (void *)&cmd_5tuple_filter_priority_value,
10036 (void *)&cmd_5tuple_filter_queue,
10037 (void *)&cmd_5tuple_filter_queue_id,
10042 /* *** ADD/REMOVE A flex FILTER *** */
10043 struct cmd_flex_filter_result {
10044 cmdline_fixed_string_t filter;
10045 cmdline_fixed_string_t ops;
10047 cmdline_fixed_string_t len;
10049 cmdline_fixed_string_t bytes;
10050 cmdline_fixed_string_t bytes_value;
10051 cmdline_fixed_string_t mask;
10052 cmdline_fixed_string_t mask_value;
10053 cmdline_fixed_string_t priority;
10054 uint8_t priority_value;
10055 cmdline_fixed_string_t queue;
10059 static int xdigit2val(unsigned char c)
10064 else if (isupper(c))
10065 val = c - 'A' + 10;
10067 val = c - 'a' + 10;
10072 cmd_flex_filter_parsed(void *parsed_result,
10073 __attribute__((unused)) struct cmdline *cl,
10074 __attribute__((unused)) void *data)
10077 struct rte_eth_flex_filter filter;
10078 struct cmd_flex_filter_result *res = parsed_result;
10079 char *bytes_ptr, *mask_ptr;
10080 uint16_t len, i, j = 0;
10085 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10086 printf("the len exceed the max length 128\n");
10089 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10090 filter.len = res->len_value;
10091 filter.priority = res->priority_value;
10092 filter.queue = res->queue_id;
10093 bytes_ptr = res->bytes_value;
10094 mask_ptr = res->mask_value;
10096 /* translate bytes string to array. */
10097 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10098 (bytes_ptr[1] == 'X')))
10100 len = strnlen(bytes_ptr, res->len_value * 2);
10101 if (len == 0 || (len % 8 != 0)) {
10102 printf("please check len and bytes input\n");
10105 for (i = 0; i < len; i++) {
10107 if (isxdigit(c) == 0) {
10108 /* invalid characters. */
10109 printf("invalid input\n");
10112 val = xdigit2val(c);
10115 filter.bytes[j] = byte;
10116 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10123 /* translate mask string to uint8_t array. */
10124 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10125 (mask_ptr[1] == 'X')))
10127 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10129 printf("invalid input\n");
10134 for (i = 0; i < len; i++) {
10136 if (isxdigit(c) == 0) {
10137 /* invalid characters. */
10138 printf("invalid input\n");
10141 val = xdigit2val(c);
10144 filter.mask[j] = byte;
10145 printf("mask[%d]:%02x ", j, filter.mask[j]);
10153 if (!strcmp(res->ops, "add"))
10154 ret = rte_eth_dev_filter_ctrl(res->port_id,
10155 RTE_ETH_FILTER_FLEXIBLE,
10156 RTE_ETH_FILTER_ADD,
10159 ret = rte_eth_dev_filter_ctrl(res->port_id,
10160 RTE_ETH_FILTER_FLEXIBLE,
10161 RTE_ETH_FILTER_DELETE,
10165 printf("flex filter setting error: (%s)\n", strerror(-ret));
10168 cmdline_parse_token_string_t cmd_flex_filter_filter =
10169 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10170 filter, "flex_filter");
10171 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10172 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10174 cmdline_parse_token_string_t cmd_flex_filter_ops =
10175 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10177 cmdline_parse_token_string_t cmd_flex_filter_len =
10178 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10180 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10181 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10183 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10184 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10186 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10187 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10188 bytes_value, NULL);
10189 cmdline_parse_token_string_t cmd_flex_filter_mask =
10190 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10192 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10193 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10195 cmdline_parse_token_string_t cmd_flex_filter_priority =
10196 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10197 priority, "priority");
10198 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10199 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10200 priority_value, UINT8);
10201 cmdline_parse_token_string_t cmd_flex_filter_queue =
10202 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10204 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10205 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10207 cmdline_parse_inst_t cmd_flex_filter = {
10208 .f = cmd_flex_filter_parsed,
10210 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10211 "<value> mask <value> priority <value> queue <queue_id>: "
10212 "Add/Del a flex filter",
10214 (void *)&cmd_flex_filter_filter,
10215 (void *)&cmd_flex_filter_port_id,
10216 (void *)&cmd_flex_filter_ops,
10217 (void *)&cmd_flex_filter_len,
10218 (void *)&cmd_flex_filter_len_value,
10219 (void *)&cmd_flex_filter_bytes,
10220 (void *)&cmd_flex_filter_bytes_value,
10221 (void *)&cmd_flex_filter_mask,
10222 (void *)&cmd_flex_filter_mask_value,
10223 (void *)&cmd_flex_filter_priority,
10224 (void *)&cmd_flex_filter_priority_value,
10225 (void *)&cmd_flex_filter_queue,
10226 (void *)&cmd_flex_filter_queue_id,
10231 /* *** Filters Control *** */
10233 /* *** deal with ethertype filter *** */
10234 struct cmd_ethertype_filter_result {
10235 cmdline_fixed_string_t filter;
10237 cmdline_fixed_string_t ops;
10238 cmdline_fixed_string_t mac;
10239 struct ether_addr mac_addr;
10240 cmdline_fixed_string_t ethertype;
10241 uint16_t ethertype_value;
10242 cmdline_fixed_string_t drop;
10243 cmdline_fixed_string_t queue;
10247 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10248 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10249 filter, "ethertype_filter");
10250 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10251 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10253 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10254 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10256 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10257 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10258 mac, "mac_addr#mac_ignr");
10259 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10260 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10262 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10263 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10264 ethertype, "ethertype");
10265 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10266 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10267 ethertype_value, UINT16);
10268 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10269 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10271 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10272 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10274 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10275 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10279 cmd_ethertype_filter_parsed(void *parsed_result,
10280 __attribute__((unused)) struct cmdline *cl,
10281 __attribute__((unused)) void *data)
10283 struct cmd_ethertype_filter_result *res = parsed_result;
10284 struct rte_eth_ethertype_filter filter;
10287 ret = rte_eth_dev_filter_supported(res->port_id,
10288 RTE_ETH_FILTER_ETHERTYPE);
10290 printf("ethertype filter is not supported on port %u.\n",
10295 memset(&filter, 0, sizeof(filter));
10296 if (!strcmp(res->mac, "mac_addr")) {
10297 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10298 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10299 sizeof(struct ether_addr));
10301 if (!strcmp(res->drop, "drop"))
10302 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10303 filter.ether_type = res->ethertype_value;
10304 filter.queue = res->queue_id;
10306 if (!strcmp(res->ops, "add"))
10307 ret = rte_eth_dev_filter_ctrl(res->port_id,
10308 RTE_ETH_FILTER_ETHERTYPE,
10309 RTE_ETH_FILTER_ADD,
10312 ret = rte_eth_dev_filter_ctrl(res->port_id,
10313 RTE_ETH_FILTER_ETHERTYPE,
10314 RTE_ETH_FILTER_DELETE,
10317 printf("ethertype filter programming error: (%s)\n",
10321 cmdline_parse_inst_t cmd_ethertype_filter = {
10322 .f = cmd_ethertype_filter_parsed,
10324 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10325 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10326 "Add or delete an ethertype filter entry",
10328 (void *)&cmd_ethertype_filter_filter,
10329 (void *)&cmd_ethertype_filter_port_id,
10330 (void *)&cmd_ethertype_filter_ops,
10331 (void *)&cmd_ethertype_filter_mac,
10332 (void *)&cmd_ethertype_filter_mac_addr,
10333 (void *)&cmd_ethertype_filter_ethertype,
10334 (void *)&cmd_ethertype_filter_ethertype_value,
10335 (void *)&cmd_ethertype_filter_drop,
10336 (void *)&cmd_ethertype_filter_queue,
10337 (void *)&cmd_ethertype_filter_queue_id,
10342 /* *** deal with flow director filter *** */
10343 struct cmd_flow_director_result {
10344 cmdline_fixed_string_t flow_director_filter;
10346 cmdline_fixed_string_t mode;
10347 cmdline_fixed_string_t mode_value;
10348 cmdline_fixed_string_t ops;
10349 cmdline_fixed_string_t flow;
10350 cmdline_fixed_string_t flow_type;
10351 cmdline_fixed_string_t ether;
10352 uint16_t ether_type;
10353 cmdline_fixed_string_t src;
10354 cmdline_ipaddr_t ip_src;
10356 cmdline_fixed_string_t dst;
10357 cmdline_ipaddr_t ip_dst;
10359 cmdline_fixed_string_t verify_tag;
10360 uint32_t verify_tag_value;
10361 cmdline_fixed_string_t tos;
10363 cmdline_fixed_string_t proto;
10364 uint8_t proto_value;
10365 cmdline_fixed_string_t ttl;
10367 cmdline_fixed_string_t vlan;
10368 uint16_t vlan_value;
10369 cmdline_fixed_string_t flexbytes;
10370 cmdline_fixed_string_t flexbytes_value;
10371 cmdline_fixed_string_t pf_vf;
10372 cmdline_fixed_string_t drop;
10373 cmdline_fixed_string_t queue;
10375 cmdline_fixed_string_t fd_id;
10376 uint32_t fd_id_value;
10377 cmdline_fixed_string_t mac;
10378 struct ether_addr mac_addr;
10379 cmdline_fixed_string_t tunnel;
10380 cmdline_fixed_string_t tunnel_type;
10381 cmdline_fixed_string_t tunnel_id;
10382 uint32_t tunnel_id_value;
10383 cmdline_fixed_string_t packet;
10388 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10391 const char *p, *p0 = q_arg;
10393 unsigned long int_fld;
10394 char *str_fld[max_num];
10399 p = strchr(p0, '(');
10403 p0 = strchr(p, ')');
10408 if (size >= sizeof(s))
10411 snprintf(s, sizeof(s), "%.*s", size, p);
10412 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10413 if (ret < 0 || ret > max_num)
10415 for (i = 0; i < ret; i++) {
10417 int_fld = strtoul(str_fld[i], &end, 0);
10418 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10420 flexbytes[i] = (uint8_t)int_fld;
10426 str2flowtype(char *string)
10429 static const struct {
10432 } flowtype_str[] = {
10433 {"raw", RTE_ETH_FLOW_RAW},
10434 {"ipv4", RTE_ETH_FLOW_IPV4},
10435 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10436 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10437 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10438 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10439 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10440 {"ipv6", RTE_ETH_FLOW_IPV6},
10441 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10442 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10443 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10444 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10445 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10446 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10449 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10450 if (!strcmp(flowtype_str[i].str, string))
10451 return flowtype_str[i].type;
10454 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10455 return (uint16_t)atoi(string);
10457 return RTE_ETH_FLOW_UNKNOWN;
10460 static enum rte_eth_fdir_tunnel_type
10461 str2fdir_tunneltype(char *string)
10465 static const struct {
10467 enum rte_eth_fdir_tunnel_type type;
10468 } tunneltype_str[] = {
10469 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10470 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10473 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10474 if (!strcmp(tunneltype_str[i].str, string))
10475 return tunneltype_str[i].type;
10477 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10480 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10482 if ((ip_addr).family == AF_INET) \
10483 (ip) = (ip_addr).addr.ipv4.s_addr; \
10485 printf("invalid parameter.\n"); \
10490 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10492 if ((ip_addr).family == AF_INET6) \
10493 rte_memcpy(&(ip), \
10494 &((ip_addr).addr.ipv6), \
10495 sizeof(struct in6_addr)); \
10497 printf("invalid parameter.\n"); \
10503 cmd_flow_director_filter_parsed(void *parsed_result,
10504 __attribute__((unused)) struct cmdline *cl,
10505 __attribute__((unused)) void *data)
10507 struct cmd_flow_director_result *res = parsed_result;
10508 struct rte_eth_fdir_filter entry;
10509 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10511 unsigned long vf_id;
10514 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10516 printf("flow director is not supported on port %u.\n",
10520 memset(flexbytes, 0, sizeof(flexbytes));
10521 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10523 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10524 if (strcmp(res->mode_value, "MAC-VLAN")) {
10525 printf("Please set mode to MAC-VLAN.\n");
10528 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10529 if (strcmp(res->mode_value, "Tunnel")) {
10530 printf("Please set mode to Tunnel.\n");
10534 if (!strcmp(res->mode_value, "raw")) {
10535 #ifdef RTE_LIBRTE_I40E_PMD
10536 struct rte_pmd_i40e_flow_type_mapping
10537 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10538 struct rte_pmd_i40e_pkt_template_conf conf;
10539 uint16_t flow_type = str2flowtype(res->flow_type);
10540 uint16_t i, port = res->port_id;
10543 memset(&conf, 0, sizeof(conf));
10545 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10546 printf("Invalid flow type specified.\n");
10549 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10553 if (mapping[flow_type].pctype == 0ULL) {
10554 printf("Invalid flow type specified.\n");
10557 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10558 if (mapping[flow_type].pctype & (1ULL << i)) {
10559 conf.input.pctype = i;
10564 conf.input.packet = open_file(res->filepath,
10565 &conf.input.length);
10566 if (!conf.input.packet)
10568 if (!strcmp(res->drop, "drop"))
10569 conf.action.behavior =
10570 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10572 conf.action.behavior =
10573 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10574 conf.action.report_status =
10575 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10576 conf.action.rx_queue = res->queue_id;
10577 conf.soft_id = res->fd_id_value;
10578 add = strcmp(res->ops, "del") ? 1 : 0;
10579 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10583 printf("flow director config error: (%s)\n",
10585 close_file(conf.input.packet);
10588 } else if (strcmp(res->mode_value, "IP")) {
10589 printf("Please set mode to IP or raw.\n");
10592 entry.input.flow_type = str2flowtype(res->flow_type);
10595 ret = parse_flexbytes(res->flexbytes_value,
10597 RTE_ETH_FDIR_MAX_FLEXLEN);
10599 printf("error: Cannot parse flexbytes input.\n");
10603 switch (entry.input.flow_type) {
10604 case RTE_ETH_FLOW_FRAG_IPV4:
10605 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10606 entry.input.flow.ip4_flow.proto = res->proto_value;
10608 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10609 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10610 IPV4_ADDR_TO_UINT(res->ip_dst,
10611 entry.input.flow.ip4_flow.dst_ip);
10612 IPV4_ADDR_TO_UINT(res->ip_src,
10613 entry.input.flow.ip4_flow.src_ip);
10614 entry.input.flow.ip4_flow.tos = res->tos_value;
10615 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10616 /* need convert to big endian. */
10617 entry.input.flow.udp4_flow.dst_port =
10618 rte_cpu_to_be_16(res->port_dst);
10619 entry.input.flow.udp4_flow.src_port =
10620 rte_cpu_to_be_16(res->port_src);
10622 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10623 IPV4_ADDR_TO_UINT(res->ip_dst,
10624 entry.input.flow.sctp4_flow.ip.dst_ip);
10625 IPV4_ADDR_TO_UINT(res->ip_src,
10626 entry.input.flow.sctp4_flow.ip.src_ip);
10627 entry.input.flow.ip4_flow.tos = res->tos_value;
10628 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10629 /* need convert to big endian. */
10630 entry.input.flow.sctp4_flow.dst_port =
10631 rte_cpu_to_be_16(res->port_dst);
10632 entry.input.flow.sctp4_flow.src_port =
10633 rte_cpu_to_be_16(res->port_src);
10634 entry.input.flow.sctp4_flow.verify_tag =
10635 rte_cpu_to_be_32(res->verify_tag_value);
10637 case RTE_ETH_FLOW_FRAG_IPV6:
10638 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10639 entry.input.flow.ipv6_flow.proto = res->proto_value;
10641 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10642 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10643 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10644 entry.input.flow.ipv6_flow.dst_ip);
10645 IPV6_ADDR_TO_ARRAY(res->ip_src,
10646 entry.input.flow.ipv6_flow.src_ip);
10647 entry.input.flow.ipv6_flow.tc = res->tos_value;
10648 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10649 /* need convert to big endian. */
10650 entry.input.flow.udp6_flow.dst_port =
10651 rte_cpu_to_be_16(res->port_dst);
10652 entry.input.flow.udp6_flow.src_port =
10653 rte_cpu_to_be_16(res->port_src);
10655 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10656 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10657 entry.input.flow.sctp6_flow.ip.dst_ip);
10658 IPV6_ADDR_TO_ARRAY(res->ip_src,
10659 entry.input.flow.sctp6_flow.ip.src_ip);
10660 entry.input.flow.ipv6_flow.tc = res->tos_value;
10661 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10662 /* need convert to big endian. */
10663 entry.input.flow.sctp6_flow.dst_port =
10664 rte_cpu_to_be_16(res->port_dst);
10665 entry.input.flow.sctp6_flow.src_port =
10666 rte_cpu_to_be_16(res->port_src);
10667 entry.input.flow.sctp6_flow.verify_tag =
10668 rte_cpu_to_be_32(res->verify_tag_value);
10670 case RTE_ETH_FLOW_L2_PAYLOAD:
10671 entry.input.flow.l2_flow.ether_type =
10672 rte_cpu_to_be_16(res->ether_type);
10678 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10679 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10681 sizeof(struct ether_addr));
10683 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10684 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10686 sizeof(struct ether_addr));
10687 entry.input.flow.tunnel_flow.tunnel_type =
10688 str2fdir_tunneltype(res->tunnel_type);
10689 entry.input.flow.tunnel_flow.tunnel_id =
10690 rte_cpu_to_be_32(res->tunnel_id_value);
10693 rte_memcpy(entry.input.flow_ext.flexbytes,
10695 RTE_ETH_FDIR_MAX_FLEXLEN);
10697 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10699 entry.action.flex_off = 0; /*use 0 by default */
10700 if (!strcmp(res->drop, "drop"))
10701 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10703 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10705 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10706 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10707 if (!strcmp(res->pf_vf, "pf"))
10708 entry.input.flow_ext.is_vf = 0;
10709 else if (!strncmp(res->pf_vf, "vf", 2)) {
10710 struct rte_eth_dev_info dev_info;
10712 memset(&dev_info, 0, sizeof(dev_info));
10713 rte_eth_dev_info_get(res->port_id, &dev_info);
10715 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10716 if (errno != 0 || *end != '\0' ||
10717 vf_id >= dev_info.max_vfs) {
10718 printf("invalid parameter %s.\n", res->pf_vf);
10721 entry.input.flow_ext.is_vf = 1;
10722 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10724 printf("invalid parameter %s.\n", res->pf_vf);
10729 /* set to report FD ID by default */
10730 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10731 entry.action.rx_queue = res->queue_id;
10732 entry.soft_id = res->fd_id_value;
10733 if (!strcmp(res->ops, "add"))
10734 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10735 RTE_ETH_FILTER_ADD, &entry);
10736 else if (!strcmp(res->ops, "del"))
10737 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10738 RTE_ETH_FILTER_DELETE, &entry);
10740 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10741 RTE_ETH_FILTER_UPDATE, &entry);
10743 printf("flow director programming error: (%s)\n",
10747 cmdline_parse_token_string_t cmd_flow_director_filter =
10748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10749 flow_director_filter, "flow_director_filter");
10750 cmdline_parse_token_num_t cmd_flow_director_port_id =
10751 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10753 cmdline_parse_token_string_t cmd_flow_director_ops =
10754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10755 ops, "add#del#update");
10756 cmdline_parse_token_string_t cmd_flow_director_flow =
10757 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10759 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10762 cmdline_parse_token_string_t cmd_flow_director_ether =
10763 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10765 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10766 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10767 ether_type, UINT16);
10768 cmdline_parse_token_string_t cmd_flow_director_src =
10769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10771 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10772 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10774 cmdline_parse_token_num_t cmd_flow_director_port_src =
10775 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10777 cmdline_parse_token_string_t cmd_flow_director_dst =
10778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10780 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10781 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10783 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10784 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10786 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10787 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10788 verify_tag, "verify_tag");
10789 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10790 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10791 verify_tag_value, UINT32);
10792 cmdline_parse_token_string_t cmd_flow_director_tos =
10793 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10795 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10796 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10798 cmdline_parse_token_string_t cmd_flow_director_proto =
10799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10801 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10802 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10803 proto_value, UINT8);
10804 cmdline_parse_token_string_t cmd_flow_director_ttl =
10805 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10807 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10808 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10810 cmdline_parse_token_string_t cmd_flow_director_vlan =
10811 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10813 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10814 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10815 vlan_value, UINT16);
10816 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10817 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10818 flexbytes, "flexbytes");
10819 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10820 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10821 flexbytes_value, NULL);
10822 cmdline_parse_token_string_t cmd_flow_director_drop =
10823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10825 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10828 cmdline_parse_token_string_t cmd_flow_director_queue =
10829 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10831 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10832 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10834 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10835 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10837 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10838 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10839 fd_id_value, UINT32);
10841 cmdline_parse_token_string_t cmd_flow_director_mode =
10842 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10844 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10845 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10847 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10848 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10849 mode_value, "MAC-VLAN");
10850 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10851 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10852 mode_value, "Tunnel");
10853 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10854 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10855 mode_value, "raw");
10856 cmdline_parse_token_string_t cmd_flow_director_mac =
10857 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10859 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10860 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10862 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10865 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10866 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10867 tunnel_type, "NVGRE#VxLAN");
10868 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10870 tunnel_id, "tunnel-id");
10871 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10872 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10873 tunnel_id_value, UINT32);
10874 cmdline_parse_token_string_t cmd_flow_director_packet =
10875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10877 cmdline_parse_token_string_t cmd_flow_director_filepath =
10878 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10881 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10882 .f = cmd_flow_director_filter_parsed,
10884 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10885 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10886 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10887 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10888 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10889 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10890 "fd_id <fd_id_value>: "
10891 "Add or delete an ip flow director entry on NIC",
10893 (void *)&cmd_flow_director_filter,
10894 (void *)&cmd_flow_director_port_id,
10895 (void *)&cmd_flow_director_mode,
10896 (void *)&cmd_flow_director_mode_ip,
10897 (void *)&cmd_flow_director_ops,
10898 (void *)&cmd_flow_director_flow,
10899 (void *)&cmd_flow_director_flow_type,
10900 (void *)&cmd_flow_director_src,
10901 (void *)&cmd_flow_director_ip_src,
10902 (void *)&cmd_flow_director_dst,
10903 (void *)&cmd_flow_director_ip_dst,
10904 (void *)&cmd_flow_director_tos,
10905 (void *)&cmd_flow_director_tos_value,
10906 (void *)&cmd_flow_director_proto,
10907 (void *)&cmd_flow_director_proto_value,
10908 (void *)&cmd_flow_director_ttl,
10909 (void *)&cmd_flow_director_ttl_value,
10910 (void *)&cmd_flow_director_vlan,
10911 (void *)&cmd_flow_director_vlan_value,
10912 (void *)&cmd_flow_director_flexbytes,
10913 (void *)&cmd_flow_director_flexbytes_value,
10914 (void *)&cmd_flow_director_drop,
10915 (void *)&cmd_flow_director_pf_vf,
10916 (void *)&cmd_flow_director_queue,
10917 (void *)&cmd_flow_director_queue_id,
10918 (void *)&cmd_flow_director_fd_id,
10919 (void *)&cmd_flow_director_fd_id_value,
10924 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10925 .f = cmd_flow_director_filter_parsed,
10927 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10928 "director entry on NIC",
10930 (void *)&cmd_flow_director_filter,
10931 (void *)&cmd_flow_director_port_id,
10932 (void *)&cmd_flow_director_mode,
10933 (void *)&cmd_flow_director_mode_ip,
10934 (void *)&cmd_flow_director_ops,
10935 (void *)&cmd_flow_director_flow,
10936 (void *)&cmd_flow_director_flow_type,
10937 (void *)&cmd_flow_director_src,
10938 (void *)&cmd_flow_director_ip_src,
10939 (void *)&cmd_flow_director_port_src,
10940 (void *)&cmd_flow_director_dst,
10941 (void *)&cmd_flow_director_ip_dst,
10942 (void *)&cmd_flow_director_port_dst,
10943 (void *)&cmd_flow_director_tos,
10944 (void *)&cmd_flow_director_tos_value,
10945 (void *)&cmd_flow_director_ttl,
10946 (void *)&cmd_flow_director_ttl_value,
10947 (void *)&cmd_flow_director_vlan,
10948 (void *)&cmd_flow_director_vlan_value,
10949 (void *)&cmd_flow_director_flexbytes,
10950 (void *)&cmd_flow_director_flexbytes_value,
10951 (void *)&cmd_flow_director_drop,
10952 (void *)&cmd_flow_director_pf_vf,
10953 (void *)&cmd_flow_director_queue,
10954 (void *)&cmd_flow_director_queue_id,
10955 (void *)&cmd_flow_director_fd_id,
10956 (void *)&cmd_flow_director_fd_id_value,
10961 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10962 .f = cmd_flow_director_filter_parsed,
10964 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10965 "director entry on NIC",
10967 (void *)&cmd_flow_director_filter,
10968 (void *)&cmd_flow_director_port_id,
10969 (void *)&cmd_flow_director_mode,
10970 (void *)&cmd_flow_director_mode_ip,
10971 (void *)&cmd_flow_director_ops,
10972 (void *)&cmd_flow_director_flow,
10973 (void *)&cmd_flow_director_flow_type,
10974 (void *)&cmd_flow_director_src,
10975 (void *)&cmd_flow_director_ip_src,
10976 (void *)&cmd_flow_director_port_src,
10977 (void *)&cmd_flow_director_dst,
10978 (void *)&cmd_flow_director_ip_dst,
10979 (void *)&cmd_flow_director_port_dst,
10980 (void *)&cmd_flow_director_verify_tag,
10981 (void *)&cmd_flow_director_verify_tag_value,
10982 (void *)&cmd_flow_director_tos,
10983 (void *)&cmd_flow_director_tos_value,
10984 (void *)&cmd_flow_director_ttl,
10985 (void *)&cmd_flow_director_ttl_value,
10986 (void *)&cmd_flow_director_vlan,
10987 (void *)&cmd_flow_director_vlan_value,
10988 (void *)&cmd_flow_director_flexbytes,
10989 (void *)&cmd_flow_director_flexbytes_value,
10990 (void *)&cmd_flow_director_drop,
10991 (void *)&cmd_flow_director_pf_vf,
10992 (void *)&cmd_flow_director_queue,
10993 (void *)&cmd_flow_director_queue_id,
10994 (void *)&cmd_flow_director_fd_id,
10995 (void *)&cmd_flow_director_fd_id_value,
11000 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11001 .f = cmd_flow_director_filter_parsed,
11003 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11004 "director entry on NIC",
11006 (void *)&cmd_flow_director_filter,
11007 (void *)&cmd_flow_director_port_id,
11008 (void *)&cmd_flow_director_mode,
11009 (void *)&cmd_flow_director_mode_ip,
11010 (void *)&cmd_flow_director_ops,
11011 (void *)&cmd_flow_director_flow,
11012 (void *)&cmd_flow_director_flow_type,
11013 (void *)&cmd_flow_director_ether,
11014 (void *)&cmd_flow_director_ether_type,
11015 (void *)&cmd_flow_director_flexbytes,
11016 (void *)&cmd_flow_director_flexbytes_value,
11017 (void *)&cmd_flow_director_drop,
11018 (void *)&cmd_flow_director_pf_vf,
11019 (void *)&cmd_flow_director_queue,
11020 (void *)&cmd_flow_director_queue_id,
11021 (void *)&cmd_flow_director_fd_id,
11022 (void *)&cmd_flow_director_fd_id_value,
11027 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11028 .f = cmd_flow_director_filter_parsed,
11030 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11031 "director entry on NIC",
11033 (void *)&cmd_flow_director_filter,
11034 (void *)&cmd_flow_director_port_id,
11035 (void *)&cmd_flow_director_mode,
11036 (void *)&cmd_flow_director_mode_mac_vlan,
11037 (void *)&cmd_flow_director_ops,
11038 (void *)&cmd_flow_director_mac,
11039 (void *)&cmd_flow_director_mac_addr,
11040 (void *)&cmd_flow_director_vlan,
11041 (void *)&cmd_flow_director_vlan_value,
11042 (void *)&cmd_flow_director_flexbytes,
11043 (void *)&cmd_flow_director_flexbytes_value,
11044 (void *)&cmd_flow_director_drop,
11045 (void *)&cmd_flow_director_queue,
11046 (void *)&cmd_flow_director_queue_id,
11047 (void *)&cmd_flow_director_fd_id,
11048 (void *)&cmd_flow_director_fd_id_value,
11053 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11054 .f = cmd_flow_director_filter_parsed,
11056 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11057 "director entry on NIC",
11059 (void *)&cmd_flow_director_filter,
11060 (void *)&cmd_flow_director_port_id,
11061 (void *)&cmd_flow_director_mode,
11062 (void *)&cmd_flow_director_mode_tunnel,
11063 (void *)&cmd_flow_director_ops,
11064 (void *)&cmd_flow_director_mac,
11065 (void *)&cmd_flow_director_mac_addr,
11066 (void *)&cmd_flow_director_vlan,
11067 (void *)&cmd_flow_director_vlan_value,
11068 (void *)&cmd_flow_director_tunnel,
11069 (void *)&cmd_flow_director_tunnel_type,
11070 (void *)&cmd_flow_director_tunnel_id,
11071 (void *)&cmd_flow_director_tunnel_id_value,
11072 (void *)&cmd_flow_director_flexbytes,
11073 (void *)&cmd_flow_director_flexbytes_value,
11074 (void *)&cmd_flow_director_drop,
11075 (void *)&cmd_flow_director_queue,
11076 (void *)&cmd_flow_director_queue_id,
11077 (void *)&cmd_flow_director_fd_id,
11078 (void *)&cmd_flow_director_fd_id_value,
11083 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11084 .f = cmd_flow_director_filter_parsed,
11086 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11087 "director entry on NIC",
11089 (void *)&cmd_flow_director_filter,
11090 (void *)&cmd_flow_director_port_id,
11091 (void *)&cmd_flow_director_mode,
11092 (void *)&cmd_flow_director_mode_raw,
11093 (void *)&cmd_flow_director_ops,
11094 (void *)&cmd_flow_director_flow,
11095 (void *)&cmd_flow_director_flow_type,
11096 (void *)&cmd_flow_director_drop,
11097 (void *)&cmd_flow_director_queue,
11098 (void *)&cmd_flow_director_queue_id,
11099 (void *)&cmd_flow_director_fd_id,
11100 (void *)&cmd_flow_director_fd_id_value,
11101 (void *)&cmd_flow_director_packet,
11102 (void *)&cmd_flow_director_filepath,
11107 struct cmd_flush_flow_director_result {
11108 cmdline_fixed_string_t flush_flow_director;
11112 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11113 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11114 flush_flow_director, "flush_flow_director");
11115 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11116 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11120 cmd_flush_flow_director_parsed(void *parsed_result,
11121 __attribute__((unused)) struct cmdline *cl,
11122 __attribute__((unused)) void *data)
11124 struct cmd_flow_director_result *res = parsed_result;
11127 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11129 printf("flow director is not supported on port %u.\n",
11134 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11135 RTE_ETH_FILTER_FLUSH, NULL);
11137 printf("flow director table flushing error: (%s)\n",
11141 cmdline_parse_inst_t cmd_flush_flow_director = {
11142 .f = cmd_flush_flow_director_parsed,
11144 .help_str = "flush_flow_director <port_id>: "
11145 "Flush all flow director entries of a device on NIC",
11147 (void *)&cmd_flush_flow_director_flush,
11148 (void *)&cmd_flush_flow_director_port_id,
11153 /* *** deal with flow director mask *** */
11154 struct cmd_flow_director_mask_result {
11155 cmdline_fixed_string_t flow_director_mask;
11157 cmdline_fixed_string_t mode;
11158 cmdline_fixed_string_t mode_value;
11159 cmdline_fixed_string_t vlan;
11160 uint16_t vlan_mask;
11161 cmdline_fixed_string_t src_mask;
11162 cmdline_ipaddr_t ipv4_src;
11163 cmdline_ipaddr_t ipv6_src;
11165 cmdline_fixed_string_t dst_mask;
11166 cmdline_ipaddr_t ipv4_dst;
11167 cmdline_ipaddr_t ipv6_dst;
11169 cmdline_fixed_string_t mac;
11170 uint8_t mac_addr_byte_mask;
11171 cmdline_fixed_string_t tunnel_id;
11172 uint32_t tunnel_id_mask;
11173 cmdline_fixed_string_t tunnel_type;
11174 uint8_t tunnel_type_mask;
11178 cmd_flow_director_mask_parsed(void *parsed_result,
11179 __attribute__((unused)) struct cmdline *cl,
11180 __attribute__((unused)) void *data)
11182 struct cmd_flow_director_mask_result *res = parsed_result;
11183 struct rte_eth_fdir_masks *mask;
11184 struct rte_port *port;
11186 port = &ports[res->port_id];
11187 /** Check if the port is not started **/
11188 if (port->port_status != RTE_PORT_STOPPED) {
11189 printf("Please stop port %d first\n", res->port_id);
11193 mask = &port->dev_conf.fdir_conf.mask;
11195 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11196 if (strcmp(res->mode_value, "MAC-VLAN")) {
11197 printf("Please set mode to MAC-VLAN.\n");
11201 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11202 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11203 if (strcmp(res->mode_value, "Tunnel")) {
11204 printf("Please set mode to Tunnel.\n");
11208 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11209 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11210 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11211 mask->tunnel_type_mask = res->tunnel_type_mask;
11213 if (strcmp(res->mode_value, "IP")) {
11214 printf("Please set mode to IP.\n");
11218 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11219 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11220 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11221 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11222 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11223 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11224 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11227 cmd_reconfig_device_queue(res->port_id, 1, 1);
11230 cmdline_parse_token_string_t cmd_flow_director_mask =
11231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11232 flow_director_mask, "flow_director_mask");
11233 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11234 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11236 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11239 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11240 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11241 vlan_mask, UINT16);
11242 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11244 src_mask, "src_mask");
11245 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11246 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11248 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11249 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11251 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11252 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11254 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11256 dst_mask, "dst_mask");
11257 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11258 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11260 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11261 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11263 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11264 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11267 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11270 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11273 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11275 mode_value, "MAC-VLAN");
11276 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11278 mode_value, "Tunnel");
11279 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11282 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11283 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11284 mac_addr_byte_mask, UINT8);
11285 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11287 tunnel_type, "tunnel-type");
11288 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11289 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11290 tunnel_type_mask, UINT8);
11291 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11293 tunnel_id, "tunnel-id");
11294 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11295 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11296 tunnel_id_mask, UINT32);
11298 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11299 .f = cmd_flow_director_mask_parsed,
11301 .help_str = "flow_director_mask ... : "
11302 "Set IP mode flow director's mask on NIC",
11304 (void *)&cmd_flow_director_mask,
11305 (void *)&cmd_flow_director_mask_port_id,
11306 (void *)&cmd_flow_director_mask_mode,
11307 (void *)&cmd_flow_director_mask_mode_ip,
11308 (void *)&cmd_flow_director_mask_vlan,
11309 (void *)&cmd_flow_director_mask_vlan_value,
11310 (void *)&cmd_flow_director_mask_src,
11311 (void *)&cmd_flow_director_mask_ipv4_src,
11312 (void *)&cmd_flow_director_mask_ipv6_src,
11313 (void *)&cmd_flow_director_mask_port_src,
11314 (void *)&cmd_flow_director_mask_dst,
11315 (void *)&cmd_flow_director_mask_ipv4_dst,
11316 (void *)&cmd_flow_director_mask_ipv6_dst,
11317 (void *)&cmd_flow_director_mask_port_dst,
11322 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11323 .f = cmd_flow_director_mask_parsed,
11325 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11326 "flow director's mask on NIC",
11328 (void *)&cmd_flow_director_mask,
11329 (void *)&cmd_flow_director_mask_port_id,
11330 (void *)&cmd_flow_director_mask_mode,
11331 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11332 (void *)&cmd_flow_director_mask_vlan,
11333 (void *)&cmd_flow_director_mask_vlan_value,
11338 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11339 .f = cmd_flow_director_mask_parsed,
11341 .help_str = "flow_director_mask ... : Set tunnel mode "
11342 "flow director's mask on NIC",
11344 (void *)&cmd_flow_director_mask,
11345 (void *)&cmd_flow_director_mask_port_id,
11346 (void *)&cmd_flow_director_mask_mode,
11347 (void *)&cmd_flow_director_mask_mode_tunnel,
11348 (void *)&cmd_flow_director_mask_vlan,
11349 (void *)&cmd_flow_director_mask_vlan_value,
11350 (void *)&cmd_flow_director_mask_mac,
11351 (void *)&cmd_flow_director_mask_mac_value,
11352 (void *)&cmd_flow_director_mask_tunnel_type,
11353 (void *)&cmd_flow_director_mask_tunnel_type_value,
11354 (void *)&cmd_flow_director_mask_tunnel_id,
11355 (void *)&cmd_flow_director_mask_tunnel_id_value,
11360 /* *** deal with flow director mask on flexible payload *** */
11361 struct cmd_flow_director_flex_mask_result {
11362 cmdline_fixed_string_t flow_director_flexmask;
11364 cmdline_fixed_string_t flow;
11365 cmdline_fixed_string_t flow_type;
11366 cmdline_fixed_string_t mask;
11370 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11371 __attribute__((unused)) struct cmdline *cl,
11372 __attribute__((unused)) void *data)
11374 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11375 struct rte_eth_fdir_info fdir_info;
11376 struct rte_eth_fdir_flex_mask flex_mask;
11377 struct rte_port *port;
11378 uint64_t flow_type_mask;
11382 port = &ports[res->port_id];
11383 /** Check if the port is not started **/
11384 if (port->port_status != RTE_PORT_STOPPED) {
11385 printf("Please stop port %d first\n", res->port_id);
11389 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11390 ret = parse_flexbytes(res->mask,
11392 RTE_ETH_FDIR_MAX_FLEXLEN);
11394 printf("error: Cannot parse mask input.\n");
11398 memset(&fdir_info, 0, sizeof(fdir_info));
11399 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11400 RTE_ETH_FILTER_INFO, &fdir_info);
11402 printf("Cannot get FDir filter info\n");
11406 if (!strcmp(res->flow_type, "none")) {
11407 /* means don't specify the flow type */
11408 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11409 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11410 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11411 0, sizeof(struct rte_eth_fdir_flex_mask));
11412 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11413 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11415 sizeof(struct rte_eth_fdir_flex_mask));
11416 cmd_reconfig_device_queue(res->port_id, 1, 1);
11419 flow_type_mask = fdir_info.flow_types_mask[0];
11420 if (!strcmp(res->flow_type, "all")) {
11421 if (!flow_type_mask) {
11422 printf("No flow type supported\n");
11425 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11426 if (flow_type_mask & (1ULL << i)) {
11427 flex_mask.flow_type = i;
11428 fdir_set_flex_mask(res->port_id, &flex_mask);
11431 cmd_reconfig_device_queue(res->port_id, 1, 1);
11434 flex_mask.flow_type = str2flowtype(res->flow_type);
11435 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11436 printf("Flow type %s not supported on port %d\n",
11437 res->flow_type, res->port_id);
11440 fdir_set_flex_mask(res->port_id, &flex_mask);
11441 cmd_reconfig_device_queue(res->port_id, 1, 1);
11444 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11445 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11446 flow_director_flexmask,
11447 "flow_director_flex_mask");
11448 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11449 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11451 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11452 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11454 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11455 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11456 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11457 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11458 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11459 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11462 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11463 .f = cmd_flow_director_flex_mask_parsed,
11465 .help_str = "flow_director_flex_mask ... : "
11466 "Set flow director's flex mask on NIC",
11468 (void *)&cmd_flow_director_flexmask,
11469 (void *)&cmd_flow_director_flexmask_port_id,
11470 (void *)&cmd_flow_director_flexmask_flow,
11471 (void *)&cmd_flow_director_flexmask_flow_type,
11472 (void *)&cmd_flow_director_flexmask_mask,
11477 /* *** deal with flow director flexible payload configuration *** */
11478 struct cmd_flow_director_flexpayload_result {
11479 cmdline_fixed_string_t flow_director_flexpayload;
11481 cmdline_fixed_string_t payload_layer;
11482 cmdline_fixed_string_t payload_cfg;
11486 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11489 const char *p, *p0 = q_arg;
11491 unsigned long int_fld;
11492 char *str_fld[max_num];
11497 p = strchr(p0, '(');
11501 p0 = strchr(p, ')');
11506 if (size >= sizeof(s))
11509 snprintf(s, sizeof(s), "%.*s", size, p);
11510 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11511 if (ret < 0 || ret > max_num)
11513 for (i = 0; i < ret; i++) {
11515 int_fld = strtoul(str_fld[i], &end, 0);
11516 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11518 offsets[i] = (uint16_t)int_fld;
11524 cmd_flow_director_flxpld_parsed(void *parsed_result,
11525 __attribute__((unused)) struct cmdline *cl,
11526 __attribute__((unused)) void *data)
11528 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11529 struct rte_eth_flex_payload_cfg flex_cfg;
11530 struct rte_port *port;
11533 port = &ports[res->port_id];
11534 /** Check if the port is not started **/
11535 if (port->port_status != RTE_PORT_STOPPED) {
11536 printf("Please stop port %d first\n", res->port_id);
11540 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11542 if (!strcmp(res->payload_layer, "raw"))
11543 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11544 else if (!strcmp(res->payload_layer, "l2"))
11545 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11546 else if (!strcmp(res->payload_layer, "l3"))
11547 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11548 else if (!strcmp(res->payload_layer, "l4"))
11549 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11551 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11552 RTE_ETH_FDIR_MAX_FLEXLEN);
11554 printf("error: Cannot parse flex payload input.\n");
11558 fdir_set_flex_payload(res->port_id, &flex_cfg);
11559 cmd_reconfig_device_queue(res->port_id, 1, 1);
11562 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11564 flow_director_flexpayload,
11565 "flow_director_flex_payload");
11566 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11567 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11569 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11571 payload_layer, "raw#l2#l3#l4");
11572 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11574 payload_cfg, NULL);
11576 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11577 .f = cmd_flow_director_flxpld_parsed,
11579 .help_str = "flow_director_flexpayload ... : "
11580 "Set flow director's flex payload on NIC",
11582 (void *)&cmd_flow_director_flexpayload,
11583 (void *)&cmd_flow_director_flexpayload_port_id,
11584 (void *)&cmd_flow_director_flexpayload_payload_layer,
11585 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11590 /* Generic flow interface command. */
11591 extern cmdline_parse_inst_t cmd_flow;
11593 /* *** Classification Filters Control *** */
11594 /* *** Get symmetric hash enable per port *** */
11595 struct cmd_get_sym_hash_ena_per_port_result {
11596 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11601 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11602 __rte_unused struct cmdline *cl,
11603 __rte_unused void *data)
11605 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11606 struct rte_eth_hash_filter_info info;
11609 if (rte_eth_dev_filter_supported(res->port_id,
11610 RTE_ETH_FILTER_HASH) < 0) {
11611 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11616 memset(&info, 0, sizeof(info));
11617 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11618 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11619 RTE_ETH_FILTER_GET, &info);
11622 printf("Cannot get symmetric hash enable per port "
11623 "on port %u\n", res->port_id);
11627 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11628 "enabled" : "disabled", res->port_id);
11631 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11632 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11633 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11634 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11635 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11638 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11639 .f = cmd_get_sym_hash_per_port_parsed,
11641 .help_str = "get_sym_hash_ena_per_port <port_id>",
11643 (void *)&cmd_get_sym_hash_ena_per_port_all,
11644 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11649 /* *** Set symmetric hash enable per port *** */
11650 struct cmd_set_sym_hash_ena_per_port_result {
11651 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11652 cmdline_fixed_string_t enable;
11657 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11658 __rte_unused struct cmdline *cl,
11659 __rte_unused void *data)
11661 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11662 struct rte_eth_hash_filter_info info;
11665 if (rte_eth_dev_filter_supported(res->port_id,
11666 RTE_ETH_FILTER_HASH) < 0) {
11667 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11672 memset(&info, 0, sizeof(info));
11673 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11674 if (!strcmp(res->enable, "enable"))
11675 info.info.enable = 1;
11676 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11677 RTE_ETH_FILTER_SET, &info);
11679 printf("Cannot set symmetric hash enable per port on "
11680 "port %u\n", res->port_id);
11683 printf("Symmetric hash has been set to %s on port %u\n",
11684 res->enable, res->port_id);
11687 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11688 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11689 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11690 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11691 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11693 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11694 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11695 enable, "enable#disable");
11697 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11698 .f = cmd_set_sym_hash_per_port_parsed,
11700 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11702 (void *)&cmd_set_sym_hash_ena_per_port_all,
11703 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11704 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11709 /* Get global config of hash function */
11710 struct cmd_get_hash_global_config_result {
11711 cmdline_fixed_string_t get_hash_global_config;
11716 flowtype_to_str(uint16_t ftype)
11722 } ftype_table[] = {
11723 {"ipv4", RTE_ETH_FLOW_IPV4},
11724 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11725 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11726 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11727 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11728 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11729 {"ipv6", RTE_ETH_FLOW_IPV6},
11730 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11731 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11732 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11733 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11734 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11735 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11736 {"port", RTE_ETH_FLOW_PORT},
11737 {"vxlan", RTE_ETH_FLOW_VXLAN},
11738 {"geneve", RTE_ETH_FLOW_GENEVE},
11739 {"nvgre", RTE_ETH_FLOW_NVGRE},
11742 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11743 if (ftype_table[i].ftype == ftype)
11744 return ftype_table[i].str;
11751 cmd_get_hash_global_config_parsed(void *parsed_result,
11752 __rte_unused struct cmdline *cl,
11753 __rte_unused void *data)
11755 struct cmd_get_hash_global_config_result *res = parsed_result;
11756 struct rte_eth_hash_filter_info info;
11757 uint32_t idx, offset;
11762 if (rte_eth_dev_filter_supported(res->port_id,
11763 RTE_ETH_FILTER_HASH) < 0) {
11764 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11769 memset(&info, 0, sizeof(info));
11770 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11771 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11772 RTE_ETH_FILTER_GET, &info);
11774 printf("Cannot get hash global configurations by port %d\n",
11779 switch (info.info.global_conf.hash_func) {
11780 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11781 printf("Hash function is Toeplitz\n");
11783 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11784 printf("Hash function is Simple XOR\n");
11787 printf("Unknown hash function\n");
11791 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11792 idx = i / UINT64_BIT;
11793 offset = i % UINT64_BIT;
11794 if (!(info.info.global_conf.valid_bit_mask[idx] &
11797 str = flowtype_to_str(i);
11800 printf("Symmetric hash is %s globally for flow type %s "
11802 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11803 (1ULL << offset)) ? "enabled" : "disabled"), str,
11808 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11809 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11810 get_hash_global_config, "get_hash_global_config");
11811 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11812 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11815 cmdline_parse_inst_t cmd_get_hash_global_config = {
11816 .f = cmd_get_hash_global_config_parsed,
11818 .help_str = "get_hash_global_config <port_id>",
11820 (void *)&cmd_get_hash_global_config_all,
11821 (void *)&cmd_get_hash_global_config_port_id,
11826 /* Set global config of hash function */
11827 struct cmd_set_hash_global_config_result {
11828 cmdline_fixed_string_t set_hash_global_config;
11830 cmdline_fixed_string_t hash_func;
11831 cmdline_fixed_string_t flow_type;
11832 cmdline_fixed_string_t enable;
11836 cmd_set_hash_global_config_parsed(void *parsed_result,
11837 __rte_unused struct cmdline *cl,
11838 __rte_unused void *data)
11840 struct cmd_set_hash_global_config_result *res = parsed_result;
11841 struct rte_eth_hash_filter_info info;
11842 uint32_t ftype, idx, offset;
11845 if (rte_eth_dev_filter_supported(res->port_id,
11846 RTE_ETH_FILTER_HASH) < 0) {
11847 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11851 memset(&info, 0, sizeof(info));
11852 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11853 if (!strcmp(res->hash_func, "toeplitz"))
11854 info.info.global_conf.hash_func =
11855 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11856 else if (!strcmp(res->hash_func, "simple_xor"))
11857 info.info.global_conf.hash_func =
11858 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11859 else if (!strcmp(res->hash_func, "default"))
11860 info.info.global_conf.hash_func =
11861 RTE_ETH_HASH_FUNCTION_DEFAULT;
11863 ftype = str2flowtype(res->flow_type);
11864 idx = ftype / UINT64_BIT;
11865 offset = ftype % UINT64_BIT;
11866 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11867 if (!strcmp(res->enable, "enable"))
11868 info.info.global_conf.sym_hash_enable_mask[idx] |=
11870 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11871 RTE_ETH_FILTER_SET, &info);
11873 printf("Cannot set global hash configurations by port %d\n",
11876 printf("Global hash configurations have been set "
11877 "succcessfully by port %d\n", res->port_id);
11880 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11881 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11882 set_hash_global_config, "set_hash_global_config");
11883 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11884 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11886 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11887 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11888 hash_func, "toeplitz#simple_xor#default");
11889 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11890 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11892 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11893 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11894 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11895 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11896 enable, "enable#disable");
11898 cmdline_parse_inst_t cmd_set_hash_global_config = {
11899 .f = cmd_set_hash_global_config_parsed,
11901 .help_str = "set_hash_global_config <port_id> "
11902 "toeplitz|simple_xor|default "
11903 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11904 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11905 "l2_payload enable|disable",
11907 (void *)&cmd_set_hash_global_config_all,
11908 (void *)&cmd_set_hash_global_config_port_id,
11909 (void *)&cmd_set_hash_global_config_hash_func,
11910 (void *)&cmd_set_hash_global_config_flow_type,
11911 (void *)&cmd_set_hash_global_config_enable,
11916 /* Set hash input set */
11917 struct cmd_set_hash_input_set_result {
11918 cmdline_fixed_string_t set_hash_input_set;
11920 cmdline_fixed_string_t flow_type;
11921 cmdline_fixed_string_t inset_field;
11922 cmdline_fixed_string_t select;
11925 static enum rte_eth_input_set_field
11926 str2inset(char *string)
11930 static const struct {
11932 enum rte_eth_input_set_field inset;
11933 } inset_table[] = {
11934 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11935 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11936 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11937 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11938 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11939 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11940 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11941 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11942 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11943 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11944 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11945 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11946 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11947 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11948 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11949 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11950 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11951 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11952 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11953 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11954 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11955 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11956 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11957 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11958 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11959 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11960 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11961 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11962 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11963 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11964 {"none", RTE_ETH_INPUT_SET_NONE},
11967 for (i = 0; i < RTE_DIM(inset_table); i++) {
11968 if (!strcmp(string, inset_table[i].str))
11969 return inset_table[i].inset;
11972 return RTE_ETH_INPUT_SET_UNKNOWN;
11976 cmd_set_hash_input_set_parsed(void *parsed_result,
11977 __rte_unused struct cmdline *cl,
11978 __rte_unused void *data)
11980 struct cmd_set_hash_input_set_result *res = parsed_result;
11981 struct rte_eth_hash_filter_info info;
11983 memset(&info, 0, sizeof(info));
11984 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11985 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11986 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11987 info.info.input_set_conf.inset_size = 1;
11988 if (!strcmp(res->select, "select"))
11989 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11990 else if (!strcmp(res->select, "add"))
11991 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11992 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11993 RTE_ETH_FILTER_SET, &info);
11996 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11997 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11998 set_hash_input_set, "set_hash_input_set");
11999 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12000 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12002 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12003 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12005 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12006 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12008 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12009 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12010 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12011 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12012 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12014 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12015 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12016 select, "select#add");
12018 cmdline_parse_inst_t cmd_set_hash_input_set = {
12019 .f = cmd_set_hash_input_set_parsed,
12021 .help_str = "set_hash_input_set <port_id> "
12022 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12023 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12024 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12025 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12026 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12027 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12028 "fld-7th|fld-8th|none select|add",
12030 (void *)&cmd_set_hash_input_set_cmd,
12031 (void *)&cmd_set_hash_input_set_port_id,
12032 (void *)&cmd_set_hash_input_set_flow_type,
12033 (void *)&cmd_set_hash_input_set_field,
12034 (void *)&cmd_set_hash_input_set_select,
12039 /* Set flow director input set */
12040 struct cmd_set_fdir_input_set_result {
12041 cmdline_fixed_string_t set_fdir_input_set;
12043 cmdline_fixed_string_t flow_type;
12044 cmdline_fixed_string_t inset_field;
12045 cmdline_fixed_string_t select;
12049 cmd_set_fdir_input_set_parsed(void *parsed_result,
12050 __rte_unused struct cmdline *cl,
12051 __rte_unused void *data)
12053 struct cmd_set_fdir_input_set_result *res = parsed_result;
12054 struct rte_eth_fdir_filter_info info;
12056 memset(&info, 0, sizeof(info));
12057 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12058 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12059 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12060 info.info.input_set_conf.inset_size = 1;
12061 if (!strcmp(res->select, "select"))
12062 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12063 else if (!strcmp(res->select, "add"))
12064 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12065 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12066 RTE_ETH_FILTER_SET, &info);
12069 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12070 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12071 set_fdir_input_set, "set_fdir_input_set");
12072 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12073 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12075 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12076 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12078 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12079 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12080 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12081 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12083 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12084 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12085 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12086 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12087 "sctp-veri-tag#none");
12088 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12089 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12090 select, "select#add");
12092 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12093 .f = cmd_set_fdir_input_set_parsed,
12095 .help_str = "set_fdir_input_set <port_id> "
12096 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12097 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12098 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12099 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12100 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12101 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12102 "sctp-veri-tag|none select|add",
12104 (void *)&cmd_set_fdir_input_set_cmd,
12105 (void *)&cmd_set_fdir_input_set_port_id,
12106 (void *)&cmd_set_fdir_input_set_flow_type,
12107 (void *)&cmd_set_fdir_input_set_field,
12108 (void *)&cmd_set_fdir_input_set_select,
12113 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12114 struct cmd_mcast_addr_result {
12115 cmdline_fixed_string_t mcast_addr_cmd;
12116 cmdline_fixed_string_t what;
12118 struct ether_addr mc_addr;
12121 static void cmd_mcast_addr_parsed(void *parsed_result,
12122 __attribute__((unused)) struct cmdline *cl,
12123 __attribute__((unused)) void *data)
12125 struct cmd_mcast_addr_result *res = parsed_result;
12127 if (!is_multicast_ether_addr(&res->mc_addr)) {
12128 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12129 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12130 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12131 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12134 if (strcmp(res->what, "add") == 0)
12135 mcast_addr_add(res->port_num, &res->mc_addr);
12137 mcast_addr_remove(res->port_num, &res->mc_addr);
12140 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12141 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12142 mcast_addr_cmd, "mcast_addr");
12143 cmdline_parse_token_string_t cmd_mcast_addr_what =
12144 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12146 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12147 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12148 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12149 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12151 cmdline_parse_inst_t cmd_mcast_addr = {
12152 .f = cmd_mcast_addr_parsed,
12154 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12155 "Add/Remove multicast MAC address on port_id",
12157 (void *)&cmd_mcast_addr_cmd,
12158 (void *)&cmd_mcast_addr_what,
12159 (void *)&cmd_mcast_addr_portnum,
12160 (void *)&cmd_mcast_addr_addr,
12165 /* l2 tunnel config
12166 * only support E-tag now.
12169 /* Ether type config */
12170 struct cmd_config_l2_tunnel_eth_type_result {
12171 cmdline_fixed_string_t port;
12172 cmdline_fixed_string_t config;
12173 cmdline_fixed_string_t all;
12175 cmdline_fixed_string_t l2_tunnel;
12176 cmdline_fixed_string_t l2_tunnel_type;
12177 cmdline_fixed_string_t eth_type;
12178 uint16_t eth_type_val;
12181 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12182 TOKEN_STRING_INITIALIZER
12183 (struct cmd_config_l2_tunnel_eth_type_result,
12185 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12186 TOKEN_STRING_INITIALIZER
12187 (struct cmd_config_l2_tunnel_eth_type_result,
12189 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12190 TOKEN_STRING_INITIALIZER
12191 (struct cmd_config_l2_tunnel_eth_type_result,
12193 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12194 TOKEN_NUM_INITIALIZER
12195 (struct cmd_config_l2_tunnel_eth_type_result,
12197 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12198 TOKEN_STRING_INITIALIZER
12199 (struct cmd_config_l2_tunnel_eth_type_result,
12200 l2_tunnel, "l2-tunnel");
12201 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12202 TOKEN_STRING_INITIALIZER
12203 (struct cmd_config_l2_tunnel_eth_type_result,
12204 l2_tunnel_type, "E-tag");
12205 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12206 TOKEN_STRING_INITIALIZER
12207 (struct cmd_config_l2_tunnel_eth_type_result,
12208 eth_type, "ether-type");
12209 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12210 TOKEN_NUM_INITIALIZER
12211 (struct cmd_config_l2_tunnel_eth_type_result,
12212 eth_type_val, UINT16);
12214 static enum rte_eth_tunnel_type
12215 str2fdir_l2_tunnel_type(char *string)
12219 static const struct {
12221 enum rte_eth_tunnel_type type;
12222 } l2_tunnel_type_str[] = {
12223 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12226 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12227 if (!strcmp(l2_tunnel_type_str[i].str, string))
12228 return l2_tunnel_type_str[i].type;
12230 return RTE_TUNNEL_TYPE_NONE;
12233 /* ether type config for all ports */
12235 cmd_config_l2_tunnel_eth_type_all_parsed
12236 (void *parsed_result,
12237 __attribute__((unused)) struct cmdline *cl,
12238 __attribute__((unused)) void *data)
12240 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12241 struct rte_eth_l2_tunnel_conf entry;
12244 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12245 entry.ether_type = res->eth_type_val;
12247 RTE_ETH_FOREACH_DEV(pid) {
12248 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12252 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12253 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12255 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12257 (void *)&cmd_config_l2_tunnel_eth_type_port,
12258 (void *)&cmd_config_l2_tunnel_eth_type_config,
12259 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12260 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12261 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12262 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12263 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12268 /* ether type config for a specific port */
12270 cmd_config_l2_tunnel_eth_type_specific_parsed(
12271 void *parsed_result,
12272 __attribute__((unused)) struct cmdline *cl,
12273 __attribute__((unused)) void *data)
12275 struct cmd_config_l2_tunnel_eth_type_result *res =
12277 struct rte_eth_l2_tunnel_conf entry;
12279 if (port_id_is_invalid(res->id, ENABLED_WARN))
12282 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12283 entry.ether_type = res->eth_type_val;
12285 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12288 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12289 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12291 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12293 (void *)&cmd_config_l2_tunnel_eth_type_port,
12294 (void *)&cmd_config_l2_tunnel_eth_type_config,
12295 (void *)&cmd_config_l2_tunnel_eth_type_id,
12296 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12297 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12298 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12299 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12304 /* Enable/disable l2 tunnel */
12305 struct cmd_config_l2_tunnel_en_dis_result {
12306 cmdline_fixed_string_t port;
12307 cmdline_fixed_string_t config;
12308 cmdline_fixed_string_t all;
12310 cmdline_fixed_string_t l2_tunnel;
12311 cmdline_fixed_string_t l2_tunnel_type;
12312 cmdline_fixed_string_t en_dis;
12315 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12316 TOKEN_STRING_INITIALIZER
12317 (struct cmd_config_l2_tunnel_en_dis_result,
12319 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12320 TOKEN_STRING_INITIALIZER
12321 (struct cmd_config_l2_tunnel_en_dis_result,
12323 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12324 TOKEN_STRING_INITIALIZER
12325 (struct cmd_config_l2_tunnel_en_dis_result,
12327 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12328 TOKEN_NUM_INITIALIZER
12329 (struct cmd_config_l2_tunnel_en_dis_result,
12331 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12332 TOKEN_STRING_INITIALIZER
12333 (struct cmd_config_l2_tunnel_en_dis_result,
12334 l2_tunnel, "l2-tunnel");
12335 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12336 TOKEN_STRING_INITIALIZER
12337 (struct cmd_config_l2_tunnel_en_dis_result,
12338 l2_tunnel_type, "E-tag");
12339 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12340 TOKEN_STRING_INITIALIZER
12341 (struct cmd_config_l2_tunnel_en_dis_result,
12342 en_dis, "enable#disable");
12344 /* enable/disable l2 tunnel for all ports */
12346 cmd_config_l2_tunnel_en_dis_all_parsed(
12347 void *parsed_result,
12348 __attribute__((unused)) struct cmdline *cl,
12349 __attribute__((unused)) void *data)
12351 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12352 struct rte_eth_l2_tunnel_conf entry;
12356 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12358 if (!strcmp("enable", res->en_dis))
12363 RTE_ETH_FOREACH_DEV(pid) {
12364 rte_eth_dev_l2_tunnel_offload_set(pid,
12366 ETH_L2_TUNNEL_ENABLE_MASK,
12371 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12372 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12374 .help_str = "port config all l2-tunnel E-tag enable|disable",
12376 (void *)&cmd_config_l2_tunnel_en_dis_port,
12377 (void *)&cmd_config_l2_tunnel_en_dis_config,
12378 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12379 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12380 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12381 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12386 /* enable/disable l2 tunnel for a port */
12388 cmd_config_l2_tunnel_en_dis_specific_parsed(
12389 void *parsed_result,
12390 __attribute__((unused)) struct cmdline *cl,
12391 __attribute__((unused)) void *data)
12393 struct cmd_config_l2_tunnel_en_dis_result *res =
12395 struct rte_eth_l2_tunnel_conf entry;
12397 if (port_id_is_invalid(res->id, ENABLED_WARN))
12400 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12402 if (!strcmp("enable", res->en_dis))
12403 rte_eth_dev_l2_tunnel_offload_set(res->id,
12405 ETH_L2_TUNNEL_ENABLE_MASK,
12408 rte_eth_dev_l2_tunnel_offload_set(res->id,
12410 ETH_L2_TUNNEL_ENABLE_MASK,
12414 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12415 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12417 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12419 (void *)&cmd_config_l2_tunnel_en_dis_port,
12420 (void *)&cmd_config_l2_tunnel_en_dis_config,
12421 (void *)&cmd_config_l2_tunnel_en_dis_id,
12422 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12423 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12424 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12429 /* E-tag configuration */
12431 /* Common result structure for all E-tag configuration */
12432 struct cmd_config_e_tag_result {
12433 cmdline_fixed_string_t e_tag;
12434 cmdline_fixed_string_t set;
12435 cmdline_fixed_string_t insertion;
12436 cmdline_fixed_string_t stripping;
12437 cmdline_fixed_string_t forwarding;
12438 cmdline_fixed_string_t filter;
12439 cmdline_fixed_string_t add;
12440 cmdline_fixed_string_t del;
12441 cmdline_fixed_string_t on;
12442 cmdline_fixed_string_t off;
12443 cmdline_fixed_string_t on_off;
12444 cmdline_fixed_string_t port_tag_id;
12445 uint32_t port_tag_id_val;
12446 cmdline_fixed_string_t e_tag_id;
12447 uint16_t e_tag_id_val;
12448 cmdline_fixed_string_t dst_pool;
12449 uint8_t dst_pool_val;
12450 cmdline_fixed_string_t port;
12452 cmdline_fixed_string_t vf;
12456 /* Common CLI fields for all E-tag configuration */
12457 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12458 TOKEN_STRING_INITIALIZER
12459 (struct cmd_config_e_tag_result,
12461 cmdline_parse_token_string_t cmd_config_e_tag_set =
12462 TOKEN_STRING_INITIALIZER
12463 (struct cmd_config_e_tag_result,
12465 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12466 TOKEN_STRING_INITIALIZER
12467 (struct cmd_config_e_tag_result,
12468 insertion, "insertion");
12469 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12470 TOKEN_STRING_INITIALIZER
12471 (struct cmd_config_e_tag_result,
12472 stripping, "stripping");
12473 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12474 TOKEN_STRING_INITIALIZER
12475 (struct cmd_config_e_tag_result,
12476 forwarding, "forwarding");
12477 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12478 TOKEN_STRING_INITIALIZER
12479 (struct cmd_config_e_tag_result,
12481 cmdline_parse_token_string_t cmd_config_e_tag_add =
12482 TOKEN_STRING_INITIALIZER
12483 (struct cmd_config_e_tag_result,
12485 cmdline_parse_token_string_t cmd_config_e_tag_del =
12486 TOKEN_STRING_INITIALIZER
12487 (struct cmd_config_e_tag_result,
12489 cmdline_parse_token_string_t cmd_config_e_tag_on =
12490 TOKEN_STRING_INITIALIZER
12491 (struct cmd_config_e_tag_result,
12493 cmdline_parse_token_string_t cmd_config_e_tag_off =
12494 TOKEN_STRING_INITIALIZER
12495 (struct cmd_config_e_tag_result,
12497 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12498 TOKEN_STRING_INITIALIZER
12499 (struct cmd_config_e_tag_result,
12501 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12502 TOKEN_STRING_INITIALIZER
12503 (struct cmd_config_e_tag_result,
12504 port_tag_id, "port-tag-id");
12505 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12506 TOKEN_NUM_INITIALIZER
12507 (struct cmd_config_e_tag_result,
12508 port_tag_id_val, UINT32);
12509 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12510 TOKEN_STRING_INITIALIZER
12511 (struct cmd_config_e_tag_result,
12512 e_tag_id, "e-tag-id");
12513 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12514 TOKEN_NUM_INITIALIZER
12515 (struct cmd_config_e_tag_result,
12516 e_tag_id_val, UINT16);
12517 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12518 TOKEN_STRING_INITIALIZER
12519 (struct cmd_config_e_tag_result,
12520 dst_pool, "dst-pool");
12521 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12522 TOKEN_NUM_INITIALIZER
12523 (struct cmd_config_e_tag_result,
12524 dst_pool_val, UINT8);
12525 cmdline_parse_token_string_t cmd_config_e_tag_port =
12526 TOKEN_STRING_INITIALIZER
12527 (struct cmd_config_e_tag_result,
12529 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12530 TOKEN_NUM_INITIALIZER
12531 (struct cmd_config_e_tag_result,
12533 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12534 TOKEN_STRING_INITIALIZER
12535 (struct cmd_config_e_tag_result,
12537 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12538 TOKEN_NUM_INITIALIZER
12539 (struct cmd_config_e_tag_result,
12542 /* E-tag insertion configuration */
12544 cmd_config_e_tag_insertion_en_parsed(
12545 void *parsed_result,
12546 __attribute__((unused)) struct cmdline *cl,
12547 __attribute__((unused)) void *data)
12549 struct cmd_config_e_tag_result *res =
12551 struct rte_eth_l2_tunnel_conf entry;
12553 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12556 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12557 entry.tunnel_id = res->port_tag_id_val;
12558 entry.vf_id = res->vf_id;
12559 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12561 ETH_L2_TUNNEL_INSERTION_MASK,
12566 cmd_config_e_tag_insertion_dis_parsed(
12567 void *parsed_result,
12568 __attribute__((unused)) struct cmdline *cl,
12569 __attribute__((unused)) void *data)
12571 struct cmd_config_e_tag_result *res =
12573 struct rte_eth_l2_tunnel_conf entry;
12575 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12578 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12579 entry.vf_id = res->vf_id;
12581 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12583 ETH_L2_TUNNEL_INSERTION_MASK,
12587 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12588 .f = cmd_config_e_tag_insertion_en_parsed,
12590 .help_str = "E-tag ... : E-tag insertion enable",
12592 (void *)&cmd_config_e_tag_e_tag,
12593 (void *)&cmd_config_e_tag_set,
12594 (void *)&cmd_config_e_tag_insertion,
12595 (void *)&cmd_config_e_tag_on,
12596 (void *)&cmd_config_e_tag_port_tag_id,
12597 (void *)&cmd_config_e_tag_port_tag_id_val,
12598 (void *)&cmd_config_e_tag_port,
12599 (void *)&cmd_config_e_tag_port_id,
12600 (void *)&cmd_config_e_tag_vf,
12601 (void *)&cmd_config_e_tag_vf_id,
12606 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12607 .f = cmd_config_e_tag_insertion_dis_parsed,
12609 .help_str = "E-tag ... : E-tag insertion disable",
12611 (void *)&cmd_config_e_tag_e_tag,
12612 (void *)&cmd_config_e_tag_set,
12613 (void *)&cmd_config_e_tag_insertion,
12614 (void *)&cmd_config_e_tag_off,
12615 (void *)&cmd_config_e_tag_port,
12616 (void *)&cmd_config_e_tag_port_id,
12617 (void *)&cmd_config_e_tag_vf,
12618 (void *)&cmd_config_e_tag_vf_id,
12623 /* E-tag stripping configuration */
12625 cmd_config_e_tag_stripping_parsed(
12626 void *parsed_result,
12627 __attribute__((unused)) struct cmdline *cl,
12628 __attribute__((unused)) void *data)
12630 struct cmd_config_e_tag_result *res =
12632 struct rte_eth_l2_tunnel_conf entry;
12634 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12637 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12639 if (!strcmp(res->on_off, "on"))
12640 rte_eth_dev_l2_tunnel_offload_set
12643 ETH_L2_TUNNEL_STRIPPING_MASK,
12646 rte_eth_dev_l2_tunnel_offload_set
12649 ETH_L2_TUNNEL_STRIPPING_MASK,
12653 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12654 .f = cmd_config_e_tag_stripping_parsed,
12656 .help_str = "E-tag ... : E-tag stripping enable/disable",
12658 (void *)&cmd_config_e_tag_e_tag,
12659 (void *)&cmd_config_e_tag_set,
12660 (void *)&cmd_config_e_tag_stripping,
12661 (void *)&cmd_config_e_tag_on_off,
12662 (void *)&cmd_config_e_tag_port,
12663 (void *)&cmd_config_e_tag_port_id,
12668 /* E-tag forwarding configuration */
12670 cmd_config_e_tag_forwarding_parsed(
12671 void *parsed_result,
12672 __attribute__((unused)) struct cmdline *cl,
12673 __attribute__((unused)) void *data)
12675 struct cmd_config_e_tag_result *res = parsed_result;
12676 struct rte_eth_l2_tunnel_conf entry;
12678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12681 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12683 if (!strcmp(res->on_off, "on"))
12684 rte_eth_dev_l2_tunnel_offload_set
12687 ETH_L2_TUNNEL_FORWARDING_MASK,
12690 rte_eth_dev_l2_tunnel_offload_set
12693 ETH_L2_TUNNEL_FORWARDING_MASK,
12697 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12698 .f = cmd_config_e_tag_forwarding_parsed,
12700 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12702 (void *)&cmd_config_e_tag_e_tag,
12703 (void *)&cmd_config_e_tag_set,
12704 (void *)&cmd_config_e_tag_forwarding,
12705 (void *)&cmd_config_e_tag_on_off,
12706 (void *)&cmd_config_e_tag_port,
12707 (void *)&cmd_config_e_tag_port_id,
12712 /* E-tag filter configuration */
12714 cmd_config_e_tag_filter_add_parsed(
12715 void *parsed_result,
12716 __attribute__((unused)) struct cmdline *cl,
12717 __attribute__((unused)) void *data)
12719 struct cmd_config_e_tag_result *res = parsed_result;
12720 struct rte_eth_l2_tunnel_conf entry;
12723 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12726 if (res->e_tag_id_val > 0x3fff) {
12727 printf("e-tag-id must be equal or less than 0x3fff.\n");
12731 ret = rte_eth_dev_filter_supported(res->port_id,
12732 RTE_ETH_FILTER_L2_TUNNEL);
12734 printf("E-tag filter is not supported on port %u.\n",
12739 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12740 entry.tunnel_id = res->e_tag_id_val;
12741 entry.pool = res->dst_pool_val;
12743 ret = rte_eth_dev_filter_ctrl(res->port_id,
12744 RTE_ETH_FILTER_L2_TUNNEL,
12745 RTE_ETH_FILTER_ADD,
12748 printf("E-tag filter programming error: (%s)\n",
12752 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12753 .f = cmd_config_e_tag_filter_add_parsed,
12755 .help_str = "E-tag ... : E-tag filter add",
12757 (void *)&cmd_config_e_tag_e_tag,
12758 (void *)&cmd_config_e_tag_set,
12759 (void *)&cmd_config_e_tag_filter,
12760 (void *)&cmd_config_e_tag_add,
12761 (void *)&cmd_config_e_tag_e_tag_id,
12762 (void *)&cmd_config_e_tag_e_tag_id_val,
12763 (void *)&cmd_config_e_tag_dst_pool,
12764 (void *)&cmd_config_e_tag_dst_pool_val,
12765 (void *)&cmd_config_e_tag_port,
12766 (void *)&cmd_config_e_tag_port_id,
12772 cmd_config_e_tag_filter_del_parsed(
12773 void *parsed_result,
12774 __attribute__((unused)) struct cmdline *cl,
12775 __attribute__((unused)) void *data)
12777 struct cmd_config_e_tag_result *res = parsed_result;
12778 struct rte_eth_l2_tunnel_conf entry;
12781 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12784 if (res->e_tag_id_val > 0x3fff) {
12785 printf("e-tag-id must be less than 0x3fff.\n");
12789 ret = rte_eth_dev_filter_supported(res->port_id,
12790 RTE_ETH_FILTER_L2_TUNNEL);
12792 printf("E-tag filter is not supported on port %u.\n",
12797 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12798 entry.tunnel_id = res->e_tag_id_val;
12800 ret = rte_eth_dev_filter_ctrl(res->port_id,
12801 RTE_ETH_FILTER_L2_TUNNEL,
12802 RTE_ETH_FILTER_DELETE,
12805 printf("E-tag filter programming error: (%s)\n",
12809 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12810 .f = cmd_config_e_tag_filter_del_parsed,
12812 .help_str = "E-tag ... : E-tag filter delete",
12814 (void *)&cmd_config_e_tag_e_tag,
12815 (void *)&cmd_config_e_tag_set,
12816 (void *)&cmd_config_e_tag_filter,
12817 (void *)&cmd_config_e_tag_del,
12818 (void *)&cmd_config_e_tag_e_tag_id,
12819 (void *)&cmd_config_e_tag_e_tag_id_val,
12820 (void *)&cmd_config_e_tag_port,
12821 (void *)&cmd_config_e_tag_port_id,
12826 /* vf vlan anti spoof configuration */
12828 /* Common result structure for vf vlan anti spoof */
12829 struct cmd_vf_vlan_anti_spoof_result {
12830 cmdline_fixed_string_t set;
12831 cmdline_fixed_string_t vf;
12832 cmdline_fixed_string_t vlan;
12833 cmdline_fixed_string_t antispoof;
12836 cmdline_fixed_string_t on_off;
12839 /* Common CLI fields for vf vlan anti spoof enable disable */
12840 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12841 TOKEN_STRING_INITIALIZER
12842 (struct cmd_vf_vlan_anti_spoof_result,
12844 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12845 TOKEN_STRING_INITIALIZER
12846 (struct cmd_vf_vlan_anti_spoof_result,
12848 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12849 TOKEN_STRING_INITIALIZER
12850 (struct cmd_vf_vlan_anti_spoof_result,
12852 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12853 TOKEN_STRING_INITIALIZER
12854 (struct cmd_vf_vlan_anti_spoof_result,
12855 antispoof, "antispoof");
12856 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12857 TOKEN_NUM_INITIALIZER
12858 (struct cmd_vf_vlan_anti_spoof_result,
12860 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12861 TOKEN_NUM_INITIALIZER
12862 (struct cmd_vf_vlan_anti_spoof_result,
12864 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12865 TOKEN_STRING_INITIALIZER
12866 (struct cmd_vf_vlan_anti_spoof_result,
12870 cmd_set_vf_vlan_anti_spoof_parsed(
12871 void *parsed_result,
12872 __attribute__((unused)) struct cmdline *cl,
12873 __attribute__((unused)) void *data)
12875 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12876 int ret = -ENOTSUP;
12878 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12880 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12883 #ifdef RTE_LIBRTE_IXGBE_PMD
12884 if (ret == -ENOTSUP)
12885 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12886 res->vf_id, is_on);
12888 #ifdef RTE_LIBRTE_I40E_PMD
12889 if (ret == -ENOTSUP)
12890 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12891 res->vf_id, is_on);
12893 #ifdef RTE_LIBRTE_BNXT_PMD
12894 if (ret == -ENOTSUP)
12895 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12896 res->vf_id, is_on);
12903 printf("invalid vf_id %d\n", res->vf_id);
12906 printf("invalid port_id %d\n", res->port_id);
12909 printf("function not implemented\n");
12912 printf("programming error: (%s)\n", strerror(-ret));
12916 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12917 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12919 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12921 (void *)&cmd_vf_vlan_anti_spoof_set,
12922 (void *)&cmd_vf_vlan_anti_spoof_vf,
12923 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12924 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12925 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12926 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12927 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12932 /* vf mac anti spoof configuration */
12934 /* Common result structure for vf mac anti spoof */
12935 struct cmd_vf_mac_anti_spoof_result {
12936 cmdline_fixed_string_t set;
12937 cmdline_fixed_string_t vf;
12938 cmdline_fixed_string_t mac;
12939 cmdline_fixed_string_t antispoof;
12942 cmdline_fixed_string_t on_off;
12945 /* Common CLI fields for vf mac anti spoof enable disable */
12946 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12947 TOKEN_STRING_INITIALIZER
12948 (struct cmd_vf_mac_anti_spoof_result,
12950 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12951 TOKEN_STRING_INITIALIZER
12952 (struct cmd_vf_mac_anti_spoof_result,
12954 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12955 TOKEN_STRING_INITIALIZER
12956 (struct cmd_vf_mac_anti_spoof_result,
12958 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12959 TOKEN_STRING_INITIALIZER
12960 (struct cmd_vf_mac_anti_spoof_result,
12961 antispoof, "antispoof");
12962 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12963 TOKEN_NUM_INITIALIZER
12964 (struct cmd_vf_mac_anti_spoof_result,
12966 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12967 TOKEN_NUM_INITIALIZER
12968 (struct cmd_vf_mac_anti_spoof_result,
12970 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12971 TOKEN_STRING_INITIALIZER
12972 (struct cmd_vf_mac_anti_spoof_result,
12976 cmd_set_vf_mac_anti_spoof_parsed(
12977 void *parsed_result,
12978 __attribute__((unused)) struct cmdline *cl,
12979 __attribute__((unused)) void *data)
12981 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12982 int ret = -ENOTSUP;
12984 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12986 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12989 #ifdef RTE_LIBRTE_IXGBE_PMD
12990 if (ret == -ENOTSUP)
12991 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12992 res->vf_id, is_on);
12994 #ifdef RTE_LIBRTE_I40E_PMD
12995 if (ret == -ENOTSUP)
12996 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12997 res->vf_id, is_on);
12999 #ifdef RTE_LIBRTE_BNXT_PMD
13000 if (ret == -ENOTSUP)
13001 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13002 res->vf_id, is_on);
13009 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13012 printf("invalid port_id %d\n", res->port_id);
13015 printf("function not implemented\n");
13018 printf("programming error: (%s)\n", strerror(-ret));
13022 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13023 .f = cmd_set_vf_mac_anti_spoof_parsed,
13025 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13027 (void *)&cmd_vf_mac_anti_spoof_set,
13028 (void *)&cmd_vf_mac_anti_spoof_vf,
13029 (void *)&cmd_vf_mac_anti_spoof_mac,
13030 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13031 (void *)&cmd_vf_mac_anti_spoof_port_id,
13032 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13033 (void *)&cmd_vf_mac_anti_spoof_on_off,
13038 /* vf vlan strip queue configuration */
13040 /* Common result structure for vf mac anti spoof */
13041 struct cmd_vf_vlan_stripq_result {
13042 cmdline_fixed_string_t set;
13043 cmdline_fixed_string_t vf;
13044 cmdline_fixed_string_t vlan;
13045 cmdline_fixed_string_t stripq;
13048 cmdline_fixed_string_t on_off;
13051 /* Common CLI fields for vf vlan strip enable disable */
13052 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13053 TOKEN_STRING_INITIALIZER
13054 (struct cmd_vf_vlan_stripq_result,
13056 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13057 TOKEN_STRING_INITIALIZER
13058 (struct cmd_vf_vlan_stripq_result,
13060 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13061 TOKEN_STRING_INITIALIZER
13062 (struct cmd_vf_vlan_stripq_result,
13064 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13065 TOKEN_STRING_INITIALIZER
13066 (struct cmd_vf_vlan_stripq_result,
13068 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13069 TOKEN_NUM_INITIALIZER
13070 (struct cmd_vf_vlan_stripq_result,
13072 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13073 TOKEN_NUM_INITIALIZER
13074 (struct cmd_vf_vlan_stripq_result,
13076 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13077 TOKEN_STRING_INITIALIZER
13078 (struct cmd_vf_vlan_stripq_result,
13082 cmd_set_vf_vlan_stripq_parsed(
13083 void *parsed_result,
13084 __attribute__((unused)) struct cmdline *cl,
13085 __attribute__((unused)) void *data)
13087 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13088 int ret = -ENOTSUP;
13090 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13095 #ifdef RTE_LIBRTE_IXGBE_PMD
13096 if (ret == -ENOTSUP)
13097 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13098 res->vf_id, is_on);
13100 #ifdef RTE_LIBRTE_I40E_PMD
13101 if (ret == -ENOTSUP)
13102 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13103 res->vf_id, is_on);
13105 #ifdef RTE_LIBRTE_BNXT_PMD
13106 if (ret == -ENOTSUP)
13107 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13108 res->vf_id, is_on);
13115 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13118 printf("invalid port_id %d\n", res->port_id);
13121 printf("function not implemented\n");
13124 printf("programming error: (%s)\n", strerror(-ret));
13128 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13129 .f = cmd_set_vf_vlan_stripq_parsed,
13131 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13133 (void *)&cmd_vf_vlan_stripq_set,
13134 (void *)&cmd_vf_vlan_stripq_vf,
13135 (void *)&cmd_vf_vlan_stripq_vlan,
13136 (void *)&cmd_vf_vlan_stripq_stripq,
13137 (void *)&cmd_vf_vlan_stripq_port_id,
13138 (void *)&cmd_vf_vlan_stripq_vf_id,
13139 (void *)&cmd_vf_vlan_stripq_on_off,
13144 /* vf vlan insert configuration */
13146 /* Common result structure for vf vlan insert */
13147 struct cmd_vf_vlan_insert_result {
13148 cmdline_fixed_string_t set;
13149 cmdline_fixed_string_t vf;
13150 cmdline_fixed_string_t vlan;
13151 cmdline_fixed_string_t insert;
13157 /* Common CLI fields for vf vlan insert enable disable */
13158 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13159 TOKEN_STRING_INITIALIZER
13160 (struct cmd_vf_vlan_insert_result,
13162 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13163 TOKEN_STRING_INITIALIZER
13164 (struct cmd_vf_vlan_insert_result,
13166 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13167 TOKEN_STRING_INITIALIZER
13168 (struct cmd_vf_vlan_insert_result,
13170 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13171 TOKEN_STRING_INITIALIZER
13172 (struct cmd_vf_vlan_insert_result,
13174 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13175 TOKEN_NUM_INITIALIZER
13176 (struct cmd_vf_vlan_insert_result,
13178 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13179 TOKEN_NUM_INITIALIZER
13180 (struct cmd_vf_vlan_insert_result,
13182 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13183 TOKEN_NUM_INITIALIZER
13184 (struct cmd_vf_vlan_insert_result,
13188 cmd_set_vf_vlan_insert_parsed(
13189 void *parsed_result,
13190 __attribute__((unused)) struct cmdline *cl,
13191 __attribute__((unused)) void *data)
13193 struct cmd_vf_vlan_insert_result *res = parsed_result;
13194 int ret = -ENOTSUP;
13196 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13199 #ifdef RTE_LIBRTE_IXGBE_PMD
13200 if (ret == -ENOTSUP)
13201 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13204 #ifdef RTE_LIBRTE_I40E_PMD
13205 if (ret == -ENOTSUP)
13206 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13209 #ifdef RTE_LIBRTE_BNXT_PMD
13210 if (ret == -ENOTSUP)
13211 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13219 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13222 printf("invalid port_id %d\n", res->port_id);
13225 printf("function not implemented\n");
13228 printf("programming error: (%s)\n", strerror(-ret));
13232 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13233 .f = cmd_set_vf_vlan_insert_parsed,
13235 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13237 (void *)&cmd_vf_vlan_insert_set,
13238 (void *)&cmd_vf_vlan_insert_vf,
13239 (void *)&cmd_vf_vlan_insert_vlan,
13240 (void *)&cmd_vf_vlan_insert_insert,
13241 (void *)&cmd_vf_vlan_insert_port_id,
13242 (void *)&cmd_vf_vlan_insert_vf_id,
13243 (void *)&cmd_vf_vlan_insert_vlan_id,
13248 /* tx loopback configuration */
13250 /* Common result structure for tx loopback */
13251 struct cmd_tx_loopback_result {
13252 cmdline_fixed_string_t set;
13253 cmdline_fixed_string_t tx;
13254 cmdline_fixed_string_t loopback;
13256 cmdline_fixed_string_t on_off;
13259 /* Common CLI fields for tx loopback enable disable */
13260 cmdline_parse_token_string_t cmd_tx_loopback_set =
13261 TOKEN_STRING_INITIALIZER
13262 (struct cmd_tx_loopback_result,
13264 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13265 TOKEN_STRING_INITIALIZER
13266 (struct cmd_tx_loopback_result,
13268 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13269 TOKEN_STRING_INITIALIZER
13270 (struct cmd_tx_loopback_result,
13271 loopback, "loopback");
13272 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13273 TOKEN_NUM_INITIALIZER
13274 (struct cmd_tx_loopback_result,
13276 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13277 TOKEN_STRING_INITIALIZER
13278 (struct cmd_tx_loopback_result,
13282 cmd_set_tx_loopback_parsed(
13283 void *parsed_result,
13284 __attribute__((unused)) struct cmdline *cl,
13285 __attribute__((unused)) void *data)
13287 struct cmd_tx_loopback_result *res = parsed_result;
13288 int ret = -ENOTSUP;
13290 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13292 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13295 #ifdef RTE_LIBRTE_IXGBE_PMD
13296 if (ret == -ENOTSUP)
13297 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13299 #ifdef RTE_LIBRTE_I40E_PMD
13300 if (ret == -ENOTSUP)
13301 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13303 #ifdef RTE_LIBRTE_BNXT_PMD
13304 if (ret == -ENOTSUP)
13305 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13307 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13308 if (ret == -ENOTSUP)
13309 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13316 printf("invalid is_on %d\n", is_on);
13319 printf("invalid port_id %d\n", res->port_id);
13322 printf("function not implemented\n");
13325 printf("programming error: (%s)\n", strerror(-ret));
13329 cmdline_parse_inst_t cmd_set_tx_loopback = {
13330 .f = cmd_set_tx_loopback_parsed,
13332 .help_str = "set tx loopback <port_id> on|off",
13334 (void *)&cmd_tx_loopback_set,
13335 (void *)&cmd_tx_loopback_tx,
13336 (void *)&cmd_tx_loopback_loopback,
13337 (void *)&cmd_tx_loopback_port_id,
13338 (void *)&cmd_tx_loopback_on_off,
13343 /* all queues drop enable configuration */
13345 /* Common result structure for all queues drop enable */
13346 struct cmd_all_queues_drop_en_result {
13347 cmdline_fixed_string_t set;
13348 cmdline_fixed_string_t all;
13349 cmdline_fixed_string_t queues;
13350 cmdline_fixed_string_t drop;
13352 cmdline_fixed_string_t on_off;
13355 /* Common CLI fields for tx loopback enable disable */
13356 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13357 TOKEN_STRING_INITIALIZER
13358 (struct cmd_all_queues_drop_en_result,
13360 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13361 TOKEN_STRING_INITIALIZER
13362 (struct cmd_all_queues_drop_en_result,
13364 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13365 TOKEN_STRING_INITIALIZER
13366 (struct cmd_all_queues_drop_en_result,
13368 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13369 TOKEN_STRING_INITIALIZER
13370 (struct cmd_all_queues_drop_en_result,
13372 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13373 TOKEN_NUM_INITIALIZER
13374 (struct cmd_all_queues_drop_en_result,
13376 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13377 TOKEN_STRING_INITIALIZER
13378 (struct cmd_all_queues_drop_en_result,
13382 cmd_set_all_queues_drop_en_parsed(
13383 void *parsed_result,
13384 __attribute__((unused)) struct cmdline *cl,
13385 __attribute__((unused)) void *data)
13387 struct cmd_all_queues_drop_en_result *res = parsed_result;
13388 int ret = -ENOTSUP;
13389 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13391 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13394 #ifdef RTE_LIBRTE_IXGBE_PMD
13395 if (ret == -ENOTSUP)
13396 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13398 #ifdef RTE_LIBRTE_BNXT_PMD
13399 if (ret == -ENOTSUP)
13400 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13406 printf("invalid is_on %d\n", is_on);
13409 printf("invalid port_id %d\n", res->port_id);
13412 printf("function not implemented\n");
13415 printf("programming error: (%s)\n", strerror(-ret));
13419 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13420 .f = cmd_set_all_queues_drop_en_parsed,
13422 .help_str = "set all queues drop <port_id> on|off",
13424 (void *)&cmd_all_queues_drop_en_set,
13425 (void *)&cmd_all_queues_drop_en_all,
13426 (void *)&cmd_all_queues_drop_en_queues,
13427 (void *)&cmd_all_queues_drop_en_drop,
13428 (void *)&cmd_all_queues_drop_en_port_id,
13429 (void *)&cmd_all_queues_drop_en_on_off,
13434 /* vf split drop enable configuration */
13436 /* Common result structure for vf split drop enable */
13437 struct cmd_vf_split_drop_en_result {
13438 cmdline_fixed_string_t set;
13439 cmdline_fixed_string_t vf;
13440 cmdline_fixed_string_t split;
13441 cmdline_fixed_string_t drop;
13444 cmdline_fixed_string_t on_off;
13447 /* Common CLI fields for vf split drop enable disable */
13448 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13449 TOKEN_STRING_INITIALIZER
13450 (struct cmd_vf_split_drop_en_result,
13452 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13453 TOKEN_STRING_INITIALIZER
13454 (struct cmd_vf_split_drop_en_result,
13456 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13457 TOKEN_STRING_INITIALIZER
13458 (struct cmd_vf_split_drop_en_result,
13460 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13461 TOKEN_STRING_INITIALIZER
13462 (struct cmd_vf_split_drop_en_result,
13464 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13465 TOKEN_NUM_INITIALIZER
13466 (struct cmd_vf_split_drop_en_result,
13468 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13469 TOKEN_NUM_INITIALIZER
13470 (struct cmd_vf_split_drop_en_result,
13472 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13473 TOKEN_STRING_INITIALIZER
13474 (struct cmd_vf_split_drop_en_result,
13478 cmd_set_vf_split_drop_en_parsed(
13479 void *parsed_result,
13480 __attribute__((unused)) struct cmdline *cl,
13481 __attribute__((unused)) void *data)
13483 struct cmd_vf_split_drop_en_result *res = parsed_result;
13484 int ret = -ENOTSUP;
13485 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13487 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13490 #ifdef RTE_LIBRTE_IXGBE_PMD
13491 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13498 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13501 printf("invalid port_id %d\n", res->port_id);
13504 printf("not supported on port %d\n", res->port_id);
13507 printf("programming error: (%s)\n", strerror(-ret));
13511 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13512 .f = cmd_set_vf_split_drop_en_parsed,
13514 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13516 (void *)&cmd_vf_split_drop_en_set,
13517 (void *)&cmd_vf_split_drop_en_vf,
13518 (void *)&cmd_vf_split_drop_en_split,
13519 (void *)&cmd_vf_split_drop_en_drop,
13520 (void *)&cmd_vf_split_drop_en_port_id,
13521 (void *)&cmd_vf_split_drop_en_vf_id,
13522 (void *)&cmd_vf_split_drop_en_on_off,
13527 /* vf mac address configuration */
13529 /* Common result structure for vf mac address */
13530 struct cmd_set_vf_mac_addr_result {
13531 cmdline_fixed_string_t set;
13532 cmdline_fixed_string_t vf;
13533 cmdline_fixed_string_t mac;
13534 cmdline_fixed_string_t addr;
13537 struct ether_addr mac_addr;
13541 /* Common CLI fields for vf split drop enable disable */
13542 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13543 TOKEN_STRING_INITIALIZER
13544 (struct cmd_set_vf_mac_addr_result,
13546 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13547 TOKEN_STRING_INITIALIZER
13548 (struct cmd_set_vf_mac_addr_result,
13550 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13551 TOKEN_STRING_INITIALIZER
13552 (struct cmd_set_vf_mac_addr_result,
13554 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13555 TOKEN_STRING_INITIALIZER
13556 (struct cmd_set_vf_mac_addr_result,
13558 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13559 TOKEN_NUM_INITIALIZER
13560 (struct cmd_set_vf_mac_addr_result,
13562 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13563 TOKEN_NUM_INITIALIZER
13564 (struct cmd_set_vf_mac_addr_result,
13566 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13567 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13571 cmd_set_vf_mac_addr_parsed(
13572 void *parsed_result,
13573 __attribute__((unused)) struct cmdline *cl,
13574 __attribute__((unused)) void *data)
13576 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13577 int ret = -ENOTSUP;
13579 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13582 #ifdef RTE_LIBRTE_IXGBE_PMD
13583 if (ret == -ENOTSUP)
13584 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13587 #ifdef RTE_LIBRTE_I40E_PMD
13588 if (ret == -ENOTSUP)
13589 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13592 #ifdef RTE_LIBRTE_BNXT_PMD
13593 if (ret == -ENOTSUP)
13594 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13602 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13605 printf("invalid port_id %d\n", res->port_id);
13608 printf("function not implemented\n");
13611 printf("programming error: (%s)\n", strerror(-ret));
13615 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13616 .f = cmd_set_vf_mac_addr_parsed,
13618 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13620 (void *)&cmd_set_vf_mac_addr_set,
13621 (void *)&cmd_set_vf_mac_addr_vf,
13622 (void *)&cmd_set_vf_mac_addr_mac,
13623 (void *)&cmd_set_vf_mac_addr_addr,
13624 (void *)&cmd_set_vf_mac_addr_port_id,
13625 (void *)&cmd_set_vf_mac_addr_vf_id,
13626 (void *)&cmd_set_vf_mac_addr_mac_addr,
13631 /* MACsec configuration */
13633 /* Common result structure for MACsec offload enable */
13634 struct cmd_macsec_offload_on_result {
13635 cmdline_fixed_string_t set;
13636 cmdline_fixed_string_t macsec;
13637 cmdline_fixed_string_t offload;
13639 cmdline_fixed_string_t on;
13640 cmdline_fixed_string_t encrypt;
13641 cmdline_fixed_string_t en_on_off;
13642 cmdline_fixed_string_t replay_protect;
13643 cmdline_fixed_string_t rp_on_off;
13646 /* Common CLI fields for MACsec offload disable */
13647 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13648 TOKEN_STRING_INITIALIZER
13649 (struct cmd_macsec_offload_on_result,
13651 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13652 TOKEN_STRING_INITIALIZER
13653 (struct cmd_macsec_offload_on_result,
13655 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13656 TOKEN_STRING_INITIALIZER
13657 (struct cmd_macsec_offload_on_result,
13658 offload, "offload");
13659 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13660 TOKEN_NUM_INITIALIZER
13661 (struct cmd_macsec_offload_on_result,
13663 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13664 TOKEN_STRING_INITIALIZER
13665 (struct cmd_macsec_offload_on_result,
13667 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13668 TOKEN_STRING_INITIALIZER
13669 (struct cmd_macsec_offload_on_result,
13670 encrypt, "encrypt");
13671 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13672 TOKEN_STRING_INITIALIZER
13673 (struct cmd_macsec_offload_on_result,
13674 en_on_off, "on#off");
13675 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13676 TOKEN_STRING_INITIALIZER
13677 (struct cmd_macsec_offload_on_result,
13678 replay_protect, "replay-protect");
13679 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13680 TOKEN_STRING_INITIALIZER
13681 (struct cmd_macsec_offload_on_result,
13682 rp_on_off, "on#off");
13685 cmd_set_macsec_offload_on_parsed(
13686 void *parsed_result,
13687 __attribute__((unused)) struct cmdline *cl,
13688 __attribute__((unused)) void *data)
13690 struct cmd_macsec_offload_on_result *res = parsed_result;
13691 int ret = -ENOTSUP;
13692 portid_t port_id = res->port_id;
13693 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13694 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13695 struct rte_eth_dev_info dev_info;
13697 if (port_id_is_invalid(port_id, ENABLED_WARN))
13699 if (!port_is_stopped(port_id)) {
13700 printf("Please stop port %d first\n", port_id);
13704 rte_eth_dev_info_get(port_id, &dev_info);
13705 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13706 #ifdef RTE_LIBRTE_IXGBE_PMD
13707 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13715 ports[port_id].dev_conf.txmode.offloads |=
13716 DEV_TX_OFFLOAD_MACSEC_INSERT;
13717 cmd_reconfig_device_queue(port_id, 1, 1);
13720 printf("invalid port_id %d\n", port_id);
13723 printf("not supported on port %d\n", port_id);
13726 printf("programming error: (%s)\n", strerror(-ret));
13730 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13731 .f = cmd_set_macsec_offload_on_parsed,
13733 .help_str = "set macsec offload <port_id> on "
13734 "encrypt on|off replay-protect on|off",
13736 (void *)&cmd_macsec_offload_on_set,
13737 (void *)&cmd_macsec_offload_on_macsec,
13738 (void *)&cmd_macsec_offload_on_offload,
13739 (void *)&cmd_macsec_offload_on_port_id,
13740 (void *)&cmd_macsec_offload_on_on,
13741 (void *)&cmd_macsec_offload_on_encrypt,
13742 (void *)&cmd_macsec_offload_on_en_on_off,
13743 (void *)&cmd_macsec_offload_on_replay_protect,
13744 (void *)&cmd_macsec_offload_on_rp_on_off,
13749 /* Common result structure for MACsec offload disable */
13750 struct cmd_macsec_offload_off_result {
13751 cmdline_fixed_string_t set;
13752 cmdline_fixed_string_t macsec;
13753 cmdline_fixed_string_t offload;
13755 cmdline_fixed_string_t off;
13758 /* Common CLI fields for MACsec offload disable */
13759 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13760 TOKEN_STRING_INITIALIZER
13761 (struct cmd_macsec_offload_off_result,
13763 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13764 TOKEN_STRING_INITIALIZER
13765 (struct cmd_macsec_offload_off_result,
13767 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13768 TOKEN_STRING_INITIALIZER
13769 (struct cmd_macsec_offload_off_result,
13770 offload, "offload");
13771 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13772 TOKEN_NUM_INITIALIZER
13773 (struct cmd_macsec_offload_off_result,
13775 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13776 TOKEN_STRING_INITIALIZER
13777 (struct cmd_macsec_offload_off_result,
13781 cmd_set_macsec_offload_off_parsed(
13782 void *parsed_result,
13783 __attribute__((unused)) struct cmdline *cl,
13784 __attribute__((unused)) void *data)
13786 struct cmd_macsec_offload_off_result *res = parsed_result;
13787 int ret = -ENOTSUP;
13788 struct rte_eth_dev_info dev_info;
13789 portid_t port_id = res->port_id;
13791 if (port_id_is_invalid(port_id, ENABLED_WARN))
13793 if (!port_is_stopped(port_id)) {
13794 printf("Please stop port %d first\n", port_id);
13798 rte_eth_dev_info_get(port_id, &dev_info);
13799 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13800 #ifdef RTE_LIBRTE_IXGBE_PMD
13801 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13806 ports[port_id].dev_conf.txmode.offloads &=
13807 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13808 cmd_reconfig_device_queue(port_id, 1, 1);
13811 printf("invalid port_id %d\n", port_id);
13814 printf("not supported on port %d\n", port_id);
13817 printf("programming error: (%s)\n", strerror(-ret));
13821 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13822 .f = cmd_set_macsec_offload_off_parsed,
13824 .help_str = "set macsec offload <port_id> off",
13826 (void *)&cmd_macsec_offload_off_set,
13827 (void *)&cmd_macsec_offload_off_macsec,
13828 (void *)&cmd_macsec_offload_off_offload,
13829 (void *)&cmd_macsec_offload_off_port_id,
13830 (void *)&cmd_macsec_offload_off_off,
13835 /* Common result structure for MACsec secure connection configure */
13836 struct cmd_macsec_sc_result {
13837 cmdline_fixed_string_t set;
13838 cmdline_fixed_string_t macsec;
13839 cmdline_fixed_string_t sc;
13840 cmdline_fixed_string_t tx_rx;
13842 struct ether_addr mac;
13846 /* Common CLI fields for MACsec secure connection configure */
13847 cmdline_parse_token_string_t cmd_macsec_sc_set =
13848 TOKEN_STRING_INITIALIZER
13849 (struct cmd_macsec_sc_result,
13851 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13852 TOKEN_STRING_INITIALIZER
13853 (struct cmd_macsec_sc_result,
13855 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13856 TOKEN_STRING_INITIALIZER
13857 (struct cmd_macsec_sc_result,
13859 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13860 TOKEN_STRING_INITIALIZER
13861 (struct cmd_macsec_sc_result,
13863 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13864 TOKEN_NUM_INITIALIZER
13865 (struct cmd_macsec_sc_result,
13867 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13868 TOKEN_ETHERADDR_INITIALIZER
13869 (struct cmd_macsec_sc_result,
13871 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13872 TOKEN_NUM_INITIALIZER
13873 (struct cmd_macsec_sc_result,
13877 cmd_set_macsec_sc_parsed(
13878 void *parsed_result,
13879 __attribute__((unused)) struct cmdline *cl,
13880 __attribute__((unused)) void *data)
13882 struct cmd_macsec_sc_result *res = parsed_result;
13883 int ret = -ENOTSUP;
13884 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13886 #ifdef RTE_LIBRTE_IXGBE_PMD
13888 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13889 res->mac.addr_bytes) :
13890 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13891 res->mac.addr_bytes, res->pi);
13893 RTE_SET_USED(is_tx);
13899 printf("invalid port_id %d\n", res->port_id);
13902 printf("not supported on port %d\n", res->port_id);
13905 printf("programming error: (%s)\n", strerror(-ret));
13909 cmdline_parse_inst_t cmd_set_macsec_sc = {
13910 .f = cmd_set_macsec_sc_parsed,
13912 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13914 (void *)&cmd_macsec_sc_set,
13915 (void *)&cmd_macsec_sc_macsec,
13916 (void *)&cmd_macsec_sc_sc,
13917 (void *)&cmd_macsec_sc_tx_rx,
13918 (void *)&cmd_macsec_sc_port_id,
13919 (void *)&cmd_macsec_sc_mac,
13920 (void *)&cmd_macsec_sc_pi,
13925 /* Common result structure for MACsec secure connection configure */
13926 struct cmd_macsec_sa_result {
13927 cmdline_fixed_string_t set;
13928 cmdline_fixed_string_t macsec;
13929 cmdline_fixed_string_t sa;
13930 cmdline_fixed_string_t tx_rx;
13935 cmdline_fixed_string_t key;
13938 /* Common CLI fields for MACsec secure connection configure */
13939 cmdline_parse_token_string_t cmd_macsec_sa_set =
13940 TOKEN_STRING_INITIALIZER
13941 (struct cmd_macsec_sa_result,
13943 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13944 TOKEN_STRING_INITIALIZER
13945 (struct cmd_macsec_sa_result,
13947 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13948 TOKEN_STRING_INITIALIZER
13949 (struct cmd_macsec_sa_result,
13951 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13952 TOKEN_STRING_INITIALIZER
13953 (struct cmd_macsec_sa_result,
13955 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13956 TOKEN_NUM_INITIALIZER
13957 (struct cmd_macsec_sa_result,
13959 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13960 TOKEN_NUM_INITIALIZER
13961 (struct cmd_macsec_sa_result,
13963 cmdline_parse_token_num_t cmd_macsec_sa_an =
13964 TOKEN_NUM_INITIALIZER
13965 (struct cmd_macsec_sa_result,
13967 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13968 TOKEN_NUM_INITIALIZER
13969 (struct cmd_macsec_sa_result,
13971 cmdline_parse_token_string_t cmd_macsec_sa_key =
13972 TOKEN_STRING_INITIALIZER
13973 (struct cmd_macsec_sa_result,
13977 cmd_set_macsec_sa_parsed(
13978 void *parsed_result,
13979 __attribute__((unused)) struct cmdline *cl,
13980 __attribute__((unused)) void *data)
13982 struct cmd_macsec_sa_result *res = parsed_result;
13983 int ret = -ENOTSUP;
13984 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13985 uint8_t key[16] = { 0 };
13991 key_len = strlen(res->key) / 2;
13995 for (i = 0; i < key_len; i++) {
13996 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13999 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14002 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14005 #ifdef RTE_LIBRTE_IXGBE_PMD
14007 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14008 res->idx, res->an, res->pn, key) :
14009 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14010 res->idx, res->an, res->pn, key);
14012 RTE_SET_USED(is_tx);
14019 printf("invalid idx %d or an %d\n", res->idx, res->an);
14022 printf("invalid port_id %d\n", res->port_id);
14025 printf("not supported on port %d\n", res->port_id);
14028 printf("programming error: (%s)\n", strerror(-ret));
14032 cmdline_parse_inst_t cmd_set_macsec_sa = {
14033 .f = cmd_set_macsec_sa_parsed,
14035 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14037 (void *)&cmd_macsec_sa_set,
14038 (void *)&cmd_macsec_sa_macsec,
14039 (void *)&cmd_macsec_sa_sa,
14040 (void *)&cmd_macsec_sa_tx_rx,
14041 (void *)&cmd_macsec_sa_port_id,
14042 (void *)&cmd_macsec_sa_idx,
14043 (void *)&cmd_macsec_sa_an,
14044 (void *)&cmd_macsec_sa_pn,
14045 (void *)&cmd_macsec_sa_key,
14050 /* VF unicast promiscuous mode configuration */
14052 /* Common result structure for VF unicast promiscuous mode */
14053 struct cmd_vf_promisc_result {
14054 cmdline_fixed_string_t set;
14055 cmdline_fixed_string_t vf;
14056 cmdline_fixed_string_t promisc;
14059 cmdline_fixed_string_t on_off;
14062 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14063 cmdline_parse_token_string_t cmd_vf_promisc_set =
14064 TOKEN_STRING_INITIALIZER
14065 (struct cmd_vf_promisc_result,
14067 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14068 TOKEN_STRING_INITIALIZER
14069 (struct cmd_vf_promisc_result,
14071 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14072 TOKEN_STRING_INITIALIZER
14073 (struct cmd_vf_promisc_result,
14074 promisc, "promisc");
14075 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14076 TOKEN_NUM_INITIALIZER
14077 (struct cmd_vf_promisc_result,
14079 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14080 TOKEN_NUM_INITIALIZER
14081 (struct cmd_vf_promisc_result,
14083 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14084 TOKEN_STRING_INITIALIZER
14085 (struct cmd_vf_promisc_result,
14089 cmd_set_vf_promisc_parsed(
14090 void *parsed_result,
14091 __attribute__((unused)) struct cmdline *cl,
14092 __attribute__((unused)) void *data)
14094 struct cmd_vf_promisc_result *res = parsed_result;
14095 int ret = -ENOTSUP;
14097 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14099 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14102 #ifdef RTE_LIBRTE_I40E_PMD
14103 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14104 res->vf_id, is_on);
14111 printf("invalid vf_id %d\n", res->vf_id);
14114 printf("invalid port_id %d\n", res->port_id);
14117 printf("function not implemented\n");
14120 printf("programming error: (%s)\n", strerror(-ret));
14124 cmdline_parse_inst_t cmd_set_vf_promisc = {
14125 .f = cmd_set_vf_promisc_parsed,
14127 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14128 "Set unicast promiscuous mode for a VF from the PF",
14130 (void *)&cmd_vf_promisc_set,
14131 (void *)&cmd_vf_promisc_vf,
14132 (void *)&cmd_vf_promisc_promisc,
14133 (void *)&cmd_vf_promisc_port_id,
14134 (void *)&cmd_vf_promisc_vf_id,
14135 (void *)&cmd_vf_promisc_on_off,
14140 /* VF multicast promiscuous mode configuration */
14142 /* Common result structure for VF multicast promiscuous mode */
14143 struct cmd_vf_allmulti_result {
14144 cmdline_fixed_string_t set;
14145 cmdline_fixed_string_t vf;
14146 cmdline_fixed_string_t allmulti;
14149 cmdline_fixed_string_t on_off;
14152 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14153 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14154 TOKEN_STRING_INITIALIZER
14155 (struct cmd_vf_allmulti_result,
14157 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14158 TOKEN_STRING_INITIALIZER
14159 (struct cmd_vf_allmulti_result,
14161 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14162 TOKEN_STRING_INITIALIZER
14163 (struct cmd_vf_allmulti_result,
14164 allmulti, "allmulti");
14165 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14166 TOKEN_NUM_INITIALIZER
14167 (struct cmd_vf_allmulti_result,
14169 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14170 TOKEN_NUM_INITIALIZER
14171 (struct cmd_vf_allmulti_result,
14173 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14174 TOKEN_STRING_INITIALIZER
14175 (struct cmd_vf_allmulti_result,
14179 cmd_set_vf_allmulti_parsed(
14180 void *parsed_result,
14181 __attribute__((unused)) struct cmdline *cl,
14182 __attribute__((unused)) void *data)
14184 struct cmd_vf_allmulti_result *res = parsed_result;
14185 int ret = -ENOTSUP;
14187 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14189 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14192 #ifdef RTE_LIBRTE_I40E_PMD
14193 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14194 res->vf_id, is_on);
14201 printf("invalid vf_id %d\n", res->vf_id);
14204 printf("invalid port_id %d\n", res->port_id);
14207 printf("function not implemented\n");
14210 printf("programming error: (%s)\n", strerror(-ret));
14214 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14215 .f = cmd_set_vf_allmulti_parsed,
14217 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14218 "Set multicast promiscuous mode for a VF from the PF",
14220 (void *)&cmd_vf_allmulti_set,
14221 (void *)&cmd_vf_allmulti_vf,
14222 (void *)&cmd_vf_allmulti_allmulti,
14223 (void *)&cmd_vf_allmulti_port_id,
14224 (void *)&cmd_vf_allmulti_vf_id,
14225 (void *)&cmd_vf_allmulti_on_off,
14230 /* vf broadcast mode configuration */
14232 /* Common result structure for vf broadcast */
14233 struct cmd_set_vf_broadcast_result {
14234 cmdline_fixed_string_t set;
14235 cmdline_fixed_string_t vf;
14236 cmdline_fixed_string_t broadcast;
14239 cmdline_fixed_string_t on_off;
14242 /* Common CLI fields for vf broadcast enable disable */
14243 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14244 TOKEN_STRING_INITIALIZER
14245 (struct cmd_set_vf_broadcast_result,
14247 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14248 TOKEN_STRING_INITIALIZER
14249 (struct cmd_set_vf_broadcast_result,
14251 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14252 TOKEN_STRING_INITIALIZER
14253 (struct cmd_set_vf_broadcast_result,
14254 broadcast, "broadcast");
14255 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14256 TOKEN_NUM_INITIALIZER
14257 (struct cmd_set_vf_broadcast_result,
14259 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14260 TOKEN_NUM_INITIALIZER
14261 (struct cmd_set_vf_broadcast_result,
14263 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14264 TOKEN_STRING_INITIALIZER
14265 (struct cmd_set_vf_broadcast_result,
14269 cmd_set_vf_broadcast_parsed(
14270 void *parsed_result,
14271 __attribute__((unused)) struct cmdline *cl,
14272 __attribute__((unused)) void *data)
14274 struct cmd_set_vf_broadcast_result *res = parsed_result;
14275 int ret = -ENOTSUP;
14277 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14279 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14282 #ifdef RTE_LIBRTE_I40E_PMD
14283 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14284 res->vf_id, is_on);
14291 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14294 printf("invalid port_id %d\n", res->port_id);
14297 printf("function not implemented\n");
14300 printf("programming error: (%s)\n", strerror(-ret));
14304 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14305 .f = cmd_set_vf_broadcast_parsed,
14307 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14309 (void *)&cmd_set_vf_broadcast_set,
14310 (void *)&cmd_set_vf_broadcast_vf,
14311 (void *)&cmd_set_vf_broadcast_broadcast,
14312 (void *)&cmd_set_vf_broadcast_port_id,
14313 (void *)&cmd_set_vf_broadcast_vf_id,
14314 (void *)&cmd_set_vf_broadcast_on_off,
14319 /* vf vlan tag configuration */
14321 /* Common result structure for vf vlan tag */
14322 struct cmd_set_vf_vlan_tag_result {
14323 cmdline_fixed_string_t set;
14324 cmdline_fixed_string_t vf;
14325 cmdline_fixed_string_t vlan;
14326 cmdline_fixed_string_t tag;
14329 cmdline_fixed_string_t on_off;
14332 /* Common CLI fields for vf vlan tag enable disable */
14333 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14334 TOKEN_STRING_INITIALIZER
14335 (struct cmd_set_vf_vlan_tag_result,
14337 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14338 TOKEN_STRING_INITIALIZER
14339 (struct cmd_set_vf_vlan_tag_result,
14341 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14342 TOKEN_STRING_INITIALIZER
14343 (struct cmd_set_vf_vlan_tag_result,
14345 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14346 TOKEN_STRING_INITIALIZER
14347 (struct cmd_set_vf_vlan_tag_result,
14349 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14350 TOKEN_NUM_INITIALIZER
14351 (struct cmd_set_vf_vlan_tag_result,
14353 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14354 TOKEN_NUM_INITIALIZER
14355 (struct cmd_set_vf_vlan_tag_result,
14357 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14358 TOKEN_STRING_INITIALIZER
14359 (struct cmd_set_vf_vlan_tag_result,
14363 cmd_set_vf_vlan_tag_parsed(
14364 void *parsed_result,
14365 __attribute__((unused)) struct cmdline *cl,
14366 __attribute__((unused)) void *data)
14368 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14369 int ret = -ENOTSUP;
14371 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14373 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14376 #ifdef RTE_LIBRTE_I40E_PMD
14377 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14378 res->vf_id, is_on);
14385 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14388 printf("invalid port_id %d\n", res->port_id);
14391 printf("function not implemented\n");
14394 printf("programming error: (%s)\n", strerror(-ret));
14398 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14399 .f = cmd_set_vf_vlan_tag_parsed,
14401 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14403 (void *)&cmd_set_vf_vlan_tag_set,
14404 (void *)&cmd_set_vf_vlan_tag_vf,
14405 (void *)&cmd_set_vf_vlan_tag_vlan,
14406 (void *)&cmd_set_vf_vlan_tag_tag,
14407 (void *)&cmd_set_vf_vlan_tag_port_id,
14408 (void *)&cmd_set_vf_vlan_tag_vf_id,
14409 (void *)&cmd_set_vf_vlan_tag_on_off,
14414 /* Common definition of VF and TC TX bandwidth configuration */
14415 struct cmd_vf_tc_bw_result {
14416 cmdline_fixed_string_t set;
14417 cmdline_fixed_string_t vf;
14418 cmdline_fixed_string_t tc;
14419 cmdline_fixed_string_t tx;
14420 cmdline_fixed_string_t min_bw;
14421 cmdline_fixed_string_t max_bw;
14422 cmdline_fixed_string_t strict_link_prio;
14427 cmdline_fixed_string_t bw_list;
14431 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14432 TOKEN_STRING_INITIALIZER
14433 (struct cmd_vf_tc_bw_result,
14435 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14436 TOKEN_STRING_INITIALIZER
14437 (struct cmd_vf_tc_bw_result,
14439 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14440 TOKEN_STRING_INITIALIZER
14441 (struct cmd_vf_tc_bw_result,
14443 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14444 TOKEN_STRING_INITIALIZER
14445 (struct cmd_vf_tc_bw_result,
14447 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14448 TOKEN_STRING_INITIALIZER
14449 (struct cmd_vf_tc_bw_result,
14450 strict_link_prio, "strict-link-priority");
14451 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14452 TOKEN_STRING_INITIALIZER
14453 (struct cmd_vf_tc_bw_result,
14454 min_bw, "min-bandwidth");
14455 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14456 TOKEN_STRING_INITIALIZER
14457 (struct cmd_vf_tc_bw_result,
14458 max_bw, "max-bandwidth");
14459 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14460 TOKEN_NUM_INITIALIZER
14461 (struct cmd_vf_tc_bw_result,
14463 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14464 TOKEN_NUM_INITIALIZER
14465 (struct cmd_vf_tc_bw_result,
14467 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14468 TOKEN_NUM_INITIALIZER
14469 (struct cmd_vf_tc_bw_result,
14471 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14472 TOKEN_NUM_INITIALIZER
14473 (struct cmd_vf_tc_bw_result,
14475 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14476 TOKEN_STRING_INITIALIZER
14477 (struct cmd_vf_tc_bw_result,
14479 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14480 TOKEN_NUM_INITIALIZER
14481 (struct cmd_vf_tc_bw_result,
14484 /* VF max bandwidth setting */
14486 cmd_vf_max_bw_parsed(
14487 void *parsed_result,
14488 __attribute__((unused)) struct cmdline *cl,
14489 __attribute__((unused)) void *data)
14491 struct cmd_vf_tc_bw_result *res = parsed_result;
14492 int ret = -ENOTSUP;
14494 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14497 #ifdef RTE_LIBRTE_I40E_PMD
14498 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14499 res->vf_id, res->bw);
14506 printf("invalid vf_id %d or bandwidth %d\n",
14507 res->vf_id, res->bw);
14510 printf("invalid port_id %d\n", res->port_id);
14513 printf("function not implemented\n");
14516 printf("programming error: (%s)\n", strerror(-ret));
14520 cmdline_parse_inst_t cmd_vf_max_bw = {
14521 .f = cmd_vf_max_bw_parsed,
14523 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14525 (void *)&cmd_vf_tc_bw_set,
14526 (void *)&cmd_vf_tc_bw_vf,
14527 (void *)&cmd_vf_tc_bw_tx,
14528 (void *)&cmd_vf_tc_bw_max_bw,
14529 (void *)&cmd_vf_tc_bw_port_id,
14530 (void *)&cmd_vf_tc_bw_vf_id,
14531 (void *)&cmd_vf_tc_bw_bw,
14537 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14542 const char *p, *p0 = str;
14549 p = strchr(p0, '(');
14551 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14555 p0 = strchr(p, ')');
14557 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14561 if (size >= sizeof(s)) {
14562 printf("The string size exceeds the internal buffer size\n");
14565 snprintf(s, sizeof(s), "%.*s", size, p);
14566 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14568 printf("Failed to get the bandwidth list. ");
14572 for (i = 0; i < ret; i++)
14573 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14578 /* TC min bandwidth setting */
14580 cmd_vf_tc_min_bw_parsed(
14581 void *parsed_result,
14582 __attribute__((unused)) struct cmdline *cl,
14583 __attribute__((unused)) void *data)
14585 struct cmd_vf_tc_bw_result *res = parsed_result;
14588 int ret = -ENOTSUP;
14590 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14593 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14597 #ifdef RTE_LIBRTE_I40E_PMD
14598 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14606 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14609 printf("invalid port_id %d\n", res->port_id);
14612 printf("function not implemented\n");
14615 printf("programming error: (%s)\n", strerror(-ret));
14619 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14620 .f = cmd_vf_tc_min_bw_parsed,
14622 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14623 " <bw1, bw2, ...>",
14625 (void *)&cmd_vf_tc_bw_set,
14626 (void *)&cmd_vf_tc_bw_vf,
14627 (void *)&cmd_vf_tc_bw_tc,
14628 (void *)&cmd_vf_tc_bw_tx,
14629 (void *)&cmd_vf_tc_bw_min_bw,
14630 (void *)&cmd_vf_tc_bw_port_id,
14631 (void *)&cmd_vf_tc_bw_vf_id,
14632 (void *)&cmd_vf_tc_bw_bw_list,
14638 cmd_tc_min_bw_parsed(
14639 void *parsed_result,
14640 __attribute__((unused)) struct cmdline *cl,
14641 __attribute__((unused)) void *data)
14643 struct cmd_vf_tc_bw_result *res = parsed_result;
14644 struct rte_port *port;
14647 int ret = -ENOTSUP;
14649 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14652 port = &ports[res->port_id];
14653 /** Check if the port is not started **/
14654 if (port->port_status != RTE_PORT_STOPPED) {
14655 printf("Please stop port %d first\n", res->port_id);
14659 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14663 #ifdef RTE_LIBRTE_IXGBE_PMD
14664 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14671 printf("invalid bandwidth\n");
14674 printf("invalid port_id %d\n", res->port_id);
14677 printf("function not implemented\n");
14680 printf("programming error: (%s)\n", strerror(-ret));
14684 cmdline_parse_inst_t cmd_tc_min_bw = {
14685 .f = cmd_tc_min_bw_parsed,
14687 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14689 (void *)&cmd_vf_tc_bw_set,
14690 (void *)&cmd_vf_tc_bw_tc,
14691 (void *)&cmd_vf_tc_bw_tx,
14692 (void *)&cmd_vf_tc_bw_min_bw,
14693 (void *)&cmd_vf_tc_bw_port_id,
14694 (void *)&cmd_vf_tc_bw_bw_list,
14699 /* TC max bandwidth setting */
14701 cmd_vf_tc_max_bw_parsed(
14702 void *parsed_result,
14703 __attribute__((unused)) struct cmdline *cl,
14704 __attribute__((unused)) void *data)
14706 struct cmd_vf_tc_bw_result *res = parsed_result;
14707 int ret = -ENOTSUP;
14709 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14712 #ifdef RTE_LIBRTE_I40E_PMD
14713 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14714 res->tc_no, res->bw);
14721 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14722 res->vf_id, res->tc_no, res->bw);
14725 printf("invalid port_id %d\n", res->port_id);
14728 printf("function not implemented\n");
14731 printf("programming error: (%s)\n", strerror(-ret));
14735 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14736 .f = cmd_vf_tc_max_bw_parsed,
14738 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14741 (void *)&cmd_vf_tc_bw_set,
14742 (void *)&cmd_vf_tc_bw_vf,
14743 (void *)&cmd_vf_tc_bw_tc,
14744 (void *)&cmd_vf_tc_bw_tx,
14745 (void *)&cmd_vf_tc_bw_max_bw,
14746 (void *)&cmd_vf_tc_bw_port_id,
14747 (void *)&cmd_vf_tc_bw_vf_id,
14748 (void *)&cmd_vf_tc_bw_tc_no,
14749 (void *)&cmd_vf_tc_bw_bw,
14755 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14757 /* *** Set Port default Traffic Management Hierarchy *** */
14758 struct cmd_set_port_tm_hierarchy_default_result {
14759 cmdline_fixed_string_t set;
14760 cmdline_fixed_string_t port;
14761 cmdline_fixed_string_t tm;
14762 cmdline_fixed_string_t hierarchy;
14763 cmdline_fixed_string_t def;
14767 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14768 TOKEN_STRING_INITIALIZER(
14769 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14770 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14771 TOKEN_STRING_INITIALIZER(
14772 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14773 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14774 TOKEN_STRING_INITIALIZER(
14775 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14776 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14777 TOKEN_STRING_INITIALIZER(
14778 struct cmd_set_port_tm_hierarchy_default_result,
14779 hierarchy, "hierarchy");
14780 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14781 TOKEN_STRING_INITIALIZER(
14782 struct cmd_set_port_tm_hierarchy_default_result,
14784 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14785 TOKEN_NUM_INITIALIZER(
14786 struct cmd_set_port_tm_hierarchy_default_result,
14789 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14790 __attribute__((unused)) struct cmdline *cl,
14791 __attribute__((unused)) void *data)
14793 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14794 struct rte_port *p;
14795 portid_t port_id = res->port_id;
14797 if (port_id_is_invalid(port_id, ENABLED_WARN))
14800 p = &ports[port_id];
14803 if (p->softport.tm_flag == 0) {
14804 printf(" tm not enabled on port %u (error)\n", port_id);
14808 /* Forward mode: tm */
14809 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14810 printf(" tm mode not enabled(error)\n");
14814 /* Set the default tm hierarchy */
14815 p->softport.tm.default_hierarchy_enable = 1;
14818 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14819 .f = cmd_set_port_tm_hierarchy_default_parsed,
14821 .help_str = "set port tm hierarchy default <port_id>",
14823 (void *)&cmd_set_port_tm_hierarchy_default_set,
14824 (void *)&cmd_set_port_tm_hierarchy_default_port,
14825 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14826 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14827 (void *)&cmd_set_port_tm_hierarchy_default_default,
14828 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14834 /* Strict link priority scheduling mode setting */
14836 cmd_strict_link_prio_parsed(
14837 void *parsed_result,
14838 __attribute__((unused)) struct cmdline *cl,
14839 __attribute__((unused)) void *data)
14841 struct cmd_vf_tc_bw_result *res = parsed_result;
14842 int ret = -ENOTSUP;
14844 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14847 #ifdef RTE_LIBRTE_I40E_PMD
14848 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14855 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14858 printf("invalid port_id %d\n", res->port_id);
14861 printf("function not implemented\n");
14864 printf("programming error: (%s)\n", strerror(-ret));
14868 cmdline_parse_inst_t cmd_strict_link_prio = {
14869 .f = cmd_strict_link_prio_parsed,
14871 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14873 (void *)&cmd_vf_tc_bw_set,
14874 (void *)&cmd_vf_tc_bw_tx,
14875 (void *)&cmd_vf_tc_bw_strict_link_prio,
14876 (void *)&cmd_vf_tc_bw_port_id,
14877 (void *)&cmd_vf_tc_bw_tc_map,
14882 /* Load dynamic device personalization*/
14883 struct cmd_ddp_add_result {
14884 cmdline_fixed_string_t ddp;
14885 cmdline_fixed_string_t add;
14890 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14891 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14892 cmdline_parse_token_string_t cmd_ddp_add_add =
14893 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14894 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14895 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14896 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14897 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14900 cmd_ddp_add_parsed(
14901 void *parsed_result,
14902 __attribute__((unused)) struct cmdline *cl,
14903 __attribute__((unused)) void *data)
14905 struct cmd_ddp_add_result *res = parsed_result;
14911 int ret = -ENOTSUP;
14913 if (!all_ports_stopped()) {
14914 printf("Please stop all ports first\n");
14918 filepath = strdup(res->filepath);
14919 if (filepath == NULL) {
14920 printf("Failed to allocate memory\n");
14923 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14925 buff = open_file(file_fld[0], &size);
14927 free((void *)filepath);
14931 #ifdef RTE_LIBRTE_I40E_PMD
14932 if (ret == -ENOTSUP)
14933 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14935 RTE_PMD_I40E_PKG_OP_WR_ADD);
14938 if (ret == -EEXIST)
14939 printf("Profile has already existed.\n");
14941 printf("Failed to load profile.\n");
14942 else if (file_num == 2)
14943 save_file(file_fld[1], buff, size);
14946 free((void *)filepath);
14949 cmdline_parse_inst_t cmd_ddp_add = {
14950 .f = cmd_ddp_add_parsed,
14952 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14954 (void *)&cmd_ddp_add_ddp,
14955 (void *)&cmd_ddp_add_add,
14956 (void *)&cmd_ddp_add_port_id,
14957 (void *)&cmd_ddp_add_filepath,
14962 /* Delete dynamic device personalization*/
14963 struct cmd_ddp_del_result {
14964 cmdline_fixed_string_t ddp;
14965 cmdline_fixed_string_t del;
14970 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14971 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14972 cmdline_parse_token_string_t cmd_ddp_del_del =
14973 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14974 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14975 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14976 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14977 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14980 cmd_ddp_del_parsed(
14981 void *parsed_result,
14982 __attribute__((unused)) struct cmdline *cl,
14983 __attribute__((unused)) void *data)
14985 struct cmd_ddp_del_result *res = parsed_result;
14988 int ret = -ENOTSUP;
14990 if (!all_ports_stopped()) {
14991 printf("Please stop all ports first\n");
14995 buff = open_file(res->filepath, &size);
14999 #ifdef RTE_LIBRTE_I40E_PMD
15000 if (ret == -ENOTSUP)
15001 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15003 RTE_PMD_I40E_PKG_OP_WR_DEL);
15006 if (ret == -EACCES)
15007 printf("Profile does not exist.\n");
15009 printf("Failed to delete profile.\n");
15014 cmdline_parse_inst_t cmd_ddp_del = {
15015 .f = cmd_ddp_del_parsed,
15017 .help_str = "ddp del <port_id> <backup_profile_path>",
15019 (void *)&cmd_ddp_del_ddp,
15020 (void *)&cmd_ddp_del_del,
15021 (void *)&cmd_ddp_del_port_id,
15022 (void *)&cmd_ddp_del_filepath,
15027 /* Get dynamic device personalization profile info */
15028 struct cmd_ddp_info_result {
15029 cmdline_fixed_string_t ddp;
15030 cmdline_fixed_string_t get;
15031 cmdline_fixed_string_t info;
15035 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15036 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15037 cmdline_parse_token_string_t cmd_ddp_info_get =
15038 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15039 cmdline_parse_token_string_t cmd_ddp_info_info =
15040 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15041 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15042 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15045 cmd_ddp_info_parsed(
15046 void *parsed_result,
15047 __attribute__((unused)) struct cmdline *cl,
15048 __attribute__((unused)) void *data)
15050 struct cmd_ddp_info_result *res = parsed_result;
15053 int ret = -ENOTSUP;
15054 #ifdef RTE_LIBRTE_I40E_PMD
15057 uint32_t buff_size = 0;
15058 struct rte_pmd_i40e_profile_info info;
15059 uint32_t dev_num = 0;
15060 struct rte_pmd_i40e_ddp_device_id *devs;
15061 uint32_t proto_num = 0;
15062 struct rte_pmd_i40e_proto_info *proto = NULL;
15063 uint32_t pctype_num = 0;
15064 struct rte_pmd_i40e_ptype_info *pctype;
15065 uint32_t ptype_num = 0;
15066 struct rte_pmd_i40e_ptype_info *ptype;
15071 pkg = open_file(res->filepath, &pkg_size);
15075 #ifdef RTE_LIBRTE_I40E_PMD
15076 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15077 (uint8_t *)&info, sizeof(info),
15078 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15080 printf("Global Track id: 0x%x\n", info.track_id);
15081 printf("Global Version: %d.%d.%d.%d\n",
15082 info.version.major,
15083 info.version.minor,
15084 info.version.update,
15085 info.version.draft);
15086 printf("Global Package name: %s\n\n", info.name);
15089 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15090 (uint8_t *)&info, sizeof(info),
15091 RTE_PMD_I40E_PKG_INFO_HEADER);
15093 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15094 printf("i40e Profile Version: %d.%d.%d.%d\n",
15095 info.version.major,
15096 info.version.minor,
15097 info.version.update,
15098 info.version.draft);
15099 printf("i40e Profile name: %s\n\n", info.name);
15102 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15103 (uint8_t *)&buff_size, sizeof(buff_size),
15104 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15105 if (!ret && buff_size) {
15106 buff = (uint8_t *)malloc(buff_size);
15108 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15110 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15112 printf("Package Notes:\n%s\n\n", buff);
15117 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15118 (uint8_t *)&dev_num, sizeof(dev_num),
15119 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15120 if (!ret && dev_num) {
15121 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15122 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15124 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15125 (uint8_t *)devs, buff_size,
15126 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15128 printf("List of supported devices:\n");
15129 for (i = 0; i < dev_num; i++) {
15130 printf(" %04X:%04X %04X:%04X\n",
15131 devs[i].vendor_dev_id >> 16,
15132 devs[i].vendor_dev_id & 0xFFFF,
15133 devs[i].sub_vendor_dev_id >> 16,
15134 devs[i].sub_vendor_dev_id & 0xFFFF);
15142 /* get information about protocols and packet types */
15143 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15144 (uint8_t *)&proto_num, sizeof(proto_num),
15145 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15146 if (ret || !proto_num)
15147 goto no_print_return;
15149 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15150 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15152 goto no_print_return;
15154 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15156 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15158 printf("List of used protocols:\n");
15159 for (i = 0; i < proto_num; i++)
15160 printf(" %2u: %s\n", proto[i].proto_id,
15164 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15165 (uint8_t *)&pctype_num, sizeof(pctype_num),
15166 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15167 if (ret || !pctype_num)
15168 goto no_print_pctypes;
15170 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15171 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15173 goto no_print_pctypes;
15175 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15177 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15180 goto no_print_pctypes;
15183 printf("List of defined packet classification types:\n");
15184 for (i = 0; i < pctype_num; i++) {
15185 printf(" %2u:", pctype[i].ptype_id);
15186 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15187 proto_id = pctype[i].protocols[j];
15188 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15189 for (n = 0; n < proto_num; n++) {
15190 if (proto[n].proto_id == proto_id) {
15191 printf(" %s", proto[n].name);
15204 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15206 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15207 if (ret || !ptype_num)
15208 goto no_print_return;
15210 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15211 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15213 goto no_print_return;
15215 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15217 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15220 goto no_print_return;
15222 printf("List of defined packet types:\n");
15223 for (i = 0; i < ptype_num; i++) {
15224 printf(" %2u:", ptype[i].ptype_id);
15225 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15226 proto_id = ptype[i].protocols[j];
15227 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15228 for (n = 0; n < proto_num; n++) {
15229 if (proto[n].proto_id == proto_id) {
15230 printf(" %s", proto[n].name);
15246 if (ret == -ENOTSUP)
15247 printf("Function not supported in PMD driver\n");
15251 cmdline_parse_inst_t cmd_ddp_get_info = {
15252 .f = cmd_ddp_info_parsed,
15254 .help_str = "ddp get info <profile_path>",
15256 (void *)&cmd_ddp_info_ddp,
15257 (void *)&cmd_ddp_info_get,
15258 (void *)&cmd_ddp_info_info,
15259 (void *)&cmd_ddp_info_filepath,
15264 /* Get dynamic device personalization profile info list*/
15265 #define PROFILE_INFO_SIZE 48
15266 #define MAX_PROFILE_NUM 16
15268 struct cmd_ddp_get_list_result {
15269 cmdline_fixed_string_t ddp;
15270 cmdline_fixed_string_t get;
15271 cmdline_fixed_string_t list;
15275 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15276 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15277 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15278 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15279 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15280 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15281 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15282 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15285 cmd_ddp_get_list_parsed(
15286 __attribute__((unused)) void *parsed_result,
15287 __attribute__((unused)) struct cmdline *cl,
15288 __attribute__((unused)) void *data)
15290 #ifdef RTE_LIBRTE_I40E_PMD
15291 struct cmd_ddp_get_list_result *res = parsed_result;
15292 struct rte_pmd_i40e_profile_list *p_list;
15293 struct rte_pmd_i40e_profile_info *p_info;
15298 int ret = -ENOTSUP;
15300 #ifdef RTE_LIBRTE_I40E_PMD
15301 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15302 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15304 printf("%s: Failed to malloc buffer\n", __func__);
15306 if (ret == -ENOTSUP)
15307 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15308 (uint8_t *)p_list, size);
15311 p_num = p_list->p_count;
15312 printf("Profile number is: %d\n\n", p_num);
15314 for (i = 0; i < p_num; i++) {
15315 p_info = &p_list->p_info[i];
15316 printf("Profile %d:\n", i);
15317 printf("Track id: 0x%x\n", p_info->track_id);
15318 printf("Version: %d.%d.%d.%d\n",
15319 p_info->version.major,
15320 p_info->version.minor,
15321 p_info->version.update,
15322 p_info->version.draft);
15323 printf("Profile name: %s\n\n", p_info->name);
15331 printf("Failed to get ddp list\n");
15334 cmdline_parse_inst_t cmd_ddp_get_list = {
15335 .f = cmd_ddp_get_list_parsed,
15337 .help_str = "ddp get list <port_id>",
15339 (void *)&cmd_ddp_get_list_ddp,
15340 (void *)&cmd_ddp_get_list_get,
15341 (void *)&cmd_ddp_get_list_list,
15342 (void *)&cmd_ddp_get_list_port_id,
15347 /* Configure input set */
15348 struct cmd_cfg_input_set_result {
15349 cmdline_fixed_string_t port;
15350 cmdline_fixed_string_t cfg;
15352 cmdline_fixed_string_t pctype;
15354 cmdline_fixed_string_t inset_type;
15355 cmdline_fixed_string_t opt;
15356 cmdline_fixed_string_t field;
15361 cmd_cfg_input_set_parsed(
15362 __attribute__((unused)) void *parsed_result,
15363 __attribute__((unused)) struct cmdline *cl,
15364 __attribute__((unused)) void *data)
15366 #ifdef RTE_LIBRTE_I40E_PMD
15367 struct cmd_cfg_input_set_result *res = parsed_result;
15368 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15369 struct rte_pmd_i40e_inset inset;
15371 int ret = -ENOTSUP;
15373 if (!all_ports_stopped()) {
15374 printf("Please stop all ports first\n");
15378 #ifdef RTE_LIBRTE_I40E_PMD
15379 if (!strcmp(res->inset_type, "hash_inset"))
15380 inset_type = INSET_HASH;
15381 else if (!strcmp(res->inset_type, "fdir_inset"))
15382 inset_type = INSET_FDIR;
15383 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15384 inset_type = INSET_FDIR_FLX;
15385 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15386 &inset, inset_type);
15388 printf("Failed to get input set.\n");
15392 if (!strcmp(res->opt, "get")) {
15393 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15396 printf("Field index %d is enabled.\n", res->field_idx);
15398 printf("Field index %d is disabled.\n", res->field_idx);
15400 } else if (!strcmp(res->opt, "set"))
15401 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15403 else if (!strcmp(res->opt, "clear"))
15404 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15407 printf("Failed to configure input set field.\n");
15411 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15412 &inset, inset_type);
15414 printf("Failed to set input set.\n");
15419 if (ret == -ENOTSUP)
15420 printf("Function not supported\n");
15423 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15424 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15426 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15427 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15429 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15430 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15432 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15433 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15435 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15436 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15438 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15439 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15441 "hash_inset#fdir_inset#fdir_flx_inset");
15442 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15443 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15444 opt, "get#set#clear");
15445 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15446 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15448 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15449 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15452 cmdline_parse_inst_t cmd_cfg_input_set = {
15453 .f = cmd_cfg_input_set_parsed,
15455 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15456 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15458 (void *)&cmd_cfg_input_set_port,
15459 (void *)&cmd_cfg_input_set_cfg,
15460 (void *)&cmd_cfg_input_set_port_id,
15461 (void *)&cmd_cfg_input_set_pctype,
15462 (void *)&cmd_cfg_input_set_pctype_id,
15463 (void *)&cmd_cfg_input_set_inset_type,
15464 (void *)&cmd_cfg_input_set_opt,
15465 (void *)&cmd_cfg_input_set_field,
15466 (void *)&cmd_cfg_input_set_field_idx,
15471 /* Clear input set */
15472 struct cmd_clear_input_set_result {
15473 cmdline_fixed_string_t port;
15474 cmdline_fixed_string_t cfg;
15476 cmdline_fixed_string_t pctype;
15478 cmdline_fixed_string_t inset_type;
15479 cmdline_fixed_string_t clear;
15480 cmdline_fixed_string_t all;
15484 cmd_clear_input_set_parsed(
15485 __attribute__((unused)) void *parsed_result,
15486 __attribute__((unused)) struct cmdline *cl,
15487 __attribute__((unused)) void *data)
15489 #ifdef RTE_LIBRTE_I40E_PMD
15490 struct cmd_clear_input_set_result *res = parsed_result;
15491 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15492 struct rte_pmd_i40e_inset inset;
15494 int ret = -ENOTSUP;
15496 if (!all_ports_stopped()) {
15497 printf("Please stop all ports first\n");
15501 #ifdef RTE_LIBRTE_I40E_PMD
15502 if (!strcmp(res->inset_type, "hash_inset"))
15503 inset_type = INSET_HASH;
15504 else if (!strcmp(res->inset_type, "fdir_inset"))
15505 inset_type = INSET_FDIR;
15506 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15507 inset_type = INSET_FDIR_FLX;
15509 memset(&inset, 0, sizeof(inset));
15511 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15512 &inset, inset_type);
15514 printf("Failed to clear input set.\n");
15520 if (ret == -ENOTSUP)
15521 printf("Function not supported\n");
15524 cmdline_parse_token_string_t cmd_clear_input_set_port =
15525 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15527 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15528 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15530 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15531 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15533 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15534 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15536 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15537 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15539 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15540 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15542 "hash_inset#fdir_inset#fdir_flx_inset");
15543 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15544 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15546 cmdline_parse_token_string_t cmd_clear_input_set_all =
15547 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15550 cmdline_parse_inst_t cmd_clear_input_set = {
15551 .f = cmd_clear_input_set_parsed,
15553 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15554 "fdir_inset|fdir_flx_inset clear all",
15556 (void *)&cmd_clear_input_set_port,
15557 (void *)&cmd_clear_input_set_cfg,
15558 (void *)&cmd_clear_input_set_port_id,
15559 (void *)&cmd_clear_input_set_pctype,
15560 (void *)&cmd_clear_input_set_pctype_id,
15561 (void *)&cmd_clear_input_set_inset_type,
15562 (void *)&cmd_clear_input_set_clear,
15563 (void *)&cmd_clear_input_set_all,
15568 /* show vf stats */
15570 /* Common result structure for show vf stats */
15571 struct cmd_show_vf_stats_result {
15572 cmdline_fixed_string_t show;
15573 cmdline_fixed_string_t vf;
15574 cmdline_fixed_string_t stats;
15579 /* Common CLI fields show vf stats*/
15580 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15581 TOKEN_STRING_INITIALIZER
15582 (struct cmd_show_vf_stats_result,
15584 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15585 TOKEN_STRING_INITIALIZER
15586 (struct cmd_show_vf_stats_result,
15588 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15589 TOKEN_STRING_INITIALIZER
15590 (struct cmd_show_vf_stats_result,
15592 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15593 TOKEN_NUM_INITIALIZER
15594 (struct cmd_show_vf_stats_result,
15596 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15597 TOKEN_NUM_INITIALIZER
15598 (struct cmd_show_vf_stats_result,
15602 cmd_show_vf_stats_parsed(
15603 void *parsed_result,
15604 __attribute__((unused)) struct cmdline *cl,
15605 __attribute__((unused)) void *data)
15607 struct cmd_show_vf_stats_result *res = parsed_result;
15608 struct rte_eth_stats stats;
15609 int ret = -ENOTSUP;
15610 static const char *nic_stats_border = "########################";
15612 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15615 memset(&stats, 0, sizeof(stats));
15617 #ifdef RTE_LIBRTE_I40E_PMD
15618 if (ret == -ENOTSUP)
15619 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15623 #ifdef RTE_LIBRTE_BNXT_PMD
15624 if (ret == -ENOTSUP)
15625 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15634 printf("invalid vf_id %d\n", res->vf_id);
15637 printf("invalid port_id %d\n", res->port_id);
15640 printf("function not implemented\n");
15643 printf("programming error: (%s)\n", strerror(-ret));
15646 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15647 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15649 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15651 stats.ipackets, stats.imissed, stats.ibytes);
15652 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15653 printf(" RX-nombuf: %-10"PRIu64"\n",
15655 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15657 stats.opackets, stats.oerrors, stats.obytes);
15659 printf(" %s############################%s\n",
15660 nic_stats_border, nic_stats_border);
15663 cmdline_parse_inst_t cmd_show_vf_stats = {
15664 .f = cmd_show_vf_stats_parsed,
15666 .help_str = "show vf stats <port_id> <vf_id>",
15668 (void *)&cmd_show_vf_stats_show,
15669 (void *)&cmd_show_vf_stats_vf,
15670 (void *)&cmd_show_vf_stats_stats,
15671 (void *)&cmd_show_vf_stats_port_id,
15672 (void *)&cmd_show_vf_stats_vf_id,
15677 /* clear vf stats */
15679 /* Common result structure for clear vf stats */
15680 struct cmd_clear_vf_stats_result {
15681 cmdline_fixed_string_t clear;
15682 cmdline_fixed_string_t vf;
15683 cmdline_fixed_string_t stats;
15688 /* Common CLI fields clear vf stats*/
15689 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15690 TOKEN_STRING_INITIALIZER
15691 (struct cmd_clear_vf_stats_result,
15693 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15694 TOKEN_STRING_INITIALIZER
15695 (struct cmd_clear_vf_stats_result,
15697 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15698 TOKEN_STRING_INITIALIZER
15699 (struct cmd_clear_vf_stats_result,
15701 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15702 TOKEN_NUM_INITIALIZER
15703 (struct cmd_clear_vf_stats_result,
15705 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15706 TOKEN_NUM_INITIALIZER
15707 (struct cmd_clear_vf_stats_result,
15711 cmd_clear_vf_stats_parsed(
15712 void *parsed_result,
15713 __attribute__((unused)) struct cmdline *cl,
15714 __attribute__((unused)) void *data)
15716 struct cmd_clear_vf_stats_result *res = parsed_result;
15717 int ret = -ENOTSUP;
15719 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15722 #ifdef RTE_LIBRTE_I40E_PMD
15723 if (ret == -ENOTSUP)
15724 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15727 #ifdef RTE_LIBRTE_BNXT_PMD
15728 if (ret == -ENOTSUP)
15729 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15737 printf("invalid vf_id %d\n", res->vf_id);
15740 printf("invalid port_id %d\n", res->port_id);
15743 printf("function not implemented\n");
15746 printf("programming error: (%s)\n", strerror(-ret));
15750 cmdline_parse_inst_t cmd_clear_vf_stats = {
15751 .f = cmd_clear_vf_stats_parsed,
15753 .help_str = "clear vf stats <port_id> <vf_id>",
15755 (void *)&cmd_clear_vf_stats_clear,
15756 (void *)&cmd_clear_vf_stats_vf,
15757 (void *)&cmd_clear_vf_stats_stats,
15758 (void *)&cmd_clear_vf_stats_port_id,
15759 (void *)&cmd_clear_vf_stats_vf_id,
15764 /* port config pctype mapping reset */
15766 /* Common result structure for port config pctype mapping reset */
15767 struct cmd_pctype_mapping_reset_result {
15768 cmdline_fixed_string_t port;
15769 cmdline_fixed_string_t config;
15771 cmdline_fixed_string_t pctype;
15772 cmdline_fixed_string_t mapping;
15773 cmdline_fixed_string_t reset;
15776 /* Common CLI fields for port config pctype mapping reset*/
15777 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15778 TOKEN_STRING_INITIALIZER
15779 (struct cmd_pctype_mapping_reset_result,
15781 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15782 TOKEN_STRING_INITIALIZER
15783 (struct cmd_pctype_mapping_reset_result,
15785 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15786 TOKEN_NUM_INITIALIZER
15787 (struct cmd_pctype_mapping_reset_result,
15789 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15790 TOKEN_STRING_INITIALIZER
15791 (struct cmd_pctype_mapping_reset_result,
15793 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15794 TOKEN_STRING_INITIALIZER
15795 (struct cmd_pctype_mapping_reset_result,
15796 mapping, "mapping");
15797 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15798 TOKEN_STRING_INITIALIZER
15799 (struct cmd_pctype_mapping_reset_result,
15803 cmd_pctype_mapping_reset_parsed(
15804 void *parsed_result,
15805 __attribute__((unused)) struct cmdline *cl,
15806 __attribute__((unused)) void *data)
15808 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15809 int ret = -ENOTSUP;
15811 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15814 #ifdef RTE_LIBRTE_I40E_PMD
15815 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15822 printf("invalid port_id %d\n", res->port_id);
15825 printf("function not implemented\n");
15828 printf("programming error: (%s)\n", strerror(-ret));
15832 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15833 .f = cmd_pctype_mapping_reset_parsed,
15835 .help_str = "port config <port_id> pctype mapping reset",
15837 (void *)&cmd_pctype_mapping_reset_port,
15838 (void *)&cmd_pctype_mapping_reset_config,
15839 (void *)&cmd_pctype_mapping_reset_port_id,
15840 (void *)&cmd_pctype_mapping_reset_pctype,
15841 (void *)&cmd_pctype_mapping_reset_mapping,
15842 (void *)&cmd_pctype_mapping_reset_reset,
15847 /* show port pctype mapping */
15849 /* Common result structure for show port pctype mapping */
15850 struct cmd_pctype_mapping_get_result {
15851 cmdline_fixed_string_t show;
15852 cmdline_fixed_string_t port;
15854 cmdline_fixed_string_t pctype;
15855 cmdline_fixed_string_t mapping;
15858 /* Common CLI fields for pctype mapping get */
15859 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15860 TOKEN_STRING_INITIALIZER
15861 (struct cmd_pctype_mapping_get_result,
15863 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15864 TOKEN_STRING_INITIALIZER
15865 (struct cmd_pctype_mapping_get_result,
15867 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15868 TOKEN_NUM_INITIALIZER
15869 (struct cmd_pctype_mapping_get_result,
15871 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15872 TOKEN_STRING_INITIALIZER
15873 (struct cmd_pctype_mapping_get_result,
15875 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15876 TOKEN_STRING_INITIALIZER
15877 (struct cmd_pctype_mapping_get_result,
15878 mapping, "mapping");
15881 cmd_pctype_mapping_get_parsed(
15882 void *parsed_result,
15883 __attribute__((unused)) struct cmdline *cl,
15884 __attribute__((unused)) void *data)
15886 struct cmd_pctype_mapping_get_result *res = parsed_result;
15887 int ret = -ENOTSUP;
15888 #ifdef RTE_LIBRTE_I40E_PMD
15889 struct rte_pmd_i40e_flow_type_mapping
15890 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15891 int i, j, first_pctype;
15894 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15897 #ifdef RTE_LIBRTE_I40E_PMD
15898 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15905 printf("invalid port_id %d\n", res->port_id);
15908 printf("function not implemented\n");
15911 printf("programming error: (%s)\n", strerror(-ret));
15915 #ifdef RTE_LIBRTE_I40E_PMD
15916 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15917 if (mapping[i].pctype != 0ULL) {
15920 printf("pctype: ");
15921 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15922 if (mapping[i].pctype & (1ULL << j)) {
15923 printf(first_pctype ?
15924 "%02d" : ",%02d", j);
15928 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15934 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15935 .f = cmd_pctype_mapping_get_parsed,
15937 .help_str = "show port <port_id> pctype mapping",
15939 (void *)&cmd_pctype_mapping_get_show,
15940 (void *)&cmd_pctype_mapping_get_port,
15941 (void *)&cmd_pctype_mapping_get_port_id,
15942 (void *)&cmd_pctype_mapping_get_pctype,
15943 (void *)&cmd_pctype_mapping_get_mapping,
15948 /* port config pctype mapping update */
15950 /* Common result structure for port config pctype mapping update */
15951 struct cmd_pctype_mapping_update_result {
15952 cmdline_fixed_string_t port;
15953 cmdline_fixed_string_t config;
15955 cmdline_fixed_string_t pctype;
15956 cmdline_fixed_string_t mapping;
15957 cmdline_fixed_string_t update;
15958 cmdline_fixed_string_t pctype_list;
15959 uint16_t flow_type;
15962 /* Common CLI fields for pctype mapping update*/
15963 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15964 TOKEN_STRING_INITIALIZER
15965 (struct cmd_pctype_mapping_update_result,
15967 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15968 TOKEN_STRING_INITIALIZER
15969 (struct cmd_pctype_mapping_update_result,
15971 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15972 TOKEN_NUM_INITIALIZER
15973 (struct cmd_pctype_mapping_update_result,
15975 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15976 TOKEN_STRING_INITIALIZER
15977 (struct cmd_pctype_mapping_update_result,
15979 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15980 TOKEN_STRING_INITIALIZER
15981 (struct cmd_pctype_mapping_update_result,
15982 mapping, "mapping");
15983 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15984 TOKEN_STRING_INITIALIZER
15985 (struct cmd_pctype_mapping_update_result,
15987 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15988 TOKEN_STRING_INITIALIZER
15989 (struct cmd_pctype_mapping_update_result,
15990 pctype_list, NULL);
15991 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15992 TOKEN_NUM_INITIALIZER
15993 (struct cmd_pctype_mapping_update_result,
15994 flow_type, UINT16);
15997 cmd_pctype_mapping_update_parsed(
15998 void *parsed_result,
15999 __attribute__((unused)) struct cmdline *cl,
16000 __attribute__((unused)) void *data)
16002 struct cmd_pctype_mapping_update_result *res = parsed_result;
16003 int ret = -ENOTSUP;
16004 #ifdef RTE_LIBRTE_I40E_PMD
16005 struct rte_pmd_i40e_flow_type_mapping mapping;
16007 unsigned int nb_item;
16008 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16011 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16014 #ifdef RTE_LIBRTE_I40E_PMD
16015 nb_item = parse_item_list(res->pctype_list, "pctypes",
16016 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16017 mapping.flow_type = res->flow_type;
16018 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16019 mapping.pctype |= (1ULL << pctype_list[i]);
16020 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16030 printf("invalid pctype or flow type\n");
16033 printf("invalid port_id %d\n", res->port_id);
16036 printf("function not implemented\n");
16039 printf("programming error: (%s)\n", strerror(-ret));
16043 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16044 .f = cmd_pctype_mapping_update_parsed,
16046 .help_str = "port config <port_id> pctype mapping update"
16047 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16049 (void *)&cmd_pctype_mapping_update_port,
16050 (void *)&cmd_pctype_mapping_update_config,
16051 (void *)&cmd_pctype_mapping_update_port_id,
16052 (void *)&cmd_pctype_mapping_update_pctype,
16053 (void *)&cmd_pctype_mapping_update_mapping,
16054 (void *)&cmd_pctype_mapping_update_update,
16055 (void *)&cmd_pctype_mapping_update_pc_type,
16056 (void *)&cmd_pctype_mapping_update_flow_type,
16061 /* ptype mapping get */
16063 /* Common result structure for ptype mapping get */
16064 struct cmd_ptype_mapping_get_result {
16065 cmdline_fixed_string_t ptype;
16066 cmdline_fixed_string_t mapping;
16067 cmdline_fixed_string_t get;
16069 uint8_t valid_only;
16072 /* Common CLI fields for ptype mapping get */
16073 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16074 TOKEN_STRING_INITIALIZER
16075 (struct cmd_ptype_mapping_get_result,
16077 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16078 TOKEN_STRING_INITIALIZER
16079 (struct cmd_ptype_mapping_get_result,
16080 mapping, "mapping");
16081 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16082 TOKEN_STRING_INITIALIZER
16083 (struct cmd_ptype_mapping_get_result,
16085 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16086 TOKEN_NUM_INITIALIZER
16087 (struct cmd_ptype_mapping_get_result,
16089 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16090 TOKEN_NUM_INITIALIZER
16091 (struct cmd_ptype_mapping_get_result,
16092 valid_only, UINT8);
16095 cmd_ptype_mapping_get_parsed(
16096 void *parsed_result,
16097 __attribute__((unused)) struct cmdline *cl,
16098 __attribute__((unused)) void *data)
16100 struct cmd_ptype_mapping_get_result *res = parsed_result;
16101 int ret = -ENOTSUP;
16102 #ifdef RTE_LIBRTE_I40E_PMD
16103 int max_ptype_num = 256;
16104 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16109 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16112 #ifdef RTE_LIBRTE_I40E_PMD
16113 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16124 printf("invalid port_id %d\n", res->port_id);
16127 printf("function not implemented\n");
16130 printf("programming error: (%s)\n", strerror(-ret));
16133 #ifdef RTE_LIBRTE_I40E_PMD
16135 for (i = 0; i < count; i++)
16136 printf("%3d\t0x%08x\n",
16137 mapping[i].hw_ptype, mapping[i].sw_ptype);
16142 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16143 .f = cmd_ptype_mapping_get_parsed,
16145 .help_str = "ptype mapping get <port_id> <valid_only>",
16147 (void *)&cmd_ptype_mapping_get_ptype,
16148 (void *)&cmd_ptype_mapping_get_mapping,
16149 (void *)&cmd_ptype_mapping_get_get,
16150 (void *)&cmd_ptype_mapping_get_port_id,
16151 (void *)&cmd_ptype_mapping_get_valid_only,
16156 /* ptype mapping replace */
16158 /* Common result structure for ptype mapping replace */
16159 struct cmd_ptype_mapping_replace_result {
16160 cmdline_fixed_string_t ptype;
16161 cmdline_fixed_string_t mapping;
16162 cmdline_fixed_string_t replace;
16169 /* Common CLI fields for ptype mapping replace */
16170 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16171 TOKEN_STRING_INITIALIZER
16172 (struct cmd_ptype_mapping_replace_result,
16174 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16175 TOKEN_STRING_INITIALIZER
16176 (struct cmd_ptype_mapping_replace_result,
16177 mapping, "mapping");
16178 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16179 TOKEN_STRING_INITIALIZER
16180 (struct cmd_ptype_mapping_replace_result,
16181 replace, "replace");
16182 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16183 TOKEN_NUM_INITIALIZER
16184 (struct cmd_ptype_mapping_replace_result,
16186 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16187 TOKEN_NUM_INITIALIZER
16188 (struct cmd_ptype_mapping_replace_result,
16190 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16191 TOKEN_NUM_INITIALIZER
16192 (struct cmd_ptype_mapping_replace_result,
16194 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16195 TOKEN_NUM_INITIALIZER
16196 (struct cmd_ptype_mapping_replace_result,
16200 cmd_ptype_mapping_replace_parsed(
16201 void *parsed_result,
16202 __attribute__((unused)) struct cmdline *cl,
16203 __attribute__((unused)) void *data)
16205 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16206 int ret = -ENOTSUP;
16208 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16211 #ifdef RTE_LIBRTE_I40E_PMD
16212 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16222 printf("invalid ptype 0x%8x or 0x%8x\n",
16223 res->target, res->pkt_type);
16226 printf("invalid port_id %d\n", res->port_id);
16229 printf("function not implemented\n");
16232 printf("programming error: (%s)\n", strerror(-ret));
16236 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16237 .f = cmd_ptype_mapping_replace_parsed,
16240 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16242 (void *)&cmd_ptype_mapping_replace_ptype,
16243 (void *)&cmd_ptype_mapping_replace_mapping,
16244 (void *)&cmd_ptype_mapping_replace_replace,
16245 (void *)&cmd_ptype_mapping_replace_port_id,
16246 (void *)&cmd_ptype_mapping_replace_target,
16247 (void *)&cmd_ptype_mapping_replace_mask,
16248 (void *)&cmd_ptype_mapping_replace_pkt_type,
16253 /* ptype mapping reset */
16255 /* Common result structure for ptype mapping reset */
16256 struct cmd_ptype_mapping_reset_result {
16257 cmdline_fixed_string_t ptype;
16258 cmdline_fixed_string_t mapping;
16259 cmdline_fixed_string_t reset;
16263 /* Common CLI fields for ptype mapping reset*/
16264 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16265 TOKEN_STRING_INITIALIZER
16266 (struct cmd_ptype_mapping_reset_result,
16268 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16269 TOKEN_STRING_INITIALIZER
16270 (struct cmd_ptype_mapping_reset_result,
16271 mapping, "mapping");
16272 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16273 TOKEN_STRING_INITIALIZER
16274 (struct cmd_ptype_mapping_reset_result,
16276 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16277 TOKEN_NUM_INITIALIZER
16278 (struct cmd_ptype_mapping_reset_result,
16282 cmd_ptype_mapping_reset_parsed(
16283 void *parsed_result,
16284 __attribute__((unused)) struct cmdline *cl,
16285 __attribute__((unused)) void *data)
16287 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16288 int ret = -ENOTSUP;
16290 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16293 #ifdef RTE_LIBRTE_I40E_PMD
16294 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16301 printf("invalid port_id %d\n", res->port_id);
16304 printf("function not implemented\n");
16307 printf("programming error: (%s)\n", strerror(-ret));
16311 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16312 .f = cmd_ptype_mapping_reset_parsed,
16314 .help_str = "ptype mapping reset <port_id>",
16316 (void *)&cmd_ptype_mapping_reset_ptype,
16317 (void *)&cmd_ptype_mapping_reset_mapping,
16318 (void *)&cmd_ptype_mapping_reset_reset,
16319 (void *)&cmd_ptype_mapping_reset_port_id,
16324 /* ptype mapping update */
16326 /* Common result structure for ptype mapping update */
16327 struct cmd_ptype_mapping_update_result {
16328 cmdline_fixed_string_t ptype;
16329 cmdline_fixed_string_t mapping;
16330 cmdline_fixed_string_t reset;
16336 /* Common CLI fields for ptype mapping update*/
16337 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16338 TOKEN_STRING_INITIALIZER
16339 (struct cmd_ptype_mapping_update_result,
16341 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16342 TOKEN_STRING_INITIALIZER
16343 (struct cmd_ptype_mapping_update_result,
16344 mapping, "mapping");
16345 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16346 TOKEN_STRING_INITIALIZER
16347 (struct cmd_ptype_mapping_update_result,
16349 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16350 TOKEN_NUM_INITIALIZER
16351 (struct cmd_ptype_mapping_update_result,
16353 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16354 TOKEN_NUM_INITIALIZER
16355 (struct cmd_ptype_mapping_update_result,
16357 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16358 TOKEN_NUM_INITIALIZER
16359 (struct cmd_ptype_mapping_update_result,
16363 cmd_ptype_mapping_update_parsed(
16364 void *parsed_result,
16365 __attribute__((unused)) struct cmdline *cl,
16366 __attribute__((unused)) void *data)
16368 struct cmd_ptype_mapping_update_result *res = parsed_result;
16369 int ret = -ENOTSUP;
16370 #ifdef RTE_LIBRTE_I40E_PMD
16371 struct rte_pmd_i40e_ptype_mapping mapping;
16373 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16376 #ifdef RTE_LIBRTE_I40E_PMD
16377 mapping.hw_ptype = res->hw_ptype;
16378 mapping.sw_ptype = res->sw_ptype;
16379 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16389 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16392 printf("invalid port_id %d\n", res->port_id);
16395 printf("function not implemented\n");
16398 printf("programming error: (%s)\n", strerror(-ret));
16402 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16403 .f = cmd_ptype_mapping_update_parsed,
16405 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16407 (void *)&cmd_ptype_mapping_update_ptype,
16408 (void *)&cmd_ptype_mapping_update_mapping,
16409 (void *)&cmd_ptype_mapping_update_update,
16410 (void *)&cmd_ptype_mapping_update_port_id,
16411 (void *)&cmd_ptype_mapping_update_hw_ptype,
16412 (void *)&cmd_ptype_mapping_update_sw_ptype,
16417 /* Common result structure for file commands */
16418 struct cmd_cmdfile_result {
16419 cmdline_fixed_string_t load;
16420 cmdline_fixed_string_t filename;
16423 /* Common CLI fields for file commands */
16424 cmdline_parse_token_string_t cmd_load_cmdfile =
16425 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16426 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16427 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16430 cmd_load_from_file_parsed(
16431 void *parsed_result,
16432 __attribute__((unused)) struct cmdline *cl,
16433 __attribute__((unused)) void *data)
16435 struct cmd_cmdfile_result *res = parsed_result;
16437 cmdline_read_from_file(res->filename);
16440 cmdline_parse_inst_t cmd_load_from_file = {
16441 .f = cmd_load_from_file_parsed,
16443 .help_str = "load <filename>",
16445 (void *)&cmd_load_cmdfile,
16446 (void *)&cmd_load_cmdfile_filename,
16451 /* ******************************************************************************** */
16453 /* list of instructions */
16454 cmdline_parse_ctx_t main_ctx[] = {
16455 (cmdline_parse_inst_t *)&cmd_help_brief,
16456 (cmdline_parse_inst_t *)&cmd_help_long,
16457 (cmdline_parse_inst_t *)&cmd_quit,
16458 (cmdline_parse_inst_t *)&cmd_load_from_file,
16459 (cmdline_parse_inst_t *)&cmd_showport,
16460 (cmdline_parse_inst_t *)&cmd_showqueue,
16461 (cmdline_parse_inst_t *)&cmd_showportall,
16462 (cmdline_parse_inst_t *)&cmd_showcfg,
16463 (cmdline_parse_inst_t *)&cmd_start,
16464 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16465 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16466 (cmdline_parse_inst_t *)&cmd_set_link_up,
16467 (cmdline_parse_inst_t *)&cmd_set_link_down,
16468 (cmdline_parse_inst_t *)&cmd_reset,
16469 (cmdline_parse_inst_t *)&cmd_set_numbers,
16470 (cmdline_parse_inst_t *)&cmd_set_log,
16471 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16472 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16473 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16474 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16475 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16476 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16477 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16478 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16479 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16480 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16481 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16482 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16483 (cmdline_parse_inst_t *)&cmd_set_link_check,
16484 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16485 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16486 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16487 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16488 #ifdef RTE_LIBRTE_PMD_BOND
16489 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16490 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16491 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16492 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16493 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16494 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16495 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16496 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16497 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16498 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16499 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16501 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16502 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16503 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16504 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16505 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16506 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16507 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16508 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16509 (cmdline_parse_inst_t *)&cmd_csum_set,
16510 (cmdline_parse_inst_t *)&cmd_csum_show,
16511 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16512 (cmdline_parse_inst_t *)&cmd_tso_set,
16513 (cmdline_parse_inst_t *)&cmd_tso_show,
16514 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16515 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16516 (cmdline_parse_inst_t *)&cmd_gro_enable,
16517 (cmdline_parse_inst_t *)&cmd_gro_flush,
16518 (cmdline_parse_inst_t *)&cmd_gro_show,
16519 (cmdline_parse_inst_t *)&cmd_gso_enable,
16520 (cmdline_parse_inst_t *)&cmd_gso_size,
16521 (cmdline_parse_inst_t *)&cmd_gso_show,
16522 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16523 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16524 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16525 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16526 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16527 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16528 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16529 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16530 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16531 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16532 (cmdline_parse_inst_t *)&cmd_config_dcb,
16533 (cmdline_parse_inst_t *)&cmd_read_reg,
16534 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16535 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16536 (cmdline_parse_inst_t *)&cmd_write_reg,
16537 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16538 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16539 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16540 (cmdline_parse_inst_t *)&cmd_stop,
16541 (cmdline_parse_inst_t *)&cmd_mac_addr,
16542 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16543 (cmdline_parse_inst_t *)&cmd_set_qmap,
16544 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16545 (cmdline_parse_inst_t *)&cmd_operate_port,
16546 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16547 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16548 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16549 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16550 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16551 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16552 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16553 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16554 (cmdline_parse_inst_t *)&cmd_config_mtu,
16555 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16556 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16557 (cmdline_parse_inst_t *)&cmd_config_rss,
16558 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16559 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16560 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16561 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16562 (cmdline_parse_inst_t *)&cmd_showport_reta,
16563 (cmdline_parse_inst_t *)&cmd_config_burst,
16564 (cmdline_parse_inst_t *)&cmd_config_thresh,
16565 (cmdline_parse_inst_t *)&cmd_config_threshold,
16566 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16567 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16568 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16569 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16570 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16571 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16572 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16573 (cmdline_parse_inst_t *)&cmd_global_config,
16574 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16575 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16576 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16577 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16578 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16579 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16580 (cmdline_parse_inst_t *)&cmd_dump,
16581 (cmdline_parse_inst_t *)&cmd_dump_one,
16582 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16583 (cmdline_parse_inst_t *)&cmd_syn_filter,
16584 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16585 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16586 (cmdline_parse_inst_t *)&cmd_flex_filter,
16587 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16588 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16589 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16590 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16591 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16592 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16593 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16594 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16595 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16596 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16597 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16598 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16599 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16600 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16601 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16602 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16603 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16604 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16605 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16606 (cmdline_parse_inst_t *)&cmd_flow,
16607 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16608 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16609 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16610 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16611 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16612 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16613 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16614 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16615 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16616 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16617 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16618 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16619 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16620 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16621 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16622 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16623 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16624 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16625 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16626 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16627 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16628 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16629 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16630 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16631 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16632 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16633 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16634 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16635 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16636 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16637 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16638 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16639 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16640 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16641 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16642 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16643 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16644 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16645 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16646 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16647 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16648 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16649 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16650 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16651 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16652 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16653 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16654 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16655 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16656 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16657 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16659 (cmdline_parse_inst_t *)&cmd_ddp_add,
16660 (cmdline_parse_inst_t *)&cmd_ddp_del,
16661 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16662 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16663 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16664 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16665 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16666 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16667 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16668 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16669 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16670 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16672 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16673 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16674 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16675 (cmdline_parse_inst_t *)&cmd_queue_region,
16676 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16677 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16678 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16679 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16680 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16681 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16682 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16683 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16684 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16685 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16686 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16687 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16688 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16689 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16690 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16691 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16692 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16693 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16694 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16695 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16696 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16697 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
16701 /* read cmdline commands from file */
16703 cmdline_read_from_file(const char *filename)
16705 struct cmdline *cl;
16707 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16709 printf("Failed to create file based cmdline context: %s\n",
16714 cmdline_interact(cl);
16719 printf("Read CLI commands from %s\n", filename);
16722 /* prompt function, called from main on MASTER lcore */
16726 /* initialize non-constant commands */
16727 cmd_set_fwd_mode_init();
16728 cmd_set_fwd_retry_mode_init();
16730 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16731 if (testpmd_cl == NULL)
16733 cmdline_interact(testpmd_cl);
16734 cmdline_stdin_exit(testpmd_cl);
16740 if (testpmd_cl != NULL)
16741 cmdline_quit(testpmd_cl);
16745 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16747 if (id == (portid_t)RTE_PORT_ALL) {
16750 RTE_ETH_FOREACH_DEV(pid) {
16751 /* check if need_reconfig has been set to 1 */
16752 if (ports[pid].need_reconfig == 0)
16753 ports[pid].need_reconfig = dev;
16754 /* check if need_reconfig_queues has been set to 1 */
16755 if (ports[pid].need_reconfig_queues == 0)
16756 ports[pid].need_reconfig_queues = queue;
16758 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16759 /* check if need_reconfig has been set to 1 */
16760 if (ports[id].need_reconfig == 0)
16761 ports[id].need_reconfig = dev;
16762 /* check if need_reconfig_queues has been set to 1 */
16763 if (ports[id].need_reconfig_queues == 0)
16764 ports[id].need_reconfig_queues = queue;