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"
80 static struct cmdline *testpmd_cl;
82 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
84 /* *** Help command with introduction. *** */
85 struct cmd_help_brief_result {
86 cmdline_fixed_string_t help;
89 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
91 __attribute__((unused)) void *data)
96 "Help is available for the following sections:\n\n"
97 " help control : Start and stop forwarding.\n"
98 " help display : Displaying port, stats and config "
100 " help config : Configuration information.\n"
101 " help ports : Configuring ports.\n"
102 " help registers : Reading and setting port registers.\n"
103 " help filters : Filters configuration help.\n"
104 " help all : All of the above sections.\n\n"
109 cmdline_parse_token_string_t cmd_help_brief_help =
110 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
112 cmdline_parse_inst_t cmd_help_brief = {
113 .f = cmd_help_brief_parsed,
115 .help_str = "help: Show help",
117 (void *)&cmd_help_brief_help,
122 /* *** Help command with help sections. *** */
123 struct cmd_help_long_result {
124 cmdline_fixed_string_t help;
125 cmdline_fixed_string_t section;
128 static void cmd_help_long_parsed(void *parsed_result,
130 __attribute__((unused)) void *data)
133 struct cmd_help_long_result *res = parsed_result;
135 if (!strcmp(res->section, "all"))
138 if (show_all || !strcmp(res->section, "control")) {
143 "Control forwarding:\n"
144 "-------------------\n\n"
147 " Start packet forwarding with current configuration.\n\n"
150 " Start packet forwarding with current config"
151 " after sending one burst of packets.\n\n"
154 " Stop packet forwarding, and display accumulated"
158 " Quit to prompt.\n\n"
162 if (show_all || !strcmp(res->section, "display")) {
170 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
171 " Display information for port_id, or all.\n\n"
173 "show port X rss reta (size) (mask0,mask1,...)\n"
174 " Display the rss redirection table entry indicated"
175 " by masks on port X. size is used to indicate the"
176 " hardware supported reta size\n\n"
178 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
179 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
180 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
181 " Display the RSS hash functions and RSS hash key"
184 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
185 " Clear information for port_id, or all.\n\n"
187 "show (rxq|txq) info (port_id) (queue_id)\n"
188 " Display information for configured RX/TX queue.\n\n"
190 "show config (rxtx|cores|fwd|txpkts)\n"
191 " Display the given configuration.\n\n"
193 "read rxd (port_id) (queue_id) (rxd_id)\n"
194 " Display an RX descriptor of a port RX queue.\n\n"
196 "read txd (port_id) (queue_id) (txd_id)\n"
197 " Display a TX descriptor of a port TX queue.\n\n"
199 "ddp get list (port_id)\n"
200 " Get ddp profile info list\n\n"
202 "ddp get info (profile_path)\n"
203 " Get ddp profile information.\n\n"
205 "show vf stats (port_id) (vf_id)\n"
206 " Display a VF's statistics.\n\n"
208 "clear vf stats (port_id) (vf_id)\n"
209 " Reset a VF's statistics.\n\n"
211 "show port (port_id) pctype mapping\n"
212 " Get flow ptype to pctype mapping on a port\n\n"
214 "show port meter stats (port_id) (meter_id) (clear)\n"
215 " Get meter stats on a port\n\n"
216 "show port tm cap (port_id)\n"
217 " Display the port TM capability.\n\n"
219 "show port tm level cap (port_id) (level_id)\n"
220 " Display the port TM hierarchical level capability.\n\n"
222 "show port tm node cap (port_id) (node_id)\n"
223 " Display the port TM node capability.\n\n"
225 "show port tm node type (port_id) (node_id)\n"
226 " Display the port TM node type.\n\n"
228 "show port tm node stats (port_id) (node_id) (clear)\n"
229 " Display the port TM node stats.\n\n"
234 if (show_all || !strcmp(res->section, "config")) {
240 "Configuration changes only become active when"
241 " forwarding is started/restarted.\n\n"
244 " Reset forwarding to the default configuration.\n\n"
246 "set verbose (level)\n"
247 " Set the debug verbosity level X.\n\n"
249 "set log global|(type) (level)\n"
250 " Set the log level.\n\n"
253 " Set number of ports.\n\n"
256 " Set number of cores.\n\n"
258 "set coremask (mask)\n"
259 " Set the forwarding cores hexadecimal mask.\n\n"
261 "set portmask (mask)\n"
262 " Set the forwarding ports hexadecimal mask.\n\n"
265 " Set number of packets per burst.\n\n"
267 "set burst tx delay (microseconds) retry (num)\n"
268 " Set the transmit delay time and number of retries,"
269 " effective when retry is enabled.\n\n"
271 "set txpkts (x[,y]*)\n"
272 " Set the length of each segment of TXONLY"
273 " and optionally CSUM packets.\n\n"
275 "set txsplit (off|on|rand)\n"
276 " Set the split policy for the TX packets."
277 " Right now only applicable for CSUM and TXONLY"
280 "set corelist (x[,y]*)\n"
281 " Set the list of forwarding cores.\n\n"
283 "set portlist (x[,y]*)\n"
284 " Set the list of forwarding ports.\n\n"
286 "set tx loopback (port_id) (on|off)\n"
287 " Enable or disable tx loopback.\n\n"
289 "set all queues drop (port_id) (on|off)\n"
290 " Set drop enable bit for all queues.\n\n"
292 "set vf split drop (port_id) (vf_id) (on|off)\n"
293 " Set split drop enable bit for a VF from the PF.\n\n"
295 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
296 " Set MAC antispoof for a VF from the PF.\n\n"
298 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
299 " Enable MACsec offload.\n\n"
301 "set macsec offload (port_id) off\n"
302 " Disable MACsec offload.\n\n"
304 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
305 " Configure MACsec secure connection (SC).\n\n"
307 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
308 " Configure MACsec secure association (SA).\n\n"
310 "set vf broadcast (port_id) (vf_id) (on|off)\n"
311 " Set VF broadcast for a VF from the PF.\n\n"
313 "vlan set strip (on|off) (port_id)\n"
314 " Set the VLAN strip on a port.\n\n"
316 "vlan set stripq (on|off) (port_id,queue_id)\n"
317 " Set the VLAN strip for a queue on a port.\n\n"
319 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
320 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
322 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
323 " Set VLAN insert for a VF from the PF.\n\n"
325 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
326 " Set VLAN antispoof for a VF from the PF.\n\n"
328 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
329 " Set VLAN tag for a VF from the PF.\n\n"
331 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
332 " Set a VF's max bandwidth(Mbps).\n\n"
334 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
335 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
337 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
338 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
340 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
341 " Set some TCs' strict link priority mode on a physical port.\n\n"
343 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
344 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
346 "vlan set filter (on|off) (port_id)\n"
347 " Set the VLAN filter on a port.\n\n"
349 "vlan set qinq (on|off) (port_id)\n"
350 " Set the VLAN QinQ (extended queue in queue)"
353 "vlan set (inner|outer) tpid (value) (port_id)\n"
354 " Set the VLAN TPID for Packet Filtering on"
357 "rx_vlan add (vlan_id|all) (port_id)\n"
358 " Add a vlan_id, or all identifiers, to the set"
359 " of VLAN identifiers filtered by port_id.\n\n"
361 "rx_vlan rm (vlan_id|all) (port_id)\n"
362 " Remove a vlan_id, or all identifiers, from the set"
363 " of VLAN identifiers filtered by port_id.\n\n"
365 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
366 " Add a vlan_id, to the set of VLAN identifiers"
367 "filtered for VF(s) from port_id.\n\n"
369 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
370 " Remove a vlan_id, to the set of VLAN identifiers"
371 "filtered for VF(s) from port_id.\n\n"
373 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
374 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
375 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
376 " add a tunnel filter of a port.\n\n"
378 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
379 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
380 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
381 " remove a tunnel filter of a port.\n\n"
383 "rx_vxlan_port add (udp_port) (port_id)\n"
384 " Add an UDP port for VXLAN packet filter on a port\n\n"
386 "rx_vxlan_port rm (udp_port) (port_id)\n"
387 " Remove an UDP port for VXLAN packet filter on a port\n\n"
389 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
390 " Set hardware insertion of VLAN IDs (single or double VLAN "
391 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
393 "tx_vlan set pvid port_id vlan_id (on|off)\n"
394 " Set port based TX VLAN insertion.\n\n"
396 "tx_vlan reset (port_id)\n"
397 " Disable hardware insertion of a VLAN header in"
398 " packets sent on a port.\n\n"
400 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
401 " Select hardware or software calculation of the"
402 " checksum when transmitting a packet using the"
403 " csum forward engine.\n"
404 " ip|udp|tcp|sctp always concern the inner layer.\n"
405 " outer-ip concerns the outer IP layer in"
406 " case the packet is recognized as a tunnel packet by"
407 " the forward engine (vxlan, gre and ipip are supported)\n"
408 " Please check the NIC datasheet for HW limits.\n\n"
410 "csum parse-tunnel (on|off) (tx_port_id)\n"
411 " If disabled, treat tunnel packets as non-tunneled"
412 " packets (treat inner headers as payload). The port\n"
413 " argument is the port used for TX in csum forward"
416 "csum show (port_id)\n"
417 " Display tx checksum offload configuration\n\n"
419 "tso set (segsize) (portid)\n"
420 " Enable TCP Segmentation Offload in csum forward"
422 " Please check the NIC datasheet for HW limits.\n\n"
425 " Display the status of TCP Segmentation Offload.\n\n"
427 "set port (port_id) gro on|off\n"
428 " Enable or disable Generic Receive Offload in"
429 " csum forwarding engine.\n\n"
431 "show port (port_id) gro\n"
432 " Display GRO configuration.\n\n"
434 "set gro flush (cycles)\n"
435 " Set the cycle to flush GROed packets from"
436 " reassembly tables.\n\n"
438 "set port (port_id) gso (on|off)"
439 " Enable or disable Generic Segmentation Offload in"
440 " csum forwarding engine.\n\n"
442 "set gso segsz (length)\n"
443 " Set max packet length for output GSO segments,"
444 " including packet header and payload.\n\n"
446 "show port (port_id) gso\n"
447 " Show GSO configuration.\n\n"
450 " Set packet forwarding mode.\n\n"
452 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
453 " Add a MAC address on port_id.\n\n"
455 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
456 " Remove a MAC address from port_id.\n\n"
458 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
459 " Set the default MAC address for port_id.\n\n"
461 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
462 " Add a MAC address for a VF on the port.\n\n"
464 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
465 " Set the MAC address for a VF from the PF.\n\n"
467 "set eth-peer (port_id) (peer_addr)\n"
468 " set the peer address for certain port.\n\n"
470 "set port (port_id) uta (mac_address|all) (on|off)\n"
471 " Add/Remove a or all unicast hash filter(s)"
474 "set promisc (port_id|all) (on|off)\n"
475 " Set the promiscuous mode on port_id, or all.\n\n"
477 "set allmulti (port_id|all) (on|off)\n"
478 " Set the allmulti mode on port_id, or all.\n\n"
480 "set vf promisc (port_id) (vf_id) (on|off)\n"
481 " Set unicast promiscuous mode for a VF from the PF.\n\n"
483 "set vf allmulti (port_id) (vf_id) (on|off)\n"
484 " Set multicast promiscuous mode for a VF from the PF.\n\n"
486 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
487 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
488 " (on|off) autoneg (on|off) (port_id)\n"
489 "set flow_ctrl rx (on|off) (portid)\n"
490 "set flow_ctrl tx (on|off) (portid)\n"
491 "set flow_ctrl high_water (high_water) (portid)\n"
492 "set flow_ctrl low_water (low_water) (portid)\n"
493 "set flow_ctrl pause_time (pause_time) (portid)\n"
494 "set flow_ctrl send_xon (send_xon) (portid)\n"
495 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
496 "set flow_ctrl autoneg (on|off) (port_id)\n"
497 " Set the link flow control parameter on a port.\n\n"
499 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
500 " (low_water) (pause_time) (priority) (port_id)\n"
501 " Set the priority flow control parameter on a"
504 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
505 " Set statistics mapping (qmapping 0..15) for RX/TX"
507 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
508 " on port 0 to mapping 5.\n\n"
510 "set xstats-hide-zero on|off\n"
511 " Set the option to hide the zero values"
512 " for xstats display.\n"
514 "set port (port_id) vf (vf_id) rx|tx on|off\n"
515 " Enable/Disable a VF receive/tranmit from a port\n\n"
517 "set port (port_id) vf (vf_id) (mac_addr)"
518 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
519 " Add/Remove unicast or multicast MAC addr filter"
522 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
524 " AUPE:accepts untagged VLAN;"
525 "ROPE:accept unicast hash\n\n"
526 " BAM:accepts broadcast packets;"
527 "MPE:accepts all multicast packets\n\n"
528 " Enable/Disable a VF receive mode of a port\n\n"
530 "set port (port_id) queue (queue_id) rate (rate_num)\n"
531 " Set rate limit for a queue of a port\n\n"
533 "set port (port_id) vf (vf_id) rate (rate_num) "
534 "queue_mask (queue_mask_value)\n"
535 " Set rate limit for queues in VF of a port\n\n"
537 "set port (port_id) mirror-rule (rule_id)"
538 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
539 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
540 " Set pool or vlan type mirror rule on a port.\n"
541 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
542 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
545 "set port (port_id) mirror-rule (rule_id)"
546 " (uplink-mirror|downlink-mirror) dst-pool"
547 " (pool_id) (on|off)\n"
548 " Set uplink or downlink type mirror rule on a port.\n"
549 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
550 " 0 on' enable mirror income traffic to pool 0.\n\n"
552 "reset port (port_id) mirror-rule (rule_id)\n"
553 " Reset a mirror rule.\n\n"
555 "set flush_rx (on|off)\n"
556 " Flush (default) or don't flush RX streams before"
557 " forwarding. Mainly used with PCAP drivers.\n\n"
559 "set bypass mode (normal|bypass|isolate) (port_id)\n"
560 " Set the bypass mode for the lowest port on bypass enabled"
563 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
564 "mode (normal|bypass|isolate) (port_id)\n"
565 " Set the event required to initiate specified bypass mode for"
566 " the lowest port on a bypass enabled NIC where:\n"
567 " timeout = enable bypass after watchdog timeout.\n"
568 " os_on = enable bypass when OS/board is powered on.\n"
569 " os_off = enable bypass when OS/board is powered off.\n"
570 " power_on = enable bypass when power supply is turned on.\n"
571 " power_off = enable bypass when power supply is turned off."
574 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
575 " Set the bypass watchdog timeout to 'n' seconds"
576 " where 0 = instant.\n\n"
578 "show bypass config (port_id)\n"
579 " Show the bypass configuration for a bypass enabled NIC"
580 " using the lowest port on the NIC.\n\n"
582 #ifdef RTE_LIBRTE_PMD_BOND
583 "create bonded device (mode) (socket)\n"
584 " Create a new bonded device with specific bonding mode and socket.\n\n"
586 "add bonding slave (slave_id) (port_id)\n"
587 " Add a slave device to a bonded device.\n\n"
589 "remove bonding slave (slave_id) (port_id)\n"
590 " Remove a slave device from a bonded device.\n\n"
592 "set bonding mode (value) (port_id)\n"
593 " Set the bonding mode on a bonded device.\n\n"
595 "set bonding primary (slave_id) (port_id)\n"
596 " Set the primary slave for a bonded device.\n\n"
598 "show bonding config (port_id)\n"
599 " Show the bonding config for port_id.\n\n"
601 "set bonding mac_addr (port_id) (address)\n"
602 " Set the MAC address of a bonded device.\n\n"
604 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
605 " Set Aggregation mode for IEEE802.3AD (mode 4)"
607 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
608 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
610 "set bonding mon_period (port_id) (value)\n"
611 " Set the bonding link status monitoring polling period in ms.\n\n"
613 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
614 " Enable/disable dedicated queues for LACP control traffic.\n\n"
617 "set link-up port (port_id)\n"
618 " Set link up for a port.\n\n"
620 "set link-down port (port_id)\n"
621 " Set link down for a port.\n\n"
623 "E-tag set insertion on port-tag-id (value)"
624 " port (port_id) vf (vf_id)\n"
625 " Enable E-tag insertion for a VF on a port\n\n"
627 "E-tag set insertion off port (port_id) vf (vf_id)\n"
628 " Disable E-tag insertion for a VF on a port\n\n"
630 "E-tag set stripping (on|off) port (port_id)\n"
631 " Enable/disable E-tag stripping on a port\n\n"
633 "E-tag set forwarding (on|off) port (port_id)\n"
634 " Enable/disable E-tag based forwarding"
637 "E-tag set filter add e-tag-id (value) dst-pool"
638 " (pool_id) port (port_id)\n"
639 " Add an E-tag forwarding filter on a port\n\n"
641 "E-tag set filter del e-tag-id (value) port (port_id)\n"
642 " Delete an E-tag forwarding filter on a port\n\n"
644 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
645 "set port tm hierarchy default (port_id)\n"
646 " Set default traffic Management hierarchy on a port\n\n"
649 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
650 " Load a profile package on a port\n\n"
652 "ddp del (port_id) (backup_profile_path)\n"
653 " Delete a profile package from a port\n\n"
655 "ptype mapping get (port_id) (valid_only)\n"
656 " Get ptype mapping on a port\n\n"
658 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
659 " Replace target with the pkt_type in ptype mapping\n\n"
661 "ptype mapping reset (port_id)\n"
662 " Reset ptype mapping on a port\n\n"
664 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
665 " Update a ptype mapping item on a port\n\n"
667 "set port (port_id) queue-region region_id (value) "
668 "queue_start_index (value) queue_num (value)\n"
669 " Set a queue region on a port\n\n"
671 "set port (port_id) queue-region region_id (value) "
673 " Set a flowtype region index on a port\n\n"
675 "set port (port_id) queue-region UP (value) region_id (value)\n"
676 " Set the mapping of User Priority to "
677 "queue region on a port\n\n"
679 "set port (port_id) queue-region flush (on|off)\n"
680 " flush all queue region related configuration\n\n"
682 "show port meter cap (port_id)\n"
683 " Show port meter capability information\n\n"
685 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
686 " meter profile add - srtcm rfc 2697\n\n"
688 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
689 " meter profile add - trtcm rfc 2698\n\n"
691 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
692 " meter profile add - trtcm rfc 4115\n\n"
694 "del port meter profile (port_id) (profile_id)\n"
695 " meter profile delete\n\n"
697 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
698 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
699 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
700 "(dscp_tbl_entry63)]\n"
703 "enable port meter (port_id) (mtr_id)\n"
706 "disable port meter (port_id) (mtr_id)\n"
709 "del port meter (port_id) (mtr_id)\n"
712 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
713 " meter update meter profile\n\n"
715 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
716 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
717 " update meter dscp table entries\n\n"
719 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
720 "(action0) [(action1) (action2)]\n"
721 " meter update policer action\n\n"
723 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
724 " meter update stats\n\n"
726 "show port (port_id) queue-region\n"
727 " show all queue region related configuration info\n\n"
729 "add port tm node shaper profile (port_id) (shaper_profile_id)"
730 " (tb_rate) (tb_size) (packet_length_adjust)\n"
731 " Add port tm node private shaper profile.\n\n"
733 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
734 " Delete port tm node private shaper profile.\n\n"
736 "add port tm node shared shaper (port_id) (shared_shaper_id)"
737 " (shaper_profile_id)\n"
738 " Add/update port tm node shared shaper.\n\n"
740 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
741 " Delete port tm node shared shaper.\n\n"
743 "set port tm node shaper profile (port_id) (node_id)"
744 " (shaper_profile_id)\n"
745 " Set port tm node shaper profile.\n\n"
747 "add port tm node wred profile (port_id) (wred_profile_id)"
748 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
749 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
750 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
751 " Add port tm node wred profile.\n\n"
753 "del port tm node wred profile (port_id) (wred_profile_id)\n"
754 " Delete port tm node wred profile.\n\n"
756 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
757 " (priority) (weight) (level_id) (shaper_profile_id)"
758 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
759 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
760 " Add port tm nonleaf node.\n\n"
762 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
763 " (priority) (weight) (level_id) (shaper_profile_id)"
764 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
765 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
766 " Add port tm leaf node.\n\n"
768 "del port tm node (port_id) (node_id)\n"
769 " Delete port tm node.\n\n"
771 "set port tm node parent (port_id) (node_id) (parent_node_id)"
772 " (priority) (weight)\n"
773 " Set port tm node parent.\n\n"
775 "suspend port tm node (port_id) (node_id)"
776 " Suspend tm node.\n\n"
778 "resume port tm node (port_id) (node_id)"
779 " Resume tm node.\n\n"
781 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
782 " Commit tm hierarchy.\n\n"
784 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
785 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
786 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
787 " Configure the VXLAN encapsulation for flows.\n\n"
789 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
790 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
791 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
792 " eth-dst (eth-dst)\n"
793 " Configure the VXLAN encapsulation for flows.\n\n"
795 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
796 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
798 " Configure the NVGRE encapsulation for flows.\n\n"
800 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
801 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
802 " eth-src (eth-src) eth-dst (eth-dst)\n"
803 " Configure the NVGRE encapsulation for flows.\n\n"
805 , list_pkt_forwarding_modes()
809 if (show_all || !strcmp(res->section, "ports")) {
815 "----------------\n\n"
817 "port start (port_id|all)\n"
818 " Start all ports or port_id.\n\n"
820 "port stop (port_id|all)\n"
821 " Stop all ports or port_id.\n\n"
823 "port close (port_id|all)\n"
824 " Close all ports or port_id.\n\n"
826 "port attach (ident)\n"
827 " Attach physical or virtual dev by pci address or virtual device name\n\n"
829 "port detach (port_id)\n"
830 " Detach physical or virtual dev by port_id\n\n"
832 "port config (port_id|all)"
833 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
834 " duplex (half|full|auto)\n"
835 " Set speed and duplex for all ports or port_id\n\n"
837 "port config (port_id|all) loopback (mode)\n"
838 " Set loopback mode for all ports or port_id\n\n"
840 "port config all (rxq|txq|rxd|txd) (value)\n"
841 " Set number for rxq/txq/rxd/txd.\n\n"
843 "port config all max-pkt-len (value)\n"
844 " Set the max packet length.\n\n"
846 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
847 "hw-vlan-strip|hw-vlan-extend|drop-en)"
849 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
852 "port config all rss (all|default|ip|tcp|udp|sctp|"
853 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
854 " Set the RSS mode.\n\n"
856 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
857 " Set the RSS redirection table.\n\n"
859 "port config (port_id) dcb vt (on|off) (traffic_class)"
861 " Set the DCB mode.\n\n"
863 "port config all burst (value)\n"
864 " Set the number of packets per burst.\n\n"
866 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
868 " Set the ring prefetch/host/writeback threshold"
869 " for tx/rx queue.\n\n"
871 "port config all (txfreet|txrst|rxfreet) (value)\n"
872 " Set free threshold for rx/tx, or set"
873 " tx rs bit threshold.\n\n"
874 "port config mtu X value\n"
875 " Set the MTU of port X to a given value\n\n"
877 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
878 " Set a rx/tx queue's ring size configuration, the new"
879 " value will take effect after command that (re-)start the port"
880 " or command that setup the specific queue\n\n"
882 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
883 " Start/stop a rx/tx queue of port X. Only take effect"
884 " when port X is started\n\n"
886 "port (port_id) (rxq|txq) (queue_id) setup\n"
887 " Setup a rx/tx queue of port X.\n\n"
889 "port config (port_id|all) l2-tunnel E-tag ether-type"
891 " Set the value of E-tag ether-type.\n\n"
893 "port config (port_id|all) l2-tunnel E-tag"
894 " (enable|disable)\n"
895 " Enable/disable the E-tag support.\n\n"
897 "port config (port_id) pctype mapping reset\n"
898 " Reset flow type to pctype mapping on a port\n\n"
900 "port config (port_id) pctype mapping update"
901 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
902 " Update a flow type to pctype mapping item on a port\n\n"
904 "port config (port_id) pctype (pctype_id) hash_inset|"
905 "fdir_inset|fdir_flx_inset get|set|clear field\n"
907 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
909 "port config (port_id) pctype (pctype_id) hash_inset|"
910 "fdir_inset|fdir_flx_inset clear all"
911 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
913 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
914 " Add/remove UDP tunnel port for tunneling offload\n\n"
918 if (show_all || !strcmp(res->section, "registers")) {
926 "read reg (port_id) (address)\n"
927 " Display value of a port register.\n\n"
929 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
930 " Display a port register bit field.\n\n"
932 "read regbit (port_id) (address) (bit_x)\n"
933 " Display a single port register bit.\n\n"
935 "write reg (port_id) (address) (value)\n"
936 " Set value of a port register.\n\n"
938 "write regfield (port_id) (address) (bit_x) (bit_y)"
940 " Set bit field of a port register.\n\n"
942 "write regbit (port_id) (address) (bit_x) (value)\n"
943 " Set single bit value of a port register.\n\n"
946 if (show_all || !strcmp(res->section, "filters")) {
954 "ethertype_filter (port_id) (add|del)"
955 " (mac_addr|mac_ignr) (mac_address) ethertype"
956 " (ether_type) (drop|fwd) queue (queue_id)\n"
957 " Add/Del an ethertype filter.\n\n"
959 "2tuple_filter (port_id) (add|del)"
960 " dst_port (dst_port_value) protocol (protocol_value)"
961 " mask (mask_value) tcp_flags (tcp_flags_value)"
962 " priority (prio_value) queue (queue_id)\n"
963 " Add/Del a 2tuple filter.\n\n"
965 "5tuple_filter (port_id) (add|del)"
966 " dst_ip (dst_address) src_ip (src_address)"
967 " dst_port (dst_port_value) src_port (src_port_value)"
968 " protocol (protocol_value)"
969 " mask (mask_value) tcp_flags (tcp_flags_value)"
970 " priority (prio_value) queue (queue_id)\n"
971 " Add/Del a 5tuple filter.\n\n"
973 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
974 " Add/Del syn filter.\n\n"
976 "flex_filter (port_id) (add|del) len (len_value)"
977 " bytes (bytes_value) mask (mask_value)"
978 " priority (prio_value) queue (queue_id)\n"
979 " Add/Del a flex filter.\n\n"
981 "flow_director_filter (port_id) mode IP (add|del|update)"
982 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
983 " src (src_ip_address) dst (dst_ip_address)"
984 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
985 " vlan (vlan_value) flexbytes (flexbytes_value)"
986 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
987 " fd_id (fd_id_value)\n"
988 " Add/Del an IP type flow director filter.\n\n"
990 "flow_director_filter (port_id) mode IP (add|del|update)"
991 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
992 " src (src_ip_address) (src_port)"
993 " dst (dst_ip_address) (dst_port)"
994 " tos (tos_value) ttl (ttl_value)"
995 " vlan (vlan_value) flexbytes (flexbytes_value)"
996 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
997 " fd_id (fd_id_value)\n"
998 " Add/Del an UDP/TCP type flow director filter.\n\n"
1000 "flow_director_filter (port_id) mode IP (add|del|update)"
1001 " flow (ipv4-sctp|ipv6-sctp)"
1002 " src (src_ip_address) (src_port)"
1003 " dst (dst_ip_address) (dst_port)"
1004 " tag (verification_tag) "
1005 " tos (tos_value) ttl (ttl_value)"
1006 " vlan (vlan_value)"
1007 " flexbytes (flexbytes_value) (drop|fwd)"
1008 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1009 " Add/Del a SCTP type flow director filter.\n\n"
1011 "flow_director_filter (port_id) mode IP (add|del|update)"
1012 " flow l2_payload ether (ethertype)"
1013 " flexbytes (flexbytes_value) (drop|fwd)"
1014 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1015 " Add/Del a l2 payload type flow director filter.\n\n"
1017 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1018 " mac (mac_address) vlan (vlan_value)"
1019 " flexbytes (flexbytes_value) (drop|fwd)"
1020 " queue (queue_id) fd_id (fd_id_value)\n"
1021 " Add/Del a MAC-VLAN flow director filter.\n\n"
1023 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1024 " mac (mac_address) vlan (vlan_value)"
1025 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1026 " flexbytes (flexbytes_value) (drop|fwd)"
1027 " queue (queue_id) fd_id (fd_id_value)\n"
1028 " Add/Del a Tunnel flow director filter.\n\n"
1030 "flow_director_filter (port_id) mode raw (add|del|update)"
1031 " flow (flow_id) (drop|fwd) queue (queue_id)"
1032 " fd_id (fd_id_value) packet (packet file name)\n"
1033 " Add/Del a raw type flow director filter.\n\n"
1035 "flush_flow_director (port_id)\n"
1036 " Flush all flow director entries of a device.\n\n"
1038 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1039 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1040 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1041 " Set flow director IP mask.\n\n"
1043 "flow_director_mask (port_id) mode MAC-VLAN"
1044 " vlan (vlan_value)\n"
1045 " Set flow director MAC-VLAN mask.\n\n"
1047 "flow_director_mask (port_id) mode Tunnel"
1048 " vlan (vlan_value) mac (mac_value)"
1049 " tunnel-type (tunnel_type_value)"
1050 " tunnel-id (tunnel_id_value)\n"
1051 " Set flow director Tunnel mask.\n\n"
1053 "flow_director_flex_mask (port_id)"
1054 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1055 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1057 " Configure mask of flex payload.\n\n"
1059 "flow_director_flex_payload (port_id)"
1060 " (raw|l2|l3|l4) (config)\n"
1061 " Configure flex payload selection.\n\n"
1063 "get_sym_hash_ena_per_port (port_id)\n"
1064 " get symmetric hash enable configuration per port.\n\n"
1066 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1067 " set symmetric hash enable configuration per port"
1068 " to enable or disable.\n\n"
1070 "get_hash_global_config (port_id)\n"
1071 " Get the global configurations of hash filters.\n\n"
1073 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1074 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1075 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1076 " (enable|disable)\n"
1077 " Set the global configurations of hash filters.\n\n"
1079 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1080 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1081 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1082 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1083 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1084 "ipv6-next-header|udp-src-port|udp-dst-port|"
1085 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1086 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1087 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1088 "fld-8th|none) (select|add)\n"
1089 " Set the input set for hash.\n\n"
1091 "set_fdir_input_set (port_id) "
1092 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1093 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1094 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1095 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1096 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1097 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1098 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1100 " Set the input set for FDir.\n\n"
1102 "flow validate {port_id}"
1103 " [group {group_id}] [priority {level}]"
1104 " [ingress] [egress]"
1105 " pattern {item} [/ {item} [...]] / end"
1106 " actions {action} [/ {action} [...]] / end\n"
1107 " Check whether a flow rule can be created.\n\n"
1109 "flow create {port_id}"
1110 " [group {group_id}] [priority {level}]"
1111 " [ingress] [egress]"
1112 " pattern {item} [/ {item} [...]] / end"
1113 " actions {action} [/ {action} [...]] / end\n"
1114 " Create a flow rule.\n\n"
1116 "flow destroy {port_id} rule {rule_id} [...]\n"
1117 " Destroy specific flow rules.\n\n"
1119 "flow flush {port_id}\n"
1120 " Destroy all flow rules.\n\n"
1122 "flow query {port_id} {rule_id} {action}\n"
1123 " Query an existing flow rule.\n\n"
1125 "flow list {port_id} [group {group_id}] [...]\n"
1126 " List existing flow rules sorted by priority,"
1127 " filtered by group identifiers.\n\n"
1129 "flow isolate {port_id} {boolean}\n"
1130 " Restrict ingress traffic to the defined"
1136 cmdline_parse_token_string_t cmd_help_long_help =
1137 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1139 cmdline_parse_token_string_t cmd_help_long_section =
1140 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1141 "all#control#display#config#"
1142 "ports#registers#filters");
1144 cmdline_parse_inst_t cmd_help_long = {
1145 .f = cmd_help_long_parsed,
1147 .help_str = "help all|control|display|config|ports|register|filters: "
1150 (void *)&cmd_help_long_help,
1151 (void *)&cmd_help_long_section,
1157 /* *** start/stop/close all ports *** */
1158 struct cmd_operate_port_result {
1159 cmdline_fixed_string_t keyword;
1160 cmdline_fixed_string_t name;
1161 cmdline_fixed_string_t value;
1164 static void cmd_operate_port_parsed(void *parsed_result,
1165 __attribute__((unused)) struct cmdline *cl,
1166 __attribute__((unused)) void *data)
1168 struct cmd_operate_port_result *res = parsed_result;
1170 if (!strcmp(res->name, "start"))
1171 start_port(RTE_PORT_ALL);
1172 else if (!strcmp(res->name, "stop"))
1173 stop_port(RTE_PORT_ALL);
1174 else if (!strcmp(res->name, "close"))
1175 close_port(RTE_PORT_ALL);
1176 else if (!strcmp(res->name, "reset"))
1177 reset_port(RTE_PORT_ALL);
1179 printf("Unknown parameter\n");
1182 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1183 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1185 cmdline_parse_token_string_t cmd_operate_port_all_port =
1186 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1187 "start#stop#close#reset");
1188 cmdline_parse_token_string_t cmd_operate_port_all_all =
1189 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1191 cmdline_parse_inst_t cmd_operate_port = {
1192 .f = cmd_operate_port_parsed,
1194 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1196 (void *)&cmd_operate_port_all_cmd,
1197 (void *)&cmd_operate_port_all_port,
1198 (void *)&cmd_operate_port_all_all,
1203 /* *** start/stop/close specific port *** */
1204 struct cmd_operate_specific_port_result {
1205 cmdline_fixed_string_t keyword;
1206 cmdline_fixed_string_t name;
1210 static void cmd_operate_specific_port_parsed(void *parsed_result,
1211 __attribute__((unused)) struct cmdline *cl,
1212 __attribute__((unused)) void *data)
1214 struct cmd_operate_specific_port_result *res = parsed_result;
1216 if (!strcmp(res->name, "start"))
1217 start_port(res->value);
1218 else if (!strcmp(res->name, "stop"))
1219 stop_port(res->value);
1220 else if (!strcmp(res->name, "close"))
1221 close_port(res->value);
1222 else if (!strcmp(res->name, "reset"))
1223 reset_port(res->value);
1225 printf("Unknown parameter\n");
1228 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1229 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1231 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1232 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1233 name, "start#stop#close#reset");
1234 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1235 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1238 cmdline_parse_inst_t cmd_operate_specific_port = {
1239 .f = cmd_operate_specific_port_parsed,
1241 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1243 (void *)&cmd_operate_specific_port_cmd,
1244 (void *)&cmd_operate_specific_port_port,
1245 (void *)&cmd_operate_specific_port_id,
1250 /* *** attach a specified port *** */
1251 struct cmd_operate_attach_port_result {
1252 cmdline_fixed_string_t port;
1253 cmdline_fixed_string_t keyword;
1254 cmdline_fixed_string_t identifier;
1257 static void cmd_operate_attach_port_parsed(void *parsed_result,
1258 __attribute__((unused)) struct cmdline *cl,
1259 __attribute__((unused)) void *data)
1261 struct cmd_operate_attach_port_result *res = parsed_result;
1263 if (!strcmp(res->keyword, "attach"))
1264 attach_port(res->identifier);
1266 printf("Unknown parameter\n");
1269 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1270 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1272 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1273 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1275 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1279 cmdline_parse_inst_t cmd_operate_attach_port = {
1280 .f = cmd_operate_attach_port_parsed,
1282 .help_str = "port attach <identifier>: "
1283 "(identifier: pci address or virtual dev name)",
1285 (void *)&cmd_operate_attach_port_port,
1286 (void *)&cmd_operate_attach_port_keyword,
1287 (void *)&cmd_operate_attach_port_identifier,
1292 /* *** detach a specified port *** */
1293 struct cmd_operate_detach_port_result {
1294 cmdline_fixed_string_t port;
1295 cmdline_fixed_string_t keyword;
1299 static void cmd_operate_detach_port_parsed(void *parsed_result,
1300 __attribute__((unused)) struct cmdline *cl,
1301 __attribute__((unused)) void *data)
1303 struct cmd_operate_detach_port_result *res = parsed_result;
1305 if (!strcmp(res->keyword, "detach"))
1306 detach_port(res->port_id);
1308 printf("Unknown parameter\n");
1311 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1312 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1314 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1315 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1317 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1318 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1321 cmdline_parse_inst_t cmd_operate_detach_port = {
1322 .f = cmd_operate_detach_port_parsed,
1324 .help_str = "port detach <port_id>",
1326 (void *)&cmd_operate_detach_port_port,
1327 (void *)&cmd_operate_detach_port_keyword,
1328 (void *)&cmd_operate_detach_port_port_id,
1333 /* *** configure speed for all ports *** */
1334 struct cmd_config_speed_all {
1335 cmdline_fixed_string_t port;
1336 cmdline_fixed_string_t keyword;
1337 cmdline_fixed_string_t all;
1338 cmdline_fixed_string_t item1;
1339 cmdline_fixed_string_t item2;
1340 cmdline_fixed_string_t value1;
1341 cmdline_fixed_string_t value2;
1345 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1350 if (!strcmp(duplexstr, "half")) {
1351 duplex = ETH_LINK_HALF_DUPLEX;
1352 } else if (!strcmp(duplexstr, "full")) {
1353 duplex = ETH_LINK_FULL_DUPLEX;
1354 } else if (!strcmp(duplexstr, "auto")) {
1355 duplex = ETH_LINK_FULL_DUPLEX;
1357 printf("Unknown duplex parameter\n");
1361 if (!strcmp(speedstr, "10")) {
1362 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1363 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1364 } else if (!strcmp(speedstr, "100")) {
1365 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1366 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1368 if (duplex != ETH_LINK_FULL_DUPLEX) {
1369 printf("Invalid speed/duplex parameters\n");
1372 if (!strcmp(speedstr, "1000")) {
1373 *speed = ETH_LINK_SPEED_1G;
1374 } else if (!strcmp(speedstr, "10000")) {
1375 *speed = ETH_LINK_SPEED_10G;
1376 } else if (!strcmp(speedstr, "25000")) {
1377 *speed = ETH_LINK_SPEED_25G;
1378 } else if (!strcmp(speedstr, "40000")) {
1379 *speed = ETH_LINK_SPEED_40G;
1380 } else if (!strcmp(speedstr, "50000")) {
1381 *speed = ETH_LINK_SPEED_50G;
1382 } else if (!strcmp(speedstr, "100000")) {
1383 *speed = ETH_LINK_SPEED_100G;
1384 } else if (!strcmp(speedstr, "auto")) {
1385 *speed = ETH_LINK_SPEED_AUTONEG;
1387 printf("Unknown speed parameter\n");
1396 cmd_config_speed_all_parsed(void *parsed_result,
1397 __attribute__((unused)) struct cmdline *cl,
1398 __attribute__((unused)) void *data)
1400 struct cmd_config_speed_all *res = parsed_result;
1401 uint32_t link_speed;
1404 if (!all_ports_stopped()) {
1405 printf("Please stop all ports first\n");
1409 if (parse_and_check_speed_duplex(res->value1, res->value2,
1413 RTE_ETH_FOREACH_DEV(pid) {
1414 ports[pid].dev_conf.link_speeds = link_speed;
1417 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1420 cmdline_parse_token_string_t cmd_config_speed_all_port =
1421 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1422 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1425 cmdline_parse_token_string_t cmd_config_speed_all_all =
1426 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1427 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1428 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1429 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1430 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1431 "10#100#1000#10000#25000#40000#50000#100000#auto");
1432 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1433 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1434 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1435 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1438 cmdline_parse_inst_t cmd_config_speed_all = {
1439 .f = cmd_config_speed_all_parsed,
1441 .help_str = "port config all speed "
1442 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1445 (void *)&cmd_config_speed_all_port,
1446 (void *)&cmd_config_speed_all_keyword,
1447 (void *)&cmd_config_speed_all_all,
1448 (void *)&cmd_config_speed_all_item1,
1449 (void *)&cmd_config_speed_all_value1,
1450 (void *)&cmd_config_speed_all_item2,
1451 (void *)&cmd_config_speed_all_value2,
1456 /* *** configure speed for specific port *** */
1457 struct cmd_config_speed_specific {
1458 cmdline_fixed_string_t port;
1459 cmdline_fixed_string_t keyword;
1461 cmdline_fixed_string_t item1;
1462 cmdline_fixed_string_t item2;
1463 cmdline_fixed_string_t value1;
1464 cmdline_fixed_string_t value2;
1468 cmd_config_speed_specific_parsed(void *parsed_result,
1469 __attribute__((unused)) struct cmdline *cl,
1470 __attribute__((unused)) void *data)
1472 struct cmd_config_speed_specific *res = parsed_result;
1473 uint32_t link_speed;
1475 if (!all_ports_stopped()) {
1476 printf("Please stop all ports first\n");
1480 if (port_id_is_invalid(res->id, ENABLED_WARN))
1483 if (parse_and_check_speed_duplex(res->value1, res->value2,
1487 ports[res->id].dev_conf.link_speeds = link_speed;
1489 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1493 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1496 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1497 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1499 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1500 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1501 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1502 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1504 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1505 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1506 "10#100#1000#10000#25000#40000#50000#100000#auto");
1507 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1508 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1510 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1511 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1514 cmdline_parse_inst_t cmd_config_speed_specific = {
1515 .f = cmd_config_speed_specific_parsed,
1517 .help_str = "port config <port_id> speed "
1518 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1521 (void *)&cmd_config_speed_specific_port,
1522 (void *)&cmd_config_speed_specific_keyword,
1523 (void *)&cmd_config_speed_specific_id,
1524 (void *)&cmd_config_speed_specific_item1,
1525 (void *)&cmd_config_speed_specific_value1,
1526 (void *)&cmd_config_speed_specific_item2,
1527 (void *)&cmd_config_speed_specific_value2,
1532 /* *** configure loopback for all ports *** */
1533 struct cmd_config_loopback_all {
1534 cmdline_fixed_string_t port;
1535 cmdline_fixed_string_t keyword;
1536 cmdline_fixed_string_t all;
1537 cmdline_fixed_string_t item;
1542 cmd_config_loopback_all_parsed(void *parsed_result,
1543 __attribute__((unused)) struct cmdline *cl,
1544 __attribute__((unused)) void *data)
1546 struct cmd_config_loopback_all *res = parsed_result;
1549 if (!all_ports_stopped()) {
1550 printf("Please stop all ports first\n");
1554 RTE_ETH_FOREACH_DEV(pid) {
1555 ports[pid].dev_conf.lpbk_mode = res->mode;
1558 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1561 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1563 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1566 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1568 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1571 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1572 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1574 cmdline_parse_inst_t cmd_config_loopback_all = {
1575 .f = cmd_config_loopback_all_parsed,
1577 .help_str = "port config all loopback <mode>",
1579 (void *)&cmd_config_loopback_all_port,
1580 (void *)&cmd_config_loopback_all_keyword,
1581 (void *)&cmd_config_loopback_all_all,
1582 (void *)&cmd_config_loopback_all_item,
1583 (void *)&cmd_config_loopback_all_mode,
1588 /* *** configure loopback for specific port *** */
1589 struct cmd_config_loopback_specific {
1590 cmdline_fixed_string_t port;
1591 cmdline_fixed_string_t keyword;
1593 cmdline_fixed_string_t item;
1598 cmd_config_loopback_specific_parsed(void *parsed_result,
1599 __attribute__((unused)) struct cmdline *cl,
1600 __attribute__((unused)) void *data)
1602 struct cmd_config_loopback_specific *res = parsed_result;
1604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1607 if (!port_is_stopped(res->port_id)) {
1608 printf("Please stop port %u first\n", res->port_id);
1612 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1614 cmd_reconfig_device_queue(res->port_id, 1, 1);
1618 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1619 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1621 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1622 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1624 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1625 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1627 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1630 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1631 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1634 cmdline_parse_inst_t cmd_config_loopback_specific = {
1635 .f = cmd_config_loopback_specific_parsed,
1637 .help_str = "port config <port_id> loopback <mode>",
1639 (void *)&cmd_config_loopback_specific_port,
1640 (void *)&cmd_config_loopback_specific_keyword,
1641 (void *)&cmd_config_loopback_specific_id,
1642 (void *)&cmd_config_loopback_specific_item,
1643 (void *)&cmd_config_loopback_specific_mode,
1648 /* *** configure txq/rxq, txd/rxd *** */
1649 struct cmd_config_rx_tx {
1650 cmdline_fixed_string_t port;
1651 cmdline_fixed_string_t keyword;
1652 cmdline_fixed_string_t all;
1653 cmdline_fixed_string_t name;
1658 cmd_config_rx_tx_parsed(void *parsed_result,
1659 __attribute__((unused)) struct cmdline *cl,
1660 __attribute__((unused)) void *data)
1662 struct cmd_config_rx_tx *res = parsed_result;
1664 if (!all_ports_stopped()) {
1665 printf("Please stop all ports first\n");
1668 if (!strcmp(res->name, "rxq")) {
1669 if (!res->value && !nb_txq) {
1670 printf("Warning: Either rx or tx queues should be non zero\n");
1673 if (check_nb_rxq(res->value) != 0)
1675 nb_rxq = res->value;
1677 else if (!strcmp(res->name, "txq")) {
1678 if (!res->value && !nb_rxq) {
1679 printf("Warning: Either rx or tx queues should be non zero\n");
1682 if (check_nb_txq(res->value) != 0)
1684 nb_txq = res->value;
1686 else if (!strcmp(res->name, "rxd")) {
1687 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1688 printf("rxd %d invalid - must be > 0 && <= %d\n",
1689 res->value, RTE_TEST_RX_DESC_MAX);
1692 nb_rxd = res->value;
1693 } else if (!strcmp(res->name, "txd")) {
1694 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1695 printf("txd %d invalid - must be > 0 && <= %d\n",
1696 res->value, RTE_TEST_TX_DESC_MAX);
1699 nb_txd = res->value;
1701 printf("Unknown parameter\n");
1709 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1712 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1713 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1714 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1716 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1718 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1719 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1721 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1722 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1724 cmdline_parse_inst_t cmd_config_rx_tx = {
1725 .f = cmd_config_rx_tx_parsed,
1727 .help_str = "port config all rxq|txq|rxd|txd <value>",
1729 (void *)&cmd_config_rx_tx_port,
1730 (void *)&cmd_config_rx_tx_keyword,
1731 (void *)&cmd_config_rx_tx_all,
1732 (void *)&cmd_config_rx_tx_name,
1733 (void *)&cmd_config_rx_tx_value,
1738 /* *** config max packet length *** */
1739 struct cmd_config_max_pkt_len_result {
1740 cmdline_fixed_string_t port;
1741 cmdline_fixed_string_t keyword;
1742 cmdline_fixed_string_t all;
1743 cmdline_fixed_string_t name;
1748 cmd_config_max_pkt_len_parsed(void *parsed_result,
1749 __attribute__((unused)) struct cmdline *cl,
1750 __attribute__((unused)) void *data)
1752 struct cmd_config_max_pkt_len_result *res = parsed_result;
1755 if (!all_ports_stopped()) {
1756 printf("Please stop all ports first\n");
1760 RTE_ETH_FOREACH_DEV(pid) {
1761 struct rte_port *port = &ports[pid];
1762 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1764 if (!strcmp(res->name, "max-pkt-len")) {
1765 if (res->value < ETHER_MIN_LEN) {
1766 printf("max-pkt-len can not be less than %d\n",
1770 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1773 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1774 if (res->value > ETHER_MAX_LEN)
1775 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1777 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1778 port->dev_conf.rxmode.offloads = rx_offloads;
1780 printf("Unknown parameter\n");
1787 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1790 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1793 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1796 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1799 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1802 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1803 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1806 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1807 .f = cmd_config_max_pkt_len_parsed,
1809 .help_str = "port config all max-pkt-len <value>",
1811 (void *)&cmd_config_max_pkt_len_port,
1812 (void *)&cmd_config_max_pkt_len_keyword,
1813 (void *)&cmd_config_max_pkt_len_all,
1814 (void *)&cmd_config_max_pkt_len_name,
1815 (void *)&cmd_config_max_pkt_len_value,
1820 /* *** configure port MTU *** */
1821 struct cmd_config_mtu_result {
1822 cmdline_fixed_string_t port;
1823 cmdline_fixed_string_t keyword;
1824 cmdline_fixed_string_t mtu;
1830 cmd_config_mtu_parsed(void *parsed_result,
1831 __attribute__((unused)) struct cmdline *cl,
1832 __attribute__((unused)) void *data)
1834 struct cmd_config_mtu_result *res = parsed_result;
1836 if (res->value < ETHER_MIN_LEN) {
1837 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1840 port_mtu_set(res->port_id, res->value);
1843 cmdline_parse_token_string_t cmd_config_mtu_port =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1846 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1849 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1852 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1853 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1854 cmdline_parse_token_num_t cmd_config_mtu_value =
1855 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1857 cmdline_parse_inst_t cmd_config_mtu = {
1858 .f = cmd_config_mtu_parsed,
1860 .help_str = "port config mtu <port_id> <value>",
1862 (void *)&cmd_config_mtu_port,
1863 (void *)&cmd_config_mtu_keyword,
1864 (void *)&cmd_config_mtu_mtu,
1865 (void *)&cmd_config_mtu_port_id,
1866 (void *)&cmd_config_mtu_value,
1871 /* *** configure rx mode *** */
1872 struct cmd_config_rx_mode_flag {
1873 cmdline_fixed_string_t port;
1874 cmdline_fixed_string_t keyword;
1875 cmdline_fixed_string_t all;
1876 cmdline_fixed_string_t name;
1877 cmdline_fixed_string_t value;
1881 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1882 __attribute__((unused)) struct cmdline *cl,
1883 __attribute__((unused)) void *data)
1885 struct cmd_config_rx_mode_flag *res = parsed_result;
1888 if (!all_ports_stopped()) {
1889 printf("Please stop all ports first\n");
1893 RTE_ETH_FOREACH_DEV(pid) {
1894 struct rte_port *port;
1895 uint64_t rx_offloads;
1898 rx_offloads = port->dev_conf.rxmode.offloads;
1899 if (!strcmp(res->name, "crc-strip")) {
1900 if (!strcmp(res->value, "on"))
1901 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1902 else if (!strcmp(res->value, "off"))
1903 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1905 printf("Unknown parameter\n");
1908 } else if (!strcmp(res->name, "scatter")) {
1909 if (!strcmp(res->value, "on")) {
1910 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1911 } else if (!strcmp(res->value, "off")) {
1912 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1914 printf("Unknown parameter\n");
1917 } else if (!strcmp(res->name, "rx-cksum")) {
1918 if (!strcmp(res->value, "on"))
1919 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1920 else if (!strcmp(res->value, "off"))
1921 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1923 printf("Unknown parameter\n");
1926 } else if (!strcmp(res->name, "rx-timestamp")) {
1927 if (!strcmp(res->value, "on"))
1928 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1929 else if (!strcmp(res->value, "off"))
1930 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1932 printf("Unknown parameter\n");
1935 } else if (!strcmp(res->name, "hw-vlan")) {
1936 if (!strcmp(res->value, "on")) {
1937 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1938 DEV_RX_OFFLOAD_VLAN_STRIP);
1939 } else if (!strcmp(res->value, "off")) {
1940 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1941 DEV_RX_OFFLOAD_VLAN_STRIP);
1943 printf("Unknown parameter\n");
1946 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1947 if (!strcmp(res->value, "on"))
1948 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1949 else if (!strcmp(res->value, "off"))
1950 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1952 printf("Unknown parameter\n");
1955 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1956 if (!strcmp(res->value, "on"))
1957 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1958 else if (!strcmp(res->value, "off"))
1959 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1961 printf("Unknown parameter\n");
1964 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1965 if (!strcmp(res->value, "on"))
1966 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1967 else if (!strcmp(res->value, "off"))
1968 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1970 printf("Unknown parameter\n");
1973 } else if (!strcmp(res->name, "drop-en")) {
1974 if (!strcmp(res->value, "on"))
1976 else if (!strcmp(res->value, "off"))
1979 printf("Unknown parameter\n");
1983 printf("Unknown parameter\n");
1986 port->dev_conf.rxmode.offloads = rx_offloads;
1991 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1994 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1995 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1996 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1997 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1999 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2001 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2003 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2004 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2005 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2006 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2009 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2010 .f = cmd_config_rx_mode_flag_parsed,
2012 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2013 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2015 (void *)&cmd_config_rx_mode_flag_port,
2016 (void *)&cmd_config_rx_mode_flag_keyword,
2017 (void *)&cmd_config_rx_mode_flag_all,
2018 (void *)&cmd_config_rx_mode_flag_name,
2019 (void *)&cmd_config_rx_mode_flag_value,
2024 /* *** configure rss *** */
2025 struct cmd_config_rss {
2026 cmdline_fixed_string_t port;
2027 cmdline_fixed_string_t keyword;
2028 cmdline_fixed_string_t all;
2029 cmdline_fixed_string_t name;
2030 cmdline_fixed_string_t value;
2034 cmd_config_rss_parsed(void *parsed_result,
2035 __attribute__((unused)) struct cmdline *cl,
2036 __attribute__((unused)) void *data)
2038 struct cmd_config_rss *res = parsed_result;
2039 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2040 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2041 int use_default = 0;
2042 int all_updated = 1;
2046 if (!strcmp(res->value, "all"))
2047 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2048 ETH_RSS_UDP | ETH_RSS_SCTP |
2050 else if (!strcmp(res->value, "ip"))
2051 rss_conf.rss_hf = ETH_RSS_IP;
2052 else if (!strcmp(res->value, "udp"))
2053 rss_conf.rss_hf = ETH_RSS_UDP;
2054 else if (!strcmp(res->value, "tcp"))
2055 rss_conf.rss_hf = ETH_RSS_TCP;
2056 else if (!strcmp(res->value, "sctp"))
2057 rss_conf.rss_hf = ETH_RSS_SCTP;
2058 else if (!strcmp(res->value, "ether"))
2059 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2060 else if (!strcmp(res->value, "port"))
2061 rss_conf.rss_hf = ETH_RSS_PORT;
2062 else if (!strcmp(res->value, "vxlan"))
2063 rss_conf.rss_hf = ETH_RSS_VXLAN;
2064 else if (!strcmp(res->value, "geneve"))
2065 rss_conf.rss_hf = ETH_RSS_GENEVE;
2066 else if (!strcmp(res->value, "nvgre"))
2067 rss_conf.rss_hf = ETH_RSS_NVGRE;
2068 else if (!strcmp(res->value, "none"))
2069 rss_conf.rss_hf = 0;
2070 else if (!strcmp(res->value, "default"))
2072 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2073 atoi(res->value) < 64)
2074 rss_conf.rss_hf = 1ULL << atoi(res->value);
2076 printf("Unknown parameter\n");
2079 rss_conf.rss_key = NULL;
2080 /* Update global configuration for RSS types. */
2081 RTE_ETH_FOREACH_DEV(i) {
2082 struct rte_eth_rss_conf local_rss_conf;
2084 rte_eth_dev_info_get(i, &dev_info);
2086 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2088 local_rss_conf = rss_conf;
2089 local_rss_conf.rss_hf = rss_conf.rss_hf &
2090 dev_info.flow_type_rss_offloads;
2091 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2092 printf("Port %u modified RSS hash function based on hardware support,"
2093 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2094 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2096 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2099 printf("Configuration of RSS hash at ethernet port %d "
2100 "failed with error (%d): %s.\n",
2101 i, -diag, strerror(-diag));
2104 if (all_updated && !use_default)
2105 rss_hf = rss_conf.rss_hf;
2108 cmdline_parse_token_string_t cmd_config_rss_port =
2109 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2110 cmdline_parse_token_string_t cmd_config_rss_keyword =
2111 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2112 cmdline_parse_token_string_t cmd_config_rss_all =
2113 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2114 cmdline_parse_token_string_t cmd_config_rss_name =
2115 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2116 cmdline_parse_token_string_t cmd_config_rss_value =
2117 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2119 cmdline_parse_inst_t cmd_config_rss = {
2120 .f = cmd_config_rss_parsed,
2122 .help_str = "port config all rss "
2123 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2125 (void *)&cmd_config_rss_port,
2126 (void *)&cmd_config_rss_keyword,
2127 (void *)&cmd_config_rss_all,
2128 (void *)&cmd_config_rss_name,
2129 (void *)&cmd_config_rss_value,
2134 /* *** configure rss hash key *** */
2135 struct cmd_config_rss_hash_key {
2136 cmdline_fixed_string_t port;
2137 cmdline_fixed_string_t config;
2139 cmdline_fixed_string_t rss_hash_key;
2140 cmdline_fixed_string_t rss_type;
2141 cmdline_fixed_string_t key;
2145 hexa_digit_to_value(char hexa_digit)
2147 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2148 return (uint8_t) (hexa_digit - '0');
2149 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2150 return (uint8_t) ((hexa_digit - 'a') + 10);
2151 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2152 return (uint8_t) ((hexa_digit - 'A') + 10);
2153 /* Invalid hexa digit */
2158 parse_and_check_key_hexa_digit(char *key, int idx)
2162 hexa_v = hexa_digit_to_value(key[idx]);
2164 printf("invalid key: character %c at position %d is not a "
2165 "valid hexa digit\n", key[idx], idx);
2170 cmd_config_rss_hash_key_parsed(void *parsed_result,
2171 __attribute__((unused)) struct cmdline *cl,
2172 __attribute__((unused)) void *data)
2174 struct cmd_config_rss_hash_key *res = parsed_result;
2175 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2179 struct rte_eth_dev_info dev_info;
2180 uint8_t hash_key_size;
2183 memset(&dev_info, 0, sizeof(dev_info));
2184 rte_eth_dev_info_get(res->port_id, &dev_info);
2185 if (dev_info.hash_key_size > 0 &&
2186 dev_info.hash_key_size <= sizeof(hash_key))
2187 hash_key_size = dev_info.hash_key_size;
2189 printf("dev_info did not provide a valid hash key size\n");
2192 /* Check the length of the RSS hash key */
2193 key_len = strlen(res->key);
2194 if (key_len != (hash_key_size * 2)) {
2195 printf("key length: %d invalid - key must be a string of %d"
2196 " hexa-decimal numbers\n",
2197 (int) key_len, hash_key_size * 2);
2200 /* Translate RSS hash key into binary representation */
2201 for (i = 0; i < hash_key_size; i++) {
2202 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2205 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2208 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2210 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2214 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2215 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2216 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2217 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2219 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2220 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2221 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2222 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2223 rss_hash_key, "rss-hash-key");
2224 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2225 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2226 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2227 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2228 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2229 "ipv6-tcp-ex#ipv6-udp-ex");
2230 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2231 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2233 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2234 .f = cmd_config_rss_hash_key_parsed,
2236 .help_str = "port config <port_id> rss-hash-key "
2237 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2238 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2239 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2240 "<string of hex digits (variable length, NIC dependent)>",
2242 (void *)&cmd_config_rss_hash_key_port,
2243 (void *)&cmd_config_rss_hash_key_config,
2244 (void *)&cmd_config_rss_hash_key_port_id,
2245 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2246 (void *)&cmd_config_rss_hash_key_rss_type,
2247 (void *)&cmd_config_rss_hash_key_value,
2252 /* *** configure port rxq/txq ring size *** */
2253 struct cmd_config_rxtx_ring_size {
2254 cmdline_fixed_string_t port;
2255 cmdline_fixed_string_t config;
2257 cmdline_fixed_string_t rxtxq;
2259 cmdline_fixed_string_t rsize;
2264 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2265 __attribute__((unused)) struct cmdline *cl,
2266 __attribute__((unused)) void *data)
2268 struct cmd_config_rxtx_ring_size *res = parsed_result;
2269 struct rte_port *port;
2272 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2275 if (res->portid == (portid_t)RTE_PORT_ALL) {
2276 printf("Invalid port id\n");
2280 port = &ports[res->portid];
2282 if (!strcmp(res->rxtxq, "rxq"))
2284 else if (!strcmp(res->rxtxq, "txq"))
2287 printf("Unknown parameter\n");
2291 if (isrx && rx_queue_id_is_invalid(res->qid))
2293 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2296 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2297 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2303 port->nb_rx_desc[res->qid] = res->size;
2305 port->nb_tx_desc[res->qid] = res->size;
2307 cmd_reconfig_device_queue(res->portid, 0, 1);
2310 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2311 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2313 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2316 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2317 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2319 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2320 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2322 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2323 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2325 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2326 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2327 rsize, "ring_size");
2328 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2329 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2332 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2333 .f = cmd_config_rxtx_ring_size_parsed,
2335 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2337 (void *)&cmd_config_rxtx_ring_size_port,
2338 (void *)&cmd_config_rxtx_ring_size_config,
2339 (void *)&cmd_config_rxtx_ring_size_portid,
2340 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2341 (void *)&cmd_config_rxtx_ring_size_qid,
2342 (void *)&cmd_config_rxtx_ring_size_rsize,
2343 (void *)&cmd_config_rxtx_ring_size_size,
2348 /* *** configure port rxq/txq start/stop *** */
2349 struct cmd_config_rxtx_queue {
2350 cmdline_fixed_string_t port;
2352 cmdline_fixed_string_t rxtxq;
2354 cmdline_fixed_string_t opname;
2358 cmd_config_rxtx_queue_parsed(void *parsed_result,
2359 __attribute__((unused)) struct cmdline *cl,
2360 __attribute__((unused)) void *data)
2362 struct cmd_config_rxtx_queue *res = parsed_result;
2367 if (test_done == 0) {
2368 printf("Please stop forwarding first\n");
2372 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2375 if (port_is_started(res->portid) != 1) {
2376 printf("Please start port %u first\n", res->portid);
2380 if (!strcmp(res->rxtxq, "rxq"))
2382 else if (!strcmp(res->rxtxq, "txq"))
2385 printf("Unknown parameter\n");
2389 if (isrx && rx_queue_id_is_invalid(res->qid))
2391 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2394 if (!strcmp(res->opname, "start"))
2396 else if (!strcmp(res->opname, "stop"))
2399 printf("Unknown parameter\n");
2403 if (isstart && isrx)
2404 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2405 else if (!isstart && isrx)
2406 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2407 else if (isstart && !isrx)
2408 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2410 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2412 if (ret == -ENOTSUP)
2413 printf("Function not supported in PMD driver\n");
2416 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2417 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2418 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2419 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2420 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2421 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2422 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2423 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2424 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2425 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2428 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2429 .f = cmd_config_rxtx_queue_parsed,
2431 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2433 (void *)&cmd_config_rxtx_queue_port,
2434 (void *)&cmd_config_rxtx_queue_portid,
2435 (void *)&cmd_config_rxtx_queue_rxtxq,
2436 (void *)&cmd_config_rxtx_queue_qid,
2437 (void *)&cmd_config_rxtx_queue_opname,
2442 /* *** configure port rxq/txq setup *** */
2443 struct cmd_setup_rxtx_queue {
2444 cmdline_fixed_string_t port;
2446 cmdline_fixed_string_t rxtxq;
2448 cmdline_fixed_string_t setup;
2451 /* Common CLI fields for queue setup */
2452 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2453 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2454 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2455 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2456 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2457 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2458 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2459 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2460 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2461 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2464 cmd_setup_rxtx_queue_parsed(
2465 void *parsed_result,
2466 __attribute__((unused)) struct cmdline *cl,
2467 __attribute__((unused)) void *data)
2469 struct cmd_setup_rxtx_queue *res = parsed_result;
2470 struct rte_port *port;
2471 struct rte_mempool *mp;
2472 unsigned int socket_id;
2476 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2479 if (res->portid == (portid_t)RTE_PORT_ALL) {
2480 printf("Invalid port id\n");
2484 if (!strcmp(res->rxtxq, "rxq"))
2486 else if (!strcmp(res->rxtxq, "txq"))
2489 printf("Unknown parameter\n");
2493 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2494 printf("Invalid rx queue\n");
2496 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2497 printf("Invalid tx queue\n");
2501 port = &ports[res->portid];
2503 socket_id = rxring_numa[res->portid];
2504 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2505 socket_id = port->socket_id;
2507 mp = mbuf_pool_find(socket_id);
2509 printf("Failed to setup RX queue: "
2510 "No mempool allocation"
2511 " on the socket %d\n",
2512 rxring_numa[res->portid]);
2515 ret = rte_eth_rx_queue_setup(res->portid,
2517 port->nb_rx_desc[res->qid],
2519 &port->rx_conf[res->qid],
2522 printf("Failed to setup RX queue\n");
2524 socket_id = txring_numa[res->portid];
2525 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2526 socket_id = port->socket_id;
2528 ret = rte_eth_tx_queue_setup(res->portid,
2530 port->nb_tx_desc[res->qid],
2532 &port->tx_conf[res->qid]);
2534 printf("Failed to setup TX queue\n");
2538 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2539 .f = cmd_setup_rxtx_queue_parsed,
2541 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2543 (void *)&cmd_setup_rxtx_queue_port,
2544 (void *)&cmd_setup_rxtx_queue_portid,
2545 (void *)&cmd_setup_rxtx_queue_rxtxq,
2546 (void *)&cmd_setup_rxtx_queue_qid,
2547 (void *)&cmd_setup_rxtx_queue_setup,
2553 /* *** Configure RSS RETA *** */
2554 struct cmd_config_rss_reta {
2555 cmdline_fixed_string_t port;
2556 cmdline_fixed_string_t keyword;
2558 cmdline_fixed_string_t name;
2559 cmdline_fixed_string_t list_name;
2560 cmdline_fixed_string_t list_of_items;
2564 parse_reta_config(const char *str,
2565 struct rte_eth_rss_reta_entry64 *reta_conf,
2566 uint16_t nb_entries)
2570 uint16_t hash_index, idx, shift;
2573 const char *p, *p0 = str;
2580 unsigned long int_fld[_NUM_FLD];
2581 char *str_fld[_NUM_FLD];
2583 while ((p = strchr(p0,'(')) != NULL) {
2585 if((p0 = strchr(p,')')) == NULL)
2589 if(size >= sizeof(s))
2592 snprintf(s, sizeof(s), "%.*s", size, p);
2593 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2595 for (i = 0; i < _NUM_FLD; i++) {
2597 int_fld[i] = strtoul(str_fld[i], &end, 0);
2598 if (errno != 0 || end == str_fld[i] ||
2603 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2604 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2606 if (hash_index >= nb_entries) {
2607 printf("Invalid RETA hash index=%d\n", hash_index);
2611 idx = hash_index / RTE_RETA_GROUP_SIZE;
2612 shift = hash_index % RTE_RETA_GROUP_SIZE;
2613 reta_conf[idx].mask |= (1ULL << shift);
2614 reta_conf[idx].reta[shift] = nb_queue;
2621 cmd_set_rss_reta_parsed(void *parsed_result,
2622 __attribute__((unused)) struct cmdline *cl,
2623 __attribute__((unused)) void *data)
2626 struct rte_eth_dev_info dev_info;
2627 struct rte_eth_rss_reta_entry64 reta_conf[8];
2628 struct cmd_config_rss_reta *res = parsed_result;
2630 memset(&dev_info, 0, sizeof(dev_info));
2631 rte_eth_dev_info_get(res->port_id, &dev_info);
2632 if (dev_info.reta_size == 0) {
2633 printf("Redirection table size is 0 which is "
2634 "invalid for RSS\n");
2637 printf("The reta size of port %d is %u\n",
2638 res->port_id, dev_info.reta_size);
2639 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2640 printf("Currently do not support more than %u entries of "
2641 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2645 memset(reta_conf, 0, sizeof(reta_conf));
2646 if (!strcmp(res->list_name, "reta")) {
2647 if (parse_reta_config(res->list_of_items, reta_conf,
2648 dev_info.reta_size)) {
2649 printf("Invalid RSS Redirection Table "
2650 "config entered\n");
2653 ret = rte_eth_dev_rss_reta_update(res->port_id,
2654 reta_conf, dev_info.reta_size);
2656 printf("Bad redirection table parameter, "
2657 "return code = %d \n", ret);
2661 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2662 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2663 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2664 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2665 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2666 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2667 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2668 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2669 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2670 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2671 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2672 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2674 cmdline_parse_inst_t cmd_config_rss_reta = {
2675 .f = cmd_set_rss_reta_parsed,
2677 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2679 (void *)&cmd_config_rss_reta_port,
2680 (void *)&cmd_config_rss_reta_keyword,
2681 (void *)&cmd_config_rss_reta_port_id,
2682 (void *)&cmd_config_rss_reta_name,
2683 (void *)&cmd_config_rss_reta_list_name,
2684 (void *)&cmd_config_rss_reta_list_of_items,
2689 /* *** SHOW PORT RETA INFO *** */
2690 struct cmd_showport_reta {
2691 cmdline_fixed_string_t show;
2692 cmdline_fixed_string_t port;
2694 cmdline_fixed_string_t rss;
2695 cmdline_fixed_string_t reta;
2697 cmdline_fixed_string_t list_of_items;
2701 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2702 uint16_t nb_entries,
2706 const char *p, *p0 = str;
2711 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2712 RTE_RETA_GROUP_SIZE;
2715 p = strchr(p0, '(');
2719 p0 = strchr(p, ')');
2723 if (size >= sizeof(s)) {
2724 printf("The string size exceeds the internal buffer size\n");
2727 snprintf(s, sizeof(s), "%.*s", size, p);
2728 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2729 if (ret <= 0 || ret != num) {
2730 printf("The bits of masks do not match the number of "
2731 "reta entries: %u\n", num);
2734 for (i = 0; i < ret; i++)
2735 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2741 cmd_showport_reta_parsed(void *parsed_result,
2742 __attribute__((unused)) struct cmdline *cl,
2743 __attribute__((unused)) void *data)
2745 struct cmd_showport_reta *res = parsed_result;
2746 struct rte_eth_rss_reta_entry64 reta_conf[8];
2747 struct rte_eth_dev_info dev_info;
2748 uint16_t max_reta_size;
2750 memset(&dev_info, 0, sizeof(dev_info));
2751 rte_eth_dev_info_get(res->port_id, &dev_info);
2752 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2753 if (res->size == 0 || res->size > max_reta_size) {
2754 printf("Invalid redirection table size: %u (1-%u)\n",
2755 res->size, max_reta_size);
2759 memset(reta_conf, 0, sizeof(reta_conf));
2760 if (showport_parse_reta_config(reta_conf, res->size,
2761 res->list_of_items) < 0) {
2762 printf("Invalid string: %s for reta masks\n",
2763 res->list_of_items);
2766 port_rss_reta_info(res->port_id, reta_conf, res->size);
2769 cmdline_parse_token_string_t cmd_showport_reta_show =
2770 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2771 cmdline_parse_token_string_t cmd_showport_reta_port =
2772 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2773 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2774 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2775 cmdline_parse_token_string_t cmd_showport_reta_rss =
2776 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2777 cmdline_parse_token_string_t cmd_showport_reta_reta =
2778 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2779 cmdline_parse_token_num_t cmd_showport_reta_size =
2780 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2781 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2782 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2783 list_of_items, NULL);
2785 cmdline_parse_inst_t cmd_showport_reta = {
2786 .f = cmd_showport_reta_parsed,
2788 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2790 (void *)&cmd_showport_reta_show,
2791 (void *)&cmd_showport_reta_port,
2792 (void *)&cmd_showport_reta_port_id,
2793 (void *)&cmd_showport_reta_rss,
2794 (void *)&cmd_showport_reta_reta,
2795 (void *)&cmd_showport_reta_size,
2796 (void *)&cmd_showport_reta_list_of_items,
2801 /* *** Show RSS hash configuration *** */
2802 struct cmd_showport_rss_hash {
2803 cmdline_fixed_string_t show;
2804 cmdline_fixed_string_t port;
2806 cmdline_fixed_string_t rss_hash;
2807 cmdline_fixed_string_t rss_type;
2808 cmdline_fixed_string_t key; /* optional argument */
2811 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2812 __attribute__((unused)) struct cmdline *cl,
2815 struct cmd_showport_rss_hash *res = parsed_result;
2817 port_rss_hash_conf_show(res->port_id, res->rss_type,
2818 show_rss_key != NULL);
2821 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2822 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2823 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2824 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2825 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2826 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2827 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2828 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2830 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2831 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2832 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2833 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2834 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2835 "ipv6-tcp-ex#ipv6-udp-ex");
2836 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2837 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2839 cmdline_parse_inst_t cmd_showport_rss_hash = {
2840 .f = cmd_showport_rss_hash_parsed,
2842 .help_str = "show port <port_id> rss-hash "
2843 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2844 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2845 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2847 (void *)&cmd_showport_rss_hash_show,
2848 (void *)&cmd_showport_rss_hash_port,
2849 (void *)&cmd_showport_rss_hash_port_id,
2850 (void *)&cmd_showport_rss_hash_rss_hash,
2851 (void *)&cmd_showport_rss_hash_rss_hash_info,
2856 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2857 .f = cmd_showport_rss_hash_parsed,
2859 .help_str = "show port <port_id> rss-hash "
2860 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2861 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2862 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2864 (void *)&cmd_showport_rss_hash_show,
2865 (void *)&cmd_showport_rss_hash_port,
2866 (void *)&cmd_showport_rss_hash_port_id,
2867 (void *)&cmd_showport_rss_hash_rss_hash,
2868 (void *)&cmd_showport_rss_hash_rss_hash_info,
2869 (void *)&cmd_showport_rss_hash_rss_key,
2874 /* *** Configure DCB *** */
2875 struct cmd_config_dcb {
2876 cmdline_fixed_string_t port;
2877 cmdline_fixed_string_t config;
2879 cmdline_fixed_string_t dcb;
2880 cmdline_fixed_string_t vt;
2881 cmdline_fixed_string_t vt_en;
2883 cmdline_fixed_string_t pfc;
2884 cmdline_fixed_string_t pfc_en;
2888 cmd_config_dcb_parsed(void *parsed_result,
2889 __attribute__((unused)) struct cmdline *cl,
2890 __attribute__((unused)) void *data)
2892 struct cmd_config_dcb *res = parsed_result;
2893 portid_t port_id = res->port_id;
2894 struct rte_port *port;
2898 port = &ports[port_id];
2899 /** Check if the port is not started **/
2900 if (port->port_status != RTE_PORT_STOPPED) {
2901 printf("Please stop port %d first\n", port_id);
2905 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2906 printf("The invalid number of traffic class,"
2907 " only 4 or 8 allowed.\n");
2911 if (nb_fwd_lcores < res->num_tcs) {
2912 printf("nb_cores shouldn't be less than number of TCs.\n");
2915 if (!strncmp(res->pfc_en, "on", 2))
2920 /* DCB in VT mode */
2921 if (!strncmp(res->vt_en, "on", 2))
2922 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2923 (enum rte_eth_nb_tcs)res->num_tcs,
2926 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2927 (enum rte_eth_nb_tcs)res->num_tcs,
2932 printf("Cannot initialize network ports.\n");
2936 cmd_reconfig_device_queue(port_id, 1, 1);
2939 cmdline_parse_token_string_t cmd_config_dcb_port =
2940 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2941 cmdline_parse_token_string_t cmd_config_dcb_config =
2942 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2943 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2944 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2945 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2946 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2947 cmdline_parse_token_string_t cmd_config_dcb_vt =
2948 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2949 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2950 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2951 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2952 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2953 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2954 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2955 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2956 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2958 cmdline_parse_inst_t cmd_config_dcb = {
2959 .f = cmd_config_dcb_parsed,
2961 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2963 (void *)&cmd_config_dcb_port,
2964 (void *)&cmd_config_dcb_config,
2965 (void *)&cmd_config_dcb_port_id,
2966 (void *)&cmd_config_dcb_dcb,
2967 (void *)&cmd_config_dcb_vt,
2968 (void *)&cmd_config_dcb_vt_en,
2969 (void *)&cmd_config_dcb_num_tcs,
2970 (void *)&cmd_config_dcb_pfc,
2971 (void *)&cmd_config_dcb_pfc_en,
2976 /* *** configure number of packets per burst *** */
2977 struct cmd_config_burst {
2978 cmdline_fixed_string_t port;
2979 cmdline_fixed_string_t keyword;
2980 cmdline_fixed_string_t all;
2981 cmdline_fixed_string_t name;
2986 cmd_config_burst_parsed(void *parsed_result,
2987 __attribute__((unused)) struct cmdline *cl,
2988 __attribute__((unused)) void *data)
2990 struct cmd_config_burst *res = parsed_result;
2991 struct rte_eth_dev_info dev_info;
2992 uint16_t rec_nb_pkts;
2994 if (!all_ports_stopped()) {
2995 printf("Please stop all ports first\n");
2999 if (!strcmp(res->name, "burst")) {
3000 if (res->value == 0) {
3001 /* If user gives a value of zero, query the PMD for
3002 * its recommended Rx burst size. Testpmd uses a single
3003 * size for all ports, so assume all ports are the same
3004 * NIC model and use the values from Port 0.
3006 rte_eth_dev_info_get(0, &dev_info);
3007 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3009 if (rec_nb_pkts == 0) {
3010 printf("PMD does not recommend a burst size.\n"
3011 "User provided value must be between"
3012 " 1 and %d\n", MAX_PKT_BURST);
3014 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3015 printf("PMD recommended burst size of %d"
3016 " exceeds maximum value of %d\n",
3017 rec_nb_pkts, MAX_PKT_BURST);
3020 printf("Using PMD-provided burst value of %d\n",
3022 nb_pkt_per_burst = rec_nb_pkts;
3023 } else if (res->value > MAX_PKT_BURST) {
3024 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3027 nb_pkt_per_burst = res->value;
3029 printf("Unknown parameter\n");
3035 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3038 cmdline_parse_token_string_t cmd_config_burst_port =
3039 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3040 cmdline_parse_token_string_t cmd_config_burst_keyword =
3041 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3042 cmdline_parse_token_string_t cmd_config_burst_all =
3043 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3044 cmdline_parse_token_string_t cmd_config_burst_name =
3045 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3046 cmdline_parse_token_num_t cmd_config_burst_value =
3047 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3049 cmdline_parse_inst_t cmd_config_burst = {
3050 .f = cmd_config_burst_parsed,
3052 .help_str = "port config all burst <value>",
3054 (void *)&cmd_config_burst_port,
3055 (void *)&cmd_config_burst_keyword,
3056 (void *)&cmd_config_burst_all,
3057 (void *)&cmd_config_burst_name,
3058 (void *)&cmd_config_burst_value,
3063 /* *** configure rx/tx queues *** */
3064 struct cmd_config_thresh {
3065 cmdline_fixed_string_t port;
3066 cmdline_fixed_string_t keyword;
3067 cmdline_fixed_string_t all;
3068 cmdline_fixed_string_t name;
3073 cmd_config_thresh_parsed(void *parsed_result,
3074 __attribute__((unused)) struct cmdline *cl,
3075 __attribute__((unused)) void *data)
3077 struct cmd_config_thresh *res = parsed_result;
3079 if (!all_ports_stopped()) {
3080 printf("Please stop all ports first\n");
3084 if (!strcmp(res->name, "txpt"))
3085 tx_pthresh = res->value;
3086 else if(!strcmp(res->name, "txht"))
3087 tx_hthresh = res->value;
3088 else if(!strcmp(res->name, "txwt"))
3089 tx_wthresh = res->value;
3090 else if(!strcmp(res->name, "rxpt"))
3091 rx_pthresh = res->value;
3092 else if(!strcmp(res->name, "rxht"))
3093 rx_hthresh = res->value;
3094 else if(!strcmp(res->name, "rxwt"))
3095 rx_wthresh = res->value;
3097 printf("Unknown parameter\n");
3103 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3106 cmdline_parse_token_string_t cmd_config_thresh_port =
3107 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3108 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3109 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3110 cmdline_parse_token_string_t cmd_config_thresh_all =
3111 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3112 cmdline_parse_token_string_t cmd_config_thresh_name =
3113 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3114 "txpt#txht#txwt#rxpt#rxht#rxwt");
3115 cmdline_parse_token_num_t cmd_config_thresh_value =
3116 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3118 cmdline_parse_inst_t cmd_config_thresh = {
3119 .f = cmd_config_thresh_parsed,
3121 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3123 (void *)&cmd_config_thresh_port,
3124 (void *)&cmd_config_thresh_keyword,
3125 (void *)&cmd_config_thresh_all,
3126 (void *)&cmd_config_thresh_name,
3127 (void *)&cmd_config_thresh_value,
3132 /* *** configure free/rs threshold *** */
3133 struct cmd_config_threshold {
3134 cmdline_fixed_string_t port;
3135 cmdline_fixed_string_t keyword;
3136 cmdline_fixed_string_t all;
3137 cmdline_fixed_string_t name;
3142 cmd_config_threshold_parsed(void *parsed_result,
3143 __attribute__((unused)) struct cmdline *cl,
3144 __attribute__((unused)) void *data)
3146 struct cmd_config_threshold *res = parsed_result;
3148 if (!all_ports_stopped()) {
3149 printf("Please stop all ports first\n");
3153 if (!strcmp(res->name, "txfreet"))
3154 tx_free_thresh = res->value;
3155 else if (!strcmp(res->name, "txrst"))
3156 tx_rs_thresh = res->value;
3157 else if (!strcmp(res->name, "rxfreet"))
3158 rx_free_thresh = res->value;
3160 printf("Unknown parameter\n");
3166 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3169 cmdline_parse_token_string_t cmd_config_threshold_port =
3170 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3171 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3172 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3174 cmdline_parse_token_string_t cmd_config_threshold_all =
3175 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3176 cmdline_parse_token_string_t cmd_config_threshold_name =
3177 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3178 "txfreet#txrst#rxfreet");
3179 cmdline_parse_token_num_t cmd_config_threshold_value =
3180 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3182 cmdline_parse_inst_t cmd_config_threshold = {
3183 .f = cmd_config_threshold_parsed,
3185 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3187 (void *)&cmd_config_threshold_port,
3188 (void *)&cmd_config_threshold_keyword,
3189 (void *)&cmd_config_threshold_all,
3190 (void *)&cmd_config_threshold_name,
3191 (void *)&cmd_config_threshold_value,
3197 struct cmd_stop_result {
3198 cmdline_fixed_string_t stop;
3201 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3202 __attribute__((unused)) struct cmdline *cl,
3203 __attribute__((unused)) void *data)
3205 stop_packet_forwarding();
3208 cmdline_parse_token_string_t cmd_stop_stop =
3209 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3211 cmdline_parse_inst_t cmd_stop = {
3212 .f = cmd_stop_parsed,
3214 .help_str = "stop: Stop packet forwarding",
3216 (void *)&cmd_stop_stop,
3221 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3224 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3225 unsigned int *parsed_items, int check_unique_values)
3227 unsigned int nb_item;
3235 * First parse all items in the list and store their value.
3240 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3242 if ((c >= '0') && (c <= '9')) {
3243 value = (unsigned int) (value * 10 + (c - '0'));
3248 printf("character %c is not a decimal digit\n", c);
3252 printf("No valid value before comma\n");
3255 if (nb_item < max_items) {
3256 parsed_items[nb_item] = value;
3262 if (nb_item >= max_items) {
3263 printf("Number of %s = %u > %u (maximum items)\n",
3264 item_name, nb_item + 1, max_items);
3267 parsed_items[nb_item++] = value;
3268 if (! check_unique_values)
3272 * Then, check that all values in the list are differents.
3273 * No optimization here...
3275 for (i = 0; i < nb_item; i++) {
3276 for (j = i + 1; j < nb_item; j++) {
3277 if (parsed_items[j] == parsed_items[i]) {
3278 printf("duplicated %s %u at index %u and %u\n",
3279 item_name, parsed_items[i], i, j);
3287 struct cmd_set_list_result {
3288 cmdline_fixed_string_t cmd_keyword;
3289 cmdline_fixed_string_t list_name;
3290 cmdline_fixed_string_t list_of_items;
3293 static void cmd_set_list_parsed(void *parsed_result,
3294 __attribute__((unused)) struct cmdline *cl,
3295 __attribute__((unused)) void *data)
3297 struct cmd_set_list_result *res;
3299 unsigned int lcorelist[RTE_MAX_LCORE];
3300 unsigned int portlist[RTE_MAX_ETHPORTS];
3302 unsigned int nb_item;
3304 if (test_done == 0) {
3305 printf("Please stop forwarding first\n");
3309 res = parsed_result;
3310 if (!strcmp(res->list_name, "corelist")) {
3311 nb_item = parse_item_list(res->list_of_items, "core",
3313 parsed_items.lcorelist, 1);
3315 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3320 if (!strcmp(res->list_name, "portlist")) {
3321 nb_item = parse_item_list(res->list_of_items, "port",
3323 parsed_items.portlist, 1);
3325 set_fwd_ports_list(parsed_items.portlist, nb_item);
3331 cmdline_parse_token_string_t cmd_set_list_keyword =
3332 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3334 cmdline_parse_token_string_t cmd_set_list_name =
3335 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3336 "corelist#portlist");
3337 cmdline_parse_token_string_t cmd_set_list_of_items =
3338 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3341 cmdline_parse_inst_t cmd_set_fwd_list = {
3342 .f = cmd_set_list_parsed,
3344 .help_str = "set corelist|portlist <list0[,list1]*>",
3346 (void *)&cmd_set_list_keyword,
3347 (void *)&cmd_set_list_name,
3348 (void *)&cmd_set_list_of_items,
3353 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3355 struct cmd_setmask_result {
3356 cmdline_fixed_string_t set;
3357 cmdline_fixed_string_t mask;
3361 static void cmd_set_mask_parsed(void *parsed_result,
3362 __attribute__((unused)) struct cmdline *cl,
3363 __attribute__((unused)) void *data)
3365 struct cmd_setmask_result *res = parsed_result;
3367 if (test_done == 0) {
3368 printf("Please stop forwarding first\n");
3371 if (!strcmp(res->mask, "coremask")) {
3372 set_fwd_lcores_mask(res->hexavalue);
3374 } else if (!strcmp(res->mask, "portmask")) {
3375 set_fwd_ports_mask(res->hexavalue);
3380 cmdline_parse_token_string_t cmd_setmask_set =
3381 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3382 cmdline_parse_token_string_t cmd_setmask_mask =
3383 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3384 "coremask#portmask");
3385 cmdline_parse_token_num_t cmd_setmask_value =
3386 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3388 cmdline_parse_inst_t cmd_set_fwd_mask = {
3389 .f = cmd_set_mask_parsed,
3391 .help_str = "set coremask|portmask <hexadecimal value>",
3393 (void *)&cmd_setmask_set,
3394 (void *)&cmd_setmask_mask,
3395 (void *)&cmd_setmask_value,
3401 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3403 struct cmd_set_result {
3404 cmdline_fixed_string_t set;
3405 cmdline_fixed_string_t what;
3409 static void cmd_set_parsed(void *parsed_result,
3410 __attribute__((unused)) struct cmdline *cl,
3411 __attribute__((unused)) void *data)
3413 struct cmd_set_result *res = parsed_result;
3414 if (!strcmp(res->what, "nbport")) {
3415 set_fwd_ports_number(res->value);
3417 } else if (!strcmp(res->what, "nbcore")) {
3418 set_fwd_lcores_number(res->value);
3420 } else if (!strcmp(res->what, "burst"))
3421 set_nb_pkt_per_burst(res->value);
3422 else if (!strcmp(res->what, "verbose"))
3423 set_verbose_level(res->value);
3426 cmdline_parse_token_string_t cmd_set_set =
3427 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3428 cmdline_parse_token_string_t cmd_set_what =
3429 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3430 "nbport#nbcore#burst#verbose");
3431 cmdline_parse_token_num_t cmd_set_value =
3432 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3434 cmdline_parse_inst_t cmd_set_numbers = {
3435 .f = cmd_set_parsed,
3437 .help_str = "set nbport|nbcore|burst|verbose <value>",
3439 (void *)&cmd_set_set,
3440 (void *)&cmd_set_what,
3441 (void *)&cmd_set_value,
3446 /* *** SET LOG LEVEL CONFIGURATION *** */
3448 struct cmd_set_log_result {
3449 cmdline_fixed_string_t set;
3450 cmdline_fixed_string_t log;
3451 cmdline_fixed_string_t type;
3456 cmd_set_log_parsed(void *parsed_result,
3457 __attribute__((unused)) struct cmdline *cl,
3458 __attribute__((unused)) void *data)
3460 struct cmd_set_log_result *res;
3463 res = parsed_result;
3464 if (!strcmp(res->type, "global"))
3465 rte_log_set_global_level(res->level);
3467 ret = rte_log_set_level_regexp(res->type, res->level);
3469 printf("Unable to set log level\n");
3473 cmdline_parse_token_string_t cmd_set_log_set =
3474 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3475 cmdline_parse_token_string_t cmd_set_log_log =
3476 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3477 cmdline_parse_token_string_t cmd_set_log_type =
3478 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3479 cmdline_parse_token_num_t cmd_set_log_level =
3480 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3482 cmdline_parse_inst_t cmd_set_log = {
3483 .f = cmd_set_log_parsed,
3485 .help_str = "set log global|<type> <level>",
3487 (void *)&cmd_set_log_set,
3488 (void *)&cmd_set_log_log,
3489 (void *)&cmd_set_log_type,
3490 (void *)&cmd_set_log_level,
3495 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3497 struct cmd_set_txpkts_result {
3498 cmdline_fixed_string_t cmd_keyword;
3499 cmdline_fixed_string_t txpkts;
3500 cmdline_fixed_string_t seg_lengths;
3504 cmd_set_txpkts_parsed(void *parsed_result,
3505 __attribute__((unused)) struct cmdline *cl,
3506 __attribute__((unused)) void *data)
3508 struct cmd_set_txpkts_result *res;
3509 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3510 unsigned int nb_segs;
3512 res = parsed_result;
3513 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3514 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3516 set_tx_pkt_segments(seg_lengths, nb_segs);
3519 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3520 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3521 cmd_keyword, "set");
3522 cmdline_parse_token_string_t cmd_set_txpkts_name =
3523 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3525 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3526 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3529 cmdline_parse_inst_t cmd_set_txpkts = {
3530 .f = cmd_set_txpkts_parsed,
3532 .help_str = "set txpkts <len0[,len1]*>",
3534 (void *)&cmd_set_txpkts_keyword,
3535 (void *)&cmd_set_txpkts_name,
3536 (void *)&cmd_set_txpkts_lengths,
3541 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3543 struct cmd_set_txsplit_result {
3544 cmdline_fixed_string_t cmd_keyword;
3545 cmdline_fixed_string_t txsplit;
3546 cmdline_fixed_string_t mode;
3550 cmd_set_txsplit_parsed(void *parsed_result,
3551 __attribute__((unused)) struct cmdline *cl,
3552 __attribute__((unused)) void *data)
3554 struct cmd_set_txsplit_result *res;
3556 res = parsed_result;
3557 set_tx_pkt_split(res->mode);
3560 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3561 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3562 cmd_keyword, "set");
3563 cmdline_parse_token_string_t cmd_set_txsplit_name =
3564 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3565 txsplit, "txsplit");
3566 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3567 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3570 cmdline_parse_inst_t cmd_set_txsplit = {
3571 .f = cmd_set_txsplit_parsed,
3573 .help_str = "set txsplit on|off|rand",
3575 (void *)&cmd_set_txsplit_keyword,
3576 (void *)&cmd_set_txsplit_name,
3577 (void *)&cmd_set_txsplit_mode,
3582 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3583 struct cmd_rx_vlan_filter_all_result {
3584 cmdline_fixed_string_t rx_vlan;
3585 cmdline_fixed_string_t what;
3586 cmdline_fixed_string_t all;
3591 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3592 __attribute__((unused)) struct cmdline *cl,
3593 __attribute__((unused)) void *data)
3595 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3597 if (!strcmp(res->what, "add"))
3598 rx_vlan_all_filter_set(res->port_id, 1);
3600 rx_vlan_all_filter_set(res->port_id, 0);
3603 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3604 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3605 rx_vlan, "rx_vlan");
3606 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3607 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3609 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3610 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3612 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3613 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3616 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3617 .f = cmd_rx_vlan_filter_all_parsed,
3619 .help_str = "rx_vlan add|rm all <port_id>: "
3620 "Add/Remove all identifiers to/from the set of VLAN "
3621 "identifiers filtered by a port",
3623 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3624 (void *)&cmd_rx_vlan_filter_all_what,
3625 (void *)&cmd_rx_vlan_filter_all_all,
3626 (void *)&cmd_rx_vlan_filter_all_portid,
3631 /* *** VLAN OFFLOAD SET ON A PORT *** */
3632 struct cmd_vlan_offload_result {
3633 cmdline_fixed_string_t vlan;
3634 cmdline_fixed_string_t set;
3635 cmdline_fixed_string_t vlan_type;
3636 cmdline_fixed_string_t what;
3637 cmdline_fixed_string_t on;
3638 cmdline_fixed_string_t port_id;
3642 cmd_vlan_offload_parsed(void *parsed_result,
3643 __attribute__((unused)) struct cmdline *cl,
3644 __attribute__((unused)) void *data)
3647 struct cmd_vlan_offload_result *res = parsed_result;
3650 portid_t port_id = 0;
3654 len = strnlen(str, STR_TOKEN_SIZE);
3656 /* Get port_id first */
3664 tmp = strtoul(str, NULL, 0);
3665 /* If port_id greater that what portid_t can represent, return */
3666 if(tmp >= RTE_MAX_ETHPORTS)
3668 port_id = (portid_t)tmp;
3670 if (!strcmp(res->on, "on"))
3675 if (!strcmp(res->what, "strip"))
3676 rx_vlan_strip_set(port_id, on);
3677 else if(!strcmp(res->what, "stripq")){
3678 uint16_t queue_id = 0;
3680 /* No queue_id, return */
3682 printf("must specify (port,queue_id)\n");
3685 tmp = strtoul(str + i + 1, NULL, 0);
3686 /* If queue_id greater that what 16-bits can represent, return */
3690 queue_id = (uint16_t)tmp;
3691 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3693 else if (!strcmp(res->what, "filter"))
3694 rx_vlan_filter_set(port_id, on);
3696 vlan_extend_set(port_id, on);
3701 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3702 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3704 cmdline_parse_token_string_t cmd_vlan_offload_set =
3705 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3707 cmdline_parse_token_string_t cmd_vlan_offload_what =
3708 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3709 what, "strip#filter#qinq#stripq");
3710 cmdline_parse_token_string_t cmd_vlan_offload_on =
3711 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3713 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3714 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3717 cmdline_parse_inst_t cmd_vlan_offload = {
3718 .f = cmd_vlan_offload_parsed,
3720 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3721 "<port_id[,queue_id]>: "
3722 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3724 (void *)&cmd_vlan_offload_vlan,
3725 (void *)&cmd_vlan_offload_set,
3726 (void *)&cmd_vlan_offload_what,
3727 (void *)&cmd_vlan_offload_on,
3728 (void *)&cmd_vlan_offload_portid,
3733 /* *** VLAN TPID SET ON A PORT *** */
3734 struct cmd_vlan_tpid_result {
3735 cmdline_fixed_string_t vlan;
3736 cmdline_fixed_string_t set;
3737 cmdline_fixed_string_t vlan_type;
3738 cmdline_fixed_string_t what;
3744 cmd_vlan_tpid_parsed(void *parsed_result,
3745 __attribute__((unused)) struct cmdline *cl,
3746 __attribute__((unused)) void *data)
3748 struct cmd_vlan_tpid_result *res = parsed_result;
3749 enum rte_vlan_type vlan_type;
3751 if (!strcmp(res->vlan_type, "inner"))
3752 vlan_type = ETH_VLAN_TYPE_INNER;
3753 else if (!strcmp(res->vlan_type, "outer"))
3754 vlan_type = ETH_VLAN_TYPE_OUTER;
3756 printf("Unknown vlan type\n");
3759 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3762 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3763 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3765 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3766 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3768 cmdline_parse_token_string_t cmd_vlan_type =
3769 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3770 vlan_type, "inner#outer");
3771 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3772 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3774 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3775 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3777 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3778 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3781 cmdline_parse_inst_t cmd_vlan_tpid = {
3782 .f = cmd_vlan_tpid_parsed,
3784 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3785 "Set the VLAN Ether type",
3787 (void *)&cmd_vlan_tpid_vlan,
3788 (void *)&cmd_vlan_tpid_set,
3789 (void *)&cmd_vlan_type,
3790 (void *)&cmd_vlan_tpid_what,
3791 (void *)&cmd_vlan_tpid_tpid,
3792 (void *)&cmd_vlan_tpid_portid,
3797 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3798 struct cmd_rx_vlan_filter_result {
3799 cmdline_fixed_string_t rx_vlan;
3800 cmdline_fixed_string_t what;
3806 cmd_rx_vlan_filter_parsed(void *parsed_result,
3807 __attribute__((unused)) struct cmdline *cl,
3808 __attribute__((unused)) void *data)
3810 struct cmd_rx_vlan_filter_result *res = parsed_result;
3812 if (!strcmp(res->what, "add"))
3813 rx_vft_set(res->port_id, res->vlan_id, 1);
3815 rx_vft_set(res->port_id, res->vlan_id, 0);
3818 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3819 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3820 rx_vlan, "rx_vlan");
3821 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3822 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3824 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3825 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3827 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3828 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3831 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3832 .f = cmd_rx_vlan_filter_parsed,
3834 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3835 "Add/Remove a VLAN identifier to/from the set of VLAN "
3836 "identifiers filtered by a port",
3838 (void *)&cmd_rx_vlan_filter_rx_vlan,
3839 (void *)&cmd_rx_vlan_filter_what,
3840 (void *)&cmd_rx_vlan_filter_vlanid,
3841 (void *)&cmd_rx_vlan_filter_portid,
3846 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3847 struct cmd_tx_vlan_set_result {
3848 cmdline_fixed_string_t tx_vlan;
3849 cmdline_fixed_string_t set;
3855 cmd_tx_vlan_set_parsed(void *parsed_result,
3856 __attribute__((unused)) struct cmdline *cl,
3857 __attribute__((unused)) void *data)
3859 struct cmd_tx_vlan_set_result *res = parsed_result;
3861 if (!port_is_stopped(res->port_id)) {
3862 printf("Please stop port %d first\n", res->port_id);
3866 tx_vlan_set(res->port_id, res->vlan_id);
3868 cmd_reconfig_device_queue(res->port_id, 1, 1);
3871 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3872 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3873 tx_vlan, "tx_vlan");
3874 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3875 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3877 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3878 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3880 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3881 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3884 cmdline_parse_inst_t cmd_tx_vlan_set = {
3885 .f = cmd_tx_vlan_set_parsed,
3887 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3888 "Enable hardware insertion of a single VLAN header "
3889 "with a given TAG Identifier in packets sent on a port",
3891 (void *)&cmd_tx_vlan_set_tx_vlan,
3892 (void *)&cmd_tx_vlan_set_set,
3893 (void *)&cmd_tx_vlan_set_portid,
3894 (void *)&cmd_tx_vlan_set_vlanid,
3899 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3900 struct cmd_tx_vlan_set_qinq_result {
3901 cmdline_fixed_string_t tx_vlan;
3902 cmdline_fixed_string_t set;
3905 uint16_t vlan_id_outer;
3909 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3910 __attribute__((unused)) struct cmdline *cl,
3911 __attribute__((unused)) void *data)
3913 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3915 if (!port_is_stopped(res->port_id)) {
3916 printf("Please stop port %d first\n", res->port_id);
3920 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3922 cmd_reconfig_device_queue(res->port_id, 1, 1);
3925 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3926 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3927 tx_vlan, "tx_vlan");
3928 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3929 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3931 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3932 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3934 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3935 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3937 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3938 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3939 vlan_id_outer, UINT16);
3941 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3942 .f = cmd_tx_vlan_set_qinq_parsed,
3944 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3945 "Enable hardware insertion of double VLAN header "
3946 "with given TAG Identifiers in packets sent on a port",
3948 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3949 (void *)&cmd_tx_vlan_set_qinq_set,
3950 (void *)&cmd_tx_vlan_set_qinq_portid,
3951 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3952 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3957 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3958 struct cmd_tx_vlan_set_pvid_result {
3959 cmdline_fixed_string_t tx_vlan;
3960 cmdline_fixed_string_t set;
3961 cmdline_fixed_string_t pvid;
3964 cmdline_fixed_string_t mode;
3968 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3969 __attribute__((unused)) struct cmdline *cl,
3970 __attribute__((unused)) void *data)
3972 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3974 if (strcmp(res->mode, "on") == 0)
3975 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3977 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3980 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3981 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3982 tx_vlan, "tx_vlan");
3983 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3984 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3986 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3987 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3989 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3990 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3992 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3993 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3995 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3996 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3999 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4000 .f = cmd_tx_vlan_set_pvid_parsed,
4002 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4004 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4005 (void *)&cmd_tx_vlan_set_pvid_set,
4006 (void *)&cmd_tx_vlan_set_pvid_pvid,
4007 (void *)&cmd_tx_vlan_set_pvid_port_id,
4008 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4009 (void *)&cmd_tx_vlan_set_pvid_mode,
4014 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4015 struct cmd_tx_vlan_reset_result {
4016 cmdline_fixed_string_t tx_vlan;
4017 cmdline_fixed_string_t reset;
4022 cmd_tx_vlan_reset_parsed(void *parsed_result,
4023 __attribute__((unused)) struct cmdline *cl,
4024 __attribute__((unused)) void *data)
4026 struct cmd_tx_vlan_reset_result *res = parsed_result;
4028 if (!port_is_stopped(res->port_id)) {
4029 printf("Please stop port %d first\n", res->port_id);
4033 tx_vlan_reset(res->port_id);
4035 cmd_reconfig_device_queue(res->port_id, 1, 1);
4038 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4039 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4040 tx_vlan, "tx_vlan");
4041 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4042 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4044 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4045 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4048 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4049 .f = cmd_tx_vlan_reset_parsed,
4051 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4052 "VLAN header in packets sent on a port",
4054 (void *)&cmd_tx_vlan_reset_tx_vlan,
4055 (void *)&cmd_tx_vlan_reset_reset,
4056 (void *)&cmd_tx_vlan_reset_portid,
4062 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4063 struct cmd_csum_result {
4064 cmdline_fixed_string_t csum;
4065 cmdline_fixed_string_t mode;
4066 cmdline_fixed_string_t proto;
4067 cmdline_fixed_string_t hwsw;
4072 csum_show(int port_id)
4074 struct rte_eth_dev_info dev_info;
4075 uint64_t tx_offloads;
4077 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4078 printf("Parse tunnel is %s\n",
4079 (ports[port_id].parse_tunnel) ? "on" : "off");
4080 printf("IP checksum offload is %s\n",
4081 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4082 printf("UDP checksum offload is %s\n",
4083 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4084 printf("TCP checksum offload is %s\n",
4085 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4086 printf("SCTP checksum offload is %s\n",
4087 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4088 printf("Outer-Ip checksum offload is %s\n",
4089 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4091 /* display warnings if configuration is not supported by the NIC */
4092 rte_eth_dev_info_get(port_id, &dev_info);
4093 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4094 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4095 printf("Warning: hardware IP checksum enabled but not "
4096 "supported by port %d\n", port_id);
4098 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4099 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4100 printf("Warning: hardware UDP checksum enabled but not "
4101 "supported by port %d\n", port_id);
4103 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4104 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4105 printf("Warning: hardware TCP checksum enabled but not "
4106 "supported by port %d\n", port_id);
4108 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4109 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4110 printf("Warning: hardware SCTP checksum enabled but not "
4111 "supported by port %d\n", port_id);
4113 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4114 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4115 printf("Warning: hardware outer IP checksum enabled but not "
4116 "supported by port %d\n", port_id);
4121 cmd_csum_parsed(void *parsed_result,
4122 __attribute__((unused)) struct cmdline *cl,
4123 __attribute__((unused)) void *data)
4125 struct cmd_csum_result *res = parsed_result;
4127 uint64_t csum_offloads = 0;
4128 struct rte_eth_dev_info dev_info;
4130 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4131 printf("invalid port %d\n", res->port_id);
4134 if (!port_is_stopped(res->port_id)) {
4135 printf("Please stop port %d first\n", res->port_id);
4139 rte_eth_dev_info_get(res->port_id, &dev_info);
4140 if (!strcmp(res->mode, "set")) {
4142 if (!strcmp(res->hwsw, "hw"))
4145 if (!strcmp(res->proto, "ip")) {
4146 if (hw == 0 || (dev_info.tx_offload_capa &
4147 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4148 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4150 printf("IP checksum offload is not supported "
4151 "by port %u\n", res->port_id);
4153 } else if (!strcmp(res->proto, "udp")) {
4154 if (hw == 0 || (dev_info.tx_offload_capa &
4155 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4156 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4158 printf("UDP checksum offload is not supported "
4159 "by port %u\n", res->port_id);
4161 } else if (!strcmp(res->proto, "tcp")) {
4162 if (hw == 0 || (dev_info.tx_offload_capa &
4163 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4164 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4166 printf("TCP checksum offload is not supported "
4167 "by port %u\n", res->port_id);
4169 } else if (!strcmp(res->proto, "sctp")) {
4170 if (hw == 0 || (dev_info.tx_offload_capa &
4171 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4172 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4174 printf("SCTP checksum offload is not supported "
4175 "by port %u\n", res->port_id);
4177 } else if (!strcmp(res->proto, "outer-ip")) {
4178 if (hw == 0 || (dev_info.tx_offload_capa &
4179 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4181 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4183 printf("Outer IP checksum offload is not "
4184 "supported by port %u\n", res->port_id);
4189 ports[res->port_id].dev_conf.txmode.offloads |=
4192 ports[res->port_id].dev_conf.txmode.offloads &=
4196 csum_show(res->port_id);
4198 cmd_reconfig_device_queue(res->port_id, 1, 1);
4201 cmdline_parse_token_string_t cmd_csum_csum =
4202 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4204 cmdline_parse_token_string_t cmd_csum_mode =
4205 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4207 cmdline_parse_token_string_t cmd_csum_proto =
4208 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4209 proto, "ip#tcp#udp#sctp#outer-ip");
4210 cmdline_parse_token_string_t cmd_csum_hwsw =
4211 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4213 cmdline_parse_token_num_t cmd_csum_portid =
4214 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4217 cmdline_parse_inst_t cmd_csum_set = {
4218 .f = cmd_csum_parsed,
4220 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4221 "Enable/Disable hardware calculation of L3/L4 checksum when "
4222 "using csum forward engine",
4224 (void *)&cmd_csum_csum,
4225 (void *)&cmd_csum_mode,
4226 (void *)&cmd_csum_proto,
4227 (void *)&cmd_csum_hwsw,
4228 (void *)&cmd_csum_portid,
4233 cmdline_parse_token_string_t cmd_csum_mode_show =
4234 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4237 cmdline_parse_inst_t cmd_csum_show = {
4238 .f = cmd_csum_parsed,
4240 .help_str = "csum show <port_id>: Show checksum offload configuration",
4242 (void *)&cmd_csum_csum,
4243 (void *)&cmd_csum_mode_show,
4244 (void *)&cmd_csum_portid,
4249 /* Enable/disable tunnel parsing */
4250 struct cmd_csum_tunnel_result {
4251 cmdline_fixed_string_t csum;
4252 cmdline_fixed_string_t parse;
4253 cmdline_fixed_string_t onoff;
4258 cmd_csum_tunnel_parsed(void *parsed_result,
4259 __attribute__((unused)) struct cmdline *cl,
4260 __attribute__((unused)) void *data)
4262 struct cmd_csum_tunnel_result *res = parsed_result;
4264 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4267 if (!strcmp(res->onoff, "on"))
4268 ports[res->port_id].parse_tunnel = 1;
4270 ports[res->port_id].parse_tunnel = 0;
4272 csum_show(res->port_id);
4275 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4276 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4278 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4279 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4280 parse, "parse_tunnel");
4281 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4282 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4284 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4285 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4288 cmdline_parse_inst_t cmd_csum_tunnel = {
4289 .f = cmd_csum_tunnel_parsed,
4291 .help_str = "csum parse_tunnel on|off <port_id>: "
4292 "Enable/Disable parsing of tunnels for csum engine",
4294 (void *)&cmd_csum_tunnel_csum,
4295 (void *)&cmd_csum_tunnel_parse,
4296 (void *)&cmd_csum_tunnel_onoff,
4297 (void *)&cmd_csum_tunnel_portid,
4302 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4303 struct cmd_tso_set_result {
4304 cmdline_fixed_string_t tso;
4305 cmdline_fixed_string_t mode;
4311 cmd_tso_set_parsed(void *parsed_result,
4312 __attribute__((unused)) struct cmdline *cl,
4313 __attribute__((unused)) void *data)
4315 struct cmd_tso_set_result *res = parsed_result;
4316 struct rte_eth_dev_info dev_info;
4318 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4320 if (!port_is_stopped(res->port_id)) {
4321 printf("Please stop port %d first\n", res->port_id);
4325 if (!strcmp(res->mode, "set"))
4326 ports[res->port_id].tso_segsz = res->tso_segsz;
4328 rte_eth_dev_info_get(res->port_id, &dev_info);
4329 if ((ports[res->port_id].tso_segsz != 0) &&
4330 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4331 printf("Error: TSO is not supported by port %d\n",
4336 if (ports[res->port_id].tso_segsz == 0) {
4337 ports[res->port_id].dev_conf.txmode.offloads &=
4338 ~DEV_TX_OFFLOAD_TCP_TSO;
4339 printf("TSO for non-tunneled packets is disabled\n");
4341 ports[res->port_id].dev_conf.txmode.offloads |=
4342 DEV_TX_OFFLOAD_TCP_TSO;
4343 printf("TSO segment size for non-tunneled packets is %d\n",
4344 ports[res->port_id].tso_segsz);
4347 /* display warnings if configuration is not supported by the NIC */
4348 rte_eth_dev_info_get(res->port_id, &dev_info);
4349 if ((ports[res->port_id].tso_segsz != 0) &&
4350 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4351 printf("Warning: TSO enabled but not "
4352 "supported by port %d\n", res->port_id);
4355 cmd_reconfig_device_queue(res->port_id, 1, 1);
4358 cmdline_parse_token_string_t cmd_tso_set_tso =
4359 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4361 cmdline_parse_token_string_t cmd_tso_set_mode =
4362 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4364 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4365 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4367 cmdline_parse_token_num_t cmd_tso_set_portid =
4368 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4371 cmdline_parse_inst_t cmd_tso_set = {
4372 .f = cmd_tso_set_parsed,
4374 .help_str = "tso set <tso_segsz> <port_id>: "
4375 "Set TSO segment size of non-tunneled packets for csum engine "
4378 (void *)&cmd_tso_set_tso,
4379 (void *)&cmd_tso_set_mode,
4380 (void *)&cmd_tso_set_tso_segsz,
4381 (void *)&cmd_tso_set_portid,
4386 cmdline_parse_token_string_t cmd_tso_show_mode =
4387 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4391 cmdline_parse_inst_t cmd_tso_show = {
4392 .f = cmd_tso_set_parsed,
4394 .help_str = "tso show <port_id>: "
4395 "Show TSO segment size of non-tunneled packets for csum engine",
4397 (void *)&cmd_tso_set_tso,
4398 (void *)&cmd_tso_show_mode,
4399 (void *)&cmd_tso_set_portid,
4404 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4405 struct cmd_tunnel_tso_set_result {
4406 cmdline_fixed_string_t tso;
4407 cmdline_fixed_string_t mode;
4412 static struct rte_eth_dev_info
4413 check_tunnel_tso_nic_support(portid_t port_id)
4415 struct rte_eth_dev_info dev_info;
4417 rte_eth_dev_info_get(port_id, &dev_info);
4418 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4419 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4420 "not enabled for port %d\n", port_id);
4421 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4422 printf("Warning: GRE TUNNEL TSO not supported therefore "
4423 "not enabled for port %d\n", port_id);
4424 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4425 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4426 "not enabled for port %d\n", port_id);
4427 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4428 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4429 "not enabled for port %d\n", port_id);
4430 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4431 printf("Warning: IP TUNNEL TSO not supported therefore "
4432 "not enabled for port %d\n", port_id);
4433 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4434 printf("Warning: UDP TUNNEL TSO not supported therefore "
4435 "not enabled for port %d\n", port_id);
4440 cmd_tunnel_tso_set_parsed(void *parsed_result,
4441 __attribute__((unused)) struct cmdline *cl,
4442 __attribute__((unused)) void *data)
4444 struct cmd_tunnel_tso_set_result *res = parsed_result;
4445 struct rte_eth_dev_info dev_info;
4447 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4449 if (!port_is_stopped(res->port_id)) {
4450 printf("Please stop port %d first\n", res->port_id);
4454 if (!strcmp(res->mode, "set"))
4455 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4457 dev_info = check_tunnel_tso_nic_support(res->port_id);
4458 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4459 ports[res->port_id].dev_conf.txmode.offloads &=
4460 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4461 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4462 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4463 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4464 DEV_TX_OFFLOAD_IP_TNL_TSO |
4465 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4466 printf("TSO for tunneled packets is disabled\n");
4468 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4469 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4470 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4471 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4472 DEV_TX_OFFLOAD_IP_TNL_TSO |
4473 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4475 ports[res->port_id].dev_conf.txmode.offloads |=
4476 (tso_offloads & dev_info.tx_offload_capa);
4477 printf("TSO segment size for tunneled packets is %d\n",
4478 ports[res->port_id].tunnel_tso_segsz);
4480 /* Below conditions are needed to make it work:
4481 * (1) tunnel TSO is supported by the NIC;
4482 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4484 * (3) for tunneled pkts with outer L3 of IPv4,
4485 * "csum set outer-ip" must be set to hw, because after tso,
4486 * total_len of outer IP header is changed, and the checksum
4487 * of outer IP header calculated by sw should be wrong; that
4488 * is not necessary for IPv6 tunneled pkts because there's no
4489 * checksum in IP header anymore.
4492 if (!ports[res->port_id].parse_tunnel)
4493 printf("Warning: csum parse_tunnel must be set "
4494 "so that tunneled packets are recognized\n");
4495 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4496 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4497 printf("Warning: csum set outer-ip must be set to hw "
4498 "if outer L3 is IPv4; not necessary for IPv6\n");
4501 cmd_reconfig_device_queue(res->port_id, 1, 1);
4504 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4505 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4507 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4508 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4510 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4511 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4513 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4514 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4517 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4518 .f = cmd_tunnel_tso_set_parsed,
4520 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4521 "Set TSO segment size of tunneled packets for csum engine "
4524 (void *)&cmd_tunnel_tso_set_tso,
4525 (void *)&cmd_tunnel_tso_set_mode,
4526 (void *)&cmd_tunnel_tso_set_tso_segsz,
4527 (void *)&cmd_tunnel_tso_set_portid,
4532 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4533 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4537 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4538 .f = cmd_tunnel_tso_set_parsed,
4540 .help_str = "tunnel_tso show <port_id> "
4541 "Show TSO segment size of tunneled packets for csum engine",
4543 (void *)&cmd_tunnel_tso_set_tso,
4544 (void *)&cmd_tunnel_tso_show_mode,
4545 (void *)&cmd_tunnel_tso_set_portid,
4550 /* *** SET GRO FOR A PORT *** */
4551 struct cmd_gro_enable_result {
4552 cmdline_fixed_string_t cmd_set;
4553 cmdline_fixed_string_t cmd_port;
4554 cmdline_fixed_string_t cmd_keyword;
4555 cmdline_fixed_string_t cmd_onoff;
4560 cmd_gro_enable_parsed(void *parsed_result,
4561 __attribute__((unused)) struct cmdline *cl,
4562 __attribute__((unused)) void *data)
4564 struct cmd_gro_enable_result *res;
4566 res = parsed_result;
4567 if (!strcmp(res->cmd_keyword, "gro"))
4568 setup_gro(res->cmd_onoff, res->cmd_pid);
4571 cmdline_parse_token_string_t cmd_gro_enable_set =
4572 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4574 cmdline_parse_token_string_t cmd_gro_enable_port =
4575 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4576 cmd_keyword, "port");
4577 cmdline_parse_token_num_t cmd_gro_enable_pid =
4578 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4580 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4581 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4582 cmd_keyword, "gro");
4583 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4584 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4585 cmd_onoff, "on#off");
4587 cmdline_parse_inst_t cmd_gro_enable = {
4588 .f = cmd_gro_enable_parsed,
4590 .help_str = "set port <port_id> gro on|off",
4592 (void *)&cmd_gro_enable_set,
4593 (void *)&cmd_gro_enable_port,
4594 (void *)&cmd_gro_enable_pid,
4595 (void *)&cmd_gro_enable_keyword,
4596 (void *)&cmd_gro_enable_onoff,
4601 /* *** DISPLAY GRO CONFIGURATION *** */
4602 struct cmd_gro_show_result {
4603 cmdline_fixed_string_t cmd_show;
4604 cmdline_fixed_string_t cmd_port;
4605 cmdline_fixed_string_t cmd_keyword;
4610 cmd_gro_show_parsed(void *parsed_result,
4611 __attribute__((unused)) struct cmdline *cl,
4612 __attribute__((unused)) void *data)
4614 struct cmd_gro_show_result *res;
4616 res = parsed_result;
4617 if (!strcmp(res->cmd_keyword, "gro"))
4618 show_gro(res->cmd_pid);
4621 cmdline_parse_token_string_t cmd_gro_show_show =
4622 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4624 cmdline_parse_token_string_t cmd_gro_show_port =
4625 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4627 cmdline_parse_token_num_t cmd_gro_show_pid =
4628 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4630 cmdline_parse_token_string_t cmd_gro_show_keyword =
4631 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4632 cmd_keyword, "gro");
4634 cmdline_parse_inst_t cmd_gro_show = {
4635 .f = cmd_gro_show_parsed,
4637 .help_str = "show port <port_id> gro",
4639 (void *)&cmd_gro_show_show,
4640 (void *)&cmd_gro_show_port,
4641 (void *)&cmd_gro_show_pid,
4642 (void *)&cmd_gro_show_keyword,
4647 /* *** SET FLUSH CYCLES FOR GRO *** */
4648 struct cmd_gro_flush_result {
4649 cmdline_fixed_string_t cmd_set;
4650 cmdline_fixed_string_t cmd_keyword;
4651 cmdline_fixed_string_t cmd_flush;
4656 cmd_gro_flush_parsed(void *parsed_result,
4657 __attribute__((unused)) struct cmdline *cl,
4658 __attribute__((unused)) void *data)
4660 struct cmd_gro_flush_result *res;
4662 res = parsed_result;
4663 if ((!strcmp(res->cmd_keyword, "gro")) &&
4664 (!strcmp(res->cmd_flush, "flush")))
4665 setup_gro_flush_cycles(res->cmd_cycles);
4668 cmdline_parse_token_string_t cmd_gro_flush_set =
4669 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4671 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4672 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4673 cmd_keyword, "gro");
4674 cmdline_parse_token_string_t cmd_gro_flush_flush =
4675 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4676 cmd_flush, "flush");
4677 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4678 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4681 cmdline_parse_inst_t cmd_gro_flush = {
4682 .f = cmd_gro_flush_parsed,
4684 .help_str = "set gro flush <cycles>",
4686 (void *)&cmd_gro_flush_set,
4687 (void *)&cmd_gro_flush_keyword,
4688 (void *)&cmd_gro_flush_flush,
4689 (void *)&cmd_gro_flush_cycles,
4694 /* *** ENABLE/DISABLE GSO *** */
4695 struct cmd_gso_enable_result {
4696 cmdline_fixed_string_t cmd_set;
4697 cmdline_fixed_string_t cmd_port;
4698 cmdline_fixed_string_t cmd_keyword;
4699 cmdline_fixed_string_t cmd_mode;
4704 cmd_gso_enable_parsed(void *parsed_result,
4705 __attribute__((unused)) struct cmdline *cl,
4706 __attribute__((unused)) void *data)
4708 struct cmd_gso_enable_result *res;
4710 res = parsed_result;
4711 if (!strcmp(res->cmd_keyword, "gso"))
4712 setup_gso(res->cmd_mode, res->cmd_pid);
4715 cmdline_parse_token_string_t cmd_gso_enable_set =
4716 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4718 cmdline_parse_token_string_t cmd_gso_enable_port =
4719 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4721 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4722 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4723 cmd_keyword, "gso");
4724 cmdline_parse_token_string_t cmd_gso_enable_mode =
4725 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4726 cmd_mode, "on#off");
4727 cmdline_parse_token_num_t cmd_gso_enable_pid =
4728 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4731 cmdline_parse_inst_t cmd_gso_enable = {
4732 .f = cmd_gso_enable_parsed,
4734 .help_str = "set port <port_id> gso on|off",
4736 (void *)&cmd_gso_enable_set,
4737 (void *)&cmd_gso_enable_port,
4738 (void *)&cmd_gso_enable_pid,
4739 (void *)&cmd_gso_enable_keyword,
4740 (void *)&cmd_gso_enable_mode,
4745 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4746 struct cmd_gso_size_result {
4747 cmdline_fixed_string_t cmd_set;
4748 cmdline_fixed_string_t cmd_keyword;
4749 cmdline_fixed_string_t cmd_segsz;
4754 cmd_gso_size_parsed(void *parsed_result,
4755 __attribute__((unused)) struct cmdline *cl,
4756 __attribute__((unused)) void *data)
4758 struct cmd_gso_size_result *res = parsed_result;
4760 if (test_done == 0) {
4761 printf("Before setting GSO segsz, please first"
4762 " stop fowarding\n");
4766 if (!strcmp(res->cmd_keyword, "gso") &&
4767 !strcmp(res->cmd_segsz, "segsz")) {
4768 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4769 printf("gso_size should be larger than %zu."
4770 " Please input a legal value\n",
4771 RTE_GSO_SEG_SIZE_MIN);
4773 gso_max_segment_size = res->cmd_size;
4777 cmdline_parse_token_string_t cmd_gso_size_set =
4778 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4780 cmdline_parse_token_string_t cmd_gso_size_keyword =
4781 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4782 cmd_keyword, "gso");
4783 cmdline_parse_token_string_t cmd_gso_size_segsz =
4784 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4785 cmd_segsz, "segsz");
4786 cmdline_parse_token_num_t cmd_gso_size_size =
4787 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4790 cmdline_parse_inst_t cmd_gso_size = {
4791 .f = cmd_gso_size_parsed,
4793 .help_str = "set gso segsz <length>",
4795 (void *)&cmd_gso_size_set,
4796 (void *)&cmd_gso_size_keyword,
4797 (void *)&cmd_gso_size_segsz,
4798 (void *)&cmd_gso_size_size,
4803 /* *** SHOW GSO CONFIGURATION *** */
4804 struct cmd_gso_show_result {
4805 cmdline_fixed_string_t cmd_show;
4806 cmdline_fixed_string_t cmd_port;
4807 cmdline_fixed_string_t cmd_keyword;
4812 cmd_gso_show_parsed(void *parsed_result,
4813 __attribute__((unused)) struct cmdline *cl,
4814 __attribute__((unused)) void *data)
4816 struct cmd_gso_show_result *res = parsed_result;
4818 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4819 printf("invalid port id %u\n", res->cmd_pid);
4822 if (!strcmp(res->cmd_keyword, "gso")) {
4823 if (gso_ports[res->cmd_pid].enable) {
4824 printf("Max GSO'd packet size: %uB\n"
4825 "Supported GSO types: TCP/IPv4, "
4826 "UDP/IPv4, VxLAN with inner "
4827 "TCP/IPv4 packet, GRE with inner "
4828 "TCP/IPv4 packet\n",
4829 gso_max_segment_size);
4831 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4835 cmdline_parse_token_string_t cmd_gso_show_show =
4836 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4838 cmdline_parse_token_string_t cmd_gso_show_port =
4839 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4841 cmdline_parse_token_string_t cmd_gso_show_keyword =
4842 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4843 cmd_keyword, "gso");
4844 cmdline_parse_token_num_t cmd_gso_show_pid =
4845 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4848 cmdline_parse_inst_t cmd_gso_show = {
4849 .f = cmd_gso_show_parsed,
4851 .help_str = "show port <port_id> gso",
4853 (void *)&cmd_gso_show_show,
4854 (void *)&cmd_gso_show_port,
4855 (void *)&cmd_gso_show_pid,
4856 (void *)&cmd_gso_show_keyword,
4861 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4862 struct cmd_set_flush_rx {
4863 cmdline_fixed_string_t set;
4864 cmdline_fixed_string_t flush_rx;
4865 cmdline_fixed_string_t mode;
4869 cmd_set_flush_rx_parsed(void *parsed_result,
4870 __attribute__((unused)) struct cmdline *cl,
4871 __attribute__((unused)) void *data)
4873 struct cmd_set_flush_rx *res = parsed_result;
4874 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4877 cmdline_parse_token_string_t cmd_setflushrx_set =
4878 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4880 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4882 flush_rx, "flush_rx");
4883 cmdline_parse_token_string_t cmd_setflushrx_mode =
4884 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4888 cmdline_parse_inst_t cmd_set_flush_rx = {
4889 .f = cmd_set_flush_rx_parsed,
4890 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4893 (void *)&cmd_setflushrx_set,
4894 (void *)&cmd_setflushrx_flush_rx,
4895 (void *)&cmd_setflushrx_mode,
4900 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4901 struct cmd_set_link_check {
4902 cmdline_fixed_string_t set;
4903 cmdline_fixed_string_t link_check;
4904 cmdline_fixed_string_t mode;
4908 cmd_set_link_check_parsed(void *parsed_result,
4909 __attribute__((unused)) struct cmdline *cl,
4910 __attribute__((unused)) void *data)
4912 struct cmd_set_link_check *res = parsed_result;
4913 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4916 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4917 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4919 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4920 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4921 link_check, "link_check");
4922 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4923 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4927 cmdline_parse_inst_t cmd_set_link_check = {
4928 .f = cmd_set_link_check_parsed,
4929 .help_str = "set link_check on|off: Enable/Disable link status check "
4930 "when starting/stopping a port",
4933 (void *)&cmd_setlinkcheck_set,
4934 (void *)&cmd_setlinkcheck_link_check,
4935 (void *)&cmd_setlinkcheck_mode,
4940 /* *** SET NIC BYPASS MODE *** */
4941 struct cmd_set_bypass_mode_result {
4942 cmdline_fixed_string_t set;
4943 cmdline_fixed_string_t bypass;
4944 cmdline_fixed_string_t mode;
4945 cmdline_fixed_string_t value;
4950 cmd_set_bypass_mode_parsed(void *parsed_result,
4951 __attribute__((unused)) struct cmdline *cl,
4952 __attribute__((unused)) void *data)
4954 struct cmd_set_bypass_mode_result *res = parsed_result;
4955 portid_t port_id = res->port_id;
4956 int32_t rc = -EINVAL;
4958 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4959 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4961 if (!strcmp(res->value, "bypass"))
4962 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4963 else if (!strcmp(res->value, "isolate"))
4964 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4966 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4968 /* Set the bypass mode for the relevant port. */
4969 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4972 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4975 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4976 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4978 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4979 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4981 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4984 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4986 value, "normal#bypass#isolate");
4987 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4988 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4991 cmdline_parse_inst_t cmd_set_bypass_mode = {
4992 .f = cmd_set_bypass_mode_parsed,
4993 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4994 "Set the NIC bypass mode for port_id",
4997 (void *)&cmd_setbypass_mode_set,
4998 (void *)&cmd_setbypass_mode_bypass,
4999 (void *)&cmd_setbypass_mode_mode,
5000 (void *)&cmd_setbypass_mode_value,
5001 (void *)&cmd_setbypass_mode_port,
5006 /* *** SET NIC BYPASS EVENT *** */
5007 struct cmd_set_bypass_event_result {
5008 cmdline_fixed_string_t set;
5009 cmdline_fixed_string_t bypass;
5010 cmdline_fixed_string_t event;
5011 cmdline_fixed_string_t event_value;
5012 cmdline_fixed_string_t mode;
5013 cmdline_fixed_string_t mode_value;
5018 cmd_set_bypass_event_parsed(void *parsed_result,
5019 __attribute__((unused)) struct cmdline *cl,
5020 __attribute__((unused)) void *data)
5022 int32_t rc = -EINVAL;
5023 struct cmd_set_bypass_event_result *res = parsed_result;
5024 portid_t port_id = res->port_id;
5026 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5027 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5028 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5030 if (!strcmp(res->event_value, "timeout"))
5031 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5032 else if (!strcmp(res->event_value, "os_on"))
5033 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5034 else if (!strcmp(res->event_value, "os_off"))
5035 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5036 else if (!strcmp(res->event_value, "power_on"))
5037 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5038 else if (!strcmp(res->event_value, "power_off"))
5039 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5041 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5043 if (!strcmp(res->mode_value, "bypass"))
5044 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5045 else if (!strcmp(res->mode_value, "isolate"))
5046 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5048 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5050 /* Set the watchdog timeout. */
5051 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5054 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5055 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5059 printf("Failed to set timeout value %u "
5060 "for port %d, errto code: %d.\n",
5061 bypass_timeout, port_id, rc);
5065 /* Set the bypass event to transition to bypass mode. */
5066 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5071 printf("\t Failed to set bypass event for port = %d.\n",
5075 cmdline_parse_token_string_t cmd_setbypass_event_set =
5076 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5078 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5079 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5081 cmdline_parse_token_string_t cmd_setbypass_event_event =
5082 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5084 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5085 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5086 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5087 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5088 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5090 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5091 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5092 mode_value, "normal#bypass#isolate");
5093 cmdline_parse_token_num_t cmd_setbypass_event_port =
5094 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5097 cmdline_parse_inst_t cmd_set_bypass_event = {
5098 .f = cmd_set_bypass_event_parsed,
5099 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5100 "power_off mode normal|bypass|isolate <port_id>: "
5101 "Set the NIC bypass event mode for port_id",
5104 (void *)&cmd_setbypass_event_set,
5105 (void *)&cmd_setbypass_event_bypass,
5106 (void *)&cmd_setbypass_event_event,
5107 (void *)&cmd_setbypass_event_event_value,
5108 (void *)&cmd_setbypass_event_mode,
5109 (void *)&cmd_setbypass_event_mode_value,
5110 (void *)&cmd_setbypass_event_port,
5116 /* *** SET NIC BYPASS TIMEOUT *** */
5117 struct cmd_set_bypass_timeout_result {
5118 cmdline_fixed_string_t set;
5119 cmdline_fixed_string_t bypass;
5120 cmdline_fixed_string_t timeout;
5121 cmdline_fixed_string_t value;
5125 cmd_set_bypass_timeout_parsed(void *parsed_result,
5126 __attribute__((unused)) struct cmdline *cl,
5127 __attribute__((unused)) void *data)
5129 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5131 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5132 if (!strcmp(res->value, "1.5"))
5133 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5134 else if (!strcmp(res->value, "2"))
5135 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5136 else if (!strcmp(res->value, "3"))
5137 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5138 else if (!strcmp(res->value, "4"))
5139 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5140 else if (!strcmp(res->value, "8"))
5141 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5142 else if (!strcmp(res->value, "16"))
5143 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5144 else if (!strcmp(res->value, "32"))
5145 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5147 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5151 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5152 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5154 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5155 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5157 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5158 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5159 timeout, "timeout");
5160 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5161 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5162 value, "0#1.5#2#3#4#8#16#32");
5164 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5165 .f = cmd_set_bypass_timeout_parsed,
5166 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5167 "Set the NIC bypass watchdog timeout in seconds",
5170 (void *)&cmd_setbypass_timeout_set,
5171 (void *)&cmd_setbypass_timeout_bypass,
5172 (void *)&cmd_setbypass_timeout_timeout,
5173 (void *)&cmd_setbypass_timeout_value,
5178 /* *** SHOW NIC BYPASS MODE *** */
5179 struct cmd_show_bypass_config_result {
5180 cmdline_fixed_string_t show;
5181 cmdline_fixed_string_t bypass;
5182 cmdline_fixed_string_t config;
5187 cmd_show_bypass_config_parsed(void *parsed_result,
5188 __attribute__((unused)) struct cmdline *cl,
5189 __attribute__((unused)) void *data)
5191 struct cmd_show_bypass_config_result *res = parsed_result;
5192 portid_t port_id = res->port_id;
5194 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5195 uint32_t event_mode;
5196 uint32_t bypass_mode;
5197 uint32_t timeout = bypass_timeout;
5200 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5201 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5202 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5203 {"UNKNOWN", "normal", "bypass", "isolate"};
5204 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5211 int num_events = (sizeof events) / (sizeof events[0]);
5213 /* Display the bypass mode.*/
5214 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5215 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5219 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5220 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5222 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5225 /* Display the bypass timeout.*/
5226 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5227 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5229 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5231 /* Display the bypass events and associated modes. */
5232 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5234 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5235 printf("\tFailed to get bypass mode for event = %s\n",
5238 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5239 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5241 printf("\tbypass event: %-16s = %s\n", events[i],
5247 printf("\tFailed to get bypass configuration for port = %d\n",
5251 cmdline_parse_token_string_t cmd_showbypass_config_show =
5252 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5254 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5255 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5257 cmdline_parse_token_string_t cmd_showbypass_config_config =
5258 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5260 cmdline_parse_token_num_t cmd_showbypass_config_port =
5261 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5264 cmdline_parse_inst_t cmd_show_bypass_config = {
5265 .f = cmd_show_bypass_config_parsed,
5266 .help_str = "show bypass config <port_id>: "
5267 "Show the NIC bypass config for port_id",
5270 (void *)&cmd_showbypass_config_show,
5271 (void *)&cmd_showbypass_config_bypass,
5272 (void *)&cmd_showbypass_config_config,
5273 (void *)&cmd_showbypass_config_port,
5278 #ifdef RTE_LIBRTE_PMD_BOND
5279 /* *** SET BONDING MODE *** */
5280 struct cmd_set_bonding_mode_result {
5281 cmdline_fixed_string_t set;
5282 cmdline_fixed_string_t bonding;
5283 cmdline_fixed_string_t mode;
5288 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5289 __attribute__((unused)) struct cmdline *cl,
5290 __attribute__((unused)) void *data)
5292 struct cmd_set_bonding_mode_result *res = parsed_result;
5293 portid_t port_id = res->port_id;
5295 /* Set the bonding mode for the relevant port. */
5296 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5297 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5300 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5301 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5303 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5304 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5305 bonding, "bonding");
5306 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5307 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5309 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5310 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5312 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5313 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5316 cmdline_parse_inst_t cmd_set_bonding_mode = {
5317 .f = cmd_set_bonding_mode_parsed,
5318 .help_str = "set bonding mode <mode_value> <port_id>: "
5319 "Set the bonding mode for port_id",
5322 (void *) &cmd_setbonding_mode_set,
5323 (void *) &cmd_setbonding_mode_bonding,
5324 (void *) &cmd_setbonding_mode_mode,
5325 (void *) &cmd_setbonding_mode_value,
5326 (void *) &cmd_setbonding_mode_port,
5331 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5332 struct cmd_set_bonding_lacp_dedicated_queues_result {
5333 cmdline_fixed_string_t set;
5334 cmdline_fixed_string_t bonding;
5335 cmdline_fixed_string_t lacp;
5336 cmdline_fixed_string_t dedicated_queues;
5338 cmdline_fixed_string_t mode;
5341 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5342 __attribute__((unused)) struct cmdline *cl,
5343 __attribute__((unused)) void *data)
5345 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5346 portid_t port_id = res->port_id;
5347 struct rte_port *port;
5349 port = &ports[port_id];
5351 /** Check if the port is not started **/
5352 if (port->port_status != RTE_PORT_STOPPED) {
5353 printf("Please stop port %d first\n", port_id);
5357 if (!strcmp(res->mode, "enable")) {
5358 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5359 printf("Dedicate queues for LACP control packets"
5362 printf("Enabling dedicate queues for LACP control "
5363 "packets on port %d failed\n", port_id);
5364 } else if (!strcmp(res->mode, "disable")) {
5365 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5366 printf("Dedicated queues for LACP control packets "
5369 printf("Disabling dedicated queues for LACP control "
5370 "traffic on port %d failed\n", port_id);
5374 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5375 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5377 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5378 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5379 bonding, "bonding");
5380 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5381 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5383 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5384 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5385 dedicated_queues, "dedicated_queues");
5386 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5387 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5389 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5390 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5391 mode, "enable#disable");
5393 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5394 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5395 .help_str = "set bonding lacp dedicated_queues <port_id> "
5397 "Enable/disable dedicated queues for LACP control traffic for port_id",
5400 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5401 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5402 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5403 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5404 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5405 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5410 /* *** SET BALANCE XMIT POLICY *** */
5411 struct cmd_set_bonding_balance_xmit_policy_result {
5412 cmdline_fixed_string_t set;
5413 cmdline_fixed_string_t bonding;
5414 cmdline_fixed_string_t balance_xmit_policy;
5416 cmdline_fixed_string_t policy;
5419 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5420 __attribute__((unused)) struct cmdline *cl,
5421 __attribute__((unused)) void *data)
5423 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5424 portid_t port_id = res->port_id;
5427 if (!strcmp(res->policy, "l2")) {
5428 policy = BALANCE_XMIT_POLICY_LAYER2;
5429 } else if (!strcmp(res->policy, "l23")) {
5430 policy = BALANCE_XMIT_POLICY_LAYER23;
5431 } else if (!strcmp(res->policy, "l34")) {
5432 policy = BALANCE_XMIT_POLICY_LAYER34;
5434 printf("\t Invalid xmit policy selection");
5438 /* Set the bonding mode for the relevant port. */
5439 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5440 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5445 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5448 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5449 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5450 bonding, "bonding");
5451 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5452 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5453 balance_xmit_policy, "balance_xmit_policy");
5454 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5455 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5457 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5458 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5459 policy, "l2#l23#l34");
5461 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5462 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5463 .help_str = "set bonding balance_xmit_policy <port_id> "
5465 "Set the bonding balance_xmit_policy for port_id",
5468 (void *)&cmd_setbonding_balance_xmit_policy_set,
5469 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5470 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5471 (void *)&cmd_setbonding_balance_xmit_policy_port,
5472 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5477 /* *** SHOW NIC BONDING CONFIGURATION *** */
5478 struct cmd_show_bonding_config_result {
5479 cmdline_fixed_string_t show;
5480 cmdline_fixed_string_t bonding;
5481 cmdline_fixed_string_t config;
5485 static void cmd_show_bonding_config_parsed(void *parsed_result,
5486 __attribute__((unused)) struct cmdline *cl,
5487 __attribute__((unused)) void *data)
5489 struct cmd_show_bonding_config_result *res = parsed_result;
5490 int bonding_mode, agg_mode;
5491 portid_t slaves[RTE_MAX_ETHPORTS];
5492 int num_slaves, num_active_slaves;
5495 portid_t port_id = res->port_id;
5497 /* Display the bonding mode.*/
5498 bonding_mode = rte_eth_bond_mode_get(port_id);
5499 if (bonding_mode < 0) {
5500 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5503 printf("\tBonding mode: %d\n", bonding_mode);
5505 if (bonding_mode == BONDING_MODE_BALANCE) {
5506 int balance_xmit_policy;
5508 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5509 if (balance_xmit_policy < 0) {
5510 printf("\tFailed to get balance xmit policy for port = %d\n",
5514 printf("\tBalance Xmit Policy: ");
5516 switch (balance_xmit_policy) {
5517 case BALANCE_XMIT_POLICY_LAYER2:
5518 printf("BALANCE_XMIT_POLICY_LAYER2");
5520 case BALANCE_XMIT_POLICY_LAYER23:
5521 printf("BALANCE_XMIT_POLICY_LAYER23");
5523 case BALANCE_XMIT_POLICY_LAYER34:
5524 printf("BALANCE_XMIT_POLICY_LAYER34");
5531 if (bonding_mode == BONDING_MODE_8023AD) {
5532 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5533 printf("\tIEEE802.3AD Aggregator Mode: ");
5536 printf("bandwidth");
5548 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5550 if (num_slaves < 0) {
5551 printf("\tFailed to get slave list for port = %d\n", port_id);
5554 if (num_slaves > 0) {
5555 printf("\tSlaves (%d): [", num_slaves);
5556 for (i = 0; i < num_slaves - 1; i++)
5557 printf("%d ", slaves[i]);
5559 printf("%d]\n", slaves[num_slaves - 1]);
5561 printf("\tSlaves: []\n");
5565 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5568 if (num_active_slaves < 0) {
5569 printf("\tFailed to get active slave list for port = %d\n", port_id);
5572 if (num_active_slaves > 0) {
5573 printf("\tActive Slaves (%d): [", num_active_slaves);
5574 for (i = 0; i < num_active_slaves - 1; i++)
5575 printf("%d ", slaves[i]);
5577 printf("%d]\n", slaves[num_active_slaves - 1]);
5580 printf("\tActive Slaves: []\n");
5584 primary_id = rte_eth_bond_primary_get(port_id);
5585 if (primary_id < 0) {
5586 printf("\tFailed to get primary slave for port = %d\n", port_id);
5589 printf("\tPrimary: [%d]\n", primary_id);
5593 cmdline_parse_token_string_t cmd_showbonding_config_show =
5594 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5596 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5597 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5598 bonding, "bonding");
5599 cmdline_parse_token_string_t cmd_showbonding_config_config =
5600 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5602 cmdline_parse_token_num_t cmd_showbonding_config_port =
5603 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5606 cmdline_parse_inst_t cmd_show_bonding_config = {
5607 .f = cmd_show_bonding_config_parsed,
5608 .help_str = "show bonding config <port_id>: "
5609 "Show the bonding config for port_id",
5612 (void *)&cmd_showbonding_config_show,
5613 (void *)&cmd_showbonding_config_bonding,
5614 (void *)&cmd_showbonding_config_config,
5615 (void *)&cmd_showbonding_config_port,
5620 /* *** SET BONDING PRIMARY *** */
5621 struct cmd_set_bonding_primary_result {
5622 cmdline_fixed_string_t set;
5623 cmdline_fixed_string_t bonding;
5624 cmdline_fixed_string_t primary;
5629 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5630 __attribute__((unused)) struct cmdline *cl,
5631 __attribute__((unused)) void *data)
5633 struct cmd_set_bonding_primary_result *res = parsed_result;
5634 portid_t master_port_id = res->port_id;
5635 portid_t slave_port_id = res->slave_id;
5637 /* Set the primary slave for a bonded device. */
5638 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5639 printf("\t Failed to set primary slave for port = %d.\n",
5646 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5647 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5649 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5650 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5651 bonding, "bonding");
5652 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5653 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5654 primary, "primary");
5655 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5656 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5658 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5659 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5662 cmdline_parse_inst_t cmd_set_bonding_primary = {
5663 .f = cmd_set_bonding_primary_parsed,
5664 .help_str = "set bonding primary <slave_id> <port_id>: "
5665 "Set the primary slave for port_id",
5668 (void *)&cmd_setbonding_primary_set,
5669 (void *)&cmd_setbonding_primary_bonding,
5670 (void *)&cmd_setbonding_primary_primary,
5671 (void *)&cmd_setbonding_primary_slave,
5672 (void *)&cmd_setbonding_primary_port,
5677 /* *** ADD SLAVE *** */
5678 struct cmd_add_bonding_slave_result {
5679 cmdline_fixed_string_t add;
5680 cmdline_fixed_string_t bonding;
5681 cmdline_fixed_string_t slave;
5686 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5687 __attribute__((unused)) struct cmdline *cl,
5688 __attribute__((unused)) void *data)
5690 struct cmd_add_bonding_slave_result *res = parsed_result;
5691 portid_t master_port_id = res->port_id;
5692 portid_t slave_port_id = res->slave_id;
5694 /* add the slave for a bonded device. */
5695 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5696 printf("\t Failed to add slave %d to master port = %d.\n",
5697 slave_port_id, master_port_id);
5701 set_port_slave_flag(slave_port_id);
5704 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5705 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5707 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5708 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5709 bonding, "bonding");
5710 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5711 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5713 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5714 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5716 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5717 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5720 cmdline_parse_inst_t cmd_add_bonding_slave = {
5721 .f = cmd_add_bonding_slave_parsed,
5722 .help_str = "add bonding slave <slave_id> <port_id>: "
5723 "Add a slave device to a bonded device",
5726 (void *)&cmd_addbonding_slave_add,
5727 (void *)&cmd_addbonding_slave_bonding,
5728 (void *)&cmd_addbonding_slave_slave,
5729 (void *)&cmd_addbonding_slave_slaveid,
5730 (void *)&cmd_addbonding_slave_port,
5735 /* *** REMOVE SLAVE *** */
5736 struct cmd_remove_bonding_slave_result {
5737 cmdline_fixed_string_t remove;
5738 cmdline_fixed_string_t bonding;
5739 cmdline_fixed_string_t slave;
5744 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5745 __attribute__((unused)) struct cmdline *cl,
5746 __attribute__((unused)) void *data)
5748 struct cmd_remove_bonding_slave_result *res = parsed_result;
5749 portid_t master_port_id = res->port_id;
5750 portid_t slave_port_id = res->slave_id;
5752 /* remove the slave from a bonded device. */
5753 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5754 printf("\t Failed to remove slave %d from master port = %d.\n",
5755 slave_port_id, master_port_id);
5759 clear_port_slave_flag(slave_port_id);
5762 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5763 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5765 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5766 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5767 bonding, "bonding");
5768 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5769 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5771 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5772 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5774 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5775 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5778 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5779 .f = cmd_remove_bonding_slave_parsed,
5780 .help_str = "remove bonding slave <slave_id> <port_id>: "
5781 "Remove a slave device from a bonded device",
5784 (void *)&cmd_removebonding_slave_remove,
5785 (void *)&cmd_removebonding_slave_bonding,
5786 (void *)&cmd_removebonding_slave_slave,
5787 (void *)&cmd_removebonding_slave_slaveid,
5788 (void *)&cmd_removebonding_slave_port,
5793 /* *** CREATE BONDED DEVICE *** */
5794 struct cmd_create_bonded_device_result {
5795 cmdline_fixed_string_t create;
5796 cmdline_fixed_string_t bonded;
5797 cmdline_fixed_string_t device;
5802 static int bond_dev_num = 0;
5804 static void cmd_create_bonded_device_parsed(void *parsed_result,
5805 __attribute__((unused)) struct cmdline *cl,
5806 __attribute__((unused)) void *data)
5808 struct cmd_create_bonded_device_result *res = parsed_result;
5809 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5812 if (test_done == 0) {
5813 printf("Please stop forwarding first\n");
5817 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5820 /* Create a new bonded device. */
5821 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5823 printf("\t Failed to create bonded device.\n");
5826 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5829 /* Update number of ports */
5830 nb_ports = rte_eth_dev_count_avail();
5831 reconfig(port_id, res->socket);
5832 rte_eth_promiscuous_enable(port_id);
5837 cmdline_parse_token_string_t cmd_createbonded_device_create =
5838 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5840 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5841 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5843 cmdline_parse_token_string_t cmd_createbonded_device_device =
5844 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5846 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5847 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5849 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5850 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5853 cmdline_parse_inst_t cmd_create_bonded_device = {
5854 .f = cmd_create_bonded_device_parsed,
5855 .help_str = "create bonded device <mode> <socket>: "
5856 "Create a new bonded device with specific bonding mode and socket",
5859 (void *)&cmd_createbonded_device_create,
5860 (void *)&cmd_createbonded_device_bonded,
5861 (void *)&cmd_createbonded_device_device,
5862 (void *)&cmd_createbonded_device_mode,
5863 (void *)&cmd_createbonded_device_socket,
5868 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5869 struct cmd_set_bond_mac_addr_result {
5870 cmdline_fixed_string_t set;
5871 cmdline_fixed_string_t bonding;
5872 cmdline_fixed_string_t mac_addr;
5874 struct ether_addr address;
5877 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5878 __attribute__((unused)) struct cmdline *cl,
5879 __attribute__((unused)) void *data)
5881 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5884 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5887 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5889 /* check the return value and print it if is < 0 */
5891 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5894 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5895 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5896 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5897 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5899 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5900 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5902 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5903 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5905 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5906 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5908 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5909 .f = cmd_set_bond_mac_addr_parsed,
5911 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5913 (void *)&cmd_set_bond_mac_addr_set,
5914 (void *)&cmd_set_bond_mac_addr_bonding,
5915 (void *)&cmd_set_bond_mac_addr_mac,
5916 (void *)&cmd_set_bond_mac_addr_portnum,
5917 (void *)&cmd_set_bond_mac_addr_addr,
5923 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5924 struct cmd_set_bond_mon_period_result {
5925 cmdline_fixed_string_t set;
5926 cmdline_fixed_string_t bonding;
5927 cmdline_fixed_string_t mon_period;
5932 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5933 __attribute__((unused)) struct cmdline *cl,
5934 __attribute__((unused)) void *data)
5936 struct cmd_set_bond_mon_period_result *res = parsed_result;
5939 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5941 /* check the return value and print it if is < 0 */
5943 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5946 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5947 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5949 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5950 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5951 bonding, "bonding");
5952 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5953 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5954 mon_period, "mon_period");
5955 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5956 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5958 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5959 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5962 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5963 .f = cmd_set_bond_mon_period_parsed,
5965 .help_str = "set bonding mon_period <port_id> <period_ms>",
5967 (void *)&cmd_set_bond_mon_period_set,
5968 (void *)&cmd_set_bond_mon_period_bonding,
5969 (void *)&cmd_set_bond_mon_period_mon_period,
5970 (void *)&cmd_set_bond_mon_period_portnum,
5971 (void *)&cmd_set_bond_mon_period_period_ms,
5978 struct cmd_set_bonding_agg_mode_policy_result {
5979 cmdline_fixed_string_t set;
5980 cmdline_fixed_string_t bonding;
5981 cmdline_fixed_string_t agg_mode;
5983 cmdline_fixed_string_t policy;
5988 cmd_set_bonding_agg_mode(void *parsed_result,
5989 __attribute__((unused)) struct cmdline *cl,
5990 __attribute__((unused)) void *data)
5992 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5993 uint8_t policy = AGG_BANDWIDTH;
5995 if (!strcmp(res->policy, "bandwidth"))
5996 policy = AGG_BANDWIDTH;
5997 else if (!strcmp(res->policy, "stable"))
5998 policy = AGG_STABLE;
5999 else if (!strcmp(res->policy, "count"))
6002 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6006 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6007 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6009 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6010 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6011 bonding, "bonding");
6013 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6014 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6015 agg_mode, "agg_mode");
6017 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6018 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6021 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6022 TOKEN_STRING_INITIALIZER(
6023 struct cmd_set_bonding_balance_xmit_policy_result,
6024 policy, "stable#bandwidth#count");
6026 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6027 .f = cmd_set_bonding_agg_mode,
6029 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6031 (void *)&cmd_set_bonding_agg_mode_set,
6032 (void *)&cmd_set_bonding_agg_mode_bonding,
6033 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6034 (void *)&cmd_set_bonding_agg_mode_portnum,
6035 (void *)&cmd_set_bonding_agg_mode_policy_string,
6041 #endif /* RTE_LIBRTE_PMD_BOND */
6043 /* *** SET FORWARDING MODE *** */
6044 struct cmd_set_fwd_mode_result {
6045 cmdline_fixed_string_t set;
6046 cmdline_fixed_string_t fwd;
6047 cmdline_fixed_string_t mode;
6050 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6051 __attribute__((unused)) struct cmdline *cl,
6052 __attribute__((unused)) void *data)
6054 struct cmd_set_fwd_mode_result *res = parsed_result;
6057 set_pkt_forwarding_mode(res->mode);
6060 cmdline_parse_token_string_t cmd_setfwd_set =
6061 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6062 cmdline_parse_token_string_t cmd_setfwd_fwd =
6063 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6064 cmdline_parse_token_string_t cmd_setfwd_mode =
6065 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6066 "" /* defined at init */);
6068 cmdline_parse_inst_t cmd_set_fwd_mode = {
6069 .f = cmd_set_fwd_mode_parsed,
6071 .help_str = NULL, /* defined at init */
6073 (void *)&cmd_setfwd_set,
6074 (void *)&cmd_setfwd_fwd,
6075 (void *)&cmd_setfwd_mode,
6080 static void cmd_set_fwd_mode_init(void)
6083 static char token[128];
6084 static char help[256];
6085 cmdline_parse_token_string_t *token_struct;
6087 modes = list_pkt_forwarding_modes();
6088 snprintf(help, sizeof(help), "set fwd %s: "
6089 "Set packet forwarding mode", modes);
6090 cmd_set_fwd_mode.help_str = help;
6092 /* string token separator is # */
6093 for (c = token; *modes != '\0'; modes++)
6098 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6099 token_struct->string_data.str = token;
6102 /* *** SET RETRY FORWARDING MODE *** */
6103 struct cmd_set_fwd_retry_mode_result {
6104 cmdline_fixed_string_t set;
6105 cmdline_fixed_string_t fwd;
6106 cmdline_fixed_string_t mode;
6107 cmdline_fixed_string_t retry;
6110 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6111 __attribute__((unused)) struct cmdline *cl,
6112 __attribute__((unused)) void *data)
6114 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6117 set_pkt_forwarding_mode(res->mode);
6120 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6121 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6123 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6124 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6126 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6127 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6129 "" /* defined at init */);
6130 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6131 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6134 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6135 .f = cmd_set_fwd_retry_mode_parsed,
6137 .help_str = NULL, /* defined at init */
6139 (void *)&cmd_setfwd_retry_set,
6140 (void *)&cmd_setfwd_retry_fwd,
6141 (void *)&cmd_setfwd_retry_mode,
6142 (void *)&cmd_setfwd_retry_retry,
6147 static void cmd_set_fwd_retry_mode_init(void)
6150 static char token[128];
6151 static char help[256];
6152 cmdline_parse_token_string_t *token_struct;
6154 modes = list_pkt_forwarding_retry_modes();
6155 snprintf(help, sizeof(help), "set fwd %s retry: "
6156 "Set packet forwarding mode with retry", modes);
6157 cmd_set_fwd_retry_mode.help_str = help;
6159 /* string token separator is # */
6160 for (c = token; *modes != '\0'; modes++)
6165 token_struct = (cmdline_parse_token_string_t *)
6166 cmd_set_fwd_retry_mode.tokens[2];
6167 token_struct->string_data.str = token;
6170 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6171 struct cmd_set_burst_tx_retry_result {
6172 cmdline_fixed_string_t set;
6173 cmdline_fixed_string_t burst;
6174 cmdline_fixed_string_t tx;
6175 cmdline_fixed_string_t delay;
6177 cmdline_fixed_string_t retry;
6181 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6182 __attribute__((unused)) struct cmdline *cl,
6183 __attribute__((unused)) void *data)
6185 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6187 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6188 && !strcmp(res->tx, "tx")) {
6189 if (!strcmp(res->delay, "delay"))
6190 burst_tx_delay_time = res->time;
6191 if (!strcmp(res->retry, "retry"))
6192 burst_tx_retry_num = res->retry_num;
6197 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6198 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6199 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6200 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6202 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6203 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6204 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6205 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6206 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6207 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6208 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6209 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6210 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6211 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6213 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6214 .f = cmd_set_burst_tx_retry_parsed,
6215 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6217 (void *)&cmd_set_burst_tx_retry_set,
6218 (void *)&cmd_set_burst_tx_retry_burst,
6219 (void *)&cmd_set_burst_tx_retry_tx,
6220 (void *)&cmd_set_burst_tx_retry_delay,
6221 (void *)&cmd_set_burst_tx_retry_time,
6222 (void *)&cmd_set_burst_tx_retry_retry,
6223 (void *)&cmd_set_burst_tx_retry_retry_num,
6228 /* *** SET PROMISC MODE *** */
6229 struct cmd_set_promisc_mode_result {
6230 cmdline_fixed_string_t set;
6231 cmdline_fixed_string_t promisc;
6232 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6233 uint16_t port_num; /* valid if "allports" argument == 0 */
6234 cmdline_fixed_string_t mode;
6237 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6238 __attribute__((unused)) struct cmdline *cl,
6241 struct cmd_set_promisc_mode_result *res = parsed_result;
6245 if (!strcmp(res->mode, "on"))
6252 RTE_ETH_FOREACH_DEV(i) {
6254 rte_eth_promiscuous_enable(i);
6256 rte_eth_promiscuous_disable(i);
6261 rte_eth_promiscuous_enable(res->port_num);
6263 rte_eth_promiscuous_disable(res->port_num);
6267 cmdline_parse_token_string_t cmd_setpromisc_set =
6268 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6269 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6270 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6272 cmdline_parse_token_string_t cmd_setpromisc_portall =
6273 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6275 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6276 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6278 cmdline_parse_token_string_t cmd_setpromisc_mode =
6279 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6282 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6283 .f = cmd_set_promisc_mode_parsed,
6285 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6287 (void *)&cmd_setpromisc_set,
6288 (void *)&cmd_setpromisc_promisc,
6289 (void *)&cmd_setpromisc_portall,
6290 (void *)&cmd_setpromisc_mode,
6295 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6296 .f = cmd_set_promisc_mode_parsed,
6298 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6300 (void *)&cmd_setpromisc_set,
6301 (void *)&cmd_setpromisc_promisc,
6302 (void *)&cmd_setpromisc_portnum,
6303 (void *)&cmd_setpromisc_mode,
6308 /* *** SET ALLMULTI MODE *** */
6309 struct cmd_set_allmulti_mode_result {
6310 cmdline_fixed_string_t set;
6311 cmdline_fixed_string_t allmulti;
6312 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6313 uint16_t port_num; /* valid if "allports" argument == 0 */
6314 cmdline_fixed_string_t mode;
6317 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6318 __attribute__((unused)) struct cmdline *cl,
6321 struct cmd_set_allmulti_mode_result *res = parsed_result;
6325 if (!strcmp(res->mode, "on"))
6332 RTE_ETH_FOREACH_DEV(i) {
6334 rte_eth_allmulticast_enable(i);
6336 rte_eth_allmulticast_disable(i);
6341 rte_eth_allmulticast_enable(res->port_num);
6343 rte_eth_allmulticast_disable(res->port_num);
6347 cmdline_parse_token_string_t cmd_setallmulti_set =
6348 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6349 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6350 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6352 cmdline_parse_token_string_t cmd_setallmulti_portall =
6353 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6355 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6356 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6358 cmdline_parse_token_string_t cmd_setallmulti_mode =
6359 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6362 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6363 .f = cmd_set_allmulti_mode_parsed,
6365 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6367 (void *)&cmd_setallmulti_set,
6368 (void *)&cmd_setallmulti_allmulti,
6369 (void *)&cmd_setallmulti_portall,
6370 (void *)&cmd_setallmulti_mode,
6375 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6376 .f = cmd_set_allmulti_mode_parsed,
6378 .help_str = "set allmulti <port_id> on|off: "
6379 "Set allmulti mode on port_id",
6381 (void *)&cmd_setallmulti_set,
6382 (void *)&cmd_setallmulti_allmulti,
6383 (void *)&cmd_setallmulti_portnum,
6384 (void *)&cmd_setallmulti_mode,
6389 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6390 struct cmd_link_flow_ctrl_set_result {
6391 cmdline_fixed_string_t set;
6392 cmdline_fixed_string_t flow_ctrl;
6393 cmdline_fixed_string_t rx;
6394 cmdline_fixed_string_t rx_lfc_mode;
6395 cmdline_fixed_string_t tx;
6396 cmdline_fixed_string_t tx_lfc_mode;
6397 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6398 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6399 cmdline_fixed_string_t autoneg_str;
6400 cmdline_fixed_string_t autoneg;
6401 cmdline_fixed_string_t hw_str;
6402 uint32_t high_water;
6403 cmdline_fixed_string_t lw_str;
6405 cmdline_fixed_string_t pt_str;
6406 uint16_t pause_time;
6407 cmdline_fixed_string_t xon_str;
6412 cmdline_parse_token_string_t cmd_lfc_set_set =
6413 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6415 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6416 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6417 flow_ctrl, "flow_ctrl");
6418 cmdline_parse_token_string_t cmd_lfc_set_rx =
6419 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6421 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6423 rx_lfc_mode, "on#off");
6424 cmdline_parse_token_string_t cmd_lfc_set_tx =
6425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6427 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6429 tx_lfc_mode, "on#off");
6430 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6432 hw_str, "high_water");
6433 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6434 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6435 high_water, UINT32);
6436 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6437 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6438 lw_str, "low_water");
6439 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6440 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6442 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6443 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6444 pt_str, "pause_time");
6445 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6446 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6447 pause_time, UINT16);
6448 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6449 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6450 xon_str, "send_xon");
6451 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6452 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6454 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6455 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6456 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6457 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6458 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6459 mac_ctrl_frame_fwd_mode, "on#off");
6460 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6461 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6462 autoneg_str, "autoneg");
6463 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6464 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6466 cmdline_parse_token_num_t cmd_lfc_set_portid =
6467 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6470 /* forward declaration */
6472 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6475 cmdline_parse_inst_t cmd_link_flow_control_set = {
6476 .f = cmd_link_flow_ctrl_set_parsed,
6478 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6479 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6480 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6482 (void *)&cmd_lfc_set_set,
6483 (void *)&cmd_lfc_set_flow_ctrl,
6484 (void *)&cmd_lfc_set_rx,
6485 (void *)&cmd_lfc_set_rx_mode,
6486 (void *)&cmd_lfc_set_tx,
6487 (void *)&cmd_lfc_set_tx_mode,
6488 (void *)&cmd_lfc_set_high_water,
6489 (void *)&cmd_lfc_set_low_water,
6490 (void *)&cmd_lfc_set_pause_time,
6491 (void *)&cmd_lfc_set_send_xon,
6492 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6493 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6494 (void *)&cmd_lfc_set_autoneg_str,
6495 (void *)&cmd_lfc_set_autoneg,
6496 (void *)&cmd_lfc_set_portid,
6501 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6502 .f = cmd_link_flow_ctrl_set_parsed,
6503 .data = (void *)&cmd_link_flow_control_set_rx,
6504 .help_str = "set flow_ctrl rx on|off <port_id>: "
6505 "Change rx flow control parameter",
6507 (void *)&cmd_lfc_set_set,
6508 (void *)&cmd_lfc_set_flow_ctrl,
6509 (void *)&cmd_lfc_set_rx,
6510 (void *)&cmd_lfc_set_rx_mode,
6511 (void *)&cmd_lfc_set_portid,
6516 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6517 .f = cmd_link_flow_ctrl_set_parsed,
6518 .data = (void *)&cmd_link_flow_control_set_tx,
6519 .help_str = "set flow_ctrl tx on|off <port_id>: "
6520 "Change tx flow control parameter",
6522 (void *)&cmd_lfc_set_set,
6523 (void *)&cmd_lfc_set_flow_ctrl,
6524 (void *)&cmd_lfc_set_tx,
6525 (void *)&cmd_lfc_set_tx_mode,
6526 (void *)&cmd_lfc_set_portid,
6531 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6532 .f = cmd_link_flow_ctrl_set_parsed,
6533 .data = (void *)&cmd_link_flow_control_set_hw,
6534 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6535 "Change high water flow control parameter",
6537 (void *)&cmd_lfc_set_set,
6538 (void *)&cmd_lfc_set_flow_ctrl,
6539 (void *)&cmd_lfc_set_high_water_str,
6540 (void *)&cmd_lfc_set_high_water,
6541 (void *)&cmd_lfc_set_portid,
6546 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6547 .f = cmd_link_flow_ctrl_set_parsed,
6548 .data = (void *)&cmd_link_flow_control_set_lw,
6549 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6550 "Change low water flow control parameter",
6552 (void *)&cmd_lfc_set_set,
6553 (void *)&cmd_lfc_set_flow_ctrl,
6554 (void *)&cmd_lfc_set_low_water_str,
6555 (void *)&cmd_lfc_set_low_water,
6556 (void *)&cmd_lfc_set_portid,
6561 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6562 .f = cmd_link_flow_ctrl_set_parsed,
6563 .data = (void *)&cmd_link_flow_control_set_pt,
6564 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6565 "Change pause time flow control parameter",
6567 (void *)&cmd_lfc_set_set,
6568 (void *)&cmd_lfc_set_flow_ctrl,
6569 (void *)&cmd_lfc_set_pause_time_str,
6570 (void *)&cmd_lfc_set_pause_time,
6571 (void *)&cmd_lfc_set_portid,
6576 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6577 .f = cmd_link_flow_ctrl_set_parsed,
6578 .data = (void *)&cmd_link_flow_control_set_xon,
6579 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6580 "Change send_xon flow control parameter",
6582 (void *)&cmd_lfc_set_set,
6583 (void *)&cmd_lfc_set_flow_ctrl,
6584 (void *)&cmd_lfc_set_send_xon_str,
6585 (void *)&cmd_lfc_set_send_xon,
6586 (void *)&cmd_lfc_set_portid,
6591 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6592 .f = cmd_link_flow_ctrl_set_parsed,
6593 .data = (void *)&cmd_link_flow_control_set_macfwd,
6594 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6595 "Change mac ctrl fwd flow control parameter",
6597 (void *)&cmd_lfc_set_set,
6598 (void *)&cmd_lfc_set_flow_ctrl,
6599 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6600 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6601 (void *)&cmd_lfc_set_portid,
6606 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6607 .f = cmd_link_flow_ctrl_set_parsed,
6608 .data = (void *)&cmd_link_flow_control_set_autoneg,
6609 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6610 "Change autoneg flow control parameter",
6612 (void *)&cmd_lfc_set_set,
6613 (void *)&cmd_lfc_set_flow_ctrl,
6614 (void *)&cmd_lfc_set_autoneg_str,
6615 (void *)&cmd_lfc_set_autoneg,
6616 (void *)&cmd_lfc_set_portid,
6622 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6623 __attribute__((unused)) struct cmdline *cl,
6626 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6627 cmdline_parse_inst_t *cmd = data;
6628 struct rte_eth_fc_conf fc_conf;
6634 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6635 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6636 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6637 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6639 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6640 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6643 /* Partial command line, retrieve current configuration */
6645 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6647 printf("cannot get current flow ctrl parameters, return"
6648 "code = %d\n", ret);
6652 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6653 (fc_conf.mode == RTE_FC_FULL))
6655 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6656 (fc_conf.mode == RTE_FC_FULL))
6660 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6661 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6663 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6664 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6666 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6668 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6669 fc_conf.high_water = res->high_water;
6671 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6672 fc_conf.low_water = res->low_water;
6674 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6675 fc_conf.pause_time = res->pause_time;
6677 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6678 fc_conf.send_xon = res->send_xon;
6680 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6681 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6682 fc_conf.mac_ctrl_frame_fwd = 1;
6684 fc_conf.mac_ctrl_frame_fwd = 0;
6687 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6688 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6690 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6692 printf("bad flow contrl parameter, return code = %d \n", ret);
6695 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6696 struct cmd_priority_flow_ctrl_set_result {
6697 cmdline_fixed_string_t set;
6698 cmdline_fixed_string_t pfc_ctrl;
6699 cmdline_fixed_string_t rx;
6700 cmdline_fixed_string_t rx_pfc_mode;
6701 cmdline_fixed_string_t tx;
6702 cmdline_fixed_string_t tx_pfc_mode;
6703 uint32_t high_water;
6705 uint16_t pause_time;
6711 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6712 __attribute__((unused)) struct cmdline *cl,
6713 __attribute__((unused)) void *data)
6715 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6716 struct rte_eth_pfc_conf pfc_conf;
6717 int rx_fc_enable, tx_fc_enable;
6721 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6722 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6723 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6724 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6726 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6727 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6730 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6731 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6732 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6733 pfc_conf.fc.high_water = res->high_water;
6734 pfc_conf.fc.low_water = res->low_water;
6735 pfc_conf.fc.pause_time = res->pause_time;
6736 pfc_conf.priority = res->priority;
6738 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6740 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6743 cmdline_parse_token_string_t cmd_pfc_set_set =
6744 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6746 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6747 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6748 pfc_ctrl, "pfc_ctrl");
6749 cmdline_parse_token_string_t cmd_pfc_set_rx =
6750 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6752 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6753 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6754 rx_pfc_mode, "on#off");
6755 cmdline_parse_token_string_t cmd_pfc_set_tx =
6756 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6758 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6759 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6760 tx_pfc_mode, "on#off");
6761 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6762 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6763 high_water, UINT32);
6764 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6765 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6767 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6768 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6769 pause_time, UINT16);
6770 cmdline_parse_token_num_t cmd_pfc_set_priority =
6771 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6773 cmdline_parse_token_num_t cmd_pfc_set_portid =
6774 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6777 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6778 .f = cmd_priority_flow_ctrl_set_parsed,
6780 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6781 "<pause_time> <priority> <port_id>: "
6782 "Configure the Ethernet priority flow control",
6784 (void *)&cmd_pfc_set_set,
6785 (void *)&cmd_pfc_set_flow_ctrl,
6786 (void *)&cmd_pfc_set_rx,
6787 (void *)&cmd_pfc_set_rx_mode,
6788 (void *)&cmd_pfc_set_tx,
6789 (void *)&cmd_pfc_set_tx_mode,
6790 (void *)&cmd_pfc_set_high_water,
6791 (void *)&cmd_pfc_set_low_water,
6792 (void *)&cmd_pfc_set_pause_time,
6793 (void *)&cmd_pfc_set_priority,
6794 (void *)&cmd_pfc_set_portid,
6799 /* *** RESET CONFIGURATION *** */
6800 struct cmd_reset_result {
6801 cmdline_fixed_string_t reset;
6802 cmdline_fixed_string_t def;
6805 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6807 __attribute__((unused)) void *data)
6809 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6810 set_def_fwd_config();
6813 cmdline_parse_token_string_t cmd_reset_set =
6814 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6815 cmdline_parse_token_string_t cmd_reset_def =
6816 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6819 cmdline_parse_inst_t cmd_reset = {
6820 .f = cmd_reset_parsed,
6822 .help_str = "set default: Reset default forwarding configuration",
6824 (void *)&cmd_reset_set,
6825 (void *)&cmd_reset_def,
6830 /* *** START FORWARDING *** */
6831 struct cmd_start_result {
6832 cmdline_fixed_string_t start;
6835 cmdline_parse_token_string_t cmd_start_start =
6836 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6838 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6839 __attribute__((unused)) struct cmdline *cl,
6840 __attribute__((unused)) void *data)
6842 start_packet_forwarding(0);
6845 cmdline_parse_inst_t cmd_start = {
6846 .f = cmd_start_parsed,
6848 .help_str = "start: Start packet forwarding",
6850 (void *)&cmd_start_start,
6855 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6856 struct cmd_start_tx_first_result {
6857 cmdline_fixed_string_t start;
6858 cmdline_fixed_string_t tx_first;
6862 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6863 __attribute__((unused)) struct cmdline *cl,
6864 __attribute__((unused)) void *data)
6866 start_packet_forwarding(1);
6869 cmdline_parse_token_string_t cmd_start_tx_first_start =
6870 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6872 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6873 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6874 tx_first, "tx_first");
6876 cmdline_parse_inst_t cmd_start_tx_first = {
6877 .f = cmd_start_tx_first_parsed,
6879 .help_str = "start tx_first: Start packet forwarding, "
6880 "after sending 1 burst of packets",
6882 (void *)&cmd_start_tx_first_start,
6883 (void *)&cmd_start_tx_first_tx_first,
6888 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6889 struct cmd_start_tx_first_n_result {
6890 cmdline_fixed_string_t start;
6891 cmdline_fixed_string_t tx_first;
6896 cmd_start_tx_first_n_parsed(void *parsed_result,
6897 __attribute__((unused)) struct cmdline *cl,
6898 __attribute__((unused)) void *data)
6900 struct cmd_start_tx_first_n_result *res = parsed_result;
6902 start_packet_forwarding(res->tx_num);
6905 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6906 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6908 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6909 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6910 tx_first, "tx_first");
6911 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6912 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6915 cmdline_parse_inst_t cmd_start_tx_first_n = {
6916 .f = cmd_start_tx_first_n_parsed,
6918 .help_str = "start tx_first <num>: "
6919 "packet forwarding, after sending <num> bursts of packets",
6921 (void *)&cmd_start_tx_first_n_start,
6922 (void *)&cmd_start_tx_first_n_tx_first,
6923 (void *)&cmd_start_tx_first_n_tx_num,
6928 /* *** SET LINK UP *** */
6929 struct cmd_set_link_up_result {
6930 cmdline_fixed_string_t set;
6931 cmdline_fixed_string_t link_up;
6932 cmdline_fixed_string_t port;
6936 cmdline_parse_token_string_t cmd_set_link_up_set =
6937 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6938 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6939 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6941 cmdline_parse_token_string_t cmd_set_link_up_port =
6942 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6943 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6944 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6946 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6947 __attribute__((unused)) struct cmdline *cl,
6948 __attribute__((unused)) void *data)
6950 struct cmd_set_link_up_result *res = parsed_result;
6951 dev_set_link_up(res->port_id);
6954 cmdline_parse_inst_t cmd_set_link_up = {
6955 .f = cmd_set_link_up_parsed,
6957 .help_str = "set link-up port <port id>",
6959 (void *)&cmd_set_link_up_set,
6960 (void *)&cmd_set_link_up_link_up,
6961 (void *)&cmd_set_link_up_port,
6962 (void *)&cmd_set_link_up_port_id,
6967 /* *** SET LINK DOWN *** */
6968 struct cmd_set_link_down_result {
6969 cmdline_fixed_string_t set;
6970 cmdline_fixed_string_t link_down;
6971 cmdline_fixed_string_t port;
6975 cmdline_parse_token_string_t cmd_set_link_down_set =
6976 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6977 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6978 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6980 cmdline_parse_token_string_t cmd_set_link_down_port =
6981 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6982 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6983 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6985 static void cmd_set_link_down_parsed(
6986 __attribute__((unused)) void *parsed_result,
6987 __attribute__((unused)) struct cmdline *cl,
6988 __attribute__((unused)) void *data)
6990 struct cmd_set_link_down_result *res = parsed_result;
6991 dev_set_link_down(res->port_id);
6994 cmdline_parse_inst_t cmd_set_link_down = {
6995 .f = cmd_set_link_down_parsed,
6997 .help_str = "set link-down port <port id>",
6999 (void *)&cmd_set_link_down_set,
7000 (void *)&cmd_set_link_down_link_down,
7001 (void *)&cmd_set_link_down_port,
7002 (void *)&cmd_set_link_down_port_id,
7007 /* *** SHOW CFG *** */
7008 struct cmd_showcfg_result {
7009 cmdline_fixed_string_t show;
7010 cmdline_fixed_string_t cfg;
7011 cmdline_fixed_string_t what;
7014 static void cmd_showcfg_parsed(void *parsed_result,
7015 __attribute__((unused)) struct cmdline *cl,
7016 __attribute__((unused)) void *data)
7018 struct cmd_showcfg_result *res = parsed_result;
7019 if (!strcmp(res->what, "rxtx"))
7020 rxtx_config_display();
7021 else if (!strcmp(res->what, "cores"))
7022 fwd_lcores_config_display();
7023 else if (!strcmp(res->what, "fwd"))
7024 pkt_fwd_config_display(&cur_fwd_config);
7025 else if (!strcmp(res->what, "txpkts"))
7026 show_tx_pkt_segments();
7029 cmdline_parse_token_string_t cmd_showcfg_show =
7030 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7031 cmdline_parse_token_string_t cmd_showcfg_port =
7032 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7033 cmdline_parse_token_string_t cmd_showcfg_what =
7034 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7035 "rxtx#cores#fwd#txpkts");
7037 cmdline_parse_inst_t cmd_showcfg = {
7038 .f = cmd_showcfg_parsed,
7040 .help_str = "show config rxtx|cores|fwd|txpkts",
7042 (void *)&cmd_showcfg_show,
7043 (void *)&cmd_showcfg_port,
7044 (void *)&cmd_showcfg_what,
7049 /* *** SHOW ALL PORT INFO *** */
7050 struct cmd_showportall_result {
7051 cmdline_fixed_string_t show;
7052 cmdline_fixed_string_t port;
7053 cmdline_fixed_string_t what;
7054 cmdline_fixed_string_t all;
7057 static void cmd_showportall_parsed(void *parsed_result,
7058 __attribute__((unused)) struct cmdline *cl,
7059 __attribute__((unused)) void *data)
7063 struct cmd_showportall_result *res = parsed_result;
7064 if (!strcmp(res->show, "clear")) {
7065 if (!strcmp(res->what, "stats"))
7066 RTE_ETH_FOREACH_DEV(i)
7068 else if (!strcmp(res->what, "xstats"))
7069 RTE_ETH_FOREACH_DEV(i)
7070 nic_xstats_clear(i);
7071 } else if (!strcmp(res->what, "info"))
7072 RTE_ETH_FOREACH_DEV(i)
7073 port_infos_display(i);
7074 else if (!strcmp(res->what, "stats"))
7075 RTE_ETH_FOREACH_DEV(i)
7076 nic_stats_display(i);
7077 else if (!strcmp(res->what, "xstats"))
7078 RTE_ETH_FOREACH_DEV(i)
7079 nic_xstats_display(i);
7080 else if (!strcmp(res->what, "fdir"))
7081 RTE_ETH_FOREACH_DEV(i)
7083 else if (!strcmp(res->what, "stat_qmap"))
7084 RTE_ETH_FOREACH_DEV(i)
7085 nic_stats_mapping_display(i);
7086 else if (!strcmp(res->what, "dcb_tc"))
7087 RTE_ETH_FOREACH_DEV(i)
7088 port_dcb_info_display(i);
7089 else if (!strcmp(res->what, "cap"))
7090 RTE_ETH_FOREACH_DEV(i)
7091 port_offload_cap_display(i);
7094 cmdline_parse_token_string_t cmd_showportall_show =
7095 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7097 cmdline_parse_token_string_t cmd_showportall_port =
7098 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7099 cmdline_parse_token_string_t cmd_showportall_what =
7100 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7101 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7102 cmdline_parse_token_string_t cmd_showportall_all =
7103 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7104 cmdline_parse_inst_t cmd_showportall = {
7105 .f = cmd_showportall_parsed,
7107 .help_str = "show|clear port "
7108 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7110 (void *)&cmd_showportall_show,
7111 (void *)&cmd_showportall_port,
7112 (void *)&cmd_showportall_what,
7113 (void *)&cmd_showportall_all,
7118 /* *** SHOW PORT INFO *** */
7119 struct cmd_showport_result {
7120 cmdline_fixed_string_t show;
7121 cmdline_fixed_string_t port;
7122 cmdline_fixed_string_t what;
7126 static void cmd_showport_parsed(void *parsed_result,
7127 __attribute__((unused)) struct cmdline *cl,
7128 __attribute__((unused)) void *data)
7130 struct cmd_showport_result *res = parsed_result;
7131 if (!strcmp(res->show, "clear")) {
7132 if (!strcmp(res->what, "stats"))
7133 nic_stats_clear(res->portnum);
7134 else if (!strcmp(res->what, "xstats"))
7135 nic_xstats_clear(res->portnum);
7136 } else if (!strcmp(res->what, "info"))
7137 port_infos_display(res->portnum);
7138 else if (!strcmp(res->what, "stats"))
7139 nic_stats_display(res->portnum);
7140 else if (!strcmp(res->what, "xstats"))
7141 nic_xstats_display(res->portnum);
7142 else if (!strcmp(res->what, "fdir"))
7143 fdir_get_infos(res->portnum);
7144 else if (!strcmp(res->what, "stat_qmap"))
7145 nic_stats_mapping_display(res->portnum);
7146 else if (!strcmp(res->what, "dcb_tc"))
7147 port_dcb_info_display(res->portnum);
7148 else if (!strcmp(res->what, "cap"))
7149 port_offload_cap_display(res->portnum);
7152 cmdline_parse_token_string_t cmd_showport_show =
7153 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7155 cmdline_parse_token_string_t cmd_showport_port =
7156 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7157 cmdline_parse_token_string_t cmd_showport_what =
7158 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7159 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7160 cmdline_parse_token_num_t cmd_showport_portnum =
7161 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7163 cmdline_parse_inst_t cmd_showport = {
7164 .f = cmd_showport_parsed,
7166 .help_str = "show|clear port "
7167 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7170 (void *)&cmd_showport_show,
7171 (void *)&cmd_showport_port,
7172 (void *)&cmd_showport_what,
7173 (void *)&cmd_showport_portnum,
7178 /* *** SHOW QUEUE INFO *** */
7179 struct cmd_showqueue_result {
7180 cmdline_fixed_string_t show;
7181 cmdline_fixed_string_t type;
7182 cmdline_fixed_string_t what;
7188 cmd_showqueue_parsed(void *parsed_result,
7189 __attribute__((unused)) struct cmdline *cl,
7190 __attribute__((unused)) void *data)
7192 struct cmd_showqueue_result *res = parsed_result;
7194 if (!strcmp(res->type, "rxq"))
7195 rx_queue_infos_display(res->portnum, res->queuenum);
7196 else if (!strcmp(res->type, "txq"))
7197 tx_queue_infos_display(res->portnum, res->queuenum);
7200 cmdline_parse_token_string_t cmd_showqueue_show =
7201 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7202 cmdline_parse_token_string_t cmd_showqueue_type =
7203 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7204 cmdline_parse_token_string_t cmd_showqueue_what =
7205 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7206 cmdline_parse_token_num_t cmd_showqueue_portnum =
7207 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7208 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7209 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7211 cmdline_parse_inst_t cmd_showqueue = {
7212 .f = cmd_showqueue_parsed,
7214 .help_str = "show rxq|txq info <port_id> <queue_id>",
7216 (void *)&cmd_showqueue_show,
7217 (void *)&cmd_showqueue_type,
7218 (void *)&cmd_showqueue_what,
7219 (void *)&cmd_showqueue_portnum,
7220 (void *)&cmd_showqueue_queuenum,
7225 /* *** READ PORT REGISTER *** */
7226 struct cmd_read_reg_result {
7227 cmdline_fixed_string_t read;
7228 cmdline_fixed_string_t reg;
7234 cmd_read_reg_parsed(void *parsed_result,
7235 __attribute__((unused)) struct cmdline *cl,
7236 __attribute__((unused)) void *data)
7238 struct cmd_read_reg_result *res = parsed_result;
7239 port_reg_display(res->port_id, res->reg_off);
7242 cmdline_parse_token_string_t cmd_read_reg_read =
7243 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7244 cmdline_parse_token_string_t cmd_read_reg_reg =
7245 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7246 cmdline_parse_token_num_t cmd_read_reg_port_id =
7247 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7248 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7249 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7251 cmdline_parse_inst_t cmd_read_reg = {
7252 .f = cmd_read_reg_parsed,
7254 .help_str = "read reg <port_id> <reg_off>",
7256 (void *)&cmd_read_reg_read,
7257 (void *)&cmd_read_reg_reg,
7258 (void *)&cmd_read_reg_port_id,
7259 (void *)&cmd_read_reg_reg_off,
7264 /* *** READ PORT REGISTER BIT FIELD *** */
7265 struct cmd_read_reg_bit_field_result {
7266 cmdline_fixed_string_t read;
7267 cmdline_fixed_string_t regfield;
7275 cmd_read_reg_bit_field_parsed(void *parsed_result,
7276 __attribute__((unused)) struct cmdline *cl,
7277 __attribute__((unused)) void *data)
7279 struct cmd_read_reg_bit_field_result *res = parsed_result;
7280 port_reg_bit_field_display(res->port_id, res->reg_off,
7281 res->bit1_pos, res->bit2_pos);
7284 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7285 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7287 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7288 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7289 regfield, "regfield");
7290 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7291 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7293 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7294 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7296 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7297 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7299 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7300 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7303 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7304 .f = cmd_read_reg_bit_field_parsed,
7306 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7307 "Read register bit field between bit_x and bit_y included",
7309 (void *)&cmd_read_reg_bit_field_read,
7310 (void *)&cmd_read_reg_bit_field_regfield,
7311 (void *)&cmd_read_reg_bit_field_port_id,
7312 (void *)&cmd_read_reg_bit_field_reg_off,
7313 (void *)&cmd_read_reg_bit_field_bit1_pos,
7314 (void *)&cmd_read_reg_bit_field_bit2_pos,
7319 /* *** READ PORT REGISTER BIT *** */
7320 struct cmd_read_reg_bit_result {
7321 cmdline_fixed_string_t read;
7322 cmdline_fixed_string_t regbit;
7329 cmd_read_reg_bit_parsed(void *parsed_result,
7330 __attribute__((unused)) struct cmdline *cl,
7331 __attribute__((unused)) void *data)
7333 struct cmd_read_reg_bit_result *res = parsed_result;
7334 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7337 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7338 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7339 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7340 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7342 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7343 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7344 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7345 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7346 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7347 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7349 cmdline_parse_inst_t cmd_read_reg_bit = {
7350 .f = cmd_read_reg_bit_parsed,
7352 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7354 (void *)&cmd_read_reg_bit_read,
7355 (void *)&cmd_read_reg_bit_regbit,
7356 (void *)&cmd_read_reg_bit_port_id,
7357 (void *)&cmd_read_reg_bit_reg_off,
7358 (void *)&cmd_read_reg_bit_bit_pos,
7363 /* *** WRITE PORT REGISTER *** */
7364 struct cmd_write_reg_result {
7365 cmdline_fixed_string_t write;
7366 cmdline_fixed_string_t reg;
7373 cmd_write_reg_parsed(void *parsed_result,
7374 __attribute__((unused)) struct cmdline *cl,
7375 __attribute__((unused)) void *data)
7377 struct cmd_write_reg_result *res = parsed_result;
7378 port_reg_set(res->port_id, res->reg_off, res->value);
7381 cmdline_parse_token_string_t cmd_write_reg_write =
7382 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7383 cmdline_parse_token_string_t cmd_write_reg_reg =
7384 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7385 cmdline_parse_token_num_t cmd_write_reg_port_id =
7386 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7387 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7388 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7389 cmdline_parse_token_num_t cmd_write_reg_value =
7390 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7392 cmdline_parse_inst_t cmd_write_reg = {
7393 .f = cmd_write_reg_parsed,
7395 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7397 (void *)&cmd_write_reg_write,
7398 (void *)&cmd_write_reg_reg,
7399 (void *)&cmd_write_reg_port_id,
7400 (void *)&cmd_write_reg_reg_off,
7401 (void *)&cmd_write_reg_value,
7406 /* *** WRITE PORT REGISTER BIT FIELD *** */
7407 struct cmd_write_reg_bit_field_result {
7408 cmdline_fixed_string_t write;
7409 cmdline_fixed_string_t regfield;
7418 cmd_write_reg_bit_field_parsed(void *parsed_result,
7419 __attribute__((unused)) struct cmdline *cl,
7420 __attribute__((unused)) void *data)
7422 struct cmd_write_reg_bit_field_result *res = parsed_result;
7423 port_reg_bit_field_set(res->port_id, res->reg_off,
7424 res->bit1_pos, res->bit2_pos, res->value);
7427 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7428 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7430 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7431 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7432 regfield, "regfield");
7433 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7434 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7436 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7437 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7439 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7440 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7442 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7443 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7445 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7446 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7449 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7450 .f = cmd_write_reg_bit_field_parsed,
7452 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7454 "Set register bit field between bit_x and bit_y included",
7456 (void *)&cmd_write_reg_bit_field_write,
7457 (void *)&cmd_write_reg_bit_field_regfield,
7458 (void *)&cmd_write_reg_bit_field_port_id,
7459 (void *)&cmd_write_reg_bit_field_reg_off,
7460 (void *)&cmd_write_reg_bit_field_bit1_pos,
7461 (void *)&cmd_write_reg_bit_field_bit2_pos,
7462 (void *)&cmd_write_reg_bit_field_value,
7467 /* *** WRITE PORT REGISTER BIT *** */
7468 struct cmd_write_reg_bit_result {
7469 cmdline_fixed_string_t write;
7470 cmdline_fixed_string_t regbit;
7478 cmd_write_reg_bit_parsed(void *parsed_result,
7479 __attribute__((unused)) struct cmdline *cl,
7480 __attribute__((unused)) void *data)
7482 struct cmd_write_reg_bit_result *res = parsed_result;
7483 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7486 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7487 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7489 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7490 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7492 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7493 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7494 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7495 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7496 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7497 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7498 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7499 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7501 cmdline_parse_inst_t cmd_write_reg_bit = {
7502 .f = cmd_write_reg_bit_parsed,
7504 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7507 (void *)&cmd_write_reg_bit_write,
7508 (void *)&cmd_write_reg_bit_regbit,
7509 (void *)&cmd_write_reg_bit_port_id,
7510 (void *)&cmd_write_reg_bit_reg_off,
7511 (void *)&cmd_write_reg_bit_bit_pos,
7512 (void *)&cmd_write_reg_bit_value,
7517 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7518 struct cmd_read_rxd_txd_result {
7519 cmdline_fixed_string_t read;
7520 cmdline_fixed_string_t rxd_txd;
7527 cmd_read_rxd_txd_parsed(void *parsed_result,
7528 __attribute__((unused)) struct cmdline *cl,
7529 __attribute__((unused)) void *data)
7531 struct cmd_read_rxd_txd_result *res = parsed_result;
7533 if (!strcmp(res->rxd_txd, "rxd"))
7534 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7535 else if (!strcmp(res->rxd_txd, "txd"))
7536 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7539 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7540 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7541 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7542 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7544 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7545 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7546 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7547 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7548 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7549 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7551 cmdline_parse_inst_t cmd_read_rxd_txd = {
7552 .f = cmd_read_rxd_txd_parsed,
7554 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7556 (void *)&cmd_read_rxd_txd_read,
7557 (void *)&cmd_read_rxd_txd_rxd_txd,
7558 (void *)&cmd_read_rxd_txd_port_id,
7559 (void *)&cmd_read_rxd_txd_queue_id,
7560 (void *)&cmd_read_rxd_txd_desc_id,
7566 struct cmd_quit_result {
7567 cmdline_fixed_string_t quit;
7570 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7572 __attribute__((unused)) void *data)
7578 cmdline_parse_token_string_t cmd_quit_quit =
7579 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7581 cmdline_parse_inst_t cmd_quit = {
7582 .f = cmd_quit_parsed,
7584 .help_str = "quit: Exit application",
7586 (void *)&cmd_quit_quit,
7591 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7592 struct cmd_mac_addr_result {
7593 cmdline_fixed_string_t mac_addr_cmd;
7594 cmdline_fixed_string_t what;
7596 struct ether_addr address;
7599 static void cmd_mac_addr_parsed(void *parsed_result,
7600 __attribute__((unused)) struct cmdline *cl,
7601 __attribute__((unused)) void *data)
7603 struct cmd_mac_addr_result *res = parsed_result;
7606 if (strcmp(res->what, "add") == 0)
7607 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7608 else if (strcmp(res->what, "set") == 0)
7609 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7612 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7614 /* check the return value and print it if is < 0 */
7616 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7620 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7621 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7623 cmdline_parse_token_string_t cmd_mac_addr_what =
7624 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7626 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7627 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7629 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7630 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7632 cmdline_parse_inst_t cmd_mac_addr = {
7633 .f = cmd_mac_addr_parsed,
7635 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7636 "Add/Remove/Set MAC address on port_id",
7638 (void *)&cmd_mac_addr_cmd,
7639 (void *)&cmd_mac_addr_what,
7640 (void *)&cmd_mac_addr_portnum,
7641 (void *)&cmd_mac_addr_addr,
7646 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7647 struct cmd_eth_peer_result {
7648 cmdline_fixed_string_t set;
7649 cmdline_fixed_string_t eth_peer;
7651 cmdline_fixed_string_t peer_addr;
7654 static void cmd_set_eth_peer_parsed(void *parsed_result,
7655 __attribute__((unused)) struct cmdline *cl,
7656 __attribute__((unused)) void *data)
7658 struct cmd_eth_peer_result *res = parsed_result;
7660 if (test_done == 0) {
7661 printf("Please stop forwarding first\n");
7664 if (!strcmp(res->eth_peer, "eth-peer")) {
7665 set_fwd_eth_peer(res->port_id, res->peer_addr);
7669 cmdline_parse_token_string_t cmd_eth_peer_set =
7670 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7671 cmdline_parse_token_string_t cmd_eth_peer =
7672 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7673 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7674 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7675 cmdline_parse_token_string_t cmd_eth_peer_addr =
7676 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7678 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7679 .f = cmd_set_eth_peer_parsed,
7681 .help_str = "set eth-peer <port_id> <peer_mac>",
7683 (void *)&cmd_eth_peer_set,
7684 (void *)&cmd_eth_peer,
7685 (void *)&cmd_eth_peer_port_id,
7686 (void *)&cmd_eth_peer_addr,
7691 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7692 struct cmd_set_qmap_result {
7693 cmdline_fixed_string_t set;
7694 cmdline_fixed_string_t qmap;
7695 cmdline_fixed_string_t what;
7702 cmd_set_qmap_parsed(void *parsed_result,
7703 __attribute__((unused)) struct cmdline *cl,
7704 __attribute__((unused)) void *data)
7706 struct cmd_set_qmap_result *res = parsed_result;
7707 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7709 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7712 cmdline_parse_token_string_t cmd_setqmap_set =
7713 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7715 cmdline_parse_token_string_t cmd_setqmap_qmap =
7716 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7718 cmdline_parse_token_string_t cmd_setqmap_what =
7719 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7721 cmdline_parse_token_num_t cmd_setqmap_portid =
7722 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7724 cmdline_parse_token_num_t cmd_setqmap_queueid =
7725 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7727 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7728 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7731 cmdline_parse_inst_t cmd_set_qmap = {
7732 .f = cmd_set_qmap_parsed,
7734 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7735 "Set statistics mapping value on tx|rx queue_id of port_id",
7737 (void *)&cmd_setqmap_set,
7738 (void *)&cmd_setqmap_qmap,
7739 (void *)&cmd_setqmap_what,
7740 (void *)&cmd_setqmap_portid,
7741 (void *)&cmd_setqmap_queueid,
7742 (void *)&cmd_setqmap_mapvalue,
7747 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7748 struct cmd_set_xstats_hide_zero_result {
7749 cmdline_fixed_string_t keyword;
7750 cmdline_fixed_string_t name;
7751 cmdline_fixed_string_t on_off;
7755 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7756 __attribute__((unused)) struct cmdline *cl,
7757 __attribute__((unused)) void *data)
7759 struct cmd_set_xstats_hide_zero_result *res;
7760 uint16_t on_off = 0;
7762 res = parsed_result;
7763 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7764 set_xstats_hide_zero(on_off);
7767 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7768 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7770 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7771 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7772 name, "xstats-hide-zero");
7773 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7774 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7777 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7778 .f = cmd_set_xstats_hide_zero_parsed,
7780 .help_str = "set xstats-hide-zero on|off",
7782 (void *)&cmd_set_xstats_hide_zero_keyword,
7783 (void *)&cmd_set_xstats_hide_zero_name,
7784 (void *)&cmd_set_xstats_hide_zero_on_off,
7789 /* *** CONFIGURE UNICAST HASH TABLE *** */
7790 struct cmd_set_uc_hash_table {
7791 cmdline_fixed_string_t set;
7792 cmdline_fixed_string_t port;
7794 cmdline_fixed_string_t what;
7795 struct ether_addr address;
7796 cmdline_fixed_string_t mode;
7800 cmd_set_uc_hash_parsed(void *parsed_result,
7801 __attribute__((unused)) struct cmdline *cl,
7802 __attribute__((unused)) void *data)
7805 struct cmd_set_uc_hash_table *res = parsed_result;
7807 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7809 if (strcmp(res->what, "uta") == 0)
7810 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7811 &res->address,(uint8_t)is_on);
7813 printf("bad unicast hash table parameter, return code = %d \n", ret);
7817 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7818 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7820 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7821 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7823 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7824 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7826 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7827 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7829 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7830 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7832 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7833 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7836 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7837 .f = cmd_set_uc_hash_parsed,
7839 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7841 (void *)&cmd_set_uc_hash_set,
7842 (void *)&cmd_set_uc_hash_port,
7843 (void *)&cmd_set_uc_hash_portid,
7844 (void *)&cmd_set_uc_hash_what,
7845 (void *)&cmd_set_uc_hash_mac,
7846 (void *)&cmd_set_uc_hash_mode,
7851 struct cmd_set_uc_all_hash_table {
7852 cmdline_fixed_string_t set;
7853 cmdline_fixed_string_t port;
7855 cmdline_fixed_string_t what;
7856 cmdline_fixed_string_t value;
7857 cmdline_fixed_string_t mode;
7861 cmd_set_uc_all_hash_parsed(void *parsed_result,
7862 __attribute__((unused)) struct cmdline *cl,
7863 __attribute__((unused)) void *data)
7866 struct cmd_set_uc_all_hash_table *res = parsed_result;
7868 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7870 if ((strcmp(res->what, "uta") == 0) &&
7871 (strcmp(res->value, "all") == 0))
7872 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7874 printf("bad unicast hash table parameter,"
7875 "return code = %d \n", ret);
7878 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7879 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7881 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7882 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7884 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7885 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7887 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7888 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7890 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7891 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7893 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7894 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7897 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7898 .f = cmd_set_uc_all_hash_parsed,
7900 .help_str = "set port <port_id> uta all on|off",
7902 (void *)&cmd_set_uc_all_hash_set,
7903 (void *)&cmd_set_uc_all_hash_port,
7904 (void *)&cmd_set_uc_all_hash_portid,
7905 (void *)&cmd_set_uc_all_hash_what,
7906 (void *)&cmd_set_uc_all_hash_value,
7907 (void *)&cmd_set_uc_all_hash_mode,
7912 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7913 struct cmd_set_vf_macvlan_filter {
7914 cmdline_fixed_string_t set;
7915 cmdline_fixed_string_t port;
7917 cmdline_fixed_string_t vf;
7919 struct ether_addr address;
7920 cmdline_fixed_string_t filter_type;
7921 cmdline_fixed_string_t mode;
7925 cmd_set_vf_macvlan_parsed(void *parsed_result,
7926 __attribute__((unused)) struct cmdline *cl,
7927 __attribute__((unused)) void *data)
7930 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7931 struct rte_eth_mac_filter filter;
7933 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7935 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7937 /* set VF MAC filter */
7941 filter.dst_id = res->vf_id;
7943 if (!strcmp(res->filter_type, "exact-mac"))
7944 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7945 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7946 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7947 else if (!strcmp(res->filter_type, "hashmac"))
7948 filter.filter_type = RTE_MAC_HASH_MATCH;
7949 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7950 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7952 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7955 ret = rte_eth_dev_filter_ctrl(res->port_id,
7956 RTE_ETH_FILTER_MACVLAN,
7960 ret = rte_eth_dev_filter_ctrl(res->port_id,
7961 RTE_ETH_FILTER_MACVLAN,
7962 RTE_ETH_FILTER_DELETE,
7966 printf("bad set MAC hash parameter, return code = %d\n", ret);
7970 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7971 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7973 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7974 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7976 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7977 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7979 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7980 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7982 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7983 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7985 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7986 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7988 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7989 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7990 filter_type, "exact-mac#exact-mac-vlan"
7991 "#hashmac#hashmac-vlan");
7992 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7993 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7996 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7997 .f = cmd_set_vf_macvlan_parsed,
7999 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8000 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8001 "Exact match rule: exact match of MAC or MAC and VLAN; "
8002 "hash match rule: hash match of MAC and exact match of VLAN",
8004 (void *)&cmd_set_vf_macvlan_set,
8005 (void *)&cmd_set_vf_macvlan_port,
8006 (void *)&cmd_set_vf_macvlan_portid,
8007 (void *)&cmd_set_vf_macvlan_vf,
8008 (void *)&cmd_set_vf_macvlan_vf_id,
8009 (void *)&cmd_set_vf_macvlan_mac,
8010 (void *)&cmd_set_vf_macvlan_filter_type,
8011 (void *)&cmd_set_vf_macvlan_mode,
8016 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8017 struct cmd_set_vf_traffic {
8018 cmdline_fixed_string_t set;
8019 cmdline_fixed_string_t port;
8021 cmdline_fixed_string_t vf;
8023 cmdline_fixed_string_t what;
8024 cmdline_fixed_string_t mode;
8028 cmd_set_vf_traffic_parsed(void *parsed_result,
8029 __attribute__((unused)) struct cmdline *cl,
8030 __attribute__((unused)) void *data)
8032 struct cmd_set_vf_traffic *res = parsed_result;
8033 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8034 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8036 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8039 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8040 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8042 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8043 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8045 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8046 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8048 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8049 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8051 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8052 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8054 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8055 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8057 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8058 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8061 cmdline_parse_inst_t cmd_set_vf_traffic = {
8062 .f = cmd_set_vf_traffic_parsed,
8064 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8066 (void *)&cmd_setvf_traffic_set,
8067 (void *)&cmd_setvf_traffic_port,
8068 (void *)&cmd_setvf_traffic_portid,
8069 (void *)&cmd_setvf_traffic_vf,
8070 (void *)&cmd_setvf_traffic_vfid,
8071 (void *)&cmd_setvf_traffic_what,
8072 (void *)&cmd_setvf_traffic_mode,
8077 /* *** CONFIGURE VF RECEIVE MODE *** */
8078 struct cmd_set_vf_rxmode {
8079 cmdline_fixed_string_t set;
8080 cmdline_fixed_string_t port;
8082 cmdline_fixed_string_t vf;
8084 cmdline_fixed_string_t what;
8085 cmdline_fixed_string_t mode;
8086 cmdline_fixed_string_t on;
8090 cmd_set_vf_rxmode_parsed(void *parsed_result,
8091 __attribute__((unused)) struct cmdline *cl,
8092 __attribute__((unused)) void *data)
8095 uint16_t rx_mode = 0;
8096 struct cmd_set_vf_rxmode *res = parsed_result;
8098 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8099 if (!strcmp(res->what,"rxmode")) {
8100 if (!strcmp(res->mode, "AUPE"))
8101 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8102 else if (!strcmp(res->mode, "ROPE"))
8103 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8104 else if (!strcmp(res->mode, "BAM"))
8105 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8106 else if (!strncmp(res->mode, "MPE",3))
8107 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8110 RTE_SET_USED(is_on);
8112 #ifdef RTE_LIBRTE_IXGBE_PMD
8113 if (ret == -ENOTSUP)
8114 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8115 rx_mode, (uint8_t)is_on);
8117 #ifdef RTE_LIBRTE_BNXT_PMD
8118 if (ret == -ENOTSUP)
8119 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8120 rx_mode, (uint8_t)is_on);
8123 printf("bad VF receive mode parameter, return code = %d \n",
8127 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8128 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8130 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8131 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8133 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8134 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8136 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8137 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8139 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8140 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8142 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8143 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8145 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8146 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8147 mode, "AUPE#ROPE#BAM#MPE");
8148 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8149 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8152 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8153 .f = cmd_set_vf_rxmode_parsed,
8155 .help_str = "set port <port_id> vf <vf_id> rxmode "
8156 "AUPE|ROPE|BAM|MPE on|off",
8158 (void *)&cmd_set_vf_rxmode_set,
8159 (void *)&cmd_set_vf_rxmode_port,
8160 (void *)&cmd_set_vf_rxmode_portid,
8161 (void *)&cmd_set_vf_rxmode_vf,
8162 (void *)&cmd_set_vf_rxmode_vfid,
8163 (void *)&cmd_set_vf_rxmode_what,
8164 (void *)&cmd_set_vf_rxmode_mode,
8165 (void *)&cmd_set_vf_rxmode_on,
8170 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8171 struct cmd_vf_mac_addr_result {
8172 cmdline_fixed_string_t mac_addr_cmd;
8173 cmdline_fixed_string_t what;
8174 cmdline_fixed_string_t port;
8176 cmdline_fixed_string_t vf;
8178 struct ether_addr address;
8181 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8182 __attribute__((unused)) struct cmdline *cl,
8183 __attribute__((unused)) void *data)
8185 struct cmd_vf_mac_addr_result *res = parsed_result;
8188 if (strcmp(res->what, "add") != 0)
8191 #ifdef RTE_LIBRTE_I40E_PMD
8192 if (ret == -ENOTSUP)
8193 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8196 #ifdef RTE_LIBRTE_BNXT_PMD
8197 if (ret == -ENOTSUP)
8198 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8203 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8207 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8208 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8209 mac_addr_cmd,"mac_addr");
8210 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8211 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8213 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8214 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8216 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8217 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8219 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8220 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8222 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8223 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8225 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8226 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8229 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8230 .f = cmd_vf_mac_addr_parsed,
8232 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8233 "Add MAC address filtering for a VF on port_id",
8235 (void *)&cmd_vf_mac_addr_cmd,
8236 (void *)&cmd_vf_mac_addr_what,
8237 (void *)&cmd_vf_mac_addr_port,
8238 (void *)&cmd_vf_mac_addr_portnum,
8239 (void *)&cmd_vf_mac_addr_vf,
8240 (void *)&cmd_vf_mac_addr_vfnum,
8241 (void *)&cmd_vf_mac_addr_addr,
8246 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8247 struct cmd_vf_rx_vlan_filter {
8248 cmdline_fixed_string_t rx_vlan;
8249 cmdline_fixed_string_t what;
8251 cmdline_fixed_string_t port;
8253 cmdline_fixed_string_t vf;
8258 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8259 __attribute__((unused)) struct cmdline *cl,
8260 __attribute__((unused)) void *data)
8262 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8265 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8267 #ifdef RTE_LIBRTE_IXGBE_PMD
8268 if (ret == -ENOTSUP)
8269 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8270 res->vlan_id, res->vf_mask, is_add);
8272 #ifdef RTE_LIBRTE_I40E_PMD
8273 if (ret == -ENOTSUP)
8274 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8275 res->vlan_id, res->vf_mask, is_add);
8277 #ifdef RTE_LIBRTE_BNXT_PMD
8278 if (ret == -ENOTSUP)
8279 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8280 res->vlan_id, res->vf_mask, is_add);
8287 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8288 res->vlan_id, res->vf_mask);
8291 printf("invalid port_id %d\n", res->port_id);
8294 printf("function not implemented or supported\n");
8297 printf("programming error: (%s)\n", strerror(-ret));
8301 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8302 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8303 rx_vlan, "rx_vlan");
8304 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8305 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8307 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8308 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8310 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8311 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8313 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8314 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8316 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8317 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8319 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8320 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8323 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8324 .f = cmd_vf_rx_vlan_filter_parsed,
8326 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8327 "(vf_mask = hexadecimal VF mask)",
8329 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8330 (void *)&cmd_vf_rx_vlan_filter_what,
8331 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8332 (void *)&cmd_vf_rx_vlan_filter_port,
8333 (void *)&cmd_vf_rx_vlan_filter_portid,
8334 (void *)&cmd_vf_rx_vlan_filter_vf,
8335 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8340 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8341 struct cmd_queue_rate_limit_result {
8342 cmdline_fixed_string_t set;
8343 cmdline_fixed_string_t port;
8345 cmdline_fixed_string_t queue;
8347 cmdline_fixed_string_t rate;
8351 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8352 __attribute__((unused)) struct cmdline *cl,
8353 __attribute__((unused)) void *data)
8355 struct cmd_queue_rate_limit_result *res = parsed_result;
8358 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8359 && (strcmp(res->queue, "queue") == 0)
8360 && (strcmp(res->rate, "rate") == 0))
8361 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8364 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8368 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8369 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8371 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8372 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8374 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8375 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8377 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8378 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8380 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8381 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8383 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8384 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8386 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8387 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8390 cmdline_parse_inst_t cmd_queue_rate_limit = {
8391 .f = cmd_queue_rate_limit_parsed,
8393 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8394 "Set rate limit for a queue on port_id",
8396 (void *)&cmd_queue_rate_limit_set,
8397 (void *)&cmd_queue_rate_limit_port,
8398 (void *)&cmd_queue_rate_limit_portnum,
8399 (void *)&cmd_queue_rate_limit_queue,
8400 (void *)&cmd_queue_rate_limit_queuenum,
8401 (void *)&cmd_queue_rate_limit_rate,
8402 (void *)&cmd_queue_rate_limit_ratenum,
8407 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8408 struct cmd_vf_rate_limit_result {
8409 cmdline_fixed_string_t set;
8410 cmdline_fixed_string_t port;
8412 cmdline_fixed_string_t vf;
8414 cmdline_fixed_string_t rate;
8416 cmdline_fixed_string_t q_msk;
8420 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8421 __attribute__((unused)) struct cmdline *cl,
8422 __attribute__((unused)) void *data)
8424 struct cmd_vf_rate_limit_result *res = parsed_result;
8427 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8428 && (strcmp(res->vf, "vf") == 0)
8429 && (strcmp(res->rate, "rate") == 0)
8430 && (strcmp(res->q_msk, "queue_mask") == 0))
8431 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8432 res->rate_num, res->q_msk_val);
8434 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8438 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8439 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8441 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8442 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8444 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8445 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8447 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8448 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8450 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8451 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8453 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8454 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8456 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8457 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8459 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8460 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8461 q_msk, "queue_mask");
8462 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8463 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8466 cmdline_parse_inst_t cmd_vf_rate_limit = {
8467 .f = cmd_vf_rate_limit_parsed,
8469 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8470 "queue_mask <queue_mask_value>: "
8471 "Set rate limit for queues of VF on port_id",
8473 (void *)&cmd_vf_rate_limit_set,
8474 (void *)&cmd_vf_rate_limit_port,
8475 (void *)&cmd_vf_rate_limit_portnum,
8476 (void *)&cmd_vf_rate_limit_vf,
8477 (void *)&cmd_vf_rate_limit_vfnum,
8478 (void *)&cmd_vf_rate_limit_rate,
8479 (void *)&cmd_vf_rate_limit_ratenum,
8480 (void *)&cmd_vf_rate_limit_q_msk,
8481 (void *)&cmd_vf_rate_limit_q_msk_val,
8486 /* *** ADD TUNNEL FILTER OF A PORT *** */
8487 struct cmd_tunnel_filter_result {
8488 cmdline_fixed_string_t cmd;
8489 cmdline_fixed_string_t what;
8491 struct ether_addr outer_mac;
8492 struct ether_addr inner_mac;
8493 cmdline_ipaddr_t ip_value;
8494 uint16_t inner_vlan;
8495 cmdline_fixed_string_t tunnel_type;
8496 cmdline_fixed_string_t filter_type;
8502 cmd_tunnel_filter_parsed(void *parsed_result,
8503 __attribute__((unused)) struct cmdline *cl,
8504 __attribute__((unused)) void *data)
8506 struct cmd_tunnel_filter_result *res = parsed_result;
8507 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8510 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8512 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8513 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8514 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8516 if (res->ip_value.family == AF_INET) {
8517 tunnel_filter_conf.ip_addr.ipv4_addr =
8518 res->ip_value.addr.ipv4.s_addr;
8519 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8521 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8522 &(res->ip_value.addr.ipv6),
8523 sizeof(struct in6_addr));
8524 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8527 if (!strcmp(res->filter_type, "imac-ivlan"))
8528 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8529 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8530 tunnel_filter_conf.filter_type =
8531 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8532 else if (!strcmp(res->filter_type, "imac-tenid"))
8533 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8534 else if (!strcmp(res->filter_type, "imac"))
8535 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8536 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8537 tunnel_filter_conf.filter_type =
8538 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8539 else if (!strcmp(res->filter_type, "oip"))
8540 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8541 else if (!strcmp(res->filter_type, "iip"))
8542 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8544 printf("The filter type is not supported");
8548 if (!strcmp(res->tunnel_type, "vxlan"))
8549 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8550 else if (!strcmp(res->tunnel_type, "nvgre"))
8551 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8552 else if (!strcmp(res->tunnel_type, "ipingre"))
8553 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8555 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8559 tunnel_filter_conf.tenant_id = res->tenant_id;
8560 tunnel_filter_conf.queue_id = res->queue_num;
8561 if (!strcmp(res->what, "add"))
8562 ret = rte_eth_dev_filter_ctrl(res->port_id,
8563 RTE_ETH_FILTER_TUNNEL,
8565 &tunnel_filter_conf);
8567 ret = rte_eth_dev_filter_ctrl(res->port_id,
8568 RTE_ETH_FILTER_TUNNEL,
8569 RTE_ETH_FILTER_DELETE,
8570 &tunnel_filter_conf);
8572 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8576 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8577 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8578 cmd, "tunnel_filter");
8579 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8580 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8582 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8583 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8585 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8586 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8588 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8589 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8591 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8592 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8593 inner_vlan, UINT16);
8594 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8595 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8597 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8598 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8599 tunnel_type, "vxlan#nvgre#ipingre");
8601 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8602 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8603 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8604 "imac#omac-imac-tenid");
8605 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8606 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8608 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8609 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8612 cmdline_parse_inst_t cmd_tunnel_filter = {
8613 .f = cmd_tunnel_filter_parsed,
8615 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8616 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8617 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8618 "<queue_id>: Add/Rm tunnel filter of a port",
8620 (void *)&cmd_tunnel_filter_cmd,
8621 (void *)&cmd_tunnel_filter_what,
8622 (void *)&cmd_tunnel_filter_port_id,
8623 (void *)&cmd_tunnel_filter_outer_mac,
8624 (void *)&cmd_tunnel_filter_inner_mac,
8625 (void *)&cmd_tunnel_filter_ip_value,
8626 (void *)&cmd_tunnel_filter_innner_vlan,
8627 (void *)&cmd_tunnel_filter_tunnel_type,
8628 (void *)&cmd_tunnel_filter_filter_type,
8629 (void *)&cmd_tunnel_filter_tenant_id,
8630 (void *)&cmd_tunnel_filter_queue_num,
8635 /* *** CONFIGURE TUNNEL UDP PORT *** */
8636 struct cmd_tunnel_udp_config {
8637 cmdline_fixed_string_t cmd;
8638 cmdline_fixed_string_t what;
8644 cmd_tunnel_udp_config_parsed(void *parsed_result,
8645 __attribute__((unused)) struct cmdline *cl,
8646 __attribute__((unused)) void *data)
8648 struct cmd_tunnel_udp_config *res = parsed_result;
8649 struct rte_eth_udp_tunnel tunnel_udp;
8652 tunnel_udp.udp_port = res->udp_port;
8654 if (!strcmp(res->cmd, "rx_vxlan_port"))
8655 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8657 if (!strcmp(res->what, "add"))
8658 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8661 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8665 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8668 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8669 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8670 cmd, "rx_vxlan_port");
8671 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8672 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8674 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8675 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8677 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8678 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8681 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8682 .f = cmd_tunnel_udp_config_parsed,
8684 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8685 "Add/Remove a tunneling UDP port filter",
8687 (void *)&cmd_tunnel_udp_config_cmd,
8688 (void *)&cmd_tunnel_udp_config_what,
8689 (void *)&cmd_tunnel_udp_config_udp_port,
8690 (void *)&cmd_tunnel_udp_config_port_id,
8695 struct cmd_config_tunnel_udp_port {
8696 cmdline_fixed_string_t port;
8697 cmdline_fixed_string_t config;
8699 cmdline_fixed_string_t udp_tunnel_port;
8700 cmdline_fixed_string_t action;
8701 cmdline_fixed_string_t tunnel_type;
8706 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8707 __attribute__((unused)) struct cmdline *cl,
8708 __attribute__((unused)) void *data)
8710 struct cmd_config_tunnel_udp_port *res = parsed_result;
8711 struct rte_eth_udp_tunnel tunnel_udp;
8714 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8717 tunnel_udp.udp_port = res->udp_port;
8719 if (!strcmp(res->tunnel_type, "vxlan")) {
8720 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8721 } else if (!strcmp(res->tunnel_type, "geneve")) {
8722 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8724 printf("Invalid tunnel type\n");
8728 if (!strcmp(res->action, "add"))
8729 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8732 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8736 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8739 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8740 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8742 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8743 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8745 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8746 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8748 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8749 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8752 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8753 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8755 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8756 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8758 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8759 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8762 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8763 .f = cmd_cfg_tunnel_udp_port_parsed,
8765 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8767 (void *)&cmd_config_tunnel_udp_port_port,
8768 (void *)&cmd_config_tunnel_udp_port_config,
8769 (void *)&cmd_config_tunnel_udp_port_port_id,
8770 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8771 (void *)&cmd_config_tunnel_udp_port_action,
8772 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8773 (void *)&cmd_config_tunnel_udp_port_value,
8778 /* *** GLOBAL CONFIG *** */
8779 struct cmd_global_config_result {
8780 cmdline_fixed_string_t cmd;
8782 cmdline_fixed_string_t cfg_type;
8787 cmd_global_config_parsed(void *parsed_result,
8788 __attribute__((unused)) struct cmdline *cl,
8789 __attribute__((unused)) void *data)
8791 struct cmd_global_config_result *res = parsed_result;
8792 struct rte_eth_global_cfg conf;
8795 memset(&conf, 0, sizeof(conf));
8796 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8797 conf.cfg.gre_key_len = res->len;
8798 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8799 RTE_ETH_FILTER_SET, &conf);
8801 printf("Global config error\n");
8804 cmdline_parse_token_string_t cmd_global_config_cmd =
8805 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8807 cmdline_parse_token_num_t cmd_global_config_port_id =
8808 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8810 cmdline_parse_token_string_t cmd_global_config_type =
8811 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8812 cfg_type, "gre-key-len");
8813 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8814 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8817 cmdline_parse_inst_t cmd_global_config = {
8818 .f = cmd_global_config_parsed,
8819 .data = (void *)NULL,
8820 .help_str = "global_config <port_id> gre-key-len <key_len>",
8822 (void *)&cmd_global_config_cmd,
8823 (void *)&cmd_global_config_port_id,
8824 (void *)&cmd_global_config_type,
8825 (void *)&cmd_global_config_gre_key_len,
8830 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8831 struct cmd_set_mirror_mask_result {
8832 cmdline_fixed_string_t set;
8833 cmdline_fixed_string_t port;
8835 cmdline_fixed_string_t mirror;
8837 cmdline_fixed_string_t what;
8838 cmdline_fixed_string_t value;
8839 cmdline_fixed_string_t dstpool;
8841 cmdline_fixed_string_t on;
8844 cmdline_parse_token_string_t cmd_mirror_mask_set =
8845 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8847 cmdline_parse_token_string_t cmd_mirror_mask_port =
8848 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8850 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8851 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8853 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8854 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8855 mirror, "mirror-rule");
8856 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8857 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8859 cmdline_parse_token_string_t cmd_mirror_mask_what =
8860 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8861 what, "pool-mirror-up#pool-mirror-down"
8863 cmdline_parse_token_string_t cmd_mirror_mask_value =
8864 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8866 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8867 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8868 dstpool, "dst-pool");
8869 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8870 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8872 cmdline_parse_token_string_t cmd_mirror_mask_on =
8873 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8877 cmd_set_mirror_mask_parsed(void *parsed_result,
8878 __attribute__((unused)) struct cmdline *cl,
8879 __attribute__((unused)) void *data)
8882 struct cmd_set_mirror_mask_result *res = parsed_result;
8883 struct rte_eth_mirror_conf mr_conf;
8885 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8887 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8889 mr_conf.dst_pool = res->dstpool_id;
8891 if (!strcmp(res->what, "pool-mirror-up")) {
8892 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8893 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8894 } else if (!strcmp(res->what, "pool-mirror-down")) {
8895 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8896 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8897 } else if (!strcmp(res->what, "vlan-mirror")) {
8898 mr_conf.rule_type = ETH_MIRROR_VLAN;
8899 nb_item = parse_item_list(res->value, "vlan",
8900 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8904 for (i = 0; i < nb_item; i++) {
8905 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8906 printf("Invalid vlan_id: must be < 4096\n");
8910 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8911 mr_conf.vlan.vlan_mask |= 1ULL << i;
8915 if (!strcmp(res->on, "on"))
8916 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8919 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8922 printf("mirror rule add error: (%s)\n", strerror(-ret));
8925 cmdline_parse_inst_t cmd_set_mirror_mask = {
8926 .f = cmd_set_mirror_mask_parsed,
8928 .help_str = "set port <port_id> mirror-rule <rule_id> "
8929 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8930 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8932 (void *)&cmd_mirror_mask_set,
8933 (void *)&cmd_mirror_mask_port,
8934 (void *)&cmd_mirror_mask_portid,
8935 (void *)&cmd_mirror_mask_mirror,
8936 (void *)&cmd_mirror_mask_ruleid,
8937 (void *)&cmd_mirror_mask_what,
8938 (void *)&cmd_mirror_mask_value,
8939 (void *)&cmd_mirror_mask_dstpool,
8940 (void *)&cmd_mirror_mask_poolid,
8941 (void *)&cmd_mirror_mask_on,
8946 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8947 struct cmd_set_mirror_link_result {
8948 cmdline_fixed_string_t set;
8949 cmdline_fixed_string_t port;
8951 cmdline_fixed_string_t mirror;
8953 cmdline_fixed_string_t what;
8954 cmdline_fixed_string_t dstpool;
8956 cmdline_fixed_string_t on;
8959 cmdline_parse_token_string_t cmd_mirror_link_set =
8960 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8962 cmdline_parse_token_string_t cmd_mirror_link_port =
8963 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8965 cmdline_parse_token_num_t cmd_mirror_link_portid =
8966 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8968 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8969 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8970 mirror, "mirror-rule");
8971 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8972 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8974 cmdline_parse_token_string_t cmd_mirror_link_what =
8975 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8976 what, "uplink-mirror#downlink-mirror");
8977 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8978 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8979 dstpool, "dst-pool");
8980 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8981 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8983 cmdline_parse_token_string_t cmd_mirror_link_on =
8984 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8988 cmd_set_mirror_link_parsed(void *parsed_result,
8989 __attribute__((unused)) struct cmdline *cl,
8990 __attribute__((unused)) void *data)
8993 struct cmd_set_mirror_link_result *res = parsed_result;
8994 struct rte_eth_mirror_conf mr_conf;
8996 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8997 if (!strcmp(res->what, "uplink-mirror"))
8998 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9000 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9002 mr_conf.dst_pool = res->dstpool_id;
9004 if (!strcmp(res->on, "on"))
9005 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9008 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9011 /* check the return value and print it if is < 0 */
9013 printf("mirror rule add error: (%s)\n", strerror(-ret));
9017 cmdline_parse_inst_t cmd_set_mirror_link = {
9018 .f = cmd_set_mirror_link_parsed,
9020 .help_str = "set port <port_id> mirror-rule <rule_id> "
9021 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9023 (void *)&cmd_mirror_link_set,
9024 (void *)&cmd_mirror_link_port,
9025 (void *)&cmd_mirror_link_portid,
9026 (void *)&cmd_mirror_link_mirror,
9027 (void *)&cmd_mirror_link_ruleid,
9028 (void *)&cmd_mirror_link_what,
9029 (void *)&cmd_mirror_link_dstpool,
9030 (void *)&cmd_mirror_link_poolid,
9031 (void *)&cmd_mirror_link_on,
9036 /* *** RESET VM MIRROR RULE *** */
9037 struct cmd_rm_mirror_rule_result {
9038 cmdline_fixed_string_t reset;
9039 cmdline_fixed_string_t port;
9041 cmdline_fixed_string_t mirror;
9045 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9046 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9048 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9049 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9051 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9052 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9054 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9055 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9056 mirror, "mirror-rule");
9057 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9058 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9062 cmd_reset_mirror_rule_parsed(void *parsed_result,
9063 __attribute__((unused)) struct cmdline *cl,
9064 __attribute__((unused)) void *data)
9067 struct cmd_set_mirror_link_result *res = parsed_result;
9069 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9071 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9074 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9075 .f = cmd_reset_mirror_rule_parsed,
9077 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9079 (void *)&cmd_rm_mirror_rule_reset,
9080 (void *)&cmd_rm_mirror_rule_port,
9081 (void *)&cmd_rm_mirror_rule_portid,
9082 (void *)&cmd_rm_mirror_rule_mirror,
9083 (void *)&cmd_rm_mirror_rule_ruleid,
9088 /* ******************************************************************************** */
9090 struct cmd_dump_result {
9091 cmdline_fixed_string_t dump;
9095 dump_struct_sizes(void)
9097 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9098 DUMP_SIZE(struct rte_mbuf);
9099 DUMP_SIZE(struct rte_mempool);
9100 DUMP_SIZE(struct rte_ring);
9104 static void cmd_dump_parsed(void *parsed_result,
9105 __attribute__((unused)) struct cmdline *cl,
9106 __attribute__((unused)) void *data)
9108 struct cmd_dump_result *res = parsed_result;
9110 if (!strcmp(res->dump, "dump_physmem"))
9111 rte_dump_physmem_layout(stdout);
9112 else if (!strcmp(res->dump, "dump_memzone"))
9113 rte_memzone_dump(stdout);
9114 else if (!strcmp(res->dump, "dump_struct_sizes"))
9115 dump_struct_sizes();
9116 else if (!strcmp(res->dump, "dump_ring"))
9117 rte_ring_list_dump(stdout);
9118 else if (!strcmp(res->dump, "dump_mempool"))
9119 rte_mempool_list_dump(stdout);
9120 else if (!strcmp(res->dump, "dump_devargs"))
9121 rte_devargs_dump(stdout);
9122 else if (!strcmp(res->dump, "dump_log_types"))
9123 rte_log_dump(stdout);
9126 cmdline_parse_token_string_t cmd_dump_dump =
9127 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9130 "dump_struct_sizes#"
9136 cmdline_parse_inst_t cmd_dump = {
9137 .f = cmd_dump_parsed, /* function to call */
9138 .data = NULL, /* 2nd arg of func */
9139 .help_str = "Dump status",
9140 .tokens = { /* token list, NULL terminated */
9141 (void *)&cmd_dump_dump,
9146 /* ******************************************************************************** */
9148 struct cmd_dump_one_result {
9149 cmdline_fixed_string_t dump;
9150 cmdline_fixed_string_t name;
9153 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9154 __attribute__((unused)) void *data)
9156 struct cmd_dump_one_result *res = parsed_result;
9158 if (!strcmp(res->dump, "dump_ring")) {
9160 r = rte_ring_lookup(res->name);
9162 cmdline_printf(cl, "Cannot find ring\n");
9165 rte_ring_dump(stdout, r);
9166 } else if (!strcmp(res->dump, "dump_mempool")) {
9167 struct rte_mempool *mp;
9168 mp = rte_mempool_lookup(res->name);
9170 cmdline_printf(cl, "Cannot find mempool\n");
9173 rte_mempool_dump(stdout, mp);
9177 cmdline_parse_token_string_t cmd_dump_one_dump =
9178 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9179 "dump_ring#dump_mempool");
9181 cmdline_parse_token_string_t cmd_dump_one_name =
9182 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9184 cmdline_parse_inst_t cmd_dump_one = {
9185 .f = cmd_dump_one_parsed, /* function to call */
9186 .data = NULL, /* 2nd arg of func */
9187 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9188 .tokens = { /* token list, NULL terminated */
9189 (void *)&cmd_dump_one_dump,
9190 (void *)&cmd_dump_one_name,
9195 /* *** Add/Del syn filter *** */
9196 struct cmd_syn_filter_result {
9197 cmdline_fixed_string_t filter;
9199 cmdline_fixed_string_t ops;
9200 cmdline_fixed_string_t priority;
9201 cmdline_fixed_string_t high;
9202 cmdline_fixed_string_t queue;
9207 cmd_syn_filter_parsed(void *parsed_result,
9208 __attribute__((unused)) struct cmdline *cl,
9209 __attribute__((unused)) void *data)
9211 struct cmd_syn_filter_result *res = parsed_result;
9212 struct rte_eth_syn_filter syn_filter;
9215 ret = rte_eth_dev_filter_supported(res->port_id,
9216 RTE_ETH_FILTER_SYN);
9218 printf("syn filter is not supported on port %u.\n",
9223 memset(&syn_filter, 0, sizeof(syn_filter));
9225 if (!strcmp(res->ops, "add")) {
9226 if (!strcmp(res->high, "high"))
9227 syn_filter.hig_pri = 1;
9229 syn_filter.hig_pri = 0;
9231 syn_filter.queue = res->queue_id;
9232 ret = rte_eth_dev_filter_ctrl(res->port_id,
9237 ret = rte_eth_dev_filter_ctrl(res->port_id,
9239 RTE_ETH_FILTER_DELETE,
9243 printf("syn filter programming error: (%s)\n",
9247 cmdline_parse_token_string_t cmd_syn_filter_filter =
9248 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9249 filter, "syn_filter");
9250 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9251 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9253 cmdline_parse_token_string_t cmd_syn_filter_ops =
9254 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9256 cmdline_parse_token_string_t cmd_syn_filter_priority =
9257 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9258 priority, "priority");
9259 cmdline_parse_token_string_t cmd_syn_filter_high =
9260 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9262 cmdline_parse_token_string_t cmd_syn_filter_queue =
9263 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9265 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9266 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9269 cmdline_parse_inst_t cmd_syn_filter = {
9270 .f = cmd_syn_filter_parsed,
9272 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9273 "<queue_id>: Add/Delete syn filter",
9275 (void *)&cmd_syn_filter_filter,
9276 (void *)&cmd_syn_filter_port_id,
9277 (void *)&cmd_syn_filter_ops,
9278 (void *)&cmd_syn_filter_priority,
9279 (void *)&cmd_syn_filter_high,
9280 (void *)&cmd_syn_filter_queue,
9281 (void *)&cmd_syn_filter_queue_id,
9286 /* *** queue region set *** */
9287 struct cmd_queue_region_result {
9288 cmdline_fixed_string_t set;
9289 cmdline_fixed_string_t port;
9291 cmdline_fixed_string_t cmd;
9292 cmdline_fixed_string_t region;
9294 cmdline_fixed_string_t queue_start_index;
9296 cmdline_fixed_string_t queue_num;
9297 uint8_t queue_num_value;
9301 cmd_queue_region_parsed(void *parsed_result,
9302 __attribute__((unused)) struct cmdline *cl,
9303 __attribute__((unused)) void *data)
9305 struct cmd_queue_region_result *res = parsed_result;
9307 #ifdef RTE_LIBRTE_I40E_PMD
9308 struct rte_pmd_i40e_queue_region_conf region_conf;
9309 enum rte_pmd_i40e_queue_region_op op_type;
9312 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9315 #ifdef RTE_LIBRTE_I40E_PMD
9316 memset(®ion_conf, 0, sizeof(region_conf));
9317 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9318 region_conf.region_id = res->region_id;
9319 region_conf.queue_num = res->queue_num_value;
9320 region_conf.queue_start_index = res->queue_id;
9322 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9323 op_type, ®ion_conf);
9330 printf("function not implemented or supported\n");
9333 printf("queue region config error: (%s)\n", strerror(-ret));
9337 cmdline_parse_token_string_t cmd_queue_region_set =
9338 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9340 cmdline_parse_token_string_t cmd_queue_region_port =
9341 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9342 cmdline_parse_token_num_t cmd_queue_region_port_id =
9343 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9345 cmdline_parse_token_string_t cmd_queue_region_cmd =
9346 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9347 cmd, "queue-region");
9348 cmdline_parse_token_string_t cmd_queue_region_id =
9349 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9350 region, "region_id");
9351 cmdline_parse_token_num_t cmd_queue_region_index =
9352 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9354 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9355 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9356 queue_start_index, "queue_start_index");
9357 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9358 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9360 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9361 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9362 queue_num, "queue_num");
9363 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9364 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9365 queue_num_value, UINT8);
9367 cmdline_parse_inst_t cmd_queue_region = {
9368 .f = cmd_queue_region_parsed,
9370 .help_str = "set port <port_id> queue-region region_id <value> "
9371 "queue_start_index <value> queue_num <value>: Set a queue region",
9373 (void *)&cmd_queue_region_set,
9374 (void *)&cmd_queue_region_port,
9375 (void *)&cmd_queue_region_port_id,
9376 (void *)&cmd_queue_region_cmd,
9377 (void *)&cmd_queue_region_id,
9378 (void *)&cmd_queue_region_index,
9379 (void *)&cmd_queue_region_queue_start_index,
9380 (void *)&cmd_queue_region_queue_id,
9381 (void *)&cmd_queue_region_queue_num,
9382 (void *)&cmd_queue_region_queue_num_value,
9387 /* *** queue region and flowtype set *** */
9388 struct cmd_region_flowtype_result {
9389 cmdline_fixed_string_t set;
9390 cmdline_fixed_string_t port;
9392 cmdline_fixed_string_t cmd;
9393 cmdline_fixed_string_t region;
9395 cmdline_fixed_string_t flowtype;
9396 uint8_t flowtype_id;
9400 cmd_region_flowtype_parsed(void *parsed_result,
9401 __attribute__((unused)) struct cmdline *cl,
9402 __attribute__((unused)) void *data)
9404 struct cmd_region_flowtype_result *res = parsed_result;
9406 #ifdef RTE_LIBRTE_I40E_PMD
9407 struct rte_pmd_i40e_queue_region_conf region_conf;
9408 enum rte_pmd_i40e_queue_region_op op_type;
9411 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9414 #ifdef RTE_LIBRTE_I40E_PMD
9415 memset(®ion_conf, 0, sizeof(region_conf));
9417 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9418 region_conf.region_id = res->region_id;
9419 region_conf.hw_flowtype = res->flowtype_id;
9421 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9422 op_type, ®ion_conf);
9429 printf("function not implemented or supported\n");
9432 printf("region flowtype config error: (%s)\n", strerror(-ret));
9436 cmdline_parse_token_string_t cmd_region_flowtype_set =
9437 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9439 cmdline_parse_token_string_t cmd_region_flowtype_port =
9440 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9442 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9443 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9445 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9446 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9447 cmd, "queue-region");
9448 cmdline_parse_token_string_t cmd_region_flowtype_index =
9449 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9450 region, "region_id");
9451 cmdline_parse_token_num_t cmd_region_flowtype_id =
9452 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9454 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9455 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9456 flowtype, "flowtype");
9457 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9458 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9459 flowtype_id, UINT8);
9460 cmdline_parse_inst_t cmd_region_flowtype = {
9461 .f = cmd_region_flowtype_parsed,
9463 .help_str = "set port <port_id> queue-region region_id <value> "
9464 "flowtype <value>: Set a flowtype region index",
9466 (void *)&cmd_region_flowtype_set,
9467 (void *)&cmd_region_flowtype_port,
9468 (void *)&cmd_region_flowtype_port_index,
9469 (void *)&cmd_region_flowtype_cmd,
9470 (void *)&cmd_region_flowtype_index,
9471 (void *)&cmd_region_flowtype_id,
9472 (void *)&cmd_region_flowtype_flow_index,
9473 (void *)&cmd_region_flowtype_flow_id,
9478 /* *** User Priority (UP) to queue region (region_id) set *** */
9479 struct cmd_user_priority_region_result {
9480 cmdline_fixed_string_t set;
9481 cmdline_fixed_string_t port;
9483 cmdline_fixed_string_t cmd;
9484 cmdline_fixed_string_t user_priority;
9485 uint8_t user_priority_id;
9486 cmdline_fixed_string_t region;
9491 cmd_user_priority_region_parsed(void *parsed_result,
9492 __attribute__((unused)) struct cmdline *cl,
9493 __attribute__((unused)) void *data)
9495 struct cmd_user_priority_region_result *res = parsed_result;
9497 #ifdef RTE_LIBRTE_I40E_PMD
9498 struct rte_pmd_i40e_queue_region_conf region_conf;
9499 enum rte_pmd_i40e_queue_region_op op_type;
9502 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9505 #ifdef RTE_LIBRTE_I40E_PMD
9506 memset(®ion_conf, 0, sizeof(region_conf));
9507 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9508 region_conf.user_priority = res->user_priority_id;
9509 region_conf.region_id = res->region_id;
9511 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9512 op_type, ®ion_conf);
9519 printf("function not implemented or supported\n");
9522 printf("user_priority region config error: (%s)\n",
9527 cmdline_parse_token_string_t cmd_user_priority_region_set =
9528 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9530 cmdline_parse_token_string_t cmd_user_priority_region_port =
9531 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9533 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9534 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9536 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9537 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9538 cmd, "queue-region");
9539 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9540 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9541 user_priority, "UP");
9542 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9543 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9544 user_priority_id, UINT8);
9545 cmdline_parse_token_string_t cmd_user_priority_region_region =
9546 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9547 region, "region_id");
9548 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9549 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9552 cmdline_parse_inst_t cmd_user_priority_region = {
9553 .f = cmd_user_priority_region_parsed,
9555 .help_str = "set port <port_id> queue-region UP <value> "
9556 "region_id <value>: Set the mapping of User Priority (UP) "
9557 "to queue region (region_id) ",
9559 (void *)&cmd_user_priority_region_set,
9560 (void *)&cmd_user_priority_region_port,
9561 (void *)&cmd_user_priority_region_port_index,
9562 (void *)&cmd_user_priority_region_cmd,
9563 (void *)&cmd_user_priority_region_UP,
9564 (void *)&cmd_user_priority_region_UP_id,
9565 (void *)&cmd_user_priority_region_region,
9566 (void *)&cmd_user_priority_region_region_id,
9571 /* *** flush all queue region related configuration *** */
9572 struct cmd_flush_queue_region_result {
9573 cmdline_fixed_string_t set;
9574 cmdline_fixed_string_t port;
9576 cmdline_fixed_string_t cmd;
9577 cmdline_fixed_string_t flush;
9578 cmdline_fixed_string_t what;
9582 cmd_flush_queue_region_parsed(void *parsed_result,
9583 __attribute__((unused)) struct cmdline *cl,
9584 __attribute__((unused)) void *data)
9586 struct cmd_flush_queue_region_result *res = parsed_result;
9588 #ifdef RTE_LIBRTE_I40E_PMD
9589 struct rte_pmd_i40e_queue_region_conf region_conf;
9590 enum rte_pmd_i40e_queue_region_op op_type;
9593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9596 #ifdef RTE_LIBRTE_I40E_PMD
9597 memset(®ion_conf, 0, sizeof(region_conf));
9599 if (strcmp(res->what, "on") == 0)
9600 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9602 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9604 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9605 op_type, ®ion_conf);
9612 printf("function not implemented or supported\n");
9615 printf("queue region config flush error: (%s)\n",
9620 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9621 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9623 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9624 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9626 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9627 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9629 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9630 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9631 cmd, "queue-region");
9632 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9633 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9635 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9636 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9639 cmdline_parse_inst_t cmd_flush_queue_region = {
9640 .f = cmd_flush_queue_region_parsed,
9642 .help_str = "set port <port_id> queue-region flush on|off"
9643 ": flush all queue region related configuration",
9645 (void *)&cmd_flush_queue_region_set,
9646 (void *)&cmd_flush_queue_region_port,
9647 (void *)&cmd_flush_queue_region_port_index,
9648 (void *)&cmd_flush_queue_region_cmd,
9649 (void *)&cmd_flush_queue_region_flush,
9650 (void *)&cmd_flush_queue_region_what,
9655 /* *** get all queue region related configuration info *** */
9656 struct cmd_show_queue_region_info {
9657 cmdline_fixed_string_t show;
9658 cmdline_fixed_string_t port;
9660 cmdline_fixed_string_t cmd;
9664 cmd_show_queue_region_info_parsed(void *parsed_result,
9665 __attribute__((unused)) struct cmdline *cl,
9666 __attribute__((unused)) void *data)
9668 struct cmd_show_queue_region_info *res = parsed_result;
9670 #ifdef RTE_LIBRTE_I40E_PMD
9671 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9672 enum rte_pmd_i40e_queue_region_op op_type;
9675 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9678 #ifdef RTE_LIBRTE_I40E_PMD
9679 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9681 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9683 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9684 op_type, &rte_pmd_regions);
9686 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9693 printf("function not implemented or supported\n");
9696 printf("queue region config info show error: (%s)\n",
9701 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9702 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9704 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9705 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9707 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9708 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9710 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9711 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9712 cmd, "queue-region");
9714 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9715 .f = cmd_show_queue_region_info_parsed,
9717 .help_str = "show port <port_id> queue-region"
9718 ": show all queue region related configuration info",
9720 (void *)&cmd_show_queue_region_info_get,
9721 (void *)&cmd_show_queue_region_info_port,
9722 (void *)&cmd_show_queue_region_info_port_index,
9723 (void *)&cmd_show_queue_region_info_cmd,
9728 /* *** ADD/REMOVE A 2tuple FILTER *** */
9729 struct cmd_2tuple_filter_result {
9730 cmdline_fixed_string_t filter;
9732 cmdline_fixed_string_t ops;
9733 cmdline_fixed_string_t dst_port;
9734 uint16_t dst_port_value;
9735 cmdline_fixed_string_t protocol;
9736 uint8_t protocol_value;
9737 cmdline_fixed_string_t mask;
9739 cmdline_fixed_string_t tcp_flags;
9740 uint8_t tcp_flags_value;
9741 cmdline_fixed_string_t priority;
9742 uint8_t priority_value;
9743 cmdline_fixed_string_t queue;
9748 cmd_2tuple_filter_parsed(void *parsed_result,
9749 __attribute__((unused)) struct cmdline *cl,
9750 __attribute__((unused)) void *data)
9752 struct rte_eth_ntuple_filter filter;
9753 struct cmd_2tuple_filter_result *res = parsed_result;
9756 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9758 printf("ntuple filter is not supported on port %u.\n",
9763 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9765 filter.flags = RTE_2TUPLE_FLAGS;
9766 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9767 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9768 filter.proto = res->protocol_value;
9769 filter.priority = res->priority_value;
9770 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9771 printf("nonzero tcp_flags is only meaningful"
9772 " when protocol is TCP.\n");
9775 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9776 printf("invalid TCP flags.\n");
9780 if (res->tcp_flags_value != 0) {
9781 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9782 filter.tcp_flags = res->tcp_flags_value;
9785 /* need convert to big endian. */
9786 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9787 filter.queue = res->queue_id;
9789 if (!strcmp(res->ops, "add"))
9790 ret = rte_eth_dev_filter_ctrl(res->port_id,
9791 RTE_ETH_FILTER_NTUPLE,
9795 ret = rte_eth_dev_filter_ctrl(res->port_id,
9796 RTE_ETH_FILTER_NTUPLE,
9797 RTE_ETH_FILTER_DELETE,
9800 printf("2tuple filter programming error: (%s)\n",
9805 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9806 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9807 filter, "2tuple_filter");
9808 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9809 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9811 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9812 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9814 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9815 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9816 dst_port, "dst_port");
9817 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9818 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9819 dst_port_value, UINT16);
9820 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9821 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9822 protocol, "protocol");
9823 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9824 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9825 protocol_value, UINT8);
9826 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9827 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9829 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9830 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9832 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9833 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9834 tcp_flags, "tcp_flags");
9835 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9836 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9837 tcp_flags_value, UINT8);
9838 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9839 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9840 priority, "priority");
9841 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9842 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9843 priority_value, UINT8);
9844 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9845 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9847 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9848 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9851 cmdline_parse_inst_t cmd_2tuple_filter = {
9852 .f = cmd_2tuple_filter_parsed,
9854 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9855 "<value> mask <value> tcp_flags <value> priority <value> queue "
9856 "<queue_id>: Add a 2tuple filter",
9858 (void *)&cmd_2tuple_filter_filter,
9859 (void *)&cmd_2tuple_filter_port_id,
9860 (void *)&cmd_2tuple_filter_ops,
9861 (void *)&cmd_2tuple_filter_dst_port,
9862 (void *)&cmd_2tuple_filter_dst_port_value,
9863 (void *)&cmd_2tuple_filter_protocol,
9864 (void *)&cmd_2tuple_filter_protocol_value,
9865 (void *)&cmd_2tuple_filter_mask,
9866 (void *)&cmd_2tuple_filter_mask_value,
9867 (void *)&cmd_2tuple_filter_tcp_flags,
9868 (void *)&cmd_2tuple_filter_tcp_flags_value,
9869 (void *)&cmd_2tuple_filter_priority,
9870 (void *)&cmd_2tuple_filter_priority_value,
9871 (void *)&cmd_2tuple_filter_queue,
9872 (void *)&cmd_2tuple_filter_queue_id,
9877 /* *** ADD/REMOVE A 5tuple FILTER *** */
9878 struct cmd_5tuple_filter_result {
9879 cmdline_fixed_string_t filter;
9881 cmdline_fixed_string_t ops;
9882 cmdline_fixed_string_t dst_ip;
9883 cmdline_ipaddr_t dst_ip_value;
9884 cmdline_fixed_string_t src_ip;
9885 cmdline_ipaddr_t src_ip_value;
9886 cmdline_fixed_string_t dst_port;
9887 uint16_t dst_port_value;
9888 cmdline_fixed_string_t src_port;
9889 uint16_t src_port_value;
9890 cmdline_fixed_string_t protocol;
9891 uint8_t protocol_value;
9892 cmdline_fixed_string_t mask;
9894 cmdline_fixed_string_t tcp_flags;
9895 uint8_t tcp_flags_value;
9896 cmdline_fixed_string_t priority;
9897 uint8_t priority_value;
9898 cmdline_fixed_string_t queue;
9903 cmd_5tuple_filter_parsed(void *parsed_result,
9904 __attribute__((unused)) struct cmdline *cl,
9905 __attribute__((unused)) void *data)
9907 struct rte_eth_ntuple_filter filter;
9908 struct cmd_5tuple_filter_result *res = parsed_result;
9911 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9913 printf("ntuple filter is not supported on port %u.\n",
9918 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9920 filter.flags = RTE_5TUPLE_FLAGS;
9921 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9922 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9923 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9924 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9925 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9926 filter.proto = res->protocol_value;
9927 filter.priority = res->priority_value;
9928 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9929 printf("nonzero tcp_flags is only meaningful"
9930 " when protocol is TCP.\n");
9933 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9934 printf("invalid TCP flags.\n");
9938 if (res->tcp_flags_value != 0) {
9939 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9940 filter.tcp_flags = res->tcp_flags_value;
9943 if (res->dst_ip_value.family == AF_INET)
9944 /* no need to convert, already big endian. */
9945 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9947 if (filter.dst_ip_mask == 0) {
9948 printf("can not support ipv6 involved compare.\n");
9954 if (res->src_ip_value.family == AF_INET)
9955 /* no need to convert, already big endian. */
9956 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9958 if (filter.src_ip_mask == 0) {
9959 printf("can not support ipv6 involved compare.\n");
9964 /* need convert to big endian. */
9965 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9966 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9967 filter.queue = res->queue_id;
9969 if (!strcmp(res->ops, "add"))
9970 ret = rte_eth_dev_filter_ctrl(res->port_id,
9971 RTE_ETH_FILTER_NTUPLE,
9975 ret = rte_eth_dev_filter_ctrl(res->port_id,
9976 RTE_ETH_FILTER_NTUPLE,
9977 RTE_ETH_FILTER_DELETE,
9980 printf("5tuple filter programming error: (%s)\n",
9984 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9985 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9986 filter, "5tuple_filter");
9987 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9988 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9990 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9991 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9993 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9994 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9996 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9997 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9999 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10000 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10002 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10003 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10005 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10006 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10007 dst_port, "dst_port");
10008 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10009 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10010 dst_port_value, UINT16);
10011 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10012 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10013 src_port, "src_port");
10014 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10015 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10016 src_port_value, UINT16);
10017 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10018 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10019 protocol, "protocol");
10020 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10021 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10022 protocol_value, UINT8);
10023 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10024 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10026 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10027 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10029 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10030 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10031 tcp_flags, "tcp_flags");
10032 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10033 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10034 tcp_flags_value, UINT8);
10035 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10036 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10037 priority, "priority");
10038 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10039 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10040 priority_value, UINT8);
10041 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10042 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10044 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10045 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10048 cmdline_parse_inst_t cmd_5tuple_filter = {
10049 .f = cmd_5tuple_filter_parsed,
10051 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10052 "src_ip <value> dst_port <value> src_port <value> "
10053 "protocol <value> mask <value> tcp_flags <value> "
10054 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10056 (void *)&cmd_5tuple_filter_filter,
10057 (void *)&cmd_5tuple_filter_port_id,
10058 (void *)&cmd_5tuple_filter_ops,
10059 (void *)&cmd_5tuple_filter_dst_ip,
10060 (void *)&cmd_5tuple_filter_dst_ip_value,
10061 (void *)&cmd_5tuple_filter_src_ip,
10062 (void *)&cmd_5tuple_filter_src_ip_value,
10063 (void *)&cmd_5tuple_filter_dst_port,
10064 (void *)&cmd_5tuple_filter_dst_port_value,
10065 (void *)&cmd_5tuple_filter_src_port,
10066 (void *)&cmd_5tuple_filter_src_port_value,
10067 (void *)&cmd_5tuple_filter_protocol,
10068 (void *)&cmd_5tuple_filter_protocol_value,
10069 (void *)&cmd_5tuple_filter_mask,
10070 (void *)&cmd_5tuple_filter_mask_value,
10071 (void *)&cmd_5tuple_filter_tcp_flags,
10072 (void *)&cmd_5tuple_filter_tcp_flags_value,
10073 (void *)&cmd_5tuple_filter_priority,
10074 (void *)&cmd_5tuple_filter_priority_value,
10075 (void *)&cmd_5tuple_filter_queue,
10076 (void *)&cmd_5tuple_filter_queue_id,
10081 /* *** ADD/REMOVE A flex FILTER *** */
10082 struct cmd_flex_filter_result {
10083 cmdline_fixed_string_t filter;
10084 cmdline_fixed_string_t ops;
10086 cmdline_fixed_string_t len;
10088 cmdline_fixed_string_t bytes;
10089 cmdline_fixed_string_t bytes_value;
10090 cmdline_fixed_string_t mask;
10091 cmdline_fixed_string_t mask_value;
10092 cmdline_fixed_string_t priority;
10093 uint8_t priority_value;
10094 cmdline_fixed_string_t queue;
10098 static int xdigit2val(unsigned char c)
10103 else if (isupper(c))
10104 val = c - 'A' + 10;
10106 val = c - 'a' + 10;
10111 cmd_flex_filter_parsed(void *parsed_result,
10112 __attribute__((unused)) struct cmdline *cl,
10113 __attribute__((unused)) void *data)
10116 struct rte_eth_flex_filter filter;
10117 struct cmd_flex_filter_result *res = parsed_result;
10118 char *bytes_ptr, *mask_ptr;
10119 uint16_t len, i, j = 0;
10124 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10125 printf("the len exceed the max length 128\n");
10128 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10129 filter.len = res->len_value;
10130 filter.priority = res->priority_value;
10131 filter.queue = res->queue_id;
10132 bytes_ptr = res->bytes_value;
10133 mask_ptr = res->mask_value;
10135 /* translate bytes string to array. */
10136 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10137 (bytes_ptr[1] == 'X')))
10139 len = strnlen(bytes_ptr, res->len_value * 2);
10140 if (len == 0 || (len % 8 != 0)) {
10141 printf("please check len and bytes input\n");
10144 for (i = 0; i < len; i++) {
10146 if (isxdigit(c) == 0) {
10147 /* invalid characters. */
10148 printf("invalid input\n");
10151 val = xdigit2val(c);
10154 filter.bytes[j] = byte;
10155 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10162 /* translate mask string to uint8_t array. */
10163 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10164 (mask_ptr[1] == 'X')))
10166 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10168 printf("invalid input\n");
10173 for (i = 0; i < len; i++) {
10175 if (isxdigit(c) == 0) {
10176 /* invalid characters. */
10177 printf("invalid input\n");
10180 val = xdigit2val(c);
10183 filter.mask[j] = byte;
10184 printf("mask[%d]:%02x ", j, filter.mask[j]);
10192 if (!strcmp(res->ops, "add"))
10193 ret = rte_eth_dev_filter_ctrl(res->port_id,
10194 RTE_ETH_FILTER_FLEXIBLE,
10195 RTE_ETH_FILTER_ADD,
10198 ret = rte_eth_dev_filter_ctrl(res->port_id,
10199 RTE_ETH_FILTER_FLEXIBLE,
10200 RTE_ETH_FILTER_DELETE,
10204 printf("flex filter setting error: (%s)\n", strerror(-ret));
10207 cmdline_parse_token_string_t cmd_flex_filter_filter =
10208 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10209 filter, "flex_filter");
10210 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10211 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10213 cmdline_parse_token_string_t cmd_flex_filter_ops =
10214 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10216 cmdline_parse_token_string_t cmd_flex_filter_len =
10217 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10219 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10220 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10222 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10223 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10225 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10226 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10227 bytes_value, NULL);
10228 cmdline_parse_token_string_t cmd_flex_filter_mask =
10229 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10231 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10232 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10234 cmdline_parse_token_string_t cmd_flex_filter_priority =
10235 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10236 priority, "priority");
10237 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10238 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10239 priority_value, UINT8);
10240 cmdline_parse_token_string_t cmd_flex_filter_queue =
10241 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10243 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10244 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10246 cmdline_parse_inst_t cmd_flex_filter = {
10247 .f = cmd_flex_filter_parsed,
10249 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10250 "<value> mask <value> priority <value> queue <queue_id>: "
10251 "Add/Del a flex filter",
10253 (void *)&cmd_flex_filter_filter,
10254 (void *)&cmd_flex_filter_port_id,
10255 (void *)&cmd_flex_filter_ops,
10256 (void *)&cmd_flex_filter_len,
10257 (void *)&cmd_flex_filter_len_value,
10258 (void *)&cmd_flex_filter_bytes,
10259 (void *)&cmd_flex_filter_bytes_value,
10260 (void *)&cmd_flex_filter_mask,
10261 (void *)&cmd_flex_filter_mask_value,
10262 (void *)&cmd_flex_filter_priority,
10263 (void *)&cmd_flex_filter_priority_value,
10264 (void *)&cmd_flex_filter_queue,
10265 (void *)&cmd_flex_filter_queue_id,
10270 /* *** Filters Control *** */
10272 /* *** deal with ethertype filter *** */
10273 struct cmd_ethertype_filter_result {
10274 cmdline_fixed_string_t filter;
10276 cmdline_fixed_string_t ops;
10277 cmdline_fixed_string_t mac;
10278 struct ether_addr mac_addr;
10279 cmdline_fixed_string_t ethertype;
10280 uint16_t ethertype_value;
10281 cmdline_fixed_string_t drop;
10282 cmdline_fixed_string_t queue;
10286 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10287 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10288 filter, "ethertype_filter");
10289 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10290 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10292 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10293 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10295 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10296 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10297 mac, "mac_addr#mac_ignr");
10298 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10299 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10301 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10302 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10303 ethertype, "ethertype");
10304 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10305 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10306 ethertype_value, UINT16);
10307 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10308 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10310 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10311 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10313 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10314 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10318 cmd_ethertype_filter_parsed(void *parsed_result,
10319 __attribute__((unused)) struct cmdline *cl,
10320 __attribute__((unused)) void *data)
10322 struct cmd_ethertype_filter_result *res = parsed_result;
10323 struct rte_eth_ethertype_filter filter;
10326 ret = rte_eth_dev_filter_supported(res->port_id,
10327 RTE_ETH_FILTER_ETHERTYPE);
10329 printf("ethertype filter is not supported on port %u.\n",
10334 memset(&filter, 0, sizeof(filter));
10335 if (!strcmp(res->mac, "mac_addr")) {
10336 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10337 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10338 sizeof(struct ether_addr));
10340 if (!strcmp(res->drop, "drop"))
10341 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10342 filter.ether_type = res->ethertype_value;
10343 filter.queue = res->queue_id;
10345 if (!strcmp(res->ops, "add"))
10346 ret = rte_eth_dev_filter_ctrl(res->port_id,
10347 RTE_ETH_FILTER_ETHERTYPE,
10348 RTE_ETH_FILTER_ADD,
10351 ret = rte_eth_dev_filter_ctrl(res->port_id,
10352 RTE_ETH_FILTER_ETHERTYPE,
10353 RTE_ETH_FILTER_DELETE,
10356 printf("ethertype filter programming error: (%s)\n",
10360 cmdline_parse_inst_t cmd_ethertype_filter = {
10361 .f = cmd_ethertype_filter_parsed,
10363 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10364 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10365 "Add or delete an ethertype filter entry",
10367 (void *)&cmd_ethertype_filter_filter,
10368 (void *)&cmd_ethertype_filter_port_id,
10369 (void *)&cmd_ethertype_filter_ops,
10370 (void *)&cmd_ethertype_filter_mac,
10371 (void *)&cmd_ethertype_filter_mac_addr,
10372 (void *)&cmd_ethertype_filter_ethertype,
10373 (void *)&cmd_ethertype_filter_ethertype_value,
10374 (void *)&cmd_ethertype_filter_drop,
10375 (void *)&cmd_ethertype_filter_queue,
10376 (void *)&cmd_ethertype_filter_queue_id,
10381 /* *** deal with flow director filter *** */
10382 struct cmd_flow_director_result {
10383 cmdline_fixed_string_t flow_director_filter;
10385 cmdline_fixed_string_t mode;
10386 cmdline_fixed_string_t mode_value;
10387 cmdline_fixed_string_t ops;
10388 cmdline_fixed_string_t flow;
10389 cmdline_fixed_string_t flow_type;
10390 cmdline_fixed_string_t ether;
10391 uint16_t ether_type;
10392 cmdline_fixed_string_t src;
10393 cmdline_ipaddr_t ip_src;
10395 cmdline_fixed_string_t dst;
10396 cmdline_ipaddr_t ip_dst;
10398 cmdline_fixed_string_t verify_tag;
10399 uint32_t verify_tag_value;
10400 cmdline_fixed_string_t tos;
10402 cmdline_fixed_string_t proto;
10403 uint8_t proto_value;
10404 cmdline_fixed_string_t ttl;
10406 cmdline_fixed_string_t vlan;
10407 uint16_t vlan_value;
10408 cmdline_fixed_string_t flexbytes;
10409 cmdline_fixed_string_t flexbytes_value;
10410 cmdline_fixed_string_t pf_vf;
10411 cmdline_fixed_string_t drop;
10412 cmdline_fixed_string_t queue;
10414 cmdline_fixed_string_t fd_id;
10415 uint32_t fd_id_value;
10416 cmdline_fixed_string_t mac;
10417 struct ether_addr mac_addr;
10418 cmdline_fixed_string_t tunnel;
10419 cmdline_fixed_string_t tunnel_type;
10420 cmdline_fixed_string_t tunnel_id;
10421 uint32_t tunnel_id_value;
10422 cmdline_fixed_string_t packet;
10427 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10430 const char *p, *p0 = q_arg;
10432 unsigned long int_fld;
10433 char *str_fld[max_num];
10438 p = strchr(p0, '(');
10442 p0 = strchr(p, ')');
10447 if (size >= sizeof(s))
10450 snprintf(s, sizeof(s), "%.*s", size, p);
10451 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10452 if (ret < 0 || ret > max_num)
10454 for (i = 0; i < ret; i++) {
10456 int_fld = strtoul(str_fld[i], &end, 0);
10457 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10459 flexbytes[i] = (uint8_t)int_fld;
10465 str2flowtype(char *string)
10468 static const struct {
10471 } flowtype_str[] = {
10472 {"raw", RTE_ETH_FLOW_RAW},
10473 {"ipv4", RTE_ETH_FLOW_IPV4},
10474 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10475 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10476 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10477 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10478 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10479 {"ipv6", RTE_ETH_FLOW_IPV6},
10480 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10481 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10482 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10483 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10484 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10485 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10488 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10489 if (!strcmp(flowtype_str[i].str, string))
10490 return flowtype_str[i].type;
10493 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10494 return (uint16_t)atoi(string);
10496 return RTE_ETH_FLOW_UNKNOWN;
10499 static enum rte_eth_fdir_tunnel_type
10500 str2fdir_tunneltype(char *string)
10504 static const struct {
10506 enum rte_eth_fdir_tunnel_type type;
10507 } tunneltype_str[] = {
10508 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10509 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10512 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10513 if (!strcmp(tunneltype_str[i].str, string))
10514 return tunneltype_str[i].type;
10516 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10519 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10521 if ((ip_addr).family == AF_INET) \
10522 (ip) = (ip_addr).addr.ipv4.s_addr; \
10524 printf("invalid parameter.\n"); \
10529 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10531 if ((ip_addr).family == AF_INET6) \
10532 rte_memcpy(&(ip), \
10533 &((ip_addr).addr.ipv6), \
10534 sizeof(struct in6_addr)); \
10536 printf("invalid parameter.\n"); \
10542 cmd_flow_director_filter_parsed(void *parsed_result,
10543 __attribute__((unused)) struct cmdline *cl,
10544 __attribute__((unused)) void *data)
10546 struct cmd_flow_director_result *res = parsed_result;
10547 struct rte_eth_fdir_filter entry;
10548 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10550 unsigned long vf_id;
10553 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10555 printf("flow director is not supported on port %u.\n",
10559 memset(flexbytes, 0, sizeof(flexbytes));
10560 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10562 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10563 if (strcmp(res->mode_value, "MAC-VLAN")) {
10564 printf("Please set mode to MAC-VLAN.\n");
10567 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10568 if (strcmp(res->mode_value, "Tunnel")) {
10569 printf("Please set mode to Tunnel.\n");
10573 if (!strcmp(res->mode_value, "raw")) {
10574 #ifdef RTE_LIBRTE_I40E_PMD
10575 struct rte_pmd_i40e_flow_type_mapping
10576 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10577 struct rte_pmd_i40e_pkt_template_conf conf;
10578 uint16_t flow_type = str2flowtype(res->flow_type);
10579 uint16_t i, port = res->port_id;
10582 memset(&conf, 0, sizeof(conf));
10584 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10585 printf("Invalid flow type specified.\n");
10588 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10592 if (mapping[flow_type].pctype == 0ULL) {
10593 printf("Invalid flow type specified.\n");
10596 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10597 if (mapping[flow_type].pctype & (1ULL << i)) {
10598 conf.input.pctype = i;
10603 conf.input.packet = open_file(res->filepath,
10604 &conf.input.length);
10605 if (!conf.input.packet)
10607 if (!strcmp(res->drop, "drop"))
10608 conf.action.behavior =
10609 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10611 conf.action.behavior =
10612 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10613 conf.action.report_status =
10614 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10615 conf.action.rx_queue = res->queue_id;
10616 conf.soft_id = res->fd_id_value;
10617 add = strcmp(res->ops, "del") ? 1 : 0;
10618 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10622 printf("flow director config error: (%s)\n",
10624 close_file(conf.input.packet);
10627 } else if (strcmp(res->mode_value, "IP")) {
10628 printf("Please set mode to IP or raw.\n");
10631 entry.input.flow_type = str2flowtype(res->flow_type);
10634 ret = parse_flexbytes(res->flexbytes_value,
10636 RTE_ETH_FDIR_MAX_FLEXLEN);
10638 printf("error: Cannot parse flexbytes input.\n");
10642 switch (entry.input.flow_type) {
10643 case RTE_ETH_FLOW_FRAG_IPV4:
10644 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10645 entry.input.flow.ip4_flow.proto = res->proto_value;
10647 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10648 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10649 IPV4_ADDR_TO_UINT(res->ip_dst,
10650 entry.input.flow.ip4_flow.dst_ip);
10651 IPV4_ADDR_TO_UINT(res->ip_src,
10652 entry.input.flow.ip4_flow.src_ip);
10653 entry.input.flow.ip4_flow.tos = res->tos_value;
10654 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10655 /* need convert to big endian. */
10656 entry.input.flow.udp4_flow.dst_port =
10657 rte_cpu_to_be_16(res->port_dst);
10658 entry.input.flow.udp4_flow.src_port =
10659 rte_cpu_to_be_16(res->port_src);
10661 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10662 IPV4_ADDR_TO_UINT(res->ip_dst,
10663 entry.input.flow.sctp4_flow.ip.dst_ip);
10664 IPV4_ADDR_TO_UINT(res->ip_src,
10665 entry.input.flow.sctp4_flow.ip.src_ip);
10666 entry.input.flow.ip4_flow.tos = res->tos_value;
10667 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10668 /* need convert to big endian. */
10669 entry.input.flow.sctp4_flow.dst_port =
10670 rte_cpu_to_be_16(res->port_dst);
10671 entry.input.flow.sctp4_flow.src_port =
10672 rte_cpu_to_be_16(res->port_src);
10673 entry.input.flow.sctp4_flow.verify_tag =
10674 rte_cpu_to_be_32(res->verify_tag_value);
10676 case RTE_ETH_FLOW_FRAG_IPV6:
10677 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10678 entry.input.flow.ipv6_flow.proto = res->proto_value;
10680 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10681 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10682 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10683 entry.input.flow.ipv6_flow.dst_ip);
10684 IPV6_ADDR_TO_ARRAY(res->ip_src,
10685 entry.input.flow.ipv6_flow.src_ip);
10686 entry.input.flow.ipv6_flow.tc = res->tos_value;
10687 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10688 /* need convert to big endian. */
10689 entry.input.flow.udp6_flow.dst_port =
10690 rte_cpu_to_be_16(res->port_dst);
10691 entry.input.flow.udp6_flow.src_port =
10692 rte_cpu_to_be_16(res->port_src);
10694 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10695 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10696 entry.input.flow.sctp6_flow.ip.dst_ip);
10697 IPV6_ADDR_TO_ARRAY(res->ip_src,
10698 entry.input.flow.sctp6_flow.ip.src_ip);
10699 entry.input.flow.ipv6_flow.tc = res->tos_value;
10700 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10701 /* need convert to big endian. */
10702 entry.input.flow.sctp6_flow.dst_port =
10703 rte_cpu_to_be_16(res->port_dst);
10704 entry.input.flow.sctp6_flow.src_port =
10705 rte_cpu_to_be_16(res->port_src);
10706 entry.input.flow.sctp6_flow.verify_tag =
10707 rte_cpu_to_be_32(res->verify_tag_value);
10709 case RTE_ETH_FLOW_L2_PAYLOAD:
10710 entry.input.flow.l2_flow.ether_type =
10711 rte_cpu_to_be_16(res->ether_type);
10717 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10718 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10720 sizeof(struct ether_addr));
10722 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10723 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10725 sizeof(struct ether_addr));
10726 entry.input.flow.tunnel_flow.tunnel_type =
10727 str2fdir_tunneltype(res->tunnel_type);
10728 entry.input.flow.tunnel_flow.tunnel_id =
10729 rte_cpu_to_be_32(res->tunnel_id_value);
10732 rte_memcpy(entry.input.flow_ext.flexbytes,
10734 RTE_ETH_FDIR_MAX_FLEXLEN);
10736 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10738 entry.action.flex_off = 0; /*use 0 by default */
10739 if (!strcmp(res->drop, "drop"))
10740 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10742 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10744 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10745 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10746 if (!strcmp(res->pf_vf, "pf"))
10747 entry.input.flow_ext.is_vf = 0;
10748 else if (!strncmp(res->pf_vf, "vf", 2)) {
10749 struct rte_eth_dev_info dev_info;
10751 memset(&dev_info, 0, sizeof(dev_info));
10752 rte_eth_dev_info_get(res->port_id, &dev_info);
10754 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10755 if (errno != 0 || *end != '\0' ||
10756 vf_id >= dev_info.max_vfs) {
10757 printf("invalid parameter %s.\n", res->pf_vf);
10760 entry.input.flow_ext.is_vf = 1;
10761 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10763 printf("invalid parameter %s.\n", res->pf_vf);
10768 /* set to report FD ID by default */
10769 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10770 entry.action.rx_queue = res->queue_id;
10771 entry.soft_id = res->fd_id_value;
10772 if (!strcmp(res->ops, "add"))
10773 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10774 RTE_ETH_FILTER_ADD, &entry);
10775 else if (!strcmp(res->ops, "del"))
10776 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10777 RTE_ETH_FILTER_DELETE, &entry);
10779 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10780 RTE_ETH_FILTER_UPDATE, &entry);
10782 printf("flow director programming error: (%s)\n",
10786 cmdline_parse_token_string_t cmd_flow_director_filter =
10787 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10788 flow_director_filter, "flow_director_filter");
10789 cmdline_parse_token_num_t cmd_flow_director_port_id =
10790 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10792 cmdline_parse_token_string_t cmd_flow_director_ops =
10793 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10794 ops, "add#del#update");
10795 cmdline_parse_token_string_t cmd_flow_director_flow =
10796 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10798 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10801 cmdline_parse_token_string_t cmd_flow_director_ether =
10802 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10804 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10805 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10806 ether_type, UINT16);
10807 cmdline_parse_token_string_t cmd_flow_director_src =
10808 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10810 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10811 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10813 cmdline_parse_token_num_t cmd_flow_director_port_src =
10814 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10816 cmdline_parse_token_string_t cmd_flow_director_dst =
10817 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10819 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10820 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10822 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10823 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10825 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10827 verify_tag, "verify_tag");
10828 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10829 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10830 verify_tag_value, UINT32);
10831 cmdline_parse_token_string_t cmd_flow_director_tos =
10832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10834 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10835 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10837 cmdline_parse_token_string_t cmd_flow_director_proto =
10838 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10840 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10841 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10842 proto_value, UINT8);
10843 cmdline_parse_token_string_t cmd_flow_director_ttl =
10844 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10846 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10847 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10849 cmdline_parse_token_string_t cmd_flow_director_vlan =
10850 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10852 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10853 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10854 vlan_value, UINT16);
10855 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10857 flexbytes, "flexbytes");
10858 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10860 flexbytes_value, NULL);
10861 cmdline_parse_token_string_t cmd_flow_director_drop =
10862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10864 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10867 cmdline_parse_token_string_t cmd_flow_director_queue =
10868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10870 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10871 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10873 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10876 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10877 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10878 fd_id_value, UINT32);
10880 cmdline_parse_token_string_t cmd_flow_director_mode =
10881 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10883 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10884 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10886 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10887 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10888 mode_value, "MAC-VLAN");
10889 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10890 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10891 mode_value, "Tunnel");
10892 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10893 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10894 mode_value, "raw");
10895 cmdline_parse_token_string_t cmd_flow_director_mac =
10896 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10898 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10899 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10901 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10902 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10904 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10905 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10906 tunnel_type, "NVGRE#VxLAN");
10907 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10908 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10909 tunnel_id, "tunnel-id");
10910 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10911 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10912 tunnel_id_value, UINT32);
10913 cmdline_parse_token_string_t cmd_flow_director_packet =
10914 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10916 cmdline_parse_token_string_t cmd_flow_director_filepath =
10917 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10920 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10921 .f = cmd_flow_director_filter_parsed,
10923 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10924 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10925 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10926 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10927 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10928 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10929 "fd_id <fd_id_value>: "
10930 "Add or delete an ip flow director entry on NIC",
10932 (void *)&cmd_flow_director_filter,
10933 (void *)&cmd_flow_director_port_id,
10934 (void *)&cmd_flow_director_mode,
10935 (void *)&cmd_flow_director_mode_ip,
10936 (void *)&cmd_flow_director_ops,
10937 (void *)&cmd_flow_director_flow,
10938 (void *)&cmd_flow_director_flow_type,
10939 (void *)&cmd_flow_director_src,
10940 (void *)&cmd_flow_director_ip_src,
10941 (void *)&cmd_flow_director_dst,
10942 (void *)&cmd_flow_director_ip_dst,
10943 (void *)&cmd_flow_director_tos,
10944 (void *)&cmd_flow_director_tos_value,
10945 (void *)&cmd_flow_director_proto,
10946 (void *)&cmd_flow_director_proto_value,
10947 (void *)&cmd_flow_director_ttl,
10948 (void *)&cmd_flow_director_ttl_value,
10949 (void *)&cmd_flow_director_vlan,
10950 (void *)&cmd_flow_director_vlan_value,
10951 (void *)&cmd_flow_director_flexbytes,
10952 (void *)&cmd_flow_director_flexbytes_value,
10953 (void *)&cmd_flow_director_drop,
10954 (void *)&cmd_flow_director_pf_vf,
10955 (void *)&cmd_flow_director_queue,
10956 (void *)&cmd_flow_director_queue_id,
10957 (void *)&cmd_flow_director_fd_id,
10958 (void *)&cmd_flow_director_fd_id_value,
10963 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10964 .f = cmd_flow_director_filter_parsed,
10966 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10967 "director entry on NIC",
10969 (void *)&cmd_flow_director_filter,
10970 (void *)&cmd_flow_director_port_id,
10971 (void *)&cmd_flow_director_mode,
10972 (void *)&cmd_flow_director_mode_ip,
10973 (void *)&cmd_flow_director_ops,
10974 (void *)&cmd_flow_director_flow,
10975 (void *)&cmd_flow_director_flow_type,
10976 (void *)&cmd_flow_director_src,
10977 (void *)&cmd_flow_director_ip_src,
10978 (void *)&cmd_flow_director_port_src,
10979 (void *)&cmd_flow_director_dst,
10980 (void *)&cmd_flow_director_ip_dst,
10981 (void *)&cmd_flow_director_port_dst,
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_sctp_flow_director = {
11001 .f = cmd_flow_director_filter_parsed,
11003 .help_str = "flow_director_filter ... : Add or delete a sctp 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_src,
11014 (void *)&cmd_flow_director_ip_src,
11015 (void *)&cmd_flow_director_port_src,
11016 (void *)&cmd_flow_director_dst,
11017 (void *)&cmd_flow_director_ip_dst,
11018 (void *)&cmd_flow_director_port_dst,
11019 (void *)&cmd_flow_director_verify_tag,
11020 (void *)&cmd_flow_director_verify_tag_value,
11021 (void *)&cmd_flow_director_tos,
11022 (void *)&cmd_flow_director_tos_value,
11023 (void *)&cmd_flow_director_ttl,
11024 (void *)&cmd_flow_director_ttl_value,
11025 (void *)&cmd_flow_director_vlan,
11026 (void *)&cmd_flow_director_vlan_value,
11027 (void *)&cmd_flow_director_flexbytes,
11028 (void *)&cmd_flow_director_flexbytes_value,
11029 (void *)&cmd_flow_director_drop,
11030 (void *)&cmd_flow_director_pf_vf,
11031 (void *)&cmd_flow_director_queue,
11032 (void *)&cmd_flow_director_queue_id,
11033 (void *)&cmd_flow_director_fd_id,
11034 (void *)&cmd_flow_director_fd_id_value,
11039 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11040 .f = cmd_flow_director_filter_parsed,
11042 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11043 "director entry on NIC",
11045 (void *)&cmd_flow_director_filter,
11046 (void *)&cmd_flow_director_port_id,
11047 (void *)&cmd_flow_director_mode,
11048 (void *)&cmd_flow_director_mode_ip,
11049 (void *)&cmd_flow_director_ops,
11050 (void *)&cmd_flow_director_flow,
11051 (void *)&cmd_flow_director_flow_type,
11052 (void *)&cmd_flow_director_ether,
11053 (void *)&cmd_flow_director_ether_type,
11054 (void *)&cmd_flow_director_flexbytes,
11055 (void *)&cmd_flow_director_flexbytes_value,
11056 (void *)&cmd_flow_director_drop,
11057 (void *)&cmd_flow_director_pf_vf,
11058 (void *)&cmd_flow_director_queue,
11059 (void *)&cmd_flow_director_queue_id,
11060 (void *)&cmd_flow_director_fd_id,
11061 (void *)&cmd_flow_director_fd_id_value,
11066 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11067 .f = cmd_flow_director_filter_parsed,
11069 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11070 "director entry on NIC",
11072 (void *)&cmd_flow_director_filter,
11073 (void *)&cmd_flow_director_port_id,
11074 (void *)&cmd_flow_director_mode,
11075 (void *)&cmd_flow_director_mode_mac_vlan,
11076 (void *)&cmd_flow_director_ops,
11077 (void *)&cmd_flow_director_mac,
11078 (void *)&cmd_flow_director_mac_addr,
11079 (void *)&cmd_flow_director_vlan,
11080 (void *)&cmd_flow_director_vlan_value,
11081 (void *)&cmd_flow_director_flexbytes,
11082 (void *)&cmd_flow_director_flexbytes_value,
11083 (void *)&cmd_flow_director_drop,
11084 (void *)&cmd_flow_director_queue,
11085 (void *)&cmd_flow_director_queue_id,
11086 (void *)&cmd_flow_director_fd_id,
11087 (void *)&cmd_flow_director_fd_id_value,
11092 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11093 .f = cmd_flow_director_filter_parsed,
11095 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11096 "director entry on NIC",
11098 (void *)&cmd_flow_director_filter,
11099 (void *)&cmd_flow_director_port_id,
11100 (void *)&cmd_flow_director_mode,
11101 (void *)&cmd_flow_director_mode_tunnel,
11102 (void *)&cmd_flow_director_ops,
11103 (void *)&cmd_flow_director_mac,
11104 (void *)&cmd_flow_director_mac_addr,
11105 (void *)&cmd_flow_director_vlan,
11106 (void *)&cmd_flow_director_vlan_value,
11107 (void *)&cmd_flow_director_tunnel,
11108 (void *)&cmd_flow_director_tunnel_type,
11109 (void *)&cmd_flow_director_tunnel_id,
11110 (void *)&cmd_flow_director_tunnel_id_value,
11111 (void *)&cmd_flow_director_flexbytes,
11112 (void *)&cmd_flow_director_flexbytes_value,
11113 (void *)&cmd_flow_director_drop,
11114 (void *)&cmd_flow_director_queue,
11115 (void *)&cmd_flow_director_queue_id,
11116 (void *)&cmd_flow_director_fd_id,
11117 (void *)&cmd_flow_director_fd_id_value,
11122 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11123 .f = cmd_flow_director_filter_parsed,
11125 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11126 "director entry on NIC",
11128 (void *)&cmd_flow_director_filter,
11129 (void *)&cmd_flow_director_port_id,
11130 (void *)&cmd_flow_director_mode,
11131 (void *)&cmd_flow_director_mode_raw,
11132 (void *)&cmd_flow_director_ops,
11133 (void *)&cmd_flow_director_flow,
11134 (void *)&cmd_flow_director_flow_type,
11135 (void *)&cmd_flow_director_drop,
11136 (void *)&cmd_flow_director_queue,
11137 (void *)&cmd_flow_director_queue_id,
11138 (void *)&cmd_flow_director_fd_id,
11139 (void *)&cmd_flow_director_fd_id_value,
11140 (void *)&cmd_flow_director_packet,
11141 (void *)&cmd_flow_director_filepath,
11146 struct cmd_flush_flow_director_result {
11147 cmdline_fixed_string_t flush_flow_director;
11151 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11152 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11153 flush_flow_director, "flush_flow_director");
11154 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11155 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11159 cmd_flush_flow_director_parsed(void *parsed_result,
11160 __attribute__((unused)) struct cmdline *cl,
11161 __attribute__((unused)) void *data)
11163 struct cmd_flow_director_result *res = parsed_result;
11166 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11168 printf("flow director is not supported on port %u.\n",
11173 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11174 RTE_ETH_FILTER_FLUSH, NULL);
11176 printf("flow director table flushing error: (%s)\n",
11180 cmdline_parse_inst_t cmd_flush_flow_director = {
11181 .f = cmd_flush_flow_director_parsed,
11183 .help_str = "flush_flow_director <port_id>: "
11184 "Flush all flow director entries of a device on NIC",
11186 (void *)&cmd_flush_flow_director_flush,
11187 (void *)&cmd_flush_flow_director_port_id,
11192 /* *** deal with flow director mask *** */
11193 struct cmd_flow_director_mask_result {
11194 cmdline_fixed_string_t flow_director_mask;
11196 cmdline_fixed_string_t mode;
11197 cmdline_fixed_string_t mode_value;
11198 cmdline_fixed_string_t vlan;
11199 uint16_t vlan_mask;
11200 cmdline_fixed_string_t src_mask;
11201 cmdline_ipaddr_t ipv4_src;
11202 cmdline_ipaddr_t ipv6_src;
11204 cmdline_fixed_string_t dst_mask;
11205 cmdline_ipaddr_t ipv4_dst;
11206 cmdline_ipaddr_t ipv6_dst;
11208 cmdline_fixed_string_t mac;
11209 uint8_t mac_addr_byte_mask;
11210 cmdline_fixed_string_t tunnel_id;
11211 uint32_t tunnel_id_mask;
11212 cmdline_fixed_string_t tunnel_type;
11213 uint8_t tunnel_type_mask;
11217 cmd_flow_director_mask_parsed(void *parsed_result,
11218 __attribute__((unused)) struct cmdline *cl,
11219 __attribute__((unused)) void *data)
11221 struct cmd_flow_director_mask_result *res = parsed_result;
11222 struct rte_eth_fdir_masks *mask;
11223 struct rte_port *port;
11225 port = &ports[res->port_id];
11226 /** Check if the port is not started **/
11227 if (port->port_status != RTE_PORT_STOPPED) {
11228 printf("Please stop port %d first\n", res->port_id);
11232 mask = &port->dev_conf.fdir_conf.mask;
11234 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11235 if (strcmp(res->mode_value, "MAC-VLAN")) {
11236 printf("Please set mode to MAC-VLAN.\n");
11240 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11241 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11242 if (strcmp(res->mode_value, "Tunnel")) {
11243 printf("Please set mode to Tunnel.\n");
11247 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11248 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11249 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11250 mask->tunnel_type_mask = res->tunnel_type_mask;
11252 if (strcmp(res->mode_value, "IP")) {
11253 printf("Please set mode to IP.\n");
11257 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11258 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11259 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11260 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11261 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11262 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11263 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11266 cmd_reconfig_device_queue(res->port_id, 1, 1);
11269 cmdline_parse_token_string_t cmd_flow_director_mask =
11270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11271 flow_director_mask, "flow_director_mask");
11272 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11273 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11275 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11278 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11279 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11280 vlan_mask, UINT16);
11281 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11282 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11283 src_mask, "src_mask");
11284 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11285 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11287 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11288 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11290 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11291 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11293 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11295 dst_mask, "dst_mask");
11296 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11297 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11299 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11300 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11302 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11303 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11306 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11307 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11309 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11312 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11313 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11314 mode_value, "MAC-VLAN");
11315 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11316 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11317 mode_value, "Tunnel");
11318 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11321 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11322 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11323 mac_addr_byte_mask, UINT8);
11324 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11325 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11326 tunnel_type, "tunnel-type");
11327 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11328 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11329 tunnel_type_mask, UINT8);
11330 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11331 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11332 tunnel_id, "tunnel-id");
11333 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11334 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11335 tunnel_id_mask, UINT32);
11337 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11338 .f = cmd_flow_director_mask_parsed,
11340 .help_str = "flow_director_mask ... : "
11341 "Set IP mode flow director's mask on NIC",
11343 (void *)&cmd_flow_director_mask,
11344 (void *)&cmd_flow_director_mask_port_id,
11345 (void *)&cmd_flow_director_mask_mode,
11346 (void *)&cmd_flow_director_mask_mode_ip,
11347 (void *)&cmd_flow_director_mask_vlan,
11348 (void *)&cmd_flow_director_mask_vlan_value,
11349 (void *)&cmd_flow_director_mask_src,
11350 (void *)&cmd_flow_director_mask_ipv4_src,
11351 (void *)&cmd_flow_director_mask_ipv6_src,
11352 (void *)&cmd_flow_director_mask_port_src,
11353 (void *)&cmd_flow_director_mask_dst,
11354 (void *)&cmd_flow_director_mask_ipv4_dst,
11355 (void *)&cmd_flow_director_mask_ipv6_dst,
11356 (void *)&cmd_flow_director_mask_port_dst,
11361 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11362 .f = cmd_flow_director_mask_parsed,
11364 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11365 "flow director's mask on NIC",
11367 (void *)&cmd_flow_director_mask,
11368 (void *)&cmd_flow_director_mask_port_id,
11369 (void *)&cmd_flow_director_mask_mode,
11370 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11371 (void *)&cmd_flow_director_mask_vlan,
11372 (void *)&cmd_flow_director_mask_vlan_value,
11377 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11378 .f = cmd_flow_director_mask_parsed,
11380 .help_str = "flow_director_mask ... : Set tunnel mode "
11381 "flow director's mask on NIC",
11383 (void *)&cmd_flow_director_mask,
11384 (void *)&cmd_flow_director_mask_port_id,
11385 (void *)&cmd_flow_director_mask_mode,
11386 (void *)&cmd_flow_director_mask_mode_tunnel,
11387 (void *)&cmd_flow_director_mask_vlan,
11388 (void *)&cmd_flow_director_mask_vlan_value,
11389 (void *)&cmd_flow_director_mask_mac,
11390 (void *)&cmd_flow_director_mask_mac_value,
11391 (void *)&cmd_flow_director_mask_tunnel_type,
11392 (void *)&cmd_flow_director_mask_tunnel_type_value,
11393 (void *)&cmd_flow_director_mask_tunnel_id,
11394 (void *)&cmd_flow_director_mask_tunnel_id_value,
11399 /* *** deal with flow director mask on flexible payload *** */
11400 struct cmd_flow_director_flex_mask_result {
11401 cmdline_fixed_string_t flow_director_flexmask;
11403 cmdline_fixed_string_t flow;
11404 cmdline_fixed_string_t flow_type;
11405 cmdline_fixed_string_t mask;
11409 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11410 __attribute__((unused)) struct cmdline *cl,
11411 __attribute__((unused)) void *data)
11413 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11414 struct rte_eth_fdir_info fdir_info;
11415 struct rte_eth_fdir_flex_mask flex_mask;
11416 struct rte_port *port;
11417 uint64_t flow_type_mask;
11421 port = &ports[res->port_id];
11422 /** Check if the port is not started **/
11423 if (port->port_status != RTE_PORT_STOPPED) {
11424 printf("Please stop port %d first\n", res->port_id);
11428 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11429 ret = parse_flexbytes(res->mask,
11431 RTE_ETH_FDIR_MAX_FLEXLEN);
11433 printf("error: Cannot parse mask input.\n");
11437 memset(&fdir_info, 0, sizeof(fdir_info));
11438 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11439 RTE_ETH_FILTER_INFO, &fdir_info);
11441 printf("Cannot get FDir filter info\n");
11445 if (!strcmp(res->flow_type, "none")) {
11446 /* means don't specify the flow type */
11447 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11448 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11449 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11450 0, sizeof(struct rte_eth_fdir_flex_mask));
11451 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11452 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11454 sizeof(struct rte_eth_fdir_flex_mask));
11455 cmd_reconfig_device_queue(res->port_id, 1, 1);
11458 flow_type_mask = fdir_info.flow_types_mask[0];
11459 if (!strcmp(res->flow_type, "all")) {
11460 if (!flow_type_mask) {
11461 printf("No flow type supported\n");
11464 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11465 if (flow_type_mask & (1ULL << i)) {
11466 flex_mask.flow_type = i;
11467 fdir_set_flex_mask(res->port_id, &flex_mask);
11470 cmd_reconfig_device_queue(res->port_id, 1, 1);
11473 flex_mask.flow_type = str2flowtype(res->flow_type);
11474 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11475 printf("Flow type %s not supported on port %d\n",
11476 res->flow_type, res->port_id);
11479 fdir_set_flex_mask(res->port_id, &flex_mask);
11480 cmd_reconfig_device_queue(res->port_id, 1, 1);
11483 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11484 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11485 flow_director_flexmask,
11486 "flow_director_flex_mask");
11487 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11488 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11490 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11491 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11493 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11494 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11495 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11496 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11497 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11498 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11501 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11502 .f = cmd_flow_director_flex_mask_parsed,
11504 .help_str = "flow_director_flex_mask ... : "
11505 "Set flow director's flex mask on NIC",
11507 (void *)&cmd_flow_director_flexmask,
11508 (void *)&cmd_flow_director_flexmask_port_id,
11509 (void *)&cmd_flow_director_flexmask_flow,
11510 (void *)&cmd_flow_director_flexmask_flow_type,
11511 (void *)&cmd_flow_director_flexmask_mask,
11516 /* *** deal with flow director flexible payload configuration *** */
11517 struct cmd_flow_director_flexpayload_result {
11518 cmdline_fixed_string_t flow_director_flexpayload;
11520 cmdline_fixed_string_t payload_layer;
11521 cmdline_fixed_string_t payload_cfg;
11525 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11528 const char *p, *p0 = q_arg;
11530 unsigned long int_fld;
11531 char *str_fld[max_num];
11536 p = strchr(p0, '(');
11540 p0 = strchr(p, ')');
11545 if (size >= sizeof(s))
11548 snprintf(s, sizeof(s), "%.*s", size, p);
11549 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11550 if (ret < 0 || ret > max_num)
11552 for (i = 0; i < ret; i++) {
11554 int_fld = strtoul(str_fld[i], &end, 0);
11555 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11557 offsets[i] = (uint16_t)int_fld;
11563 cmd_flow_director_flxpld_parsed(void *parsed_result,
11564 __attribute__((unused)) struct cmdline *cl,
11565 __attribute__((unused)) void *data)
11567 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11568 struct rte_eth_flex_payload_cfg flex_cfg;
11569 struct rte_port *port;
11572 port = &ports[res->port_id];
11573 /** Check if the port is not started **/
11574 if (port->port_status != RTE_PORT_STOPPED) {
11575 printf("Please stop port %d first\n", res->port_id);
11579 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11581 if (!strcmp(res->payload_layer, "raw"))
11582 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11583 else if (!strcmp(res->payload_layer, "l2"))
11584 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11585 else if (!strcmp(res->payload_layer, "l3"))
11586 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11587 else if (!strcmp(res->payload_layer, "l4"))
11588 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11590 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11591 RTE_ETH_FDIR_MAX_FLEXLEN);
11593 printf("error: Cannot parse flex payload input.\n");
11597 fdir_set_flex_payload(res->port_id, &flex_cfg);
11598 cmd_reconfig_device_queue(res->port_id, 1, 1);
11601 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11603 flow_director_flexpayload,
11604 "flow_director_flex_payload");
11605 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11606 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11608 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11609 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11610 payload_layer, "raw#l2#l3#l4");
11611 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11612 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11613 payload_cfg, NULL);
11615 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11616 .f = cmd_flow_director_flxpld_parsed,
11618 .help_str = "flow_director_flexpayload ... : "
11619 "Set flow director's flex payload on NIC",
11621 (void *)&cmd_flow_director_flexpayload,
11622 (void *)&cmd_flow_director_flexpayload_port_id,
11623 (void *)&cmd_flow_director_flexpayload_payload_layer,
11624 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11629 /* Generic flow interface command. */
11630 extern cmdline_parse_inst_t cmd_flow;
11632 /* *** Classification Filters Control *** */
11633 /* *** Get symmetric hash enable per port *** */
11634 struct cmd_get_sym_hash_ena_per_port_result {
11635 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11640 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11641 __rte_unused struct cmdline *cl,
11642 __rte_unused void *data)
11644 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11645 struct rte_eth_hash_filter_info info;
11648 if (rte_eth_dev_filter_supported(res->port_id,
11649 RTE_ETH_FILTER_HASH) < 0) {
11650 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11655 memset(&info, 0, sizeof(info));
11656 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11657 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11658 RTE_ETH_FILTER_GET, &info);
11661 printf("Cannot get symmetric hash enable per port "
11662 "on port %u\n", res->port_id);
11666 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11667 "enabled" : "disabled", res->port_id);
11670 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11671 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11672 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11673 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11674 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11677 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11678 .f = cmd_get_sym_hash_per_port_parsed,
11680 .help_str = "get_sym_hash_ena_per_port <port_id>",
11682 (void *)&cmd_get_sym_hash_ena_per_port_all,
11683 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11688 /* *** Set symmetric hash enable per port *** */
11689 struct cmd_set_sym_hash_ena_per_port_result {
11690 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11691 cmdline_fixed_string_t enable;
11696 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11697 __rte_unused struct cmdline *cl,
11698 __rte_unused void *data)
11700 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11701 struct rte_eth_hash_filter_info info;
11704 if (rte_eth_dev_filter_supported(res->port_id,
11705 RTE_ETH_FILTER_HASH) < 0) {
11706 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11711 memset(&info, 0, sizeof(info));
11712 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11713 if (!strcmp(res->enable, "enable"))
11714 info.info.enable = 1;
11715 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11716 RTE_ETH_FILTER_SET, &info);
11718 printf("Cannot set symmetric hash enable per port on "
11719 "port %u\n", res->port_id);
11722 printf("Symmetric hash has been set to %s on port %u\n",
11723 res->enable, res->port_id);
11726 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11727 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11728 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11729 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11730 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11732 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11733 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11734 enable, "enable#disable");
11736 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11737 .f = cmd_set_sym_hash_per_port_parsed,
11739 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11741 (void *)&cmd_set_sym_hash_ena_per_port_all,
11742 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11743 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11748 /* Get global config of hash function */
11749 struct cmd_get_hash_global_config_result {
11750 cmdline_fixed_string_t get_hash_global_config;
11755 flowtype_to_str(uint16_t ftype)
11761 } ftype_table[] = {
11762 {"ipv4", RTE_ETH_FLOW_IPV4},
11763 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11764 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11765 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11766 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11767 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11768 {"ipv6", RTE_ETH_FLOW_IPV6},
11769 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11770 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11771 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11772 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11773 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11774 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11775 {"port", RTE_ETH_FLOW_PORT},
11776 {"vxlan", RTE_ETH_FLOW_VXLAN},
11777 {"geneve", RTE_ETH_FLOW_GENEVE},
11778 {"nvgre", RTE_ETH_FLOW_NVGRE},
11781 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11782 if (ftype_table[i].ftype == ftype)
11783 return ftype_table[i].str;
11790 cmd_get_hash_global_config_parsed(void *parsed_result,
11791 __rte_unused struct cmdline *cl,
11792 __rte_unused void *data)
11794 struct cmd_get_hash_global_config_result *res = parsed_result;
11795 struct rte_eth_hash_filter_info info;
11796 uint32_t idx, offset;
11801 if (rte_eth_dev_filter_supported(res->port_id,
11802 RTE_ETH_FILTER_HASH) < 0) {
11803 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11808 memset(&info, 0, sizeof(info));
11809 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11810 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11811 RTE_ETH_FILTER_GET, &info);
11813 printf("Cannot get hash global configurations by port %d\n",
11818 switch (info.info.global_conf.hash_func) {
11819 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11820 printf("Hash function is Toeplitz\n");
11822 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11823 printf("Hash function is Simple XOR\n");
11826 printf("Unknown hash function\n");
11830 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11831 idx = i / UINT64_BIT;
11832 offset = i % UINT64_BIT;
11833 if (!(info.info.global_conf.valid_bit_mask[idx] &
11836 str = flowtype_to_str(i);
11839 printf("Symmetric hash is %s globally for flow type %s "
11841 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11842 (1ULL << offset)) ? "enabled" : "disabled"), str,
11847 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11848 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11849 get_hash_global_config, "get_hash_global_config");
11850 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11851 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11854 cmdline_parse_inst_t cmd_get_hash_global_config = {
11855 .f = cmd_get_hash_global_config_parsed,
11857 .help_str = "get_hash_global_config <port_id>",
11859 (void *)&cmd_get_hash_global_config_all,
11860 (void *)&cmd_get_hash_global_config_port_id,
11865 /* Set global config of hash function */
11866 struct cmd_set_hash_global_config_result {
11867 cmdline_fixed_string_t set_hash_global_config;
11869 cmdline_fixed_string_t hash_func;
11870 cmdline_fixed_string_t flow_type;
11871 cmdline_fixed_string_t enable;
11875 cmd_set_hash_global_config_parsed(void *parsed_result,
11876 __rte_unused struct cmdline *cl,
11877 __rte_unused void *data)
11879 struct cmd_set_hash_global_config_result *res = parsed_result;
11880 struct rte_eth_hash_filter_info info;
11881 uint32_t ftype, idx, offset;
11884 if (rte_eth_dev_filter_supported(res->port_id,
11885 RTE_ETH_FILTER_HASH) < 0) {
11886 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11890 memset(&info, 0, sizeof(info));
11891 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11892 if (!strcmp(res->hash_func, "toeplitz"))
11893 info.info.global_conf.hash_func =
11894 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11895 else if (!strcmp(res->hash_func, "simple_xor"))
11896 info.info.global_conf.hash_func =
11897 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11898 else if (!strcmp(res->hash_func, "default"))
11899 info.info.global_conf.hash_func =
11900 RTE_ETH_HASH_FUNCTION_DEFAULT;
11902 ftype = str2flowtype(res->flow_type);
11903 idx = ftype / UINT64_BIT;
11904 offset = ftype % UINT64_BIT;
11905 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11906 if (!strcmp(res->enable, "enable"))
11907 info.info.global_conf.sym_hash_enable_mask[idx] |=
11909 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11910 RTE_ETH_FILTER_SET, &info);
11912 printf("Cannot set global hash configurations by port %d\n",
11915 printf("Global hash configurations have been set "
11916 "succcessfully by port %d\n", res->port_id);
11919 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11920 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11921 set_hash_global_config, "set_hash_global_config");
11922 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11923 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11925 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11926 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11927 hash_func, "toeplitz#simple_xor#default");
11928 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11929 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11931 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11932 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11933 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11934 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11935 enable, "enable#disable");
11937 cmdline_parse_inst_t cmd_set_hash_global_config = {
11938 .f = cmd_set_hash_global_config_parsed,
11940 .help_str = "set_hash_global_config <port_id> "
11941 "toeplitz|simple_xor|default "
11942 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11943 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11944 "l2_payload enable|disable",
11946 (void *)&cmd_set_hash_global_config_all,
11947 (void *)&cmd_set_hash_global_config_port_id,
11948 (void *)&cmd_set_hash_global_config_hash_func,
11949 (void *)&cmd_set_hash_global_config_flow_type,
11950 (void *)&cmd_set_hash_global_config_enable,
11955 /* Set hash input set */
11956 struct cmd_set_hash_input_set_result {
11957 cmdline_fixed_string_t set_hash_input_set;
11959 cmdline_fixed_string_t flow_type;
11960 cmdline_fixed_string_t inset_field;
11961 cmdline_fixed_string_t select;
11964 static enum rte_eth_input_set_field
11965 str2inset(char *string)
11969 static const struct {
11971 enum rte_eth_input_set_field inset;
11972 } inset_table[] = {
11973 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11974 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11975 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11976 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11977 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11978 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11979 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11980 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11981 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11982 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11983 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11984 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11985 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11986 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11987 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11988 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11989 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11990 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11991 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11992 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11993 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11994 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11995 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11996 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11997 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11998 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11999 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12000 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12001 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12002 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12003 {"none", RTE_ETH_INPUT_SET_NONE},
12006 for (i = 0; i < RTE_DIM(inset_table); i++) {
12007 if (!strcmp(string, inset_table[i].str))
12008 return inset_table[i].inset;
12011 return RTE_ETH_INPUT_SET_UNKNOWN;
12015 cmd_set_hash_input_set_parsed(void *parsed_result,
12016 __rte_unused struct cmdline *cl,
12017 __rte_unused void *data)
12019 struct cmd_set_hash_input_set_result *res = parsed_result;
12020 struct rte_eth_hash_filter_info info;
12022 memset(&info, 0, sizeof(info));
12023 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12024 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12025 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12026 info.info.input_set_conf.inset_size = 1;
12027 if (!strcmp(res->select, "select"))
12028 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12029 else if (!strcmp(res->select, "add"))
12030 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12031 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12032 RTE_ETH_FILTER_SET, &info);
12035 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12036 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12037 set_hash_input_set, "set_hash_input_set");
12038 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12039 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12041 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12042 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12044 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12045 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12047 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12048 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12049 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12050 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12051 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12053 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12054 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12055 select, "select#add");
12057 cmdline_parse_inst_t cmd_set_hash_input_set = {
12058 .f = cmd_set_hash_input_set_parsed,
12060 .help_str = "set_hash_input_set <port_id> "
12061 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12062 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12063 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12064 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12065 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12066 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12067 "fld-7th|fld-8th|none select|add",
12069 (void *)&cmd_set_hash_input_set_cmd,
12070 (void *)&cmd_set_hash_input_set_port_id,
12071 (void *)&cmd_set_hash_input_set_flow_type,
12072 (void *)&cmd_set_hash_input_set_field,
12073 (void *)&cmd_set_hash_input_set_select,
12078 /* Set flow director input set */
12079 struct cmd_set_fdir_input_set_result {
12080 cmdline_fixed_string_t set_fdir_input_set;
12082 cmdline_fixed_string_t flow_type;
12083 cmdline_fixed_string_t inset_field;
12084 cmdline_fixed_string_t select;
12088 cmd_set_fdir_input_set_parsed(void *parsed_result,
12089 __rte_unused struct cmdline *cl,
12090 __rte_unused void *data)
12092 struct cmd_set_fdir_input_set_result *res = parsed_result;
12093 struct rte_eth_fdir_filter_info info;
12095 memset(&info, 0, sizeof(info));
12096 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12097 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12098 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12099 info.info.input_set_conf.inset_size = 1;
12100 if (!strcmp(res->select, "select"))
12101 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12102 else if (!strcmp(res->select, "add"))
12103 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12104 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12105 RTE_ETH_FILTER_SET, &info);
12108 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12109 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12110 set_fdir_input_set, "set_fdir_input_set");
12111 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12112 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12114 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12115 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12117 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12118 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12119 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12120 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12122 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12123 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12124 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12125 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12126 "sctp-veri-tag#none");
12127 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12128 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12129 select, "select#add");
12131 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12132 .f = cmd_set_fdir_input_set_parsed,
12134 .help_str = "set_fdir_input_set <port_id> "
12135 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12136 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12137 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12138 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12139 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12140 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12141 "sctp-veri-tag|none select|add",
12143 (void *)&cmd_set_fdir_input_set_cmd,
12144 (void *)&cmd_set_fdir_input_set_port_id,
12145 (void *)&cmd_set_fdir_input_set_flow_type,
12146 (void *)&cmd_set_fdir_input_set_field,
12147 (void *)&cmd_set_fdir_input_set_select,
12152 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12153 struct cmd_mcast_addr_result {
12154 cmdline_fixed_string_t mcast_addr_cmd;
12155 cmdline_fixed_string_t what;
12157 struct ether_addr mc_addr;
12160 static void cmd_mcast_addr_parsed(void *parsed_result,
12161 __attribute__((unused)) struct cmdline *cl,
12162 __attribute__((unused)) void *data)
12164 struct cmd_mcast_addr_result *res = parsed_result;
12166 if (!is_multicast_ether_addr(&res->mc_addr)) {
12167 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12168 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12169 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12170 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12173 if (strcmp(res->what, "add") == 0)
12174 mcast_addr_add(res->port_num, &res->mc_addr);
12176 mcast_addr_remove(res->port_num, &res->mc_addr);
12179 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12180 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12181 mcast_addr_cmd, "mcast_addr");
12182 cmdline_parse_token_string_t cmd_mcast_addr_what =
12183 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12185 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12186 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12187 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12188 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12190 cmdline_parse_inst_t cmd_mcast_addr = {
12191 .f = cmd_mcast_addr_parsed,
12193 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12194 "Add/Remove multicast MAC address on port_id",
12196 (void *)&cmd_mcast_addr_cmd,
12197 (void *)&cmd_mcast_addr_what,
12198 (void *)&cmd_mcast_addr_portnum,
12199 (void *)&cmd_mcast_addr_addr,
12204 /* l2 tunnel config
12205 * only support E-tag now.
12208 /* Ether type config */
12209 struct cmd_config_l2_tunnel_eth_type_result {
12210 cmdline_fixed_string_t port;
12211 cmdline_fixed_string_t config;
12212 cmdline_fixed_string_t all;
12214 cmdline_fixed_string_t l2_tunnel;
12215 cmdline_fixed_string_t l2_tunnel_type;
12216 cmdline_fixed_string_t eth_type;
12217 uint16_t eth_type_val;
12220 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12221 TOKEN_STRING_INITIALIZER
12222 (struct cmd_config_l2_tunnel_eth_type_result,
12224 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12225 TOKEN_STRING_INITIALIZER
12226 (struct cmd_config_l2_tunnel_eth_type_result,
12228 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12229 TOKEN_STRING_INITIALIZER
12230 (struct cmd_config_l2_tunnel_eth_type_result,
12232 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12233 TOKEN_NUM_INITIALIZER
12234 (struct cmd_config_l2_tunnel_eth_type_result,
12236 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12237 TOKEN_STRING_INITIALIZER
12238 (struct cmd_config_l2_tunnel_eth_type_result,
12239 l2_tunnel, "l2-tunnel");
12240 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12241 TOKEN_STRING_INITIALIZER
12242 (struct cmd_config_l2_tunnel_eth_type_result,
12243 l2_tunnel_type, "E-tag");
12244 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12245 TOKEN_STRING_INITIALIZER
12246 (struct cmd_config_l2_tunnel_eth_type_result,
12247 eth_type, "ether-type");
12248 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12249 TOKEN_NUM_INITIALIZER
12250 (struct cmd_config_l2_tunnel_eth_type_result,
12251 eth_type_val, UINT16);
12253 static enum rte_eth_tunnel_type
12254 str2fdir_l2_tunnel_type(char *string)
12258 static const struct {
12260 enum rte_eth_tunnel_type type;
12261 } l2_tunnel_type_str[] = {
12262 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12265 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12266 if (!strcmp(l2_tunnel_type_str[i].str, string))
12267 return l2_tunnel_type_str[i].type;
12269 return RTE_TUNNEL_TYPE_NONE;
12272 /* ether type config for all ports */
12274 cmd_config_l2_tunnel_eth_type_all_parsed
12275 (void *parsed_result,
12276 __attribute__((unused)) struct cmdline *cl,
12277 __attribute__((unused)) void *data)
12279 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12280 struct rte_eth_l2_tunnel_conf entry;
12283 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12284 entry.ether_type = res->eth_type_val;
12286 RTE_ETH_FOREACH_DEV(pid) {
12287 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12291 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12292 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12294 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12296 (void *)&cmd_config_l2_tunnel_eth_type_port,
12297 (void *)&cmd_config_l2_tunnel_eth_type_config,
12298 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12299 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12300 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12301 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12302 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12307 /* ether type config for a specific port */
12309 cmd_config_l2_tunnel_eth_type_specific_parsed(
12310 void *parsed_result,
12311 __attribute__((unused)) struct cmdline *cl,
12312 __attribute__((unused)) void *data)
12314 struct cmd_config_l2_tunnel_eth_type_result *res =
12316 struct rte_eth_l2_tunnel_conf entry;
12318 if (port_id_is_invalid(res->id, ENABLED_WARN))
12321 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12322 entry.ether_type = res->eth_type_val;
12324 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12327 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12328 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12330 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12332 (void *)&cmd_config_l2_tunnel_eth_type_port,
12333 (void *)&cmd_config_l2_tunnel_eth_type_config,
12334 (void *)&cmd_config_l2_tunnel_eth_type_id,
12335 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12336 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12337 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12338 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12343 /* Enable/disable l2 tunnel */
12344 struct cmd_config_l2_tunnel_en_dis_result {
12345 cmdline_fixed_string_t port;
12346 cmdline_fixed_string_t config;
12347 cmdline_fixed_string_t all;
12349 cmdline_fixed_string_t l2_tunnel;
12350 cmdline_fixed_string_t l2_tunnel_type;
12351 cmdline_fixed_string_t en_dis;
12354 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12355 TOKEN_STRING_INITIALIZER
12356 (struct cmd_config_l2_tunnel_en_dis_result,
12358 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12359 TOKEN_STRING_INITIALIZER
12360 (struct cmd_config_l2_tunnel_en_dis_result,
12362 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12363 TOKEN_STRING_INITIALIZER
12364 (struct cmd_config_l2_tunnel_en_dis_result,
12366 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12367 TOKEN_NUM_INITIALIZER
12368 (struct cmd_config_l2_tunnel_en_dis_result,
12370 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12371 TOKEN_STRING_INITIALIZER
12372 (struct cmd_config_l2_tunnel_en_dis_result,
12373 l2_tunnel, "l2-tunnel");
12374 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12375 TOKEN_STRING_INITIALIZER
12376 (struct cmd_config_l2_tunnel_en_dis_result,
12377 l2_tunnel_type, "E-tag");
12378 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12379 TOKEN_STRING_INITIALIZER
12380 (struct cmd_config_l2_tunnel_en_dis_result,
12381 en_dis, "enable#disable");
12383 /* enable/disable l2 tunnel for all ports */
12385 cmd_config_l2_tunnel_en_dis_all_parsed(
12386 void *parsed_result,
12387 __attribute__((unused)) struct cmdline *cl,
12388 __attribute__((unused)) void *data)
12390 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12391 struct rte_eth_l2_tunnel_conf entry;
12395 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12397 if (!strcmp("enable", res->en_dis))
12402 RTE_ETH_FOREACH_DEV(pid) {
12403 rte_eth_dev_l2_tunnel_offload_set(pid,
12405 ETH_L2_TUNNEL_ENABLE_MASK,
12410 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12411 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12413 .help_str = "port config all l2-tunnel E-tag enable|disable",
12415 (void *)&cmd_config_l2_tunnel_en_dis_port,
12416 (void *)&cmd_config_l2_tunnel_en_dis_config,
12417 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12418 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12419 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12420 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12425 /* enable/disable l2 tunnel for a port */
12427 cmd_config_l2_tunnel_en_dis_specific_parsed(
12428 void *parsed_result,
12429 __attribute__((unused)) struct cmdline *cl,
12430 __attribute__((unused)) void *data)
12432 struct cmd_config_l2_tunnel_en_dis_result *res =
12434 struct rte_eth_l2_tunnel_conf entry;
12436 if (port_id_is_invalid(res->id, ENABLED_WARN))
12439 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12441 if (!strcmp("enable", res->en_dis))
12442 rte_eth_dev_l2_tunnel_offload_set(res->id,
12444 ETH_L2_TUNNEL_ENABLE_MASK,
12447 rte_eth_dev_l2_tunnel_offload_set(res->id,
12449 ETH_L2_TUNNEL_ENABLE_MASK,
12453 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12454 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12456 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12458 (void *)&cmd_config_l2_tunnel_en_dis_port,
12459 (void *)&cmd_config_l2_tunnel_en_dis_config,
12460 (void *)&cmd_config_l2_tunnel_en_dis_id,
12461 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12462 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12463 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12468 /* E-tag configuration */
12470 /* Common result structure for all E-tag configuration */
12471 struct cmd_config_e_tag_result {
12472 cmdline_fixed_string_t e_tag;
12473 cmdline_fixed_string_t set;
12474 cmdline_fixed_string_t insertion;
12475 cmdline_fixed_string_t stripping;
12476 cmdline_fixed_string_t forwarding;
12477 cmdline_fixed_string_t filter;
12478 cmdline_fixed_string_t add;
12479 cmdline_fixed_string_t del;
12480 cmdline_fixed_string_t on;
12481 cmdline_fixed_string_t off;
12482 cmdline_fixed_string_t on_off;
12483 cmdline_fixed_string_t port_tag_id;
12484 uint32_t port_tag_id_val;
12485 cmdline_fixed_string_t e_tag_id;
12486 uint16_t e_tag_id_val;
12487 cmdline_fixed_string_t dst_pool;
12488 uint8_t dst_pool_val;
12489 cmdline_fixed_string_t port;
12491 cmdline_fixed_string_t vf;
12495 /* Common CLI fields for all E-tag configuration */
12496 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12497 TOKEN_STRING_INITIALIZER
12498 (struct cmd_config_e_tag_result,
12500 cmdline_parse_token_string_t cmd_config_e_tag_set =
12501 TOKEN_STRING_INITIALIZER
12502 (struct cmd_config_e_tag_result,
12504 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12505 TOKEN_STRING_INITIALIZER
12506 (struct cmd_config_e_tag_result,
12507 insertion, "insertion");
12508 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12509 TOKEN_STRING_INITIALIZER
12510 (struct cmd_config_e_tag_result,
12511 stripping, "stripping");
12512 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12513 TOKEN_STRING_INITIALIZER
12514 (struct cmd_config_e_tag_result,
12515 forwarding, "forwarding");
12516 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12517 TOKEN_STRING_INITIALIZER
12518 (struct cmd_config_e_tag_result,
12520 cmdline_parse_token_string_t cmd_config_e_tag_add =
12521 TOKEN_STRING_INITIALIZER
12522 (struct cmd_config_e_tag_result,
12524 cmdline_parse_token_string_t cmd_config_e_tag_del =
12525 TOKEN_STRING_INITIALIZER
12526 (struct cmd_config_e_tag_result,
12528 cmdline_parse_token_string_t cmd_config_e_tag_on =
12529 TOKEN_STRING_INITIALIZER
12530 (struct cmd_config_e_tag_result,
12532 cmdline_parse_token_string_t cmd_config_e_tag_off =
12533 TOKEN_STRING_INITIALIZER
12534 (struct cmd_config_e_tag_result,
12536 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12537 TOKEN_STRING_INITIALIZER
12538 (struct cmd_config_e_tag_result,
12540 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12541 TOKEN_STRING_INITIALIZER
12542 (struct cmd_config_e_tag_result,
12543 port_tag_id, "port-tag-id");
12544 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12545 TOKEN_NUM_INITIALIZER
12546 (struct cmd_config_e_tag_result,
12547 port_tag_id_val, UINT32);
12548 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12549 TOKEN_STRING_INITIALIZER
12550 (struct cmd_config_e_tag_result,
12551 e_tag_id, "e-tag-id");
12552 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12553 TOKEN_NUM_INITIALIZER
12554 (struct cmd_config_e_tag_result,
12555 e_tag_id_val, UINT16);
12556 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12557 TOKEN_STRING_INITIALIZER
12558 (struct cmd_config_e_tag_result,
12559 dst_pool, "dst-pool");
12560 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12561 TOKEN_NUM_INITIALIZER
12562 (struct cmd_config_e_tag_result,
12563 dst_pool_val, UINT8);
12564 cmdline_parse_token_string_t cmd_config_e_tag_port =
12565 TOKEN_STRING_INITIALIZER
12566 (struct cmd_config_e_tag_result,
12568 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12569 TOKEN_NUM_INITIALIZER
12570 (struct cmd_config_e_tag_result,
12572 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12573 TOKEN_STRING_INITIALIZER
12574 (struct cmd_config_e_tag_result,
12576 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12577 TOKEN_NUM_INITIALIZER
12578 (struct cmd_config_e_tag_result,
12581 /* E-tag insertion configuration */
12583 cmd_config_e_tag_insertion_en_parsed(
12584 void *parsed_result,
12585 __attribute__((unused)) struct cmdline *cl,
12586 __attribute__((unused)) void *data)
12588 struct cmd_config_e_tag_result *res =
12590 struct rte_eth_l2_tunnel_conf entry;
12592 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12595 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12596 entry.tunnel_id = res->port_tag_id_val;
12597 entry.vf_id = res->vf_id;
12598 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12600 ETH_L2_TUNNEL_INSERTION_MASK,
12605 cmd_config_e_tag_insertion_dis_parsed(
12606 void *parsed_result,
12607 __attribute__((unused)) struct cmdline *cl,
12608 __attribute__((unused)) void *data)
12610 struct cmd_config_e_tag_result *res =
12612 struct rte_eth_l2_tunnel_conf entry;
12614 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12617 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12618 entry.vf_id = res->vf_id;
12620 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12622 ETH_L2_TUNNEL_INSERTION_MASK,
12626 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12627 .f = cmd_config_e_tag_insertion_en_parsed,
12629 .help_str = "E-tag ... : E-tag insertion enable",
12631 (void *)&cmd_config_e_tag_e_tag,
12632 (void *)&cmd_config_e_tag_set,
12633 (void *)&cmd_config_e_tag_insertion,
12634 (void *)&cmd_config_e_tag_on,
12635 (void *)&cmd_config_e_tag_port_tag_id,
12636 (void *)&cmd_config_e_tag_port_tag_id_val,
12637 (void *)&cmd_config_e_tag_port,
12638 (void *)&cmd_config_e_tag_port_id,
12639 (void *)&cmd_config_e_tag_vf,
12640 (void *)&cmd_config_e_tag_vf_id,
12645 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12646 .f = cmd_config_e_tag_insertion_dis_parsed,
12648 .help_str = "E-tag ... : E-tag insertion disable",
12650 (void *)&cmd_config_e_tag_e_tag,
12651 (void *)&cmd_config_e_tag_set,
12652 (void *)&cmd_config_e_tag_insertion,
12653 (void *)&cmd_config_e_tag_off,
12654 (void *)&cmd_config_e_tag_port,
12655 (void *)&cmd_config_e_tag_port_id,
12656 (void *)&cmd_config_e_tag_vf,
12657 (void *)&cmd_config_e_tag_vf_id,
12662 /* E-tag stripping configuration */
12664 cmd_config_e_tag_stripping_parsed(
12665 void *parsed_result,
12666 __attribute__((unused)) struct cmdline *cl,
12667 __attribute__((unused)) void *data)
12669 struct cmd_config_e_tag_result *res =
12671 struct rte_eth_l2_tunnel_conf entry;
12673 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12676 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12678 if (!strcmp(res->on_off, "on"))
12679 rte_eth_dev_l2_tunnel_offload_set
12682 ETH_L2_TUNNEL_STRIPPING_MASK,
12685 rte_eth_dev_l2_tunnel_offload_set
12688 ETH_L2_TUNNEL_STRIPPING_MASK,
12692 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12693 .f = cmd_config_e_tag_stripping_parsed,
12695 .help_str = "E-tag ... : E-tag stripping enable/disable",
12697 (void *)&cmd_config_e_tag_e_tag,
12698 (void *)&cmd_config_e_tag_set,
12699 (void *)&cmd_config_e_tag_stripping,
12700 (void *)&cmd_config_e_tag_on_off,
12701 (void *)&cmd_config_e_tag_port,
12702 (void *)&cmd_config_e_tag_port_id,
12707 /* E-tag forwarding configuration */
12709 cmd_config_e_tag_forwarding_parsed(
12710 void *parsed_result,
12711 __attribute__((unused)) struct cmdline *cl,
12712 __attribute__((unused)) void *data)
12714 struct cmd_config_e_tag_result *res = parsed_result;
12715 struct rte_eth_l2_tunnel_conf entry;
12717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12720 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12722 if (!strcmp(res->on_off, "on"))
12723 rte_eth_dev_l2_tunnel_offload_set
12726 ETH_L2_TUNNEL_FORWARDING_MASK,
12729 rte_eth_dev_l2_tunnel_offload_set
12732 ETH_L2_TUNNEL_FORWARDING_MASK,
12736 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12737 .f = cmd_config_e_tag_forwarding_parsed,
12739 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12741 (void *)&cmd_config_e_tag_e_tag,
12742 (void *)&cmd_config_e_tag_set,
12743 (void *)&cmd_config_e_tag_forwarding,
12744 (void *)&cmd_config_e_tag_on_off,
12745 (void *)&cmd_config_e_tag_port,
12746 (void *)&cmd_config_e_tag_port_id,
12751 /* E-tag filter configuration */
12753 cmd_config_e_tag_filter_add_parsed(
12754 void *parsed_result,
12755 __attribute__((unused)) struct cmdline *cl,
12756 __attribute__((unused)) void *data)
12758 struct cmd_config_e_tag_result *res = parsed_result;
12759 struct rte_eth_l2_tunnel_conf entry;
12762 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12765 if (res->e_tag_id_val > 0x3fff) {
12766 printf("e-tag-id must be equal or less than 0x3fff.\n");
12770 ret = rte_eth_dev_filter_supported(res->port_id,
12771 RTE_ETH_FILTER_L2_TUNNEL);
12773 printf("E-tag filter is not supported on port %u.\n",
12778 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12779 entry.tunnel_id = res->e_tag_id_val;
12780 entry.pool = res->dst_pool_val;
12782 ret = rte_eth_dev_filter_ctrl(res->port_id,
12783 RTE_ETH_FILTER_L2_TUNNEL,
12784 RTE_ETH_FILTER_ADD,
12787 printf("E-tag filter programming error: (%s)\n",
12791 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12792 .f = cmd_config_e_tag_filter_add_parsed,
12794 .help_str = "E-tag ... : E-tag filter add",
12796 (void *)&cmd_config_e_tag_e_tag,
12797 (void *)&cmd_config_e_tag_set,
12798 (void *)&cmd_config_e_tag_filter,
12799 (void *)&cmd_config_e_tag_add,
12800 (void *)&cmd_config_e_tag_e_tag_id,
12801 (void *)&cmd_config_e_tag_e_tag_id_val,
12802 (void *)&cmd_config_e_tag_dst_pool,
12803 (void *)&cmd_config_e_tag_dst_pool_val,
12804 (void *)&cmd_config_e_tag_port,
12805 (void *)&cmd_config_e_tag_port_id,
12811 cmd_config_e_tag_filter_del_parsed(
12812 void *parsed_result,
12813 __attribute__((unused)) struct cmdline *cl,
12814 __attribute__((unused)) void *data)
12816 struct cmd_config_e_tag_result *res = parsed_result;
12817 struct rte_eth_l2_tunnel_conf entry;
12820 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12823 if (res->e_tag_id_val > 0x3fff) {
12824 printf("e-tag-id must be less than 0x3fff.\n");
12828 ret = rte_eth_dev_filter_supported(res->port_id,
12829 RTE_ETH_FILTER_L2_TUNNEL);
12831 printf("E-tag filter is not supported on port %u.\n",
12836 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12837 entry.tunnel_id = res->e_tag_id_val;
12839 ret = rte_eth_dev_filter_ctrl(res->port_id,
12840 RTE_ETH_FILTER_L2_TUNNEL,
12841 RTE_ETH_FILTER_DELETE,
12844 printf("E-tag filter programming error: (%s)\n",
12848 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12849 .f = cmd_config_e_tag_filter_del_parsed,
12851 .help_str = "E-tag ... : E-tag filter delete",
12853 (void *)&cmd_config_e_tag_e_tag,
12854 (void *)&cmd_config_e_tag_set,
12855 (void *)&cmd_config_e_tag_filter,
12856 (void *)&cmd_config_e_tag_del,
12857 (void *)&cmd_config_e_tag_e_tag_id,
12858 (void *)&cmd_config_e_tag_e_tag_id_val,
12859 (void *)&cmd_config_e_tag_port,
12860 (void *)&cmd_config_e_tag_port_id,
12865 /* vf vlan anti spoof configuration */
12867 /* Common result structure for vf vlan anti spoof */
12868 struct cmd_vf_vlan_anti_spoof_result {
12869 cmdline_fixed_string_t set;
12870 cmdline_fixed_string_t vf;
12871 cmdline_fixed_string_t vlan;
12872 cmdline_fixed_string_t antispoof;
12875 cmdline_fixed_string_t on_off;
12878 /* Common CLI fields for vf vlan anti spoof enable disable */
12879 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12880 TOKEN_STRING_INITIALIZER
12881 (struct cmd_vf_vlan_anti_spoof_result,
12883 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12884 TOKEN_STRING_INITIALIZER
12885 (struct cmd_vf_vlan_anti_spoof_result,
12887 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12888 TOKEN_STRING_INITIALIZER
12889 (struct cmd_vf_vlan_anti_spoof_result,
12891 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12892 TOKEN_STRING_INITIALIZER
12893 (struct cmd_vf_vlan_anti_spoof_result,
12894 antispoof, "antispoof");
12895 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12896 TOKEN_NUM_INITIALIZER
12897 (struct cmd_vf_vlan_anti_spoof_result,
12899 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12900 TOKEN_NUM_INITIALIZER
12901 (struct cmd_vf_vlan_anti_spoof_result,
12903 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12904 TOKEN_STRING_INITIALIZER
12905 (struct cmd_vf_vlan_anti_spoof_result,
12909 cmd_set_vf_vlan_anti_spoof_parsed(
12910 void *parsed_result,
12911 __attribute__((unused)) struct cmdline *cl,
12912 __attribute__((unused)) void *data)
12914 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12915 int ret = -ENOTSUP;
12917 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12919 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12922 #ifdef RTE_LIBRTE_IXGBE_PMD
12923 if (ret == -ENOTSUP)
12924 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12925 res->vf_id, is_on);
12927 #ifdef RTE_LIBRTE_I40E_PMD
12928 if (ret == -ENOTSUP)
12929 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12930 res->vf_id, is_on);
12932 #ifdef RTE_LIBRTE_BNXT_PMD
12933 if (ret == -ENOTSUP)
12934 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12935 res->vf_id, is_on);
12942 printf("invalid vf_id %d\n", res->vf_id);
12945 printf("invalid port_id %d\n", res->port_id);
12948 printf("function not implemented\n");
12951 printf("programming error: (%s)\n", strerror(-ret));
12955 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12956 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12958 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12960 (void *)&cmd_vf_vlan_anti_spoof_set,
12961 (void *)&cmd_vf_vlan_anti_spoof_vf,
12962 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12963 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12964 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12965 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12966 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12971 /* vf mac anti spoof configuration */
12973 /* Common result structure for vf mac anti spoof */
12974 struct cmd_vf_mac_anti_spoof_result {
12975 cmdline_fixed_string_t set;
12976 cmdline_fixed_string_t vf;
12977 cmdline_fixed_string_t mac;
12978 cmdline_fixed_string_t antispoof;
12981 cmdline_fixed_string_t on_off;
12984 /* Common CLI fields for vf mac anti spoof enable disable */
12985 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12986 TOKEN_STRING_INITIALIZER
12987 (struct cmd_vf_mac_anti_spoof_result,
12989 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12990 TOKEN_STRING_INITIALIZER
12991 (struct cmd_vf_mac_anti_spoof_result,
12993 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12994 TOKEN_STRING_INITIALIZER
12995 (struct cmd_vf_mac_anti_spoof_result,
12997 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12998 TOKEN_STRING_INITIALIZER
12999 (struct cmd_vf_mac_anti_spoof_result,
13000 antispoof, "antispoof");
13001 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13002 TOKEN_NUM_INITIALIZER
13003 (struct cmd_vf_mac_anti_spoof_result,
13005 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13006 TOKEN_NUM_INITIALIZER
13007 (struct cmd_vf_mac_anti_spoof_result,
13009 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13010 TOKEN_STRING_INITIALIZER
13011 (struct cmd_vf_mac_anti_spoof_result,
13015 cmd_set_vf_mac_anti_spoof_parsed(
13016 void *parsed_result,
13017 __attribute__((unused)) struct cmdline *cl,
13018 __attribute__((unused)) void *data)
13020 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13021 int ret = -ENOTSUP;
13023 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13025 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13028 #ifdef RTE_LIBRTE_IXGBE_PMD
13029 if (ret == -ENOTSUP)
13030 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13031 res->vf_id, is_on);
13033 #ifdef RTE_LIBRTE_I40E_PMD
13034 if (ret == -ENOTSUP)
13035 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13036 res->vf_id, is_on);
13038 #ifdef RTE_LIBRTE_BNXT_PMD
13039 if (ret == -ENOTSUP)
13040 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13041 res->vf_id, is_on);
13048 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13051 printf("invalid port_id %d\n", res->port_id);
13054 printf("function not implemented\n");
13057 printf("programming error: (%s)\n", strerror(-ret));
13061 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13062 .f = cmd_set_vf_mac_anti_spoof_parsed,
13064 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13066 (void *)&cmd_vf_mac_anti_spoof_set,
13067 (void *)&cmd_vf_mac_anti_spoof_vf,
13068 (void *)&cmd_vf_mac_anti_spoof_mac,
13069 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13070 (void *)&cmd_vf_mac_anti_spoof_port_id,
13071 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13072 (void *)&cmd_vf_mac_anti_spoof_on_off,
13077 /* vf vlan strip queue configuration */
13079 /* Common result structure for vf mac anti spoof */
13080 struct cmd_vf_vlan_stripq_result {
13081 cmdline_fixed_string_t set;
13082 cmdline_fixed_string_t vf;
13083 cmdline_fixed_string_t vlan;
13084 cmdline_fixed_string_t stripq;
13087 cmdline_fixed_string_t on_off;
13090 /* Common CLI fields for vf vlan strip enable disable */
13091 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13092 TOKEN_STRING_INITIALIZER
13093 (struct cmd_vf_vlan_stripq_result,
13095 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13096 TOKEN_STRING_INITIALIZER
13097 (struct cmd_vf_vlan_stripq_result,
13099 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13100 TOKEN_STRING_INITIALIZER
13101 (struct cmd_vf_vlan_stripq_result,
13103 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13104 TOKEN_STRING_INITIALIZER
13105 (struct cmd_vf_vlan_stripq_result,
13107 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13108 TOKEN_NUM_INITIALIZER
13109 (struct cmd_vf_vlan_stripq_result,
13111 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13112 TOKEN_NUM_INITIALIZER
13113 (struct cmd_vf_vlan_stripq_result,
13115 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13116 TOKEN_STRING_INITIALIZER
13117 (struct cmd_vf_vlan_stripq_result,
13121 cmd_set_vf_vlan_stripq_parsed(
13122 void *parsed_result,
13123 __attribute__((unused)) struct cmdline *cl,
13124 __attribute__((unused)) void *data)
13126 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13127 int ret = -ENOTSUP;
13129 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13131 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13134 #ifdef RTE_LIBRTE_IXGBE_PMD
13135 if (ret == -ENOTSUP)
13136 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13137 res->vf_id, is_on);
13139 #ifdef RTE_LIBRTE_I40E_PMD
13140 if (ret == -ENOTSUP)
13141 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13142 res->vf_id, is_on);
13144 #ifdef RTE_LIBRTE_BNXT_PMD
13145 if (ret == -ENOTSUP)
13146 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13147 res->vf_id, is_on);
13154 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13157 printf("invalid port_id %d\n", res->port_id);
13160 printf("function not implemented\n");
13163 printf("programming error: (%s)\n", strerror(-ret));
13167 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13168 .f = cmd_set_vf_vlan_stripq_parsed,
13170 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13172 (void *)&cmd_vf_vlan_stripq_set,
13173 (void *)&cmd_vf_vlan_stripq_vf,
13174 (void *)&cmd_vf_vlan_stripq_vlan,
13175 (void *)&cmd_vf_vlan_stripq_stripq,
13176 (void *)&cmd_vf_vlan_stripq_port_id,
13177 (void *)&cmd_vf_vlan_stripq_vf_id,
13178 (void *)&cmd_vf_vlan_stripq_on_off,
13183 /* vf vlan insert configuration */
13185 /* Common result structure for vf vlan insert */
13186 struct cmd_vf_vlan_insert_result {
13187 cmdline_fixed_string_t set;
13188 cmdline_fixed_string_t vf;
13189 cmdline_fixed_string_t vlan;
13190 cmdline_fixed_string_t insert;
13196 /* Common CLI fields for vf vlan insert enable disable */
13197 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13198 TOKEN_STRING_INITIALIZER
13199 (struct cmd_vf_vlan_insert_result,
13201 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13202 TOKEN_STRING_INITIALIZER
13203 (struct cmd_vf_vlan_insert_result,
13205 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13206 TOKEN_STRING_INITIALIZER
13207 (struct cmd_vf_vlan_insert_result,
13209 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13210 TOKEN_STRING_INITIALIZER
13211 (struct cmd_vf_vlan_insert_result,
13213 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13214 TOKEN_NUM_INITIALIZER
13215 (struct cmd_vf_vlan_insert_result,
13217 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13218 TOKEN_NUM_INITIALIZER
13219 (struct cmd_vf_vlan_insert_result,
13221 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13222 TOKEN_NUM_INITIALIZER
13223 (struct cmd_vf_vlan_insert_result,
13227 cmd_set_vf_vlan_insert_parsed(
13228 void *parsed_result,
13229 __attribute__((unused)) struct cmdline *cl,
13230 __attribute__((unused)) void *data)
13232 struct cmd_vf_vlan_insert_result *res = parsed_result;
13233 int ret = -ENOTSUP;
13235 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13238 #ifdef RTE_LIBRTE_IXGBE_PMD
13239 if (ret == -ENOTSUP)
13240 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13243 #ifdef RTE_LIBRTE_I40E_PMD
13244 if (ret == -ENOTSUP)
13245 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13248 #ifdef RTE_LIBRTE_BNXT_PMD
13249 if (ret == -ENOTSUP)
13250 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13258 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13261 printf("invalid port_id %d\n", res->port_id);
13264 printf("function not implemented\n");
13267 printf("programming error: (%s)\n", strerror(-ret));
13271 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13272 .f = cmd_set_vf_vlan_insert_parsed,
13274 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13276 (void *)&cmd_vf_vlan_insert_set,
13277 (void *)&cmd_vf_vlan_insert_vf,
13278 (void *)&cmd_vf_vlan_insert_vlan,
13279 (void *)&cmd_vf_vlan_insert_insert,
13280 (void *)&cmd_vf_vlan_insert_port_id,
13281 (void *)&cmd_vf_vlan_insert_vf_id,
13282 (void *)&cmd_vf_vlan_insert_vlan_id,
13287 /* tx loopback configuration */
13289 /* Common result structure for tx loopback */
13290 struct cmd_tx_loopback_result {
13291 cmdline_fixed_string_t set;
13292 cmdline_fixed_string_t tx;
13293 cmdline_fixed_string_t loopback;
13295 cmdline_fixed_string_t on_off;
13298 /* Common CLI fields for tx loopback enable disable */
13299 cmdline_parse_token_string_t cmd_tx_loopback_set =
13300 TOKEN_STRING_INITIALIZER
13301 (struct cmd_tx_loopback_result,
13303 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13304 TOKEN_STRING_INITIALIZER
13305 (struct cmd_tx_loopback_result,
13307 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13308 TOKEN_STRING_INITIALIZER
13309 (struct cmd_tx_loopback_result,
13310 loopback, "loopback");
13311 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13312 TOKEN_NUM_INITIALIZER
13313 (struct cmd_tx_loopback_result,
13315 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13316 TOKEN_STRING_INITIALIZER
13317 (struct cmd_tx_loopback_result,
13321 cmd_set_tx_loopback_parsed(
13322 void *parsed_result,
13323 __attribute__((unused)) struct cmdline *cl,
13324 __attribute__((unused)) void *data)
13326 struct cmd_tx_loopback_result *res = parsed_result;
13327 int ret = -ENOTSUP;
13329 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13331 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13334 #ifdef RTE_LIBRTE_IXGBE_PMD
13335 if (ret == -ENOTSUP)
13336 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13338 #ifdef RTE_LIBRTE_I40E_PMD
13339 if (ret == -ENOTSUP)
13340 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13342 #ifdef RTE_LIBRTE_BNXT_PMD
13343 if (ret == -ENOTSUP)
13344 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13346 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13347 if (ret == -ENOTSUP)
13348 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13355 printf("invalid is_on %d\n", is_on);
13358 printf("invalid port_id %d\n", res->port_id);
13361 printf("function not implemented\n");
13364 printf("programming error: (%s)\n", strerror(-ret));
13368 cmdline_parse_inst_t cmd_set_tx_loopback = {
13369 .f = cmd_set_tx_loopback_parsed,
13371 .help_str = "set tx loopback <port_id> on|off",
13373 (void *)&cmd_tx_loopback_set,
13374 (void *)&cmd_tx_loopback_tx,
13375 (void *)&cmd_tx_loopback_loopback,
13376 (void *)&cmd_tx_loopback_port_id,
13377 (void *)&cmd_tx_loopback_on_off,
13382 /* all queues drop enable configuration */
13384 /* Common result structure for all queues drop enable */
13385 struct cmd_all_queues_drop_en_result {
13386 cmdline_fixed_string_t set;
13387 cmdline_fixed_string_t all;
13388 cmdline_fixed_string_t queues;
13389 cmdline_fixed_string_t drop;
13391 cmdline_fixed_string_t on_off;
13394 /* Common CLI fields for tx loopback enable disable */
13395 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13396 TOKEN_STRING_INITIALIZER
13397 (struct cmd_all_queues_drop_en_result,
13399 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13400 TOKEN_STRING_INITIALIZER
13401 (struct cmd_all_queues_drop_en_result,
13403 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13404 TOKEN_STRING_INITIALIZER
13405 (struct cmd_all_queues_drop_en_result,
13407 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13408 TOKEN_STRING_INITIALIZER
13409 (struct cmd_all_queues_drop_en_result,
13411 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13412 TOKEN_NUM_INITIALIZER
13413 (struct cmd_all_queues_drop_en_result,
13415 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13416 TOKEN_STRING_INITIALIZER
13417 (struct cmd_all_queues_drop_en_result,
13421 cmd_set_all_queues_drop_en_parsed(
13422 void *parsed_result,
13423 __attribute__((unused)) struct cmdline *cl,
13424 __attribute__((unused)) void *data)
13426 struct cmd_all_queues_drop_en_result *res = parsed_result;
13427 int ret = -ENOTSUP;
13428 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13430 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13433 #ifdef RTE_LIBRTE_IXGBE_PMD
13434 if (ret == -ENOTSUP)
13435 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13437 #ifdef RTE_LIBRTE_BNXT_PMD
13438 if (ret == -ENOTSUP)
13439 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13445 printf("invalid is_on %d\n", is_on);
13448 printf("invalid port_id %d\n", res->port_id);
13451 printf("function not implemented\n");
13454 printf("programming error: (%s)\n", strerror(-ret));
13458 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13459 .f = cmd_set_all_queues_drop_en_parsed,
13461 .help_str = "set all queues drop <port_id> on|off",
13463 (void *)&cmd_all_queues_drop_en_set,
13464 (void *)&cmd_all_queues_drop_en_all,
13465 (void *)&cmd_all_queues_drop_en_queues,
13466 (void *)&cmd_all_queues_drop_en_drop,
13467 (void *)&cmd_all_queues_drop_en_port_id,
13468 (void *)&cmd_all_queues_drop_en_on_off,
13473 /* vf split drop enable configuration */
13475 /* Common result structure for vf split drop enable */
13476 struct cmd_vf_split_drop_en_result {
13477 cmdline_fixed_string_t set;
13478 cmdline_fixed_string_t vf;
13479 cmdline_fixed_string_t split;
13480 cmdline_fixed_string_t drop;
13483 cmdline_fixed_string_t on_off;
13486 /* Common CLI fields for vf split drop enable disable */
13487 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13488 TOKEN_STRING_INITIALIZER
13489 (struct cmd_vf_split_drop_en_result,
13491 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13492 TOKEN_STRING_INITIALIZER
13493 (struct cmd_vf_split_drop_en_result,
13495 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13496 TOKEN_STRING_INITIALIZER
13497 (struct cmd_vf_split_drop_en_result,
13499 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13500 TOKEN_STRING_INITIALIZER
13501 (struct cmd_vf_split_drop_en_result,
13503 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13504 TOKEN_NUM_INITIALIZER
13505 (struct cmd_vf_split_drop_en_result,
13507 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13508 TOKEN_NUM_INITIALIZER
13509 (struct cmd_vf_split_drop_en_result,
13511 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13512 TOKEN_STRING_INITIALIZER
13513 (struct cmd_vf_split_drop_en_result,
13517 cmd_set_vf_split_drop_en_parsed(
13518 void *parsed_result,
13519 __attribute__((unused)) struct cmdline *cl,
13520 __attribute__((unused)) void *data)
13522 struct cmd_vf_split_drop_en_result *res = parsed_result;
13523 int ret = -ENOTSUP;
13524 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13526 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13529 #ifdef RTE_LIBRTE_IXGBE_PMD
13530 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13537 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13540 printf("invalid port_id %d\n", res->port_id);
13543 printf("not supported on port %d\n", res->port_id);
13546 printf("programming error: (%s)\n", strerror(-ret));
13550 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13551 .f = cmd_set_vf_split_drop_en_parsed,
13553 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13555 (void *)&cmd_vf_split_drop_en_set,
13556 (void *)&cmd_vf_split_drop_en_vf,
13557 (void *)&cmd_vf_split_drop_en_split,
13558 (void *)&cmd_vf_split_drop_en_drop,
13559 (void *)&cmd_vf_split_drop_en_port_id,
13560 (void *)&cmd_vf_split_drop_en_vf_id,
13561 (void *)&cmd_vf_split_drop_en_on_off,
13566 /* vf mac address configuration */
13568 /* Common result structure for vf mac address */
13569 struct cmd_set_vf_mac_addr_result {
13570 cmdline_fixed_string_t set;
13571 cmdline_fixed_string_t vf;
13572 cmdline_fixed_string_t mac;
13573 cmdline_fixed_string_t addr;
13576 struct ether_addr mac_addr;
13580 /* Common CLI fields for vf split drop enable disable */
13581 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13582 TOKEN_STRING_INITIALIZER
13583 (struct cmd_set_vf_mac_addr_result,
13585 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13586 TOKEN_STRING_INITIALIZER
13587 (struct cmd_set_vf_mac_addr_result,
13589 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13590 TOKEN_STRING_INITIALIZER
13591 (struct cmd_set_vf_mac_addr_result,
13593 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13594 TOKEN_STRING_INITIALIZER
13595 (struct cmd_set_vf_mac_addr_result,
13597 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13598 TOKEN_NUM_INITIALIZER
13599 (struct cmd_set_vf_mac_addr_result,
13601 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13602 TOKEN_NUM_INITIALIZER
13603 (struct cmd_set_vf_mac_addr_result,
13605 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13606 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13610 cmd_set_vf_mac_addr_parsed(
13611 void *parsed_result,
13612 __attribute__((unused)) struct cmdline *cl,
13613 __attribute__((unused)) void *data)
13615 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13616 int ret = -ENOTSUP;
13618 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13621 #ifdef RTE_LIBRTE_IXGBE_PMD
13622 if (ret == -ENOTSUP)
13623 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13626 #ifdef RTE_LIBRTE_I40E_PMD
13627 if (ret == -ENOTSUP)
13628 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13631 #ifdef RTE_LIBRTE_BNXT_PMD
13632 if (ret == -ENOTSUP)
13633 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13641 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13644 printf("invalid port_id %d\n", res->port_id);
13647 printf("function not implemented\n");
13650 printf("programming error: (%s)\n", strerror(-ret));
13654 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13655 .f = cmd_set_vf_mac_addr_parsed,
13657 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13659 (void *)&cmd_set_vf_mac_addr_set,
13660 (void *)&cmd_set_vf_mac_addr_vf,
13661 (void *)&cmd_set_vf_mac_addr_mac,
13662 (void *)&cmd_set_vf_mac_addr_addr,
13663 (void *)&cmd_set_vf_mac_addr_port_id,
13664 (void *)&cmd_set_vf_mac_addr_vf_id,
13665 (void *)&cmd_set_vf_mac_addr_mac_addr,
13670 /* MACsec configuration */
13672 /* Common result structure for MACsec offload enable */
13673 struct cmd_macsec_offload_on_result {
13674 cmdline_fixed_string_t set;
13675 cmdline_fixed_string_t macsec;
13676 cmdline_fixed_string_t offload;
13678 cmdline_fixed_string_t on;
13679 cmdline_fixed_string_t encrypt;
13680 cmdline_fixed_string_t en_on_off;
13681 cmdline_fixed_string_t replay_protect;
13682 cmdline_fixed_string_t rp_on_off;
13685 /* Common CLI fields for MACsec offload disable */
13686 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13687 TOKEN_STRING_INITIALIZER
13688 (struct cmd_macsec_offload_on_result,
13690 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13691 TOKEN_STRING_INITIALIZER
13692 (struct cmd_macsec_offload_on_result,
13694 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13695 TOKEN_STRING_INITIALIZER
13696 (struct cmd_macsec_offload_on_result,
13697 offload, "offload");
13698 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13699 TOKEN_NUM_INITIALIZER
13700 (struct cmd_macsec_offload_on_result,
13702 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13703 TOKEN_STRING_INITIALIZER
13704 (struct cmd_macsec_offload_on_result,
13706 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13707 TOKEN_STRING_INITIALIZER
13708 (struct cmd_macsec_offload_on_result,
13709 encrypt, "encrypt");
13710 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13711 TOKEN_STRING_INITIALIZER
13712 (struct cmd_macsec_offload_on_result,
13713 en_on_off, "on#off");
13714 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13715 TOKEN_STRING_INITIALIZER
13716 (struct cmd_macsec_offload_on_result,
13717 replay_protect, "replay-protect");
13718 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13719 TOKEN_STRING_INITIALIZER
13720 (struct cmd_macsec_offload_on_result,
13721 rp_on_off, "on#off");
13724 cmd_set_macsec_offload_on_parsed(
13725 void *parsed_result,
13726 __attribute__((unused)) struct cmdline *cl,
13727 __attribute__((unused)) void *data)
13729 struct cmd_macsec_offload_on_result *res = parsed_result;
13730 int ret = -ENOTSUP;
13731 portid_t port_id = res->port_id;
13732 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13733 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13734 struct rte_eth_dev_info dev_info;
13736 if (port_id_is_invalid(port_id, ENABLED_WARN))
13738 if (!port_is_stopped(port_id)) {
13739 printf("Please stop port %d first\n", port_id);
13743 rte_eth_dev_info_get(port_id, &dev_info);
13744 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13745 #ifdef RTE_LIBRTE_IXGBE_PMD
13746 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13754 ports[port_id].dev_conf.txmode.offloads |=
13755 DEV_TX_OFFLOAD_MACSEC_INSERT;
13756 cmd_reconfig_device_queue(port_id, 1, 1);
13759 printf("invalid port_id %d\n", port_id);
13762 printf("not supported on port %d\n", port_id);
13765 printf("programming error: (%s)\n", strerror(-ret));
13769 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13770 .f = cmd_set_macsec_offload_on_parsed,
13772 .help_str = "set macsec offload <port_id> on "
13773 "encrypt on|off replay-protect on|off",
13775 (void *)&cmd_macsec_offload_on_set,
13776 (void *)&cmd_macsec_offload_on_macsec,
13777 (void *)&cmd_macsec_offload_on_offload,
13778 (void *)&cmd_macsec_offload_on_port_id,
13779 (void *)&cmd_macsec_offload_on_on,
13780 (void *)&cmd_macsec_offload_on_encrypt,
13781 (void *)&cmd_macsec_offload_on_en_on_off,
13782 (void *)&cmd_macsec_offload_on_replay_protect,
13783 (void *)&cmd_macsec_offload_on_rp_on_off,
13788 /* Common result structure for MACsec offload disable */
13789 struct cmd_macsec_offload_off_result {
13790 cmdline_fixed_string_t set;
13791 cmdline_fixed_string_t macsec;
13792 cmdline_fixed_string_t offload;
13794 cmdline_fixed_string_t off;
13797 /* Common CLI fields for MACsec offload disable */
13798 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13799 TOKEN_STRING_INITIALIZER
13800 (struct cmd_macsec_offload_off_result,
13802 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13803 TOKEN_STRING_INITIALIZER
13804 (struct cmd_macsec_offload_off_result,
13806 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13807 TOKEN_STRING_INITIALIZER
13808 (struct cmd_macsec_offload_off_result,
13809 offload, "offload");
13810 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13811 TOKEN_NUM_INITIALIZER
13812 (struct cmd_macsec_offload_off_result,
13814 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13815 TOKEN_STRING_INITIALIZER
13816 (struct cmd_macsec_offload_off_result,
13820 cmd_set_macsec_offload_off_parsed(
13821 void *parsed_result,
13822 __attribute__((unused)) struct cmdline *cl,
13823 __attribute__((unused)) void *data)
13825 struct cmd_macsec_offload_off_result *res = parsed_result;
13826 int ret = -ENOTSUP;
13827 struct rte_eth_dev_info dev_info;
13828 portid_t port_id = res->port_id;
13830 if (port_id_is_invalid(port_id, ENABLED_WARN))
13832 if (!port_is_stopped(port_id)) {
13833 printf("Please stop port %d first\n", port_id);
13837 rte_eth_dev_info_get(port_id, &dev_info);
13838 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13839 #ifdef RTE_LIBRTE_IXGBE_PMD
13840 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13845 ports[port_id].dev_conf.txmode.offloads &=
13846 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13847 cmd_reconfig_device_queue(port_id, 1, 1);
13850 printf("invalid port_id %d\n", port_id);
13853 printf("not supported on port %d\n", port_id);
13856 printf("programming error: (%s)\n", strerror(-ret));
13860 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13861 .f = cmd_set_macsec_offload_off_parsed,
13863 .help_str = "set macsec offload <port_id> off",
13865 (void *)&cmd_macsec_offload_off_set,
13866 (void *)&cmd_macsec_offload_off_macsec,
13867 (void *)&cmd_macsec_offload_off_offload,
13868 (void *)&cmd_macsec_offload_off_port_id,
13869 (void *)&cmd_macsec_offload_off_off,
13874 /* Common result structure for MACsec secure connection configure */
13875 struct cmd_macsec_sc_result {
13876 cmdline_fixed_string_t set;
13877 cmdline_fixed_string_t macsec;
13878 cmdline_fixed_string_t sc;
13879 cmdline_fixed_string_t tx_rx;
13881 struct ether_addr mac;
13885 /* Common CLI fields for MACsec secure connection configure */
13886 cmdline_parse_token_string_t cmd_macsec_sc_set =
13887 TOKEN_STRING_INITIALIZER
13888 (struct cmd_macsec_sc_result,
13890 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13891 TOKEN_STRING_INITIALIZER
13892 (struct cmd_macsec_sc_result,
13894 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13895 TOKEN_STRING_INITIALIZER
13896 (struct cmd_macsec_sc_result,
13898 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13899 TOKEN_STRING_INITIALIZER
13900 (struct cmd_macsec_sc_result,
13902 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13903 TOKEN_NUM_INITIALIZER
13904 (struct cmd_macsec_sc_result,
13906 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13907 TOKEN_ETHERADDR_INITIALIZER
13908 (struct cmd_macsec_sc_result,
13910 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13911 TOKEN_NUM_INITIALIZER
13912 (struct cmd_macsec_sc_result,
13916 cmd_set_macsec_sc_parsed(
13917 void *parsed_result,
13918 __attribute__((unused)) struct cmdline *cl,
13919 __attribute__((unused)) void *data)
13921 struct cmd_macsec_sc_result *res = parsed_result;
13922 int ret = -ENOTSUP;
13923 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13925 #ifdef RTE_LIBRTE_IXGBE_PMD
13927 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13928 res->mac.addr_bytes) :
13929 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13930 res->mac.addr_bytes, res->pi);
13932 RTE_SET_USED(is_tx);
13938 printf("invalid port_id %d\n", res->port_id);
13941 printf("not supported on port %d\n", res->port_id);
13944 printf("programming error: (%s)\n", strerror(-ret));
13948 cmdline_parse_inst_t cmd_set_macsec_sc = {
13949 .f = cmd_set_macsec_sc_parsed,
13951 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13953 (void *)&cmd_macsec_sc_set,
13954 (void *)&cmd_macsec_sc_macsec,
13955 (void *)&cmd_macsec_sc_sc,
13956 (void *)&cmd_macsec_sc_tx_rx,
13957 (void *)&cmd_macsec_sc_port_id,
13958 (void *)&cmd_macsec_sc_mac,
13959 (void *)&cmd_macsec_sc_pi,
13964 /* Common result structure for MACsec secure connection configure */
13965 struct cmd_macsec_sa_result {
13966 cmdline_fixed_string_t set;
13967 cmdline_fixed_string_t macsec;
13968 cmdline_fixed_string_t sa;
13969 cmdline_fixed_string_t tx_rx;
13974 cmdline_fixed_string_t key;
13977 /* Common CLI fields for MACsec secure connection configure */
13978 cmdline_parse_token_string_t cmd_macsec_sa_set =
13979 TOKEN_STRING_INITIALIZER
13980 (struct cmd_macsec_sa_result,
13982 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13983 TOKEN_STRING_INITIALIZER
13984 (struct cmd_macsec_sa_result,
13986 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13987 TOKEN_STRING_INITIALIZER
13988 (struct cmd_macsec_sa_result,
13990 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13991 TOKEN_STRING_INITIALIZER
13992 (struct cmd_macsec_sa_result,
13994 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13995 TOKEN_NUM_INITIALIZER
13996 (struct cmd_macsec_sa_result,
13998 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13999 TOKEN_NUM_INITIALIZER
14000 (struct cmd_macsec_sa_result,
14002 cmdline_parse_token_num_t cmd_macsec_sa_an =
14003 TOKEN_NUM_INITIALIZER
14004 (struct cmd_macsec_sa_result,
14006 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14007 TOKEN_NUM_INITIALIZER
14008 (struct cmd_macsec_sa_result,
14010 cmdline_parse_token_string_t cmd_macsec_sa_key =
14011 TOKEN_STRING_INITIALIZER
14012 (struct cmd_macsec_sa_result,
14016 cmd_set_macsec_sa_parsed(
14017 void *parsed_result,
14018 __attribute__((unused)) struct cmdline *cl,
14019 __attribute__((unused)) void *data)
14021 struct cmd_macsec_sa_result *res = parsed_result;
14022 int ret = -ENOTSUP;
14023 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14024 uint8_t key[16] = { 0 };
14030 key_len = strlen(res->key) / 2;
14034 for (i = 0; i < key_len; i++) {
14035 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14038 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14041 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14044 #ifdef RTE_LIBRTE_IXGBE_PMD
14046 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14047 res->idx, res->an, res->pn, key) :
14048 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14049 res->idx, res->an, res->pn, key);
14051 RTE_SET_USED(is_tx);
14058 printf("invalid idx %d or an %d\n", res->idx, res->an);
14061 printf("invalid port_id %d\n", res->port_id);
14064 printf("not supported on port %d\n", res->port_id);
14067 printf("programming error: (%s)\n", strerror(-ret));
14071 cmdline_parse_inst_t cmd_set_macsec_sa = {
14072 .f = cmd_set_macsec_sa_parsed,
14074 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14076 (void *)&cmd_macsec_sa_set,
14077 (void *)&cmd_macsec_sa_macsec,
14078 (void *)&cmd_macsec_sa_sa,
14079 (void *)&cmd_macsec_sa_tx_rx,
14080 (void *)&cmd_macsec_sa_port_id,
14081 (void *)&cmd_macsec_sa_idx,
14082 (void *)&cmd_macsec_sa_an,
14083 (void *)&cmd_macsec_sa_pn,
14084 (void *)&cmd_macsec_sa_key,
14089 /* VF unicast promiscuous mode configuration */
14091 /* Common result structure for VF unicast promiscuous mode */
14092 struct cmd_vf_promisc_result {
14093 cmdline_fixed_string_t set;
14094 cmdline_fixed_string_t vf;
14095 cmdline_fixed_string_t promisc;
14098 cmdline_fixed_string_t on_off;
14101 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14102 cmdline_parse_token_string_t cmd_vf_promisc_set =
14103 TOKEN_STRING_INITIALIZER
14104 (struct cmd_vf_promisc_result,
14106 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14107 TOKEN_STRING_INITIALIZER
14108 (struct cmd_vf_promisc_result,
14110 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14111 TOKEN_STRING_INITIALIZER
14112 (struct cmd_vf_promisc_result,
14113 promisc, "promisc");
14114 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14115 TOKEN_NUM_INITIALIZER
14116 (struct cmd_vf_promisc_result,
14118 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14119 TOKEN_NUM_INITIALIZER
14120 (struct cmd_vf_promisc_result,
14122 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14123 TOKEN_STRING_INITIALIZER
14124 (struct cmd_vf_promisc_result,
14128 cmd_set_vf_promisc_parsed(
14129 void *parsed_result,
14130 __attribute__((unused)) struct cmdline *cl,
14131 __attribute__((unused)) void *data)
14133 struct cmd_vf_promisc_result *res = parsed_result;
14134 int ret = -ENOTSUP;
14136 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14138 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14141 #ifdef RTE_LIBRTE_I40E_PMD
14142 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14143 res->vf_id, is_on);
14150 printf("invalid vf_id %d\n", res->vf_id);
14153 printf("invalid port_id %d\n", res->port_id);
14156 printf("function not implemented\n");
14159 printf("programming error: (%s)\n", strerror(-ret));
14163 cmdline_parse_inst_t cmd_set_vf_promisc = {
14164 .f = cmd_set_vf_promisc_parsed,
14166 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14167 "Set unicast promiscuous mode for a VF from the PF",
14169 (void *)&cmd_vf_promisc_set,
14170 (void *)&cmd_vf_promisc_vf,
14171 (void *)&cmd_vf_promisc_promisc,
14172 (void *)&cmd_vf_promisc_port_id,
14173 (void *)&cmd_vf_promisc_vf_id,
14174 (void *)&cmd_vf_promisc_on_off,
14179 /* VF multicast promiscuous mode configuration */
14181 /* Common result structure for VF multicast promiscuous mode */
14182 struct cmd_vf_allmulti_result {
14183 cmdline_fixed_string_t set;
14184 cmdline_fixed_string_t vf;
14185 cmdline_fixed_string_t allmulti;
14188 cmdline_fixed_string_t on_off;
14191 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14192 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14193 TOKEN_STRING_INITIALIZER
14194 (struct cmd_vf_allmulti_result,
14196 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14197 TOKEN_STRING_INITIALIZER
14198 (struct cmd_vf_allmulti_result,
14200 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14201 TOKEN_STRING_INITIALIZER
14202 (struct cmd_vf_allmulti_result,
14203 allmulti, "allmulti");
14204 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14205 TOKEN_NUM_INITIALIZER
14206 (struct cmd_vf_allmulti_result,
14208 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14209 TOKEN_NUM_INITIALIZER
14210 (struct cmd_vf_allmulti_result,
14212 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14213 TOKEN_STRING_INITIALIZER
14214 (struct cmd_vf_allmulti_result,
14218 cmd_set_vf_allmulti_parsed(
14219 void *parsed_result,
14220 __attribute__((unused)) struct cmdline *cl,
14221 __attribute__((unused)) void *data)
14223 struct cmd_vf_allmulti_result *res = parsed_result;
14224 int ret = -ENOTSUP;
14226 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14228 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14231 #ifdef RTE_LIBRTE_I40E_PMD
14232 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14233 res->vf_id, is_on);
14240 printf("invalid vf_id %d\n", res->vf_id);
14243 printf("invalid port_id %d\n", res->port_id);
14246 printf("function not implemented\n");
14249 printf("programming error: (%s)\n", strerror(-ret));
14253 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14254 .f = cmd_set_vf_allmulti_parsed,
14256 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14257 "Set multicast promiscuous mode for a VF from the PF",
14259 (void *)&cmd_vf_allmulti_set,
14260 (void *)&cmd_vf_allmulti_vf,
14261 (void *)&cmd_vf_allmulti_allmulti,
14262 (void *)&cmd_vf_allmulti_port_id,
14263 (void *)&cmd_vf_allmulti_vf_id,
14264 (void *)&cmd_vf_allmulti_on_off,
14269 /* vf broadcast mode configuration */
14271 /* Common result structure for vf broadcast */
14272 struct cmd_set_vf_broadcast_result {
14273 cmdline_fixed_string_t set;
14274 cmdline_fixed_string_t vf;
14275 cmdline_fixed_string_t broadcast;
14278 cmdline_fixed_string_t on_off;
14281 /* Common CLI fields for vf broadcast enable disable */
14282 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14283 TOKEN_STRING_INITIALIZER
14284 (struct cmd_set_vf_broadcast_result,
14286 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14287 TOKEN_STRING_INITIALIZER
14288 (struct cmd_set_vf_broadcast_result,
14290 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14291 TOKEN_STRING_INITIALIZER
14292 (struct cmd_set_vf_broadcast_result,
14293 broadcast, "broadcast");
14294 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14295 TOKEN_NUM_INITIALIZER
14296 (struct cmd_set_vf_broadcast_result,
14298 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14299 TOKEN_NUM_INITIALIZER
14300 (struct cmd_set_vf_broadcast_result,
14302 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14303 TOKEN_STRING_INITIALIZER
14304 (struct cmd_set_vf_broadcast_result,
14308 cmd_set_vf_broadcast_parsed(
14309 void *parsed_result,
14310 __attribute__((unused)) struct cmdline *cl,
14311 __attribute__((unused)) void *data)
14313 struct cmd_set_vf_broadcast_result *res = parsed_result;
14314 int ret = -ENOTSUP;
14316 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14318 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14321 #ifdef RTE_LIBRTE_I40E_PMD
14322 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14323 res->vf_id, is_on);
14330 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14333 printf("invalid port_id %d\n", res->port_id);
14336 printf("function not implemented\n");
14339 printf("programming error: (%s)\n", strerror(-ret));
14343 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14344 .f = cmd_set_vf_broadcast_parsed,
14346 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14348 (void *)&cmd_set_vf_broadcast_set,
14349 (void *)&cmd_set_vf_broadcast_vf,
14350 (void *)&cmd_set_vf_broadcast_broadcast,
14351 (void *)&cmd_set_vf_broadcast_port_id,
14352 (void *)&cmd_set_vf_broadcast_vf_id,
14353 (void *)&cmd_set_vf_broadcast_on_off,
14358 /* vf vlan tag configuration */
14360 /* Common result structure for vf vlan tag */
14361 struct cmd_set_vf_vlan_tag_result {
14362 cmdline_fixed_string_t set;
14363 cmdline_fixed_string_t vf;
14364 cmdline_fixed_string_t vlan;
14365 cmdline_fixed_string_t tag;
14368 cmdline_fixed_string_t on_off;
14371 /* Common CLI fields for vf vlan tag enable disable */
14372 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14373 TOKEN_STRING_INITIALIZER
14374 (struct cmd_set_vf_vlan_tag_result,
14376 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14377 TOKEN_STRING_INITIALIZER
14378 (struct cmd_set_vf_vlan_tag_result,
14380 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14381 TOKEN_STRING_INITIALIZER
14382 (struct cmd_set_vf_vlan_tag_result,
14384 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14385 TOKEN_STRING_INITIALIZER
14386 (struct cmd_set_vf_vlan_tag_result,
14388 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14389 TOKEN_NUM_INITIALIZER
14390 (struct cmd_set_vf_vlan_tag_result,
14392 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14393 TOKEN_NUM_INITIALIZER
14394 (struct cmd_set_vf_vlan_tag_result,
14396 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14397 TOKEN_STRING_INITIALIZER
14398 (struct cmd_set_vf_vlan_tag_result,
14402 cmd_set_vf_vlan_tag_parsed(
14403 void *parsed_result,
14404 __attribute__((unused)) struct cmdline *cl,
14405 __attribute__((unused)) void *data)
14407 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14408 int ret = -ENOTSUP;
14410 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14412 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14415 #ifdef RTE_LIBRTE_I40E_PMD
14416 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14417 res->vf_id, is_on);
14424 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14427 printf("invalid port_id %d\n", res->port_id);
14430 printf("function not implemented\n");
14433 printf("programming error: (%s)\n", strerror(-ret));
14437 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14438 .f = cmd_set_vf_vlan_tag_parsed,
14440 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14442 (void *)&cmd_set_vf_vlan_tag_set,
14443 (void *)&cmd_set_vf_vlan_tag_vf,
14444 (void *)&cmd_set_vf_vlan_tag_vlan,
14445 (void *)&cmd_set_vf_vlan_tag_tag,
14446 (void *)&cmd_set_vf_vlan_tag_port_id,
14447 (void *)&cmd_set_vf_vlan_tag_vf_id,
14448 (void *)&cmd_set_vf_vlan_tag_on_off,
14453 /* Common definition of VF and TC TX bandwidth configuration */
14454 struct cmd_vf_tc_bw_result {
14455 cmdline_fixed_string_t set;
14456 cmdline_fixed_string_t vf;
14457 cmdline_fixed_string_t tc;
14458 cmdline_fixed_string_t tx;
14459 cmdline_fixed_string_t min_bw;
14460 cmdline_fixed_string_t max_bw;
14461 cmdline_fixed_string_t strict_link_prio;
14466 cmdline_fixed_string_t bw_list;
14470 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14471 TOKEN_STRING_INITIALIZER
14472 (struct cmd_vf_tc_bw_result,
14474 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14475 TOKEN_STRING_INITIALIZER
14476 (struct cmd_vf_tc_bw_result,
14478 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14479 TOKEN_STRING_INITIALIZER
14480 (struct cmd_vf_tc_bw_result,
14482 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14483 TOKEN_STRING_INITIALIZER
14484 (struct cmd_vf_tc_bw_result,
14486 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14487 TOKEN_STRING_INITIALIZER
14488 (struct cmd_vf_tc_bw_result,
14489 strict_link_prio, "strict-link-priority");
14490 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14491 TOKEN_STRING_INITIALIZER
14492 (struct cmd_vf_tc_bw_result,
14493 min_bw, "min-bandwidth");
14494 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14495 TOKEN_STRING_INITIALIZER
14496 (struct cmd_vf_tc_bw_result,
14497 max_bw, "max-bandwidth");
14498 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14499 TOKEN_NUM_INITIALIZER
14500 (struct cmd_vf_tc_bw_result,
14502 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14503 TOKEN_NUM_INITIALIZER
14504 (struct cmd_vf_tc_bw_result,
14506 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14507 TOKEN_NUM_INITIALIZER
14508 (struct cmd_vf_tc_bw_result,
14510 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14511 TOKEN_NUM_INITIALIZER
14512 (struct cmd_vf_tc_bw_result,
14514 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14515 TOKEN_STRING_INITIALIZER
14516 (struct cmd_vf_tc_bw_result,
14518 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14519 TOKEN_NUM_INITIALIZER
14520 (struct cmd_vf_tc_bw_result,
14523 /* VF max bandwidth setting */
14525 cmd_vf_max_bw_parsed(
14526 void *parsed_result,
14527 __attribute__((unused)) struct cmdline *cl,
14528 __attribute__((unused)) void *data)
14530 struct cmd_vf_tc_bw_result *res = parsed_result;
14531 int ret = -ENOTSUP;
14533 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14536 #ifdef RTE_LIBRTE_I40E_PMD
14537 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14538 res->vf_id, res->bw);
14545 printf("invalid vf_id %d or bandwidth %d\n",
14546 res->vf_id, res->bw);
14549 printf("invalid port_id %d\n", res->port_id);
14552 printf("function not implemented\n");
14555 printf("programming error: (%s)\n", strerror(-ret));
14559 cmdline_parse_inst_t cmd_vf_max_bw = {
14560 .f = cmd_vf_max_bw_parsed,
14562 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14564 (void *)&cmd_vf_tc_bw_set,
14565 (void *)&cmd_vf_tc_bw_vf,
14566 (void *)&cmd_vf_tc_bw_tx,
14567 (void *)&cmd_vf_tc_bw_max_bw,
14568 (void *)&cmd_vf_tc_bw_port_id,
14569 (void *)&cmd_vf_tc_bw_vf_id,
14570 (void *)&cmd_vf_tc_bw_bw,
14576 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14581 const char *p, *p0 = str;
14588 p = strchr(p0, '(');
14590 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14594 p0 = strchr(p, ')');
14596 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14600 if (size >= sizeof(s)) {
14601 printf("The string size exceeds the internal buffer size\n");
14604 snprintf(s, sizeof(s), "%.*s", size, p);
14605 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14607 printf("Failed to get the bandwidth list. ");
14611 for (i = 0; i < ret; i++)
14612 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14617 /* TC min bandwidth setting */
14619 cmd_vf_tc_min_bw_parsed(
14620 void *parsed_result,
14621 __attribute__((unused)) struct cmdline *cl,
14622 __attribute__((unused)) void *data)
14624 struct cmd_vf_tc_bw_result *res = parsed_result;
14627 int ret = -ENOTSUP;
14629 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14632 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14636 #ifdef RTE_LIBRTE_I40E_PMD
14637 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14645 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14648 printf("invalid port_id %d\n", res->port_id);
14651 printf("function not implemented\n");
14654 printf("programming error: (%s)\n", strerror(-ret));
14658 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14659 .f = cmd_vf_tc_min_bw_parsed,
14661 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14662 " <bw1, bw2, ...>",
14664 (void *)&cmd_vf_tc_bw_set,
14665 (void *)&cmd_vf_tc_bw_vf,
14666 (void *)&cmd_vf_tc_bw_tc,
14667 (void *)&cmd_vf_tc_bw_tx,
14668 (void *)&cmd_vf_tc_bw_min_bw,
14669 (void *)&cmd_vf_tc_bw_port_id,
14670 (void *)&cmd_vf_tc_bw_vf_id,
14671 (void *)&cmd_vf_tc_bw_bw_list,
14677 cmd_tc_min_bw_parsed(
14678 void *parsed_result,
14679 __attribute__((unused)) struct cmdline *cl,
14680 __attribute__((unused)) void *data)
14682 struct cmd_vf_tc_bw_result *res = parsed_result;
14683 struct rte_port *port;
14686 int ret = -ENOTSUP;
14688 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14691 port = &ports[res->port_id];
14692 /** Check if the port is not started **/
14693 if (port->port_status != RTE_PORT_STOPPED) {
14694 printf("Please stop port %d first\n", res->port_id);
14698 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14702 #ifdef RTE_LIBRTE_IXGBE_PMD
14703 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14710 printf("invalid bandwidth\n");
14713 printf("invalid port_id %d\n", res->port_id);
14716 printf("function not implemented\n");
14719 printf("programming error: (%s)\n", strerror(-ret));
14723 cmdline_parse_inst_t cmd_tc_min_bw = {
14724 .f = cmd_tc_min_bw_parsed,
14726 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14728 (void *)&cmd_vf_tc_bw_set,
14729 (void *)&cmd_vf_tc_bw_tc,
14730 (void *)&cmd_vf_tc_bw_tx,
14731 (void *)&cmd_vf_tc_bw_min_bw,
14732 (void *)&cmd_vf_tc_bw_port_id,
14733 (void *)&cmd_vf_tc_bw_bw_list,
14738 /* TC max bandwidth setting */
14740 cmd_vf_tc_max_bw_parsed(
14741 void *parsed_result,
14742 __attribute__((unused)) struct cmdline *cl,
14743 __attribute__((unused)) void *data)
14745 struct cmd_vf_tc_bw_result *res = parsed_result;
14746 int ret = -ENOTSUP;
14748 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14751 #ifdef RTE_LIBRTE_I40E_PMD
14752 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14753 res->tc_no, res->bw);
14760 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14761 res->vf_id, res->tc_no, res->bw);
14764 printf("invalid port_id %d\n", res->port_id);
14767 printf("function not implemented\n");
14770 printf("programming error: (%s)\n", strerror(-ret));
14774 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14775 .f = cmd_vf_tc_max_bw_parsed,
14777 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14780 (void *)&cmd_vf_tc_bw_set,
14781 (void *)&cmd_vf_tc_bw_vf,
14782 (void *)&cmd_vf_tc_bw_tc,
14783 (void *)&cmd_vf_tc_bw_tx,
14784 (void *)&cmd_vf_tc_bw_max_bw,
14785 (void *)&cmd_vf_tc_bw_port_id,
14786 (void *)&cmd_vf_tc_bw_vf_id,
14787 (void *)&cmd_vf_tc_bw_tc_no,
14788 (void *)&cmd_vf_tc_bw_bw,
14794 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14796 /* *** Set Port default Traffic Management Hierarchy *** */
14797 struct cmd_set_port_tm_hierarchy_default_result {
14798 cmdline_fixed_string_t set;
14799 cmdline_fixed_string_t port;
14800 cmdline_fixed_string_t tm;
14801 cmdline_fixed_string_t hierarchy;
14802 cmdline_fixed_string_t def;
14806 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14807 TOKEN_STRING_INITIALIZER(
14808 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14809 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14810 TOKEN_STRING_INITIALIZER(
14811 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14812 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14813 TOKEN_STRING_INITIALIZER(
14814 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14815 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14816 TOKEN_STRING_INITIALIZER(
14817 struct cmd_set_port_tm_hierarchy_default_result,
14818 hierarchy, "hierarchy");
14819 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14820 TOKEN_STRING_INITIALIZER(
14821 struct cmd_set_port_tm_hierarchy_default_result,
14823 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14824 TOKEN_NUM_INITIALIZER(
14825 struct cmd_set_port_tm_hierarchy_default_result,
14828 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14829 __attribute__((unused)) struct cmdline *cl,
14830 __attribute__((unused)) void *data)
14832 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14833 struct rte_port *p;
14834 portid_t port_id = res->port_id;
14836 if (port_id_is_invalid(port_id, ENABLED_WARN))
14839 p = &ports[port_id];
14841 /* Forward mode: tm */
14842 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
14843 printf(" softnicfwd mode not enabled(error)\n");
14847 /* Set the default tm hierarchy */
14848 p->softport.default_tm_hierarchy_enable = 1;
14851 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14852 .f = cmd_set_port_tm_hierarchy_default_parsed,
14854 .help_str = "set port tm hierarchy default <port_id>",
14856 (void *)&cmd_set_port_tm_hierarchy_default_set,
14857 (void *)&cmd_set_port_tm_hierarchy_default_port,
14858 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14859 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14860 (void *)&cmd_set_port_tm_hierarchy_default_default,
14861 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14867 /** Set VXLAN encapsulation details */
14868 struct cmd_set_vxlan_result {
14869 cmdline_fixed_string_t set;
14870 cmdline_fixed_string_t vxlan;
14871 cmdline_fixed_string_t pos_token;
14872 cmdline_fixed_string_t ip_version;
14873 uint32_t vlan_present:1;
14877 cmdline_ipaddr_t ip_src;
14878 cmdline_ipaddr_t ip_dst;
14880 struct ether_addr eth_src;
14881 struct ether_addr eth_dst;
14884 cmdline_parse_token_string_t cmd_set_vxlan_set =
14885 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
14886 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
14887 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
14888 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
14889 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14890 "vxlan-with-vlan");
14891 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
14892 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14894 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
14895 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
14897 cmdline_parse_token_string_t cmd_set_vxlan_vni =
14898 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14900 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
14901 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
14902 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
14903 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14905 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
14906 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
14907 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
14908 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14910 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
14911 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
14912 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
14913 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14915 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
14916 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
14917 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
14918 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14920 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
14921 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
14922 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
14923 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14925 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
14926 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
14927 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
14928 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14930 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
14931 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
14932 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
14933 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14935 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
14936 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
14938 static void cmd_set_vxlan_parsed(void *parsed_result,
14939 __attribute__((unused)) struct cmdline *cl,
14940 __attribute__((unused)) void *data)
14942 struct cmd_set_vxlan_result *res = parsed_result;
14947 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
14950 if (strcmp(res->vxlan, "vxlan") == 0)
14951 vxlan_encap_conf.select_vlan = 0;
14952 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
14953 vxlan_encap_conf.select_vlan = 1;
14954 if (strcmp(res->ip_version, "ipv4") == 0)
14955 vxlan_encap_conf.select_ipv4 = 1;
14956 else if (strcmp(res->ip_version, "ipv6") == 0)
14957 vxlan_encap_conf.select_ipv4 = 0;
14960 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
14961 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
14962 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
14963 if (vxlan_encap_conf.select_ipv4) {
14964 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
14965 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
14967 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
14968 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
14970 if (vxlan_encap_conf.select_vlan)
14971 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14972 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
14974 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14978 cmdline_parse_inst_t cmd_set_vxlan = {
14979 .f = cmd_set_vxlan_parsed,
14981 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
14982 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
14983 " eth-src <eth-src> eth-dst <eth-dst>",
14985 (void *)&cmd_set_vxlan_set,
14986 (void *)&cmd_set_vxlan_vxlan,
14987 (void *)&cmd_set_vxlan_ip_version,
14988 (void *)&cmd_set_vxlan_ip_version_value,
14989 (void *)&cmd_set_vxlan_vni,
14990 (void *)&cmd_set_vxlan_vni_value,
14991 (void *)&cmd_set_vxlan_udp_src,
14992 (void *)&cmd_set_vxlan_udp_src_value,
14993 (void *)&cmd_set_vxlan_udp_dst,
14994 (void *)&cmd_set_vxlan_udp_dst_value,
14995 (void *)&cmd_set_vxlan_ip_src,
14996 (void *)&cmd_set_vxlan_ip_src_value,
14997 (void *)&cmd_set_vxlan_ip_dst,
14998 (void *)&cmd_set_vxlan_ip_dst_value,
14999 (void *)&cmd_set_vxlan_eth_src,
15000 (void *)&cmd_set_vxlan_eth_src_value,
15001 (void *)&cmd_set_vxlan_eth_dst,
15002 (void *)&cmd_set_vxlan_eth_dst_value,
15007 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15008 .f = cmd_set_vxlan_parsed,
15010 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15011 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15012 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15015 (void *)&cmd_set_vxlan_set,
15016 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15017 (void *)&cmd_set_vxlan_ip_version,
15018 (void *)&cmd_set_vxlan_ip_version_value,
15019 (void *)&cmd_set_vxlan_vni,
15020 (void *)&cmd_set_vxlan_vni_value,
15021 (void *)&cmd_set_vxlan_udp_src,
15022 (void *)&cmd_set_vxlan_udp_src_value,
15023 (void *)&cmd_set_vxlan_udp_dst,
15024 (void *)&cmd_set_vxlan_udp_dst_value,
15025 (void *)&cmd_set_vxlan_ip_src,
15026 (void *)&cmd_set_vxlan_ip_src_value,
15027 (void *)&cmd_set_vxlan_ip_dst,
15028 (void *)&cmd_set_vxlan_ip_dst_value,
15029 (void *)&cmd_set_vxlan_vlan,
15030 (void *)&cmd_set_vxlan_vlan_value,
15031 (void *)&cmd_set_vxlan_eth_src,
15032 (void *)&cmd_set_vxlan_eth_src_value,
15033 (void *)&cmd_set_vxlan_eth_dst,
15034 (void *)&cmd_set_vxlan_eth_dst_value,
15039 /** Set NVGRE encapsulation details */
15040 struct cmd_set_nvgre_result {
15041 cmdline_fixed_string_t set;
15042 cmdline_fixed_string_t nvgre;
15043 cmdline_fixed_string_t pos_token;
15044 cmdline_fixed_string_t ip_version;
15046 cmdline_ipaddr_t ip_src;
15047 cmdline_ipaddr_t ip_dst;
15049 struct ether_addr eth_src;
15050 struct ether_addr eth_dst;
15053 cmdline_parse_token_string_t cmd_set_nvgre_set =
15054 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15055 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15056 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15057 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15058 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15059 "nvgre-with-vlan");
15060 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15061 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15063 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15064 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15066 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15067 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15069 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15070 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15071 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15072 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15074 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15075 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15076 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15077 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15079 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15080 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15081 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15082 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15084 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15085 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15086 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15087 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15089 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15090 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15091 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15092 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15094 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15095 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15097 static void cmd_set_nvgre_parsed(void *parsed_result,
15098 __attribute__((unused)) struct cmdline *cl,
15099 __attribute__((unused)) void *data)
15101 struct cmd_set_nvgre_result *res = parsed_result;
15103 uint32_t nvgre_tni;
15106 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15109 if (strcmp(res->nvgre, "nvgre") == 0)
15110 nvgre_encap_conf.select_vlan = 0;
15111 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15112 nvgre_encap_conf.select_vlan = 1;
15113 if (strcmp(res->ip_version, "ipv4") == 0)
15114 nvgre_encap_conf.select_ipv4 = 1;
15115 else if (strcmp(res->ip_version, "ipv6") == 0)
15116 nvgre_encap_conf.select_ipv4 = 0;
15119 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15120 if (nvgre_encap_conf.select_ipv4) {
15121 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15122 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15124 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15125 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15127 if (nvgre_encap_conf.select_vlan)
15128 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15129 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15131 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15135 cmdline_parse_inst_t cmd_set_nvgre = {
15136 .f = cmd_set_nvgre_parsed,
15138 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15139 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15140 " eth-dst <eth-dst>",
15142 (void *)&cmd_set_nvgre_set,
15143 (void *)&cmd_set_nvgre_nvgre,
15144 (void *)&cmd_set_nvgre_ip_version,
15145 (void *)&cmd_set_nvgre_ip_version_value,
15146 (void *)&cmd_set_nvgre_tni,
15147 (void *)&cmd_set_nvgre_tni_value,
15148 (void *)&cmd_set_nvgre_ip_src,
15149 (void *)&cmd_set_nvgre_ip_src_value,
15150 (void *)&cmd_set_nvgre_ip_dst,
15151 (void *)&cmd_set_nvgre_ip_dst_value,
15152 (void *)&cmd_set_nvgre_eth_src,
15153 (void *)&cmd_set_nvgre_eth_src_value,
15154 (void *)&cmd_set_nvgre_eth_dst,
15155 (void *)&cmd_set_nvgre_eth_dst_value,
15160 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15161 .f = cmd_set_nvgre_parsed,
15163 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15164 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15165 " eth-src <eth-src> eth-dst <eth-dst>",
15167 (void *)&cmd_set_nvgre_set,
15168 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15169 (void *)&cmd_set_nvgre_ip_version,
15170 (void *)&cmd_set_nvgre_ip_version_value,
15171 (void *)&cmd_set_nvgre_tni,
15172 (void *)&cmd_set_nvgre_tni_value,
15173 (void *)&cmd_set_nvgre_ip_src,
15174 (void *)&cmd_set_nvgre_ip_src_value,
15175 (void *)&cmd_set_nvgre_ip_dst,
15176 (void *)&cmd_set_nvgre_ip_dst_value,
15177 (void *)&cmd_set_nvgre_vlan,
15178 (void *)&cmd_set_nvgre_vlan_value,
15179 (void *)&cmd_set_nvgre_eth_src,
15180 (void *)&cmd_set_nvgre_eth_src_value,
15181 (void *)&cmd_set_nvgre_eth_dst,
15182 (void *)&cmd_set_nvgre_eth_dst_value,
15187 /* Strict link priority scheduling mode setting */
15189 cmd_strict_link_prio_parsed(
15190 void *parsed_result,
15191 __attribute__((unused)) struct cmdline *cl,
15192 __attribute__((unused)) void *data)
15194 struct cmd_vf_tc_bw_result *res = parsed_result;
15195 int ret = -ENOTSUP;
15197 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15200 #ifdef RTE_LIBRTE_I40E_PMD
15201 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15208 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15211 printf("invalid port_id %d\n", res->port_id);
15214 printf("function not implemented\n");
15217 printf("programming error: (%s)\n", strerror(-ret));
15221 cmdline_parse_inst_t cmd_strict_link_prio = {
15222 .f = cmd_strict_link_prio_parsed,
15224 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
15226 (void *)&cmd_vf_tc_bw_set,
15227 (void *)&cmd_vf_tc_bw_tx,
15228 (void *)&cmd_vf_tc_bw_strict_link_prio,
15229 (void *)&cmd_vf_tc_bw_port_id,
15230 (void *)&cmd_vf_tc_bw_tc_map,
15235 /* Load dynamic device personalization*/
15236 struct cmd_ddp_add_result {
15237 cmdline_fixed_string_t ddp;
15238 cmdline_fixed_string_t add;
15243 cmdline_parse_token_string_t cmd_ddp_add_ddp =
15244 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
15245 cmdline_parse_token_string_t cmd_ddp_add_add =
15246 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
15247 cmdline_parse_token_num_t cmd_ddp_add_port_id =
15248 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
15249 cmdline_parse_token_string_t cmd_ddp_add_filepath =
15250 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
15253 cmd_ddp_add_parsed(
15254 void *parsed_result,
15255 __attribute__((unused)) struct cmdline *cl,
15256 __attribute__((unused)) void *data)
15258 struct cmd_ddp_add_result *res = parsed_result;
15264 int ret = -ENOTSUP;
15266 if (!all_ports_stopped()) {
15267 printf("Please stop all ports first\n");
15271 filepath = strdup(res->filepath);
15272 if (filepath == NULL) {
15273 printf("Failed to allocate memory\n");
15276 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
15278 buff = open_file(file_fld[0], &size);
15280 free((void *)filepath);
15284 #ifdef RTE_LIBRTE_I40E_PMD
15285 if (ret == -ENOTSUP)
15286 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15288 RTE_PMD_I40E_PKG_OP_WR_ADD);
15291 if (ret == -EEXIST)
15292 printf("Profile has already existed.\n");
15294 printf("Failed to load profile.\n");
15295 else if (file_num == 2)
15296 save_file(file_fld[1], buff, size);
15299 free((void *)filepath);
15302 cmdline_parse_inst_t cmd_ddp_add = {
15303 .f = cmd_ddp_add_parsed,
15305 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
15307 (void *)&cmd_ddp_add_ddp,
15308 (void *)&cmd_ddp_add_add,
15309 (void *)&cmd_ddp_add_port_id,
15310 (void *)&cmd_ddp_add_filepath,
15315 /* Delete dynamic device personalization*/
15316 struct cmd_ddp_del_result {
15317 cmdline_fixed_string_t ddp;
15318 cmdline_fixed_string_t del;
15323 cmdline_parse_token_string_t cmd_ddp_del_ddp =
15324 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
15325 cmdline_parse_token_string_t cmd_ddp_del_del =
15326 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
15327 cmdline_parse_token_num_t cmd_ddp_del_port_id =
15328 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
15329 cmdline_parse_token_string_t cmd_ddp_del_filepath =
15330 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
15333 cmd_ddp_del_parsed(
15334 void *parsed_result,
15335 __attribute__((unused)) struct cmdline *cl,
15336 __attribute__((unused)) void *data)
15338 struct cmd_ddp_del_result *res = parsed_result;
15341 int ret = -ENOTSUP;
15343 if (!all_ports_stopped()) {
15344 printf("Please stop all ports first\n");
15348 buff = open_file(res->filepath, &size);
15352 #ifdef RTE_LIBRTE_I40E_PMD
15353 if (ret == -ENOTSUP)
15354 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15356 RTE_PMD_I40E_PKG_OP_WR_DEL);
15359 if (ret == -EACCES)
15360 printf("Profile does not exist.\n");
15362 printf("Failed to delete profile.\n");
15367 cmdline_parse_inst_t cmd_ddp_del = {
15368 .f = cmd_ddp_del_parsed,
15370 .help_str = "ddp del <port_id> <backup_profile_path>",
15372 (void *)&cmd_ddp_del_ddp,
15373 (void *)&cmd_ddp_del_del,
15374 (void *)&cmd_ddp_del_port_id,
15375 (void *)&cmd_ddp_del_filepath,
15380 /* Get dynamic device personalization profile info */
15381 struct cmd_ddp_info_result {
15382 cmdline_fixed_string_t ddp;
15383 cmdline_fixed_string_t get;
15384 cmdline_fixed_string_t info;
15388 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15389 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15390 cmdline_parse_token_string_t cmd_ddp_info_get =
15391 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15392 cmdline_parse_token_string_t cmd_ddp_info_info =
15393 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15394 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15395 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15398 cmd_ddp_info_parsed(
15399 void *parsed_result,
15400 __attribute__((unused)) struct cmdline *cl,
15401 __attribute__((unused)) void *data)
15403 struct cmd_ddp_info_result *res = parsed_result;
15406 int ret = -ENOTSUP;
15407 #ifdef RTE_LIBRTE_I40E_PMD
15410 uint32_t buff_size = 0;
15411 struct rte_pmd_i40e_profile_info info;
15412 uint32_t dev_num = 0;
15413 struct rte_pmd_i40e_ddp_device_id *devs;
15414 uint32_t proto_num = 0;
15415 struct rte_pmd_i40e_proto_info *proto = NULL;
15416 uint32_t pctype_num = 0;
15417 struct rte_pmd_i40e_ptype_info *pctype;
15418 uint32_t ptype_num = 0;
15419 struct rte_pmd_i40e_ptype_info *ptype;
15424 pkg = open_file(res->filepath, &pkg_size);
15428 #ifdef RTE_LIBRTE_I40E_PMD
15429 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15430 (uint8_t *)&info, sizeof(info),
15431 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15433 printf("Global Track id: 0x%x\n", info.track_id);
15434 printf("Global Version: %d.%d.%d.%d\n",
15435 info.version.major,
15436 info.version.minor,
15437 info.version.update,
15438 info.version.draft);
15439 printf("Global Package name: %s\n\n", info.name);
15442 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15443 (uint8_t *)&info, sizeof(info),
15444 RTE_PMD_I40E_PKG_INFO_HEADER);
15446 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15447 printf("i40e Profile Version: %d.%d.%d.%d\n",
15448 info.version.major,
15449 info.version.minor,
15450 info.version.update,
15451 info.version.draft);
15452 printf("i40e Profile name: %s\n\n", info.name);
15455 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15456 (uint8_t *)&buff_size, sizeof(buff_size),
15457 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15458 if (!ret && buff_size) {
15459 buff = (uint8_t *)malloc(buff_size);
15461 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15463 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15465 printf("Package Notes:\n%s\n\n", buff);
15470 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15471 (uint8_t *)&dev_num, sizeof(dev_num),
15472 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15473 if (!ret && dev_num) {
15474 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15475 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15477 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15478 (uint8_t *)devs, buff_size,
15479 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15481 printf("List of supported devices:\n");
15482 for (i = 0; i < dev_num; i++) {
15483 printf(" %04X:%04X %04X:%04X\n",
15484 devs[i].vendor_dev_id >> 16,
15485 devs[i].vendor_dev_id & 0xFFFF,
15486 devs[i].sub_vendor_dev_id >> 16,
15487 devs[i].sub_vendor_dev_id & 0xFFFF);
15495 /* get information about protocols and packet types */
15496 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15497 (uint8_t *)&proto_num, sizeof(proto_num),
15498 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15499 if (ret || !proto_num)
15500 goto no_print_return;
15502 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15503 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15505 goto no_print_return;
15507 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15509 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15511 printf("List of used protocols:\n");
15512 for (i = 0; i < proto_num; i++)
15513 printf(" %2u: %s\n", proto[i].proto_id,
15517 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15518 (uint8_t *)&pctype_num, sizeof(pctype_num),
15519 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15520 if (ret || !pctype_num)
15521 goto no_print_pctypes;
15523 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15524 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15526 goto no_print_pctypes;
15528 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15530 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15533 goto no_print_pctypes;
15536 printf("List of defined packet classification types:\n");
15537 for (i = 0; i < pctype_num; i++) {
15538 printf(" %2u:", pctype[i].ptype_id);
15539 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15540 proto_id = pctype[i].protocols[j];
15541 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15542 for (n = 0; n < proto_num; n++) {
15543 if (proto[n].proto_id == proto_id) {
15544 printf(" %s", proto[n].name);
15557 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15559 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15560 if (ret || !ptype_num)
15561 goto no_print_return;
15563 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15564 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15566 goto no_print_return;
15568 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15570 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15573 goto no_print_return;
15575 printf("List of defined packet types:\n");
15576 for (i = 0; i < ptype_num; i++) {
15577 printf(" %2u:", ptype[i].ptype_id);
15578 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15579 proto_id = ptype[i].protocols[j];
15580 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15581 for (n = 0; n < proto_num; n++) {
15582 if (proto[n].proto_id == proto_id) {
15583 printf(" %s", proto[n].name);
15599 if (ret == -ENOTSUP)
15600 printf("Function not supported in PMD driver\n");
15604 cmdline_parse_inst_t cmd_ddp_get_info = {
15605 .f = cmd_ddp_info_parsed,
15607 .help_str = "ddp get info <profile_path>",
15609 (void *)&cmd_ddp_info_ddp,
15610 (void *)&cmd_ddp_info_get,
15611 (void *)&cmd_ddp_info_info,
15612 (void *)&cmd_ddp_info_filepath,
15617 /* Get dynamic device personalization profile info list*/
15618 #define PROFILE_INFO_SIZE 48
15619 #define MAX_PROFILE_NUM 16
15621 struct cmd_ddp_get_list_result {
15622 cmdline_fixed_string_t ddp;
15623 cmdline_fixed_string_t get;
15624 cmdline_fixed_string_t list;
15628 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15629 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15630 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15631 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15632 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15633 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15634 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15635 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15638 cmd_ddp_get_list_parsed(
15639 __attribute__((unused)) void *parsed_result,
15640 __attribute__((unused)) struct cmdline *cl,
15641 __attribute__((unused)) void *data)
15643 #ifdef RTE_LIBRTE_I40E_PMD
15644 struct cmd_ddp_get_list_result *res = parsed_result;
15645 struct rte_pmd_i40e_profile_list *p_list;
15646 struct rte_pmd_i40e_profile_info *p_info;
15651 int ret = -ENOTSUP;
15653 #ifdef RTE_LIBRTE_I40E_PMD
15654 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15655 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15657 printf("%s: Failed to malloc buffer\n", __func__);
15659 if (ret == -ENOTSUP)
15660 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15661 (uint8_t *)p_list, size);
15664 p_num = p_list->p_count;
15665 printf("Profile number is: %d\n\n", p_num);
15667 for (i = 0; i < p_num; i++) {
15668 p_info = &p_list->p_info[i];
15669 printf("Profile %d:\n", i);
15670 printf("Track id: 0x%x\n", p_info->track_id);
15671 printf("Version: %d.%d.%d.%d\n",
15672 p_info->version.major,
15673 p_info->version.minor,
15674 p_info->version.update,
15675 p_info->version.draft);
15676 printf("Profile name: %s\n\n", p_info->name);
15684 printf("Failed to get ddp list\n");
15687 cmdline_parse_inst_t cmd_ddp_get_list = {
15688 .f = cmd_ddp_get_list_parsed,
15690 .help_str = "ddp get list <port_id>",
15692 (void *)&cmd_ddp_get_list_ddp,
15693 (void *)&cmd_ddp_get_list_get,
15694 (void *)&cmd_ddp_get_list_list,
15695 (void *)&cmd_ddp_get_list_port_id,
15700 /* Configure input set */
15701 struct cmd_cfg_input_set_result {
15702 cmdline_fixed_string_t port;
15703 cmdline_fixed_string_t cfg;
15705 cmdline_fixed_string_t pctype;
15707 cmdline_fixed_string_t inset_type;
15708 cmdline_fixed_string_t opt;
15709 cmdline_fixed_string_t field;
15714 cmd_cfg_input_set_parsed(
15715 __attribute__((unused)) void *parsed_result,
15716 __attribute__((unused)) struct cmdline *cl,
15717 __attribute__((unused)) void *data)
15719 #ifdef RTE_LIBRTE_I40E_PMD
15720 struct cmd_cfg_input_set_result *res = parsed_result;
15721 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15722 struct rte_pmd_i40e_inset inset;
15724 int ret = -ENOTSUP;
15726 if (!all_ports_stopped()) {
15727 printf("Please stop all ports first\n");
15731 #ifdef RTE_LIBRTE_I40E_PMD
15732 if (!strcmp(res->inset_type, "hash_inset"))
15733 inset_type = INSET_HASH;
15734 else if (!strcmp(res->inset_type, "fdir_inset"))
15735 inset_type = INSET_FDIR;
15736 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15737 inset_type = INSET_FDIR_FLX;
15738 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15739 &inset, inset_type);
15741 printf("Failed to get input set.\n");
15745 if (!strcmp(res->opt, "get")) {
15746 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15749 printf("Field index %d is enabled.\n", res->field_idx);
15751 printf("Field index %d is disabled.\n", res->field_idx);
15753 } else if (!strcmp(res->opt, "set"))
15754 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15756 else if (!strcmp(res->opt, "clear"))
15757 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15760 printf("Failed to configure input set field.\n");
15764 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15765 &inset, inset_type);
15767 printf("Failed to set input set.\n");
15772 if (ret == -ENOTSUP)
15773 printf("Function not supported\n");
15776 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15777 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15779 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15780 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15782 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15783 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15785 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15786 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15788 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15789 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15791 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15792 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15794 "hash_inset#fdir_inset#fdir_flx_inset");
15795 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15796 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15797 opt, "get#set#clear");
15798 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15799 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15801 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15802 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15805 cmdline_parse_inst_t cmd_cfg_input_set = {
15806 .f = cmd_cfg_input_set_parsed,
15808 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15809 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15811 (void *)&cmd_cfg_input_set_port,
15812 (void *)&cmd_cfg_input_set_cfg,
15813 (void *)&cmd_cfg_input_set_port_id,
15814 (void *)&cmd_cfg_input_set_pctype,
15815 (void *)&cmd_cfg_input_set_pctype_id,
15816 (void *)&cmd_cfg_input_set_inset_type,
15817 (void *)&cmd_cfg_input_set_opt,
15818 (void *)&cmd_cfg_input_set_field,
15819 (void *)&cmd_cfg_input_set_field_idx,
15824 /* Clear input set */
15825 struct cmd_clear_input_set_result {
15826 cmdline_fixed_string_t port;
15827 cmdline_fixed_string_t cfg;
15829 cmdline_fixed_string_t pctype;
15831 cmdline_fixed_string_t inset_type;
15832 cmdline_fixed_string_t clear;
15833 cmdline_fixed_string_t all;
15837 cmd_clear_input_set_parsed(
15838 __attribute__((unused)) void *parsed_result,
15839 __attribute__((unused)) struct cmdline *cl,
15840 __attribute__((unused)) void *data)
15842 #ifdef RTE_LIBRTE_I40E_PMD
15843 struct cmd_clear_input_set_result *res = parsed_result;
15844 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15845 struct rte_pmd_i40e_inset inset;
15847 int ret = -ENOTSUP;
15849 if (!all_ports_stopped()) {
15850 printf("Please stop all ports first\n");
15854 #ifdef RTE_LIBRTE_I40E_PMD
15855 if (!strcmp(res->inset_type, "hash_inset"))
15856 inset_type = INSET_HASH;
15857 else if (!strcmp(res->inset_type, "fdir_inset"))
15858 inset_type = INSET_FDIR;
15859 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15860 inset_type = INSET_FDIR_FLX;
15862 memset(&inset, 0, sizeof(inset));
15864 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15865 &inset, inset_type);
15867 printf("Failed to clear input set.\n");
15873 if (ret == -ENOTSUP)
15874 printf("Function not supported\n");
15877 cmdline_parse_token_string_t cmd_clear_input_set_port =
15878 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15880 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15881 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15883 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15884 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15886 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15887 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15889 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15890 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15892 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15893 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15895 "hash_inset#fdir_inset#fdir_flx_inset");
15896 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15897 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15899 cmdline_parse_token_string_t cmd_clear_input_set_all =
15900 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15903 cmdline_parse_inst_t cmd_clear_input_set = {
15904 .f = cmd_clear_input_set_parsed,
15906 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15907 "fdir_inset|fdir_flx_inset clear all",
15909 (void *)&cmd_clear_input_set_port,
15910 (void *)&cmd_clear_input_set_cfg,
15911 (void *)&cmd_clear_input_set_port_id,
15912 (void *)&cmd_clear_input_set_pctype,
15913 (void *)&cmd_clear_input_set_pctype_id,
15914 (void *)&cmd_clear_input_set_inset_type,
15915 (void *)&cmd_clear_input_set_clear,
15916 (void *)&cmd_clear_input_set_all,
15921 /* show vf stats */
15923 /* Common result structure for show vf stats */
15924 struct cmd_show_vf_stats_result {
15925 cmdline_fixed_string_t show;
15926 cmdline_fixed_string_t vf;
15927 cmdline_fixed_string_t stats;
15932 /* Common CLI fields show vf stats*/
15933 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15934 TOKEN_STRING_INITIALIZER
15935 (struct cmd_show_vf_stats_result,
15937 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15938 TOKEN_STRING_INITIALIZER
15939 (struct cmd_show_vf_stats_result,
15941 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15942 TOKEN_STRING_INITIALIZER
15943 (struct cmd_show_vf_stats_result,
15945 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15946 TOKEN_NUM_INITIALIZER
15947 (struct cmd_show_vf_stats_result,
15949 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15950 TOKEN_NUM_INITIALIZER
15951 (struct cmd_show_vf_stats_result,
15955 cmd_show_vf_stats_parsed(
15956 void *parsed_result,
15957 __attribute__((unused)) struct cmdline *cl,
15958 __attribute__((unused)) void *data)
15960 struct cmd_show_vf_stats_result *res = parsed_result;
15961 struct rte_eth_stats stats;
15962 int ret = -ENOTSUP;
15963 static const char *nic_stats_border = "########################";
15965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15968 memset(&stats, 0, sizeof(stats));
15970 #ifdef RTE_LIBRTE_I40E_PMD
15971 if (ret == -ENOTSUP)
15972 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15976 #ifdef RTE_LIBRTE_BNXT_PMD
15977 if (ret == -ENOTSUP)
15978 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15987 printf("invalid vf_id %d\n", res->vf_id);
15990 printf("invalid port_id %d\n", res->port_id);
15993 printf("function not implemented\n");
15996 printf("programming error: (%s)\n", strerror(-ret));
15999 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16000 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16002 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16004 stats.ipackets, stats.imissed, stats.ibytes);
16005 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16006 printf(" RX-nombuf: %-10"PRIu64"\n",
16008 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16010 stats.opackets, stats.oerrors, stats.obytes);
16012 printf(" %s############################%s\n",
16013 nic_stats_border, nic_stats_border);
16016 cmdline_parse_inst_t cmd_show_vf_stats = {
16017 .f = cmd_show_vf_stats_parsed,
16019 .help_str = "show vf stats <port_id> <vf_id>",
16021 (void *)&cmd_show_vf_stats_show,
16022 (void *)&cmd_show_vf_stats_vf,
16023 (void *)&cmd_show_vf_stats_stats,
16024 (void *)&cmd_show_vf_stats_port_id,
16025 (void *)&cmd_show_vf_stats_vf_id,
16030 /* clear vf stats */
16032 /* Common result structure for clear vf stats */
16033 struct cmd_clear_vf_stats_result {
16034 cmdline_fixed_string_t clear;
16035 cmdline_fixed_string_t vf;
16036 cmdline_fixed_string_t stats;
16041 /* Common CLI fields clear vf stats*/
16042 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16043 TOKEN_STRING_INITIALIZER
16044 (struct cmd_clear_vf_stats_result,
16046 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16047 TOKEN_STRING_INITIALIZER
16048 (struct cmd_clear_vf_stats_result,
16050 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16051 TOKEN_STRING_INITIALIZER
16052 (struct cmd_clear_vf_stats_result,
16054 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16055 TOKEN_NUM_INITIALIZER
16056 (struct cmd_clear_vf_stats_result,
16058 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16059 TOKEN_NUM_INITIALIZER
16060 (struct cmd_clear_vf_stats_result,
16064 cmd_clear_vf_stats_parsed(
16065 void *parsed_result,
16066 __attribute__((unused)) struct cmdline *cl,
16067 __attribute__((unused)) void *data)
16069 struct cmd_clear_vf_stats_result *res = parsed_result;
16070 int ret = -ENOTSUP;
16072 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16075 #ifdef RTE_LIBRTE_I40E_PMD
16076 if (ret == -ENOTSUP)
16077 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16080 #ifdef RTE_LIBRTE_BNXT_PMD
16081 if (ret == -ENOTSUP)
16082 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16090 printf("invalid vf_id %d\n", res->vf_id);
16093 printf("invalid port_id %d\n", res->port_id);
16096 printf("function not implemented\n");
16099 printf("programming error: (%s)\n", strerror(-ret));
16103 cmdline_parse_inst_t cmd_clear_vf_stats = {
16104 .f = cmd_clear_vf_stats_parsed,
16106 .help_str = "clear vf stats <port_id> <vf_id>",
16108 (void *)&cmd_clear_vf_stats_clear,
16109 (void *)&cmd_clear_vf_stats_vf,
16110 (void *)&cmd_clear_vf_stats_stats,
16111 (void *)&cmd_clear_vf_stats_port_id,
16112 (void *)&cmd_clear_vf_stats_vf_id,
16117 /* port config pctype mapping reset */
16119 /* Common result structure for port config pctype mapping reset */
16120 struct cmd_pctype_mapping_reset_result {
16121 cmdline_fixed_string_t port;
16122 cmdline_fixed_string_t config;
16124 cmdline_fixed_string_t pctype;
16125 cmdline_fixed_string_t mapping;
16126 cmdline_fixed_string_t reset;
16129 /* Common CLI fields for port config pctype mapping reset*/
16130 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16131 TOKEN_STRING_INITIALIZER
16132 (struct cmd_pctype_mapping_reset_result,
16134 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16135 TOKEN_STRING_INITIALIZER
16136 (struct cmd_pctype_mapping_reset_result,
16138 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16139 TOKEN_NUM_INITIALIZER
16140 (struct cmd_pctype_mapping_reset_result,
16142 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16143 TOKEN_STRING_INITIALIZER
16144 (struct cmd_pctype_mapping_reset_result,
16146 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16147 TOKEN_STRING_INITIALIZER
16148 (struct cmd_pctype_mapping_reset_result,
16149 mapping, "mapping");
16150 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16151 TOKEN_STRING_INITIALIZER
16152 (struct cmd_pctype_mapping_reset_result,
16156 cmd_pctype_mapping_reset_parsed(
16157 void *parsed_result,
16158 __attribute__((unused)) struct cmdline *cl,
16159 __attribute__((unused)) void *data)
16161 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16162 int ret = -ENOTSUP;
16164 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16167 #ifdef RTE_LIBRTE_I40E_PMD
16168 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16175 printf("invalid port_id %d\n", res->port_id);
16178 printf("function not implemented\n");
16181 printf("programming error: (%s)\n", strerror(-ret));
16185 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16186 .f = cmd_pctype_mapping_reset_parsed,
16188 .help_str = "port config <port_id> pctype mapping reset",
16190 (void *)&cmd_pctype_mapping_reset_port,
16191 (void *)&cmd_pctype_mapping_reset_config,
16192 (void *)&cmd_pctype_mapping_reset_port_id,
16193 (void *)&cmd_pctype_mapping_reset_pctype,
16194 (void *)&cmd_pctype_mapping_reset_mapping,
16195 (void *)&cmd_pctype_mapping_reset_reset,
16200 /* show port pctype mapping */
16202 /* Common result structure for show port pctype mapping */
16203 struct cmd_pctype_mapping_get_result {
16204 cmdline_fixed_string_t show;
16205 cmdline_fixed_string_t port;
16207 cmdline_fixed_string_t pctype;
16208 cmdline_fixed_string_t mapping;
16211 /* Common CLI fields for pctype mapping get */
16212 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
16213 TOKEN_STRING_INITIALIZER
16214 (struct cmd_pctype_mapping_get_result,
16216 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16217 TOKEN_STRING_INITIALIZER
16218 (struct cmd_pctype_mapping_get_result,
16220 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
16221 TOKEN_NUM_INITIALIZER
16222 (struct cmd_pctype_mapping_get_result,
16224 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
16225 TOKEN_STRING_INITIALIZER
16226 (struct cmd_pctype_mapping_get_result,
16228 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
16229 TOKEN_STRING_INITIALIZER
16230 (struct cmd_pctype_mapping_get_result,
16231 mapping, "mapping");
16234 cmd_pctype_mapping_get_parsed(
16235 void *parsed_result,
16236 __attribute__((unused)) struct cmdline *cl,
16237 __attribute__((unused)) void *data)
16239 struct cmd_pctype_mapping_get_result *res = parsed_result;
16240 int ret = -ENOTSUP;
16241 #ifdef RTE_LIBRTE_I40E_PMD
16242 struct rte_pmd_i40e_flow_type_mapping
16243 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
16244 int i, j, first_pctype;
16247 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16250 #ifdef RTE_LIBRTE_I40E_PMD
16251 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
16258 printf("invalid port_id %d\n", res->port_id);
16261 printf("function not implemented\n");
16264 printf("programming error: (%s)\n", strerror(-ret));
16268 #ifdef RTE_LIBRTE_I40E_PMD
16269 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
16270 if (mapping[i].pctype != 0ULL) {
16273 printf("pctype: ");
16274 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
16275 if (mapping[i].pctype & (1ULL << j)) {
16276 printf(first_pctype ?
16277 "%02d" : ",%02d", j);
16281 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
16287 cmdline_parse_inst_t cmd_pctype_mapping_get = {
16288 .f = cmd_pctype_mapping_get_parsed,
16290 .help_str = "show port <port_id> pctype mapping",
16292 (void *)&cmd_pctype_mapping_get_show,
16293 (void *)&cmd_pctype_mapping_get_port,
16294 (void *)&cmd_pctype_mapping_get_port_id,
16295 (void *)&cmd_pctype_mapping_get_pctype,
16296 (void *)&cmd_pctype_mapping_get_mapping,
16301 /* port config pctype mapping update */
16303 /* Common result structure for port config pctype mapping update */
16304 struct cmd_pctype_mapping_update_result {
16305 cmdline_fixed_string_t port;
16306 cmdline_fixed_string_t config;
16308 cmdline_fixed_string_t pctype;
16309 cmdline_fixed_string_t mapping;
16310 cmdline_fixed_string_t update;
16311 cmdline_fixed_string_t pctype_list;
16312 uint16_t flow_type;
16315 /* Common CLI fields for pctype mapping update*/
16316 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
16317 TOKEN_STRING_INITIALIZER
16318 (struct cmd_pctype_mapping_update_result,
16320 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
16321 TOKEN_STRING_INITIALIZER
16322 (struct cmd_pctype_mapping_update_result,
16324 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
16325 TOKEN_NUM_INITIALIZER
16326 (struct cmd_pctype_mapping_update_result,
16328 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
16329 TOKEN_STRING_INITIALIZER
16330 (struct cmd_pctype_mapping_update_result,
16332 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
16333 TOKEN_STRING_INITIALIZER
16334 (struct cmd_pctype_mapping_update_result,
16335 mapping, "mapping");
16336 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
16337 TOKEN_STRING_INITIALIZER
16338 (struct cmd_pctype_mapping_update_result,
16340 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16341 TOKEN_STRING_INITIALIZER
16342 (struct cmd_pctype_mapping_update_result,
16343 pctype_list, NULL);
16344 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16345 TOKEN_NUM_INITIALIZER
16346 (struct cmd_pctype_mapping_update_result,
16347 flow_type, UINT16);
16350 cmd_pctype_mapping_update_parsed(
16351 void *parsed_result,
16352 __attribute__((unused)) struct cmdline *cl,
16353 __attribute__((unused)) void *data)
16355 struct cmd_pctype_mapping_update_result *res = parsed_result;
16356 int ret = -ENOTSUP;
16357 #ifdef RTE_LIBRTE_I40E_PMD
16358 struct rte_pmd_i40e_flow_type_mapping mapping;
16360 unsigned int nb_item;
16361 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16364 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16367 #ifdef RTE_LIBRTE_I40E_PMD
16368 nb_item = parse_item_list(res->pctype_list, "pctypes",
16369 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16370 mapping.flow_type = res->flow_type;
16371 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16372 mapping.pctype |= (1ULL << pctype_list[i]);
16373 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16383 printf("invalid pctype or flow type\n");
16386 printf("invalid port_id %d\n", res->port_id);
16389 printf("function not implemented\n");
16392 printf("programming error: (%s)\n", strerror(-ret));
16396 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16397 .f = cmd_pctype_mapping_update_parsed,
16399 .help_str = "port config <port_id> pctype mapping update"
16400 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16402 (void *)&cmd_pctype_mapping_update_port,
16403 (void *)&cmd_pctype_mapping_update_config,
16404 (void *)&cmd_pctype_mapping_update_port_id,
16405 (void *)&cmd_pctype_mapping_update_pctype,
16406 (void *)&cmd_pctype_mapping_update_mapping,
16407 (void *)&cmd_pctype_mapping_update_update,
16408 (void *)&cmd_pctype_mapping_update_pc_type,
16409 (void *)&cmd_pctype_mapping_update_flow_type,
16414 /* ptype mapping get */
16416 /* Common result structure for ptype mapping get */
16417 struct cmd_ptype_mapping_get_result {
16418 cmdline_fixed_string_t ptype;
16419 cmdline_fixed_string_t mapping;
16420 cmdline_fixed_string_t get;
16422 uint8_t valid_only;
16425 /* Common CLI fields for ptype mapping get */
16426 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16427 TOKEN_STRING_INITIALIZER
16428 (struct cmd_ptype_mapping_get_result,
16430 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16431 TOKEN_STRING_INITIALIZER
16432 (struct cmd_ptype_mapping_get_result,
16433 mapping, "mapping");
16434 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16435 TOKEN_STRING_INITIALIZER
16436 (struct cmd_ptype_mapping_get_result,
16438 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16439 TOKEN_NUM_INITIALIZER
16440 (struct cmd_ptype_mapping_get_result,
16442 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16443 TOKEN_NUM_INITIALIZER
16444 (struct cmd_ptype_mapping_get_result,
16445 valid_only, UINT8);
16448 cmd_ptype_mapping_get_parsed(
16449 void *parsed_result,
16450 __attribute__((unused)) struct cmdline *cl,
16451 __attribute__((unused)) void *data)
16453 struct cmd_ptype_mapping_get_result *res = parsed_result;
16454 int ret = -ENOTSUP;
16455 #ifdef RTE_LIBRTE_I40E_PMD
16456 int max_ptype_num = 256;
16457 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16462 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16465 #ifdef RTE_LIBRTE_I40E_PMD
16466 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16477 printf("invalid port_id %d\n", res->port_id);
16480 printf("function not implemented\n");
16483 printf("programming error: (%s)\n", strerror(-ret));
16486 #ifdef RTE_LIBRTE_I40E_PMD
16488 for (i = 0; i < count; i++)
16489 printf("%3d\t0x%08x\n",
16490 mapping[i].hw_ptype, mapping[i].sw_ptype);
16495 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16496 .f = cmd_ptype_mapping_get_parsed,
16498 .help_str = "ptype mapping get <port_id> <valid_only>",
16500 (void *)&cmd_ptype_mapping_get_ptype,
16501 (void *)&cmd_ptype_mapping_get_mapping,
16502 (void *)&cmd_ptype_mapping_get_get,
16503 (void *)&cmd_ptype_mapping_get_port_id,
16504 (void *)&cmd_ptype_mapping_get_valid_only,
16509 /* ptype mapping replace */
16511 /* Common result structure for ptype mapping replace */
16512 struct cmd_ptype_mapping_replace_result {
16513 cmdline_fixed_string_t ptype;
16514 cmdline_fixed_string_t mapping;
16515 cmdline_fixed_string_t replace;
16522 /* Common CLI fields for ptype mapping replace */
16523 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16524 TOKEN_STRING_INITIALIZER
16525 (struct cmd_ptype_mapping_replace_result,
16527 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16528 TOKEN_STRING_INITIALIZER
16529 (struct cmd_ptype_mapping_replace_result,
16530 mapping, "mapping");
16531 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16532 TOKEN_STRING_INITIALIZER
16533 (struct cmd_ptype_mapping_replace_result,
16534 replace, "replace");
16535 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16536 TOKEN_NUM_INITIALIZER
16537 (struct cmd_ptype_mapping_replace_result,
16539 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16540 TOKEN_NUM_INITIALIZER
16541 (struct cmd_ptype_mapping_replace_result,
16543 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16544 TOKEN_NUM_INITIALIZER
16545 (struct cmd_ptype_mapping_replace_result,
16547 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16548 TOKEN_NUM_INITIALIZER
16549 (struct cmd_ptype_mapping_replace_result,
16553 cmd_ptype_mapping_replace_parsed(
16554 void *parsed_result,
16555 __attribute__((unused)) struct cmdline *cl,
16556 __attribute__((unused)) void *data)
16558 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16559 int ret = -ENOTSUP;
16561 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16564 #ifdef RTE_LIBRTE_I40E_PMD
16565 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16575 printf("invalid ptype 0x%8x or 0x%8x\n",
16576 res->target, res->pkt_type);
16579 printf("invalid port_id %d\n", res->port_id);
16582 printf("function not implemented\n");
16585 printf("programming error: (%s)\n", strerror(-ret));
16589 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16590 .f = cmd_ptype_mapping_replace_parsed,
16593 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16595 (void *)&cmd_ptype_mapping_replace_ptype,
16596 (void *)&cmd_ptype_mapping_replace_mapping,
16597 (void *)&cmd_ptype_mapping_replace_replace,
16598 (void *)&cmd_ptype_mapping_replace_port_id,
16599 (void *)&cmd_ptype_mapping_replace_target,
16600 (void *)&cmd_ptype_mapping_replace_mask,
16601 (void *)&cmd_ptype_mapping_replace_pkt_type,
16606 /* ptype mapping reset */
16608 /* Common result structure for ptype mapping reset */
16609 struct cmd_ptype_mapping_reset_result {
16610 cmdline_fixed_string_t ptype;
16611 cmdline_fixed_string_t mapping;
16612 cmdline_fixed_string_t reset;
16616 /* Common CLI fields for ptype mapping reset*/
16617 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16618 TOKEN_STRING_INITIALIZER
16619 (struct cmd_ptype_mapping_reset_result,
16621 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16622 TOKEN_STRING_INITIALIZER
16623 (struct cmd_ptype_mapping_reset_result,
16624 mapping, "mapping");
16625 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16626 TOKEN_STRING_INITIALIZER
16627 (struct cmd_ptype_mapping_reset_result,
16629 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16630 TOKEN_NUM_INITIALIZER
16631 (struct cmd_ptype_mapping_reset_result,
16635 cmd_ptype_mapping_reset_parsed(
16636 void *parsed_result,
16637 __attribute__((unused)) struct cmdline *cl,
16638 __attribute__((unused)) void *data)
16640 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16641 int ret = -ENOTSUP;
16643 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16646 #ifdef RTE_LIBRTE_I40E_PMD
16647 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16654 printf("invalid port_id %d\n", res->port_id);
16657 printf("function not implemented\n");
16660 printf("programming error: (%s)\n", strerror(-ret));
16664 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16665 .f = cmd_ptype_mapping_reset_parsed,
16667 .help_str = "ptype mapping reset <port_id>",
16669 (void *)&cmd_ptype_mapping_reset_ptype,
16670 (void *)&cmd_ptype_mapping_reset_mapping,
16671 (void *)&cmd_ptype_mapping_reset_reset,
16672 (void *)&cmd_ptype_mapping_reset_port_id,
16677 /* ptype mapping update */
16679 /* Common result structure for ptype mapping update */
16680 struct cmd_ptype_mapping_update_result {
16681 cmdline_fixed_string_t ptype;
16682 cmdline_fixed_string_t mapping;
16683 cmdline_fixed_string_t reset;
16689 /* Common CLI fields for ptype mapping update*/
16690 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16691 TOKEN_STRING_INITIALIZER
16692 (struct cmd_ptype_mapping_update_result,
16694 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16695 TOKEN_STRING_INITIALIZER
16696 (struct cmd_ptype_mapping_update_result,
16697 mapping, "mapping");
16698 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16699 TOKEN_STRING_INITIALIZER
16700 (struct cmd_ptype_mapping_update_result,
16702 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16703 TOKEN_NUM_INITIALIZER
16704 (struct cmd_ptype_mapping_update_result,
16706 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16707 TOKEN_NUM_INITIALIZER
16708 (struct cmd_ptype_mapping_update_result,
16710 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16711 TOKEN_NUM_INITIALIZER
16712 (struct cmd_ptype_mapping_update_result,
16716 cmd_ptype_mapping_update_parsed(
16717 void *parsed_result,
16718 __attribute__((unused)) struct cmdline *cl,
16719 __attribute__((unused)) void *data)
16721 struct cmd_ptype_mapping_update_result *res = parsed_result;
16722 int ret = -ENOTSUP;
16723 #ifdef RTE_LIBRTE_I40E_PMD
16724 struct rte_pmd_i40e_ptype_mapping mapping;
16726 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16729 #ifdef RTE_LIBRTE_I40E_PMD
16730 mapping.hw_ptype = res->hw_ptype;
16731 mapping.sw_ptype = res->sw_ptype;
16732 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16742 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16745 printf("invalid port_id %d\n", res->port_id);
16748 printf("function not implemented\n");
16751 printf("programming error: (%s)\n", strerror(-ret));
16755 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16756 .f = cmd_ptype_mapping_update_parsed,
16758 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16760 (void *)&cmd_ptype_mapping_update_ptype,
16761 (void *)&cmd_ptype_mapping_update_mapping,
16762 (void *)&cmd_ptype_mapping_update_update,
16763 (void *)&cmd_ptype_mapping_update_port_id,
16764 (void *)&cmd_ptype_mapping_update_hw_ptype,
16765 (void *)&cmd_ptype_mapping_update_sw_ptype,
16770 /* Common result structure for file commands */
16771 struct cmd_cmdfile_result {
16772 cmdline_fixed_string_t load;
16773 cmdline_fixed_string_t filename;
16776 /* Common CLI fields for file commands */
16777 cmdline_parse_token_string_t cmd_load_cmdfile =
16778 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16779 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16780 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16783 cmd_load_from_file_parsed(
16784 void *parsed_result,
16785 __attribute__((unused)) struct cmdline *cl,
16786 __attribute__((unused)) void *data)
16788 struct cmd_cmdfile_result *res = parsed_result;
16790 cmdline_read_from_file(res->filename);
16793 cmdline_parse_inst_t cmd_load_from_file = {
16794 .f = cmd_load_from_file_parsed,
16796 .help_str = "load <filename>",
16798 (void *)&cmd_load_cmdfile,
16799 (void *)&cmd_load_cmdfile_filename,
16804 /* Get Rx offloads capabilities */
16805 struct cmd_rx_offload_get_capa_result {
16806 cmdline_fixed_string_t show;
16807 cmdline_fixed_string_t port;
16809 cmdline_fixed_string_t rx_offload;
16810 cmdline_fixed_string_t capabilities;
16813 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16814 TOKEN_STRING_INITIALIZER
16815 (struct cmd_rx_offload_get_capa_result,
16817 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16818 TOKEN_STRING_INITIALIZER
16819 (struct cmd_rx_offload_get_capa_result,
16821 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16822 TOKEN_NUM_INITIALIZER
16823 (struct cmd_rx_offload_get_capa_result,
16825 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16826 TOKEN_STRING_INITIALIZER
16827 (struct cmd_rx_offload_get_capa_result,
16828 rx_offload, "rx_offload");
16829 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16830 TOKEN_STRING_INITIALIZER
16831 (struct cmd_rx_offload_get_capa_result,
16832 capabilities, "capabilities");
16835 print_rx_offloads(uint64_t offloads)
16837 uint64_t single_offload;
16845 begin = __builtin_ctzll(offloads);
16846 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16848 single_offload = 1 << begin;
16849 for (bit = begin; bit < end; bit++) {
16850 if (offloads & single_offload)
16852 rte_eth_dev_rx_offload_name(single_offload));
16853 single_offload <<= 1;
16858 cmd_rx_offload_get_capa_parsed(
16859 void *parsed_result,
16860 __attribute__((unused)) struct cmdline *cl,
16861 __attribute__((unused)) void *data)
16863 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16864 struct rte_eth_dev_info dev_info;
16865 portid_t port_id = res->port_id;
16866 uint64_t queue_offloads;
16867 uint64_t port_offloads;
16869 rte_eth_dev_info_get(port_id, &dev_info);
16870 queue_offloads = dev_info.rx_queue_offload_capa;
16871 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16873 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16874 printf(" Per Queue :");
16875 print_rx_offloads(queue_offloads);
16878 printf(" Per Port :");
16879 print_rx_offloads(port_offloads);
16883 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16884 .f = cmd_rx_offload_get_capa_parsed,
16886 .help_str = "show port <port_id> rx_offload capabilities",
16888 (void *)&cmd_rx_offload_get_capa_show,
16889 (void *)&cmd_rx_offload_get_capa_port,
16890 (void *)&cmd_rx_offload_get_capa_port_id,
16891 (void *)&cmd_rx_offload_get_capa_rx_offload,
16892 (void *)&cmd_rx_offload_get_capa_capabilities,
16897 /* Get Rx offloads configuration */
16898 struct cmd_rx_offload_get_configuration_result {
16899 cmdline_fixed_string_t show;
16900 cmdline_fixed_string_t port;
16902 cmdline_fixed_string_t rx_offload;
16903 cmdline_fixed_string_t configuration;
16906 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16907 TOKEN_STRING_INITIALIZER
16908 (struct cmd_rx_offload_get_configuration_result,
16910 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16911 TOKEN_STRING_INITIALIZER
16912 (struct cmd_rx_offload_get_configuration_result,
16914 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16915 TOKEN_NUM_INITIALIZER
16916 (struct cmd_rx_offload_get_configuration_result,
16918 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16919 TOKEN_STRING_INITIALIZER
16920 (struct cmd_rx_offload_get_configuration_result,
16921 rx_offload, "rx_offload");
16922 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16923 TOKEN_STRING_INITIALIZER
16924 (struct cmd_rx_offload_get_configuration_result,
16925 configuration, "configuration");
16928 cmd_rx_offload_get_configuration_parsed(
16929 void *parsed_result,
16930 __attribute__((unused)) struct cmdline *cl,
16931 __attribute__((unused)) void *data)
16933 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16934 struct rte_eth_dev_info dev_info;
16935 portid_t port_id = res->port_id;
16936 struct rte_port *port = &ports[port_id];
16937 uint64_t port_offloads;
16938 uint64_t queue_offloads;
16939 uint16_t nb_rx_queues;
16942 printf("Rx Offloading Configuration of port %d :\n", port_id);
16944 port_offloads = port->dev_conf.rxmode.offloads;
16946 print_rx_offloads(port_offloads);
16949 rte_eth_dev_info_get(port_id, &dev_info);
16950 nb_rx_queues = dev_info.nb_rx_queues;
16951 for (q = 0; q < nb_rx_queues; q++) {
16952 queue_offloads = port->rx_conf[q].offloads;
16953 printf(" Queue[%2d] :", q);
16954 print_rx_offloads(queue_offloads);
16960 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16961 .f = cmd_rx_offload_get_configuration_parsed,
16963 .help_str = "show port <port_id> rx_offload configuration",
16965 (void *)&cmd_rx_offload_get_configuration_show,
16966 (void *)&cmd_rx_offload_get_configuration_port,
16967 (void *)&cmd_rx_offload_get_configuration_port_id,
16968 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16969 (void *)&cmd_rx_offload_get_configuration_configuration,
16974 /* Enable/Disable a per port offloading */
16975 struct cmd_config_per_port_rx_offload_result {
16976 cmdline_fixed_string_t port;
16977 cmdline_fixed_string_t config;
16979 cmdline_fixed_string_t rx_offload;
16980 cmdline_fixed_string_t offload;
16981 cmdline_fixed_string_t on_off;
16984 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16985 TOKEN_STRING_INITIALIZER
16986 (struct cmd_config_per_port_rx_offload_result,
16988 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16989 TOKEN_STRING_INITIALIZER
16990 (struct cmd_config_per_port_rx_offload_result,
16992 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16993 TOKEN_NUM_INITIALIZER
16994 (struct cmd_config_per_port_rx_offload_result,
16996 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16997 TOKEN_STRING_INITIALIZER
16998 (struct cmd_config_per_port_rx_offload_result,
16999 rx_offload, "rx_offload");
17000 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17001 TOKEN_STRING_INITIALIZER
17002 (struct cmd_config_per_port_rx_offload_result,
17003 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17004 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17005 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17006 "crc_strip#scatter#timestamp#security");
17007 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17008 TOKEN_STRING_INITIALIZER
17009 (struct cmd_config_per_port_rx_offload_result,
17013 search_rx_offload(const char *name)
17015 uint64_t single_offload;
17016 const char *single_name;
17020 single_offload = 1;
17021 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17022 single_name = rte_eth_dev_rx_offload_name(single_offload);
17023 if (!strcasecmp(single_name, name)) {
17026 } else if (!strcasecmp(single_name, "UNKNOWN"))
17028 else if (single_name == NULL)
17030 single_offload <<= 1;
17034 return single_offload;
17040 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17041 __attribute__((unused)) struct cmdline *cl,
17042 __attribute__((unused)) void *data)
17044 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17045 portid_t port_id = res->port_id;
17046 struct rte_eth_dev_info dev_info;
17047 struct rte_port *port = &ports[port_id];
17048 uint64_t single_offload;
17049 uint16_t nb_rx_queues;
17052 if (port->port_status != RTE_PORT_STOPPED) {
17053 printf("Error: Can't config offload when Port %d "
17054 "is not stopped\n", port_id);
17058 single_offload = search_rx_offload(res->offload);
17059 if (single_offload == 0) {
17060 printf("Unknown offload name: %s\n", res->offload);
17064 rte_eth_dev_info_get(port_id, &dev_info);
17065 nb_rx_queues = dev_info.nb_rx_queues;
17066 if (!strcmp(res->on_off, "on")) {
17067 port->dev_conf.rxmode.offloads |= single_offload;
17068 for (q = 0; q < nb_rx_queues; q++)
17069 port->rx_conf[q].offloads |= single_offload;
17071 port->dev_conf.rxmode.offloads &= ~single_offload;
17072 for (q = 0; q < nb_rx_queues; q++)
17073 port->rx_conf[q].offloads &= ~single_offload;
17076 cmd_reconfig_device_queue(port_id, 1, 1);
17079 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17080 .f = cmd_config_per_port_rx_offload_parsed,
17082 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17083 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17084 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17085 "jumbo_frame|crc_strip|scatter|timestamp|security "
17088 (void *)&cmd_config_per_port_rx_offload_result_port,
17089 (void *)&cmd_config_per_port_rx_offload_result_config,
17090 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17091 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17092 (void *)&cmd_config_per_port_rx_offload_result_offload,
17093 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17098 /* Enable/Disable a per queue offloading */
17099 struct cmd_config_per_queue_rx_offload_result {
17100 cmdline_fixed_string_t port;
17102 cmdline_fixed_string_t rxq;
17104 cmdline_fixed_string_t rx_offload;
17105 cmdline_fixed_string_t offload;
17106 cmdline_fixed_string_t on_off;
17109 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17110 TOKEN_STRING_INITIALIZER
17111 (struct cmd_config_per_queue_rx_offload_result,
17113 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17114 TOKEN_NUM_INITIALIZER
17115 (struct cmd_config_per_queue_rx_offload_result,
17117 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17118 TOKEN_STRING_INITIALIZER
17119 (struct cmd_config_per_queue_rx_offload_result,
17121 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17122 TOKEN_NUM_INITIALIZER
17123 (struct cmd_config_per_queue_rx_offload_result,
17125 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17126 TOKEN_STRING_INITIALIZER
17127 (struct cmd_config_per_queue_rx_offload_result,
17128 rx_offload, "rx_offload");
17129 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17130 TOKEN_STRING_INITIALIZER
17131 (struct cmd_config_per_queue_rx_offload_result,
17132 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17133 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17134 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17135 "crc_strip#scatter#timestamp#security");
17136 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17137 TOKEN_STRING_INITIALIZER
17138 (struct cmd_config_per_queue_rx_offload_result,
17142 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17143 __attribute__((unused)) struct cmdline *cl,
17144 __attribute__((unused)) void *data)
17146 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17147 struct rte_eth_dev_info dev_info;
17148 portid_t port_id = res->port_id;
17149 uint16_t queue_id = res->queue_id;
17150 struct rte_port *port = &ports[port_id];
17151 uint64_t single_offload;
17153 if (port->port_status != RTE_PORT_STOPPED) {
17154 printf("Error: Can't config offload when Port %d "
17155 "is not stopped\n", port_id);
17159 rte_eth_dev_info_get(port_id, &dev_info);
17160 if (queue_id >= dev_info.nb_rx_queues) {
17161 printf("Error: input queue_id should be 0 ... "
17162 "%d\n", dev_info.nb_rx_queues - 1);
17166 single_offload = search_rx_offload(res->offload);
17167 if (single_offload == 0) {
17168 printf("Unknown offload name: %s\n", res->offload);
17172 if (!strcmp(res->on_off, "on"))
17173 port->rx_conf[queue_id].offloads |= single_offload;
17175 port->rx_conf[queue_id].offloads &= ~single_offload;
17177 cmd_reconfig_device_queue(port_id, 1, 1);
17180 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17181 .f = cmd_config_per_queue_rx_offload_parsed,
17183 .help_str = "port <port_id> rxq <queue_id> rx_offload "
17184 "vlan_strip|ipv4_cksum|"
17185 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17186 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17187 "jumbo_frame|crc_strip|scatter|timestamp|security "
17190 (void *)&cmd_config_per_queue_rx_offload_result_port,
17191 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
17192 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
17193 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
17194 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
17195 (void *)&cmd_config_per_queue_rx_offload_result_offload,
17196 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
17201 /* Get Tx offloads capabilities */
17202 struct cmd_tx_offload_get_capa_result {
17203 cmdline_fixed_string_t show;
17204 cmdline_fixed_string_t port;
17206 cmdline_fixed_string_t tx_offload;
17207 cmdline_fixed_string_t capabilities;
17210 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17211 TOKEN_STRING_INITIALIZER
17212 (struct cmd_tx_offload_get_capa_result,
17214 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17215 TOKEN_STRING_INITIALIZER
17216 (struct cmd_tx_offload_get_capa_result,
17218 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
17219 TOKEN_NUM_INITIALIZER
17220 (struct cmd_tx_offload_get_capa_result,
17222 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
17223 TOKEN_STRING_INITIALIZER
17224 (struct cmd_tx_offload_get_capa_result,
17225 tx_offload, "tx_offload");
17226 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
17227 TOKEN_STRING_INITIALIZER
17228 (struct cmd_tx_offload_get_capa_result,
17229 capabilities, "capabilities");
17232 print_tx_offloads(uint64_t offloads)
17234 uint64_t single_offload;
17242 begin = __builtin_ctzll(offloads);
17243 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17245 single_offload = 1 << begin;
17246 for (bit = begin; bit < end; bit++) {
17247 if (offloads & single_offload)
17249 rte_eth_dev_tx_offload_name(single_offload));
17250 single_offload <<= 1;
17255 cmd_tx_offload_get_capa_parsed(
17256 void *parsed_result,
17257 __attribute__((unused)) struct cmdline *cl,
17258 __attribute__((unused)) void *data)
17260 struct cmd_tx_offload_get_capa_result *res = parsed_result;
17261 struct rte_eth_dev_info dev_info;
17262 portid_t port_id = res->port_id;
17263 uint64_t queue_offloads;
17264 uint64_t port_offloads;
17266 rte_eth_dev_info_get(port_id, &dev_info);
17267 queue_offloads = dev_info.tx_queue_offload_capa;
17268 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
17270 printf("Tx Offloading Capabilities of port %d :\n", port_id);
17271 printf(" Per Queue :");
17272 print_tx_offloads(queue_offloads);
17275 printf(" Per Port :");
17276 print_tx_offloads(port_offloads);
17280 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
17281 .f = cmd_tx_offload_get_capa_parsed,
17283 .help_str = "show port <port_id> tx_offload capabilities",
17285 (void *)&cmd_tx_offload_get_capa_show,
17286 (void *)&cmd_tx_offload_get_capa_port,
17287 (void *)&cmd_tx_offload_get_capa_port_id,
17288 (void *)&cmd_tx_offload_get_capa_tx_offload,
17289 (void *)&cmd_tx_offload_get_capa_capabilities,
17294 /* Get Tx offloads configuration */
17295 struct cmd_tx_offload_get_configuration_result {
17296 cmdline_fixed_string_t show;
17297 cmdline_fixed_string_t port;
17299 cmdline_fixed_string_t tx_offload;
17300 cmdline_fixed_string_t configuration;
17303 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
17304 TOKEN_STRING_INITIALIZER
17305 (struct cmd_tx_offload_get_configuration_result,
17307 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
17308 TOKEN_STRING_INITIALIZER
17309 (struct cmd_tx_offload_get_configuration_result,
17311 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
17312 TOKEN_NUM_INITIALIZER
17313 (struct cmd_tx_offload_get_configuration_result,
17315 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
17316 TOKEN_STRING_INITIALIZER
17317 (struct cmd_tx_offload_get_configuration_result,
17318 tx_offload, "tx_offload");
17319 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
17320 TOKEN_STRING_INITIALIZER
17321 (struct cmd_tx_offload_get_configuration_result,
17322 configuration, "configuration");
17325 cmd_tx_offload_get_configuration_parsed(
17326 void *parsed_result,
17327 __attribute__((unused)) struct cmdline *cl,
17328 __attribute__((unused)) void *data)
17330 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
17331 struct rte_eth_dev_info dev_info;
17332 portid_t port_id = res->port_id;
17333 struct rte_port *port = &ports[port_id];
17334 uint64_t port_offloads;
17335 uint64_t queue_offloads;
17336 uint16_t nb_tx_queues;
17339 printf("Tx Offloading Configuration of port %d :\n", port_id);
17341 port_offloads = port->dev_conf.txmode.offloads;
17343 print_tx_offloads(port_offloads);
17346 rte_eth_dev_info_get(port_id, &dev_info);
17347 nb_tx_queues = dev_info.nb_tx_queues;
17348 for (q = 0; q < nb_tx_queues; q++) {
17349 queue_offloads = port->tx_conf[q].offloads;
17350 printf(" Queue[%2d] :", q);
17351 print_tx_offloads(queue_offloads);
17357 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17358 .f = cmd_tx_offload_get_configuration_parsed,
17360 .help_str = "show port <port_id> tx_offload configuration",
17362 (void *)&cmd_tx_offload_get_configuration_show,
17363 (void *)&cmd_tx_offload_get_configuration_port,
17364 (void *)&cmd_tx_offload_get_configuration_port_id,
17365 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17366 (void *)&cmd_tx_offload_get_configuration_configuration,
17371 /* Enable/Disable a per port offloading */
17372 struct cmd_config_per_port_tx_offload_result {
17373 cmdline_fixed_string_t port;
17374 cmdline_fixed_string_t config;
17376 cmdline_fixed_string_t tx_offload;
17377 cmdline_fixed_string_t offload;
17378 cmdline_fixed_string_t on_off;
17381 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17382 TOKEN_STRING_INITIALIZER
17383 (struct cmd_config_per_port_tx_offload_result,
17385 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17386 TOKEN_STRING_INITIALIZER
17387 (struct cmd_config_per_port_tx_offload_result,
17389 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17390 TOKEN_NUM_INITIALIZER
17391 (struct cmd_config_per_port_tx_offload_result,
17393 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17394 TOKEN_STRING_INITIALIZER
17395 (struct cmd_config_per_port_tx_offload_result,
17396 tx_offload, "tx_offload");
17397 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17398 TOKEN_STRING_INITIALIZER
17399 (struct cmd_config_per_port_tx_offload_result,
17400 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17401 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17402 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17403 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17404 "mt_lockfree#multi_segs#fast_free#security");
17405 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17406 TOKEN_STRING_INITIALIZER
17407 (struct cmd_config_per_port_tx_offload_result,
17411 search_tx_offload(const char *name)
17413 uint64_t single_offload;
17414 const char *single_name;
17418 single_offload = 1;
17419 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17420 single_name = rte_eth_dev_tx_offload_name(single_offload);
17421 if (!strcasecmp(single_name, name)) {
17424 } else if (!strcasecmp(single_name, "UNKNOWN"))
17426 else if (single_name == NULL)
17428 single_offload <<= 1;
17432 return single_offload;
17438 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17439 __attribute__((unused)) struct cmdline *cl,
17440 __attribute__((unused)) void *data)
17442 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17443 portid_t port_id = res->port_id;
17444 struct rte_eth_dev_info dev_info;
17445 struct rte_port *port = &ports[port_id];
17446 uint64_t single_offload;
17447 uint16_t nb_tx_queues;
17450 if (port->port_status != RTE_PORT_STOPPED) {
17451 printf("Error: Can't config offload when Port %d "
17452 "is not stopped\n", port_id);
17456 single_offload = search_tx_offload(res->offload);
17457 if (single_offload == 0) {
17458 printf("Unknown offload name: %s\n", res->offload);
17462 rte_eth_dev_info_get(port_id, &dev_info);
17463 nb_tx_queues = dev_info.nb_tx_queues;
17464 if (!strcmp(res->on_off, "on")) {
17465 port->dev_conf.txmode.offloads |= single_offload;
17466 for (q = 0; q < nb_tx_queues; q++)
17467 port->tx_conf[q].offloads |= single_offload;
17469 port->dev_conf.txmode.offloads &= ~single_offload;
17470 for (q = 0; q < nb_tx_queues; q++)
17471 port->tx_conf[q].offloads &= ~single_offload;
17474 cmd_reconfig_device_queue(port_id, 1, 1);
17477 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17478 .f = cmd_config_per_port_tx_offload_parsed,
17480 .help_str = "port config <port_id> tx_offload "
17481 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17482 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17483 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17484 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17485 "mt_lockfree|multi_segs|fast_free|security "
17488 (void *)&cmd_config_per_port_tx_offload_result_port,
17489 (void *)&cmd_config_per_port_tx_offload_result_config,
17490 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17491 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17492 (void *)&cmd_config_per_port_tx_offload_result_offload,
17493 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17498 /* Enable/Disable a per queue offloading */
17499 struct cmd_config_per_queue_tx_offload_result {
17500 cmdline_fixed_string_t port;
17502 cmdline_fixed_string_t txq;
17504 cmdline_fixed_string_t tx_offload;
17505 cmdline_fixed_string_t offload;
17506 cmdline_fixed_string_t on_off;
17509 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17510 TOKEN_STRING_INITIALIZER
17511 (struct cmd_config_per_queue_tx_offload_result,
17513 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17514 TOKEN_NUM_INITIALIZER
17515 (struct cmd_config_per_queue_tx_offload_result,
17517 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17518 TOKEN_STRING_INITIALIZER
17519 (struct cmd_config_per_queue_tx_offload_result,
17521 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17522 TOKEN_NUM_INITIALIZER
17523 (struct cmd_config_per_queue_tx_offload_result,
17525 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17526 TOKEN_STRING_INITIALIZER
17527 (struct cmd_config_per_queue_tx_offload_result,
17528 tx_offload, "tx_offload");
17529 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17530 TOKEN_STRING_INITIALIZER
17531 (struct cmd_config_per_queue_tx_offload_result,
17532 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17533 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17534 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17535 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17536 "mt_lockfree#multi_segs#fast_free#security");
17537 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17538 TOKEN_STRING_INITIALIZER
17539 (struct cmd_config_per_queue_tx_offload_result,
17543 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17544 __attribute__((unused)) struct cmdline *cl,
17545 __attribute__((unused)) void *data)
17547 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17548 struct rte_eth_dev_info dev_info;
17549 portid_t port_id = res->port_id;
17550 uint16_t queue_id = res->queue_id;
17551 struct rte_port *port = &ports[port_id];
17552 uint64_t single_offload;
17554 if (port->port_status != RTE_PORT_STOPPED) {
17555 printf("Error: Can't config offload when Port %d "
17556 "is not stopped\n", port_id);
17560 rte_eth_dev_info_get(port_id, &dev_info);
17561 if (queue_id >= dev_info.nb_tx_queues) {
17562 printf("Error: input queue_id should be 0 ... "
17563 "%d\n", dev_info.nb_tx_queues - 1);
17567 single_offload = search_tx_offload(res->offload);
17568 if (single_offload == 0) {
17569 printf("Unknown offload name: %s\n", res->offload);
17573 if (!strcmp(res->on_off, "on"))
17574 port->tx_conf[queue_id].offloads |= single_offload;
17576 port->tx_conf[queue_id].offloads &= ~single_offload;
17578 cmd_reconfig_device_queue(port_id, 1, 1);
17581 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17582 .f = cmd_config_per_queue_tx_offload_parsed,
17584 .help_str = "port <port_id> txq <queue_id> tx_offload "
17585 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17586 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17587 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17588 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17589 "mt_lockfree|multi_segs|fast_free|security "
17592 (void *)&cmd_config_per_queue_tx_offload_result_port,
17593 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17594 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17595 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17596 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17597 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17598 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17603 /* ******************************************************************************** */
17605 /* list of instructions */
17606 cmdline_parse_ctx_t main_ctx[] = {
17607 (cmdline_parse_inst_t *)&cmd_help_brief,
17608 (cmdline_parse_inst_t *)&cmd_help_long,
17609 (cmdline_parse_inst_t *)&cmd_quit,
17610 (cmdline_parse_inst_t *)&cmd_load_from_file,
17611 (cmdline_parse_inst_t *)&cmd_showport,
17612 (cmdline_parse_inst_t *)&cmd_showqueue,
17613 (cmdline_parse_inst_t *)&cmd_showportall,
17614 (cmdline_parse_inst_t *)&cmd_showcfg,
17615 (cmdline_parse_inst_t *)&cmd_start,
17616 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17617 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17618 (cmdline_parse_inst_t *)&cmd_set_link_up,
17619 (cmdline_parse_inst_t *)&cmd_set_link_down,
17620 (cmdline_parse_inst_t *)&cmd_reset,
17621 (cmdline_parse_inst_t *)&cmd_set_numbers,
17622 (cmdline_parse_inst_t *)&cmd_set_log,
17623 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17624 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17625 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17626 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17627 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17628 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17629 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17630 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17631 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17632 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17633 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17634 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17635 (cmdline_parse_inst_t *)&cmd_set_link_check,
17636 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17637 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17638 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17639 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17640 #ifdef RTE_LIBRTE_PMD_BOND
17641 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17642 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17643 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17644 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17645 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17646 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17647 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17648 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17649 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17650 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17651 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17653 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17654 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17655 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17656 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17657 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17658 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17659 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17660 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17661 (cmdline_parse_inst_t *)&cmd_csum_set,
17662 (cmdline_parse_inst_t *)&cmd_csum_show,
17663 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17664 (cmdline_parse_inst_t *)&cmd_tso_set,
17665 (cmdline_parse_inst_t *)&cmd_tso_show,
17666 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17667 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17668 (cmdline_parse_inst_t *)&cmd_gro_enable,
17669 (cmdline_parse_inst_t *)&cmd_gro_flush,
17670 (cmdline_parse_inst_t *)&cmd_gro_show,
17671 (cmdline_parse_inst_t *)&cmd_gso_enable,
17672 (cmdline_parse_inst_t *)&cmd_gso_size,
17673 (cmdline_parse_inst_t *)&cmd_gso_show,
17674 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17675 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17676 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17677 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17678 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17679 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17680 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17681 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17682 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17683 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17684 (cmdline_parse_inst_t *)&cmd_config_dcb,
17685 (cmdline_parse_inst_t *)&cmd_read_reg,
17686 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17687 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17688 (cmdline_parse_inst_t *)&cmd_write_reg,
17689 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17690 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17691 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17692 (cmdline_parse_inst_t *)&cmd_stop,
17693 (cmdline_parse_inst_t *)&cmd_mac_addr,
17694 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17695 (cmdline_parse_inst_t *)&cmd_set_qmap,
17696 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17697 (cmdline_parse_inst_t *)&cmd_operate_port,
17698 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17699 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17700 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17701 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17702 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17703 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17704 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17705 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17706 (cmdline_parse_inst_t *)&cmd_config_mtu,
17707 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17708 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17709 (cmdline_parse_inst_t *)&cmd_config_rss,
17710 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17711 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17712 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17713 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17714 (cmdline_parse_inst_t *)&cmd_showport_reta,
17715 (cmdline_parse_inst_t *)&cmd_config_burst,
17716 (cmdline_parse_inst_t *)&cmd_config_thresh,
17717 (cmdline_parse_inst_t *)&cmd_config_threshold,
17718 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17719 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17720 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17721 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
17722 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17723 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
17724 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17725 (cmdline_parse_inst_t *)&cmd_global_config,
17726 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17727 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17728 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17729 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17730 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17731 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17732 (cmdline_parse_inst_t *)&cmd_dump,
17733 (cmdline_parse_inst_t *)&cmd_dump_one,
17734 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
17735 (cmdline_parse_inst_t *)&cmd_syn_filter,
17736 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
17737 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
17738 (cmdline_parse_inst_t *)&cmd_flex_filter,
17739 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
17740 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
17741 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
17742 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
17743 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
17744 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
17745 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17746 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
17747 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17748 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17749 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17750 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
17751 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17752 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
17753 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
17754 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
17755 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
17756 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
17757 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
17758 (cmdline_parse_inst_t *)&cmd_flow,
17759 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17760 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17761 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17762 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17763 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17764 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17765 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17766 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17767 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17768 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17769 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17770 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17771 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17772 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17773 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
17774 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
17775 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
17776 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
17777 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
17778 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
17779 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
17780 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
17781 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
17782 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
17783 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17784 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17785 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17786 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17787 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17788 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17789 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17790 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17791 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17792 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17793 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17794 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17795 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17796 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17797 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17798 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17799 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17800 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17801 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17802 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17803 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17804 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17805 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17806 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17807 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17808 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
17809 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
17811 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17812 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17813 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17814 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17815 (cmdline_parse_inst_t *)&cmd_ddp_add,
17816 (cmdline_parse_inst_t *)&cmd_ddp_del,
17817 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17818 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17819 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17820 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17821 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17822 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17823 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17824 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17825 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17826 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17828 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17829 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17830 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17831 (cmdline_parse_inst_t *)&cmd_queue_region,
17832 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17833 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17834 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17835 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17836 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17837 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17838 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17839 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17840 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17841 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17842 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17843 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17844 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17845 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17846 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17847 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17848 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17849 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17850 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17851 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17852 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17853 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17854 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17855 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17856 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17857 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17858 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17859 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17860 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17861 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17862 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17863 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17864 #ifdef RTE_LIBRTE_BPF
17865 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17866 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17871 /* read cmdline commands from file */
17873 cmdline_read_from_file(const char *filename)
17875 struct cmdline *cl;
17877 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17879 printf("Failed to create file based cmdline context: %s\n",
17884 cmdline_interact(cl);
17889 printf("Read CLI commands from %s\n", filename);
17892 /* prompt function, called from main on MASTER lcore */
17896 /* initialize non-constant commands */
17897 cmd_set_fwd_mode_init();
17898 cmd_set_fwd_retry_mode_init();
17900 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17901 if (testpmd_cl == NULL)
17903 cmdline_interact(testpmd_cl);
17904 cmdline_stdin_exit(testpmd_cl);
17910 if (testpmd_cl != NULL)
17911 cmdline_quit(testpmd_cl);
17915 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17917 if (id == (portid_t)RTE_PORT_ALL) {
17920 RTE_ETH_FOREACH_DEV(pid) {
17921 /* check if need_reconfig has been set to 1 */
17922 if (ports[pid].need_reconfig == 0)
17923 ports[pid].need_reconfig = dev;
17924 /* check if need_reconfig_queues has been set to 1 */
17925 if (ports[pid].need_reconfig_queues == 0)
17926 ports[pid].need_reconfig_queues = queue;
17928 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17929 /* check if need_reconfig has been set to 1 */
17930 if (ports[id].need_reconfig == 0)
17931 ports[id].need_reconfig = dev;
17932 /* check if need_reconfig_queues has been set to 1 */
17933 if (ports[id].need_reconfig_queues == 0)
17934 ports[id].need_reconfig_queues = queue;