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 , list_pkt_forwarding_modes()
788 if (show_all || !strcmp(res->section, "ports")) {
794 "----------------\n\n"
796 "port start (port_id|all)\n"
797 " Start all ports or port_id.\n\n"
799 "port stop (port_id|all)\n"
800 " Stop all ports or port_id.\n\n"
802 "port close (port_id|all)\n"
803 " Close all ports or port_id.\n\n"
805 "port attach (ident)\n"
806 " Attach physical or virtual dev by pci address or virtual device name\n\n"
808 "port detach (port_id)\n"
809 " Detach physical or virtual dev by port_id\n\n"
811 "port config (port_id|all)"
812 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
813 " duplex (half|full|auto)\n"
814 " Set speed and duplex for all ports or port_id\n\n"
816 "port config (port_id|all) loopback (mode)\n"
817 " Set loopback mode for all ports or port_id\n\n"
819 "port config all (rxq|txq|rxd|txd) (value)\n"
820 " Set number for rxq/txq/rxd/txd.\n\n"
822 "port config all max-pkt-len (value)\n"
823 " Set the max packet length.\n\n"
825 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
826 "hw-vlan-strip|hw-vlan-extend|drop-en)"
828 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
831 "port config all rss (all|default|ip|tcp|udp|sctp|"
832 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
833 " Set the RSS mode.\n\n"
835 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
836 " Set the RSS redirection table.\n\n"
838 "port config (port_id) dcb vt (on|off) (traffic_class)"
840 " Set the DCB mode.\n\n"
842 "port config all burst (value)\n"
843 " Set the number of packets per burst.\n\n"
845 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
847 " Set the ring prefetch/host/writeback threshold"
848 " for tx/rx queue.\n\n"
850 "port config all (txfreet|txrst|rxfreet) (value)\n"
851 " Set free threshold for rx/tx, or set"
852 " tx rs bit threshold.\n\n"
853 "port config mtu X value\n"
854 " Set the MTU of port X to a given value\n\n"
856 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
857 " Set a rx/tx queue's ring size configuration, the new"
858 " value will take effect after command that (re-)start the port"
859 " or command that setup the specific queue\n\n"
861 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
862 " Start/stop a rx/tx queue of port X. Only take effect"
863 " when port X is started\n\n"
865 "port (port_id) (rxq|txq) (queue_id) setup\n"
866 " Setup a rx/tx queue of port X.\n\n"
868 "port config (port_id|all) l2-tunnel E-tag ether-type"
870 " Set the value of E-tag ether-type.\n\n"
872 "port config (port_id|all) l2-tunnel E-tag"
873 " (enable|disable)\n"
874 " Enable/disable the E-tag support.\n\n"
876 "port config (port_id) pctype mapping reset\n"
877 " Reset flow type to pctype mapping on a port\n\n"
879 "port config (port_id) pctype mapping update"
880 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
881 " Update a flow type to pctype mapping item on a port\n\n"
883 "port config (port_id) pctype (pctype_id) hash_inset|"
884 "fdir_inset|fdir_flx_inset get|set|clear field\n"
886 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
888 "port config (port_id) pctype (pctype_id) hash_inset|"
889 "fdir_inset|fdir_flx_inset clear all"
890 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
892 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
893 " Add/remove UDP tunnel port for tunneling offload\n\n"
897 if (show_all || !strcmp(res->section, "registers")) {
905 "read reg (port_id) (address)\n"
906 " Display value of a port register.\n\n"
908 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
909 " Display a port register bit field.\n\n"
911 "read regbit (port_id) (address) (bit_x)\n"
912 " Display a single port register bit.\n\n"
914 "write reg (port_id) (address) (value)\n"
915 " Set value of a port register.\n\n"
917 "write regfield (port_id) (address) (bit_x) (bit_y)"
919 " Set bit field of a port register.\n\n"
921 "write regbit (port_id) (address) (bit_x) (value)\n"
922 " Set single bit value of a port register.\n\n"
925 if (show_all || !strcmp(res->section, "filters")) {
933 "ethertype_filter (port_id) (add|del)"
934 " (mac_addr|mac_ignr) (mac_address) ethertype"
935 " (ether_type) (drop|fwd) queue (queue_id)\n"
936 " Add/Del an ethertype filter.\n\n"
938 "2tuple_filter (port_id) (add|del)"
939 " dst_port (dst_port_value) protocol (protocol_value)"
940 " mask (mask_value) tcp_flags (tcp_flags_value)"
941 " priority (prio_value) queue (queue_id)\n"
942 " Add/Del a 2tuple filter.\n\n"
944 "5tuple_filter (port_id) (add|del)"
945 " dst_ip (dst_address) src_ip (src_address)"
946 " dst_port (dst_port_value) src_port (src_port_value)"
947 " protocol (protocol_value)"
948 " mask (mask_value) tcp_flags (tcp_flags_value)"
949 " priority (prio_value) queue (queue_id)\n"
950 " Add/Del a 5tuple filter.\n\n"
952 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
953 " Add/Del syn filter.\n\n"
955 "flex_filter (port_id) (add|del) len (len_value)"
956 " bytes (bytes_value) mask (mask_value)"
957 " priority (prio_value) queue (queue_id)\n"
958 " Add/Del a flex filter.\n\n"
960 "flow_director_filter (port_id) mode IP (add|del|update)"
961 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
962 " src (src_ip_address) dst (dst_ip_address)"
963 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
964 " vlan (vlan_value) flexbytes (flexbytes_value)"
965 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
966 " fd_id (fd_id_value)\n"
967 " Add/Del an IP type flow director filter.\n\n"
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
971 " src (src_ip_address) (src_port)"
972 " dst (dst_ip_address) (dst_port)"
973 " tos (tos_value) ttl (ttl_value)"
974 " vlan (vlan_value) flexbytes (flexbytes_value)"
975 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
976 " fd_id (fd_id_value)\n"
977 " Add/Del an UDP/TCP type flow director filter.\n\n"
979 "flow_director_filter (port_id) mode IP (add|del|update)"
980 " flow (ipv4-sctp|ipv6-sctp)"
981 " src (src_ip_address) (src_port)"
982 " dst (dst_ip_address) (dst_port)"
983 " tag (verification_tag) "
984 " tos (tos_value) ttl (ttl_value)"
986 " flexbytes (flexbytes_value) (drop|fwd)"
987 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
988 " Add/Del a SCTP type flow director filter.\n\n"
990 "flow_director_filter (port_id) mode IP (add|del|update)"
991 " flow l2_payload ether (ethertype)"
992 " flexbytes (flexbytes_value) (drop|fwd)"
993 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
994 " Add/Del a l2 payload type flow director filter.\n\n"
996 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
997 " mac (mac_address) vlan (vlan_value)"
998 " flexbytes (flexbytes_value) (drop|fwd)"
999 " queue (queue_id) fd_id (fd_id_value)\n"
1000 " Add/Del a MAC-VLAN flow director filter.\n\n"
1002 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1003 " mac (mac_address) vlan (vlan_value)"
1004 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1005 " flexbytes (flexbytes_value) (drop|fwd)"
1006 " queue (queue_id) fd_id (fd_id_value)\n"
1007 " Add/Del a Tunnel flow director filter.\n\n"
1009 "flow_director_filter (port_id) mode raw (add|del|update)"
1010 " flow (flow_id) (drop|fwd) queue (queue_id)"
1011 " fd_id (fd_id_value) packet (packet file name)\n"
1012 " Add/Del a raw type flow director filter.\n\n"
1014 "flush_flow_director (port_id)\n"
1015 " Flush all flow director entries of a device.\n\n"
1017 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1018 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1019 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1020 " Set flow director IP mask.\n\n"
1022 "flow_director_mask (port_id) mode MAC-VLAN"
1023 " vlan (vlan_value)\n"
1024 " Set flow director MAC-VLAN mask.\n\n"
1026 "flow_director_mask (port_id) mode Tunnel"
1027 " vlan (vlan_value) mac (mac_value)"
1028 " tunnel-type (tunnel_type_value)"
1029 " tunnel-id (tunnel_id_value)\n"
1030 " Set flow director Tunnel mask.\n\n"
1032 "flow_director_flex_mask (port_id)"
1033 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1034 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1036 " Configure mask of flex payload.\n\n"
1038 "flow_director_flex_payload (port_id)"
1039 " (raw|l2|l3|l4) (config)\n"
1040 " Configure flex payload selection.\n\n"
1042 "get_sym_hash_ena_per_port (port_id)\n"
1043 " get symmetric hash enable configuration per port.\n\n"
1045 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1046 " set symmetric hash enable configuration per port"
1047 " to enable or disable.\n\n"
1049 "get_hash_global_config (port_id)\n"
1050 " Get the global configurations of hash filters.\n\n"
1052 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1053 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1054 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1055 " (enable|disable)\n"
1056 " Set the global configurations of hash filters.\n\n"
1058 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1059 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1060 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1061 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1062 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1063 "ipv6-next-header|udp-src-port|udp-dst-port|"
1064 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1065 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1066 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1067 "fld-8th|none) (select|add)\n"
1068 " Set the input set for hash.\n\n"
1070 "set_fdir_input_set (port_id) "
1071 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1072 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1073 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1074 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1075 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1076 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1077 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1079 " Set the input set for FDir.\n\n"
1081 "flow validate {port_id}"
1082 " [group {group_id}] [priority {level}]"
1083 " [ingress] [egress]"
1084 " pattern {item} [/ {item} [...]] / end"
1085 " actions {action} [/ {action} [...]] / end\n"
1086 " Check whether a flow rule can be created.\n\n"
1088 "flow create {port_id}"
1089 " [group {group_id}] [priority {level}]"
1090 " [ingress] [egress]"
1091 " pattern {item} [/ {item} [...]] / end"
1092 " actions {action} [/ {action} [...]] / end\n"
1093 " Create a flow rule.\n\n"
1095 "flow destroy {port_id} rule {rule_id} [...]\n"
1096 " Destroy specific flow rules.\n\n"
1098 "flow flush {port_id}\n"
1099 " Destroy all flow rules.\n\n"
1101 "flow query {port_id} {rule_id} {action}\n"
1102 " Query an existing flow rule.\n\n"
1104 "flow list {port_id} [group {group_id}] [...]\n"
1105 " List existing flow rules sorted by priority,"
1106 " filtered by group identifiers.\n\n"
1108 "flow isolate {port_id} {boolean}\n"
1109 " Restrict ingress traffic to the defined"
1115 cmdline_parse_token_string_t cmd_help_long_help =
1116 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1118 cmdline_parse_token_string_t cmd_help_long_section =
1119 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1120 "all#control#display#config#"
1121 "ports#registers#filters");
1123 cmdline_parse_inst_t cmd_help_long = {
1124 .f = cmd_help_long_parsed,
1126 .help_str = "help all|control|display|config|ports|register|filters: "
1129 (void *)&cmd_help_long_help,
1130 (void *)&cmd_help_long_section,
1136 /* *** start/stop/close all ports *** */
1137 struct cmd_operate_port_result {
1138 cmdline_fixed_string_t keyword;
1139 cmdline_fixed_string_t name;
1140 cmdline_fixed_string_t value;
1143 static void cmd_operate_port_parsed(void *parsed_result,
1144 __attribute__((unused)) struct cmdline *cl,
1145 __attribute__((unused)) void *data)
1147 struct cmd_operate_port_result *res = parsed_result;
1149 if (!strcmp(res->name, "start"))
1150 start_port(RTE_PORT_ALL);
1151 else if (!strcmp(res->name, "stop"))
1152 stop_port(RTE_PORT_ALL);
1153 else if (!strcmp(res->name, "close"))
1154 close_port(RTE_PORT_ALL);
1155 else if (!strcmp(res->name, "reset"))
1156 reset_port(RTE_PORT_ALL);
1158 printf("Unknown parameter\n");
1161 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1162 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1164 cmdline_parse_token_string_t cmd_operate_port_all_port =
1165 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1166 "start#stop#close#reset");
1167 cmdline_parse_token_string_t cmd_operate_port_all_all =
1168 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1170 cmdline_parse_inst_t cmd_operate_port = {
1171 .f = cmd_operate_port_parsed,
1173 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1175 (void *)&cmd_operate_port_all_cmd,
1176 (void *)&cmd_operate_port_all_port,
1177 (void *)&cmd_operate_port_all_all,
1182 /* *** start/stop/close specific port *** */
1183 struct cmd_operate_specific_port_result {
1184 cmdline_fixed_string_t keyword;
1185 cmdline_fixed_string_t name;
1189 static void cmd_operate_specific_port_parsed(void *parsed_result,
1190 __attribute__((unused)) struct cmdline *cl,
1191 __attribute__((unused)) void *data)
1193 struct cmd_operate_specific_port_result *res = parsed_result;
1195 if (!strcmp(res->name, "start"))
1196 start_port(res->value);
1197 else if (!strcmp(res->name, "stop"))
1198 stop_port(res->value);
1199 else if (!strcmp(res->name, "close"))
1200 close_port(res->value);
1201 else if (!strcmp(res->name, "reset"))
1202 reset_port(res->value);
1204 printf("Unknown parameter\n");
1207 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1208 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1210 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1211 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1212 name, "start#stop#close#reset");
1213 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1214 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1217 cmdline_parse_inst_t cmd_operate_specific_port = {
1218 .f = cmd_operate_specific_port_parsed,
1220 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1222 (void *)&cmd_operate_specific_port_cmd,
1223 (void *)&cmd_operate_specific_port_port,
1224 (void *)&cmd_operate_specific_port_id,
1229 /* *** attach a specified port *** */
1230 struct cmd_operate_attach_port_result {
1231 cmdline_fixed_string_t port;
1232 cmdline_fixed_string_t keyword;
1233 cmdline_fixed_string_t identifier;
1236 static void cmd_operate_attach_port_parsed(void *parsed_result,
1237 __attribute__((unused)) struct cmdline *cl,
1238 __attribute__((unused)) void *data)
1240 struct cmd_operate_attach_port_result *res = parsed_result;
1242 if (!strcmp(res->keyword, "attach"))
1243 attach_port(res->identifier);
1245 printf("Unknown parameter\n");
1248 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1249 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1251 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1252 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1254 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1255 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1258 cmdline_parse_inst_t cmd_operate_attach_port = {
1259 .f = cmd_operate_attach_port_parsed,
1261 .help_str = "port attach <identifier>: "
1262 "(identifier: pci address or virtual dev name)",
1264 (void *)&cmd_operate_attach_port_port,
1265 (void *)&cmd_operate_attach_port_keyword,
1266 (void *)&cmd_operate_attach_port_identifier,
1271 /* *** detach a specified port *** */
1272 struct cmd_operate_detach_port_result {
1273 cmdline_fixed_string_t port;
1274 cmdline_fixed_string_t keyword;
1278 static void cmd_operate_detach_port_parsed(void *parsed_result,
1279 __attribute__((unused)) struct cmdline *cl,
1280 __attribute__((unused)) void *data)
1282 struct cmd_operate_detach_port_result *res = parsed_result;
1284 if (!strcmp(res->keyword, "detach"))
1285 detach_port(res->port_id);
1287 printf("Unknown parameter\n");
1290 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1291 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1293 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1294 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1296 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1297 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1300 cmdline_parse_inst_t cmd_operate_detach_port = {
1301 .f = cmd_operate_detach_port_parsed,
1303 .help_str = "port detach <port_id>",
1305 (void *)&cmd_operate_detach_port_port,
1306 (void *)&cmd_operate_detach_port_keyword,
1307 (void *)&cmd_operate_detach_port_port_id,
1312 /* *** configure speed for all ports *** */
1313 struct cmd_config_speed_all {
1314 cmdline_fixed_string_t port;
1315 cmdline_fixed_string_t keyword;
1316 cmdline_fixed_string_t all;
1317 cmdline_fixed_string_t item1;
1318 cmdline_fixed_string_t item2;
1319 cmdline_fixed_string_t value1;
1320 cmdline_fixed_string_t value2;
1324 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1329 if (!strcmp(duplexstr, "half")) {
1330 duplex = ETH_LINK_HALF_DUPLEX;
1331 } else if (!strcmp(duplexstr, "full")) {
1332 duplex = ETH_LINK_FULL_DUPLEX;
1333 } else if (!strcmp(duplexstr, "auto")) {
1334 duplex = ETH_LINK_FULL_DUPLEX;
1336 printf("Unknown duplex parameter\n");
1340 if (!strcmp(speedstr, "10")) {
1341 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1342 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1343 } else if (!strcmp(speedstr, "100")) {
1344 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1345 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1347 if (duplex != ETH_LINK_FULL_DUPLEX) {
1348 printf("Invalid speed/duplex parameters\n");
1351 if (!strcmp(speedstr, "1000")) {
1352 *speed = ETH_LINK_SPEED_1G;
1353 } else if (!strcmp(speedstr, "10000")) {
1354 *speed = ETH_LINK_SPEED_10G;
1355 } else if (!strcmp(speedstr, "25000")) {
1356 *speed = ETH_LINK_SPEED_25G;
1357 } else if (!strcmp(speedstr, "40000")) {
1358 *speed = ETH_LINK_SPEED_40G;
1359 } else if (!strcmp(speedstr, "50000")) {
1360 *speed = ETH_LINK_SPEED_50G;
1361 } else if (!strcmp(speedstr, "100000")) {
1362 *speed = ETH_LINK_SPEED_100G;
1363 } else if (!strcmp(speedstr, "auto")) {
1364 *speed = ETH_LINK_SPEED_AUTONEG;
1366 printf("Unknown speed parameter\n");
1375 cmd_config_speed_all_parsed(void *parsed_result,
1376 __attribute__((unused)) struct cmdline *cl,
1377 __attribute__((unused)) void *data)
1379 struct cmd_config_speed_all *res = parsed_result;
1380 uint32_t link_speed;
1383 if (!all_ports_stopped()) {
1384 printf("Please stop all ports first\n");
1388 if (parse_and_check_speed_duplex(res->value1, res->value2,
1392 RTE_ETH_FOREACH_DEV(pid) {
1393 ports[pid].dev_conf.link_speeds = link_speed;
1396 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1399 cmdline_parse_token_string_t cmd_config_speed_all_port =
1400 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1401 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1404 cmdline_parse_token_string_t cmd_config_speed_all_all =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1406 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1407 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1408 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1409 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1410 "10#100#1000#10000#25000#40000#50000#100000#auto");
1411 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1412 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1413 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1417 cmdline_parse_inst_t cmd_config_speed_all = {
1418 .f = cmd_config_speed_all_parsed,
1420 .help_str = "port config all speed "
1421 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1424 (void *)&cmd_config_speed_all_port,
1425 (void *)&cmd_config_speed_all_keyword,
1426 (void *)&cmd_config_speed_all_all,
1427 (void *)&cmd_config_speed_all_item1,
1428 (void *)&cmd_config_speed_all_value1,
1429 (void *)&cmd_config_speed_all_item2,
1430 (void *)&cmd_config_speed_all_value2,
1435 /* *** configure speed for specific port *** */
1436 struct cmd_config_speed_specific {
1437 cmdline_fixed_string_t port;
1438 cmdline_fixed_string_t keyword;
1440 cmdline_fixed_string_t item1;
1441 cmdline_fixed_string_t item2;
1442 cmdline_fixed_string_t value1;
1443 cmdline_fixed_string_t value2;
1447 cmd_config_speed_specific_parsed(void *parsed_result,
1448 __attribute__((unused)) struct cmdline *cl,
1449 __attribute__((unused)) void *data)
1451 struct cmd_config_speed_specific *res = parsed_result;
1452 uint32_t link_speed;
1454 if (!all_ports_stopped()) {
1455 printf("Please stop all ports first\n");
1459 if (port_id_is_invalid(res->id, ENABLED_WARN))
1462 if (parse_and_check_speed_duplex(res->value1, res->value2,
1466 ports[res->id].dev_conf.link_speeds = link_speed;
1468 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1472 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1473 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1475 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1476 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1478 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1479 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1480 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1483 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1484 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1485 "10#100#1000#10000#25000#40000#50000#100000#auto");
1486 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1487 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1489 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1493 cmdline_parse_inst_t cmd_config_speed_specific = {
1494 .f = cmd_config_speed_specific_parsed,
1496 .help_str = "port config <port_id> speed "
1497 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1500 (void *)&cmd_config_speed_specific_port,
1501 (void *)&cmd_config_speed_specific_keyword,
1502 (void *)&cmd_config_speed_specific_id,
1503 (void *)&cmd_config_speed_specific_item1,
1504 (void *)&cmd_config_speed_specific_value1,
1505 (void *)&cmd_config_speed_specific_item2,
1506 (void *)&cmd_config_speed_specific_value2,
1511 /* *** configure loopback for all ports *** */
1512 struct cmd_config_loopback_all {
1513 cmdline_fixed_string_t port;
1514 cmdline_fixed_string_t keyword;
1515 cmdline_fixed_string_t all;
1516 cmdline_fixed_string_t item;
1521 cmd_config_loopback_all_parsed(void *parsed_result,
1522 __attribute__((unused)) struct cmdline *cl,
1523 __attribute__((unused)) void *data)
1525 struct cmd_config_loopback_all *res = parsed_result;
1528 if (!all_ports_stopped()) {
1529 printf("Please stop all ports first\n");
1533 RTE_ETH_FOREACH_DEV(pid) {
1534 ports[pid].dev_conf.lpbk_mode = res->mode;
1537 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1540 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1541 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1542 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1543 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1545 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1546 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1547 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1548 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1550 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1551 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1553 cmdline_parse_inst_t cmd_config_loopback_all = {
1554 .f = cmd_config_loopback_all_parsed,
1556 .help_str = "port config all loopback <mode>",
1558 (void *)&cmd_config_loopback_all_port,
1559 (void *)&cmd_config_loopback_all_keyword,
1560 (void *)&cmd_config_loopback_all_all,
1561 (void *)&cmd_config_loopback_all_item,
1562 (void *)&cmd_config_loopback_all_mode,
1567 /* *** configure loopback for specific port *** */
1568 struct cmd_config_loopback_specific {
1569 cmdline_fixed_string_t port;
1570 cmdline_fixed_string_t keyword;
1572 cmdline_fixed_string_t item;
1577 cmd_config_loopback_specific_parsed(void *parsed_result,
1578 __attribute__((unused)) struct cmdline *cl,
1579 __attribute__((unused)) void *data)
1581 struct cmd_config_loopback_specific *res = parsed_result;
1583 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1586 if (!port_is_stopped(res->port_id)) {
1587 printf("Please stop port %u first\n", res->port_id);
1591 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1593 cmd_reconfig_device_queue(res->port_id, 1, 1);
1597 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1598 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1600 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1601 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1603 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1604 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1606 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1607 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1609 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1610 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1613 cmdline_parse_inst_t cmd_config_loopback_specific = {
1614 .f = cmd_config_loopback_specific_parsed,
1616 .help_str = "port config <port_id> loopback <mode>",
1618 (void *)&cmd_config_loopback_specific_port,
1619 (void *)&cmd_config_loopback_specific_keyword,
1620 (void *)&cmd_config_loopback_specific_id,
1621 (void *)&cmd_config_loopback_specific_item,
1622 (void *)&cmd_config_loopback_specific_mode,
1627 /* *** configure txq/rxq, txd/rxd *** */
1628 struct cmd_config_rx_tx {
1629 cmdline_fixed_string_t port;
1630 cmdline_fixed_string_t keyword;
1631 cmdline_fixed_string_t all;
1632 cmdline_fixed_string_t name;
1637 cmd_config_rx_tx_parsed(void *parsed_result,
1638 __attribute__((unused)) struct cmdline *cl,
1639 __attribute__((unused)) void *data)
1641 struct cmd_config_rx_tx *res = parsed_result;
1643 if (!all_ports_stopped()) {
1644 printf("Please stop all ports first\n");
1647 if (!strcmp(res->name, "rxq")) {
1648 if (!res->value && !nb_txq) {
1649 printf("Warning: Either rx or tx queues should be non zero\n");
1652 if (check_nb_rxq(res->value) != 0)
1654 nb_rxq = res->value;
1656 else if (!strcmp(res->name, "txq")) {
1657 if (!res->value && !nb_rxq) {
1658 printf("Warning: Either rx or tx queues should be non zero\n");
1661 if (check_nb_txq(res->value) != 0)
1663 nb_txq = res->value;
1665 else if (!strcmp(res->name, "rxd")) {
1666 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1667 printf("rxd %d invalid - must be > 0 && <= %d\n",
1668 res->value, RTE_TEST_RX_DESC_MAX);
1671 nb_rxd = res->value;
1672 } else if (!strcmp(res->name, "txd")) {
1673 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1674 printf("txd %d invalid - must be > 0 && <= %d\n",
1675 res->value, RTE_TEST_TX_DESC_MAX);
1678 nb_txd = res->value;
1680 printf("Unknown parameter\n");
1688 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1691 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1692 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1693 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1695 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1697 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1700 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1701 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1703 cmdline_parse_inst_t cmd_config_rx_tx = {
1704 .f = cmd_config_rx_tx_parsed,
1706 .help_str = "port config all rxq|txq|rxd|txd <value>",
1708 (void *)&cmd_config_rx_tx_port,
1709 (void *)&cmd_config_rx_tx_keyword,
1710 (void *)&cmd_config_rx_tx_all,
1711 (void *)&cmd_config_rx_tx_name,
1712 (void *)&cmd_config_rx_tx_value,
1717 /* *** config max packet length *** */
1718 struct cmd_config_max_pkt_len_result {
1719 cmdline_fixed_string_t port;
1720 cmdline_fixed_string_t keyword;
1721 cmdline_fixed_string_t all;
1722 cmdline_fixed_string_t name;
1727 cmd_config_max_pkt_len_parsed(void *parsed_result,
1728 __attribute__((unused)) struct cmdline *cl,
1729 __attribute__((unused)) void *data)
1731 struct cmd_config_max_pkt_len_result *res = parsed_result;
1734 if (!all_ports_stopped()) {
1735 printf("Please stop all ports first\n");
1739 RTE_ETH_FOREACH_DEV(pid) {
1740 struct rte_port *port = &ports[pid];
1741 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1743 if (!strcmp(res->name, "max-pkt-len")) {
1744 if (res->value < ETHER_MIN_LEN) {
1745 printf("max-pkt-len can not be less than %d\n",
1749 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1752 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1753 if (res->value > ETHER_MAX_LEN)
1754 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1756 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1757 port->dev_conf.rxmode.offloads = rx_offloads;
1759 printf("Unknown parameter\n");
1766 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1769 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1772 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1773 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1775 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1778 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1779 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1781 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1782 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1785 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1786 .f = cmd_config_max_pkt_len_parsed,
1788 .help_str = "port config all max-pkt-len <value>",
1790 (void *)&cmd_config_max_pkt_len_port,
1791 (void *)&cmd_config_max_pkt_len_keyword,
1792 (void *)&cmd_config_max_pkt_len_all,
1793 (void *)&cmd_config_max_pkt_len_name,
1794 (void *)&cmd_config_max_pkt_len_value,
1799 /* *** configure port MTU *** */
1800 struct cmd_config_mtu_result {
1801 cmdline_fixed_string_t port;
1802 cmdline_fixed_string_t keyword;
1803 cmdline_fixed_string_t mtu;
1809 cmd_config_mtu_parsed(void *parsed_result,
1810 __attribute__((unused)) struct cmdline *cl,
1811 __attribute__((unused)) void *data)
1813 struct cmd_config_mtu_result *res = parsed_result;
1815 if (res->value < ETHER_MIN_LEN) {
1816 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1819 port_mtu_set(res->port_id, res->value);
1822 cmdline_parse_token_string_t cmd_config_mtu_port =
1823 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1825 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1826 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1828 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1829 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1831 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1832 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1833 cmdline_parse_token_num_t cmd_config_mtu_value =
1834 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1836 cmdline_parse_inst_t cmd_config_mtu = {
1837 .f = cmd_config_mtu_parsed,
1839 .help_str = "port config mtu <port_id> <value>",
1841 (void *)&cmd_config_mtu_port,
1842 (void *)&cmd_config_mtu_keyword,
1843 (void *)&cmd_config_mtu_mtu,
1844 (void *)&cmd_config_mtu_port_id,
1845 (void *)&cmd_config_mtu_value,
1850 /* *** configure rx mode *** */
1851 struct cmd_config_rx_mode_flag {
1852 cmdline_fixed_string_t port;
1853 cmdline_fixed_string_t keyword;
1854 cmdline_fixed_string_t all;
1855 cmdline_fixed_string_t name;
1856 cmdline_fixed_string_t value;
1860 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1861 __attribute__((unused)) struct cmdline *cl,
1862 __attribute__((unused)) void *data)
1864 struct cmd_config_rx_mode_flag *res = parsed_result;
1867 if (!all_ports_stopped()) {
1868 printf("Please stop all ports first\n");
1872 RTE_ETH_FOREACH_DEV(pid) {
1873 struct rte_port *port;
1874 uint64_t rx_offloads;
1877 rx_offloads = port->dev_conf.rxmode.offloads;
1878 if (!strcmp(res->name, "crc-strip")) {
1879 if (!strcmp(res->value, "on"))
1880 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1881 else if (!strcmp(res->value, "off"))
1882 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1884 printf("Unknown parameter\n");
1887 } else if (!strcmp(res->name, "scatter")) {
1888 if (!strcmp(res->value, "on")) {
1889 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1890 } else if (!strcmp(res->value, "off")) {
1891 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1893 printf("Unknown parameter\n");
1896 } else if (!strcmp(res->name, "rx-cksum")) {
1897 if (!strcmp(res->value, "on"))
1898 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1899 else if (!strcmp(res->value, "off"))
1900 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1902 printf("Unknown parameter\n");
1905 } else if (!strcmp(res->name, "rx-timestamp")) {
1906 if (!strcmp(res->value, "on"))
1907 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1908 else if (!strcmp(res->value, "off"))
1909 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1911 printf("Unknown parameter\n");
1914 } else if (!strcmp(res->name, "hw-vlan")) {
1915 if (!strcmp(res->value, "on")) {
1916 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1917 DEV_RX_OFFLOAD_VLAN_STRIP);
1918 } else if (!strcmp(res->value, "off")) {
1919 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1920 DEV_RX_OFFLOAD_VLAN_STRIP);
1922 printf("Unknown parameter\n");
1925 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1926 if (!strcmp(res->value, "on"))
1927 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1928 else if (!strcmp(res->value, "off"))
1929 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1931 printf("Unknown parameter\n");
1934 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1935 if (!strcmp(res->value, "on"))
1936 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1937 else if (!strcmp(res->value, "off"))
1938 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1940 printf("Unknown parameter\n");
1943 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1944 if (!strcmp(res->value, "on"))
1945 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1946 else if (!strcmp(res->value, "off"))
1947 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1949 printf("Unknown parameter\n");
1952 } else if (!strcmp(res->name, "drop-en")) {
1953 if (!strcmp(res->value, "on"))
1955 else if (!strcmp(res->value, "off"))
1958 printf("Unknown parameter\n");
1962 printf("Unknown parameter\n");
1965 port->dev_conf.rxmode.offloads = rx_offloads;
1970 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1973 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1974 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1975 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1976 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1978 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1979 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1980 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1981 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1982 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1983 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1984 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1985 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1988 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1989 .f = cmd_config_rx_mode_flag_parsed,
1991 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1992 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1994 (void *)&cmd_config_rx_mode_flag_port,
1995 (void *)&cmd_config_rx_mode_flag_keyword,
1996 (void *)&cmd_config_rx_mode_flag_all,
1997 (void *)&cmd_config_rx_mode_flag_name,
1998 (void *)&cmd_config_rx_mode_flag_value,
2003 /* *** configure rss *** */
2004 struct cmd_config_rss {
2005 cmdline_fixed_string_t port;
2006 cmdline_fixed_string_t keyword;
2007 cmdline_fixed_string_t all;
2008 cmdline_fixed_string_t name;
2009 cmdline_fixed_string_t value;
2013 cmd_config_rss_parsed(void *parsed_result,
2014 __attribute__((unused)) struct cmdline *cl,
2015 __attribute__((unused)) void *data)
2017 struct cmd_config_rss *res = parsed_result;
2018 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2019 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2020 int use_default = 0;
2021 int all_updated = 1;
2025 if (!strcmp(res->value, "all"))
2026 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2027 ETH_RSS_UDP | ETH_RSS_SCTP |
2029 else if (!strcmp(res->value, "ip"))
2030 rss_conf.rss_hf = ETH_RSS_IP;
2031 else if (!strcmp(res->value, "udp"))
2032 rss_conf.rss_hf = ETH_RSS_UDP;
2033 else if (!strcmp(res->value, "tcp"))
2034 rss_conf.rss_hf = ETH_RSS_TCP;
2035 else if (!strcmp(res->value, "sctp"))
2036 rss_conf.rss_hf = ETH_RSS_SCTP;
2037 else if (!strcmp(res->value, "ether"))
2038 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2039 else if (!strcmp(res->value, "port"))
2040 rss_conf.rss_hf = ETH_RSS_PORT;
2041 else if (!strcmp(res->value, "vxlan"))
2042 rss_conf.rss_hf = ETH_RSS_VXLAN;
2043 else if (!strcmp(res->value, "geneve"))
2044 rss_conf.rss_hf = ETH_RSS_GENEVE;
2045 else if (!strcmp(res->value, "nvgre"))
2046 rss_conf.rss_hf = ETH_RSS_NVGRE;
2047 else if (!strcmp(res->value, "none"))
2048 rss_conf.rss_hf = 0;
2049 else if (!strcmp(res->value, "default"))
2051 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2052 atoi(res->value) < 64)
2053 rss_conf.rss_hf = 1ULL << atoi(res->value);
2055 printf("Unknown parameter\n");
2058 rss_conf.rss_key = NULL;
2059 /* Update global configuration for RSS types. */
2060 RTE_ETH_FOREACH_DEV(i) {
2061 struct rte_eth_rss_conf local_rss_conf;
2063 rte_eth_dev_info_get(i, &dev_info);
2065 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2067 local_rss_conf = rss_conf;
2068 local_rss_conf.rss_hf = rss_conf.rss_hf &
2069 dev_info.flow_type_rss_offloads;
2070 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2071 printf("Port %u modified RSS hash function based on hardware support,"
2072 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2073 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2075 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2078 printf("Configuration of RSS hash at ethernet port %d "
2079 "failed with error (%d): %s.\n",
2080 i, -diag, strerror(-diag));
2083 if (all_updated && !use_default)
2084 rss_hf = rss_conf.rss_hf;
2087 cmdline_parse_token_string_t cmd_config_rss_port =
2088 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2089 cmdline_parse_token_string_t cmd_config_rss_keyword =
2090 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2091 cmdline_parse_token_string_t cmd_config_rss_all =
2092 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2093 cmdline_parse_token_string_t cmd_config_rss_name =
2094 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2095 cmdline_parse_token_string_t cmd_config_rss_value =
2096 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2098 cmdline_parse_inst_t cmd_config_rss = {
2099 .f = cmd_config_rss_parsed,
2101 .help_str = "port config all rss "
2102 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2104 (void *)&cmd_config_rss_port,
2105 (void *)&cmd_config_rss_keyword,
2106 (void *)&cmd_config_rss_all,
2107 (void *)&cmd_config_rss_name,
2108 (void *)&cmd_config_rss_value,
2113 /* *** configure rss hash key *** */
2114 struct cmd_config_rss_hash_key {
2115 cmdline_fixed_string_t port;
2116 cmdline_fixed_string_t config;
2118 cmdline_fixed_string_t rss_hash_key;
2119 cmdline_fixed_string_t rss_type;
2120 cmdline_fixed_string_t key;
2124 hexa_digit_to_value(char hexa_digit)
2126 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2127 return (uint8_t) (hexa_digit - '0');
2128 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2129 return (uint8_t) ((hexa_digit - 'a') + 10);
2130 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2131 return (uint8_t) ((hexa_digit - 'A') + 10);
2132 /* Invalid hexa digit */
2137 parse_and_check_key_hexa_digit(char *key, int idx)
2141 hexa_v = hexa_digit_to_value(key[idx]);
2143 printf("invalid key: character %c at position %d is not a "
2144 "valid hexa digit\n", key[idx], idx);
2149 cmd_config_rss_hash_key_parsed(void *parsed_result,
2150 __attribute__((unused)) struct cmdline *cl,
2151 __attribute__((unused)) void *data)
2153 struct cmd_config_rss_hash_key *res = parsed_result;
2154 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2158 struct rte_eth_dev_info dev_info;
2159 uint8_t hash_key_size;
2162 memset(&dev_info, 0, sizeof(dev_info));
2163 rte_eth_dev_info_get(res->port_id, &dev_info);
2164 if (dev_info.hash_key_size > 0 &&
2165 dev_info.hash_key_size <= sizeof(hash_key))
2166 hash_key_size = dev_info.hash_key_size;
2168 printf("dev_info did not provide a valid hash key size\n");
2171 /* Check the length of the RSS hash key */
2172 key_len = strlen(res->key);
2173 if (key_len != (hash_key_size * 2)) {
2174 printf("key length: %d invalid - key must be a string of %d"
2175 " hexa-decimal numbers\n",
2176 (int) key_len, hash_key_size * 2);
2179 /* Translate RSS hash key into binary representation */
2180 for (i = 0; i < hash_key_size; i++) {
2181 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2184 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2187 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2189 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2193 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2194 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2195 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2196 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2198 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2199 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2200 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2201 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2202 rss_hash_key, "rss-hash-key");
2203 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2204 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2205 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2206 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2207 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2208 "ipv6-tcp-ex#ipv6-udp-ex");
2209 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2210 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2212 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2213 .f = cmd_config_rss_hash_key_parsed,
2215 .help_str = "port config <port_id> rss-hash-key "
2216 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2217 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2218 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2219 "<string of hex digits (variable length, NIC dependent)>",
2221 (void *)&cmd_config_rss_hash_key_port,
2222 (void *)&cmd_config_rss_hash_key_config,
2223 (void *)&cmd_config_rss_hash_key_port_id,
2224 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2225 (void *)&cmd_config_rss_hash_key_rss_type,
2226 (void *)&cmd_config_rss_hash_key_value,
2231 /* *** configure port rxq/txq ring size *** */
2232 struct cmd_config_rxtx_ring_size {
2233 cmdline_fixed_string_t port;
2234 cmdline_fixed_string_t config;
2236 cmdline_fixed_string_t rxtxq;
2238 cmdline_fixed_string_t rsize;
2243 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2244 __attribute__((unused)) struct cmdline *cl,
2245 __attribute__((unused)) void *data)
2247 struct cmd_config_rxtx_ring_size *res = parsed_result;
2248 struct rte_port *port;
2251 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2254 if (res->portid == (portid_t)RTE_PORT_ALL) {
2255 printf("Invalid port id\n");
2259 port = &ports[res->portid];
2261 if (!strcmp(res->rxtxq, "rxq"))
2263 else if (!strcmp(res->rxtxq, "txq"))
2266 printf("Unknown parameter\n");
2270 if (isrx && rx_queue_id_is_invalid(res->qid))
2272 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2275 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2276 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2282 port->nb_rx_desc[res->qid] = res->size;
2284 port->nb_tx_desc[res->qid] = res->size;
2286 cmd_reconfig_device_queue(res->portid, 0, 1);
2289 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2290 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2292 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2293 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2295 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2296 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2298 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2299 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2301 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2302 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2304 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2305 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2306 rsize, "ring_size");
2307 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2308 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2311 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2312 .f = cmd_config_rxtx_ring_size_parsed,
2314 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2316 (void *)&cmd_config_rxtx_ring_size_port,
2317 (void *)&cmd_config_rxtx_ring_size_config,
2318 (void *)&cmd_config_rxtx_ring_size_portid,
2319 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2320 (void *)&cmd_config_rxtx_ring_size_qid,
2321 (void *)&cmd_config_rxtx_ring_size_rsize,
2322 (void *)&cmd_config_rxtx_ring_size_size,
2327 /* *** configure port rxq/txq start/stop *** */
2328 struct cmd_config_rxtx_queue {
2329 cmdline_fixed_string_t port;
2331 cmdline_fixed_string_t rxtxq;
2333 cmdline_fixed_string_t opname;
2337 cmd_config_rxtx_queue_parsed(void *parsed_result,
2338 __attribute__((unused)) struct cmdline *cl,
2339 __attribute__((unused)) void *data)
2341 struct cmd_config_rxtx_queue *res = parsed_result;
2346 if (test_done == 0) {
2347 printf("Please stop forwarding first\n");
2351 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2354 if (port_is_started(res->portid) != 1) {
2355 printf("Please start port %u first\n", res->portid);
2359 if (!strcmp(res->rxtxq, "rxq"))
2361 else if (!strcmp(res->rxtxq, "txq"))
2364 printf("Unknown parameter\n");
2368 if (isrx && rx_queue_id_is_invalid(res->qid))
2370 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2373 if (!strcmp(res->opname, "start"))
2375 else if (!strcmp(res->opname, "stop"))
2378 printf("Unknown parameter\n");
2382 if (isstart && isrx)
2383 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2384 else if (!isstart && isrx)
2385 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2386 else if (isstart && !isrx)
2387 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2389 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2391 if (ret == -ENOTSUP)
2392 printf("Function not supported in PMD driver\n");
2395 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2396 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2397 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2398 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2399 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2400 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2401 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2402 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2403 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2404 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2407 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2408 .f = cmd_config_rxtx_queue_parsed,
2410 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2412 (void *)&cmd_config_rxtx_queue_port,
2413 (void *)&cmd_config_rxtx_queue_portid,
2414 (void *)&cmd_config_rxtx_queue_rxtxq,
2415 (void *)&cmd_config_rxtx_queue_qid,
2416 (void *)&cmd_config_rxtx_queue_opname,
2421 /* *** configure port rxq/txq setup *** */
2422 struct cmd_setup_rxtx_queue {
2423 cmdline_fixed_string_t port;
2425 cmdline_fixed_string_t rxtxq;
2427 cmdline_fixed_string_t setup;
2430 /* Common CLI fields for queue setup */
2431 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2432 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2433 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2434 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2435 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2436 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2437 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2438 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2439 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2440 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2443 cmd_setup_rxtx_queue_parsed(
2444 void *parsed_result,
2445 __attribute__((unused)) struct cmdline *cl,
2446 __attribute__((unused)) void *data)
2448 struct cmd_setup_rxtx_queue *res = parsed_result;
2449 struct rte_port *port;
2450 struct rte_mempool *mp;
2451 unsigned int socket_id;
2455 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2458 if (res->portid == (portid_t)RTE_PORT_ALL) {
2459 printf("Invalid port id\n");
2463 if (!strcmp(res->rxtxq, "rxq"))
2465 else if (!strcmp(res->rxtxq, "txq"))
2468 printf("Unknown parameter\n");
2472 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2473 printf("Invalid rx queue\n");
2475 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2476 printf("Invalid tx queue\n");
2480 port = &ports[res->portid];
2482 socket_id = rxring_numa[res->portid];
2483 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2484 socket_id = port->socket_id;
2486 mp = mbuf_pool_find(socket_id);
2488 printf("Failed to setup RX queue: "
2489 "No mempool allocation"
2490 " on the socket %d\n",
2491 rxring_numa[res->portid]);
2494 ret = rte_eth_rx_queue_setup(res->portid,
2496 port->nb_rx_desc[res->qid],
2498 &port->rx_conf[res->qid],
2501 printf("Failed to setup RX queue\n");
2503 socket_id = txring_numa[res->portid];
2504 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2505 socket_id = port->socket_id;
2507 ret = rte_eth_tx_queue_setup(res->portid,
2509 port->nb_tx_desc[res->qid],
2511 &port->tx_conf[res->qid]);
2513 printf("Failed to setup TX queue\n");
2517 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2518 .f = cmd_setup_rxtx_queue_parsed,
2520 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2522 (void *)&cmd_setup_rxtx_queue_port,
2523 (void *)&cmd_setup_rxtx_queue_portid,
2524 (void *)&cmd_setup_rxtx_queue_rxtxq,
2525 (void *)&cmd_setup_rxtx_queue_qid,
2526 (void *)&cmd_setup_rxtx_queue_setup,
2532 /* *** Configure RSS RETA *** */
2533 struct cmd_config_rss_reta {
2534 cmdline_fixed_string_t port;
2535 cmdline_fixed_string_t keyword;
2537 cmdline_fixed_string_t name;
2538 cmdline_fixed_string_t list_name;
2539 cmdline_fixed_string_t list_of_items;
2543 parse_reta_config(const char *str,
2544 struct rte_eth_rss_reta_entry64 *reta_conf,
2545 uint16_t nb_entries)
2549 uint16_t hash_index, idx, shift;
2552 const char *p, *p0 = str;
2559 unsigned long int_fld[_NUM_FLD];
2560 char *str_fld[_NUM_FLD];
2562 while ((p = strchr(p0,'(')) != NULL) {
2564 if((p0 = strchr(p,')')) == NULL)
2568 if(size >= sizeof(s))
2571 snprintf(s, sizeof(s), "%.*s", size, p);
2572 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2574 for (i = 0; i < _NUM_FLD; i++) {
2576 int_fld[i] = strtoul(str_fld[i], &end, 0);
2577 if (errno != 0 || end == str_fld[i] ||
2582 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2583 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2585 if (hash_index >= nb_entries) {
2586 printf("Invalid RETA hash index=%d\n", hash_index);
2590 idx = hash_index / RTE_RETA_GROUP_SIZE;
2591 shift = hash_index % RTE_RETA_GROUP_SIZE;
2592 reta_conf[idx].mask |= (1ULL << shift);
2593 reta_conf[idx].reta[shift] = nb_queue;
2600 cmd_set_rss_reta_parsed(void *parsed_result,
2601 __attribute__((unused)) struct cmdline *cl,
2602 __attribute__((unused)) void *data)
2605 struct rte_eth_dev_info dev_info;
2606 struct rte_eth_rss_reta_entry64 reta_conf[8];
2607 struct cmd_config_rss_reta *res = parsed_result;
2609 memset(&dev_info, 0, sizeof(dev_info));
2610 rte_eth_dev_info_get(res->port_id, &dev_info);
2611 if (dev_info.reta_size == 0) {
2612 printf("Redirection table size is 0 which is "
2613 "invalid for RSS\n");
2616 printf("The reta size of port %d is %u\n",
2617 res->port_id, dev_info.reta_size);
2618 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2619 printf("Currently do not support more than %u entries of "
2620 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2624 memset(reta_conf, 0, sizeof(reta_conf));
2625 if (!strcmp(res->list_name, "reta")) {
2626 if (parse_reta_config(res->list_of_items, reta_conf,
2627 dev_info.reta_size)) {
2628 printf("Invalid RSS Redirection Table "
2629 "config entered\n");
2632 ret = rte_eth_dev_rss_reta_update(res->port_id,
2633 reta_conf, dev_info.reta_size);
2635 printf("Bad redirection table parameter, "
2636 "return code = %d \n", ret);
2640 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2641 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2642 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2643 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2644 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2645 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2646 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2647 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2648 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2649 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2650 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2651 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2653 cmdline_parse_inst_t cmd_config_rss_reta = {
2654 .f = cmd_set_rss_reta_parsed,
2656 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2658 (void *)&cmd_config_rss_reta_port,
2659 (void *)&cmd_config_rss_reta_keyword,
2660 (void *)&cmd_config_rss_reta_port_id,
2661 (void *)&cmd_config_rss_reta_name,
2662 (void *)&cmd_config_rss_reta_list_name,
2663 (void *)&cmd_config_rss_reta_list_of_items,
2668 /* *** SHOW PORT RETA INFO *** */
2669 struct cmd_showport_reta {
2670 cmdline_fixed_string_t show;
2671 cmdline_fixed_string_t port;
2673 cmdline_fixed_string_t rss;
2674 cmdline_fixed_string_t reta;
2676 cmdline_fixed_string_t list_of_items;
2680 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2681 uint16_t nb_entries,
2685 const char *p, *p0 = str;
2690 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2691 RTE_RETA_GROUP_SIZE;
2694 p = strchr(p0, '(');
2698 p0 = strchr(p, ')');
2702 if (size >= sizeof(s)) {
2703 printf("The string size exceeds the internal buffer size\n");
2706 snprintf(s, sizeof(s), "%.*s", size, p);
2707 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2708 if (ret <= 0 || ret != num) {
2709 printf("The bits of masks do not match the number of "
2710 "reta entries: %u\n", num);
2713 for (i = 0; i < ret; i++)
2714 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2720 cmd_showport_reta_parsed(void *parsed_result,
2721 __attribute__((unused)) struct cmdline *cl,
2722 __attribute__((unused)) void *data)
2724 struct cmd_showport_reta *res = parsed_result;
2725 struct rte_eth_rss_reta_entry64 reta_conf[8];
2726 struct rte_eth_dev_info dev_info;
2727 uint16_t max_reta_size;
2729 memset(&dev_info, 0, sizeof(dev_info));
2730 rte_eth_dev_info_get(res->port_id, &dev_info);
2731 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2732 if (res->size == 0 || res->size > max_reta_size) {
2733 printf("Invalid redirection table size: %u (1-%u)\n",
2734 res->size, max_reta_size);
2738 memset(reta_conf, 0, sizeof(reta_conf));
2739 if (showport_parse_reta_config(reta_conf, res->size,
2740 res->list_of_items) < 0) {
2741 printf("Invalid string: %s for reta masks\n",
2742 res->list_of_items);
2745 port_rss_reta_info(res->port_id, reta_conf, res->size);
2748 cmdline_parse_token_string_t cmd_showport_reta_show =
2749 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2750 cmdline_parse_token_string_t cmd_showport_reta_port =
2751 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2752 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2753 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2754 cmdline_parse_token_string_t cmd_showport_reta_rss =
2755 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2756 cmdline_parse_token_string_t cmd_showport_reta_reta =
2757 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2758 cmdline_parse_token_num_t cmd_showport_reta_size =
2759 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2760 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2761 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2762 list_of_items, NULL);
2764 cmdline_parse_inst_t cmd_showport_reta = {
2765 .f = cmd_showport_reta_parsed,
2767 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2769 (void *)&cmd_showport_reta_show,
2770 (void *)&cmd_showport_reta_port,
2771 (void *)&cmd_showport_reta_port_id,
2772 (void *)&cmd_showport_reta_rss,
2773 (void *)&cmd_showport_reta_reta,
2774 (void *)&cmd_showport_reta_size,
2775 (void *)&cmd_showport_reta_list_of_items,
2780 /* *** Show RSS hash configuration *** */
2781 struct cmd_showport_rss_hash {
2782 cmdline_fixed_string_t show;
2783 cmdline_fixed_string_t port;
2785 cmdline_fixed_string_t rss_hash;
2786 cmdline_fixed_string_t rss_type;
2787 cmdline_fixed_string_t key; /* optional argument */
2790 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2791 __attribute__((unused)) struct cmdline *cl,
2794 struct cmd_showport_rss_hash *res = parsed_result;
2796 port_rss_hash_conf_show(res->port_id, res->rss_type,
2797 show_rss_key != NULL);
2800 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2801 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2802 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2803 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2804 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2805 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2806 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2807 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2809 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2810 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2811 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2812 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2813 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2814 "ipv6-tcp-ex#ipv6-udp-ex");
2815 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2816 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2818 cmdline_parse_inst_t cmd_showport_rss_hash = {
2819 .f = cmd_showport_rss_hash_parsed,
2821 .help_str = "show port <port_id> rss-hash "
2822 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2823 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2824 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2826 (void *)&cmd_showport_rss_hash_show,
2827 (void *)&cmd_showport_rss_hash_port,
2828 (void *)&cmd_showport_rss_hash_port_id,
2829 (void *)&cmd_showport_rss_hash_rss_hash,
2830 (void *)&cmd_showport_rss_hash_rss_hash_info,
2835 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2836 .f = cmd_showport_rss_hash_parsed,
2838 .help_str = "show port <port_id> rss-hash "
2839 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2840 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2841 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2843 (void *)&cmd_showport_rss_hash_show,
2844 (void *)&cmd_showport_rss_hash_port,
2845 (void *)&cmd_showport_rss_hash_port_id,
2846 (void *)&cmd_showport_rss_hash_rss_hash,
2847 (void *)&cmd_showport_rss_hash_rss_hash_info,
2848 (void *)&cmd_showport_rss_hash_rss_key,
2853 /* *** Configure DCB *** */
2854 struct cmd_config_dcb {
2855 cmdline_fixed_string_t port;
2856 cmdline_fixed_string_t config;
2858 cmdline_fixed_string_t dcb;
2859 cmdline_fixed_string_t vt;
2860 cmdline_fixed_string_t vt_en;
2862 cmdline_fixed_string_t pfc;
2863 cmdline_fixed_string_t pfc_en;
2867 cmd_config_dcb_parsed(void *parsed_result,
2868 __attribute__((unused)) struct cmdline *cl,
2869 __attribute__((unused)) void *data)
2871 struct cmd_config_dcb *res = parsed_result;
2872 portid_t port_id = res->port_id;
2873 struct rte_port *port;
2877 port = &ports[port_id];
2878 /** Check if the port is not started **/
2879 if (port->port_status != RTE_PORT_STOPPED) {
2880 printf("Please stop port %d first\n", port_id);
2884 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2885 printf("The invalid number of traffic class,"
2886 " only 4 or 8 allowed.\n");
2890 if (nb_fwd_lcores < res->num_tcs) {
2891 printf("nb_cores shouldn't be less than number of TCs.\n");
2894 if (!strncmp(res->pfc_en, "on", 2))
2899 /* DCB in VT mode */
2900 if (!strncmp(res->vt_en, "on", 2))
2901 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2902 (enum rte_eth_nb_tcs)res->num_tcs,
2905 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2906 (enum rte_eth_nb_tcs)res->num_tcs,
2911 printf("Cannot initialize network ports.\n");
2915 cmd_reconfig_device_queue(port_id, 1, 1);
2918 cmdline_parse_token_string_t cmd_config_dcb_port =
2919 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2920 cmdline_parse_token_string_t cmd_config_dcb_config =
2921 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2922 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2923 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2924 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2925 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2926 cmdline_parse_token_string_t cmd_config_dcb_vt =
2927 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2928 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2929 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2930 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2931 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2932 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2933 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2934 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2935 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2937 cmdline_parse_inst_t cmd_config_dcb = {
2938 .f = cmd_config_dcb_parsed,
2940 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2942 (void *)&cmd_config_dcb_port,
2943 (void *)&cmd_config_dcb_config,
2944 (void *)&cmd_config_dcb_port_id,
2945 (void *)&cmd_config_dcb_dcb,
2946 (void *)&cmd_config_dcb_vt,
2947 (void *)&cmd_config_dcb_vt_en,
2948 (void *)&cmd_config_dcb_num_tcs,
2949 (void *)&cmd_config_dcb_pfc,
2950 (void *)&cmd_config_dcb_pfc_en,
2955 /* *** configure number of packets per burst *** */
2956 struct cmd_config_burst {
2957 cmdline_fixed_string_t port;
2958 cmdline_fixed_string_t keyword;
2959 cmdline_fixed_string_t all;
2960 cmdline_fixed_string_t name;
2965 cmd_config_burst_parsed(void *parsed_result,
2966 __attribute__((unused)) struct cmdline *cl,
2967 __attribute__((unused)) void *data)
2969 struct cmd_config_burst *res = parsed_result;
2970 struct rte_eth_dev_info dev_info;
2971 uint16_t rec_nb_pkts;
2973 if (!all_ports_stopped()) {
2974 printf("Please stop all ports first\n");
2978 if (!strcmp(res->name, "burst")) {
2979 if (res->value == 0) {
2980 /* If user gives a value of zero, query the PMD for
2981 * its recommended Rx burst size. Testpmd uses a single
2982 * size for all ports, so assume all ports are the same
2983 * NIC model and use the values from Port 0.
2985 rte_eth_dev_info_get(0, &dev_info);
2986 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2988 if (rec_nb_pkts == 0) {
2989 printf("PMD does not recommend a burst size.\n"
2990 "User provided value must be between"
2991 " 1 and %d\n", MAX_PKT_BURST);
2993 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2994 printf("PMD recommended burst size of %d"
2995 " exceeds maximum value of %d\n",
2996 rec_nb_pkts, MAX_PKT_BURST);
2999 printf("Using PMD-provided burst value of %d\n",
3001 nb_pkt_per_burst = rec_nb_pkts;
3002 } else if (res->value > MAX_PKT_BURST) {
3003 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3006 nb_pkt_per_burst = res->value;
3008 printf("Unknown parameter\n");
3014 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3017 cmdline_parse_token_string_t cmd_config_burst_port =
3018 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3019 cmdline_parse_token_string_t cmd_config_burst_keyword =
3020 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3021 cmdline_parse_token_string_t cmd_config_burst_all =
3022 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3023 cmdline_parse_token_string_t cmd_config_burst_name =
3024 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3025 cmdline_parse_token_num_t cmd_config_burst_value =
3026 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3028 cmdline_parse_inst_t cmd_config_burst = {
3029 .f = cmd_config_burst_parsed,
3031 .help_str = "port config all burst <value>",
3033 (void *)&cmd_config_burst_port,
3034 (void *)&cmd_config_burst_keyword,
3035 (void *)&cmd_config_burst_all,
3036 (void *)&cmd_config_burst_name,
3037 (void *)&cmd_config_burst_value,
3042 /* *** configure rx/tx queues *** */
3043 struct cmd_config_thresh {
3044 cmdline_fixed_string_t port;
3045 cmdline_fixed_string_t keyword;
3046 cmdline_fixed_string_t all;
3047 cmdline_fixed_string_t name;
3052 cmd_config_thresh_parsed(void *parsed_result,
3053 __attribute__((unused)) struct cmdline *cl,
3054 __attribute__((unused)) void *data)
3056 struct cmd_config_thresh *res = parsed_result;
3058 if (!all_ports_stopped()) {
3059 printf("Please stop all ports first\n");
3063 if (!strcmp(res->name, "txpt"))
3064 tx_pthresh = res->value;
3065 else if(!strcmp(res->name, "txht"))
3066 tx_hthresh = res->value;
3067 else if(!strcmp(res->name, "txwt"))
3068 tx_wthresh = res->value;
3069 else if(!strcmp(res->name, "rxpt"))
3070 rx_pthresh = res->value;
3071 else if(!strcmp(res->name, "rxht"))
3072 rx_hthresh = res->value;
3073 else if(!strcmp(res->name, "rxwt"))
3074 rx_wthresh = res->value;
3076 printf("Unknown parameter\n");
3082 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3085 cmdline_parse_token_string_t cmd_config_thresh_port =
3086 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3087 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3088 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3089 cmdline_parse_token_string_t cmd_config_thresh_all =
3090 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3091 cmdline_parse_token_string_t cmd_config_thresh_name =
3092 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3093 "txpt#txht#txwt#rxpt#rxht#rxwt");
3094 cmdline_parse_token_num_t cmd_config_thresh_value =
3095 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3097 cmdline_parse_inst_t cmd_config_thresh = {
3098 .f = cmd_config_thresh_parsed,
3100 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3102 (void *)&cmd_config_thresh_port,
3103 (void *)&cmd_config_thresh_keyword,
3104 (void *)&cmd_config_thresh_all,
3105 (void *)&cmd_config_thresh_name,
3106 (void *)&cmd_config_thresh_value,
3111 /* *** configure free/rs threshold *** */
3112 struct cmd_config_threshold {
3113 cmdline_fixed_string_t port;
3114 cmdline_fixed_string_t keyword;
3115 cmdline_fixed_string_t all;
3116 cmdline_fixed_string_t name;
3121 cmd_config_threshold_parsed(void *parsed_result,
3122 __attribute__((unused)) struct cmdline *cl,
3123 __attribute__((unused)) void *data)
3125 struct cmd_config_threshold *res = parsed_result;
3127 if (!all_ports_stopped()) {
3128 printf("Please stop all ports first\n");
3132 if (!strcmp(res->name, "txfreet"))
3133 tx_free_thresh = res->value;
3134 else if (!strcmp(res->name, "txrst"))
3135 tx_rs_thresh = res->value;
3136 else if (!strcmp(res->name, "rxfreet"))
3137 rx_free_thresh = res->value;
3139 printf("Unknown parameter\n");
3145 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3148 cmdline_parse_token_string_t cmd_config_threshold_port =
3149 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3150 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3151 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3153 cmdline_parse_token_string_t cmd_config_threshold_all =
3154 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3155 cmdline_parse_token_string_t cmd_config_threshold_name =
3156 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3157 "txfreet#txrst#rxfreet");
3158 cmdline_parse_token_num_t cmd_config_threshold_value =
3159 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3161 cmdline_parse_inst_t cmd_config_threshold = {
3162 .f = cmd_config_threshold_parsed,
3164 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3166 (void *)&cmd_config_threshold_port,
3167 (void *)&cmd_config_threshold_keyword,
3168 (void *)&cmd_config_threshold_all,
3169 (void *)&cmd_config_threshold_name,
3170 (void *)&cmd_config_threshold_value,
3176 struct cmd_stop_result {
3177 cmdline_fixed_string_t stop;
3180 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3181 __attribute__((unused)) struct cmdline *cl,
3182 __attribute__((unused)) void *data)
3184 stop_packet_forwarding();
3187 cmdline_parse_token_string_t cmd_stop_stop =
3188 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3190 cmdline_parse_inst_t cmd_stop = {
3191 .f = cmd_stop_parsed,
3193 .help_str = "stop: Stop packet forwarding",
3195 (void *)&cmd_stop_stop,
3200 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3203 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3204 unsigned int *parsed_items, int check_unique_values)
3206 unsigned int nb_item;
3214 * First parse all items in the list and store their value.
3219 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3221 if ((c >= '0') && (c <= '9')) {
3222 value = (unsigned int) (value * 10 + (c - '0'));
3227 printf("character %c is not a decimal digit\n", c);
3231 printf("No valid value before comma\n");
3234 if (nb_item < max_items) {
3235 parsed_items[nb_item] = value;
3241 if (nb_item >= max_items) {
3242 printf("Number of %s = %u > %u (maximum items)\n",
3243 item_name, nb_item + 1, max_items);
3246 parsed_items[nb_item++] = value;
3247 if (! check_unique_values)
3251 * Then, check that all values in the list are differents.
3252 * No optimization here...
3254 for (i = 0; i < nb_item; i++) {
3255 for (j = i + 1; j < nb_item; j++) {
3256 if (parsed_items[j] == parsed_items[i]) {
3257 printf("duplicated %s %u at index %u and %u\n",
3258 item_name, parsed_items[i], i, j);
3266 struct cmd_set_list_result {
3267 cmdline_fixed_string_t cmd_keyword;
3268 cmdline_fixed_string_t list_name;
3269 cmdline_fixed_string_t list_of_items;
3272 static void cmd_set_list_parsed(void *parsed_result,
3273 __attribute__((unused)) struct cmdline *cl,
3274 __attribute__((unused)) void *data)
3276 struct cmd_set_list_result *res;
3278 unsigned int lcorelist[RTE_MAX_LCORE];
3279 unsigned int portlist[RTE_MAX_ETHPORTS];
3281 unsigned int nb_item;
3283 if (test_done == 0) {
3284 printf("Please stop forwarding first\n");
3288 res = parsed_result;
3289 if (!strcmp(res->list_name, "corelist")) {
3290 nb_item = parse_item_list(res->list_of_items, "core",
3292 parsed_items.lcorelist, 1);
3294 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3299 if (!strcmp(res->list_name, "portlist")) {
3300 nb_item = parse_item_list(res->list_of_items, "port",
3302 parsed_items.portlist, 1);
3304 set_fwd_ports_list(parsed_items.portlist, nb_item);
3310 cmdline_parse_token_string_t cmd_set_list_keyword =
3311 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3313 cmdline_parse_token_string_t cmd_set_list_name =
3314 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3315 "corelist#portlist");
3316 cmdline_parse_token_string_t cmd_set_list_of_items =
3317 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3320 cmdline_parse_inst_t cmd_set_fwd_list = {
3321 .f = cmd_set_list_parsed,
3323 .help_str = "set corelist|portlist <list0[,list1]*>",
3325 (void *)&cmd_set_list_keyword,
3326 (void *)&cmd_set_list_name,
3327 (void *)&cmd_set_list_of_items,
3332 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3334 struct cmd_setmask_result {
3335 cmdline_fixed_string_t set;
3336 cmdline_fixed_string_t mask;
3340 static void cmd_set_mask_parsed(void *parsed_result,
3341 __attribute__((unused)) struct cmdline *cl,
3342 __attribute__((unused)) void *data)
3344 struct cmd_setmask_result *res = parsed_result;
3346 if (test_done == 0) {
3347 printf("Please stop forwarding first\n");
3350 if (!strcmp(res->mask, "coremask")) {
3351 set_fwd_lcores_mask(res->hexavalue);
3353 } else if (!strcmp(res->mask, "portmask")) {
3354 set_fwd_ports_mask(res->hexavalue);
3359 cmdline_parse_token_string_t cmd_setmask_set =
3360 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3361 cmdline_parse_token_string_t cmd_setmask_mask =
3362 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3363 "coremask#portmask");
3364 cmdline_parse_token_num_t cmd_setmask_value =
3365 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3367 cmdline_parse_inst_t cmd_set_fwd_mask = {
3368 .f = cmd_set_mask_parsed,
3370 .help_str = "set coremask|portmask <hexadecimal value>",
3372 (void *)&cmd_setmask_set,
3373 (void *)&cmd_setmask_mask,
3374 (void *)&cmd_setmask_value,
3380 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3382 struct cmd_set_result {
3383 cmdline_fixed_string_t set;
3384 cmdline_fixed_string_t what;
3388 static void cmd_set_parsed(void *parsed_result,
3389 __attribute__((unused)) struct cmdline *cl,
3390 __attribute__((unused)) void *data)
3392 struct cmd_set_result *res = parsed_result;
3393 if (!strcmp(res->what, "nbport")) {
3394 set_fwd_ports_number(res->value);
3396 } else if (!strcmp(res->what, "nbcore")) {
3397 set_fwd_lcores_number(res->value);
3399 } else if (!strcmp(res->what, "burst"))
3400 set_nb_pkt_per_burst(res->value);
3401 else if (!strcmp(res->what, "verbose"))
3402 set_verbose_level(res->value);
3405 cmdline_parse_token_string_t cmd_set_set =
3406 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3407 cmdline_parse_token_string_t cmd_set_what =
3408 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3409 "nbport#nbcore#burst#verbose");
3410 cmdline_parse_token_num_t cmd_set_value =
3411 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3413 cmdline_parse_inst_t cmd_set_numbers = {
3414 .f = cmd_set_parsed,
3416 .help_str = "set nbport|nbcore|burst|verbose <value>",
3418 (void *)&cmd_set_set,
3419 (void *)&cmd_set_what,
3420 (void *)&cmd_set_value,
3425 /* *** SET LOG LEVEL CONFIGURATION *** */
3427 struct cmd_set_log_result {
3428 cmdline_fixed_string_t set;
3429 cmdline_fixed_string_t log;
3430 cmdline_fixed_string_t type;
3435 cmd_set_log_parsed(void *parsed_result,
3436 __attribute__((unused)) struct cmdline *cl,
3437 __attribute__((unused)) void *data)
3439 struct cmd_set_log_result *res;
3442 res = parsed_result;
3443 if (!strcmp(res->type, "global"))
3444 rte_log_set_global_level(res->level);
3446 ret = rte_log_set_level_regexp(res->type, res->level);
3448 printf("Unable to set log level\n");
3452 cmdline_parse_token_string_t cmd_set_log_set =
3453 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3454 cmdline_parse_token_string_t cmd_set_log_log =
3455 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3456 cmdline_parse_token_string_t cmd_set_log_type =
3457 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3458 cmdline_parse_token_num_t cmd_set_log_level =
3459 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3461 cmdline_parse_inst_t cmd_set_log = {
3462 .f = cmd_set_log_parsed,
3464 .help_str = "set log global|<type> <level>",
3466 (void *)&cmd_set_log_set,
3467 (void *)&cmd_set_log_log,
3468 (void *)&cmd_set_log_type,
3469 (void *)&cmd_set_log_level,
3474 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3476 struct cmd_set_txpkts_result {
3477 cmdline_fixed_string_t cmd_keyword;
3478 cmdline_fixed_string_t txpkts;
3479 cmdline_fixed_string_t seg_lengths;
3483 cmd_set_txpkts_parsed(void *parsed_result,
3484 __attribute__((unused)) struct cmdline *cl,
3485 __attribute__((unused)) void *data)
3487 struct cmd_set_txpkts_result *res;
3488 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3489 unsigned int nb_segs;
3491 res = parsed_result;
3492 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3493 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3495 set_tx_pkt_segments(seg_lengths, nb_segs);
3498 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3499 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3500 cmd_keyword, "set");
3501 cmdline_parse_token_string_t cmd_set_txpkts_name =
3502 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3504 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3505 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3508 cmdline_parse_inst_t cmd_set_txpkts = {
3509 .f = cmd_set_txpkts_parsed,
3511 .help_str = "set txpkts <len0[,len1]*>",
3513 (void *)&cmd_set_txpkts_keyword,
3514 (void *)&cmd_set_txpkts_name,
3515 (void *)&cmd_set_txpkts_lengths,
3520 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3522 struct cmd_set_txsplit_result {
3523 cmdline_fixed_string_t cmd_keyword;
3524 cmdline_fixed_string_t txsplit;
3525 cmdline_fixed_string_t mode;
3529 cmd_set_txsplit_parsed(void *parsed_result,
3530 __attribute__((unused)) struct cmdline *cl,
3531 __attribute__((unused)) void *data)
3533 struct cmd_set_txsplit_result *res;
3535 res = parsed_result;
3536 set_tx_pkt_split(res->mode);
3539 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3540 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3541 cmd_keyword, "set");
3542 cmdline_parse_token_string_t cmd_set_txsplit_name =
3543 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3544 txsplit, "txsplit");
3545 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3546 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3549 cmdline_parse_inst_t cmd_set_txsplit = {
3550 .f = cmd_set_txsplit_parsed,
3552 .help_str = "set txsplit on|off|rand",
3554 (void *)&cmd_set_txsplit_keyword,
3555 (void *)&cmd_set_txsplit_name,
3556 (void *)&cmd_set_txsplit_mode,
3561 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3562 struct cmd_rx_vlan_filter_all_result {
3563 cmdline_fixed_string_t rx_vlan;
3564 cmdline_fixed_string_t what;
3565 cmdline_fixed_string_t all;
3570 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3571 __attribute__((unused)) struct cmdline *cl,
3572 __attribute__((unused)) void *data)
3574 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3576 if (!strcmp(res->what, "add"))
3577 rx_vlan_all_filter_set(res->port_id, 1);
3579 rx_vlan_all_filter_set(res->port_id, 0);
3582 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3583 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3584 rx_vlan, "rx_vlan");
3585 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3586 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3588 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3589 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3591 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3592 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3595 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3596 .f = cmd_rx_vlan_filter_all_parsed,
3598 .help_str = "rx_vlan add|rm all <port_id>: "
3599 "Add/Remove all identifiers to/from the set of VLAN "
3600 "identifiers filtered by a port",
3602 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3603 (void *)&cmd_rx_vlan_filter_all_what,
3604 (void *)&cmd_rx_vlan_filter_all_all,
3605 (void *)&cmd_rx_vlan_filter_all_portid,
3610 /* *** VLAN OFFLOAD SET ON A PORT *** */
3611 struct cmd_vlan_offload_result {
3612 cmdline_fixed_string_t vlan;
3613 cmdline_fixed_string_t set;
3614 cmdline_fixed_string_t vlan_type;
3615 cmdline_fixed_string_t what;
3616 cmdline_fixed_string_t on;
3617 cmdline_fixed_string_t port_id;
3621 cmd_vlan_offload_parsed(void *parsed_result,
3622 __attribute__((unused)) struct cmdline *cl,
3623 __attribute__((unused)) void *data)
3626 struct cmd_vlan_offload_result *res = parsed_result;
3629 portid_t port_id = 0;
3633 len = strnlen(str, STR_TOKEN_SIZE);
3635 /* Get port_id first */
3643 tmp = strtoul(str, NULL, 0);
3644 /* If port_id greater that what portid_t can represent, return */
3645 if(tmp >= RTE_MAX_ETHPORTS)
3647 port_id = (portid_t)tmp;
3649 if (!strcmp(res->on, "on"))
3654 if (!strcmp(res->what, "strip"))
3655 rx_vlan_strip_set(port_id, on);
3656 else if(!strcmp(res->what, "stripq")){
3657 uint16_t queue_id = 0;
3659 /* No queue_id, return */
3661 printf("must specify (port,queue_id)\n");
3664 tmp = strtoul(str + i + 1, NULL, 0);
3665 /* If queue_id greater that what 16-bits can represent, return */
3669 queue_id = (uint16_t)tmp;
3670 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3672 else if (!strcmp(res->what, "filter"))
3673 rx_vlan_filter_set(port_id, on);
3675 vlan_extend_set(port_id, on);
3680 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3681 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3683 cmdline_parse_token_string_t cmd_vlan_offload_set =
3684 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3686 cmdline_parse_token_string_t cmd_vlan_offload_what =
3687 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3688 what, "strip#filter#qinq#stripq");
3689 cmdline_parse_token_string_t cmd_vlan_offload_on =
3690 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3692 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3693 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3696 cmdline_parse_inst_t cmd_vlan_offload = {
3697 .f = cmd_vlan_offload_parsed,
3699 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3700 "<port_id[,queue_id]>: "
3701 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3703 (void *)&cmd_vlan_offload_vlan,
3704 (void *)&cmd_vlan_offload_set,
3705 (void *)&cmd_vlan_offload_what,
3706 (void *)&cmd_vlan_offload_on,
3707 (void *)&cmd_vlan_offload_portid,
3712 /* *** VLAN TPID SET ON A PORT *** */
3713 struct cmd_vlan_tpid_result {
3714 cmdline_fixed_string_t vlan;
3715 cmdline_fixed_string_t set;
3716 cmdline_fixed_string_t vlan_type;
3717 cmdline_fixed_string_t what;
3723 cmd_vlan_tpid_parsed(void *parsed_result,
3724 __attribute__((unused)) struct cmdline *cl,
3725 __attribute__((unused)) void *data)
3727 struct cmd_vlan_tpid_result *res = parsed_result;
3728 enum rte_vlan_type vlan_type;
3730 if (!strcmp(res->vlan_type, "inner"))
3731 vlan_type = ETH_VLAN_TYPE_INNER;
3732 else if (!strcmp(res->vlan_type, "outer"))
3733 vlan_type = ETH_VLAN_TYPE_OUTER;
3735 printf("Unknown vlan type\n");
3738 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3741 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3742 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3744 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3745 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3747 cmdline_parse_token_string_t cmd_vlan_type =
3748 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3749 vlan_type, "inner#outer");
3750 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3751 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3753 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3754 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3756 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3757 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3760 cmdline_parse_inst_t cmd_vlan_tpid = {
3761 .f = cmd_vlan_tpid_parsed,
3763 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3764 "Set the VLAN Ether type",
3766 (void *)&cmd_vlan_tpid_vlan,
3767 (void *)&cmd_vlan_tpid_set,
3768 (void *)&cmd_vlan_type,
3769 (void *)&cmd_vlan_tpid_what,
3770 (void *)&cmd_vlan_tpid_tpid,
3771 (void *)&cmd_vlan_tpid_portid,
3776 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3777 struct cmd_rx_vlan_filter_result {
3778 cmdline_fixed_string_t rx_vlan;
3779 cmdline_fixed_string_t what;
3785 cmd_rx_vlan_filter_parsed(void *parsed_result,
3786 __attribute__((unused)) struct cmdline *cl,
3787 __attribute__((unused)) void *data)
3789 struct cmd_rx_vlan_filter_result *res = parsed_result;
3791 if (!strcmp(res->what, "add"))
3792 rx_vft_set(res->port_id, res->vlan_id, 1);
3794 rx_vft_set(res->port_id, res->vlan_id, 0);
3797 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3798 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3799 rx_vlan, "rx_vlan");
3800 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3801 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3803 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3804 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3806 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3807 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3810 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3811 .f = cmd_rx_vlan_filter_parsed,
3813 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3814 "Add/Remove a VLAN identifier to/from the set of VLAN "
3815 "identifiers filtered by a port",
3817 (void *)&cmd_rx_vlan_filter_rx_vlan,
3818 (void *)&cmd_rx_vlan_filter_what,
3819 (void *)&cmd_rx_vlan_filter_vlanid,
3820 (void *)&cmd_rx_vlan_filter_portid,
3825 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3826 struct cmd_tx_vlan_set_result {
3827 cmdline_fixed_string_t tx_vlan;
3828 cmdline_fixed_string_t set;
3834 cmd_tx_vlan_set_parsed(void *parsed_result,
3835 __attribute__((unused)) struct cmdline *cl,
3836 __attribute__((unused)) void *data)
3838 struct cmd_tx_vlan_set_result *res = parsed_result;
3840 if (!port_is_stopped(res->port_id)) {
3841 printf("Please stop port %d first\n", res->port_id);
3845 tx_vlan_set(res->port_id, res->vlan_id);
3847 cmd_reconfig_device_queue(res->port_id, 1, 1);
3850 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3851 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3852 tx_vlan, "tx_vlan");
3853 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3854 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3856 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3857 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3859 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3860 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3863 cmdline_parse_inst_t cmd_tx_vlan_set = {
3864 .f = cmd_tx_vlan_set_parsed,
3866 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3867 "Enable hardware insertion of a single VLAN header "
3868 "with a given TAG Identifier in packets sent on a port",
3870 (void *)&cmd_tx_vlan_set_tx_vlan,
3871 (void *)&cmd_tx_vlan_set_set,
3872 (void *)&cmd_tx_vlan_set_portid,
3873 (void *)&cmd_tx_vlan_set_vlanid,
3878 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3879 struct cmd_tx_vlan_set_qinq_result {
3880 cmdline_fixed_string_t tx_vlan;
3881 cmdline_fixed_string_t set;
3884 uint16_t vlan_id_outer;
3888 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3889 __attribute__((unused)) struct cmdline *cl,
3890 __attribute__((unused)) void *data)
3892 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3894 if (!port_is_stopped(res->port_id)) {
3895 printf("Please stop port %d first\n", res->port_id);
3899 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3901 cmd_reconfig_device_queue(res->port_id, 1, 1);
3904 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3905 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3906 tx_vlan, "tx_vlan");
3907 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3908 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3910 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3911 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3913 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3914 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3916 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3917 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3918 vlan_id_outer, UINT16);
3920 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3921 .f = cmd_tx_vlan_set_qinq_parsed,
3923 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3924 "Enable hardware insertion of double VLAN header "
3925 "with given TAG Identifiers in packets sent on a port",
3927 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3928 (void *)&cmd_tx_vlan_set_qinq_set,
3929 (void *)&cmd_tx_vlan_set_qinq_portid,
3930 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3931 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3936 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3937 struct cmd_tx_vlan_set_pvid_result {
3938 cmdline_fixed_string_t tx_vlan;
3939 cmdline_fixed_string_t set;
3940 cmdline_fixed_string_t pvid;
3943 cmdline_fixed_string_t mode;
3947 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3948 __attribute__((unused)) struct cmdline *cl,
3949 __attribute__((unused)) void *data)
3951 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3953 if (strcmp(res->mode, "on") == 0)
3954 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3956 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3959 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3960 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3961 tx_vlan, "tx_vlan");
3962 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3963 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3965 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3966 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3968 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3969 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3971 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3972 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3974 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3975 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3978 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3979 .f = cmd_tx_vlan_set_pvid_parsed,
3981 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3983 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3984 (void *)&cmd_tx_vlan_set_pvid_set,
3985 (void *)&cmd_tx_vlan_set_pvid_pvid,
3986 (void *)&cmd_tx_vlan_set_pvid_port_id,
3987 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3988 (void *)&cmd_tx_vlan_set_pvid_mode,
3993 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3994 struct cmd_tx_vlan_reset_result {
3995 cmdline_fixed_string_t tx_vlan;
3996 cmdline_fixed_string_t reset;
4001 cmd_tx_vlan_reset_parsed(void *parsed_result,
4002 __attribute__((unused)) struct cmdline *cl,
4003 __attribute__((unused)) void *data)
4005 struct cmd_tx_vlan_reset_result *res = parsed_result;
4007 if (!port_is_stopped(res->port_id)) {
4008 printf("Please stop port %d first\n", res->port_id);
4012 tx_vlan_reset(res->port_id);
4014 cmd_reconfig_device_queue(res->port_id, 1, 1);
4017 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4018 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4019 tx_vlan, "tx_vlan");
4020 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4021 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4023 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4024 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4027 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4028 .f = cmd_tx_vlan_reset_parsed,
4030 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4031 "VLAN header in packets sent on a port",
4033 (void *)&cmd_tx_vlan_reset_tx_vlan,
4034 (void *)&cmd_tx_vlan_reset_reset,
4035 (void *)&cmd_tx_vlan_reset_portid,
4041 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4042 struct cmd_csum_result {
4043 cmdline_fixed_string_t csum;
4044 cmdline_fixed_string_t mode;
4045 cmdline_fixed_string_t proto;
4046 cmdline_fixed_string_t hwsw;
4051 csum_show(int port_id)
4053 struct rte_eth_dev_info dev_info;
4054 uint64_t tx_offloads;
4056 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4057 printf("Parse tunnel is %s\n",
4058 (ports[port_id].parse_tunnel) ? "on" : "off");
4059 printf("IP checksum offload is %s\n",
4060 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4061 printf("UDP checksum offload is %s\n",
4062 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4063 printf("TCP checksum offload is %s\n",
4064 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4065 printf("SCTP checksum offload is %s\n",
4066 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4067 printf("Outer-Ip checksum offload is %s\n",
4068 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4070 /* display warnings if configuration is not supported by the NIC */
4071 rte_eth_dev_info_get(port_id, &dev_info);
4072 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4073 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4074 printf("Warning: hardware IP checksum enabled but not "
4075 "supported by port %d\n", port_id);
4077 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4078 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4079 printf("Warning: hardware UDP checksum enabled but not "
4080 "supported by port %d\n", port_id);
4082 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4083 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4084 printf("Warning: hardware TCP checksum enabled but not "
4085 "supported by port %d\n", port_id);
4087 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4088 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4089 printf("Warning: hardware SCTP checksum enabled but not "
4090 "supported by port %d\n", port_id);
4092 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4093 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4094 printf("Warning: hardware outer IP checksum enabled but not "
4095 "supported by port %d\n", port_id);
4100 cmd_csum_parsed(void *parsed_result,
4101 __attribute__((unused)) struct cmdline *cl,
4102 __attribute__((unused)) void *data)
4104 struct cmd_csum_result *res = parsed_result;
4106 uint64_t csum_offloads = 0;
4107 struct rte_eth_dev_info dev_info;
4109 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4110 printf("invalid port %d\n", res->port_id);
4113 if (!port_is_stopped(res->port_id)) {
4114 printf("Please stop port %d first\n", res->port_id);
4118 rte_eth_dev_info_get(res->port_id, &dev_info);
4119 if (!strcmp(res->mode, "set")) {
4121 if (!strcmp(res->hwsw, "hw"))
4124 if (!strcmp(res->proto, "ip")) {
4125 if (hw == 0 || (dev_info.tx_offload_capa &
4126 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4127 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4129 printf("IP checksum offload is not supported "
4130 "by port %u\n", res->port_id);
4132 } else if (!strcmp(res->proto, "udp")) {
4133 if (hw == 0 || (dev_info.tx_offload_capa &
4134 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4135 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4137 printf("UDP checksum offload is not supported "
4138 "by port %u\n", res->port_id);
4140 } else if (!strcmp(res->proto, "tcp")) {
4141 if (hw == 0 || (dev_info.tx_offload_capa &
4142 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4143 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4145 printf("TCP checksum offload is not supported "
4146 "by port %u\n", res->port_id);
4148 } else if (!strcmp(res->proto, "sctp")) {
4149 if (hw == 0 || (dev_info.tx_offload_capa &
4150 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4151 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4153 printf("SCTP checksum offload is not supported "
4154 "by port %u\n", res->port_id);
4156 } else if (!strcmp(res->proto, "outer-ip")) {
4157 if (hw == 0 || (dev_info.tx_offload_capa &
4158 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4160 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4162 printf("Outer IP checksum offload is not "
4163 "supported by port %u\n", res->port_id);
4168 ports[res->port_id].dev_conf.txmode.offloads |=
4171 ports[res->port_id].dev_conf.txmode.offloads &=
4175 csum_show(res->port_id);
4177 cmd_reconfig_device_queue(res->port_id, 1, 1);
4180 cmdline_parse_token_string_t cmd_csum_csum =
4181 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4183 cmdline_parse_token_string_t cmd_csum_mode =
4184 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4186 cmdline_parse_token_string_t cmd_csum_proto =
4187 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4188 proto, "ip#tcp#udp#sctp#outer-ip");
4189 cmdline_parse_token_string_t cmd_csum_hwsw =
4190 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4192 cmdline_parse_token_num_t cmd_csum_portid =
4193 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4196 cmdline_parse_inst_t cmd_csum_set = {
4197 .f = cmd_csum_parsed,
4199 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4200 "Enable/Disable hardware calculation of L3/L4 checksum when "
4201 "using csum forward engine",
4203 (void *)&cmd_csum_csum,
4204 (void *)&cmd_csum_mode,
4205 (void *)&cmd_csum_proto,
4206 (void *)&cmd_csum_hwsw,
4207 (void *)&cmd_csum_portid,
4212 cmdline_parse_token_string_t cmd_csum_mode_show =
4213 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4216 cmdline_parse_inst_t cmd_csum_show = {
4217 .f = cmd_csum_parsed,
4219 .help_str = "csum show <port_id>: Show checksum offload configuration",
4221 (void *)&cmd_csum_csum,
4222 (void *)&cmd_csum_mode_show,
4223 (void *)&cmd_csum_portid,
4228 /* Enable/disable tunnel parsing */
4229 struct cmd_csum_tunnel_result {
4230 cmdline_fixed_string_t csum;
4231 cmdline_fixed_string_t parse;
4232 cmdline_fixed_string_t onoff;
4237 cmd_csum_tunnel_parsed(void *parsed_result,
4238 __attribute__((unused)) struct cmdline *cl,
4239 __attribute__((unused)) void *data)
4241 struct cmd_csum_tunnel_result *res = parsed_result;
4243 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4246 if (!strcmp(res->onoff, "on"))
4247 ports[res->port_id].parse_tunnel = 1;
4249 ports[res->port_id].parse_tunnel = 0;
4251 csum_show(res->port_id);
4254 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4255 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4257 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4258 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4259 parse, "parse_tunnel");
4260 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4261 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4263 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4264 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4267 cmdline_parse_inst_t cmd_csum_tunnel = {
4268 .f = cmd_csum_tunnel_parsed,
4270 .help_str = "csum parse_tunnel on|off <port_id>: "
4271 "Enable/Disable parsing of tunnels for csum engine",
4273 (void *)&cmd_csum_tunnel_csum,
4274 (void *)&cmd_csum_tunnel_parse,
4275 (void *)&cmd_csum_tunnel_onoff,
4276 (void *)&cmd_csum_tunnel_portid,
4281 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4282 struct cmd_tso_set_result {
4283 cmdline_fixed_string_t tso;
4284 cmdline_fixed_string_t mode;
4290 cmd_tso_set_parsed(void *parsed_result,
4291 __attribute__((unused)) struct cmdline *cl,
4292 __attribute__((unused)) void *data)
4294 struct cmd_tso_set_result *res = parsed_result;
4295 struct rte_eth_dev_info dev_info;
4297 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4299 if (!port_is_stopped(res->port_id)) {
4300 printf("Please stop port %d first\n", res->port_id);
4304 if (!strcmp(res->mode, "set"))
4305 ports[res->port_id].tso_segsz = res->tso_segsz;
4307 rte_eth_dev_info_get(res->port_id, &dev_info);
4308 if ((ports[res->port_id].tso_segsz != 0) &&
4309 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4310 printf("Error: TSO is not supported by port %d\n",
4315 if (ports[res->port_id].tso_segsz == 0) {
4316 ports[res->port_id].dev_conf.txmode.offloads &=
4317 ~DEV_TX_OFFLOAD_TCP_TSO;
4318 printf("TSO for non-tunneled packets is disabled\n");
4320 ports[res->port_id].dev_conf.txmode.offloads |=
4321 DEV_TX_OFFLOAD_TCP_TSO;
4322 printf("TSO segment size for non-tunneled packets is %d\n",
4323 ports[res->port_id].tso_segsz);
4326 /* display warnings if configuration is not supported by the NIC */
4327 rte_eth_dev_info_get(res->port_id, &dev_info);
4328 if ((ports[res->port_id].tso_segsz != 0) &&
4329 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4330 printf("Warning: TSO enabled but not "
4331 "supported by port %d\n", res->port_id);
4334 cmd_reconfig_device_queue(res->port_id, 1, 1);
4337 cmdline_parse_token_string_t cmd_tso_set_tso =
4338 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4340 cmdline_parse_token_string_t cmd_tso_set_mode =
4341 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4343 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4344 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4346 cmdline_parse_token_num_t cmd_tso_set_portid =
4347 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4350 cmdline_parse_inst_t cmd_tso_set = {
4351 .f = cmd_tso_set_parsed,
4353 .help_str = "tso set <tso_segsz> <port_id>: "
4354 "Set TSO segment size of non-tunneled packets for csum engine "
4357 (void *)&cmd_tso_set_tso,
4358 (void *)&cmd_tso_set_mode,
4359 (void *)&cmd_tso_set_tso_segsz,
4360 (void *)&cmd_tso_set_portid,
4365 cmdline_parse_token_string_t cmd_tso_show_mode =
4366 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4370 cmdline_parse_inst_t cmd_tso_show = {
4371 .f = cmd_tso_set_parsed,
4373 .help_str = "tso show <port_id>: "
4374 "Show TSO segment size of non-tunneled packets for csum engine",
4376 (void *)&cmd_tso_set_tso,
4377 (void *)&cmd_tso_show_mode,
4378 (void *)&cmd_tso_set_portid,
4383 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4384 struct cmd_tunnel_tso_set_result {
4385 cmdline_fixed_string_t tso;
4386 cmdline_fixed_string_t mode;
4391 static struct rte_eth_dev_info
4392 check_tunnel_tso_nic_support(portid_t port_id)
4394 struct rte_eth_dev_info dev_info;
4396 rte_eth_dev_info_get(port_id, &dev_info);
4397 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4398 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4399 "not enabled for port %d\n", port_id);
4400 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4401 printf("Warning: GRE TUNNEL TSO not supported therefore "
4402 "not enabled for port %d\n", port_id);
4403 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4404 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4405 "not enabled for port %d\n", port_id);
4406 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4407 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4408 "not enabled for port %d\n", port_id);
4409 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4410 printf("Warning: IP TUNNEL TSO not supported therefore "
4411 "not enabled for port %d\n", port_id);
4412 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4413 printf("Warning: UDP TUNNEL TSO not supported therefore "
4414 "not enabled for port %d\n", port_id);
4419 cmd_tunnel_tso_set_parsed(void *parsed_result,
4420 __attribute__((unused)) struct cmdline *cl,
4421 __attribute__((unused)) void *data)
4423 struct cmd_tunnel_tso_set_result *res = parsed_result;
4424 struct rte_eth_dev_info dev_info;
4426 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4428 if (!port_is_stopped(res->port_id)) {
4429 printf("Please stop port %d first\n", res->port_id);
4433 if (!strcmp(res->mode, "set"))
4434 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4436 dev_info = check_tunnel_tso_nic_support(res->port_id);
4437 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4438 ports[res->port_id].dev_conf.txmode.offloads &=
4439 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4440 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4441 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4442 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4443 DEV_TX_OFFLOAD_IP_TNL_TSO |
4444 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4445 printf("TSO for tunneled packets is disabled\n");
4447 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4448 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4449 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4450 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4451 DEV_TX_OFFLOAD_IP_TNL_TSO |
4452 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4454 ports[res->port_id].dev_conf.txmode.offloads |=
4455 (tso_offloads & dev_info.tx_offload_capa);
4456 printf("TSO segment size for tunneled packets is %d\n",
4457 ports[res->port_id].tunnel_tso_segsz);
4459 /* Below conditions are needed to make it work:
4460 * (1) tunnel TSO is supported by the NIC;
4461 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4463 * (3) for tunneled pkts with outer L3 of IPv4,
4464 * "csum set outer-ip" must be set to hw, because after tso,
4465 * total_len of outer IP header is changed, and the checksum
4466 * of outer IP header calculated by sw should be wrong; that
4467 * is not necessary for IPv6 tunneled pkts because there's no
4468 * checksum in IP header anymore.
4471 if (!ports[res->port_id].parse_tunnel)
4472 printf("Warning: csum parse_tunnel must be set "
4473 "so that tunneled packets are recognized\n");
4474 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4475 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4476 printf("Warning: csum set outer-ip must be set to hw "
4477 "if outer L3 is IPv4; not necessary for IPv6\n");
4480 cmd_reconfig_device_queue(res->port_id, 1, 1);
4483 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4484 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4486 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4487 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4489 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4490 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4492 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4493 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4496 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4497 .f = cmd_tunnel_tso_set_parsed,
4499 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4500 "Set TSO segment size of tunneled packets for csum engine "
4503 (void *)&cmd_tunnel_tso_set_tso,
4504 (void *)&cmd_tunnel_tso_set_mode,
4505 (void *)&cmd_tunnel_tso_set_tso_segsz,
4506 (void *)&cmd_tunnel_tso_set_portid,
4511 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4512 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4516 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4517 .f = cmd_tunnel_tso_set_parsed,
4519 .help_str = "tunnel_tso show <port_id> "
4520 "Show TSO segment size of tunneled packets for csum engine",
4522 (void *)&cmd_tunnel_tso_set_tso,
4523 (void *)&cmd_tunnel_tso_show_mode,
4524 (void *)&cmd_tunnel_tso_set_portid,
4529 /* *** SET GRO FOR A PORT *** */
4530 struct cmd_gro_enable_result {
4531 cmdline_fixed_string_t cmd_set;
4532 cmdline_fixed_string_t cmd_port;
4533 cmdline_fixed_string_t cmd_keyword;
4534 cmdline_fixed_string_t cmd_onoff;
4539 cmd_gro_enable_parsed(void *parsed_result,
4540 __attribute__((unused)) struct cmdline *cl,
4541 __attribute__((unused)) void *data)
4543 struct cmd_gro_enable_result *res;
4545 res = parsed_result;
4546 if (!strcmp(res->cmd_keyword, "gro"))
4547 setup_gro(res->cmd_onoff, res->cmd_pid);
4550 cmdline_parse_token_string_t cmd_gro_enable_set =
4551 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4553 cmdline_parse_token_string_t cmd_gro_enable_port =
4554 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4555 cmd_keyword, "port");
4556 cmdline_parse_token_num_t cmd_gro_enable_pid =
4557 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4559 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4560 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4561 cmd_keyword, "gro");
4562 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4563 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4564 cmd_onoff, "on#off");
4566 cmdline_parse_inst_t cmd_gro_enable = {
4567 .f = cmd_gro_enable_parsed,
4569 .help_str = "set port <port_id> gro on|off",
4571 (void *)&cmd_gro_enable_set,
4572 (void *)&cmd_gro_enable_port,
4573 (void *)&cmd_gro_enable_pid,
4574 (void *)&cmd_gro_enable_keyword,
4575 (void *)&cmd_gro_enable_onoff,
4580 /* *** DISPLAY GRO CONFIGURATION *** */
4581 struct cmd_gro_show_result {
4582 cmdline_fixed_string_t cmd_show;
4583 cmdline_fixed_string_t cmd_port;
4584 cmdline_fixed_string_t cmd_keyword;
4589 cmd_gro_show_parsed(void *parsed_result,
4590 __attribute__((unused)) struct cmdline *cl,
4591 __attribute__((unused)) void *data)
4593 struct cmd_gro_show_result *res;
4595 res = parsed_result;
4596 if (!strcmp(res->cmd_keyword, "gro"))
4597 show_gro(res->cmd_pid);
4600 cmdline_parse_token_string_t cmd_gro_show_show =
4601 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4603 cmdline_parse_token_string_t cmd_gro_show_port =
4604 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4606 cmdline_parse_token_num_t cmd_gro_show_pid =
4607 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4609 cmdline_parse_token_string_t cmd_gro_show_keyword =
4610 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4611 cmd_keyword, "gro");
4613 cmdline_parse_inst_t cmd_gro_show = {
4614 .f = cmd_gro_show_parsed,
4616 .help_str = "show port <port_id> gro",
4618 (void *)&cmd_gro_show_show,
4619 (void *)&cmd_gro_show_port,
4620 (void *)&cmd_gro_show_pid,
4621 (void *)&cmd_gro_show_keyword,
4626 /* *** SET FLUSH CYCLES FOR GRO *** */
4627 struct cmd_gro_flush_result {
4628 cmdline_fixed_string_t cmd_set;
4629 cmdline_fixed_string_t cmd_keyword;
4630 cmdline_fixed_string_t cmd_flush;
4635 cmd_gro_flush_parsed(void *parsed_result,
4636 __attribute__((unused)) struct cmdline *cl,
4637 __attribute__((unused)) void *data)
4639 struct cmd_gro_flush_result *res;
4641 res = parsed_result;
4642 if ((!strcmp(res->cmd_keyword, "gro")) &&
4643 (!strcmp(res->cmd_flush, "flush")))
4644 setup_gro_flush_cycles(res->cmd_cycles);
4647 cmdline_parse_token_string_t cmd_gro_flush_set =
4648 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4650 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4651 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4652 cmd_keyword, "gro");
4653 cmdline_parse_token_string_t cmd_gro_flush_flush =
4654 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4655 cmd_flush, "flush");
4656 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4657 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4660 cmdline_parse_inst_t cmd_gro_flush = {
4661 .f = cmd_gro_flush_parsed,
4663 .help_str = "set gro flush <cycles>",
4665 (void *)&cmd_gro_flush_set,
4666 (void *)&cmd_gro_flush_keyword,
4667 (void *)&cmd_gro_flush_flush,
4668 (void *)&cmd_gro_flush_cycles,
4673 /* *** ENABLE/DISABLE GSO *** */
4674 struct cmd_gso_enable_result {
4675 cmdline_fixed_string_t cmd_set;
4676 cmdline_fixed_string_t cmd_port;
4677 cmdline_fixed_string_t cmd_keyword;
4678 cmdline_fixed_string_t cmd_mode;
4683 cmd_gso_enable_parsed(void *parsed_result,
4684 __attribute__((unused)) struct cmdline *cl,
4685 __attribute__((unused)) void *data)
4687 struct cmd_gso_enable_result *res;
4689 res = parsed_result;
4690 if (!strcmp(res->cmd_keyword, "gso"))
4691 setup_gso(res->cmd_mode, res->cmd_pid);
4694 cmdline_parse_token_string_t cmd_gso_enable_set =
4695 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4697 cmdline_parse_token_string_t cmd_gso_enable_port =
4698 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4700 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4701 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4702 cmd_keyword, "gso");
4703 cmdline_parse_token_string_t cmd_gso_enable_mode =
4704 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4705 cmd_mode, "on#off");
4706 cmdline_parse_token_num_t cmd_gso_enable_pid =
4707 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4710 cmdline_parse_inst_t cmd_gso_enable = {
4711 .f = cmd_gso_enable_parsed,
4713 .help_str = "set port <port_id> gso on|off",
4715 (void *)&cmd_gso_enable_set,
4716 (void *)&cmd_gso_enable_port,
4717 (void *)&cmd_gso_enable_pid,
4718 (void *)&cmd_gso_enable_keyword,
4719 (void *)&cmd_gso_enable_mode,
4724 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4725 struct cmd_gso_size_result {
4726 cmdline_fixed_string_t cmd_set;
4727 cmdline_fixed_string_t cmd_keyword;
4728 cmdline_fixed_string_t cmd_segsz;
4733 cmd_gso_size_parsed(void *parsed_result,
4734 __attribute__((unused)) struct cmdline *cl,
4735 __attribute__((unused)) void *data)
4737 struct cmd_gso_size_result *res = parsed_result;
4739 if (test_done == 0) {
4740 printf("Before setting GSO segsz, please first"
4741 " stop fowarding\n");
4745 if (!strcmp(res->cmd_keyword, "gso") &&
4746 !strcmp(res->cmd_segsz, "segsz")) {
4747 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4748 printf("gso_size should be larger than %zu."
4749 " Please input a legal value\n",
4750 RTE_GSO_SEG_SIZE_MIN);
4752 gso_max_segment_size = res->cmd_size;
4756 cmdline_parse_token_string_t cmd_gso_size_set =
4757 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4759 cmdline_parse_token_string_t cmd_gso_size_keyword =
4760 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4761 cmd_keyword, "gso");
4762 cmdline_parse_token_string_t cmd_gso_size_segsz =
4763 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4764 cmd_segsz, "segsz");
4765 cmdline_parse_token_num_t cmd_gso_size_size =
4766 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4769 cmdline_parse_inst_t cmd_gso_size = {
4770 .f = cmd_gso_size_parsed,
4772 .help_str = "set gso segsz <length>",
4774 (void *)&cmd_gso_size_set,
4775 (void *)&cmd_gso_size_keyword,
4776 (void *)&cmd_gso_size_segsz,
4777 (void *)&cmd_gso_size_size,
4782 /* *** SHOW GSO CONFIGURATION *** */
4783 struct cmd_gso_show_result {
4784 cmdline_fixed_string_t cmd_show;
4785 cmdline_fixed_string_t cmd_port;
4786 cmdline_fixed_string_t cmd_keyword;
4791 cmd_gso_show_parsed(void *parsed_result,
4792 __attribute__((unused)) struct cmdline *cl,
4793 __attribute__((unused)) void *data)
4795 struct cmd_gso_show_result *res = parsed_result;
4797 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4798 printf("invalid port id %u\n", res->cmd_pid);
4801 if (!strcmp(res->cmd_keyword, "gso")) {
4802 if (gso_ports[res->cmd_pid].enable) {
4803 printf("Max GSO'd packet size: %uB\n"
4804 "Supported GSO types: TCP/IPv4, "
4805 "UDP/IPv4, VxLAN with inner "
4806 "TCP/IPv4 packet, GRE with inner "
4807 "TCP/IPv4 packet\n",
4808 gso_max_segment_size);
4810 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4814 cmdline_parse_token_string_t cmd_gso_show_show =
4815 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4817 cmdline_parse_token_string_t cmd_gso_show_port =
4818 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4820 cmdline_parse_token_string_t cmd_gso_show_keyword =
4821 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4822 cmd_keyword, "gso");
4823 cmdline_parse_token_num_t cmd_gso_show_pid =
4824 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4827 cmdline_parse_inst_t cmd_gso_show = {
4828 .f = cmd_gso_show_parsed,
4830 .help_str = "show port <port_id> gso",
4832 (void *)&cmd_gso_show_show,
4833 (void *)&cmd_gso_show_port,
4834 (void *)&cmd_gso_show_pid,
4835 (void *)&cmd_gso_show_keyword,
4840 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4841 struct cmd_set_flush_rx {
4842 cmdline_fixed_string_t set;
4843 cmdline_fixed_string_t flush_rx;
4844 cmdline_fixed_string_t mode;
4848 cmd_set_flush_rx_parsed(void *parsed_result,
4849 __attribute__((unused)) struct cmdline *cl,
4850 __attribute__((unused)) void *data)
4852 struct cmd_set_flush_rx *res = parsed_result;
4853 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4856 cmdline_parse_token_string_t cmd_setflushrx_set =
4857 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4859 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4860 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4861 flush_rx, "flush_rx");
4862 cmdline_parse_token_string_t cmd_setflushrx_mode =
4863 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4867 cmdline_parse_inst_t cmd_set_flush_rx = {
4868 .f = cmd_set_flush_rx_parsed,
4869 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4872 (void *)&cmd_setflushrx_set,
4873 (void *)&cmd_setflushrx_flush_rx,
4874 (void *)&cmd_setflushrx_mode,
4879 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4880 struct cmd_set_link_check {
4881 cmdline_fixed_string_t set;
4882 cmdline_fixed_string_t link_check;
4883 cmdline_fixed_string_t mode;
4887 cmd_set_link_check_parsed(void *parsed_result,
4888 __attribute__((unused)) struct cmdline *cl,
4889 __attribute__((unused)) void *data)
4891 struct cmd_set_link_check *res = parsed_result;
4892 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4895 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4896 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4898 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4899 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4900 link_check, "link_check");
4901 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4902 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4906 cmdline_parse_inst_t cmd_set_link_check = {
4907 .f = cmd_set_link_check_parsed,
4908 .help_str = "set link_check on|off: Enable/Disable link status check "
4909 "when starting/stopping a port",
4912 (void *)&cmd_setlinkcheck_set,
4913 (void *)&cmd_setlinkcheck_link_check,
4914 (void *)&cmd_setlinkcheck_mode,
4919 /* *** SET NIC BYPASS MODE *** */
4920 struct cmd_set_bypass_mode_result {
4921 cmdline_fixed_string_t set;
4922 cmdline_fixed_string_t bypass;
4923 cmdline_fixed_string_t mode;
4924 cmdline_fixed_string_t value;
4929 cmd_set_bypass_mode_parsed(void *parsed_result,
4930 __attribute__((unused)) struct cmdline *cl,
4931 __attribute__((unused)) void *data)
4933 struct cmd_set_bypass_mode_result *res = parsed_result;
4934 portid_t port_id = res->port_id;
4935 int32_t rc = -EINVAL;
4937 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4938 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4940 if (!strcmp(res->value, "bypass"))
4941 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4942 else if (!strcmp(res->value, "isolate"))
4943 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4945 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4947 /* Set the bypass mode for the relevant port. */
4948 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4951 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4954 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4955 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4957 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4958 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4960 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4961 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4963 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4964 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4965 value, "normal#bypass#isolate");
4966 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4967 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4970 cmdline_parse_inst_t cmd_set_bypass_mode = {
4971 .f = cmd_set_bypass_mode_parsed,
4972 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4973 "Set the NIC bypass mode for port_id",
4976 (void *)&cmd_setbypass_mode_set,
4977 (void *)&cmd_setbypass_mode_bypass,
4978 (void *)&cmd_setbypass_mode_mode,
4979 (void *)&cmd_setbypass_mode_value,
4980 (void *)&cmd_setbypass_mode_port,
4985 /* *** SET NIC BYPASS EVENT *** */
4986 struct cmd_set_bypass_event_result {
4987 cmdline_fixed_string_t set;
4988 cmdline_fixed_string_t bypass;
4989 cmdline_fixed_string_t event;
4990 cmdline_fixed_string_t event_value;
4991 cmdline_fixed_string_t mode;
4992 cmdline_fixed_string_t mode_value;
4997 cmd_set_bypass_event_parsed(void *parsed_result,
4998 __attribute__((unused)) struct cmdline *cl,
4999 __attribute__((unused)) void *data)
5001 int32_t rc = -EINVAL;
5002 struct cmd_set_bypass_event_result *res = parsed_result;
5003 portid_t port_id = res->port_id;
5005 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5006 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5007 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5009 if (!strcmp(res->event_value, "timeout"))
5010 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5011 else if (!strcmp(res->event_value, "os_on"))
5012 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5013 else if (!strcmp(res->event_value, "os_off"))
5014 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5015 else if (!strcmp(res->event_value, "power_on"))
5016 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5017 else if (!strcmp(res->event_value, "power_off"))
5018 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5020 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5022 if (!strcmp(res->mode_value, "bypass"))
5023 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5024 else if (!strcmp(res->mode_value, "isolate"))
5025 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5027 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5029 /* Set the watchdog timeout. */
5030 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5033 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5034 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5038 printf("Failed to set timeout value %u "
5039 "for port %d, errto code: %d.\n",
5040 bypass_timeout, port_id, rc);
5044 /* Set the bypass event to transition to bypass mode. */
5045 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5050 printf("\t Failed to set bypass event for port = %d.\n",
5054 cmdline_parse_token_string_t cmd_setbypass_event_set =
5055 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5057 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5058 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5060 cmdline_parse_token_string_t cmd_setbypass_event_event =
5061 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5063 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5064 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5065 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5066 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5067 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5069 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5070 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5071 mode_value, "normal#bypass#isolate");
5072 cmdline_parse_token_num_t cmd_setbypass_event_port =
5073 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5076 cmdline_parse_inst_t cmd_set_bypass_event = {
5077 .f = cmd_set_bypass_event_parsed,
5078 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5079 "power_off mode normal|bypass|isolate <port_id>: "
5080 "Set the NIC bypass event mode for port_id",
5083 (void *)&cmd_setbypass_event_set,
5084 (void *)&cmd_setbypass_event_bypass,
5085 (void *)&cmd_setbypass_event_event,
5086 (void *)&cmd_setbypass_event_event_value,
5087 (void *)&cmd_setbypass_event_mode,
5088 (void *)&cmd_setbypass_event_mode_value,
5089 (void *)&cmd_setbypass_event_port,
5095 /* *** SET NIC BYPASS TIMEOUT *** */
5096 struct cmd_set_bypass_timeout_result {
5097 cmdline_fixed_string_t set;
5098 cmdline_fixed_string_t bypass;
5099 cmdline_fixed_string_t timeout;
5100 cmdline_fixed_string_t value;
5104 cmd_set_bypass_timeout_parsed(void *parsed_result,
5105 __attribute__((unused)) struct cmdline *cl,
5106 __attribute__((unused)) void *data)
5108 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5110 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5111 if (!strcmp(res->value, "1.5"))
5112 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5113 else if (!strcmp(res->value, "2"))
5114 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5115 else if (!strcmp(res->value, "3"))
5116 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5117 else if (!strcmp(res->value, "4"))
5118 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5119 else if (!strcmp(res->value, "8"))
5120 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5121 else if (!strcmp(res->value, "16"))
5122 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5123 else if (!strcmp(res->value, "32"))
5124 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5126 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5130 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5131 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5133 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5134 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5136 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5137 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5138 timeout, "timeout");
5139 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5140 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5141 value, "0#1.5#2#3#4#8#16#32");
5143 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5144 .f = cmd_set_bypass_timeout_parsed,
5145 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5146 "Set the NIC bypass watchdog timeout in seconds",
5149 (void *)&cmd_setbypass_timeout_set,
5150 (void *)&cmd_setbypass_timeout_bypass,
5151 (void *)&cmd_setbypass_timeout_timeout,
5152 (void *)&cmd_setbypass_timeout_value,
5157 /* *** SHOW NIC BYPASS MODE *** */
5158 struct cmd_show_bypass_config_result {
5159 cmdline_fixed_string_t show;
5160 cmdline_fixed_string_t bypass;
5161 cmdline_fixed_string_t config;
5166 cmd_show_bypass_config_parsed(void *parsed_result,
5167 __attribute__((unused)) struct cmdline *cl,
5168 __attribute__((unused)) void *data)
5170 struct cmd_show_bypass_config_result *res = parsed_result;
5171 portid_t port_id = res->port_id;
5173 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5174 uint32_t event_mode;
5175 uint32_t bypass_mode;
5176 uint32_t timeout = bypass_timeout;
5179 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5180 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5181 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5182 {"UNKNOWN", "normal", "bypass", "isolate"};
5183 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5190 int num_events = (sizeof events) / (sizeof events[0]);
5192 /* Display the bypass mode.*/
5193 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5194 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5198 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5199 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5201 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5204 /* Display the bypass timeout.*/
5205 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5206 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5208 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5210 /* Display the bypass events and associated modes. */
5211 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5213 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5214 printf("\tFailed to get bypass mode for event = %s\n",
5217 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5218 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5220 printf("\tbypass event: %-16s = %s\n", events[i],
5226 printf("\tFailed to get bypass configuration for port = %d\n",
5230 cmdline_parse_token_string_t cmd_showbypass_config_show =
5231 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5233 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5234 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5236 cmdline_parse_token_string_t cmd_showbypass_config_config =
5237 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5239 cmdline_parse_token_num_t cmd_showbypass_config_port =
5240 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5243 cmdline_parse_inst_t cmd_show_bypass_config = {
5244 .f = cmd_show_bypass_config_parsed,
5245 .help_str = "show bypass config <port_id>: "
5246 "Show the NIC bypass config for port_id",
5249 (void *)&cmd_showbypass_config_show,
5250 (void *)&cmd_showbypass_config_bypass,
5251 (void *)&cmd_showbypass_config_config,
5252 (void *)&cmd_showbypass_config_port,
5257 #ifdef RTE_LIBRTE_PMD_BOND
5258 /* *** SET BONDING MODE *** */
5259 struct cmd_set_bonding_mode_result {
5260 cmdline_fixed_string_t set;
5261 cmdline_fixed_string_t bonding;
5262 cmdline_fixed_string_t mode;
5267 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5268 __attribute__((unused)) struct cmdline *cl,
5269 __attribute__((unused)) void *data)
5271 struct cmd_set_bonding_mode_result *res = parsed_result;
5272 portid_t port_id = res->port_id;
5274 /* Set the bonding mode for the relevant port. */
5275 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5276 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5279 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5280 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5282 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5283 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5284 bonding, "bonding");
5285 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5288 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5289 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5291 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5292 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5295 cmdline_parse_inst_t cmd_set_bonding_mode = {
5296 .f = cmd_set_bonding_mode_parsed,
5297 .help_str = "set bonding mode <mode_value> <port_id>: "
5298 "Set the bonding mode for port_id",
5301 (void *) &cmd_setbonding_mode_set,
5302 (void *) &cmd_setbonding_mode_bonding,
5303 (void *) &cmd_setbonding_mode_mode,
5304 (void *) &cmd_setbonding_mode_value,
5305 (void *) &cmd_setbonding_mode_port,
5310 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5311 struct cmd_set_bonding_lacp_dedicated_queues_result {
5312 cmdline_fixed_string_t set;
5313 cmdline_fixed_string_t bonding;
5314 cmdline_fixed_string_t lacp;
5315 cmdline_fixed_string_t dedicated_queues;
5317 cmdline_fixed_string_t mode;
5320 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5321 __attribute__((unused)) struct cmdline *cl,
5322 __attribute__((unused)) void *data)
5324 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5325 portid_t port_id = res->port_id;
5326 struct rte_port *port;
5328 port = &ports[port_id];
5330 /** Check if the port is not started **/
5331 if (port->port_status != RTE_PORT_STOPPED) {
5332 printf("Please stop port %d first\n", port_id);
5336 if (!strcmp(res->mode, "enable")) {
5337 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5338 printf("Dedicate queues for LACP control packets"
5341 printf("Enabling dedicate queues for LACP control "
5342 "packets on port %d failed\n", port_id);
5343 } else if (!strcmp(res->mode, "disable")) {
5344 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5345 printf("Dedicated queues for LACP control packets "
5348 printf("Disabling dedicated queues for LACP control "
5349 "traffic on port %d failed\n", port_id);
5353 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5354 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5356 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5357 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5358 bonding, "bonding");
5359 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5360 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5362 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5363 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5364 dedicated_queues, "dedicated_queues");
5365 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5366 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5368 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5369 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5370 mode, "enable#disable");
5372 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5373 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5374 .help_str = "set bonding lacp dedicated_queues <port_id> "
5376 "Enable/disable dedicated queues for LACP control traffic for port_id",
5379 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5380 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5381 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5382 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5383 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5384 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5389 /* *** SET BALANCE XMIT POLICY *** */
5390 struct cmd_set_bonding_balance_xmit_policy_result {
5391 cmdline_fixed_string_t set;
5392 cmdline_fixed_string_t bonding;
5393 cmdline_fixed_string_t balance_xmit_policy;
5395 cmdline_fixed_string_t policy;
5398 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5399 __attribute__((unused)) struct cmdline *cl,
5400 __attribute__((unused)) void *data)
5402 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5403 portid_t port_id = res->port_id;
5406 if (!strcmp(res->policy, "l2")) {
5407 policy = BALANCE_XMIT_POLICY_LAYER2;
5408 } else if (!strcmp(res->policy, "l23")) {
5409 policy = BALANCE_XMIT_POLICY_LAYER23;
5410 } else if (!strcmp(res->policy, "l34")) {
5411 policy = BALANCE_XMIT_POLICY_LAYER34;
5413 printf("\t Invalid xmit policy selection");
5417 /* Set the bonding mode for the relevant port. */
5418 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5419 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5424 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5425 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5427 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5428 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5429 bonding, "bonding");
5430 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5431 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5432 balance_xmit_policy, "balance_xmit_policy");
5433 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5434 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5436 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5438 policy, "l2#l23#l34");
5440 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5441 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5442 .help_str = "set bonding balance_xmit_policy <port_id> "
5444 "Set the bonding balance_xmit_policy for port_id",
5447 (void *)&cmd_setbonding_balance_xmit_policy_set,
5448 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5449 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5450 (void *)&cmd_setbonding_balance_xmit_policy_port,
5451 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5456 /* *** SHOW NIC BONDING CONFIGURATION *** */
5457 struct cmd_show_bonding_config_result {
5458 cmdline_fixed_string_t show;
5459 cmdline_fixed_string_t bonding;
5460 cmdline_fixed_string_t config;
5464 static void cmd_show_bonding_config_parsed(void *parsed_result,
5465 __attribute__((unused)) struct cmdline *cl,
5466 __attribute__((unused)) void *data)
5468 struct cmd_show_bonding_config_result *res = parsed_result;
5469 int bonding_mode, agg_mode;
5470 portid_t slaves[RTE_MAX_ETHPORTS];
5471 int num_slaves, num_active_slaves;
5474 portid_t port_id = res->port_id;
5476 /* Display the bonding mode.*/
5477 bonding_mode = rte_eth_bond_mode_get(port_id);
5478 if (bonding_mode < 0) {
5479 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5482 printf("\tBonding mode: %d\n", bonding_mode);
5484 if (bonding_mode == BONDING_MODE_BALANCE) {
5485 int balance_xmit_policy;
5487 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5488 if (balance_xmit_policy < 0) {
5489 printf("\tFailed to get balance xmit policy for port = %d\n",
5493 printf("\tBalance Xmit Policy: ");
5495 switch (balance_xmit_policy) {
5496 case BALANCE_XMIT_POLICY_LAYER2:
5497 printf("BALANCE_XMIT_POLICY_LAYER2");
5499 case BALANCE_XMIT_POLICY_LAYER23:
5500 printf("BALANCE_XMIT_POLICY_LAYER23");
5502 case BALANCE_XMIT_POLICY_LAYER34:
5503 printf("BALANCE_XMIT_POLICY_LAYER34");
5510 if (bonding_mode == BONDING_MODE_8023AD) {
5511 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5512 printf("\tIEEE802.3AD Aggregator Mode: ");
5515 printf("bandwidth");
5527 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5529 if (num_slaves < 0) {
5530 printf("\tFailed to get slave list for port = %d\n", port_id);
5533 if (num_slaves > 0) {
5534 printf("\tSlaves (%d): [", num_slaves);
5535 for (i = 0; i < num_slaves - 1; i++)
5536 printf("%d ", slaves[i]);
5538 printf("%d]\n", slaves[num_slaves - 1]);
5540 printf("\tSlaves: []\n");
5544 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5547 if (num_active_slaves < 0) {
5548 printf("\tFailed to get active slave list for port = %d\n", port_id);
5551 if (num_active_slaves > 0) {
5552 printf("\tActive Slaves (%d): [", num_active_slaves);
5553 for (i = 0; i < num_active_slaves - 1; i++)
5554 printf("%d ", slaves[i]);
5556 printf("%d]\n", slaves[num_active_slaves - 1]);
5559 printf("\tActive Slaves: []\n");
5563 primary_id = rte_eth_bond_primary_get(port_id);
5564 if (primary_id < 0) {
5565 printf("\tFailed to get primary slave for port = %d\n", port_id);
5568 printf("\tPrimary: [%d]\n", primary_id);
5572 cmdline_parse_token_string_t cmd_showbonding_config_show =
5573 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5575 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5576 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5577 bonding, "bonding");
5578 cmdline_parse_token_string_t cmd_showbonding_config_config =
5579 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5581 cmdline_parse_token_num_t cmd_showbonding_config_port =
5582 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5585 cmdline_parse_inst_t cmd_show_bonding_config = {
5586 .f = cmd_show_bonding_config_parsed,
5587 .help_str = "show bonding config <port_id>: "
5588 "Show the bonding config for port_id",
5591 (void *)&cmd_showbonding_config_show,
5592 (void *)&cmd_showbonding_config_bonding,
5593 (void *)&cmd_showbonding_config_config,
5594 (void *)&cmd_showbonding_config_port,
5599 /* *** SET BONDING PRIMARY *** */
5600 struct cmd_set_bonding_primary_result {
5601 cmdline_fixed_string_t set;
5602 cmdline_fixed_string_t bonding;
5603 cmdline_fixed_string_t primary;
5608 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5609 __attribute__((unused)) struct cmdline *cl,
5610 __attribute__((unused)) void *data)
5612 struct cmd_set_bonding_primary_result *res = parsed_result;
5613 portid_t master_port_id = res->port_id;
5614 portid_t slave_port_id = res->slave_id;
5616 /* Set the primary slave for a bonded device. */
5617 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5618 printf("\t Failed to set primary slave for port = %d.\n",
5625 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5626 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5628 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5630 bonding, "bonding");
5631 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5632 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5633 primary, "primary");
5634 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5635 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5637 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5638 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5641 cmdline_parse_inst_t cmd_set_bonding_primary = {
5642 .f = cmd_set_bonding_primary_parsed,
5643 .help_str = "set bonding primary <slave_id> <port_id>: "
5644 "Set the primary slave for port_id",
5647 (void *)&cmd_setbonding_primary_set,
5648 (void *)&cmd_setbonding_primary_bonding,
5649 (void *)&cmd_setbonding_primary_primary,
5650 (void *)&cmd_setbonding_primary_slave,
5651 (void *)&cmd_setbonding_primary_port,
5656 /* *** ADD SLAVE *** */
5657 struct cmd_add_bonding_slave_result {
5658 cmdline_fixed_string_t add;
5659 cmdline_fixed_string_t bonding;
5660 cmdline_fixed_string_t slave;
5665 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5666 __attribute__((unused)) struct cmdline *cl,
5667 __attribute__((unused)) void *data)
5669 struct cmd_add_bonding_slave_result *res = parsed_result;
5670 portid_t master_port_id = res->port_id;
5671 portid_t slave_port_id = res->slave_id;
5673 /* add the slave for a bonded device. */
5674 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5675 printf("\t Failed to add slave %d to master port = %d.\n",
5676 slave_port_id, master_port_id);
5680 set_port_slave_flag(slave_port_id);
5683 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5684 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5686 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5687 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5688 bonding, "bonding");
5689 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5690 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5692 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5693 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5695 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5696 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5699 cmdline_parse_inst_t cmd_add_bonding_slave = {
5700 .f = cmd_add_bonding_slave_parsed,
5701 .help_str = "add bonding slave <slave_id> <port_id>: "
5702 "Add a slave device to a bonded device",
5705 (void *)&cmd_addbonding_slave_add,
5706 (void *)&cmd_addbonding_slave_bonding,
5707 (void *)&cmd_addbonding_slave_slave,
5708 (void *)&cmd_addbonding_slave_slaveid,
5709 (void *)&cmd_addbonding_slave_port,
5714 /* *** REMOVE SLAVE *** */
5715 struct cmd_remove_bonding_slave_result {
5716 cmdline_fixed_string_t remove;
5717 cmdline_fixed_string_t bonding;
5718 cmdline_fixed_string_t slave;
5723 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5724 __attribute__((unused)) struct cmdline *cl,
5725 __attribute__((unused)) void *data)
5727 struct cmd_remove_bonding_slave_result *res = parsed_result;
5728 portid_t master_port_id = res->port_id;
5729 portid_t slave_port_id = res->slave_id;
5731 /* remove the slave from a bonded device. */
5732 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5733 printf("\t Failed to remove slave %d from master port = %d.\n",
5734 slave_port_id, master_port_id);
5738 clear_port_slave_flag(slave_port_id);
5741 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5742 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5744 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5745 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5746 bonding, "bonding");
5747 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5748 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5750 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5751 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5753 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5754 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5757 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5758 .f = cmd_remove_bonding_slave_parsed,
5759 .help_str = "remove bonding slave <slave_id> <port_id>: "
5760 "Remove a slave device from a bonded device",
5763 (void *)&cmd_removebonding_slave_remove,
5764 (void *)&cmd_removebonding_slave_bonding,
5765 (void *)&cmd_removebonding_slave_slave,
5766 (void *)&cmd_removebonding_slave_slaveid,
5767 (void *)&cmd_removebonding_slave_port,
5772 /* *** CREATE BONDED DEVICE *** */
5773 struct cmd_create_bonded_device_result {
5774 cmdline_fixed_string_t create;
5775 cmdline_fixed_string_t bonded;
5776 cmdline_fixed_string_t device;
5781 static int bond_dev_num = 0;
5783 static void cmd_create_bonded_device_parsed(void *parsed_result,
5784 __attribute__((unused)) struct cmdline *cl,
5785 __attribute__((unused)) void *data)
5787 struct cmd_create_bonded_device_result *res = parsed_result;
5788 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5791 if (test_done == 0) {
5792 printf("Please stop forwarding first\n");
5796 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5799 /* Create a new bonded device. */
5800 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5802 printf("\t Failed to create bonded device.\n");
5805 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5808 /* Update number of ports */
5809 nb_ports = rte_eth_dev_count_avail();
5810 reconfig(port_id, res->socket);
5811 rte_eth_promiscuous_enable(port_id);
5816 cmdline_parse_token_string_t cmd_createbonded_device_create =
5817 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5819 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5820 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5822 cmdline_parse_token_string_t cmd_createbonded_device_device =
5823 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5825 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5826 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5828 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5829 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5832 cmdline_parse_inst_t cmd_create_bonded_device = {
5833 .f = cmd_create_bonded_device_parsed,
5834 .help_str = "create bonded device <mode> <socket>: "
5835 "Create a new bonded device with specific bonding mode and socket",
5838 (void *)&cmd_createbonded_device_create,
5839 (void *)&cmd_createbonded_device_bonded,
5840 (void *)&cmd_createbonded_device_device,
5841 (void *)&cmd_createbonded_device_mode,
5842 (void *)&cmd_createbonded_device_socket,
5847 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5848 struct cmd_set_bond_mac_addr_result {
5849 cmdline_fixed_string_t set;
5850 cmdline_fixed_string_t bonding;
5851 cmdline_fixed_string_t mac_addr;
5853 struct ether_addr address;
5856 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5857 __attribute__((unused)) struct cmdline *cl,
5858 __attribute__((unused)) void *data)
5860 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5863 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5866 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5868 /* check the return value and print it if is < 0 */
5870 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5873 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5874 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5875 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5876 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5878 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5879 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5881 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5882 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5884 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5885 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5887 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5888 .f = cmd_set_bond_mac_addr_parsed,
5890 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5892 (void *)&cmd_set_bond_mac_addr_set,
5893 (void *)&cmd_set_bond_mac_addr_bonding,
5894 (void *)&cmd_set_bond_mac_addr_mac,
5895 (void *)&cmd_set_bond_mac_addr_portnum,
5896 (void *)&cmd_set_bond_mac_addr_addr,
5902 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5903 struct cmd_set_bond_mon_period_result {
5904 cmdline_fixed_string_t set;
5905 cmdline_fixed_string_t bonding;
5906 cmdline_fixed_string_t mon_period;
5911 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5912 __attribute__((unused)) struct cmdline *cl,
5913 __attribute__((unused)) void *data)
5915 struct cmd_set_bond_mon_period_result *res = parsed_result;
5918 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5920 /* check the return value and print it if is < 0 */
5922 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5925 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5926 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5928 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5929 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5930 bonding, "bonding");
5931 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5932 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5933 mon_period, "mon_period");
5934 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5935 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5937 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5938 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5941 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5942 .f = cmd_set_bond_mon_period_parsed,
5944 .help_str = "set bonding mon_period <port_id> <period_ms>",
5946 (void *)&cmd_set_bond_mon_period_set,
5947 (void *)&cmd_set_bond_mon_period_bonding,
5948 (void *)&cmd_set_bond_mon_period_mon_period,
5949 (void *)&cmd_set_bond_mon_period_portnum,
5950 (void *)&cmd_set_bond_mon_period_period_ms,
5957 struct cmd_set_bonding_agg_mode_policy_result {
5958 cmdline_fixed_string_t set;
5959 cmdline_fixed_string_t bonding;
5960 cmdline_fixed_string_t agg_mode;
5962 cmdline_fixed_string_t policy;
5967 cmd_set_bonding_agg_mode(void *parsed_result,
5968 __attribute__((unused)) struct cmdline *cl,
5969 __attribute__((unused)) void *data)
5971 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5972 uint8_t policy = AGG_BANDWIDTH;
5974 if (!strcmp(res->policy, "bandwidth"))
5975 policy = AGG_BANDWIDTH;
5976 else if (!strcmp(res->policy, "stable"))
5977 policy = AGG_STABLE;
5978 else if (!strcmp(res->policy, "count"))
5981 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5985 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5986 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5988 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5989 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5990 bonding, "bonding");
5992 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5993 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5994 agg_mode, "agg_mode");
5996 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5997 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6000 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6001 TOKEN_STRING_INITIALIZER(
6002 struct cmd_set_bonding_balance_xmit_policy_result,
6003 policy, "stable#bandwidth#count");
6005 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6006 .f = cmd_set_bonding_agg_mode,
6008 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6010 (void *)&cmd_set_bonding_agg_mode_set,
6011 (void *)&cmd_set_bonding_agg_mode_bonding,
6012 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6013 (void *)&cmd_set_bonding_agg_mode_portnum,
6014 (void *)&cmd_set_bonding_agg_mode_policy_string,
6020 #endif /* RTE_LIBRTE_PMD_BOND */
6022 /* *** SET FORWARDING MODE *** */
6023 struct cmd_set_fwd_mode_result {
6024 cmdline_fixed_string_t set;
6025 cmdline_fixed_string_t fwd;
6026 cmdline_fixed_string_t mode;
6029 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6030 __attribute__((unused)) struct cmdline *cl,
6031 __attribute__((unused)) void *data)
6033 struct cmd_set_fwd_mode_result *res = parsed_result;
6036 set_pkt_forwarding_mode(res->mode);
6039 cmdline_parse_token_string_t cmd_setfwd_set =
6040 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6041 cmdline_parse_token_string_t cmd_setfwd_fwd =
6042 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6043 cmdline_parse_token_string_t cmd_setfwd_mode =
6044 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6045 "" /* defined at init */);
6047 cmdline_parse_inst_t cmd_set_fwd_mode = {
6048 .f = cmd_set_fwd_mode_parsed,
6050 .help_str = NULL, /* defined at init */
6052 (void *)&cmd_setfwd_set,
6053 (void *)&cmd_setfwd_fwd,
6054 (void *)&cmd_setfwd_mode,
6059 static void cmd_set_fwd_mode_init(void)
6062 static char token[128];
6063 static char help[256];
6064 cmdline_parse_token_string_t *token_struct;
6066 modes = list_pkt_forwarding_modes();
6067 snprintf(help, sizeof(help), "set fwd %s: "
6068 "Set packet forwarding mode", modes);
6069 cmd_set_fwd_mode.help_str = help;
6071 /* string token separator is # */
6072 for (c = token; *modes != '\0'; modes++)
6077 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6078 token_struct->string_data.str = token;
6081 /* *** SET RETRY FORWARDING MODE *** */
6082 struct cmd_set_fwd_retry_mode_result {
6083 cmdline_fixed_string_t set;
6084 cmdline_fixed_string_t fwd;
6085 cmdline_fixed_string_t mode;
6086 cmdline_fixed_string_t retry;
6089 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6090 __attribute__((unused)) struct cmdline *cl,
6091 __attribute__((unused)) void *data)
6093 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6096 set_pkt_forwarding_mode(res->mode);
6099 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6100 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6102 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6103 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6105 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6106 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6108 "" /* defined at init */);
6109 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6113 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6114 .f = cmd_set_fwd_retry_mode_parsed,
6116 .help_str = NULL, /* defined at init */
6118 (void *)&cmd_setfwd_retry_set,
6119 (void *)&cmd_setfwd_retry_fwd,
6120 (void *)&cmd_setfwd_retry_mode,
6121 (void *)&cmd_setfwd_retry_retry,
6126 static void cmd_set_fwd_retry_mode_init(void)
6129 static char token[128];
6130 static char help[256];
6131 cmdline_parse_token_string_t *token_struct;
6133 modes = list_pkt_forwarding_retry_modes();
6134 snprintf(help, sizeof(help), "set fwd %s retry: "
6135 "Set packet forwarding mode with retry", modes);
6136 cmd_set_fwd_retry_mode.help_str = help;
6138 /* string token separator is # */
6139 for (c = token; *modes != '\0'; modes++)
6144 token_struct = (cmdline_parse_token_string_t *)
6145 cmd_set_fwd_retry_mode.tokens[2];
6146 token_struct->string_data.str = token;
6149 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6150 struct cmd_set_burst_tx_retry_result {
6151 cmdline_fixed_string_t set;
6152 cmdline_fixed_string_t burst;
6153 cmdline_fixed_string_t tx;
6154 cmdline_fixed_string_t delay;
6156 cmdline_fixed_string_t retry;
6160 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6161 __attribute__((unused)) struct cmdline *cl,
6162 __attribute__((unused)) void *data)
6164 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6166 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6167 && !strcmp(res->tx, "tx")) {
6168 if (!strcmp(res->delay, "delay"))
6169 burst_tx_delay_time = res->time;
6170 if (!strcmp(res->retry, "retry"))
6171 burst_tx_retry_num = res->retry_num;
6176 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6177 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6178 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6179 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6181 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6182 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6183 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6184 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6185 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6186 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6187 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6188 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6189 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6190 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6192 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6193 .f = cmd_set_burst_tx_retry_parsed,
6194 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6196 (void *)&cmd_set_burst_tx_retry_set,
6197 (void *)&cmd_set_burst_tx_retry_burst,
6198 (void *)&cmd_set_burst_tx_retry_tx,
6199 (void *)&cmd_set_burst_tx_retry_delay,
6200 (void *)&cmd_set_burst_tx_retry_time,
6201 (void *)&cmd_set_burst_tx_retry_retry,
6202 (void *)&cmd_set_burst_tx_retry_retry_num,
6207 /* *** SET PROMISC MODE *** */
6208 struct cmd_set_promisc_mode_result {
6209 cmdline_fixed_string_t set;
6210 cmdline_fixed_string_t promisc;
6211 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6212 uint16_t port_num; /* valid if "allports" argument == 0 */
6213 cmdline_fixed_string_t mode;
6216 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6217 __attribute__((unused)) struct cmdline *cl,
6220 struct cmd_set_promisc_mode_result *res = parsed_result;
6224 if (!strcmp(res->mode, "on"))
6231 RTE_ETH_FOREACH_DEV(i) {
6233 rte_eth_promiscuous_enable(i);
6235 rte_eth_promiscuous_disable(i);
6240 rte_eth_promiscuous_enable(res->port_num);
6242 rte_eth_promiscuous_disable(res->port_num);
6246 cmdline_parse_token_string_t cmd_setpromisc_set =
6247 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6248 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6249 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6251 cmdline_parse_token_string_t cmd_setpromisc_portall =
6252 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6254 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6255 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6257 cmdline_parse_token_string_t cmd_setpromisc_mode =
6258 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6261 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6262 .f = cmd_set_promisc_mode_parsed,
6264 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6266 (void *)&cmd_setpromisc_set,
6267 (void *)&cmd_setpromisc_promisc,
6268 (void *)&cmd_setpromisc_portall,
6269 (void *)&cmd_setpromisc_mode,
6274 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6275 .f = cmd_set_promisc_mode_parsed,
6277 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6279 (void *)&cmd_setpromisc_set,
6280 (void *)&cmd_setpromisc_promisc,
6281 (void *)&cmd_setpromisc_portnum,
6282 (void *)&cmd_setpromisc_mode,
6287 /* *** SET ALLMULTI MODE *** */
6288 struct cmd_set_allmulti_mode_result {
6289 cmdline_fixed_string_t set;
6290 cmdline_fixed_string_t allmulti;
6291 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6292 uint16_t port_num; /* valid if "allports" argument == 0 */
6293 cmdline_fixed_string_t mode;
6296 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6297 __attribute__((unused)) struct cmdline *cl,
6300 struct cmd_set_allmulti_mode_result *res = parsed_result;
6304 if (!strcmp(res->mode, "on"))
6311 RTE_ETH_FOREACH_DEV(i) {
6313 rte_eth_allmulticast_enable(i);
6315 rte_eth_allmulticast_disable(i);
6320 rte_eth_allmulticast_enable(res->port_num);
6322 rte_eth_allmulticast_disable(res->port_num);
6326 cmdline_parse_token_string_t cmd_setallmulti_set =
6327 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6328 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6329 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6331 cmdline_parse_token_string_t cmd_setallmulti_portall =
6332 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6334 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6335 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6337 cmdline_parse_token_string_t cmd_setallmulti_mode =
6338 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6341 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6342 .f = cmd_set_allmulti_mode_parsed,
6344 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6346 (void *)&cmd_setallmulti_set,
6347 (void *)&cmd_setallmulti_allmulti,
6348 (void *)&cmd_setallmulti_portall,
6349 (void *)&cmd_setallmulti_mode,
6354 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6355 .f = cmd_set_allmulti_mode_parsed,
6357 .help_str = "set allmulti <port_id> on|off: "
6358 "Set allmulti mode on port_id",
6360 (void *)&cmd_setallmulti_set,
6361 (void *)&cmd_setallmulti_allmulti,
6362 (void *)&cmd_setallmulti_portnum,
6363 (void *)&cmd_setallmulti_mode,
6368 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6369 struct cmd_link_flow_ctrl_set_result {
6370 cmdline_fixed_string_t set;
6371 cmdline_fixed_string_t flow_ctrl;
6372 cmdline_fixed_string_t rx;
6373 cmdline_fixed_string_t rx_lfc_mode;
6374 cmdline_fixed_string_t tx;
6375 cmdline_fixed_string_t tx_lfc_mode;
6376 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6377 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6378 cmdline_fixed_string_t autoneg_str;
6379 cmdline_fixed_string_t autoneg;
6380 cmdline_fixed_string_t hw_str;
6381 uint32_t high_water;
6382 cmdline_fixed_string_t lw_str;
6384 cmdline_fixed_string_t pt_str;
6385 uint16_t pause_time;
6386 cmdline_fixed_string_t xon_str;
6391 cmdline_parse_token_string_t cmd_lfc_set_set =
6392 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6394 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6395 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6396 flow_ctrl, "flow_ctrl");
6397 cmdline_parse_token_string_t cmd_lfc_set_rx =
6398 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6400 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6401 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6402 rx_lfc_mode, "on#off");
6403 cmdline_parse_token_string_t cmd_lfc_set_tx =
6404 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6406 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6407 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6408 tx_lfc_mode, "on#off");
6409 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6410 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6411 hw_str, "high_water");
6412 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6413 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6414 high_water, UINT32);
6415 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6416 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6417 lw_str, "low_water");
6418 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6419 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6421 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6423 pt_str, "pause_time");
6424 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6425 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6426 pause_time, UINT16);
6427 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6429 xon_str, "send_xon");
6430 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6431 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6433 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6434 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6435 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6436 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6437 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6438 mac_ctrl_frame_fwd_mode, "on#off");
6439 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6440 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6441 autoneg_str, "autoneg");
6442 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6443 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6445 cmdline_parse_token_num_t cmd_lfc_set_portid =
6446 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6449 /* forward declaration */
6451 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6454 cmdline_parse_inst_t cmd_link_flow_control_set = {
6455 .f = cmd_link_flow_ctrl_set_parsed,
6457 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6458 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6459 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6461 (void *)&cmd_lfc_set_set,
6462 (void *)&cmd_lfc_set_flow_ctrl,
6463 (void *)&cmd_lfc_set_rx,
6464 (void *)&cmd_lfc_set_rx_mode,
6465 (void *)&cmd_lfc_set_tx,
6466 (void *)&cmd_lfc_set_tx_mode,
6467 (void *)&cmd_lfc_set_high_water,
6468 (void *)&cmd_lfc_set_low_water,
6469 (void *)&cmd_lfc_set_pause_time,
6470 (void *)&cmd_lfc_set_send_xon,
6471 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6472 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6473 (void *)&cmd_lfc_set_autoneg_str,
6474 (void *)&cmd_lfc_set_autoneg,
6475 (void *)&cmd_lfc_set_portid,
6480 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6481 .f = cmd_link_flow_ctrl_set_parsed,
6482 .data = (void *)&cmd_link_flow_control_set_rx,
6483 .help_str = "set flow_ctrl rx on|off <port_id>: "
6484 "Change rx flow control parameter",
6486 (void *)&cmd_lfc_set_set,
6487 (void *)&cmd_lfc_set_flow_ctrl,
6488 (void *)&cmd_lfc_set_rx,
6489 (void *)&cmd_lfc_set_rx_mode,
6490 (void *)&cmd_lfc_set_portid,
6495 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6496 .f = cmd_link_flow_ctrl_set_parsed,
6497 .data = (void *)&cmd_link_flow_control_set_tx,
6498 .help_str = "set flow_ctrl tx on|off <port_id>: "
6499 "Change tx flow control parameter",
6501 (void *)&cmd_lfc_set_set,
6502 (void *)&cmd_lfc_set_flow_ctrl,
6503 (void *)&cmd_lfc_set_tx,
6504 (void *)&cmd_lfc_set_tx_mode,
6505 (void *)&cmd_lfc_set_portid,
6510 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6511 .f = cmd_link_flow_ctrl_set_parsed,
6512 .data = (void *)&cmd_link_flow_control_set_hw,
6513 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6514 "Change high water flow control parameter",
6516 (void *)&cmd_lfc_set_set,
6517 (void *)&cmd_lfc_set_flow_ctrl,
6518 (void *)&cmd_lfc_set_high_water_str,
6519 (void *)&cmd_lfc_set_high_water,
6520 (void *)&cmd_lfc_set_portid,
6525 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6526 .f = cmd_link_flow_ctrl_set_parsed,
6527 .data = (void *)&cmd_link_flow_control_set_lw,
6528 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6529 "Change low water flow control parameter",
6531 (void *)&cmd_lfc_set_set,
6532 (void *)&cmd_lfc_set_flow_ctrl,
6533 (void *)&cmd_lfc_set_low_water_str,
6534 (void *)&cmd_lfc_set_low_water,
6535 (void *)&cmd_lfc_set_portid,
6540 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6541 .f = cmd_link_flow_ctrl_set_parsed,
6542 .data = (void *)&cmd_link_flow_control_set_pt,
6543 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6544 "Change pause time flow control parameter",
6546 (void *)&cmd_lfc_set_set,
6547 (void *)&cmd_lfc_set_flow_ctrl,
6548 (void *)&cmd_lfc_set_pause_time_str,
6549 (void *)&cmd_lfc_set_pause_time,
6550 (void *)&cmd_lfc_set_portid,
6555 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6556 .f = cmd_link_flow_ctrl_set_parsed,
6557 .data = (void *)&cmd_link_flow_control_set_xon,
6558 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6559 "Change send_xon flow control parameter",
6561 (void *)&cmd_lfc_set_set,
6562 (void *)&cmd_lfc_set_flow_ctrl,
6563 (void *)&cmd_lfc_set_send_xon_str,
6564 (void *)&cmd_lfc_set_send_xon,
6565 (void *)&cmd_lfc_set_portid,
6570 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6571 .f = cmd_link_flow_ctrl_set_parsed,
6572 .data = (void *)&cmd_link_flow_control_set_macfwd,
6573 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6574 "Change mac ctrl fwd flow control parameter",
6576 (void *)&cmd_lfc_set_set,
6577 (void *)&cmd_lfc_set_flow_ctrl,
6578 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6579 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6580 (void *)&cmd_lfc_set_portid,
6585 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6586 .f = cmd_link_flow_ctrl_set_parsed,
6587 .data = (void *)&cmd_link_flow_control_set_autoneg,
6588 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6589 "Change autoneg flow control parameter",
6591 (void *)&cmd_lfc_set_set,
6592 (void *)&cmd_lfc_set_flow_ctrl,
6593 (void *)&cmd_lfc_set_autoneg_str,
6594 (void *)&cmd_lfc_set_autoneg,
6595 (void *)&cmd_lfc_set_portid,
6601 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6602 __attribute__((unused)) struct cmdline *cl,
6605 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6606 cmdline_parse_inst_t *cmd = data;
6607 struct rte_eth_fc_conf fc_conf;
6613 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6614 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6615 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6616 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6618 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6619 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6622 /* Partial command line, retrieve current configuration */
6624 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6626 printf("cannot get current flow ctrl parameters, return"
6627 "code = %d\n", ret);
6631 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6632 (fc_conf.mode == RTE_FC_FULL))
6634 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6635 (fc_conf.mode == RTE_FC_FULL))
6639 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6640 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6642 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6643 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6645 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6647 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6648 fc_conf.high_water = res->high_water;
6650 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6651 fc_conf.low_water = res->low_water;
6653 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6654 fc_conf.pause_time = res->pause_time;
6656 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6657 fc_conf.send_xon = res->send_xon;
6659 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6660 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6661 fc_conf.mac_ctrl_frame_fwd = 1;
6663 fc_conf.mac_ctrl_frame_fwd = 0;
6666 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6667 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6669 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6671 printf("bad flow contrl parameter, return code = %d \n", ret);
6674 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6675 struct cmd_priority_flow_ctrl_set_result {
6676 cmdline_fixed_string_t set;
6677 cmdline_fixed_string_t pfc_ctrl;
6678 cmdline_fixed_string_t rx;
6679 cmdline_fixed_string_t rx_pfc_mode;
6680 cmdline_fixed_string_t tx;
6681 cmdline_fixed_string_t tx_pfc_mode;
6682 uint32_t high_water;
6684 uint16_t pause_time;
6690 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6691 __attribute__((unused)) struct cmdline *cl,
6692 __attribute__((unused)) void *data)
6694 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6695 struct rte_eth_pfc_conf pfc_conf;
6696 int rx_fc_enable, tx_fc_enable;
6700 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6701 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6702 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6703 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6705 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6706 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6709 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6710 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6711 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6712 pfc_conf.fc.high_water = res->high_water;
6713 pfc_conf.fc.low_water = res->low_water;
6714 pfc_conf.fc.pause_time = res->pause_time;
6715 pfc_conf.priority = res->priority;
6717 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6719 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6722 cmdline_parse_token_string_t cmd_pfc_set_set =
6723 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6725 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6726 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6727 pfc_ctrl, "pfc_ctrl");
6728 cmdline_parse_token_string_t cmd_pfc_set_rx =
6729 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6731 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6732 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6733 rx_pfc_mode, "on#off");
6734 cmdline_parse_token_string_t cmd_pfc_set_tx =
6735 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6737 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6738 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6739 tx_pfc_mode, "on#off");
6740 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6741 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6742 high_water, UINT32);
6743 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6744 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6746 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6747 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6748 pause_time, UINT16);
6749 cmdline_parse_token_num_t cmd_pfc_set_priority =
6750 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6752 cmdline_parse_token_num_t cmd_pfc_set_portid =
6753 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6756 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6757 .f = cmd_priority_flow_ctrl_set_parsed,
6759 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6760 "<pause_time> <priority> <port_id>: "
6761 "Configure the Ethernet priority flow control",
6763 (void *)&cmd_pfc_set_set,
6764 (void *)&cmd_pfc_set_flow_ctrl,
6765 (void *)&cmd_pfc_set_rx,
6766 (void *)&cmd_pfc_set_rx_mode,
6767 (void *)&cmd_pfc_set_tx,
6768 (void *)&cmd_pfc_set_tx_mode,
6769 (void *)&cmd_pfc_set_high_water,
6770 (void *)&cmd_pfc_set_low_water,
6771 (void *)&cmd_pfc_set_pause_time,
6772 (void *)&cmd_pfc_set_priority,
6773 (void *)&cmd_pfc_set_portid,
6778 /* *** RESET CONFIGURATION *** */
6779 struct cmd_reset_result {
6780 cmdline_fixed_string_t reset;
6781 cmdline_fixed_string_t def;
6784 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6786 __attribute__((unused)) void *data)
6788 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6789 set_def_fwd_config();
6792 cmdline_parse_token_string_t cmd_reset_set =
6793 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6794 cmdline_parse_token_string_t cmd_reset_def =
6795 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6798 cmdline_parse_inst_t cmd_reset = {
6799 .f = cmd_reset_parsed,
6801 .help_str = "set default: Reset default forwarding configuration",
6803 (void *)&cmd_reset_set,
6804 (void *)&cmd_reset_def,
6809 /* *** START FORWARDING *** */
6810 struct cmd_start_result {
6811 cmdline_fixed_string_t start;
6814 cmdline_parse_token_string_t cmd_start_start =
6815 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6817 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6818 __attribute__((unused)) struct cmdline *cl,
6819 __attribute__((unused)) void *data)
6821 start_packet_forwarding(0);
6824 cmdline_parse_inst_t cmd_start = {
6825 .f = cmd_start_parsed,
6827 .help_str = "start: Start packet forwarding",
6829 (void *)&cmd_start_start,
6834 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6835 struct cmd_start_tx_first_result {
6836 cmdline_fixed_string_t start;
6837 cmdline_fixed_string_t tx_first;
6841 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6842 __attribute__((unused)) struct cmdline *cl,
6843 __attribute__((unused)) void *data)
6845 start_packet_forwarding(1);
6848 cmdline_parse_token_string_t cmd_start_tx_first_start =
6849 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6851 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6852 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6853 tx_first, "tx_first");
6855 cmdline_parse_inst_t cmd_start_tx_first = {
6856 .f = cmd_start_tx_first_parsed,
6858 .help_str = "start tx_first: Start packet forwarding, "
6859 "after sending 1 burst of packets",
6861 (void *)&cmd_start_tx_first_start,
6862 (void *)&cmd_start_tx_first_tx_first,
6867 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6868 struct cmd_start_tx_first_n_result {
6869 cmdline_fixed_string_t start;
6870 cmdline_fixed_string_t tx_first;
6875 cmd_start_tx_first_n_parsed(void *parsed_result,
6876 __attribute__((unused)) struct cmdline *cl,
6877 __attribute__((unused)) void *data)
6879 struct cmd_start_tx_first_n_result *res = parsed_result;
6881 start_packet_forwarding(res->tx_num);
6884 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6885 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6887 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6888 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6889 tx_first, "tx_first");
6890 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6891 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6894 cmdline_parse_inst_t cmd_start_tx_first_n = {
6895 .f = cmd_start_tx_first_n_parsed,
6897 .help_str = "start tx_first <num>: "
6898 "packet forwarding, after sending <num> bursts of packets",
6900 (void *)&cmd_start_tx_first_n_start,
6901 (void *)&cmd_start_tx_first_n_tx_first,
6902 (void *)&cmd_start_tx_first_n_tx_num,
6907 /* *** SET LINK UP *** */
6908 struct cmd_set_link_up_result {
6909 cmdline_fixed_string_t set;
6910 cmdline_fixed_string_t link_up;
6911 cmdline_fixed_string_t port;
6915 cmdline_parse_token_string_t cmd_set_link_up_set =
6916 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6917 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6918 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6920 cmdline_parse_token_string_t cmd_set_link_up_port =
6921 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6922 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6923 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6925 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6926 __attribute__((unused)) struct cmdline *cl,
6927 __attribute__((unused)) void *data)
6929 struct cmd_set_link_up_result *res = parsed_result;
6930 dev_set_link_up(res->port_id);
6933 cmdline_parse_inst_t cmd_set_link_up = {
6934 .f = cmd_set_link_up_parsed,
6936 .help_str = "set link-up port <port id>",
6938 (void *)&cmd_set_link_up_set,
6939 (void *)&cmd_set_link_up_link_up,
6940 (void *)&cmd_set_link_up_port,
6941 (void *)&cmd_set_link_up_port_id,
6946 /* *** SET LINK DOWN *** */
6947 struct cmd_set_link_down_result {
6948 cmdline_fixed_string_t set;
6949 cmdline_fixed_string_t link_down;
6950 cmdline_fixed_string_t port;
6954 cmdline_parse_token_string_t cmd_set_link_down_set =
6955 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6956 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6957 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6959 cmdline_parse_token_string_t cmd_set_link_down_port =
6960 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6961 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6962 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6964 static void cmd_set_link_down_parsed(
6965 __attribute__((unused)) void *parsed_result,
6966 __attribute__((unused)) struct cmdline *cl,
6967 __attribute__((unused)) void *data)
6969 struct cmd_set_link_down_result *res = parsed_result;
6970 dev_set_link_down(res->port_id);
6973 cmdline_parse_inst_t cmd_set_link_down = {
6974 .f = cmd_set_link_down_parsed,
6976 .help_str = "set link-down port <port id>",
6978 (void *)&cmd_set_link_down_set,
6979 (void *)&cmd_set_link_down_link_down,
6980 (void *)&cmd_set_link_down_port,
6981 (void *)&cmd_set_link_down_port_id,
6986 /* *** SHOW CFG *** */
6987 struct cmd_showcfg_result {
6988 cmdline_fixed_string_t show;
6989 cmdline_fixed_string_t cfg;
6990 cmdline_fixed_string_t what;
6993 static void cmd_showcfg_parsed(void *parsed_result,
6994 __attribute__((unused)) struct cmdline *cl,
6995 __attribute__((unused)) void *data)
6997 struct cmd_showcfg_result *res = parsed_result;
6998 if (!strcmp(res->what, "rxtx"))
6999 rxtx_config_display();
7000 else if (!strcmp(res->what, "cores"))
7001 fwd_lcores_config_display();
7002 else if (!strcmp(res->what, "fwd"))
7003 pkt_fwd_config_display(&cur_fwd_config);
7004 else if (!strcmp(res->what, "txpkts"))
7005 show_tx_pkt_segments();
7008 cmdline_parse_token_string_t cmd_showcfg_show =
7009 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7010 cmdline_parse_token_string_t cmd_showcfg_port =
7011 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7012 cmdline_parse_token_string_t cmd_showcfg_what =
7013 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7014 "rxtx#cores#fwd#txpkts");
7016 cmdline_parse_inst_t cmd_showcfg = {
7017 .f = cmd_showcfg_parsed,
7019 .help_str = "show config rxtx|cores|fwd|txpkts",
7021 (void *)&cmd_showcfg_show,
7022 (void *)&cmd_showcfg_port,
7023 (void *)&cmd_showcfg_what,
7028 /* *** SHOW ALL PORT INFO *** */
7029 struct cmd_showportall_result {
7030 cmdline_fixed_string_t show;
7031 cmdline_fixed_string_t port;
7032 cmdline_fixed_string_t what;
7033 cmdline_fixed_string_t all;
7036 static void cmd_showportall_parsed(void *parsed_result,
7037 __attribute__((unused)) struct cmdline *cl,
7038 __attribute__((unused)) void *data)
7042 struct cmd_showportall_result *res = parsed_result;
7043 if (!strcmp(res->show, "clear")) {
7044 if (!strcmp(res->what, "stats"))
7045 RTE_ETH_FOREACH_DEV(i)
7047 else if (!strcmp(res->what, "xstats"))
7048 RTE_ETH_FOREACH_DEV(i)
7049 nic_xstats_clear(i);
7050 } else if (!strcmp(res->what, "info"))
7051 RTE_ETH_FOREACH_DEV(i)
7052 port_infos_display(i);
7053 else if (!strcmp(res->what, "stats"))
7054 RTE_ETH_FOREACH_DEV(i)
7055 nic_stats_display(i);
7056 else if (!strcmp(res->what, "xstats"))
7057 RTE_ETH_FOREACH_DEV(i)
7058 nic_xstats_display(i);
7059 else if (!strcmp(res->what, "fdir"))
7060 RTE_ETH_FOREACH_DEV(i)
7062 else if (!strcmp(res->what, "stat_qmap"))
7063 RTE_ETH_FOREACH_DEV(i)
7064 nic_stats_mapping_display(i);
7065 else if (!strcmp(res->what, "dcb_tc"))
7066 RTE_ETH_FOREACH_DEV(i)
7067 port_dcb_info_display(i);
7068 else if (!strcmp(res->what, "cap"))
7069 RTE_ETH_FOREACH_DEV(i)
7070 port_offload_cap_display(i);
7073 cmdline_parse_token_string_t cmd_showportall_show =
7074 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7076 cmdline_parse_token_string_t cmd_showportall_port =
7077 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7078 cmdline_parse_token_string_t cmd_showportall_what =
7079 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7080 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7081 cmdline_parse_token_string_t cmd_showportall_all =
7082 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7083 cmdline_parse_inst_t cmd_showportall = {
7084 .f = cmd_showportall_parsed,
7086 .help_str = "show|clear port "
7087 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7089 (void *)&cmd_showportall_show,
7090 (void *)&cmd_showportall_port,
7091 (void *)&cmd_showportall_what,
7092 (void *)&cmd_showportall_all,
7097 /* *** SHOW PORT INFO *** */
7098 struct cmd_showport_result {
7099 cmdline_fixed_string_t show;
7100 cmdline_fixed_string_t port;
7101 cmdline_fixed_string_t what;
7105 static void cmd_showport_parsed(void *parsed_result,
7106 __attribute__((unused)) struct cmdline *cl,
7107 __attribute__((unused)) void *data)
7109 struct cmd_showport_result *res = parsed_result;
7110 if (!strcmp(res->show, "clear")) {
7111 if (!strcmp(res->what, "stats"))
7112 nic_stats_clear(res->portnum);
7113 else if (!strcmp(res->what, "xstats"))
7114 nic_xstats_clear(res->portnum);
7115 } else if (!strcmp(res->what, "info"))
7116 port_infos_display(res->portnum);
7117 else if (!strcmp(res->what, "stats"))
7118 nic_stats_display(res->portnum);
7119 else if (!strcmp(res->what, "xstats"))
7120 nic_xstats_display(res->portnum);
7121 else if (!strcmp(res->what, "fdir"))
7122 fdir_get_infos(res->portnum);
7123 else if (!strcmp(res->what, "stat_qmap"))
7124 nic_stats_mapping_display(res->portnum);
7125 else if (!strcmp(res->what, "dcb_tc"))
7126 port_dcb_info_display(res->portnum);
7127 else if (!strcmp(res->what, "cap"))
7128 port_offload_cap_display(res->portnum);
7131 cmdline_parse_token_string_t cmd_showport_show =
7132 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7134 cmdline_parse_token_string_t cmd_showport_port =
7135 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7136 cmdline_parse_token_string_t cmd_showport_what =
7137 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7138 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7139 cmdline_parse_token_num_t cmd_showport_portnum =
7140 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7142 cmdline_parse_inst_t cmd_showport = {
7143 .f = cmd_showport_parsed,
7145 .help_str = "show|clear port "
7146 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7149 (void *)&cmd_showport_show,
7150 (void *)&cmd_showport_port,
7151 (void *)&cmd_showport_what,
7152 (void *)&cmd_showport_portnum,
7157 /* *** SHOW QUEUE INFO *** */
7158 struct cmd_showqueue_result {
7159 cmdline_fixed_string_t show;
7160 cmdline_fixed_string_t type;
7161 cmdline_fixed_string_t what;
7167 cmd_showqueue_parsed(void *parsed_result,
7168 __attribute__((unused)) struct cmdline *cl,
7169 __attribute__((unused)) void *data)
7171 struct cmd_showqueue_result *res = parsed_result;
7173 if (!strcmp(res->type, "rxq"))
7174 rx_queue_infos_display(res->portnum, res->queuenum);
7175 else if (!strcmp(res->type, "txq"))
7176 tx_queue_infos_display(res->portnum, res->queuenum);
7179 cmdline_parse_token_string_t cmd_showqueue_show =
7180 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7181 cmdline_parse_token_string_t cmd_showqueue_type =
7182 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7183 cmdline_parse_token_string_t cmd_showqueue_what =
7184 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7185 cmdline_parse_token_num_t cmd_showqueue_portnum =
7186 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7187 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7188 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7190 cmdline_parse_inst_t cmd_showqueue = {
7191 .f = cmd_showqueue_parsed,
7193 .help_str = "show rxq|txq info <port_id> <queue_id>",
7195 (void *)&cmd_showqueue_show,
7196 (void *)&cmd_showqueue_type,
7197 (void *)&cmd_showqueue_what,
7198 (void *)&cmd_showqueue_portnum,
7199 (void *)&cmd_showqueue_queuenum,
7204 /* *** READ PORT REGISTER *** */
7205 struct cmd_read_reg_result {
7206 cmdline_fixed_string_t read;
7207 cmdline_fixed_string_t reg;
7213 cmd_read_reg_parsed(void *parsed_result,
7214 __attribute__((unused)) struct cmdline *cl,
7215 __attribute__((unused)) void *data)
7217 struct cmd_read_reg_result *res = parsed_result;
7218 port_reg_display(res->port_id, res->reg_off);
7221 cmdline_parse_token_string_t cmd_read_reg_read =
7222 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7223 cmdline_parse_token_string_t cmd_read_reg_reg =
7224 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7225 cmdline_parse_token_num_t cmd_read_reg_port_id =
7226 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7227 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7228 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7230 cmdline_parse_inst_t cmd_read_reg = {
7231 .f = cmd_read_reg_parsed,
7233 .help_str = "read reg <port_id> <reg_off>",
7235 (void *)&cmd_read_reg_read,
7236 (void *)&cmd_read_reg_reg,
7237 (void *)&cmd_read_reg_port_id,
7238 (void *)&cmd_read_reg_reg_off,
7243 /* *** READ PORT REGISTER BIT FIELD *** */
7244 struct cmd_read_reg_bit_field_result {
7245 cmdline_fixed_string_t read;
7246 cmdline_fixed_string_t regfield;
7254 cmd_read_reg_bit_field_parsed(void *parsed_result,
7255 __attribute__((unused)) struct cmdline *cl,
7256 __attribute__((unused)) void *data)
7258 struct cmd_read_reg_bit_field_result *res = parsed_result;
7259 port_reg_bit_field_display(res->port_id, res->reg_off,
7260 res->bit1_pos, res->bit2_pos);
7263 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7264 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7266 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7267 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7268 regfield, "regfield");
7269 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7270 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7272 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7273 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7275 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7276 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7278 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7279 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7282 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7283 .f = cmd_read_reg_bit_field_parsed,
7285 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7286 "Read register bit field between bit_x and bit_y included",
7288 (void *)&cmd_read_reg_bit_field_read,
7289 (void *)&cmd_read_reg_bit_field_regfield,
7290 (void *)&cmd_read_reg_bit_field_port_id,
7291 (void *)&cmd_read_reg_bit_field_reg_off,
7292 (void *)&cmd_read_reg_bit_field_bit1_pos,
7293 (void *)&cmd_read_reg_bit_field_bit2_pos,
7298 /* *** READ PORT REGISTER BIT *** */
7299 struct cmd_read_reg_bit_result {
7300 cmdline_fixed_string_t read;
7301 cmdline_fixed_string_t regbit;
7308 cmd_read_reg_bit_parsed(void *parsed_result,
7309 __attribute__((unused)) struct cmdline *cl,
7310 __attribute__((unused)) void *data)
7312 struct cmd_read_reg_bit_result *res = parsed_result;
7313 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7316 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7317 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7318 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7319 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7321 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7322 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7323 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7324 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7325 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7326 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7328 cmdline_parse_inst_t cmd_read_reg_bit = {
7329 .f = cmd_read_reg_bit_parsed,
7331 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7333 (void *)&cmd_read_reg_bit_read,
7334 (void *)&cmd_read_reg_bit_regbit,
7335 (void *)&cmd_read_reg_bit_port_id,
7336 (void *)&cmd_read_reg_bit_reg_off,
7337 (void *)&cmd_read_reg_bit_bit_pos,
7342 /* *** WRITE PORT REGISTER *** */
7343 struct cmd_write_reg_result {
7344 cmdline_fixed_string_t write;
7345 cmdline_fixed_string_t reg;
7352 cmd_write_reg_parsed(void *parsed_result,
7353 __attribute__((unused)) struct cmdline *cl,
7354 __attribute__((unused)) void *data)
7356 struct cmd_write_reg_result *res = parsed_result;
7357 port_reg_set(res->port_id, res->reg_off, res->value);
7360 cmdline_parse_token_string_t cmd_write_reg_write =
7361 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7362 cmdline_parse_token_string_t cmd_write_reg_reg =
7363 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7364 cmdline_parse_token_num_t cmd_write_reg_port_id =
7365 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7366 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7367 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7368 cmdline_parse_token_num_t cmd_write_reg_value =
7369 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7371 cmdline_parse_inst_t cmd_write_reg = {
7372 .f = cmd_write_reg_parsed,
7374 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7376 (void *)&cmd_write_reg_write,
7377 (void *)&cmd_write_reg_reg,
7378 (void *)&cmd_write_reg_port_id,
7379 (void *)&cmd_write_reg_reg_off,
7380 (void *)&cmd_write_reg_value,
7385 /* *** WRITE PORT REGISTER BIT FIELD *** */
7386 struct cmd_write_reg_bit_field_result {
7387 cmdline_fixed_string_t write;
7388 cmdline_fixed_string_t regfield;
7397 cmd_write_reg_bit_field_parsed(void *parsed_result,
7398 __attribute__((unused)) struct cmdline *cl,
7399 __attribute__((unused)) void *data)
7401 struct cmd_write_reg_bit_field_result *res = parsed_result;
7402 port_reg_bit_field_set(res->port_id, res->reg_off,
7403 res->bit1_pos, res->bit2_pos, res->value);
7406 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7407 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7409 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7410 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7411 regfield, "regfield");
7412 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7413 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7415 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7416 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7418 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7419 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7421 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7422 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7424 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7425 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7428 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7429 .f = cmd_write_reg_bit_field_parsed,
7431 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7433 "Set register bit field between bit_x and bit_y included",
7435 (void *)&cmd_write_reg_bit_field_write,
7436 (void *)&cmd_write_reg_bit_field_regfield,
7437 (void *)&cmd_write_reg_bit_field_port_id,
7438 (void *)&cmd_write_reg_bit_field_reg_off,
7439 (void *)&cmd_write_reg_bit_field_bit1_pos,
7440 (void *)&cmd_write_reg_bit_field_bit2_pos,
7441 (void *)&cmd_write_reg_bit_field_value,
7446 /* *** WRITE PORT REGISTER BIT *** */
7447 struct cmd_write_reg_bit_result {
7448 cmdline_fixed_string_t write;
7449 cmdline_fixed_string_t regbit;
7457 cmd_write_reg_bit_parsed(void *parsed_result,
7458 __attribute__((unused)) struct cmdline *cl,
7459 __attribute__((unused)) void *data)
7461 struct cmd_write_reg_bit_result *res = parsed_result;
7462 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7465 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7466 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7468 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7469 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7471 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7472 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7473 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7474 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7475 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7476 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7477 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7478 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7480 cmdline_parse_inst_t cmd_write_reg_bit = {
7481 .f = cmd_write_reg_bit_parsed,
7483 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7486 (void *)&cmd_write_reg_bit_write,
7487 (void *)&cmd_write_reg_bit_regbit,
7488 (void *)&cmd_write_reg_bit_port_id,
7489 (void *)&cmd_write_reg_bit_reg_off,
7490 (void *)&cmd_write_reg_bit_bit_pos,
7491 (void *)&cmd_write_reg_bit_value,
7496 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7497 struct cmd_read_rxd_txd_result {
7498 cmdline_fixed_string_t read;
7499 cmdline_fixed_string_t rxd_txd;
7506 cmd_read_rxd_txd_parsed(void *parsed_result,
7507 __attribute__((unused)) struct cmdline *cl,
7508 __attribute__((unused)) void *data)
7510 struct cmd_read_rxd_txd_result *res = parsed_result;
7512 if (!strcmp(res->rxd_txd, "rxd"))
7513 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7514 else if (!strcmp(res->rxd_txd, "txd"))
7515 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7518 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7519 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7520 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7521 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7523 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7524 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7525 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7526 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7527 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7528 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7530 cmdline_parse_inst_t cmd_read_rxd_txd = {
7531 .f = cmd_read_rxd_txd_parsed,
7533 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7535 (void *)&cmd_read_rxd_txd_read,
7536 (void *)&cmd_read_rxd_txd_rxd_txd,
7537 (void *)&cmd_read_rxd_txd_port_id,
7538 (void *)&cmd_read_rxd_txd_queue_id,
7539 (void *)&cmd_read_rxd_txd_desc_id,
7545 struct cmd_quit_result {
7546 cmdline_fixed_string_t quit;
7549 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7551 __attribute__((unused)) void *data)
7557 cmdline_parse_token_string_t cmd_quit_quit =
7558 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7560 cmdline_parse_inst_t cmd_quit = {
7561 .f = cmd_quit_parsed,
7563 .help_str = "quit: Exit application",
7565 (void *)&cmd_quit_quit,
7570 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7571 struct cmd_mac_addr_result {
7572 cmdline_fixed_string_t mac_addr_cmd;
7573 cmdline_fixed_string_t what;
7575 struct ether_addr address;
7578 static void cmd_mac_addr_parsed(void *parsed_result,
7579 __attribute__((unused)) struct cmdline *cl,
7580 __attribute__((unused)) void *data)
7582 struct cmd_mac_addr_result *res = parsed_result;
7585 if (strcmp(res->what, "add") == 0)
7586 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7587 else if (strcmp(res->what, "set") == 0)
7588 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7591 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7593 /* check the return value and print it if is < 0 */
7595 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7599 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7600 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7602 cmdline_parse_token_string_t cmd_mac_addr_what =
7603 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7605 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7606 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7608 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7609 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7611 cmdline_parse_inst_t cmd_mac_addr = {
7612 .f = cmd_mac_addr_parsed,
7614 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7615 "Add/Remove/Set MAC address on port_id",
7617 (void *)&cmd_mac_addr_cmd,
7618 (void *)&cmd_mac_addr_what,
7619 (void *)&cmd_mac_addr_portnum,
7620 (void *)&cmd_mac_addr_addr,
7625 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7626 struct cmd_eth_peer_result {
7627 cmdline_fixed_string_t set;
7628 cmdline_fixed_string_t eth_peer;
7630 cmdline_fixed_string_t peer_addr;
7633 static void cmd_set_eth_peer_parsed(void *parsed_result,
7634 __attribute__((unused)) struct cmdline *cl,
7635 __attribute__((unused)) void *data)
7637 struct cmd_eth_peer_result *res = parsed_result;
7639 if (test_done == 0) {
7640 printf("Please stop forwarding first\n");
7643 if (!strcmp(res->eth_peer, "eth-peer")) {
7644 set_fwd_eth_peer(res->port_id, res->peer_addr);
7648 cmdline_parse_token_string_t cmd_eth_peer_set =
7649 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7650 cmdline_parse_token_string_t cmd_eth_peer =
7651 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7652 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7653 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7654 cmdline_parse_token_string_t cmd_eth_peer_addr =
7655 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7657 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7658 .f = cmd_set_eth_peer_parsed,
7660 .help_str = "set eth-peer <port_id> <peer_mac>",
7662 (void *)&cmd_eth_peer_set,
7663 (void *)&cmd_eth_peer,
7664 (void *)&cmd_eth_peer_port_id,
7665 (void *)&cmd_eth_peer_addr,
7670 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7671 struct cmd_set_qmap_result {
7672 cmdline_fixed_string_t set;
7673 cmdline_fixed_string_t qmap;
7674 cmdline_fixed_string_t what;
7681 cmd_set_qmap_parsed(void *parsed_result,
7682 __attribute__((unused)) struct cmdline *cl,
7683 __attribute__((unused)) void *data)
7685 struct cmd_set_qmap_result *res = parsed_result;
7686 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7688 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7691 cmdline_parse_token_string_t cmd_setqmap_set =
7692 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7694 cmdline_parse_token_string_t cmd_setqmap_qmap =
7695 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7697 cmdline_parse_token_string_t cmd_setqmap_what =
7698 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7700 cmdline_parse_token_num_t cmd_setqmap_portid =
7701 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7703 cmdline_parse_token_num_t cmd_setqmap_queueid =
7704 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7706 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7707 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7710 cmdline_parse_inst_t cmd_set_qmap = {
7711 .f = cmd_set_qmap_parsed,
7713 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7714 "Set statistics mapping value on tx|rx queue_id of port_id",
7716 (void *)&cmd_setqmap_set,
7717 (void *)&cmd_setqmap_qmap,
7718 (void *)&cmd_setqmap_what,
7719 (void *)&cmd_setqmap_portid,
7720 (void *)&cmd_setqmap_queueid,
7721 (void *)&cmd_setqmap_mapvalue,
7726 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7727 struct cmd_set_xstats_hide_zero_result {
7728 cmdline_fixed_string_t keyword;
7729 cmdline_fixed_string_t name;
7730 cmdline_fixed_string_t on_off;
7734 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7735 __attribute__((unused)) struct cmdline *cl,
7736 __attribute__((unused)) void *data)
7738 struct cmd_set_xstats_hide_zero_result *res;
7739 uint16_t on_off = 0;
7741 res = parsed_result;
7742 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7743 set_xstats_hide_zero(on_off);
7746 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7747 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7749 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7750 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7751 name, "xstats-hide-zero");
7752 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7753 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7756 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7757 .f = cmd_set_xstats_hide_zero_parsed,
7759 .help_str = "set xstats-hide-zero on|off",
7761 (void *)&cmd_set_xstats_hide_zero_keyword,
7762 (void *)&cmd_set_xstats_hide_zero_name,
7763 (void *)&cmd_set_xstats_hide_zero_on_off,
7768 /* *** CONFIGURE UNICAST HASH TABLE *** */
7769 struct cmd_set_uc_hash_table {
7770 cmdline_fixed_string_t set;
7771 cmdline_fixed_string_t port;
7773 cmdline_fixed_string_t what;
7774 struct ether_addr address;
7775 cmdline_fixed_string_t mode;
7779 cmd_set_uc_hash_parsed(void *parsed_result,
7780 __attribute__((unused)) struct cmdline *cl,
7781 __attribute__((unused)) void *data)
7784 struct cmd_set_uc_hash_table *res = parsed_result;
7786 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7788 if (strcmp(res->what, "uta") == 0)
7789 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7790 &res->address,(uint8_t)is_on);
7792 printf("bad unicast hash table parameter, return code = %d \n", ret);
7796 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7797 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7799 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7800 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7802 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7803 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7805 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7806 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7808 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7809 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7811 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7812 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7815 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7816 .f = cmd_set_uc_hash_parsed,
7818 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7820 (void *)&cmd_set_uc_hash_set,
7821 (void *)&cmd_set_uc_hash_port,
7822 (void *)&cmd_set_uc_hash_portid,
7823 (void *)&cmd_set_uc_hash_what,
7824 (void *)&cmd_set_uc_hash_mac,
7825 (void *)&cmd_set_uc_hash_mode,
7830 struct cmd_set_uc_all_hash_table {
7831 cmdline_fixed_string_t set;
7832 cmdline_fixed_string_t port;
7834 cmdline_fixed_string_t what;
7835 cmdline_fixed_string_t value;
7836 cmdline_fixed_string_t mode;
7840 cmd_set_uc_all_hash_parsed(void *parsed_result,
7841 __attribute__((unused)) struct cmdline *cl,
7842 __attribute__((unused)) void *data)
7845 struct cmd_set_uc_all_hash_table *res = parsed_result;
7847 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7849 if ((strcmp(res->what, "uta") == 0) &&
7850 (strcmp(res->value, "all") == 0))
7851 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7853 printf("bad unicast hash table parameter,"
7854 "return code = %d \n", ret);
7857 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7858 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7860 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7861 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7863 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7864 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7866 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7867 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7869 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7870 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7872 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7873 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7876 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7877 .f = cmd_set_uc_all_hash_parsed,
7879 .help_str = "set port <port_id> uta all on|off",
7881 (void *)&cmd_set_uc_all_hash_set,
7882 (void *)&cmd_set_uc_all_hash_port,
7883 (void *)&cmd_set_uc_all_hash_portid,
7884 (void *)&cmd_set_uc_all_hash_what,
7885 (void *)&cmd_set_uc_all_hash_value,
7886 (void *)&cmd_set_uc_all_hash_mode,
7891 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7892 struct cmd_set_vf_macvlan_filter {
7893 cmdline_fixed_string_t set;
7894 cmdline_fixed_string_t port;
7896 cmdline_fixed_string_t vf;
7898 struct ether_addr address;
7899 cmdline_fixed_string_t filter_type;
7900 cmdline_fixed_string_t mode;
7904 cmd_set_vf_macvlan_parsed(void *parsed_result,
7905 __attribute__((unused)) struct cmdline *cl,
7906 __attribute__((unused)) void *data)
7909 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7910 struct rte_eth_mac_filter filter;
7912 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7914 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7916 /* set VF MAC filter */
7920 filter.dst_id = res->vf_id;
7922 if (!strcmp(res->filter_type, "exact-mac"))
7923 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7924 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7925 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7926 else if (!strcmp(res->filter_type, "hashmac"))
7927 filter.filter_type = RTE_MAC_HASH_MATCH;
7928 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7929 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7931 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7934 ret = rte_eth_dev_filter_ctrl(res->port_id,
7935 RTE_ETH_FILTER_MACVLAN,
7939 ret = rte_eth_dev_filter_ctrl(res->port_id,
7940 RTE_ETH_FILTER_MACVLAN,
7941 RTE_ETH_FILTER_DELETE,
7945 printf("bad set MAC hash parameter, return code = %d\n", ret);
7949 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7950 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7952 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7953 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7955 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7956 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7958 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7959 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7961 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7962 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7964 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7965 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7967 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7968 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7969 filter_type, "exact-mac#exact-mac-vlan"
7970 "#hashmac#hashmac-vlan");
7971 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7972 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7975 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7976 .f = cmd_set_vf_macvlan_parsed,
7978 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7979 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7980 "Exact match rule: exact match of MAC or MAC and VLAN; "
7981 "hash match rule: hash match of MAC and exact match of VLAN",
7983 (void *)&cmd_set_vf_macvlan_set,
7984 (void *)&cmd_set_vf_macvlan_port,
7985 (void *)&cmd_set_vf_macvlan_portid,
7986 (void *)&cmd_set_vf_macvlan_vf,
7987 (void *)&cmd_set_vf_macvlan_vf_id,
7988 (void *)&cmd_set_vf_macvlan_mac,
7989 (void *)&cmd_set_vf_macvlan_filter_type,
7990 (void *)&cmd_set_vf_macvlan_mode,
7995 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7996 struct cmd_set_vf_traffic {
7997 cmdline_fixed_string_t set;
7998 cmdline_fixed_string_t port;
8000 cmdline_fixed_string_t vf;
8002 cmdline_fixed_string_t what;
8003 cmdline_fixed_string_t mode;
8007 cmd_set_vf_traffic_parsed(void *parsed_result,
8008 __attribute__((unused)) struct cmdline *cl,
8009 __attribute__((unused)) void *data)
8011 struct cmd_set_vf_traffic *res = parsed_result;
8012 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8013 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8015 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8018 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8019 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8021 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8022 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8024 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8025 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8027 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8028 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8030 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8031 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8033 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8034 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8036 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8037 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8040 cmdline_parse_inst_t cmd_set_vf_traffic = {
8041 .f = cmd_set_vf_traffic_parsed,
8043 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8045 (void *)&cmd_setvf_traffic_set,
8046 (void *)&cmd_setvf_traffic_port,
8047 (void *)&cmd_setvf_traffic_portid,
8048 (void *)&cmd_setvf_traffic_vf,
8049 (void *)&cmd_setvf_traffic_vfid,
8050 (void *)&cmd_setvf_traffic_what,
8051 (void *)&cmd_setvf_traffic_mode,
8056 /* *** CONFIGURE VF RECEIVE MODE *** */
8057 struct cmd_set_vf_rxmode {
8058 cmdline_fixed_string_t set;
8059 cmdline_fixed_string_t port;
8061 cmdline_fixed_string_t vf;
8063 cmdline_fixed_string_t what;
8064 cmdline_fixed_string_t mode;
8065 cmdline_fixed_string_t on;
8069 cmd_set_vf_rxmode_parsed(void *parsed_result,
8070 __attribute__((unused)) struct cmdline *cl,
8071 __attribute__((unused)) void *data)
8074 uint16_t rx_mode = 0;
8075 struct cmd_set_vf_rxmode *res = parsed_result;
8077 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8078 if (!strcmp(res->what,"rxmode")) {
8079 if (!strcmp(res->mode, "AUPE"))
8080 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8081 else if (!strcmp(res->mode, "ROPE"))
8082 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8083 else if (!strcmp(res->mode, "BAM"))
8084 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8085 else if (!strncmp(res->mode, "MPE",3))
8086 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8089 RTE_SET_USED(is_on);
8091 #ifdef RTE_LIBRTE_IXGBE_PMD
8092 if (ret == -ENOTSUP)
8093 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8094 rx_mode, (uint8_t)is_on);
8096 #ifdef RTE_LIBRTE_BNXT_PMD
8097 if (ret == -ENOTSUP)
8098 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8099 rx_mode, (uint8_t)is_on);
8102 printf("bad VF receive mode parameter, return code = %d \n",
8106 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8107 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8109 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8110 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8112 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8113 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8115 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8116 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8118 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8119 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8121 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8122 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8124 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8125 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8126 mode, "AUPE#ROPE#BAM#MPE");
8127 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8128 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8131 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8132 .f = cmd_set_vf_rxmode_parsed,
8134 .help_str = "set port <port_id> vf <vf_id> rxmode "
8135 "AUPE|ROPE|BAM|MPE on|off",
8137 (void *)&cmd_set_vf_rxmode_set,
8138 (void *)&cmd_set_vf_rxmode_port,
8139 (void *)&cmd_set_vf_rxmode_portid,
8140 (void *)&cmd_set_vf_rxmode_vf,
8141 (void *)&cmd_set_vf_rxmode_vfid,
8142 (void *)&cmd_set_vf_rxmode_what,
8143 (void *)&cmd_set_vf_rxmode_mode,
8144 (void *)&cmd_set_vf_rxmode_on,
8149 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8150 struct cmd_vf_mac_addr_result {
8151 cmdline_fixed_string_t mac_addr_cmd;
8152 cmdline_fixed_string_t what;
8153 cmdline_fixed_string_t port;
8155 cmdline_fixed_string_t vf;
8157 struct ether_addr address;
8160 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8161 __attribute__((unused)) struct cmdline *cl,
8162 __attribute__((unused)) void *data)
8164 struct cmd_vf_mac_addr_result *res = parsed_result;
8167 if (strcmp(res->what, "add") != 0)
8170 #ifdef RTE_LIBRTE_I40E_PMD
8171 if (ret == -ENOTSUP)
8172 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8175 #ifdef RTE_LIBRTE_BNXT_PMD
8176 if (ret == -ENOTSUP)
8177 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8182 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8186 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8187 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8188 mac_addr_cmd,"mac_addr");
8189 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8190 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8192 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8193 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8195 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8196 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8198 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8199 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8201 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8202 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8204 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8205 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8208 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8209 .f = cmd_vf_mac_addr_parsed,
8211 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8212 "Add MAC address filtering for a VF on port_id",
8214 (void *)&cmd_vf_mac_addr_cmd,
8215 (void *)&cmd_vf_mac_addr_what,
8216 (void *)&cmd_vf_mac_addr_port,
8217 (void *)&cmd_vf_mac_addr_portnum,
8218 (void *)&cmd_vf_mac_addr_vf,
8219 (void *)&cmd_vf_mac_addr_vfnum,
8220 (void *)&cmd_vf_mac_addr_addr,
8225 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8226 struct cmd_vf_rx_vlan_filter {
8227 cmdline_fixed_string_t rx_vlan;
8228 cmdline_fixed_string_t what;
8230 cmdline_fixed_string_t port;
8232 cmdline_fixed_string_t vf;
8237 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8238 __attribute__((unused)) struct cmdline *cl,
8239 __attribute__((unused)) void *data)
8241 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8244 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8246 #ifdef RTE_LIBRTE_IXGBE_PMD
8247 if (ret == -ENOTSUP)
8248 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8249 res->vlan_id, res->vf_mask, is_add);
8251 #ifdef RTE_LIBRTE_I40E_PMD
8252 if (ret == -ENOTSUP)
8253 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8254 res->vlan_id, res->vf_mask, is_add);
8256 #ifdef RTE_LIBRTE_BNXT_PMD
8257 if (ret == -ENOTSUP)
8258 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8259 res->vlan_id, res->vf_mask, is_add);
8266 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8267 res->vlan_id, res->vf_mask);
8270 printf("invalid port_id %d\n", res->port_id);
8273 printf("function not implemented or supported\n");
8276 printf("programming error: (%s)\n", strerror(-ret));
8280 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8281 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8282 rx_vlan, "rx_vlan");
8283 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8284 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8286 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8287 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8289 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8290 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8292 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8293 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8295 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8296 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8298 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8299 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8302 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8303 .f = cmd_vf_rx_vlan_filter_parsed,
8305 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8306 "(vf_mask = hexadecimal VF mask)",
8308 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8309 (void *)&cmd_vf_rx_vlan_filter_what,
8310 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8311 (void *)&cmd_vf_rx_vlan_filter_port,
8312 (void *)&cmd_vf_rx_vlan_filter_portid,
8313 (void *)&cmd_vf_rx_vlan_filter_vf,
8314 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8319 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8320 struct cmd_queue_rate_limit_result {
8321 cmdline_fixed_string_t set;
8322 cmdline_fixed_string_t port;
8324 cmdline_fixed_string_t queue;
8326 cmdline_fixed_string_t rate;
8330 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8331 __attribute__((unused)) struct cmdline *cl,
8332 __attribute__((unused)) void *data)
8334 struct cmd_queue_rate_limit_result *res = parsed_result;
8337 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8338 && (strcmp(res->queue, "queue") == 0)
8339 && (strcmp(res->rate, "rate") == 0))
8340 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8343 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8347 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8348 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8350 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8351 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8353 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8354 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8356 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8357 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8359 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8360 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8362 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8363 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8365 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8366 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8369 cmdline_parse_inst_t cmd_queue_rate_limit = {
8370 .f = cmd_queue_rate_limit_parsed,
8372 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8373 "Set rate limit for a queue on port_id",
8375 (void *)&cmd_queue_rate_limit_set,
8376 (void *)&cmd_queue_rate_limit_port,
8377 (void *)&cmd_queue_rate_limit_portnum,
8378 (void *)&cmd_queue_rate_limit_queue,
8379 (void *)&cmd_queue_rate_limit_queuenum,
8380 (void *)&cmd_queue_rate_limit_rate,
8381 (void *)&cmd_queue_rate_limit_ratenum,
8386 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8387 struct cmd_vf_rate_limit_result {
8388 cmdline_fixed_string_t set;
8389 cmdline_fixed_string_t port;
8391 cmdline_fixed_string_t vf;
8393 cmdline_fixed_string_t rate;
8395 cmdline_fixed_string_t q_msk;
8399 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8400 __attribute__((unused)) struct cmdline *cl,
8401 __attribute__((unused)) void *data)
8403 struct cmd_vf_rate_limit_result *res = parsed_result;
8406 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8407 && (strcmp(res->vf, "vf") == 0)
8408 && (strcmp(res->rate, "rate") == 0)
8409 && (strcmp(res->q_msk, "queue_mask") == 0))
8410 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8411 res->rate_num, res->q_msk_val);
8413 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8417 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8418 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8420 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8421 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8423 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8424 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8426 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8427 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8429 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8430 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8432 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8433 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8435 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8436 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8438 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8439 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8440 q_msk, "queue_mask");
8441 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8442 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8445 cmdline_parse_inst_t cmd_vf_rate_limit = {
8446 .f = cmd_vf_rate_limit_parsed,
8448 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8449 "queue_mask <queue_mask_value>: "
8450 "Set rate limit for queues of VF on port_id",
8452 (void *)&cmd_vf_rate_limit_set,
8453 (void *)&cmd_vf_rate_limit_port,
8454 (void *)&cmd_vf_rate_limit_portnum,
8455 (void *)&cmd_vf_rate_limit_vf,
8456 (void *)&cmd_vf_rate_limit_vfnum,
8457 (void *)&cmd_vf_rate_limit_rate,
8458 (void *)&cmd_vf_rate_limit_ratenum,
8459 (void *)&cmd_vf_rate_limit_q_msk,
8460 (void *)&cmd_vf_rate_limit_q_msk_val,
8465 /* *** ADD TUNNEL FILTER OF A PORT *** */
8466 struct cmd_tunnel_filter_result {
8467 cmdline_fixed_string_t cmd;
8468 cmdline_fixed_string_t what;
8470 struct ether_addr outer_mac;
8471 struct ether_addr inner_mac;
8472 cmdline_ipaddr_t ip_value;
8473 uint16_t inner_vlan;
8474 cmdline_fixed_string_t tunnel_type;
8475 cmdline_fixed_string_t filter_type;
8481 cmd_tunnel_filter_parsed(void *parsed_result,
8482 __attribute__((unused)) struct cmdline *cl,
8483 __attribute__((unused)) void *data)
8485 struct cmd_tunnel_filter_result *res = parsed_result;
8486 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8489 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8491 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8492 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8493 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8495 if (res->ip_value.family == AF_INET) {
8496 tunnel_filter_conf.ip_addr.ipv4_addr =
8497 res->ip_value.addr.ipv4.s_addr;
8498 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8500 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8501 &(res->ip_value.addr.ipv6),
8502 sizeof(struct in6_addr));
8503 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8506 if (!strcmp(res->filter_type, "imac-ivlan"))
8507 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8508 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8509 tunnel_filter_conf.filter_type =
8510 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8511 else if (!strcmp(res->filter_type, "imac-tenid"))
8512 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8513 else if (!strcmp(res->filter_type, "imac"))
8514 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8515 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8516 tunnel_filter_conf.filter_type =
8517 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8518 else if (!strcmp(res->filter_type, "oip"))
8519 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8520 else if (!strcmp(res->filter_type, "iip"))
8521 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8523 printf("The filter type is not supported");
8527 if (!strcmp(res->tunnel_type, "vxlan"))
8528 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8529 else if (!strcmp(res->tunnel_type, "nvgre"))
8530 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8531 else if (!strcmp(res->tunnel_type, "ipingre"))
8532 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8534 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8538 tunnel_filter_conf.tenant_id = res->tenant_id;
8539 tunnel_filter_conf.queue_id = res->queue_num;
8540 if (!strcmp(res->what, "add"))
8541 ret = rte_eth_dev_filter_ctrl(res->port_id,
8542 RTE_ETH_FILTER_TUNNEL,
8544 &tunnel_filter_conf);
8546 ret = rte_eth_dev_filter_ctrl(res->port_id,
8547 RTE_ETH_FILTER_TUNNEL,
8548 RTE_ETH_FILTER_DELETE,
8549 &tunnel_filter_conf);
8551 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8555 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8556 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8557 cmd, "tunnel_filter");
8558 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8559 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8561 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8562 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8564 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8565 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8567 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8568 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8570 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8571 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8572 inner_vlan, UINT16);
8573 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8574 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8576 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8577 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8578 tunnel_type, "vxlan#nvgre#ipingre");
8580 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8581 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8582 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8583 "imac#omac-imac-tenid");
8584 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8585 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8587 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8588 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8591 cmdline_parse_inst_t cmd_tunnel_filter = {
8592 .f = cmd_tunnel_filter_parsed,
8594 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8595 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8596 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8597 "<queue_id>: Add/Rm tunnel filter of a port",
8599 (void *)&cmd_tunnel_filter_cmd,
8600 (void *)&cmd_tunnel_filter_what,
8601 (void *)&cmd_tunnel_filter_port_id,
8602 (void *)&cmd_tunnel_filter_outer_mac,
8603 (void *)&cmd_tunnel_filter_inner_mac,
8604 (void *)&cmd_tunnel_filter_ip_value,
8605 (void *)&cmd_tunnel_filter_innner_vlan,
8606 (void *)&cmd_tunnel_filter_tunnel_type,
8607 (void *)&cmd_tunnel_filter_filter_type,
8608 (void *)&cmd_tunnel_filter_tenant_id,
8609 (void *)&cmd_tunnel_filter_queue_num,
8614 /* *** CONFIGURE TUNNEL UDP PORT *** */
8615 struct cmd_tunnel_udp_config {
8616 cmdline_fixed_string_t cmd;
8617 cmdline_fixed_string_t what;
8623 cmd_tunnel_udp_config_parsed(void *parsed_result,
8624 __attribute__((unused)) struct cmdline *cl,
8625 __attribute__((unused)) void *data)
8627 struct cmd_tunnel_udp_config *res = parsed_result;
8628 struct rte_eth_udp_tunnel tunnel_udp;
8631 tunnel_udp.udp_port = res->udp_port;
8633 if (!strcmp(res->cmd, "rx_vxlan_port"))
8634 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8636 if (!strcmp(res->what, "add"))
8637 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8640 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8644 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8647 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8648 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8649 cmd, "rx_vxlan_port");
8650 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8651 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8653 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8654 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8656 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8657 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8660 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8661 .f = cmd_tunnel_udp_config_parsed,
8663 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8664 "Add/Remove a tunneling UDP port filter",
8666 (void *)&cmd_tunnel_udp_config_cmd,
8667 (void *)&cmd_tunnel_udp_config_what,
8668 (void *)&cmd_tunnel_udp_config_udp_port,
8669 (void *)&cmd_tunnel_udp_config_port_id,
8674 struct cmd_config_tunnel_udp_port {
8675 cmdline_fixed_string_t port;
8676 cmdline_fixed_string_t config;
8678 cmdline_fixed_string_t udp_tunnel_port;
8679 cmdline_fixed_string_t action;
8680 cmdline_fixed_string_t tunnel_type;
8685 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8686 __attribute__((unused)) struct cmdline *cl,
8687 __attribute__((unused)) void *data)
8689 struct cmd_config_tunnel_udp_port *res = parsed_result;
8690 struct rte_eth_udp_tunnel tunnel_udp;
8693 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8696 tunnel_udp.udp_port = res->udp_port;
8698 if (!strcmp(res->tunnel_type, "vxlan")) {
8699 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8700 } else if (!strcmp(res->tunnel_type, "geneve")) {
8701 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8703 printf("Invalid tunnel type\n");
8707 if (!strcmp(res->action, "add"))
8708 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8711 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8715 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8718 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8719 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8721 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8722 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8724 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8725 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8727 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8728 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8731 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8732 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8734 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8735 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8737 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8738 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8741 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8742 .f = cmd_cfg_tunnel_udp_port_parsed,
8744 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8746 (void *)&cmd_config_tunnel_udp_port_port,
8747 (void *)&cmd_config_tunnel_udp_port_config,
8748 (void *)&cmd_config_tunnel_udp_port_port_id,
8749 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8750 (void *)&cmd_config_tunnel_udp_port_action,
8751 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8752 (void *)&cmd_config_tunnel_udp_port_value,
8757 /* *** GLOBAL CONFIG *** */
8758 struct cmd_global_config_result {
8759 cmdline_fixed_string_t cmd;
8761 cmdline_fixed_string_t cfg_type;
8766 cmd_global_config_parsed(void *parsed_result,
8767 __attribute__((unused)) struct cmdline *cl,
8768 __attribute__((unused)) void *data)
8770 struct cmd_global_config_result *res = parsed_result;
8771 struct rte_eth_global_cfg conf;
8774 memset(&conf, 0, sizeof(conf));
8775 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8776 conf.cfg.gre_key_len = res->len;
8777 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8778 RTE_ETH_FILTER_SET, &conf);
8780 printf("Global config error\n");
8783 cmdline_parse_token_string_t cmd_global_config_cmd =
8784 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8786 cmdline_parse_token_num_t cmd_global_config_port_id =
8787 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8789 cmdline_parse_token_string_t cmd_global_config_type =
8790 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8791 cfg_type, "gre-key-len");
8792 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8793 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8796 cmdline_parse_inst_t cmd_global_config = {
8797 .f = cmd_global_config_parsed,
8798 .data = (void *)NULL,
8799 .help_str = "global_config <port_id> gre-key-len <key_len>",
8801 (void *)&cmd_global_config_cmd,
8802 (void *)&cmd_global_config_port_id,
8803 (void *)&cmd_global_config_type,
8804 (void *)&cmd_global_config_gre_key_len,
8809 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8810 struct cmd_set_mirror_mask_result {
8811 cmdline_fixed_string_t set;
8812 cmdline_fixed_string_t port;
8814 cmdline_fixed_string_t mirror;
8816 cmdline_fixed_string_t what;
8817 cmdline_fixed_string_t value;
8818 cmdline_fixed_string_t dstpool;
8820 cmdline_fixed_string_t on;
8823 cmdline_parse_token_string_t cmd_mirror_mask_set =
8824 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8826 cmdline_parse_token_string_t cmd_mirror_mask_port =
8827 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8829 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8830 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8832 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8833 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8834 mirror, "mirror-rule");
8835 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8836 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8838 cmdline_parse_token_string_t cmd_mirror_mask_what =
8839 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8840 what, "pool-mirror-up#pool-mirror-down"
8842 cmdline_parse_token_string_t cmd_mirror_mask_value =
8843 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8845 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8846 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8847 dstpool, "dst-pool");
8848 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8849 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8851 cmdline_parse_token_string_t cmd_mirror_mask_on =
8852 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8856 cmd_set_mirror_mask_parsed(void *parsed_result,
8857 __attribute__((unused)) struct cmdline *cl,
8858 __attribute__((unused)) void *data)
8861 struct cmd_set_mirror_mask_result *res = parsed_result;
8862 struct rte_eth_mirror_conf mr_conf;
8864 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8866 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8868 mr_conf.dst_pool = res->dstpool_id;
8870 if (!strcmp(res->what, "pool-mirror-up")) {
8871 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8872 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8873 } else if (!strcmp(res->what, "pool-mirror-down")) {
8874 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8875 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8876 } else if (!strcmp(res->what, "vlan-mirror")) {
8877 mr_conf.rule_type = ETH_MIRROR_VLAN;
8878 nb_item = parse_item_list(res->value, "vlan",
8879 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8883 for (i = 0; i < nb_item; i++) {
8884 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8885 printf("Invalid vlan_id: must be < 4096\n");
8889 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8890 mr_conf.vlan.vlan_mask |= 1ULL << i;
8894 if (!strcmp(res->on, "on"))
8895 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8898 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8901 printf("mirror rule add error: (%s)\n", strerror(-ret));
8904 cmdline_parse_inst_t cmd_set_mirror_mask = {
8905 .f = cmd_set_mirror_mask_parsed,
8907 .help_str = "set port <port_id> mirror-rule <rule_id> "
8908 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8909 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8911 (void *)&cmd_mirror_mask_set,
8912 (void *)&cmd_mirror_mask_port,
8913 (void *)&cmd_mirror_mask_portid,
8914 (void *)&cmd_mirror_mask_mirror,
8915 (void *)&cmd_mirror_mask_ruleid,
8916 (void *)&cmd_mirror_mask_what,
8917 (void *)&cmd_mirror_mask_value,
8918 (void *)&cmd_mirror_mask_dstpool,
8919 (void *)&cmd_mirror_mask_poolid,
8920 (void *)&cmd_mirror_mask_on,
8925 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8926 struct cmd_set_mirror_link_result {
8927 cmdline_fixed_string_t set;
8928 cmdline_fixed_string_t port;
8930 cmdline_fixed_string_t mirror;
8932 cmdline_fixed_string_t what;
8933 cmdline_fixed_string_t dstpool;
8935 cmdline_fixed_string_t on;
8938 cmdline_parse_token_string_t cmd_mirror_link_set =
8939 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8941 cmdline_parse_token_string_t cmd_mirror_link_port =
8942 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8944 cmdline_parse_token_num_t cmd_mirror_link_portid =
8945 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8947 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8948 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8949 mirror, "mirror-rule");
8950 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8951 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8953 cmdline_parse_token_string_t cmd_mirror_link_what =
8954 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8955 what, "uplink-mirror#downlink-mirror");
8956 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8957 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8958 dstpool, "dst-pool");
8959 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8960 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8962 cmdline_parse_token_string_t cmd_mirror_link_on =
8963 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8967 cmd_set_mirror_link_parsed(void *parsed_result,
8968 __attribute__((unused)) struct cmdline *cl,
8969 __attribute__((unused)) void *data)
8972 struct cmd_set_mirror_link_result *res = parsed_result;
8973 struct rte_eth_mirror_conf mr_conf;
8975 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8976 if (!strcmp(res->what, "uplink-mirror"))
8977 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8979 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8981 mr_conf.dst_pool = res->dstpool_id;
8983 if (!strcmp(res->on, "on"))
8984 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8987 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8990 /* check the return value and print it if is < 0 */
8992 printf("mirror rule add error: (%s)\n", strerror(-ret));
8996 cmdline_parse_inst_t cmd_set_mirror_link = {
8997 .f = cmd_set_mirror_link_parsed,
8999 .help_str = "set port <port_id> mirror-rule <rule_id> "
9000 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9002 (void *)&cmd_mirror_link_set,
9003 (void *)&cmd_mirror_link_port,
9004 (void *)&cmd_mirror_link_portid,
9005 (void *)&cmd_mirror_link_mirror,
9006 (void *)&cmd_mirror_link_ruleid,
9007 (void *)&cmd_mirror_link_what,
9008 (void *)&cmd_mirror_link_dstpool,
9009 (void *)&cmd_mirror_link_poolid,
9010 (void *)&cmd_mirror_link_on,
9015 /* *** RESET VM MIRROR RULE *** */
9016 struct cmd_rm_mirror_rule_result {
9017 cmdline_fixed_string_t reset;
9018 cmdline_fixed_string_t port;
9020 cmdline_fixed_string_t mirror;
9024 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9025 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9027 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9028 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9030 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9031 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9033 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9034 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9035 mirror, "mirror-rule");
9036 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9037 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9041 cmd_reset_mirror_rule_parsed(void *parsed_result,
9042 __attribute__((unused)) struct cmdline *cl,
9043 __attribute__((unused)) void *data)
9046 struct cmd_set_mirror_link_result *res = parsed_result;
9048 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9050 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9053 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9054 .f = cmd_reset_mirror_rule_parsed,
9056 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9058 (void *)&cmd_rm_mirror_rule_reset,
9059 (void *)&cmd_rm_mirror_rule_port,
9060 (void *)&cmd_rm_mirror_rule_portid,
9061 (void *)&cmd_rm_mirror_rule_mirror,
9062 (void *)&cmd_rm_mirror_rule_ruleid,
9067 /* ******************************************************************************** */
9069 struct cmd_dump_result {
9070 cmdline_fixed_string_t dump;
9074 dump_struct_sizes(void)
9076 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9077 DUMP_SIZE(struct rte_mbuf);
9078 DUMP_SIZE(struct rte_mempool);
9079 DUMP_SIZE(struct rte_ring);
9083 static void cmd_dump_parsed(void *parsed_result,
9084 __attribute__((unused)) struct cmdline *cl,
9085 __attribute__((unused)) void *data)
9087 struct cmd_dump_result *res = parsed_result;
9089 if (!strcmp(res->dump, "dump_physmem"))
9090 rte_dump_physmem_layout(stdout);
9091 else if (!strcmp(res->dump, "dump_memzone"))
9092 rte_memzone_dump(stdout);
9093 else if (!strcmp(res->dump, "dump_struct_sizes"))
9094 dump_struct_sizes();
9095 else if (!strcmp(res->dump, "dump_ring"))
9096 rte_ring_list_dump(stdout);
9097 else if (!strcmp(res->dump, "dump_mempool"))
9098 rte_mempool_list_dump(stdout);
9099 else if (!strcmp(res->dump, "dump_devargs"))
9100 rte_devargs_dump(stdout);
9101 else if (!strcmp(res->dump, "dump_log_types"))
9102 rte_log_dump(stdout);
9105 cmdline_parse_token_string_t cmd_dump_dump =
9106 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9109 "dump_struct_sizes#"
9115 cmdline_parse_inst_t cmd_dump = {
9116 .f = cmd_dump_parsed, /* function to call */
9117 .data = NULL, /* 2nd arg of func */
9118 .help_str = "Dump status",
9119 .tokens = { /* token list, NULL terminated */
9120 (void *)&cmd_dump_dump,
9125 /* ******************************************************************************** */
9127 struct cmd_dump_one_result {
9128 cmdline_fixed_string_t dump;
9129 cmdline_fixed_string_t name;
9132 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9133 __attribute__((unused)) void *data)
9135 struct cmd_dump_one_result *res = parsed_result;
9137 if (!strcmp(res->dump, "dump_ring")) {
9139 r = rte_ring_lookup(res->name);
9141 cmdline_printf(cl, "Cannot find ring\n");
9144 rte_ring_dump(stdout, r);
9145 } else if (!strcmp(res->dump, "dump_mempool")) {
9146 struct rte_mempool *mp;
9147 mp = rte_mempool_lookup(res->name);
9149 cmdline_printf(cl, "Cannot find mempool\n");
9152 rte_mempool_dump(stdout, mp);
9156 cmdline_parse_token_string_t cmd_dump_one_dump =
9157 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9158 "dump_ring#dump_mempool");
9160 cmdline_parse_token_string_t cmd_dump_one_name =
9161 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9163 cmdline_parse_inst_t cmd_dump_one = {
9164 .f = cmd_dump_one_parsed, /* function to call */
9165 .data = NULL, /* 2nd arg of func */
9166 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9167 .tokens = { /* token list, NULL terminated */
9168 (void *)&cmd_dump_one_dump,
9169 (void *)&cmd_dump_one_name,
9174 /* *** Add/Del syn filter *** */
9175 struct cmd_syn_filter_result {
9176 cmdline_fixed_string_t filter;
9178 cmdline_fixed_string_t ops;
9179 cmdline_fixed_string_t priority;
9180 cmdline_fixed_string_t high;
9181 cmdline_fixed_string_t queue;
9186 cmd_syn_filter_parsed(void *parsed_result,
9187 __attribute__((unused)) struct cmdline *cl,
9188 __attribute__((unused)) void *data)
9190 struct cmd_syn_filter_result *res = parsed_result;
9191 struct rte_eth_syn_filter syn_filter;
9194 ret = rte_eth_dev_filter_supported(res->port_id,
9195 RTE_ETH_FILTER_SYN);
9197 printf("syn filter is not supported on port %u.\n",
9202 memset(&syn_filter, 0, sizeof(syn_filter));
9204 if (!strcmp(res->ops, "add")) {
9205 if (!strcmp(res->high, "high"))
9206 syn_filter.hig_pri = 1;
9208 syn_filter.hig_pri = 0;
9210 syn_filter.queue = res->queue_id;
9211 ret = rte_eth_dev_filter_ctrl(res->port_id,
9216 ret = rte_eth_dev_filter_ctrl(res->port_id,
9218 RTE_ETH_FILTER_DELETE,
9222 printf("syn filter programming error: (%s)\n",
9226 cmdline_parse_token_string_t cmd_syn_filter_filter =
9227 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9228 filter, "syn_filter");
9229 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9230 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9232 cmdline_parse_token_string_t cmd_syn_filter_ops =
9233 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9235 cmdline_parse_token_string_t cmd_syn_filter_priority =
9236 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9237 priority, "priority");
9238 cmdline_parse_token_string_t cmd_syn_filter_high =
9239 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9241 cmdline_parse_token_string_t cmd_syn_filter_queue =
9242 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9244 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9245 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9248 cmdline_parse_inst_t cmd_syn_filter = {
9249 .f = cmd_syn_filter_parsed,
9251 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9252 "<queue_id>: Add/Delete syn filter",
9254 (void *)&cmd_syn_filter_filter,
9255 (void *)&cmd_syn_filter_port_id,
9256 (void *)&cmd_syn_filter_ops,
9257 (void *)&cmd_syn_filter_priority,
9258 (void *)&cmd_syn_filter_high,
9259 (void *)&cmd_syn_filter_queue,
9260 (void *)&cmd_syn_filter_queue_id,
9265 /* *** queue region set *** */
9266 struct cmd_queue_region_result {
9267 cmdline_fixed_string_t set;
9268 cmdline_fixed_string_t port;
9270 cmdline_fixed_string_t cmd;
9271 cmdline_fixed_string_t region;
9273 cmdline_fixed_string_t queue_start_index;
9275 cmdline_fixed_string_t queue_num;
9276 uint8_t queue_num_value;
9280 cmd_queue_region_parsed(void *parsed_result,
9281 __attribute__((unused)) struct cmdline *cl,
9282 __attribute__((unused)) void *data)
9284 struct cmd_queue_region_result *res = parsed_result;
9286 #ifdef RTE_LIBRTE_I40E_PMD
9287 struct rte_pmd_i40e_queue_region_conf region_conf;
9288 enum rte_pmd_i40e_queue_region_op op_type;
9291 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9294 #ifdef RTE_LIBRTE_I40E_PMD
9295 memset(®ion_conf, 0, sizeof(region_conf));
9296 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9297 region_conf.region_id = res->region_id;
9298 region_conf.queue_num = res->queue_num_value;
9299 region_conf.queue_start_index = res->queue_id;
9301 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9302 op_type, ®ion_conf);
9309 printf("function not implemented or supported\n");
9312 printf("queue region config error: (%s)\n", strerror(-ret));
9316 cmdline_parse_token_string_t cmd_queue_region_set =
9317 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9319 cmdline_parse_token_string_t cmd_queue_region_port =
9320 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9321 cmdline_parse_token_num_t cmd_queue_region_port_id =
9322 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9324 cmdline_parse_token_string_t cmd_queue_region_cmd =
9325 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9326 cmd, "queue-region");
9327 cmdline_parse_token_string_t cmd_queue_region_id =
9328 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9329 region, "region_id");
9330 cmdline_parse_token_num_t cmd_queue_region_index =
9331 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9333 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9334 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9335 queue_start_index, "queue_start_index");
9336 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9337 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9339 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9340 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9341 queue_num, "queue_num");
9342 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9343 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9344 queue_num_value, UINT8);
9346 cmdline_parse_inst_t cmd_queue_region = {
9347 .f = cmd_queue_region_parsed,
9349 .help_str = "set port <port_id> queue-region region_id <value> "
9350 "queue_start_index <value> queue_num <value>: Set a queue region",
9352 (void *)&cmd_queue_region_set,
9353 (void *)&cmd_queue_region_port,
9354 (void *)&cmd_queue_region_port_id,
9355 (void *)&cmd_queue_region_cmd,
9356 (void *)&cmd_queue_region_id,
9357 (void *)&cmd_queue_region_index,
9358 (void *)&cmd_queue_region_queue_start_index,
9359 (void *)&cmd_queue_region_queue_id,
9360 (void *)&cmd_queue_region_queue_num,
9361 (void *)&cmd_queue_region_queue_num_value,
9366 /* *** queue region and flowtype set *** */
9367 struct cmd_region_flowtype_result {
9368 cmdline_fixed_string_t set;
9369 cmdline_fixed_string_t port;
9371 cmdline_fixed_string_t cmd;
9372 cmdline_fixed_string_t region;
9374 cmdline_fixed_string_t flowtype;
9375 uint8_t flowtype_id;
9379 cmd_region_flowtype_parsed(void *parsed_result,
9380 __attribute__((unused)) struct cmdline *cl,
9381 __attribute__((unused)) void *data)
9383 struct cmd_region_flowtype_result *res = parsed_result;
9385 #ifdef RTE_LIBRTE_I40E_PMD
9386 struct rte_pmd_i40e_queue_region_conf region_conf;
9387 enum rte_pmd_i40e_queue_region_op op_type;
9390 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9393 #ifdef RTE_LIBRTE_I40E_PMD
9394 memset(®ion_conf, 0, sizeof(region_conf));
9396 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9397 region_conf.region_id = res->region_id;
9398 region_conf.hw_flowtype = res->flowtype_id;
9400 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9401 op_type, ®ion_conf);
9408 printf("function not implemented or supported\n");
9411 printf("region flowtype config error: (%s)\n", strerror(-ret));
9415 cmdline_parse_token_string_t cmd_region_flowtype_set =
9416 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9418 cmdline_parse_token_string_t cmd_region_flowtype_port =
9419 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9421 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9422 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9424 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9425 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9426 cmd, "queue-region");
9427 cmdline_parse_token_string_t cmd_region_flowtype_index =
9428 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9429 region, "region_id");
9430 cmdline_parse_token_num_t cmd_region_flowtype_id =
9431 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9433 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9434 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9435 flowtype, "flowtype");
9436 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9437 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9438 flowtype_id, UINT8);
9439 cmdline_parse_inst_t cmd_region_flowtype = {
9440 .f = cmd_region_flowtype_parsed,
9442 .help_str = "set port <port_id> queue-region region_id <value> "
9443 "flowtype <value>: Set a flowtype region index",
9445 (void *)&cmd_region_flowtype_set,
9446 (void *)&cmd_region_flowtype_port,
9447 (void *)&cmd_region_flowtype_port_index,
9448 (void *)&cmd_region_flowtype_cmd,
9449 (void *)&cmd_region_flowtype_index,
9450 (void *)&cmd_region_flowtype_id,
9451 (void *)&cmd_region_flowtype_flow_index,
9452 (void *)&cmd_region_flowtype_flow_id,
9457 /* *** User Priority (UP) to queue region (region_id) set *** */
9458 struct cmd_user_priority_region_result {
9459 cmdline_fixed_string_t set;
9460 cmdline_fixed_string_t port;
9462 cmdline_fixed_string_t cmd;
9463 cmdline_fixed_string_t user_priority;
9464 uint8_t user_priority_id;
9465 cmdline_fixed_string_t region;
9470 cmd_user_priority_region_parsed(void *parsed_result,
9471 __attribute__((unused)) struct cmdline *cl,
9472 __attribute__((unused)) void *data)
9474 struct cmd_user_priority_region_result *res = parsed_result;
9476 #ifdef RTE_LIBRTE_I40E_PMD
9477 struct rte_pmd_i40e_queue_region_conf region_conf;
9478 enum rte_pmd_i40e_queue_region_op op_type;
9481 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9484 #ifdef RTE_LIBRTE_I40E_PMD
9485 memset(®ion_conf, 0, sizeof(region_conf));
9486 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9487 region_conf.user_priority = res->user_priority_id;
9488 region_conf.region_id = res->region_id;
9490 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9491 op_type, ®ion_conf);
9498 printf("function not implemented or supported\n");
9501 printf("user_priority region config error: (%s)\n",
9506 cmdline_parse_token_string_t cmd_user_priority_region_set =
9507 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9509 cmdline_parse_token_string_t cmd_user_priority_region_port =
9510 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9512 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9513 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9515 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9516 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9517 cmd, "queue-region");
9518 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9519 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9520 user_priority, "UP");
9521 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9522 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9523 user_priority_id, UINT8);
9524 cmdline_parse_token_string_t cmd_user_priority_region_region =
9525 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9526 region, "region_id");
9527 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9528 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9531 cmdline_parse_inst_t cmd_user_priority_region = {
9532 .f = cmd_user_priority_region_parsed,
9534 .help_str = "set port <port_id> queue-region UP <value> "
9535 "region_id <value>: Set the mapping of User Priority (UP) "
9536 "to queue region (region_id) ",
9538 (void *)&cmd_user_priority_region_set,
9539 (void *)&cmd_user_priority_region_port,
9540 (void *)&cmd_user_priority_region_port_index,
9541 (void *)&cmd_user_priority_region_cmd,
9542 (void *)&cmd_user_priority_region_UP,
9543 (void *)&cmd_user_priority_region_UP_id,
9544 (void *)&cmd_user_priority_region_region,
9545 (void *)&cmd_user_priority_region_region_id,
9550 /* *** flush all queue region related configuration *** */
9551 struct cmd_flush_queue_region_result {
9552 cmdline_fixed_string_t set;
9553 cmdline_fixed_string_t port;
9555 cmdline_fixed_string_t cmd;
9556 cmdline_fixed_string_t flush;
9557 cmdline_fixed_string_t what;
9561 cmd_flush_queue_region_parsed(void *parsed_result,
9562 __attribute__((unused)) struct cmdline *cl,
9563 __attribute__((unused)) void *data)
9565 struct cmd_flush_queue_region_result *res = parsed_result;
9567 #ifdef RTE_LIBRTE_I40E_PMD
9568 struct rte_pmd_i40e_queue_region_conf region_conf;
9569 enum rte_pmd_i40e_queue_region_op op_type;
9572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9575 #ifdef RTE_LIBRTE_I40E_PMD
9576 memset(®ion_conf, 0, sizeof(region_conf));
9578 if (strcmp(res->what, "on") == 0)
9579 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9581 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9583 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9584 op_type, ®ion_conf);
9591 printf("function not implemented or supported\n");
9594 printf("queue region config flush error: (%s)\n",
9599 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9600 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9602 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9603 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9605 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9606 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9608 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9609 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9610 cmd, "queue-region");
9611 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9612 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9614 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9615 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9618 cmdline_parse_inst_t cmd_flush_queue_region = {
9619 .f = cmd_flush_queue_region_parsed,
9621 .help_str = "set port <port_id> queue-region flush on|off"
9622 ": flush all queue region related configuration",
9624 (void *)&cmd_flush_queue_region_set,
9625 (void *)&cmd_flush_queue_region_port,
9626 (void *)&cmd_flush_queue_region_port_index,
9627 (void *)&cmd_flush_queue_region_cmd,
9628 (void *)&cmd_flush_queue_region_flush,
9629 (void *)&cmd_flush_queue_region_what,
9634 /* *** get all queue region related configuration info *** */
9635 struct cmd_show_queue_region_info {
9636 cmdline_fixed_string_t show;
9637 cmdline_fixed_string_t port;
9639 cmdline_fixed_string_t cmd;
9643 cmd_show_queue_region_info_parsed(void *parsed_result,
9644 __attribute__((unused)) struct cmdline *cl,
9645 __attribute__((unused)) void *data)
9647 struct cmd_show_queue_region_info *res = parsed_result;
9649 #ifdef RTE_LIBRTE_I40E_PMD
9650 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9651 enum rte_pmd_i40e_queue_region_op op_type;
9654 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9657 #ifdef RTE_LIBRTE_I40E_PMD
9658 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9660 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9662 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9663 op_type, &rte_pmd_regions);
9665 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9672 printf("function not implemented or supported\n");
9675 printf("queue region config info show error: (%s)\n",
9680 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9681 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9683 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9684 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9686 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9687 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9689 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9690 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9691 cmd, "queue-region");
9693 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9694 .f = cmd_show_queue_region_info_parsed,
9696 .help_str = "show port <port_id> queue-region"
9697 ": show all queue region related configuration info",
9699 (void *)&cmd_show_queue_region_info_get,
9700 (void *)&cmd_show_queue_region_info_port,
9701 (void *)&cmd_show_queue_region_info_port_index,
9702 (void *)&cmd_show_queue_region_info_cmd,
9707 /* *** ADD/REMOVE A 2tuple FILTER *** */
9708 struct cmd_2tuple_filter_result {
9709 cmdline_fixed_string_t filter;
9711 cmdline_fixed_string_t ops;
9712 cmdline_fixed_string_t dst_port;
9713 uint16_t dst_port_value;
9714 cmdline_fixed_string_t protocol;
9715 uint8_t protocol_value;
9716 cmdline_fixed_string_t mask;
9718 cmdline_fixed_string_t tcp_flags;
9719 uint8_t tcp_flags_value;
9720 cmdline_fixed_string_t priority;
9721 uint8_t priority_value;
9722 cmdline_fixed_string_t queue;
9727 cmd_2tuple_filter_parsed(void *parsed_result,
9728 __attribute__((unused)) struct cmdline *cl,
9729 __attribute__((unused)) void *data)
9731 struct rte_eth_ntuple_filter filter;
9732 struct cmd_2tuple_filter_result *res = parsed_result;
9735 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9737 printf("ntuple filter is not supported on port %u.\n",
9742 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9744 filter.flags = RTE_2TUPLE_FLAGS;
9745 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9746 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9747 filter.proto = res->protocol_value;
9748 filter.priority = res->priority_value;
9749 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9750 printf("nonzero tcp_flags is only meaningful"
9751 " when protocol is TCP.\n");
9754 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9755 printf("invalid TCP flags.\n");
9759 if (res->tcp_flags_value != 0) {
9760 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9761 filter.tcp_flags = res->tcp_flags_value;
9764 /* need convert to big endian. */
9765 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9766 filter.queue = res->queue_id;
9768 if (!strcmp(res->ops, "add"))
9769 ret = rte_eth_dev_filter_ctrl(res->port_id,
9770 RTE_ETH_FILTER_NTUPLE,
9774 ret = rte_eth_dev_filter_ctrl(res->port_id,
9775 RTE_ETH_FILTER_NTUPLE,
9776 RTE_ETH_FILTER_DELETE,
9779 printf("2tuple filter programming error: (%s)\n",
9784 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9785 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9786 filter, "2tuple_filter");
9787 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9788 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9790 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9791 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9793 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9794 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9795 dst_port, "dst_port");
9796 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9797 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9798 dst_port_value, UINT16);
9799 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9800 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9801 protocol, "protocol");
9802 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9803 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9804 protocol_value, UINT8);
9805 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9806 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9808 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9809 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9811 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9812 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9813 tcp_flags, "tcp_flags");
9814 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9815 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9816 tcp_flags_value, UINT8);
9817 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9818 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9819 priority, "priority");
9820 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9821 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9822 priority_value, UINT8);
9823 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9824 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9826 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9827 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9830 cmdline_parse_inst_t cmd_2tuple_filter = {
9831 .f = cmd_2tuple_filter_parsed,
9833 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9834 "<value> mask <value> tcp_flags <value> priority <value> queue "
9835 "<queue_id>: Add a 2tuple filter",
9837 (void *)&cmd_2tuple_filter_filter,
9838 (void *)&cmd_2tuple_filter_port_id,
9839 (void *)&cmd_2tuple_filter_ops,
9840 (void *)&cmd_2tuple_filter_dst_port,
9841 (void *)&cmd_2tuple_filter_dst_port_value,
9842 (void *)&cmd_2tuple_filter_protocol,
9843 (void *)&cmd_2tuple_filter_protocol_value,
9844 (void *)&cmd_2tuple_filter_mask,
9845 (void *)&cmd_2tuple_filter_mask_value,
9846 (void *)&cmd_2tuple_filter_tcp_flags,
9847 (void *)&cmd_2tuple_filter_tcp_flags_value,
9848 (void *)&cmd_2tuple_filter_priority,
9849 (void *)&cmd_2tuple_filter_priority_value,
9850 (void *)&cmd_2tuple_filter_queue,
9851 (void *)&cmd_2tuple_filter_queue_id,
9856 /* *** ADD/REMOVE A 5tuple FILTER *** */
9857 struct cmd_5tuple_filter_result {
9858 cmdline_fixed_string_t filter;
9860 cmdline_fixed_string_t ops;
9861 cmdline_fixed_string_t dst_ip;
9862 cmdline_ipaddr_t dst_ip_value;
9863 cmdline_fixed_string_t src_ip;
9864 cmdline_ipaddr_t src_ip_value;
9865 cmdline_fixed_string_t dst_port;
9866 uint16_t dst_port_value;
9867 cmdline_fixed_string_t src_port;
9868 uint16_t src_port_value;
9869 cmdline_fixed_string_t protocol;
9870 uint8_t protocol_value;
9871 cmdline_fixed_string_t mask;
9873 cmdline_fixed_string_t tcp_flags;
9874 uint8_t tcp_flags_value;
9875 cmdline_fixed_string_t priority;
9876 uint8_t priority_value;
9877 cmdline_fixed_string_t queue;
9882 cmd_5tuple_filter_parsed(void *parsed_result,
9883 __attribute__((unused)) struct cmdline *cl,
9884 __attribute__((unused)) void *data)
9886 struct rte_eth_ntuple_filter filter;
9887 struct cmd_5tuple_filter_result *res = parsed_result;
9890 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9892 printf("ntuple filter is not supported on port %u.\n",
9897 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9899 filter.flags = RTE_5TUPLE_FLAGS;
9900 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9901 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9902 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9903 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9904 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9905 filter.proto = res->protocol_value;
9906 filter.priority = res->priority_value;
9907 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9908 printf("nonzero tcp_flags is only meaningful"
9909 " when protocol is TCP.\n");
9912 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9913 printf("invalid TCP flags.\n");
9917 if (res->tcp_flags_value != 0) {
9918 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9919 filter.tcp_flags = res->tcp_flags_value;
9922 if (res->dst_ip_value.family == AF_INET)
9923 /* no need to convert, already big endian. */
9924 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9926 if (filter.dst_ip_mask == 0) {
9927 printf("can not support ipv6 involved compare.\n");
9933 if (res->src_ip_value.family == AF_INET)
9934 /* no need to convert, already big endian. */
9935 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9937 if (filter.src_ip_mask == 0) {
9938 printf("can not support ipv6 involved compare.\n");
9943 /* need convert to big endian. */
9944 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9945 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9946 filter.queue = res->queue_id;
9948 if (!strcmp(res->ops, "add"))
9949 ret = rte_eth_dev_filter_ctrl(res->port_id,
9950 RTE_ETH_FILTER_NTUPLE,
9954 ret = rte_eth_dev_filter_ctrl(res->port_id,
9955 RTE_ETH_FILTER_NTUPLE,
9956 RTE_ETH_FILTER_DELETE,
9959 printf("5tuple filter programming error: (%s)\n",
9963 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9964 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9965 filter, "5tuple_filter");
9966 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9967 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9969 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9970 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9972 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9973 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9975 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9976 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9978 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9979 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9981 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9982 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9984 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9985 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9986 dst_port, "dst_port");
9987 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9988 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9989 dst_port_value, UINT16);
9990 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9991 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9992 src_port, "src_port");
9993 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9994 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9995 src_port_value, UINT16);
9996 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9997 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9998 protocol, "protocol");
9999 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10000 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10001 protocol_value, UINT8);
10002 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10003 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10005 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10006 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10008 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10009 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10010 tcp_flags, "tcp_flags");
10011 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10012 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10013 tcp_flags_value, UINT8);
10014 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10015 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10016 priority, "priority");
10017 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10018 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10019 priority_value, UINT8);
10020 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10021 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10023 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10024 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10027 cmdline_parse_inst_t cmd_5tuple_filter = {
10028 .f = cmd_5tuple_filter_parsed,
10030 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10031 "src_ip <value> dst_port <value> src_port <value> "
10032 "protocol <value> mask <value> tcp_flags <value> "
10033 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10035 (void *)&cmd_5tuple_filter_filter,
10036 (void *)&cmd_5tuple_filter_port_id,
10037 (void *)&cmd_5tuple_filter_ops,
10038 (void *)&cmd_5tuple_filter_dst_ip,
10039 (void *)&cmd_5tuple_filter_dst_ip_value,
10040 (void *)&cmd_5tuple_filter_src_ip,
10041 (void *)&cmd_5tuple_filter_src_ip_value,
10042 (void *)&cmd_5tuple_filter_dst_port,
10043 (void *)&cmd_5tuple_filter_dst_port_value,
10044 (void *)&cmd_5tuple_filter_src_port,
10045 (void *)&cmd_5tuple_filter_src_port_value,
10046 (void *)&cmd_5tuple_filter_protocol,
10047 (void *)&cmd_5tuple_filter_protocol_value,
10048 (void *)&cmd_5tuple_filter_mask,
10049 (void *)&cmd_5tuple_filter_mask_value,
10050 (void *)&cmd_5tuple_filter_tcp_flags,
10051 (void *)&cmd_5tuple_filter_tcp_flags_value,
10052 (void *)&cmd_5tuple_filter_priority,
10053 (void *)&cmd_5tuple_filter_priority_value,
10054 (void *)&cmd_5tuple_filter_queue,
10055 (void *)&cmd_5tuple_filter_queue_id,
10060 /* *** ADD/REMOVE A flex FILTER *** */
10061 struct cmd_flex_filter_result {
10062 cmdline_fixed_string_t filter;
10063 cmdline_fixed_string_t ops;
10065 cmdline_fixed_string_t len;
10067 cmdline_fixed_string_t bytes;
10068 cmdline_fixed_string_t bytes_value;
10069 cmdline_fixed_string_t mask;
10070 cmdline_fixed_string_t mask_value;
10071 cmdline_fixed_string_t priority;
10072 uint8_t priority_value;
10073 cmdline_fixed_string_t queue;
10077 static int xdigit2val(unsigned char c)
10082 else if (isupper(c))
10083 val = c - 'A' + 10;
10085 val = c - 'a' + 10;
10090 cmd_flex_filter_parsed(void *parsed_result,
10091 __attribute__((unused)) struct cmdline *cl,
10092 __attribute__((unused)) void *data)
10095 struct rte_eth_flex_filter filter;
10096 struct cmd_flex_filter_result *res = parsed_result;
10097 char *bytes_ptr, *mask_ptr;
10098 uint16_t len, i, j = 0;
10103 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10104 printf("the len exceed the max length 128\n");
10107 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10108 filter.len = res->len_value;
10109 filter.priority = res->priority_value;
10110 filter.queue = res->queue_id;
10111 bytes_ptr = res->bytes_value;
10112 mask_ptr = res->mask_value;
10114 /* translate bytes string to array. */
10115 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10116 (bytes_ptr[1] == 'X')))
10118 len = strnlen(bytes_ptr, res->len_value * 2);
10119 if (len == 0 || (len % 8 != 0)) {
10120 printf("please check len and bytes input\n");
10123 for (i = 0; i < len; i++) {
10125 if (isxdigit(c) == 0) {
10126 /* invalid characters. */
10127 printf("invalid input\n");
10130 val = xdigit2val(c);
10133 filter.bytes[j] = byte;
10134 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10141 /* translate mask string to uint8_t array. */
10142 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10143 (mask_ptr[1] == 'X')))
10145 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10147 printf("invalid input\n");
10152 for (i = 0; i < len; i++) {
10154 if (isxdigit(c) == 0) {
10155 /* invalid characters. */
10156 printf("invalid input\n");
10159 val = xdigit2val(c);
10162 filter.mask[j] = byte;
10163 printf("mask[%d]:%02x ", j, filter.mask[j]);
10171 if (!strcmp(res->ops, "add"))
10172 ret = rte_eth_dev_filter_ctrl(res->port_id,
10173 RTE_ETH_FILTER_FLEXIBLE,
10174 RTE_ETH_FILTER_ADD,
10177 ret = rte_eth_dev_filter_ctrl(res->port_id,
10178 RTE_ETH_FILTER_FLEXIBLE,
10179 RTE_ETH_FILTER_DELETE,
10183 printf("flex filter setting error: (%s)\n", strerror(-ret));
10186 cmdline_parse_token_string_t cmd_flex_filter_filter =
10187 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10188 filter, "flex_filter");
10189 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10190 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10192 cmdline_parse_token_string_t cmd_flex_filter_ops =
10193 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10195 cmdline_parse_token_string_t cmd_flex_filter_len =
10196 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10198 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10199 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10201 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10202 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10204 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10205 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10206 bytes_value, NULL);
10207 cmdline_parse_token_string_t cmd_flex_filter_mask =
10208 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10210 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10211 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10213 cmdline_parse_token_string_t cmd_flex_filter_priority =
10214 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10215 priority, "priority");
10216 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10217 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10218 priority_value, UINT8);
10219 cmdline_parse_token_string_t cmd_flex_filter_queue =
10220 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10222 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10223 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10225 cmdline_parse_inst_t cmd_flex_filter = {
10226 .f = cmd_flex_filter_parsed,
10228 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10229 "<value> mask <value> priority <value> queue <queue_id>: "
10230 "Add/Del a flex filter",
10232 (void *)&cmd_flex_filter_filter,
10233 (void *)&cmd_flex_filter_port_id,
10234 (void *)&cmd_flex_filter_ops,
10235 (void *)&cmd_flex_filter_len,
10236 (void *)&cmd_flex_filter_len_value,
10237 (void *)&cmd_flex_filter_bytes,
10238 (void *)&cmd_flex_filter_bytes_value,
10239 (void *)&cmd_flex_filter_mask,
10240 (void *)&cmd_flex_filter_mask_value,
10241 (void *)&cmd_flex_filter_priority,
10242 (void *)&cmd_flex_filter_priority_value,
10243 (void *)&cmd_flex_filter_queue,
10244 (void *)&cmd_flex_filter_queue_id,
10249 /* *** Filters Control *** */
10251 /* *** deal with ethertype filter *** */
10252 struct cmd_ethertype_filter_result {
10253 cmdline_fixed_string_t filter;
10255 cmdline_fixed_string_t ops;
10256 cmdline_fixed_string_t mac;
10257 struct ether_addr mac_addr;
10258 cmdline_fixed_string_t ethertype;
10259 uint16_t ethertype_value;
10260 cmdline_fixed_string_t drop;
10261 cmdline_fixed_string_t queue;
10265 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10266 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10267 filter, "ethertype_filter");
10268 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10269 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10271 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10272 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10274 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10275 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10276 mac, "mac_addr#mac_ignr");
10277 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10278 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10280 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10281 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10282 ethertype, "ethertype");
10283 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10284 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10285 ethertype_value, UINT16);
10286 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10287 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10289 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10290 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10292 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10293 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10297 cmd_ethertype_filter_parsed(void *parsed_result,
10298 __attribute__((unused)) struct cmdline *cl,
10299 __attribute__((unused)) void *data)
10301 struct cmd_ethertype_filter_result *res = parsed_result;
10302 struct rte_eth_ethertype_filter filter;
10305 ret = rte_eth_dev_filter_supported(res->port_id,
10306 RTE_ETH_FILTER_ETHERTYPE);
10308 printf("ethertype filter is not supported on port %u.\n",
10313 memset(&filter, 0, sizeof(filter));
10314 if (!strcmp(res->mac, "mac_addr")) {
10315 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10316 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10317 sizeof(struct ether_addr));
10319 if (!strcmp(res->drop, "drop"))
10320 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10321 filter.ether_type = res->ethertype_value;
10322 filter.queue = res->queue_id;
10324 if (!strcmp(res->ops, "add"))
10325 ret = rte_eth_dev_filter_ctrl(res->port_id,
10326 RTE_ETH_FILTER_ETHERTYPE,
10327 RTE_ETH_FILTER_ADD,
10330 ret = rte_eth_dev_filter_ctrl(res->port_id,
10331 RTE_ETH_FILTER_ETHERTYPE,
10332 RTE_ETH_FILTER_DELETE,
10335 printf("ethertype filter programming error: (%s)\n",
10339 cmdline_parse_inst_t cmd_ethertype_filter = {
10340 .f = cmd_ethertype_filter_parsed,
10342 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10343 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10344 "Add or delete an ethertype filter entry",
10346 (void *)&cmd_ethertype_filter_filter,
10347 (void *)&cmd_ethertype_filter_port_id,
10348 (void *)&cmd_ethertype_filter_ops,
10349 (void *)&cmd_ethertype_filter_mac,
10350 (void *)&cmd_ethertype_filter_mac_addr,
10351 (void *)&cmd_ethertype_filter_ethertype,
10352 (void *)&cmd_ethertype_filter_ethertype_value,
10353 (void *)&cmd_ethertype_filter_drop,
10354 (void *)&cmd_ethertype_filter_queue,
10355 (void *)&cmd_ethertype_filter_queue_id,
10360 /* *** deal with flow director filter *** */
10361 struct cmd_flow_director_result {
10362 cmdline_fixed_string_t flow_director_filter;
10364 cmdline_fixed_string_t mode;
10365 cmdline_fixed_string_t mode_value;
10366 cmdline_fixed_string_t ops;
10367 cmdline_fixed_string_t flow;
10368 cmdline_fixed_string_t flow_type;
10369 cmdline_fixed_string_t ether;
10370 uint16_t ether_type;
10371 cmdline_fixed_string_t src;
10372 cmdline_ipaddr_t ip_src;
10374 cmdline_fixed_string_t dst;
10375 cmdline_ipaddr_t ip_dst;
10377 cmdline_fixed_string_t verify_tag;
10378 uint32_t verify_tag_value;
10379 cmdline_fixed_string_t tos;
10381 cmdline_fixed_string_t proto;
10382 uint8_t proto_value;
10383 cmdline_fixed_string_t ttl;
10385 cmdline_fixed_string_t vlan;
10386 uint16_t vlan_value;
10387 cmdline_fixed_string_t flexbytes;
10388 cmdline_fixed_string_t flexbytes_value;
10389 cmdline_fixed_string_t pf_vf;
10390 cmdline_fixed_string_t drop;
10391 cmdline_fixed_string_t queue;
10393 cmdline_fixed_string_t fd_id;
10394 uint32_t fd_id_value;
10395 cmdline_fixed_string_t mac;
10396 struct ether_addr mac_addr;
10397 cmdline_fixed_string_t tunnel;
10398 cmdline_fixed_string_t tunnel_type;
10399 cmdline_fixed_string_t tunnel_id;
10400 uint32_t tunnel_id_value;
10401 cmdline_fixed_string_t packet;
10406 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10409 const char *p, *p0 = q_arg;
10411 unsigned long int_fld;
10412 char *str_fld[max_num];
10417 p = strchr(p0, '(');
10421 p0 = strchr(p, ')');
10426 if (size >= sizeof(s))
10429 snprintf(s, sizeof(s), "%.*s", size, p);
10430 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10431 if (ret < 0 || ret > max_num)
10433 for (i = 0; i < ret; i++) {
10435 int_fld = strtoul(str_fld[i], &end, 0);
10436 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10438 flexbytes[i] = (uint8_t)int_fld;
10444 str2flowtype(char *string)
10447 static const struct {
10450 } flowtype_str[] = {
10451 {"raw", RTE_ETH_FLOW_RAW},
10452 {"ipv4", RTE_ETH_FLOW_IPV4},
10453 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10454 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10455 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10456 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10457 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10458 {"ipv6", RTE_ETH_FLOW_IPV6},
10459 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10460 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10461 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10462 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10463 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10464 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10467 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10468 if (!strcmp(flowtype_str[i].str, string))
10469 return flowtype_str[i].type;
10472 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10473 return (uint16_t)atoi(string);
10475 return RTE_ETH_FLOW_UNKNOWN;
10478 static enum rte_eth_fdir_tunnel_type
10479 str2fdir_tunneltype(char *string)
10483 static const struct {
10485 enum rte_eth_fdir_tunnel_type type;
10486 } tunneltype_str[] = {
10487 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10488 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10491 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10492 if (!strcmp(tunneltype_str[i].str, string))
10493 return tunneltype_str[i].type;
10495 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10498 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10500 if ((ip_addr).family == AF_INET) \
10501 (ip) = (ip_addr).addr.ipv4.s_addr; \
10503 printf("invalid parameter.\n"); \
10508 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10510 if ((ip_addr).family == AF_INET6) \
10511 rte_memcpy(&(ip), \
10512 &((ip_addr).addr.ipv6), \
10513 sizeof(struct in6_addr)); \
10515 printf("invalid parameter.\n"); \
10521 cmd_flow_director_filter_parsed(void *parsed_result,
10522 __attribute__((unused)) struct cmdline *cl,
10523 __attribute__((unused)) void *data)
10525 struct cmd_flow_director_result *res = parsed_result;
10526 struct rte_eth_fdir_filter entry;
10527 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10529 unsigned long vf_id;
10532 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10534 printf("flow director is not supported on port %u.\n",
10538 memset(flexbytes, 0, sizeof(flexbytes));
10539 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10541 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10542 if (strcmp(res->mode_value, "MAC-VLAN")) {
10543 printf("Please set mode to MAC-VLAN.\n");
10546 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10547 if (strcmp(res->mode_value, "Tunnel")) {
10548 printf("Please set mode to Tunnel.\n");
10552 if (!strcmp(res->mode_value, "raw")) {
10553 #ifdef RTE_LIBRTE_I40E_PMD
10554 struct rte_pmd_i40e_flow_type_mapping
10555 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10556 struct rte_pmd_i40e_pkt_template_conf conf;
10557 uint16_t flow_type = str2flowtype(res->flow_type);
10558 uint16_t i, port = res->port_id;
10561 memset(&conf, 0, sizeof(conf));
10563 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10564 printf("Invalid flow type specified.\n");
10567 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10571 if (mapping[flow_type].pctype == 0ULL) {
10572 printf("Invalid flow type specified.\n");
10575 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10576 if (mapping[flow_type].pctype & (1ULL << i)) {
10577 conf.input.pctype = i;
10582 conf.input.packet = open_file(res->filepath,
10583 &conf.input.length);
10584 if (!conf.input.packet)
10586 if (!strcmp(res->drop, "drop"))
10587 conf.action.behavior =
10588 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10590 conf.action.behavior =
10591 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10592 conf.action.report_status =
10593 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10594 conf.action.rx_queue = res->queue_id;
10595 conf.soft_id = res->fd_id_value;
10596 add = strcmp(res->ops, "del") ? 1 : 0;
10597 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10601 printf("flow director config error: (%s)\n",
10603 close_file(conf.input.packet);
10606 } else if (strcmp(res->mode_value, "IP")) {
10607 printf("Please set mode to IP or raw.\n");
10610 entry.input.flow_type = str2flowtype(res->flow_type);
10613 ret = parse_flexbytes(res->flexbytes_value,
10615 RTE_ETH_FDIR_MAX_FLEXLEN);
10617 printf("error: Cannot parse flexbytes input.\n");
10621 switch (entry.input.flow_type) {
10622 case RTE_ETH_FLOW_FRAG_IPV4:
10623 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10624 entry.input.flow.ip4_flow.proto = res->proto_value;
10626 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10627 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10628 IPV4_ADDR_TO_UINT(res->ip_dst,
10629 entry.input.flow.ip4_flow.dst_ip);
10630 IPV4_ADDR_TO_UINT(res->ip_src,
10631 entry.input.flow.ip4_flow.src_ip);
10632 entry.input.flow.ip4_flow.tos = res->tos_value;
10633 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10634 /* need convert to big endian. */
10635 entry.input.flow.udp4_flow.dst_port =
10636 rte_cpu_to_be_16(res->port_dst);
10637 entry.input.flow.udp4_flow.src_port =
10638 rte_cpu_to_be_16(res->port_src);
10640 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10641 IPV4_ADDR_TO_UINT(res->ip_dst,
10642 entry.input.flow.sctp4_flow.ip.dst_ip);
10643 IPV4_ADDR_TO_UINT(res->ip_src,
10644 entry.input.flow.sctp4_flow.ip.src_ip);
10645 entry.input.flow.ip4_flow.tos = res->tos_value;
10646 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10647 /* need convert to big endian. */
10648 entry.input.flow.sctp4_flow.dst_port =
10649 rte_cpu_to_be_16(res->port_dst);
10650 entry.input.flow.sctp4_flow.src_port =
10651 rte_cpu_to_be_16(res->port_src);
10652 entry.input.flow.sctp4_flow.verify_tag =
10653 rte_cpu_to_be_32(res->verify_tag_value);
10655 case RTE_ETH_FLOW_FRAG_IPV6:
10656 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10657 entry.input.flow.ipv6_flow.proto = res->proto_value;
10659 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10660 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10661 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10662 entry.input.flow.ipv6_flow.dst_ip);
10663 IPV6_ADDR_TO_ARRAY(res->ip_src,
10664 entry.input.flow.ipv6_flow.src_ip);
10665 entry.input.flow.ipv6_flow.tc = res->tos_value;
10666 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10667 /* need convert to big endian. */
10668 entry.input.flow.udp6_flow.dst_port =
10669 rte_cpu_to_be_16(res->port_dst);
10670 entry.input.flow.udp6_flow.src_port =
10671 rte_cpu_to_be_16(res->port_src);
10673 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10674 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10675 entry.input.flow.sctp6_flow.ip.dst_ip);
10676 IPV6_ADDR_TO_ARRAY(res->ip_src,
10677 entry.input.flow.sctp6_flow.ip.src_ip);
10678 entry.input.flow.ipv6_flow.tc = res->tos_value;
10679 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10680 /* need convert to big endian. */
10681 entry.input.flow.sctp6_flow.dst_port =
10682 rte_cpu_to_be_16(res->port_dst);
10683 entry.input.flow.sctp6_flow.src_port =
10684 rte_cpu_to_be_16(res->port_src);
10685 entry.input.flow.sctp6_flow.verify_tag =
10686 rte_cpu_to_be_32(res->verify_tag_value);
10688 case RTE_ETH_FLOW_L2_PAYLOAD:
10689 entry.input.flow.l2_flow.ether_type =
10690 rte_cpu_to_be_16(res->ether_type);
10696 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10697 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10699 sizeof(struct ether_addr));
10701 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10702 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10704 sizeof(struct ether_addr));
10705 entry.input.flow.tunnel_flow.tunnel_type =
10706 str2fdir_tunneltype(res->tunnel_type);
10707 entry.input.flow.tunnel_flow.tunnel_id =
10708 rte_cpu_to_be_32(res->tunnel_id_value);
10711 rte_memcpy(entry.input.flow_ext.flexbytes,
10713 RTE_ETH_FDIR_MAX_FLEXLEN);
10715 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10717 entry.action.flex_off = 0; /*use 0 by default */
10718 if (!strcmp(res->drop, "drop"))
10719 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10721 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10723 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10724 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10725 if (!strcmp(res->pf_vf, "pf"))
10726 entry.input.flow_ext.is_vf = 0;
10727 else if (!strncmp(res->pf_vf, "vf", 2)) {
10728 struct rte_eth_dev_info dev_info;
10730 memset(&dev_info, 0, sizeof(dev_info));
10731 rte_eth_dev_info_get(res->port_id, &dev_info);
10733 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10734 if (errno != 0 || *end != '\0' ||
10735 vf_id >= dev_info.max_vfs) {
10736 printf("invalid parameter %s.\n", res->pf_vf);
10739 entry.input.flow_ext.is_vf = 1;
10740 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10742 printf("invalid parameter %s.\n", res->pf_vf);
10747 /* set to report FD ID by default */
10748 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10749 entry.action.rx_queue = res->queue_id;
10750 entry.soft_id = res->fd_id_value;
10751 if (!strcmp(res->ops, "add"))
10752 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10753 RTE_ETH_FILTER_ADD, &entry);
10754 else if (!strcmp(res->ops, "del"))
10755 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10756 RTE_ETH_FILTER_DELETE, &entry);
10758 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10759 RTE_ETH_FILTER_UPDATE, &entry);
10761 printf("flow director programming error: (%s)\n",
10765 cmdline_parse_token_string_t cmd_flow_director_filter =
10766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10767 flow_director_filter, "flow_director_filter");
10768 cmdline_parse_token_num_t cmd_flow_director_port_id =
10769 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10771 cmdline_parse_token_string_t cmd_flow_director_ops =
10772 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10773 ops, "add#del#update");
10774 cmdline_parse_token_string_t cmd_flow_director_flow =
10775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10777 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10780 cmdline_parse_token_string_t cmd_flow_director_ether =
10781 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10783 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10784 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10785 ether_type, UINT16);
10786 cmdline_parse_token_string_t cmd_flow_director_src =
10787 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10789 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10790 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10792 cmdline_parse_token_num_t cmd_flow_director_port_src =
10793 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10795 cmdline_parse_token_string_t cmd_flow_director_dst =
10796 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10798 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10799 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10801 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10802 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10804 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10805 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10806 verify_tag, "verify_tag");
10807 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10808 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10809 verify_tag_value, UINT32);
10810 cmdline_parse_token_string_t cmd_flow_director_tos =
10811 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10813 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10814 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10816 cmdline_parse_token_string_t cmd_flow_director_proto =
10817 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10819 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10820 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10821 proto_value, UINT8);
10822 cmdline_parse_token_string_t cmd_flow_director_ttl =
10823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10825 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10826 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10828 cmdline_parse_token_string_t cmd_flow_director_vlan =
10829 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10831 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10832 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10833 vlan_value, UINT16);
10834 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10835 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10836 flexbytes, "flexbytes");
10837 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10838 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10839 flexbytes_value, NULL);
10840 cmdline_parse_token_string_t cmd_flow_director_drop =
10841 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10843 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10844 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10846 cmdline_parse_token_string_t cmd_flow_director_queue =
10847 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10849 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10850 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10852 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10855 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10856 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10857 fd_id_value, UINT32);
10859 cmdline_parse_token_string_t cmd_flow_director_mode =
10860 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10862 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10865 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10866 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10867 mode_value, "MAC-VLAN");
10868 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10870 mode_value, "Tunnel");
10871 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10873 mode_value, "raw");
10874 cmdline_parse_token_string_t cmd_flow_director_mac =
10875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10877 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10878 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10880 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10881 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10883 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10884 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10885 tunnel_type, "NVGRE#VxLAN");
10886 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10887 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10888 tunnel_id, "tunnel-id");
10889 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10890 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10891 tunnel_id_value, UINT32);
10892 cmdline_parse_token_string_t cmd_flow_director_packet =
10893 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10895 cmdline_parse_token_string_t cmd_flow_director_filepath =
10896 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10899 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10900 .f = cmd_flow_director_filter_parsed,
10902 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10903 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10904 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10905 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10906 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10907 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10908 "fd_id <fd_id_value>: "
10909 "Add or delete an ip flow director entry on NIC",
10911 (void *)&cmd_flow_director_filter,
10912 (void *)&cmd_flow_director_port_id,
10913 (void *)&cmd_flow_director_mode,
10914 (void *)&cmd_flow_director_mode_ip,
10915 (void *)&cmd_flow_director_ops,
10916 (void *)&cmd_flow_director_flow,
10917 (void *)&cmd_flow_director_flow_type,
10918 (void *)&cmd_flow_director_src,
10919 (void *)&cmd_flow_director_ip_src,
10920 (void *)&cmd_flow_director_dst,
10921 (void *)&cmd_flow_director_ip_dst,
10922 (void *)&cmd_flow_director_tos,
10923 (void *)&cmd_flow_director_tos_value,
10924 (void *)&cmd_flow_director_proto,
10925 (void *)&cmd_flow_director_proto_value,
10926 (void *)&cmd_flow_director_ttl,
10927 (void *)&cmd_flow_director_ttl_value,
10928 (void *)&cmd_flow_director_vlan,
10929 (void *)&cmd_flow_director_vlan_value,
10930 (void *)&cmd_flow_director_flexbytes,
10931 (void *)&cmd_flow_director_flexbytes_value,
10932 (void *)&cmd_flow_director_drop,
10933 (void *)&cmd_flow_director_pf_vf,
10934 (void *)&cmd_flow_director_queue,
10935 (void *)&cmd_flow_director_queue_id,
10936 (void *)&cmd_flow_director_fd_id,
10937 (void *)&cmd_flow_director_fd_id_value,
10942 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10943 .f = cmd_flow_director_filter_parsed,
10945 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10946 "director entry on NIC",
10948 (void *)&cmd_flow_director_filter,
10949 (void *)&cmd_flow_director_port_id,
10950 (void *)&cmd_flow_director_mode,
10951 (void *)&cmd_flow_director_mode_ip,
10952 (void *)&cmd_flow_director_ops,
10953 (void *)&cmd_flow_director_flow,
10954 (void *)&cmd_flow_director_flow_type,
10955 (void *)&cmd_flow_director_src,
10956 (void *)&cmd_flow_director_ip_src,
10957 (void *)&cmd_flow_director_port_src,
10958 (void *)&cmd_flow_director_dst,
10959 (void *)&cmd_flow_director_ip_dst,
10960 (void *)&cmd_flow_director_port_dst,
10961 (void *)&cmd_flow_director_tos,
10962 (void *)&cmd_flow_director_tos_value,
10963 (void *)&cmd_flow_director_ttl,
10964 (void *)&cmd_flow_director_ttl_value,
10965 (void *)&cmd_flow_director_vlan,
10966 (void *)&cmd_flow_director_vlan_value,
10967 (void *)&cmd_flow_director_flexbytes,
10968 (void *)&cmd_flow_director_flexbytes_value,
10969 (void *)&cmd_flow_director_drop,
10970 (void *)&cmd_flow_director_pf_vf,
10971 (void *)&cmd_flow_director_queue,
10972 (void *)&cmd_flow_director_queue_id,
10973 (void *)&cmd_flow_director_fd_id,
10974 (void *)&cmd_flow_director_fd_id_value,
10979 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10980 .f = cmd_flow_director_filter_parsed,
10982 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10983 "director entry on NIC",
10985 (void *)&cmd_flow_director_filter,
10986 (void *)&cmd_flow_director_port_id,
10987 (void *)&cmd_flow_director_mode,
10988 (void *)&cmd_flow_director_mode_ip,
10989 (void *)&cmd_flow_director_ops,
10990 (void *)&cmd_flow_director_flow,
10991 (void *)&cmd_flow_director_flow_type,
10992 (void *)&cmd_flow_director_src,
10993 (void *)&cmd_flow_director_ip_src,
10994 (void *)&cmd_flow_director_port_src,
10995 (void *)&cmd_flow_director_dst,
10996 (void *)&cmd_flow_director_ip_dst,
10997 (void *)&cmd_flow_director_port_dst,
10998 (void *)&cmd_flow_director_verify_tag,
10999 (void *)&cmd_flow_director_verify_tag_value,
11000 (void *)&cmd_flow_director_tos,
11001 (void *)&cmd_flow_director_tos_value,
11002 (void *)&cmd_flow_director_ttl,
11003 (void *)&cmd_flow_director_ttl_value,
11004 (void *)&cmd_flow_director_vlan,
11005 (void *)&cmd_flow_director_vlan_value,
11006 (void *)&cmd_flow_director_flexbytes,
11007 (void *)&cmd_flow_director_flexbytes_value,
11008 (void *)&cmd_flow_director_drop,
11009 (void *)&cmd_flow_director_pf_vf,
11010 (void *)&cmd_flow_director_queue,
11011 (void *)&cmd_flow_director_queue_id,
11012 (void *)&cmd_flow_director_fd_id,
11013 (void *)&cmd_flow_director_fd_id_value,
11018 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11019 .f = cmd_flow_director_filter_parsed,
11021 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11022 "director entry on NIC",
11024 (void *)&cmd_flow_director_filter,
11025 (void *)&cmd_flow_director_port_id,
11026 (void *)&cmd_flow_director_mode,
11027 (void *)&cmd_flow_director_mode_ip,
11028 (void *)&cmd_flow_director_ops,
11029 (void *)&cmd_flow_director_flow,
11030 (void *)&cmd_flow_director_flow_type,
11031 (void *)&cmd_flow_director_ether,
11032 (void *)&cmd_flow_director_ether_type,
11033 (void *)&cmd_flow_director_flexbytes,
11034 (void *)&cmd_flow_director_flexbytes_value,
11035 (void *)&cmd_flow_director_drop,
11036 (void *)&cmd_flow_director_pf_vf,
11037 (void *)&cmd_flow_director_queue,
11038 (void *)&cmd_flow_director_queue_id,
11039 (void *)&cmd_flow_director_fd_id,
11040 (void *)&cmd_flow_director_fd_id_value,
11045 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11046 .f = cmd_flow_director_filter_parsed,
11048 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11049 "director entry on NIC",
11051 (void *)&cmd_flow_director_filter,
11052 (void *)&cmd_flow_director_port_id,
11053 (void *)&cmd_flow_director_mode,
11054 (void *)&cmd_flow_director_mode_mac_vlan,
11055 (void *)&cmd_flow_director_ops,
11056 (void *)&cmd_flow_director_mac,
11057 (void *)&cmd_flow_director_mac_addr,
11058 (void *)&cmd_flow_director_vlan,
11059 (void *)&cmd_flow_director_vlan_value,
11060 (void *)&cmd_flow_director_flexbytes,
11061 (void *)&cmd_flow_director_flexbytes_value,
11062 (void *)&cmd_flow_director_drop,
11063 (void *)&cmd_flow_director_queue,
11064 (void *)&cmd_flow_director_queue_id,
11065 (void *)&cmd_flow_director_fd_id,
11066 (void *)&cmd_flow_director_fd_id_value,
11071 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11072 .f = cmd_flow_director_filter_parsed,
11074 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11075 "director entry on NIC",
11077 (void *)&cmd_flow_director_filter,
11078 (void *)&cmd_flow_director_port_id,
11079 (void *)&cmd_flow_director_mode,
11080 (void *)&cmd_flow_director_mode_tunnel,
11081 (void *)&cmd_flow_director_ops,
11082 (void *)&cmd_flow_director_mac,
11083 (void *)&cmd_flow_director_mac_addr,
11084 (void *)&cmd_flow_director_vlan,
11085 (void *)&cmd_flow_director_vlan_value,
11086 (void *)&cmd_flow_director_tunnel,
11087 (void *)&cmd_flow_director_tunnel_type,
11088 (void *)&cmd_flow_director_tunnel_id,
11089 (void *)&cmd_flow_director_tunnel_id_value,
11090 (void *)&cmd_flow_director_flexbytes,
11091 (void *)&cmd_flow_director_flexbytes_value,
11092 (void *)&cmd_flow_director_drop,
11093 (void *)&cmd_flow_director_queue,
11094 (void *)&cmd_flow_director_queue_id,
11095 (void *)&cmd_flow_director_fd_id,
11096 (void *)&cmd_flow_director_fd_id_value,
11101 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11102 .f = cmd_flow_director_filter_parsed,
11104 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11105 "director entry on NIC",
11107 (void *)&cmd_flow_director_filter,
11108 (void *)&cmd_flow_director_port_id,
11109 (void *)&cmd_flow_director_mode,
11110 (void *)&cmd_flow_director_mode_raw,
11111 (void *)&cmd_flow_director_ops,
11112 (void *)&cmd_flow_director_flow,
11113 (void *)&cmd_flow_director_flow_type,
11114 (void *)&cmd_flow_director_drop,
11115 (void *)&cmd_flow_director_queue,
11116 (void *)&cmd_flow_director_queue_id,
11117 (void *)&cmd_flow_director_fd_id,
11118 (void *)&cmd_flow_director_fd_id_value,
11119 (void *)&cmd_flow_director_packet,
11120 (void *)&cmd_flow_director_filepath,
11125 struct cmd_flush_flow_director_result {
11126 cmdline_fixed_string_t flush_flow_director;
11130 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11131 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11132 flush_flow_director, "flush_flow_director");
11133 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11134 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11138 cmd_flush_flow_director_parsed(void *parsed_result,
11139 __attribute__((unused)) struct cmdline *cl,
11140 __attribute__((unused)) void *data)
11142 struct cmd_flow_director_result *res = parsed_result;
11145 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11147 printf("flow director is not supported on port %u.\n",
11152 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11153 RTE_ETH_FILTER_FLUSH, NULL);
11155 printf("flow director table flushing error: (%s)\n",
11159 cmdline_parse_inst_t cmd_flush_flow_director = {
11160 .f = cmd_flush_flow_director_parsed,
11162 .help_str = "flush_flow_director <port_id>: "
11163 "Flush all flow director entries of a device on NIC",
11165 (void *)&cmd_flush_flow_director_flush,
11166 (void *)&cmd_flush_flow_director_port_id,
11171 /* *** deal with flow director mask *** */
11172 struct cmd_flow_director_mask_result {
11173 cmdline_fixed_string_t flow_director_mask;
11175 cmdline_fixed_string_t mode;
11176 cmdline_fixed_string_t mode_value;
11177 cmdline_fixed_string_t vlan;
11178 uint16_t vlan_mask;
11179 cmdline_fixed_string_t src_mask;
11180 cmdline_ipaddr_t ipv4_src;
11181 cmdline_ipaddr_t ipv6_src;
11183 cmdline_fixed_string_t dst_mask;
11184 cmdline_ipaddr_t ipv4_dst;
11185 cmdline_ipaddr_t ipv6_dst;
11187 cmdline_fixed_string_t mac;
11188 uint8_t mac_addr_byte_mask;
11189 cmdline_fixed_string_t tunnel_id;
11190 uint32_t tunnel_id_mask;
11191 cmdline_fixed_string_t tunnel_type;
11192 uint8_t tunnel_type_mask;
11196 cmd_flow_director_mask_parsed(void *parsed_result,
11197 __attribute__((unused)) struct cmdline *cl,
11198 __attribute__((unused)) void *data)
11200 struct cmd_flow_director_mask_result *res = parsed_result;
11201 struct rte_eth_fdir_masks *mask;
11202 struct rte_port *port;
11204 port = &ports[res->port_id];
11205 /** Check if the port is not started **/
11206 if (port->port_status != RTE_PORT_STOPPED) {
11207 printf("Please stop port %d first\n", res->port_id);
11211 mask = &port->dev_conf.fdir_conf.mask;
11213 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11214 if (strcmp(res->mode_value, "MAC-VLAN")) {
11215 printf("Please set mode to MAC-VLAN.\n");
11219 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11220 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11221 if (strcmp(res->mode_value, "Tunnel")) {
11222 printf("Please set mode to Tunnel.\n");
11226 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11227 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11228 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11229 mask->tunnel_type_mask = res->tunnel_type_mask;
11231 if (strcmp(res->mode_value, "IP")) {
11232 printf("Please set mode to IP.\n");
11236 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11237 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11238 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11239 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11240 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11241 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11242 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11245 cmd_reconfig_device_queue(res->port_id, 1, 1);
11248 cmdline_parse_token_string_t cmd_flow_director_mask =
11249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11250 flow_director_mask, "flow_director_mask");
11251 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11252 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11254 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11257 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11258 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11259 vlan_mask, UINT16);
11260 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11262 src_mask, "src_mask");
11263 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11264 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11266 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11267 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11269 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11270 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11272 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11273 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11274 dst_mask, "dst_mask");
11275 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11276 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11278 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11279 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11281 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11282 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11285 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11288 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11291 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11293 mode_value, "MAC-VLAN");
11294 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11296 mode_value, "Tunnel");
11297 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11300 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11301 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11302 mac_addr_byte_mask, UINT8);
11303 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11304 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11305 tunnel_type, "tunnel-type");
11306 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11307 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11308 tunnel_type_mask, UINT8);
11309 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11311 tunnel_id, "tunnel-id");
11312 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11313 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11314 tunnel_id_mask, UINT32);
11316 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11317 .f = cmd_flow_director_mask_parsed,
11319 .help_str = "flow_director_mask ... : "
11320 "Set IP mode flow director's mask on NIC",
11322 (void *)&cmd_flow_director_mask,
11323 (void *)&cmd_flow_director_mask_port_id,
11324 (void *)&cmd_flow_director_mask_mode,
11325 (void *)&cmd_flow_director_mask_mode_ip,
11326 (void *)&cmd_flow_director_mask_vlan,
11327 (void *)&cmd_flow_director_mask_vlan_value,
11328 (void *)&cmd_flow_director_mask_src,
11329 (void *)&cmd_flow_director_mask_ipv4_src,
11330 (void *)&cmd_flow_director_mask_ipv6_src,
11331 (void *)&cmd_flow_director_mask_port_src,
11332 (void *)&cmd_flow_director_mask_dst,
11333 (void *)&cmd_flow_director_mask_ipv4_dst,
11334 (void *)&cmd_flow_director_mask_ipv6_dst,
11335 (void *)&cmd_flow_director_mask_port_dst,
11340 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11341 .f = cmd_flow_director_mask_parsed,
11343 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11344 "flow director's mask on NIC",
11346 (void *)&cmd_flow_director_mask,
11347 (void *)&cmd_flow_director_mask_port_id,
11348 (void *)&cmd_flow_director_mask_mode,
11349 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11350 (void *)&cmd_flow_director_mask_vlan,
11351 (void *)&cmd_flow_director_mask_vlan_value,
11356 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11357 .f = cmd_flow_director_mask_parsed,
11359 .help_str = "flow_director_mask ... : Set tunnel mode "
11360 "flow director's mask on NIC",
11362 (void *)&cmd_flow_director_mask,
11363 (void *)&cmd_flow_director_mask_port_id,
11364 (void *)&cmd_flow_director_mask_mode,
11365 (void *)&cmd_flow_director_mask_mode_tunnel,
11366 (void *)&cmd_flow_director_mask_vlan,
11367 (void *)&cmd_flow_director_mask_vlan_value,
11368 (void *)&cmd_flow_director_mask_mac,
11369 (void *)&cmd_flow_director_mask_mac_value,
11370 (void *)&cmd_flow_director_mask_tunnel_type,
11371 (void *)&cmd_flow_director_mask_tunnel_type_value,
11372 (void *)&cmd_flow_director_mask_tunnel_id,
11373 (void *)&cmd_flow_director_mask_tunnel_id_value,
11378 /* *** deal with flow director mask on flexible payload *** */
11379 struct cmd_flow_director_flex_mask_result {
11380 cmdline_fixed_string_t flow_director_flexmask;
11382 cmdline_fixed_string_t flow;
11383 cmdline_fixed_string_t flow_type;
11384 cmdline_fixed_string_t mask;
11388 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11389 __attribute__((unused)) struct cmdline *cl,
11390 __attribute__((unused)) void *data)
11392 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11393 struct rte_eth_fdir_info fdir_info;
11394 struct rte_eth_fdir_flex_mask flex_mask;
11395 struct rte_port *port;
11396 uint64_t flow_type_mask;
11400 port = &ports[res->port_id];
11401 /** Check if the port is not started **/
11402 if (port->port_status != RTE_PORT_STOPPED) {
11403 printf("Please stop port %d first\n", res->port_id);
11407 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11408 ret = parse_flexbytes(res->mask,
11410 RTE_ETH_FDIR_MAX_FLEXLEN);
11412 printf("error: Cannot parse mask input.\n");
11416 memset(&fdir_info, 0, sizeof(fdir_info));
11417 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11418 RTE_ETH_FILTER_INFO, &fdir_info);
11420 printf("Cannot get FDir filter info\n");
11424 if (!strcmp(res->flow_type, "none")) {
11425 /* means don't specify the flow type */
11426 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11427 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11428 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11429 0, sizeof(struct rte_eth_fdir_flex_mask));
11430 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11431 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11433 sizeof(struct rte_eth_fdir_flex_mask));
11434 cmd_reconfig_device_queue(res->port_id, 1, 1);
11437 flow_type_mask = fdir_info.flow_types_mask[0];
11438 if (!strcmp(res->flow_type, "all")) {
11439 if (!flow_type_mask) {
11440 printf("No flow type supported\n");
11443 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11444 if (flow_type_mask & (1ULL << i)) {
11445 flex_mask.flow_type = i;
11446 fdir_set_flex_mask(res->port_id, &flex_mask);
11449 cmd_reconfig_device_queue(res->port_id, 1, 1);
11452 flex_mask.flow_type = str2flowtype(res->flow_type);
11453 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11454 printf("Flow type %s not supported on port %d\n",
11455 res->flow_type, res->port_id);
11458 fdir_set_flex_mask(res->port_id, &flex_mask);
11459 cmd_reconfig_device_queue(res->port_id, 1, 1);
11462 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11463 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11464 flow_director_flexmask,
11465 "flow_director_flex_mask");
11466 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11467 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11469 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11472 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11474 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11475 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11476 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11477 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11480 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11481 .f = cmd_flow_director_flex_mask_parsed,
11483 .help_str = "flow_director_flex_mask ... : "
11484 "Set flow director's flex mask on NIC",
11486 (void *)&cmd_flow_director_flexmask,
11487 (void *)&cmd_flow_director_flexmask_port_id,
11488 (void *)&cmd_flow_director_flexmask_flow,
11489 (void *)&cmd_flow_director_flexmask_flow_type,
11490 (void *)&cmd_flow_director_flexmask_mask,
11495 /* *** deal with flow director flexible payload configuration *** */
11496 struct cmd_flow_director_flexpayload_result {
11497 cmdline_fixed_string_t flow_director_flexpayload;
11499 cmdline_fixed_string_t payload_layer;
11500 cmdline_fixed_string_t payload_cfg;
11504 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11507 const char *p, *p0 = q_arg;
11509 unsigned long int_fld;
11510 char *str_fld[max_num];
11515 p = strchr(p0, '(');
11519 p0 = strchr(p, ')');
11524 if (size >= sizeof(s))
11527 snprintf(s, sizeof(s), "%.*s", size, p);
11528 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11529 if (ret < 0 || ret > max_num)
11531 for (i = 0; i < ret; i++) {
11533 int_fld = strtoul(str_fld[i], &end, 0);
11534 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11536 offsets[i] = (uint16_t)int_fld;
11542 cmd_flow_director_flxpld_parsed(void *parsed_result,
11543 __attribute__((unused)) struct cmdline *cl,
11544 __attribute__((unused)) void *data)
11546 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11547 struct rte_eth_flex_payload_cfg flex_cfg;
11548 struct rte_port *port;
11551 port = &ports[res->port_id];
11552 /** Check if the port is not started **/
11553 if (port->port_status != RTE_PORT_STOPPED) {
11554 printf("Please stop port %d first\n", res->port_id);
11558 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11560 if (!strcmp(res->payload_layer, "raw"))
11561 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11562 else if (!strcmp(res->payload_layer, "l2"))
11563 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11564 else if (!strcmp(res->payload_layer, "l3"))
11565 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11566 else if (!strcmp(res->payload_layer, "l4"))
11567 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11569 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11570 RTE_ETH_FDIR_MAX_FLEXLEN);
11572 printf("error: Cannot parse flex payload input.\n");
11576 fdir_set_flex_payload(res->port_id, &flex_cfg);
11577 cmd_reconfig_device_queue(res->port_id, 1, 1);
11580 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11581 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11582 flow_director_flexpayload,
11583 "flow_director_flex_payload");
11584 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11585 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11587 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11588 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11589 payload_layer, "raw#l2#l3#l4");
11590 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11592 payload_cfg, NULL);
11594 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11595 .f = cmd_flow_director_flxpld_parsed,
11597 .help_str = "flow_director_flexpayload ... : "
11598 "Set flow director's flex payload on NIC",
11600 (void *)&cmd_flow_director_flexpayload,
11601 (void *)&cmd_flow_director_flexpayload_port_id,
11602 (void *)&cmd_flow_director_flexpayload_payload_layer,
11603 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11608 /* Generic flow interface command. */
11609 extern cmdline_parse_inst_t cmd_flow;
11611 /* *** Classification Filters Control *** */
11612 /* *** Get symmetric hash enable per port *** */
11613 struct cmd_get_sym_hash_ena_per_port_result {
11614 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11619 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11620 __rte_unused struct cmdline *cl,
11621 __rte_unused void *data)
11623 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11624 struct rte_eth_hash_filter_info info;
11627 if (rte_eth_dev_filter_supported(res->port_id,
11628 RTE_ETH_FILTER_HASH) < 0) {
11629 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11634 memset(&info, 0, sizeof(info));
11635 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11636 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11637 RTE_ETH_FILTER_GET, &info);
11640 printf("Cannot get symmetric hash enable per port "
11641 "on port %u\n", res->port_id);
11645 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11646 "enabled" : "disabled", res->port_id);
11649 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11650 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11651 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11652 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11653 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11656 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11657 .f = cmd_get_sym_hash_per_port_parsed,
11659 .help_str = "get_sym_hash_ena_per_port <port_id>",
11661 (void *)&cmd_get_sym_hash_ena_per_port_all,
11662 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11667 /* *** Set symmetric hash enable per port *** */
11668 struct cmd_set_sym_hash_ena_per_port_result {
11669 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11670 cmdline_fixed_string_t enable;
11675 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11676 __rte_unused struct cmdline *cl,
11677 __rte_unused void *data)
11679 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11680 struct rte_eth_hash_filter_info info;
11683 if (rte_eth_dev_filter_supported(res->port_id,
11684 RTE_ETH_FILTER_HASH) < 0) {
11685 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11690 memset(&info, 0, sizeof(info));
11691 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11692 if (!strcmp(res->enable, "enable"))
11693 info.info.enable = 1;
11694 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11695 RTE_ETH_FILTER_SET, &info);
11697 printf("Cannot set symmetric hash enable per port on "
11698 "port %u\n", res->port_id);
11701 printf("Symmetric hash has been set to %s on port %u\n",
11702 res->enable, res->port_id);
11705 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11706 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11707 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11708 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11709 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11711 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11712 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11713 enable, "enable#disable");
11715 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11716 .f = cmd_set_sym_hash_per_port_parsed,
11718 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11720 (void *)&cmd_set_sym_hash_ena_per_port_all,
11721 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11722 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11727 /* Get global config of hash function */
11728 struct cmd_get_hash_global_config_result {
11729 cmdline_fixed_string_t get_hash_global_config;
11734 flowtype_to_str(uint16_t ftype)
11740 } ftype_table[] = {
11741 {"ipv4", RTE_ETH_FLOW_IPV4},
11742 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11743 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11744 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11745 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11746 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11747 {"ipv6", RTE_ETH_FLOW_IPV6},
11748 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11749 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11750 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11751 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11752 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11753 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11754 {"port", RTE_ETH_FLOW_PORT},
11755 {"vxlan", RTE_ETH_FLOW_VXLAN},
11756 {"geneve", RTE_ETH_FLOW_GENEVE},
11757 {"nvgre", RTE_ETH_FLOW_NVGRE},
11760 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11761 if (ftype_table[i].ftype == ftype)
11762 return ftype_table[i].str;
11769 cmd_get_hash_global_config_parsed(void *parsed_result,
11770 __rte_unused struct cmdline *cl,
11771 __rte_unused void *data)
11773 struct cmd_get_hash_global_config_result *res = parsed_result;
11774 struct rte_eth_hash_filter_info info;
11775 uint32_t idx, offset;
11780 if (rte_eth_dev_filter_supported(res->port_id,
11781 RTE_ETH_FILTER_HASH) < 0) {
11782 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11787 memset(&info, 0, sizeof(info));
11788 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11789 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11790 RTE_ETH_FILTER_GET, &info);
11792 printf("Cannot get hash global configurations by port %d\n",
11797 switch (info.info.global_conf.hash_func) {
11798 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11799 printf("Hash function is Toeplitz\n");
11801 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11802 printf("Hash function is Simple XOR\n");
11805 printf("Unknown hash function\n");
11809 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11810 idx = i / UINT64_BIT;
11811 offset = i % UINT64_BIT;
11812 if (!(info.info.global_conf.valid_bit_mask[idx] &
11815 str = flowtype_to_str(i);
11818 printf("Symmetric hash is %s globally for flow type %s "
11820 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11821 (1ULL << offset)) ? "enabled" : "disabled"), str,
11826 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11827 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11828 get_hash_global_config, "get_hash_global_config");
11829 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11830 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11833 cmdline_parse_inst_t cmd_get_hash_global_config = {
11834 .f = cmd_get_hash_global_config_parsed,
11836 .help_str = "get_hash_global_config <port_id>",
11838 (void *)&cmd_get_hash_global_config_all,
11839 (void *)&cmd_get_hash_global_config_port_id,
11844 /* Set global config of hash function */
11845 struct cmd_set_hash_global_config_result {
11846 cmdline_fixed_string_t set_hash_global_config;
11848 cmdline_fixed_string_t hash_func;
11849 cmdline_fixed_string_t flow_type;
11850 cmdline_fixed_string_t enable;
11854 cmd_set_hash_global_config_parsed(void *parsed_result,
11855 __rte_unused struct cmdline *cl,
11856 __rte_unused void *data)
11858 struct cmd_set_hash_global_config_result *res = parsed_result;
11859 struct rte_eth_hash_filter_info info;
11860 uint32_t ftype, idx, offset;
11863 if (rte_eth_dev_filter_supported(res->port_id,
11864 RTE_ETH_FILTER_HASH) < 0) {
11865 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11869 memset(&info, 0, sizeof(info));
11870 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11871 if (!strcmp(res->hash_func, "toeplitz"))
11872 info.info.global_conf.hash_func =
11873 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11874 else if (!strcmp(res->hash_func, "simple_xor"))
11875 info.info.global_conf.hash_func =
11876 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11877 else if (!strcmp(res->hash_func, "default"))
11878 info.info.global_conf.hash_func =
11879 RTE_ETH_HASH_FUNCTION_DEFAULT;
11881 ftype = str2flowtype(res->flow_type);
11882 idx = ftype / UINT64_BIT;
11883 offset = ftype % UINT64_BIT;
11884 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11885 if (!strcmp(res->enable, "enable"))
11886 info.info.global_conf.sym_hash_enable_mask[idx] |=
11888 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11889 RTE_ETH_FILTER_SET, &info);
11891 printf("Cannot set global hash configurations by port %d\n",
11894 printf("Global hash configurations have been set "
11895 "succcessfully by port %d\n", res->port_id);
11898 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11899 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11900 set_hash_global_config, "set_hash_global_config");
11901 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11902 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11904 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11905 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11906 hash_func, "toeplitz#simple_xor#default");
11907 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11908 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11910 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11911 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11912 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11913 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11914 enable, "enable#disable");
11916 cmdline_parse_inst_t cmd_set_hash_global_config = {
11917 .f = cmd_set_hash_global_config_parsed,
11919 .help_str = "set_hash_global_config <port_id> "
11920 "toeplitz|simple_xor|default "
11921 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11922 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11923 "l2_payload enable|disable",
11925 (void *)&cmd_set_hash_global_config_all,
11926 (void *)&cmd_set_hash_global_config_port_id,
11927 (void *)&cmd_set_hash_global_config_hash_func,
11928 (void *)&cmd_set_hash_global_config_flow_type,
11929 (void *)&cmd_set_hash_global_config_enable,
11934 /* Set hash input set */
11935 struct cmd_set_hash_input_set_result {
11936 cmdline_fixed_string_t set_hash_input_set;
11938 cmdline_fixed_string_t flow_type;
11939 cmdline_fixed_string_t inset_field;
11940 cmdline_fixed_string_t select;
11943 static enum rte_eth_input_set_field
11944 str2inset(char *string)
11948 static const struct {
11950 enum rte_eth_input_set_field inset;
11951 } inset_table[] = {
11952 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11953 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11954 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11955 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11956 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11957 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11958 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11959 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11960 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11961 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11962 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11963 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11964 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11965 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11966 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11967 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11968 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11969 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11970 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11971 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11972 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11973 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11974 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11975 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11976 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11977 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11978 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11979 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11980 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11981 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11982 {"none", RTE_ETH_INPUT_SET_NONE},
11985 for (i = 0; i < RTE_DIM(inset_table); i++) {
11986 if (!strcmp(string, inset_table[i].str))
11987 return inset_table[i].inset;
11990 return RTE_ETH_INPUT_SET_UNKNOWN;
11994 cmd_set_hash_input_set_parsed(void *parsed_result,
11995 __rte_unused struct cmdline *cl,
11996 __rte_unused void *data)
11998 struct cmd_set_hash_input_set_result *res = parsed_result;
11999 struct rte_eth_hash_filter_info info;
12001 memset(&info, 0, sizeof(info));
12002 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12003 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12004 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12005 info.info.input_set_conf.inset_size = 1;
12006 if (!strcmp(res->select, "select"))
12007 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12008 else if (!strcmp(res->select, "add"))
12009 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12010 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12011 RTE_ETH_FILTER_SET, &info);
12014 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12015 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12016 set_hash_input_set, "set_hash_input_set");
12017 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12018 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12020 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12021 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12023 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12024 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12026 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12027 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12028 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12029 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12030 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12032 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12033 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12034 select, "select#add");
12036 cmdline_parse_inst_t cmd_set_hash_input_set = {
12037 .f = cmd_set_hash_input_set_parsed,
12039 .help_str = "set_hash_input_set <port_id> "
12040 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12041 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12042 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12043 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12044 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12045 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12046 "fld-7th|fld-8th|none select|add",
12048 (void *)&cmd_set_hash_input_set_cmd,
12049 (void *)&cmd_set_hash_input_set_port_id,
12050 (void *)&cmd_set_hash_input_set_flow_type,
12051 (void *)&cmd_set_hash_input_set_field,
12052 (void *)&cmd_set_hash_input_set_select,
12057 /* Set flow director input set */
12058 struct cmd_set_fdir_input_set_result {
12059 cmdline_fixed_string_t set_fdir_input_set;
12061 cmdline_fixed_string_t flow_type;
12062 cmdline_fixed_string_t inset_field;
12063 cmdline_fixed_string_t select;
12067 cmd_set_fdir_input_set_parsed(void *parsed_result,
12068 __rte_unused struct cmdline *cl,
12069 __rte_unused void *data)
12071 struct cmd_set_fdir_input_set_result *res = parsed_result;
12072 struct rte_eth_fdir_filter_info info;
12074 memset(&info, 0, sizeof(info));
12075 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12076 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12077 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12078 info.info.input_set_conf.inset_size = 1;
12079 if (!strcmp(res->select, "select"))
12080 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12081 else if (!strcmp(res->select, "add"))
12082 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12083 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12084 RTE_ETH_FILTER_SET, &info);
12087 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12088 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12089 set_fdir_input_set, "set_fdir_input_set");
12090 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12091 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12093 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12094 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12096 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12097 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12098 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12099 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12101 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12102 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12103 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12104 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12105 "sctp-veri-tag#none");
12106 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12107 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12108 select, "select#add");
12110 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12111 .f = cmd_set_fdir_input_set_parsed,
12113 .help_str = "set_fdir_input_set <port_id> "
12114 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12115 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12116 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12117 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12118 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12119 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12120 "sctp-veri-tag|none select|add",
12122 (void *)&cmd_set_fdir_input_set_cmd,
12123 (void *)&cmd_set_fdir_input_set_port_id,
12124 (void *)&cmd_set_fdir_input_set_flow_type,
12125 (void *)&cmd_set_fdir_input_set_field,
12126 (void *)&cmd_set_fdir_input_set_select,
12131 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12132 struct cmd_mcast_addr_result {
12133 cmdline_fixed_string_t mcast_addr_cmd;
12134 cmdline_fixed_string_t what;
12136 struct ether_addr mc_addr;
12139 static void cmd_mcast_addr_parsed(void *parsed_result,
12140 __attribute__((unused)) struct cmdline *cl,
12141 __attribute__((unused)) void *data)
12143 struct cmd_mcast_addr_result *res = parsed_result;
12145 if (!is_multicast_ether_addr(&res->mc_addr)) {
12146 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12147 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12148 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12149 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12152 if (strcmp(res->what, "add") == 0)
12153 mcast_addr_add(res->port_num, &res->mc_addr);
12155 mcast_addr_remove(res->port_num, &res->mc_addr);
12158 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12159 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12160 mcast_addr_cmd, "mcast_addr");
12161 cmdline_parse_token_string_t cmd_mcast_addr_what =
12162 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12164 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12165 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12166 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12167 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12169 cmdline_parse_inst_t cmd_mcast_addr = {
12170 .f = cmd_mcast_addr_parsed,
12172 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12173 "Add/Remove multicast MAC address on port_id",
12175 (void *)&cmd_mcast_addr_cmd,
12176 (void *)&cmd_mcast_addr_what,
12177 (void *)&cmd_mcast_addr_portnum,
12178 (void *)&cmd_mcast_addr_addr,
12183 /* l2 tunnel config
12184 * only support E-tag now.
12187 /* Ether type config */
12188 struct cmd_config_l2_tunnel_eth_type_result {
12189 cmdline_fixed_string_t port;
12190 cmdline_fixed_string_t config;
12191 cmdline_fixed_string_t all;
12193 cmdline_fixed_string_t l2_tunnel;
12194 cmdline_fixed_string_t l2_tunnel_type;
12195 cmdline_fixed_string_t eth_type;
12196 uint16_t eth_type_val;
12199 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12200 TOKEN_STRING_INITIALIZER
12201 (struct cmd_config_l2_tunnel_eth_type_result,
12203 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12204 TOKEN_STRING_INITIALIZER
12205 (struct cmd_config_l2_tunnel_eth_type_result,
12207 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12208 TOKEN_STRING_INITIALIZER
12209 (struct cmd_config_l2_tunnel_eth_type_result,
12211 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12212 TOKEN_NUM_INITIALIZER
12213 (struct cmd_config_l2_tunnel_eth_type_result,
12215 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12216 TOKEN_STRING_INITIALIZER
12217 (struct cmd_config_l2_tunnel_eth_type_result,
12218 l2_tunnel, "l2-tunnel");
12219 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12220 TOKEN_STRING_INITIALIZER
12221 (struct cmd_config_l2_tunnel_eth_type_result,
12222 l2_tunnel_type, "E-tag");
12223 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12224 TOKEN_STRING_INITIALIZER
12225 (struct cmd_config_l2_tunnel_eth_type_result,
12226 eth_type, "ether-type");
12227 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12228 TOKEN_NUM_INITIALIZER
12229 (struct cmd_config_l2_tunnel_eth_type_result,
12230 eth_type_val, UINT16);
12232 static enum rte_eth_tunnel_type
12233 str2fdir_l2_tunnel_type(char *string)
12237 static const struct {
12239 enum rte_eth_tunnel_type type;
12240 } l2_tunnel_type_str[] = {
12241 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12244 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12245 if (!strcmp(l2_tunnel_type_str[i].str, string))
12246 return l2_tunnel_type_str[i].type;
12248 return RTE_TUNNEL_TYPE_NONE;
12251 /* ether type config for all ports */
12253 cmd_config_l2_tunnel_eth_type_all_parsed
12254 (void *parsed_result,
12255 __attribute__((unused)) struct cmdline *cl,
12256 __attribute__((unused)) void *data)
12258 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12259 struct rte_eth_l2_tunnel_conf entry;
12262 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12263 entry.ether_type = res->eth_type_val;
12265 RTE_ETH_FOREACH_DEV(pid) {
12266 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12270 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12271 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12273 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12275 (void *)&cmd_config_l2_tunnel_eth_type_port,
12276 (void *)&cmd_config_l2_tunnel_eth_type_config,
12277 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12278 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12279 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12280 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12281 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12286 /* ether type config for a specific port */
12288 cmd_config_l2_tunnel_eth_type_specific_parsed(
12289 void *parsed_result,
12290 __attribute__((unused)) struct cmdline *cl,
12291 __attribute__((unused)) void *data)
12293 struct cmd_config_l2_tunnel_eth_type_result *res =
12295 struct rte_eth_l2_tunnel_conf entry;
12297 if (port_id_is_invalid(res->id, ENABLED_WARN))
12300 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12301 entry.ether_type = res->eth_type_val;
12303 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12306 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12307 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12309 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12311 (void *)&cmd_config_l2_tunnel_eth_type_port,
12312 (void *)&cmd_config_l2_tunnel_eth_type_config,
12313 (void *)&cmd_config_l2_tunnel_eth_type_id,
12314 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12315 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12316 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12317 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12322 /* Enable/disable l2 tunnel */
12323 struct cmd_config_l2_tunnel_en_dis_result {
12324 cmdline_fixed_string_t port;
12325 cmdline_fixed_string_t config;
12326 cmdline_fixed_string_t all;
12328 cmdline_fixed_string_t l2_tunnel;
12329 cmdline_fixed_string_t l2_tunnel_type;
12330 cmdline_fixed_string_t en_dis;
12333 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12334 TOKEN_STRING_INITIALIZER
12335 (struct cmd_config_l2_tunnel_en_dis_result,
12337 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12338 TOKEN_STRING_INITIALIZER
12339 (struct cmd_config_l2_tunnel_en_dis_result,
12341 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12342 TOKEN_STRING_INITIALIZER
12343 (struct cmd_config_l2_tunnel_en_dis_result,
12345 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12346 TOKEN_NUM_INITIALIZER
12347 (struct cmd_config_l2_tunnel_en_dis_result,
12349 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12350 TOKEN_STRING_INITIALIZER
12351 (struct cmd_config_l2_tunnel_en_dis_result,
12352 l2_tunnel, "l2-tunnel");
12353 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12354 TOKEN_STRING_INITIALIZER
12355 (struct cmd_config_l2_tunnel_en_dis_result,
12356 l2_tunnel_type, "E-tag");
12357 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12358 TOKEN_STRING_INITIALIZER
12359 (struct cmd_config_l2_tunnel_en_dis_result,
12360 en_dis, "enable#disable");
12362 /* enable/disable l2 tunnel for all ports */
12364 cmd_config_l2_tunnel_en_dis_all_parsed(
12365 void *parsed_result,
12366 __attribute__((unused)) struct cmdline *cl,
12367 __attribute__((unused)) void *data)
12369 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12370 struct rte_eth_l2_tunnel_conf entry;
12374 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12376 if (!strcmp("enable", res->en_dis))
12381 RTE_ETH_FOREACH_DEV(pid) {
12382 rte_eth_dev_l2_tunnel_offload_set(pid,
12384 ETH_L2_TUNNEL_ENABLE_MASK,
12389 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12390 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12392 .help_str = "port config all l2-tunnel E-tag enable|disable",
12394 (void *)&cmd_config_l2_tunnel_en_dis_port,
12395 (void *)&cmd_config_l2_tunnel_en_dis_config,
12396 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12397 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12398 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12399 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12404 /* enable/disable l2 tunnel for a port */
12406 cmd_config_l2_tunnel_en_dis_specific_parsed(
12407 void *parsed_result,
12408 __attribute__((unused)) struct cmdline *cl,
12409 __attribute__((unused)) void *data)
12411 struct cmd_config_l2_tunnel_en_dis_result *res =
12413 struct rte_eth_l2_tunnel_conf entry;
12415 if (port_id_is_invalid(res->id, ENABLED_WARN))
12418 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12420 if (!strcmp("enable", res->en_dis))
12421 rte_eth_dev_l2_tunnel_offload_set(res->id,
12423 ETH_L2_TUNNEL_ENABLE_MASK,
12426 rte_eth_dev_l2_tunnel_offload_set(res->id,
12428 ETH_L2_TUNNEL_ENABLE_MASK,
12432 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12433 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12435 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12437 (void *)&cmd_config_l2_tunnel_en_dis_port,
12438 (void *)&cmd_config_l2_tunnel_en_dis_config,
12439 (void *)&cmd_config_l2_tunnel_en_dis_id,
12440 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12441 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12442 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12447 /* E-tag configuration */
12449 /* Common result structure for all E-tag configuration */
12450 struct cmd_config_e_tag_result {
12451 cmdline_fixed_string_t e_tag;
12452 cmdline_fixed_string_t set;
12453 cmdline_fixed_string_t insertion;
12454 cmdline_fixed_string_t stripping;
12455 cmdline_fixed_string_t forwarding;
12456 cmdline_fixed_string_t filter;
12457 cmdline_fixed_string_t add;
12458 cmdline_fixed_string_t del;
12459 cmdline_fixed_string_t on;
12460 cmdline_fixed_string_t off;
12461 cmdline_fixed_string_t on_off;
12462 cmdline_fixed_string_t port_tag_id;
12463 uint32_t port_tag_id_val;
12464 cmdline_fixed_string_t e_tag_id;
12465 uint16_t e_tag_id_val;
12466 cmdline_fixed_string_t dst_pool;
12467 uint8_t dst_pool_val;
12468 cmdline_fixed_string_t port;
12470 cmdline_fixed_string_t vf;
12474 /* Common CLI fields for all E-tag configuration */
12475 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12476 TOKEN_STRING_INITIALIZER
12477 (struct cmd_config_e_tag_result,
12479 cmdline_parse_token_string_t cmd_config_e_tag_set =
12480 TOKEN_STRING_INITIALIZER
12481 (struct cmd_config_e_tag_result,
12483 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12484 TOKEN_STRING_INITIALIZER
12485 (struct cmd_config_e_tag_result,
12486 insertion, "insertion");
12487 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12488 TOKEN_STRING_INITIALIZER
12489 (struct cmd_config_e_tag_result,
12490 stripping, "stripping");
12491 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12492 TOKEN_STRING_INITIALIZER
12493 (struct cmd_config_e_tag_result,
12494 forwarding, "forwarding");
12495 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12496 TOKEN_STRING_INITIALIZER
12497 (struct cmd_config_e_tag_result,
12499 cmdline_parse_token_string_t cmd_config_e_tag_add =
12500 TOKEN_STRING_INITIALIZER
12501 (struct cmd_config_e_tag_result,
12503 cmdline_parse_token_string_t cmd_config_e_tag_del =
12504 TOKEN_STRING_INITIALIZER
12505 (struct cmd_config_e_tag_result,
12507 cmdline_parse_token_string_t cmd_config_e_tag_on =
12508 TOKEN_STRING_INITIALIZER
12509 (struct cmd_config_e_tag_result,
12511 cmdline_parse_token_string_t cmd_config_e_tag_off =
12512 TOKEN_STRING_INITIALIZER
12513 (struct cmd_config_e_tag_result,
12515 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12516 TOKEN_STRING_INITIALIZER
12517 (struct cmd_config_e_tag_result,
12519 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12520 TOKEN_STRING_INITIALIZER
12521 (struct cmd_config_e_tag_result,
12522 port_tag_id, "port-tag-id");
12523 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12524 TOKEN_NUM_INITIALIZER
12525 (struct cmd_config_e_tag_result,
12526 port_tag_id_val, UINT32);
12527 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12528 TOKEN_STRING_INITIALIZER
12529 (struct cmd_config_e_tag_result,
12530 e_tag_id, "e-tag-id");
12531 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12532 TOKEN_NUM_INITIALIZER
12533 (struct cmd_config_e_tag_result,
12534 e_tag_id_val, UINT16);
12535 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12536 TOKEN_STRING_INITIALIZER
12537 (struct cmd_config_e_tag_result,
12538 dst_pool, "dst-pool");
12539 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12540 TOKEN_NUM_INITIALIZER
12541 (struct cmd_config_e_tag_result,
12542 dst_pool_val, UINT8);
12543 cmdline_parse_token_string_t cmd_config_e_tag_port =
12544 TOKEN_STRING_INITIALIZER
12545 (struct cmd_config_e_tag_result,
12547 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12548 TOKEN_NUM_INITIALIZER
12549 (struct cmd_config_e_tag_result,
12551 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12552 TOKEN_STRING_INITIALIZER
12553 (struct cmd_config_e_tag_result,
12555 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12556 TOKEN_NUM_INITIALIZER
12557 (struct cmd_config_e_tag_result,
12560 /* E-tag insertion configuration */
12562 cmd_config_e_tag_insertion_en_parsed(
12563 void *parsed_result,
12564 __attribute__((unused)) struct cmdline *cl,
12565 __attribute__((unused)) void *data)
12567 struct cmd_config_e_tag_result *res =
12569 struct rte_eth_l2_tunnel_conf entry;
12571 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12574 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12575 entry.tunnel_id = res->port_tag_id_val;
12576 entry.vf_id = res->vf_id;
12577 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12579 ETH_L2_TUNNEL_INSERTION_MASK,
12584 cmd_config_e_tag_insertion_dis_parsed(
12585 void *parsed_result,
12586 __attribute__((unused)) struct cmdline *cl,
12587 __attribute__((unused)) void *data)
12589 struct cmd_config_e_tag_result *res =
12591 struct rte_eth_l2_tunnel_conf entry;
12593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12596 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12597 entry.vf_id = res->vf_id;
12599 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12601 ETH_L2_TUNNEL_INSERTION_MASK,
12605 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12606 .f = cmd_config_e_tag_insertion_en_parsed,
12608 .help_str = "E-tag ... : E-tag insertion enable",
12610 (void *)&cmd_config_e_tag_e_tag,
12611 (void *)&cmd_config_e_tag_set,
12612 (void *)&cmd_config_e_tag_insertion,
12613 (void *)&cmd_config_e_tag_on,
12614 (void *)&cmd_config_e_tag_port_tag_id,
12615 (void *)&cmd_config_e_tag_port_tag_id_val,
12616 (void *)&cmd_config_e_tag_port,
12617 (void *)&cmd_config_e_tag_port_id,
12618 (void *)&cmd_config_e_tag_vf,
12619 (void *)&cmd_config_e_tag_vf_id,
12624 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12625 .f = cmd_config_e_tag_insertion_dis_parsed,
12627 .help_str = "E-tag ... : E-tag insertion disable",
12629 (void *)&cmd_config_e_tag_e_tag,
12630 (void *)&cmd_config_e_tag_set,
12631 (void *)&cmd_config_e_tag_insertion,
12632 (void *)&cmd_config_e_tag_off,
12633 (void *)&cmd_config_e_tag_port,
12634 (void *)&cmd_config_e_tag_port_id,
12635 (void *)&cmd_config_e_tag_vf,
12636 (void *)&cmd_config_e_tag_vf_id,
12641 /* E-tag stripping configuration */
12643 cmd_config_e_tag_stripping_parsed(
12644 void *parsed_result,
12645 __attribute__((unused)) struct cmdline *cl,
12646 __attribute__((unused)) void *data)
12648 struct cmd_config_e_tag_result *res =
12650 struct rte_eth_l2_tunnel_conf entry;
12652 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12655 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12657 if (!strcmp(res->on_off, "on"))
12658 rte_eth_dev_l2_tunnel_offload_set
12661 ETH_L2_TUNNEL_STRIPPING_MASK,
12664 rte_eth_dev_l2_tunnel_offload_set
12667 ETH_L2_TUNNEL_STRIPPING_MASK,
12671 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12672 .f = cmd_config_e_tag_stripping_parsed,
12674 .help_str = "E-tag ... : E-tag stripping enable/disable",
12676 (void *)&cmd_config_e_tag_e_tag,
12677 (void *)&cmd_config_e_tag_set,
12678 (void *)&cmd_config_e_tag_stripping,
12679 (void *)&cmd_config_e_tag_on_off,
12680 (void *)&cmd_config_e_tag_port,
12681 (void *)&cmd_config_e_tag_port_id,
12686 /* E-tag forwarding configuration */
12688 cmd_config_e_tag_forwarding_parsed(
12689 void *parsed_result,
12690 __attribute__((unused)) struct cmdline *cl,
12691 __attribute__((unused)) void *data)
12693 struct cmd_config_e_tag_result *res = parsed_result;
12694 struct rte_eth_l2_tunnel_conf entry;
12696 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12699 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12701 if (!strcmp(res->on_off, "on"))
12702 rte_eth_dev_l2_tunnel_offload_set
12705 ETH_L2_TUNNEL_FORWARDING_MASK,
12708 rte_eth_dev_l2_tunnel_offload_set
12711 ETH_L2_TUNNEL_FORWARDING_MASK,
12715 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12716 .f = cmd_config_e_tag_forwarding_parsed,
12718 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12720 (void *)&cmd_config_e_tag_e_tag,
12721 (void *)&cmd_config_e_tag_set,
12722 (void *)&cmd_config_e_tag_forwarding,
12723 (void *)&cmd_config_e_tag_on_off,
12724 (void *)&cmd_config_e_tag_port,
12725 (void *)&cmd_config_e_tag_port_id,
12730 /* E-tag filter configuration */
12732 cmd_config_e_tag_filter_add_parsed(
12733 void *parsed_result,
12734 __attribute__((unused)) struct cmdline *cl,
12735 __attribute__((unused)) void *data)
12737 struct cmd_config_e_tag_result *res = parsed_result;
12738 struct rte_eth_l2_tunnel_conf entry;
12741 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12744 if (res->e_tag_id_val > 0x3fff) {
12745 printf("e-tag-id must be equal or less than 0x3fff.\n");
12749 ret = rte_eth_dev_filter_supported(res->port_id,
12750 RTE_ETH_FILTER_L2_TUNNEL);
12752 printf("E-tag filter is not supported on port %u.\n",
12757 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12758 entry.tunnel_id = res->e_tag_id_val;
12759 entry.pool = res->dst_pool_val;
12761 ret = rte_eth_dev_filter_ctrl(res->port_id,
12762 RTE_ETH_FILTER_L2_TUNNEL,
12763 RTE_ETH_FILTER_ADD,
12766 printf("E-tag filter programming error: (%s)\n",
12770 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12771 .f = cmd_config_e_tag_filter_add_parsed,
12773 .help_str = "E-tag ... : E-tag filter add",
12775 (void *)&cmd_config_e_tag_e_tag,
12776 (void *)&cmd_config_e_tag_set,
12777 (void *)&cmd_config_e_tag_filter,
12778 (void *)&cmd_config_e_tag_add,
12779 (void *)&cmd_config_e_tag_e_tag_id,
12780 (void *)&cmd_config_e_tag_e_tag_id_val,
12781 (void *)&cmd_config_e_tag_dst_pool,
12782 (void *)&cmd_config_e_tag_dst_pool_val,
12783 (void *)&cmd_config_e_tag_port,
12784 (void *)&cmd_config_e_tag_port_id,
12790 cmd_config_e_tag_filter_del_parsed(
12791 void *parsed_result,
12792 __attribute__((unused)) struct cmdline *cl,
12793 __attribute__((unused)) void *data)
12795 struct cmd_config_e_tag_result *res = parsed_result;
12796 struct rte_eth_l2_tunnel_conf entry;
12799 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12802 if (res->e_tag_id_val > 0x3fff) {
12803 printf("e-tag-id must be less than 0x3fff.\n");
12807 ret = rte_eth_dev_filter_supported(res->port_id,
12808 RTE_ETH_FILTER_L2_TUNNEL);
12810 printf("E-tag filter is not supported on port %u.\n",
12815 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12816 entry.tunnel_id = res->e_tag_id_val;
12818 ret = rte_eth_dev_filter_ctrl(res->port_id,
12819 RTE_ETH_FILTER_L2_TUNNEL,
12820 RTE_ETH_FILTER_DELETE,
12823 printf("E-tag filter programming error: (%s)\n",
12827 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12828 .f = cmd_config_e_tag_filter_del_parsed,
12830 .help_str = "E-tag ... : E-tag filter delete",
12832 (void *)&cmd_config_e_tag_e_tag,
12833 (void *)&cmd_config_e_tag_set,
12834 (void *)&cmd_config_e_tag_filter,
12835 (void *)&cmd_config_e_tag_del,
12836 (void *)&cmd_config_e_tag_e_tag_id,
12837 (void *)&cmd_config_e_tag_e_tag_id_val,
12838 (void *)&cmd_config_e_tag_port,
12839 (void *)&cmd_config_e_tag_port_id,
12844 /* vf vlan anti spoof configuration */
12846 /* Common result structure for vf vlan anti spoof */
12847 struct cmd_vf_vlan_anti_spoof_result {
12848 cmdline_fixed_string_t set;
12849 cmdline_fixed_string_t vf;
12850 cmdline_fixed_string_t vlan;
12851 cmdline_fixed_string_t antispoof;
12854 cmdline_fixed_string_t on_off;
12857 /* Common CLI fields for vf vlan anti spoof enable disable */
12858 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12859 TOKEN_STRING_INITIALIZER
12860 (struct cmd_vf_vlan_anti_spoof_result,
12862 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12863 TOKEN_STRING_INITIALIZER
12864 (struct cmd_vf_vlan_anti_spoof_result,
12866 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12867 TOKEN_STRING_INITIALIZER
12868 (struct cmd_vf_vlan_anti_spoof_result,
12870 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12871 TOKEN_STRING_INITIALIZER
12872 (struct cmd_vf_vlan_anti_spoof_result,
12873 antispoof, "antispoof");
12874 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12875 TOKEN_NUM_INITIALIZER
12876 (struct cmd_vf_vlan_anti_spoof_result,
12878 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12879 TOKEN_NUM_INITIALIZER
12880 (struct cmd_vf_vlan_anti_spoof_result,
12882 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12883 TOKEN_STRING_INITIALIZER
12884 (struct cmd_vf_vlan_anti_spoof_result,
12888 cmd_set_vf_vlan_anti_spoof_parsed(
12889 void *parsed_result,
12890 __attribute__((unused)) struct cmdline *cl,
12891 __attribute__((unused)) void *data)
12893 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12894 int ret = -ENOTSUP;
12896 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12898 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12901 #ifdef RTE_LIBRTE_IXGBE_PMD
12902 if (ret == -ENOTSUP)
12903 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12904 res->vf_id, is_on);
12906 #ifdef RTE_LIBRTE_I40E_PMD
12907 if (ret == -ENOTSUP)
12908 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12909 res->vf_id, is_on);
12911 #ifdef RTE_LIBRTE_BNXT_PMD
12912 if (ret == -ENOTSUP)
12913 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12914 res->vf_id, is_on);
12921 printf("invalid vf_id %d\n", res->vf_id);
12924 printf("invalid port_id %d\n", res->port_id);
12927 printf("function not implemented\n");
12930 printf("programming error: (%s)\n", strerror(-ret));
12934 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12935 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12937 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12939 (void *)&cmd_vf_vlan_anti_spoof_set,
12940 (void *)&cmd_vf_vlan_anti_spoof_vf,
12941 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12942 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12943 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12944 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12945 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12950 /* vf mac anti spoof configuration */
12952 /* Common result structure for vf mac anti spoof */
12953 struct cmd_vf_mac_anti_spoof_result {
12954 cmdline_fixed_string_t set;
12955 cmdline_fixed_string_t vf;
12956 cmdline_fixed_string_t mac;
12957 cmdline_fixed_string_t antispoof;
12960 cmdline_fixed_string_t on_off;
12963 /* Common CLI fields for vf mac anti spoof enable disable */
12964 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12965 TOKEN_STRING_INITIALIZER
12966 (struct cmd_vf_mac_anti_spoof_result,
12968 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12969 TOKEN_STRING_INITIALIZER
12970 (struct cmd_vf_mac_anti_spoof_result,
12972 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12973 TOKEN_STRING_INITIALIZER
12974 (struct cmd_vf_mac_anti_spoof_result,
12976 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12977 TOKEN_STRING_INITIALIZER
12978 (struct cmd_vf_mac_anti_spoof_result,
12979 antispoof, "antispoof");
12980 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12981 TOKEN_NUM_INITIALIZER
12982 (struct cmd_vf_mac_anti_spoof_result,
12984 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12985 TOKEN_NUM_INITIALIZER
12986 (struct cmd_vf_mac_anti_spoof_result,
12988 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12989 TOKEN_STRING_INITIALIZER
12990 (struct cmd_vf_mac_anti_spoof_result,
12994 cmd_set_vf_mac_anti_spoof_parsed(
12995 void *parsed_result,
12996 __attribute__((unused)) struct cmdline *cl,
12997 __attribute__((unused)) void *data)
12999 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13000 int ret = -ENOTSUP;
13002 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13004 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13007 #ifdef RTE_LIBRTE_IXGBE_PMD
13008 if (ret == -ENOTSUP)
13009 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13010 res->vf_id, is_on);
13012 #ifdef RTE_LIBRTE_I40E_PMD
13013 if (ret == -ENOTSUP)
13014 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13015 res->vf_id, is_on);
13017 #ifdef RTE_LIBRTE_BNXT_PMD
13018 if (ret == -ENOTSUP)
13019 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13020 res->vf_id, is_on);
13027 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13030 printf("invalid port_id %d\n", res->port_id);
13033 printf("function not implemented\n");
13036 printf("programming error: (%s)\n", strerror(-ret));
13040 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13041 .f = cmd_set_vf_mac_anti_spoof_parsed,
13043 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13045 (void *)&cmd_vf_mac_anti_spoof_set,
13046 (void *)&cmd_vf_mac_anti_spoof_vf,
13047 (void *)&cmd_vf_mac_anti_spoof_mac,
13048 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13049 (void *)&cmd_vf_mac_anti_spoof_port_id,
13050 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13051 (void *)&cmd_vf_mac_anti_spoof_on_off,
13056 /* vf vlan strip queue configuration */
13058 /* Common result structure for vf mac anti spoof */
13059 struct cmd_vf_vlan_stripq_result {
13060 cmdline_fixed_string_t set;
13061 cmdline_fixed_string_t vf;
13062 cmdline_fixed_string_t vlan;
13063 cmdline_fixed_string_t stripq;
13066 cmdline_fixed_string_t on_off;
13069 /* Common CLI fields for vf vlan strip enable disable */
13070 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13071 TOKEN_STRING_INITIALIZER
13072 (struct cmd_vf_vlan_stripq_result,
13074 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13075 TOKEN_STRING_INITIALIZER
13076 (struct cmd_vf_vlan_stripq_result,
13078 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13079 TOKEN_STRING_INITIALIZER
13080 (struct cmd_vf_vlan_stripq_result,
13082 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13083 TOKEN_STRING_INITIALIZER
13084 (struct cmd_vf_vlan_stripq_result,
13086 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13087 TOKEN_NUM_INITIALIZER
13088 (struct cmd_vf_vlan_stripq_result,
13090 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13091 TOKEN_NUM_INITIALIZER
13092 (struct cmd_vf_vlan_stripq_result,
13094 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13095 TOKEN_STRING_INITIALIZER
13096 (struct cmd_vf_vlan_stripq_result,
13100 cmd_set_vf_vlan_stripq_parsed(
13101 void *parsed_result,
13102 __attribute__((unused)) struct cmdline *cl,
13103 __attribute__((unused)) void *data)
13105 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13106 int ret = -ENOTSUP;
13108 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13110 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13113 #ifdef RTE_LIBRTE_IXGBE_PMD
13114 if (ret == -ENOTSUP)
13115 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13116 res->vf_id, is_on);
13118 #ifdef RTE_LIBRTE_I40E_PMD
13119 if (ret == -ENOTSUP)
13120 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13121 res->vf_id, is_on);
13123 #ifdef RTE_LIBRTE_BNXT_PMD
13124 if (ret == -ENOTSUP)
13125 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13126 res->vf_id, is_on);
13133 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13136 printf("invalid port_id %d\n", res->port_id);
13139 printf("function not implemented\n");
13142 printf("programming error: (%s)\n", strerror(-ret));
13146 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13147 .f = cmd_set_vf_vlan_stripq_parsed,
13149 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13151 (void *)&cmd_vf_vlan_stripq_set,
13152 (void *)&cmd_vf_vlan_stripq_vf,
13153 (void *)&cmd_vf_vlan_stripq_vlan,
13154 (void *)&cmd_vf_vlan_stripq_stripq,
13155 (void *)&cmd_vf_vlan_stripq_port_id,
13156 (void *)&cmd_vf_vlan_stripq_vf_id,
13157 (void *)&cmd_vf_vlan_stripq_on_off,
13162 /* vf vlan insert configuration */
13164 /* Common result structure for vf vlan insert */
13165 struct cmd_vf_vlan_insert_result {
13166 cmdline_fixed_string_t set;
13167 cmdline_fixed_string_t vf;
13168 cmdline_fixed_string_t vlan;
13169 cmdline_fixed_string_t insert;
13175 /* Common CLI fields for vf vlan insert enable disable */
13176 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13177 TOKEN_STRING_INITIALIZER
13178 (struct cmd_vf_vlan_insert_result,
13180 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13181 TOKEN_STRING_INITIALIZER
13182 (struct cmd_vf_vlan_insert_result,
13184 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13185 TOKEN_STRING_INITIALIZER
13186 (struct cmd_vf_vlan_insert_result,
13188 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13189 TOKEN_STRING_INITIALIZER
13190 (struct cmd_vf_vlan_insert_result,
13192 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13193 TOKEN_NUM_INITIALIZER
13194 (struct cmd_vf_vlan_insert_result,
13196 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13197 TOKEN_NUM_INITIALIZER
13198 (struct cmd_vf_vlan_insert_result,
13200 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13201 TOKEN_NUM_INITIALIZER
13202 (struct cmd_vf_vlan_insert_result,
13206 cmd_set_vf_vlan_insert_parsed(
13207 void *parsed_result,
13208 __attribute__((unused)) struct cmdline *cl,
13209 __attribute__((unused)) void *data)
13211 struct cmd_vf_vlan_insert_result *res = parsed_result;
13212 int ret = -ENOTSUP;
13214 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13217 #ifdef RTE_LIBRTE_IXGBE_PMD
13218 if (ret == -ENOTSUP)
13219 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13222 #ifdef RTE_LIBRTE_I40E_PMD
13223 if (ret == -ENOTSUP)
13224 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13227 #ifdef RTE_LIBRTE_BNXT_PMD
13228 if (ret == -ENOTSUP)
13229 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13237 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13240 printf("invalid port_id %d\n", res->port_id);
13243 printf("function not implemented\n");
13246 printf("programming error: (%s)\n", strerror(-ret));
13250 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13251 .f = cmd_set_vf_vlan_insert_parsed,
13253 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13255 (void *)&cmd_vf_vlan_insert_set,
13256 (void *)&cmd_vf_vlan_insert_vf,
13257 (void *)&cmd_vf_vlan_insert_vlan,
13258 (void *)&cmd_vf_vlan_insert_insert,
13259 (void *)&cmd_vf_vlan_insert_port_id,
13260 (void *)&cmd_vf_vlan_insert_vf_id,
13261 (void *)&cmd_vf_vlan_insert_vlan_id,
13266 /* tx loopback configuration */
13268 /* Common result structure for tx loopback */
13269 struct cmd_tx_loopback_result {
13270 cmdline_fixed_string_t set;
13271 cmdline_fixed_string_t tx;
13272 cmdline_fixed_string_t loopback;
13274 cmdline_fixed_string_t on_off;
13277 /* Common CLI fields for tx loopback enable disable */
13278 cmdline_parse_token_string_t cmd_tx_loopback_set =
13279 TOKEN_STRING_INITIALIZER
13280 (struct cmd_tx_loopback_result,
13282 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13283 TOKEN_STRING_INITIALIZER
13284 (struct cmd_tx_loopback_result,
13286 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13287 TOKEN_STRING_INITIALIZER
13288 (struct cmd_tx_loopback_result,
13289 loopback, "loopback");
13290 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13291 TOKEN_NUM_INITIALIZER
13292 (struct cmd_tx_loopback_result,
13294 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13295 TOKEN_STRING_INITIALIZER
13296 (struct cmd_tx_loopback_result,
13300 cmd_set_tx_loopback_parsed(
13301 void *parsed_result,
13302 __attribute__((unused)) struct cmdline *cl,
13303 __attribute__((unused)) void *data)
13305 struct cmd_tx_loopback_result *res = parsed_result;
13306 int ret = -ENOTSUP;
13308 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13313 #ifdef RTE_LIBRTE_IXGBE_PMD
13314 if (ret == -ENOTSUP)
13315 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13317 #ifdef RTE_LIBRTE_I40E_PMD
13318 if (ret == -ENOTSUP)
13319 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13321 #ifdef RTE_LIBRTE_BNXT_PMD
13322 if (ret == -ENOTSUP)
13323 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13325 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13326 if (ret == -ENOTSUP)
13327 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13334 printf("invalid is_on %d\n", is_on);
13337 printf("invalid port_id %d\n", res->port_id);
13340 printf("function not implemented\n");
13343 printf("programming error: (%s)\n", strerror(-ret));
13347 cmdline_parse_inst_t cmd_set_tx_loopback = {
13348 .f = cmd_set_tx_loopback_parsed,
13350 .help_str = "set tx loopback <port_id> on|off",
13352 (void *)&cmd_tx_loopback_set,
13353 (void *)&cmd_tx_loopback_tx,
13354 (void *)&cmd_tx_loopback_loopback,
13355 (void *)&cmd_tx_loopback_port_id,
13356 (void *)&cmd_tx_loopback_on_off,
13361 /* all queues drop enable configuration */
13363 /* Common result structure for all queues drop enable */
13364 struct cmd_all_queues_drop_en_result {
13365 cmdline_fixed_string_t set;
13366 cmdline_fixed_string_t all;
13367 cmdline_fixed_string_t queues;
13368 cmdline_fixed_string_t drop;
13370 cmdline_fixed_string_t on_off;
13373 /* Common CLI fields for tx loopback enable disable */
13374 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13375 TOKEN_STRING_INITIALIZER
13376 (struct cmd_all_queues_drop_en_result,
13378 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13379 TOKEN_STRING_INITIALIZER
13380 (struct cmd_all_queues_drop_en_result,
13382 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13383 TOKEN_STRING_INITIALIZER
13384 (struct cmd_all_queues_drop_en_result,
13386 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13387 TOKEN_STRING_INITIALIZER
13388 (struct cmd_all_queues_drop_en_result,
13390 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13391 TOKEN_NUM_INITIALIZER
13392 (struct cmd_all_queues_drop_en_result,
13394 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13395 TOKEN_STRING_INITIALIZER
13396 (struct cmd_all_queues_drop_en_result,
13400 cmd_set_all_queues_drop_en_parsed(
13401 void *parsed_result,
13402 __attribute__((unused)) struct cmdline *cl,
13403 __attribute__((unused)) void *data)
13405 struct cmd_all_queues_drop_en_result *res = parsed_result;
13406 int ret = -ENOTSUP;
13407 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13412 #ifdef RTE_LIBRTE_IXGBE_PMD
13413 if (ret == -ENOTSUP)
13414 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13416 #ifdef RTE_LIBRTE_BNXT_PMD
13417 if (ret == -ENOTSUP)
13418 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13424 printf("invalid is_on %d\n", is_on);
13427 printf("invalid port_id %d\n", res->port_id);
13430 printf("function not implemented\n");
13433 printf("programming error: (%s)\n", strerror(-ret));
13437 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13438 .f = cmd_set_all_queues_drop_en_parsed,
13440 .help_str = "set all queues drop <port_id> on|off",
13442 (void *)&cmd_all_queues_drop_en_set,
13443 (void *)&cmd_all_queues_drop_en_all,
13444 (void *)&cmd_all_queues_drop_en_queues,
13445 (void *)&cmd_all_queues_drop_en_drop,
13446 (void *)&cmd_all_queues_drop_en_port_id,
13447 (void *)&cmd_all_queues_drop_en_on_off,
13452 /* vf split drop enable configuration */
13454 /* Common result structure for vf split drop enable */
13455 struct cmd_vf_split_drop_en_result {
13456 cmdline_fixed_string_t set;
13457 cmdline_fixed_string_t vf;
13458 cmdline_fixed_string_t split;
13459 cmdline_fixed_string_t drop;
13462 cmdline_fixed_string_t on_off;
13465 /* Common CLI fields for vf split drop enable disable */
13466 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13467 TOKEN_STRING_INITIALIZER
13468 (struct cmd_vf_split_drop_en_result,
13470 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13471 TOKEN_STRING_INITIALIZER
13472 (struct cmd_vf_split_drop_en_result,
13474 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13475 TOKEN_STRING_INITIALIZER
13476 (struct cmd_vf_split_drop_en_result,
13478 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13479 TOKEN_STRING_INITIALIZER
13480 (struct cmd_vf_split_drop_en_result,
13482 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13483 TOKEN_NUM_INITIALIZER
13484 (struct cmd_vf_split_drop_en_result,
13486 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13487 TOKEN_NUM_INITIALIZER
13488 (struct cmd_vf_split_drop_en_result,
13490 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13491 TOKEN_STRING_INITIALIZER
13492 (struct cmd_vf_split_drop_en_result,
13496 cmd_set_vf_split_drop_en_parsed(
13497 void *parsed_result,
13498 __attribute__((unused)) struct cmdline *cl,
13499 __attribute__((unused)) void *data)
13501 struct cmd_vf_split_drop_en_result *res = parsed_result;
13502 int ret = -ENOTSUP;
13503 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13505 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13508 #ifdef RTE_LIBRTE_IXGBE_PMD
13509 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13516 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13519 printf("invalid port_id %d\n", res->port_id);
13522 printf("not supported on port %d\n", res->port_id);
13525 printf("programming error: (%s)\n", strerror(-ret));
13529 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13530 .f = cmd_set_vf_split_drop_en_parsed,
13532 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13534 (void *)&cmd_vf_split_drop_en_set,
13535 (void *)&cmd_vf_split_drop_en_vf,
13536 (void *)&cmd_vf_split_drop_en_split,
13537 (void *)&cmd_vf_split_drop_en_drop,
13538 (void *)&cmd_vf_split_drop_en_port_id,
13539 (void *)&cmd_vf_split_drop_en_vf_id,
13540 (void *)&cmd_vf_split_drop_en_on_off,
13545 /* vf mac address configuration */
13547 /* Common result structure for vf mac address */
13548 struct cmd_set_vf_mac_addr_result {
13549 cmdline_fixed_string_t set;
13550 cmdline_fixed_string_t vf;
13551 cmdline_fixed_string_t mac;
13552 cmdline_fixed_string_t addr;
13555 struct ether_addr mac_addr;
13559 /* Common CLI fields for vf split drop enable disable */
13560 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13561 TOKEN_STRING_INITIALIZER
13562 (struct cmd_set_vf_mac_addr_result,
13564 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13565 TOKEN_STRING_INITIALIZER
13566 (struct cmd_set_vf_mac_addr_result,
13568 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13569 TOKEN_STRING_INITIALIZER
13570 (struct cmd_set_vf_mac_addr_result,
13572 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13573 TOKEN_STRING_INITIALIZER
13574 (struct cmd_set_vf_mac_addr_result,
13576 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13577 TOKEN_NUM_INITIALIZER
13578 (struct cmd_set_vf_mac_addr_result,
13580 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13581 TOKEN_NUM_INITIALIZER
13582 (struct cmd_set_vf_mac_addr_result,
13584 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13585 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13589 cmd_set_vf_mac_addr_parsed(
13590 void *parsed_result,
13591 __attribute__((unused)) struct cmdline *cl,
13592 __attribute__((unused)) void *data)
13594 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13595 int ret = -ENOTSUP;
13597 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13600 #ifdef RTE_LIBRTE_IXGBE_PMD
13601 if (ret == -ENOTSUP)
13602 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13605 #ifdef RTE_LIBRTE_I40E_PMD
13606 if (ret == -ENOTSUP)
13607 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13610 #ifdef RTE_LIBRTE_BNXT_PMD
13611 if (ret == -ENOTSUP)
13612 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13620 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13623 printf("invalid port_id %d\n", res->port_id);
13626 printf("function not implemented\n");
13629 printf("programming error: (%s)\n", strerror(-ret));
13633 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13634 .f = cmd_set_vf_mac_addr_parsed,
13636 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13638 (void *)&cmd_set_vf_mac_addr_set,
13639 (void *)&cmd_set_vf_mac_addr_vf,
13640 (void *)&cmd_set_vf_mac_addr_mac,
13641 (void *)&cmd_set_vf_mac_addr_addr,
13642 (void *)&cmd_set_vf_mac_addr_port_id,
13643 (void *)&cmd_set_vf_mac_addr_vf_id,
13644 (void *)&cmd_set_vf_mac_addr_mac_addr,
13649 /* MACsec configuration */
13651 /* Common result structure for MACsec offload enable */
13652 struct cmd_macsec_offload_on_result {
13653 cmdline_fixed_string_t set;
13654 cmdline_fixed_string_t macsec;
13655 cmdline_fixed_string_t offload;
13657 cmdline_fixed_string_t on;
13658 cmdline_fixed_string_t encrypt;
13659 cmdline_fixed_string_t en_on_off;
13660 cmdline_fixed_string_t replay_protect;
13661 cmdline_fixed_string_t rp_on_off;
13664 /* Common CLI fields for MACsec offload disable */
13665 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13666 TOKEN_STRING_INITIALIZER
13667 (struct cmd_macsec_offload_on_result,
13669 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13670 TOKEN_STRING_INITIALIZER
13671 (struct cmd_macsec_offload_on_result,
13673 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13674 TOKEN_STRING_INITIALIZER
13675 (struct cmd_macsec_offload_on_result,
13676 offload, "offload");
13677 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13678 TOKEN_NUM_INITIALIZER
13679 (struct cmd_macsec_offload_on_result,
13681 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13682 TOKEN_STRING_INITIALIZER
13683 (struct cmd_macsec_offload_on_result,
13685 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13686 TOKEN_STRING_INITIALIZER
13687 (struct cmd_macsec_offload_on_result,
13688 encrypt, "encrypt");
13689 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13690 TOKEN_STRING_INITIALIZER
13691 (struct cmd_macsec_offload_on_result,
13692 en_on_off, "on#off");
13693 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13694 TOKEN_STRING_INITIALIZER
13695 (struct cmd_macsec_offload_on_result,
13696 replay_protect, "replay-protect");
13697 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13698 TOKEN_STRING_INITIALIZER
13699 (struct cmd_macsec_offload_on_result,
13700 rp_on_off, "on#off");
13703 cmd_set_macsec_offload_on_parsed(
13704 void *parsed_result,
13705 __attribute__((unused)) struct cmdline *cl,
13706 __attribute__((unused)) void *data)
13708 struct cmd_macsec_offload_on_result *res = parsed_result;
13709 int ret = -ENOTSUP;
13710 portid_t port_id = res->port_id;
13711 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13712 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13713 struct rte_eth_dev_info dev_info;
13715 if (port_id_is_invalid(port_id, ENABLED_WARN))
13717 if (!port_is_stopped(port_id)) {
13718 printf("Please stop port %d first\n", port_id);
13722 rte_eth_dev_info_get(port_id, &dev_info);
13723 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13724 #ifdef RTE_LIBRTE_IXGBE_PMD
13725 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13733 ports[port_id].dev_conf.txmode.offloads |=
13734 DEV_TX_OFFLOAD_MACSEC_INSERT;
13735 cmd_reconfig_device_queue(port_id, 1, 1);
13738 printf("invalid port_id %d\n", port_id);
13741 printf("not supported on port %d\n", port_id);
13744 printf("programming error: (%s)\n", strerror(-ret));
13748 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13749 .f = cmd_set_macsec_offload_on_parsed,
13751 .help_str = "set macsec offload <port_id> on "
13752 "encrypt on|off replay-protect on|off",
13754 (void *)&cmd_macsec_offload_on_set,
13755 (void *)&cmd_macsec_offload_on_macsec,
13756 (void *)&cmd_macsec_offload_on_offload,
13757 (void *)&cmd_macsec_offload_on_port_id,
13758 (void *)&cmd_macsec_offload_on_on,
13759 (void *)&cmd_macsec_offload_on_encrypt,
13760 (void *)&cmd_macsec_offload_on_en_on_off,
13761 (void *)&cmd_macsec_offload_on_replay_protect,
13762 (void *)&cmd_macsec_offload_on_rp_on_off,
13767 /* Common result structure for MACsec offload disable */
13768 struct cmd_macsec_offload_off_result {
13769 cmdline_fixed_string_t set;
13770 cmdline_fixed_string_t macsec;
13771 cmdline_fixed_string_t offload;
13773 cmdline_fixed_string_t off;
13776 /* Common CLI fields for MACsec offload disable */
13777 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13778 TOKEN_STRING_INITIALIZER
13779 (struct cmd_macsec_offload_off_result,
13781 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13782 TOKEN_STRING_INITIALIZER
13783 (struct cmd_macsec_offload_off_result,
13785 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13786 TOKEN_STRING_INITIALIZER
13787 (struct cmd_macsec_offload_off_result,
13788 offload, "offload");
13789 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13790 TOKEN_NUM_INITIALIZER
13791 (struct cmd_macsec_offload_off_result,
13793 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13794 TOKEN_STRING_INITIALIZER
13795 (struct cmd_macsec_offload_off_result,
13799 cmd_set_macsec_offload_off_parsed(
13800 void *parsed_result,
13801 __attribute__((unused)) struct cmdline *cl,
13802 __attribute__((unused)) void *data)
13804 struct cmd_macsec_offload_off_result *res = parsed_result;
13805 int ret = -ENOTSUP;
13806 struct rte_eth_dev_info dev_info;
13807 portid_t port_id = res->port_id;
13809 if (port_id_is_invalid(port_id, ENABLED_WARN))
13811 if (!port_is_stopped(port_id)) {
13812 printf("Please stop port %d first\n", port_id);
13816 rte_eth_dev_info_get(port_id, &dev_info);
13817 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13818 #ifdef RTE_LIBRTE_IXGBE_PMD
13819 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13824 ports[port_id].dev_conf.txmode.offloads &=
13825 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13826 cmd_reconfig_device_queue(port_id, 1, 1);
13829 printf("invalid port_id %d\n", port_id);
13832 printf("not supported on port %d\n", port_id);
13835 printf("programming error: (%s)\n", strerror(-ret));
13839 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13840 .f = cmd_set_macsec_offload_off_parsed,
13842 .help_str = "set macsec offload <port_id> off",
13844 (void *)&cmd_macsec_offload_off_set,
13845 (void *)&cmd_macsec_offload_off_macsec,
13846 (void *)&cmd_macsec_offload_off_offload,
13847 (void *)&cmd_macsec_offload_off_port_id,
13848 (void *)&cmd_macsec_offload_off_off,
13853 /* Common result structure for MACsec secure connection configure */
13854 struct cmd_macsec_sc_result {
13855 cmdline_fixed_string_t set;
13856 cmdline_fixed_string_t macsec;
13857 cmdline_fixed_string_t sc;
13858 cmdline_fixed_string_t tx_rx;
13860 struct ether_addr mac;
13864 /* Common CLI fields for MACsec secure connection configure */
13865 cmdline_parse_token_string_t cmd_macsec_sc_set =
13866 TOKEN_STRING_INITIALIZER
13867 (struct cmd_macsec_sc_result,
13869 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13870 TOKEN_STRING_INITIALIZER
13871 (struct cmd_macsec_sc_result,
13873 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13874 TOKEN_STRING_INITIALIZER
13875 (struct cmd_macsec_sc_result,
13877 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13878 TOKEN_STRING_INITIALIZER
13879 (struct cmd_macsec_sc_result,
13881 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13882 TOKEN_NUM_INITIALIZER
13883 (struct cmd_macsec_sc_result,
13885 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13886 TOKEN_ETHERADDR_INITIALIZER
13887 (struct cmd_macsec_sc_result,
13889 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13890 TOKEN_NUM_INITIALIZER
13891 (struct cmd_macsec_sc_result,
13895 cmd_set_macsec_sc_parsed(
13896 void *parsed_result,
13897 __attribute__((unused)) struct cmdline *cl,
13898 __attribute__((unused)) void *data)
13900 struct cmd_macsec_sc_result *res = parsed_result;
13901 int ret = -ENOTSUP;
13902 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13904 #ifdef RTE_LIBRTE_IXGBE_PMD
13906 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13907 res->mac.addr_bytes) :
13908 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13909 res->mac.addr_bytes, res->pi);
13911 RTE_SET_USED(is_tx);
13917 printf("invalid port_id %d\n", res->port_id);
13920 printf("not supported on port %d\n", res->port_id);
13923 printf("programming error: (%s)\n", strerror(-ret));
13927 cmdline_parse_inst_t cmd_set_macsec_sc = {
13928 .f = cmd_set_macsec_sc_parsed,
13930 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13932 (void *)&cmd_macsec_sc_set,
13933 (void *)&cmd_macsec_sc_macsec,
13934 (void *)&cmd_macsec_sc_sc,
13935 (void *)&cmd_macsec_sc_tx_rx,
13936 (void *)&cmd_macsec_sc_port_id,
13937 (void *)&cmd_macsec_sc_mac,
13938 (void *)&cmd_macsec_sc_pi,
13943 /* Common result structure for MACsec secure connection configure */
13944 struct cmd_macsec_sa_result {
13945 cmdline_fixed_string_t set;
13946 cmdline_fixed_string_t macsec;
13947 cmdline_fixed_string_t sa;
13948 cmdline_fixed_string_t tx_rx;
13953 cmdline_fixed_string_t key;
13956 /* Common CLI fields for MACsec secure connection configure */
13957 cmdline_parse_token_string_t cmd_macsec_sa_set =
13958 TOKEN_STRING_INITIALIZER
13959 (struct cmd_macsec_sa_result,
13961 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13962 TOKEN_STRING_INITIALIZER
13963 (struct cmd_macsec_sa_result,
13965 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13966 TOKEN_STRING_INITIALIZER
13967 (struct cmd_macsec_sa_result,
13969 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13970 TOKEN_STRING_INITIALIZER
13971 (struct cmd_macsec_sa_result,
13973 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13974 TOKEN_NUM_INITIALIZER
13975 (struct cmd_macsec_sa_result,
13977 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13978 TOKEN_NUM_INITIALIZER
13979 (struct cmd_macsec_sa_result,
13981 cmdline_parse_token_num_t cmd_macsec_sa_an =
13982 TOKEN_NUM_INITIALIZER
13983 (struct cmd_macsec_sa_result,
13985 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13986 TOKEN_NUM_INITIALIZER
13987 (struct cmd_macsec_sa_result,
13989 cmdline_parse_token_string_t cmd_macsec_sa_key =
13990 TOKEN_STRING_INITIALIZER
13991 (struct cmd_macsec_sa_result,
13995 cmd_set_macsec_sa_parsed(
13996 void *parsed_result,
13997 __attribute__((unused)) struct cmdline *cl,
13998 __attribute__((unused)) void *data)
14000 struct cmd_macsec_sa_result *res = parsed_result;
14001 int ret = -ENOTSUP;
14002 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14003 uint8_t key[16] = { 0 };
14009 key_len = strlen(res->key) / 2;
14013 for (i = 0; i < key_len; i++) {
14014 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14017 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14020 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14023 #ifdef RTE_LIBRTE_IXGBE_PMD
14025 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14026 res->idx, res->an, res->pn, key) :
14027 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14028 res->idx, res->an, res->pn, key);
14030 RTE_SET_USED(is_tx);
14037 printf("invalid idx %d or an %d\n", res->idx, res->an);
14040 printf("invalid port_id %d\n", res->port_id);
14043 printf("not supported on port %d\n", res->port_id);
14046 printf("programming error: (%s)\n", strerror(-ret));
14050 cmdline_parse_inst_t cmd_set_macsec_sa = {
14051 .f = cmd_set_macsec_sa_parsed,
14053 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14055 (void *)&cmd_macsec_sa_set,
14056 (void *)&cmd_macsec_sa_macsec,
14057 (void *)&cmd_macsec_sa_sa,
14058 (void *)&cmd_macsec_sa_tx_rx,
14059 (void *)&cmd_macsec_sa_port_id,
14060 (void *)&cmd_macsec_sa_idx,
14061 (void *)&cmd_macsec_sa_an,
14062 (void *)&cmd_macsec_sa_pn,
14063 (void *)&cmd_macsec_sa_key,
14068 /* VF unicast promiscuous mode configuration */
14070 /* Common result structure for VF unicast promiscuous mode */
14071 struct cmd_vf_promisc_result {
14072 cmdline_fixed_string_t set;
14073 cmdline_fixed_string_t vf;
14074 cmdline_fixed_string_t promisc;
14077 cmdline_fixed_string_t on_off;
14080 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14081 cmdline_parse_token_string_t cmd_vf_promisc_set =
14082 TOKEN_STRING_INITIALIZER
14083 (struct cmd_vf_promisc_result,
14085 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14086 TOKEN_STRING_INITIALIZER
14087 (struct cmd_vf_promisc_result,
14089 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14090 TOKEN_STRING_INITIALIZER
14091 (struct cmd_vf_promisc_result,
14092 promisc, "promisc");
14093 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14094 TOKEN_NUM_INITIALIZER
14095 (struct cmd_vf_promisc_result,
14097 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14098 TOKEN_NUM_INITIALIZER
14099 (struct cmd_vf_promisc_result,
14101 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14102 TOKEN_STRING_INITIALIZER
14103 (struct cmd_vf_promisc_result,
14107 cmd_set_vf_promisc_parsed(
14108 void *parsed_result,
14109 __attribute__((unused)) struct cmdline *cl,
14110 __attribute__((unused)) void *data)
14112 struct cmd_vf_promisc_result *res = parsed_result;
14113 int ret = -ENOTSUP;
14115 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14117 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14120 #ifdef RTE_LIBRTE_I40E_PMD
14121 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14122 res->vf_id, is_on);
14129 printf("invalid vf_id %d\n", res->vf_id);
14132 printf("invalid port_id %d\n", res->port_id);
14135 printf("function not implemented\n");
14138 printf("programming error: (%s)\n", strerror(-ret));
14142 cmdline_parse_inst_t cmd_set_vf_promisc = {
14143 .f = cmd_set_vf_promisc_parsed,
14145 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14146 "Set unicast promiscuous mode for a VF from the PF",
14148 (void *)&cmd_vf_promisc_set,
14149 (void *)&cmd_vf_promisc_vf,
14150 (void *)&cmd_vf_promisc_promisc,
14151 (void *)&cmd_vf_promisc_port_id,
14152 (void *)&cmd_vf_promisc_vf_id,
14153 (void *)&cmd_vf_promisc_on_off,
14158 /* VF multicast promiscuous mode configuration */
14160 /* Common result structure for VF multicast promiscuous mode */
14161 struct cmd_vf_allmulti_result {
14162 cmdline_fixed_string_t set;
14163 cmdline_fixed_string_t vf;
14164 cmdline_fixed_string_t allmulti;
14167 cmdline_fixed_string_t on_off;
14170 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14171 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14172 TOKEN_STRING_INITIALIZER
14173 (struct cmd_vf_allmulti_result,
14175 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14176 TOKEN_STRING_INITIALIZER
14177 (struct cmd_vf_allmulti_result,
14179 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14180 TOKEN_STRING_INITIALIZER
14181 (struct cmd_vf_allmulti_result,
14182 allmulti, "allmulti");
14183 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14184 TOKEN_NUM_INITIALIZER
14185 (struct cmd_vf_allmulti_result,
14187 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14188 TOKEN_NUM_INITIALIZER
14189 (struct cmd_vf_allmulti_result,
14191 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14192 TOKEN_STRING_INITIALIZER
14193 (struct cmd_vf_allmulti_result,
14197 cmd_set_vf_allmulti_parsed(
14198 void *parsed_result,
14199 __attribute__((unused)) struct cmdline *cl,
14200 __attribute__((unused)) void *data)
14202 struct cmd_vf_allmulti_result *res = parsed_result;
14203 int ret = -ENOTSUP;
14205 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14207 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14210 #ifdef RTE_LIBRTE_I40E_PMD
14211 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14212 res->vf_id, is_on);
14219 printf("invalid vf_id %d\n", res->vf_id);
14222 printf("invalid port_id %d\n", res->port_id);
14225 printf("function not implemented\n");
14228 printf("programming error: (%s)\n", strerror(-ret));
14232 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14233 .f = cmd_set_vf_allmulti_parsed,
14235 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14236 "Set multicast promiscuous mode for a VF from the PF",
14238 (void *)&cmd_vf_allmulti_set,
14239 (void *)&cmd_vf_allmulti_vf,
14240 (void *)&cmd_vf_allmulti_allmulti,
14241 (void *)&cmd_vf_allmulti_port_id,
14242 (void *)&cmd_vf_allmulti_vf_id,
14243 (void *)&cmd_vf_allmulti_on_off,
14248 /* vf broadcast mode configuration */
14250 /* Common result structure for vf broadcast */
14251 struct cmd_set_vf_broadcast_result {
14252 cmdline_fixed_string_t set;
14253 cmdline_fixed_string_t vf;
14254 cmdline_fixed_string_t broadcast;
14257 cmdline_fixed_string_t on_off;
14260 /* Common CLI fields for vf broadcast enable disable */
14261 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14262 TOKEN_STRING_INITIALIZER
14263 (struct cmd_set_vf_broadcast_result,
14265 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14266 TOKEN_STRING_INITIALIZER
14267 (struct cmd_set_vf_broadcast_result,
14269 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14270 TOKEN_STRING_INITIALIZER
14271 (struct cmd_set_vf_broadcast_result,
14272 broadcast, "broadcast");
14273 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14274 TOKEN_NUM_INITIALIZER
14275 (struct cmd_set_vf_broadcast_result,
14277 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14278 TOKEN_NUM_INITIALIZER
14279 (struct cmd_set_vf_broadcast_result,
14281 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14282 TOKEN_STRING_INITIALIZER
14283 (struct cmd_set_vf_broadcast_result,
14287 cmd_set_vf_broadcast_parsed(
14288 void *parsed_result,
14289 __attribute__((unused)) struct cmdline *cl,
14290 __attribute__((unused)) void *data)
14292 struct cmd_set_vf_broadcast_result *res = parsed_result;
14293 int ret = -ENOTSUP;
14295 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14297 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14300 #ifdef RTE_LIBRTE_I40E_PMD
14301 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14302 res->vf_id, is_on);
14309 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14312 printf("invalid port_id %d\n", res->port_id);
14315 printf("function not implemented\n");
14318 printf("programming error: (%s)\n", strerror(-ret));
14322 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14323 .f = cmd_set_vf_broadcast_parsed,
14325 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14327 (void *)&cmd_set_vf_broadcast_set,
14328 (void *)&cmd_set_vf_broadcast_vf,
14329 (void *)&cmd_set_vf_broadcast_broadcast,
14330 (void *)&cmd_set_vf_broadcast_port_id,
14331 (void *)&cmd_set_vf_broadcast_vf_id,
14332 (void *)&cmd_set_vf_broadcast_on_off,
14337 /* vf vlan tag configuration */
14339 /* Common result structure for vf vlan tag */
14340 struct cmd_set_vf_vlan_tag_result {
14341 cmdline_fixed_string_t set;
14342 cmdline_fixed_string_t vf;
14343 cmdline_fixed_string_t vlan;
14344 cmdline_fixed_string_t tag;
14347 cmdline_fixed_string_t on_off;
14350 /* Common CLI fields for vf vlan tag enable disable */
14351 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14352 TOKEN_STRING_INITIALIZER
14353 (struct cmd_set_vf_vlan_tag_result,
14355 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14356 TOKEN_STRING_INITIALIZER
14357 (struct cmd_set_vf_vlan_tag_result,
14359 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14360 TOKEN_STRING_INITIALIZER
14361 (struct cmd_set_vf_vlan_tag_result,
14363 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14364 TOKEN_STRING_INITIALIZER
14365 (struct cmd_set_vf_vlan_tag_result,
14367 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14368 TOKEN_NUM_INITIALIZER
14369 (struct cmd_set_vf_vlan_tag_result,
14371 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14372 TOKEN_NUM_INITIALIZER
14373 (struct cmd_set_vf_vlan_tag_result,
14375 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14376 TOKEN_STRING_INITIALIZER
14377 (struct cmd_set_vf_vlan_tag_result,
14381 cmd_set_vf_vlan_tag_parsed(
14382 void *parsed_result,
14383 __attribute__((unused)) struct cmdline *cl,
14384 __attribute__((unused)) void *data)
14386 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14387 int ret = -ENOTSUP;
14389 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14391 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14394 #ifdef RTE_LIBRTE_I40E_PMD
14395 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14396 res->vf_id, is_on);
14403 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14406 printf("invalid port_id %d\n", res->port_id);
14409 printf("function not implemented\n");
14412 printf("programming error: (%s)\n", strerror(-ret));
14416 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14417 .f = cmd_set_vf_vlan_tag_parsed,
14419 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14421 (void *)&cmd_set_vf_vlan_tag_set,
14422 (void *)&cmd_set_vf_vlan_tag_vf,
14423 (void *)&cmd_set_vf_vlan_tag_vlan,
14424 (void *)&cmd_set_vf_vlan_tag_tag,
14425 (void *)&cmd_set_vf_vlan_tag_port_id,
14426 (void *)&cmd_set_vf_vlan_tag_vf_id,
14427 (void *)&cmd_set_vf_vlan_tag_on_off,
14432 /* Common definition of VF and TC TX bandwidth configuration */
14433 struct cmd_vf_tc_bw_result {
14434 cmdline_fixed_string_t set;
14435 cmdline_fixed_string_t vf;
14436 cmdline_fixed_string_t tc;
14437 cmdline_fixed_string_t tx;
14438 cmdline_fixed_string_t min_bw;
14439 cmdline_fixed_string_t max_bw;
14440 cmdline_fixed_string_t strict_link_prio;
14445 cmdline_fixed_string_t bw_list;
14449 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14450 TOKEN_STRING_INITIALIZER
14451 (struct cmd_vf_tc_bw_result,
14453 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14454 TOKEN_STRING_INITIALIZER
14455 (struct cmd_vf_tc_bw_result,
14457 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14458 TOKEN_STRING_INITIALIZER
14459 (struct cmd_vf_tc_bw_result,
14461 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14462 TOKEN_STRING_INITIALIZER
14463 (struct cmd_vf_tc_bw_result,
14465 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14466 TOKEN_STRING_INITIALIZER
14467 (struct cmd_vf_tc_bw_result,
14468 strict_link_prio, "strict-link-priority");
14469 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14470 TOKEN_STRING_INITIALIZER
14471 (struct cmd_vf_tc_bw_result,
14472 min_bw, "min-bandwidth");
14473 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14474 TOKEN_STRING_INITIALIZER
14475 (struct cmd_vf_tc_bw_result,
14476 max_bw, "max-bandwidth");
14477 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14478 TOKEN_NUM_INITIALIZER
14479 (struct cmd_vf_tc_bw_result,
14481 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14482 TOKEN_NUM_INITIALIZER
14483 (struct cmd_vf_tc_bw_result,
14485 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14486 TOKEN_NUM_INITIALIZER
14487 (struct cmd_vf_tc_bw_result,
14489 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14490 TOKEN_NUM_INITIALIZER
14491 (struct cmd_vf_tc_bw_result,
14493 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14494 TOKEN_STRING_INITIALIZER
14495 (struct cmd_vf_tc_bw_result,
14497 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14498 TOKEN_NUM_INITIALIZER
14499 (struct cmd_vf_tc_bw_result,
14502 /* VF max bandwidth setting */
14504 cmd_vf_max_bw_parsed(
14505 void *parsed_result,
14506 __attribute__((unused)) struct cmdline *cl,
14507 __attribute__((unused)) void *data)
14509 struct cmd_vf_tc_bw_result *res = parsed_result;
14510 int ret = -ENOTSUP;
14512 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14515 #ifdef RTE_LIBRTE_I40E_PMD
14516 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14517 res->vf_id, res->bw);
14524 printf("invalid vf_id %d or bandwidth %d\n",
14525 res->vf_id, res->bw);
14528 printf("invalid port_id %d\n", res->port_id);
14531 printf("function not implemented\n");
14534 printf("programming error: (%s)\n", strerror(-ret));
14538 cmdline_parse_inst_t cmd_vf_max_bw = {
14539 .f = cmd_vf_max_bw_parsed,
14541 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14543 (void *)&cmd_vf_tc_bw_set,
14544 (void *)&cmd_vf_tc_bw_vf,
14545 (void *)&cmd_vf_tc_bw_tx,
14546 (void *)&cmd_vf_tc_bw_max_bw,
14547 (void *)&cmd_vf_tc_bw_port_id,
14548 (void *)&cmd_vf_tc_bw_vf_id,
14549 (void *)&cmd_vf_tc_bw_bw,
14555 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14560 const char *p, *p0 = str;
14567 p = strchr(p0, '(');
14569 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14573 p0 = strchr(p, ')');
14575 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14579 if (size >= sizeof(s)) {
14580 printf("The string size exceeds the internal buffer size\n");
14583 snprintf(s, sizeof(s), "%.*s", size, p);
14584 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14586 printf("Failed to get the bandwidth list. ");
14590 for (i = 0; i < ret; i++)
14591 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14596 /* TC min bandwidth setting */
14598 cmd_vf_tc_min_bw_parsed(
14599 void *parsed_result,
14600 __attribute__((unused)) struct cmdline *cl,
14601 __attribute__((unused)) void *data)
14603 struct cmd_vf_tc_bw_result *res = parsed_result;
14606 int ret = -ENOTSUP;
14608 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14611 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14615 #ifdef RTE_LIBRTE_I40E_PMD
14616 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14624 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14627 printf("invalid port_id %d\n", res->port_id);
14630 printf("function not implemented\n");
14633 printf("programming error: (%s)\n", strerror(-ret));
14637 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14638 .f = cmd_vf_tc_min_bw_parsed,
14640 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14641 " <bw1, bw2, ...>",
14643 (void *)&cmd_vf_tc_bw_set,
14644 (void *)&cmd_vf_tc_bw_vf,
14645 (void *)&cmd_vf_tc_bw_tc,
14646 (void *)&cmd_vf_tc_bw_tx,
14647 (void *)&cmd_vf_tc_bw_min_bw,
14648 (void *)&cmd_vf_tc_bw_port_id,
14649 (void *)&cmd_vf_tc_bw_vf_id,
14650 (void *)&cmd_vf_tc_bw_bw_list,
14656 cmd_tc_min_bw_parsed(
14657 void *parsed_result,
14658 __attribute__((unused)) struct cmdline *cl,
14659 __attribute__((unused)) void *data)
14661 struct cmd_vf_tc_bw_result *res = parsed_result;
14662 struct rte_port *port;
14665 int ret = -ENOTSUP;
14667 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14670 port = &ports[res->port_id];
14671 /** Check if the port is not started **/
14672 if (port->port_status != RTE_PORT_STOPPED) {
14673 printf("Please stop port %d first\n", res->port_id);
14677 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14681 #ifdef RTE_LIBRTE_IXGBE_PMD
14682 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14689 printf("invalid bandwidth\n");
14692 printf("invalid port_id %d\n", res->port_id);
14695 printf("function not implemented\n");
14698 printf("programming error: (%s)\n", strerror(-ret));
14702 cmdline_parse_inst_t cmd_tc_min_bw = {
14703 .f = cmd_tc_min_bw_parsed,
14705 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14707 (void *)&cmd_vf_tc_bw_set,
14708 (void *)&cmd_vf_tc_bw_tc,
14709 (void *)&cmd_vf_tc_bw_tx,
14710 (void *)&cmd_vf_tc_bw_min_bw,
14711 (void *)&cmd_vf_tc_bw_port_id,
14712 (void *)&cmd_vf_tc_bw_bw_list,
14717 /* TC max bandwidth setting */
14719 cmd_vf_tc_max_bw_parsed(
14720 void *parsed_result,
14721 __attribute__((unused)) struct cmdline *cl,
14722 __attribute__((unused)) void *data)
14724 struct cmd_vf_tc_bw_result *res = parsed_result;
14725 int ret = -ENOTSUP;
14727 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14730 #ifdef RTE_LIBRTE_I40E_PMD
14731 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14732 res->tc_no, res->bw);
14739 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14740 res->vf_id, res->tc_no, res->bw);
14743 printf("invalid port_id %d\n", res->port_id);
14746 printf("function not implemented\n");
14749 printf("programming error: (%s)\n", strerror(-ret));
14753 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14754 .f = cmd_vf_tc_max_bw_parsed,
14756 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14759 (void *)&cmd_vf_tc_bw_set,
14760 (void *)&cmd_vf_tc_bw_vf,
14761 (void *)&cmd_vf_tc_bw_tc,
14762 (void *)&cmd_vf_tc_bw_tx,
14763 (void *)&cmd_vf_tc_bw_max_bw,
14764 (void *)&cmd_vf_tc_bw_port_id,
14765 (void *)&cmd_vf_tc_bw_vf_id,
14766 (void *)&cmd_vf_tc_bw_tc_no,
14767 (void *)&cmd_vf_tc_bw_bw,
14773 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14775 /* *** Set Port default Traffic Management Hierarchy *** */
14776 struct cmd_set_port_tm_hierarchy_default_result {
14777 cmdline_fixed_string_t set;
14778 cmdline_fixed_string_t port;
14779 cmdline_fixed_string_t tm;
14780 cmdline_fixed_string_t hierarchy;
14781 cmdline_fixed_string_t def;
14785 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14786 TOKEN_STRING_INITIALIZER(
14787 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14788 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14789 TOKEN_STRING_INITIALIZER(
14790 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14791 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14792 TOKEN_STRING_INITIALIZER(
14793 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14794 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14795 TOKEN_STRING_INITIALIZER(
14796 struct cmd_set_port_tm_hierarchy_default_result,
14797 hierarchy, "hierarchy");
14798 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14799 TOKEN_STRING_INITIALIZER(
14800 struct cmd_set_port_tm_hierarchy_default_result,
14802 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14803 TOKEN_NUM_INITIALIZER(
14804 struct cmd_set_port_tm_hierarchy_default_result,
14807 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14808 __attribute__((unused)) struct cmdline *cl,
14809 __attribute__((unused)) void *data)
14811 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14812 struct rte_port *p;
14813 portid_t port_id = res->port_id;
14815 if (port_id_is_invalid(port_id, ENABLED_WARN))
14818 p = &ports[port_id];
14821 if (p->softport.tm_flag == 0) {
14822 printf(" tm not enabled on port %u (error)\n", port_id);
14826 /* Forward mode: tm */
14827 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14828 printf(" tm mode not enabled(error)\n");
14832 /* Set the default tm hierarchy */
14833 p->softport.tm.default_hierarchy_enable = 1;
14836 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14837 .f = cmd_set_port_tm_hierarchy_default_parsed,
14839 .help_str = "set port tm hierarchy default <port_id>",
14841 (void *)&cmd_set_port_tm_hierarchy_default_set,
14842 (void *)&cmd_set_port_tm_hierarchy_default_port,
14843 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14844 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14845 (void *)&cmd_set_port_tm_hierarchy_default_default,
14846 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14852 /* Strict link priority scheduling mode setting */
14854 cmd_strict_link_prio_parsed(
14855 void *parsed_result,
14856 __attribute__((unused)) struct cmdline *cl,
14857 __attribute__((unused)) void *data)
14859 struct cmd_vf_tc_bw_result *res = parsed_result;
14860 int ret = -ENOTSUP;
14862 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14865 #ifdef RTE_LIBRTE_I40E_PMD
14866 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14873 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14876 printf("invalid port_id %d\n", res->port_id);
14879 printf("function not implemented\n");
14882 printf("programming error: (%s)\n", strerror(-ret));
14886 cmdline_parse_inst_t cmd_strict_link_prio = {
14887 .f = cmd_strict_link_prio_parsed,
14889 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14891 (void *)&cmd_vf_tc_bw_set,
14892 (void *)&cmd_vf_tc_bw_tx,
14893 (void *)&cmd_vf_tc_bw_strict_link_prio,
14894 (void *)&cmd_vf_tc_bw_port_id,
14895 (void *)&cmd_vf_tc_bw_tc_map,
14900 /* Load dynamic device personalization*/
14901 struct cmd_ddp_add_result {
14902 cmdline_fixed_string_t ddp;
14903 cmdline_fixed_string_t add;
14908 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14909 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14910 cmdline_parse_token_string_t cmd_ddp_add_add =
14911 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14912 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14913 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14914 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14915 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14918 cmd_ddp_add_parsed(
14919 void *parsed_result,
14920 __attribute__((unused)) struct cmdline *cl,
14921 __attribute__((unused)) void *data)
14923 struct cmd_ddp_add_result *res = parsed_result;
14929 int ret = -ENOTSUP;
14931 if (!all_ports_stopped()) {
14932 printf("Please stop all ports first\n");
14936 filepath = strdup(res->filepath);
14937 if (filepath == NULL) {
14938 printf("Failed to allocate memory\n");
14941 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14943 buff = open_file(file_fld[0], &size);
14945 free((void *)filepath);
14949 #ifdef RTE_LIBRTE_I40E_PMD
14950 if (ret == -ENOTSUP)
14951 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14953 RTE_PMD_I40E_PKG_OP_WR_ADD);
14956 if (ret == -EEXIST)
14957 printf("Profile has already existed.\n");
14959 printf("Failed to load profile.\n");
14960 else if (file_num == 2)
14961 save_file(file_fld[1], buff, size);
14964 free((void *)filepath);
14967 cmdline_parse_inst_t cmd_ddp_add = {
14968 .f = cmd_ddp_add_parsed,
14970 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14972 (void *)&cmd_ddp_add_ddp,
14973 (void *)&cmd_ddp_add_add,
14974 (void *)&cmd_ddp_add_port_id,
14975 (void *)&cmd_ddp_add_filepath,
14980 /* Delete dynamic device personalization*/
14981 struct cmd_ddp_del_result {
14982 cmdline_fixed_string_t ddp;
14983 cmdline_fixed_string_t del;
14988 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14989 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14990 cmdline_parse_token_string_t cmd_ddp_del_del =
14991 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14992 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14993 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14994 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14995 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14998 cmd_ddp_del_parsed(
14999 void *parsed_result,
15000 __attribute__((unused)) struct cmdline *cl,
15001 __attribute__((unused)) void *data)
15003 struct cmd_ddp_del_result *res = parsed_result;
15006 int ret = -ENOTSUP;
15008 if (!all_ports_stopped()) {
15009 printf("Please stop all ports first\n");
15013 buff = open_file(res->filepath, &size);
15017 #ifdef RTE_LIBRTE_I40E_PMD
15018 if (ret == -ENOTSUP)
15019 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15021 RTE_PMD_I40E_PKG_OP_WR_DEL);
15024 if (ret == -EACCES)
15025 printf("Profile does not exist.\n");
15027 printf("Failed to delete profile.\n");
15032 cmdline_parse_inst_t cmd_ddp_del = {
15033 .f = cmd_ddp_del_parsed,
15035 .help_str = "ddp del <port_id> <backup_profile_path>",
15037 (void *)&cmd_ddp_del_ddp,
15038 (void *)&cmd_ddp_del_del,
15039 (void *)&cmd_ddp_del_port_id,
15040 (void *)&cmd_ddp_del_filepath,
15045 /* Get dynamic device personalization profile info */
15046 struct cmd_ddp_info_result {
15047 cmdline_fixed_string_t ddp;
15048 cmdline_fixed_string_t get;
15049 cmdline_fixed_string_t info;
15053 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15054 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15055 cmdline_parse_token_string_t cmd_ddp_info_get =
15056 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15057 cmdline_parse_token_string_t cmd_ddp_info_info =
15058 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15059 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15060 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15063 cmd_ddp_info_parsed(
15064 void *parsed_result,
15065 __attribute__((unused)) struct cmdline *cl,
15066 __attribute__((unused)) void *data)
15068 struct cmd_ddp_info_result *res = parsed_result;
15071 int ret = -ENOTSUP;
15072 #ifdef RTE_LIBRTE_I40E_PMD
15075 uint32_t buff_size = 0;
15076 struct rte_pmd_i40e_profile_info info;
15077 uint32_t dev_num = 0;
15078 struct rte_pmd_i40e_ddp_device_id *devs;
15079 uint32_t proto_num = 0;
15080 struct rte_pmd_i40e_proto_info *proto = NULL;
15081 uint32_t pctype_num = 0;
15082 struct rte_pmd_i40e_ptype_info *pctype;
15083 uint32_t ptype_num = 0;
15084 struct rte_pmd_i40e_ptype_info *ptype;
15089 pkg = open_file(res->filepath, &pkg_size);
15093 #ifdef RTE_LIBRTE_I40E_PMD
15094 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15095 (uint8_t *)&info, sizeof(info),
15096 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15098 printf("Global Track id: 0x%x\n", info.track_id);
15099 printf("Global Version: %d.%d.%d.%d\n",
15100 info.version.major,
15101 info.version.minor,
15102 info.version.update,
15103 info.version.draft);
15104 printf("Global Package name: %s\n\n", info.name);
15107 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15108 (uint8_t *)&info, sizeof(info),
15109 RTE_PMD_I40E_PKG_INFO_HEADER);
15111 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15112 printf("i40e Profile Version: %d.%d.%d.%d\n",
15113 info.version.major,
15114 info.version.minor,
15115 info.version.update,
15116 info.version.draft);
15117 printf("i40e Profile name: %s\n\n", info.name);
15120 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15121 (uint8_t *)&buff_size, sizeof(buff_size),
15122 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15123 if (!ret && buff_size) {
15124 buff = (uint8_t *)malloc(buff_size);
15126 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15128 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15130 printf("Package Notes:\n%s\n\n", buff);
15135 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15136 (uint8_t *)&dev_num, sizeof(dev_num),
15137 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15138 if (!ret && dev_num) {
15139 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15140 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15142 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15143 (uint8_t *)devs, buff_size,
15144 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15146 printf("List of supported devices:\n");
15147 for (i = 0; i < dev_num; i++) {
15148 printf(" %04X:%04X %04X:%04X\n",
15149 devs[i].vendor_dev_id >> 16,
15150 devs[i].vendor_dev_id & 0xFFFF,
15151 devs[i].sub_vendor_dev_id >> 16,
15152 devs[i].sub_vendor_dev_id & 0xFFFF);
15160 /* get information about protocols and packet types */
15161 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15162 (uint8_t *)&proto_num, sizeof(proto_num),
15163 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15164 if (ret || !proto_num)
15165 goto no_print_return;
15167 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15168 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15170 goto no_print_return;
15172 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15174 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15176 printf("List of used protocols:\n");
15177 for (i = 0; i < proto_num; i++)
15178 printf(" %2u: %s\n", proto[i].proto_id,
15182 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15183 (uint8_t *)&pctype_num, sizeof(pctype_num),
15184 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15185 if (ret || !pctype_num)
15186 goto no_print_pctypes;
15188 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15189 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15191 goto no_print_pctypes;
15193 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15195 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15198 goto no_print_pctypes;
15201 printf("List of defined packet classification types:\n");
15202 for (i = 0; i < pctype_num; i++) {
15203 printf(" %2u:", pctype[i].ptype_id);
15204 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15205 proto_id = pctype[i].protocols[j];
15206 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15207 for (n = 0; n < proto_num; n++) {
15208 if (proto[n].proto_id == proto_id) {
15209 printf(" %s", proto[n].name);
15222 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15224 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15225 if (ret || !ptype_num)
15226 goto no_print_return;
15228 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15229 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15231 goto no_print_return;
15233 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15235 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15238 goto no_print_return;
15240 printf("List of defined packet types:\n");
15241 for (i = 0; i < ptype_num; i++) {
15242 printf(" %2u:", ptype[i].ptype_id);
15243 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15244 proto_id = ptype[i].protocols[j];
15245 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15246 for (n = 0; n < proto_num; n++) {
15247 if (proto[n].proto_id == proto_id) {
15248 printf(" %s", proto[n].name);
15264 if (ret == -ENOTSUP)
15265 printf("Function not supported in PMD driver\n");
15269 cmdline_parse_inst_t cmd_ddp_get_info = {
15270 .f = cmd_ddp_info_parsed,
15272 .help_str = "ddp get info <profile_path>",
15274 (void *)&cmd_ddp_info_ddp,
15275 (void *)&cmd_ddp_info_get,
15276 (void *)&cmd_ddp_info_info,
15277 (void *)&cmd_ddp_info_filepath,
15282 /* Get dynamic device personalization profile info list*/
15283 #define PROFILE_INFO_SIZE 48
15284 #define MAX_PROFILE_NUM 16
15286 struct cmd_ddp_get_list_result {
15287 cmdline_fixed_string_t ddp;
15288 cmdline_fixed_string_t get;
15289 cmdline_fixed_string_t list;
15293 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15294 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15295 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15296 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15297 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15298 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15299 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15300 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15303 cmd_ddp_get_list_parsed(
15304 __attribute__((unused)) void *parsed_result,
15305 __attribute__((unused)) struct cmdline *cl,
15306 __attribute__((unused)) void *data)
15308 #ifdef RTE_LIBRTE_I40E_PMD
15309 struct cmd_ddp_get_list_result *res = parsed_result;
15310 struct rte_pmd_i40e_profile_list *p_list;
15311 struct rte_pmd_i40e_profile_info *p_info;
15316 int ret = -ENOTSUP;
15318 #ifdef RTE_LIBRTE_I40E_PMD
15319 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15320 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15322 printf("%s: Failed to malloc buffer\n", __func__);
15324 if (ret == -ENOTSUP)
15325 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15326 (uint8_t *)p_list, size);
15329 p_num = p_list->p_count;
15330 printf("Profile number is: %d\n\n", p_num);
15332 for (i = 0; i < p_num; i++) {
15333 p_info = &p_list->p_info[i];
15334 printf("Profile %d:\n", i);
15335 printf("Track id: 0x%x\n", p_info->track_id);
15336 printf("Version: %d.%d.%d.%d\n",
15337 p_info->version.major,
15338 p_info->version.minor,
15339 p_info->version.update,
15340 p_info->version.draft);
15341 printf("Profile name: %s\n\n", p_info->name);
15349 printf("Failed to get ddp list\n");
15352 cmdline_parse_inst_t cmd_ddp_get_list = {
15353 .f = cmd_ddp_get_list_parsed,
15355 .help_str = "ddp get list <port_id>",
15357 (void *)&cmd_ddp_get_list_ddp,
15358 (void *)&cmd_ddp_get_list_get,
15359 (void *)&cmd_ddp_get_list_list,
15360 (void *)&cmd_ddp_get_list_port_id,
15365 /* Configure input set */
15366 struct cmd_cfg_input_set_result {
15367 cmdline_fixed_string_t port;
15368 cmdline_fixed_string_t cfg;
15370 cmdline_fixed_string_t pctype;
15372 cmdline_fixed_string_t inset_type;
15373 cmdline_fixed_string_t opt;
15374 cmdline_fixed_string_t field;
15379 cmd_cfg_input_set_parsed(
15380 __attribute__((unused)) void *parsed_result,
15381 __attribute__((unused)) struct cmdline *cl,
15382 __attribute__((unused)) void *data)
15384 #ifdef RTE_LIBRTE_I40E_PMD
15385 struct cmd_cfg_input_set_result *res = parsed_result;
15386 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15387 struct rte_pmd_i40e_inset inset;
15389 int ret = -ENOTSUP;
15391 if (!all_ports_stopped()) {
15392 printf("Please stop all ports first\n");
15396 #ifdef RTE_LIBRTE_I40E_PMD
15397 if (!strcmp(res->inset_type, "hash_inset"))
15398 inset_type = INSET_HASH;
15399 else if (!strcmp(res->inset_type, "fdir_inset"))
15400 inset_type = INSET_FDIR;
15401 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15402 inset_type = INSET_FDIR_FLX;
15403 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15404 &inset, inset_type);
15406 printf("Failed to get input set.\n");
15410 if (!strcmp(res->opt, "get")) {
15411 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15414 printf("Field index %d is enabled.\n", res->field_idx);
15416 printf("Field index %d is disabled.\n", res->field_idx);
15418 } else if (!strcmp(res->opt, "set"))
15419 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15421 else if (!strcmp(res->opt, "clear"))
15422 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15425 printf("Failed to configure input set field.\n");
15429 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15430 &inset, inset_type);
15432 printf("Failed to set input set.\n");
15437 if (ret == -ENOTSUP)
15438 printf("Function not supported\n");
15441 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15442 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15444 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15445 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15447 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15448 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15450 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15451 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15453 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15454 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15456 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15457 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15459 "hash_inset#fdir_inset#fdir_flx_inset");
15460 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15461 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15462 opt, "get#set#clear");
15463 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15464 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15466 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15467 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15470 cmdline_parse_inst_t cmd_cfg_input_set = {
15471 .f = cmd_cfg_input_set_parsed,
15473 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15474 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15476 (void *)&cmd_cfg_input_set_port,
15477 (void *)&cmd_cfg_input_set_cfg,
15478 (void *)&cmd_cfg_input_set_port_id,
15479 (void *)&cmd_cfg_input_set_pctype,
15480 (void *)&cmd_cfg_input_set_pctype_id,
15481 (void *)&cmd_cfg_input_set_inset_type,
15482 (void *)&cmd_cfg_input_set_opt,
15483 (void *)&cmd_cfg_input_set_field,
15484 (void *)&cmd_cfg_input_set_field_idx,
15489 /* Clear input set */
15490 struct cmd_clear_input_set_result {
15491 cmdline_fixed_string_t port;
15492 cmdline_fixed_string_t cfg;
15494 cmdline_fixed_string_t pctype;
15496 cmdline_fixed_string_t inset_type;
15497 cmdline_fixed_string_t clear;
15498 cmdline_fixed_string_t all;
15502 cmd_clear_input_set_parsed(
15503 __attribute__((unused)) void *parsed_result,
15504 __attribute__((unused)) struct cmdline *cl,
15505 __attribute__((unused)) void *data)
15507 #ifdef RTE_LIBRTE_I40E_PMD
15508 struct cmd_clear_input_set_result *res = parsed_result;
15509 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15510 struct rte_pmd_i40e_inset inset;
15512 int ret = -ENOTSUP;
15514 if (!all_ports_stopped()) {
15515 printf("Please stop all ports first\n");
15519 #ifdef RTE_LIBRTE_I40E_PMD
15520 if (!strcmp(res->inset_type, "hash_inset"))
15521 inset_type = INSET_HASH;
15522 else if (!strcmp(res->inset_type, "fdir_inset"))
15523 inset_type = INSET_FDIR;
15524 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15525 inset_type = INSET_FDIR_FLX;
15527 memset(&inset, 0, sizeof(inset));
15529 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15530 &inset, inset_type);
15532 printf("Failed to clear input set.\n");
15538 if (ret == -ENOTSUP)
15539 printf("Function not supported\n");
15542 cmdline_parse_token_string_t cmd_clear_input_set_port =
15543 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15545 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15546 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15548 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15549 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15551 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15552 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15554 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15555 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15557 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15558 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15560 "hash_inset#fdir_inset#fdir_flx_inset");
15561 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15562 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15564 cmdline_parse_token_string_t cmd_clear_input_set_all =
15565 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15568 cmdline_parse_inst_t cmd_clear_input_set = {
15569 .f = cmd_clear_input_set_parsed,
15571 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15572 "fdir_inset|fdir_flx_inset clear all",
15574 (void *)&cmd_clear_input_set_port,
15575 (void *)&cmd_clear_input_set_cfg,
15576 (void *)&cmd_clear_input_set_port_id,
15577 (void *)&cmd_clear_input_set_pctype,
15578 (void *)&cmd_clear_input_set_pctype_id,
15579 (void *)&cmd_clear_input_set_inset_type,
15580 (void *)&cmd_clear_input_set_clear,
15581 (void *)&cmd_clear_input_set_all,
15586 /* show vf stats */
15588 /* Common result structure for show vf stats */
15589 struct cmd_show_vf_stats_result {
15590 cmdline_fixed_string_t show;
15591 cmdline_fixed_string_t vf;
15592 cmdline_fixed_string_t stats;
15597 /* Common CLI fields show vf stats*/
15598 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15599 TOKEN_STRING_INITIALIZER
15600 (struct cmd_show_vf_stats_result,
15602 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15603 TOKEN_STRING_INITIALIZER
15604 (struct cmd_show_vf_stats_result,
15606 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15607 TOKEN_STRING_INITIALIZER
15608 (struct cmd_show_vf_stats_result,
15610 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15611 TOKEN_NUM_INITIALIZER
15612 (struct cmd_show_vf_stats_result,
15614 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15615 TOKEN_NUM_INITIALIZER
15616 (struct cmd_show_vf_stats_result,
15620 cmd_show_vf_stats_parsed(
15621 void *parsed_result,
15622 __attribute__((unused)) struct cmdline *cl,
15623 __attribute__((unused)) void *data)
15625 struct cmd_show_vf_stats_result *res = parsed_result;
15626 struct rte_eth_stats stats;
15627 int ret = -ENOTSUP;
15628 static const char *nic_stats_border = "########################";
15630 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15633 memset(&stats, 0, sizeof(stats));
15635 #ifdef RTE_LIBRTE_I40E_PMD
15636 if (ret == -ENOTSUP)
15637 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15641 #ifdef RTE_LIBRTE_BNXT_PMD
15642 if (ret == -ENOTSUP)
15643 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15652 printf("invalid vf_id %d\n", res->vf_id);
15655 printf("invalid port_id %d\n", res->port_id);
15658 printf("function not implemented\n");
15661 printf("programming error: (%s)\n", strerror(-ret));
15664 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15665 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15667 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15669 stats.ipackets, stats.imissed, stats.ibytes);
15670 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15671 printf(" RX-nombuf: %-10"PRIu64"\n",
15673 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15675 stats.opackets, stats.oerrors, stats.obytes);
15677 printf(" %s############################%s\n",
15678 nic_stats_border, nic_stats_border);
15681 cmdline_parse_inst_t cmd_show_vf_stats = {
15682 .f = cmd_show_vf_stats_parsed,
15684 .help_str = "show vf stats <port_id> <vf_id>",
15686 (void *)&cmd_show_vf_stats_show,
15687 (void *)&cmd_show_vf_stats_vf,
15688 (void *)&cmd_show_vf_stats_stats,
15689 (void *)&cmd_show_vf_stats_port_id,
15690 (void *)&cmd_show_vf_stats_vf_id,
15695 /* clear vf stats */
15697 /* Common result structure for clear vf stats */
15698 struct cmd_clear_vf_stats_result {
15699 cmdline_fixed_string_t clear;
15700 cmdline_fixed_string_t vf;
15701 cmdline_fixed_string_t stats;
15706 /* Common CLI fields clear vf stats*/
15707 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15708 TOKEN_STRING_INITIALIZER
15709 (struct cmd_clear_vf_stats_result,
15711 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15712 TOKEN_STRING_INITIALIZER
15713 (struct cmd_clear_vf_stats_result,
15715 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15716 TOKEN_STRING_INITIALIZER
15717 (struct cmd_clear_vf_stats_result,
15719 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15720 TOKEN_NUM_INITIALIZER
15721 (struct cmd_clear_vf_stats_result,
15723 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15724 TOKEN_NUM_INITIALIZER
15725 (struct cmd_clear_vf_stats_result,
15729 cmd_clear_vf_stats_parsed(
15730 void *parsed_result,
15731 __attribute__((unused)) struct cmdline *cl,
15732 __attribute__((unused)) void *data)
15734 struct cmd_clear_vf_stats_result *res = parsed_result;
15735 int ret = -ENOTSUP;
15737 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15740 #ifdef RTE_LIBRTE_I40E_PMD
15741 if (ret == -ENOTSUP)
15742 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15745 #ifdef RTE_LIBRTE_BNXT_PMD
15746 if (ret == -ENOTSUP)
15747 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15755 printf("invalid vf_id %d\n", res->vf_id);
15758 printf("invalid port_id %d\n", res->port_id);
15761 printf("function not implemented\n");
15764 printf("programming error: (%s)\n", strerror(-ret));
15768 cmdline_parse_inst_t cmd_clear_vf_stats = {
15769 .f = cmd_clear_vf_stats_parsed,
15771 .help_str = "clear vf stats <port_id> <vf_id>",
15773 (void *)&cmd_clear_vf_stats_clear,
15774 (void *)&cmd_clear_vf_stats_vf,
15775 (void *)&cmd_clear_vf_stats_stats,
15776 (void *)&cmd_clear_vf_stats_port_id,
15777 (void *)&cmd_clear_vf_stats_vf_id,
15782 /* port config pctype mapping reset */
15784 /* Common result structure for port config pctype mapping reset */
15785 struct cmd_pctype_mapping_reset_result {
15786 cmdline_fixed_string_t port;
15787 cmdline_fixed_string_t config;
15789 cmdline_fixed_string_t pctype;
15790 cmdline_fixed_string_t mapping;
15791 cmdline_fixed_string_t reset;
15794 /* Common CLI fields for port config pctype mapping reset*/
15795 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15796 TOKEN_STRING_INITIALIZER
15797 (struct cmd_pctype_mapping_reset_result,
15799 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15800 TOKEN_STRING_INITIALIZER
15801 (struct cmd_pctype_mapping_reset_result,
15803 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15804 TOKEN_NUM_INITIALIZER
15805 (struct cmd_pctype_mapping_reset_result,
15807 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15808 TOKEN_STRING_INITIALIZER
15809 (struct cmd_pctype_mapping_reset_result,
15811 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15812 TOKEN_STRING_INITIALIZER
15813 (struct cmd_pctype_mapping_reset_result,
15814 mapping, "mapping");
15815 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15816 TOKEN_STRING_INITIALIZER
15817 (struct cmd_pctype_mapping_reset_result,
15821 cmd_pctype_mapping_reset_parsed(
15822 void *parsed_result,
15823 __attribute__((unused)) struct cmdline *cl,
15824 __attribute__((unused)) void *data)
15826 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15827 int ret = -ENOTSUP;
15829 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15832 #ifdef RTE_LIBRTE_I40E_PMD
15833 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15840 printf("invalid port_id %d\n", res->port_id);
15843 printf("function not implemented\n");
15846 printf("programming error: (%s)\n", strerror(-ret));
15850 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15851 .f = cmd_pctype_mapping_reset_parsed,
15853 .help_str = "port config <port_id> pctype mapping reset",
15855 (void *)&cmd_pctype_mapping_reset_port,
15856 (void *)&cmd_pctype_mapping_reset_config,
15857 (void *)&cmd_pctype_mapping_reset_port_id,
15858 (void *)&cmd_pctype_mapping_reset_pctype,
15859 (void *)&cmd_pctype_mapping_reset_mapping,
15860 (void *)&cmd_pctype_mapping_reset_reset,
15865 /* show port pctype mapping */
15867 /* Common result structure for show port pctype mapping */
15868 struct cmd_pctype_mapping_get_result {
15869 cmdline_fixed_string_t show;
15870 cmdline_fixed_string_t port;
15872 cmdline_fixed_string_t pctype;
15873 cmdline_fixed_string_t mapping;
15876 /* Common CLI fields for pctype mapping get */
15877 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15878 TOKEN_STRING_INITIALIZER
15879 (struct cmd_pctype_mapping_get_result,
15881 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15882 TOKEN_STRING_INITIALIZER
15883 (struct cmd_pctype_mapping_get_result,
15885 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15886 TOKEN_NUM_INITIALIZER
15887 (struct cmd_pctype_mapping_get_result,
15889 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15890 TOKEN_STRING_INITIALIZER
15891 (struct cmd_pctype_mapping_get_result,
15893 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15894 TOKEN_STRING_INITIALIZER
15895 (struct cmd_pctype_mapping_get_result,
15896 mapping, "mapping");
15899 cmd_pctype_mapping_get_parsed(
15900 void *parsed_result,
15901 __attribute__((unused)) struct cmdline *cl,
15902 __attribute__((unused)) void *data)
15904 struct cmd_pctype_mapping_get_result *res = parsed_result;
15905 int ret = -ENOTSUP;
15906 #ifdef RTE_LIBRTE_I40E_PMD
15907 struct rte_pmd_i40e_flow_type_mapping
15908 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15909 int i, j, first_pctype;
15912 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15915 #ifdef RTE_LIBRTE_I40E_PMD
15916 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15923 printf("invalid port_id %d\n", res->port_id);
15926 printf("function not implemented\n");
15929 printf("programming error: (%s)\n", strerror(-ret));
15933 #ifdef RTE_LIBRTE_I40E_PMD
15934 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15935 if (mapping[i].pctype != 0ULL) {
15938 printf("pctype: ");
15939 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15940 if (mapping[i].pctype & (1ULL << j)) {
15941 printf(first_pctype ?
15942 "%02d" : ",%02d", j);
15946 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15952 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15953 .f = cmd_pctype_mapping_get_parsed,
15955 .help_str = "show port <port_id> pctype mapping",
15957 (void *)&cmd_pctype_mapping_get_show,
15958 (void *)&cmd_pctype_mapping_get_port,
15959 (void *)&cmd_pctype_mapping_get_port_id,
15960 (void *)&cmd_pctype_mapping_get_pctype,
15961 (void *)&cmd_pctype_mapping_get_mapping,
15966 /* port config pctype mapping update */
15968 /* Common result structure for port config pctype mapping update */
15969 struct cmd_pctype_mapping_update_result {
15970 cmdline_fixed_string_t port;
15971 cmdline_fixed_string_t config;
15973 cmdline_fixed_string_t pctype;
15974 cmdline_fixed_string_t mapping;
15975 cmdline_fixed_string_t update;
15976 cmdline_fixed_string_t pctype_list;
15977 uint16_t flow_type;
15980 /* Common CLI fields for pctype mapping update*/
15981 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15982 TOKEN_STRING_INITIALIZER
15983 (struct cmd_pctype_mapping_update_result,
15985 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15986 TOKEN_STRING_INITIALIZER
15987 (struct cmd_pctype_mapping_update_result,
15989 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15990 TOKEN_NUM_INITIALIZER
15991 (struct cmd_pctype_mapping_update_result,
15993 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15994 TOKEN_STRING_INITIALIZER
15995 (struct cmd_pctype_mapping_update_result,
15997 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15998 TOKEN_STRING_INITIALIZER
15999 (struct cmd_pctype_mapping_update_result,
16000 mapping, "mapping");
16001 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
16002 TOKEN_STRING_INITIALIZER
16003 (struct cmd_pctype_mapping_update_result,
16005 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16006 TOKEN_STRING_INITIALIZER
16007 (struct cmd_pctype_mapping_update_result,
16008 pctype_list, NULL);
16009 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16010 TOKEN_NUM_INITIALIZER
16011 (struct cmd_pctype_mapping_update_result,
16012 flow_type, UINT16);
16015 cmd_pctype_mapping_update_parsed(
16016 void *parsed_result,
16017 __attribute__((unused)) struct cmdline *cl,
16018 __attribute__((unused)) void *data)
16020 struct cmd_pctype_mapping_update_result *res = parsed_result;
16021 int ret = -ENOTSUP;
16022 #ifdef RTE_LIBRTE_I40E_PMD
16023 struct rte_pmd_i40e_flow_type_mapping mapping;
16025 unsigned int nb_item;
16026 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16029 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16032 #ifdef RTE_LIBRTE_I40E_PMD
16033 nb_item = parse_item_list(res->pctype_list, "pctypes",
16034 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16035 mapping.flow_type = res->flow_type;
16036 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16037 mapping.pctype |= (1ULL << pctype_list[i]);
16038 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16048 printf("invalid pctype or flow type\n");
16051 printf("invalid port_id %d\n", res->port_id);
16054 printf("function not implemented\n");
16057 printf("programming error: (%s)\n", strerror(-ret));
16061 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16062 .f = cmd_pctype_mapping_update_parsed,
16064 .help_str = "port config <port_id> pctype mapping update"
16065 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16067 (void *)&cmd_pctype_mapping_update_port,
16068 (void *)&cmd_pctype_mapping_update_config,
16069 (void *)&cmd_pctype_mapping_update_port_id,
16070 (void *)&cmd_pctype_mapping_update_pctype,
16071 (void *)&cmd_pctype_mapping_update_mapping,
16072 (void *)&cmd_pctype_mapping_update_update,
16073 (void *)&cmd_pctype_mapping_update_pc_type,
16074 (void *)&cmd_pctype_mapping_update_flow_type,
16079 /* ptype mapping get */
16081 /* Common result structure for ptype mapping get */
16082 struct cmd_ptype_mapping_get_result {
16083 cmdline_fixed_string_t ptype;
16084 cmdline_fixed_string_t mapping;
16085 cmdline_fixed_string_t get;
16087 uint8_t valid_only;
16090 /* Common CLI fields for ptype mapping get */
16091 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16092 TOKEN_STRING_INITIALIZER
16093 (struct cmd_ptype_mapping_get_result,
16095 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16096 TOKEN_STRING_INITIALIZER
16097 (struct cmd_ptype_mapping_get_result,
16098 mapping, "mapping");
16099 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16100 TOKEN_STRING_INITIALIZER
16101 (struct cmd_ptype_mapping_get_result,
16103 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16104 TOKEN_NUM_INITIALIZER
16105 (struct cmd_ptype_mapping_get_result,
16107 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16108 TOKEN_NUM_INITIALIZER
16109 (struct cmd_ptype_mapping_get_result,
16110 valid_only, UINT8);
16113 cmd_ptype_mapping_get_parsed(
16114 void *parsed_result,
16115 __attribute__((unused)) struct cmdline *cl,
16116 __attribute__((unused)) void *data)
16118 struct cmd_ptype_mapping_get_result *res = parsed_result;
16119 int ret = -ENOTSUP;
16120 #ifdef RTE_LIBRTE_I40E_PMD
16121 int max_ptype_num = 256;
16122 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16127 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16130 #ifdef RTE_LIBRTE_I40E_PMD
16131 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16142 printf("invalid port_id %d\n", res->port_id);
16145 printf("function not implemented\n");
16148 printf("programming error: (%s)\n", strerror(-ret));
16151 #ifdef RTE_LIBRTE_I40E_PMD
16153 for (i = 0; i < count; i++)
16154 printf("%3d\t0x%08x\n",
16155 mapping[i].hw_ptype, mapping[i].sw_ptype);
16160 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16161 .f = cmd_ptype_mapping_get_parsed,
16163 .help_str = "ptype mapping get <port_id> <valid_only>",
16165 (void *)&cmd_ptype_mapping_get_ptype,
16166 (void *)&cmd_ptype_mapping_get_mapping,
16167 (void *)&cmd_ptype_mapping_get_get,
16168 (void *)&cmd_ptype_mapping_get_port_id,
16169 (void *)&cmd_ptype_mapping_get_valid_only,
16174 /* ptype mapping replace */
16176 /* Common result structure for ptype mapping replace */
16177 struct cmd_ptype_mapping_replace_result {
16178 cmdline_fixed_string_t ptype;
16179 cmdline_fixed_string_t mapping;
16180 cmdline_fixed_string_t replace;
16187 /* Common CLI fields for ptype mapping replace */
16188 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16189 TOKEN_STRING_INITIALIZER
16190 (struct cmd_ptype_mapping_replace_result,
16192 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16193 TOKEN_STRING_INITIALIZER
16194 (struct cmd_ptype_mapping_replace_result,
16195 mapping, "mapping");
16196 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16197 TOKEN_STRING_INITIALIZER
16198 (struct cmd_ptype_mapping_replace_result,
16199 replace, "replace");
16200 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16201 TOKEN_NUM_INITIALIZER
16202 (struct cmd_ptype_mapping_replace_result,
16204 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16205 TOKEN_NUM_INITIALIZER
16206 (struct cmd_ptype_mapping_replace_result,
16208 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16209 TOKEN_NUM_INITIALIZER
16210 (struct cmd_ptype_mapping_replace_result,
16212 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16213 TOKEN_NUM_INITIALIZER
16214 (struct cmd_ptype_mapping_replace_result,
16218 cmd_ptype_mapping_replace_parsed(
16219 void *parsed_result,
16220 __attribute__((unused)) struct cmdline *cl,
16221 __attribute__((unused)) void *data)
16223 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16224 int ret = -ENOTSUP;
16226 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16229 #ifdef RTE_LIBRTE_I40E_PMD
16230 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16240 printf("invalid ptype 0x%8x or 0x%8x\n",
16241 res->target, res->pkt_type);
16244 printf("invalid port_id %d\n", res->port_id);
16247 printf("function not implemented\n");
16250 printf("programming error: (%s)\n", strerror(-ret));
16254 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16255 .f = cmd_ptype_mapping_replace_parsed,
16258 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16260 (void *)&cmd_ptype_mapping_replace_ptype,
16261 (void *)&cmd_ptype_mapping_replace_mapping,
16262 (void *)&cmd_ptype_mapping_replace_replace,
16263 (void *)&cmd_ptype_mapping_replace_port_id,
16264 (void *)&cmd_ptype_mapping_replace_target,
16265 (void *)&cmd_ptype_mapping_replace_mask,
16266 (void *)&cmd_ptype_mapping_replace_pkt_type,
16271 /* ptype mapping reset */
16273 /* Common result structure for ptype mapping reset */
16274 struct cmd_ptype_mapping_reset_result {
16275 cmdline_fixed_string_t ptype;
16276 cmdline_fixed_string_t mapping;
16277 cmdline_fixed_string_t reset;
16281 /* Common CLI fields for ptype mapping reset*/
16282 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16283 TOKEN_STRING_INITIALIZER
16284 (struct cmd_ptype_mapping_reset_result,
16286 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16287 TOKEN_STRING_INITIALIZER
16288 (struct cmd_ptype_mapping_reset_result,
16289 mapping, "mapping");
16290 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16291 TOKEN_STRING_INITIALIZER
16292 (struct cmd_ptype_mapping_reset_result,
16294 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16295 TOKEN_NUM_INITIALIZER
16296 (struct cmd_ptype_mapping_reset_result,
16300 cmd_ptype_mapping_reset_parsed(
16301 void *parsed_result,
16302 __attribute__((unused)) struct cmdline *cl,
16303 __attribute__((unused)) void *data)
16305 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16306 int ret = -ENOTSUP;
16308 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16311 #ifdef RTE_LIBRTE_I40E_PMD
16312 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16319 printf("invalid port_id %d\n", res->port_id);
16322 printf("function not implemented\n");
16325 printf("programming error: (%s)\n", strerror(-ret));
16329 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16330 .f = cmd_ptype_mapping_reset_parsed,
16332 .help_str = "ptype mapping reset <port_id>",
16334 (void *)&cmd_ptype_mapping_reset_ptype,
16335 (void *)&cmd_ptype_mapping_reset_mapping,
16336 (void *)&cmd_ptype_mapping_reset_reset,
16337 (void *)&cmd_ptype_mapping_reset_port_id,
16342 /* ptype mapping update */
16344 /* Common result structure for ptype mapping update */
16345 struct cmd_ptype_mapping_update_result {
16346 cmdline_fixed_string_t ptype;
16347 cmdline_fixed_string_t mapping;
16348 cmdline_fixed_string_t reset;
16354 /* Common CLI fields for ptype mapping update*/
16355 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16356 TOKEN_STRING_INITIALIZER
16357 (struct cmd_ptype_mapping_update_result,
16359 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16360 TOKEN_STRING_INITIALIZER
16361 (struct cmd_ptype_mapping_update_result,
16362 mapping, "mapping");
16363 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16364 TOKEN_STRING_INITIALIZER
16365 (struct cmd_ptype_mapping_update_result,
16367 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16368 TOKEN_NUM_INITIALIZER
16369 (struct cmd_ptype_mapping_update_result,
16371 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16372 TOKEN_NUM_INITIALIZER
16373 (struct cmd_ptype_mapping_update_result,
16375 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16376 TOKEN_NUM_INITIALIZER
16377 (struct cmd_ptype_mapping_update_result,
16381 cmd_ptype_mapping_update_parsed(
16382 void *parsed_result,
16383 __attribute__((unused)) struct cmdline *cl,
16384 __attribute__((unused)) void *data)
16386 struct cmd_ptype_mapping_update_result *res = parsed_result;
16387 int ret = -ENOTSUP;
16388 #ifdef RTE_LIBRTE_I40E_PMD
16389 struct rte_pmd_i40e_ptype_mapping mapping;
16391 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16394 #ifdef RTE_LIBRTE_I40E_PMD
16395 mapping.hw_ptype = res->hw_ptype;
16396 mapping.sw_ptype = res->sw_ptype;
16397 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16407 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16410 printf("invalid port_id %d\n", res->port_id);
16413 printf("function not implemented\n");
16416 printf("programming error: (%s)\n", strerror(-ret));
16420 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16421 .f = cmd_ptype_mapping_update_parsed,
16423 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16425 (void *)&cmd_ptype_mapping_update_ptype,
16426 (void *)&cmd_ptype_mapping_update_mapping,
16427 (void *)&cmd_ptype_mapping_update_update,
16428 (void *)&cmd_ptype_mapping_update_port_id,
16429 (void *)&cmd_ptype_mapping_update_hw_ptype,
16430 (void *)&cmd_ptype_mapping_update_sw_ptype,
16435 /* Common result structure for file commands */
16436 struct cmd_cmdfile_result {
16437 cmdline_fixed_string_t load;
16438 cmdline_fixed_string_t filename;
16441 /* Common CLI fields for file commands */
16442 cmdline_parse_token_string_t cmd_load_cmdfile =
16443 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16444 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16445 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16448 cmd_load_from_file_parsed(
16449 void *parsed_result,
16450 __attribute__((unused)) struct cmdline *cl,
16451 __attribute__((unused)) void *data)
16453 struct cmd_cmdfile_result *res = parsed_result;
16455 cmdline_read_from_file(res->filename);
16458 cmdline_parse_inst_t cmd_load_from_file = {
16459 .f = cmd_load_from_file_parsed,
16461 .help_str = "load <filename>",
16463 (void *)&cmd_load_cmdfile,
16464 (void *)&cmd_load_cmdfile_filename,
16469 /* Get Rx offloads capabilities */
16470 struct cmd_rx_offload_get_capa_result {
16471 cmdline_fixed_string_t show;
16472 cmdline_fixed_string_t port;
16474 cmdline_fixed_string_t rx_offload;
16475 cmdline_fixed_string_t capabilities;
16478 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16479 TOKEN_STRING_INITIALIZER
16480 (struct cmd_rx_offload_get_capa_result,
16482 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16483 TOKEN_STRING_INITIALIZER
16484 (struct cmd_rx_offload_get_capa_result,
16486 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16487 TOKEN_NUM_INITIALIZER
16488 (struct cmd_rx_offload_get_capa_result,
16490 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16491 TOKEN_STRING_INITIALIZER
16492 (struct cmd_rx_offload_get_capa_result,
16493 rx_offload, "rx_offload");
16494 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16495 TOKEN_STRING_INITIALIZER
16496 (struct cmd_rx_offload_get_capa_result,
16497 capabilities, "capabilities");
16500 print_rx_offloads(uint64_t offloads)
16502 uint64_t single_offload;
16510 begin = __builtin_ctzll(offloads);
16511 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16513 single_offload = 1 << begin;
16514 for (bit = begin; bit < end; bit++) {
16515 if (offloads & single_offload)
16517 rte_eth_dev_rx_offload_name(single_offload));
16518 single_offload <<= 1;
16523 cmd_rx_offload_get_capa_parsed(
16524 void *parsed_result,
16525 __attribute__((unused)) struct cmdline *cl,
16526 __attribute__((unused)) void *data)
16528 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16529 struct rte_eth_dev_info dev_info;
16530 portid_t port_id = res->port_id;
16531 uint64_t queue_offloads;
16532 uint64_t port_offloads;
16534 rte_eth_dev_info_get(port_id, &dev_info);
16535 queue_offloads = dev_info.rx_queue_offload_capa;
16536 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16538 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16539 printf(" Per Queue :");
16540 print_rx_offloads(queue_offloads);
16543 printf(" Per Port :");
16544 print_rx_offloads(port_offloads);
16548 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16549 .f = cmd_rx_offload_get_capa_parsed,
16551 .help_str = "show port <port_id> rx_offload capabilities",
16553 (void *)&cmd_rx_offload_get_capa_show,
16554 (void *)&cmd_rx_offload_get_capa_port,
16555 (void *)&cmd_rx_offload_get_capa_port_id,
16556 (void *)&cmd_rx_offload_get_capa_rx_offload,
16557 (void *)&cmd_rx_offload_get_capa_capabilities,
16562 /* Get Rx offloads configuration */
16563 struct cmd_rx_offload_get_configuration_result {
16564 cmdline_fixed_string_t show;
16565 cmdline_fixed_string_t port;
16567 cmdline_fixed_string_t rx_offload;
16568 cmdline_fixed_string_t configuration;
16571 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16572 TOKEN_STRING_INITIALIZER
16573 (struct cmd_rx_offload_get_configuration_result,
16575 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16576 TOKEN_STRING_INITIALIZER
16577 (struct cmd_rx_offload_get_configuration_result,
16579 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16580 TOKEN_NUM_INITIALIZER
16581 (struct cmd_rx_offload_get_configuration_result,
16583 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16584 TOKEN_STRING_INITIALIZER
16585 (struct cmd_rx_offload_get_configuration_result,
16586 rx_offload, "rx_offload");
16587 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16588 TOKEN_STRING_INITIALIZER
16589 (struct cmd_rx_offload_get_configuration_result,
16590 configuration, "configuration");
16593 cmd_rx_offload_get_configuration_parsed(
16594 void *parsed_result,
16595 __attribute__((unused)) struct cmdline *cl,
16596 __attribute__((unused)) void *data)
16598 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16599 struct rte_eth_dev_info dev_info;
16600 portid_t port_id = res->port_id;
16601 struct rte_port *port = &ports[port_id];
16602 uint64_t port_offloads;
16603 uint64_t queue_offloads;
16604 uint16_t nb_rx_queues;
16607 printf("Rx Offloading Configuration of port %d :\n", port_id);
16609 port_offloads = port->dev_conf.rxmode.offloads;
16611 print_rx_offloads(port_offloads);
16614 rte_eth_dev_info_get(port_id, &dev_info);
16615 nb_rx_queues = dev_info.nb_rx_queues;
16616 for (q = 0; q < nb_rx_queues; q++) {
16617 queue_offloads = port->rx_conf[q].offloads;
16618 printf(" Queue[%2d] :", q);
16619 print_rx_offloads(queue_offloads);
16625 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16626 .f = cmd_rx_offload_get_configuration_parsed,
16628 .help_str = "show port <port_id> rx_offload configuration",
16630 (void *)&cmd_rx_offload_get_configuration_show,
16631 (void *)&cmd_rx_offload_get_configuration_port,
16632 (void *)&cmd_rx_offload_get_configuration_port_id,
16633 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16634 (void *)&cmd_rx_offload_get_configuration_configuration,
16639 /* Enable/Disable a per port offloading */
16640 struct cmd_config_per_port_rx_offload_result {
16641 cmdline_fixed_string_t port;
16642 cmdline_fixed_string_t config;
16644 cmdline_fixed_string_t rx_offload;
16645 cmdline_fixed_string_t offload;
16646 cmdline_fixed_string_t on_off;
16649 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16650 TOKEN_STRING_INITIALIZER
16651 (struct cmd_config_per_port_rx_offload_result,
16653 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16654 TOKEN_STRING_INITIALIZER
16655 (struct cmd_config_per_port_rx_offload_result,
16657 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16658 TOKEN_NUM_INITIALIZER
16659 (struct cmd_config_per_port_rx_offload_result,
16661 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16662 TOKEN_STRING_INITIALIZER
16663 (struct cmd_config_per_port_rx_offload_result,
16664 rx_offload, "rx_offload");
16665 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16666 TOKEN_STRING_INITIALIZER
16667 (struct cmd_config_per_port_rx_offload_result,
16668 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16669 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16670 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16671 "crc_strip#scatter#timestamp#security");
16672 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16673 TOKEN_STRING_INITIALIZER
16674 (struct cmd_config_per_port_rx_offload_result,
16678 search_rx_offload(const char *name)
16680 uint64_t single_offload;
16681 const char *single_name;
16685 single_offload = 1;
16686 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16687 single_name = rte_eth_dev_rx_offload_name(single_offload);
16688 if (!strcasecmp(single_name, name)) {
16691 } else if (!strcasecmp(single_name, "UNKNOWN"))
16693 else if (single_name == NULL)
16695 single_offload <<= 1;
16699 return single_offload;
16705 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16706 __attribute__((unused)) struct cmdline *cl,
16707 __attribute__((unused)) void *data)
16709 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16710 portid_t port_id = res->port_id;
16711 struct rte_eth_dev_info dev_info;
16712 struct rte_port *port = &ports[port_id];
16713 uint64_t single_offload;
16714 uint16_t nb_rx_queues;
16717 if (port->port_status != RTE_PORT_STOPPED) {
16718 printf("Error: Can't config offload when Port %d "
16719 "is not stopped\n", port_id);
16723 single_offload = search_rx_offload(res->offload);
16724 if (single_offload == 0) {
16725 printf("Unknown offload name: %s\n", res->offload);
16729 rte_eth_dev_info_get(port_id, &dev_info);
16730 nb_rx_queues = dev_info.nb_rx_queues;
16731 if (!strcmp(res->on_off, "on")) {
16732 port->dev_conf.rxmode.offloads |= single_offload;
16733 for (q = 0; q < nb_rx_queues; q++)
16734 port->rx_conf[q].offloads |= single_offload;
16736 port->dev_conf.rxmode.offloads &= ~single_offload;
16737 for (q = 0; q < nb_rx_queues; q++)
16738 port->rx_conf[q].offloads &= ~single_offload;
16741 cmd_reconfig_device_queue(port_id, 1, 1);
16744 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16745 .f = cmd_config_per_port_rx_offload_parsed,
16747 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16748 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16749 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16750 "jumbo_frame|crc_strip|scatter|timestamp|security "
16753 (void *)&cmd_config_per_port_rx_offload_result_port,
16754 (void *)&cmd_config_per_port_rx_offload_result_config,
16755 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16756 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16757 (void *)&cmd_config_per_port_rx_offload_result_offload,
16758 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16763 /* Enable/Disable a per queue offloading */
16764 struct cmd_config_per_queue_rx_offload_result {
16765 cmdline_fixed_string_t port;
16767 cmdline_fixed_string_t rxq;
16769 cmdline_fixed_string_t rx_offload;
16770 cmdline_fixed_string_t offload;
16771 cmdline_fixed_string_t on_off;
16774 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16775 TOKEN_STRING_INITIALIZER
16776 (struct cmd_config_per_queue_rx_offload_result,
16778 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16779 TOKEN_NUM_INITIALIZER
16780 (struct cmd_config_per_queue_rx_offload_result,
16782 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16783 TOKEN_STRING_INITIALIZER
16784 (struct cmd_config_per_queue_rx_offload_result,
16786 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16787 TOKEN_NUM_INITIALIZER
16788 (struct cmd_config_per_queue_rx_offload_result,
16790 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16791 TOKEN_STRING_INITIALIZER
16792 (struct cmd_config_per_queue_rx_offload_result,
16793 rx_offload, "rx_offload");
16794 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16795 TOKEN_STRING_INITIALIZER
16796 (struct cmd_config_per_queue_rx_offload_result,
16797 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16798 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16799 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16800 "crc_strip#scatter#timestamp#security");
16801 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16802 TOKEN_STRING_INITIALIZER
16803 (struct cmd_config_per_queue_rx_offload_result,
16807 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16808 __attribute__((unused)) struct cmdline *cl,
16809 __attribute__((unused)) void *data)
16811 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16812 struct rte_eth_dev_info dev_info;
16813 portid_t port_id = res->port_id;
16814 uint16_t queue_id = res->queue_id;
16815 struct rte_port *port = &ports[port_id];
16816 uint64_t single_offload;
16818 if (port->port_status != RTE_PORT_STOPPED) {
16819 printf("Error: Can't config offload when Port %d "
16820 "is not stopped\n", port_id);
16824 rte_eth_dev_info_get(port_id, &dev_info);
16825 if (queue_id >= dev_info.nb_rx_queues) {
16826 printf("Error: input queue_id should be 0 ... "
16827 "%d\n", dev_info.nb_rx_queues - 1);
16831 single_offload = search_rx_offload(res->offload);
16832 if (single_offload == 0) {
16833 printf("Unknown offload name: %s\n", res->offload);
16837 if (!strcmp(res->on_off, "on"))
16838 port->rx_conf[queue_id].offloads |= single_offload;
16840 port->rx_conf[queue_id].offloads &= ~single_offload;
16842 cmd_reconfig_device_queue(port_id, 1, 1);
16845 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16846 .f = cmd_config_per_queue_rx_offload_parsed,
16848 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16849 "vlan_strip|ipv4_cksum|"
16850 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16851 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16852 "jumbo_frame|crc_strip|scatter|timestamp|security "
16855 (void *)&cmd_config_per_queue_rx_offload_result_port,
16856 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16857 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16858 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16859 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16860 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16861 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16866 /* Get Tx offloads capabilities */
16867 struct cmd_tx_offload_get_capa_result {
16868 cmdline_fixed_string_t show;
16869 cmdline_fixed_string_t port;
16871 cmdline_fixed_string_t tx_offload;
16872 cmdline_fixed_string_t capabilities;
16875 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16876 TOKEN_STRING_INITIALIZER
16877 (struct cmd_tx_offload_get_capa_result,
16879 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16880 TOKEN_STRING_INITIALIZER
16881 (struct cmd_tx_offload_get_capa_result,
16883 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16884 TOKEN_NUM_INITIALIZER
16885 (struct cmd_tx_offload_get_capa_result,
16887 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16888 TOKEN_STRING_INITIALIZER
16889 (struct cmd_tx_offload_get_capa_result,
16890 tx_offload, "tx_offload");
16891 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16892 TOKEN_STRING_INITIALIZER
16893 (struct cmd_tx_offload_get_capa_result,
16894 capabilities, "capabilities");
16897 print_tx_offloads(uint64_t offloads)
16899 uint64_t single_offload;
16907 begin = __builtin_ctzll(offloads);
16908 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16910 single_offload = 1 << begin;
16911 for (bit = begin; bit < end; bit++) {
16912 if (offloads & single_offload)
16914 rte_eth_dev_tx_offload_name(single_offload));
16915 single_offload <<= 1;
16920 cmd_tx_offload_get_capa_parsed(
16921 void *parsed_result,
16922 __attribute__((unused)) struct cmdline *cl,
16923 __attribute__((unused)) void *data)
16925 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16926 struct rte_eth_dev_info dev_info;
16927 portid_t port_id = res->port_id;
16928 uint64_t queue_offloads;
16929 uint64_t port_offloads;
16931 rte_eth_dev_info_get(port_id, &dev_info);
16932 queue_offloads = dev_info.tx_queue_offload_capa;
16933 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16935 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16936 printf(" Per Queue :");
16937 print_tx_offloads(queue_offloads);
16940 printf(" Per Port :");
16941 print_tx_offloads(port_offloads);
16945 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16946 .f = cmd_tx_offload_get_capa_parsed,
16948 .help_str = "show port <port_id> tx_offload capabilities",
16950 (void *)&cmd_tx_offload_get_capa_show,
16951 (void *)&cmd_tx_offload_get_capa_port,
16952 (void *)&cmd_tx_offload_get_capa_port_id,
16953 (void *)&cmd_tx_offload_get_capa_tx_offload,
16954 (void *)&cmd_tx_offload_get_capa_capabilities,
16959 /* Get Tx offloads configuration */
16960 struct cmd_tx_offload_get_configuration_result {
16961 cmdline_fixed_string_t show;
16962 cmdline_fixed_string_t port;
16964 cmdline_fixed_string_t tx_offload;
16965 cmdline_fixed_string_t configuration;
16968 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16969 TOKEN_STRING_INITIALIZER
16970 (struct cmd_tx_offload_get_configuration_result,
16972 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16973 TOKEN_STRING_INITIALIZER
16974 (struct cmd_tx_offload_get_configuration_result,
16976 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16977 TOKEN_NUM_INITIALIZER
16978 (struct cmd_tx_offload_get_configuration_result,
16980 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16981 TOKEN_STRING_INITIALIZER
16982 (struct cmd_tx_offload_get_configuration_result,
16983 tx_offload, "tx_offload");
16984 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16985 TOKEN_STRING_INITIALIZER
16986 (struct cmd_tx_offload_get_configuration_result,
16987 configuration, "configuration");
16990 cmd_tx_offload_get_configuration_parsed(
16991 void *parsed_result,
16992 __attribute__((unused)) struct cmdline *cl,
16993 __attribute__((unused)) void *data)
16995 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16996 struct rte_eth_dev_info dev_info;
16997 portid_t port_id = res->port_id;
16998 struct rte_port *port = &ports[port_id];
16999 uint64_t port_offloads;
17000 uint64_t queue_offloads;
17001 uint16_t nb_tx_queues;
17004 printf("Tx Offloading Configuration of port %d :\n", port_id);
17006 port_offloads = port->dev_conf.txmode.offloads;
17008 print_tx_offloads(port_offloads);
17011 rte_eth_dev_info_get(port_id, &dev_info);
17012 nb_tx_queues = dev_info.nb_tx_queues;
17013 for (q = 0; q < nb_tx_queues; q++) {
17014 queue_offloads = port->tx_conf[q].offloads;
17015 printf(" Queue[%2d] :", q);
17016 print_tx_offloads(queue_offloads);
17022 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17023 .f = cmd_tx_offload_get_configuration_parsed,
17025 .help_str = "show port <port_id> tx_offload configuration",
17027 (void *)&cmd_tx_offload_get_configuration_show,
17028 (void *)&cmd_tx_offload_get_configuration_port,
17029 (void *)&cmd_tx_offload_get_configuration_port_id,
17030 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17031 (void *)&cmd_tx_offload_get_configuration_configuration,
17036 /* Enable/Disable a per port offloading */
17037 struct cmd_config_per_port_tx_offload_result {
17038 cmdline_fixed_string_t port;
17039 cmdline_fixed_string_t config;
17041 cmdline_fixed_string_t tx_offload;
17042 cmdline_fixed_string_t offload;
17043 cmdline_fixed_string_t on_off;
17046 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17047 TOKEN_STRING_INITIALIZER
17048 (struct cmd_config_per_port_tx_offload_result,
17050 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17051 TOKEN_STRING_INITIALIZER
17052 (struct cmd_config_per_port_tx_offload_result,
17054 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17055 TOKEN_NUM_INITIALIZER
17056 (struct cmd_config_per_port_tx_offload_result,
17058 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17059 TOKEN_STRING_INITIALIZER
17060 (struct cmd_config_per_port_tx_offload_result,
17061 tx_offload, "tx_offload");
17062 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17063 TOKEN_STRING_INITIALIZER
17064 (struct cmd_config_per_port_tx_offload_result,
17065 offload, "vlan_insert#ipv4_cksum#udp_cksum#udp_cksum#"
17066 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17067 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17068 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17069 "mt_lockfree#multi_segs#fast_free#security");
17070 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17071 TOKEN_STRING_INITIALIZER
17072 (struct cmd_config_per_port_tx_offload_result,
17076 search_tx_offload(const char *name)
17078 uint64_t single_offload;
17079 const char *single_name;
17083 single_offload = 1;
17084 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17085 single_name = rte_eth_dev_tx_offload_name(single_offload);
17086 if (!strcasecmp(single_name, name)) {
17089 } else if (!strcasecmp(single_name, "UNKNOWN"))
17091 else if (single_name == NULL)
17093 single_offload <<= 1;
17097 return single_offload;
17103 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17104 __attribute__((unused)) struct cmdline *cl,
17105 __attribute__((unused)) void *data)
17107 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17108 portid_t port_id = res->port_id;
17109 struct rte_eth_dev_info dev_info;
17110 struct rte_port *port = &ports[port_id];
17111 uint64_t single_offload;
17112 uint16_t nb_tx_queues;
17115 if (port->port_status != RTE_PORT_STOPPED) {
17116 printf("Error: Can't config offload when Port %d "
17117 "is not stopped\n", port_id);
17121 single_offload = search_tx_offload(res->offload);
17122 if (single_offload == 0) {
17123 printf("Unknown offload name: %s\n", res->offload);
17127 rte_eth_dev_info_get(port_id, &dev_info);
17128 nb_tx_queues = dev_info.nb_tx_queues;
17129 if (!strcmp(res->on_off, "on")) {
17130 port->dev_conf.txmode.offloads |= single_offload;
17131 for (q = 0; q < nb_tx_queues; q++)
17132 port->tx_conf[q].offloads |= single_offload;
17134 port->dev_conf.txmode.offloads &= ~single_offload;
17135 for (q = 0; q < nb_tx_queues; q++)
17136 port->tx_conf[q].offloads &= ~single_offload;
17139 cmd_reconfig_device_queue(port_id, 1, 1);
17142 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17143 .f = cmd_config_per_port_tx_offload_parsed,
17145 .help_str = "port config <port_id> tx_offload "
17146 "vlan_insert|ipv4_cksum|udp_cksum|udp_cksum|"
17147 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17148 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17149 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17150 "mt_lockfree|multi_segs|fast_free|security "
17153 (void *)&cmd_config_per_port_tx_offload_result_port,
17154 (void *)&cmd_config_per_port_tx_offload_result_config,
17155 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17156 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17157 (void *)&cmd_config_per_port_tx_offload_result_offload,
17158 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17163 /* Enable/Disable a per queue offloading */
17164 struct cmd_config_per_queue_tx_offload_result {
17165 cmdline_fixed_string_t port;
17167 cmdline_fixed_string_t txq;
17169 cmdline_fixed_string_t tx_offload;
17170 cmdline_fixed_string_t offload;
17171 cmdline_fixed_string_t on_off;
17174 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17175 TOKEN_STRING_INITIALIZER
17176 (struct cmd_config_per_queue_tx_offload_result,
17178 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17179 TOKEN_NUM_INITIALIZER
17180 (struct cmd_config_per_queue_tx_offload_result,
17182 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17183 TOKEN_STRING_INITIALIZER
17184 (struct cmd_config_per_queue_tx_offload_result,
17186 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17187 TOKEN_NUM_INITIALIZER
17188 (struct cmd_config_per_queue_tx_offload_result,
17190 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17191 TOKEN_STRING_INITIALIZER
17192 (struct cmd_config_per_queue_tx_offload_result,
17193 tx_offload, "tx_offload");
17194 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17195 TOKEN_STRING_INITIALIZER
17196 (struct cmd_config_per_queue_tx_offload_result,
17197 offload, "vlan_insert#ipv4_cksum#udp_cksum#udp_cksum#"
17198 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17199 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17200 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17201 "mt_lockfree#multi_segs#fast_free#security");
17202 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17203 TOKEN_STRING_INITIALIZER
17204 (struct cmd_config_per_queue_tx_offload_result,
17208 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17209 __attribute__((unused)) struct cmdline *cl,
17210 __attribute__((unused)) void *data)
17212 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17213 struct rte_eth_dev_info dev_info;
17214 portid_t port_id = res->port_id;
17215 uint16_t queue_id = res->queue_id;
17216 struct rte_port *port = &ports[port_id];
17217 uint64_t single_offload;
17219 if (port->port_status != RTE_PORT_STOPPED) {
17220 printf("Error: Can't config offload when Port %d "
17221 "is not stopped\n", port_id);
17225 rte_eth_dev_info_get(port_id, &dev_info);
17226 if (queue_id >= dev_info.nb_tx_queues) {
17227 printf("Error: input queue_id should be 0 ... "
17228 "%d\n", dev_info.nb_tx_queues - 1);
17232 single_offload = search_tx_offload(res->offload);
17233 if (single_offload == 0) {
17234 printf("Unknown offload name: %s\n", res->offload);
17238 if (!strcmp(res->on_off, "on"))
17239 port->tx_conf[queue_id].offloads |= single_offload;
17241 port->tx_conf[queue_id].offloads &= ~single_offload;
17243 cmd_reconfig_device_queue(port_id, 1, 1);
17246 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17247 .f = cmd_config_per_queue_tx_offload_parsed,
17249 .help_str = "port <port_id> txq <queue_id> tx_offload "
17250 "vlan_insert|ipv4_cksum|udp_cksum|udp_cksum|"
17251 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17252 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17253 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17254 "mt_lockfree|multi_segs|fast_free|security "
17257 (void *)&cmd_config_per_queue_tx_offload_result_port,
17258 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17259 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17260 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17261 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17262 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17263 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17268 /* ******************************************************************************** */
17270 /* list of instructions */
17271 cmdline_parse_ctx_t main_ctx[] = {
17272 (cmdline_parse_inst_t *)&cmd_help_brief,
17273 (cmdline_parse_inst_t *)&cmd_help_long,
17274 (cmdline_parse_inst_t *)&cmd_quit,
17275 (cmdline_parse_inst_t *)&cmd_load_from_file,
17276 (cmdline_parse_inst_t *)&cmd_showport,
17277 (cmdline_parse_inst_t *)&cmd_showqueue,
17278 (cmdline_parse_inst_t *)&cmd_showportall,
17279 (cmdline_parse_inst_t *)&cmd_showcfg,
17280 (cmdline_parse_inst_t *)&cmd_start,
17281 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17282 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17283 (cmdline_parse_inst_t *)&cmd_set_link_up,
17284 (cmdline_parse_inst_t *)&cmd_set_link_down,
17285 (cmdline_parse_inst_t *)&cmd_reset,
17286 (cmdline_parse_inst_t *)&cmd_set_numbers,
17287 (cmdline_parse_inst_t *)&cmd_set_log,
17288 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17289 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17290 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17291 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17292 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17293 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17294 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17295 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17296 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17297 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17298 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17299 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17300 (cmdline_parse_inst_t *)&cmd_set_link_check,
17301 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17302 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17303 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17304 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17305 #ifdef RTE_LIBRTE_PMD_BOND
17306 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17307 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17308 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17309 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17310 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17311 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17312 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17313 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17314 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17315 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17316 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17318 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17319 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17320 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17321 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17322 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17323 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17324 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17325 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17326 (cmdline_parse_inst_t *)&cmd_csum_set,
17327 (cmdline_parse_inst_t *)&cmd_csum_show,
17328 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17329 (cmdline_parse_inst_t *)&cmd_tso_set,
17330 (cmdline_parse_inst_t *)&cmd_tso_show,
17331 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17332 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17333 (cmdline_parse_inst_t *)&cmd_gro_enable,
17334 (cmdline_parse_inst_t *)&cmd_gro_flush,
17335 (cmdline_parse_inst_t *)&cmd_gro_show,
17336 (cmdline_parse_inst_t *)&cmd_gso_enable,
17337 (cmdline_parse_inst_t *)&cmd_gso_size,
17338 (cmdline_parse_inst_t *)&cmd_gso_show,
17339 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17340 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17341 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17342 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17343 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17344 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17345 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17346 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17347 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17348 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17349 (cmdline_parse_inst_t *)&cmd_config_dcb,
17350 (cmdline_parse_inst_t *)&cmd_read_reg,
17351 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17352 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17353 (cmdline_parse_inst_t *)&cmd_write_reg,
17354 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17355 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17356 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17357 (cmdline_parse_inst_t *)&cmd_stop,
17358 (cmdline_parse_inst_t *)&cmd_mac_addr,
17359 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17360 (cmdline_parse_inst_t *)&cmd_set_qmap,
17361 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17362 (cmdline_parse_inst_t *)&cmd_operate_port,
17363 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17364 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17365 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17366 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17367 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17368 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17369 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17370 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17371 (cmdline_parse_inst_t *)&cmd_config_mtu,
17372 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17373 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17374 (cmdline_parse_inst_t *)&cmd_config_rss,
17375 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17376 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17377 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17378 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17379 (cmdline_parse_inst_t *)&cmd_showport_reta,
17380 (cmdline_parse_inst_t *)&cmd_config_burst,
17381 (cmdline_parse_inst_t *)&cmd_config_thresh,
17382 (cmdline_parse_inst_t *)&cmd_config_threshold,
17383 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17384 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17385 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17386 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
17387 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17388 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
17389 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17390 (cmdline_parse_inst_t *)&cmd_global_config,
17391 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17392 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17393 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17394 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17395 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17396 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17397 (cmdline_parse_inst_t *)&cmd_dump,
17398 (cmdline_parse_inst_t *)&cmd_dump_one,
17399 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
17400 (cmdline_parse_inst_t *)&cmd_syn_filter,
17401 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
17402 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
17403 (cmdline_parse_inst_t *)&cmd_flex_filter,
17404 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
17405 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
17406 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
17407 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
17408 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
17409 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
17410 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17411 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
17412 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17413 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17414 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17415 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
17416 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17417 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
17418 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
17419 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
17420 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
17421 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
17422 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
17423 (cmdline_parse_inst_t *)&cmd_flow,
17424 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17425 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17426 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17427 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17428 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17429 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17430 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17431 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17432 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17433 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17434 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17435 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17436 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17437 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17438 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
17439 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
17440 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
17441 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
17442 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
17443 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
17444 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
17445 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
17446 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
17447 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
17448 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17449 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17450 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17451 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17452 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17453 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17454 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17455 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17456 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17457 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17458 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17459 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17460 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17461 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17462 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17463 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17464 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17465 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17466 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17467 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17468 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17469 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17470 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17471 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17472 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17473 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
17474 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
17476 (cmdline_parse_inst_t *)&cmd_ddp_add,
17477 (cmdline_parse_inst_t *)&cmd_ddp_del,
17478 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17479 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17480 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17481 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17482 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17483 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17484 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17485 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17486 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17487 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17489 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17490 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17491 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17492 (cmdline_parse_inst_t *)&cmd_queue_region,
17493 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17494 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17495 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17496 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17497 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17498 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17499 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17500 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17501 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17502 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17503 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17504 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17505 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17506 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17507 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17508 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17509 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17510 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17511 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17512 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17513 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17514 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17515 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17516 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17517 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17518 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17519 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17520 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17521 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17522 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17523 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17524 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17525 #ifdef RTE_LIBRTE_BPF
17526 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17527 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17532 /* read cmdline commands from file */
17534 cmdline_read_from_file(const char *filename)
17536 struct cmdline *cl;
17538 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17540 printf("Failed to create file based cmdline context: %s\n",
17545 cmdline_interact(cl);
17550 printf("Read CLI commands from %s\n", filename);
17553 /* prompt function, called from main on MASTER lcore */
17557 /* initialize non-constant commands */
17558 cmd_set_fwd_mode_init();
17559 cmd_set_fwd_retry_mode_init();
17561 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17562 if (testpmd_cl == NULL)
17564 cmdline_interact(testpmd_cl);
17565 cmdline_stdin_exit(testpmd_cl);
17571 if (testpmd_cl != NULL)
17572 cmdline_quit(testpmd_cl);
17576 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17578 if (id == (portid_t)RTE_PORT_ALL) {
17581 RTE_ETH_FOREACH_DEV(pid) {
17582 /* check if need_reconfig has been set to 1 */
17583 if (ports[pid].need_reconfig == 0)
17584 ports[pid].need_reconfig = dev;
17585 /* check if need_reconfig_queues has been set to 1 */
17586 if (ports[pid].need_reconfig_queues == 0)
17587 ports[pid].need_reconfig_queues = queue;
17589 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17590 /* check if need_reconfig has been set to 1 */
17591 if (ports[id].need_reconfig == 0)
17592 ports[id].need_reconfig = dev;
17593 /* check if need_reconfig_queues has been set to 1 */
17594 if (ports[id].need_reconfig_queues == 0)
17595 ports[id].need_reconfig_queues = queue;